diff options
author | Raven Szewczyk <git@eigenraven.me> | 2024-07-27 07:12:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-27 13:12:04 +0700 |
commit | c7b38c23c5b34a324256966f0a9335694fe8d63b (patch) | |
tree | 92aab6471745549a79c9f84f38c3076d9275ac4f /src/main/java/gtPlusPlus/core/item | |
parent | c55db9d91fa0a065d7565107a1eca679698eab04 (diff) | |
download | GT5-Unofficial-c7b38c23c5b34a324256966f0a9335694fe8d63b.tar.gz GT5-Unofficial-c7b38c23c5b34a324256966f0a9335694fe8d63b.tar.bz2 GT5-Unofficial-c7b38c23c5b34a324256966f0a9335694fe8d63b.zip |
Optimize load time (#2774)
* Load time optimization: replace recipe reflection with mixin accessor
* Save an inner loop allocation in StaticRecipeChangeLoaders
* Move Bauble event handler from individual items to GT++ proxy
* Update mobs info with more optimizations
Diffstat (limited to 'src/main/java/gtPlusPlus/core/item')
-rw-r--r-- | src/main/java/gtPlusPlus/core/item/bauble/BaseBauble.java | 29 |
1 files changed, 4 insertions, 25 deletions
diff --git a/src/main/java/gtPlusPlus/core/item/bauble/BaseBauble.java b/src/main/java/gtPlusPlus/core/item/bauble/BaseBauble.java index 92468aa6d8..76121ef266 100644 --- a/src/main/java/gtPlusPlus/core/item/bauble/BaseBauble.java +++ b/src/main/java/gtPlusPlus/core/item/bauble/BaseBauble.java @@ -9,21 +9,16 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.World; -import net.minecraftforge.event.entity.living.LivingAttackEvent; import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; import baubles.api.BaubleType; import baubles.api.IBauble; -import baubles.common.container.InventoryBaubles; -import baubles.common.lib.PlayerHandler; import cpw.mods.fml.common.Optional; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; import gregtech.api.enums.Mods; import gregtech.api.util.GT_LanguageManager; import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.NBTUtils; @Optional.InterfaceList( @@ -41,11 +36,14 @@ public class BaseBauble extends Item implements IBauble { public BaseBauble(BaubleType type) { this.mThisBauble = type; - Utils.registerEvent(this); this.setMaxStackSize(1); this.setCreativeTab(AddToCreativeTab.tabMisc); } + public List<String> getDamageNegations() { + return damageNegations; + } + @Override public String getItemStackDisplayName(final ItemStack tItem) { String key = "gtplusplus." + getUnlocalizedName() + ".name"; @@ -55,14 +53,6 @@ public class BaseBauble extends Item implements IBauble { return GT_LanguageManager.getTranslation(key); } - @SubscribeEvent - public void onPlayerAttacked(LivingAttackEvent event) { - if (event.entityLiving instanceof EntityPlayer player) { - if (getCorrectBauble(player) != null && damageNegations.contains(event.source.damageType)) - event.setCanceled(true); - } - } - @Override public boolean canEquip(ItemStack arg0, EntityLivingBase arg1) { return arg1 instanceof EntityPlayer; @@ -107,17 +97,6 @@ public class BaseBauble extends Item implements IBauble { .removeAttributeModifiers(attributes); } - public ItemStack getCorrectBauble(EntityPlayer player) { - InventoryBaubles baubles = PlayerHandler.getPlayerBaubles(player); - ItemStack stack1 = baubles.getStackInSlot(1); - ItemStack stack2 = baubles.getStackInSlot(2); - return isCorrectBauble(stack1) ? stack1 : isCorrectBauble(stack2) ? stack2 : null; - } - - private boolean isCorrectBauble(ItemStack stack) { - return stack != null && (stack.getItem() == this); - } - @Override public int getEntityLifespan(ItemStack itemStack, World world) { return Integer.MAX_VALUE; |