From 0443a4aaf58eda999e3b3c575ffb98cd61010af1 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sat, 31 Dec 2016 16:15:56 +0100 Subject: [PATCH] the bat bat --- .../mod/event/ClientEvents.java | 37 +++++++++++-------- .../mod/items/ItemWingsOfTheBats.java | 21 +++++++++-- 2 files changed, 40 insertions(+), 18 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/event/ClientEvents.java b/src/main/java/de/ellpeck/actuallyadditions/mod/event/ClientEvents.java index 51f70a8e7..b3c2b74e2 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/event/ClientEvents.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/event/ClientEvents.java @@ -14,6 +14,7 @@ import de.ellpeck.actuallyadditions.mod.blocks.IHudDisplay; import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues; import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues; import de.ellpeck.actuallyadditions.mod.inventory.gui.EnergyDisplay; +import de.ellpeck.actuallyadditions.mod.items.ItemWingsOfTheBats; import de.ellpeck.actuallyadditions.mod.tile.IEnergyDisplay; import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; import de.ellpeck.actuallyadditions.mod.util.ModUtil; @@ -28,6 +29,7 @@ import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemSword; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; @@ -57,6 +59,26 @@ public class ClientEvents{ @SubscribeEvent public void onTooltipEvent(ItemTooltipEvent event){ + ItemStack stack = event.getItemStack(); + if(StackUtil.isValid(stack)){ + //Be da bland + if(ConfigBoolValues.MOST_BLAND_PERSON_EVER.isEnabled()){ + ResourceLocation regName = stack.getItem().getRegistryName(); + if(regName != null){ + if(regName.toString().toLowerCase(Locale.ROOT).contains(ModUtil.MOD_ID)){ + if(event.getToolTip().size() > 0){ + event.getToolTip().set(0, TextFormatting.RESET+event.getToolTip().get(0)); + } + } + } + } + + if(ItemWingsOfTheBats.THE_BAT_BAT.equalsIgnoreCase(stack.getDisplayName()) && stack.getItem() instanceof ItemSword){ + event.getToolTip().set(0, TextFormatting.GOLD+event.getToolTip().get(0)); + event.getToolTip().add(1, TextFormatting.RED.toString()+TextFormatting.ITALIC+"That's a really bat pun"); + } + } + //Advanced Item Info if(event.isShowAdvancedItemTooltips() && StackUtil.isValid(event.getItemStack())){ if(ConfigBoolValues.CTRL_EXTRA_INFO.isEnabled()){ @@ -133,21 +155,6 @@ public class ClientEvents{ } } } - - //Be da bland - if(ConfigBoolValues.MOST_BLAND_PERSON_EVER.isEnabled()){ - ItemStack stack = event.getItemStack(); - if(StackUtil.isValid(stack)){ - ResourceLocation regName = stack.getItem().getRegistryName(); - if(regName != null){ - if(regName.toString().toLowerCase(Locale.ROOT).contains(ModUtil.MOD_ID)){ - if(event.getToolTip().size() > 0){ - event.getToolTip().set(0, TextFormatting.RESET+event.getToolTip().get(0)); - } - } - } - } - } } @SubscribeEvent diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWingsOfTheBats.java b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWingsOfTheBats.java index 95ffb15a2..36e91e551 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWingsOfTheBats.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/items/ItemWingsOfTheBats.java @@ -18,11 +18,13 @@ import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper; import de.ellpeck.actuallyadditions.mod.util.StackUtil; import net.minecraft.block.state.IBlockState; +import net.minecraft.entity.Entity; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.passive.EntityBat; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.EnumRarity; import net.minecraft.item.ItemStack; +import net.minecraft.item.ItemSword; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; @@ -33,6 +35,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class ItemWingsOfTheBats extends ItemBase{ + public static final String THE_BAT_BAT = "the bat bat"; public static final int MAX_FLY_TIME = 800; public ItemWingsOfTheBats(String name){ @@ -90,11 +93,23 @@ public class ItemWingsOfTheBats extends ItemBase{ @SubscribeEvent public void onEntityDropEvent(LivingDropsEvent event){ - if(event.getEntityLiving().world != null && !event.getEntityLiving().world.isRemote && event.getSource().getEntity() instanceof EntityPlayer){ + Entity source = event.getSource().getEntity(); + + if(event.getEntityLiving().world != null && !event.getEntityLiving().world.isRemote && source instanceof EntityPlayer){ //Drop Wings from Bats if(ConfigBoolValues.DO_BAT_DROPS.isEnabled() && event.getEntityLiving() instanceof EntityBat){ - if(event.getEntityLiving().world.rand.nextInt(15) <= event.getLootingLevel()*2){ - event.getDrops().add(new EntityItem(event.getEntityLiving().world, event.getEntityLiving().posX, event.getEntityLiving().posY, event.getEntityLiving().posZ, new ItemStack(InitItems.itemMisc, event.getEntityLiving().world.rand.nextInt(2+event.getLootingLevel())+1, TheMiscItems.BAT_WING.ordinal()))); + int looting = event.getLootingLevel(); + + Iterable equip = source.getHeldEquipment(); + for(ItemStack stack : equip){ + if(StackUtil.isValid(stack) && ItemWingsOfTheBats.THE_BAT_BAT.equalsIgnoreCase(stack.getDisplayName()) && stack.getItem() instanceof ItemSword){ + looting += 3; + break; + } + } + + if(event.getEntityLiving().world.rand.nextInt(15) <= looting*2){ + event.getDrops().add(new EntityItem(event.getEntityLiving().world, event.getEntityLiving().posX, event.getEntityLiving().posY, event.getEntityLiving().posZ, new ItemStack(InitItems.itemMisc, event.getEntityLiving().world.rand.nextInt(2+looting)+1, TheMiscItems.BAT_WING.ordinal()))); } } }