Experimental curios support

This commit is contained in:
Vincent Lee authored and Vincent Lee committed 2019-06-02 12:44:22 -07:00
1 parent 1c499028f7
commit 6ce466273c
18 files changed
+314 -326

No files matched your search

@@ -23,6 +23,7 @@ import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.client.event.RenderWorldLastEvent;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
@@ -64,24 +65,27 @@ public final class BoundTileRenderer {
renderBlockOutlineAt(coords, color);
}
IItemHandlerModifiable mainInv = (IItemHandlerModifiable) player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.UP).orElseThrow(IllegalStateException::new);
IItemHandlerModifiable baublesInv = BotaniaAPI.internalHandler.getBaublesInventoryWrapped(player);
IItemHandler joined = baublesInv != null ? new CombinedInvWrapper(mainInv, baublesInv) : mainInv;
LazyOptional<IItemHandler> mainInvCap = player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.UP);
mainInvCap.ifPresent(mainInv -> {
IItemHandlerModifiable baublesInv = BotaniaAPI.internalHandler.getBaublesInventoryWrapped(player);
IItemHandler joined = baublesInv != null ? new CombinedInvWrapper((IItemHandlerModifiable) mainInv, baublesInv) : mainInv;
for(int i = 0; i < joined.getSlots(); i++) {
ItemStack stackInSlot = joined.getStackInSlot(i);
for (int i = 0; i < joined.getSlots(); i++) {
ItemStack stackInSlot = joined.getStackInSlot(i);
if(!stackInSlot.isEmpty() && stackInSlot.getItem() instanceof IWireframeCoordinateListProvider) {
IWireframeCoordinateListProvider provider = (IWireframeCoordinateListProvider) stackInSlot.getItem();
List<BlockPos> coordsList = provider.getWireframesToDraw(player, stackInSlot);
for(BlockPos coords : coordsList)
renderBlockOutlineAt(coords, color);
if (!stackInSlot.isEmpty() && stackInSlot.getItem() instanceof IWireframeCoordinateListProvider) {
IWireframeCoordinateListProvider provider = (IWireframeCoordinateListProvider) stackInSlot.getItem();
List<BlockPos> coordsList = provider.getWireframesToDraw(player, stackInSlot);
for (BlockPos coords : coordsList)
renderBlockOutlineAt(coords, color);
BlockPos coords = provider.getSourceWireframe(player, stackInSlot);
if(coords != null && coords.getY() > -1)
renderBlockOutlineAt(coords, color, 5F);
BlockPos coords = provider.getSourceWireframe(player, stackInSlot);
if (coords != null && coords.getY() > -1)
renderBlockOutlineAt(coords, color, 5F);
}
}
}
});
GlStateManager.enableDepthTest();
GlStateManager.enableTexture2D();
@@ -206,7 +206,7 @@ public final class HUDHandler {
boolean anyRequest = false;
boolean creative = false;
IItemHandler mainInv = player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).orElseThrow(NullPointerException::new);
IItemHandler mainInv = new net.minecraftforge.items.ItemStackHandler(1); // player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).orElseThrow(NullPointerException::new);
IItemHandler baublesInv = null; // todo 1.13
int invSize = mainInv.getSlots();
@@ -11,7 +11,6 @@
package vazkii.botania.common;
import net.minecraft.advancements.CriteriaTriggers;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.MultiPartEntityPart;
import net.minecraft.entity.boss.EntityDragon;
@@ -19,6 +18,7 @@ import net.minecraft.entity.boss.EntityWither;
import net.minecraft.entity.item.EntityEnderCrystal;
import net.minecraft.entity.item.EntityItemFrame;
import net.minecraft.entity.item.EntityPainting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.RecipeSerializers;
import net.minecraft.world.storage.loot.conditions.LootConditionManager;
import net.minecraft.world.storage.loot.functions.LootFunctionManager;
@@ -32,7 +32,6 @@ import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent;
import net.minecraftforge.fml.event.lifecycle.FMLModIdMappingEvent;
import net.minecraftforge.fml.event.server.FMLServerAboutToStartEvent;
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
import net.minecraftforge.fml.event.server.FMLServerStoppingEvent;
@@ -40,7 +39,6 @@ import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import vazkii.botania.api.BotaniaAPI;
import vazkii.botania.api.ColorHelper;
import vazkii.botania.api.capability.FloatingFlowerImpl;
import vazkii.botania.api.item.IFloatingFlower;
import vazkii.botania.api.lexicon.ITwoNamedPage;
@@ -71,9 +69,6 @@ import vazkii.botania.common.core.proxy.ServerProxy;
import vazkii.botania.common.crafting.ModBrewRecipes;
import vazkii.botania.common.crafting.ModCraftingRecipes;
import vazkii.botania.common.crafting.ModElvenTradeRecipes;
import vazkii.botania.common.crafting.ModManaAlchemyRecipes;
import vazkii.botania.common.crafting.ModManaConjurationRecipes;
import vazkii.botania.common.crafting.ModManaInfusionRecipes;
import vazkii.botania.common.crafting.ModPetalRecipes;
import vazkii.botania.common.crafting.ModPureDaisyRecipes;
import vazkii.botania.common.crafting.ModRuneRecipes;
@@ -102,15 +97,13 @@ import vazkii.botania.common.entity.EntityManaBurst;
import vazkii.botania.common.entity.EntityPinkWither;
import vazkii.botania.common.entity.EntitySignalFlare;
import vazkii.botania.common.entity.EntitySpark;
import vazkii.botania.common.integration.curios.CurioIntegration;
import vazkii.botania.common.lexicon.LexiconData;
import vazkii.botania.common.lib.LibMisc;
import vazkii.botania.common.network.GuiHandler;
import vazkii.botania.common.network.PacketHandler;
import vazkii.botania.common.world.SkyblockWorldEvents;
import vazkii.botania.common.world.WorldTypeSkyblock;
import java.util.Collections;
@Mod(LibMisc.MOD_ID)
public class Botania {
@@ -173,6 +166,11 @@ public class Botania {
MinecraftForge.EVENT_BUS.register(TileCorporeaIndex.getInputHandler());
MinecraftForge.EVENT_BUS.register(new LootHandler());
if(ModList.get().isLoaded("curios")) {
FMLJavaModLoadingContext.get().getModEventBus().addListener(CurioIntegration::sendImc);
MinecraftForge.EVENT_BUS.addGenericListener(ItemStack.class, CurioIntegration::attachCaps);
}
if(Botania.gardenOfGlassLoaded)
MinecraftForge.EVENT_BUS.register(SkyblockWorldEvents.class);
@@ -0,0 +1,35 @@
package vazkii.botania.common.integration.curios;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import top.theillusivec4.curios.api.capability.ICurio;
import vazkii.botania.common.core.handler.ModSounds;
import vazkii.botania.common.core.helper.PlayerHelper;
import vazkii.botania.common.lib.LibMisc;
public class BaseCurio implements ICurio {
protected final ItemStack stack;
public BaseCurio(ItemStack stack) {
this.stack = stack;
}
@Override
public boolean canRightClickEquip() {
return true;
}
@Override
public void onEquipped(String identifier, EntityLivingBase living) {
if(!living.world.isRemote && living instanceof EntityPlayerMP) {
PlayerHelper.grantCriterion((EntityPlayerMP) living, new ResourceLocation(LibMisc.MOD_ID, "main/bauble_wear"), "code_triggered");
}
}
@Override
public void playEquipSound(EntityLivingBase living) {
living.world.playSound(null, living.posX, living.posY, living.posZ, ModSounds.equipBauble, living.getSoundCategory(), 0.1F, 1.3F);
}
}
@@ -0,0 +1,68 @@
package vazkii.botania.common.integration.curios;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.ICapabilityProvider;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.event.AttachCapabilitiesEvent;
import net.minecraftforge.fml.InterModComms;
import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent;
import top.theillusivec4.curios.api.CuriosAPI;
import top.theillusivec4.curios.api.capability.CuriosCapability;
import top.theillusivec4.curios.api.capability.ICurio;
import top.theillusivec4.curios.api.imc.CurioIMCMessage;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.item.equipment.bauble.ItemIcePendant;
import vazkii.botania.common.item.equipment.bauble.ItemKnockbackBelt;
import vazkii.botania.common.item.equipment.bauble.ItemReachRing;
import vazkii.botania.common.item.equipment.bauble.ItemWaterRing;
import vazkii.botania.common.item.relic.ItemOdinRing;
import vazkii.botania.common.lib.LibMisc;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
// Classloading-safe way to attach curio behaviour to our items
public class CurioIntegration {
private static final ResourceLocation KEY = new ResourceLocation(LibMisc.MOD_ID, "curio");
private static class Provider implements ICapabilityProvider {
private final ICurio curio;
private final LazyOptional<ICurio> curioCap;
public Provider(ICurio curio) {
this.curio = curio;
curioCap = LazyOptional.of(() -> this.curio);
}
@Nonnull
@Override
public <T> LazyOptional<T> getCapability(@Nonnull Capability<T> cap, @Nullable EnumFacing side) {
return CuriosCapability.ITEM.orEmpty(cap, curioCap);
}
}
public static void sendImc(InterModEnqueueEvent evt) {
InterModComms.sendTo("curios", CuriosAPI.IMC.REGISTER_TYPE, () -> new CurioIMCMessage("charm"));
InterModComms.sendTo("curios", CuriosAPI.IMC.REGISTER_TYPE, () -> new CurioIMCMessage("ring"));
InterModComms.sendTo("curios", CuriosAPI.IMC.REGISTER_TYPE, () -> new CurioIMCMessage("belt"));
}
public static void attachCaps(AttachCapabilitiesEvent<ItemStack> evt) {
ItemStack stack = evt.getObject();
if(stack.getItem() == ModItems.icePendant) {
evt.addCapability(KEY, new Provider(new ItemIcePendant.Curio(stack)));
} else if (stack.getItem() == ModItems.waterRing) {
evt.addCapability(KEY, new Provider(new ItemWaterRing.Curio(stack)));
} else if (stack.getItem() == ModItems.knockbackBelt) {
evt.addCapability(KEY, new Provider(new ItemKnockbackBelt.Curio(stack)));
} else if (stack.getItem() == ModItems.odinRing) {
evt.addCapability(KEY, new Provider(new ItemOdinRing.Curio(stack, ((ItemOdinRing) ModItems.odinRing).getDummy())));
} else if (stack.getItem() == ModItems.reachRing) {
evt.addCapability(KEY, new Provider(new ItemReachRing.Curio(stack)));
}
}
}
@@ -0,0 +1,31 @@
package vazkii.botania.common.integration.curios;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import vazkii.botania.common.item.relic.ItemRelic;
public class RelicCurio extends BaseCurio{
private final ItemRelic relicDelegate;
public RelicCurio(ItemStack stack, ItemRelic relicDelegate) {
super(stack);
this.relicDelegate = relicDelegate;
}
@Override
public void onCurioTick(String identifier, EntityLivingBase living) {
if(living instanceof EntityPlayer) {
EntityPlayer ePlayer = (EntityPlayer) living;
relicDelegate.updateRelic(stack, ePlayer);
if(relicDelegate.isRightPlayer(ePlayer, stack))
onValidPlayerWornTick(ePlayer);
}
}
@Override
public boolean canEquip(String identifier, EntityLivingBase living) {
return living instanceof EntityPlayer && relicDelegate.isRightPlayer((EntityPlayer) living, stack);
}
public void onValidPlayerWornTick(EntityPlayer player) {}
}
@@ -59,79 +59,6 @@ public abstract class ItemBauble extends ItemMod implements ICosmeticAttachable,
super(props);
}
// Apparently baubles doesn't unequip on death, which causes attribute modifiers to get weird/desync on respawn
// See Baubles#236
// Do it for our baubles if they're going to drop
// TODO there is still some weirdness going on when dying/returning in the End, figure that out
@SubscribeEvent
public static void onDeath(LivingDeathEvent evt) {
/* todo 1.13
if(!evt.getEntityLiving().world.isRemote
&& evt.getEntityLiving() instanceof EntityPlayer
&& !evt.getEntityLiving().world.getGameRules().getBoolean("keepInventory")
&& !((EntityPlayer) evt.getEntityLiving()).isSpectator()) {
IItemHandler inv = BaublesApi.getBaublesHandler((EntityPlayer) evt.getEntityLiving());
for(int i = 0; i < inv.getSlots(); i++) {
ItemStack stack = inv.getStackInSlot(i);
if (!stack.isEmpty() && stack.getItem().getRegistryName().getNamespace().equals(LibMisc.MOD_ID)) {
((ItemBauble) stack.getItem()).onUnequipped(stack, evt.getEntityLiving());
}
}
}
*/
}
@Nonnull
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, @Nonnull EnumHand hand) {
ItemStack stack = player.getHeldItem(hand);
if(!EntityDoppleganger.isTruePlayer(player))
return ActionResult.newResult(EnumActionResult.FAIL, stack);
/* todo 1.13
ItemStack toEquip = stack.copy();
toEquip.setCount(1);
if(canEquip(toEquip, player)) {
if(world.isRemote)
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
IBaublesItemHandler baubles = BaublesApi.getBaublesHandler(player);
for(int i = 0; i < baubles.getSlots(); i++) {
if(baubles.isItemValidForSlot(i, toEquip, player)) {
ItemStack stackInSlot = baubles.getStackInSlot(i);
if(stackInSlot.isEmpty() || ((IBauble) stackInSlot.getItem()).canUnequip(stackInSlot, player)) {
// If toEquip and stackInSlot are stacks with equal value but not identity, ItemStackHandler.setStackInSlot actually does nothing >.>
// Prevent it from trying to be overly smart by going through empty first
baubles.setStackInSlot(i, ItemStack.EMPTY);
baubles.setStackInSlot(i, toEquip);
((IBauble) toEquip.getItem()).onEquipped(toEquip, player);
stack.shrink(1);
PlayerHelper.grantCriterion((EntityPlayerMP) player, new ResourceLocation(LibMisc.MOD_ID, "main/bauble_wear"), "code_triggered");
if(!stackInSlot.isEmpty()) {
((IBauble) stackInSlot.getItem()).onUnequipped(stackInSlot, player);
if(stack.isEmpty()) {
return ActionResult.newResult(EnumActionResult.SUCCESS, stackInSlot);
} else {
ItemHandlerHelper.giveItemToPlayer(player, stackInSlot);
}
}
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
}
}
}
}
*/
return ActionResult.newResult(EnumActionResult.PASS, stack);
}
@Override
@OnlyIn(Dist.CLIENT)
public void addInformation(ItemStack par1ItemStack, World world, List<ITextComponent> stacks, ITooltipFlag flags) {
@@ -142,7 +69,7 @@ public abstract class ItemBauble extends ItemMod implements ICosmeticAttachable,
@OnlyIn(Dist.CLIENT)
public void addHiddenTooltip(ItemStack par1ItemStack, World world, List<ITextComponent> stacks, ITooltipFlag flags) {
String key = vazkii.botania.client.core.helper.RenderHelper.getKeyDisplayString("Baubles Inventory");
String key = vazkii.botania.client.core.helper.RenderHelper.getKeyDisplayString("key.curios.open.desc");
if(key != null)
stacks.add(new TextComponentTranslation("botania.baubletooltip", key));
@@ -155,35 +82,18 @@ public abstract class ItemBauble extends ItemMod implements ICosmeticAttachable,
stacks.add(new TextComponentTranslation("botaniamisc.hasPhantomInk"));
}
public boolean canEquip(ItemStack stack, EntityLivingBase player) {
return true;
}
public boolean canUnequip(ItemStack stack, EntityLivingBase player) {
return true;
}
public void onWornTick(ItemStack stack, EntityLivingBase player) {
if(getLastPlayerHashcode(stack) != player.hashCode()) {
onEquippedOrLoadedIntoWorld(stack, player);
setLastPlayerHashcode(stack, player.hashCode());
}
}
public void onEquipped(ItemStack stack, EntityLivingBase player) {
if(player != null) {
if(!player.world.isRemote) {
player.world.playSound(null, player.posX, player.posY, player.posZ, ModSounds.equipBauble, SoundCategory.PLAYERS, 0.1F, 1.3F);
PlayerHelper.grantCriterion((EntityPlayerMP) player, new ResourceLocation(LibMisc.MOD_ID, "main/bauble_wear"), "code_triggered");
}
onEquippedOrLoadedIntoWorld(stack, player);
setLastPlayerHashcode(stack, player.hashCode());
}
}
public void onEquippedOrLoadedIntoWorld(ItemStack stack, EntityLivingBase player) {}
public void onUnequipped(ItemStack stack, EntityLivingBase player) { }
@Override
@@ -1,44 +0,0 @@
/**
* This class was created by <Vazkii>. It's distributed as
* part of the Botania Mod. Get the Source Code in github:
* https://github.com/Vazkii/Botania
*
* Botania is Open Source and distributed under the
* Botania License: http://botaniamod.net/license.php
*
* File Created @ [Apr 26, 2014, 10:28:39 PM (GMT)]
*/
package vazkii.botania.common.item.equipment.bauble;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.item.ItemStack;
public abstract class ItemBaubleModifier extends ItemBauble {
public ItemBaubleModifier(Properties props) {
super(props);
}
@Override
public void onEquippedOrLoadedIntoWorld(ItemStack stack, EntityLivingBase player) {
if(!player.world.isRemote) {
Multimap<String, AttributeModifier> attributes = HashMultimap.create();
fillModifiers(attributes, stack);
player.getAttributeMap().applyAttributeModifiers(attributes);
}
}
@Override
public void onUnequipped(ItemStack stack, EntityLivingBase player) {
if(!player.world.isRemote) {
Multimap<String, AttributeModifier> attributes = HashMultimap.create();
fillModifiers(attributes, stack);
player.getAttributeMap().removeAttributeModifiers(attributes);
}
}
abstract void fillModifiers(Multimap<String, AttributeModifier> attributes, ItemStack stack);
}
@@ -17,47 +17,43 @@ import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.enchantment.EnchantmentFrostWalker;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import vazkii.botania.api.item.IBaubleRender;
import vazkii.botania.client.core.handler.MiscellaneousIcons;
import vazkii.botania.client.core.helper.IconHelper;
import vazkii.botania.common.lib.LibItemNames;
import vazkii.botania.common.integration.curios.BaseCurio;
public class ItemIcePendant extends ItemBauble implements IBaubleRender {
public class ItemIcePendant extends ItemBauble {
public ItemIcePendant(Properties props) {
super(props);
}
/* todo 1.13
@Override
public BaubleType getBaubleType(ItemStack itemstack) {
return BaubleType.AMULET;
}
*/
@Override
public void onWornTick(ItemStack stack, EntityLivingBase entity) {
super.onWornTick(stack, entity);
if(!entity.world.isRemote) {
boolean lastOnGround = entity.onGround;
entity.onGround = true;
EnchantmentFrostWalker.freezeNearby(entity, entity.world, new BlockPos(entity), 8);
entity.onGround = lastOnGround;
public static class Curio extends BaseCurio {
public Curio(ItemStack stack) {
super(stack);
}
}
@Override
@OnlyIn(Dist.CLIENT)
public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) {
if(type == RenderType.BODY) {
@Override
public void onCurioTick(String type, EntityLivingBase entity) {
if(!entity.world.isRemote) {
boolean lastOnGround = entity.onGround;
entity.onGround = true;
EnchantmentFrostWalker.freezeNearby(entity, entity.world, new BlockPos(entity), 8);
entity.onGround = lastOnGround;
}
}
@Override
public boolean hasRender(String identifier, EntityLivingBase entityLivingBase) {
return true;
}
@Override
public void doRender(String identifier, EntityLivingBase player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
Helper.rotateIfSneaking(player);
boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty();
GlStateManager.rotatef(180F, 1F, 0F, 0F);
GlStateManager.translatef(-0.36F, -0.3F, armor ? 0.2F : 0.15F);
@@ -10,10 +10,12 @@
*/
package vazkii.botania.common.item.equipment.bauble;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.model.ModelBiped;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.player.EntityPlayer;
@@ -23,9 +25,10 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import vazkii.botania.api.item.IBaubleRender;
import vazkii.botania.client.lib.LibResources;
import vazkii.botania.common.integration.curios.BaseCurio;
import vazkii.botania.common.lib.LibItemNames;
public class ItemKnockbackBelt extends ItemBaubleModifier implements IBaubleRender {
public class ItemKnockbackBelt extends ItemBauble {
private static final ResourceLocation texture = new ResourceLocation(LibResources.MODEL_KNOCKBACK_BELT);
private static ModelBiped model;
@@ -34,27 +37,26 @@ public class ItemKnockbackBelt extends ItemBaubleModifier implements IBaubleRend
super(props);
}
/* todo 1.13
@Override
public BaubleType getBaubleType(ItemStack itemstack) {
return BaubleType.BELT;
}
*/
public static class Curio extends BaseCurio {
public Curio(ItemStack stack) {
super(stack);
}
@Override
void fillModifiers(Multimap<String, AttributeModifier> attributes, ItemStack stack) {
if(stack.isEmpty()) // workaround for Azanor/Baubles#156
return;
attributes.put(SharedMonsterAttributes.KNOCKBACK_RESISTANCE.getName(), new AttributeModifier(getBaubleUUID(stack), "Knockback Belt", 1, 0).setSaved(false));
}
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(String identifier) {
Multimap<String, AttributeModifier> attributes = HashMultimap.create();
attributes.put(SharedMonsterAttributes.KNOCKBACK_RESISTANCE.getName(), new AttributeModifier(getBaubleUUID(stack), "Knockback Belt", 1, 0).setSaved(false));
return attributes;
}
@Override
@OnlyIn(Dist.CLIENT)
public void onPlayerBaubleRender(ItemStack stack, EntityPlayer player, RenderType type, float partialTicks) {
if(type == RenderType.BODY) {
@Override
public boolean hasRender(String identifier, EntityLivingBase living) {
return true;
}
@Override
public void doRender(String identifier, EntityLivingBase living, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
Minecraft.getInstance().textureManager.bindTexture(texture);
Helper.rotateIfSneaking(player);
GlStateManager.translatef(0F, 0.2F, 0F);
@@ -67,5 +69,4 @@ public class ItemKnockbackBelt extends ItemBaubleModifier implements IBaubleRend
model.bipedBody.render(1F);
}
}
}
@@ -10,28 +10,31 @@
*/
package vazkii.botania.common.item.equipment.bauble;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import vazkii.botania.common.integration.curios.BaseCurio;
import vazkii.botania.common.lib.LibItemNames;
public class ItemReachRing extends ItemBaubleModifier {
public class ItemReachRing extends ItemBauble {
public ItemReachRing(Properties props) {
super(props);
}
@Override
void fillModifiers(Multimap<String, AttributeModifier> attributes, ItemStack stack) {
attributes.put(EntityPlayer.REACH_DISTANCE.getName(), new AttributeModifier(getBaubleUUID(stack), "Reach Ring", 3.5, 0).setSaved(false));
}
public static class Curio extends BaseCurio {
public Curio(ItemStack stack) {
super(stack);
}
/* todo 1.13
@Override
public BaubleType getBaubleType(ItemStack arg0) {
return BaubleType.RING;
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(String identifier) {
Multimap<String, AttributeModifier> attributes = HashMultimap.create();
attributes.put(EntityPlayer.REACH_DISTANCE.getName(), new AttributeModifier(getBaubleUUID(stack), "Reach Ring", 3.5, 0).setSaved(false));
return attributes;
}
}
*/
}
@@ -10,15 +10,16 @@
*/
package vazkii.botania.common.item.equipment.bauble;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import top.theillusivec4.curios.api.CuriosAPI;
import vazkii.botania.api.mana.IManaUsingItem;
import vazkii.botania.api.mana.ManaItemHandler;
import vazkii.botania.common.lib.LibItemNames;
import vazkii.botania.common.integration.curios.BaseCurio;
import vazkii.botania.common.item.ModItems;
public class ItemWaterRing extends ItemBauble implements IManaUsingItem {
@@ -29,59 +30,56 @@ public class ItemWaterRing extends ItemBauble implements IManaUsingItem {
super(props);
}
@Override
public void onWornTick(ItemStack stack, EntityLivingBase player) {
super.onWornTick(stack, player);
public static class Curio extends BaseCurio {
public Curio(ItemStack stack) {
super(stack);
}
if(player.isInWaterOrBubbleColumn()) {
if(player instanceof EntityPlayer) {
ItemStack firstRing = ItemStack.EMPTY; // todo 1.13 BaublesApi.getBaublesHandler((EntityPlayer) player).getStackInSlot(1);
if(!firstRing.isEmpty() && firstRing.getItem() instanceof ItemWaterRing && firstRing != stack) {
return;
@Override
public void onCurioTick(String identifier, EntityLivingBase living) {
if(living.isInWaterOrBubbleColumn()) {
if(living instanceof EntityPlayer) {
// only activate for one ring at a time
CuriosAPI.FinderData result = CuriosAPI.getCurioEquipped(ModItems.waterRing, living);
if(result == null || result.getStack() != stack)
return;
}
}
double motionX = player.motionX * SPEED_MULT;
double motionY = player.motionY * SPEED_MULT;
double motionZ = player.motionZ * SPEED_MULT;
double motionX = living.motionX * SPEED_MULT;
double motionY = living.motionY * SPEED_MULT;
double motionZ = living.motionZ * SPEED_MULT;
boolean flying = player instanceof EntityPlayer && ((EntityPlayer) player).abilities.isFlying;
boolean flying = living instanceof EntityPlayer && ((EntityPlayer) living).abilities.isFlying;
if(Math.abs(motionX) < MAX_SPEED && !flying)
player.motionX = motionX;
if(Math.abs(motionY) < MAX_SPEED && !flying)
player.motionY = motionY;
if(Math.abs(motionZ) < MAX_SPEED && !flying)
player.motionZ = motionZ;
if(Math.abs(motionX) < MAX_SPEED && !flying)
living.motionX = motionX;
if(Math.abs(motionY) < MAX_SPEED && !flying)
living.motionY = motionY;
if(Math.abs(motionZ) < MAX_SPEED && !flying)
living.motionZ = motionZ;
PotionEffect effect = player.getActivePotionEffect(MobEffects.NIGHT_VISION);
if(effect == null) {
PotionEffect neweffect = new PotionEffect(MobEffects.NIGHT_VISION, Integer.MAX_VALUE, -42, true, true);
player.addPotionEffect(neweffect);
}
PotionEffect effect = living.getActivePotionEffect(MobEffects.NIGHT_VISION);
if(effect == null) {
PotionEffect neweffect = new PotionEffect(MobEffects.NIGHT_VISION, Integer.MAX_VALUE, -42, true, true);
living.addPotionEffect(neweffect);
}
if(player.getAir() <= 1 && player instanceof EntityPlayer) {
int mana = ManaItemHandler.requestMana(stack, (EntityPlayer) player, 300, true);
if (mana > 0)
player.setAir(mana);
}
} else onUnequipped(stack, player);
if(living.getAir() <= 1 && living instanceof EntityPlayer) {
int mana = ManaItemHandler.requestMana(stack, (EntityPlayer) living, 300, true);
if(mana > 0)
living.setAir(mana);
}
} else onUnequipped(identifier, living);
}
@Override
public void onUnequipped(String identifier, EntityLivingBase living) {
PotionEffect effect = living.getActivePotionEffect(MobEffects.NIGHT_VISION);
if(effect != null && effect.getAmplifier() == -42)
living.removePotionEffect(MobEffects.NIGHT_VISION);
}
}
@Override
public void onUnequipped(ItemStack stack, EntityLivingBase player) {
PotionEffect effect = player.getActivePotionEffect(MobEffects.NIGHT_VISION);
if(effect != null && effect.getAmplifier() == -42)
player.removePotionEffect(MobEffects.NIGHT_VISION);
}
/* todo 1.13
@Override
public BaubleType getBaubleType(ItemStack arg0) {
return BaubleType.RING;
}
*/
@Override
public boolean usesMana(ItemStack stack) {
return true;
@@ -24,7 +24,9 @@ import net.minecraftforge.event.entity.living.LivingAttackEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.items.IItemHandler;
import top.theillusivec4.curios.api.CuriosAPI;
import vazkii.botania.common.core.handler.ConfigHandler;
import vazkii.botania.common.integration.curios.RelicCurio;
import vazkii.botania.common.item.ModItems;
import vazkii.botania.common.lib.LibItemNames;
import vazkii.botania.common.lib.LibMisc;
@@ -52,10 +54,23 @@ public class ItemOdinRing extends ItemRelicBauble {
fireNegations.add(DamageSource.ON_FIRE.damageType);
}
@Override
public void onValidPlayerWornTick(ItemStack stack, EntityPlayer player) {
if(player.isBurning() && ConfigHandler.COMMON.ringOfOdinFireResist.get())
player.extinguish();
public static class Curio extends RelicCurio {
public Curio(ItemStack stack, ItemRelic relicDelegate) {
super(stack, relicDelegate);
}
@Override
public void onValidPlayerWornTick(EntityPlayer player) {
if(player.isBurning() && ConfigHandler.COMMON.ringOfOdinFireResist.get())
player.extinguish();
}
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers(String identifier) {
Multimap<String, AttributeModifier> attributes = HashMultimap.create();
attributes.put(SharedMonsterAttributes.MAX_HEALTH.getName(), new AttributeModifier(getBaubleUUID(stack), "Odin Ring", 20, 0).setSaved(false));
return attributes;
}
}
@SubscribeEvent
@@ -64,52 +79,12 @@ public class ItemOdinRing extends ItemRelicBauble {
EntityPlayer player = (EntityPlayer) event.getEntityLiving();
boolean negate = damageNegations.contains(event.getSource().damageType)
|| (ConfigHandler.COMMON.ringOfOdinFireResist.get() && fireNegations.contains(event.getSource().damageType));
if(!getOdinRing(player).isEmpty() && negate)
CuriosAPI.FinderData result = CuriosAPI.getCurioEquipped(ModItems.odinRing, player);
if(result != null && negate)
event.setCanceled(true);
}
}
/* todo 1.13
@Override
public BaubleType getBaubleType(ItemStack arg0) {
return BaubleType.RING;
}
*/
public static ItemStack getOdinRing(EntityPlayer player) {
IItemHandler baubles = null; // BaublesApi.getBaublesHandler(player);
int slot = -1; // todo 1.13 BaublesApi.isBaubleEquipped(player, ModItems.odinRing);
if (slot < 0) {
return ItemStack.EMPTY;
}
return baubles.getStackInSlot(slot);
}
@Override
public void onEquippedOrLoadedIntoWorld(ItemStack stack, EntityLivingBase player) {
if(!player.world.isRemote) {
Multimap<String, AttributeModifier> attributes = HashMultimap.create();
fillModifiers(attributes, stack);
player.getAttributeMap().applyAttributeModifiers(attributes);
}
}
@Override
public void onUnequipped(ItemStack stack, EntityLivingBase player) {
if(!player.world.isRemote) {
Multimap<String, AttributeModifier> attributes = HashMultimap.create();
fillModifiers(attributes, stack);
player.getAttributeMap().removeAttributeModifiers(attributes);
}
}
private void fillModifiers(Multimap<String, AttributeModifier> attributes, ItemStack stack) {
if(stack.isEmpty()) // workaround for Azanor/Baubles#156
return;
attributes.put(SharedMonsterAttributes.MAX_HEALTH.getName(), new AttributeModifier(getBaubleUUID(stack), "Odin Ring", 20, 0).setSaved(false));
}
@Override
public ResourceLocation getAdvancement() {
return new ResourceLocation(LibMisc.MOD_ID, "challenge/odin_ring");
@@ -36,23 +36,16 @@ public abstract class ItemRelicBauble extends ItemBauble implements IRelic {
super(props);
}
public ItemRelic getDummy() {
return dummy;
}
@Override
public void inventoryTick(ItemStack stack, World world, Entity entity, int slot, boolean held) {
if(entity instanceof EntityPlayer)
dummy.updateRelic(stack, (EntityPlayer) entity);
}
@Override
public void onWornTick(ItemStack stack, EntityLivingBase player) {
super.onWornTick(stack, player);
if(player instanceof EntityPlayer) {
EntityPlayer ePlayer = (EntityPlayer) player;
dummy.updateRelic(stack, ePlayer);
if(dummy.isRightPlayer(ePlayer, stack))
onValidPlayerWornTick(stack, ePlayer);
}
}
@OnlyIn(Dist.CLIENT)
@Override
public void addHiddenTooltip(ItemStack par1ItemStack, World world, List<ITextComponent> stacks, ITooltipFlag flags) {
@@ -60,13 +53,6 @@ public abstract class ItemRelicBauble extends ItemBauble implements IRelic {
dummy.addBindInfo(stacks, par1ItemStack);
}
public void onValidPlayerWornTick(ItemStack stack, EntityPlayer player) {}
@Override
public boolean canEquip(ItemStack stack, EntityLivingBase player) {
return player instanceof EntityPlayer && dummy.isRightPlayer((EntityPlayer) player, stack);
}
@Override
public void bindToUUID(UUID uuid, ItemStack stack) {
dummy.bindToUUID(uuid, stack);