diff --git a/ReleaseNotes.txt b/ReleaseNotes.txt index bf37efaa..6df4dfda 100644 --- a/ReleaseNotes.txt +++ b/ReleaseNotes.txt @@ -11,6 +11,8 @@ New - Added preferences for Ore Dictionary outputs for the SAG Mill and Alloy Furnace. - Defaults to Thermal Foundation when available, see OreDictionaryPreferences_Core.xml - Added config option to add Ore Dictionary entries and registered names to tooltips (default is off) +- Added support for increased Enderman Skull drops when using a TiC Cleaver or weapon with the beheading modifier + - Values adjustable in config. Default sets Cleaver = The Ender, Beheading = looting on The Ender Changes - Updated implementation of RF API to correctly handle IEnergyReceivers that are not IEnergyHandlers @@ -19,7 +21,8 @@ Changes - Improved recipe support for Thermal Foundation/Expansion in the SAG Mill and Alloy Smelter - Painted items are now rendered with a border to make it easier to tell them from the paint source blocks - Painted glow stone hardness increased to stop instant breaking -- Increased mining level of Dark Steel Pick so it can mine TiC Cobalt and Ardite ore +- Increased mining level of Dark Steel Pick so it can mine TiC Cobalt and Ardite ore (can be disabled in the config) +- Halved the skull drop chance when mobs killed by a 'fake player', such as killer joe (can be changed in the config) Bugs - #1268 Capacitor bank not honoring input redstone settings diff --git a/src/main/java/crazypants/enderio/config/Config.java b/src/main/java/crazypants/enderio/config/Config.java index 3924c9cf..c3eea6de 100644 --- a/src/main/java/crazypants/enderio/config/Config.java +++ b/src/main/java/crazypants/enderio/config/Config.java @@ -177,6 +177,10 @@ public final class Config { public static float darkSteelSwordSkullLootingModifier = 0.075f; public static float vanillaSwordSkullLootingModifier = 0.05f; public static float vanillaSwordSkullChance = 0.05f; + public static float ticCleaverSkullDropChance = 0.1f; + public static float ticBeheadingSkullModifier = 0.075f; + public static float fakePlayerSkullChance = 0.5f; + public static int darkSteelSwordPowerUsePerHit = 750; public static double darkSteelSwordEnderPearlDropChance = 1; public static double darkSteelSwordEnderPearlDropChancePerLooting = 0.5; @@ -185,6 +189,7 @@ public final class Config { public static int darkSteelPickEffeciencyObsidian = 50; public static int darkSteelPickPowerUsePerDamagePoint = 750; public static float darkSteelPickEffeciencyBoostWhenPowered = 2; + public static boolean darkSteelPickMinesTiCArdite = true; public static int darkSteelAxePowerUsePerDamagePoint = 750; public static int darkSteelAxePowerUsePerDamagePointMultiHarvest = 1500; @@ -397,7 +402,6 @@ public final class Config { public static int enchantmentSoulBoundWeight = 1; public static boolean enchantmentSoulBoundEnabled = true; - public static void load(FMLPreInitializationEvent event) { FMLCommonHandler.instance().bus().register(new Config()); @@ -797,6 +801,22 @@ public final class Config { "The chance per looting level that a skull will be dropped when using a non-dark steel sword (0 = no chance, 1 = 100% chance)").getDouble( vanillaSwordSkullLootingModifier); + ticCleaverSkullDropChance = (float) config.get(sectionDarkSteel.name, "ticCleaverSkullDropChance", ticCleaverSkullDropChance, + "The base chance that an enderman skull will be dropped when using TiC Cleaver").getDouble( + ticCleaverSkullDropChance); + ticBeheadingSkullModifier = (float) config.get(sectionPersonal.name, "ticBeheadingSkullModifier", ticBeheadingSkullModifier, + "The chance per level of Beheading that a skull will be dropped when using a TiC weapon").getDouble( + ticBeheadingSkullModifier); + + fakePlayerSkullChance = (float) config + .get( + sectionDarkSteel.name, + "fakePlayerSkullChance", + fakePlayerSkullChance, + "The ratio of skull drops when a mob is killed by a 'FakePlayer', such as Killer Joe. When set to 0 no skulls will drop, at 1 the rate of skull drops is not modified") + .getDouble( + fakePlayerSkullChance); + darkSteelSwordPowerUsePerHit = config.get(sectionDarkSteel.name, "darkSteelSwordPowerUsePerHit", darkSteelSwordPowerUsePerHit, "The amount of power (RF) used per hit.").getInt(darkSteelSwordPowerUsePerHit); darkSteelSwordEnderPearlDropChance = config.get(sectionDarkSteel.name, "darkSteelSwordEnderPearlDropChance", darkSteelSwordEnderPearlDropChance, @@ -816,6 +836,8 @@ public final class Config { "Power use (RF) per damage/durability point avoided.").getInt(darkSteelPickPowerUsePerDamagePoint); darkSteelPickEffeciencyBoostWhenPowered = (float) config.get(sectionDarkSteel.name, "darkSteelPickEffeciencyBoostWhenPowered", darkSteelPickEffeciencyBoostWhenPowered, "The increase in effciency when powered.").getDouble(darkSteelPickEffeciencyBoostWhenPowered); + darkSteelPickMinesTiCArdite = config.getBoolean("darkSteelPickMinesTiCArdite", sectionDarkSteel.name, darkSteelPickMinesTiCArdite, + "When true the dark steel pick will be able to mine TiC Ardite and Cobalt"); darkSteelAxePowerUsePerDamagePoint = config.get(sectionDarkSteel.name, "darkSteelAxePowerUsePerDamagePoint", darkSteelAxePowerUsePerDamagePoint, "Power use (RF) per damage/durability point avoided.").getInt(darkSteelAxePowerUsePerDamagePoint); diff --git a/src/main/java/crazypants/enderio/item/darksteel/ItemDarkSteelSword.java b/src/main/java/crazypants/enderio/item/darksteel/ItemDarkSteelSword.java index 082ad824..664e6e26 100644 --- a/src/main/java/crazypants/enderio/item/darksteel/ItemDarkSteelSword.java +++ b/src/main/java/crazypants/enderio/item/darksteel/ItemDarkSteelSword.java @@ -15,13 +15,16 @@ import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; +import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.EnumChatFormatting; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.EnumHelper; +import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.event.entity.living.EnderTeleportEvent; import net.minecraftforge.event.entity.living.LivingDropsEvent; import cofh.api.energy.IEnergyContainerItem; +import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; @@ -40,8 +43,8 @@ import crazypants.util.Util; public class ItemDarkSteelSword extends ItemSword implements IEnergyContainerItem, IAdvancedTooltipProvider, IDarkSteelItem, IItemOfTravel { private static final String ENDERZOO_ENDERMINY = "enderzoo.Enderminy"; - - static final ToolMaterial MATERIAL = EnumHelper.addToolMaterial("darkSteel", 5, 1561, 7, 2, 25); + + static final ToolMaterial MATERIAL = EnumHelper.addToolMaterial("darkSteel", Config.darkSteelPickMinesTiCArdite ? 5 : 3, 1561, 7, 2, 25); public static boolean isEquipped(EntityPlayer player) { if(player == null) { @@ -83,21 +86,21 @@ public class ItemDarkSteelSword extends ItemSword implements IEnergyContainerIte @Override @SideOnly(Side.CLIENT) public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List par3List) { - ItemStack is = new ItemStack(this); + ItemStack is = new ItemStack(this); par3List.add(is); is = new ItemStack(this); EnergyUpgrade.EMPOWERED_FOUR.writeToItem(is); EnergyUpgrade.setPowerFull(is); - TravelUpgrade.INSTANCE.writeToItem(is); + TravelUpgrade.INSTANCE.writeToItem(is); par3List.add(is); } - + @Override public int getIngotsRequiredForFullRepair() { - return 3; + return 3; } - + @Override public boolean isDamaged(ItemStack stack) { return false; @@ -110,56 +113,110 @@ public class ItemDarkSteelSword extends ItemSword implements IEnergyContainerIte } } - @SubscribeEvent + //Set priorty to lowest in the hope any other mod adding head drops will have already added them + //by the time this is called to prevent multiple head drops + @SubscribeEvent(priority = EventPriority.LOWEST) public void onEntityDrop(LivingDropsEvent evt) { - if(evt.source.getEntity() instanceof EntityPlayer) { - EntityPlayer player = (EntityPlayer) evt.source.getEntity(); - double skullDropChance = getSkullDropChance(player, evt); - if(Math.random() <= skullDropChance) { - ItemStack skull = getSkullForEntity(evt.entityLiving); - if(skull != null && !containsDrop(evt, skull)) { - //TODO: Shouldn't I add this to the list in the event? - Util.dropItems(player.worldObj, skull, evt.entityLiving.posX, evt.entityLiving.posY, evt.entityLiving.posZ, true); + if(!(evt.source.getEntity() instanceof EntityPlayer)) { + return; + } + + EntityPlayer player = (EntityPlayer) evt.source.getEntity(); + //Handle TiC weapons with beheading differently + if(handleBeheadingWeapons(player, evt)) { + return; + } + + double skullDropChance = getSkullDropChance(player, evt); + if(player instanceof FakePlayer) { + skullDropChance *= Config.fakePlayerSkullChance; + } + if(Math.random() <= skullDropChance) { + dropSkull(evt, player); + } + + //Special handling for ender pear drops + if(isEquipped(player)) { + String name = EntityList.getEntityString(evt.entityLiving); + if(evt.entityLiving instanceof EntityEnderman || ENDERZOO_ENDERMINY.equals(name)) { + int numPearls = 0; + if(Math.random() <= Config.darkSteelSwordEnderPearlDropChance) { + numPearls++; } - } - if(isEquipped(player)) { - String name = EntityList.getEntityString(evt.entityLiving); - if(evt.entityLiving instanceof EntityEnderman || ENDERZOO_ENDERMINY.equals(name)) { - int numPearls = 0; - if(Math.random() <= Config.darkSteelSwordEnderPearlDropChance) { + for (int i = 0; i < evt.lootingLevel; i++) { + if(Math.random() <= Config.darkSteelSwordEnderPearlDropChancePerLooting) { numPearls++; } - for (int i = 0; i < evt.lootingLevel; i++) { - if(Math.random() <= Config.darkSteelSwordEnderPearlDropChancePerLooting) { - numPearls++; - } - } - - int existing = 0; - for (EntityItem stack : evt.drops) { - if(stack.getEntityItem() != null && stack.getEntityItem().getItem() == Items.ender_pearl) { - existing += stack.getEntityItem().stackSize; - } - } - int toDrop = numPearls - existing; - if(toDrop > 0) { - evt.drops.add(Util.createDrop(player.worldObj, new ItemStack(Items.ender_pearl, toDrop, 0), evt.entityLiving.posX, evt.entityLiving.posY, - evt.entityLiving.posZ, - false)); - } - } - } + int existing = 0; + for (EntityItem stack : evt.drops) { + if(stack.getEntityItem() != null && stack.getEntityItem().getItem() == Items.ender_pearl) { + existing += stack.getEntityItem().stackSize; + } + } + int toDrop = numPearls - existing; + if(toDrop > 0) { + evt.drops.add(Util.createDrop(player.worldObj, new ItemStack(Items.ender_pearl, toDrop, 0), evt.entityLiving.posX, evt.entityLiving.posY, + evt.entityLiving.posZ, + false)); + } + + } + } + + } + + protected void dropSkull(LivingDropsEvent evt, EntityPlayer player) { + ItemStack skull = getSkullForEntity(evt.entityLiving); + if(skull != null && !containsDrop(evt, skull)) { + evt.drops.add(Util.createEntityItem(player.worldObj, skull, evt.entityLiving.posX, evt.entityLiving.posY, evt.entityLiving.posZ)); } } + private boolean handleBeheadingWeapons(EntityPlayer player, LivingDropsEvent evt) { + ItemStack equipped = player.getCurrentEquippedItem(); + if(equipped == null || equipped.stackTagCompound == null) { + return false; + } + NBTTagCompound infiToolRoot = equipped.getTagCompound().getCompoundTag("InfiTool"); + if(infiToolRoot == null) { + return false; + } + + boolean isCleaver = "tconstruct.items.tools.Cleaver".equals(equipped.getItem().getClass().getName()); + boolean hasBeheading = infiToolRoot.hasKey("Beheading"); + if(!isCleaver && !hasBeheading) { + //Use default behavior if it is not a cleaver and doesn't have beheading + return false; + } + + if(!(evt.entityLiving instanceof EntityEnderman)) { + //If its not an enderman just let TiC do its thing + //We wont modify head drops at all + return true; + } + + float fromWeapon = 0; + if(isCleaver) { + fromWeapon = Config.ticCleaverSkullDropChance; + } else { + fromWeapon = Config.vanillaSwordSkullChance; + } + float fromLooting = 0; + if(hasBeheading) { + fromLooting = Config.ticBeheadingSkullModifier * infiToolRoot.getInteger("Beheading"); + } + float skullDropChance = fromWeapon + fromLooting; + if(Math.random() <= skullDropChance) { + dropSkull(evt, player); + } + return true; + } + private double getSkullDropChance(EntityPlayer player, LivingDropsEvent evt) { - - //TODO: stack.getTagCompound().getCompoundTag("InfiTool").getInteger("Beheading") - - if(evt.entityLiving instanceof EntitySkeleton && ((EntitySkeleton) evt.entityLiving).getSkeletonType() == 1) { + if(isWitherSkeleton(evt)) { if(isEquippedAndPowered(player, Config.darkSteelSwordPowerUsePerHit)) { return Config.darkSteelSwordWitherSkullChance + (Config.darkSteelSwordWitherSkullLootingModifier * evt.lootingLevel); } else { @@ -178,6 +235,10 @@ public class ItemDarkSteelSword extends ItemSword implements IEnergyContainerIte return fromWeapon + fromLooting; } + protected boolean isWitherSkeleton(LivingDropsEvent evt) { + return evt.entityLiving instanceof EntitySkeleton && ((EntitySkeleton) evt.entityLiving).getSkeletonType() == 1; + } + private boolean containsDrop(LivingDropsEvent evt, ItemStack skull) { for (EntityItem ei : evt.drops) { if(ei != null && ei.getEntityItem() != null && ei.getEntityItem().getItem() == skull.getItem() @@ -292,7 +353,7 @@ public class ItemDarkSteelSword extends ItemSword implements IEnergyContainerIte list.add(str); } list.add(EnumChatFormatting.WHITE + Lang.localize("item.darkSteel_sword.tooltip.line1")); - if(EnergyUpgrade.itemHasAnyPowerUpgrade(itemstack)) { + if(EnergyUpgrade.itemHasAnyPowerUpgrade(itemstack)) { list.add(EnumChatFormatting.WHITE + Lang.localize("item.darkSteel_sword.tooltip.line2")); list.add(EnumChatFormatting.WHITE + Lang.localize("item.darkSteel_sword.tooltip.line3")); } @@ -312,13 +373,13 @@ public class ItemDarkSteelSword extends ItemSword implements IEnergyContainerIte public void extractInternal(ItemStack equipped, int power) { extractEnergy(equipped, power, false); } - + private boolean isTravelUpgradeActive(EntityPlayer ep, ItemStack equipped) { return isEquipped(ep) && ep.isSneaking() && TravelUpgrade.loadFromItem(equipped) != null; } @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { if(isTravelUpgradeActive(player, stack)) { if(world.isRemote) { if(TravelController.instance.activateTravelAccessable(stack, world, player, TravelSource.STAFF)) { @@ -326,7 +387,7 @@ public class ItemDarkSteelSword extends ItemSword implements IEnergyContainerIte return stack; } } - + long ticksSinceBlink = EnderIO.proxy.getTickCount() - lastBlickTick; if(ticksSinceBlink < 0) { lastBlickTick = -1; @@ -336,13 +397,11 @@ public class ItemDarkSteelSword extends ItemSword implements IEnergyContainerIte player.swingItem(); lastBlickTick = EnderIO.proxy.getTickCount(); } - } + } return stack; } - + return super.onItemRightClick(stack, world, player); } - - } diff --git a/src/main/java/crazypants/util/Util.java b/src/main/java/crazypants/util/Util.java index b319ba4c..7b471107 100644 --- a/src/main/java/crazypants/util/Util.java +++ b/src/main/java/crazypants/util/Util.java @@ -146,23 +146,32 @@ public class Util { return; } + EntityItem entityitem = createEntityItem(world, stack, x, y, z, doRandomSpread); + world.spawnEntityInWorld(entityitem); + + } + + public static EntityItem createEntityItem(World world, ItemStack stack, double x, double y, double z) { + return createEntityItem(world, stack, x, y, z, true); + } + + public static EntityItem createEntityItem(World world, ItemStack stack, double x, double y, double z, boolean doRandomSpread) { + EntityItem entityitem; if(doRandomSpread) { float f1 = 0.7F; double d = (world.rand.nextFloat() * f1) + (1.0F - f1) * 0.5D; double d1 = (world.rand.nextFloat() * f1) + (1.0F - f1) * 0.5D; double d2 = (world.rand.nextFloat() * f1) + (1.0F - f1) * 0.5D; - EntityItem entityitem = new EntityItem(world, x + d, y + d1, z + d2, stack); + entityitem = new EntityItem(world, x + d, y + d1, z + d2, stack); entityitem.delayBeforeCanPickup = 10; - world.spawnEntityInWorld(entityitem); } else { - EntityItem entityitem = new EntityItem(world, x, y, z, stack); + entityitem = new EntityItem(world, x, y, z, stack); entityitem.motionX = 0; entityitem.motionY = 0; entityitem.motionZ = 0; entityitem.delayBeforeCanPickup = 0; - world.spawnEntityInWorld(entityitem); } - + return entityitem; } public static void dropItems(World world, ItemStack stack, int x, int y, int z, boolean doRandomSpread) {