From a50f409b608b2e8a551404c153c9288d5dbdce06 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Fri, 17 Jul 2015 07:38:55 +0200 Subject: [PATCH] Spiders now drop Cobweb rarely --- .../config/values/ConfigBoolValues.java | 2 ++ .../config/values/ConfigIntValues.java | 1 + .../actuallyadditions/event/LivingDropEvent.java | 12 ++++++++++++ .../actuallyadditions/items/ItemLeafBlower.java | 2 +- .../assets/actuallyadditions/lang/en_US.lang | 2 +- 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/main/java/ellpeck/actuallyadditions/config/values/ConfigBoolValues.java b/src/main/java/ellpeck/actuallyadditions/config/values/ConfigBoolValues.java index 0348ded48..741031174 100644 --- a/src/main/java/ellpeck/actuallyadditions/config/values/ConfigBoolValues.java +++ b/src/main/java/ellpeck/actuallyadditions/config/values/ConfigBoolValues.java @@ -37,6 +37,8 @@ public enum ConfigBoolValues{ DO_COFFEE_GEN("Coffee Gen", ConfigCategories.WORLD_GEN, true, "If Coffee should generate in the World"), DO_TREASURE_CHEST_GEN("Treasure Chest Gen", ConfigCategories.WORLD_GEN, true, "If Treasure Chests should generate in the World"), + DO_SPIDER_DROPS("Spider Cobweb Drop", ConfigCategories.MOB_DROPS, true, "If Cobwebs should sometimes drop from Spiders"), + PREVENT_OIL_OVERRIDE("Oil Fluid Override", ConfigCategories.FLUIDS, false, "If not registering Oil Fluids from Actually Additions if other Oil is already registered should be prevented"+ConfigurationHandler.ISSUES_WARNING), PREVENT_CANOLA_OVERRIDE("Canola Oil Fluid Override", ConfigCategories.FLUIDS, false, "If not registering Canola Oil Fluids from Actually Additions if other Canola Oil is already registered should be prevented"+ConfigurationHandler.ISSUES_WARNING), PREVENT_OIL_BLOCK_OVERRIDE("Oil Block Override", ConfigCategories.FLUIDS, false, "If not registering Oil Blocks from Actually Additions if other Oil is already registered should be prevented"+ConfigurationHandler.ISSUES_WARNING), diff --git a/src/main/java/ellpeck/actuallyadditions/config/values/ConfigIntValues.java b/src/main/java/ellpeck/actuallyadditions/config/values/ConfigIntValues.java index 1ca42285d..b307d5910 100644 --- a/src/main/java/ellpeck/actuallyadditions/config/values/ConfigIntValues.java +++ b/src/main/java/ellpeck/actuallyadditions/config/values/ConfigIntValues.java @@ -70,6 +70,7 @@ public enum ConfigIntValues{ DROPPER_TIME_NEEDED("Dropper: Time Needed", ConfigCategories.MACHINE_VALUES, 10, 1, 10000, "The Time Needed for the Dropper to drop an Item"), CAT_DROP_CHANCE("Cat Drops: Chance", ConfigCategories.OTHER, 5000, 5, 10000000, "The 1 in X chance for a Hairy Ball to Drop from a Cat with X being this value"), + SPIDER_DROP_CHANCE("Cobweb Drop from Spider: Chance", ConfigCategories.MOB_DROPS, 300, 1, 1000000000, "The 1 in X chance for a Cobweb to drop from a Spider"), RICE_AMOUNT("Rice Amount", ConfigCategories.WORLD_GEN, 15, 1, 100, "The Chance of Rice generating"), CANOLA_AMOUNT("Canola Amount", ConfigCategories.WORLD_GEN, 10, 1, 50, "The Chance of Canola generating"), diff --git a/src/main/java/ellpeck/actuallyadditions/event/LivingDropEvent.java b/src/main/java/ellpeck/actuallyadditions/event/LivingDropEvent.java index fb3739d34..64c5e8b89 100644 --- a/src/main/java/ellpeck/actuallyadditions/event/LivingDropEvent.java +++ b/src/main/java/ellpeck/actuallyadditions/event/LivingDropEvent.java @@ -1,9 +1,13 @@ package ellpeck.actuallyadditions.event; import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import ellpeck.actuallyadditions.config.values.ConfigBoolValues; +import ellpeck.actuallyadditions.config.values.ConfigIntValues; import ellpeck.actuallyadditions.items.InitItems; import ellpeck.actuallyadditions.items.metalists.TheSpecialDrops; +import net.minecraft.entity.monster.EntitySpider; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraftforge.event.entity.living.LivingDropsEvent; @@ -14,6 +18,7 @@ public class LivingDropEvent{ @SubscribeEvent public void onEntityDropEvent(LivingDropsEvent event){ if(event.source.getEntity() instanceof EntityPlayer){ + //Drop Special Items (Solidified Experience, Pearl Shards etc.) for(int i = 0; i < TheSpecialDrops.values().length; i++){ TheSpecialDrops theDrop = TheSpecialDrops.values()[i]; if(theDrop.canDrop && theDrop.dropFrom.isAssignableFrom(event.entityLiving.getClass())){ @@ -22,6 +27,13 @@ public class LivingDropEvent{ } } } + + //Drop Cobwebs from Spiders + if(ConfigBoolValues.DO_SPIDER_DROPS.isEnabled() && event.entityLiving instanceof EntitySpider){ + if(new Random().nextInt(ConfigIntValues.SPIDER_DROP_CHANCE.getValue()) <= 0){ + event.entityLiving.entityDropItem(new ItemStack(Blocks.web, new Random().nextInt(2)+1), 0); + } + } } } } diff --git a/src/main/java/ellpeck/actuallyadditions/items/ItemLeafBlower.java b/src/main/java/ellpeck/actuallyadditions/items/ItemLeafBlower.java index 3a2260991..b04eb5246 100644 --- a/src/main/java/ellpeck/actuallyadditions/items/ItemLeafBlower.java +++ b/src/main/java/ellpeck/actuallyadditions/items/ItemLeafBlower.java @@ -55,7 +55,7 @@ public class ItemLeafBlower extends Item implements INameableItem{ if(block != null && (block instanceof BlockBush || (this.isAdvanced && block instanceof BlockLeavesBase))){ WorldPos theCoord = new WorldPos(world, x+reachX, y+reachY, z+reachZ); Block theBlock = world.getBlock(theCoord.getX(), theCoord.getY(), theCoord.getZ()); - ArrayList drops = new ArrayList(); + ArrayList drops = new ArrayList<>(); int meta = world.getBlockMetadata(theCoord.getX(), theCoord.getY(), theCoord.getZ()); drops.addAll(theBlock.getDrops(world, theCoord.getX(), theCoord.getY(), theCoord.getZ(), meta, 0)); diff --git a/src/main/resources/assets/actuallyadditions/lang/en_US.lang b/src/main/resources/assets/actuallyadditions/lang/en_US.lang index a2d0da1e3..af719857c 100644 --- a/src/main/resources/assets/actuallyadditions/lang/en_US.lang +++ b/src/main/resources/assets/actuallyadditions/lang/en_US.lang @@ -399,7 +399,7 @@ tooltip.actuallyadditions.itemJamChApCi.desc=Cherry, Apple and Cinnamon tooltip.actuallyadditions.itemJamHoMeKi.desc=Honeydew Melon and Kiwi tooltip.actuallyadditions.itemJamPiCo.desc=Pineapple and Coconut -tooltip.actuallyadditions.itemHairyBall.desc.1=A Ball of Hair dropped from a Cat... +tooltip.actuallyadditions.itemHairyBall.desc.1=A Ball of Hair dropped from a (LIVING!) Cat... tooltip.actuallyadditions.itemHairyBall.desc.2=Maybe you can get something from it by using it... tooltip.actuallyadditions.blockPhantomRange.desc=Range