From 3ae91186395994034573b0ba8cc5da91a217bf42 Mon Sep 17 00:00:00 2001 From: Furgl Date: Sun, 24 Jul 2016 19:31:08 -0500 Subject: [PATCH] v2.0 --- build.gradle | 2 +- .../java/furgl/autoPickup/AutoPickup.java | 55 ++-- src/main/java/furgl/autoPickup/Config.java | 8 +- src/main/java/furgl/autoPickup/IgnoreKey.java | 31 +++ .../furgl/autoPickup/PacketIgnoreKey.java | 43 +++ .../autoPickup/event/AttackEntityEvents.java | 125 --------- .../furgl/autoPickup/event/BlockEvents.java | 251 ------------------ .../autoPickup/event/DelayedPickupEvent.java | 88 ++++++ .../event/EntityInteractEvents.java | 61 ----- .../event/EntityItemPickupEvents.java | 3 +- .../furgl/autoPickup/event/LivingEvents.java | 79 ------ .../event/PlayerInteractEvents.java | 34 --- src/main/resources/mcmod.info | 4 +- 13 files changed, 198 insertions(+), 586 deletions(-) create mode 100644 src/main/java/furgl/autoPickup/IgnoreKey.java create mode 100644 src/main/java/furgl/autoPickup/PacketIgnoreKey.java delete mode 100644 src/main/java/furgl/autoPickup/event/AttackEntityEvents.java delete mode 100644 src/main/java/furgl/autoPickup/event/BlockEvents.java create mode 100644 src/main/java/furgl/autoPickup/event/DelayedPickupEvent.java delete mode 100644 src/main/java/furgl/autoPickup/event/EntityInteractEvents.java delete mode 100644 src/main/java/furgl/autoPickup/event/LivingEvents.java delete mode 100644 src/main/java/furgl/autoPickup/event/PlayerInteractEvents.java diff --git a/build.gradle b/build.gradle index 8aee89e..70bb07c 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,7 @@ buildscript { apply plugin: 'forge' -version = "1.7.10-1.1" +version = "1.7.10-2.0" group= "furgl.autoPickup" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "AutoPickup" diff --git a/src/main/java/furgl/autoPickup/AutoPickup.java b/src/main/java/furgl/autoPickup/AutoPickup.java index 4220544..31e2a6a 100644 --- a/src/main/java/furgl/autoPickup/AutoPickup.java +++ b/src/main/java/furgl/autoPickup/AutoPickup.java @@ -1,22 +1,25 @@ package furgl.autoPickup; +import org.lwjgl.input.Keyboard; + +import cpw.mods.fml.client.registry.ClientRegistry; +import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; +import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.event.FMLServerStartingEvent; -import furgl.autoPickup.event.AttackEntityEvents; -import furgl.autoPickup.event.BlockEvents; -import furgl.autoPickup.event.EntityInteractEvents; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; +import cpw.mods.fml.relauncher.Side; +import furgl.autoPickup.event.DelayedPickupEvent; import furgl.autoPickup.event.EntityItemPickupEvents; import furgl.autoPickup.event.EntityJoinWorldEvents; import furgl.autoPickup.event.ItemTossEvents; -import furgl.autoPickup.event.LivingEvents; import furgl.autoPickup.event.PlaySoundAtEntityEvents; -import furgl.autoPickup.event.PlayerInteractEvents; -import net.minecraft.entity.item.EntityItem; +import net.minecraft.client.settings.KeyBinding; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; @Mod(modid = AutoPickup.MODID, name = AutoPickup.MODNAME, version = AutoPickup.VERSION) @@ -24,14 +27,26 @@ public class AutoPickup { public static final String MODID = "autopickup"; public static final String MODNAME = "AutoPickup"; - public static final String VERSION = "1.1"; + public static final String VERSION = "2.0"; + public static SimpleNetworkWrapper network; + public static KeyBinding ignoreBlacklist = new KeyBinding("Ignore Blacklist", Keyboard.KEY_LMENU, "Auto Pickup"); + @EventHandler public void preInit(FMLPreInitializationEvent event) { + network = NetworkRegistry.INSTANCE.newSimpleChannel("autoPickupChannel"); + network.registerMessage(PacketIgnoreKey.Handler.class, PacketIgnoreKey.class, 1, Side.SERVER); registerEventListeners(); Config.init(event.getSuggestedConfigurationFile()); } + + @EventHandler + public void init(FMLInitializationEvent event) + { + ClientRegistry.registerKeyBinding(ignoreBlacklist); + } + @EventHandler public void serverLoad(FMLServerStartingEvent event) @@ -41,15 +56,13 @@ public void serverLoad(FMLServerStartingEvent event) public void registerEventListeners() { - MinecraftForge.EVENT_BUS.register(new BlockEvents()); - MinecraftForge.EVENT_BUS.register(new LivingEvents()); + MinecraftForge.EVENT_BUS.register(new DelayedPickupEvent()); MinecraftForge.EVENT_BUS.register(new EntityJoinWorldEvents()); MinecraftForge.EVENT_BUS.register(new PlaySoundAtEntityEvents()); - MinecraftForge.EVENT_BUS.register(new EntityInteractEvents()); - MinecraftForge.EVENT_BUS.register(new AttackEntityEvents()); - MinecraftForge.EVENT_BUS.register(new PlayerInteractEvents()); MinecraftForge.EVENT_BUS.register(new EntityItemPickupEvents()); MinecraftForge.EVENT_BUS.register(new ItemTossEvents()); + FMLCommonHandler.instance().bus().register(new IgnoreKey()); + FMLCommonHandler.instance().bus().register(new DelayedPickupEvent()); } public static boolean addItem(EntityPlayer player, ItemStack itemStack, boolean giveIfCreative) @@ -57,7 +70,7 @@ public static boolean addItem(EntityPlayer player, ItemStack itemStack, boolean if (!giveIfCreative && player.capabilities.isCreativeMode) return true; Config.syncFromConfig(player.getDisplayName()); - if (itemStack != null && !Config.blacklistNames.contains(itemStack.getItem().getItemStackDisplayName(itemStack).replace(" ", "_"))) + if (itemStack != null && (!Config.blacklistNames.contains(itemStack.getItem().getItemStackDisplayName(itemStack).replace(" ", "_")) || IgnoreKey.isPressed)) { boolean value = player.inventory.addItemStackToInventory(itemStack); if (value) @@ -67,19 +80,5 @@ public static boolean addItem(EntityPlayer player, ItemStack itemStack, boolean else return false; } - - public static void spawnEntityItem(World world, double x, double y, double z, ItemStack itemStack) - { - if (itemStack != null) - { - float f = 0.5F; - double d0 = (double)(world.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D; - double d1 = (double)(world.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D; - double d2 = (double)(world.rand.nextFloat() * f) + (double)(1.0F - f) * 0.5D; - EntityItem entityitem = new EntityItem(world, x + d0, y + d1, z + d2, itemStack); - entityitem.delayBeforeCanPickup = 10; - world.spawnEntityInWorld(entityitem); - } - } } diff --git a/src/main/java/furgl/autoPickup/Config.java b/src/main/java/furgl/autoPickup/Config.java index aa91c9b..a0dfbcb 100644 --- a/src/main/java/furgl/autoPickup/Config.java +++ b/src/main/java/furgl/autoPickup/Config.java @@ -26,9 +26,9 @@ public static void syncFromConfig(String playerName) { Property autoAddProp = Config.config.get(playerName, "AutoAdd", true); autoAdd = autoAddProp.getBoolean(); - Property itemProp = Config.config.get(playerName, "Blacklisted Items", new String[0]); + Property itemsProp = Config.config.get(playerName, "Blacklisted Items", new String[0]); blacklistNames = new ArrayList(); - String[] names = itemProp.getStringList(); + String[] names = itemsProp.getStringList(); for (int i=0; i + { + @Override + public IMessage onMessage(final PacketIgnoreKey packet, final MessageContext ctx) + { + IgnoreKey.isPressed = packet.pressed; + return null; + } + } +} \ No newline at end of file diff --git a/src/main/java/furgl/autoPickup/event/AttackEntityEvents.java b/src/main/java/furgl/autoPickup/event/AttackEntityEvents.java deleted file mode 100644 index ffdf314..0000000 --- a/src/main/java/furgl/autoPickup/event/AttackEntityEvents.java +++ /dev/null @@ -1,125 +0,0 @@ -package furgl.autoPickup.event; - -import cpw.mods.fml.common.eventhandler.EventPriority; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import furgl.autoPickup.AutoPickup; -import net.minecraft.entity.item.EntityBoat; -import net.minecraft.entity.item.EntityItemFrame; -import net.minecraft.entity.item.EntityMinecart; -import net.minecraft.entity.item.EntityMinecartContainer; -import net.minecraft.entity.item.EntityPainting; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraftforge.event.entity.player.AttackEntityEvent; - -public class AttackEntityEvents -{ - /** Detect when minecart container/item frame/painting/armor stand/boat destroyed and give contents to player. - * - * @param event - */ - @SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true) - public void onEvent(AttackEntityEvent event) - { - if (!event.entityPlayer.worldObj.isRemote) - { - if (event.target instanceof EntityItemFrame) - { - EntityItemFrame frame = (EntityItemFrame) event.target; - if (frame.getDisplayedItem() != null) - { - if (!AutoPickup.addItem(event.entityPlayer, frame.getDisplayedItem(), true)) - frame.entityDropItem(frame.getDisplayedItem(), 0.0F); - frame.setDisplayedItem((ItemStack)null); - event.setCanceled(true); - } - else if (frame.getDisplayedItem() == null) - { - if (!AutoPickup.addItem(event.entityPlayer, new ItemStack(Items.item_frame), false)) - frame.entityDropItem(new ItemStack(Items.item_frame), 0.0F); - frame.setDead(); - } - } - - else if (event.target instanceof EntityPainting) - { - EntityPainting painting = (EntityPainting) event.target; - if (!AutoPickup.addItem(event.entityPlayer, new ItemStack(Items.painting), false)) - painting.entityDropItem(new ItemStack(Items.painting), 0.0F); - painting.setDead(); - } - - else if (event.target instanceof EntityMinecart) - { - int damage; - if (event.entityPlayer.getHeldItem() != null) - damage = event.entityPlayer.getHeldItem().getItem().getMaxDamage(event.entityPlayer.getHeldItem()); - else - damage = 10; - if (event.target instanceof EntityMinecartContainer) - { - EntityMinecartContainer minecart = (EntityMinecartContainer) event.target; - if (minecart.getDataWatcher().getWatchableObjectFloat(19) + damage >= 40) - { - for (int i=0; i= 40) - { - if (minecart.getMinecartType() == 3) - { - if (!AutoPickup.addItem(event.entityPlayer, new ItemStack(Item.getItemFromBlock(Blocks.tnt)), false)) - minecart.entityDropItem(new ItemStack(Item.getItemFromBlock(Blocks.tnt)), 0.0F); - } - else if (minecart.getMinecartType() == 2) - { - if (!AutoPickup.addItem(event.entityPlayer, new ItemStack(Item.getItemFromBlock(Blocks.furnace)), false)) - minecart.entityDropItem(new ItemStack(Item.getItemFromBlock(Blocks.furnace)), 0.0F); - } - if (!AutoPickup.addItem(event.entityPlayer, new ItemStack(Items.minecart), false)) - minecart.entityDropItem(new ItemStack(Items.minecart), 0.0F); - minecart.setDead(); - } - } - } - - else if (event.target instanceof EntityBoat) - { - EntityBoat boat = (EntityBoat) event.target; - int damage; - if (event.entityPlayer.getHeldItem() != null) - damage = event.entityPlayer.getHeldItem().getItem().getMaxDamage(event.entityPlayer.getHeldItem()); - else - damage = 10; - if (boat.getDataWatcher().getWatchableObjectFloat(19) + damage >= 40) - { - if (!AutoPickup.addItem(event.entityPlayer, new ItemStack(Items.boat), false)) - boat.entityDropItem(new ItemStack(Items.boat), 0.0F); - boat.setDead(); - } - } - } - } -} diff --git a/src/main/java/furgl/autoPickup/event/BlockEvents.java b/src/main/java/furgl/autoPickup/event/BlockEvents.java deleted file mode 100644 index f9a39db..0000000 --- a/src/main/java/furgl/autoPickup/event/BlockEvents.java +++ /dev/null @@ -1,251 +0,0 @@ -package furgl.autoPickup.event; - -import java.util.Random; - -import cpw.mods.fml.common.eventhandler.EventPriority; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import furgl.autoPickup.AutoPickup; -import net.minecraft.block.BlockBed; -import net.minecraft.block.BlockBrewingStand; -import net.minecraft.block.BlockCactus; -import net.minecraft.block.BlockContainer; -import net.minecraft.block.BlockDoor; -import net.minecraft.block.BlockDoublePlant; -import net.minecraft.block.BlockJukebox; -import net.minecraft.block.BlockPistonExtension; -import net.minecraft.block.BlockReed; -import net.minecraft.block.BlockSkull; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.Item; -import net.minecraft.item.ItemShears; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTUtil; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntitySkull; -import net.minecraft.util.Facing; -import net.minecraftforge.event.world.BlockEvent; - -public class BlockEvents -{ - /** Detect when blocks are broken and give drops to player. - * - * @param event - */ - @SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true) - public void onEvent(BlockEvent.HarvestDropsEvent event) - { - if (!event.world.isRemote) - { - if (event.harvester != null) - { - for (int i=0; i drops = block.onSheared(event.getPlayer().getCurrentEquippedItem(), event.getPlayer().worldObj, event.x, event.y, event.z, net.minecraft.enchantment.EnchantmentHelper.getEnchantmentLevel(net.minecraft.enchantment.Enchantment.fortune.effectId, event.getPlayer().getCurrentEquippedItem())); - for (ItemStack stack : drops) - { - if (!AutoPickup.addItem(event.getPlayer(), stack, true)) - { - AutoPickup.spawnEntityItem(event.world, event.x, event.y, event.z, stack); - } - event.world.setBlockToAir(event.x, event.y, event.z); - } - } - else if (event.block instanceof BlockDoublePlant) - { - //Values: SUNFLOWER=0 LILAC=1 GRASS=2 FERNS=3 ROSES=4 PEONY=5 - int value = event.block.getDamageValue(event.world, event.x, event.y, event.z); - if (value != 2 && value != 3) - { - if (!AutoPickup.addItem(event.getPlayer(), new ItemStack(Blocks.double_plant, 1, value), false)) - AutoPickup.spawnEntityItem(event.world, event.x, event.y, event.z, new ItemStack(Blocks.double_plant, 1, value)); - } - else if (event.getPlayer().getCurrentEquippedItem() != null && event.getPlayer().getCurrentEquippedItem().getItem() instanceof ItemShears) - { - if (!AutoPickup.addItem(event.getPlayer(), new ItemStack(Blocks.tallgrass, 2, value-1), false)) - AutoPickup.spawnEntityItem(event.world, event.x, event.y, event.z, new ItemStack(Blocks.tallgrass, 2, value-1)); - } - else if (event.world.rand.nextInt(8) == 0) - { - if (!AutoPickup.addItem(event.getPlayer(), new ItemStack(Items.wheat_seeds), false)) - AutoPickup.spawnEntityItem(event.world, event.x, event.y, event.z, new ItemStack(Items.wheat_seeds)); - } - if (event.world.getBlock(event.x, event.y-1, event.z) instanceof BlockDoublePlant) - event.world.setBlockToAir(event.x, event.y-1, event.z); - else - event.world.setBlockToAir(event.x, event.y, event.z); - } - } - if (event.block instanceof BlockContainer) - { - TileEntity tileentity = event.world.getTileEntity(event.x, event.y, event.z); - if (tileentity instanceof IInventory) - { - IInventory inventory = (IInventory) tileentity; - for (int i=0; i0; i--) - { - event.world.setBlockToAir(event.x, y, event.z); - y--; - } - } - if (event.block instanceof BlockReed) - { - int y = event.y; - int reedsAbove = 0; - while (event.world.getBlock(event.x, y+1, event.z) instanceof BlockReed) - { - reedsAbove++; - y++; - if (!AutoPickup.addItem(event.getPlayer(), new ItemStack(Items.reeds), false)) - AutoPickup.spawnEntityItem(event.world, event.x, y, event.z, new ItemStack(Items.reeds)); - } - for (int i=reedsAbove; i>0; i--) - { - event.world.setBlockToAir(event.x, y, event.z); - y--; - } - } - event.getPlayer().addExperience(event.getExpToDrop()); - event.setExpToDrop(0); - } - } -} diff --git a/src/main/java/furgl/autoPickup/event/DelayedPickupEvent.java b/src/main/java/furgl/autoPickup/event/DelayedPickupEvent.java new file mode 100644 index 0000000..6f16837 --- /dev/null +++ b/src/main/java/furgl/autoPickup/event/DelayedPickupEvent.java @@ -0,0 +1,88 @@ +package furgl.autoPickup.event; + +import java.util.ArrayList; +import java.util.List; + +import cpw.mods.fml.common.eventhandler.EventPriority; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent; +import furgl.autoPickup.AutoPickup; +import net.minecraft.entity.item.EntityItem; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.AxisAlignedBB; +import net.minecraftforge.event.entity.living.LivingDropsEvent; +import net.minecraftforge.event.entity.player.AttackEntityEvent; +import net.minecraftforge.event.entity.player.EntityInteractEvent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent; +import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; +import net.minecraftforge.event.world.BlockEvent; + +public class DelayedPickupEvent +{ + private static final int DELAY = 1; + private static final int PICKUP_RADIUS = 2; + private static ArrayList delays = new ArrayList(); + private static ArrayList players = new ArrayList(); + private static ArrayList aabb = new ArrayList(); + + public static void setDelayedPickup(EntityPlayer player, double x, double y, double z) + { + delays.add(DELAY); + players.add(player); + aabb.add(AxisAlignedBB.getBoundingBox(x-PICKUP_RADIUS, y-PICKUP_RADIUS, z-PICKUP_RADIUS, x+PICKUP_RADIUS, y+PICKUP_RADIUS, z+PICKUP_RADIUS)); + } + + @SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true) + public void onEvent(TickEvent.WorldTickEvent event) + { + if (players.size() > 0 && event.world == players.get(0).worldObj && delays.set(0, delays.get(0)-1) == 1) + { + List items = event.world.getEntitiesWithinAABB(EntityItem.class, aabb.get(0)); + for (EntityItem item : items) + AutoPickup.addItem(players.get(0), item.getEntityItem(), true); + players.remove(0); + aabb.remove(0); + delays.remove(0); + } + } + + /** Detect when mob killed and give drops to player.*/ + @SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true) + public void onEvent(LivingDropsEvent event) + { + if (!event.entity.worldObj.isRemote && event.source.getEntity() instanceof EntityPlayer) + DelayedPickupEvent.setDelayedPickup((EntityPlayer) event.source.getEntity(), event.entity.posX, event.entity.posY, event.entity.posZ); + } + + /** Detect when player clicks jukebox and gives record to player.*/ + @SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true) + public void onEvent(PlayerInteractEvent event) + { + if (!event.entityPlayer.worldObj.isRemote && event.action == Action.RIGHT_CLICK_BLOCK) + DelayedPickupEvent.setDelayedPickup(event.entityPlayer, event.x, event.y, event.z); + } + + /** Detect when mob sheared.*/ + @SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true) + public void onEvent(EntityInteractEvent event) + { + if (!event.entityPlayer.worldObj.isRemote) + DelayedPickupEvent.setDelayedPickup(event.entityPlayer, event.target.posX, event.target.posY, event.target.posZ); + } + + /** Detect when blocks are broken and give drops to player.*/ + @SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true) + public void onEvent(BlockEvent.BreakEvent event) + { + if (!event.world.isRemote) + DelayedPickupEvent.setDelayedPickup(event.getPlayer(), event.x, event.y, event.z); + } + + /** Detect when minecart container/item frame/painting/armor stand/boat destroyed and give contents to player.*/ + @SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true) + public void onEvent(AttackEntityEvent event) + { + if (!event.entityPlayer.worldObj.isRemote) + DelayedPickupEvent.setDelayedPickup(event.entityPlayer, event.target.posX, event.target.posY, event.target.posZ); + } +} diff --git a/src/main/java/furgl/autoPickup/event/EntityInteractEvents.java b/src/main/java/furgl/autoPickup/event/EntityInteractEvents.java deleted file mode 100644 index 6f5c299..0000000 --- a/src/main/java/furgl/autoPickup/event/EntityInteractEvents.java +++ /dev/null @@ -1,61 +0,0 @@ -package furgl.autoPickup.event; - -import java.util.Random; - -import cpw.mods.fml.common.eventhandler.EventPriority; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import furgl.autoPickup.AutoPickup; -import net.minecraft.entity.passive.EntityCow; -import net.minecraft.entity.passive.EntityMooshroom; -import net.minecraft.entity.passive.EntitySheep; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraftforge.event.entity.player.EntityInteractEvent; - -public class EntityInteractEvents -{ - /** Detect when sheep sheared and give wool to player. - * - * @param event - */ - @SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true) - public void onEvent(EntityInteractEvent event) - { - if (!event.entityPlayer.worldObj.isRemote) - { - ItemStack itemstack = event.entityPlayer.inventory.getCurrentItem(); - if (event.target instanceof EntitySheep && itemstack != null && itemstack.getItem() == Items.shears && !((EntitySheep) event.target).getSheared() && !((EntitySheep) event.target).isChild()) - { - ((EntitySheep) event.target).setSheared(true); - Random rand = new Random(); - int i = 1 + rand.nextInt(3); - for (int j = 0; j < i; ++j) - { - if (!AutoPickup.addItem(event.entityPlayer, new ItemStack(Item.getItemFromBlock(Blocks.wool), 1, ((EntitySheep) event.target).getFleeceColor()), true)) - event.target.entityDropItem(new ItemStack(Item.getItemFromBlock(Blocks.wool), 1, ((EntitySheep) event.target).getFleeceColor()), 0); - } - itemstack.damageItem(1, event.entityPlayer); - ((EntitySheep) event.target).playSound("mob.sheep.shear", 1.0F, 1.0F); - } - if (event.target instanceof EntityMooshroom && itemstack != null && itemstack.getItem() == Items.shears && !((EntityMooshroom) event.target).isChild()) - { - for (int j = 0; j < 5; ++j) - { - if (!AutoPickup.addItem(event.entityPlayer, new ItemStack(Blocks.red_mushroom), true)) - event.target.entityDropItem(new ItemStack(Blocks.red_mushroom), 1); - } - itemstack.damageItem(1, event.entityPlayer); - ((EntityMooshroom) event.target).playSound("mob.sheep.shear", 1.0F, 1.0F); - EntityCow entitycow = new EntityCow(event.target.worldObj); - entitycow.setLocationAndAngles(event.target.posX, event.target.posY, event.target.posZ, event.target.rotationYaw, event.target.rotationPitch); - entitycow.setHealth(((EntityMooshroom) event.target).getHealth()); - entitycow.renderYawOffset = ((EntityMooshroom) event.target).renderYawOffset; - event.target.worldObj.spawnEntityInWorld(entitycow); - event.target.setDead(); - event.setCanceled(true); - } - } - } -} diff --git a/src/main/java/furgl/autoPickup/event/EntityItemPickupEvents.java b/src/main/java/furgl/autoPickup/event/EntityItemPickupEvents.java index 6895a71..862e1a7 100644 --- a/src/main/java/furgl/autoPickup/event/EntityItemPickupEvents.java +++ b/src/main/java/furgl/autoPickup/event/EntityItemPickupEvents.java @@ -3,6 +3,7 @@ import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import furgl.autoPickup.Config; +import furgl.autoPickup.IgnoreKey; import net.minecraftforge.event.entity.player.EntityItemPickupEvent; public class EntityItemPickupEvents @@ -11,7 +12,7 @@ public class EntityItemPickupEvents public void onEvent(EntityItemPickupEvent event) { Config.syncFromConfig(event.entityPlayer.getDisplayName()); - if (Config.blacklistNames.contains(event.item.getEntityItem().getItem().getItemStackDisplayName(event.item.getEntityItem()).replace(" ", "_"))) + if (!IgnoreKey.isPressed && Config.blacklistNames.contains(event.item.getEntityItem().getItem().getItemStackDisplayName(event.item.getEntityItem()).replace(" ", "_"))) { event.item.delayBeforeCanPickup = 10; event.setCanceled(true); diff --git a/src/main/java/furgl/autoPickup/event/LivingEvents.java b/src/main/java/furgl/autoPickup/event/LivingEvents.java deleted file mode 100644 index 6aae448..0000000 --- a/src/main/java/furgl/autoPickup/event/LivingEvents.java +++ /dev/null @@ -1,79 +0,0 @@ -package furgl.autoPickup.event; - -import cpw.mods.fml.common.eventhandler.EventPriority; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import furgl.autoPickup.AutoPickup; -import net.minecraft.entity.passive.EntityHorse; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraftforge.event.entity.living.LivingDropsEvent; - -public class LivingEvents -{ - /** Detect when mob killed and give drops to player. - * - * @param event - */ - @SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true) - public void onEvent(LivingDropsEvent event) - { - if (!event.entity.worldObj.isRemote) - { - if (event.source.getEntity() instanceof EntityPlayer && event.source.getEntity() != null) - { - EntityPlayer player = (EntityPlayer) event.source.getEntity(); - for (int i=0; i