aboutsummaryrefslogtreecommitdiff
path: root/src/Java/gtPlusPlus/core/util
diff options
context:
space:
mode:
author‭huajijam <strhuaji@gmail.com>2019-04-19 18:29:22 +0800
committer‭huajijam <strhuaji@gmail.com>2019-04-19 18:29:22 +0800
commit399674bb9946664a880ee5e26690eb98f9aa7170 (patch)
tree7da9495cfd23b3582896428e2481afdddceb0e1b /src/Java/gtPlusPlus/core/util
parent98649eab067e2ffd4c6983fe44f75b65ffb0954b (diff)
parent7f7eecf6a84264ca229f6b8d6759004a9a21ae5d (diff)
downloadGT5-Unofficial-399674bb9946664a880ee5e26690eb98f9aa7170.tar.gz
GT5-Unofficial-399674bb9946664a880ee5e26690eb98f9aa7170.tar.bz2
GT5-Unofficial-399674bb9946664a880ee5e26690eb98f9aa7170.zip
Automatic synchronization
Diffstat (limited to 'src/Java/gtPlusPlus/core/util')
-rw-r--r--src/Java/gtPlusPlus/core/util/minecraft/EntityUtils.java77
-rw-r--r--src/Java/gtPlusPlus/core/util/minecraft/HazmatUtils.java349
-rw-r--r--src/Java/gtPlusPlus/core/util/minecraft/InventoryUtils.java82
-rw-r--r--src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java65
-rw-r--r--src/Java/gtPlusPlus/core/util/reflect/ProxyFinder.java2
5 files changed, 524 insertions, 51 deletions
diff --git a/src/Java/gtPlusPlus/core/util/minecraft/EntityUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/EntityUtils.java
index 839cb164cb..8c5a9f6581 100644
--- a/src/Java/gtPlusPlus/core/util/minecraft/EntityUtils.java
+++ b/src/Java/gtPlusPlus/core/util/minecraft/EntityUtils.java
@@ -1,24 +1,30 @@
package gtPlusPlus.core.util.minecraft;
+import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.util.List;
+import java.util.Map;
import cpw.mods.fml.common.registry.EntityRegistry;
-
+import gregtech.api.util.GT_Utility;
+import gtPlusPlus.api.objects.data.AutoMap;
+import gtPlusPlus.api.objects.minecraft.AABB;
+import gtPlusPlus.api.objects.minecraft.BlockPos;
+import gtPlusPlus.core.util.reflect.ReflectionUtils;
+import ic2.core.IC2Potion;
+import ic2.core.item.armor.ItemArmorHazmat;
import net.minecraft.block.Block;
-import net.minecraft.entity.*;
+import net.minecraft.entity.Entity;
+import net.minecraft.entity.EntityLiving;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.entity.EnumCreatureType;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
-import gregtech.api.util.GT_Utility;
-
-import gtPlusPlus.api.objects.minecraft.BlockPos;
-import ic2.core.IC2Potion;
-import ic2.core.item.armor.ItemArmorHazmat;
-
public class EntityUtils {
public static void setEntityOnFire(final Entity entity, final int length){
@@ -125,5 +131,60 @@ public class EntityUtils {
public static void doDamage(Entity entity, DamageSource dmg, int i) {
entity.attackEntityFrom(dmg, i);
}
+
+ public static boolean isTileEntityRegistered(Class aTileClass, String aTileName) {
+ Field aRegistry = ReflectionUtils.getField(ReflectionUtils.getClass("net.minecraft.tileentity.TileEntity"), "nameToClassMap");
+ Field aRegistry2 = ReflectionUtils.getField(ReflectionUtils.getClass("net.minecraft.tileentity.TileEntity"), "classToNameMap");
+ try {
+ Object o = aRegistry.get(null);
+ if (o != null) {
+ Map nameToClassMap = (Map) o;
+ if (!nameToClassMap.containsKey(aTileName)) {
+ o = aRegistry2.get(null);
+ if (o != null) {
+ Map classToNameMap = (Map) o;
+ if (!classToNameMap.containsKey(aTileClass)) {
+ return false;
+ }
+ else {
+ return true;
+ }
+ }
+ }
+ else {
+ return true;
+ }
+ }
+ } catch (IllegalArgumentException | IllegalAccessException e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+ public static double getDistance(Entity p1, Entity p2) {
+ return Math.sqrt( Math.pow(p1.posX - p2.posX, 2) + Math.pow(p1.posY - p2.posY, 2) + Math.pow(p1.posZ - p2.posZ, 2));
+ }
+
+ public static AutoMap<Entity> getEntitiesWithinBoundingBoxExcluding(Entity aExclusion, AABB aBoundingBox){
+
+ if (aExclusion == null) {
+ return new AutoMap<Entity>();
+ }
+ else {
+ List<Entity> aEntities = aBoundingBox.world().getEntitiesWithinAABBExcludingEntity(aExclusion, aBoundingBox.get());
+ return new AutoMap<Entity>(aEntities);
+ }
+ }
+
+ public static AutoMap<Entity> getEntitiesWithinBoundingBox(Class aEntityType, AABB aBoundingBox){
+
+ if (aEntityType == null) {
+ return new AutoMap<Entity>();
+ }
+ else {
+ List<Entity> aEntities = aBoundingBox.world().getEntitiesWithinAABB(aEntityType, aBoundingBox.get());
+ return new AutoMap<Entity>(aEntities);
+ }
+ }
}
diff --git a/src/Java/gtPlusPlus/core/util/minecraft/HazmatUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/HazmatUtils.java
new file mode 100644
index 0000000000..c529f60ba1
--- /dev/null
+++ b/src/Java/gtPlusPlus/core/util/minecraft/HazmatUtils.java
@@ -0,0 +1,349 @@
+package gtPlusPlus.core.util.minecraft;
+
+import static gregtech.api.GregTech_API.sBioHazmatList;
+import static gregtech.api.GregTech_API.sElectroHazmatList;
+import static gregtech.api.GregTech_API.sFrostHazmatList;
+import static gregtech.api.GregTech_API.sGasHazmatList;
+import static gregtech.api.GregTech_API.sHeatHazmatList;
+import static gregtech.api.GregTech_API.sRadioHazmatList;
+
+import java.util.Collections;
+import java.util.HashMap;
+
+import cpw.mods.fml.common.eventhandler.SubscribeEvent;
+import gregtech.api.objects.GT_HashSet;
+import gregtech.api.objects.GT_ItemStack;
+import gregtech.api.util.GT_ModHandler;
+import gtPlusPlus.GTplusplus;
+import gtPlusPlus.GTplusplus.INIT_PHASE;
+import gtPlusPlus.api.objects.Logger;
+import gtPlusPlus.api.objects.data.AutoMap;
+import gtPlusPlus.core.util.Utils;
+import ic2.core.item.armor.ItemArmorHazmat;
+import ic2.core.item.armor.ItemArmorNanoSuit;
+import ic2.core.item.armor.ItemArmorQuantumSuit;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.item.ItemStack;
+import net.minecraft.util.EnumChatFormatting;
+import net.minecraftforge.event.entity.player.ItemTooltipEvent;
+
+public class HazmatUtils {
+
+ public static final GT_HashSet<GT_ItemStack> sHazmatList = new GT_HashSet<GT_ItemStack>();
+
+ private static final HashMap<String, AutoMap<String>> mToolTips = new HashMap<String, AutoMap<String>>();
+
+ private static boolean mInit = false;
+ private static HazmatUtils mInstance;
+
+ public static void init() {
+ if (mInit) {
+ return;
+ }
+
+ mInstance = new HazmatUtils();
+
+ sHazmatList.add(GT_ModHandler.getIC2Item("hazmatHelmet", 1L, 32767));
+ sHazmatList.add(GT_ModHandler.getIC2Item("hazmatChestplate", 1L, 32767));
+ sHazmatList.add(GT_ModHandler.getIC2Item("hazmatLeggings", 1L, 32767));
+ sHazmatList.add(GT_ModHandler.getIC2Item("hazmatBoots", 1L, 32767));
+
+ // Make Nano a hazmat suit
+ addProtection(ItemUtils.getItemStackFromFQRN("IC2:itemArmorNanoHelmet:27", 1));
+ addProtection(ItemUtils.getItemStackFromFQRN("IC2:itemArmorNanoChestplate:27", 1));
+ addProtection(ItemUtils.getItemStackFromFQRN("IC2:itemArmorNanoLegs:27", 1));
+ addProtection(ItemUtils.getItemStackFromFQRN("IC2:itemArmorNanoBoots:27", 1));
+
+ Logger.INFO("[Hazmat] Registered Nano as hazmat gear.");
+
+ // Make Quantum a hazmat suit
+ addProtection(ItemUtils.getItemStackFromFQRN("IC2:itemArmorQuantumHelmet:27", 1));
+ addProtection(ItemUtils.getItemStackFromFQRN("IC2:itemArmorQuantumChestplate:27", 1));
+ addProtection(ItemUtils.getItemStackFromFQRN("IC2:itemArmorQuantumLegs:27", 1));
+ addProtection(ItemUtils.getItemStackFromFQRN("IC2:itemArmorQuantumBoots:27", 1));
+ Logger.INFO("[Hazmat] Registered Quantum as hazmat gear.");
+
+ Utils.registerEvent(mInstance);
+ Logger.INFO("[Hazmat] Registered Tooltip handler for hazmat gear.");
+ mInit = true;
+
+ }
+
+ private final static String mToolTipText = "Provides protection from:";
+
+ @SubscribeEvent
+ public void onItemTooltip(ItemTooltipEvent event) {
+ //Logger.INFO("Ticking Hazmat handler");
+ if (GTplusplus.CURRENT_LOAD_PHASE != INIT_PHASE.STARTED
+ && GTplusplus.CURRENT_LOAD_PHASE != INIT_PHASE.SERVER_START) {
+ //Logger.INFO("[Hazmat] Bad Phase : " + GTplusplus.CURRENT_LOAD_PHASE);
+ return;
+ }
+ if (event.itemStack == null || isVanillaHazmatPiece(event.itemStack)) {
+ //Logger.INFO("[Hazmat] Invalid Itemstack or vanilla hazmat");
+ return;
+ } else {
+ ItemStack aStackTemp = event.itemStack;
+ GT_ItemStack aStack = new GT_ItemStack(aStackTemp);
+ if (isNanoArmourPiece(aStackTemp) || isQuantumArmourPiece(aStackTemp)) {
+ event.toolTip.add(EnumChatFormatting.DARK_PURPLE+"Provides full hazmat protection.");
+ }
+ else {
+ //Logger.INFO("[Hazmat] Finding Tooltip Data");
+ String[] aTooltips = getTooltips(aStack);
+ if (aTooltips == null || aTooltips.length == 0) {
+ //Logger.INFO("[Hazmat] No Info!");
+ return;
+ } else {
+ //Logger.INFO("[Hazmat] Found Tooltips!");
+ if (providesProtection(aStackTemp)) {
+ event.toolTip.add(EnumChatFormatting.LIGHT_PURPLE+"Provides full hazmat protection.");
+ } else {
+ event.toolTip.add(mToolTipText);
+ for (String r : aTooltips) {
+ event.toolTip.add(" - " + r);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Static function to replace
+ * {@link #ic2.core.item.armor.ItemArmorHazmat.hasCompleteHazmat(EntityLivingBase)}.
+ * Because IC2 doesn't let us register things ourself, anything registered via
+ * GT/GT++ will return true.
+ *
+ * @param living - Entity Wearing Armour
+ * @return - Does {@link EntityLivingBase} have a full hazmat suit on?
+ */
+ public static boolean hasCompleteHazmat(EntityLivingBase living) {
+ // Entity is Null, cannot have Hazmat.
+ if (living == null || living.isDead) {
+ return false;
+ } else {
+
+ // Map All Player Armour slots
+ AutoMap<ItemStack> aEquipment = new AutoMap<ItemStack>();
+ for (int i = 1; i < 5; ++i) {
+ ItemStack stack = living.getEquipmentInSlot(i);
+
+ // Item is Null, cannot have full suit
+ if (stack == null) {
+ return false;
+ } else {
+ aEquipment.put(stack);
+ }
+ }
+
+ // Compare Equipment to all items mapped for full hazmat.
+ for (ItemStack aSlotStack : aEquipment) {
+ if (!isHazmatPiece(aSlotStack)) {
+ return false;
+ }
+ }
+
+ // We are in some kind of full hazmat, huzzah!
+ return true;
+ }
+ }
+
+ /**
+ * Is this item vanilla IC2 hazmat?
+ *
+ * @param aArmour - The Armour to provide protection.
+ * @return
+ */
+ public static boolean isVanillaHazmatPiece(ItemStack aArmour) {
+ return aArmour != null ? aArmour.getItem() instanceof ItemArmorHazmat : false;
+ }
+
+ /**
+ * Is this item vanilla IC2 Nanosuit?
+ *
+ * @param aArmour - The Armour to provide protection.
+ * @return
+ */
+ public static boolean isNanoArmourPiece(ItemStack aArmour) {
+ return aArmour != null ? aArmour.getItem() instanceof ItemArmorNanoSuit : false;
+ }
+
+ /**
+ * Is this item vanilla IC2 Quantum?
+ *
+ * @param aArmour - The Armour to provide protection.
+ * @return
+ */
+ public static boolean isQuantumArmourPiece(ItemStack aArmour) {
+ return aArmour != null ? aArmour.getItem() instanceof ItemArmorQuantumSuit : false;
+ }
+
+ /**
+ * Is this item a registered piece of full hazmat? (Provides all 6 protections)
+ *
+ * @param aStack - The Armour to provide protection.
+ * @return
+ */
+ public static boolean isHazmatPiece(ItemStack aStack) {
+ return isVanillaHazmatPiece(aStack) || providesProtection(aStack);
+ }
+
+ /**
+ * Registers the {@link ItemStack} to all types of protection. Provides full
+ * hazmat protection. Frost, Fire, Bio, Gas, Radioaton & Electricity.
+ *
+ * @param aStack - The Armour to provide protection.
+ * @return - Did we register this ItemStack properly?
+ */
+ public static boolean addProtection(ItemStack aVanStack) {
+ Logger.INFO("[Hazmat] Registering " + aVanStack.getDisplayName() + " for full Hazmat protection.");
+ GT_ItemStack aStack = getGtStackFromVanilla(aVanStack);
+ AutoMap<Boolean> aAdded = new AutoMap<Boolean>();
+ aAdded.put(addProtection_Frost(aStack));
+ aAdded.put(addProtection_Fire(aStack));
+ aAdded.put(addProtection_Biohazard(aStack));
+ aAdded.put(addProtection_Gas(aStack));
+ aAdded.put(addProtection_Radiation(aStack));
+ aAdded.put(addProtection_Electricty(aStack));
+ for (boolean b : aAdded) {
+ if (!b) {
+ return false;
+ }
+ }
+ Logger.INFO("[Hazmat] Protection added for all 6 damage types, registering to master Hazmat list.");
+ sHazmatList.add(aStack);
+ return true;
+ }
+
+ public static boolean addProtection_Frost(GT_ItemStack aStack) {
+ registerTooltip(aStack, EnumChatFormatting.AQUA + "Frost");
+ return addProtection_Generic(sFrostHazmatList, aStack);
+ }
+
+ public static boolean addProtection_Fire(GT_ItemStack aStack) {
+ registerTooltip(aStack, EnumChatFormatting.DARK_RED + "Heat");
+ return addProtection_Generic(sHeatHazmatList, aStack);
+ }
+
+ public static boolean addProtection_Biohazard(GT_ItemStack aStack) {
+ registerTooltip(aStack, EnumChatFormatting.GREEN + "Biohazards");
+ return addProtection_Generic(sBioHazmatList, aStack);
+ }
+
+ public static boolean addProtection_Gas(GT_ItemStack aStack) {
+ registerTooltip(aStack, EnumChatFormatting.WHITE + "Gas");
+ return addProtection_Generic(sGasHazmatList, aStack);
+ }
+
+ public static boolean addProtection_Radiation(GT_ItemStack aStack) {
+ registerTooltip(aStack, EnumChatFormatting.DARK_GREEN + "Radiation");
+ return addProtection_Generic(sRadioHazmatList, aStack);
+ }
+
+ public static boolean addProtection_Electricty(GT_ItemStack aStack) {
+ registerTooltip(aStack, EnumChatFormatting.YELLOW + "Electricity");
+ return addProtection_Generic(sElectroHazmatList, aStack);
+ }
+
+ private static boolean addProtection_Generic(GT_HashSet<GT_ItemStack> aSet, GT_ItemStack aStack) {
+ int aMapSize = aSet.size();
+ aSet.add(aStack);
+ return aMapSize < aSet.size();
+ }
+
+ /**
+ * Does this item provide hazmat protection? (Protection against Frost, Heat,
+ * Bio, Gas, Rads, Elec) An item may return false even if it protects against
+ * all six damage types. This is because it's not actually registered as hazmat
+ * correct.
+ *
+ * @param aStack - The item to check for protection
+ * @return
+ */
+ public static boolean providesProtection(ItemStack aStack) {
+ return providesProtetion_Generic(sHazmatList, aStack);
+ }
+
+ public static boolean providesProtetion_Frost(ItemStack aStack) {
+ return providesProtetion_Generic(sFrostHazmatList, aStack);
+ }
+
+ public static boolean providesProtetion_Fire(ItemStack aStack) {
+ return providesProtetion_Generic(sHeatHazmatList, aStack);
+ }
+
+ public static boolean providesProtetion_Biohazard(ItemStack aStack) {
+ return providesProtetion_Generic(sBioHazmatList, aStack);
+ }
+
+ public static boolean providesProtetion_Gas(ItemStack aStack) {
+ return providesProtetion_Generic(sGasHazmatList, aStack);
+ }
+
+ public static boolean providesProtetion_Radiation(ItemStack aStack) {
+ return providesProtetion_Generic(sRadioHazmatList, aStack);
+ }
+
+ public static boolean providesProtetion_Electricity(ItemStack aStack) {
+ return providesProtetion_Generic(sElectroHazmatList, aStack);
+ }
+
+ private static boolean providesProtetion_Generic(GT_HashSet aSet, ItemStack aStack) {
+ if (isVanillaHazmatPiece(aStack)) {
+ return true;
+ }
+ return aSet.getMap().containsKey(aStack);
+ }
+
+ private static String[] getTooltips(GT_ItemStack aStack) {
+ String aKey = convertGtItemstackToStringData(aStack);
+ AutoMap<String> aTempTooltipData = mToolTips.get(aKey);
+ if (aTempTooltipData == null) {
+ //Logger.INFO("[Hazmat] Item was not mapped for TTs - "+aKey);
+ return new String[] {};
+ } else {
+ //Logger.INFO("[Hazmat] Item was mapped for TTs");
+ Collections.sort(aTempTooltipData);
+ //Logger.INFO("[Hazmat] Sorted TTs");
+ return aTempTooltipData.toArray();
+ }
+ }
+
+ private static void registerTooltip(GT_ItemStack aStack, String aTooltip) {
+ String aKey = convertGtItemstackToStringData(aStack);
+ Logger.INFO("[Hazmat] Mapping " + aTooltip + " for " + aKey);
+ AutoMap<String> aTempTooltipData = mToolTips.get(aKey);
+ if (aTempTooltipData == null) {
+ Logger.INFO("No data mapped yet, creating.");
+ aTempTooltipData = new AutoMap<String>();
+ }
+ aTempTooltipData.add(aTooltip);
+ mToolTips.put(convertGtItemstackToStringData(aStack), aTempTooltipData);
+ }
+
+ public static ItemStack getStackFromGtStack(GT_ItemStack aGtStack) {
+ return ItemUtils.simpleMetaStack(aGtStack.mItem, aGtStack.mMetaData, aGtStack.mStackSize);
+ }
+
+ public static GT_ItemStack getGtStackFromVanilla(ItemStack aStack) {
+ return new GT_ItemStack(aStack);
+ }
+
+ private static String convertGtItemstackToStringData(GT_ItemStack aStack) {
+ if (aStack == null) {
+ return "NULL";
+ } else {
+ return aStack.mItem.getUnlocalizedName() + "." + aStack.mMetaData + "." + aStack.mStackSize;
+ }
+ }
+
+ private static String convertGtItemstackToStringDataIgnoreDamage(GT_ItemStack aStack) {
+ if (aStack == null) {
+ return "NULL";
+ } else {
+ return aStack.mItem.getUnlocalizedName() + "." + aStack.mStackSize;
+ }
+ }
+
+}
diff --git a/src/Java/gtPlusPlus/core/util/minecraft/InventoryUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/InventoryUtils.java
index 0d4394d773..8f12d20494 100644
--- a/src/Java/gtPlusPlus/core/util/minecraft/InventoryUtils.java
+++ b/src/Java/gtPlusPlus/core/util/minecraft/InventoryUtils.java
@@ -7,54 +7,52 @@ import net.minecraft.entity.item.EntityItem;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class InventoryUtils {
private final static Random mRandom = new Random();
- public static void dropInventoryItems(World world, int x, int y, int z, Block block){
- Object tileentity = world.getTileEntity(x, y, z);
-
- if (tileentity != null)
- {
- for (int i1 = 0; i1 < ((IInventory) tileentity).getSizeInventory(); ++i1)
- {
- ItemStack itemstack = ((IInventory) tileentity).getStackInSlot(i1);
-
- if (itemstack != null)
- {
- float f = mRandom.nextFloat() * 0.8F + 0.1F;
- float f1 = mRandom.nextFloat() * 0.8F + 0.1F;
- EntityItem entityitem;
-
- for (float f2 = mRandom.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; world.spawnEntityInWorld(entityitem))
- {
- int j1 = mRandom.nextInt(21) + 10;
-
- if (j1 > itemstack.stackSize)
- {
- j1 = itemstack.stackSize;
- }
-
- itemstack.stackSize -= j1;
- entityitem = new EntityItem(world, x + f, y + f1, z + f2, new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));
- float f3 = 0.05F;
- entityitem.motionX = (float)mRandom.nextGaussian() * f3;
- entityitem.motionY = (float)mRandom.nextGaussian() * f3 + 0.2F;
- entityitem.motionZ = (float)mRandom.nextGaussian() * f3;
-
- if (itemstack.hasTagCompound())
- {
- entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy());
- }
- }
- }
- }
-
- world.func_147453_f(x, y, z, block);
- }
-
+ public static void dropInventoryItems(World world, int x, int y, int z, Block block) {
+ TileEntity tileentity = world.getTileEntity(x, y, z);
+
+ if (tileentity != null && tileentity instanceof IInventory
+ && ((IInventory) tileentity).getSizeInventory() > 0) {
+ for (int i1 = 0; i1 < ((IInventory) tileentity).getSizeInventory(); ++i1) {
+ ItemStack itemstack = ((IInventory) tileentity).getStackInSlot(i1);
+
+ if (itemstack != null) {
+ float f = mRandom.nextFloat() * 0.8F + 0.1F;
+ float f1 = mRandom.nextFloat() * 0.8F + 0.1F;
+ EntityItem entityitem;
+
+ for (float f2 = mRandom.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; world.spawnEntityInWorld(entityitem)) {
+ int j1 = mRandom.nextInt(21) + 10;
+
+ if (j1 > itemstack.stackSize) {
+ j1 = itemstack.stackSize;
+ }
+
+ itemstack.stackSize -= j1;
+ entityitem = new EntityItem(world, x + f, y + f1, z + f2,
+ new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));
+ float f3 = 0.05F;
+ entityitem.motionX = (float) mRandom.nextGaussian() * f3;
+ entityitem.motionY = (float) mRandom.nextGaussian() * f3 + 0.2F;
+ entityitem.motionZ = (float) mRandom.nextGaussian() * f3;
+
+ if (itemstack.hasTagCompound()) {
+ entityitem.getEntityItem()
+ .setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
+ }
+ }
+ }
+ }
+
+ world.func_147453_f(x, y, z, block);
+ }
+
}
}
diff --git a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java
index d32ff4e160..ae799baa2b 100644
--- a/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java
+++ b/src/Java/gtPlusPlus/core/util/minecraft/ItemUtils.java
@@ -13,6 +13,7 @@ import gregtech.api.enums.OrePrefixes;
import gregtech.api.util.GT_ModHandler;
import gregtech.api.util.GT_OreDictUnificator;
import gregtech.api.util.GT_Utility;
+import gregtech.common.items.GT_MetaGenerated_Tool_01;
import gtPlusPlus.api.objects.Logger;
import gtPlusPlus.api.objects.data.Pair;
import gtPlusPlus.api.objects.minecraft.BlockPos;
@@ -29,6 +30,8 @@ import gtPlusPlus.core.lib.LoadedMods;
import gtPlusPlus.core.material.Material;
import gtPlusPlus.core.util.Utils;
import gtPlusPlus.core.util.reflect.ReflectionUtils;
+import gtPlusPlus.xmod.gregtech.api.items.Gregtech_MetaTool;
+import gtPlusPlus.xmod.gregtech.common.items.MetaGeneratedGregtechTools;
import gtPlusPlus.xmod.gregtech.loaders.RecipeGen_DustGeneration;
import net.minecraft.block.Block;
import net.minecraft.init.Items;
@@ -1113,5 +1116,67 @@ public class ItemUtils {
}
return aDisplay;
}
+
+ public static boolean isItemGregtechTool(ItemStack aStack) {
+ if (aStack == null) {
+ return false;
+ }
+ final Item mItem = aStack.getItem();
+ final Item aSkookum = ItemUtils.getItemFromFQRN("miscutils:gt.plusplus.metatool.01");
+ final Class aSkookClass = aSkookum.getClass();
+ if (aSkookClass.isInstance(mItem) || mItem instanceof GT_MetaGenerated_Tool_01 || mItem instanceof MetaGeneratedGregtechTools || mItem instanceof Gregtech_MetaTool || mItem == aSkookum) {
+ return true;
+ }
+ return false;
+ }
+
+ public static boolean isToolWrench(ItemStack aWrench) {
+ if (isItemGregtechTool(aWrench) && (aWrench.getItemDamage() == 16 || aWrench.getItemDamage() == 120 || aWrench.getItemDamage() == 122 || aWrench.getItemDamage() == 124 || aWrench.getItemDamage() == 7734)) {
+ return true;
+ }
+ return false;
+ }
+
+ public static boolean isToolMallet(ItemStack aMallet) {
+ if (isItemGregtechTool(aMallet) && (aMallet.getItemDamage() == 14)) {
+ return true;
+ }
+ return false;
+ }
+
+ public static boolean isToolScrewdriver(ItemStack aScrewdriver) {
+ if (isItemGregtechTool(aScrewdriver) && (aScrewdriver.getItemDamage() == 22 || aScrewdriver.getItemDamage() == 150)) {
+ return true;
+ }
+ return false;
+ }
+
+ public static boolean isToolCrowbar(ItemStack aCrowbar) {
+ if (isItemGregtechTool(aCrowbar) && (aCrowbar.getItemDamage() == 20)) {
+ return true;
+ }
+ return false;
+ }
+
+ public static boolean isToolWirecutters(ItemStack aWirecutters) {
+ if (isItemGregtechTool(aWirecutters) && (aWirecutters.getItemDamage() == 26)) {
+ return true;
+ }
+ return false;
+ }
+
+ public static boolean isToolHammer(ItemStack aHammer) {
+ if (isItemGregtechTool(aHammer) && (aHammer.getItemDamage() == 12 || aHammer.getItemDamage() == 7734)) {
+ return true;
+ }
+ return false;
+ }
+
+ public static boolean isToolSolderingIron(ItemStack aSoldering) {
+ if (isItemGregtechTool(aSoldering) && (aSoldering.getItemDamage() == 160)) {
+ return true;
+ }
+ return false;
+ }
}
diff --git a/src/Java/gtPlusPlus/core/util/reflect/ProxyFinder.java b/src/Java/gtPlusPlus/core/util/reflect/ProxyFinder.java
index d22fafb37b..aaa9b2fae7 100644
--- a/src/Java/gtPlusPlus/core/util/reflect/ProxyFinder.java
+++ b/src/Java/gtPlusPlus/core/util/reflect/ProxyFinder.java
@@ -20,7 +20,7 @@ public class ProxyFinder {
}
} catch (final NoClassDefFoundError err) {
- //its server side
+ //its client side
return null;
}
break;