From 05c88fd62a7543e0098aa698c1d2725f5d4776fb Mon Sep 17 00:00:00 2001 From: Hubry Date: Tue, 25 Jun 2019 03:45:59 +0200 Subject: [PATCH] Make handling of curios centralized and add handling for no curios (#2913) Minor fixes to cosmetic bauble rendering (GL stack overflows), include the missed belt in belt curios --- .../client/core/handler/HUDHandler.java | 14 +- .../java/vazkii/botania/common/Botania.java | 8 +- .../common/core/handler/EquipmentHandler.java | 166 ++++++++ .../core/handler/InternalMethodHandler.java | 5 +- .../common/core/handler/PixieHandler.java | 19 +- .../botania/common/entity/EntitySpark.java | 14 +- .../common/integration/curios/BaseCurio.java | 35 -- .../integration/curios/CurioIntegration.java | 276 ++++++------- .../common/integration/curios/RelicCurio.java | 31 -- .../integration/curios/RenderableCurio.java | 23 -- .../item/equipment/bauble/ItemAuraRing.java | 17 +- .../item/equipment/bauble/ItemBauble.java | 60 ++- .../equipment/bauble/ItemBaubleCosmetic.java | 367 +++++++++-------- .../equipment/bauble/ItemBloodPendant.java | 87 ++-- .../equipment/bauble/ItemCloudPendant.java | 79 ++-- .../item/equipment/bauble/ItemDivaCharm.java | 39 +- .../item/equipment/bauble/ItemDodgeRing.java | 28 +- .../equipment/bauble/ItemFlightTiara.java | 374 +++++++++--------- .../equipment/bauble/ItemGoddessCharm.java | 39 +- .../equipment/bauble/ItemGreaterAuraRing.java | 15 +- .../bauble/ItemGreaterMagnetRing.java | 2 - .../equipment/bauble/ItemGreaterManaRing.java | 1 - .../item/equipment/bauble/ItemHolyCloak.java | 70 ++-- .../item/equipment/bauble/ItemIcePendant.java | 58 ++- .../bauble/ItemInvisibilityCloak.java | 42 +- .../item/equipment/bauble/ItemItemFinder.java | 68 ++-- .../equipment/bauble/ItemKnockbackBelt.java | 39 +- .../equipment/bauble/ItemLavaPendant.java | 47 +-- .../item/equipment/bauble/ItemMagnetRing.java | 70 ++-- .../item/equipment/bauble/ItemMiningRing.java | 48 +-- .../item/equipment/bauble/ItemMonocle.java | 37 +- .../item/equipment/bauble/ItemReachRing.java | 21 +- .../bauble/ItemSuperLavaPendant.java | 52 ++- .../item/equipment/bauble/ItemSwapRing.java | 96 +++-- .../item/equipment/bauble/ItemThirdEye.java | 115 +++--- .../item/equipment/bauble/ItemTinyPlanet.java | 37 +- .../item/equipment/bauble/ItemTravelBelt.java | 44 +-- .../item/equipment/bauble/ItemWaterRing.java | 85 ++-- .../common/item/relic/ItemLokiRing.java | 54 +-- .../common/item/relic/ItemOdinRing.java | 41 +- .../common/item/relic/ItemRelicBauble.java | 16 + .../common/item/relic/ItemThorRing.java | 10 +- .../botania/common/network/PacketDodge.java | 12 +- .../botania/common/network/PacketJump.java | 19 +- .../data/curios/tags/items/belt.json | 15 +- 45 files changed, 1334 insertions(+), 1461 deletions(-) create mode 100644 src/main/java/vazkii/botania/common/core/handler/EquipmentHandler.java delete mode 100644 src/main/java/vazkii/botania/common/integration/curios/BaseCurio.java delete mode 100644 src/main/java/vazkii/botania/common/integration/curios/RelicCurio.java delete mode 100644 src/main/java/vazkii/botania/common/integration/curios/RenderableCurio.java diff --git a/src/main/java/vazkii/botania/client/core/handler/HUDHandler.java b/src/main/java/vazkii/botania/client/core/handler/HUDHandler.java index 83f66da11..6e94f7943 100644 --- a/src/main/java/vazkii/botania/client/core/handler/HUDHandler.java +++ b/src/main/java/vazkii/botania/client/core/handler/HUDHandler.java @@ -28,15 +28,15 @@ import net.minecraft.util.ResourceLocation; import net.minecraft.util.Util; import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.text.TextFormatting; +import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; import net.minecraftforge.eventbus.api.EventPriority; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.items.IItemHandler; import org.lwjgl.opengl.GL11; -import top.theillusivec4.curios.api.CuriosAPI; +import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.lexicon.ILexicon; import vazkii.botania.api.lexicon.ILexiconable; import vazkii.botania.api.lexicon.LexiconEntry; @@ -59,8 +59,8 @@ import vazkii.botania.common.block.tile.corporea.TileCorporeaIndex; import vazkii.botania.common.block.tile.corporea.TileCorporeaIndex.InputHandler; import vazkii.botania.common.block.tile.mana.TilePool; import vazkii.botania.common.core.handler.ConfigHandler; +import vazkii.botania.common.core.handler.EquipmentHandler; import vazkii.botania.common.core.helper.PlayerHelper; -import vazkii.botania.common.integration.curios.CurioIntegration; import vazkii.botania.common.item.ItemCraftingHalo; import vazkii.botania.common.item.ItemSextant; import vazkii.botania.common.item.ItemTwigWand; @@ -87,17 +87,17 @@ public final class HUDHandler { Minecraft mc = Minecraft.getInstance(); Profiler profiler = mc.profiler; - if(event.getType() == ElementType.HEALTH && Botania.curiosLoaded) { + if(event.getType() == ElementType.HEALTH) { profiler.startSection("botania-hud"); - ItemStack tiara = CurioIntegration.findOrEmpty(ModItems.flightTiara, mc.player); + ItemStack tiara = EquipmentHandler.findOrEmpty(ModItems.flightTiara, mc.player); if(!tiara.isEmpty()) { profiler.startSection("flugelTiara"); ItemFlightTiara.renderHUD(mc.player, tiara); profiler.endSection(); } - ItemStack dodgeRing = CurioIntegration.findOrEmpty(ModItems.dodgeRing, mc.player); + ItemStack dodgeRing = EquipmentHandler.findOrEmpty(ModItems.dodgeRing, mc.player); if(!dodgeRing.isEmpty()) { profiler.startSection("dodgeRing"); ItemDodgeRing.renderHUD(mc.player, dodgeRing, event.getPartialTicks()); @@ -200,7 +200,7 @@ public final class HUDHandler { boolean creative = false; IItemHandler mainInv = new net.minecraftforge.items.ItemStackHandler(1); // player.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY).orElseThrow(NullPointerException::new); - IItemHandler accInv = Botania.curiosLoaded ? CurioIntegration.getAllCurios(player).orElse(null) : null; + IItemHandler accInv = BotaniaAPI.internalHandler.getAccessoriesInventory(player); int invSize = mainInv.getSlots(); int size = invSize; diff --git a/src/main/java/vazkii/botania/common/Botania.java b/src/main/java/vazkii/botania/common/Botania.java index b105717cd..3cea9ac70 100644 --- a/src/main/java/vazkii/botania/common/Botania.java +++ b/src/main/java/vazkii/botania/common/Botania.java @@ -56,6 +56,7 @@ import vazkii.botania.common.core.command.CommandOpen; import vazkii.botania.common.core.command.CommandShare; import vazkii.botania.common.core.command.CommandSkyblockSpread; import vazkii.botania.common.core.handler.ConfigHandler; +import vazkii.botania.common.core.handler.EquipmentHandler; import vazkii.botania.common.core.handler.IMCHandler; import vazkii.botania.common.core.handler.IMCSender; import vazkii.botania.common.core.handler.InternalMethodHandler; @@ -99,7 +100,6 @@ 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.PacketHandler; @@ -170,11 +170,7 @@ public class Botania { MinecraftForge.EVENT_BUS.register(TileCorporeaIndex.getInputHandler()); MinecraftForge.EVENT_BUS.register(new LootHandler()); - if(curiosLoaded) { - CurioIntegration.init(); - FMLJavaModLoadingContext.get().getModEventBus().register(CurioIntegration.class); - MinecraftForge.EVENT_BUS.register(CurioIntegration.class); - } + EquipmentHandler.init(); if(Botania.gardenOfGlassLoaded) MinecraftForge.EVENT_BUS.register(SkyblockWorldEvents.class); diff --git a/src/main/java/vazkii/botania/common/core/handler/EquipmentHandler.java b/src/main/java/vazkii/botania/common/core/handler/EquipmentHandler.java new file mode 100644 index 000000000..3f479d0a3 --- /dev/null +++ b/src/main/java/vazkii/botania/common/core/handler/EquipmentHandler.java @@ -0,0 +1,166 @@ +/** + * This class was created by . 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 @ [May 30 2019, 16:45:42 (GMT)] + */ + +package vazkii.botania.common.core.handler; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.capabilities.ICapabilityProvider; +import net.minecraftforge.common.util.LazyOptional; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; +import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext; +import net.minecraftforge.items.IItemHandlerModifiable; +import net.minecraftforge.items.wrapper.InvWrapper; +import net.minecraftforge.items.wrapper.RangedWrapper; +import vazkii.botania.common.Botania; +import vazkii.botania.common.integration.curios.CurioIntegration; +import vazkii.botania.common.item.equipment.bauble.ItemBauble; + +import java.util.Arrays; +import java.util.Map; +import java.util.WeakHashMap; +import java.util.function.Predicate; + +public abstract class EquipmentHandler { + private static EquipmentHandler instance; + + public static void init() { //todo maybe support baubles when/if that gets released + if(Botania.curiosLoaded) { + instance = new CurioIntegration(); + FMLJavaModLoadingContext.get().getModEventBus().register(CurioIntegration.class); + MinecraftForge.EVENT_BUS.register(CurioIntegration.class); + } else { + InventoryEquipmentHandler handler = new InventoryEquipmentHandler(); + instance = handler; + MinecraftForge.EVENT_BUS.addListener(handler::onPlayerTick); + } + } + + public static LazyOptional getAllWorn(EntityLivingBase living) { + return instance.getAllWornItems(living); + } + + public static ItemStack findOrEmpty(Item item, EntityLivingBase living) { + return instance.findItem(item, living); + } + + public static ItemStack findOrEmpty(Predicate pred, EntityLivingBase living) { + return instance.findItem(pred, living); + } + + public static ICapabilityProvider initBaubleCap(ItemStack stack) { + if(instance != null) // Happens to be called in ModItems class init, which is too early to know about which handler to use + return instance.initCap(stack); + return null; + } + + protected abstract LazyOptional getAllWornItems(EntityLivingBase living); + + protected abstract ItemStack findItem(Item item, EntityLivingBase living); + + protected abstract ItemStack findItem(Predicate pred, EntityLivingBase living); + + protected abstract ICapabilityProvider initCap(ItemStack stack); + + // Fallback equipment handler for curios-less (or baubles-less) installs. + static class InventoryEquipmentHandler extends EquipmentHandler { + private final Map map = new WeakHashMap<>(); + + @SubscribeEvent + public void onPlayerTick(TickEvent.PlayerTickEvent event) { + if(event.phase != TickEvent.Phase.START || event.player.world.isRemote) + return; + EntityPlayer player = event.player; + player.world.profiler.startSection("botania:tick_wearables"); + + ItemStack[] oldStacks = map.computeIfAbsent(player, p -> { + ItemStack[] array = new ItemStack[9]; + Arrays.fill(array, ItemStack.EMPTY); + return array; + }); + + InventoryPlayer inv = player.inventory; + for(int i = 0; i < 9; i++) { + ItemStack old = oldStacks[i]; + ItemStack current = inv.getStackInSlot(i); + + if(!ItemStack.areItemStacksEqual(old, current)) { + if(old.getItem() instanceof ItemBauble) { + player.getAttributeMap().removeAttributeModifiers(((ItemBauble) old.getItem()).getEquippedAttributeModifiers(old)); + ((ItemBauble) old.getItem()).onUnequipped(old, player); + } + if(canEquip(current, player)) { + player.getAttributeMap().applyAttributeModifiers(((ItemBauble) current.getItem()).getEquippedAttributeModifiers(current)); + ((ItemBauble) current.getItem()).onEquipped(current, player); + } + oldStacks[i] = current.copy(); // shift-clicking mutates the stack we stored, + // making it empty and failing the equality check - let's avoid that + } + + if(canEquip(current, player)) { + ((ItemBauble) current.getItem()).onWornTick(current, player); + } + } + player.world.profiler.endSection(); + } + + + @Override + protected LazyOptional getAllWornItems(EntityLivingBase living) { + if(living instanceof EntityPlayer) { + return LazyOptional.of(() -> new RangedWrapper(new InvWrapper(((EntityPlayer) living).inventory), 0, 9)); + } + return LazyOptional.empty(); + } + + @Override + protected ItemStack findItem(Item item, EntityLivingBase living) { + if(living instanceof EntityPlayer) { + InventoryPlayer inv = ((EntityPlayer) living).inventory; + for(int i = 0; i < 9; i++) { + ItemStack stack = inv.getStackInSlot(i); + if(stack.getItem() == item && canEquip(stack, living)) { + return stack; + } + } + } + return ItemStack.EMPTY; + } + + @Override + protected ItemStack findItem(Predicate pred, EntityLivingBase living) { + if(living instanceof EntityPlayer) { + InventoryPlayer inv = ((EntityPlayer) living).inventory; + for(int i = 0; i < 9; i++) { + ItemStack stack = inv.getStackInSlot(i); + if(pred.test(stack) && canEquip(stack, living)) { + return stack; + } + } + } + return ItemStack.EMPTY; + } + + @Override + protected ICapabilityProvider initCap(ItemStack stack) { + return null; + } + + private static boolean canEquip(ItemStack stack, EntityLivingBase player) { + return stack.getItem() instanceof ItemBauble && ((ItemBauble) stack.getItem()).canEquip(stack, player); + } + } +} diff --git a/src/main/java/vazkii/botania/common/core/handler/InternalMethodHandler.java b/src/main/java/vazkii/botania/common/core/handler/InternalMethodHandler.java index 64e76c0a1..9ecf10d6b 100644 --- a/src/main/java/vazkii/botania/common/core/handler/InternalMethodHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/InternalMethodHandler.java @@ -37,9 +37,9 @@ import vazkii.botania.api.recipe.RecipeManaInfusion; import vazkii.botania.api.recipe.RecipePetals; import vazkii.botania.api.recipe.RecipeRuneAltar; import vazkii.botania.api.subtile.ISpecialFlower; -import vazkii.botania.api.subtile.TileEntitySpecialFlower; import vazkii.botania.api.subtile.TileEntityFunctionalFlower; import vazkii.botania.api.subtile.TileEntityGeneratingFlower; +import vazkii.botania.api.subtile.TileEntitySpecialFlower; import vazkii.botania.client.core.handler.BossBarHandler; import vazkii.botania.client.core.handler.HUDHandler; import vazkii.botania.common.Botania; @@ -48,7 +48,6 @@ import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.block.decor.BlockFloatingFlower; import vazkii.botania.common.block.subtile.functional.SubTileSolegnolia; import vazkii.botania.common.integration.corporea.WrappedIInventory; -import vazkii.botania.common.integration.curios.CurioIntegration; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.relic.ItemLokiRing; import vazkii.botania.common.lexicon.page.PageBrew; @@ -151,7 +150,7 @@ public class InternalMethodHandler extends DummyMethodHandler { @Override public IItemHandlerModifiable getAccessoriesInventory(EntityPlayer player) { if(Botania.curiosLoaded) { - LazyOptional cap = CurioIntegration.getAllCurios(player); + LazyOptional cap = EquipmentHandler.getAllWorn(player); return cap.orElseGet(EmptyHandler::new); } return new EmptyHandler(); diff --git a/src/main/java/vazkii/botania/common/core/handler/PixieHandler.java b/src/main/java/vazkii/botania/common/core/handler/PixieHandler.java index 245f5f16d..dfdfcbea2 100644 --- a/src/main/java/vazkii/botania/common/core/handler/PixieHandler.java +++ b/src/main/java/vazkii/botania/common/core/handler/PixieHandler.java @@ -7,17 +7,14 @@ import net.minecraft.item.ItemStack; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.math.BlockPos; -import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.event.entity.living.LivingHurtEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandlerModifiable; +import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.item.IPixieSpawner; -import vazkii.botania.common.Botania; import vazkii.botania.common.core.helper.PlayerHelper; import vazkii.botania.common.entity.EntityPixie; -import vazkii.botania.common.integration.curios.CurioIntegration; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.armor.elementium.ItemElementiumHelm; import vazkii.botania.common.lib.LibMisc; @@ -41,17 +38,13 @@ public final class PixieHandler { ItemStack stack = PlayerHelper.getFirstHeldItemClass(player, IPixieSpawner.class); float chance = getChance(stack); - for (ItemStack element : player.inventory.armorInventory) + for(ItemStack element : player.inventory.armorInventory) chance += getChance(element); - if(Botania.curiosLoaded) { - LazyOptional cap = CurioIntegration.getAllCurios(player); - if(cap.isPresent()) { - IItemHandlerModifiable handler = cap.orElseThrow(NullPointerException::new); - for(int i = 0; i < handler.getSlots(); i++) - chance += getChance(handler.getStackInSlot(i)); - } - } + IItemHandlerModifiable handler = BotaniaAPI.internalHandler.getAccessoriesInventory(player); + for(int i = 0; i < handler.getSlots(); i++) + chance += getChance(handler.getStackInSlot(i)); + if(Math.random() < chance) { EntityPixie pixie = new EntityPixie(player.world); diff --git a/src/main/java/vazkii/botania/common/entity/EntitySpark.java b/src/main/java/vazkii/botania/common/entity/EntitySpark.java index c69d159f1..f2a35836b 100644 --- a/src/main/java/vazkii/botania/common/entity/EntitySpark.java +++ b/src/main/java/vazkii/botania/common/entity/EntitySpark.java @@ -27,21 +27,19 @@ import net.minecraft.util.math.RayTraceResult; import net.minecraft.world.World; import net.minecraftforge.items.IItemHandler; import net.minecraftforge.registries.ObjectHolder; +import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.mana.IManaItem; import vazkii.botania.api.mana.IManaPool; import vazkii.botania.api.mana.spark.ISparkAttachable; import vazkii.botania.api.mana.spark.ISparkEntity; import vazkii.botania.api.mana.spark.SparkHelper; import vazkii.botania.api.mana.spark.SparkUpgradeType; -import vazkii.botania.common.Botania; -import vazkii.botania.common.integration.curios.CurioIntegration; import vazkii.botania.common.item.ItemSparkUpgrade; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.LibMisc; import vazkii.botania.common.network.PacketBotaniaEffect; import vazkii.botania.common.network.PacketHandler; -import javax.annotation.Nonnull; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -51,6 +49,7 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.WeakHashMap; +import javax.annotation.Nonnull; public class EntitySpark extends Entity implements ISparkEntity { @ObjectHolder(LibMisc.MOD_ID + ":spark") @@ -113,12 +112,9 @@ public class EntitySpark extends Entity implements ISparkEntity { stacks.addAll(player.inventory.mainInventory); stacks.addAll(player.inventory.armorInventory); - if(Botania.curiosLoaded) { - CurioIntegration.getAllCurios(player).ifPresent(inv -> { - for (int i = 0; i < inv.getSlots(); i++) - stacks.add(inv.getStackInSlot(i)); - }); - } + IItemHandler inv = BotaniaAPI.internalHandler.getAccessoriesInventory(player); + for(int i = 0; i < inv.getSlots(); i++) + stacks.add(inv.getStackInSlot(i)); for(ItemStack stack : stacks) { if(stack.isEmpty() || !(stack.getItem() instanceof IManaItem)) diff --git a/src/main/java/vazkii/botania/common/integration/curios/BaseCurio.java b/src/main/java/vazkii/botania/common/integration/curios/BaseCurio.java deleted file mode 100644 index 6c546d8c7..000000000 --- a/src/main/java/vazkii/botania/common/integration/curios/BaseCurio.java +++ /dev/null @@ -1,35 +0,0 @@ -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); - } -} diff --git a/src/main/java/vazkii/botania/common/integration/curios/CurioIntegration.java b/src/main/java/vazkii/botania/common/integration/curios/CurioIntegration.java index da05d3b58..1fc7a172a 100644 --- a/src/main/java/vazkii/botania/common/integration/curios/CurioIntegration.java +++ b/src/main/java/vazkii/botania/common/integration/curios/CurioIntegration.java @@ -1,132 +1,144 @@ -package vazkii.botania.common.integration.curios; - -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.item.Item; -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.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.InterModComms; -import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent; -import net.minecraftforge.items.IItemHandlerModifiable; -import net.minecraftforge.items.wrapper.CombinedInvWrapper; -import net.minecraftforge.registries.IRegistryDelegate; -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.*; -import vazkii.botania.common.item.relic.ItemLokiRing; -import vazkii.botania.common.item.relic.ItemOdinRing; -import vazkii.botania.common.item.relic.ItemThorRing; -import vazkii.botania.common.lib.LibMisc; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.util.HashMap; -import java.util.Map; -import java.util.function.Function; -import java.util.function.Predicate; - -// 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 curioCap; - - public Provider(ICurio curio) { - this.curio = curio; - curioCap = LazyOptional.of(() -> this.curio); - } - - @Nonnull - @Override - public LazyOptional getCapability(@Nonnull Capability cap, @Nullable EnumFacing side) { - return CuriosCapability.ITEM.orEmpty(cap, curioCap); - } - } - - @SubscribeEvent - 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")); - InterModComms.sendTo("curios", CuriosAPI.IMC.REGISTER_TYPE, () -> new CurioIMCMessage("body")); - InterModComms.sendTo("curios", CuriosAPI.IMC.REGISTER_TYPE, () -> new CurioIMCMessage("head")); - InterModComms.sendTo("curios", CuriosAPI.IMC.REGISTER_TYPE, () -> new CurioIMCMessage("trinket")); - } - - public static LazyOptional getAllCurios(EntityLivingBase living) { - return CuriosAPI.getCuriosHandler(living).map(h -> { - IItemHandlerModifiable[] invs = h.getCurioMap().values().toArray(new IItemHandlerModifiable[0]); - return new CombinedInvWrapper(invs); - }); - } - - // Convenience methods, also avoids referencing FinderData class in common code - public static ItemStack findOrEmpty(Item item, EntityLivingBase living) { - CuriosAPI.FinderData result = CuriosAPI.getCurioEquipped(item, living); - return result == null ? ItemStack.EMPTY : result.getStack(); - } - - public static ItemStack findOrEmpty(Predicate pred, EntityLivingBase living) { - CuriosAPI.FinderData result = CuriosAPI.getCurioEquipped(pred, living); - return result == null ? ItemStack.EMPTY : result.getStack(); - } - - public static void init() { - FACTORIES.put(ModItems.auraRing.delegate, ItemAuraRing.Curio::new); - FACTORIES.put(ModItems.auraRingGreater.delegate, ItemGreaterAuraRing.Curio::new); - FACTORIES.put(ModItems.balanceCloak.delegate, ItemHolyCloak.Curio::new); - FACTORIES.put(ModItems.bloodPendant.delegate, ItemBloodPendant.Curio::new); - FACTORIES.put(ModItems.divaCharm.delegate, ItemDivaCharm.Curio::new); - FACTORIES.put(ModItems.dodgeRing.delegate, ItemDodgeRing.Curio::new); - FACTORIES.put(ModItems.flightTiara.delegate, ItemFlightTiara.Curio::new); - FACTORIES.put(ModItems.goddessCharm.delegate, ItemGoddessCharm.Curio::new); - FACTORIES.put(ModItems.holyCloak.delegate, ItemHolyCloak.Curio::new); - FACTORIES.put(ModItems.icePendant.delegate, ItemIcePendant.Curio::new); - FACTORIES.put(ModItems.invisibilityCloak.delegate, ItemInvisibilityCloak.Curio::new); - FACTORIES.put(ModItems.itemFinder.delegate, ItemItemFinder.Curio::new); - FACTORIES.put(ModItems.knockbackBelt.delegate, ItemKnockbackBelt.Curio::new); - FACTORIES.put(ModItems.lavaPendant.delegate, ItemLavaPendant.Curio::new); - FACTORIES.put(ModItems.lokiRing.delegate, s -> new ItemLokiRing.Curio(s, ((ItemLokiRing) ModItems.lokiRing).getDummy())); - FACTORIES.put(ModItems.magnetRing.delegate, ItemMagnetRing.Curio::new); - FACTORIES.put(ModItems.magnetRingGreater.delegate, ItemMagnetRing.Curio::new); - FACTORIES.put(ModItems.manaRing.delegate, BaseCurio::new); - FACTORIES.put(ModItems.manaRingGreater.delegate, BaseCurio::new); - FACTORIES.put(ModItems.miningRing.delegate, ItemMiningRing.Curio::new); - FACTORIES.put(ModItems.odinRing.delegate, s -> new ItemOdinRing.Curio(s, ((ItemOdinRing) ModItems.odinRing).getDummy())); - FACTORIES.put(ModItems.pixieRing.delegate, BaseCurio::new); - FACTORIES.put(ModItems.reachRing.delegate, ItemReachRing.Curio::new); - FACTORIES.put(ModItems.superLavaPendant.delegate, ItemSuperLavaPendant.Curio::new); - FACTORIES.put(ModItems.superTravelBelt.delegate, ItemTravelBelt.Curio::new); - FACTORIES.put(ModItems.swapRing.delegate, ItemSwapRing.Curio::new); - FACTORIES.put(ModItems.thirdEye.delegate, ItemThirdEye.Curio::new); - FACTORIES.put(ModItems.tinyPlanet.delegate, ItemTinyPlanet.Curio::new); - FACTORIES.put(ModItems.thorRing.delegate, s -> new RelicCurio(s, ((ItemThorRing) ModItems.thorRing).getDummy())); - FACTORIES.put(ModItems.travelBelt.delegate, ItemTravelBelt.Curio::new); - FACTORIES.put(ModItems.unholyCloak.delegate, ItemHolyCloak.Curio::new); - FACTORIES.put(ModItems.waterRing.delegate, ItemWaterRing.Curio::new); - for (Item i : ModItems.cosmetics.values()) { - FACTORIES.put(i.delegate, ItemBaubleCosmetic.Curio::new); - } - } - - private static final Map, Function> FACTORIES = new HashMap<>(); - - @SubscribeEvent - public static void attachCaps(AttachCapabilitiesEvent evt) { - ItemStack stack = evt.getObject(); - Function factory = FACTORIES.get(stack.getItem().delegate); - if (factory != null) { - evt.addCapability(KEY, new Provider(factory.apply(stack))); - } - } -} +package vazkii.botania.common.integration.curios; + +import com.google.common.collect.Multimap; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.ai.attributes.AttributeModifier; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumFacing; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.ICapabilityProvider; +import net.minecraftforge.common.util.LazyOptional; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.InterModComms; +import net.minecraftforge.fml.event.lifecycle.InterModEnqueueEvent; +import net.minecraftforge.items.IItemHandlerModifiable; +import net.minecraftforge.items.wrapper.CombinedInvWrapper; +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.core.handler.EquipmentHandler; +import vazkii.botania.common.core.handler.ModSounds; +import vazkii.botania.common.item.equipment.bauble.ItemBauble; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import java.util.function.Predicate; + +// Classloading-safe way to attach curio behaviour to our items +public class CurioIntegration extends EquipmentHandler { + + private static class Provider implements ICapabilityProvider { + private final ICurio curio; + private final LazyOptional curioCap; + + Provider(ICurio curio) { + this.curio = curio; + curioCap = LazyOptional.of(() -> this.curio); + } + + @Nonnull + @Override + public LazyOptional getCapability(@Nonnull Capability cap, @Nullable EnumFacing side) { + return CuriosCapability.ITEM.orEmpty(cap, curioCap); + } + } + + @SubscribeEvent + 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").setSize(2)); + InterModComms.sendTo("curios", CuriosAPI.IMC.REGISTER_TYPE, () -> new CurioIMCMessage("belt")); + InterModComms.sendTo("curios", CuriosAPI.IMC.REGISTER_TYPE, () -> new CurioIMCMessage("body")); + InterModComms.sendTo("curios", CuriosAPI.IMC.REGISTER_TYPE, () -> new CurioIMCMessage("head")); + InterModComms.sendTo("curios", CuriosAPI.IMC.REGISTER_TYPE, () -> new CurioIMCMessage("trinket")); + } + + @Override + protected LazyOptional getAllWornItems(EntityLivingBase living) { + return CuriosAPI.getCuriosHandler(living).map(h -> { + IItemHandlerModifiable[] invs = h.getCurioMap().values().toArray(new IItemHandlerModifiable[0]); + return new CombinedInvWrapper(invs); + }); + } + + @Override + protected ItemStack findItem(Item item, EntityLivingBase living) { + CuriosAPI.FinderData result = CuriosAPI.getCurioEquipped(item, living); + return result == null ? ItemStack.EMPTY : result.getStack(); + } + + @Override + protected ItemStack findItem(Predicate pred, EntityLivingBase living) { + CuriosAPI.FinderData result = CuriosAPI.getCurioEquipped(pred, living); + return result == null ? ItemStack.EMPTY : result.getStack(); + } + + @Override + protected ICapabilityProvider initCap(ItemStack stack) { + return new Provider(new Wrapper(stack)); + } + + private static class Wrapper implements ICurio { + private final ItemStack stack; + + Wrapper(ItemStack stack) { + this.stack = stack; + } + + private ItemBauble getItem() { + return (ItemBauble) stack.getItem(); + } + + @Override + public void onCurioTick(String identifier, EntityLivingBase entity) { + getItem().onWornTick(stack, entity); + } + + @Override + public void onEquipped(String identifier, EntityLivingBase entity) { + getItem().onEquipped(stack, entity); + } + + @Override + public void onUnequipped(String identifier, EntityLivingBase entity) { + getItem().onUnequipped(stack, entity); + } + + @Override + public boolean canEquip(String identifier, EntityLivingBase entity) { + return getItem().canEquip(stack, entity); + } + + @Override + public Multimap getAttributeModifiers(String identifier) { + return getItem().getEquippedAttributeModifiers(stack); + } + + @Override + public boolean shouldSyncToTracking(String identifier, EntityLivingBase entity) { + return getItem().shouldSyncToTracking(stack, entity); + } + + @Override + public void playEquipSound(EntityLivingBase entity) { + entity.world.playSound(null, entity.posX, entity.posY, entity.posZ, ModSounds.equipBauble, entity.getSoundCategory(), 0.1F, 1.3F); + } + + @Override + public boolean canRightClickEquip() { + return true; + } + + @Override + public boolean hasRender(String identifier, EntityLivingBase entity) { + return getItem().hasRender(stack, entity); + } + + @Override + public void doRender(String identifier, EntityLivingBase entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + getItem().doRender(stack, entitylivingbaseIn, limbSwing, limbSwingAmount, partialTicks, ageInTicks, netHeadYaw, headPitch, scale); + } + } +} diff --git a/src/main/java/vazkii/botania/common/integration/curios/RelicCurio.java b/src/main/java/vazkii/botania/common/integration/curios/RelicCurio.java deleted file mode 100644 index ac4eccb7b..000000000 --- a/src/main/java/vazkii/botania/common/integration/curios/RelicCurio.java +++ /dev/null @@ -1,31 +0,0 @@ -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) {} -} diff --git a/src/main/java/vazkii/botania/common/integration/curios/RenderableCurio.java b/src/main/java/vazkii/botania/common/integration/curios/RenderableCurio.java deleted file mode 100644 index 6b88032da..000000000 --- a/src/main/java/vazkii/botania/common/integration/curios/RenderableCurio.java +++ /dev/null @@ -1,23 +0,0 @@ -package vazkii.botania.common.integration.curios; - -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.init.MobEffects; -import net.minecraft.item.ItemStack; -import vazkii.botania.api.item.ICosmeticAttachable; -import vazkii.botania.api.item.IPhantomInkable; -import vazkii.botania.common.core.handler.ConfigHandler; - -public class RenderableCurio extends BaseCurio { - public RenderableCurio(ItemStack stack) { - super(stack); - } - - @Override - public boolean hasRender(String identifier, EntityLivingBase living) { - boolean hasCosmetic = stack.getItem() instanceof ICosmeticAttachable && !((ICosmeticAttachable) stack.getItem()).getCosmeticItem(stack).isEmpty(); - boolean ink = stack.getItem() instanceof IPhantomInkable && ((IPhantomInkable) stack.getItem()).hasPhantomInk(stack); - boolean config = ConfigHandler.CLIENT.renderAccessories.get(); - boolean invis = living.getActivePotionEffect(MobEffects.INVISIBILITY) != null; - return !hasCosmetic && !ink && config && !invis; - } -} diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemAuraRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemAuraRing.java index 2e66eaace..2151bb7f9 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemAuraRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemAuraRing.java @@ -15,8 +15,6 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import vazkii.botania.api.mana.IManaGivingItem; import vazkii.botania.api.mana.ManaItemHandler; -import vazkii.botania.common.integration.curios.BaseCurio; -import vazkii.botania.common.lib.LibItemNames; public class ItemAuraRing extends ItemBauble implements IManaGivingItem { @@ -24,16 +22,9 @@ public class ItemAuraRing extends ItemBauble implements IManaGivingItem { super(props); } - public static class Curio extends BaseCurio { - public Curio(ItemStack stack) { - super(stack); - } - - @Override - public void onCurioTick(String identifier, EntityLivingBase player) { - if(player instanceof EntityPlayer && player.ticksExisted % 10 == 0) - ManaItemHandler.dispatchManaExact(stack, (EntityPlayer) player, 1, true); - } + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + if (player instanceof EntityPlayer && player.ticksExisted % 10 == 0) + ManaItemHandler.dispatchManaExact(stack, (EntityPlayer) player, 1, true); } - } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBauble.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBauble.java index bbf65c01f..fbfc1c502 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBauble.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBauble.java @@ -10,39 +10,35 @@ */ package vazkii.botania.common.item.equipment.bauble; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.resources.I18n; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.player.EntityPlayerMP; +import net.minecraft.init.MobEffects; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.ActionResult; -import net.minecraft.util.EnumActionResult; -import net.minecraft.util.EnumHand; import net.minecraft.util.ResourceLocation; -import net.minecraft.util.SoundCategory; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.World; -import net.minecraftforge.event.entity.living.LivingDeathEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.items.IItemHandler; -import net.minecraftforge.items.ItemHandlerHelper; +import net.minecraftforge.common.capabilities.ICapabilityProvider; +import net.minecraftforge.fml.common.Mod; import vazkii.botania.api.item.ICosmeticAttachable; import vazkii.botania.api.item.IPhantomInkable; -import vazkii.botania.common.core.handler.ModSounds; +import vazkii.botania.common.core.handler.ConfigHandler; +import vazkii.botania.common.core.handler.EquipmentHandler; import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.core.helper.PlayerHelper; -import vazkii.botania.common.entity.EntityDoppleganger; import vazkii.botania.common.item.ItemMod; import vazkii.botania.common.lib.LibMisc; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import java.util.List; import java.util.UUID; @@ -130,4 +126,42 @@ public abstract class ItemBauble extends ItemMod implements ICosmeticAttachable, public void setPhantomInk(ItemStack stack, boolean ink) { ItemNBTHelper.setBoolean(stack, TAG_PHANTOM_INK, ink); } + + @Nullable + @Override + public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) { + return EquipmentHandler.initBaubleCap(stack); + } + + public void onWornTick(ItemStack stack, EntityLivingBase entity) {} + + public void onEquipped(ItemStack stack, EntityLivingBase entity) { + if(!entity.world.isRemote && entity instanceof EntityPlayerMP) { + PlayerHelper.grantCriterion((EntityPlayerMP) entity, new ResourceLocation(LibMisc.MOD_ID, "main/bauble_wear"), "code_triggered"); + } + } + + public void onUnequipped(ItemStack stack, EntityLivingBase entity) {} + + public boolean canEquip(ItemStack stack, EntityLivingBase entity) { + return true; + } + + public Multimap getEquippedAttributeModifiers(ItemStack stack) { + return HashMultimap.create(); + } + + public boolean shouldSyncToTracking(ItemStack stack, EntityLivingBase entity) { + return false; + } + + public boolean hasRender(ItemStack stack, EntityLivingBase living) { + return !(stack.getItem() instanceof ICosmeticAttachable && !((ICosmeticAttachable) stack.getItem()).getCosmeticItem(stack).isEmpty()) + && !(stack.getItem() instanceof IPhantomInkable && ((IPhantomInkable) stack.getItem()).hasPhantomInk(stack)) + && ConfigHandler.CLIENT.renderAccessories.get() + && living.getActivePotionEffect(MobEffects.INVISIBILITY) == null; + } + + @OnlyIn(Dist.CLIENT) + public void doRender(ItemStack stack, EntityLivingBase player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) {} } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBaubleCosmetic.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBaubleCosmetic.java index 4ca5bda23..5e1302134 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBaubleCosmetic.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBaubleCosmetic.java @@ -31,7 +31,6 @@ import net.minecraftforge.api.distmarker.OnlyIn; import org.lwjgl.opengl.GL11; import vazkii.botania.api.item.AccessoryRenderHelper; import vazkii.botania.api.item.ICosmeticBauble; -import vazkii.botania.common.integration.curios.RenderableCurio; import java.util.List; @@ -68,218 +67,212 @@ public class ItemBaubleCosmetic extends ItemBauble implements ICosmeticBauble { super.addHiddenTooltip(stack, world, stacks, flags); } - public static class Curio extends RenderableCurio { - public Curio(ItemStack stack) { - super(stack); - } - @Override - @OnlyIn(Dist.CLIENT) - public void doRender(String identifier, EntityLivingBase player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { - Variant variant = ((ItemBaubleCosmetic) stack.getItem()).variant; - Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); + @Override + @OnlyIn(Dist.CLIENT) + public void doRender(ItemStack stack, EntityLivingBase player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + Variant variant = ((ItemBaubleCosmetic) stack.getItem()).variant; + Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); + AccessoryRenderHelper.translateToHeadLevel(player); + AccessoryRenderHelper.translateToFace(); + AccessoryRenderHelper.defaultTransforms(); + switch (variant) { + case RED_GLASSES: + scale(1.25F); + GlStateManager.translatef(0F, -0.085F, 0.045F); + renderItem(stack); + break; + case ENGINEER_GOGGLES: + scale(1.25F); + GlStateManager.translatef(0F, -0.085F, 0.045F); + renderItem(stack); + break; + case EYEPATCH: + scale(0.55F); + GlStateManager.translatef(-0.45F, -0.25F, 0F); + renderItem(stack); + break; + case WICKED_EYEPATCH: + scale(0.55F); + GlStateManager.translatef(0.45F, -0.25F, 0F); + renderItem(stack); + break; + case RED_RIBBONS: + scale(0.9F); + GlStateManager.translatef(0F, 0.75F, 1F); + renderItem(stack); + break; + case PINK_FLOWER_BUD: + GlStateManager.rotatef(-90F, 0F, 1F, 0F); + GlStateManager.translatef(0.4F, 0.6F, 0.45F); + renderItem(stack); + break; + case POLKA_DOTTED_BOWS: + GlStateManager.rotatef(-90F, 0F, 1F, 0F); + GlStateManager.translatef(0.65F, 0.3F, 0.5F); + renderItem(stack); + GlStateManager.translatef(0F, 0F, -1F); + renderItem(stack); + break; + case BLUE_BUTTERFLY: + GlStateManager.translatef(-0.75F, 0.1F, 1F); GlStateManager.pushMatrix(); - AccessoryRenderHelper.translateToHeadLevel(player); - AccessoryRenderHelper.translateToFace(); + GlStateManager.rotatef(45F, 0F, 1F, 0F); + renderItem(stack); + GlStateManager.popMatrix(); + + GlStateManager.translatef(0F, 0F, -0.75F); + GlStateManager.rotatef(-45F, 0F, 1F, 0F); + renderItem(stack); + break; + case CAT_EARS: + GlStateManager.translatef(0F, 0.25F, 0.25F); + renderItem(stack); + break; + case GOOGLY_EYES: + GlStateManager.rotatef(180F, 0F, 1F, 0F); + GlStateManager.scalef(1.5F, 1.5F, 1F); + GlStateManager.translatef(0F, -0.05F, 0F); + renderItem(stack); + break; + case CLOCK_EYE: + scale(0.75F); + GlStateManager.translatef(-0.25F, -0.1F, 0F); + GlStateManager.rotatef(180F, 0F, 0F, 1F); + renderItem(stack); + break; + case UNICORN_HORN: + scale(1.25F); + GlStateManager.rotatef(-90F, 0F, 1F, 0F); + GlStateManager.translatef(0F, 0.4F, 0F); + renderItem(stack); + break; + case DEVIL_HORNS: + GlStateManager.translatef(0F, 0.2F, 0.25F); + renderItem(stack); + break; + case HYPER_PLUS: + scale(0.35F); + GlStateManager.translatef(-0.7F, 1F, -0.5F); + renderItem(stack); + GlStateManager.translatef(1.45F, 0F, 0F); + renderItem(stack); + break; + case ANCIENT_MASK: + scale(1.25F); + GlStateManager.translatef(0F, 0.025F, 0.01F); + renderItem(stack); + break; + case EERIE_MASK: + renderItem(stack); + break; + case ALIEN_ANTENNA: + scale(0.9F); + GlStateManager.rotatef(180F, 0F, 1F, 0F); + GlStateManager.translatef(0F, 0.75F, -1F); + renderItem(stack); + break; + case ANAGLYPH_GLASSES: + scale(1.25F); + GlStateManager.translatef(0F, -0.025F, 0F); + renderItem(stack); + break; + case ORANGE_SHADES: + scale(1.25f); + GlStateManager.translatef(0F, 0.04F, 0F); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.color4f(1F, 1F, 1F, 0.7F); + renderItem(stack); + break; + case GROUCHO_GLASSES: + scale(1.5F); + GlStateManager.translatef(0F, -0.2125F, 0F); + renderItem(stack); + break; + case THICK_EYEBROWS: + scale(0.5F); + GlStateManager.translatef(-0.4F, 0.05F, 0F); + renderItem(stack); + GlStateManager.rotatef(180F, 0F, 1F, 0F); + GlStateManager.translatef(-0.775F, 0F, 0F); + renderItem(stack); + break; + case TINY_POTATO_MASK: + scale(1.25F); + GlStateManager.translatef(0F, 0.025F, 0F); + renderItem(stack); + break; + case QUESTGIVER_MARK: + scale(0.8F); + GlStateManager.translatef(0F, 1F, 0.3F); + renderItem(stack); + break; + case THINKING_HAND: + scale(0.9f); + GlStateManager.translatef(0.2F, -0.5F, 0F); + GlStateManager.scalef(-1, 1, 1); + GlStateManager.rotatef(15F, 0F, 0F, 1F); + renderItem(stack); + break; + default: { + // body cosmetics + AccessoryRenderHelper.rotateIfSneaking(player); + AccessoryRenderHelper.translateToChest(); AccessoryRenderHelper.defaultTransforms(); switch (variant) { - case RED_GLASSES: - scale(1.25F); - GlStateManager.translatef(0F, -0.085F, 0.045F); + case BLACK_BOWTIE: + GlStateManager.translatef(0F, 0.15F, 0F); renderItem(stack); break; - case ENGINEER_GOGGLES: - scale(1.25F); - GlStateManager.translatef(0F, -0.085F, 0.045F); + case BLACK_TIE: + GlStateManager.translatef(0F, -0.15F, 0F); renderItem(stack); break; - case EYEPATCH: - scale(0.55F); - GlStateManager.translatef(-0.45F, -0.25F, 0F); + case PUFFY_SCARF: + GlStateManager.translatef(0F, -0.15F, 0F); renderItem(stack); break; - case WICKED_EYEPATCH: - scale(0.55F); - GlStateManager.translatef(0.45F, -0.25F, 0F); - renderItem(stack); - break; - case RED_RIBBONS: - scale(0.9F); - GlStateManager.translatef(0F, 0.75F, 1F); - renderItem(stack); - break; - case PINK_FLOWER_BUD: - GlStateManager.rotatef(-90F, 0F, 1F, 0F); - GlStateManager.translatef(0.4F, 0.6F, 0.45F); - renderItem(stack); - break; - case POLKA_DOTTED_BOWS: - GlStateManager.rotatef(-90F, 0F, 1F, 0F); - GlStateManager.translatef(0.65F, 0.3F, 0.5F); - renderItem(stack); - GlStateManager.translatef(0F, 0F, -1F); - renderItem(stack); - break; - case BLUE_BUTTERFLY: - GlStateManager.translatef(-0.75F, 0.1F, 1F); - GlStateManager.pushMatrix(); - GlStateManager.rotatef(45F, 0F, 1F, 0F); - renderItem(stack); - GlStateManager.popMatrix(); - - GlStateManager.translatef(0F, 0F, -0.75F); - GlStateManager.rotatef(-45F, 0F, 1F, 0F); - renderItem(stack); - break; - case CAT_EARS: - GlStateManager.translatef(0F, 0.25F, 0.25F); - renderItem(stack); - break; - case GOOGLY_EYES: - GlStateManager.rotatef(180F, 0F, 1F, 0F); - GlStateManager.scalef(1.5F, 1.5F, 1F); - GlStateManager.translatef(0F, -0.05F, 0F); - renderItem(stack); - break; - case CLOCK_EYE: - scale(0.75F); - GlStateManager.translatef(-0.25F, -0.1F, 0F); - GlStateManager.rotatef(180F, 0F, 0F, 1F); - renderItem(stack); - break; - case UNICORN_HORN: - scale(1.25F); - GlStateManager.rotatef(-90F, 0F, 1F, 0F); - GlStateManager.translatef(0F, 0.4F, 0F); - renderItem(stack); - break; - case DEVIL_HORNS: - GlStateManager.translatef(0F, 0.2F, 0.25F); - renderItem(stack); - break; - case HYPER_PLUS: + case WITCH_PIN: scale(0.35F); - GlStateManager.translatef(-0.7F, 1F, -0.5F); - renderItem(stack); - GlStateManager.translatef(1.45F, 0F, 0F); + GlStateManager.translatef(-0.35F, 0.35F, 0.15F); renderItem(stack); break; - case ANCIENT_MASK: - scale(1.25F); - GlStateManager.translatef(0F, 0.025F, 0.01F); + case DEVIL_TAIL: + GlStateManager.rotatef(90F, 0F, 1F, 0F); + GlStateManager.translatef(0.5F, -0.75F, 0F); renderItem(stack); break; - case EERIE_MASK: - renderItem(stack); - break; - case ALIEN_ANTENNA: + case KAMUI_EYE: // DON'T LOSE YOUR WAAAAAAAAY scale(0.9F); - GlStateManager.rotatef(180F, 0F, 1F, 0F); - GlStateManager.translatef(0F, 0.75F, -1F); + GlStateManager.translatef(0.9F, 0.35F, 0F); renderItem(stack); + GlStateManager.translatef(-1.3F, -0.5F, 0.5F); + GlStateManager.rotatef(180F, 0F, 0F, 1F); + GlStateManager.rotatef(180F, 1F, 0F, 0F); + renderKamuiBlack(stack); break; - case ANAGLYPH_GLASSES: - scale(1.25F); - GlStateManager.translatef(0F, -0.025F, 0F); - renderItem(stack); - break; - case ORANGE_SHADES: - scale(1.25f); - GlStateManager.translatef(0F, 0.04F, 0F); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.color4f(1F, 1F, 1F, 0.7F); - renderItem(stack); - break; - case GROUCHO_GLASSES: - scale(1.5F); - GlStateManager.translatef(0F, -0.2125F, 0F); - renderItem(stack); - break; - case THICK_EYEBROWS: + case FOUR_LEAF_CLOVER: scale(0.5F); - GlStateManager.translatef(-0.4F, 0.05F, 0F); + GlStateManager.translatef(0.35F, 0.3F, -0.075F); renderItem(stack); + break; + case BOTANIST_EMBLEM: + scale(0.5F); + GlStateManager.translatef(0F, -0.75F, 0F); + renderItem(stack); + break; + case LUSITANIC_SHIELD: GlStateManager.rotatef(180F, 0F, 1F, 0F); - GlStateManager.translatef(-0.775F, 0F, 0F); + GlStateManager.translatef(0.035F, -0.2F, 0.55F); + GlStateManager.rotatef(8F, 0F, 0F, 1F); renderItem(stack); break; - case TINY_POTATO_MASK: - scale(1.25F); - GlStateManager.translatef(0F, 0.025F, 0F); - renderItem(stack); + default: break; - case QUESTGIVER_MARK: - scale(0.8F); - GlStateManager.translatef(0F, 1F, 0.3F); - renderItem(stack); - break; - case THINKING_HAND: - scale(0.9f); - GlStateManager.translatef(0.2F, -0.5F, 0F); - GlStateManager.scalef(-1, 1, 1); - GlStateManager.rotatef(15F, 0F, 0F, 1F); - renderItem(stack); - break; - default: { - // body cosmetics - GlStateManager.popMatrix(); - AccessoryRenderHelper.rotateIfSneaking(player); - AccessoryRenderHelper.translateToChest(); - AccessoryRenderHelper.defaultTransforms(); - switch (variant) { - case BLACK_BOWTIE: - GlStateManager.translatef(0F, 0.15F, 0F); - renderItem(stack); - break; - case BLACK_TIE: - GlStateManager.translatef(0F, -0.15F, 0F); - renderItem(stack); - break; - case PUFFY_SCARF: - GlStateManager.translatef(0F, -0.15F, 0F); - renderItem(stack); - break; - case WITCH_PIN: - scale(0.35F); - GlStateManager.translatef(-0.35F, 0.35F, 0.15F); - renderItem(stack); - break; - case DEVIL_TAIL: - GlStateManager.rotatef(90F, 0F, 1F, 0F); - GlStateManager.translatef(0.5F, -0.75F, 0F); - renderItem(stack); - break; - case KAMUI_EYE: // DON'T LOSE YOUR WAAAAAAAAY - scale(0.9F); - GlStateManager.translatef(0.9F, 0.35F, 0F); - renderItem(stack); - GlStateManager.translatef(-1.3F, -0.5F, 0.5F); - GlStateManager.rotatef(180F, 0F, 0F, 1F); - GlStateManager.rotatef(180F, 1F, 0F, 0F); - renderKamuiBlack(stack); - break; - case FOUR_LEAF_CLOVER: - scale(0.5F); - GlStateManager.translatef(0.35F, 0.3F, -0.075F); - renderItem(stack); - break; - case BOTANIST_EMBLEM: - scale(0.5F); - GlStateManager.translatef(0F, -0.75F, 0F); - renderItem(stack); - break; - case LUSITANIC_SHIELD: - GlStateManager.rotatef(180F, 0F, 1F, 0F); - GlStateManager.translatef(0.035F, -0.2F, 0.55F); - GlStateManager.rotatef(8F, 0F, 0F, 1F); - renderItem(stack); - break; - default: break; - } - } } } + } } public static void scale(float f) { diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBloodPendant.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBloodPendant.java index 282c15c03..6cd742134 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBloodPendant.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemBloodPendant.java @@ -42,7 +42,6 @@ import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.client.core.handler.MiscellaneousIcons; import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.core.helper.ItemNBTHelper; -import vazkii.botania.common.integration.curios.RenderableCurio; import java.awt.Color; import java.util.List; @@ -90,59 +89,53 @@ public class ItemBloodPendant extends ItemBauble implements IBrewContainer, IBre } } - public static class Curio extends RenderableCurio { - public Curio(ItemStack stack) { - super(stack); - } - - @Override - public void onCurioTick(String identifier, EntityLivingBase player) { - Brew brew = ((IBrewItem) stack.getItem()).getBrew(stack); - if(brew != BotaniaAPI.fallbackBrew && player instanceof EntityPlayer && !player.world.isRemote) { - EntityPlayer eplayer = (EntityPlayer) player; - PotionEffect effect = brew.getPotionEffects(stack).get(0); - float cost = (float) brew.getManaCost(stack) / effect.getDuration() / (1 + effect.getAmplifier()) * 2.5F; - boolean doRand = cost < 1; - if(ManaItemHandler.requestManaExact(stack, eplayer, (int) Math.ceil(cost), false)) { - PotionEffect currentEffect = player.getActivePotionEffect(effect.getPotion()); - boolean nightVision = effect.getPotion() == MobEffects.NIGHT_VISION; - if(currentEffect == null || currentEffect.getDuration() < (nightVision ? 305 : 3)) { - PotionEffect applyEffect = new PotionEffect(effect.getPotion(), nightVision ? 385 : 80, effect.getAmplifier(), true, true); - player.addPotionEffect(applyEffect); - } - - if(!doRand || Math.random() < cost) - ManaItemHandler.requestManaExact(stack, eplayer, (int) Math.ceil(cost), true); + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + Brew brew = ((IBrewItem) stack.getItem()).getBrew(stack); + if (brew != BotaniaAPI.fallbackBrew && player instanceof EntityPlayer && !player.world.isRemote) { + EntityPlayer eplayer = (EntityPlayer) player; + PotionEffect effect = brew.getPotionEffects(stack).get(0); + float cost = (float) brew.getManaCost(stack) / effect.getDuration() / (1 + effect.getAmplifier()) * 2.5F; + boolean doRand = cost < 1; + if (ManaItemHandler.requestManaExact(stack, eplayer, (int) Math.ceil(cost), false)) { + PotionEffect currentEffect = player.getActivePotionEffect(effect.getPotion()); + boolean nightVision = effect.getPotion() == MobEffects.NIGHT_VISION; + if (currentEffect == null || currentEffect.getDuration() < (nightVision ? 305 : 3)) { + PotionEffect applyEffect = new PotionEffect(effect.getPotion(), nightVision ? 385 : 80, effect.getAmplifier(), true, true); + player.addPotionEffect(applyEffect); } + + if (!doRand || Math.random() < cost) + ManaItemHandler.requestManaExact(stack, eplayer, (int) Math.ceil(cost), true); } } + } - @Override - @OnlyIn(Dist.CLIENT) - 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); - AccessoryRenderHelper.rotateIfSneaking(player); - boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty(); - GlStateManager.rotatef(180F, 1F, 0F, 0F); - GlStateManager.translatef(-0.26F, -0.4F, armor ? 0.2F : 0.15F); - GlStateManager.scalef(0.5F, 0.5F, 0.5F); + @Override + @OnlyIn(Dist.CLIENT) + public void doRender(ItemStack stack, EntityLivingBase player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); + AccessoryRenderHelper.rotateIfSneaking(player); + boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty(); + GlStateManager.rotatef(180F, 1F, 0F, 0F); + GlStateManager.translatef(-0.26F, -0.4F, armor ? 0.2F : 0.15F); + GlStateManager.scalef(0.5F, 0.5F, 0.5F); - for(TextureAtlasSprite icon : new TextureAtlasSprite[] { MiscellaneousIcons.INSTANCE.bloodPendantChain, MiscellaneousIcons.INSTANCE.bloodPendantGem }) { - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, icon.getWidth(), icon.getHeight(), 1F / 32F); + for (TextureAtlasSprite icon : new TextureAtlasSprite[]{MiscellaneousIcons.INSTANCE.bloodPendantChain, MiscellaneousIcons.INSTANCE.bloodPendantGem}) { + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, icon.getWidth(), icon.getHeight(), 1F / 32F); - Color color = new Color(Minecraft.getInstance().getItemColors().getColor(stack, 1)); - GlStateManager.color3f(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F); - int light = 15728880; - int lightmapX = light % 65536; - int lightmapY = light / 65536; - OpenGlHelper.glMultiTexCoord2f(OpenGlHelper.GL_TEXTURE1, lightmapX, lightmapY); - } - GlStateManager.color3f(1, 1, 1); + Color color = new Color(Minecraft.getInstance().getItemColors().getColor(stack, 1)); + GlStateManager.color3f(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F); + int light = 15728880; + int lightmapX = light % 65536; + int lightmapY = light / 65536; + OpenGlHelper.glMultiTexCoord2f(OpenGlHelper.GL_TEXTURE1, lightmapX, lightmapY); } + GlStateManager.color3f(1, 1, 1); } @Override diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemCloudPendant.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemCloudPendant.java index e509150a9..7ee26e747 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemCloudPendant.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemCloudPendant.java @@ -25,7 +25,6 @@ import net.minecraftforge.fml.DistExecutor; import vazkii.botania.api.item.AccessoryRenderHelper; import vazkii.botania.client.core.handler.MiscellaneousIcons; import vazkii.botania.client.core.helper.IconHelper; -import vazkii.botania.common.integration.curios.RenderableCurio; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.network.PacketHandler; import vazkii.botania.common.network.PacketJump; @@ -39,52 +38,46 @@ public class ItemCloudPendant extends ItemBauble { super(props); } - public static class Curio extends RenderableCurio { - public Curio(ItemStack stack) { - super(stack); - } + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> { + if(player instanceof EntityPlayerSP && player == Minecraft.getInstance().player) { + EntityPlayerSP playerSp = (EntityPlayerSP) player; - @Override - public void onCurioTick(String identifier, EntityLivingBase player) { - DistExecutor.runWhenOn(Dist.CLIENT, () -> () -> { - if(player instanceof EntityPlayerSP && player == Minecraft.getInstance().player) { - EntityPlayerSP playerSp = (EntityPlayerSP) player; - - if(playerSp.onGround) - timesJumped = 0; - else { - if(playerSp.movementInput.jump) { - if(!jumpDown && timesJumped < ((ItemCloudPendant) stack.getItem()).getMaxAllowedJumps()) { - playerSp.jump(); - PacketHandler.sendToServer(new PacketJump()); - timesJumped++; - } - jumpDown = true; - } else jumpDown = false; - } + if (playerSp.onGround) + timesJumped = 0; + else { + if(playerSp.movementInput.jump) { + if (!jumpDown && timesJumped < ((ItemCloudPendant) stack.getItem()).getMaxAllowedJumps()) { + playerSp.jump(); + PacketHandler.sendToServer(new PacketJump()); + timesJumped++; + } + jumpDown = true; + } else jumpDown = false; } - }); - } + } + }); + } - @Override - @OnlyIn(Dist.CLIENT) - 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); - AccessoryRenderHelper.rotateIfSneaking(player); - boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty(); - GlStateManager.rotatef(180F, 1F, 0F, 0F); - GlStateManager.translatef(-0.2F, -0.3F, armor ? 0.2F : 0.15F); - GlStateManager.scalef(0.5F, 0.5F, 0.5F); + @Override + @OnlyIn(Dist.CLIENT) + public void doRender(ItemStack stack, EntityLivingBase player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); + AccessoryRenderHelper.rotateIfSneaking(player); + boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty(); + GlStateManager.rotatef(180F, 1F, 0F, 0F); + GlStateManager.translatef(-0.2F, -0.3F, armor ? 0.2F : 0.15F); + GlStateManager.scalef(0.5F, 0.5F, 0.5F); - TextureAtlasSprite gemIcon = stack.getItem() == ModItems.superCloudPendant - ? MiscellaneousIcons.INSTANCE.nimbusGem - : MiscellaneousIcons.INSTANCE.cirrusGem; - float f = gemIcon.getMinU(); - float f1 = gemIcon.getMaxU(); - float f2 = gemIcon.getMinV(); - float f3 = gemIcon.getMaxV(); - IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getWidth(), gemIcon.getHeight(), 1F / 32F); - } + TextureAtlasSprite gemIcon = stack.getItem() == ModItems.superCloudPendant + ? MiscellaneousIcons.INSTANCE.nimbusGem + : MiscellaneousIcons.INSTANCE.cirrusGem; + float f = gemIcon.getMinU(); + float f1 = gemIcon.getMaxU(); + float f2 = gemIcon.getMinV(); + float f3 = gemIcon.getMaxV(); + IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getWidth(), gemIcon.getHeight(), 1F / 32F); } public int getMaxAllowedJumps() { diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemDivaCharm.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemDivaCharm.java index aede2a531..c98a1f8ce 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemDivaCharm.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemDivaCharm.java @@ -26,20 +26,17 @@ import net.minecraft.item.ItemStack; import net.minecraft.server.MinecraftServer; import net.minecraft.util.SoundCategory; import net.minecraft.util.math.AxisAlignedBB; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.entity.living.LivingHurtEvent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.living.LivingHurtEvent; import net.minecraftforge.fml.server.ServerLifecycleHooks; -import top.theillusivec4.curios.api.CuriosAPI; import vazkii.botania.api.item.AccessoryRenderHelper; import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; -import vazkii.botania.common.Botania; import vazkii.botania.common.block.subtile.functional.SubTileHeiseiDream; +import vazkii.botania.common.core.handler.EquipmentHandler; import vazkii.botania.common.core.handler.ModSounds; -import vazkii.botania.common.integration.curios.CurioIntegration; -import vazkii.botania.common.integration.curios.RenderableCurio; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.network.PacketBotaniaEffect; import vazkii.botania.common.network.PacketHandler; @@ -54,11 +51,11 @@ public class ItemDivaCharm extends ItemBauble implements IManaUsingItem { } private void onEntityDamaged(LivingHurtEvent event) { - if (event.getSource().getImmediateSource() instanceof EntityPlayer && event.getEntityLiving() instanceof EntityLiving && !event.getEntityLiving().world.isRemote && Math.random() < 0.6F) { + if(event.getSource().getImmediateSource() instanceof EntityPlayer && event.getEntityLiving() instanceof EntityLiving && !event.getEntityLiving().world.isRemote && Math.random() < 0.6F) { Runnable lambda = () -> { EntityLiving target = (EntityLiving) event.getEntityLiving(); EntityPlayer player = (EntityPlayer) event.getSource().getImmediateSource(); - ItemStack amulet = Botania.curiosLoaded ? CurioIntegration.findOrEmpty(ModItems.divaCharm, player) : ItemStack.EMPTY; + ItemStack amulet = EquipmentHandler.findOrEmpty(ModItems.divaCharm, player); if(!amulet.isEmpty()) { final int cost = 250; @@ -96,21 +93,15 @@ public class ItemDivaCharm extends ItemBauble implements IManaUsingItem { return true; } - public static class Curio extends RenderableCurio { - public Curio(ItemStack stack) { - super(stack); - } - - @Override - @OnlyIn(Dist.CLIENT) - public void doRender(String identifier, EntityLivingBase player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { - AccessoryRenderHelper.translateToHeadLevel(player); - Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); - GlStateManager.scaled(0.8, 0.8, 0.8); - GlStateManager.rotatef(-90, 0, 1, 0); - GlStateManager.rotatef(180, 1, 0, 0); - GlStateManager.translated(0.1625, -1.625, 0.40); - Minecraft.getInstance().getItemRenderer().renderItem(stack, ItemCameraTransforms.TransformType.GROUND); - } + @Override + @OnlyIn(Dist.CLIENT) + public void doRender(ItemStack stack, EntityLivingBase player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + AccessoryRenderHelper.translateToHeadLevel(player); + Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); + GlStateManager.scaled(0.8, 0.8, 0.8); + GlStateManager.rotatef(-90, 0, 1, 0); + GlStateManager.rotatef(180, 1, 0, 0); + GlStateManager.translated(0.1625, -1.625, 0.40); + Minecraft.getInstance().getItemRenderer().renderItem(stack, ItemCameraTransforms.TransformType.GROUND); } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemDodgeRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemDodgeRing.java index 07c461e51..8c31ff7c1 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemDodgeRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemDodgeRing.java @@ -17,21 +17,16 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.math.MathHelper; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.client.event.InputEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.items.IItemHandler; -import top.theillusivec4.curios.api.CuriosAPI; import vazkii.botania.client.core.handler.ClientTickHandler; -import vazkii.botania.common.Botania; +import vazkii.botania.common.core.handler.EquipmentHandler; import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.core.helper.Vector3; -import vazkii.botania.common.integration.curios.BaseCurio; -import vazkii.botania.common.integration.curios.CurioIntegration; import vazkii.botania.common.item.ModItems; -import vazkii.botania.common.lib.LibItemNames; import vazkii.botania.common.lib.LibMisc; import vazkii.botania.common.network.PacketDodge; import vazkii.botania.common.network.PacketHandler; @@ -56,7 +51,7 @@ public class ItemDodgeRing extends ItemBauble { if(mc.player == null) return; - ItemStack ringStack = Botania.curiosLoaded ? CurioIntegration.findOrEmpty(ModItems.dodgeRing, mc.player) : ItemStack.EMPTY; + ItemStack ringStack = EquipmentHandler.findOrEmpty(ModItems.dodgeRing, mc.player); if(ringStack.isEmpty() || ItemNBTHelper.getInt(ringStack, TAG_DODGE_COOLDOWN, 0) > 0) return; @@ -79,17 +74,12 @@ public class ItemDodgeRing extends ItemBauble { oldRightDown = mc.gameSettings.keyBindRight.isKeyDown(); } - public static class Curio extends BaseCurio { - public Curio(ItemStack stack) { - super(stack); - } - @Override - public void onCurioTick(String identifier, EntityLivingBase player) { - int cd = ItemNBTHelper.getInt(stack, TAG_DODGE_COOLDOWN, 0); - if(cd > 0) - ItemNBTHelper.setInt(stack, TAG_DODGE_COOLDOWN, cd - 1); - } + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + int cd = ItemNBTHelper.getInt(stack, TAG_DODGE_COOLDOWN, 0); + if(cd > 0) + ItemNBTHelper.setInt(stack, TAG_DODGE_COOLDOWN, cd - 1); } private static void dodge(EntityPlayer player, boolean left) { diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemFlightTiara.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemFlightTiara.java index 35c407643..9ca17d5d5 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemFlightTiara.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemFlightTiara.java @@ -30,14 +30,13 @@ import net.minecraft.util.SoundCategory; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.world.World; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.PlayerEvent; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; import org.lwjgl.opengl.GL11; -import top.theillusivec4.curios.api.CuriosAPI; import vazkii.botania.api.item.AccessoryRenderHelper; import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; @@ -48,12 +47,11 @@ import vazkii.botania.client.core.helper.ShaderHelper; import vazkii.botania.client.lib.LibResources; import vazkii.botania.common.Botania; import vazkii.botania.common.core.handler.ConfigHandler; +import vazkii.botania.common.core.handler.EquipmentHandler; import vazkii.botania.common.core.handler.ModSounds; import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.core.helper.StringObfuscator; import vazkii.botania.common.core.helper.Vector3; -import vazkii.botania.common.integration.curios.CurioIntegration; -import vazkii.botania.common.integration.curios.RenderableCurio; import vazkii.botania.common.item.ModItems; import javax.annotation.Nonnull; @@ -109,7 +107,7 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem { public void updatePlayerFlyStatus(LivingUpdateEvent event) { if(event.getEntityLiving() instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.getEntityLiving(); - ItemStack tiara = Botania.curiosLoaded ? CurioIntegration.findOrEmpty(ModItems.flightTiara, player) : ItemStack.EMPTY; + ItemStack tiara = EquipmentHandler.findOrEmpty(ModItems.flightTiara, player); int left = ItemNBTHelper.getInt(tiara, TAG_TIME_LEFT, MAX_FLY_TIME); if(playersWithFlight.contains(playerStr(player))) { @@ -208,7 +206,7 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem { } private boolean shouldPlayerHaveFlight(EntityPlayer player) { - ItemStack armor = Botania.curiosLoaded ? CurioIntegration.findOrEmpty(ModItems.flightTiara, player) : ItemStack.EMPTY; + ItemStack armor = EquipmentHandler.findOrEmpty(ModItems.flightTiara, player); if(!armor.isEmpty()) { int left = ItemNBTHelper.getInt(armor, TAG_TIME_LEFT, MAX_FLY_TIME); boolean flying = ItemNBTHelper.getBoolean(armor, TAG_FLYING, false); @@ -227,216 +225,210 @@ public class ItemFlightTiara extends ItemBauble implements IManaUsingItem { return true; } - public static class Curio extends RenderableCurio { - public Curio(ItemStack stack) { - super(stack); + @Override + public void onEquipped(ItemStack stack, EntityLivingBase living) { + super.onEquipped(stack, living); + int variant = ItemNBTHelper.getInt(stack, TAG_VARIANT, 0); + if(variant != WING_TYPES && StringObfuscator.matchesHash(stack.getDisplayName().getString(), SUPER_AWESOME_HASH)) { + ItemNBTHelper.setInt(stack, TAG_VARIANT, WING_TYPES); + stack.clearCustomName(); } + } - @Override - public void onEquipped(String identifier, EntityLivingBase living) { - super.onEquipped(identifier, living); - int variant = ItemNBTHelper.getInt(stack, TAG_VARIANT, 0); - if(variant != WING_TYPES && StringObfuscator.matchesHash(stack.getDisplayName().getString(), SUPER_AWESOME_HASH)) { - ItemNBTHelper.setInt(stack, TAG_VARIANT, WING_TYPES); - stack.clearCustomName(); + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + if(player instanceof EntityPlayer) { + EntityPlayer p = (EntityPlayer) player; + boolean flying = p.abilities.isFlying; + + boolean wasSprting = ItemNBTHelper.getBoolean(stack, TAG_IS_SPRINTING, false); + boolean isSprinting = p.isSprinting(); + if(isSprinting != wasSprting) + ItemNBTHelper.setBoolean(stack, TAG_IS_SPRINTING, isSprinting); + + int time = ItemNBTHelper.getInt(stack, TAG_TIME_LEFT, MAX_FLY_TIME); + int newTime = time; + Vector3 look = new Vector3(p.getLookVec()).multiply(1, 0, 1).normalize(); + + if(flying) { + if(time > 0 && !ItemNBTHelper.getBoolean(stack, TAG_INFINITE_FLIGHT, false)) + newTime--; + final int maxCd = 80; + int cooldown = ItemNBTHelper.getInt(stack, TAG_DASH_COOLDOWN, 0); + if(!wasSprting && isSprinting && cooldown == 0) { + p.motionX += look.x; + p.motionZ += look.z; + p.world.playSound(null, p.posX, p.posY, p.posZ, ModSounds.dash, SoundCategory.PLAYERS, 1F, 1F); + ItemNBTHelper.setInt(stack, TAG_DASH_COOLDOWN, maxCd); + } else if(cooldown > 0) { + if(maxCd - cooldown < 2) + player.moveRelative(0F, 0F, 1F, 5F); + else if(maxCd - cooldown < 10) + player.setSprinting(false); + ItemNBTHelper.setInt(stack, TAG_DASH_COOLDOWN, cooldown - 2); + } + } else if(!flying) { + boolean doGlide = player.isSneaking() && !player.onGround && player.fallDistance >= 2F; + if(time < MAX_FLY_TIME && player.ticksExisted % (doGlide ? 6 : 2) == 0) + newTime++; + + if(doGlide) { + player.motionY = Math.max(-0.15F, player.motionY); + float mul = 0.6F; + player.motionX = look.x * mul; + player.motionZ = look.z * mul; + player.fallDistance = 2F; + } } + + ItemNBTHelper.setBoolean(stack, TAG_FLYING, flying); + if(newTime != time) + ItemNBTHelper.setInt(stack, TAG_TIME_LEFT, newTime); } + } - @Override - public void onCurioTick(String identifier, EntityLivingBase player) { - if(player instanceof EntityPlayer) { - EntityPlayer p = (EntityPlayer) player; - boolean flying = p.abilities.isFlying; + @Override + public boolean shouldSyncToTracking(ItemStack stack, EntityLivingBase living) { + return true; + } - boolean wasSprting = ItemNBTHelper.getBoolean(stack, TAG_IS_SPRINTING, false); - boolean isSprinting = p.isSprinting(); - if(isSprinting != wasSprting) - ItemNBTHelper.setBoolean(stack, TAG_IS_SPRINTING, isSprinting); + @Override + public boolean hasRender(ItemStack stack, EntityLivingBase living) { + return super.hasRender(stack, living) && living instanceof EntityPlayer; + } - int time = ItemNBTHelper.getInt(stack, TAG_TIME_LEFT, MAX_FLY_TIME); - int newTime = time; - Vector3 look = new Vector3(p.getLookVec()).multiply(1, 0, 1).normalize(); + @Override + @OnlyIn(Dist.CLIENT) + public void doRender(ItemStack stack, EntityLivingBase player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + int meta = ItemNBTHelper.getInt(stack, TAG_VARIANT, 0); + if(meta > 0 && meta <= MiscellaneousIcons.INSTANCE.tiaraWingIcons.length) { + TextureAtlasSprite icon = MiscellaneousIcons.INSTANCE.tiaraWingIcons[meta - 1]; + Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); - if(flying) { - if(time > 0 && !ItemNBTHelper.getBoolean(stack, TAG_INFINITE_FLIGHT, false)) - newTime--; - final int maxCd = 80; - int cooldown = ItemNBTHelper.getInt(stack, TAG_DASH_COOLDOWN, 0); - if(!wasSprting && isSprinting && cooldown == 0) { - p.motionX += look.x; - p.motionZ += look.z; - p.world.playSound(null, p.posX, p.posY, p.posZ, ModSounds.dash, SoundCategory.PLAYERS, 1F, 1F); - ItemNBTHelper.setInt(stack, TAG_DASH_COOLDOWN, maxCd); - } else if(cooldown > 0) { - if(maxCd - cooldown < 2) - player.moveRelative(0F, 0F, 1F, 5F); - else if(maxCd - cooldown < 10) - player.setSprinting(false); - ItemNBTHelper.setInt(stack, TAG_DASH_COOLDOWN, cooldown - 2); - } - } else if(!flying) { - boolean doGlide = player.isSneaking() && !player.onGround && player.fallDistance >= 2F; - if(time < MAX_FLY_TIME && player.ticksExisted % (doGlide ? 6 : 2) == 0) - newTime++; + boolean flying = ((EntityPlayer) player).abilities.isFlying; - if(doGlide) { - player.motionY = Math.max(-0.15F, player.motionY); - float mul = 0.6F; - player.motionX = look.x * mul; - player.motionZ = look.z * mul; - player.fallDistance = 2F; - } - } + float rz = 120F; + float rx = 20F + (float) ((Math.sin((double) (player.ticksExisted + partialTicks) * (flying ? 0.4F : 0.2F)) + 0.5F) * (flying ? 30F : 5F)); + float ry = 0F; + float h = 0.2F; + float i = 0.15F; + float s = 1F; - ItemNBTHelper.setBoolean(stack, TAG_FLYING, flying); - if(newTime != time) - ItemNBTHelper.setInt(stack, TAG_TIME_LEFT, newTime); + GlStateManager.pushMatrix(); + GlStateManager.enableBlend(); + GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GlStateManager.color4f(1F, 1F, 1F, 1F); + + int light = 15728880; + int lightmapX = light % 65536; + int lightmapY = light / 65536; + + float lbx = OpenGlHelper.lastBrightnessX; + float lby = OpenGlHelper.lastBrightnessY; + + switch (meta) { + case 1: { // Jibril + h = 0.4F; + break; + } + case 2: { // Sephiroth + s = 1.3F; + break; + } + case 3: { // Cirno + h = -0.1F; + rz = 0F; + rx = 0F; + i = 0.3F; + break; + } + case 4: { // Phoenix + rz = 180F; + h = 0.5F; + rx = 20F; + ry = -(float) ((Math.sin((double) (player.ticksExisted + partialTicks) * (flying ? 0.4F : 0.2F)) + 0.6F) * (flying ? 30F : 5F)); + OpenGlHelper.glMultiTexCoord2f(OpenGlHelper.GL_TEXTURE1, lightmapX, lightmapY); + break; + } + case 5: { // Kuroyukihime + h = 0.8F; + rz = 180F; + ry = -rx; + rx = 0F; + s = 2F; + break; + } + case 6: { // Random Devil + rz = 150F; + break; + } + case 7: { // Lyfa + OpenGlHelper.glMultiTexCoord2f(OpenGlHelper.GL_TEXTURE1, lightmapX, lightmapY); + h = -0.1F; + rz = 0F; + ry = -rx; + rx = 0F; + GlStateManager.color4f(1F, 1F, 1F, 0.5F + (float) Math.cos((double) (player.ticksExisted + partialTicks) * 0.3F) * 0.2F); + break; + } + case 8: { // Mega Ultra Chicken + h = 0.1F; + break; + } + case 9: { // The One + OpenGlHelper.glMultiTexCoord2f(OpenGlHelper.GL_TEXTURE1, lightmapX, lightmapY); + rz = 180F; + rx = 0F; + h = 1.1F; + ry = -(float) ((Math.sin((double) (player.ticksExisted + partialTicks) * 0.2F) + 0.6F) * (flying ? 12F : 5F)); + GlStateManager.color4f(1F, 1F, 1F, 0.5F + (flying ? (float) Math.cos((double) (player.ticksExisted + partialTicks) * 0.3F) * 0.25F + 0.25F : 0F)); + } } - } - @Override - public boolean shouldSyncToTracking(String identifier, EntityLivingBase living) { - return true; - } + // account for padding in the texture + float mul = 32F / 20F; + s *= mul; - @Override - public boolean hasRender(String identifier, EntityLivingBase living) { - return super.hasRender(identifier, living) && living instanceof EntityPlayer; - } + float f = icon.getMinU(); + float f1 = icon.getMaxU(); + float f2 = icon.getMinV(); + float f3 = icon.getMaxV(); + float sr = 1F / s; - @Override - @OnlyIn(Dist.CLIENT) - public void doRender(String identifier, EntityLivingBase player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { - int meta = ItemNBTHelper.getInt(stack, TAG_VARIANT, 0); - if(meta > 0 && meta <= MiscellaneousIcons.INSTANCE.tiaraWingIcons.length) { - TextureAtlasSprite icon = MiscellaneousIcons.INSTANCE.tiaraWingIcons[meta - 1]; - Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); + AccessoryRenderHelper.rotateIfSneaking(player); - boolean flying = ((EntityPlayer) player).abilities.isFlying; + GlStateManager.translatef(0F, h, i); - float rz = 120F; - float rx = 20F + (float) ((Math.sin((double) (player.ticksExisted + partialTicks) * (flying ? 0.4F : 0.2F)) + 0.5F) * (flying ? 30F : 5F)); - float ry = 0F; - float h = 0.2F; - float i = 0.15F; - float s = 1F; - - GlStateManager.pushMatrix(); - GlStateManager.enableBlend(); - GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GlStateManager.color4f(1F, 1F, 1F, 1F); - - int light = 15728880; - int lightmapX = light % 65536; - int lightmapY = light / 65536; - - float lbx = OpenGlHelper.lastBrightnessX; - float lby = OpenGlHelper.lastBrightnessY; - - switch(meta) { - case 1 : { // Jibril - h = 0.4F; - break; - } - case 2 : { // Sephiroth - s = 1.3F; - break; - } - case 3 : { // Cirno - h = -0.1F; - rz = 0F; - rx = 0F; - i = 0.3F; - break; - } - case 4 : { // Phoenix - rz = 180F; - h = 0.5F; - rx = 20F; - ry = -(float) ((Math.sin((double) (player.ticksExisted + partialTicks) * (flying ? 0.4F : 0.2F)) + 0.6F) * (flying ? 30F : 5F)); - OpenGlHelper.glMultiTexCoord2f(OpenGlHelper.GL_TEXTURE1, lightmapX, lightmapY); - break; - } - case 5 : { // Kuroyukihime - h = 0.8F; - rz = 180F; - ry = -rx; - rx = 0F; - s = 2F; - break; - } - case 6 : { // Random Devil - rz = 150F; - break; - } - case 7 : { // Lyfa - OpenGlHelper.glMultiTexCoord2f(OpenGlHelper.GL_TEXTURE1, lightmapX, lightmapY); - h = -0.1F; - rz = 0F; - ry = -rx; - rx = 0F; - GlStateManager.color4f(1F, 1F, 1F, 0.5F + (float) Math.cos((double) (player.ticksExisted + partialTicks) * 0.3F) * 0.2F); - break; - } - case 8 : { // Mega Ultra Chicken - h = 0.1F; - break; - } - case 9 : { // The One - OpenGlHelper.glMultiTexCoord2f(OpenGlHelper.GL_TEXTURE1, lightmapX, lightmapY); - rz = 180F; - rx = 0F; - h = 1.1F; - ry = -(float) ((Math.sin((double) (player.ticksExisted + partialTicks) * 0.2F) + 0.6F) * (flying ? 12F : 5F)); - GlStateManager.color4f(1F, 1F, 1F, 0.5F + (flying ? (float) Math.cos((double) (player.ticksExisted + partialTicks) * 0.3F) * 0.25F + 0.25F : 0F)); - } - } - - // account for padding in the texture - float mul = 32F / 20F; - s *= mul; - - float f = icon.getMinU(); - float f1 = icon.getMaxU(); - float f2 = icon.getMinV(); - float f3 = icon.getMaxV(); - float sr = 1F / s; - - AccessoryRenderHelper.rotateIfSneaking(player); - - GlStateManager.translatef(0F, h, i); + GlStateManager.rotatef(rz, 0F, 0F, 1F); + GlStateManager.rotatef(rx, 1F, 0F, 0F); + GlStateManager.rotatef(ry, 0F, 1F, 0F); + GlStateManager.scalef(s, s, s); + IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, icon.getWidth(), icon.getHeight(), 1F / 32F); + GlStateManager.scalef(sr, sr, sr); + GlStateManager.rotatef(-ry, 0F, 1F, 0F); + GlStateManager.rotatef(-rx, 1F, 0F, 0F); + GlStateManager.rotatef(-rz, 0F, 0F, 1F); + if(meta != 2) { // Sephiroth + GlStateManager.scalef(-1F, 1F, 1F); GlStateManager.rotatef(rz, 0F, 0F, 1F); GlStateManager.rotatef(rx, 1F, 0F, 0F); GlStateManager.rotatef(ry, 0F, 1F, 0F); GlStateManager.scalef(s, s, s); IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, icon.getWidth(), icon.getHeight(), 1F / 32F); GlStateManager.scalef(sr, sr, sr); - GlStateManager.rotatef(-ry, 0F, 1F, 0F); + GlStateManager.rotatef(-ry, 1F, 0F, 0F); GlStateManager.rotatef(-rx, 1F, 0F, 0F); GlStateManager.rotatef(-rz, 0F, 0F, 1F); - - if(meta != 2) { // Sephiroth - GlStateManager.scalef(-1F, 1F, 1F); - GlStateManager.rotatef(rz, 0F, 0F, 1F); - GlStateManager.rotatef(rx, 1F, 0F, 0F); - GlStateManager.rotatef(ry, 0F, 1F, 0F); - GlStateManager.scalef(s, s, s); - IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, icon.getWidth(), icon.getHeight(), 1F / 32F); - GlStateManager.scalef(sr, sr, sr); - GlStateManager.rotatef(-ry, 1F, 0F, 0F); - GlStateManager.rotatef(-rx, 1F, 0F, 0F); - GlStateManager.rotatef(-rz, 0F, 0F, 1F); - } - - GlStateManager.color3f(1F, 1F, 1F); - GlStateManager.popMatrix(); - - OpenGlHelper.glMultiTexCoord2f(OpenGlHelper.GL_TEXTURE1, lbx, lby); - - if(meta == 1) - renderHalo(player, partialTicks); } + + GlStateManager.color3f(1F, 1F, 1F); + GlStateManager.popMatrix(); + + OpenGlHelper.glMultiTexCoord2f(OpenGlHelper.GL_TEXTURE1, lbx, lby); + + if(meta == 1) + renderHalo(player, partialTicks); } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGoddessCharm.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGoddessCharm.java index 3b6c69bc4..dacf72d01 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGoddessCharm.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGoddessCharm.java @@ -19,18 +19,15 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.Vec3d; import net.minecraft.world.Explosion; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.event.world.ExplosionEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import top.theillusivec4.curios.api.CuriosAPI; import vazkii.botania.api.item.AccessoryRenderHelper; import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; -import vazkii.botania.common.Botania; -import vazkii.botania.common.integration.curios.CurioIntegration; -import vazkii.botania.common.integration.curios.RenderableCurio; +import vazkii.botania.common.core.handler.EquipmentHandler; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.lib.LibMisc; @@ -52,7 +49,7 @@ public class ItemGoddessCharm extends ItemBauble implements IManaUsingItem { List players = event.getWorld().getEntitiesWithinAABB(EntityPlayer.class, new AxisAlignedBB(vec.x, vec.y, vec.z, vec.x, vec.y, vec.z).grow(8)); for(EntityPlayer player : players) { - ItemStack charm = Botania.curiosLoaded ? CurioIntegration.findOrEmpty(ModItems.goddessCharm, player) : ItemStack.EMPTY; + ItemStack charm = EquipmentHandler.findOrEmpty(ModItems.goddessCharm, player); if(!charm.isEmpty() && ManaItemHandler.requestManaExact(charm, player, COST, true)) { event.getAffectedBlocks().clear(); return; @@ -60,23 +57,17 @@ public class ItemGoddessCharm extends ItemBauble implements IManaUsingItem { } } - public static class Curio extends RenderableCurio { - public Curio(ItemStack stack) { - super(stack); - } - - @Override - @OnlyIn(Dist.CLIENT) - public void doRender(String identifier, EntityLivingBase player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { - GlStateManager.pushMatrix(); - AccessoryRenderHelper.translateToHeadLevel(player); - AccessoryRenderHelper.translateToFace(); - AccessoryRenderHelper.defaultTransforms(); - GlStateManager.rotatef(-90F, 0F, 1F, 0F); - GlStateManager.translatef(0.5F, 0.2F, 0.45F); - Minecraft.getInstance().getItemRenderer().renderItem(stack, ItemCameraTransforms.TransformType.NONE); - GlStateManager.popMatrix(); - } + @Override + @OnlyIn(Dist.CLIENT) + public void doRender(ItemStack stack, EntityLivingBase player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + GlStateManager.pushMatrix(); + AccessoryRenderHelper.translateToHeadLevel(player); + AccessoryRenderHelper.translateToFace(); + AccessoryRenderHelper.defaultTransforms(); + GlStateManager.rotatef(-90F, 0F, 1F, 0F); + GlStateManager.translatef(0.5F, 0.2F, 0.45F); + Minecraft.getInstance().getItemRenderer().renderItem(stack, ItemCameraTransforms.TransformType.NONE); + GlStateManager.popMatrix(); } @Override diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterAuraRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterAuraRing.java index 10657e1cd..f06b73d2d 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterAuraRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterAuraRing.java @@ -15,7 +15,6 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import vazkii.botania.api.mana.IManaGivingItem; import vazkii.botania.api.mana.ManaItemHandler; -import vazkii.botania.common.integration.curios.BaseCurio; public class ItemGreaterAuraRing extends ItemBauble implements IManaGivingItem { @@ -23,15 +22,9 @@ public class ItemGreaterAuraRing extends ItemBauble implements IManaGivingItem { super(props); } - public static class Curio extends BaseCurio { - public Curio(ItemStack stack) { - super(stack); - } - - @Override - public void onCurioTick(String identifier, EntityLivingBase player) { - if(player instanceof EntityPlayer && player.ticksExisted % 2 == 0) - ManaItemHandler.dispatchManaExact(stack, (EntityPlayer) player, 1, true); - } + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + if (player instanceof EntityPlayer && player.ticksExisted % 2 == 0) + ManaItemHandler.dispatchManaExact(stack, (EntityPlayer) player, 1, true); } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterMagnetRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterMagnetRing.java index ad8afa26b..31b3c5994 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterMagnetRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterMagnetRing.java @@ -10,8 +10,6 @@ */ package vazkii.botania.common.item.equipment.bauble; -import vazkii.botania.common.lib.LibItemNames; - public class ItemGreaterMagnetRing extends ItemMagnetRing { public ItemGreaterMagnetRing(Properties props) { diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterManaRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterManaRing.java index 6f0c4c445..a1fcbd087 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterManaRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemGreaterManaRing.java @@ -11,7 +11,6 @@ package vazkii.botania.common.item.equipment.bauble; import net.minecraft.item.ItemStack; -import vazkii.botania.common.lib.LibItemNames; public class ItemGreaterManaRing extends ItemManaRing { diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemHolyCloak.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemHolyCloak.java index aa0bb7d18..c994ec0b9 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemHolyCloak.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemHolyCloak.java @@ -19,19 +19,17 @@ import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundCategory; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.entity.living.LivingHurtEvent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import top.theillusivec4.curios.api.CuriosAPI; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.event.entity.living.LivingHurtEvent; import vazkii.botania.api.item.AccessoryRenderHelper; import vazkii.botania.client.lib.LibResources; import vazkii.botania.client.model.ModelCloak; import vazkii.botania.common.Botania; +import vazkii.botania.common.core.handler.EquipmentHandler; import vazkii.botania.common.core.handler.ModSounds; import vazkii.botania.common.core.helper.ItemNBTHelper; -import vazkii.botania.common.integration.curios.CurioIntegration; -import vazkii.botania.common.integration.curios.RenderableCurio; public class ItemHolyCloak extends ItemBauble { @@ -52,7 +50,7 @@ public class ItemHolyCloak extends ItemBauble { private void onPlayerDamage(LivingHurtEvent event) { if(event.getEntityLiving() instanceof EntityPlayer && !event.getSource().canHarmInCreative()) { EntityPlayer player = (EntityPlayer) event.getEntityLiving(); - ItemStack stack = Botania.curiosLoaded ? CurioIntegration.findOrEmpty(s -> s.getItem() instanceof ItemHolyCloak, player) : ItemStack.EMPTY; + ItemStack stack = EquipmentHandler.findOrEmpty(this, player); if(!stack.isEmpty() && !isInEffect(stack)) { ItemHolyCloak cloak = (ItemHolyCloak) stack.getItem(); @@ -67,44 +65,38 @@ public class ItemHolyCloak extends ItemBauble { } } - public static class Curio extends RenderableCurio { - public Curio(ItemStack stack) { - super(stack); - } + @Override + public void onWornTick(ItemStack stack, EntityLivingBase living) { + int cooldown = getCooldown(stack); + if(cooldown > 0) + setCooldown(stack, cooldown - 1); + } - @Override - public void onCurioTick(String identifier, EntityLivingBase living) { - int cooldown = getCooldown(stack); - if(cooldown > 0) - setCooldown(stack, cooldown - 1); - } + @Override + @OnlyIn(Dist.CLIENT) + public void doRender(ItemStack stack, EntityLivingBase player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + ItemHolyCloak item = ((ItemHolyCloak) stack.getItem()); + AccessoryRenderHelper.rotateIfSneaking(player); + boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty(); + GlStateManager.translatef(0F, armor ? -0.07F : -0.01F, 0F); - @Override - @OnlyIn(Dist.CLIENT) - public void doRender(String identifier, EntityLivingBase player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { - ItemHolyCloak item = ((ItemHolyCloak) stack.getItem()); - AccessoryRenderHelper.rotateIfSneaking(player); - boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty(); - GlStateManager.translatef(0F, armor ? -0.07F : -0.01F, 0F); + float s = 1F / 16F; + GlStateManager.scalef(s, s, s); + if(model == null) + model = new ModelCloak(); - float s = 1F / 16F; - GlStateManager.scalef(s, s, s); - if(model == null) - model = new ModelCloak(); + GlStateManager.enableLighting(); + GlStateManager.enableRescaleNormal(); - GlStateManager.enableLighting(); - GlStateManager.enableRescaleNormal(); + Minecraft.getInstance().textureManager.bindTexture(item.getCloakTexture()); + model.render(1F); - Minecraft.getInstance().textureManager.bindTexture(item.getCloakTexture()); - model.render(1F); - - int light = 15728880; - int lightmapX = light % 65536; - int lightmapY = light / 65536; - OpenGlHelper.glMultiTexCoord2f(OpenGlHelper.GL_TEXTURE1, lightmapX, lightmapY); - Minecraft.getInstance().textureManager.bindTexture(item.getCloakGlowTexture()); - model.render(1F); - } + int light = 15728880; + int lightmapX = light % 65536; + int lightmapY = light / 65536; + OpenGlHelper.glMultiTexCoord2f(OpenGlHelper.GL_TEXTURE1, lightmapX, lightmapY); + Minecraft.getInstance().textureManager.bindTexture(item.getCloakGlowTexture()); + model.render(1F); } public boolean effectOnDamage(LivingHurtEvent event, EntityPlayer player, ItemStack stack) { diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemIcePendant.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemIcePendant.java index 9dcabf0c9..f46732b54 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemIcePendant.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemIcePendant.java @@ -25,8 +25,6 @@ import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import vazkii.botania.client.core.handler.MiscellaneousIcons; import vazkii.botania.client.core.helper.IconHelper; -import vazkii.botania.common.integration.curios.BaseCurio; -import vazkii.botania.common.integration.curios.RenderableCurio; public class ItemIcePendant extends ItemBauble { @@ -34,38 +32,32 @@ public class ItemIcePendant extends ItemBauble { super(props); } - public static class Curio extends RenderableCurio { - public Curio(ItemStack stack) { - super(stack); - } - - @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 - @OnlyIn(Dist.CLIENT) - 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); - boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty(); - GlStateManager.rotatef(180F, 1F, 0F, 0F); - GlStateManager.translatef(-0.36F, -0.3F, armor ? 0.2F : 0.15F); - GlStateManager.rotatef(-45F, 0F, 0F, 1F); - GlStateManager.scalef(0.5F, 0.5F, 0.5F); - - TextureAtlasSprite gemIcon = MiscellaneousIcons.INSTANCE.snowflakePendantGem; - float f = gemIcon.getMinU(); - float f1 = gemIcon.getMaxU(); - float f2 = gemIcon.getMinV(); - float f3 = gemIcon.getMaxV(); - IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getWidth(), gemIcon.getHeight(), 1F / 32F); + @Override + public void onWornTick(ItemStack stack, 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 + @OnlyIn(Dist.CLIENT) + public void doRender(ItemStack stack, EntityLivingBase player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); + boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty(); + GlStateManager.rotatef(180F, 1F, 0F, 0F); + GlStateManager.translatef(-0.36F, -0.3F, armor ? 0.2F : 0.15F); + GlStateManager.rotatef(-45F, 0F, 0F, 1F); + GlStateManager.scalef(0.5F, 0.5F, 0.5F); + + TextureAtlasSprite gemIcon = MiscellaneousIcons.INSTANCE.snowflakePendantGem; + float f = gemIcon.getMinU(); + float f1 = gemIcon.getMaxU(); + float f2 = gemIcon.getMinV(); + float f3 = gemIcon.getMaxV(); + IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getWidth(), gemIcon.getHeight(), 1F / 32F); + } + } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemInvisibilityCloak.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemInvisibilityCloak.java index 52777bf10..654193b19 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemInvisibilityCloak.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemInvisibilityCloak.java @@ -17,8 +17,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.potion.PotionEffect; import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; -import vazkii.botania.common.integration.curios.BaseCurio; -import vazkii.botania.common.lib.LibItemNames; public class ItemInvisibilityCloak extends ItemBauble implements IManaUsingItem { @@ -26,31 +24,25 @@ public class ItemInvisibilityCloak extends ItemBauble implements IManaUsingItem super(props); } - public static class Curio extends BaseCurio { - public Curio(ItemStack stack) { - super(stack); - } + @Override + public void onUnequipped(ItemStack stack, EntityLivingBase player) { + PotionEffect effect = player.getActivePotionEffect(MobEffects.INVISIBILITY); + if(effect != null && player instanceof EntityPlayer && effect.getAmplifier() == -42) + player.removePotionEffect(MobEffects.INVISIBILITY); + } - @Override - public void onUnequipped(String identifier, EntityLivingBase player) { - PotionEffect effect = player.getActivePotionEffect(MobEffects.INVISIBILITY); - if(effect != null && player instanceof EntityPlayer && effect.getAmplifier() == -42) - player.removePotionEffect(MobEffects.INVISIBILITY); - } + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + if(player instanceof EntityPlayer && !player.world.isRemote) { + int manaCost = 2; + boolean hasMana = ManaItemHandler.requestManaExact(stack, (EntityPlayer) player, manaCost, false); + if(!hasMana) + onUnequipped(stack, player); + else { + if(player.getActivePotionEffect(MobEffects.INVISIBILITY) != null) + player.removePotionEffect(MobEffects.INVISIBILITY); - @Override - public void onCurioTick(String identifier, EntityLivingBase player) { - if(player instanceof EntityPlayer && !player.world.isRemote) { - int manaCost = 2; - boolean hasMana = ManaItemHandler.requestManaExact(stack, (EntityPlayer) player, manaCost, false); - if(!hasMana) - onUnequipped(identifier, player); - else { - if(player.getActivePotionEffect(MobEffects.INVISIBILITY) != null) - player.removePotionEffect(MobEffects.INVISIBILITY); - - player.addPotionEffect(new PotionEffect(MobEffects.INVISIBILITY, Integer.MAX_VALUE, -42, true, true)); - } + player.addPotionEffect(new PotionEffect(MobEffects.INVISIBILITY, Integer.MAX_VALUE, -42, true, true)); } } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemItemFinder.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemItemFinder.java index d0e2ec80f..89bdaa7c5 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemItemFinder.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemItemFinder.java @@ -31,9 +31,9 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.village.MerchantRecipe; -import net.minecraftforge.common.util.Constants; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.common.util.Constants; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.IItemHandler; @@ -44,8 +44,6 @@ import vazkii.botania.client.core.handler.MiscellaneousIcons; import vazkii.botania.client.core.helper.IconHelper; import vazkii.botania.common.Botania; import vazkii.botania.common.core.helper.ItemNBTHelper; -import vazkii.botania.common.integration.curios.RenderableCurio; -import vazkii.botania.common.item.ModItems; import java.util.ArrayList; import java.util.Collection; @@ -60,43 +58,37 @@ public class ItemItemFinder extends ItemBauble { super(props); } - public static class Curio extends RenderableCurio { - public Curio(ItemStack stack) { - super(stack); - } + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + if(!(player instanceof EntityPlayer)) + return; - @Override - public void onCurioTick(String identifier, EntityLivingBase player) { - if(!(player instanceof EntityPlayer)) - return; + if(player.world.isRemote) + this.tickClient(stack, (EntityPlayer) player); + else this.tickServer(stack, (EntityPlayer) player); + } - if(player.world.isRemote) - ((ItemItemFinder) ModItems.itemFinder).tickClient(stack, (EntityPlayer) player); - else ((ItemItemFinder) ModItems.itemFinder).tickServer(stack, (EntityPlayer) player); - } + @Override + public boolean shouldSyncToTracking(ItemStack stack, EntityLivingBase living) { + return true; + } - @Override - public boolean shouldSyncToTracking(String identifier, EntityLivingBase living) { - return true; - } - - @Override - @OnlyIn(Dist.CLIENT) - public void doRender(String identifier, EntityLivingBase living, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { - TextureAtlasSprite gemIcon = MiscellaneousIcons.INSTANCE.itemFinderGem; - float f = gemIcon.getMinU(); - float f1 = gemIcon.getMaxU(); - float f2 = gemIcon.getMinV(); - float f3 = gemIcon.getMaxV(); - boolean armor = !living.getItemStackFromSlot(EntityEquipmentSlot.HEAD).isEmpty(); - AccessoryRenderHelper.translateToHeadLevel(living); - Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); - GlStateManager.rotatef(90F, 0F, 1F, 0F); - GlStateManager.rotatef(180F, 1F, 0F, 0F); - GlStateManager.translatef(-0.4F, -1.4F, armor ? -0.3F : -0.25F); - GlStateManager.scalef(0.75F, 0.75F, 0.75F); - IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getWidth(), gemIcon.getHeight(), 1F / 16F); - } + @Override + @OnlyIn(Dist.CLIENT) + public void doRender(ItemStack stack, EntityLivingBase living, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + TextureAtlasSprite gemIcon = MiscellaneousIcons.INSTANCE.itemFinderGem; + float f = gemIcon.getMinU(); + float f1 = gemIcon.getMaxU(); + float f2 = gemIcon.getMinV(); + float f3 = gemIcon.getMaxV(); + boolean armor = !living.getItemStackFromSlot(EntityEquipmentSlot.HEAD).isEmpty(); + AccessoryRenderHelper.translateToHeadLevel(living); + Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); + GlStateManager.rotatef(90F, 0F, 1F, 0F); + GlStateManager.rotatef(180F, 1F, 0F, 0F); + GlStateManager.translatef(-0.4F, -1.4F, armor ? -0.3F : -0.25F); + GlStateManager.scalef(0.75F, 0.75F, 0.75F); + IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getWidth(), gemIcon.getHeight(), 1F / 16F); } protected void tickClient(ItemStack stack, EntityPlayer player) { @@ -114,7 +106,7 @@ public class ItemItemFinder extends ItemBauble { int[] entities = ItemNBTHelper.getIntArray(stack, TAG_ENTITY_POSITIONS); for(int i : entities) { - Entity e = player.world.getEntityByID(i); + Entity e = player.world.getEntityByID(i); if(e != null && Math.random() < 0.6) { Botania.proxy.setWispFXDepthTest(Math.random() < 0.6); Botania.proxy.wispFX(e.posX + (float) (Math.random() * 0.5 - 0.25) * 0.45F, e.posY + e.height, e.posZ + (float) (Math.random() * 0.5 - 0.25) * 0.45F, (float) Math.random(), (float) Math.random(), (float) Math.random(), 0.15F + 0.05F * (float) Math.random(), -0.05F - 0.03F * (float) Math.random()); diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemKnockbackBelt.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemKnockbackBelt.java index f9f630375..bdfaedeb8 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemKnockbackBelt.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemKnockbackBelt.java @@ -23,7 +23,6 @@ import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import vazkii.botania.client.lib.LibResources; -import vazkii.botania.common.integration.curios.RenderableCurio; public class ItemKnockbackBelt extends ItemBauble { @@ -34,32 +33,26 @@ public class ItemKnockbackBelt extends ItemBauble { super(props); } - public static class Curio extends RenderableCurio { - public Curio(ItemStack stack) { - super(stack); - } + @Override + public Multimap getEquippedAttributeModifiers(ItemStack stack) { + Multimap attributes = HashMultimap.create(); + attributes.put(SharedMonsterAttributes.KNOCKBACK_RESISTANCE.getName(), new AttributeModifier(getBaubleUUID(stack), "Knockback Belt", 1, 0).setSaved(false)); + return attributes; + } - @Override - public Multimap getAttributeModifiers(String identifier) { - Multimap 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 doRender(ItemStack stack, EntityLivingBase living, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + Minecraft.getInstance().textureManager.bindTexture(texture); - @Override - @OnlyIn(Dist.CLIENT) - 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); + GlStateManager.translatef(0F, 0.2F, 0F); - GlStateManager.translatef(0F, 0.2F, 0F); + float s = 1.05F / 16F; + GlStateManager.scalef(s, s, s); - float s = 1.05F / 16F; - GlStateManager.scalef(s, s, s); + if(model == null) + model = new ModelBiped(); - if(model == null) - model = new ModelBiped(); - - model.bipedBody.render(1F); - } + model.bipedBody.render(1F); } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemLavaPendant.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemLavaPendant.java index 8e9ec5b5a..796cf07bd 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemLavaPendant.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemLavaPendant.java @@ -23,7 +23,6 @@ import net.minecraftforge.api.distmarker.OnlyIn; import vazkii.botania.api.item.AccessoryRenderHelper; import vazkii.botania.client.core.handler.MiscellaneousIcons; import vazkii.botania.client.core.helper.IconHelper; -import vazkii.botania.common.integration.curios.RenderableCurio; public class ItemLavaPendant extends ItemBauble { @@ -31,33 +30,27 @@ public class ItemLavaPendant extends ItemBauble { super(props); } - public static class Curio extends RenderableCurio { - public Curio(ItemStack stack) { - super(stack); - } + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + if(player.isBurning()) + player.extinguish(); + } - @Override - public void onCurioTick(String identifier, EntityLivingBase player) { - if(player.isBurning()) - player.extinguish(); - } + @Override + @OnlyIn(Dist.CLIENT) + public void doRender(ItemStack stack, EntityLivingBase player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); + AccessoryRenderHelper.rotateIfSneaking(player); + boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty(); + GlStateManager.scalef(0.5F, 0.5F, 0.5F); + GlStateManager.rotatef(180, 0, 0, 1); + GlStateManager.translated(-0.5, -0.90, armor ? -0.4 : -0.25); - @Override - @OnlyIn(Dist.CLIENT) - 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); - AccessoryRenderHelper.rotateIfSneaking(player); - boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty(); - GlStateManager.scalef(0.5F, 0.5F, 0.5F); - GlStateManager.rotatef(180, 0, 0, 1); - GlStateManager.translated(-0.5, -0.90, armor ? -0.4 : -0.25); - - TextureAtlasSprite gemIcon = MiscellaneousIcons.INSTANCE.pyroclastGem; - float f = gemIcon.getMinU(); - float f1 = gemIcon.getMaxU(); - float f2 = gemIcon.getMinV(); - float f3 = gemIcon.getMaxV(); - IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getWidth(), gemIcon.getHeight(), 1F / 32F); - } + TextureAtlasSprite gemIcon = MiscellaneousIcons.INSTANCE.pyroclastGem; + float f = gemIcon.getMinU(); + float f1 = gemIcon.getMaxU(); + float f2 = gemIcon.getMinV(); + float f3 = gemIcon.getMaxV(); + IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getWidth(), gemIcon.getHeight(), 1F / 32F); } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMagnetRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMagnetRing.java index 12f954fbc..a9d1c1e53 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMagnetRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMagnetRing.java @@ -23,20 +23,16 @@ import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.item.ItemTossEvent; -import net.minecraftforge.items.IItemHandler; -import top.theillusivec4.curios.api.CuriosAPI; -import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.item.IRelic; import vazkii.botania.api.mana.IManaItem; import vazkii.botania.common.Botania; import vazkii.botania.common.block.subtile.functional.SubTileSolegnolia; import vazkii.botania.common.core.handler.ConfigHandler; +import vazkii.botania.common.core.handler.EquipmentHandler; import vazkii.botania.common.core.helper.ItemNBTHelper; import vazkii.botania.common.core.helper.MathHelper; import vazkii.botania.common.core.helper.Vector3; -import vazkii.botania.common.integration.curios.BaseCurio; import vazkii.botania.common.integration.curios.CurioIntegration; -import vazkii.botania.common.lib.LibItemNames; import vazkii.botania.common.lib.LibMisc; import java.util.List; @@ -62,51 +58,45 @@ public class ItemMagnetRing extends ItemBauble { } private void onTossItem(ItemTossEvent event) { - ItemStack ring = Botania.curiosLoaded ? CurioIntegration.findOrEmpty(this, event.getPlayer()) : ItemStack.EMPTY; + ItemStack ring = EquipmentHandler.findOrEmpty(this, event.getPlayer()); if(!ring.isEmpty()) { setCooldown(ring, 100); } } - public static class Curio extends BaseCurio { - public Curio(ItemStack stack) { - super(stack); + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + int cooldown = getCooldown(stack); + + if(SubTileSolegnolia.hasSolegnoliaAround(player)) { + if(cooldown < 0) + setCooldown(stack, 2); + return; } - @Override - public void onCurioTick(String identifier, EntityLivingBase player) { - int cooldown = getCooldown(stack); + if(cooldown <= 0) { + if(player.isSneaking() == ConfigHandler.COMMON.invertMagnetRing.get()) { + double x = player.posX; + double y = player.posY + 0.75; + double z = player.posZ; - if(SubTileSolegnolia.hasSolegnoliaAround(player)) { - if(cooldown < 0) - setCooldown(stack, 2); - return; - } + int range = ((ItemMagnetRing) stack.getItem()).range; + List items = player.world.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(x - range, y - range, z - range, x + range, y + range, z + range)); + int pulled = 0; + for(EntityItem item : items) + if(((ItemMagnetRing) stack.getItem()).canPullItem(item)) { + if(pulled > 200) + break; - if(cooldown <= 0) { - if(player.isSneaking() == ConfigHandler.COMMON.invertMagnetRing.get()) { - double x = player.posX; - double y = player.posY + 0.75; - double z = player.posZ; - - int range = ((ItemMagnetRing) stack.getItem()).range; - List items = player.world.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(x - range, y - range, z - range, x + range, y + range, z + range)); - int pulled = 0; - for(EntityItem item : items) - if(((ItemMagnetRing) stack.getItem()).canPullItem(item)) { - if(pulled > 200) - break; - - MathHelper.setEntityMotionFromVector(item, new Vector3(x, y, z), 0.45F); - if(player.world.isRemote) { - boolean red = player.world.rand.nextBoolean(); - Botania.proxy.sparkleFX(item.posX, item.posY, item.posZ, red ? 1F : 0F, 0F, red ? 0F : 1F, 1F, 3); - } - pulled++; + MathHelper.setEntityMotionFromVector(item, new Vector3(x, y, z), 0.45F); + if(player.world.isRemote) { + boolean red = player.world.rand.nextBoolean(); + Botania.proxy.sparkleFX(item.posX, item.posY, item.posZ, red ? 1F : 0F, 0F, red ? 0F : 1F, 1F, 3); } - } - } else setCooldown(stack, cooldown - 1); - } + pulled++; + } + } + } else setCooldown(stack, cooldown - 1); } private boolean canPullItem(EntityItem item) { diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMiningRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMiningRing.java index 04580cef7..5c301183d 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMiningRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMiningRing.java @@ -17,8 +17,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.potion.PotionEffect; import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; -import vazkii.botania.common.integration.curios.BaseCurio; -import vazkii.botania.common.lib.LibItemNames; public class ItemMiningRing extends ItemBauble implements IManaUsingItem { @@ -26,38 +24,32 @@ public class ItemMiningRing extends ItemBauble implements IManaUsingItem { super(props); } - public static class Curio extends BaseCurio { - public Curio(ItemStack stack) { - super(stack); - } + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + if(player instanceof EntityPlayer && !player.world.isRemote) { + int manaCost = 5; + boolean hasMana = ManaItemHandler.requestManaExact(stack, (EntityPlayer) player, manaCost, false); + if(!hasMana) + onUnequipped(stack, player); + else { + if(player.getActivePotionEffect(MobEffects.HASTE) != null) + player.removePotionEffect(MobEffects.HASTE); - @Override - public void onCurioTick(String identifier, EntityLivingBase player) { - if(player instanceof EntityPlayer && !player.world.isRemote) { - int manaCost = 5; - boolean hasMana = ManaItemHandler.requestManaExact(stack, (EntityPlayer) player, manaCost, false); - if(!hasMana) - onUnequipped(identifier, player); - else { - if(player.getActivePotionEffect(MobEffects.HASTE) != null) - player.removePotionEffect(MobEffects.HASTE); - - player.addPotionEffect(new PotionEffect(MobEffects.HASTE, Integer.MAX_VALUE, 1, true, true)); - } - - if(player.swingProgress == 0.25F) - ManaItemHandler.requestManaExact(stack, (EntityPlayer) player, manaCost, true); + player.addPotionEffect(new PotionEffect(MobEffects.HASTE, Integer.MAX_VALUE, 1, true, true)); } - } - @Override - public void onUnequipped(String identifier, EntityLivingBase player) { - PotionEffect effect = player.getActivePotionEffect(MobEffects.HASTE); - if(effect != null && effect.getAmplifier() == 1) - player.removePotionEffect(MobEffects.HASTE); + if(player.swingProgress == 0.25F) + ManaItemHandler.requestManaExact(stack, (EntityPlayer) player, manaCost, true); } } + @Override + public void onUnequipped(ItemStack stack, EntityLivingBase player) { + PotionEffect effect = player.getActivePotionEffect(MobEffects.HASTE); + if(effect != null && effect.getAmplifier() == 1) + player.removePotionEffect(MobEffects.HASTE); + } + @Override public boolean usesMana(ItemStack stack) { return true; diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMonocle.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMonocle.java index 0ea915220..2ad3bfcdc 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMonocle.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemMonocle.java @@ -31,14 +31,11 @@ import net.minecraft.util.math.RayTraceResult; import net.minecraft.util.text.TextFormatting; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -import top.theillusivec4.curios.api.CuriosAPI; import vazkii.botania.api.item.AccessoryRenderHelper; import vazkii.botania.api.item.IBurstViewerBauble; import vazkii.botania.api.item.ICosmeticAttachable; import vazkii.botania.api.item.ICosmeticBauble; -import vazkii.botania.common.Botania; -import vazkii.botania.common.integration.curios.CurioIntegration; -import vazkii.botania.common.integration.curios.RenderableCurio; +import vazkii.botania.common.core.handler.EquipmentHandler; import vazkii.botania.common.item.ModItems; public class ItemMonocle extends ItemBauble implements IBurstViewerBauble, ICosmeticBauble { @@ -47,25 +44,19 @@ public class ItemMonocle extends ItemBauble implements IBurstViewerBauble, ICosm super(props); } - public static class Curio extends RenderableCurio { - public Curio(ItemStack stack) { - super(stack); - } + @Override + @OnlyIn(Dist.CLIENT) + public void doRender(ItemStack stack, EntityLivingBase player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.HEAD).isEmpty(); + Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); - @Override - @OnlyIn(Dist.CLIENT) - public void doRender(String identifier, EntityLivingBase player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { - boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.HEAD).isEmpty(); - Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); - - AccessoryRenderHelper.translateToHeadLevel(player); - AccessoryRenderHelper.translateToFace(); - AccessoryRenderHelper.defaultTransforms(); - GlStateManager.rotatef(180F, 0F, 1F, 0F); - GlStateManager.scalef(0.5F, 0.5F, 0.5F); - GlStateManager.translatef(0.5F, -0.2F, armor ? 0.12F : 0F); - Minecraft.getInstance().getItemRenderer().renderItem(stack, ItemCameraTransforms.TransformType.NONE); - } + AccessoryRenderHelper.translateToHeadLevel(player); + AccessoryRenderHelper.translateToFace(); + AccessoryRenderHelper.defaultTransforms(); + GlStateManager.rotatef(180F, 0F, 1F, 0F); + GlStateManager.scalef(0.5F, 0.5F, 0.5F); + GlStateManager.translatef(0.5F, -0.2F, armor ? 0.12F : 0F); + Minecraft.getInstance().getItemRenderer().renderItem(stack, ItemCameraTransforms.TransformType.NONE); } @OnlyIn(Dist.CLIENT) @@ -106,7 +97,7 @@ public class ItemMonocle extends ItemBauble implements IBurstViewerBauble, ICosm } public static boolean hasMonocle(EntityPlayer player) { - ItemStack stack = Botania.curiosLoaded ? CurioIntegration.findOrEmpty(ModItems.monocle, player) : ItemStack.EMPTY; + ItemStack stack = EquipmentHandler.findOrEmpty(ModItems.monocle, player); if(!stack.isEmpty()) { Item item = stack.getItem(); if(item instanceof IBurstViewerBauble) diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemReachRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemReachRing.java index 6e1165264..d146151cc 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemReachRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemReachRing.java @@ -15,26 +15,17 @@ 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 ItemBauble { public ItemReachRing(Properties props) { super(props); } - - public static class Curio extends BaseCurio { - public Curio(ItemStack stack) { - super(stack); - } - - @Override - public Multimap getAttributeModifiers(String identifier) { - Multimap attributes = HashMultimap.create(); - attributes.put(EntityPlayer.REACH_DISTANCE.getName(), new AttributeModifier(getBaubleUUID(stack), "Reach Ring", 3.5, 0).setSaved(false)); - return attributes; - } + + @Override + public Multimap getEquippedAttributeModifiers(ItemStack stack) { + Multimap attributes = HashMultimap.create(); + attributes.put(EntityPlayer.REACH_DISTANCE.getName(), new AttributeModifier(getBaubleUUID(stack), "Reach Ring", 3.5, 0).setSaved(false)); + return attributes; } - } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperLavaPendant.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperLavaPendant.java index 578bb737b..d6332ba65 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperLavaPendant.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSuperLavaPendant.java @@ -23,7 +23,6 @@ import net.minecraftforge.api.distmarker.OnlyIn; import vazkii.botania.api.item.AccessoryRenderHelper; import vazkii.botania.client.core.handler.MiscellaneousIcons; import vazkii.botania.client.core.helper.IconHelper; -import vazkii.botania.common.integration.curios.RenderableCurio; public class ItemSuperLavaPendant extends ItemBauble { @@ -31,37 +30,32 @@ public class ItemSuperLavaPendant extends ItemBauble { super(props); } - public static class Curio extends RenderableCurio { - public Curio(ItemStack stack) { - super(stack); - } - @Override - public void onCurioTick(String identifier, EntityLivingBase living) { - living.isImmuneToFire = true; - } + @Override + public void onWornTick(ItemStack stack, EntityLivingBase living) { + living.isImmuneToFire = true; + } - @Override - public void onUnequipped(String identifier, EntityLivingBase living) { - living.isImmuneToFire = false; - } + @Override + public void onUnequipped(ItemStack stack, EntityLivingBase living) { + living.isImmuneToFire = false; + } - @Override - @OnlyIn(Dist.CLIENT) - 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); - AccessoryRenderHelper.rotateIfSneaking(player); - boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty(); - GlStateManager.scaled(0.5, 0.5, 0.5); - GlStateManager.rotatef(180, 0, 0, 1); - GlStateManager.translated(-0.5, -0.90, armor ? -0.4 : -0.25); + @Override + @OnlyIn(Dist.CLIENT) + public void doRender(ItemStack stack, EntityLivingBase player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); + AccessoryRenderHelper.rotateIfSneaking(player); + boolean armor = !player.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty(); + GlStateManager.scaled(0.5, 0.5, 0.5); + GlStateManager.rotatef(180, 0, 0, 1); + GlStateManager.translated(-0.5, -0.90, armor ? -0.4 : -0.25); - TextureAtlasSprite gemIcon = MiscellaneousIcons.INSTANCE.crimsonGem; - float f = gemIcon.getMinU(); - float f1 = gemIcon.getMaxU(); - float f2 = gemIcon.getMinV(); - float f3 = gemIcon.getMaxV(); - IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getWidth(), gemIcon.getHeight(), 1F / 32F); - } + TextureAtlasSprite gemIcon = MiscellaneousIcons.INSTANCE.crimsonGem; + float f = gemIcon.getMinU(); + float f1 = gemIcon.getMaxU(); + float f2 = gemIcon.getMinV(); + float f3 = gemIcon.getMaxV(); + IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getWidth(), gemIcon.getHeight(), 1F / 32F); } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSwapRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSwapRing.java index 8d7d6a188..0c6b4adbb 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSwapRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemSwapRing.java @@ -19,9 +19,7 @@ import net.minecraft.util.EnumHand; import net.minecraft.util.math.RayTraceResult; import vazkii.botania.api.item.ISortableTool; import vazkii.botania.api.item.ISortableTool.ToolType; -import vazkii.botania.common.integration.curios.BaseCurio; import vazkii.botania.common.item.equipment.tool.ToolCommons; -import vazkii.botania.common.lib.LibItemNames; public class ItemSwapRing extends ItemBauble { @@ -29,64 +27,58 @@ public class ItemSwapRing extends ItemBauble { super(props); } - public static class Curio extends BaseCurio { - public Curio(ItemStack stack) { - super(stack); + @Override + public void onWornTick(ItemStack stack, EntityLivingBase entity) { + if(!(entity instanceof EntityPlayer)) + return; + + EntityPlayer player = (EntityPlayer) entity; + ItemStack currentStack = player.getHeldItemMainhand(); + if(currentStack.isEmpty() || !(currentStack.getItem() instanceof ISortableTool)) + return; + + ISortableTool tool = (ISortableTool) currentStack.getItem(); + + RayTraceResult pos = ToolCommons.raytraceFromEntity(entity.world, entity, true, 4.5F); + ToolType typeToFind = null; + + if(player.isSwingInProgress && pos != null && pos.getBlockPos() != null) { + IBlockState state = entity.world.getBlockState(pos.getBlockPos()); + + Material mat = state.getMaterial(); + if(ToolCommons.materialsPick.contains(mat)) + typeToFind = ToolType.PICK; + else if(ToolCommons.materialsShovel.contains(mat)) + typeToFind = ToolType.SHOVEL; + else if(ToolCommons.materialsAxe.contains(mat)) + typeToFind = ToolType.AXE; } - @Override - public void onCurioTick(String identifier, EntityLivingBase entity) { - if(!(entity instanceof EntityPlayer)) - return; + if(typeToFind == null) + return; - EntityPlayer player = (EntityPlayer) entity; - ItemStack currentStack = player.getHeldItemMainhand(); - if(currentStack.isEmpty() || !(currentStack.getItem() instanceof ISortableTool)) - return; + ItemStack bestTool = currentStack; + int bestToolPriority = tool.getSortingType(currentStack) == typeToFind ? tool.getSortingPriority(currentStack) : -1; + int bestSlot = -1; - ISortableTool tool = (ISortableTool) currentStack.getItem(); - - RayTraceResult pos = ToolCommons.raytraceFromEntity(entity.world, entity, true, 4.5F); - ToolType typeToFind = null; - - if(player.isSwingInProgress && pos != null && pos.getBlockPos() != null) { - IBlockState state = entity.world.getBlockState(pos.getBlockPos()); - - Material mat = state.getMaterial(); - if(ToolCommons.materialsPick.contains(mat)) - typeToFind = ToolType.PICK; - else if(ToolCommons.materialsShovel.contains(mat)) - typeToFind = ToolType.SHOVEL; - else if(ToolCommons.materialsAxe.contains(mat)) - typeToFind = ToolType.AXE; - } - - if(typeToFind == null) - return; - - ItemStack bestTool = currentStack; - int bestToolPriority = tool.getSortingType(currentStack) == typeToFind ? tool.getSortingPriority(currentStack) : -1; - int bestSlot = -1; - - for(int i = 0; i < player.inventory.getSizeInventory(); i++) { - ItemStack stackInSlot = player.inventory.getStackInSlot(i); - if (!stackInSlot.isEmpty() && stackInSlot.getItem() instanceof ISortableTool && stackInSlot != currentStack) { - ISortableTool toolInSlot = (ISortableTool) stackInSlot.getItem(); - if(toolInSlot.getSortingType(stackInSlot).equals(typeToFind)) { - int priority = toolInSlot.getSortingPriority(stackInSlot); - if(priority > bestToolPriority) { - bestTool = stackInSlot; - bestToolPriority = priority; - bestSlot = i; - } + for(int i = 0; i < player.inventory.getSizeInventory(); i++) { + ItemStack stackInSlot = player.inventory.getStackInSlot(i); + if(!stackInSlot.isEmpty() && stackInSlot.getItem() instanceof ISortableTool && stackInSlot != currentStack) { + ISortableTool toolInSlot = (ISortableTool) stackInSlot.getItem(); + if(toolInSlot.getSortingType(stackInSlot).equals(typeToFind)) { + int priority = toolInSlot.getSortingPriority(stackInSlot); + if(priority > bestToolPriority) { + bestTool = stackInSlot; + bestToolPriority = priority; + bestSlot = i; } } } + } - if(bestSlot != -1) { - player.setHeldItem(EnumHand.MAIN_HAND, bestTool); - player.inventory.setInventorySlotContents(bestSlot, currentStack); - } + if(bestSlot != -1) { + player.setHeldItem(EnumHand.MAIN_HAND, bestTool); + player.inventory.setInventorySlotContents(bestSlot, currentStack); } } } diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemThirdEye.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemThirdEye.java index 21d831137..a4b4f95a0 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemThirdEye.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemThirdEye.java @@ -31,81 +31,74 @@ import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.client.core.handler.ClientTickHandler; import vazkii.botania.client.core.handler.MiscellaneousIcons; import vazkii.botania.client.core.helper.IconHelper; -import vazkii.botania.common.integration.curios.RenderableCurio; import java.util.List; public class ItemThirdEye extends ItemBauble implements IManaUsingItem { private static final int COST = 2; - + public ItemThirdEye(Properties props) { super(props); } - public static class Curio extends RenderableCurio { - public Curio(ItemStack stack) { - super(stack); - } + @Override + public void onWornTick(ItemStack stack, EntityLivingBase living) { + if(!(living instanceof EntityPlayer)) + return; + EntityPlayer eplayer = (EntityPlayer) living; - @Override - public void onCurioTick(String identifier, EntityLivingBase living) { - if(!(living instanceof EntityPlayer)) - return; - EntityPlayer eplayer = (EntityPlayer) living; + double range = 24; + AxisAlignedBB aabb = new AxisAlignedBB(living.posX, living.posY, living.posZ, living.posX, living.posY, living.posZ).grow(range); + List mobs = living.world.getEntitiesWithinAABB(EntityLivingBase.class, aabb, (Entity e) -> e instanceof IMob); - double range = 24; - AxisAlignedBB aabb = new AxisAlignedBB(living.posX, living.posY, living.posZ, living.posX, living.posY, living.posZ).grow(range); - List mobs = living.world.getEntitiesWithinAABB(EntityLivingBase.class, aabb, (Entity e) -> e instanceof IMob); - - for(EntityLivingBase e : mobs) { - PotionEffect potion = e.getActivePotionEffect(MobEffects.GLOWING); - if((potion == null || potion.getDuration() <= 2) && ManaItemHandler.requestManaExact(stack, eplayer, COST, true)) - e.addPotionEffect(new PotionEffect(MobEffects.GLOWING, 12, 0)); - } - } - - @Override - @OnlyIn(Dist.CLIENT) - 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(TextureMap.LOCATION_BLOCKS_TEXTURE); - boolean armor = !living.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty(); - GlStateManager.rotatef(180, 0, 0, 1); - GlStateManager.translated(-0.3, -0.6, armor ? -0.18 : -0.12); - GlStateManager.scaled(0.6, 0.6, 0.6); - - for(int i = 0; i < 3; i++) { - GlStateManager.pushMatrix(); - float width = 1F / 16F; - switch(i) { - case 0: break; - case 1: - double scale1 = 0.75; - width /= 2F; - - GlStateManager.translated(0.15, 0.15, -0.05); - double time = ClientTickHandler.total * 0.12; - double dist = 0.05; - GlStateManager.translated(Math.sin(time) * dist, Math.cos(time * 0.5) * dist, 0); - - GlStateManager.scaled(scale1, scale1, scale1); - break; - case 2: - GlStateManager.translated(0, 0, -0.05); - break; - } - - TextureAtlasSprite gemIcon = MiscellaneousIcons.INSTANCE.thirdEyeLayers[i]; - float f = gemIcon.getMinU(); - float f1 = gemIcon.getMaxU(); - float f2 = gemIcon.getMinV(); - float f3 = gemIcon.getMaxV(); - IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getWidth(), gemIcon.getHeight(), width); - GlStateManager.popMatrix(); - } + for(EntityLivingBase e : mobs) { + PotionEffect potion = e.getActivePotionEffect(MobEffects.GLOWING); + if((potion == null || potion.getDuration() <= 2) && ManaItemHandler.requestManaExact(stack, eplayer, COST, true)) + e.addPotionEffect(new PotionEffect(MobEffects.GLOWING, 12, 0)); } } - + + @Override + @OnlyIn(Dist.CLIENT) + public void doRender(ItemStack stack, EntityLivingBase living, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); + boolean armor = !living.getItemStackFromSlot(EntityEquipmentSlot.CHEST).isEmpty(); + GlStateManager.rotatef(180, 0, 0, 1); + GlStateManager.translated(-0.3, -0.6, armor ? -0.18 : -0.12); + GlStateManager.scaled(0.6, 0.6, 0.6); + + for(int i = 0; i < 3; i++) { + GlStateManager.pushMatrix(); + float width = 1F / 16F; + switch (i) { + case 0: break; + case 1: + double scale1 = 0.75; + width /= 2F; + + GlStateManager.translated(0.15, 0.15, -0.05); + double time = ClientTickHandler.total * 0.12; + double dist = 0.05; + GlStateManager.translated(Math.sin(time) * dist, Math.cos(time * 0.5) * dist, 0); + + GlStateManager.scaled(scale1, scale1, scale1); + break; + case 2: + GlStateManager.translated(0, 0, -0.05); + break; + } + + TextureAtlasSprite gemIcon = MiscellaneousIcons.INSTANCE.thirdEyeLayers[i]; + float f = gemIcon.getMinU(); + float f1 = gemIcon.getMaxU(); + float f2 = gemIcon.getMinV(); + float f3 = gemIcon.getMaxV(); + IconHelper.renderIconIn3D(Tessellator.getInstance(), f1, f2, f, f3, gemIcon.getWidth(), gemIcon.getHeight(), width); + GlStateManager.popMatrix(); + } + } + @Override public boolean usesMana(ItemStack stack) { return true; diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTinyPlanet.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTinyPlanet.java index ccc9d7b4b..7ff48ba71 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTinyPlanet.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTinyPlanet.java @@ -27,7 +27,6 @@ import vazkii.botania.api.internal.IManaBurst; import vazkii.botania.api.mana.ITinyPlanetExcempt; import vazkii.botania.common.block.ModBlocks; import vazkii.botania.common.core.helper.Vector3; -import vazkii.botania.common.integration.curios.RenderableCurio; import java.util.List; @@ -38,29 +37,23 @@ public class ItemTinyPlanet extends ItemBauble { public ItemTinyPlanet(Properties props) { super(props); } + + @Override + public void onWornTick(ItemStack stack, EntityLivingBase player) { + double x = player.posX; + double y = player.posY + player.getEyeHeight(); + double z = player.posZ; - public static class Curio extends RenderableCurio { - public Curio(ItemStack stack) { - super(stack); - } + applyEffect(player.world, x, y, z); + } - @Override - public void onCurioTick(String identifier, EntityLivingBase player) { - double x = player.posX; - double y = player.posY + player.getEyeHeight(); - double z = player.posZ; - - applyEffect(player.world, x, y, z); - } - - @Override - @OnlyIn(Dist.CLIENT) - 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(TextureMap.LOCATION_BLOCKS_TEXTURE); - GlStateManager.scalef(0.5F, 0.5F, 0.5F); - GlStateManager.translatef(0, -1.5F, 0.5F); - Minecraft.getInstance().getBlockRendererDispatcher().renderBlockBrightness(ModBlocks.tinyPlanet.getDefaultState(), 1.0F); - } + @Override + @OnlyIn(Dist.CLIENT) + public void doRender(ItemStack stack, EntityLivingBase living, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + Minecraft.getInstance().textureManager.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); + GlStateManager.scalef(0.5F, 0.5F, 0.5F); + GlStateManager.translatef(0, -1.5F, 0.5F); + Minecraft.getInstance().getBlockRendererDispatcher().renderBlockBrightness(ModBlocks.tinyPlanet.getDefaultState(), 1.0F); } public static void applyEffect(World world, double x, double y, double z) { diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTravelBelt.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTravelBelt.java index e4d478229..f4a595e82 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTravelBelt.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemTravelBelt.java @@ -17,21 +17,18 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingEvent.LivingJumpEvent; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.PlayerEvent; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import top.theillusivec4.curios.api.CuriosAPI; import vazkii.botania.api.item.AccessoryRenderHelper; import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; import vazkii.botania.client.lib.LibResources; -import vazkii.botania.common.Botania; -import vazkii.botania.common.integration.curios.CurioIntegration; -import vazkii.botania.common.integration.curios.RenderableCurio; +import vazkii.botania.common.core.handler.EquipmentHandler; import java.util.ArrayList; import java.util.List; @@ -67,7 +64,7 @@ public class ItemTravelBelt extends ItemBauble implements IManaUsingItem { public void updatePlayerStepStatus(LivingUpdateEvent event) { if(event.getEntityLiving() instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.getEntityLiving(); - ItemStack belt = Botania.curiosLoaded ? CurioIntegration.findOrEmpty(s -> s.getItem() instanceof ItemTravelBelt, player) : ItemStack.EMPTY; + ItemStack belt = EquipmentHandler.findOrEmpty(s -> s.getItem() instanceof ItemTravelBelt, player); String s = playerStr(player); if(playersWithStepup.contains(s)) { @@ -87,7 +84,7 @@ public class ItemTravelBelt extends ItemBauble implements IManaUsingItem { if(player.isSneaking()) player.stepHeight = 0.60001F; // Not 0.6F because that is the default - else player.stepHeight = 1.25F; + else player.stepHeight = 1.25F; } else { player.stepHeight = 0.6F; @@ -112,7 +109,7 @@ public class ItemTravelBelt extends ItemBauble implements IManaUsingItem { public void onPlayerJump(LivingJumpEvent event) { if(event.getEntityLiving() instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.getEntityLiving(); - ItemStack belt = CurioIntegration.findOrEmpty(s -> s.getItem() instanceof ItemTravelBelt, player); + ItemStack belt = EquipmentHandler.findOrEmpty(s -> s.getItem() instanceof ItemTravelBelt, player); if(!belt.isEmpty() && ManaItemHandler.requestManaExact(belt, player, COST, false)) { player.motionY += ((ItemTravelBelt) belt.getItem()).jump; @@ -122,7 +119,7 @@ public class ItemTravelBelt extends ItemBauble implements IManaUsingItem { } private boolean shouldPlayerHaveStepup(EntityPlayer player) { - ItemStack result = Botania.curiosLoaded ? CurioIntegration.findOrEmpty(s -> s.getItem() instanceof ItemTravelBelt, player) : ItemStack.EMPTY; + ItemStack result = EquipmentHandler.findOrEmpty(s -> s.getItem() instanceof ItemTravelBelt, player); return !result.isEmpty() && ManaItemHandler.requestManaExact(result, player, COST, false); } @@ -142,26 +139,21 @@ public class ItemTravelBelt extends ItemBauble implements IManaUsingItem { return texture; } - public static class Curio extends RenderableCurio { - public Curio(ItemStack stack) { - super(stack); - } - @Override - @OnlyIn(Dist.CLIENT) - 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(((ItemTravelBelt) stack.getItem()).getRenderTexture()); - AccessoryRenderHelper.rotateIfSneaking(player); + @Override + @OnlyIn(Dist.CLIENT) + public void doRender(ItemStack stack, EntityLivingBase player, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch, float scale) { + Minecraft.getInstance().textureManager.bindTexture(((ItemTravelBelt) stack.getItem()).getRenderTexture()); + AccessoryRenderHelper.rotateIfSneaking(player); - GlStateManager.translatef(0F, 0.2F, 0F); + GlStateManager.translatef(0F, 0.2F, 0F); - float s = 1.05F / 16F; - GlStateManager.scalef(s, s, s); - if(model == null) - model = new ModelBiped(); + float s = 1.05F / 16F; + GlStateManager.scalef(s, s, s); + if(model == null) + model = new ModelBiped(); - model.bipedBody.render(1F); - } + model.bipedBody.render(1F); } @Override diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemWaterRing.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemWaterRing.java index 702d4999a..6ba745785 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemWaterRing.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemWaterRing.java @@ -15,12 +15,9 @@ 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.Botania; -import vazkii.botania.common.integration.curios.BaseCurio; -import vazkii.botania.common.integration.curios.CurioIntegration; +import vazkii.botania.common.core.handler.EquipmentHandler; import vazkii.botania.common.item.ModItems; public class ItemWaterRing extends ItemBauble implements IManaUsingItem { @@ -32,54 +29,48 @@ public class ItemWaterRing extends ItemBauble implements IManaUsingItem { super(props); } - public static class Curio extends BaseCurio { - public Curio(ItemStack stack) { - super(stack); - } + @Override + public void onWornTick(ItemStack stack, EntityLivingBase living) { + if(living.isInWaterOrBubbleColumn()) { + if(living instanceof EntityPlayer) { + // only activate for one ring at a time + ItemStack result = EquipmentHandler.findOrEmpty(ModItems.waterRing, living); + if(result != 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 - ItemStack result = CurioIntegration.findOrEmpty(ModItems.waterRing, living); - if(result != stack) - return; - } + double motionX = living.motionX * SPEED_MULT; + double motionY = living.motionY * SPEED_MULT; + double motionZ = living.motionZ * SPEED_MULT; - double motionX = living.motionX * SPEED_MULT; - double motionY = living.motionY * SPEED_MULT; - double motionZ = living.motionZ * SPEED_MULT; + boolean flying = living instanceof EntityPlayer && ((EntityPlayer) living).abilities.isFlying; - boolean flying = living instanceof EntityPlayer && ((EntityPlayer) living).abilities.isFlying; + 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; - 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 = 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(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); - } + if(effect == null) { + PotionEffect neweffect = new PotionEffect(MobEffects.NIGHT_VISION, Integer.MAX_VALUE, -42, true, true); + living.addPotionEffect(neweffect); + } + + if(living.getAir() <= 1 && living instanceof EntityPlayer) { + int mana = ManaItemHandler.requestMana(stack, (EntityPlayer) living, 300, true); + if(mana > 0) + living.setAir(mana); + } + } else onUnequipped(stack, living); + } + + @Override + public void onUnequipped(ItemStack stack, EntityLivingBase living) { + PotionEffect effect = living.getActivePotionEffect(MobEffects.NIGHT_VISION); + if(effect != null && effect.getAmplifier() == -42) + living.removePotionEffect(MobEffects.NIGHT_VISION); } @Override diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemLokiRing.java b/src/main/java/vazkii/botania/common/item/relic/ItemLokiRing.java index 9bd05d433..b9d2c72e6 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemLokiRing.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemLokiRing.java @@ -10,11 +10,7 @@ */ package vazkii.botania.common.item.relic; -import java.util.ArrayList; -import java.util.List; - import com.google.common.collect.ImmutableList; - import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.entity.EntityLivingBase; @@ -28,27 +24,24 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.api.distmarker.OnlyIn; -import net.minecraftforge.items.IItemHandler; -import top.theillusivec4.curios.api.CuriosAPI; -import vazkii.botania.api.BotaniaAPI; import vazkii.botania.api.item.ISequentialBreaker; import vazkii.botania.api.item.IWireframeCoordinateListProvider; import vazkii.botania.api.mana.IManaUsingItem; import vazkii.botania.api.mana.ManaItemHandler; -import vazkii.botania.common.Botania; +import vazkii.botania.common.core.handler.EquipmentHandler; import vazkii.botania.common.core.helper.ItemNBTHelper; -import vazkii.botania.common.integration.curios.CurioIntegration; -import vazkii.botania.common.integration.curios.RelicCurio; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.tool.ToolCommons; -import vazkii.botania.common.lib.LibItemNames; import vazkii.botania.common.lib.LibMisc; +import java.util.ArrayList; +import java.util.List; + @Mod.EventBusSubscriber(modid = LibMisc.MOD_ID) public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinateListProvider, IManaUsingItem { @@ -115,7 +108,7 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat if(player.world.isAirBlock(pos) && ManaItemHandler.requestManaExact(lokiRing, player, cost, true)) { ItemStack saveHeld = heldItemStack.copy(); heldItemStack.onItemUse(new ItemUseContext(player, heldItemStack, pos, lookPos.sideHit, (float) lookPos.hitVec.x - pos.getX(), (float) lookPos.hitVec.y - pos.getY(), (float) lookPos.hitVec.z - pos.getZ())); - if (player.isCreative()) + if(player.isCreative()) player.setHeldItem(event.getHand(), saveHeld); } } @@ -131,7 +124,7 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat ISequentialBreaker breaker = (ISequentialBreaker) item; boolean dispose = breaker.disposeOfTrashBlocks(stack); - for (BlockPos offset : cursors) { + for(BlockPos offset : cursors) { BlockPos coords = pos.add(offset); IBlockState state = player.world.getBlockState(coords); breaker.breakOtherBlock(player, stack, coords, pos, side); @@ -140,20 +133,14 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat } } - public static class Curio extends RelicCurio { - public Curio(ItemStack stack, ItemRelic relicDelegate) { - super(stack, relicDelegate); - } + @Override + public boolean shouldSyncToTracking(ItemStack stack, EntityLivingBase entity) { + return true; + } - @Override - public boolean shouldSyncToTracking(String identifier, EntityLivingBase living) { - return true; - } - - @Override - public void onUnequipped(String identifier, EntityLivingBase living) { - setCursorList(stack, null); - } + @Override + public void onUnequipped(ItemStack stack, EntityLivingBase living) { + setCursorList(stack, null); } @Override @@ -168,8 +155,8 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat List list = getCursorList(stack); BlockPos origin = getOriginPos(stack); - for (int i = 0; i < list.size(); i++) { - if (origin.getY() != -1) { + for(int i = 0; i < list.size(); i++) { + if(origin.getY() != -1) { list.set(i, list.get(i).add(origin)); } else { list.set(i, list.get(i).add(lookPos.getBlockPos())); @@ -188,10 +175,7 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat } private static ItemStack getLokiRing(EntityPlayer player) { - if(Botania.curiosLoaded) { - return CurioIntegration.findOrEmpty(ModItems.lokiRing, player); - } - return ItemStack.EMPTY; + return EquipmentHandler.findOrEmpty(ModItems.lokiRing, player); } @@ -227,7 +211,7 @@ public class ItemLokiRing extends ItemRelicBauble implements IWireframeCoordinat private static void setCursorList(ItemStack stack, List cursors) { if(stack == null) return; - + NBTTagCompound cmp = new NBTTagCompound(); if(cursors != null) { int i = 0; diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemOdinRing.java b/src/main/java/vazkii/botania/common/item/relic/ItemOdinRing.java index 9af7de46b..d165dba6e 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemOdinRing.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemOdinRing.java @@ -12,30 +12,21 @@ package vazkii.botania.common.item.relic; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; -import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.DamageSource; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.common.MinecraftForge; 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.Botania; import vazkii.botania.common.core.handler.ConfigHandler; -import vazkii.botania.common.integration.curios.CurioIntegration; -import vazkii.botania.common.integration.curios.RelicCurio; +import vazkii.botania.common.core.handler.EquipmentHandler; import vazkii.botania.common.item.ModItems; -import vazkii.botania.common.lib.LibItemNames; import vazkii.botania.common.lib.LibMisc; -import java.util.ArrayList; import java.util.HashSet; -import java.util.List; import java.util.Set; @Mod.EventBusSubscriber(modid = LibMisc.MOD_ID) @@ -56,32 +47,26 @@ public class ItemOdinRing extends ItemRelicBauble { fireNegations.add(DamageSource.ON_FIRE.damageType); } - 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 void onValidPlayerWornTick(EntityPlayer player) { - if(player.isBurning() && ConfigHandler.COMMON.ringOfOdinFireResist.get()) - player.extinguish(); - } - - @Override - public Multimap getAttributeModifiers(String identifier) { - Multimap attributes = HashMultimap.create(); - attributes.put(SharedMonsterAttributes.MAX_HEALTH.getName(), new AttributeModifier(getBaubleUUID(stack), "Odin Ring", 20, 0).setSaved(false)); - return attributes; - } + @Override + public Multimap getEquippedAttributeModifiers(ItemStack stack) { + Multimap attributes = HashMultimap.create(); + attributes.put(SharedMonsterAttributes.MAX_HEALTH.getName(), new AttributeModifier(getBaubleUUID(stack), "Odin Ring", 20, 0).setSaved(false)); + return attributes; } @SubscribeEvent public static void onPlayerAttacked(LivingAttackEvent event) { - if(Botania.curiosLoaded && event.getEntityLiving() instanceof EntityPlayer) { + if(event.getEntityLiving() instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.getEntityLiving(); boolean negate = damageNegations.contains(event.getSource().damageType) || (ConfigHandler.COMMON.ringOfOdinFireResist.get() && fireNegations.contains(event.getSource().damageType)); - boolean hasRing = !CurioIntegration.findOrEmpty(ModItems.odinRing, player).isEmpty(); + boolean hasRing = !EquipmentHandler.findOrEmpty(ModItems.odinRing, player).isEmpty(); if(hasRing && negate) event.setCanceled(true); } diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemRelicBauble.java b/src/main/java/vazkii/botania/common/item/relic/ItemRelicBauble.java index 95fd2deca..e350935d1 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemRelicBauble.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemRelicBauble.java @@ -79,4 +79,20 @@ public abstract class ItemRelicBauble extends ItemBauble implements IRelic { return Integer.MAX_VALUE; } + @Override + public void onWornTick(ItemStack stack, EntityLivingBase entity) { + if(entity instanceof EntityPlayer) { + EntityPlayer ePlayer = (EntityPlayer) entity; + dummy.updateRelic(stack, ePlayer); + if(dummy.isRightPlayer(ePlayer, stack)) + onValidPlayerWornTick(ePlayer); + } + } + + public void onValidPlayerWornTick(EntityPlayer player) { } + + @Override + public boolean canEquip(ItemStack stack, EntityLivingBase entity) { + return entity instanceof EntityPlayer && dummy.isRightPlayer((EntityPlayer) entity, stack); + } } diff --git a/src/main/java/vazkii/botania/common/item/relic/ItemThorRing.java b/src/main/java/vazkii/botania/common/item/relic/ItemThorRing.java index 32e745cc0..fd6fddb07 100644 --- a/src/main/java/vazkii/botania/common/item/relic/ItemThorRing.java +++ b/src/main/java/vazkii/botania/common/item/relic/ItemThorRing.java @@ -13,11 +13,8 @@ package vazkii.botania.common.item.relic; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; -import net.minecraftforge.items.IItemHandler; -import vazkii.botania.common.Botania; -import vazkii.botania.common.integration.curios.CurioIntegration; +import vazkii.botania.common.core.handler.EquipmentHandler; import vazkii.botania.common.item.ModItems; -import vazkii.botania.common.lib.LibItemNames; import vazkii.botania.common.lib.LibMisc; public class ItemThorRing extends ItemRelicBauble { @@ -32,9 +29,6 @@ public class ItemThorRing extends ItemRelicBauble { } public static ItemStack getThorRing(EntityPlayer player) { - if(Botania.curiosLoaded) { - return CurioIntegration.findOrEmpty(ModItems.thorRing, player); - } - return ItemStack.EMPTY; + return EquipmentHandler.findOrEmpty(ModItems.thorRing, player); } } diff --git a/src/main/java/vazkii/botania/common/network/PacketDodge.java b/src/main/java/vazkii/botania/common/network/PacketDodge.java index 84750da9c..e24b2a928 100644 --- a/src/main/java/vazkii/botania/common/network/PacketDodge.java +++ b/src/main/java/vazkii/botania/common/network/PacketDodge.java @@ -10,21 +10,17 @@ */ package vazkii.botania.common.network; -import io.netty.buffer.ByteBuf; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.network.PacketBuffer; import net.minecraft.util.SoundCategory; import net.minecraft.util.text.TextComponentTranslation; import net.minecraftforge.fml.network.NetworkEvent; -import net.minecraftforge.items.IItemHandler; -import vazkii.botania.common.Botania; +import vazkii.botania.common.core.handler.EquipmentHandler; import vazkii.botania.common.core.handler.ModSounds; import vazkii.botania.common.core.helper.ItemNBTHelper; -import vazkii.botania.common.integration.curios.CurioIntegration; import vazkii.botania.common.item.ModItems; import vazkii.botania.common.item.equipment.bauble.ItemDodgeRing; -import vazkii.botania.common.item.equipment.tool.terrasteel.ItemTerraSword; import java.util.function.Supplier; @@ -40,11 +36,7 @@ public class PacketDodge { EntityPlayerMP player = ctx.get().getSender(); player.world.playSound(null, player.posX, player.posY, player.posZ, ModSounds.dash, SoundCategory.PLAYERS, 1F, 1F); - ItemStack ringStack = ItemStack.EMPTY; - if(Botania.curiosLoaded) { - ringStack = CurioIntegration.findOrEmpty(ModItems.dodgeRing, player); - } - + ItemStack ringStack = EquipmentHandler.findOrEmpty(ModItems.dodgeRing, player); if(ringStack.isEmpty()) { player.connection.disconnect(new TextComponentTranslation("botaniamisc.invalidDodge")); return; diff --git a/src/main/java/vazkii/botania/common/network/PacketJump.java b/src/main/java/vazkii/botania/common/network/PacketJump.java index 9d5ab8554..093accdd3 100644 --- a/src/main/java/vazkii/botania/common/network/PacketJump.java +++ b/src/main/java/vazkii/botania/common/network/PacketJump.java @@ -14,8 +14,7 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.network.PacketBuffer; import net.minecraftforge.fml.network.NetworkEvent; -import vazkii.botania.common.Botania; -import vazkii.botania.common.integration.curios.CurioIntegration; +import vazkii.botania.common.core.handler.EquipmentHandler; import vazkii.botania.common.item.equipment.bauble.ItemCloudPendant; import vazkii.botania.common.item.equipment.bauble.ItemTravelBelt; @@ -32,16 +31,14 @@ public class PacketJump { ctx.get().enqueueWork(() -> { EntityPlayerMP player = ctx.get().getSender(); - if(Botania.curiosLoaded) { - ItemStack amuletStack = CurioIntegration.findOrEmpty(s -> s.getItem() instanceof ItemCloudPendant, player); - if(!amuletStack.isEmpty()) { - player.addExhaustion(0.3F); - player.fallDistance = 0; + ItemStack amuletStack = EquipmentHandler.findOrEmpty(s -> s.getItem() instanceof ItemCloudPendant, player); + if(!amuletStack.isEmpty()) { + player.addExhaustion(0.3F); + player.fallDistance = 0; - ItemStack belt = CurioIntegration.findOrEmpty(s -> s.getItem() instanceof ItemTravelBelt, player); - if(!belt.isEmpty()) - player.fallDistance = -((ItemTravelBelt) belt.getItem()).fallBuffer * ((ItemCloudPendant) amuletStack.getItem()).getMaxAllowedJumps(); - } + ItemStack belt = EquipmentHandler.findOrEmpty(s -> s.getItem() instanceof ItemTravelBelt, player); + if(!belt.isEmpty()) + player.fallDistance = -((ItemTravelBelt) belt.getItem()).fallBuffer * ((ItemCloudPendant) amuletStack.getItem()).getMaxAllowedJumps(); } }); ctx.get().setPacketHandled(true); diff --git a/src/main/resources/data/curios/tags/items/belt.json b/src/main/resources/data/curios/tags/items/belt.json index 23f7dc26a..1700b6cac 100644 --- a/src/main/resources/data/curios/tags/items/belt.json +++ b/src/main/resources/data/curios/tags/items/belt.json @@ -1,8 +1,9 @@ -{ - "replace": false, - "values": [ - "botania:knockback_belt", - "botania:super_travel_belt", - "botania:travel_belt" - ] +{ + "replace": false, + "values": [ + "botania:knockback_belt", + "botania:super_travel_belt", + "botania:travel_belt", + "botania:speed_up_belt" + ] } \ No newline at end of file