the bat bat

This commit is contained in:
Ellpeck 2016-12-31 16:15:56 +01:00
parent 0582f5aee3
commit 0443a4aaf5
2 changed files with 40 additions and 18 deletions

View file

@ -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

View file

@ -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<ItemStack> 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())));
}
}
}