diff options
author | Alkalus <Draknyte1@hotmail.com> | 2020-04-11 22:40:18 +0100 |
---|---|---|
committer | Alkalus <Draknyte1@hotmail.com> | 2020-04-11 22:40:18 +0100 |
commit | baf1f6ff533b9ada00aeb7de98dd0bdaf5c28e10 (patch) | |
tree | 9cf8c1f5d0519345680569c0863eb7afe54ebb6b /src/Java/gtPlusPlus/core/handler/events | |
parent | 2a5ab9b1fce054e25af438c550328d7c18680a17 (diff) | |
download | GT5-Unofficial-baf1f6ff533b9ada00aeb7de98dd0bdaf5c28e10.tar.gz GT5-Unofficial-baf1f6ff533b9ada00aeb7de98dd0bdaf5c28e10.tar.bz2 GT5-Unofficial-baf1f6ff533b9ada00aeb7de98dd0bdaf5c28e10.zip |
+ Added more milled materials.
+ Added proper structure for Flotation Cells.
+ Added all milled materials to flotation cell recipes.
+ Added Human meat drops for dead players.
+ Added Slicing mode for ICM.
% Changed getVoltageForTier to be a switch case.
% Stopped download of cape list in dev environment.
$ Adjusted how Fusion MK4 injects power, it now pulls the voltage of the hatch.
$ Fixed Fake Player Handling.
Diffstat (limited to 'src/Java/gtPlusPlus/core/handler/events')
-rw-r--r-- | src/Java/gtPlusPlus/core/handler/events/BlockEventHandler.java | 18 | ||||
-rw-r--r-- | src/Java/gtPlusPlus/core/handler/events/EntityDeathHandler.java | 65 |
2 files changed, 52 insertions, 31 deletions
diff --git a/src/Java/gtPlusPlus/core/handler/events/BlockEventHandler.java b/src/Java/gtPlusPlus/core/handler/events/BlockEventHandler.java index b3738e6ea2..6da2dac38b 100644 --- a/src/Java/gtPlusPlus/core/handler/events/BlockEventHandler.java +++ b/src/Java/gtPlusPlus/core/handler/events/BlockEventHandler.java @@ -19,6 +19,7 @@ import gtPlusPlus.core.lib.LoadedMods; import gtPlusPlus.core.material.nuclear.FLUORIDES; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.event.entity.living.LivingDropsEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent; @@ -87,7 +88,6 @@ public class BlockEventHandler { } - public static final Map<String, EntityPlayer> mCachedFakePlayers = new WeakHashMap<String, EntityPlayer>(); // Used to handle Thaumcraft Shards when TC is not installed. @SubscribeEvent @@ -97,21 +97,9 @@ public class BlockEventHandler { if (event != null && event.harvester != null && event.harvester.worldObj != null) { if (!event.harvester.worldObj.isRemote) { - EntityPlayer p = event.harvester; - ChunkCoordinates aChunkLocation = p.getPlayerCoordinates(); - - // Cache Fake Player - if (p instanceof FakePlayer || p instanceof FakeThaumcraftPlayer - || (event.harvester.getCommandSenderName() == null - || event.harvester.getCommandSenderName().length() <= 0) - || (p.isEntityInvulnerable() && !p.canCommandSenderUseCommand(0, "") - && (aChunkLocation.posX == 0 && aChunkLocation.posY == 0 - && aChunkLocation.posZ == 0))) { - mCachedFakePlayers.put(p.getUniqueID().toString(), p); - } + EntityPlayer p = event.harvester; - if (!mCachedFakePlayers.containsKey(event.harvester.getUniqueID().toString())) { - + if (PlayerUtils.isRealPlayer(p)) { // Spawns Fluorite from Lime Stone if (chanceToDropFluoriteOre != 0) { if (!oreLimestone.isEmpty() || !blockLimestone.isEmpty()) { diff --git a/src/Java/gtPlusPlus/core/handler/events/EntityDeathHandler.java b/src/Java/gtPlusPlus/core/handler/events/EntityDeathHandler.java index c4ab6edaa6..3492ee4788 100644 --- a/src/Java/gtPlusPlus/core/handler/events/EntityDeathHandler.java +++ b/src/Java/gtPlusPlus/core/handler/events/EntityDeathHandler.java @@ -7,18 +7,25 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.api.objects.data.AutoMap; import gtPlusPlus.api.objects.data.Triplet; +import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.util.math.MathUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; +import gtPlusPlus.core.util.minecraft.PlayerUtils; +import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; +import net.minecraft.util.ChunkCoordinates; +import net.minecraftforge.common.util.FakePlayer; import net.minecraftforge.event.entity.living.LivingDropsEvent; +import thaumcraft.common.lib.FakeThaumcraftPlayer; public class EntityDeathHandler { - - + + private static final HashMap<Class, AutoMap<Triplet<ItemStack, Integer, Integer>>> mMobDropMap = new HashMap<Class, AutoMap<Triplet<ItemStack, Integer, Integer>>>(); private static final HashSet<Class> mInternalClassKeyCache = new HashSet<Class>(); - + /** * Provides the ability to provide custom drops upon the death of EntityLivingBase objects. * @param aMobClass - The Base Class you want to drop this item. @@ -34,15 +41,15 @@ public class EntityDeathHandler { } aDataMap.put(aData); mMobDropMap.put(aMobClass, aDataMap); - + Logger.INFO("[Loot] Registered "+aStack.getDisplayName()+" (1-"+aMaxAmount+") as a valid drop for "+aMobClass.getCanonicalName()); - + if (!mInternalClassKeyCache.contains(aMobClass)) { mInternalClassKeyCache.add(aMobClass); } - + } - + private static ItemStack processItemDropTriplet(Triplet<ItemStack, Integer, Integer> aData) { ItemStack aLoot = aData.getValue_1(); int aMaxDrop = aData.getValue_2(); @@ -55,7 +62,7 @@ public class EntityDeathHandler { } return null; } - + private static boolean processDropsForMob(EntityLivingBase entityLiving) { AutoMap<Triplet<ItemStack, Integer, Integer>> aMobData = mMobDropMap.get(entityLiving.getClass()); boolean aDidDrop = false; @@ -74,10 +81,30 @@ public class EntityDeathHandler { } return aDidDrop; } - - - - + + + + private static void dropMeatFromPlayer(EntityPlayer aPlayer) { + + // always drop some meat. + int aBigMeatStackSize1 = MathUtils.randInt(4, 8); + aPlayer.entityDropItem(ItemUtils.simpleMetaStack(ModItems.itemMetaFood, 0, aBigMeatStackSize1), MathUtils.randInt(0, 1)); + + // additional chances for more meat. + if (MathUtils.randInt(0, 10) < 7) { + int aBigMeatStackSize2 = MathUtils.randInt(4, 8); + aPlayer.entityDropItem(ItemUtils.simpleMetaStack(ModItems.itemMetaFood, 0, aBigMeatStackSize2), MathUtils.randInt(0, 1)); + } + if (MathUtils.randInt(0, 10) < 4) { + int aBigMeatStackSize3 = MathUtils.randInt(4, 8); + aPlayer.entityDropItem(ItemUtils.simpleMetaStack(ModItems.itemMetaFood, 0, aBigMeatStackSize3), MathUtils.randInt(0, 1)); + } + if (MathUtils.randInt(0, 10) < 2) { + int aBigMeatStackSize4 = MathUtils.randInt(4, 8); + aPlayer.entityDropItem(ItemUtils.simpleMetaStack(ModItems.itemMetaFood, 0, aBigMeatStackSize4), MathUtils.randInt(0, 1)); + } + + } @SubscribeEvent public void onEntityDrop(LivingDropsEvent event) { @@ -85,10 +112,16 @@ public class EntityDeathHandler { if (event == null || event.entityLiving == null) { return; } - for (Class c : mInternalClassKeyCache) { - if (c.isInstance(event.entityLiving)) { - aDidDrop = processDropsForMob(event.entityLiving); - } + if (PlayerUtils.isRealPlayer(event.entityLiving)) { + EntityPlayer aPlayer = (EntityPlayer) event.entityLiving; + dropMeatFromPlayer(aPlayer); + } + else { + for (Class c : mInternalClassKeyCache) { + if (c.isInstance(event.entityLiving)) { + aDidDrop = processDropsForMob(event.entityLiving); + } + } } } |