diff options
Diffstat (limited to 'src/main/java/gtPlusPlus')
45 files changed, 0 insertions, 4457 deletions
diff --git a/src/main/java/gtPlusPlus/RoadMap.java b/src/main/java/gtPlusPlus/RoadMap.java deleted file mode 100644 index e10c40d1cf..0000000000 --- a/src/main/java/gtPlusPlus/RoadMap.java +++ /dev/null @@ -1,47 +0,0 @@ -package gtPlusPlus; - -/** - * This Class purely exists to note down ideas and or plans to (re)implement things. - * - * @author Alkalus - * - */ -public class RoadMap { - - // Reorganization of Item, Block and Common Class loading. - /* - * So, due to the complex/silly way I've done things, I've ran into some circular loading problems around the mod. - * Issues occur where Classes like CI.java try access the GregtechItemList.java objects before they're actually set. - * A plan should be created to organize the best scheme to load things in the best order. - */ - - // Recreation of GUIs for all Multiblocks - /* - * Most Multi's use generic or straight out wrong GUI's on the controller. I'd like to go back and recreate all of - * these. Some could even benefit from a totally new type of UI (Instead of Text issues, just change a 2x2px area - * between red and green for status lights) These advanced GUIs are probably out of my capability, but if anyone - * thinks they're a good idea, I'll give them a go. - */ - - // Better Integration with GTNH - /* - * Refactor things to be more common, refactor things to automatically switch between GTNH and standard variants - * without having to over-abuse CORE.GTNH switches everywhere. Most of this can be done via expanding CI.java, so - * that we have automated handlers for everything (IE. getX(5) will get 5x of the correct version of X) - */ - - /* - * Thallium - Everglades only. (Mostly useless) Technetium - Has some recipes but seem to be dead ends so - * unobtainable. Polonium - Unobtainable. (Radioactive, Mostly Useless) Francium - Unobtainable. (Radioactive, - * Mostly Useless) Promethium - Unobtainable. Radium - Everglades only. (Do use, Moderately Rare) Actinium - - * Unobtainable. (Radioactive, Do use) Proactinium - Unobtainable. (Do use) Neptunium - Has some recipes but seem to - * be dead ends so unobtainable. Curium - Fusion only. Berkelium - Unobtainable. Californium - Fusion only. - * Einsteinium - Unobtainable. Fermium - Unobtainable. Strontium - Everglades only. (Do use 1) Iodine - Everglades - * only. Dysprosium - Everglades only. (Do use 1) Rhenium - Weird ABS recipe only. Flerovium - Unobtainable. Dubnium - * - Unobtainable. Seaborgium - Unobtainable. Bohrium - Unobtainable. Hassium - Unobtainable. Meitnerium - - * Unobtainable. Darmstadtium - Unobtainable. Roentgenium - Unobtainable. Copernicium - Unobtainable. Nihonium - - * Unobtainable. Moscovium - Unobtainable. Livermorium - Unobtainable. Tennessine - Unobtainable. Nobelium - - * Unobtainable. Lawrencium - Unobtainable. Astatine - Unobtainable. (Radioactive, Mostly Useless) - */ - -} diff --git a/src/main/java/gtPlusPlus/api/helpers/MaterialHelper.java b/src/main/java/gtPlusPlus/api/helpers/MaterialHelper.java deleted file mode 100644 index 4bfa15855c..0000000000 --- a/src/main/java/gtPlusPlus/api/helpers/MaterialHelper.java +++ /dev/null @@ -1,80 +0,0 @@ -package gtPlusPlus.api.helpers; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; - -import net.minecraft.item.ItemStack; - -import gregtech.api.enums.Materials; -import gregtech.api.enums.OrePrefixes; -import gregtech.api.metatileentity.implementations.GT_MetaPipeEntity_Fluid; -import gregtech.api.util.GT_OreDictUnificator; -import gtPlusPlus.core.material.Material; -import gtPlusPlus.core.util.minecraft.ItemUtils; - -public class MaterialHelper { - - public static ItemStack getComponentFromMaterial(OrePrefixes oreprefix, Material material, int amount) { - return ItemUtils.getOrePrefixStack(oreprefix, material, amount); - } - - /** - * Generates a 16 Fluid Pipe - * - * @see {@code Example: Copper 16x Pipe (Materials.Copper, Materials.Copper.mName, "Copper", ID, 60, 1000, true)} - * @param aMaterial - Pipe Material - * @param name - Pipe Internal name - * @param displayName - Pipe Display Name - * @param aID - Pipe's Meta ID - * @param baseCapacity - Pipes Base Capacity - * @param heatCapacity - Pipe Max Temp - * @param gasProof - Is Gas Proof? - * @return A boolean which corresponds to whether or not the Pipe was registered to the Ore Dictionary. - */ - public static boolean generateHexadecuplePipe(Materials aMaterial, String name, String displayName, int aID, - int baseCapacity, int heatCapacity, boolean gasProof) { - try { - Class<GT_MetaPipeEntity_Fluid> aPipeEntity = GT_MetaPipeEntity_Fluid.class; - Constructor<GT_MetaPipeEntity_Fluid> constructor = aPipeEntity.getConstructor( - new Class[] { int.class, String.class, String.class, float.class, Materials.class, int.class, - int.class, boolean.class, int.class }); - if (constructor != null) { - GT_MetaPipeEntity_Fluid aPipe; - aPipe = constructor.newInstance( - aID, - "GT_Pipe_" + name + "_Hexadecuple", - "Hexadecuple " + displayName + " Fluid Pipe", - 1.0F, - aMaterial, - baseCapacity, - heatCapacity, - gasProof, - 16); - return GT_OreDictUnificator.registerOre("pipeHexadecuple" + aMaterial, aPipe.getStackForm(1L)); - } - - } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException - | IllegalArgumentException | InvocationTargetException e) {} - return false; - } - - public static ItemStack getCells(Materials aMaterial, int i) { - return ItemUtils.getOrePrefixStack(OrePrefixes.cell, aMaterial, i); - } - - public static ItemStack getDust(Materials aMaterial, int i) { - return ItemUtils.getOrePrefixStack(OrePrefixes.dust, aMaterial, i); - } - - public static ItemStack getDustSmall(Materials aMaterial, int i) { - return ItemUtils.getOrePrefixStack(OrePrefixes.dustSmall, aMaterial, i); - } - - public static ItemStack getDustTiny(Materials aMaterial, int i) { - return ItemUtils.getOrePrefixStack(OrePrefixes.dustTiny, aMaterial, i); - } - - public static ItemStack getGems(Materials aMaterial, int i) { - return ItemUtils.getOrePrefixStack(OrePrefixes.gem, aMaterial, i); - } -} diff --git a/src/main/java/gtPlusPlus/api/interfaces/IEntityCatcher.java b/src/main/java/gtPlusPlus/api/interfaces/IEntityCatcher.java deleted file mode 100644 index e3aa00e7a1..0000000000 --- a/src/main/java/gtPlusPlus/api/interfaces/IEntityCatcher.java +++ /dev/null @@ -1,20 +0,0 @@ -package gtPlusPlus.api.interfaces; - -import net.minecraft.entity.Entity; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -import gtPlusPlus.api.objects.minecraft.BlockPos; - -public interface IEntityCatcher { - - public boolean hasEntity(ItemStack aStack); - - public Entity getStoredEntity(World aWorld, ItemStack aStack); - - public boolean setStoredEntity(World aWorld, ItemStack aStack, Entity aEntity); - - public Class<? extends Entity> getStoredEntityClass(ItemStack aStack); - - public boolean spawnStoredEntity(World aWorld, ItemStack aStack, BlockPos aPos); -} diff --git a/src/main/java/gtPlusPlus/api/interfaces/IToolable.java b/src/main/java/gtPlusPlus/api/interfaces/IToolable.java deleted file mode 100644 index d696585b76..0000000000 --- a/src/main/java/gtPlusPlus/api/interfaces/IToolable.java +++ /dev/null @@ -1,22 +0,0 @@ -package gtPlusPlus.api.interfaces; - -public interface IToolable { - - public boolean isScrewdriverable(); - - public boolean onScrewdriverLMB(); - - public boolean onScrewdriverRMB(); - - public boolean isWrenchable(); - - public boolean onWrenchLMB(); - - public boolean onWrenchRMB(); - - public boolean isMalletable(); - - public boolean onMalletLMB(); - - public boolean onMalletRMB(); -} diff --git a/src/main/java/gtPlusPlus/api/objects/GregtechException.java b/src/main/java/gtPlusPlus/api/objects/GregtechException.java deleted file mode 100644 index 083a15f790..0000000000 --- a/src/main/java/gtPlusPlus/api/objects/GregtechException.java +++ /dev/null @@ -1,25 +0,0 @@ -package gtPlusPlus.api.objects; - -public class GregtechException extends Throwable { - - private static final long serialVersionUID = 3601884582161841486L; - - public GregtechException(String aError) { - this(aError, true); - } - - public GregtechException(String aError, boolean aIsVerbose) { - Logger.ERROR("Throwing GT++ Exception!"); - Logger.ERROR("[EXCEPTION] " + aError); - if (aIsVerbose) { - Logger.INFO("Throwing GT++ Exception!"); - Logger.INFO("[EXCEPTION] " + aError); - printStackTrace(); - } - } - - @Override - public void printStackTrace() { - super.printStackTrace(); - } -} diff --git a/src/main/java/gtPlusPlus/api/objects/data/ConcurrentHashSet.java b/src/main/java/gtPlusPlus/api/objects/data/ConcurrentHashSet.java deleted file mode 100644 index 1d6cad3a38..0000000000 --- a/src/main/java/gtPlusPlus/api/objects/data/ConcurrentHashSet.java +++ /dev/null @@ -1,17 +0,0 @@ -package gtPlusPlus.api.objects.data; - -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -public class ConcurrentHashSet<V> extends ConcurrentSet<V> { - - private static final long serialVersionUID = -1293478938482781728L; - - public ConcurrentHashSet() { - this(new ConcurrentHashMap<Integer, V>()); - } - - public ConcurrentHashSet(ConcurrentMap<Integer, V> defaultMapType) { - super(defaultMapType); - } -} diff --git a/src/main/java/gtPlusPlus/api/objects/data/ConcurrentSet.java b/src/main/java/gtPlusPlus/api/objects/data/ConcurrentSet.java deleted file mode 100644 index aaa759edfa..0000000000 --- a/src/main/java/gtPlusPlus/api/objects/data/ConcurrentSet.java +++ /dev/null @@ -1,53 +0,0 @@ -package gtPlusPlus.api.objects.data; - -import java.io.Serializable; -import java.util.AbstractSet; -import java.util.Iterator; -import java.util.concurrent.ConcurrentMap; - -public abstract class ConcurrentSet<E> extends AbstractSet<E> implements Serializable { - - private static final long serialVersionUID = -6761513279741915432L; - - private final ConcurrentMap<Integer, E> mInternalMap; - - private int mInternalID = 0; - - /** - * Creates a new instance which wraps the specified {@code map}. - */ - public ConcurrentSet(ConcurrentMap<Integer, E> aMap) { - mInternalMap = aMap; - } - - @Override - public int size() { - return mInternalMap.size(); - } - - @Override - public boolean contains(Object o) { - return mInternalMap.containsKey(o); - } - - @Override - public boolean add(E o) { - return mInternalMap.putIfAbsent(mInternalID++, o) == null; - } - - @Override - public boolean remove(Object o) { - return mInternalMap.remove(o) != null; - } - - @Override - public void clear() { - this.mInternalID = 0; - mInternalMap.clear(); - } - - @Override - public Iterator<E> iterator() { - return mInternalMap.values().iterator(); - } -} diff --git a/src/main/java/gtPlusPlus/api/objects/data/FlexiblePair.java b/src/main/java/gtPlusPlus/api/objects/data/FlexiblePair.java deleted file mode 100644 index 8ec21dab59..0000000000 --- a/src/main/java/gtPlusPlus/api/objects/data/FlexiblePair.java +++ /dev/null @@ -1,39 +0,0 @@ -package gtPlusPlus.api.objects.data; - -import java.io.Serializable; - -import com.google.common.base.Objects; - -public class FlexiblePair<K, V> implements Serializable { - - /** - * SVUID - */ - private static final long serialVersionUID = 1250550491092812443L; - - private final K key; - private V value; - - public FlexiblePair(final K key, final V value) { - this.key = key; - this.value = value; - } - - public final K getKey() { - return this.key; - } - - public final V getValue() { - return this.value; - } - - public final void setValue(V aObj) { - value = aObj; - } - - @Override - public int hashCode() { - Integer aCode = Objects.hashCode(getKey(), getValue()); - return aCode != null ? aCode : super.hashCode(); - } -} diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/FakeBlockPos.java b/src/main/java/gtPlusPlus/api/objects/minecraft/FakeBlockPos.java deleted file mode 100644 index 4af3df18ba..0000000000 --- a/src/main/java/gtPlusPlus/api/objects/minecraft/FakeBlockPos.java +++ /dev/null @@ -1,272 +0,0 @@ -package gtPlusPlus.api.objects.minecraft; - -import java.util.HashSet; -import java.util.Set; - -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.world.World; -import net.minecraftforge.common.DimensionManager; - -import gtPlusPlus.api.objects.data.AutoMap; - -public class FakeBlockPos extends BlockPos { - - private static final long serialVersionUID = -6442245826092414593L; - private transient Block aBlockAtPos; - private int aBlockMetaAtPos = 0; - - public static FakeBlockPos generateBlockPos(String sUUID) { - String[] s2 = sUUID.split("@"); - return new FakeBlockPos(s2); - } - - public FakeBlockPos(String[] s) { - this(Integer.parseInt(s[1]), Integer.parseInt(s[2]), Integer.parseInt(s[3]), Integer.parseInt(s[0])); - } - - public FakeBlockPos(int x, int y, int z, Block aBlock, int aMeta) { - this(x, y, z, 0); - aBlockAtPos = aBlock; - aBlockMetaAtPos = aMeta; - } - - private FakeBlockPos(int x, int y, int z, int dim) { - this(x, y, z, DimensionManager.getWorld(dim)); - } - - private FakeBlockPos(int x, int y, int z, World dim) { - super(x, y, z, null); - } - - @Override - public String getLocationString() { - String S = "" + this.xPos + "@" + this.yPos + "@" + this.zPos; - return S; - } - - @Override - public String getUniqueIdentifier() { - String S = "" + this.xPos - + "@" - + this.yPos - + "@" - + this.zPos - + this.aBlockAtPos.getLocalizedName() - + "@" - + this.aBlockMetaAtPos; - return S; - } - - @Override - public int hashCode() { - int hash = 5; - hash += (13 * this.xPos); - hash += (19 * this.yPos); - hash += (31 * this.zPos); - hash += (17 * this.dim); - return hash; - } - - @Override - public boolean equals(Object other) { - if (other == null) { - return false; - } - if (other == this) { - return true; - } - if (!(other instanceof FakeBlockPos)) { - return false; - } - FakeBlockPos otherPoint = (FakeBlockPos) other; - return this.xPos == otherPoint.xPos && this.yPos == otherPoint.yPos && this.zPos == otherPoint.zPos; - } - - public int distanceFrom(FakeBlockPos target) { - if (target.dim != this.dim) { - return Short.MIN_VALUE; - } - return distanceFrom(target.xPos, target.yPos, target.zPos); - } - - /** - * - * @param x X coordinate of target. - * @param y Y coordinate of target. - * @param z Z coordinate of target. - * @return square of distance - */ - @Override - public int distanceFrom(int x, int y, int z) { - int distanceX = this.xPos - x; - int distanceY = this.yPos - y; - int distanceZ = this.zPos - z; - return distanceX * distanceX + distanceY * distanceY + distanceZ * distanceZ; - } - - public boolean isWithinRange(FakeBlockPos target, int range) { - if (target.dim != this.dim) { - return false; - } - return isWithinRange(target.xPos, target.yPos, target.zPos, range); - } - - @Override - public boolean isWithinRange(int x, int y, int z, int range) { - return distanceFrom(x, y, z) <= (range * range); - } - - @Override - public FakeBlockPos getUp() { - return new FakeBlockPos(this.xPos, this.yPos + 1, this.zPos, this.dim); - } - - @Override - public FakeBlockPos getDown() { - return new FakeBlockPos(this.xPos, this.yPos - 1, this.zPos, this.dim); - } - - @Override - public FakeBlockPos getXPos() { - return new FakeBlockPos(this.xPos + 1, this.yPos, this.zPos, this.dim); - } - - @Override - public FakeBlockPos getXNeg() { - return new FakeBlockPos(this.xPos - 1, this.yPos, this.zPos, this.dim); - } - - @Override - public FakeBlockPos getZPos() { - return new FakeBlockPos(this.xPos, this.yPos, this.zPos + 1, this.dim); - } - - @Override - public FakeBlockPos getZNeg() { - return new FakeBlockPos(this.xPos, this.yPos, this.zPos - 1, this.dim); - } - - @Override - public AutoMap<BlockPos> getSurroundingBlocks() { - AutoMap<BlockPos> sides = new AutoMap<BlockPos>(); - sides.put(getUp()); - sides.put(getDown()); - sides.put(getXPos()); - sides.put(getXNeg()); - sides.put(getZPos()); - sides.put(getZNeg()); - return sides; - } - - @Override - public Block getBlockAtPos() { - return getBlockAtPos(this); - } - - public Block getBlockAtPos(FakeBlockPos pos) { - return getBlockAtPos(world, pos); - } - - public Block getBlockAtPos(World world, FakeBlockPos pos) { - return aBlockAtPos; - } - - @Override - public int getMetaAtPos() { - return getMetaAtPos(this); - } - - public int getMetaAtPos(FakeBlockPos pos) { - return getMetaAtPos(world, pos); - } - - public int getMetaAtPos(World world, FakeBlockPos pos) { - return aBlockMetaAtPos; - } - - @Override - public boolean hasSimilarNeighbour() { - return hasSimilarNeighbour(false); - } - - /** - * @param strict - Does this check Meta Data? - * @return - Does this block have a neighbour that is the same? - */ - @Override - public boolean hasSimilarNeighbour(boolean strict) { - for (BlockPos g : getSurroundingBlocks().values()) { - if (getBlockAtPos(g) == getBlockAtPos()) { - if (!strict) { - return true; - } else { - if (getMetaAtPos() == getMetaAtPos(g)) { - return true; - } - } - } - } - return false; - } - - @Override - public AutoMap<BlockPos> getSimilarNeighbour() { - return getSimilarNeighbour(false); - } - - /** - * @param strict - Does this check Meta Data? - * @return - Does this block have a neighbour that is the same? - */ - @Override - public AutoMap<BlockPos> getSimilarNeighbour(boolean strict) { - AutoMap<BlockPos> sides = new AutoMap<BlockPos>(); - for (BlockPos g : getSurroundingBlocks().values()) { - if (getBlockAtPos(g) == getBlockAtPos()) { - if (!strict) { - sides.put(g); - } else { - if (getMetaAtPos() == getMetaAtPos(g)) { - sides.put(g); - } - } - } - } - return sides; - } - - @Override - public Set<BlockPos> getValidNeighboursAndSelf() { - AutoMap<BlockPos> h = getSimilarNeighbour(true); - h.put(this); - Set<BlockPos> result = new HashSet<BlockPos>(); - for (BlockPos f : h.values()) { - result.add(f); - } - return result; - } - - /** - * Called when a plant grows on this block, only implemented for saplings using the WorldGen*Trees classes right - * now. Modder may implement this for custom plants. This does not use ForgeDirection, because large/huge trees can - * be located in non-representable direction, so the source location is specified. Currently this just changes the - * block to dirt if it was grass. - * - * Note: This happens DURING the generation, the generation may not be complete when this is called. - * - * @param world Current world - * @param x Soil X - * @param y Soil Y - * @param z Soil Z - * @param sourceX Plant growth location X - * @param sourceY Plant growth location Y - * @param sourceZ Plant growth location Z - */ - public void onPlantGrow(FakeWorld world, int x, int y, int z, int sourceX, int sourceY, int sourceZ) { - if (getBlockAtPos() == Blocks.grass || getBlockAtPos() == Blocks.farmland) { - this.aBlockAtPos = Blocks.dirt; - this.aBlockMetaAtPos = 0; - } - } -} diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/FakeWorld.java b/src/main/java/gtPlusPlus/api/objects/minecraft/FakeWorld.java deleted file mode 100644 index be158a38cd..0000000000 --- a/src/main/java/gtPlusPlus/api/objects/minecraft/FakeWorld.java +++ /dev/null @@ -1,154 +0,0 @@ -package gtPlusPlus.api.objects.minecraft; - -import java.util.HashMap; - -import net.minecraft.block.Block; -import net.minecraft.block.material.Material; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.biome.BiomeGenBase; -import net.minecraftforge.common.util.ForgeDirection; - -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.data.AutoMap; -import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.util.minecraft.ItemUtils; - -public class FakeWorld implements IBlockAccess { - - public static HashMap<String, FakeBlockPos> mStaticFakeWorldData; - - public HashMap<String, FakeBlockPos> mFakeWorldData = new HashMap<String, FakeBlockPos>(); - - /** - * Must be an odd number - */ - private int aWorldSize = 99; - - private final int aDistanceFromOrigin; - private final int aWorldHeight; - - public FakeWorld() { - this(99); - } - - public FakeWorld(int aSize) { - if (MathUtils.isNumberEven(aSize)) { - aSize++; - } - aWorldSize = aSize; - aDistanceFromOrigin = ((aWorldSize - 1) / 2); - aWorldHeight = aDistanceFromOrigin >= 255 ? 255 : aDistanceFromOrigin; - Logger.WARNING("Created a Fake World with data:"); - Logger.WARNING("World Size: " + aWorldSize); - Logger.WARNING("Distance from Origin in each dir: " + aDistanceFromOrigin); - Logger.WARNING("World Height: " + aWorldHeight); - init(); - } - - public void init() { - - /* - * if (mStaticFakeWorldData == null) { Logger.WARNING("Setting all Blocks in Fake World to Air."); - * mStaticFakeWorldData = new HashMap<String, FakeBlockPos>(); for (int y=0;y<=aWorldHeight;y++) { for (int - * x=-aDistanceFromOrigin;x<=aDistanceFromOrigin;x++) { for (int - * z=-aDistanceFromOrigin;z<=aDistanceFromOrigin;z++) { FakeBlockPos aTempPos = new FakeBlockPos(x, y, z, - * Blocks.air, 0); mStaticFakeWorldData.put(aTempPos.getLocationString(), aTempPos); } } } } - */ - // if (mStaticFakeWorldData != null) { - // Logger.WARNING(" Instancing static air world."); - mFakeWorldData = new HashMap<String, FakeBlockPos>(); - // mFakeWorldData = (HashMap<String, FakeBlockPos>) mStaticFakeWorldData.clone(); - // } - - // Logger.WARNING("Initialisation of FakeWorld is now complete."); - } - - public FakeBlockPos getBlockAtCoords(int x, int y, int z) { - String S = "" + x + "@" + y + "@" + z; - FakeBlockPos aBlock = mFakeWorldData.get(S); - if (aBlock == null) { - return new FakeBlockPos(x, y, z, Blocks.air, 0); - } - return aBlock; - } - - public void setBlockAtCoords(int x, int y, int z, Block aBlock, int aMeta) { - FakeBlockPos aTempPos = new FakeBlockPos(x, y, z, aBlock, aMeta); - Logger.WARNING("Setting " + x + ", " + y + ", " + z + " to " + aBlock.getLocalizedName() + ":" + aMeta); - mFakeWorldData.put(aTempPos.getLocationString(), aTempPos); - } - - public AutoMap<ItemStack> getAllBlocksStoredInFakeWorld() { - AutoMap<ItemStack> aOutput = new AutoMap<ItemStack>(); - for (FakeBlockPos aPos : mFakeWorldData.values()) { - if (aPos == null || aPos.getBlockAtPos() == Blocks.air) { - continue; - } else { - ItemStack aTempStack = ItemUtils.simpleMetaStack(aPos.getBlockAtPos(), aPos.getMetaAtPos(), 1); - if (ItemUtils.checkForInvalidItems(aTempStack)) { - // Logger.WARNING("Output: "+aTempStack.getDisplayName()); - aOutput.put(aTempStack); - } - } - } - return aOutput; - } - - @Override - public Block getBlock(int x, int y, int z) { - FakeBlockPos aPos = getBlockAtCoords(x, y, z); - return aPos.getBlockAtPos(); - } - - @Override - public boolean isAirBlock(int x, int y, int z) { - Block aBlock = getBlock(x, y, z); - return aBlock == Blocks.air || aBlock.getMaterial() == Material.air; - } - - @Override - public TileEntity getTileEntity(int p_147438_1_, int p_147438_2_, int p_147438_3_) { - return null; - } - - @Override - public int getLightBrightnessForSkyBlocks(int p_72802_1_, int p_72802_2_, int p_72802_3_, int p_72802_4_) { - return 0; - } - - @Override - public int getBlockMetadata(int x, int y, int z) { - return getBlockAtCoords(x, y, z).getMetaAtPos(); - } - - @Override - public int isBlockProvidingPowerTo(int p_72879_1_, int p_72879_2_, int p_72879_3_, int p_72879_4_) { - return 0; - } - - @Override - public BiomeGenBase getBiomeGenForCoords(int p_72807_1_, int p_72807_2_) { - return BiomeGenBase.plains; - } - - @Override - public int getHeight() { - return aWorldHeight; - } - - @Override - public boolean extendedLevelsInChunkCache() { - return false; - } - - @Override - public boolean isSideSolid(int x, int y, int z, ForgeDirection side, boolean _default) { - if (!isAirBlock(x, y, z)) { - return true; - } - return false; - } -} diff --git a/src/main/java/gtPlusPlus/api/objects/minecraft/FormattedTooltipString.java b/src/main/java/gtPlusPlus/api/objects/minecraft/FormattedTooltipString.java deleted file mode 100644 index 73d17aba39..0000000000 --- a/src/main/java/gtPlusPlus/api/objects/minecraft/FormattedTooltipString.java +++ /dev/null @@ -1,23 +0,0 @@ -package gtPlusPlus.api.objects.minecraft; - -public class FormattedTooltipString { - - public final String mText; - public final boolean mPrefix; - - public FormattedTooltipString(String aText, boolean aPrefix) { - mText = aText; - mPrefix = aPrefix; - } - - public String getTooltip(Object aTagValue) { - String aTip; - - if (mPrefix) { - aTip = mText + ": " + aTagValue.toString(); - } else { - aTip = "" + aTagValue.toString() + ": " + mText; - } - return aTip; - } -} diff --git a/src/main/java/gtPlusPlus/core/block/base/BlockBaseNBT.java b/src/main/java/gtPlusPlus/core/block/base/BlockBaseNBT.java deleted file mode 100644 index 55f1df240f..0000000000 --- a/src/main/java/gtPlusPlus/core/block/base/BlockBaseNBT.java +++ /dev/null @@ -1,86 +0,0 @@ -package gtPlusPlus.core.block.base; - -import net.minecraft.block.Block; -import net.minecraft.block.BlockContainer; -import net.minecraft.block.material.Material; -import net.minecraft.entity.EnumCreatureType; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.IIcon; -import net.minecraft.world.Explosion; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; - -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.item.base.itemblock.ItemBlockNBT; - -public abstract class BlockBaseNBT extends BlockContainer { - - @SideOnly(Side.CLIENT) - private IIcon textureTop; - - @SideOnly(Side.CLIENT) - private IIcon textureBottom; - - @SideOnly(Side.CLIENT) - private IIcon textureFront; - - public BlockBaseNBT(final Material material, final String unlocalName, final String displayName) { - super(material); - this.setBlockName(unlocalName); - this.setCreativeTab(AddToCreativeTab.tabMachines); - GameRegistry.registerBlock(this, ItemBlockNBT.class, unlocalName); - // LanguageRegistry.addName(this, displayName); - } - - /** - * Gets the block's texture. Args: side, meta - */ - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(final int ordinalSide, final int meta) { - return ordinalSide == 1 ? this.textureTop - : (ordinalSide == 0 ? this.textureBottom - : ((ordinalSide != 2) && (ordinalSide != 4) ? this.blockIcon : this.textureFront)); - } - - @Override - public abstract TileEntity createNewTileEntity(final World world, final int p_149915_2_); - - @Override - public void breakBlock(final World world, final int x, final int y, final int z, final Block block, - final int meta) { - super.breakBlock(world, x, y, z, block, meta); - } - - @Override - public void onBlockDestroyedByPlayer(final World world, final int x, final int y, final int z, final int meta) { - super.onBlockDestroyedByPlayer(world, x, y, z, meta); - } - - @Override - public void onBlockDestroyedByExplosion(final World world, final int x, final int y, final int z, - final Explosion explosion) { - super.onBlockDestroyedByExplosion(world, x, y, z, explosion); - } - - @Override - public void onBlockHarvested(final World world, final int x, final int y, final int z, final int meta, - final EntityPlayer player) { - super.onBlockHarvested(world, x, y, z, meta, player); - } - - @Override - public void onBlockExploded(final World world, final int x, final int y, final int z, final Explosion explosion) { - super.onBlockExploded(world, x, y, z, explosion); - } - - @Override - public boolean canCreatureSpawn(final EnumCreatureType type, final IBlockAccess world, final int x, final int y, - final int z) { - return false; - } -} diff --git a/src/main/java/gtPlusPlus/core/fluids/BlockFluidBase.java b/src/main/java/gtPlusPlus/core/fluids/BlockFluidBase.java deleted file mode 100644 index 9c4fb4d66a..0000000000 --- a/src/main/java/gtPlusPlus/core/fluids/BlockFluidBase.java +++ /dev/null @@ -1,106 +0,0 @@ -package gtPlusPlus.core.fluids; - -import static gregtech.api.enums.Mods.GTPlusPlus; - -import net.minecraft.block.material.Material; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.Entity; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.util.IIcon; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.BlockFluidClassic; -import net.minecraftforge.fluids.Fluid; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gtPlusPlus.core.util.Utils; - -public class BlockFluidBase extends BlockFluidClassic { - - @SideOnly(Side.CLIENT) - protected static IIcon stillIcon; - - @SideOnly(Side.CLIENT) - protected static IIcon flowingIcon; - - protected final short[] mRGB; - - public BlockFluidBase(Fluid fluid, short[] aRGB) { - this(fluid, Material.water, aRGB); - } - - public BlockFluidBase(Fluid fluid, Material material, short[] aRGB) { - super(fluid, material); - mRGB = aRGB; - this.setHardness(100.0F); - this.setLightOpacity(3); - this.disableStats(); - } - - @Override - public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity ent) { - if (!(ent instanceof EntityLivingBase)) { - return; - } - /* - * EntityLivingBase player = (EntityLivingBase) ent; int pot = world.rand.nextInt(Potion.potionTypes.length); - * Potion.potionTypes[pot].performEffect(player, 40); - */ - } - - @Override - public IIcon getIcon(int ordinalSide, int meta) { - return (ordinalSide == 0 || ordinalSide == 1) ? stillIcon : flowingIcon; - } - - @SideOnly(Side.CLIENT) - @Override - public void registerBlockIcons(IIconRegister register) { - if (stillIcon == null) { - stillIcon = register.registerIcon(GTPlusPlus.ID + ":" + "fluids/fluid.fluid.autogenerated.still"); - } - if (flowingIcon == null) { - flowingIcon = register.registerIcon(GTPlusPlus.ID + ":" + "fluids/fluid.fluid.autogenerated.flowing"); - } - } - - @Override - public int getBlockColor() { - if (mRGB != null && mRGB.length >= 3) { - return Utils.rgbtoHexValue(mRGB[0], mRGB[1], mRGB[2]); - } - return super.getBlockColor(); - } - - @Override - public int getRenderColor(int aMeta) { - if (mRGB != null && mRGB.length >= 3) { - return Utils.rgbtoHexValue(mRGB[0], mRGB[1], mRGB[2]); - } - return super.getRenderColor(aMeta); - } - - @Override - public boolean recolourBlock(World world, int x, int y, int z, ForgeDirection side, int colour) { - // TODO Auto-generated method stub - return super.recolourBlock(world, x, y, z, side, colour); - } - - @Override - public boolean canDisplace(IBlockAccess world, int x, int y, int z) { - if (world.getBlock(x, y, z).getMaterial().isLiquid()) { - return false; - } - return super.canDisplace(world, x, y, z); - } - - @Override - public boolean displaceIfPossible(World world, int x, int y, int z) { - if (world.getBlock(x, y, z).getMaterial().isLiquid()) { - return false; - } - return super.displaceIfPossible(world, x, y, z); - } -} diff --git a/src/main/java/gtPlusPlus/core/fluids/FactoryFluid.java b/src/main/java/gtPlusPlus/core/fluids/FactoryFluid.java deleted file mode 100644 index 96936cced8..0000000000 --- a/src/main/java/gtPlusPlus/core/fluids/FactoryFluid.java +++ /dev/null @@ -1,67 +0,0 @@ -package gtPlusPlus.core.fluids; - -import static gregtech.api.enums.Mods.GTPlusPlus; - -import net.minecraft.block.Block; -import net.minecraft.item.EnumRarity; -import net.minecraftforge.fluids.Fluid; - -import gregtech.api.GregTech_API; - -public class FactoryFluid extends Fluid implements Runnable { - - private final String mTextureName; - private final short[] mRGBa; - - public FactoryFluid(String fluidName, final short[] aRGBa) { - this( - fluidName, - null, - Short.MIN_VALUE, - Short.MIN_VALUE, - Short.MIN_VALUE, - Short.MIN_VALUE, - false, - EnumRarity.common, - aRGBa); - } - - public FactoryFluid(String fluidName, int luminosity, int density, int temp, int viscosity, final short[] aRGBa) { - this( - fluidName, - null, - luminosity, - density, - temp, - viscosity, - (density == Short.MIN_VALUE || density >= 0 ? false : true), - EnumRarity.common, - aRGBa); - } - - public FactoryFluid(String fluidName, Block aBlock, int luminosity, int density, int temp, int viscosity, - boolean gas, EnumRarity aRarity, final short[] aRGBa) { - super(fluidName); - this.mRGBa = aRGBa; - this.setBlock(aBlock); - if (luminosity != Short.MIN_VALUE) this.setLuminosity(luminosity); - if (density != Short.MIN_VALUE) this.setDensity(density); - if (temp != Short.MIN_VALUE) this.setTemperature(temp); - if (viscosity != Short.MIN_VALUE) this.setViscosity(viscosity); - this.setGaseous(gas); - this.setRarity(aRarity); - this.mTextureName = GTPlusPlus.ID + ":fluids/fluid.fluid.autogenerated"; - GregTech_API.sGTBlockIconload.add(this); - } - - @Override - public int getColor() { - return (Math.max(0, Math.min(255, this.mRGBa[0])) << 16) | (Math.max(0, Math.min(255, this.mRGBa[1])) << 8) - | Math.max(0, Math.min(255, this.mRGBa[2])); - } - - @Override - public void run() { - this.setIcons(GregTech_API.sBlockIcons.registerIcon(this.mTextureName)); - } -} diff --git a/src/main/java/gtPlusPlus/core/gui/item/box/GuiBaseBox.java b/src/main/java/gtPlusPlus/core/gui/item/box/GuiBaseBox.java deleted file mode 100644 index 5bbb405aa3..0000000000 --- a/src/main/java/gtPlusPlus/core/gui/item/box/GuiBaseBox.java +++ /dev/null @@ -1,124 +0,0 @@ -package gtPlusPlus.core.gui.item.box; - -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.client.renderer.OpenGlHelper; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.resources.I18n; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.util.ResourceLocation; - -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL12; - -import gtPlusPlus.core.item.tool.misc.box.ContainerBoxBase; -import gtPlusPlus.core.item.tool.misc.box.CustomBoxInventory; - -public class GuiBaseBox extends GuiContainer { - - /** - * x and y size of the inventory window in pixels. Defined as float, passed as int These are used for drawing the - * player model. - */ - private float xSize_lo; - - private float ySize_lo; - - /** - * ResourceLocation takes 2 parameters: ModId, path to texture at the location: "src/minecraft/assets/modid/" - * - * I have provided a sample texture file that works with this tutorial. Download it from - * Forge_Tutorials/textures/gui/ - */ - private final ResourceLocation iconLocation; - - /** The inventory to render on screen */ - private final CustomBoxInventory inventory; - - public GuiBaseBox(ContainerBoxBase containerItem, ResourceLocation aGuiTexture) { - super(containerItem); - this.inventory = containerItem.getInventoryObject(); - this.iconLocation = aGuiTexture; - } - - /** - * Draws the screen and all the components in it. - */ - @Override - public void drawScreen(int par1, int par2, float par3) { - super.drawScreen(par1, par2, par3); - this.xSize_lo = (float) par1; - this.ySize_lo = (float) par2; - } - - /** - * Draw the foreground layer for the GuiContainer (everything in front of the items) - */ - @Override - protected void drawGuiContainerForegroundLayer(int par1, int par2) { - String s = this.inventory.hasCustomInventoryName() ? this.inventory.getInventoryName() - : I18n.format(this.inventory.getInventoryName()); - this.fontRendererObj.drawString(s, this.xSize / 2 - this.fontRendererObj.getStringWidth(s) / 2, 0, 4210752); - this.fontRendererObj.drawString(I18n.format("container.inventory"), 26, this.ySize - 96 + 4, 4210752); - } - - /** - * Draw the background layer for the GuiContainer (everything behind the items) - */ - @Override - protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - this.mc.getTextureManager().bindTexture(iconLocation); - int k = (this.width - this.xSize) / 2; - int l = (this.height - this.ySize) / 2; - this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); - int i1; - drawPlayerModel( - k + 51, - l + 75, - 30, - (float) (k + 51) - this.xSize_lo, - (float) (l + 75 - 50) - this.ySize_lo, - this.mc.thePlayer); - } - - /** - * This renders the player model in standard inventory position (in later versions of Minecraft / Forge, you can - * simply call GuiInventory.drawEntityOnScreen directly instead of copying this code) - */ - public static void drawPlayerModel(int x, int y, int scale, float yaw, float pitch, EntityLivingBase entity) { - GL11.glEnable(GL11.GL_COLOR_MATERIAL); - GL11.glPushMatrix(); - GL11.glTranslatef(x, y, 50.0F); - GL11.glScalef(-scale, scale, scale); - GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); - float f2 = entity.renderYawOffset; - float f3 = entity.rotationYaw; - float f4 = entity.rotationPitch; - float f5 = entity.prevRotationYawHead; - float f6 = entity.rotationYawHead; - GL11.glRotatef(135.0F, 0.0F, 1.0F, 0.0F); - RenderHelper.enableStandardItemLighting(); - GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(-((float) Math.atan(pitch / 40.0F)) * 20.0F, 1.0F, 0.0F, 0.0F); - entity.renderYawOffset = (float) Math.atan(yaw / 40.0F) * 20.0F; - entity.rotationYaw = (float) Math.atan(yaw / 40.0F) * 40.0F; - entity.rotationPitch = -((float) Math.atan(pitch / 40.0F)) * 20.0F; - entity.rotationYawHead = entity.rotationYaw; - entity.prevRotationYawHead = entity.rotationYaw; - GL11.glTranslatef(0.0F, entity.yOffset, 0.0F); - RenderManager.instance.playerViewY = 180.0F; - RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F); - entity.renderYawOffset = f2; - entity.rotationYaw = f3; - entity.rotationPitch = f4; - entity.prevRotationYawHead = f5; - entity.rotationYawHead = f6; - GL11.glPopMatrix(); - RenderHelper.disableStandardItemLighting(); - GL11.glDisable(GL12.GL_RESCALE_NORMAL); - OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); - GL11.glDisable(GL11.GL_TEXTURE_2D); - OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); - } -} diff --git a/src/main/java/gtPlusPlus/core/gui/item/box/LunchBoxGui.java b/src/main/java/gtPlusPlus/core/gui/item/box/LunchBoxGui.java deleted file mode 100644 index 80d2d6902f..0000000000 --- a/src/main/java/gtPlusPlus/core/gui/item/box/LunchBoxGui.java +++ /dev/null @@ -1,14 +0,0 @@ -package gtPlusPlus.core.gui.item.box; - -import static gregtech.api.enums.Mods.GTPlusPlus; - -import net.minecraft.util.ResourceLocation; - -import gtPlusPlus.core.item.tool.misc.box.ContainerBoxBase; - -public class LunchBoxGui extends GuiBaseBox { - - public LunchBoxGui(ContainerBoxBase containerItem) { - super(containerItem, new ResourceLocation(GTPlusPlus.ID, "textures/gui/schematic_rocket_GS1.png")); - } -} diff --git a/src/main/java/gtPlusPlus/core/gui/item/box/MagicBagGui.java b/src/main/java/gtPlusPlus/core/gui/item/box/MagicBagGui.java deleted file mode 100644 index 6858c17afb..0000000000 --- a/src/main/java/gtPlusPlus/core/gui/item/box/MagicBagGui.java +++ /dev/null @@ -1,14 +0,0 @@ -package gtPlusPlus.core.gui.item.box; - -import static gregtech.api.enums.Mods.GTPlusPlus; - -import net.minecraft.util.ResourceLocation; - -import gtPlusPlus.core.item.tool.misc.box.ContainerBoxBase; - -public class MagicBagGui extends GuiBaseBox { - - public MagicBagGui(ContainerBoxBase containerItem) { - super(containerItem, new ResourceLocation(GTPlusPlus.ID, "textures/gui/schematic_rocket_GS1.png")); - } -} diff --git a/src/main/java/gtPlusPlus/core/gui/item/box/ToolBoxGui.java b/src/main/java/gtPlusPlus/core/gui/item/box/ToolBoxGui.java deleted file mode 100644 index 4d994eee41..0000000000 --- a/src/main/java/gtPlusPlus/core/gui/item/box/ToolBoxGui.java +++ /dev/null @@ -1,14 +0,0 @@ -package gtPlusPlus.core.gui.item.box; - -import static gregtech.api.enums.Mods.GTPlusPlus; - -import net.minecraft.util.ResourceLocation; - -import gtPlusPlus.core.item.tool.misc.box.ContainerBoxBase; - -public class ToolBoxGui extends GuiBaseBox { - - public ToolBoxGui(ContainerBoxBase containerItem) { - super(containerItem, new ResourceLocation(GTPlusPlus.ID, "textures/gui/schematic_rocket_GS1.png")); - } -} diff --git a/src/main/java/gtPlusPlus/core/item/base/BaseEuItem.java b/src/main/java/gtPlusPlus/core/item/base/BaseEuItem.java deleted file mode 100644 index 194e585c0d..0000000000 --- a/src/main/java/gtPlusPlus/core/item/base/BaseEuItem.java +++ /dev/null @@ -1,636 +0,0 @@ -package gtPlusPlus.core.item.base; - -import static gregtech.api.enums.GT_Values.D1; -import static gregtech.api.enums.GT_Values.V; -import static gregtech.api.enums.Mods.GTPlusPlus; - -import java.util.ArrayList; -import java.util.BitSet; -import java.util.HashMap; -import java.util.List; - -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.IIcon; -import net.minecraft.util.StatCollector; - -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gregtech.api.GregTech_API; -import gregtech.api.enums.GT_Values; -import gregtech.api.enums.SubTag; -import gregtech.api.enums.TC_Aspects.TC_AspectStack; -import gregtech.api.interfaces.IItemBehaviour; -import gregtech.api.interfaces.IItemContainer; -import gregtech.api.objects.ItemData; -import gregtech.api.util.GT_LanguageManager; -import gregtech.api.util.GT_ModHandler; -import gregtech.api.util.GT_OreDictUnificator; -import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.objects.data.Pair; -import gtPlusPlus.core.creative.AddToCreativeTab; -import ic2.api.item.ElectricItem; -import ic2.api.item.IElectricItem; -import ic2.api.item.IElectricItemManager; -import ic2.api.item.ISpecialElectricItem; - -public class BaseEuItem extends Item implements ISpecialElectricItem, IElectricItemManager { - - /* ---------- CONSTRUCTOR AND MEMBER VARIABLES ---------- */ - private final HashMap<Short, ArrayList<IItemBehaviour<BaseEuItem>>> mItemBehaviors = new HashMap<>(); - public final short mOffset, mItemAmount; - public final BitSet mEnabledItems; - public final BitSet mVisibleItems; - public final IIcon[][] mIconList; - /** The unlocalized name of this item. */ - private String unlocalizedName; - - private final ArrayList<Pair<Integer, EnumRarity>> rarity = new ArrayList<>(); - private final ArrayList<Pair<Integer, EnumChatFormatting>> descColour = new ArrayList<>(); - private final ArrayList<Pair<Integer, String>> itemName = new ArrayList<>(); - private final ArrayList<Pair<Integer, String>> itemDescription = new ArrayList<>(); - private final ArrayList<Pair<Integer, Boolean>> hasEffect = new ArrayList<>(); - - public final HashMap<Short, Long[]> mElectricStats = new HashMap<>(); - public final HashMap<Short, Short> mBurnValues = new HashMap<>(); - - public BaseEuItem() { - this("MU-metaitem.02", AddToCreativeTab.tabOther, (short) 1000, (short) 31766); - } - - public BaseEuItem(final String unlocalizedName, final CreativeTabs creativeTab, final short aOffset, - final short aItemAmount) { - this.mEnabledItems = new BitSet(aItemAmount); - this.mVisibleItems = new BitSet(aItemAmount); - this.mOffset = (short) Math.min(32766, aOffset); - this.mItemAmount = (short) Math.min(aItemAmount, 32766 - this.mOffset); - this.mIconList = new IIcon[aItemAmount][1]; - this.setHasSubtypes(true); - this.setMaxDamage(0); - this.setUnlocalizedName(unlocalizedName); - this.setCreativeTab(creativeTab); - this.setMaxStackSize(1); - GameRegistry.registerItem(this, unlocalizedName); - } - - public void registerItem(final int id, final String localizedName, final long euStorage, final int tier, - final String description) { - this.registerItem( - id, - localizedName, - euStorage, - (short) tier, - description, - EnumRarity.common, - EnumChatFormatting.GRAY, - false); - } - - public void registerItem(final int id, final String localizedName, final long euStorage, final int tier, - final String description, final int burnTime) { - this.registerItem( - id, - localizedName, - euStorage, - (short) tier, - description, - EnumRarity.common, - EnumChatFormatting.GRAY, - false); - this.setBurnValue(id, burnTime); - } - - public void registerItem(final int id, final String localizedName, final long euStorage, final short tier, - final String description, final EnumRarity regRarity, final EnumChatFormatting colour, - final boolean Effect) { - this.addItem(id, localizedName, colour + description, new Object[] {}); - this.setElectricStats(this.mOffset + id, euStorage, GT_Values.V[tier], tier, -3L, true); - this.rarity.add(new Pair<>(id, regRarity)); - this.hasEffect.add(new Pair<>(id, Effect)); - } - - @Override - @SideOnly(Side.CLIENT) - public EnumRarity getRarity(final ItemStack par1ItemStack) { - if (this.rarity.get(par1ItemStack.getItemDamage() - this.mOffset) != null) { - return this.rarity.get(par1ItemStack.getItemDamage() - this.mOffset).getValue(); - } - return EnumRarity.common; - } - - @Override - public boolean hasEffect(final ItemStack par1ItemStack, final int pass) { - if (this.hasEffect.get(par1ItemStack.getItemDamage() - this.mOffset) != null) { - return this.hasEffect.get(par1ItemStack.getItemDamage() - this.mOffset).getValue(); - } - return false; - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void addInformation(final ItemStack aStack, final EntityPlayer aPlayer, List aList, final boolean aF3_H) { - // aList.add("Meta: "+(aStack.getItemDamage()-mOffset)); - int keyValue = aStack.getItemDamage() - this.mOffset; - final String tKey = "gtplusplus." + this.getUnlocalizedName(aStack) + "." + keyValue + ".tooltip", - tString = GT_LanguageManager.getTranslation(tKey); - if (GT_Utility.isStringValid(tString) && !tKey.equals(tString)) { - aList.add(tString); - } - aList.add(StatCollector.translateToLocal("item.itemBaseEuItem.tooltip.0")); - final Long[] tStats = this.getElectricStats(aStack); - if (tStats != null) { - if (tStats[3] > 0) { - aList.add( - EnumChatFormatting.AQUA + StatCollector.translateToLocalFormatted( - "item.itemBaseEuItem.tooltip.1", - GT_Utility.formatNumbers(tStats[3]), - (tStats[2] >= 0 ? tStats[2] : 0)) + EnumChatFormatting.GRAY); - } else { - final long tCharge = this.getRealCharge(aStack); - if ((tStats[3] == -2) && (tCharge <= 0)) { - aList.add( - EnumChatFormatting.AQUA + StatCollector.translateToLocal("item.itemBaseEuItem.tooltip.2") - + EnumChatFormatting.GRAY); - } else { - aList.add( - EnumChatFormatting.AQUA + StatCollector.translateToLocalFormatted( - "item.itemBaseEuItem.tooltip.3", - GT_Utility.formatNumbers(tCharge), - GT_Utility.formatNumbers(Math.abs(tStats[0])), - V[(int) (tStats[2] >= 0 ? tStats[2] < V.length ? tStats[2] : V.length - 1 : 1)]) - + EnumChatFormatting.GRAY); - } - } - } - final ArrayList<IItemBehaviour<BaseEuItem>> tList = this.mItemBehaviors.get((short) this.getDamage(aStack)); - if (tList != null) { - for (final IItemBehaviour<BaseEuItem> tBehavior : tList) { - aList = tBehavior.getAdditionalToolTips(this, aList, aStack); - } - } - } - - @Override - public final Item getChargedItem(final ItemStack itemStack) { - return this; - } - - @Override - public final Item getEmptyItem(final ItemStack itemStack) { - return this; - } - - @Override - public final double getMaxCharge(final ItemStack aStack) { - final Long[] tStats = this.getElectricStats(aStack); - if (tStats == null) { - return 0; - } - return Math.abs(tStats[0]); - } - - @Override - public final double getTransferLimit(final ItemStack aStack) { - final Long[] tStats = this.getElectricStats(aStack); - if (tStats == null) { - return 0; - } - return Math.max(tStats[1], tStats[3]); - } - - @Override - public final int getTier(final ItemStack aStack) { - final Long[] tStats = this.getElectricStats(aStack); - return (int) (tStats == null ? Integer.MAX_VALUE : tStats[2]); - } - - @Override - public final double charge(final ItemStack aStack, final double aCharge, final int aTier, - final boolean aIgnoreTransferLimit, final boolean aSimulate) { - final Long[] tStats = this.getElectricStats(aStack); - if ((tStats == null) || (tStats[2] > aTier) - || !((tStats[3] == -1) || (tStats[3] == -3) || ((tStats[3] < 0) && (aCharge == Integer.MAX_VALUE))) - || (aStack.stackSize != 1)) { - return 0; - } - final long tChargeBefore = this.getRealCharge(aStack), tNewCharge = aCharge == Integer.MAX_VALUE - ? Long.MAX_VALUE - : Math.min( - Math.abs(tStats[0]), - tChargeBefore + (aIgnoreTransferLimit ? (long) aCharge : Math.min(tStats[1], (long) aCharge))); - if (!aSimulate) { - this.setCharge(aStack, tNewCharge); - } - return tNewCharge - tChargeBefore; - } - - @Override - public final double discharge(final ItemStack aStack, final double aCharge, final int aTier, - final boolean aIgnoreTransferLimit, final boolean aBatteryAlike, final boolean aSimulate) { - final Long[] tStats = this.getElectricStats(aStack); - if ((tStats == null) || (tStats[2] > aTier)) { - return 0; - } - if (aBatteryAlike && !this.canProvideEnergy(aStack)) { - return 0; - } - if (tStats[3] > 0) { - if ((aCharge < tStats[3]) || (aStack.stackSize < 1)) { - return 0; - } - if (!aSimulate) { - aStack.stackSize--; - } - return tStats[3]; - } - final long tChargeBefore = this.getRealCharge(aStack), tNewCharge = Math - .max(0, tChargeBefore - (aIgnoreTransferLimit ? (long) aCharge : Math.min(tStats[1], (long) aCharge))); - if (!aSimulate) { - this.setCharge(aStack, tNewCharge); - } - return tChargeBefore - tNewCharge; - } - - @Override - public final double getCharge(final ItemStack aStack) { - return this.getRealCharge(aStack); - } - - @Override - public final boolean canUse(final ItemStack aStack, final double aAmount) { - return this.getRealCharge(aStack) >= aAmount; - } - - @Override - public final boolean use(final ItemStack aStack, final double aAmount, final EntityLivingBase aPlayer) { - this.chargeFromArmor(aStack, aPlayer); - if ((aPlayer instanceof EntityPlayer) && ((EntityPlayer) aPlayer).capabilities.isCreativeMode) { - return true; - } - final double tTransfer = this.discharge(aStack, aAmount, Integer.MAX_VALUE, true, false, true); - if (tTransfer == aAmount) { - this.discharge(aStack, aAmount, Integer.MAX_VALUE, true, false, false); - this.chargeFromArmor(aStack, aPlayer); - return true; - } - this.discharge(aStack, aAmount, Integer.MAX_VALUE, true, false, false); - this.chargeFromArmor(aStack, aPlayer); - return false; - } - - @Override - public final boolean canProvideEnergy(final ItemStack aStack) { - final Long[] tStats = this.getElectricStats(aStack); - if (tStats == null) { - return false; - } - return (tStats[3] > 0) || ((aStack.stackSize == 1) && ((tStats[3] == -2) || (tStats[3] == -3))); - } - - @Override - public final void chargeFromArmor(final ItemStack aStack, final EntityLivingBase aPlayer) { - if ((aPlayer == null) || aPlayer.worldObj.isRemote) { - return; - } - for (int i = 1; i < 5; i++) { - final ItemStack tArmor = aPlayer.getEquipmentInSlot(i); - if (GT_ModHandler.isElectricItem(tArmor)) { - final IElectricItem tArmorItem = (IElectricItem) tArmor.getItem(); - if (tArmorItem.canProvideEnergy(tArmor) && (tArmorItem.getTier(tArmor) >= this.getTier(aStack))) { - final double tCharge = ElectricItem.manager.discharge( - tArmor, - this.charge(aStack, Integer.MAX_VALUE - 1, Integer.MAX_VALUE, true, true), - Integer.MAX_VALUE, - true, - true, - false); - if (tCharge > 0) { - this.charge(aStack, tCharge, Integer.MAX_VALUE, true, false); - if (aPlayer instanceof EntityPlayer) { - final Container tContainer = ((EntityPlayer) aPlayer).openContainer; - if (tContainer != null) { - tContainer.detectAndSendChanges(); - } - } - } - } - } - } - } - - public final long getRealCharge(final ItemStack aStack) { - final Long[] tStats = this.getElectricStats(aStack); - if (tStats == null) { - return 0; - } - if (tStats[3] > 0) { - return (int) (long) tStats[3]; - } - final NBTTagCompound tNBT = aStack.getTagCompound(); - return tNBT == null ? 0 : tNBT.getLong("GT.ItemCharge"); - } - - public final boolean setCharge(final ItemStack aStack, long aCharge) { - final Long[] tStats = this.getElectricStats(aStack); - if ((tStats == null) || (tStats[3] > 0)) { - return false; - } - NBTTagCompound tNBT = aStack.getTagCompound(); - if (tNBT == null) { - tNBT = new NBTTagCompound(); - } - tNBT.removeTag("GT.ItemCharge"); - aCharge = Math.min(tStats[0] < 0 ? Math.abs(tStats[0] / 2) : aCharge, Math.abs(tStats[0])); - if (aCharge > 0) { - aStack.setItemDamage(this.getChargedMetaData(aStack)); - tNBT.setLong("GT.ItemCharge", aCharge); - } else { - aStack.setItemDamage(this.getEmptyMetaData(aStack)); - } - if (tNBT.hasNoTags()) { - aStack.setTagCompound(null); - } else { - aStack.setTagCompound(tNBT); - } - this.isItemStackUsable(aStack); - return true; - } - - public short getChargedMetaData(final ItemStack aStack) { - return (short) aStack.getItemDamage(); - } - - public short getEmptyMetaData(final ItemStack aStack) { - return (short) aStack.getItemDamage(); - } - - public boolean isItemStackUsable(final ItemStack aStack) { - final ArrayList<IItemBehaviour<BaseEuItem>> tList = this.mItemBehaviors.get((short) this.getDamage(aStack)); - if (tList != null) { - for (final IItemBehaviour<BaseEuItem> tBehavior : tList) { - if (!tBehavior.isItemStackUsable(this, aStack)) { - return false; - } - } - } - return true; - } - - @Override - public final String getToolTip(final ItemStack aStack) { - return null; - } // This has its own ToolTip Handler, no need to let the IC2 Handler screw us up at this Point - - @Override - public final IElectricItemManager getManager(final ItemStack aStack) { - return this; - } // We are our own Manager - - /** - * Sets the Furnace Burn Value for the Item. - * - * @param aMetaValue the Meta Value of the Item you want to set it to. [0 - 32765] - * @param aValue 200 = 1 Burn Process = 500 EU, max = 32767 (that is 81917.5 EU) - * @return the Item itself for convenience in constructing. - */ - public final BaseEuItem setBurnValue(final int aMetaValue, final int aValue) { - if ((aMetaValue < 0) || (aValue < 0)) { - return this; - } - if (aValue == 0) { - this.mBurnValues.remove((short) aMetaValue); - } else { - this.mBurnValues.put((short) aMetaValue, aValue > Short.MAX_VALUE ? Short.MAX_VALUE : (short) aValue); - } - return this; - } - - /** - * @param aMetaValue the Meta Value of the Item you want to set it to. [0 - 32765] - * @param aMaxCharge Maximum Charge. (if this is == 0 it will remove the Electric Behavior) - * @param aTransferLimit Transfer Limit. - * @param aTier The electric Tier. - * @param aSpecialData If this Item has a Fixed Charge, like a SingleUse Battery (if > 0). Use -1 if you want to - * make this Battery chargeable (the use and canUse Functions will still discharge if you just - * use this) Use -2 if you want to make this Battery dischargeable. Use -3 if you want to make - * this Battery charge/discharge-able. - * @return the Item itself for convenience in constructing. - */ - public final BaseEuItem setElectricStats(final int aMetaValue, final long aMaxCharge, final long aTransferLimit, - final long aTier, final long aSpecialData, final boolean aUseAnimations) { - if (aMetaValue < 0) { - return this; - } - if (aMaxCharge == 0) { - this.mElectricStats.remove((short) aMetaValue); - } else { - this.mElectricStats.put( - (short) aMetaValue, - new Long[] { aMaxCharge, Math.max(0, aTransferLimit), Math.max(-1, aTier), aSpecialData }); - } - return this; - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Override - @SideOnly(Side.CLIENT) - public void getSubItems(final Item var1, final CreativeTabs aCreativeTab, final List aList) { - for (int i = 0, j = this.mEnabledItems.length(); i < j; i++) { - if (this.mVisibleItems.get(i) || (D1 && this.mEnabledItems.get(i))) { - final Long[] tStats = this.mElectricStats.get((short) (this.mOffset + i)); - if ((tStats != null) && (tStats[3] < 0)) { - final ItemStack tStack = new ItemStack(this, 1, this.mOffset + i); - this.setCharge(tStack, Math.abs(tStats[0])); - this.isItemStackUsable(tStack); - aList.add(tStack); - } - if ((tStats == null) || (tStats[3] != -2)) { - final ItemStack tStack = new ItemStack(this, 1, this.mOffset + i); - this.isItemStackUsable(tStack); - aList.add(tStack); - } - } - } - } - - @Override - @SideOnly(Side.CLIENT) - public final void registerIcons(final IIconRegister aIconRegister) { - for (short i = 0, j = (short) this.mEnabledItems.length(); i < j; i++) { - if (this.mEnabledItems.get(i)) { - for (byte k = 1; k < this.mIconList[i].length; k++) { - this.mIconList[i][k] = aIconRegister - .registerIcon(GTPlusPlus.ID + ":" + (this.getUnlocalizedName() + "/" + i + "/" + k)); - } - this.mIconList[i][0] = aIconRegister - .registerIcon(GTPlusPlus.ID + ":" + (this.getUnlocalizedName() + "/" + i)); - } - } - } - - @Override - public final IIcon getIconFromDamage(final int aMetaData) { - if (aMetaData < 0) { - return null; - } - return (aMetaData - this.mOffset) < this.mIconList.length ? this.mIconList[aMetaData - this.mOffset][0] : null; - } - - /** - * Sets the unlocalized name of this item to the string passed as the parameter" - */ - @Override - public Item setUnlocalizedName(final String p_77655_1_) { - this.unlocalizedName = p_77655_1_; - super.setUnlocalizedName(p_77655_1_); - return this; - } - - /** - * Returns the unlocalized name of this item. - */ - @Override - public String getUnlocalizedName() { - return this.unlocalizedName; - } - - public final Long[] getElectricStats(final ItemStack aStack) { - return this.mElectricStats.get((short) aStack.getItemDamage()); - } - - @Override - public int getItemEnchantability() { - return 0; - } - - @Override - public boolean isBookEnchantable(final ItemStack aStack, final ItemStack aBook) { - return false; - } - - @Override - public boolean getIsRepairable(final ItemStack aStack, final ItemStack aMaterial) { - return false; - } - - /** - * Adds a special Item Behaviour to the Item. - * <p/> - * Note: the boolean Behaviours sometimes won't be executed if another boolean Behaviour returned true before. - * - * @param aMetaValue the Meta Value of the Item you want to add it to. [0 - 32765] - * @param aBehavior the Click Behavior you want to add. - * @return the Item itself for convenience in constructing. - */ - public final BaseEuItem addItemBehavior(final int aMetaValue, final IItemBehaviour<BaseEuItem> aBehavior) { - if ((aMetaValue < 0) || (aMetaValue >= 32766) || (aBehavior == null)) { - return this; - } - ArrayList<IItemBehaviour<BaseEuItem>> tList = this.mItemBehaviors.get((short) aMetaValue); - if (tList == null) { - tList = new ArrayList<>(1); - this.mItemBehaviors.put((short) aMetaValue, tList); - } - tList.add(aBehavior); - return this; - } - - /** - * This adds a Custom Item to the ending Range. - * - * @param aID The Id of the assigned Item [0 - mItemAmount] (The MetaData gets auto-shifted by +mOffset) - * @param aEnglish The Default Localized Name of the created Item - * @param aToolTip The Default ToolTip of the created Item, you can also insert null for having no ToolTip - * @param aFoodBehavior The Food Value of this Item. Can be null aswell. Just a convenience thing. - * @param aRandomData The OreDict Names you want to give the Item. Also used for TC Aspects and some other things. - * @return An ItemStack containing the newly created Item. - */ - @SuppressWarnings("unchecked") - public final ItemStack addItem(final int aID, final String aEnglish, String aToolTip, final Object... aRandomData) { - if (aToolTip == null) { - aToolTip = ""; - } - if ((aID >= 0) && (aID < this.mItemAmount)) { - final ItemStack rStack = new ItemStack(this, 1, this.mOffset + aID); - this.mEnabledItems.set(aID); - this.mVisibleItems.set(aID); - GT_LanguageManager.addStringLocalization( - "gtplusplus." + this.getUnlocalizedName(rStack) + "." + aID + ".name", - aEnglish); - GT_LanguageManager.addStringLocalization( - "gtplusplus." + this.getUnlocalizedName(rStack) + "." + aID + ".tooltip", - aToolTip); - final List<TC_AspectStack> tAspects = new ArrayList<>(); - // Important Stuff to do first - for (final Object tRandomData : aRandomData) { - if (tRandomData instanceof SubTag) { - if (tRandomData == SubTag.INVISIBLE) { - this.mVisibleItems.set(aID, false); - continue; - } - if (tRandomData == SubTag.NO_UNIFICATION) { - GT_OreDictUnificator.addToBlacklist(rStack); - continue; - } - } - } - // now check for the rest - for (final Object tRandomData : aRandomData) { - if (tRandomData != null) { - boolean tUseOreDict = true; - if (tRandomData instanceof IItemBehaviour) { - this.addItemBehavior(this.mOffset + aID, (IItemBehaviour<BaseEuItem>) tRandomData); - tUseOreDict = false; - } - if (tRandomData instanceof IItemContainer) { - ((IItemContainer) tRandomData).set(rStack); - tUseOreDict = false; - } - if (tRandomData instanceof SubTag) { - continue; - } - if (tRandomData instanceof TC_AspectStack) { - ((TC_AspectStack) tRandomData).addToAspectList(tAspects); - continue; - } - if (tRandomData instanceof ItemData) { - if (GT_Utility.isStringValid(tRandomData)) { - GT_OreDictUnificator.registerOre(tRandomData, rStack); - } else { - GT_OreDictUnificator.addItemData(rStack, (ItemData) tRandomData); - } - continue; - } - if (tUseOreDict) { - GT_OreDictUnificator.registerOre(tRandomData, rStack); - continue; - } - } - } - if (GregTech_API.sThaumcraftCompat != null) { - GregTech_API.sThaumcraftCompat.registerThaumcraftAspectsToItem(rStack, tAspects, false); - } - return rStack; - } - return null; - } - - @Override - public String getItemStackDisplayName(final ItemStack par1ItemStack) { - int keyValue = (par1ItemStack.getItemDamage() - this.mOffset); - if (keyValue < 0 || keyValue > 5) { - keyValue = 0; - } - return GT_LanguageManager - .getTranslation("gtplusplus." + this.getUnlocalizedName(par1ItemStack) + "." + keyValue + ".name"); - } -} diff --git a/src/main/java/gtPlusPlus/core/item/base/dusts/BaseItemDustAbstract.java b/src/main/java/gtPlusPlus/core/item/base/dusts/BaseItemDustAbstract.java deleted file mode 100644 index c89bbb1d7d..0000000000 --- a/src/main/java/gtPlusPlus/core/item/base/dusts/BaseItemDustAbstract.java +++ /dev/null @@ -1,43 +0,0 @@ -package gtPlusPlus.core.item.base.dusts; - -import static gregtech.api.enums.Mods.GTPlusPlus; - -import java.util.List; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -import cpw.mods.fml.common.registry.GameRegistry; - -public abstract class BaseItemDustAbstract extends Item { - - protected int colour = 0; - protected String materialName; - protected String pileType; - - public BaseItemDustAbstract(final String unlocalizedName, final String materialName, final int colour, - final String pileSize) { - this.setUnlocalizedName(unlocalizedName); - this.setMaxStackSize(64); - if (pileSize.equalsIgnoreCase("dust")) { - this.setTextureName(GTPlusPlus.ID + ":" + "dust"); - } else { - this.setTextureName(GTPlusPlus.ID + ":" + "dust" + pileSize); - } - this.setMaxStackSize(64); - this.colour = colour; - this.materialName = materialName; - this.setUnlocalizedName(unlocalizedName); - GameRegistry.registerItem(this, unlocalizedName); - } - - @SuppressWarnings("rawtypes") - @Override - public abstract void addInformation(ItemStack stack, EntityPlayer aPlayer, List list, boolean bool); - - public abstract String getMaterialName(); - - @Override - public abstract int getColorFromItemStack(ItemStack stack, int hex); -} diff --git a/src/main/java/gtPlusPlus/core/item/base/dusts/decimal/BaseItemCentidust.java b/src/main/java/gtPlusPlus/core/item/base/dusts/decimal/BaseItemCentidust.java deleted file mode 100644 index 78af2155b1..0000000000 --- a/src/main/java/gtPlusPlus/core/item/base/dusts/decimal/BaseItemCentidust.java +++ /dev/null @@ -1,57 +0,0 @@ -package gtPlusPlus.core.item.base.dusts.decimal; - -import static gregtech.api.enums.Mods.GTPlusPlus; - -import java.util.List; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; - -import cpw.mods.fml.common.registry.GameRegistry; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.material.Material; - -public class BaseItemCentidust extends Item { - - final Material dustMaterial; - final String materialName; - final String unlocalName; - - public BaseItemCentidust(final Material material) { - this.dustMaterial = material; - this.unlocalName = "itemCentidust" + material.getUnlocalizedName(); - this.materialName = material.getLocalizedName(); - this.setCreativeTab(AddToCreativeTab.tabMisc); - this.setUnlocalizedName(this.unlocalName); - this.setMaxStackSize(10); - this.setTextureName(GTPlusPlus.ID + ":" + "itemCentidust"); // TODO - GameRegistry.registerItem(this, this.unlocalName); - // GT_OreDictUnificator.registerOre(unlocalName.replace("itemR", "r"), UtilsItems.getSimpleStack(this)); //TODO - } - - @Override - public String getItemStackDisplayName(final ItemStack p_77653_1_) { - - return (this.materialName + " Centidust"); - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - if ((this.materialName != null) && (this.materialName != "") && !this.materialName.equals("")) { - list.add(EnumChatFormatting.GRAY + "1% of a " + this.materialName + " dust pile."); - } - super.addInformation(stack, aPlayer, list, bool); - } - - public final String getMaterialName() { - return this.materialName; - } - - @Override - public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { - return this.dustMaterial.getRgbAsHex(); - } -} diff --git a/src/main/java/gtPlusPlus/core/item/base/dusts/decimal/BaseItemDecidust.java b/src/main/java/gtPlusPlus/core/item/base/dusts/decimal/BaseItemDecidust.java deleted file mode 100644 index de1b63794e..0000000000 --- a/src/main/java/gtPlusPlus/core/item/base/dusts/decimal/BaseItemDecidust.java +++ /dev/null @@ -1,57 +0,0 @@ -package gtPlusPlus.core.item.base.dusts.decimal; - -import static gregtech.api.enums.Mods.GTPlusPlus; - -import java.util.List; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; - -import cpw.mods.fml.common.registry.GameRegistry; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.material.Material; - -public class BaseItemDecidust extends Item { - - final Material dustMaterial; - final String materialName; - final String unlocalName; - - public BaseItemDecidust(final Material material) { - this.dustMaterial = material; - this.unlocalName = "itemDecidust" + material.getUnlocalizedName(); - this.materialName = material.getLocalizedName(); - this.setCreativeTab(AddToCreativeTab.tabMisc); - this.setUnlocalizedName(this.unlocalName); - this.setMaxStackSize(10); - this.setTextureName(GTPlusPlus.ID + ":" + "itemDecidust"); // TODO - GameRegistry.registerItem(this, this.unlocalName); - // GT_OreDictUnificator.registerOre(unlocalName.replace("itemR", "r"), UtilsItems.getSimpleStack(this)); //TODO - } - - @Override - public String getItemStackDisplayName(final ItemStack p_77653_1_) { - - return (this.materialName + " Decidust"); - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - if ((this.materialName != null) && (this.materialName != "") && !this.materialName.equals("")) { - list.add(EnumChatFormatting.GRAY + "10% of a " + this.materialName + " dust pile."); - } - super.addInformation(stack, aPlayer, list, bool); - } - - public final String getMaterialName() { - return this.materialName; - } - - @Override - public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { - return this.dustMaterial.getRgbAsHex(); - } -} diff --git a/src/main/java/gtPlusPlus/core/item/base/foods/BaseItemFood.java b/src/main/java/gtPlusPlus/core/item/base/foods/BaseItemFood.java deleted file mode 100644 index f101bb969b..0000000000 --- a/src/main/java/gtPlusPlus/core/item/base/foods/BaseItemFood.java +++ /dev/null @@ -1,45 +0,0 @@ -package gtPlusPlus.core.item.base.foods; - -import static gregtech.api.enums.Mods.GTPlusPlus; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemFood; -import net.minecraft.item.ItemStack; -import net.minecraft.potion.PotionEffect; -import net.minecraft.world.World; - -import cpw.mods.fml.common.registry.GameRegistry; -import gtPlusPlus.core.creative.AddToCreativeTab; - -public class BaseItemFood extends ItemFood { - - private final PotionEffect[] effects; - protected String localName; - - public BaseItemFood(final String unlocalizedName, final String localizedName, final int healAmount, - final float saturationModifier, final boolean wolvesFavorite, final PotionEffect... effects) { - super(healAmount, saturationModifier, wolvesFavorite); - this.setUnlocalizedName(unlocalizedName); - this.setTextureName(GTPlusPlus.ID + ":" + unlocalizedName.replace("Hot", "")); - this.setCreativeTab(AddToCreativeTab.tabMisc); - this.effects = effects; - this.localName = localizedName; - GameRegistry.registerItem(this, unlocalizedName); - } - - @Override - protected void onFoodEaten(final ItemStack stack, final World world, final EntityPlayer player) { - super.onFoodEaten(stack, world, player); - - for (int i = 0; i < this.effects.length; i++) { - if (!world.isRemote && (this.effects[i] != null) && (this.effects[i].getPotionID() > 0)) { - player.addPotionEffect( - new PotionEffect( - this.effects[i].getPotionID(), - this.effects[i].getDuration(), - this.effects[i].getAmplifier(), - this.effects[i].getIsAmbient())); - } - } - } -} diff --git a/src/main/java/gtPlusPlus/core/item/base/foods/BaseItemHotFood.java b/src/main/java/gtPlusPlus/core/item/base/foods/BaseItemHotFood.java deleted file mode 100644 index b68d7a5d7f..0000000000 --- a/src/main/java/gtPlusPlus/core/item/base/foods/BaseItemHotFood.java +++ /dev/null @@ -1,84 +0,0 @@ -package gtPlusPlus.core.item.base.foods; - -import java.util.List; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.DamageSource; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.StatCollector; -import net.minecraft.world.World; - -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.math.MathUtils; -import gtPlusPlus.core.util.minecraft.ItemUtils; - -public class BaseItemHotFood extends BaseItemFood { - - protected String materialName; - protected String unlocalName; - protected int cooldownTime; - protected Item output; - - public BaseItemHotFood(final String unlocalizedName, final int healAmount, final float healSaturation, - final String foodName, final int timeToCoolInSeconds, final Item cooledFood) { - super(unlocalizedName, "Hot " + foodName, healAmount, healSaturation, false); - this.unlocalName = unlocalizedName; - this.cooldownTime = timeToCoolInSeconds * 20; - this.materialName = foodName; - this.output = cooledFood; - this.setMaxStackSize(1); - } - - @Override - public ItemStack onEaten(final ItemStack iStack, final World world, final EntityPlayer player) { - return super.onEaten(iStack, world, player); - } - - @Override - public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, - final boolean p_77663_5_) { - // Utils.LOG_INFO("Item Damage: "+iStack.getItemDamage()+" Max Damage: "+iStack.getMaxDamage()); - if (!world.isRemote) { - if (iStack.getItemDamage() == this.cooldownTime) { - if (entityHolding instanceof EntityPlayer) { - Logger.INFO("Foods Done."); - ((EntityPlayer) entityHolding).inventory - .addItemStackToInventory(ItemUtils.getSimpleStack(this.output)); - ((EntityPlayer) entityHolding).inventory.consumeInventoryItem(this); - } - } else if (iStack.getItemDamage() < this.cooldownTime) { - iStack.setItemDamage(iStack.getItemDamage() + 1); - } - if (MathUtils.divideXintoY(iStack.getItemDamage(), 150)) { - entityHolding.attackEntityFrom(DamageSource.onFire, 1); - } - } - super.onUpdate(iStack, world, entityHolding, p_77663_4_, p_77663_5_); - } - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - if ((this.materialName != null) && (this.materialName != "") && !this.materialName.equals("")) { - list.add(StatCollector.translateToLocal("item.itemBaseItemHotFood.tooltip.0")); - list.add( - EnumChatFormatting.GRAY + StatCollector.translateToLocalFormatted( - "item.itemBaseItemHotFood.tooltip.1", - (this.cooldownTime - stack.getItemDamage()) / 20)); - } - super.addInformation(stack, aPlayer, list, bool); - } - - public final String getMaterialName() { - return this.materialName; - } - - @Override - public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { - return Utils.rgbtoHexValue(230, 96, 96); - } -} diff --git a/src/main/java/gtPlusPlus/core/item/base/itemblock/FluidItemBlock.java b/src/main/java/gtPlusPlus/core/item/base/itemblock/FluidItemBlock.java deleted file mode 100644 index 8c2278d50b..0000000000 --- a/src/main/java/gtPlusPlus/core/item/base/itemblock/FluidItemBlock.java +++ /dev/null @@ -1,60 +0,0 @@ -package gtPlusPlus.core.item.base.itemblock; - -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; - -import gtPlusPlus.core.fluids.BlockFluidBase; -import gtPlusPlus.core.util.math.MathUtils; - -public class FluidItemBlock extends ItemBlock { - - protected final int blockColour; - final BlockFluidBase baseBlock; - String name; - - public FluidItemBlock(final Block block) { - super(block); - this.baseBlock = (BlockFluidBase) block; - this.blockColour = this.baseBlock.getRenderColor(1); - this.name = this.baseBlock.getLocalizedName().replace("tile", "").replace("fluid", "").replace("name", "") - .replace("block", "").replace(".", ""); - // GT_OreDictUnificator.registerOre("frameGt"+block.getUnlocalizedName().replace("tile.", - // "").replace("tile.BlockGtFrame", "").replace("-", "").replace("_", "").replace(" ", "").replace("FrameBox", - // ""), UtilsItems.getSimpleStack(this)); - } - - public int getRenderColor(final int aMeta) { - return this.blockColour; - } - - @Override - public String getItemStackDisplayName(final ItemStack iStack) { - /* - * if (this.thisFluid != null){ this.name = "Molten "+this.thisFluid.getLocalizedName(); return this.name; } - */ - this.name = "Molten " + this.baseBlock.getLocalizedName().replace("tile", "").replace("fluid", "") - .replace("name", "").replace("block", "").replace(".", ""); - return this.name; - } - - @Override - public int getColorFromItemStack(final ItemStack stack, final int HEX_OxFFFFFF) { - if (this.blockColour == 0) { - return MathUtils.generateSingularRandomHexValue(); - } - return this.blockColour; - } - - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - /* - * list.add("Temperature: "+MathUtils.celsiusToKelvin(this.thisFluid.getMeltingPointC())+"K"); if - * (this.sRadiation > 0){ list.add(CORE.GT_Tooltip_Radioactive.get()); } - */ - super.addInformation(stack, aPlayer, list, bool); - } -} diff --git a/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockDoor.java b/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockDoor.java deleted file mode 100644 index 54c8b89704..0000000000 --- a/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockDoor.java +++ /dev/null @@ -1,101 +0,0 @@ -package gtPlusPlus.core.item.base.itemblock; - -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraft.util.MathHelper; -import net.minecraft.world.World; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -public class ItemBlockDoor extends ItemBlock { - - @SideOnly(Side.CLIENT) - private IIcon field_150938_b; - - public ItemBlockDoor(Block p_i45328_1_) { - super(p_i45328_1_); - } - - /** - * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return - * True if something happen and false if it don't. This is for ITEMS, not BLOCKS - */ - @Override - public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, - int par5, int par6, int par7, float par8, float par9, float par10) { - if (par7 != 1) { - return false; - } else { - ++par5; - Block block; - - block = field_150939_a; - - if (par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack) - && par2EntityPlayer.canPlayerEdit(par4, par5 + 1, par6, par7, par1ItemStack)) { - if (!block.canPlaceBlockAt(par3World, par4, par5, par6)) { - return false; - } else { - int i1 = MathHelper.floor_double( - (double) ((par2EntityPlayer.rotationYaw + 180.0F) * 4.0F / 360.0F) - 0.5D) & 3; - byte b0 = 0; - byte b1 = 0; - - if (i1 == 0) { - b1 = 1; - } - - if (i1 == 1) { - b0 = -1; - } - - if (i1 == 2) { - b1 = -1; - } - - if (i1 == 3) { - b0 = 1; - } - - int i2 = (par3World.getBlock(par4 - b0, par5, par6 - b1).isNormalCube() ? 1 : 0) - + (par3World.getBlock(par4 - b0, par5 + 1, par6 - b1).isNormalCube() ? 1 : 0); - int j1 = (par3World.getBlock(par4 + b0, par5, par6 + b1).isNormalCube() ? 1 : 0) - + (par3World.getBlock(par4 + b0, par5 + 1, par6 + b1).isNormalCube() ? 1 : 0); - boolean flag = par3World.getBlock(par4 - b0, par5, par6 - b1) == block - || par3World.getBlock(par4 - b0, par5 + 1, par6 - b1) == block; - boolean flag1 = par3World.getBlock(par4 + b0, par5, par6 + b1) == block - || par3World.getBlock(par4 + b0, par5 + 1, par6 + b1) == block; - boolean flag2 = false; - - if (flag && !flag1) { - flag2 = true; - } else if (j1 > i2) { - flag2 = true; - } - - par3World.setBlock(par4, par5, par6, block, i1, 2); - par3World.setBlock(par4, par5 + 1, par6, block, 8 | (flag2 ? 1 : 0), 2); - par3World.notifyBlocksOfNeighborChange(par4, par5, par6, block); - par3World.notifyBlocksOfNeighborChange(par4, par5 + 1, par6, block); - - --par1ItemStack.stackSize; - return true; - } - } else { - return false; - } - } - } - - @Override - public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, List p_77624_3_, boolean p_77624_4_) { - p_77624_3_.add("This is a block, you can place it by right clicking"); - super.addInformation(p_77624_1_, p_77624_2_, p_77624_3_, p_77624_4_); - } -} diff --git a/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtFrameBox.java b/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtFrameBox.java deleted file mode 100644 index 914e39e2a5..0000000000 --- a/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockGtFrameBox.java +++ /dev/null @@ -1,91 +0,0 @@ -package gtPlusPlus.core.item.base.itemblock; - -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.world.World; - -import gtPlusPlus.core.block.base.BlockBaseModular; -import gtPlusPlus.core.lib.CORE; -import gtPlusPlus.core.material.Material; -import gtPlusPlus.core.material.MaterialStack; -import gtPlusPlus.core.util.minecraft.EntityUtils; -import gtPlusPlus.core.util.sys.KeyboardUtils; - -public class ItemBlockGtFrameBox extends ItemBlock { - - protected int blockColour; - private Material mMaterial; - private int sRadiation; - - public ItemBlockGtFrameBox(final Block block) { - super(block); - final BlockBaseModular baseBlock = (BlockBaseModular) block; - this.blockColour = baseBlock.getRenderColor(1); - - if (block instanceof BlockBaseModular) { - BlockBaseModular g = (BlockBaseModular) block; - this.mMaterial = g.getMaterialEx(); - sRadiation = mMaterial.vRadiationLevel; - } else { - this.mMaterial = null; - sRadiation = 0; - } - - // GT_OreDictUnificator.registerOre("frameGt"+block.getUnlocalizedName().replace("tile.", - // "").replace("tile.BlockGtFrame", "").replace("-", "").replace("_", "").replace(" ", "").replace("FrameBox", - // ""), ItemUtils.getSimpleStack(this)); - } - - public int getRenderColor(final int aMeta) { - return this.blockColour; - } - - @SuppressWarnings("unchecked") - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - if (this.mMaterial != null) { - list.add(this.mMaterial.vChemicalFormula); - if (this.mMaterial.vRadiationLevel > 0) { - list.add(CORE.GT_Tooltip_Radioactive.get()); - } - } else { - list.add("Material is Null."); - } - if (KeyboardUtils.isCtrlKeyDown()) { - Block b = Block.getBlockFromItem(stack.getItem()); - if (b != null) { - String aTool = b.getHarvestTool(stack.getItemDamage()); - int aMiningLevel1 = b.getHarvestLevel(stack.getItemDamage()); - list.add("Mining Level: " + Math.min(Math.max(aMiningLevel1, 0), 5)); - if (this.mMaterial != null) { - list.add("Contains: "); - if (mMaterial.getComposites().isEmpty()) { - list.add("- " + mMaterial.getLocalizedName()); - } else { - for (MaterialStack m : mMaterial.getComposites()) { - list.add("- " + m.getStackMaterial().getLocalizedName() + " x" + m.getPartsPerOneHundred()); - } - } - } - } - } else { - list.add(EnumChatFormatting.DARK_GRAY + "Hold Ctrl to show additional info."); - } - super.addInformation(stack, aPlayer, list, bool); - } - - @Override - public void onUpdate(final ItemStack iStack, final World world, final Entity entityHolding, final int p_77663_4_, - final boolean p_77663_5_) { - - if (this.sRadiation > 0) { - EntityUtils.applyRadiationDamageToEntity(iStack.stackSize, this.sRadiation, world, entityHolding); - } - } -} diff --git a/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockNBT.java b/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockNBT.java deleted file mode 100644 index abbdd61ff1..0000000000 --- a/src/main/java/gtPlusPlus/core/item/base/itemblock/ItemBlockNBT.java +++ /dev/null @@ -1,96 +0,0 @@ -package gtPlusPlus.core.item.base.itemblock; - -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.world.World; - -import gregtech.api.util.GT_Utility; -import gtPlusPlus.api.interfaces.ITileTooltip; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.tileentities.base.TileEntityBase; -import gtPlusPlus.core.util.minecraft.PlayerUtils; - -public class ItemBlockNBT extends ItemBlock { - - protected final int mID; - - public ItemBlockNBT(final Block block) { - super(block); - this.mID = ((ITileTooltip) block).getTooltipID(); - } - - @Override - public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { - - // if () - - if (this.mID == 0) { // blockDarkWorldPortalFrame - list.add("Assembled in the same shape as the Nether Portal."); - } - } - - @Override - public void onCreated(ItemStack item, World world, EntityPlayer player) { - addNBT(player, item); - super.onCreated(item, world, player); - } - - @Override - public void onUpdate(ItemStack item, World world, Entity entity, int p_77663_4_, boolean p_77663_5_) { - if (entity instanceof EntityPlayerMP) { - EntityPlayerMP mPlayer = (EntityPlayerMP) entity; - - NBTTagCompound rNBT = item.getTagCompound(); - rNBT = ((rNBT == null) ? new NBTTagCompound() : rNBT); - if (!rNBT.hasKey("mOwner")) { - addNBT(mPlayer, item); - } - } - super.onUpdate(item, world, entity, p_77663_4_, p_77663_5_); - } - - private void addNBT(EntityPlayer player, ItemStack item) { - NBTTagCompound rNBT = item.getTagCompound(); - rNBT = ((rNBT == null) ? new NBTTagCompound() : rNBT); - if (player != null) { - boolean mOP = PlayerUtils.isPlayerOP(player); - rNBT.setString("mOwner", player.getDisplayName()); - rNBT.setString("mUUID", "" + player.getUniqueID()); - rNBT.setBoolean("mOP", mOP); - } else if (player == null) { - rNBT.setString("mOwner", "fakeplayer"); - rNBT.setString("mUUID", "00000000"); - rNBT.setBoolean("mOP", false); - } - GT_Utility.ItemNBT.setNBT(item, rNBT); - } - - @Override - public boolean placeBlockAt(ItemStack aStack, EntityPlayer aPlayer, World aWorld, int aX, int aY, int aZ, int side, - float hitX, float hitY, float hitZ, int aMeta) { - if (!(aWorld.setBlock(aX, aY, aZ, this.field_150939_a, 0, 3))) { - return false; - } - if (aWorld.getBlock(aX, aY, aZ) == this.field_150939_a) { - this.field_150939_a.onBlockPlacedBy(aWorld, aX, aY, aZ, aPlayer, aStack); - this.field_150939_a.onPostBlockPlaced(aWorld, aX, aY, aZ, aMeta); - } - TileEntityBase tTileEntity = (TileEntityBase) aWorld.getTileEntity(aX, aY, aZ); - if (tTileEntity != null && aPlayer != null) { - if (tTileEntity.isServerSide()) { - Logger.INFO("Setting Tile Entity information"); - NBTTagCompound aNBT = GT_Utility.ItemNBT.getNBT(aStack); - tTileEntity - .setOwnerInformation(aNBT.getString("mOwner"), aNBT.getString("mUUID"), aNBT.getBoolean("mOP")); - } - } - return true; - } -} diff --git a/src/main/java/gtPlusPlus/core/item/tool/misc/box/BaseBoxItem.java b/src/main/java/gtPlusPlus/core/item/tool/misc/box/BaseBoxItem.java deleted file mode 100644 index 2679441d76..0000000000 --- a/src/main/java/gtPlusPlus/core/item/tool/misc/box/BaseBoxItem.java +++ /dev/null @@ -1,75 +0,0 @@ -package gtPlusPlus.core.item.tool.misc.box; - -import static gregtech.api.enums.Mods.GTPlusPlus; - -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.EnumRarity; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.world.World; - -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -import gtPlusPlus.GTplusplus; -import gtPlusPlus.core.creative.AddToCreativeTab; -import gtPlusPlus.core.item.base.CoreItem; -import gtPlusPlus.core.util.Utils; - -public class BaseBoxItem extends CoreItem { - - private final int GUI; - - public BaseBoxItem(String displayName, String[] description, int GUI_ID) { - super( - "item." + Utils.sanitizeString(displayName), - displayName, - AddToCreativeTab.tabTools, - 1, - 0, - modifyDescriptionStringArray(description), - EnumRarity.uncommon, - EnumChatFormatting.GRAY, - false, - null); - GUI = GUI_ID; - } - - private static String[] modifyDescriptionStringArray(String[] array) { - String[] a = new String[array.length + 1]; - for (int b = 0; b < array.length; b++) { - a[b] = array[b]; - } - a[a.length - 1] = "Right Click to open"; - return a; - } - - // Without this method, your inventory will NOT work!!! - @Override - public int getMaxItemUseDuration(ItemStack stack) { - return 1; // return any value greater than zero - } - - @Override - public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player) { - if (!world.isRemote) { - // If player not sneaking, open the inventory gui - if (!player.isSneaking()) { - player.openGui( - GTplusplus.instance, - GUI, - world, - (int) player.posX, - (int) player.posY, - (int) player.posZ); - } - } - return itemstack; - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister iconRegister) { - this.itemIcon = iconRegister.registerIcon(GTPlusPlus.ID + ":" + this.getUnlocalizedName().substring(5)); - } -} diff --git a/src/main/java/gtPlusPlus/core/item/tool/misc/box/ContainerBoxBase.java b/src/main/java/gtPlusPlus/core/item/tool/misc/box/ContainerBoxBase.java deleted file mode 100644 index 3f24ba5e29..0000000000 --- a/src/main/java/gtPlusPlus/core/item/tool/misc/box/ContainerBoxBase.java +++ /dev/null @@ -1,314 +0,0 @@ -package gtPlusPlus.core.item.tool.misc.box; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public class ContainerBoxBase extends Container { - - /* - * Finally, in your Container class, you will need to check if the currently opened inventory's uniqueID is equal to - * the itemstack's uniqueID in the method 'transferStackInSlot' as well as check if the itemstack is the currently - * equipped item in the method 'slotClick'. In both cases, you'll need to prevent the itemstack from being moved or - * it will cause bad things to happen. - */ - - /** - * Step 3: Create a custom Container for your Inventory - */ - - /* - * There's a LOT of code in this one, but read through all of the comments carefully and it should become clear what - * everything does. As a bonus, one of my previous tutorials is included within! - * "How to Properly Override Shift-Clicking" is here and better than ever! At least in my opinion. If you're like - * me, and you find no end of frustration trying to figure out which f-ing index you should use for which slots in - * your container when overriding transferStackInSlot, or if your following the original tutorial, then read on. - */ - - /** - * The Item Inventory for this Container, only needed if you want to reference isUseableByPlayer - */ - private final CustomBoxInventory inventory; - /** - * Using these will make transferStackInSlot easier to understand and implement INV_START is the index of the first - * slot in the Player's Inventory, so our CustomBoxInventory's number of slots (e.g. 5 slots is array indices 0-4, - * so start at 5) Notice how we don't have to remember how many slots we made? We can just use - * CustomBoxInventory.INV_SIZE and if we ever change it, the Container updates automatically. - */ - private final int INV_START, INV_END, HOTBAR_START, HOTBAR_END; - - // If you're planning to add armor slots, put those first like this: - // ARMOR_START = CustomBoxInventory.INV_SIZE, ARMOR_END = ARMOR_START+3, - // INV_START = ARMOR_END+1, and then carry on like above. - - private Slot generateSlot(final Constructor<?> aClazz, final IInventory base, final int id, final int x, - final int y) { - Slot aSlot; - try { - aSlot = (Slot) aClazz.newInstance(base, id, x, y); - if (aSlot != null) { - return aSlot; - } - } catch (InstantiationException | IllegalAccessException | IllegalArgumentException - | InvocationTargetException e) { - e.printStackTrace(); - } - return null; - } - - public ContainerBoxBase(EntityPlayer par1Player, InventoryPlayer inventoryPlayer, - CustomBoxInventory CustomBoxInventory, Class<?> aClazz, int aSlotCount) { - - INV_START = aSlotCount; - INV_END = INV_START + 26; - HOTBAR_START = INV_END + 1; - HOTBAR_END = HOTBAR_START + 8; - - this.inventory = CustomBoxInventory; - try { - - Constructor<?> constructor; - constructor = aClazz.getConstructor(IInventory.class, int.class, int.class, int.class); - - int i; - - // ITEM INVENTORY - you'll need to adjust the slot locations to match your - // texture file - // I have them set vertically in columns of 4 to the right of the player model - for (i = 0; i < CustomBoxInventory.INV_SIZE; ++i) { - // You can make a custom Slot if you need different behavior, - // such as only certain item types can be put into this slot - // We made a custom slot to prevent our inventory-storing item - // from being stored within itself, but if you want to allow that and - // you followed my advice at the end of the above step, then you - // could get away with using the vanilla Slot class - this.addSlotToContainer( - generateSlot( - constructor, - this.getInventoryObject(), - i, - 80 + (18 * (int) (i / 4)), - 8 + (18 * (i % 4)))); - } - - // If you want, you can add ARMOR SLOTS here as well, but you need to - // make a public version of SlotArmor. I won't be doing that in this tutorial. - /* - * for (i = 0; i < 4; ++i) { // These are the standard positions for survival inventory layout - * this.addSlotToContainer(new SlotArmor(this.player, inventoryPlayer, inventoryPlayer.getSizeInventory() - - * 1 - i, 8, 8 + i * 18, i)); } - */ - - // PLAYER INVENTORY - uses default locations for standard inventory texture file - for (i = 0; i < 3; ++i) { - for (int j = 0; j < 9; ++j) { - this.addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); - } - } - - // PLAYER ACTION BAR - uses default locations for standard action bar texture - // file - for (i = 0; i < 9; ++i) { - this.addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 142)); - } - - } catch (NoSuchMethodException | SecurityException e) { - e.printStackTrace(); - } - } - - @Override - public boolean canInteractWith(EntityPlayer entityplayer) { - // be sure to return the inventory's isUseableByPlayer method - // if you defined special behavior there: - return getInventoryObject().isUseableByPlayer(entityplayer); - } - - /** - * Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that. - */ - @Override - public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int index) { - ItemStack itemstack = null; - Slot slot = (Slot) this.inventorySlots.get(index); - - if (slot != null && slot.getHasStack()) { - ItemStack itemstack1 = slot.getStack(); - itemstack = itemstack1.copy(); - - // If item is in our custom Inventory or armor slot - if (index < INV_START) { - // try to place in player inventory / action bar - if (!this.mergeItemStack(itemstack1, INV_START, HOTBAR_END + 1, true)) { - return null; - } - - slot.onSlotChange(itemstack1, itemstack); - } - // Item is in inventory / hotbar, try to place in custom inventory or armor - // slots - else { - /* - * If your inventory only stores certain instances of Items, you can implement shift-clicking to your - * inventory like this: // Check that the item is the right type if (itemstack1.getItem() instanceof - * ItemCustom) { // Try to merge into your custom inventory slots // We use - * 'CustomBoxInventory.INV_SIZE' instead of INV_START just in case // you also add armor or other custom - * slots if (!this.mergeItemStack(itemstack1, 0, CustomBoxInventory.INV_SIZE, false)) { return null; } } - * // If you added armor slots, check them here as well: // Item being shift-clicked is armor - try to - * put in armor slot if (itemstack1.getItem() instanceof ItemArmor) { int type = ((ItemArmor) - * itemstack1.getItem()).armorType; if (!this.mergeItemStack(itemstack1, ARMOR_START + type, ARMOR_START - * + type + 1, false)) { return null; } } Otherwise, you have basically 2 choices: 1. shift-clicking - * between player inventory and custom inventory 2. shift-clicking between action bar and inventory Be - * sure to choose only ONE of the following implementations!!! - */ - /** - * Implementation number 1: Shift-click into your custom inventory - */ - if (index >= INV_START) { - // place in custom inventory - if (!this.mergeItemStack(itemstack1, 0, INV_START, false)) { - return null; - } - } - - /** - * Implementation number 2: Shift-click items between action bar and inventory - */ - // item is in player's inventory, but not in action bar - if (index >= INV_START && index < HOTBAR_START) { - // place in action bar - if (!this.mergeItemStack(itemstack1, HOTBAR_START, HOTBAR_END + 1, false)) { - return null; - } - } - // item in action bar - place in player inventory - else if (index >= HOTBAR_START && index < HOTBAR_END + 1) { - if (!this.mergeItemStack(itemstack1, INV_START, INV_END + 1, false)) { - return null; - } - } - } - - if (itemstack1.stackSize == 0) { - slot.putStack((ItemStack) null); - } else { - slot.onSlotChanged(); - } - - if (itemstack1.stackSize == itemstack.stackSize) { - return null; - } - - slot.onPickupFromSlot(par1EntityPlayer, itemstack1); - } - - return itemstack; - } - - /** - * You should override this method to prevent the player from moving the stack that opened the inventory, otherwise - * if the player moves it, the inventory will not be able to save properly - */ - @Override - public ItemStack slotClick(int slot, int button, int flag, EntityPlayer player) { - // this will prevent the player from interacting with the item that opened the - // inventory: - if (slot >= 0 && getSlot(slot) != null && getSlot(slot).getStack() == player.getHeldItem()) { - return null; - } - return super.slotClick(slot, button, flag, player); - } - - /* - * Special note: If your custom inventory's stack limit is 1 and you allow shift-clicking itemstacks into it, you - * will need to override mergeStackInSlot to avoid losing all the items but one in a stack when you shift-click. - */ - /** - * Vanilla mergeItemStack method doesn't correctly handle inventories whose max stack size is 1 when you shift-click - * into the inventory. This is a modified method I wrote to handle such cases. Note you only need it if your slot / - * inventory's max stack size is 1 - */ - @Override - protected boolean mergeItemStack(ItemStack stack, int start, int end, boolean backwards) { - boolean flag1 = false; - int k = (backwards ? end - 1 : start); - Slot slot; - ItemStack itemstack1; - - if (stack.isStackable()) { - while (stack.stackSize > 0 && (!backwards && k < end || backwards && k >= start)) { - slot = (Slot) inventorySlots.get(k); - itemstack1 = slot.getStack(); - - if (!slot.isItemValid(stack)) { - k += (backwards ? -1 : 1); - continue; - } - - if (itemstack1 != null && itemstack1.getItem() == stack.getItem() - && (!stack.getHasSubtypes() || stack.getItemDamage() == itemstack1.getItemDamage()) - && ItemStack.areItemStackTagsEqual(stack, itemstack1)) { - int l = itemstack1.stackSize + stack.stackSize; - - if (l <= stack.getMaxStackSize() && l <= slot.getSlotStackLimit()) { - stack.stackSize = 0; - itemstack1.stackSize = l; - getInventoryObject().markDirty(); - flag1 = true; - } else if (itemstack1.stackSize < stack.getMaxStackSize() && l < slot.getSlotStackLimit()) { - stack.stackSize -= stack.getMaxStackSize() - itemstack1.stackSize; - itemstack1.stackSize = stack.getMaxStackSize(); - getInventoryObject().markDirty(); - flag1 = true; - } - } - - k += (backwards ? -1 : 1); - } - } - if (stack.stackSize > 0) { - k = (backwards ? end - 1 : start); - while (!backwards && k < end || backwards && k >= start) { - slot = (Slot) inventorySlots.get(k); - itemstack1 = slot.getStack(); - - if (!slot.isItemValid(stack)) { - k += (backwards ? -1 : 1); - continue; - } - - if (itemstack1 == null) { - int l = stack.stackSize; - if (l <= slot.getSlotStackLimit()) { - slot.putStack(stack.copy()); - stack.stackSize = 0; - getInventoryObject().markDirty(); - flag1 = true; - break; - } else { - putStackInSlot( - k, - new ItemStack(stack.getItem(), slot.getSlotStackLimit(), stack.getItemDamage())); - stack.stackSize -= slot.getSlotStackLimit(); - getInventoryObject().markDirty(); - flag1 = true; - } - } - - k += (backwards ? -1 : 1); - } - } - - return flag1; - } - - public CustomBoxInventory getInventoryObject() { - return inventory; - } -} diff --git a/src/main/java/gtPlusPlus/core/item/tool/misc/box/CustomBoxInventory.java b/src/main/java/gtPlusPlus/core/item/tool/misc/box/CustomBoxInventory.java deleted file mode 100644 index 858689f33d..0000000000 --- a/src/main/java/gtPlusPlus/core/item/tool/misc/box/CustomBoxInventory.java +++ /dev/null @@ -1,216 +0,0 @@ -package gtPlusPlus.core.item.tool.misc.box; - -import java.util.UUID; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.nbt.NBTTagList; -import net.minecraftforge.common.util.Constants; - -public abstract class CustomBoxInventory implements IInventory { - - private final String name; - protected String uniqueID; - - /** Provides NBT Tag Compound to reference */ - private final ItemStack invItem; - - /** Defining your inventory size this way is handy */ - public final int INV_SIZE; - - /** Inventory's size must be same as number of slots you add to the Container class */ - private ItemStack[] inventory; - - /** - * @param itemstack - the ItemStack to which this inventory belongs - */ - public CustomBoxInventory(ItemStack stack, String name2) { - this(stack, name2, 8); - } - - /** - * @param itemstack - the ItemStack to which this inventory belongs - */ - public CustomBoxInventory(ItemStack stack, String name2, int slots) { - invItem = stack; - name = name2; - INV_SIZE = slots; - inventory = new ItemStack[INV_SIZE]; - - /** initialize variable within the constructor: */ - uniqueID = ""; - - if (!stack.hasTagCompound()) { - stack.setTagCompound(new NBTTagCompound()); - // no tag compound means the itemstack does not yet have a UUID, so assign one: - uniqueID = UUID.randomUUID().toString(); - } - - /** When reading from NBT: */ - if ("".equals(uniqueID)) { - // try to read unique ID from NBT - uniqueID = stack.getTagCompound().getString("uniqueID"); - // if it's still "", assign a new one: - if ("".equals(uniqueID)) { - uniqueID = UUID.randomUUID().toString(); - } - } - - /** Writing to NBT: */ - // just add this line: - stack.getTagCompound().setString("uniqueID", this.uniqueID); - - // note that it's okay to use stack instead of invItem right there - // both reference the same memory location, so whatever you change using - // either reference will change in the other - - // Read the inventory contents from NBT - readFromNBT(stack.getTagCompound()); - } - - @Override - public int getSizeInventory() { - return inventory.length; - } - - @Override - public ItemStack getStackInSlot(int slot) { - return inventory[slot]; - } - - @Override - public ItemStack decrStackSize(int slot, int amount) { - ItemStack stack = getStackInSlot(slot); - if (stack != null) { - if (stack.stackSize > amount) { - stack = stack.splitStack(amount); - // Don't forget this line or your inventory will not be saved! - markDirty(); - } else { - // this method also calls onInventoryChanged, so we don't need to call it again - setInventorySlotContents(slot, null); - } - } - return stack; - } - - @Override - public ItemStack getStackInSlotOnClosing(int slot) { - ItemStack stack = getStackInSlot(slot); - setInventorySlotContents(slot, null); - return stack; - } - - @Override - public void setInventorySlotContents(int slot, ItemStack stack) { - inventory[slot] = stack; - - if (stack != null && stack.stackSize > getInventoryStackLimit()) { - stack.stackSize = getInventoryStackLimit(); - } - - // Don't forget this line or your inventory will not be saved! - markDirty(); - } - - // 1.7.2+ renamed to getInventoryName - @Override - public String getInventoryName() { - return name; - } - - // 1.7.2+ renamed to hasCustomInventoryName - @Override - public boolean hasCustomInventoryName() { - return name.length() > 0; - } - - @Override - public int getInventoryStackLimit() { - return 64; - } - - /** - * This is the method that will handle saving the inventory contents, as it is called (or should be called!) anytime - * the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also let you change - * things in your inventory without ever opening a Gui, if you want. - */ - // 1.7.2+ renamed to markDirty - @Override - public void markDirty() { - for (int i = 0; i < getSizeInventory(); ++i) { - if (getStackInSlot(i) != null && getStackInSlot(i).stackSize == 0) { - inventory[i] = null; - } - } - - // This line here does the work: - writeToNBT(invItem.getTagCompound()); - } - - @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) { - return true; - } - - // 1.7.2+ renamed to openInventory(EntityPlayer player) - @Override - public void openInventory() {} - - // 1.7.2+ renamed to closeInventory(EntityPlayer player) - @Override - public void closeInventory() {} - - /** - * This method doesn't seem to do what it claims to do, as items can still be left-clicked and placed in the - * inventory even when this returns false - */ - @Override - public abstract boolean isItemValidForSlot(int slot, ItemStack itemstack); - - /** - * A custom method to read our inventory from an ItemStack's NBT compound - */ - public void readFromNBT(NBTTagCompound compound) { - // Gets the custom taglist we wrote to this compound, if any - // 1.7.2+ change to compound.getTagList("ItemInventory", Constants.NBT.TAG_COMPOUND); - NBTTagList items = compound.getTagList("ItemInventory", Constants.NBT.TAG_COMPOUND); - - for (int i = 0; i < items.tagCount(); ++i) { - // 1.7.2+ change to items.getCompoundTagAt(i) - NBTTagCompound item = (NBTTagCompound) items.getCompoundTagAt(i); - int slot = item.getInteger("Slot"); - - // Just double-checking that the saved slot index is within our inventory array bounds - if (slot >= 0 && slot < getSizeInventory()) { - inventory[slot] = ItemStack.loadItemStackFromNBT(item); - } - } - } - - /** - * A custom method to write our inventory to an ItemStack's NBT compound - */ - public void writeToNBT(NBTTagCompound tagcompound) { - // Create a new NBT Tag List to store itemstacks as NBT Tags - NBTTagList items = new NBTTagList(); - - for (int i = 0; i < getSizeInventory(); ++i) { - // Only write stacks that contain items - if (getStackInSlot(i) != null) { - // Make a new NBT Tag Compound to write the itemstack and slot index to - NBTTagCompound item = new NBTTagCompound(); - item.setInteger("Slot", i); - // Writes the itemstack in slot(i) to the Tag Compound we just made - getStackInSlot(i).writeToNBT(item); - - // add the tag compound to our tag list - items.appendTag(item); - } - } - // Add the TagList to the ItemStack's Tag Compound with the name "ItemInventory" - tagcompound.setTag("ItemInventory", items); - } -} diff --git a/src/main/java/gtPlusPlus/core/players/FakeFarmer.java b/src/main/java/gtPlusPlus/core/players/FakeFarmer.java deleted file mode 100644 index ba8d5f9d77..0000000000 --- a/src/main/java/gtPlusPlus/core/players/FakeFarmer.java +++ /dev/null @@ -1,85 +0,0 @@ -package gtPlusPlus.core.players; - -import java.util.UUID; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.item.ItemStack; -import net.minecraft.network.play.client.C15PacketClientSettings; -import net.minecraft.server.management.ItemInWorldManager; -import net.minecraft.stats.StatBase; -import net.minecraft.util.ChunkCoordinates; -import net.minecraft.util.DamageSource; -import net.minecraft.util.IChatComponent; -import net.minecraft.world.World; -import net.minecraft.world.WorldServer; - -import com.mojang.authlib.GameProfile; - -import cpw.mods.fml.common.FMLCommonHandler; - -public class FakeFarmer extends EntityPlayerMP { - - private static final UUID uuid = UUID.fromString("c1ddfd7f-120a-4437-8b64-38660d3ec62d"); - - private static GameProfile FAKE_PROFILE = new GameProfile(uuid, "[GT_Farm_Manager]"); - - public FakeFarmer(final WorldServer world) { - super( - FMLCommonHandler.instance().getMinecraftServerInstance(), - world, - FAKE_PROFILE, - new ItemInWorldManager(world)); - } - - @Override - public boolean canCommandSenderUseCommand(final int i, final String s) { - return false; - } - - @Override - public ChunkCoordinates getPlayerCoordinates() { - return new ChunkCoordinates(0, 0, 0); - } - - @Override - public void addChatComponentMessage(final IChatComponent chatmessagecomponent) {} - - @Override - public void addChatMessage(final IChatComponent p_145747_1_) {} - - @Override - public void addStat(final StatBase par1StatBase, final int par2) {} - - @Override - public void openGui(final Object mod, final int modGuiId, final World world, final int x, final int y, - final int z) {} - - @Override - public boolean isEntityInvulnerable() { - return true; - } - - @Override - public boolean canAttackPlayer(final EntityPlayer player) { - return false; - } - - @Override - public void onDeath(final DamageSource source) {} - - @Override - public void onUpdate() {} - - @Override - public void travelToDimension(final int dim) {} - - @Override - public void func_147100_a(final C15PacketClientSettings pkt) {} - - @Override - public boolean canPlayerEdit(final int par1, final int par2, final int par3, final int par4, - final ItemStack par5ItemStack) { - return true; - } -} diff --git a/src/main/java/gtPlusPlus/core/slots/SlotBlockedInv.java b/src/main/java/gtPlusPlus/core/slots/SlotBlockedInv.java deleted file mode 100644 index 3132baf159..0000000000 --- a/src/main/java/gtPlusPlus/core/slots/SlotBlockedInv.java +++ /dev/null @@ -1,39 +0,0 @@ -package gtPlusPlus.core.slots; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -public class SlotBlockedInv extends Slot { - - public SlotBlockedInv(IInventory inv, int index, int xPos, int yPos) { - super(inv, index, xPos, yPos); - } - - @Override - public boolean isItemValid(ItemStack stack) { - return false; - } - - @Override - public boolean canTakeStack(EntityPlayer player) { - return false; - } - - @Override - public void putStack(ItemStack itemStack) {} - - @Override - public void onPickupFromSlot(EntityPlayer player, ItemStack itemStack) {} - - @Override - public boolean getHasStack() { - return false; - } - - @Override - public ItemStack decrStackSize(int i) { - return null; - } -} diff --git a/src/main/java/gtPlusPlus/core/slots/SlotFuelRod.java b/src/main/java/gtPlusPlus/core/slots/SlotFuelRod.java deleted file mode 100644 index 0dd050b5aa..0000000000 --- a/src/main/java/gtPlusPlus/core/slots/SlotFuelRod.java +++ /dev/null @@ -1,52 +0,0 @@ -package gtPlusPlus.core.slots; - -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -import gregtech.api.enums.ItemList; -import ic2.core.Ic2Items; - -public class SlotFuelRod extends Slot { - - public SlotFuelRod(final IInventory inventory, final int index, final int x, final int y) { - super(inventory, index, x, y); - } - - @Override - public boolean isItemValid(final ItemStack itemstack) { - boolean returnValue = false; - // Uranium Rods - if (itemstack.getItem() == Ic2Items.reactorUraniumSimple.getItem()) { - returnValue = true; - } else if (itemstack.getItem() == Ic2Items.reactorUraniumDual.getItem()) { - returnValue = true; - } else if (itemstack.getItem() == Ic2Items.reactorUraniumQuad.getItem()) { - returnValue = true; - } - - // Mox Rods - if (itemstack.getItem() == Ic2Items.reactorMOXSimple.getItem()) { - returnValue = true; - } else if (itemstack.getItem() == Ic2Items.reactorMOXDual.getItem()) { - returnValue = true; - } else if (itemstack.getItem() == Ic2Items.reactorMOXQuad.getItem()) { - returnValue = true; - } - - // Thorium Rods - if (itemstack.getItem() == ItemList.ThoriumCell_1.getItem()) { - returnValue = true; - } else if (itemstack.getItem() == ItemList.ThoriumCell_2.getItem()) { - returnValue = true; - } else if (itemstack.getItem() == ItemList.ThoriumCell_4.getItem()) { - returnValue = true; - } - return returnValue; - } - - @Override - public int getSlotStackLimit() { - return 1; - } -} diff --git a/src/main/java/gtPlusPlus/core/slots/SlotGtTool.java b/src/main/java/gtPlusPlus/core/slots/SlotGtTool.java deleted file mode 100644 index 4047c4e62c..0000000000 --- a/src/main/java/gtPlusPlus/core/slots/SlotGtTool.java +++ /dev/null @@ -1,30 +0,0 @@ -package gtPlusPlus.core.slots; - -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -import gregtech.api.items.GT_MetaGenerated_Tool; -import gtPlusPlus.api.objects.Logger; - -public class SlotGtTool extends Slot { - - public SlotGtTool(final IInventory inventory, final int x, final int y, final int z) { - super(inventory, x, y, z); - } - - @Override - public boolean isItemValid(final ItemStack itemstack) { - if (itemstack.getItem() instanceof GT_MetaGenerated_Tool) { - Logger.WARNING(itemstack.getDisplayName() + " is a valid Tool."); - return true; - } - Logger.WARNING(itemstack.getDisplayName() + " is not a valid Tool."); - return false; - } - - @Override - public int getSlotStackLimit() { - return 1; - } -} diff --git a/src/main/java/gtPlusPlus/core/slots/SlotLunchBox.java b/src/main/java/gtPlusPlus/core/slots/SlotLunchBox.java deleted file mode 100644 index ffd9f6dcae..0000000000 --- a/src/main/java/gtPlusPlus/core/slots/SlotLunchBox.java +++ /dev/null @@ -1,29 +0,0 @@ -package gtPlusPlus.core.slots; - -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemFood; -import net.minecraft.item.ItemStack; - -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.util.minecraft.FoodUtils; - -public class SlotLunchBox extends SlotGtTool { - - public SlotLunchBox(final IInventory base, final int x, final int y, final int z) { - super(base, x, y, z); - } - - @Override - public boolean isItemValid(final ItemStack itemstack) { - return isItemValid_STATIC(itemstack); - } - - public static boolean isItemValid_STATIC(final ItemStack itemstack) { - if ((itemstack.getItem() instanceof ItemFood) || (FoodUtils.isFood(itemstack))) { - Logger.WARNING(itemstack.getDisplayName() + " is a valid food."); - return true; - } - Logger.WARNING(itemstack.getDisplayName() + " is not a valid food."); - return false; - } -} diff --git a/src/main/java/gtPlusPlus/core/slots/SlotMagicToolBag.java b/src/main/java/gtPlusPlus/core/slots/SlotMagicToolBag.java deleted file mode 100644 index 7c13dd1c7a..0000000000 --- a/src/main/java/gtPlusPlus/core/slots/SlotMagicToolBag.java +++ /dev/null @@ -1,29 +0,0 @@ -package gtPlusPlus.core.slots; - -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemFood; -import net.minecraft.item.ItemStack; - -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.util.minecraft.FoodUtils; - -public class SlotMagicToolBag extends SlotGtTool { - - public SlotMagicToolBag(final IInventory base, final int x, final int y, final int z) { - super(base, x, y, z); - } - - @Override - public boolean isItemValid(final ItemStack itemstack) { - return isItemValid_STATIC(itemstack); - } - - public static boolean isItemValid_STATIC(final ItemStack itemstack) { - if ((itemstack.getItem() instanceof ItemFood) || (FoodUtils.isFood(itemstack))) { - Logger.WARNING(itemstack.getDisplayName() + " is a valid food."); - return true; - } - Logger.WARNING(itemstack.getDisplayName() + " is not a valid food."); - return false; - } -} diff --git a/src/main/java/gtPlusPlus/core/slots/SlotToolBox.java b/src/main/java/gtPlusPlus/core/slots/SlotToolBox.java deleted file mode 100644 index 29ad60fa18..0000000000 --- a/src/main/java/gtPlusPlus/core/slots/SlotToolBox.java +++ /dev/null @@ -1,107 +0,0 @@ -package gtPlusPlus.core.slots; - -import net.minecraft.inventory.IInventory; -import net.minecraft.item.ItemStack; -import net.minecraft.item.ItemTool; - -import gregtech.api.items.GT_MetaGenerated_Tool; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.data.AutoMap; -import gtPlusPlus.core.util.reflect.ReflectionUtils; - -public class SlotToolBox extends SlotGtTool { - - private static final AutoMap<Class> mSupportedCustomTools = new AutoMap<Class>(); - - static { - // Look for Supported custom tool types - Class temp; - - // IC2 Electrics - temp = ReflectionUtils.getClass("ic2.api.item.IElectricItem"); - if (temp != null) { - mSupportedCustomTools.put(temp); - temp = null; - } - - // IC2 Boxables - temp = ReflectionUtils.getClass(" ic2.api.item.IBoxable"); - if (temp != null) { - mSupportedCustomTools.put(temp); - temp = null; - } - - // Tinkers Tools - temp = ReflectionUtils.getClass("tconstruct.library.tools.Weapon"); - if (temp != null) { - mSupportedCustomTools.put(temp); - temp = null; - } - // BattleGear Weapons - temp = ReflectionUtils.getClass("mods.battlegear2.api.weapons.IBattlegearWeapon"); - if (temp != null) { - mSupportedCustomTools.put(temp); - temp = null; - } - - // OpenMods - String[] OpenModsContent = new String[] { "openblocks.common.item.ItemDevNull", - "openblocks.common.item.ItemHangGlider", "openblocks.common.item.ItemWrench", - "openblocks.common.item.ItemSleepingBag" }; - for (String t : OpenModsContent) { - temp = ReflectionUtils.getClass(t); - if (temp != null) { - mSupportedCustomTools.put(temp); - temp = null; - } - } - - // GC Wrench - temp = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.items.ItemUniversalWrench"); - if (temp != null) { - mSupportedCustomTools.put(temp); - temp = null; - } - - // EIO - String[] EioContent = new String[] { "crazypants.enderio.api.tool.ITool", "crazypants.enderio.item.ItemMagnet", - "crazypants.enderio.item.ItemConduitProbe" }; - for (String t : EioContent) { - temp = ReflectionUtils.getClass(t); - if (temp != null) { - mSupportedCustomTools.put(temp); - temp = null; - } - } - - // Forestry - temp = ReflectionUtils.getClass("forestry.core.items.ItemForestryTool"); - if (temp != null) { - mSupportedCustomTools.put(temp); - temp = null; - } - } - - public SlotToolBox(final IInventory base, final int x, final int y, final int z) { - super(base, x, y, z); - } - - @Override - public boolean isItemValid(final ItemStack itemstack) { - return isItemValid_STATIC(itemstack); - } - - public static boolean isItemValid_STATIC(final ItemStack itemstack) { - if ((itemstack.getItem() instanceof GT_MetaGenerated_Tool) || (itemstack.getItem() instanceof ItemTool)) { - Logger.WARNING(itemstack.getDisplayName() + " is a valid Tool."); - return true; - } - for (Class C : mSupportedCustomTools) { - if (C.isInstance(itemstack.getItem())) { - return true; - } - } - Logger.WARNING(itemstack.getDisplayName() + " is not a valid Tool."); - return false; - } -} diff --git a/src/main/java/gtPlusPlus/core/tileentities/base/TileBasicTank.java b/src/main/java/gtPlusPlus/core/tileentities/base/TileBasicTank.java deleted file mode 100644 index 563249672d..0000000000 --- a/src/main/java/gtPlusPlus/core/tileentities/base/TileBasicTank.java +++ /dev/null @@ -1,157 +0,0 @@ -package gtPlusPlus.core.tileentities.base; - -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTankInfo; -import net.minecraftforge.fluids.IFluidHandler; -import net.minecraftforge.fluids.IFluidTank; - -import gregtech.common.covers.CoverInfo; -import gtPlusPlus.api.objects.minecraft.BTF_FluidTank; - -public class TileBasicTank extends TileEntityBase implements IFluidHandler, IFluidTank { - - public final BTF_FluidTank mTank; - - public TileBasicTank(int aMaxSlots, int aFluidCapacity) { - super(aMaxSlots); - mTank = new BTF_FluidTank(aFluidCapacity); - } - - @Override - public boolean onPreTick(long aTick) { - - if (this.isServerSide()) { - if (mTank.isFluidChangingAllowed() && mTank.getFillableStack() != null - && mTank.getFillableStack().amount <= 0) { - mTank.setFillableStack((FluidStack) null); - } - } - - return super.onPreTick(aTick); - } - - private final boolean canFillEx(ForgeDirection aSide, Fluid aFluid) { - return this.fill(aSide, new FluidStack(aFluid, 1), false) == 1; - } - - private final boolean canDrainEx(ForgeDirection aSide, Fluid aFluid) { - return this.drain(aSide, new FluidStack(aFluid, 1), false) != null; - } - - private final FluidTankInfo[] getTankInfoEx(ForgeDirection aSide) { - return mTank.getCapacity() <= 0 ? new FluidTankInfo[0] : new FluidTankInfo[] { mTank.getInfo() }; - } - - private final int fill_default(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { - return mTank.fill(aFluid, doFill); - } - - private final int fillEx(ForgeDirection aSide, FluidStack aFluid, boolean doFill) { - return this.fill_default(aSide, aFluid, doFill); - } - - private final FluidStack drainEx(ForgeDirection aSide, FluidStack aFluid, boolean doDrain) { - return mTank.getFluid() != null && aFluid != null && mTank.getFluid().isFluidEqual(aFluid) - ? mTank.drain(aFluid.amount, doDrain) - : null; - } - - private final FluidStack drainEx(ForgeDirection aSide, int maxDrain, boolean doDrain) { - return mTank.drain(maxDrain, doDrain); - } - - public boolean isLiquidInput(ForgeDirection side) { - return true; - } - - public boolean isLiquidOutput(ForgeDirection side) { - return true; - } - - @Override - public int fill(ForgeDirection side, FluidStack aFluid, boolean doFill) { - if (mTickTimer > 5 && canAccessData() - && (mRunningThroughTick || !mInputDisabled) - && (side == ForgeDirection.UNKNOWN || (this.isLiquidInput(side) - && getCoverInfoAtSide(side).letsFluidIn(aFluid == null ? null : aFluid.getFluid())))) - return this.fillEx(side, aFluid, doFill); - return 0; - } - - @Override - public FluidStack drain(ForgeDirection side, int maxDrain, boolean doDrain) { - if (mTickTimer > 5 && canAccessData() - && (mRunningThroughTick || !mOutputDisabled) - && (side == ForgeDirection.UNKNOWN || (this.isLiquidOutput(side) && getCoverInfoAtSide(side) - .letsFluidOut(this.getFluid() == null ? null : this.getFluid().getFluid())))) - return this.drainEx(side, maxDrain, doDrain); - return null; - } - - @Override - public FluidStack drain(ForgeDirection side, FluidStack aFluid, boolean doDrain) { - if (mTickTimer > 5 && canAccessData() - && (mRunningThroughTick || !mOutputDisabled) - && (side == ForgeDirection.UNKNOWN || (this.isLiquidOutput(side) - && getCoverInfoAtSide(side).letsFluidOut(aFluid == null ? null : aFluid.getFluid())))) - return this.drainEx(side, aFluid, doDrain); - return null; - } - - @Override - public boolean canFill(ForgeDirection side, Fluid aFluid) { - if (mTickTimer > 5 && canAccessData() - && (mRunningThroughTick || !mInputDisabled) - && (side == ForgeDirection.UNKNOWN - || (this.isLiquidInput(side) && getCoverInfoAtSide(side).letsFluidIn(aFluid)))) - return this.canFillEx(side, aFluid); - return false; - } - - @Override - public boolean canDrain(ForgeDirection side, Fluid aFluid) { - if (mTickTimer > 5 && canAccessData() - && (mRunningThroughTick || !mOutputDisabled) - && (side == ForgeDirection.UNKNOWN - || (this.isLiquidOutput(side) && getCoverInfoAtSide(side).letsFluidOut(aFluid)))) - return this.canDrainEx(side, aFluid); - return false; - } - - @Override - public FluidTankInfo[] getTankInfo(ForgeDirection side) { - CoverInfo coverInfo = getCoverInfoAtSide(side); - if (canAccessData() - && (side == ForgeDirection.UNKNOWN || (this.isLiquidInput(side) && coverInfo.letsFluidIn(null)) - || (this.isLiquidOutput(side) && coverInfo.letsFluidOut(null)))) - return this.getTankInfoEx(side); - return new FluidTankInfo[] {}; - } - - @Override - public FluidStack getFluid() { - return mTank.getFluid(); - } - - @Override - public int getFluidAmount() { - return mTank.getFluidAmount(); - } - - @Override - public FluidTankInfo getInfo() { - return mTank.getInfo(); - } - - @Override - public int fill(FluidStack resource, boolean doFill) { - return mTank.fill(resource, doFill); - } - - @Override - public FluidStack drain(int maxDrain, boolean doDrain) { - return mTank.drain(maxDrain, doDrain); - } -} diff --git a/src/main/java/gtPlusPlus/core/tileentities/general/redstone/TileEntityRedstoneHandler.java b/src/main/java/gtPlusPlus/core/tileentities/general/redstone/TileEntityRedstoneHandler.java deleted file mode 100644 index 62b1e365aa..0000000000 --- a/src/main/java/gtPlusPlus/core/tileentities/general/redstone/TileEntityRedstoneHandler.java +++ /dev/null @@ -1,441 +0,0 @@ -package gtPlusPlus.core.tileentities.general.redstone; - -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.IIcon; -import net.minecraft.world.EnumSkyBlock; -import net.minecraft.world.IBlockAccess; - -import cpw.mods.fml.common.registry.GameRegistry; -import gtPlusPlus.api.interfaces.IToolable; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.api.objects.minecraft.BlockPos; -import gtPlusPlus.core.util.Utils; -import gtPlusPlus.core.util.minecraft.EntityUtils; - -public abstract class TileEntityRedstoneHandler extends TileEntity implements IToolable { - - private final int mTileType; - private BlockPos mTilePos; - private boolean mRequiresUpdate = false; - private Long mStartTime; - private Byte mRedstoneLevel; - - public boolean mLightMode = false; - public float mLightValue = 0; - - /** - * Sets the Redstone Handler Type. - * - * @param aTileType - A type of the handler designated by an int. 0 = receiver, 1 = emitter, 2 = both, anything else - * = nothing. - */ - public TileEntityRedstoneHandler(int aTileType) { - mTileType = aTileType; - registerTileEntity(); - } - - private void registerTileEntity() { - if (!EntityUtils.isTileEntityRegistered(getTileEntityClass(), getTileEntityNameForRegistration())) { - GameRegistry.registerTileEntity(getTileEntityClass(), getTileEntityNameForRegistration()); - } - } - - protected abstract Class<? extends TileEntity> getTileEntityClass(); - - protected abstract String getTileEntityNameForRegistration(); - - public Block getBlock() { - return mTilePos != null ? mTilePos.getBlockAtPos() : Blocks.redstone_block; - } - - public final boolean isLight() { - return mLightMode; - } - - public final float getLightBrightness() { - if (!isLight()) { - return 0; - } else { - return mLightValue; - } - } - - @Override - public void readFromNBT(NBTTagCompound aNBT) { - mStartTime = aNBT.getLong("mStartTime"); - mInvName = aNBT.getString("mInvName"); - mLightValue = aNBT.getFloat("mLightValue"); - mLightMode = aNBT.getBoolean("mLightMode"); - mRedstoneLevel = aNBT.getByte("mRedstoneLevel"); - super.readFromNBT(aNBT); - } - - @Override - public void writeToNBT(NBTTagCompound aNBT) { - aNBT.setInteger("mTileType", mTileType); - aNBT.setLong("mStartTime", mStartTime); - aNBT.setString("mInvName", mInvName); - aNBT.setFloat("mLightValue", getLightBrightness()); - aNBT.setBoolean("mLightMode", isLight()); - aNBT.setByte("mRedstoneLevel", mRedstoneLevel); - super.writeToNBT(aNBT); - } - - private boolean mHasUpdatedRecently = false; - - private final boolean init() { - if (mTilePos == null) { - try { - mTilePos = new BlockPos(this); - } catch (Throwable t) { - return false; - } - } - if (mStartTime == null) { - try { - mStartTime = System.currentTimeMillis(); - } catch (Throwable t) { - return false; - } - } - return true; - } - - private Long mLastUpdate; - private String mInvName = ""; - - @Override - public void updateEntity() { - // Handle init - if (!init()) { - return; - } - if (mRequiresUpdate || mLastUpdate == null) { - mRequiresUpdate = false; - mHasUpdatedRecently = true; - mLastUpdate = System.currentTimeMillis(); - if (mTilePos.world.getBlockLightValue(xCoord, yCoord, zCoord) != getLightBrightness() / 0.0625f) { - mTilePos.getBlockAtPos().setLightLevel(getLightBrightness() / 0.0625f); - mTilePos.world.setLightValue( - EnumSkyBlock.Block, - xCoord, - yCoord, - zCoord, - (int) (getLightBrightness() / 0.0625f)); - mTilePos.world.updateLightByType(EnumSkyBlock.Block, xCoord, yCoord, zCoord); - Logger.INFO("Updating Light"); - } - mTilePos.world.scheduleBlockUpdate(xCoord, yCoord, zCoord, mTilePos.getBlockAtPos(), 1); - markDirty(); - } - if (Utils.getMillisSince(mLastUpdate, System.currentTimeMillis()) >= 5000) { - if (mHasUpdatedRecently) { - mHasUpdatedRecently = false; - this.markForUpdate(); - } - } - - if (Utils.getMillisSince(mStartTime, System.currentTimeMillis()) % 50 == 0) {} - - super.updateEntity(); - } - - public final void markForUpdate() { - mRequiresUpdate = true; - } - - public final boolean hasUpdatedRecently() { - return mHasUpdatedRecently; - } - - @Override - public int getBlockMetadata() { - return super.getBlockMetadata(); - } - - @Override - public void markDirty() { - super.markDirty(); - } - - @Override - public boolean canUpdate() { - return true; - } - - public void setRedstoneState(boolean aRedstoneActive) {} - - public void setCurrentTextureArray(IIcon[] aTextures) {} - - /** - * Used to see if one of the blocks next to you or your block is getting power from a neighboring block. Used by - * items like TNT or Doors so they don't have redstone going straight into them. Args: x, y, z - */ - public boolean isGettingIndirectlyPowered() { - if (mTilePos == null) { - return false; - } - return mTilePos.world.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord); - } - - public int getStrongestIndirectPower() { - if (mTilePos == null) { - return 0; - } - return mTilePos.world.getStrongestIndirectPower(xCoord, yCoord, zCoord); - } - - /** - * Gets the power level from a certain block face. Args: x, y, z, direction - */ - public int getIndirectPowerForSide(int aSide) { - if (mTilePos == null || aSide < 0 || aSide > 5) { - return 0; - } - return mTilePos.world.getIndirectPowerLevelTo(xCoord, yCoord, zCoord, aSide); - } - - /** - * Returns the highest redstone signal strength powering the given block. Args: X, Y, Z. - */ - public int getBlockPowerInput() { - if (mTilePos == null) { - return 0; - } - return mTilePos.world.getBlockPowerInput(xCoord, yCoord, zCoord); - } - - /** - * Determine if this block can make a redstone connection on the side provided, Useful to control which sides are - * inputs and outputs for redstone wires. - * - * Side: -1: UP 0: NORTH 1: EAST 2: SOUTH 3: WEST - * - * @param world The current world - * @param x X Position - * @param y Y Position - * @param z Z Position - * @param side The side that is trying to make the connection - * @return True to make the connection - */ - public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) { - if (mTilePos == null) { - return false; - } - return canAcceptRedstoneSignal() || canSupplyRedstoneSignal(); - } - - /** - * Called to determine whether to allow the a block to handle its own indirect power rather than using the default - * rules. - * - * @param world The world - * @param x The x position of this block instance - * @param y The y position of this block instance - * @param z The z position of this block instance - * @param side The INPUT side of the block to be powered - ie the opposite of this block's output side - * @return Whether Block#isProvidingWeakPower should be called when determining indirect power - */ - public boolean shouldCheckWeakPower(IBlockAccess world, int x, int y, int z, int side) { - if (mTilePos == null) { - return false; - } - return getBlock().isNormalCube(); - } - - /** - * If this block should be notified of weak changes. Weak changes are changes 1 block away through a solid block. - * Similar to comparators. - * - * @param world The current world - * @param x X Position - * @param y Y position - * @param z Z position - * @param side The side to check - * @return true To be notified of changes - */ - public boolean getWeakChanges(IBlockAccess world, int x, int y, int z) { - if (mTilePos == null) { - return false; - } - return false; - } - - /** - * Override this to change the level of redstone output. - * - * @return - */ - public int getRedstoneLevel() { - if (mTilePos == null || mRedstoneLevel == null) { - return 0; - } else { - if (canSupplyRedstoneSignal()) { - if (this.hasUpdatedRecently()) { - int aInputPower = getInputPowerLevel(); - mRedstoneLevel = (byte) ((aInputPower >= 0 && aInputPower <= 127) ? aInputPower : 0); - } - return mRedstoneLevel; - } - } - return 0; - } - - public boolean providesWeakPower() { - return isProvidingPower(); - } - - public boolean providesStrongPower() { - return isProvidingPower(); - } - - /** - * Returns the amount of week power this block is providing to a side. - * - * @param world - * @param x - * @param y - * @param z - * @param side - * @return - */ - public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) { - if (!providesWeakPower()) { - return 0; - } - return getOutputPowerLevel(); - } - - /** - * Returns the amount of strong power this block is providing to a side. - * - * @param world - * @param x - * @param y - * @param z - * @param side - * @return - */ - public int isProvidingStrongPower(IBlockAccess world, int x, int y, int z, int side) { - if (!providesStrongPower()) { - return 0; - } - return getOutputPowerLevel(); - } - - /* - * GT++ Simplified Redstone Handling functions. - */ - - /** - * - * @return - Does this Block supply redstone signal at all? - */ - public final boolean isPowered() { - return canAcceptRedstoneSignal() && getInputPowerLevel() > 0; - } - - /** - * - * @return - Can this Block provide redstone signal at all? - */ - public final boolean isProvidingPower() { - return canSupplyRedstoneSignal() && getOutputPowerLevel() > 0; - } - - /** - * - * @return - (0-15) Redstone Output signal level - */ - public final int getOutputPowerLevel() { - return getRedstoneLevel(); - } - - /** - * - * @return (0-15) Redstone Input Signal level - */ - public final int getInputPowerLevel() { - return getBlockPowerInput(); - } - - /** - * - * @return - Does this Tile Entity support outputting redstone? - */ - public final boolean canSupplyRedstoneSignal() { - return mTileType == 1 || mTileType == 2; - } - - /** - * - * @return - Does this Tile Entity support inputting redstone? - */ - public final boolean canAcceptRedstoneSignal() { - return mTileType == 0 || mTileType == 2; - } - - @Override - public boolean isScrewdriverable() { - return false; - } - - @Override - public boolean onScrewdriverLMB() { - return false; - } - - @Override - public boolean onScrewdriverRMB() { - return false; - } - - @Override - public boolean isWrenchable() { - return false; - } - - @Override - public boolean onWrenchLMB() { - return false; - } - - @Override - public boolean onWrenchRMB() { - return false; - } - - @Override - public boolean isMalletable() { - return false; - } - - @Override - public boolean onMalletLMB() { - return false; - } - - @Override - public boolean onMalletRMB() { - return false; - } - - public void setCustomName(String displayName) { - this.mInvName = displayName; - } - - public String getCustomName() { - return this.mInvName; - } - - public String getInventoryName() { - return this.hasCustomInventoryName() ? this.mInvName : "container.redstone.generic"; - } - - public boolean hasCustomInventoryName() { - return (this.mInvName != null) && !this.mInvName.equals(""); - } -} diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/FoodUtils.java b/src/main/java/gtPlusPlus/core/util/minecraft/FoodUtils.java deleted file mode 100644 index 2825ac80fd..0000000000 --- a/src/main/java/gtPlusPlus/core/util/minecraft/FoodUtils.java +++ /dev/null @@ -1,61 +0,0 @@ -package gtPlusPlus.core.util.minecraft; - -import net.minecraft.init.Items; -import net.minecraft.item.EnumAction; -import net.minecraft.item.Item; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemFood; -import net.minecraft.item.ItemStack; - -import gtPlusPlus.core.util.reflect.ReflectionUtils; - -public class FoodUtils { - - public static final Class IEdibleClass; - - static { - IEdibleClass = ReflectionUtils.getClass("squeek.applecore.api.food.IEdible"); - } - - public static boolean isFood(ItemStack food) { - - if (food == null) { - return false; - } - - Item item = food.getItem(); - - if (item == null) { - return false; - } - - EnumAction action = item.getItemUseAction(food); - - if (item instanceof ItemBlock || action == EnumAction.eat || action == EnumAction.drink) { - if (getUnmodifiedFoodValues(food) > 0) { - return true; - } - } - - return false; - } - - private static int getUnmodifiedFoodValues(ItemStack stack) { - - if (stack == null) { - return 0; - } - - Item item = stack.getItem(); - - if (item == null) { - return 0; - } - - if (IEdibleClass.isInstance(item) || item instanceof ItemFood || item == Items.cake) { - return 1; - } - - return 0; - } -} diff --git a/src/main/java/gtPlusPlus/core/util/minecraft/particles/BlockBreakParticles.java b/src/main/java/gtPlusPlus/core/util/minecraft/particles/BlockBreakParticles.java deleted file mode 100644 index ff28f59eb2..0000000000 --- a/src/main/java/gtPlusPlus/core/util/minecraft/particles/BlockBreakParticles.java +++ /dev/null @@ -1,17 +0,0 @@ -package gtPlusPlus.core.util.minecraft.particles; - -import net.minecraft.block.Block; -import net.minecraft.world.World; - -import gtPlusPlus.xmod.forestry.HANDLER_FR; - -public class BlockBreakParticles { - - public BlockBreakParticles(final World world, final int x, final int y, final int z, final Block block) { - try { - HANDLER_FR.createBlockBreakParticles(world, x, y, z, block); - } catch (final Throwable T) { - - } - } -} diff --git a/src/main/java/gtPlusPlus/core/util/sys/SystemUtils.java b/src/main/java/gtPlusPlus/core/util/sys/SystemUtils.java deleted file mode 100644 index 71ed513618..0000000000 --- a/src/main/java/gtPlusPlus/core/util/sys/SystemUtils.java +++ /dev/null @@ -1,85 +0,0 @@ -package gtPlusPlus.core.util.sys; - -public class SystemUtils { - - private static OS SystemType; - - public static OS getOS() { - if (SystemType != null) { - return SystemType; - } else { - SystemType = getOperatingSystem(); - return SystemType; - } - } - - /** - * Try invoke the runtime's Garbage Collector. - */ - public static void invokeGC() { - try { - Runtime r = Runtime.getRuntime(); - r.gc(); - } catch (Throwable t) { - // Do nothing. - } - } - - public static boolean isWindows() { - return (getOSString().indexOf("win") >= 0); - } - - public static boolean isMac() { - return (getOSString().indexOf("mac") >= 0); - } - - public static boolean isUnix() { - return (getOSString().indexOf("nix") >= 0 || getOSString().indexOf("nux") >= 0 - || getOSString().indexOf("aix") > 0); - } - - public static boolean isSolaris() { - return (getOSString().indexOf("sunos") >= 0); - } - - public static String getOSString() { - try { - return System.getProperty("os.name").toLowerCase(); - } catch (Throwable t) { - return "other"; - } - } - - public static OS getOperatingSystem() { - if (isMac()) { - return OS.MAC; - } else if (isWindows()) { - return OS.WINDOWS; - } else if (isUnix()) { - return OS.UNIX; - } else if (isSolaris()) { - return OS.SOLARIS; - } else { - return OS.OTHER; - } - } - - public static enum OS { - - MAC(1), - WINDOWS(2), - UNIX(3), - SOLARIS(4), - OTHER(0); - - private int mID; - - private OS(final int ID) { - this.mID = ID; - } - - public int getID() { - return this.mID; - } - } -} diff --git a/src/main/java/gtPlusPlus/xmod/galacticraft/util/GalacticUtils.java b/src/main/java/gtPlusPlus/xmod/galacticraft/util/GalacticUtils.java deleted file mode 100644 index c25d6b4352..0000000000 --- a/src/main/java/gtPlusPlus/xmod/galacticraft/util/GalacticUtils.java +++ /dev/null @@ -1,160 +0,0 @@ -package gtPlusPlus.xmod.galacticraft.util; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import net.minecraft.entity.Entity; -import net.minecraftforge.fluids.FluidStack; - -import gregtech.api.enums.Materials; -import gtPlusPlus.api.objects.Logger; -import gtPlusPlus.core.item.chemistry.RocketFuels; -import gtPlusPlus.core.util.minecraft.FluidUtils; -import gtPlusPlus.core.util.reflect.ReflectionUtils; - -public class GalacticUtils { - - private static final Class<?> aTieredRocket; - private static final Class<?> aLandingPad; - private static final Class<?> aBuggyPad; - private static final Class<?> aIDockable; - private static final Class<?> aIFuelable; - private static final Method getRocketTier; - private static final Method getRocket; - private static final Method getBuggy; - - static { - Class<?> a1, a2, a3, a4, a5; - Method m1, m2, m3; - try { - a1 = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.api.prefab.entity.EntityTieredRocket"); - a2 = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.tile.TileEntityLandingPad"); - a3 = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.core.tile.TileEntityBuggyFueler"); - a4 = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.api.entity.IDockable"); - a5 = ReflectionUtils.getClass("micdoodle8.mods.galacticraft.api.entity.IFuelable"); - m1 = ReflectionUtils.getMethod(a1, "getRocketTier"); - m2 = ReflectionUtils.getMethod(a2, "getDockedEntity"); - m3 = ReflectionUtils.getMethod(a3, "getDockedEntity"); - } catch (Throwable t) { - a1 = null; - a2 = null; - a3 = null; - a4 = null; - a5 = null; - m1 = null; - m2 = null; - m3 = null; - } - aTieredRocket = a1; - aLandingPad = a2; - aBuggyPad = a3; - aIDockable = a4; - aIFuelable = a5; - getRocketTier = m1; - getRocket = m2; - getBuggy = m3; - if (a1 != null && a2 != null - && a3 != null - && a4 != null - && a5 != null - && m1 != null - && m2 != null - && m3 != null) { - Logger.SPACE("Successfully relfected into 5 classes and 3 methods."); - } else { - Logger.SPACE("Failed to relfect into Galacticraft classes and methods."); - if (a1 == null) { - Logger.SPACE("micdoodle8.mods.galacticraft.api.prefab.entity.EntityTieredRocket was null.."); - } - if (a2 == null) { - Logger.SPACE("micdoodle8.mods.galacticraft.core.tile.TileEntityLandingPad was null.."); - } - if (a3 == null) { - Logger.SPACE("micdoodle8.mods.galacticraft.core.tile.TileEntityBuggyFueler was null.."); - } - if (a4 == null) { - Logger.SPACE("micdoodle8.mods.galacticraft.api.entity.IDockable was null.."); - } - if (a5 == null) { - Logger.SPACE("micdoodle8.mods.galacticraft.api.entity.IFuelable was null.."); - } - if (m1 == null) { - Logger.SPACE("getRocketTier was null.."); - } - if (m2 == null) { - Logger.SPACE("getDockedEntity was null.."); - } - if (m3 == null) { - Logger.SPACE("getDockedEntity(buggy) was null.."); - } - } - } - - public static int getRocketTier(Entity aEntity) { - if (aTieredRocket.isInstance(aEntity)) { - if (getRocketTier != null) { - try { - return (int) getRocketTier.invoke(aEntity, new Object[] {}); - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {} - } - } - return -1; - } - - public static int getRocketTier(Object aEntity) { - if (aIFuelable.isInstance(aEntity)) { - if (aLandingPad.isInstance(aEntity)) { - Object rocket; - try { - rocket = getRocket.invoke(aLandingPad, new Object[] {}); - if (aIDockable.isInstance(rocket) && rocket != null) { - return getRocketTier((Entity) rocket); - } - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {} - } else if (aBuggyPad.isInstance(aEntity)) { - Object buggy; - try { - buggy = getBuggy.invoke(aBuggyPad, new Object[] {}); - if (aIDockable.isInstance(buggy) && buggy != null) { - return 0; - } - } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {} - } - } - return -1; - } - - public static boolean isFuelValidForTier(int aTier, FluidStack aFuel) { - FluidStack aValidForThisTier = getValidFuelForTier(aTier); - if (aFuel.isFluidEqual(aValidForThisTier)) { - return true; - } - return false; - } - - public static FluidStack getValidFuelForTier(Entity aEntity) { - if (aTieredRocket.isInstance(aEntity)) { - return getValidFuelForTier(getRocketTier(aEntity)); - } else { - Logger.SPACE("Failed to get valid rocket fuel for " + aEntity.getClass().getCanonicalName()); - return getValidFuelForTier(0); - } - } - - public static FluidStack getValidFuelForTier(int aTier) { - if (aTier > 0 && aTier <= 2) { - return FluidUtils.getFluidStack(RocketFuels.RP1_Plus_Liquid_Oxygen, 1000); - } else if (aTier >= 3 && aTier <= 5) { - return FluidUtils.getFluidStack(RocketFuels.Dense_Hydrazine_Mix, 1000); - } else if (aTier >= 6 && aTier <= 7) { - return FluidUtils.getFluidStack(RocketFuels.Monomethylhydrazine_Plus_Nitric_Acid, 1000); - } else if (aTier >= 8 && aTier <= 10) { - return FluidUtils.getFluidStack(RocketFuels.Unsymmetrical_Dimethylhydrazine_Plus_Nitrogen_Tetroxide, 1000); - } else { - if (aTier == 0) { - return Materials.Fuel.getFluid(1000); - } - return null; - } - } -} diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/autocrafter/AC_Helper_Container.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/autocrafter/AC_Helper_Container.java deleted file mode 100644 index e54542f35b..0000000000 --- a/src/main/java/gtPlusPlus/xmod/gregtech/common/helpers/autocrafter/AC_Helper_Container.java +++ /dev/null @@ -1,113 +0,0 @@ -package gtPlusPlus.xmod.gregtech.common.helpers.autocrafter; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.IInventory; -import net.minecraft.inventory.InventoryCraftResult; -import net.minecraft.inventory.InventoryCrafting; -import net.minecraft.inventory.Slot; -import net.minecraft.inventory.SlotCrafting; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.CraftingManager; -import net.minecraft.world.World; - -import gtPlusPlus.api.objects.Logger; - -public class AC_Helper_Container extends Container { - - /** The crafting matrix inventory (3x3). */ - public InventoryCrafting craftMatrix = new InventoryCrafting(this, 3, 3); - - public IInventory craftResult = new InventoryCraftResult(); - private World worldObj; - - public InventoryCrafting getMatrix() { - return this.craftMatrix; - } - - public boolean putItemsIntoGrid(ItemStack[] inputs) { - if (inputs.length < 9) { - return false; - } - for (int i = 0; i < 9; i++) { - this.putStackInSlot(i, inputs[i]); - } - this.onCraftMatrixChanged(this.craftMatrix); - return true; - } - - public AC_Helper_Container(InventoryPlayer playerInventory, World world, int x, int y, int z) { - this.worldObj = world; - this.addSlotToContainer( - new SlotCrafting(playerInventory.player, this.craftMatrix, this.craftResult, 0, 124, 35)); - int l; - int i1; - - for (l = 0; l < 3; ++l) { - for (i1 = 0; i1 < 3; ++i1) { - this.addSlotToContainer(new Slot(this.craftMatrix, i1 + l * 3, 30 + i1 * 18, 17 + l * 18)); - } - } - - for (l = 0; l < 3; ++l) { - for (i1 = 0; i1 < 9; ++i1) { - this.addSlotToContainer(new Slot(playerInventory, i1 + l * 9 + 9, 8 + i1 * 18, 84 + l * 18)); - } - } - - for (l = 0; l < 9; ++l) { - this.addSlotToContainer(new Slot(playerInventory, l, 8 + l * 18, 142)); - } - - this.onCraftMatrixChanged(this.craftMatrix); - } - - /** - * Callback for when the crafting matrix is changed. - */ - @Override - public void onCraftMatrixChanged(IInventory p_75130_1_) { - this.craftResult.setInventorySlotContents( - 0, - CraftingManager.getInstance().findMatchingRecipe(this.craftMatrix, this.worldObj)); - Logger.INFO("Crafted " + this.craftResult.getStackInSlot(0)); - } - - /** - * Called when the container is closed. - */ - @Override - public void onContainerClosed(EntityPlayer p_75134_1_) { - super.onContainerClosed(p_75134_1_); - - if (!this.worldObj.isRemote) { - for (int i = 0; i < 9; ++i) { - ItemStack itemstack = this.craftMatrix.getStackInSlotOnClosing(i); - - if (itemstack != null) { - p_75134_1_.dropPlayerItemWithRandomChoice(itemstack, false); - } - } - } - } - - @Override - public boolean canInteractWith(EntityPlayer p_75145_1_) { - return true; - } - - /** - * Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that. - */ - @Override - public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_) { - ItemStack itemstack = null; - return itemstack; - } - - @Override - public boolean func_94530_a(ItemStack p_94530_1_, Slot p_94530_2_) { - return p_94530_2_.inventory != this.craftResult && super.func_94530_a(p_94530_1_, p_94530_2_); - } -} |