diff --git a/src/api/java/Reika/RotaryCraft/API/IOAPI.java b/src/api/java/Reika/RotaryCraft/API/IOAPI.java deleted file mode 100644 index 5730e6a07..000000000 --- a/src/api/java/Reika/RotaryCraft/API/IOAPI.java +++ /dev/null @@ -1,67 +0,0 @@ -/******************************************************************************* - * @author Reika Kalseki - * - * Copyright 2014 - * - * All rights reserved. - * Distribution of the software in any form is only allowed with - * explicit, prior permission from the owner. - ******************************************************************************/ -package Reika.RotaryCraft.API; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import net.minecraft.tileentity.TileEntity; - -public class IOAPI { - - private static Class io; - private static Method render; - - static { - try { - io = Class.forName("Reika.RotaryCraft.Auxiliary.IORenderer", false, IOAPI.class.getClassLoader()); - render = io.getMethod("renderIO", TileEntity.class, double.class, double.class, double.class); - } - catch (ClassNotFoundException e) { - System.out.println("RotaryCraft IORenderer class not found!"); - e.printStackTrace(); - } - catch (NoSuchMethodException e) { - System.out.println("Could not find renderIO method in IORenderer class!"); - e.printStackTrace(); - } - catch (SecurityException e) { - e.printStackTrace(); - } - } - - /** Call this to run the RotaryCraft I/O Renderer on your TileEntity. - * - * You must call this from inside your TE renderer's "renderTileEntityAt" method. - * Calling it on pass 1 only is strongly recommended to - * prevent visual glitches caused by OpenGL limitations. - * @param machine Your TileEntity as either a ShaftPowerEmitter or ShaftPowerReceiver - * @param par2 The "par2" passed in the "renderTileEntityAt"; related to x-displacement - * @param par4 The "par4" passed in the "renderTileEntityAt"; related to y-displacement - * @param par6 The "par6" passed in the "renderTileEntityAt"; related to z-displacement - */ - public static void renderIO(ShaftMachine machine, double par2, double par4, double par6) { - try { - render.invoke(null, machine, par2, par4, par6); - } - catch (IllegalAccessException e) { - e.printStackTrace(); - } - catch (IllegalArgumentException e) { - e.printStackTrace(); - } - catch (InvocationTargetException e) { - e.printStackTrace(); - } - catch (NullPointerException e) { //If init failed - e.printStackTrace(); - } - } -} diff --git a/src/api/java/Reika/RotaryCraft/API/PowerGenerator.java b/src/api/java/Reika/RotaryCraft/API/PowerGenerator.java deleted file mode 100644 index 1ba63f3c9..000000000 --- a/src/api/java/Reika/RotaryCraft/API/PowerGenerator.java +++ /dev/null @@ -1,26 +0,0 @@ -/******************************************************************************* - * @author Reika Kalseki - * - * Copyright 2014 - * - * All rights reserved. - * Distribution of the software in any form is only allowed with - * explicit, prior permission from the owner. - ******************************************************************************/ -package Reika.RotaryCraft.API; - -/** Implement this if your TE "spawns" power */ -public interface PowerGenerator { - - /** The maximum amount of power your machine can ever generate, in watts. - * If there is no cap, use Long.MAX_VALUE. */ - public long getMaxPower(); - - /** The current power your machine is producing, in watts. */ - public long getCurrentPower(); - - public int getEmittingX(); - public int getEmittingY(); - public int getEmittingZ(); - -} diff --git a/src/api/java/Reika/RotaryCraft/API/ShaftMachine.java b/src/api/java/Reika/RotaryCraft/API/ShaftMachine.java deleted file mode 100644 index 465294eb3..000000000 --- a/src/api/java/Reika/RotaryCraft/API/ShaftMachine.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * @author Reika Kalseki - * - * Copyright 2014 - * - * All rights reserved. - * Distribution of the software in any form is only allowed with - * explicit, prior permission from the owner. - ******************************************************************************/ -package Reika.RotaryCraft.API; - -public interface ShaftMachine { - - /** For fetching the current rotational speed. This can be called from - * both client and server, so ensure that the TE is prepared for that. */ - public int getOmega(); - - /** For fetching the current torque. This can be called from - * both client and server, so ensure that the TE is prepared for that. */ - public int getTorque(); - - /** For fetching the current power value. This can be called from - * both client and server, so ensure that the TE is prepared for that. */ - public long getPower(); - - /** For when to write it to chat or the like. This can be called from - * both client and server, so ensure that the TE is prepared for that. */ - public String getName(); - - /** Analogous to TileEntityIOMachine's "iotick". Used to control I/O render opacity. */ - public int getIORenderAlpha(); - - /** Analogous to TileEntityIOMachine's "iotick". Used to control I/O render opacity. - * This one is called by tools. */ - public void setIORenderAlpha(int io); - -} diff --git a/src/api/java/Reika/RotaryCraft/API/ShaftMerger.java b/src/api/java/Reika/RotaryCraft/API/ShaftMerger.java deleted file mode 100644 index aaf50af7a..000000000 --- a/src/api/java/Reika/RotaryCraft/API/ShaftMerger.java +++ /dev/null @@ -1,15 +0,0 @@ -/******************************************************************************* - * @author Reika Kalseki - * - * Copyright 2014 - * - * All rights reserved. - * Distribution of the software in any form is only allowed with - * explicit, prior permission from the owner. - ******************************************************************************/ -package Reika.RotaryCraft.API; - -/** If your machine merges two shafts, implement this to avoid being the source of a loop exploit or StackOverflow */ -public interface ShaftMerger { - -} diff --git a/src/api/java/Reika/RotaryCraft/API/ShaftPowerEmitter.java b/src/api/java/Reika/RotaryCraft/API/ShaftPowerEmitter.java deleted file mode 100644 index 27a40058c..000000000 --- a/src/api/java/Reika/RotaryCraft/API/ShaftPowerEmitter.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * @author Reika Kalseki - * - * Copyright 2014 - * - * All rights reserved. - * Distribution of the software in any form is only allowed with - * explicit, prior permission from the owner. - ******************************************************************************/ -package Reika.RotaryCraft.API; - -import net.minecraftforge.common.util.ForgeDirection; - -public interface ShaftPowerEmitter extends ShaftMachine, PowerGenerator { - - /** x,y,z to write to */ - public boolean canWriteTo(ForgeDirection dir); - - /** Whether your machine is emitting power right now */ - public boolean isEmitting(); - -} diff --git a/src/api/java/Reika/RotaryCraft/API/ShaftPowerReceiver.java b/src/api/java/Reika/RotaryCraft/API/ShaftPowerReceiver.java deleted file mode 100644 index 298710046..000000000 --- a/src/api/java/Reika/RotaryCraft/API/ShaftPowerReceiver.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * @author Reika Kalseki - * - * Copyright 2014 - * - * All rights reserved. - * Distribution of the software in any form is only allowed with - * explicit, prior permission from the owner. - ******************************************************************************/ -package Reika.RotaryCraft.API; - -import net.minecraftforge.common.util.ForgeDirection; - -public interface ShaftPowerReceiver extends ShaftMachine { - - /** RC machines set your machine's rotational speed with this. */ - public void setOmega(int omega); - - /** RC machines set your machine's torque with this. */ - public void setTorque(int torque); - - /** RC machines set your machine's power with this. - * You do not need to calculate power=omega*torque; - * RC code will do that for you. */ - public void setPower(long power); - - /** x,y,z to read from */ - public boolean canReadFrom(ForgeDirection dir); - - /** Whether your machine is able to receive power right now */ - public boolean isReceiving(); - - /** When there is no input machine. Usually used to set power, speed, torque = 0 */ - public void noInputMachine(); - - /** The minimum torque the machine requires to operate. Also controls flywheel deceleration. - * Pick something reasonable, preferably as realistic as possible. */ - public int getMinTorque(int available); - -} diff --git a/src/api/java/Reika/RotaryCraft/API/ThermalMachine.java b/src/api/java/Reika/RotaryCraft/API/ThermalMachine.java deleted file mode 100644 index e16d2a821..000000000 --- a/src/api/java/Reika/RotaryCraft/API/ThermalMachine.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * @author Reika Kalseki - * - * Copyright 2014 - * - * All rights reserved. - * Distribution of the software in any form is only allowed with - * explicit, prior permission from the owner. - ******************************************************************************/ -package Reika.RotaryCraft.API; - -import net.minecraft.world.World; - -public interface ThermalMachine { - - /** For fetching the temperature for display */ - public int getTemperature(); - - /** For overwriting the temperature */ - public void setTemperature(int T); - - /** For updating the temperature */ - public void addTemperature(int T); - - /** For display purposes */ - public String getName(); - - /** For overheating tests */ - public int getMaxTemperature(); - - /** Actions to take on overheat */ - public void onOverheat(World world, int x, int y, int z); - - /** Can the friction heater heat this machine */ - public boolean canBeFrictionHeated(); - -} diff --git a/src/api/java/cofh/api/energy/EnergyStorage.java b/src/api/java/cofh/api/energy/EnergyStorage.java deleted file mode 100644 index b3383aebe..000000000 --- a/src/api/java/cofh/api/energy/EnergyStorage.java +++ /dev/null @@ -1,158 +0,0 @@ -package cofh.api.energy; - -import net.minecraft.nbt.NBTTagCompound; - -/** - * Reference implementation of {@link IEnergyStorage}. Use/extend this or implement your own. - * - * @author King Lemming - * - */ -public class EnergyStorage implements IEnergyStorage { - - protected int energy; - protected int capacity; - protected int maxReceive; - protected int maxExtract; - - public EnergyStorage(int capacity) { - - this(capacity, capacity, capacity); - } - - public EnergyStorage(int capacity, int maxTransfer) { - - this(capacity, maxTransfer, maxTransfer); - } - - public EnergyStorage(int capacity, int maxReceive, int maxExtract) { - - this.capacity = capacity; - this.maxReceive = maxReceive; - this.maxExtract = maxExtract; - } - - public EnergyStorage readFromNBT(NBTTagCompound nbt) { - - this.energy = nbt.getInteger("Energy"); - - if (energy > capacity) { - energy = capacity; - } - return this; - } - - public NBTTagCompound writeToNBT(NBTTagCompound nbt) { - - if (energy < 0) { - energy = 0; - } - nbt.setInteger("Energy", energy); - return nbt; - } - - public void setCapacity(int capacity) { - - this.capacity = capacity; - - if (energy > capacity) { - energy = capacity; - } - } - - public void setMaxTransfer(int maxTransfer) { - - setMaxReceive(maxTransfer); - setMaxExtract(maxTransfer); - } - - public void setMaxReceive(int maxReceive) { - - this.maxReceive = maxReceive; - } - - public void setMaxExtract(int maxExtract) { - - this.maxExtract = maxExtract; - } - - public int getMaxReceive() { - - return maxReceive; - } - - public int getMaxExtract() { - - return maxExtract; - } - - /** - * This function is included to allow for server -> client sync. Do not call this externally to the containing Tile Entity, as not all IEnergyHandlers are - * guaranteed to have it. - * - * @param energy - */ - public void setEnergyStored(int energy) { - - this.energy = energy; - - if (this.energy > capacity) { - this.energy = capacity; - } else if (this.energy < 0) { - this.energy = 0; - } - } - - /** - * This function is included to allow the containing tile to directly and efficiently modify the energy contained in the EnergyStorage. Do not rely on this - * externally, as not all IEnergyHandlers are guaranteed to have it. - * - * @param energy - */ - public void modifyEnergyStored(int energy) { - - this.energy += energy; - - if (this.energy > capacity) { - this.energy = capacity; - } else if (this.energy < 0) { - this.energy = 0; - } - } - - /* IEnergyStorage */ - @Override - public int receiveEnergy(int maxReceive, boolean simulate) { - - int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive)); - - if (!simulate) { - energy += energyReceived; - } - return energyReceived; - } - - @Override - public int extractEnergy(int maxExtract, boolean simulate) { - - int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); - - if (!simulate) { - energy -= energyExtracted; - } - return energyExtracted; - } - - @Override - public int getEnergyStored() { - - return energy; - } - - @Override - public int getMaxEnergyStored() { - - return capacity; - } - -} diff --git a/src/api/java/cofh/api/energy/IEnergyConnection.java b/src/api/java/cofh/api/energy/IEnergyConnection.java deleted file mode 100644 index 63faffb9f..000000000 --- a/src/api/java/cofh/api/energy/IEnergyConnection.java +++ /dev/null @@ -1,21 +0,0 @@ -package cofh.api.energy; - -import net.minecraftforge.common.util.ForgeDirection; - -/** - * Implement this interface on TileEntities which should connect to energy transportation blocks. This is intended for blocks which generate energy but do not - * accept it; otherwise just use IEnergyHandler. - * - * Note that {@link IEnergyHandler} is an extension of this. - * - * @author King Lemming - * - */ -public interface IEnergyConnection { - - /** - * Returns TRUE if the TileEntity can connect on a given side. - */ - boolean canConnectEnergy(ForgeDirection from); - -} diff --git a/src/api/java/cofh/api/energy/IEnergyContainerItem.java b/src/api/java/cofh/api/energy/IEnergyContainerItem.java deleted file mode 100644 index 0bcfda600..000000000 --- a/src/api/java/cofh/api/energy/IEnergyContainerItem.java +++ /dev/null @@ -1,52 +0,0 @@ -package cofh.api.energy; - -import net.minecraft.item.ItemStack; - -/** - * Implement this interface on Item classes that support external manipulation of their internal energy storages. - * - * A reference implementation is provided {@link ItemEnergyContainer}. - * - * @author King Lemming - * - */ -public interface IEnergyContainerItem { - - /** - * Adds energy to a container item. Returns the quantity of energy that was accepted. This should always return 0 if the item cannot be externally charged. - * - * @param container - * ItemStack to be charged. - * @param maxReceive - * Maximum amount of energy to be sent into the item. - * @param simulate - * If TRUE, the charge will only be simulated. - * @return Amount of energy that was (or would have been, if simulated) received by the item. - */ - int receiveEnergy(ItemStack container, int maxReceive, boolean simulate); - - /** - * Removes energy from a container item. Returns the quantity of energy that was removed. This should always return 0 if the item cannot be externally - * discharged. - * - * @param container - * ItemStack to be discharged. - * @param maxExtract - * Maximum amount of energy to be extracted from the item. - * @param simulate - * If TRUE, the discharge will only be simulated. - * @return Amount of energy that was (or would have been, if simulated) extracted from the item. - */ - int extractEnergy(ItemStack container, int maxExtract, boolean simulate); - - /** - * Get the amount of energy currently stored in the container item. - */ - int getEnergyStored(ItemStack container); - - /** - * Get the max amount of energy that can be stored in the container item. - */ - int getMaxEnergyStored(ItemStack container); - -} diff --git a/src/api/java/cofh/api/energy/IEnergyHandler.java b/src/api/java/cofh/api/energy/IEnergyHandler.java deleted file mode 100644 index 3aaf81a7d..000000000 --- a/src/api/java/cofh/api/energy/IEnergyHandler.java +++ /dev/null @@ -1,51 +0,0 @@ -package cofh.api.energy; - -import net.minecraftforge.common.util.ForgeDirection; - -/** - * Implement this interface on TileEntities which should handle energy, generally storing it in one or more internal {@link IEnergyStorage} objects. - * - * A reference implementation is provided {@link TileEnergyHandler}. - * - * @author King Lemming - * - */ -public interface IEnergyHandler extends IEnergyConnection { - - /** - * Add energy to an IEnergyHandler, internal distribution is left entirely to the IEnergyHandler. - * - * @param from - * Orientation the energy is received from. - * @param maxReceive - * Maximum amount of energy to receive. - * @param simulate - * If TRUE, the charge will only be simulated. - * @return Amount of energy that was (or would have been, if simulated) received. - */ - int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate); - - /** - * Remove energy from an IEnergyHandler, internal distribution is left entirely to the IEnergyHandler. - * - * @param from - * Orientation the energy is extracted from. - * @param maxExtract - * Maximum amount of energy to extract. - * @param simulate - * If TRUE, the extraction will only be simulated. - * @return Amount of energy that was (or would have been, if simulated) extracted. - */ - int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate); - - /** - * Returns the amount of energy currently stored. - */ - int getEnergyStored(ForgeDirection from); - - /** - * Returns the maximum amount of energy that can be stored. - */ - int getMaxEnergyStored(ForgeDirection from); - -} diff --git a/src/api/java/cofh/api/energy/IEnergyStorage.java b/src/api/java/cofh/api/energy/IEnergyStorage.java deleted file mode 100644 index 1e84bc221..000000000 --- a/src/api/java/cofh/api/energy/IEnergyStorage.java +++ /dev/null @@ -1,45 +0,0 @@ -package cofh.api.energy; - -/** - * An energy storage is the unit of interaction with Energy inventories. - * - * A reference implementation can be found at {@link EnergyStorage}. - * - * @author King Lemming - * - */ -public interface IEnergyStorage { - - /** - * Adds energy to the storage. Returns quantity of energy that was accepted. - * - * @param maxReceive - * Maximum amount of energy to be inserted. - * @param simulate - * If TRUE, the insertion will only be simulated. - * @return Amount of energy that was (or would have been, if simulated) accepted by the storage. - */ - int receiveEnergy(int maxReceive, boolean simulate); - - /** - * Removes energy from the storage. Returns quantity of energy that was removed. - * - * @param maxExtract - * Maximum amount of energy to be extracted. - * @param simulate - * If TRUE, the extraction will only be simulated. - * @return Amount of energy that was (or would have been, if simulated) extracted from the storage. - */ - int extractEnergy(int maxExtract, boolean simulate); - - /** - * Returns the amount of energy currently stored. - */ - int getEnergyStored(); - - /** - * Returns the maximum amount of energy that can be stored. - */ - int getMaxEnergyStored(); - -} diff --git a/src/api/java/cofh/api/energy/ItemEnergyContainer.java b/src/api/java/cofh/api/energy/ItemEnergyContainer.java deleted file mode 100644 index 055ae45bc..000000000 --- a/src/api/java/cofh/api/energy/ItemEnergyContainer.java +++ /dev/null @@ -1,110 +0,0 @@ -package cofh.api.energy; - -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; - -/** - * Reference implementation of {@link IEnergyContainerItem}. Use/extend this or implement your own. - * - * @author King Lemming - * - */ -public class ItemEnergyContainer extends Item implements IEnergyContainerItem { - - protected int capacity; - protected int maxReceive; - protected int maxExtract; - - public ItemEnergyContainer() { - - } - - public ItemEnergyContainer(int capacity) { - - this(capacity, capacity, capacity); - } - - public ItemEnergyContainer(int capacity, int maxTransfer) { - - this(capacity, maxTransfer, maxTransfer); - } - - public ItemEnergyContainer(int capacity, int maxReceive, int maxExtract) { - - this.capacity = capacity; - this.maxReceive = maxReceive; - this.maxExtract = maxExtract; - } - - public ItemEnergyContainer setCapacity(int capacity) { - - this.capacity = capacity; - return this; - } - - public void setMaxTransfer(int maxTransfer) { - - setMaxReceive(maxTransfer); - setMaxExtract(maxTransfer); - } - - public void setMaxReceive(int maxReceive) { - - this.maxReceive = maxReceive; - } - - public void setMaxExtract(int maxExtract) { - - this.maxExtract = maxExtract; - } - - /* IEnergyContainerItem */ - @Override - public int receiveEnergy(ItemStack container, int maxReceive, boolean simulate) { - - if (container.stackTagCompound == null) { - container.stackTagCompound = new NBTTagCompound(); - } - int energy = container.stackTagCompound.getInteger("Energy"); - int energyReceived = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive)); - - if (!simulate) { - energy += energyReceived; - container.stackTagCompound.setInteger("Energy", energy); - } - return energyReceived; - } - - @Override - public int extractEnergy(ItemStack container, int maxExtract, boolean simulate) { - - if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) { - return 0; - } - int energy = container.stackTagCompound.getInteger("Energy"); - int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); - - if (!simulate) { - energy -= energyExtracted; - container.stackTagCompound.setInteger("Energy", energy); - } - return energyExtracted; - } - - @Override - public int getEnergyStored(ItemStack container) { - - if (container.stackTagCompound == null || !container.stackTagCompound.hasKey("Energy")) { - return 0; - } - return container.stackTagCompound.getInteger("Energy"); - } - - @Override - public int getMaxEnergyStored(ItemStack container) { - - return capacity; - } - -} diff --git a/src/api/java/cofh/api/energy/TileEnergyHandler.java b/src/api/java/cofh/api/energy/TileEnergyHandler.java deleted file mode 100644 index a7fabeb77..000000000 --- a/src/api/java/cofh/api/energy/TileEnergyHandler.java +++ /dev/null @@ -1,62 +0,0 @@ -package cofh.api.energy; - -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; - -/** - * Reference implementation of {@link IEnergyHandler}. Use/extend this or implement your own. - * - * @author King Lemming - * - */ -public class TileEnergyHandler extends TileEntity implements IEnergyHandler { - - protected EnergyStorage storage = new EnergyStorage(32000); - - @Override - public void readFromNBT(NBTTagCompound nbt) { - - super.readFromNBT(nbt); - storage.readFromNBT(nbt); - } - - @Override - public void writeToNBT(NBTTagCompound nbt) { - - super.writeToNBT(nbt); - storage.writeToNBT(nbt); - } - - /* IEnergyHandler */ - @Override - public boolean canConnectEnergy(ForgeDirection from) { - - return true; - } - - @Override - public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { - - return storage.receiveEnergy(maxReceive, simulate); - } - - @Override - public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) { - - return storage.extractEnergy(maxExtract, simulate); - } - - @Override - public int getEnergyStored(ForgeDirection from) { - - return storage.getEnergyStored(); - } - - @Override - public int getMaxEnergyStored(ForgeDirection from) { - - return storage.getMaxEnergyStored(); - } - -} diff --git a/src/api/java/coloredlightscore/src/api/CLApi.java b/src/api/java/coloredlightscore/src/api/CLApi.java deleted file mode 100644 index bc74e6ec8..000000000 --- a/src/api/java/coloredlightscore/src/api/CLApi.java +++ /dev/null @@ -1,269 +0,0 @@ -package coloredlightscore.src.api; - -import java.util.Random; - -import net.minecraft.block.Block; -import cpw.mods.fml.common.FMLLog; - -/** - * Public API for ColoredLightsCore - * - * @author CptSpaceToaster - * - */ -public class CLApi -{ - - public static float l[] = new float[] { 0F, 1F / 15, 2F / 15, 3F / 15, 4F / 15, 5F / 15, 6F / 15, 7F / 15, 8F / 15, 9F / 15, 10F / 15, 11F / 15, 12F / 15, - 13F / 15, 14F / 15, 1F }; - - public static int r[] = new int[] { 0, 15, 0, 8, 0, 10, 0, 5, 10, 15, 8, 15, 0, 15, 15, 15 }; - public static int g[] = new int[] { 0, 0, 15, 3, 0, 0, 15, 5, 10, 10, 15, 15, 8, 0, 12, 15 }; - public static int b[] = new int[] { 0, 0, 0, 0, 15, 15, 15, 5, 10, 13, 0, 0, 15, 15, 10, 15 }; - - public static Random rand = new Random(); - - /** - * Computes a 20-bit lighting word, containing red, green, blue, and brightness settings. Allows overriding of the - * Minecraft brightness value. This value can be used directly for Block.lightValue - * - * Word format: 0RRRR 0GGGG 0BBBB 0LLLL - * - * @param r - * Red intensity, 0.0f to 1.0f. Resolution is 4 bits. - * @param g - * Green intensity, 0.0f to 1.0f. Resolution is 4 bits. - * @param b - * Blue intensity, 0.0f to 1.0f. Resolution is 4 bits. - * @param currentLightValue - * The existing lightValue of a block. Only the lower-most 4 bits of this parameter are used. - * @return Integer describing RGBL color for a block - */ - public static int makeRGBLightValue(float r, float g, float b, float currentLightValue) - { - // Clamp color channels - if ( r < 0.0f ) - r = 0.0f; - else if ( r > 1.0f ) - r = 1.0f; - - if ( g < 0.0f ) - g = 0.0f; - else if ( g > 1.0f ) - g = 1.0f; - - if ( b < 0.0f ) - b = 0.0f; - else if ( b > 1.0f ) - b = 1.0f; - - // if (currentLightValue != Math.max(r, Math.max(g, b))) { - // FMLLog.warning("One of the color value should be equal to Current Light Brightness, but not exceed it"); - // FMLLog.warning("r: " + r + " g: " + g + " b: " + b + " l: " + currentLightValue); - // } - - int brightness = (int) (currentLightValue * 15.0f); - brightness &= 15; - - return brightness | ((((int) (15.0F * b)) << 15) + (((int) (15.0F * g)) << 10) + (((int) (15.0F * r)) << 5)); - } - - /** - * Computes a 20-bit lighting word, containing red, green, blue, and brightness settings. Allows overriding of the - * Minecraft brightness value. This value can be used directly for Block.lightValue - * - * Word format: 0RRRR 0GGGG 0BBBB 0LLLL - * - * @param r - * Red intensity, 0 to 15. Resolution is 4 bits. - * @param g - * Green intensity, 0 to 15. Resolution is 4 bits. - * @param b - * Blue intensity, 0 to 15. Resolution is 4 bits. - * @param brightness - * The existing lightValue of a block. Only the lower-most 4 bits of this parameter are used. - * @return Integer describing RGBL color for a block - */ - public static int makeRGBLightValue(int r, int g, int b, int brightness) - { - // Clamp color channels - if ( r < 0 ) - r = 0; - else if ( r > 15 ) - r = 15; - - if ( g < 0 ) - g = 0; - else if ( g > 15 ) - g = 15; - - if ( b < 0 ) - b = 0; - else if ( b > 15 ) - b = 15; - - brightness &= 15; - - if ( brightness != Math.max( r, Math.max( g, b ) ) ) - { - FMLLog.warning( "One of the color value should be equal to Current Light Brightness, but not exceed it" ); - FMLLog.warning( "r: " + r + " g: " + g + " b: " + b + " l: " + brightness ); - } - - return brightness | ((b << 15) + (g << 10) + (r << 5)); - } - - /** - * Computes a 20-bit lighting word, containing red, green, blue settings, and brightness settings. Automatically - * computes the Minecraft brightness value using the brightest of the r, g and b channels. This value can be used - * directly for Block.lightValue - * - * Word format: 0RRRR 0GGGG 0BBBB 0LLLL - * - * @param r - * Red intensity, 0.0f to 1.0f. Resolution is 4 bits. - * @param g - * Green intensity, 0.0f to 1.0f. Resolution is 4 bits. - * @param b - * Blue intensity, 0.0f to 1.0f. Resolution is 4 bits. - * @return Integer describing RGB color for a block - */ - public static int makeRGBLightValue(float r, float g, float b) - { - // Clamp color channels - if ( r < 0.0f ) - r = 0.0f; - else if ( r > 1.0f ) - r = 1.0f; - - if ( g < 0.0f ) - g = 0.0f; - else if ( g > 1.0f ) - g = 1.0f; - - if ( b < 0.0f ) - b = 0.0f; - else if ( b > 1.0f ) - b = 1.0f; - - int brightness = (int) (15.0f * Math.max( Math.max( r, g ), b )); - return brightness | ((((int) (15.0F * b)) << 15) + (((int) (15.0F * g)) << 10) + (((int) (15.0F * r)) << 5)); - } - - /** - * Computes a 20-bit lighting word, containing red, green, blue settings, and brightness settings. Automatically - * computes the Minecraft brightness value using the brightest of the r, g and b channels. This value can be used - * directly for Block.lightValue - * - * Word format: 0RRRR 0GGGG 0BBBB 0LLLL - * - * @param r - * Red intensity, 0 to 15. Resolution is 4 bits. - * @param g - * Green intensity, 0 to 15. Resolution is 4 bits. - * @param b - * Blue intensity, 0 to 15. Resolution is 4 bits. - * @return Integer describing RGB color for a block - */ - public static int makeRGBLightValue(int r, int g, int b) - { - // Clamp color channels - if ( r < 0 ) - r = 0; - else if ( r > 15 ) - r = 15; - - if ( g < 0 ) - g = 0; - else if ( g > 15 ) - g = 15; - - if ( b < 0 ) - b = 0; - else if ( b > 15 ) - b = 15; - - int brightness = Math.max( Math.max( r, g ), b ); - return brightness | ((b << 15) + (g << 10) + (r << 5)); - } - - /** - * Sets the lighting colors for a given block. - * - * @param block - * The block to set color on - * @param r - * Red intensity, 0 to 15. Resolution is 4 bits. - * @param g - * Green intensity, 0 to 15. Resolution is 4 bits. - * @param b - * Blue intensity, 0 to 15. Resolution is 4 bits. - * @param lightValue - * The Minecraft brightness to set for the block, 0 to 15. - * @return Reference to the block passed in. - */ - public static Block setBlockColorRGB(Block block, int r, int g, int b, int lightValue) - { - // block.lightValue = makeRGBLightValue(r, g, b, lightValue); - return block; - } - - /** - * Sets the lighting colors for a given block. - * - * @param block - * The block to set color on - * @param r - * Red intensity, 0.0f to 1.0f. Resolution is 4 bits. - * @param g - * Green intensity, 0.0f to 1.0f. Resolution is 4 bits. - * @param b - * Blue intensity, 0.0f to 1.0f. Resolution is 4 bits. - * @param lightValue - * The Minecraft brightness to set for the block, 0.0f to 1.0f. - * @return Reference to the block passed in. - */ - public static Block setBlockColorRGB(Block block, float r, float g, float b, float lightValue) - { - // block.lightValue = makeRGBLightValue(r, g, b, lightValue); - return block; - } - - /** - * Sets the lighting colors for a given block. Does not alter/recompute the brightness. - * - * @param block - * The block to set color on - * @param r - * Red intensity, 0.0f to 1.0f. Resolution is 4 bits. - * @param g - * Green intensity, 0.0f to 1.0f. Resolution is 4 bits. - * @param b - * Blue intensity, 0.0f to 1.0f. Resolution is 4 bits. - * @return Reference to the block passed in. - */ - public static Block setBlockColorRGB(Block block, int r, int g, int b) - { - // block.lightValue = makeRGBLightValue( r, g, b, block.lightValue ); - return block; - } - - /** - * Sets the lighting colors for a given block. Does not alter/recompute the brightness. - * - * @param block - * The block to set color on - * @param r - * Red intensity, 0.0f to 1.0f. Resolution is 4 bits. - * @param g - * Green intensity, 0.0f to 1.0f. Resolution is 4 bits. - * @param b - * Blue intensity, 0.0f to 1.0f. Resolution is 4 bits. - * @return Reference to the block passed in. - */ - public static Block setBlockColorRGB(Block block, float r, float g, float b) - { - // block.lightValue = makeRGBLightValue( r, g, b, block.lightValue / 15.0f ); - return block; - } -} \ No newline at end of file diff --git a/src/api/java/gregtechmod/api/interfaces/IDigitalChest.java b/src/api/java/gregtechmod/api/interfaces/IDigitalChest.java deleted file mode 100644 index 3c3fb6b0e..000000000 --- a/src/api/java/gregtechmod/api/interfaces/IDigitalChest.java +++ /dev/null @@ -1,29 +0,0 @@ -package gregtechmod.api.interfaces; - -import net.minecraft.item.ItemStack; - -/** - * You are allowed to include this File in your Download, as i will not change it. - */ -public interface IDigitalChest extends IHasWorldObjectAndCoords { - /** - * Is this even a TileEntity of a Digital Chest? - * I need things like this Function for MetaTileEntities, you MUST check this!!! - * Do not assume that it's a Digital Chest or similar Device, when it just implements this Interface. - */ - public boolean isDigitalChest(); - /** - * Gives an Array of Stacks with Size (of all the Data-stored Items) of the correspondent Item kinds (regular QChests have only one) - * Does NOT include the 64 "ready" Items inside the Slots, and neither the 128 Items in the overflow Buffer. - */ - public ItemStack[] getStoredItemData(); - /** - * A generic Interface for just setting the amount of contained Items - */ - public void setItemCount(int aCount); - - /** - * Gets the maximum Item count for this QChest alike Storage. This applies to the Data-Storage, not for the up to 192 buffered Items! - */ - public int getMaxItemCount(); -} \ No newline at end of file diff --git a/src/api/java/gregtechmod/api/interfaces/IHasWorldObjectAndCoords.java b/src/api/java/gregtechmod/api/interfaces/IHasWorldObjectAndCoords.java deleted file mode 100644 index f932507e8..000000000 --- a/src/api/java/gregtechmod/api/interfaces/IHasWorldObjectAndCoords.java +++ /dev/null @@ -1,75 +0,0 @@ -package gregtechmod.api.interfaces; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.IInventory; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import net.minecraft.world.biome.BiomeGenBase; - -/** - * This is a bunch of Functions my TileEntities provide, to make life much easier, and to get rid of internal TileEntity stuff. - */ -public interface IHasWorldObjectAndCoords { - public World getWorld(); - public int getXCoord(); - public int getYCoord(); - public int getZCoord(); - - public boolean isServerSide(); - public boolean isClientSide(); - - public int getRandomNumber(int aRange); - - public TileEntity getTileEntity(int aX, int aY, int aZ); - public TileEntity getTileEntityOffset(int aX, int aY, int aZ); - public TileEntity getTileEntityAtSide(byte aSide); - public TileEntity getTileEntityAtSideAndDistance(byte aSide, int aDistance); - - public IInventory getIInventory(int aX, int aY, int aZ); - public IInventory getIInventoryOffset(int aX, int aY, int aZ); - public IInventory getIInventoryAtSide(byte aSide); - public IInventory getIInventoryAtSideAndDistance(byte aSide, int aDistance); - - public short getBlockID(int aX, int aY, int aZ); - public short getBlockIDOffset(int aX, int aY, int aZ); - public short getBlockIDAtSide(byte aSide); - public short getBlockIDAtSideAndDistance(byte aSide, int aDistance); - - public byte getMetaID(int aX, int aY, int aZ); - public byte getMetaIDOffset(int aX, int aY, int aZ); - public byte getMetaIDAtSide(byte aSide); - public byte getMetaIDAtSideAndDistance(byte aSide, int aDistance); - - public byte getLightLevel(int aX, int aY, int aZ); - public byte getLightLevelOffset(int aX, int aY, int aZ); - public byte getLightLevelAtSide(byte aSide); - public byte getLightLevelAtSideAndDistance(byte aSide, int aDistance); - - public boolean getSky(int aX, int aY, int aZ); - public boolean getSkyOffset(int aX, int aY, int aZ); - public boolean getSkyAtSide(byte aSide); - public boolean getSkyAtSideAndDistance(byte aSide, int aDistance); - - public BiomeGenBase getBiome(int aX, int aZ); - - /** - * Function of the regular TileEntity - */ - public void writeToNBT(NBTTagCompound aNBT); - - /** - * Function of the regular TileEntity - */ - public void readFromNBT(NBTTagCompound aNBT); - - /** - * Function of the regular TileEntity - */ - public boolean isInvalid(); - - /** - * Opens GUI-ID of any Mod - */ - public void openGUI(EntityPlayer aPlayer, int aID, Object aMod); -} \ No newline at end of file diff --git a/src/api/java/invtweaks/api/IItemTree.java b/src/api/java/invtweaks/api/IItemTree.java deleted file mode 100644 index 5b6c0a805..000000000 --- a/src/api/java/invtweaks/api/IItemTree.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2013 Andrew Crocker - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package invtweaks.api; - -import java.util.Collection; -import java.util.List; -import java.util.Random; - -public interface IItemTree { - public void registerOre(String category, String name, String oreName, int order); - - boolean matches(List items, String keyword); - - boolean isKeywordValid(String keyword); - - Collection getAllCategories(); - - IItemTreeCategory getRootCategory(); - - IItemTreeCategory getCategory(String keyword); - - boolean isItemUnknown(String id, int damage); - - List getItems(String id, int damage); - - List getItems(String name); - - IItemTreeItem getRandomItem(Random r); - - boolean containsItem(String name); - - boolean containsCategory(String name); - - void setRootCategory(IItemTreeCategory category); - - IItemTreeCategory addCategory(String parentCategory, String newCategory) throws NullPointerException; - - void addCategory(String parentCategory, IItemTreeCategory newCategory) throws NullPointerException; - - IItemTreeItem addItem(String parentCategory, String name, String id, int damage, int order) - throws NullPointerException; - - void addItem(String parentCategory, IItemTreeItem newItem) throws NullPointerException; - - int getKeywordDepth(String keyword); - - int getKeywordOrder(String keyword); -} diff --git a/src/api/java/invtweaks/api/IItemTreeCategory.java b/src/api/java/invtweaks/api/IItemTreeCategory.java deleted file mode 100644 index f1b5e9554..000000000 --- a/src/api/java/invtweaks/api/IItemTreeCategory.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2013 Andrew Crocker - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package invtweaks.api; - -import java.util.Collection; -import java.util.List; - -public interface IItemTreeCategory { - boolean contains(IItemTreeItem item); - - void addCategory(IItemTreeCategory category); - - void addItem(IItemTreeItem item); - - Collection getSubCategories(); - - Collection> getItems(); - - String getName(); - - int getCategoryOrder(); - - int findCategoryOrder(String keyword); - - int findKeywordDepth(String keyword); -} diff --git a/src/api/java/invtweaks/api/IItemTreeItem.java b/src/api/java/invtweaks/api/IItemTreeItem.java deleted file mode 100644 index 2b6ae2db5..000000000 --- a/src/api/java/invtweaks/api/IItemTreeItem.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2013 Andrew Crocker - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package invtweaks.api; - -public interface IItemTreeItem extends Comparable { - String getName(); - - String getId(); - - int getDamage(); - - int getOrder(); -} diff --git a/src/api/java/invtweaks/api/IItemTreeListener.java b/src/api/java/invtweaks/api/IItemTreeListener.java deleted file mode 100644 index 73a5815d5..000000000 --- a/src/api/java/invtweaks/api/IItemTreeListener.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2013 Andrew Crocker - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package invtweaks.api; - -import java.util.EventListener; - -public interface IItemTreeListener extends EventListener { - void onTreeLoaded(IItemTree tree); -} diff --git a/src/api/java/invtweaks/api/InvTweaksAPI.java b/src/api/java/invtweaks/api/InvTweaksAPI.java deleted file mode 100644 index 2e1573f70..000000000 --- a/src/api/java/invtweaks/api/InvTweaksAPI.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) 2013 Andrew Crocker - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package invtweaks.api; - -import net.minecraft.item.ItemStack; - -/** - * Interface to access functions exposed by Inventory Tweaks - *

- * The main @Mod instance of the mod implements this interface, so a refernce to it can - * be obtained via @Instance("inventorytweaks") or methods in cpw.mods.fml.common.Loader - *

- * All of these functions currently have no effect if called on a dedicated server. - */ -public interface InvTweaksAPI { - /** - * Add a listener for ItemTree load events - * - * @param listener - */ - void addOnLoadListener(IItemTreeListener listener); - - /** - * Remove a listener for ItemTree load events - * - * @param listener - * @return true if the listener was previously added - */ - boolean removeOnLoadListener(IItemTreeListener listener); - - /** - * Toggle sorting shortcut state. - * - * @param enabled - */ - void setSortKeyEnabled(boolean enabled); - - /** - * Toggle sorting shortcut supression. - * Unlike setSortKeyEnabled, this flag is automatically cleared when GUIs are closed. - * - * @param enabled - */ - void setTextboxMode(boolean enabled); - - /** - * Compare two items using the default (non-rule based) algorithm, - * sutable for an implementation of Comparator<ItemStack>. - * - * @param i - * @param j - * @return A value with a sign representing the relative order of the item stacks - */ - int compareItems(ItemStack i, ItemStack j); -} diff --git a/src/api/java/invtweaks/api/container/ChestContainer.java b/src/api/java/invtweaks/api/container/ChestContainer.java deleted file mode 100644 index 3bd57e1b1..000000000 --- a/src/api/java/invtweaks/api/container/ChestContainer.java +++ /dev/null @@ -1,28 +0,0 @@ -package invtweaks.api.container; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * A marker for containers that have a chest-like persistant storage component. Enables the Inventroy Tweaks sorting - * buttons for this container. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface ChestContainer { - // Size of a chest row - int rowSize() default 9; - - // Uses 'large chest' mode for sorting buttons - // (Renders buttons vertically down the right side of the GUI) - boolean isLargeChest() default false; - - // Annotation for method to get size of a chest row if it is not a fixed size for this container class - // Signature int func() - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.METHOD) - public @interface RowSizeCallback { - } -} diff --git a/src/api/java/invtweaks/api/container/ContainerSection.java b/src/api/java/invtweaks/api/container/ContainerSection.java deleted file mode 100644 index e80a987fb..000000000 --- a/src/api/java/invtweaks/api/container/ContainerSection.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2013 Andrew Crocker - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -package invtweaks.api.container; - -/** - * Names for specific parts of containers. For unknown container types (such as mod containers), only INVENTORY and - * CHEST sections are available. - */ -public enum ContainerSection { - /** - * The player's inventory - */ - INVENTORY, - /** - * The player's inventory (only the hotbar) - */ - INVENTORY_HOTBAR, - /** - * The player's inventory (all except the hotbar) - */ - INVENTORY_NOT_HOTBAR, - /** - * The chest or dispenser contents. Also used for unknown container contents. - */ - CHEST, - /** - * The crafting input - */ - CRAFTING_IN, - /** - * The crafting input, for containters that store it internally - */ - CRAFTING_IN_PERSISTENT, - /** - * The crafting output - */ - CRAFTING_OUT, - /** - * The armor slots - */ - ARMOR, - /** - * The furnace input - */ - FURNACE_IN, - /** - * The furnace output - */ - FURNACE_OUT, - /** - * The furnace fuel - */ - FURNACE_FUEL, - /** - * The enchantment table slot - */ - ENCHANTMENT, - /** - * The three bottles slots in brewing tables - */ - BREWING_BOTTLES, - /** - * The top slot in brewing tables - */ - BREWING_INGREDIENT -} diff --git a/src/api/java/invtweaks/api/container/ContainerSectionCallback.java b/src/api/java/invtweaks/api/container/ContainerSectionCallback.java deleted file mode 100644 index 379206b37..000000000 --- a/src/api/java/invtweaks/api/container/ContainerSectionCallback.java +++ /dev/null @@ -1,16 +0,0 @@ -package invtweaks.api.container; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * A marker for a method to call which returns the set of ContainerSections for this container. - *

- * Signature of the method should be Map> func() - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.METHOD) -public @interface ContainerSectionCallback { -} diff --git a/src/api/java/invtweaks/api/container/IgnoreContainer.java b/src/api/java/invtweaks/api/container/IgnoreContainer.java deleted file mode 100644 index 4102ec92b..000000000 --- a/src/api/java/invtweaks/api/container/IgnoreContainer.java +++ /dev/null @@ -1,15 +0,0 @@ -package invtweaks.api.container; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Use this annotation to override inherited annotation properties and mark a Container as unsortable. - * This effect is inherited as well. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface IgnoreContainer { -} \ No newline at end of file diff --git a/src/api/java/invtweaks/api/container/InventoryContainer.java b/src/api/java/invtweaks/api/container/InventoryContainer.java deleted file mode 100644 index d5a45b912..000000000 --- a/src/api/java/invtweaks/api/container/InventoryContainer.java +++ /dev/null @@ -1,20 +0,0 @@ -package invtweaks.api.container; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * A marker for containers that need special treatment, such as crafting inputs or alternate player inventory positions, - * but do not have a chest-like component. - *

- * Does not enable the Inventory Tweaks sorting buttons for this container. - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface InventoryContainer { - // Set to true if the Inventory Tweaks options button should be shown for this container. - // (For instance, if you are replacing a vanilla container such as the player's inventory) - boolean showOptions() default true; -} diff --git a/src/api/java/mekanism/api/AdvancedInput.java b/src/api/java/mekanism/api/AdvancedInput.java deleted file mode 100644 index 8d2859af9..000000000 --- a/src/api/java/mekanism/api/AdvancedInput.java +++ /dev/null @@ -1,28 +0,0 @@ -package mekanism.api; - -import mekanism.api.gas.Gas; -import mekanism.common.util.StackUtils; -import net.minecraft.item.ItemStack; - -public class AdvancedInput -{ - public ItemStack itemStack; - - public Gas gasType; - - public AdvancedInput(ItemStack item, Gas gas) - { - itemStack = item; - gasType = gas; - } - - public boolean isValid() - { - return itemStack != null && gasType != null; - } - - public boolean matches(AdvancedInput input) - { - return StackUtils.equalsWildcard(itemStack, input.itemStack) && input.itemStack.stackSize >= itemStack.stackSize; - } -} diff --git a/src/api/java/mekanism/api/BlockInfo.java b/src/api/java/mekanism/api/BlockInfo.java deleted file mode 100644 index 50c990f27..000000000 --- a/src/api/java/mekanism/api/BlockInfo.java +++ /dev/null @@ -1,38 +0,0 @@ -package mekanism.api; - -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; - -public class BlockInfo -{ - public Block block; - public int meta; - - public BlockInfo(Block b, int j) - { - block = b; - meta = j; - } - - public static BlockInfo get(ItemStack stack) - { - return new BlockInfo(Block.getBlockFromItem(stack.getItem()), stack.getItemDamage()); - } - - @Override - public boolean equals(Object obj) - { - return obj instanceof BlockInfo && - ((BlockInfo)obj).block == block && - ((BlockInfo)obj).meta == meta; - } - - @Override - public int hashCode() - { - int code = 1; - code = 31 * code + block.getUnlocalizedName().hashCode(); - code = 31 * code + meta; - return code; - } -} \ No newline at end of file diff --git a/src/api/java/mekanism/api/ChanceOutput.java b/src/api/java/mekanism/api/ChanceOutput.java deleted file mode 100644 index 97ff0b7de..000000000 --- a/src/api/java/mekanism/api/ChanceOutput.java +++ /dev/null @@ -1,49 +0,0 @@ -package mekanism.api; - -import java.util.Random; - -import mekanism.common.util.StackUtils; -import net.minecraft.item.ItemStack; - -public class ChanceOutput -{ - private static Random rand = new Random(); - - public ItemStack primaryOutput; - - public ItemStack secondaryOutput; - - public double secondaryChance; - - public ChanceOutput(ItemStack primary, ItemStack secondary, double chance) - { - primaryOutput = primary; - secondaryOutput = secondary; - secondaryChance = chance; - } - - public ChanceOutput(ItemStack primary) - { - primaryOutput = primary; - } - - public boolean checkSecondary() - { - return rand.nextDouble() <= secondaryChance; - } - - public boolean hasPrimary() - { - return primaryOutput != null; - } - - public boolean hasSecondary() - { - return secondaryOutput != null; - } - - public ChanceOutput copy() - { - return new ChanceOutput(StackUtils.copy(primaryOutput), StackUtils.copy(secondaryOutput), secondaryChance); - } -} diff --git a/src/api/java/mekanism/api/ChemicalPair.java b/src/api/java/mekanism/api/ChemicalPair.java deleted file mode 100644 index 7c28ea0d0..000000000 --- a/src/api/java/mekanism/api/ChemicalPair.java +++ /dev/null @@ -1,116 +0,0 @@ -package mekanism.api; - -import mekanism.api.gas.GasStack; -import mekanism.api.gas.GasTank; - -/** - * An input of gasses for recipe use. - * @author aidancbrady - * - */ -public class ChemicalPair -{ - /** The left gas of this chemical input */ - public GasStack leftGas; - - /** The right gas of this chemical input */ - public GasStack rightGas; - - /** - * Creates a chemical input with two defined gasses. - * @param left - left gas - * @param right - right gas - */ - public ChemicalPair(GasStack left, GasStack right) - { - leftGas = left; - rightGas = right; - } - - /** - * If this is a valid ChemicalPair - * @return - */ - public boolean isValid() - { - return leftGas != null && rightGas != null; - } - - /** - * Whether or not the defined input contains the same gasses and at least the required amount of the defined gasses as this input. - * @param input - input to check - * @return if the input meets this input's requirements - */ - public boolean meetsInput(ChemicalPair input) - { - return meets(input) || meets(input.swap()); - } - - /** - * Swaps the right gas and left gas of this input. - * @return a swapped ChemicalInput - */ - public ChemicalPair swap() - { - return new ChemicalPair(rightGas, leftGas); - } - - /** - * Draws the needed amount of gas from each tank. - * @param leftTank - left tank to draw from - * @param rightTank - right tank to draw from - */ - public void draw(GasTank leftTank, GasTank rightTank) - { - if(meets(new ChemicalPair(leftTank.getGas(), rightTank.getGas()))) - { - leftTank.draw(leftGas.amount, true); - rightTank.draw(rightGas.amount, true); - } - else if(meets(new ChemicalPair(rightTank.getGas(), leftTank.getGas()))) - { - leftTank.draw(rightGas.amount, true); - rightTank.draw(leftGas.amount, true); - } - } - - /** - * Whether or not one of this ChemicalInput's GasStack entry's gas type is equal to the gas type of the given gas. - * @param stack - stack to check - * @return if the stack's gas type is contained in this ChemicalInput - */ - public boolean containsType(GasStack stack) - { - if(stack == null || stack.amount == 0) - { - return false; - } - - return stack.isGasEqual(leftGas) || stack.isGasEqual(rightGas); - } - - /** - * Actual implementation of meetsInput(), performs the checks. - * @param input - input to check - * @return if the input meets this input's requirements - */ - private boolean meets(ChemicalPair input) - { - if(input == null || !input.isValid()) - { - return false; - } - - if(input.leftGas.getGas() != leftGas.getGas() || input.rightGas.getGas() != rightGas.getGas()) - { - return false; - } - - return input.leftGas.amount >= leftGas.amount && input.rightGas.amount >= rightGas.amount; - } - - public ChemicalPair copy() - { - return new ChemicalPair(leftGas.copy(), rightGas.copy()); - } -} diff --git a/src/api/java/mekanism/api/Chunk3D.java b/src/api/java/mekanism/api/Chunk3D.java deleted file mode 100644 index 854be7158..000000000 --- a/src/api/java/mekanism/api/Chunk3D.java +++ /dev/null @@ -1,108 +0,0 @@ -package mekanism.api; - -import net.minecraft.entity.Entity; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; - -/** - * Chunk3D - an integer-based way to keep track of and perform operations on chunks in a Minecraft-based environment. This also takes - * in account the dimension the chunk is in. - * @author aidancbrady - * - */ -public class Chunk3D -{ - public int dimensionId; - - public int xCoord; - public int zCoord; - - /** - * Creates a Chunk3D object from the given x and z coordinates, as well as a dimension. - * @param x - chunk x location - * @param z - chunk z location - * @param dimension - the dimension this Chunk3D is in - */ - public Chunk3D(int x, int z, int dimension) - { - xCoord = x; - zCoord = z; - - dimensionId = dimension; - } - - /** - * Creates a Chunk3D from an entity based on it's location and dimension. - * @param entity - the entity to get the Chunk3D object from - */ - public Chunk3D(Entity entity) - { - xCoord = ((int)entity.posX) >> 4; - zCoord = ((int)entity.posZ) >> 4; - - dimensionId = entity.dimension; - } - - /** - * Creates a Chunk3D from a Coord4D based on it's coordinates and dimension. - * @param coord - the Coord4D object to get this Chunk3D from - */ - public Chunk3D(Coord4D coord) - { - xCoord = coord.xCoord >> 4; - zCoord = coord.zCoord >> 4; - - dimensionId = coord.dimensionId; - } - - /** - * Whether or not this chunk exists in the given world. - * @param world - the world to check in - * @return if the chunk exists - */ - public boolean exists(World world) - { - return world.getChunkProvider().chunkExists(xCoord, zCoord); - } - - /** - * Gets a Chunk object corresponding to this Chunk3D's coordinates. - * @param world - the world to get the Chunk object from - * @return the corresponding Chunk object - */ - public Chunk getChunk(World world) - { - return world.getChunkFromChunkCoords(xCoord, zCoord); - } - - @Override - public Coord4D clone() - { - return new Coord4D(xCoord, zCoord, dimensionId); - } - - @Override - public String toString() - { - return "[Chunk3D: " + xCoord + ", " + zCoord + ", dim=" + dimensionId + "]"; - } - - @Override - public boolean equals(Object obj) - { - return obj instanceof Chunk3D && - ((Chunk3D)obj).xCoord == xCoord && - ((Chunk3D)obj).zCoord == zCoord && - ((Chunk3D)obj).dimensionId == dimensionId; - } - - @Override - public int hashCode() - { - int code = 1; - code = 31 * code + xCoord; - code = 31 * code + zCoord; - code = 31 * code + dimensionId; - return code; - } -} diff --git a/src/api/java/mekanism/api/Coord4D.java b/src/api/java/mekanism/api/Coord4D.java deleted file mode 100644 index 22db2ccd1..000000000 --- a/src/api/java/mekanism/api/Coord4D.java +++ /dev/null @@ -1,358 +0,0 @@ -package mekanism.api; - -import io.netty.buffer.ByteBuf; - -import java.util.ArrayList; - -import net.minecraft.block.Block; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.MathHelper; -import net.minecraft.world.IBlockAccess; -import net.minecraft.world.World; -import net.minecraft.world.chunk.Chunk; -import net.minecraftforge.common.util.ForgeDirection; -import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; - -/** - * Coord4D - an integer-based way to keep track of and perform operations on blocks in a Minecraft-based environment. This also takes - * in account the dimension the coordinate is in. - * @author aidancbrady - * - */ -public class Coord4D -{ - public int xCoord; - public int yCoord; - public int zCoord; - - public int dimensionId; - - /** - * Creates a Coord4D WITHOUT a dimensionId. Don't use unless absolutely necessary. - * @param x - x coordinate - * @param y - y coordinate - * @param z - z coordinate - */ - public Coord4D(int x, int y, int z) - { - xCoord = x; - yCoord = y; - zCoord = z; - - dimensionId = 0; - } - - /** - * Creates a Coord4D from the defined x, y, z, and dimension values. - * @param x - x coordinate - * @param y - y coordinate - * @param z - z coordinate - * @param dimension - dimension ID - */ - public Coord4D(int x, int y, int z, int dimension) - { - xCoord = x; - yCoord = y; - zCoord = z; - - dimensionId = dimension; - } - - /** - * Gets the metadata of the block representing this Coord4D. - * @param world - world this Coord4D is in - * @return the metadata of this Coord4D's block - */ - public int getMetadata(IBlockAccess world) - { - return world.getBlockMetadata(xCoord, yCoord, zCoord); - } - - /** - * Gets the TileEntity of the block representing this Coord4D. - * @param world - world this Coord4D is in - * @return the TileEntity of this Coord4D's block - */ - public TileEntity getTileEntity(IBlockAccess world) - { - if(world instanceof World && !exists((World)world)) - { - return null; - } - - return world.getTileEntity(xCoord, yCoord, zCoord); - } - - /** - * Gets the Block value of the block representing this Coord4D. - * @param world - world this Coord4D is in - * @return the Block value of this Coord4D's block - */ - public Block getBlock(IBlockAccess world) - { - if(world instanceof World && !exists((World)world)) - { - return null; - } - - return world.getBlock(xCoord, yCoord, zCoord); - } - - /** - * Writes this Coord4D's data to an NBTTagCompound. - * @param nbtTags - tag compound to write to - * @return the tag compound with this Coord4D's data - */ - public NBTTagCompound write(NBTTagCompound nbtTags) - { - nbtTags.setInteger("x", xCoord); - nbtTags.setInteger("y", yCoord); - nbtTags.setInteger("z", zCoord); - nbtTags.setInteger("dimensionId", dimensionId); - - return nbtTags; - } - - /** - * Writes this Coord4D's data to an ArrayList for packet transfer. - * @param data - the ArrayList to add the data to - */ - public void write(ArrayList data) - { - data.add(xCoord); - data.add(yCoord); - data.add(zCoord); - data.add(dimensionId); - } - - /** - * Writes this Coord4D's data to a ByteBuf for packet transfer. - * @param dataStream - the ByteBuf to add the data to - */ - public void write(ByteBuf dataStream) - { - dataStream.writeInt(xCoord); - dataStream.writeInt(yCoord); - dataStream.writeInt(zCoord); - dataStream.writeInt(dimensionId); - } - - /** - * Translates this Coord4D by the defined x, y, and z values. - * @param x - x value to translate - * @param y - y value to translate - * @param z - z value to translate - * @return translated Coord4D - */ - public Coord4D translate(int x, int y, int z) - { - xCoord += x; - yCoord += y; - zCoord += z; - - return this; - } - - /** - * Creates and returns a new Coord4D translated to the defined offsets of the side. - * @param side - side to translate this Coord4D to - * @return translated Coord4D - */ - public Coord4D getFromSide(ForgeDirection side) - { - return getFromSide(side, 1); - } - - public Coord4D getFromSide(ForgeDirection side, int amount) - { - return new Coord4D(xCoord+(side.offsetX*amount), yCoord+(side.offsetY*amount), zCoord+(side.offsetZ*amount), dimensionId); - } - - /** - * Returns a new Coord4D from a defined TileEntity's xCoord, yCoord and zCoord values. - * @param tileEntity - TileEntity at the location that will represent this Coord4D - * @return the Coord4D object from the TileEntity - */ - public static Coord4D get(TileEntity tileEntity) - { - return new Coord4D(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, tileEntity.getWorldObj().provider.dimensionId); - } - - /** - * Returns a new Coord4D from a tag compound. - * @param data - tag compound to read from - * @return the Coord4D from the tag compound - */ - public static Coord4D read(NBTTagCompound tag) - { - return new Coord4D(tag.getInteger("x"), tag.getInteger("y"), tag.getInteger("z"), tag.getInteger("id")); - } - - /** - * Returns a new Coord4D from a ByteBuf. - * @param dataStream - data input to read from - * @return the Coord4D from the data input - */ - public static Coord4D read(ByteBuf dataStream) - { - return new Coord4D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt(), dataStream.readInt()); - } - - /** - * Creates and returns a new Coord4D with values representing the difference between the defined Coord4D - * @param other - the Coord4D to subtract from this - * @return a Coord4D representing the distance between the defined Coord4D - */ - public Coord4D difference(Coord4D other) - { - return new Coord4D(xCoord-other.xCoord, yCoord-other.yCoord, zCoord-other.zCoord, dimensionId); - } - - /** - * A method used to find the ForgeDirection represented by the distance of the defined Coord4D. Most likely won't have many - * applicable uses. - * @param other - Coord4D to find the side difference of - * @return ForgeDirection representing the side the defined relative Coord4D is on to this - */ - public ForgeDirection sideDifference(Coord4D other) - { - Coord4D diff = difference(other); - - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - if(side.offsetX == diff.xCoord && side.offsetY == diff.yCoord && side.offsetZ == diff.zCoord) - { - return side; - } - } - - return ForgeDirection.UNKNOWN; - } - - /** - * Gets the distance to a defined Coord4D. - * @param obj - the Coord4D to find the distance to - * @return the distance to the defined Coord4D - */ - public int distanceTo(Coord4D obj) - { - int subX = xCoord - obj.xCoord; - int subY = yCoord - obj.yCoord; - int subZ = zCoord - obj.zCoord; - return (int)MathHelper.sqrt_double(subX * subX + subY * subY + subZ * subZ); - } - - /** - * Whether or not the defined side of this Coord4D is visible. - * @param side - side to check - * @param world - world this Coord4D is in - * @return - */ - public boolean sideVisible(ForgeDirection side, IBlockAccess world) - { - return world.isAirBlock(xCoord+side.offsetX, yCoord+side.offsetY, zCoord+side.offsetZ); - } - - /** - * Gets a TargetPoint with the defined range from this Coord4D with the appropriate coordinates and dimension ID. - * @param range - the range the packet can be sent in of this Coord4D - * @return TargetPoint relative to this Coord4D - */ - public TargetPoint getTargetPoint(double range) - { - return new TargetPoint(dimensionId, xCoord, yCoord, zCoord, range); - } - - /** - * Steps this Coord4D in the defined side's offset without creating a new value. - * @param side - side to step towards - * @return this Coord4D - */ - public Coord4D step(ForgeDirection side) - { - return translate(side.offsetX, side.offsetY, side.offsetZ); - } - - /** - * Whether or not the chunk this Coord4D is in exists and is loaded. - * @param world - world this Coord4D is in - * @return the chunk of this Coord4D - */ - public boolean exists(World world) - { - return world.getChunkProvider().chunkExists(xCoord >> 4, zCoord >> 4); - } - - /** - * Gets the chunk this Coord4D is in. - * @param world - world this Coord4D is in - * @return the chunk of this Coord4D - */ - public Chunk getChunk(World world) - { - return world.getChunkFromBlockCoords(xCoord, zCoord); - } - - /** - * Gets the Chunk3D object with chunk coordinates correlating to this Coord4D's location - * @return Chunk3D with correlating chunk coordinates. - */ - public Chunk3D getChunk3D() - { - return new Chunk3D(this); - } - - /** - * Whether or not the block this Coord4D represents is an air block. - * @param world - world this Coord4D is in - * @return if this Coord4D is an air block - */ - public boolean isAirBlock(IBlockAccess world) - { - return world.isAirBlock(xCoord, yCoord, zCoord); - } - - /** - * Gets a bounding box that contains the area this Coord4D would take up in a world. - * @return this Coord4D's bounding box - */ - public AxisAlignedBB getBoundingBox() - { - return AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord+1, yCoord+1, zCoord+1); - } - - @Override - public Coord4D clone() - { - return new Coord4D(xCoord, yCoord, zCoord, dimensionId); - } - - @Override - public String toString() - { - return "[Coord4D: " + xCoord + ", " + yCoord + ", " + zCoord + ", dim=" + dimensionId + "]"; - } - - @Override - public boolean equals(Object obj) - { - return obj instanceof Coord4D && - ((Coord4D)obj).xCoord == xCoord && - ((Coord4D)obj).yCoord == yCoord && - ((Coord4D)obj).zCoord == zCoord && - ((Coord4D)obj).dimensionId == dimensionId; - } - - @Override - public int hashCode() - { - int code = 1; - code = 31 * code + xCoord; - code = 31 * code + yCoord; - code = 31 * code + zCoord; - code = 31 * code + dimensionId; - return code; - } -} \ No newline at end of file diff --git a/src/api/java/mekanism/api/EnumColor.java b/src/api/java/mekanism/api/EnumColor.java deleted file mode 100644 index 5c1351e92..000000000 --- a/src/api/java/mekanism/api/EnumColor.java +++ /dev/null @@ -1,112 +0,0 @@ -package mekanism.api; - -import net.minecraft.util.StatCollector; - -/** - * Simple color enum for adding colors to in-game GUI strings of text. - * @author AidanBrady - * - */ -public enum EnumColor -{ - BLACK("\u00a70", "black", "Black", new int[] {0, 0, 0}, 0), - DARK_BLUE("\u00a71", "darkBlue", "Blue", new int[] {0, 0, 170}, 4), - DARK_GREEN("\u00a72", "darkGreen", "Green", new int[] {0, 170, 0}, 2), - DARK_AQUA("\u00a73", "darkAqua", "Cyan", new int[] {0, 170, 170}, 6), - DARK_RED("\u00a74", "darkRed", null, new int[] {170, 0, 0}, -1), - PURPLE("\u00a75", "purple", "Purple", new int[] {170, 0, 170}, 5), - ORANGE("\u00a76", "orange", "Orange", new int[] {255, 170, 0}, 14), - GREY("\u00a77", "grey", "LightGray", new int[] {170, 170, 170}, 7), - DARK_GREY("\u00a78", "darkGrey", "Gray", new int[] {85, 85, 85}, 8), - INDIGO("\u00a79", "indigo", "LightBlue", new int[] {85, 85, 255}, 12), - BRIGHT_GREEN("\u00a7a", "brightGreen", "Lime", new int[] {85, 255, 85}, 10), - AQUA("\u00a7b", "aqua", null, new int[] {85, 255, 255}, -1), - RED("\u00a7c", "red", "Red", new int[] {255, 0, 0}, 1), - PINK("\u00a7d", "pink", "Magenta", new int[] {255, 85, 255}, 13), - YELLOW("\u00a7e", "yellow", "Yellow", new int[] {255, 255, 85}, 11), - WHITE("\u00a7f", "white", "White", new int[] {255, 255, 255}, 15), - //Extras for dye-completeness - BROWN("\u00a76", "brown", "Brown", new int[] {150, 75, 0}, 3), - BRIGHT_PINK("\u00a7d", "brightPink", "Pink", new int[] {255, 192, 203}, 9); - - public static EnumColor[] DYES = new EnumColor[] {BLACK, RED, DARK_GREEN, BROWN, DARK_BLUE, PURPLE, DARK_AQUA, GREY, DARK_GREY, BRIGHT_PINK, BRIGHT_GREEN, YELLOW, INDIGO, PINK, ORANGE, WHITE}; - - /** The color code that will be displayed */ - public final String code; - - public final int[] rgbCode; - - public final int mcMeta; - - /** A friendly name of the color. */ - public String unlocalizedName; - - public String dyeName; - - private EnumColor(String s, String n, String dye, int[] rgb, int meta) - { - code = s; - unlocalizedName = n; - dyeName = dye; - rgbCode = rgb; - mcMeta = meta; - } - - /** - * Gets the localized name of this color by translating the unlocalized name. - * @return localized name - */ - public String getLocalizedName() - { - return StatCollector.translateToLocal("color." + unlocalizedName); - } - - public String getDyeName() - { - return StatCollector.translateToLocal("dye." + unlocalizedName); - } - - public String getOreDictName() - { - return dyeName; - } - - /** - * Gets the name of this color with it's color prefix code. - * @return the color's name and color prefix - */ - public String getName() - { - return code + getLocalizedName(); - } - - public String getDyedName() - { - return code + getDyeName(); - } - - /** - * Gets the 0-1 of this color's RGB value by dividing by 255 (used for OpenGL coloring). - * @param index - R:0, G:1, B:2 - * @return the color value - */ - public float getColor(int index) - { - return (float)rgbCode[index]/255F; - } - - /** - * Gets the value of this color mapped to MC in-game item colors present in dyes and wool. - * @return mc meta value - */ - public int getMetaValue() - { - return mcMeta; - } - - @Override - public String toString() - { - return code; - } -} diff --git a/src/api/java/mekanism/api/IClientTicker.java b/src/api/java/mekanism/api/IClientTicker.java deleted file mode 100644 index 228897370..000000000 --- a/src/api/java/mekanism/api/IClientTicker.java +++ /dev/null @@ -1,8 +0,0 @@ -package mekanism.api; - -public interface IClientTicker -{ - public void clientTick(); - - public boolean needsTicks(); -} diff --git a/src/api/java/mekanism/api/IConfigurable.java b/src/api/java/mekanism/api/IConfigurable.java deleted file mode 100644 index 512fabf43..000000000 --- a/src/api/java/mekanism/api/IConfigurable.java +++ /dev/null @@ -1,27 +0,0 @@ -package mekanism.api; - -import net.minecraft.entity.player.EntityPlayer; - -/** - * Implement this in your TileEntity class if your block can be modified by a Configurator. - * @author aidancbrady - * - */ -public interface IConfigurable -{ - /** - * Called when a player shift-right clicks this block with a Configurator. - * @param player - the player who clicked the block - * @param side - the side the block was clicked on - * @return whether or not an action was performed - */ - public boolean onSneakRightClick(EntityPlayer player, int side); - - /** - * Called when a player right clicks this block with a Configurator. - * @param player - the player who clicked the block - * @param side - the side the block was clicked on - * @return whether or not an action was performed - */ - public boolean onRightClick(EntityPlayer player, int side); -} diff --git a/src/api/java/mekanism/api/IFilterAccess.java b/src/api/java/mekanism/api/IFilterAccess.java deleted file mode 100644 index abdcf29a8..000000000 --- a/src/api/java/mekanism/api/IFilterAccess.java +++ /dev/null @@ -1,31 +0,0 @@ -package mekanism.api; - -import net.minecraft.nbt.NBTTagCompound; - -/** - * Implement this in your TileEntity class if you wish for Mekanism filters to be able to store any of their - * information. - * @author aidancbrady - * - */ -public interface IFilterAccess -{ - /** - * Collects the TileEntity's filter card data into the parameterized NBTTagCompound. - * @param nbtTags - the NBTTagCompound of the filter card ItemStack - * @return the NBTTagCompound that now contains the TileEntity's filter card data - */ - public NBTTagCompound getFilterData(NBTTagCompound nbtTags); - - /** - * Retrieves the TileEntity's data contained in the filter card based on the given NBTTagCompopund. - * @param nbtTags - the NBTTagCompound of the filter card ItemStack - */ - public void setFilterData(NBTTagCompound nbtTags); - - /** - * A String name of this TileEntity that will be displayed as the type of data on the filter card. - * @return the String name of this TileEntity - */ - public String getDataType(); -} diff --git a/src/api/java/mekanism/api/ISalinationSolar.java b/src/api/java/mekanism/api/ISalinationSolar.java deleted file mode 100644 index 20e3e1ecf..000000000 --- a/src/api/java/mekanism/api/ISalinationSolar.java +++ /dev/null @@ -1,11 +0,0 @@ -package mekanism.api; - -/** - * Implement this class in a TileEntity if you wish for it to be able to heat up a Salination Plant. - * @author aidancbrady - * - */ -public interface ISalinationSolar -{ - public boolean seesSun(); -} diff --git a/src/api/java/mekanism/api/ItemInfo.java b/src/api/java/mekanism/api/ItemInfo.java deleted file mode 100644 index 2c45f0cfe..000000000 --- a/src/api/java/mekanism/api/ItemInfo.java +++ /dev/null @@ -1,38 +0,0 @@ -package mekanism.api; - -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -public class ItemInfo -{ - public Item item; - public int meta; - - public ItemInfo(Item i, int j) - { - item = i; - meta = j; - } - - public static ItemInfo get(ItemStack stack) - { - return new ItemInfo(stack.getItem(), stack.getItemDamage()); - } - - @Override - public boolean equals(Object obj) - { - return obj instanceof BlockInfo && - ((ItemInfo)obj).item == item && - ((ItemInfo)obj).meta == meta; - } - - @Override - public int hashCode() - { - int code = 1; - code = 31 * code + item.getUnlocalizedName().hashCode(); - code = 31 * code + meta; - return code; - } -} diff --git a/src/api/java/mekanism/api/ItemRetriever.java b/src/api/java/mekanism/api/ItemRetriever.java deleted file mode 100644 index a66b8b5b1..000000000 --- a/src/api/java/mekanism/api/ItemRetriever.java +++ /dev/null @@ -1,71 +0,0 @@ -package mekanism.api; - -import net.minecraft.block.Block; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -/** - * Use this class's 'getItem()' method to retrieve ItemStacks from the 'Mekanism' - * class. - * @author AidanBrady - * - */ -public final class ItemRetriever -{ - /** The 'Mekanism' class that items and blocks are retrieved from. */ - private static Class Mekanism; - - /** - * Attempts to retrieve an ItemStack of an item or block with the declared identifier. - * - * Mekanism identifiers follow an easy-to-remember pattern. All identifiers - * are identical to the String returned by 'getItemName().' None include spaces, - * and all start with a capital letter. The name that shows up in-game can be - * stripped down to identifier form by removing spaces and all non-alphabetic - * characters (,./'=-_). Below is an example: - * - * ItemStack enrichedAlloy = ItemRetriever.getItem("EnrichedAlloy"); - * - * The same also works for blocks. - * - * ItemStack refinedObsidian = ItemRetriever.getItem("RefinedObsidian"); - * - * Note that for items or blocks that have specific metadata you will need to create - * a new ItemStack with that specified value, as this will only return an ItemStack - * with the meta value '0.' - * - * Make sure you run this in or after FMLPostInitializationEvent runs, because most - * items are registered when FMLInitializationEvent runs. However, some items ARE - * registered later in order to hook into other mods. In a rare circumstance you may - * have to add "after:Mekanism" in the @Mod 'dependencies' annotation. - * - * @param identifier - a String to be searched in the 'Mekanism' class - * @return an ItemStack of the declared identifier, otherwise null. - */ - public static ItemStack getItem(String identifier) - { - try { - if(Mekanism == null) - { - Mekanism = Class.forName("mekanism.common.Mekanism"); - } - - Object ret = Mekanism.getField(identifier).get(null); - - if(ret instanceof Item) - { - return new ItemStack((Item)ret, 1); - } - else if(ret instanceof Block) - { - return new ItemStack((Block)ret, 1); - } - else { - return null; - } - } catch(Exception e) { - System.err.println("Error retrieving item with identifier '" + identifier + "': " + e.getMessage()); - return null; - } - } -} diff --git a/src/api/java/mekanism/api/ListUtils.java b/src/api/java/mekanism/api/ListUtils.java deleted file mode 100644 index fb319cee8..000000000 --- a/src/api/java/mekanism/api/ListUtils.java +++ /dev/null @@ -1,282 +0,0 @@ -package mekanism.api; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Set; - -public class ListUtils -{ - public static List inverse(List list) - { - List toReturn = new ArrayList(); - - for(int i = list.size() - 1; i >= 0; i--) - { - toReturn.add(list.get(i)); - } - - return toReturn; - } - - public static List cap(List list, int cap) - { - List toReturn = new ArrayList(); - - if(list.size() <= cap) - { - toReturn = copy(list); - } - else { - int count = 0; - - for(V obj : list) - { - count++; - - toReturn.add(obj); - - if(count == cap) - { - break; - } - } - } - - return toReturn; - } - - public static List copy(List list) - { - List toReturn = new ArrayList(); - - for(V obj : list) - { - toReturn.add(obj); - } - - return toReturn; - } - - public static List merge(List listOne, List listTwo) - { - List newList = new ArrayList(); - - for(V obj : listOne) - { - newList.add(obj); - } - - for(V obj : listTwo) - { - newList.add(obj); - } - - return newList; - } - - public static List capRemains(List list, int cap) - { - List toReturn = new ArrayList(); - - if(list.size() <= cap) - { - return toReturn; - } - else { - List inverse = inverse(list); - - int iterNeeded = list.size() - cap; - int count = 0; - - for(V obj : list) - { - count++; - - toReturn.add(obj); - - if(count == iterNeeded) - { - break; - } - } - - return toReturn; - } - } - - public static ArrayList> split(List list, int divide) - { - int remain = list.size() % divide; - int size = (list.size() - remain) / divide; - - ArrayList> toReturn = new ArrayList>(); - - for(int i = 0; i < divide; i++) - { - toReturn.add(i, new ArrayList()); - } - - for(List iterSet : toReturn) - { - List removed = new ArrayList(); - - int toAdd = size; - - if(remain > 0) - { - remain--; - toAdd++; - } - - for(V obj : list) - { - if(toAdd == 0) - { - break; - } - - iterSet.add(obj); - removed.add(obj); - toAdd--; - } - - for(V obj : removed) - { - list.remove(obj); - } - } - - return toReturn; - } - - public static V getTop(List list) - { - for(V obj : list) - { - return obj; - } - - return null; - } - - public static List asList(Set set) - { - return (List)Arrays.asList(set.toArray()); - } - - public static List asList(V... values) - { - return (List)Arrays.asList(values); - } - - public static double[] splitDouble(int size, double num) - { - double[] split = new double[size]; - - for(int i = 0; i < size; i++) - { - double remain = num%size; - double ret = (num-remain)/size; - ret += remain; - - split[i] = ret; - num -= remain; - } - - return split; - } - - public static double[] percent(double[] values) - { - double[] ret = new double[values.length]; - double total = 0; - - for(double d : values) total += d; - - for(int i = 0; i < values.length; i++) - { - ret[i] = values[i]/total; - } - - return ret; - } - - public static int[] calcPercentInt(double[] percent, int val) - { - int[] ret = new int[percent.length]; - - for(int i = 0; i < percent.length; i++) - { - ret[i] = (int)Math.round(val*percent[i]); - } - - int newTotal = 0; - for(int i : ret) newTotal += i; - - int diff = val-newTotal; - - if(diff != val) - { - for(int i = 0; i < ret.length; i++) - { - int num = ret[i]; - - if(diff < 0 && num == 0) - { - continue; - } - - if(diff > 0) - { - ret[i]++; - diff--; - } - else if(diff < 0) - { - ret[i]--; - diff++; - } - - if(diff == 0) - { - return ret; - } - } - } - - return ret; - } - - public static int[] splitInt(int size, int num) - { - int[] split = new int[size]; - - for(int i = 0; i < size; i++) - { - int remain = num%size; - int ret = (num-remain)/size; - ret += remain; - - split[i] = ret; - num -= remain; - } - - return split; - } - - public static double[] percent(int[] values) - { - double[] ret = new double[values.length]; - double total = 0; - - for(double d : values) total += d; - - for(int i = 0; i < values.length; i++) - { - ret[i] = values[i]/total; - } - - return ret; - } -} diff --git a/src/api/java/mekanism/api/MekanismAPI.java b/src/api/java/mekanism/api/MekanismAPI.java deleted file mode 100644 index 4f4cef4a9..000000000 --- a/src/api/java/mekanism/api/MekanismAPI.java +++ /dev/null @@ -1,45 +0,0 @@ -package mekanism.api; - -import java.util.HashSet; -import java.util.Set; - -import net.minecraft.block.Block; -import net.minecraft.item.Item; -import cpw.mods.fml.common.eventhandler.Event; -import net.minecraftforge.oredict.OreDictionary; - -public class MekanismAPI -{ - //Add a BlockInfo value here if you don't want a certain block to be picked up by cardboard boxes - private static Set cardboardBoxIgnore = new HashSet(); - - public static boolean isBlockCompatible(Item item, int meta) - { - for(BlockInfo i : cardboardBoxIgnore) - { - if(i.block == Block.getBlockFromItem(item) && (i.meta == OreDictionary.WILDCARD_VALUE || i.meta == meta)) - { - return false; - } - } - - return true; - } - - public static void addBoxBlacklist(Block block, int meta) - { - cardboardBoxIgnore.add(new BlockInfo(block, meta)); - } - - public static void removeBoxBlacklist(Block block, int meta) - { - cardboardBoxIgnore.remove(new BlockInfo(block, meta)); - } - - public static Set getBoxIgnore() - { - return cardboardBoxIgnore; - } - - public static class BoxBlacklistEvent extends Event {} -} diff --git a/src/api/java/mekanism/api/Pos3D.java b/src/api/java/mekanism/api/Pos3D.java deleted file mode 100644 index aa4ae089f..000000000 --- a/src/api/java/mekanism/api/Pos3D.java +++ /dev/null @@ -1,191 +0,0 @@ -package mekanism.api; - -import net.minecraft.entity.Entity; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.MathHelper; - -/** - * Pos3D - a way of performing operations on objects in a three dimensional environment. - * @author aidancbrady - * - */ -public class Pos3D -{ - public double xPos; - public double yPos; - public double zPos; - - public Pos3D() - { - this(0, 0, 0); - } - - public Pos3D(double x, double y, double z) - { - xPos = x; - yPos = y; - zPos = z; - } - - public Pos3D(Coord4D coord) - { - xPos = coord.xCoord; - yPos = coord.yCoord; - zPos = coord.zCoord; - } - - /** - * Creates a Pos3D with an entity's posX, posY, and posZ values. - * @param entity - entity to create the Pos3D from - */ - public Pos3D(Entity entity) - { - this(entity.posX, entity.posY, entity.posZ); - } - - /** - * Creates a Pos3D with a TileEntity's xCoord, yCoord and zCoord values. - * @param tileEntity - TileEntity to create the Pos3D from - */ - public Pos3D(TileEntity tileEntity) - { - this(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord); - } - - /** - * Creates and returns a Pos3D with values representing the difference between this and the Pos3D in the parameters. - * @param pos - Pos3D to subtract - * @return difference of the two Pos3Ds - */ - public Pos3D diff(Pos3D pos) - { - return new Pos3D(xPos-pos.xPos, yPos-pos.yPos, zPos-pos.zPos); - } - - /** - * Creates a new Pos3D from the motion of an entity. - * @param entity - * @return - */ - public static Pos3D fromMotion(Entity entity) - { - return new Pos3D(entity.motionX, entity.motionY, entity.motionZ); - } - - /** - * Translates this Pos3D by the defined values. - * @param x - amount to translate on the x axis - * @param y - amount to translate on the y axis - * @param z - amount to translate on the z axis - * @return the translated Pos3D - */ - public Pos3D translate(double x, double y, double z) - { - xPos += x; - yPos += y; - zPos += z; - - return this; - } - - /** - * Performs the same operation as translate(x, y, z), but with a Pos3D value instead. - * @param pos - Pos3D value to translate by - * @return translated Pos3D - */ - public Pos3D translate(Pos3D pos) - { - return translate(pos.xPos, pos.yPos, pos.zPos); - } - - /** - * Returns the distance between this and the defined Pos3D. - * @param pos - the Pos3D to find the distance to - * @return the distance between this and the defined Pos3D - */ - public double distance(Pos3D pos) - { - double subX = xPos - pos.xPos; - double subY = yPos - pos.yPos; - double subZ = zPos - pos.zPos; - return MathHelper.sqrt_double(subX * subX + subY * subY + subZ * subZ); - } - - /** - * Rotates this Pos3D by the defined yaw value. - * @param yaw - yaw to rotate by - * @return rotated Pos3D - */ - public Pos3D rotateYaw(double yaw) - { - double yawRadians = Math.toRadians(yaw); - - double x = xPos; - double z = zPos; - - if(yaw != 0) - { - xPos = x * Math.cos(yawRadians) - z * Math.sin(yawRadians); - zPos = x * Math.sin(yawRadians) + z * Math.cos(yawRadians); - } - - return this; - } - - /** - * Scales this Pos3D by the defined x, y, an z values. - * @param x - x value to scale by - * @param y - y value to scale by - * @param z - z value to scale by - * @return scaled Pos3D - */ - public Pos3D scale(double x, double y, double z) - { - xPos *= x; - yPos *= y; - zPos *= z; - - return this; - } - - /** - * Performs the same operation as scale(x, y, z), but with a value representing all three dimensions. - * @param scale - value to scale by - * @return scaled Pos3D - */ - public Pos3D scale(double scale) - { - return scale(scale, scale, scale); - } - - @Override - public Pos3D clone() - { - return new Pos3D(xPos, yPos, zPos); - } - - @Override - public String toString() - { - return "[Pos3D: " + xPos + ", " + yPos + ", " + zPos + "]"; - } - - @Override - public boolean equals(Object obj) - { - return obj instanceof Pos3D && - ((Pos3D)obj).xPos == xPos && - ((Pos3D)obj).yPos == yPos && - ((Pos3D)obj).zPos == zPos; - } - - @Override - public int hashCode() - { - int code = 1; - code = 31 * code + new Double(xPos).hashCode(); - code = 31 * code + new Double(yPos).hashCode(); - code = 31 * code + new Double(zPos).hashCode(); - return code; - } -} diff --git a/src/api/java/mekanism/api/PressurizedProducts.java b/src/api/java/mekanism/api/PressurizedProducts.java deleted file mode 100644 index 830fc55a6..000000000 --- a/src/api/java/mekanism/api/PressurizedProducts.java +++ /dev/null @@ -1,50 +0,0 @@ -package mekanism.api; - -import mekanism.api.gas.GasStack; -import mekanism.api.gas.GasTank; - -import net.minecraft.item.ItemStack; - -public class PressurizedProducts -{ - private ItemStack itemOutput; - private GasStack gasOutput; - - public PressurizedProducts(ItemStack item, GasStack gas) - { - itemOutput = item; - gasOutput = gas; - } - - public void fillTank(GasTank tank) - { - tank.receive(gasOutput, true); - } - - public void addProducts(ItemStack[] inventory, int index) - { - if(inventory[index] == null) - { - inventory[index] = itemOutput.copy(); - } - else if(inventory[index].isItemEqual(itemOutput)) - { - inventory[index].stackSize += itemOutput.stackSize; - } - } - - public ItemStack getItemOutput() - { - return itemOutput; - } - - public GasStack getGasOutput() - { - return gasOutput; - } - - public PressurizedProducts copy() - { - return new PressurizedProducts(itemOutput.copy(), gasOutput.copy()); - } -} diff --git a/src/api/java/mekanism/api/PressurizedReactants.java b/src/api/java/mekanism/api/PressurizedReactants.java deleted file mode 100644 index 07e588235..000000000 --- a/src/api/java/mekanism/api/PressurizedReactants.java +++ /dev/null @@ -1,139 +0,0 @@ -package mekanism.api; - -import mekanism.api.gas.GasStack; -import mekanism.api.gas.GasTank; -import mekanism.common.util.StackUtils; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; -import net.minecraftforge.fluids.FluidTank; - -/** - * An input of a gas, a fluid and an item for the pressurized reaction chamber - */ -public class PressurizedReactants -{ - private ItemStack theSolid; - private FluidStack theFluid; - private GasStack theGas; - - public PressurizedReactants(ItemStack solid, FluidStack fluid, GasStack gas) - { - theSolid = solid; - theFluid = fluid; - theGas = gas; - } - - /** - * If this is a valid PressurizedReactants - */ - public boolean isValid() - { - return theSolid != null && theFluid != null && theGas != null; - } - - /** - * Draws the needed amount of gas from each tank. - * @param item - ItemStack to draw from - * @param fluidTank - fluid tank to draw from - * @param gasTank - gas tank to draw from - */ - public void use(ItemStack item, FluidTank fluidTank, GasTank gasTank) - { - if(meets(new PressurizedReactants(item, fluidTank.getFluid(), gasTank.getGas()))) - { - item.stackSize -= theSolid.stackSize; - fluidTank.drain(theFluid.amount, true); - gasTank.draw(theGas.amount, true); - } - } - - /** - * Whether or not this PressurizedReactants's ItemStack entry's item type is equal to the item type of the given item. - * @param stack - stack to check - * @return if the stack's item type is contained in this PressurizedReactants - */ - public boolean containsType(ItemStack stack) - { - if(stack == null || stack.stackSize == 0) - { - return false; - } - - return StackUtils.equalsWildcard(stack, theSolid); - } - - /** - * Whether or not this PressurizedReactants's FluidStack entry's fluid type is equal to the fluid type of the given fluid. - * @param stack - stack to check - * @return if the stack's fluid type is contained in this PressurizedReactants - */ - public boolean containsType(FluidStack stack) - { - if(stack == null || stack.amount == 0) - { - return false; - } - - return stack.isFluidEqual(theFluid); - } - - /** - * Whether or not this PressurizedReactants's GasStack entry's gas type is equal to the gas type of the given gas. - * @param stack - stack to check - * @return if the stack's gas type is contained in this PressurizedReactants - */ - public boolean containsType(GasStack stack) - { - if(stack == null || stack.amount == 0) - { - return false; - } - - return stack.isGasEqual(theGas); - } - - public boolean meetsInput(ItemStack itemStack, FluidStack fluidStack, GasStack gasStack) - { - return meets(new PressurizedReactants(itemStack, fluidStack, gasStack)); - } - - /** - * Actual implementation of meetsInput(), performs the checks. - * @param input - input to check - * @return if the input meets this input's requirements - */ - private boolean meets(PressurizedReactants input) - { - if(input == null || !input.isValid()) - { - return false; - } - - if(!(StackUtils.equalsWildcard(input.theSolid, theSolid) && input.theFluid.isFluidEqual(theFluid) && input.theGas.isGasEqual(theGas))) - { - return false; - } - - return input.theSolid.stackSize >= theSolid.stackSize && input.theFluid.amount >= theFluid.amount && input.theGas.amount >= theGas.amount; - } - - public PressurizedReactants copy() - { - return new PressurizedReactants(theSolid.copy(), theFluid.copy(), theGas.copy()); - } - - public ItemStack getSolid() - { - return theSolid; - } - - public FluidStack getFluid() - { - return theFluid; - } - - public GasStack getGas() - { - return theGas; - } -} diff --git a/src/api/java/mekanism/api/PressurizedRecipe.java b/src/api/java/mekanism/api/PressurizedRecipe.java deleted file mode 100644 index d0572bda8..000000000 --- a/src/api/java/mekanism/api/PressurizedRecipe.java +++ /dev/null @@ -1,25 +0,0 @@ -package mekanism.api; - -public class PressurizedRecipe -{ - public PressurizedReactants reactants; - - public double extraEnergy; - - public PressurizedProducts products; - - public int ticks; - - public PressurizedRecipe(PressurizedReactants pressurizedReactants, double energy, PressurizedProducts pressurizedProducts, int duration) - { - reactants = pressurizedReactants; - extraEnergy = energy; - products = pressurizedProducts; - ticks = duration; - } - - public PressurizedRecipe copy() - { - return new PressurizedRecipe(reactants.copy(), extraEnergy, products.copy(), ticks); - } -} diff --git a/src/api/java/mekanism/api/RecipeHelper.java b/src/api/java/mekanism/api/RecipeHelper.java deleted file mode 100644 index 6e27c0cd5..000000000 --- a/src/api/java/mekanism/api/RecipeHelper.java +++ /dev/null @@ -1,258 +0,0 @@ -package mekanism.api; - -import java.lang.reflect.Method; - -import mekanism.api.gas.GasStack; -import mekanism.api.infuse.InfusionInput; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; - -/** - * Use this handy class to add recipes to Mekanism machinery. - * @author AidanBrady - * - */ -public final class RecipeHelper -{ - /** - * Add an Enrichment Chamber recipe. - * @param input - input ItemStack - * @param output - output ItemStack - */ - public static void addEnrichmentChamberRecipe(ItemStack input, ItemStack output) - { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addEnrichmentChamberRecipe", ItemStack.class, ItemStack.class); - m.invoke(null, input, output); - } catch(Exception e) { - System.err.println("Error while adding recipe: " + e.getMessage()); - } - } - - /** - * Add an Osmium Compressor recipe. - * @param input - input ItemStack - * @param output - output ItemStack - */ - public static void addOsmiumCompressorRecipe(ItemStack input, ItemStack output) - { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addOsmiumCompressorRecipe", ItemStack.class, ItemStack.class); - m.invoke(null, input, output); - } catch(Exception e) { - System.err.println("Error while adding recipe: " + e.getMessage()); - } - } - - /** - * Add a Combiner recipe. - * @param input - input ItemStack - * @param output - output ItemStack - */ - public static void addCombinerRecipe(ItemStack input, ItemStack output) - { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addCombinerRecipe", ItemStack.class, ItemStack.class); - m.invoke(null, input, output); - } catch(Exception e) { - System.err.println("Error while adding recipe: " + e.getMessage()); - } - } - - /** - * Add a Crusher recipe. - * @param input - input ItemStack - * @param output - output ItemStack - */ - public static void addCrusherRecipe(ItemStack input, ItemStack output) - { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addCrusherRecipe", ItemStack.class, ItemStack.class); - m.invoke(null, input, output); - } catch(Exception e) { - System.err.println("Error while adding recipe: " + e.getMessage()); - } - } - - /** - * Add a Purification Chamber recipe. - * @param input - input ItemStack - * @param output - output ItemStack - */ - public static void addPurificationChamberRecipe(ItemStack input, ItemStack output) - { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addPurificationChamberRecipe", ItemStack.class, ItemStack.class); - m.invoke(null, input, output); - } catch(Exception e) { - System.err.println("Error while adding recipe: " + e.getMessage()); - } - } - - /** - * Add a Chemical Oxidizer recipe. - * @param input - input ItemStack - * @param output - output GasStack - */ - public static void addChemicalOxidizerRecipe(ItemStack input, GasStack output) - { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addChemicalOxidizerRecipe", ItemStack.class, GasStack.class); - m.invoke(null, input, output); - } catch(Exception e) { - System.err.println("Error while adding recipe: " + e.getMessage()); - } - } - - /** - * Add a Chemical Infuser recipe. - * @param input - input ChemicalInput - * @param output - output GasStack - */ - public static void addChemicalInfuserRecipe(ChemicalPair input, GasStack output) - { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addChemicalInfuserRecipe", ChemicalPair.class, GasStack.class); - m.invoke(null, input, output); - } catch(Exception e) { - System.err.println("Error while adding recipe: " + e.getMessage()); - } - } - - /** - * Add a Precision Sawmill recipe. - * @param input - input ItemStack - * @param output - output ChanceOutput - */ - public static void addPrecisionSawmillRecipe(ItemStack input, ChanceOutput output) - { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addPrecisionSawmillRecipe", ItemStack.class, ChanceOutput.class); - m.invoke(null, input, output); - } catch(Exception e) { - System.err.println("Error while adding recipe: " + e.getMessage()); - } - } - - /** - * Add a Chemical Injection Chamber recipe. - * @param input - input AdvancedInput - * @param output - output ItemStack - */ - public static void addChemicalInjectionChamberRecipe(AdvancedInput input, ItemStack output) - { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addChemicalInjectionChamberRecipe", AdvancedInput.class, ItemStack.class); - m.invoke(null, input, output); - } catch(Exception e) { - System.err.println("Error while adding recipe: " + e.getMessage()); - } - } - - /** - * Add an Electrolytic Separator recipe. - * @param input - input FluidStack - * @param output - output ChemicalPair - */ - public static void addElectrolyticSeparatorRecipe(FluidStack input, ChemicalPair output) - { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addElectrolyticSeparatorRecipe", FluidStack.class, ChemicalPair.class); - m.invoke(null, input, output); - } catch(Exception e) { - System.err.println("Error while adding recipe: " + e.getMessage()); - } - } - - /** - * Add a Chemical Dissolution Chamber recipe. - * @param input - input ItemStack - * @param output - output GasStack - */ - public static void addChemicalDissolutionChamberRecipe(ItemStack input, GasStack output) - { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addChemicalDissolutionChamberRecipe", ItemStack.class, GasStack.class); - m.invoke(null, input, output); - } catch(Exception e) { - System.err.println("Error while adding recipe: " + e.getMessage()); - } - } - - /** - * Add a Chemical Washer recipe. - * @param input - input GasStack - * @param output - output GasStack - */ - public static void addChemicalWasherRecipe(GasStack input, GasStack output) - { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addChemicalWasherRecipe", GasStack.class, GasStack.class); - m.invoke(null, input, output); - } catch(Exception e) { - System.err.println("Error while adding recipe: " + e.getMessage()); - } - } - - /** - * Add a Chemical Crystallizer recipe. - * @param input - input GasStack - * @param output - output ItemStack - */ - public static void addChemicalCrystallizerRecipe(GasStack input, ItemStack output) - { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addChemicalCrystallizerRecipe", GasStack.class, ItemStack.class); - m.invoke(null, input, output); - } catch(Exception e) { - System.err.println("Error while adding recipe: " + e.getMessage()); - } - } - - /** - * Add a Metallurgic Infuser recipe. - * @param input - input Infusion - * @param output - output ItemStack - */ - public static void addMetallurgicInfuserRecipe(InfusionInput input, ItemStack output) - { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addMetallurgicInfuserRecipe", InfusionInput.class, ItemStack.class); - m.invoke(null, input, output); - } catch(Exception e) { - System.err.println("Error while adding recipe: " + e.getMessage()); - } - } - - /** - * Add a Pressurized Reaction Chamber recipe. - * @param input - input PressurizedReactants - * @param output - output PressurizedProducts - * @param extraEnergy - extra energy needed by the recipe - * @param ticks - amount of ticks it takes for this recipe to complete - */ - public static void addPRCRecipe(PressurizedReactants input, PressurizedProducts output, double extraEnergy, int ticks) - { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addPRCRecipe", PressurizedReactants.class, PressurizedProducts.class, Double.TYPE, Integer.TYPE); - m.invoke(null, input, output); - } catch(Exception e) { - System.err.println("Error while adding recipe: " + e.getMessage()); - } - } -} diff --git a/src/api/java/mekanism/api/TabProxy.java b/src/api/java/mekanism/api/TabProxy.java deleted file mode 100644 index c562c0247..000000000 --- a/src/api/java/mekanism/api/TabProxy.java +++ /dev/null @@ -1,42 +0,0 @@ -package mekanism.api; - -import net.minecraft.creativetab.CreativeTabs; - -/** - * Class used to indirectly reference the Mekanism creative tab. - * @author AidanBrady - * - */ -public final class TabProxy -{ - /** The 'Mekanism' class where the tab instance is stored. */ - public static Class Mekanism; - - /** - * Attempts to get the Mekanism creative tab instance from the 'Mekanism' class. Will return - * the tab if the mod is loaded, but otherwise will return the defined 'preferred' creative tab. This way - * you don't need to worry about NPEs! - * @return Mekanism creative tab if can, otherwise preferred tab - */ - public static CreativeTabs tabMekanism(CreativeTabs preferred) - { - try { - if(Mekanism == null) - { - Mekanism = Class.forName("mekanism.common.Mekanism"); - } - - Object ret = Mekanism.getField("tabMekanism").get(null); - - if(ret instanceof CreativeTabs) - { - return (CreativeTabs)ret; - } - - return preferred; - } catch(Exception e) { - System.err.println("Error retrieving Mekanism creative tab."); - return preferred; - } - } -} diff --git a/src/api/java/mekanism/api/energy/EnergizedItemManager.java b/src/api/java/mekanism/api/energy/EnergizedItemManager.java deleted file mode 100644 index 165bdf608..000000000 --- a/src/api/java/mekanism/api/energy/EnergizedItemManager.java +++ /dev/null @@ -1,60 +0,0 @@ -package mekanism.api.energy; - -import net.minecraft.item.ItemStack; - -public class EnergizedItemManager -{ - /** - * Discharges an IEnergizedItem with the defined amount of energy. - * @param itemStack - ItemStack to discharge - * @param amount - amount of energy to discharge from the item, usually the total amount of energy needed in a TileEntity - * @return amount of energy discharged - */ - public static double discharge(ItemStack itemStack, double amount) - { - if(itemStack != null) - { - if(itemStack.getItem() instanceof IEnergizedItem) - { - IEnergizedItem energizedItem = (IEnergizedItem)itemStack.getItem(); - - if(energizedItem.canSend(itemStack)) - { - double energyToUse = Math.min(energizedItem.getMaxTransfer(itemStack), Math.min(energizedItem.getEnergy(itemStack), amount)); - energizedItem.setEnergy(itemStack, energizedItem.getEnergy(itemStack) - energyToUse); - - return energyToUse; - } - } - } - - return 0; - } - - /** - * Charges an IEnergizedItem with the defined amount of energy. - * @param itemStack - ItemStack to charge - * @param amount - amount of energy to charge the item with, usually the total amount of energy stored in a TileEntity - * @return amount of energy charged - */ - public static double charge(ItemStack itemStack, double amount) - { - if(itemStack != null) - { - if(itemStack.getItem() instanceof IEnergizedItem) - { - IEnergizedItem energizedItem = (IEnergizedItem)itemStack.getItem(); - - if(energizedItem.canReceive(itemStack)) - { - double energyToSend = Math.min(energizedItem.getMaxTransfer(itemStack), Math.min(energizedItem.getMaxEnergy(itemStack) - energizedItem.getEnergy(itemStack), amount)); - energizedItem.setEnergy(itemStack, energizedItem.getEnergy(itemStack) + energyToSend); - - return energyToSend; - } - } - } - - return 0; - } -} diff --git a/src/api/java/mekanism/api/energy/ICableOutputter.java b/src/api/java/mekanism/api/energy/ICableOutputter.java deleted file mode 100644 index 015379c03..000000000 --- a/src/api/java/mekanism/api/energy/ICableOutputter.java +++ /dev/null @@ -1,18 +0,0 @@ -package mekanism.api.energy; - -import net.minecraftforge.common.util.ForgeDirection; - -/** - * Implement this if your TileEntity is capable of outputting energy to cables, overriding Mekanism's default implementation. - * @author AidanBrady - * - */ -public interface ICableOutputter -{ - /** - * Whether or not this block can output to a cable on a specific side. - * @param side - side to check - * @return if the block can output - */ - public boolean canOutputTo(ForgeDirection side); -} diff --git a/src/api/java/mekanism/api/energy/IEnergizedItem.java b/src/api/java/mekanism/api/energy/IEnergizedItem.java deleted file mode 100644 index b67254597..000000000 --- a/src/api/java/mekanism/api/energy/IEnergizedItem.java +++ /dev/null @@ -1,59 +0,0 @@ -package mekanism.api.energy; - -import net.minecraft.item.ItemStack; - -/** - * Implement this in an item's class if it should be able to store electricity. - * @author aidancbrady - * - */ -public interface IEnergizedItem -{ - /** - * Gets and returns the amount of energy stored in this item. - * @param itemStack - the ItemStack to check - * @return energy stored - */ - public double getEnergy(ItemStack itemStack); - - /** - * Sets this item's stored energy value to a new amount. - * @param itemStack - the ItemStack who's energy value is to be change - * @param amount - new amount of energy - */ - public void setEnergy(ItemStack itemStack, double amount); - - /** - * Gets and returns this item's maximum amount of energy that can be stored. - * @param itemStack - the ItemStack to check - * @return maximum energy - */ - public double getMaxEnergy(ItemStack itemStack); - - /** - * Gets and returns how much energy this item can transfer to and from charging slots. - * @param itemStack - the ItemStack to check - * @return transfer amount - */ - public double getMaxTransfer(ItemStack itemStack); - - /** - * Gets and returns whether or not this item can receive energy from a charging slot. - * @param itemStack - the ItemStack to check - * @return if the item can receive energy - */ - public boolean canReceive(ItemStack itemStack); - - /** - * Gets and returns whether or not this item can send energy to a charging slot. - * @param itemStack - the ItemStack to check - * @return if the item can send energy - */ - public boolean canSend(ItemStack itemStack); - - /** - * Returns whether or not this item contains metadata-specific subtypes instead of using metadata for damage display. - * @return if the item contains metadata-specific subtypes - */ - public boolean isMetadataSpecific(ItemStack itemStack); -} diff --git a/src/api/java/mekanism/api/energy/IStrictEnergyAcceptor.java b/src/api/java/mekanism/api/energy/IStrictEnergyAcceptor.java deleted file mode 100644 index 53edc68e6..000000000 --- a/src/api/java/mekanism/api/energy/IStrictEnergyAcceptor.java +++ /dev/null @@ -1,25 +0,0 @@ -package mekanism.api.energy; - -import net.minecraftforge.common.util.ForgeDirection; - -/** - * Implement this if your TileEntity can accept energy at a floating-point double value from Universal Cables. - * @author AidanBrady - * - */ -public interface IStrictEnergyAcceptor extends IStrictEnergyStorage -{ - /** - * Transfer a certain amount of energy to this acceptor. - * @param amount - amount to transfer - * @return energy used - */ - public double transferEnergyToAcceptor(ForgeDirection side, double amount); - - /** - * Whether or not this tile entity accepts energy from a certain side. - * @param side - side to check - * @return if tile entity accepts energy - */ - public boolean canReceiveEnergy(ForgeDirection side); -} diff --git a/src/api/java/mekanism/api/energy/IStrictEnergyStorage.java b/src/api/java/mekanism/api/energy/IStrictEnergyStorage.java deleted file mode 100644 index fd560fa18..000000000 --- a/src/api/java/mekanism/api/energy/IStrictEnergyStorage.java +++ /dev/null @@ -1,27 +0,0 @@ -package mekanism.api.energy; - -/** - * Mekanism-specific energy storage for TileEntities, already implemented in IStrictEnergyAcceptor. - * @author aidancbrady - * - */ -public interface IStrictEnergyStorage -{ - /** - * Gets the amount of energy this TileEntity is currently storing. - * @return stored energy - */ - public double getEnergy(); - - /** - * Sets the amount of stored energy of this TileEntity to a new amount. - * @param energy - new energy value - */ - public void setEnergy(double energy); - - /** - * Gets the maximum amount of energy this TileEntity can store. - * @return maximum energy - */ - public double getMaxEnergy(); -} diff --git a/src/api/java/mekanism/api/gas/FuelHandler.java b/src/api/java/mekanism/api/gas/FuelHandler.java deleted file mode 100644 index 7f61f7651..000000000 --- a/src/api/java/mekanism/api/gas/FuelHandler.java +++ /dev/null @@ -1,59 +0,0 @@ -package mekanism.api.gas; - -import java.util.HashMap; - -import net.minecraftforge.fluids.FluidContainerRegistry; -import buildcraft.api.fuels.IronEngineFuel; -import buildcraft.api.fuels.IronEngineFuel.Fuel; -import cpw.mods.fml.common.ModAPIManager; - -public class FuelHandler -{ - - public static HashMap fuels = new HashMap(); - - public static void addGas(Gas gas, int burnTicks, double energyPerMilliBucket) - { - fuels.put( gas.getName(), new FuelGas( burnTicks, energyPerMilliBucket ) ); - } - - public static FuelGas getFuel(Gas gas) - { - if ( fuels.containsKey( gas.getName() ) ) - { - return fuels.get( gas.getName() ); - } - - if ( ModAPIManager.INSTANCE.hasAPI( "BuildCraftAPI|fuel" ) && gas.hasFluid() ) - { - Fuel bcFuel = IronEngineFuel.getFuelForFluid( gas.getFluid() ); - - if ( bcFuel != null ) - { - FuelGas fuel = new FuelGas( bcFuel ); - fuels.put( gas.getName(), fuel ); - - return fuel; - } - } - - return null; - } - - public static class FuelGas - { - - public int burnTicks; - public double energyPerTick; - - public FuelGas(int duration, double energyDensity) { - burnTicks = duration; - energyPerTick = energyDensity / duration; - } - - public FuelGas(Fuel bcFuel) { - burnTicks = bcFuel.totalBurningTime / FluidContainerRegistry.BUCKET_VOLUME; - energyPerTick = bcFuel.powerPerCycle * 1; - } - } -} diff --git a/src/api/java/mekanism/api/gas/Gas.java b/src/api/java/mekanism/api/gas/Gas.java deleted file mode 100644 index f05be52c6..000000000 --- a/src/api/java/mekanism/api/gas/Gas.java +++ /dev/null @@ -1,221 +0,0 @@ -package mekanism.api.gas; - -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.IIcon; -import net.minecraft.util.StatCollector; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidRegistry; - -/** - * Gas - a class used to set specific properties of gasses when used or seen in-game. - * @author aidancbrady - * - */ -public class Gas -{ - private String name; - - private String unlocalizedName; - - private Fluid fluid; - - private IIcon icon; - - private boolean visible = true; - - private boolean from_fluid = false; - - /** - * Creates a new Gas object with a defined name or key value. - * @param s - name or key to associate this Gas with - */ - public Gas(String s) - { - unlocalizedName = name = s; - } - - /** - * Creates a new Gas object that corresponds to the given Fluid - */ - public Gas(Fluid f) - { - unlocalizedName = name = f.getName(); - icon = f.getStillIcon(); - fluid = f; - from_fluid = true; - } - - /** - * Gets the name (key) of this Gas. This is NOT a translated or localized display name. - * @return this Gas's name or key - */ - public String getName() - { - return name; - } - - /** - * Whether or not this is a visible gas. - * @return if this gas is visible - */ - public boolean isVisible() - { - return visible; - } - - /** - * Sets this gas's "visible" state to a new value. Setting it to 'false' will treat this gas as an internal gas, and it will not be displayed or accessed by other mods. - * @param v - new visible state - * @return this Gas object - */ - public Gas setVisible(boolean v) - { - visible = v; - - return this; - } - - /** - * Gets the unlocalized name of this Gas. - * @return this Gas's unlocalized name - */ - public String getUnlocalizedName() - { - return "gas." + unlocalizedName; - } - - /** - * Translates this Gas's unlocalized name and returns it as localized. - * @return this Gas's localized name - */ - public String getLocalizedName() - { - return StatCollector.translateToLocal(getUnlocalizedName()); - } - - /** - * Sets the unlocalized name of this Gas. - * @param s - unlocalized name to set - * @return this Gas object - */ - public Gas setUnlocalizedName(String s) - { - unlocalizedName = s; - - return this; - } - - /** - * Gets the IIcon associated with this Gas. - * @return associated IIcon - */ - public IIcon getIcon() - { - if(from_fluid) - { - return this.getFluid().getIcon(); - } - - return icon; - } - - /** - * Sets this gas's icon. - * @param i - IIcon to associate with this Gas - * @return this Gas object - */ - public Gas setIcon(IIcon i) - { - icon = i; - - if(hasFluid()) - { - fluid.setIcons(getIcon()); - } - - from_fluid = false; - - return this; - } - - /** - * Gets the ID associated with this gas. - * @return the associated gas ID - */ - public int getID() - { - return GasRegistry.getGasID(this); - } - - /** - * Writes this Gas to a defined tag compound. - * @param nbtTags - tag compound to write this Gas to - * @return the tag compound this gas was written to - */ - public NBTTagCompound write(NBTTagCompound nbtTags) - { - nbtTags.setString("gasName", getName()); - - return nbtTags; - } - - /** - * Returns the Gas stored in the defined tag compound. - * @param nbtTags - tag compound to get the Gas from - * @return Gas stored in the tag compound - */ - public static Gas readFromNBT(NBTTagCompound nbtTags) - { - if(nbtTags == null || nbtTags.hasNoTags()) - { - return null; - } - - return GasRegistry.getGas(nbtTags.getString("gasName")); - } - - /** - * Whether or not this Gas has an associated fluid. - * @return if this gas has a fluid - */ - public boolean hasFluid() - { - return fluid != null; - } - - /** - * Gets the fluid associated with this Gas. - * @return fluid associated with this gas - */ - public Fluid getFluid() - { - return fluid; - } - - /** - * Registers a new fluid out of this Gas or gets one from the FluidRegistry. - * @return this Gas object - */ - public Gas registerFluid() - { - if(fluid == null) - { - if(FluidRegistry.getFluid(getName()) == null) - { - fluid = new Fluid(getName()).setGaseous(true); - FluidRegistry.registerFluid(fluid); - } - else { - fluid = FluidRegistry.getFluid(getName()); - } - } - - return this; - } - - @Override - public String toString() - { - return name; - } -} diff --git a/src/api/java/mekanism/api/gas/GasNetwork.java b/src/api/java/mekanism/api/gas/GasNetwork.java deleted file mode 100644 index 0248c614b..000000000 --- a/src/api/java/mekanism/api/gas/GasNetwork.java +++ /dev/null @@ -1,477 +0,0 @@ -package mekanism.api.gas; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import mekanism.api.Coord4D; -import mekanism.api.ListUtils; -import mekanism.api.transmitters.DynamicNetwork; -import mekanism.api.transmitters.IGridTransmitter; -import mekanism.api.transmitters.ITransmitterNetwork; -import mekanism.api.transmitters.TransmissionType; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.util.ForgeDirection; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.eventhandler.Event; - -/** - * A DynamicNetwork extension created specifically for the transfer of Gasses. By default this is server-only, but if ticked on - * the client side and if it's posted events are handled properly, it has the capability to visually display gasses network-wide. - * @author aidancbrady - * - */ -public class GasNetwork extends DynamicNetwork -{ - public int transferDelay = 0; - - public boolean didTransfer; - public boolean prevTransfer; - - public float gasScale; - - public Gas refGas; - - public GasStack gasStored; - public int prevStored; - - public int prevTransferAmount = 0; - - public GasNetwork(IGridTransmitter... varPipes) - { - transmitters.addAll(Arrays.asList(varPipes)); - updateCapacity(); - register(); - } - - public GasNetwork(Collection> collection) - { - transmitters.addAll(collection); - updateCapacity(); - register(); - } - - public GasNetwork(Set networks) - { - for(GasNetwork net : networks) - { - if(net != null) - { - if(FMLCommonHandler.instance().getEffectiveSide().isClient()) - { - if(net.refGas != null && net.gasScale > gasScale) - { - gasScale = net.gasScale; - refGas = net.refGas; - gasStored = net.gasStored; - - net.gasScale = 0; - net.refGas = null; - net.gasStored = null; - } - } - else { - if(net.gasStored != null) - { - if(gasStored == null) - { - gasStored = net.gasStored; - } - else { - gasStored.amount += net.gasStored.amount; - } - - net.gasStored = null; - } - } - - addAllTransmitters(net.transmitters); - net.deregister(); - } - } - - gasScale = getScale(); - - updateCapacity(); - fullRefresh(); - register(); - } - - @Override - public void onNetworksCreated(List networks) - { - if(gasStored != null && FMLCommonHandler.instance().getEffectiveSide().isServer()) - { - int[] caps = new int[networks.size()]; - int cap = 0; - - for(GasNetwork network : networks) - { - caps[networks.indexOf(network)] = network.getCapacity(); - cap += network.getCapacity(); - } - - gasStored.amount = Math.min(cap, gasStored.amount); - - int[] values = ListUtils.calcPercentInt(ListUtils.percent(caps), gasStored.amount); - - for(GasNetwork network : networks) - { - int index = networks.indexOf(network); - - if(values[index] > 0) - { - network.gasStored = new GasStack(gasStored.getGas(), values[index]); - network.refGas = gasStored.getGas(); - } - } - } - - gasScale = 0; - refGas = null; - gasStored = null; - } - - public synchronized int getGasNeeded() - { - return getCapacity()-(gasStored != null ? gasStored.amount : 0); - } - - public synchronized int tickEmit(GasStack stack) - { - List availableAcceptors = Arrays.asList(getAcceptors(stack.getGas()).toArray()); - - Collections.shuffle(availableAcceptors); - - int toSend = stack.amount; - int prevSending = toSend; - - if(!availableAcceptors.isEmpty()) - { - int divider = availableAcceptors.size(); - int remaining = toSend % divider; - int sending = (toSend-remaining)/divider; - - for(Object obj : availableAcceptors) - { - if(obj instanceof IGasHandler) - { - IGasHandler acceptor = (IGasHandler)obj; - - int currentSending = sending; - - if(remaining > 0) - { - currentSending++; - remaining--; - } - - toSend -= acceptor.receiveGas(acceptorDirections.get(acceptor).getOpposite(), new GasStack(stack.getGas(), currentSending)); - } - } - } - - int sent = prevSending-toSend; - - if(sent > 0 && FMLCommonHandler.instance().getEffectiveSide().isServer()) - { - didTransfer = true; - transferDelay = 2; - } - - return sent; - } - - public synchronized int emit(GasStack stack) - { - if(gasStored != null && gasStored.getGas() != stack.getGas()) - { - return 0; - } - - int toUse = Math.min(getGasNeeded(), stack.amount); - - if(gasStored == null) - { - gasStored = stack.copy(); - gasStored.amount = toUse; - } - else { - gasStored.amount += toUse; - } - - return toUse; - } - - @Override - public void onUpdate() - { - super.onUpdate(); - - if(FMLCommonHandler.instance().getEffectiveSide().isServer()) - { - prevTransferAmount = 0; - - if(transferDelay == 0) - { - didTransfer = false; - } - else { - transferDelay--; - } - - int stored = gasStored != null ? gasStored.amount : 0; - - if(stored != prevStored) - { - needsUpdate = true; - } - - prevStored = stored; - - if(didTransfer != prevTransfer || needsUpdate) - { - MinecraftForge.EVENT_BUS.post(new GasTransferEvent(this, gasStored, didTransfer)); - needsUpdate = false; - } - - prevTransfer = didTransfer; - - if(gasStored != null) - { - prevTransferAmount = tickEmit(gasStored); - gasStored.amount -= prevTransferAmount; - - if(gasStored.amount <= 0) - { - gasStored = null; - } - } - } - } - - @Override - public void clientTick() - { - super.clientTick(); - - gasScale = Math.max(gasScale, getScale()); - - if(didTransfer && gasScale < 1) - { - gasScale = Math.max(getScale(), Math.min(1, gasScale+0.02F)); - } - else if(!didTransfer && gasScale > 0) - { - gasScale = Math.max(getScale(), Math.max(0, gasScale-0.02F)); - - if(gasScale == 0) - { - gasStored = null; - } - } - } - - @Override - public synchronized Set getAcceptors(Object... data) - { - Gas type = (Gas)data[0]; - Set toReturn = new HashSet(); - - for(IGasHandler acceptor : possibleAcceptors.values()) - { - if(acceptorDirections.get(acceptor) == null) - { - continue; - } - - if(acceptor.canReceiveGas(acceptorDirections.get(acceptor).getOpposite(), type)) - { - toReturn.add(acceptor); - } - } - - return toReturn; - } - - @Override - public synchronized void refresh() - { - Set> iterTubes = (Set>)transmitters.clone(); - Iterator> it = iterTubes.iterator(); - boolean networkChanged = false; - - while(it.hasNext()) - { - IGridTransmitter conductor = (IGridTransmitter)it.next(); - - if(conductor == null || conductor.getTile().isInvalid()) - { - it.remove(); - networkChanged = true; - transmitters.remove(conductor); - } - else { - conductor.setTransmitterNetwork(this); - } - } - - if(networkChanged) - { - updateCapacity(); - } - } - - @Override - public synchronized void refresh(IGridTransmitter transmitter) - { - IGasHandler[] acceptors = GasTransmission.getConnectedAcceptors(transmitter.getTile()); - - clearAround(transmitter); - - for(IGasHandler acceptor : acceptors) - { - ForgeDirection side = ForgeDirection.getOrientation(Arrays.asList(acceptors).indexOf(acceptor)); - - if(side != null && acceptor != null && !(acceptor instanceof IGridTransmitter) && transmitter.canConnectToAcceptor(side, true)) - { - possibleAcceptors.put(Coord4D.get((TileEntity)acceptor), acceptor); - acceptorDirections.put(acceptor, ForgeDirection.getOrientation(Arrays.asList(acceptors).indexOf(acceptor))); - } - } - } - - public static class GasTransferEvent extends Event - { - public final GasNetwork gasNetwork; - - public final GasStack transferType; - public final boolean didTransfer; - - public GasTransferEvent(GasNetwork network, GasStack type, boolean did) - { - gasNetwork = network; - transferType = type; - didTransfer = did; - } - } - - public float getScale() - { - return Math.min(1, (gasStored == null || getCapacity() == 0 ? 0 : (float)gasStored.amount/getCapacity())); - } - - @Override - public String toString() - { - return "[GasNetwork] " + transmitters.size() + " transmitters, " + possibleAcceptors.size() + " acceptors."; - } - - @Override - public boolean canMerge(List> networks) - { - Gas found = null; - - for(ITransmitterNetwork network : networks) - { - if(network instanceof GasNetwork) - { - GasNetwork net = (GasNetwork)network; - - if(net.gasStored != null) - { - if(found != null && found != net.gasStored.getGas()) - { - return false; - } - - found = net.gasStored.getGas(); - } - } - } - - return true; - } - - @Override - protected GasNetwork create(IGridTransmitter... varTransmitters) - { - GasNetwork network = new GasNetwork(varTransmitters); - network.refGas = refGas; - - if(gasStored != null) - { - if(network.gasStored == null) - { - network.gasStored = gasStored; - } - else { - network.gasStored.amount += gasStored.amount; - } - } - - network.gasScale = network.getScale(); - gasScale = 0; - refGas = null; - gasStored = null; - - return network; - } - - @Override - protected GasNetwork create(Collection> collection) - { - GasNetwork network = new GasNetwork(collection); - network.refGas = refGas; - - if(gasStored != null) - { - if(network.gasStored == null) - { - network.gasStored = gasStored; - } - else { - network.gasStored.amount += gasStored.amount; - } - } - - network.gasScale = network.getScale(); - - return network; - } - - @Override - protected GasNetwork create(Set networks) - { - return new GasNetwork(networks); - } - - @Override - public TransmissionType getTransmissionType() - { - return TransmissionType.GAS; - } - - @Override - public String getNeededInfo() - { - return Integer.toString(getGasNeeded()); - } - - @Override - public String getStoredInfo() - { - return gasStored != null ? gasStored.getGas().getLocalizedName() + " (" + gasStored.amount + ")" : "None"; - } - - @Override - public String getFlowInfo() - { - return Integer.toString(prevTransferAmount) + "/t"; - } -} diff --git a/src/api/java/mekanism/api/gas/GasRegistry.java b/src/api/java/mekanism/api/gas/GasRegistry.java deleted file mode 100644 index 25db9667e..000000000 --- a/src/api/java/mekanism/api/gas/GasRegistry.java +++ /dev/null @@ -1,113 +0,0 @@ -package mekanism.api.gas; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraftforge.fluids.Fluid; - -public class GasRegistry -{ - private static ArrayList registeredGasses = new ArrayList(); - - /** - * Register a new gas into GasRegistry. - * @param gas - Gas to register - * @return the gas that has been registered, pulled right out of GasRegistry - */ - public static Gas register(Gas gas) - { - if(gas == null) - { - return null; - } - - registeredGasses.add(gas); - - return getGas(gas.getName()); - } - - /** - * Gets the gas associated with the defined ID. - * @param id - ID to check - * @return gas associated with defined ID - */ - public static Gas getGas(int id) - { - if(id == -1) - { - return null; - } - - return registeredGasses.get(id); - } - - /** - * Gets the gas associated with the defined fluid. - * @param f - fluid to check - * @return the gas associated with the fluid - */ - public static Gas getGas(Fluid f) - { - for(Gas gas : getRegisteredGasses()) - { - if(gas.hasFluid() && gas.getFluid() == f) - { - return gas; - } - } - - return null; - } - - /** - * Whether or not GasRegistry contains a gas with the specified name - * @param name - name to check - * @return if GasRegistry contains a gas with the defined name - */ - public static boolean containsGas(String name) - { - return getGas(name) != null; - } - - /** - * Gets the list of all gasses registered in GasRegistry. - * @return a cloned list of all registered gasses - */ - public static List getRegisteredGasses() - { - return (List)registeredGasses.clone(); - } - - /** - * Gets the gas associated with the specified name. - * @param name - name of the gas to get - * @return gas associated with the name - */ - public static Gas getGas(String name) - { - for(Gas gas : registeredGasses) - { - if(gas.getName().toLowerCase().equals(name.toLowerCase())) - { - return gas; - } - } - - return null; - } - - /** - * Gets the gas ID of a specified gas. - * @param gas - gas to get the ID from - * @return gas ID - */ - public static int getGasID(Gas gas) - { - if(gas == null || !containsGas(gas.getName())) - { - return -1; - } - - return registeredGasses.indexOf(gas); - } -} diff --git a/src/api/java/mekanism/api/gas/GasStack.java b/src/api/java/mekanism/api/gas/GasStack.java deleted file mode 100644 index 0f3f40bfb..000000000 --- a/src/api/java/mekanism/api/gas/GasStack.java +++ /dev/null @@ -1,119 +0,0 @@ -package mekanism.api.gas; - -import net.minecraft.nbt.NBTTagCompound; - -/** - * GasStack - a specified amount of a defined Gas with certain properties. - * @author aidancbrady - * - */ -public class GasStack -{ - private Gas type; - - public int amount; - - /** - * Creates a new GasStack with a defined gas ID and quantity. - * @param id - gas ID to associate this GasStack to, will perform a GasRegistry lookup in the constructor - * @param quantity - amount of gas to be referenced in this GasStack - */ - public GasStack(int id, int quantity) - { - type = GasRegistry.getGas(id); - amount = quantity; - } - - /** - * Creates a new GasStack with a defined Gas type and quantity. - * @param gas - gas type of the stack - * @param quantity - amount of gas to be referenced in this GasStack - */ - public GasStack(Gas gas, int quantity) - { - type = gas; - amount = quantity; - } - - private GasStack() {} - - /** - * Gets the Gas type of this GasStack. - * @return this GasStack's Gas type - */ - public Gas getGas() - { - return type; - } - - /** - * Writes this GasStack to a defined tag compound. - * @param nbtTags - tag compound to write to - * @return tag compound with this GasStack's data - */ - public NBTTagCompound write(NBTTagCompound nbtTags) - { - type.write(nbtTags); - nbtTags.setInteger("amount", amount); - - return nbtTags; - } - - /** - * Reads this GasStack's data from a defined tag compound. - * @param nbtTags - tag compound to read from - */ - public void read(NBTTagCompound nbtTags) - { - type = Gas.readFromNBT(nbtTags); - amount = nbtTags.getInteger("amount"); - } - - /** - * Returns the GasStack stored in the defined tag compound, or null if it doesn't exist. - * @param nbtTags - tag compound to read from - * @return GasStack stored in the tag compound - */ - public static GasStack readFromNBT(NBTTagCompound nbtTags) - { - if(nbtTags == null || nbtTags.hasNoTags()) - { - return null; - } - - GasStack stack = new GasStack(); - stack.read(nbtTags); - - if(stack.getGas() == null) - { - return null; - } - - return stack; - } - - /** - * Returns a copied form of this GasStack. - * @return copied GasStack - */ - public GasStack copy() - { - return new GasStack(type, amount); - } - - /** - * Whether or not this GasStack's gas type is equal to the other defined GasStack. - * @param stack - GasStack to check - * @return if the GasStacks contain the same gas type - */ - public boolean isGasEqual(GasStack stack) - { - return stack != null && getGas() == stack.getGas(); - } - - @Override - public String toString() - { - return "[" + type + ", " + amount + "]"; - } -} diff --git a/src/api/java/mekanism/api/gas/GasTank.java b/src/api/java/mekanism/api/gas/GasTank.java deleted file mode 100644 index 7aa5ad5ba..000000000 --- a/src/api/java/mekanism/api/gas/GasTank.java +++ /dev/null @@ -1,241 +0,0 @@ -package mekanism.api.gas; - -import net.minecraft.nbt.NBTTagCompound; - -/** - * An optional way of managing and/or storing gasses. Would be very useful in TileEntity and Entity gas storage. - * @author aidancbrady - * - */ -public class GasTank -{ - public GasStack stored; - - private int maxGas; - - private GasTank() {} - - /** - * Creates a tank with a defined capacity. - * @param max - the maximum amount of gas this GasTank can hold - */ - public GasTank(int max) - { - maxGas = max; - } - - /** - * Sets this tank's GasStack value to a new value. Will cap the amount to this GasTank's capacity. - * @param stack - value to set this tank's GasStack value to - */ - public void setGas(GasStack stack) - { - stored = stack; - - if(stored != null) - { - stored.amount = Math.min(getMaxGas(), stored.amount); - } - } - - /** - * Draws a specified amount of gas out of this tank. - * @param amount - amount to draw - * @param doDraw - if the gas should actually be removed from this tank - * @return gas taken from this GasTank as a GasStack value - */ - public GasStack draw(int amount, boolean doDraw) - { - if(stored == null || amount <= 0) - { - return null; - } - - GasStack ret = new GasStack(getGas().getGas(), Math.min(getStored(), amount)); - - if(ret.amount > 0) - { - if(doDraw) - { - stored.amount -= ret.amount; - - if(stored.amount <= 0) - { - stored = null; - } - } - - return ret; - } - - return null; - } - - /** - * Adds a specified amount of gas to this tank. - * @param amount - the GasStack for this tank to receive - * @param doReceive - if the gas should actually be added to this tank - * @return the amount of gas accepted by this tank - */ - public int receive(GasStack amount, boolean doReceive) - { - if(amount == null || (stored != null && stored.amount == getMaxGas())) - { - return 0; - } - - int toFill = Math.min(getMaxGas()-getStored(), amount.amount); - - if(doReceive) - { - if(stored == null) - { - stored = amount.copy(); - } - else { - stored.amount = Math.min(getMaxGas(), getStored()+amount.amount); - } - } - - return toFill; - } - - /** - * If this GasTank can receive the specified type of gas. Will return false if this tank does not need anymore gas. - * @param gas - gas to check - * @return if this GasTank can accept the defined gas - */ - public boolean canReceive(Gas gas) - { - if(getNeeded() == 0 || stored != null && (gas != null && gas != stored.getGas())) - { - return false; - } - - return true; - } - - /** - * If this GasTank can receive the specified type of gas. Will return TRUE if this tank does not need anymore gas. - * @param gas - gas to check - * @return if this GasTank can accept the defined gas - */ - public boolean canReceiveType(Gas gas) - { - if(stored != null && (gas != null && gas != stored.getGas())) - { - return false; - } - - return true; - } - - /** - * If this GasTank can be drawn of the specified type of gas. Will return false if this tank does not contain any gas. - * @param gas - gas to check - * @return if this GasTank can be drawn of the defined gas - */ - public boolean canDraw(Gas gas) - { - if(stored == null || (gas != null && gas != stored.getGas())) - { - return false; - } - - return true; - } - - /** - * Gets the amount of gas needed by this GasTank. - * @return - */ - public int getNeeded() - { - return getMaxGas()-getStored(); - } - - /** - * Gets the maximum amount of gas this tank can hold. - * @return - max gas - */ - public int getMaxGas() - { - return maxGas; - } - - /** - * Gets the GasStack held by this GasTank. - * @return - GasStakc held by this tank - */ - public GasStack getGas() - { - return stored; - } - - /** - * Gets the type of gas currently stored in this GasTank. - * @return gas type contained - */ - public Gas getGasType() - { - return stored != null ? stored.getGas() : null; - } - - /** - * Gets the amount of gas stored by this GasTank. - * @return amount of gas stored - */ - public int getStored() - { - return stored != null ? stored.amount : 0; - } - - /** - * Writes this tank to a defined tag compound. - * @param nbtTags - tag compound to write to - * @return tag compound with this tank's data - */ - public NBTTagCompound write(NBTTagCompound nbtTags) - { - if(stored != null) - { - nbtTags.setTag("stored", stored.write(new NBTTagCompound())); - } - - nbtTags.setInteger("maxGas", maxGas); - - return nbtTags; - } - - /** - * Reads this tank's data from a defined tag compound. - * @param nbtTags - tag compound to read from - */ - public void read(NBTTagCompound nbtTags) - { - if(nbtTags.hasKey("stored")) - { - stored = GasStack.readFromNBT(nbtTags.getCompoundTag("stored")); - } - - maxGas = nbtTags.getInteger("maxGas"); - } - - /** - * Returns the tank stored in the defined tag compound, or null if it doesn't exist. - * @param nbtTags - tag compound to read from - * @return tank stored in the tag compound - */ - public static GasTank readFromNBT(NBTTagCompound nbtTags) - { - if(nbtTags == null || nbtTags.hasNoTags()) - { - return null; - } - - GasTank tank = new GasTank(); - tank.read(nbtTags); - - return tank; - } -} diff --git a/src/api/java/mekanism/api/gas/GasTransmission.java b/src/api/java/mekanism/api/gas/GasTransmission.java deleted file mode 100644 index c90914116..000000000 --- a/src/api/java/mekanism/api/gas/GasTransmission.java +++ /dev/null @@ -1,141 +0,0 @@ -package mekanism.api.gas; - -import mekanism.api.Coord4D; -import mekanism.api.transmitters.IGridTransmitter; -import mekanism.api.transmitters.TransmissionType; -import net.minecraft.item.ItemStack; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; - -/** - * A handy class containing several utilities for efficient gas transfer. - * @author AidanBrady - * - */ -public final class GasTransmission -{ - /** - * Gets all the tubes around a tile entity. - * @param tileEntity - center tile entity - * @return array of TileEntities - */ - public static TileEntity[] getConnectedTubes(TileEntity tileEntity) - { - TileEntity[] tubes = new TileEntity[] {null, null, null, null, null, null}; - - for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) - { - TileEntity tube = Coord4D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.getWorldObj()); - - if(TransmissionType.checkTransmissionType(tube, TransmissionType.GAS, tileEntity)) - { - tubes[orientation.ordinal()] = tube; - } - } - - return tubes; - } - - /** - * Gets all the acceptors around a tile entity. - * @param tileEntity - center tile entity - * @return array of IGasAcceptors - */ - public static IGasHandler[] getConnectedAcceptors(TileEntity tileEntity) - { - IGasHandler[] acceptors = new IGasHandler[] {null, null, null, null, null, null}; - - for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) - { - TileEntity acceptor = Coord4D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.getWorldObj()); - - if(acceptor instanceof IGasHandler) - { - acceptors[orientation.ordinal()] = (IGasHandler)acceptor; - } - } - - return acceptors; - } - - /** - * Gets all the tube connections around a tile entity. - * @param tileEntity - center tile entity - * @return array of ITubeConnections - */ - public static ITubeConnection[] getConnections(TileEntity tileEntity) - { - ITubeConnection[] connections = new ITubeConnection[] {null, null, null, null, null, null}; - - for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) - { - TileEntity connection = Coord4D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.getWorldObj()); - - if(canConnect(connection, orientation)) - { - connections[orientation.ordinal()] = (ITubeConnection)connection; - } - } - - return connections; - } - - /** - * Whether or not a TileEntity can connect to a specified tile on a specified side. - * @param tileEntity - TileEntity to attempt connection to - * @param side - side to attempt connection on - * @return if this tile and side are connectable - */ - public static boolean canConnect(TileEntity tileEntity, ForgeDirection side) - { - if(tileEntity instanceof ITubeConnection && (!(tileEntity instanceof IGasTransmitter) || TransmissionType.checkTransmissionType(tileEntity, TransmissionType.GAS, tileEntity))) - { - if(((ITubeConnection)tileEntity).canTubeConnect(side.getOpposite())) - { - return true; - } - } - - return false; - } - - /** - * Removes a specified amount of gas from an IGasItem. - * @param itemStack - ItemStack of the IGasItem - * @param type - type of gas to remove from the IGasItem, null if it doesn't matter - * @param amount - amount of gas to remove from the ItemStack - * @return the GasStack removed by the IGasItem - */ - public static GasStack removeGas(ItemStack itemStack, Gas type, int amount) - { - if(itemStack != null && itemStack.getItem() instanceof IGasItem) - { - IGasItem item = (IGasItem)itemStack.getItem(); - - if(type != null && item.getGas(itemStack) != null && item.getGas(itemStack).getGas() != type || !item.canProvideGas(itemStack, type)) - { - return null; - } - - return item.removeGas(itemStack, amount); - } - - return null; - } - - /** - * Adds a specified amount of gas to an IGasItem. - * @param itemStack - ItemStack of the IGasItem - * @param stack - stack to add to the IGasItem - * @return amount of gas accepted by the IGasItem - */ - public static int addGas(ItemStack itemStack, GasStack stack) - { - if(itemStack != null && itemStack.getItem() instanceof IGasItem && ((IGasItem)itemStack.getItem()).canReceiveGas(itemStack, stack.getGas())) - { - return ((IGasItem)itemStack.getItem()).addGas(itemStack, stack.copy()); - } - - return 0; - } -} diff --git a/src/api/java/mekanism/api/gas/IGasHandler.java b/src/api/java/mekanism/api/gas/IGasHandler.java deleted file mode 100644 index 8723da69a..000000000 --- a/src/api/java/mekanism/api/gas/IGasHandler.java +++ /dev/null @@ -1,41 +0,0 @@ -package mekanism.api.gas; - -import net.minecraftforge.common.util.ForgeDirection; - -/** - * Implement this if your tile entity accepts gas from an external source. - * @author AidanBrady - * - */ -public interface IGasHandler -{ - /** - * Transfer a certain amount of gas to this block. - * @param stack - gas to add - * @return gas added - */ - public int receiveGas(ForgeDirection side, GasStack stack); - - /** - * Draws a certain amount of gas from this block. - * @param amount - amount to draw - * @return gas drawn - */ - public GasStack drawGas(ForgeDirection side, int amount); - - /** - * Whether or not this block can accept gas from a certain side. - * @param side - side to check - * @param type - type of gas to check - * @return if block accepts gas - */ - public boolean canReceiveGas(ForgeDirection side, Gas type); - - /** - * Whether or not this block can be drawn of gas from a certain side. - * @param side - side to check - * @param type - type of gas to check - * @return if block can be drawn of gas - */ - public boolean canDrawGas(ForgeDirection side, Gas type); -} diff --git a/src/api/java/mekanism/api/gas/IGasItem.java b/src/api/java/mekanism/api/gas/IGasItem.java deleted file mode 100644 index 9c7d33230..000000000 --- a/src/api/java/mekanism/api/gas/IGasItem.java +++ /dev/null @@ -1,81 +0,0 @@ -package mekanism.api.gas; - -import net.minecraft.item.ItemStack; - -/** - * Implement this in your item class if it can store or transfer certain gasses. - * @author AidanBrady - * - */ -public interface IGasItem -{ - /** - * Gets the rate of transfer this item can handle. - * @return - */ - public int getRate(ItemStack itemstack); - - /** - * Adds a defined amount of a certain gas to an item. - * @param itemstack - the itemstack to add gas to - * @param type - the type of gas to add - * @param amount - the amount of gas to add - * @return the gas that was accepted by the item - */ - public int addGas(ItemStack itemstack, GasStack stack); - - /** - * Removes the defined amount of a certain gas from the item. - * @param itemstack - the itemstack to remove gas from - * @param type - the type of gas to remove - * @param amount - the amount of gas to remove - * @return the gas that was removed by the item - */ - public GasStack removeGas(ItemStack itemstack, int amount); - - /** - * Whether or not this storage tank be given a specific gas. - * @param itemstack - the itemstack to check - * @param type - the type of gas the tank can possibly receive - * @return if the item be charged - */ - public boolean canReceiveGas(ItemStack itemstack, Gas type); - - /** - * Whether or not this item can give a gas receiver a certain type of gas. - * @param itemstack - the itemstack to check - * @param type - the type of gas the tank can provide - * @return if the item can provide gas - */ - public boolean canProvideGas(ItemStack itemstack, Gas type); - - /** - * Get the gas of a declared type. - * @param type - type of gas - * @param data - ItemStack parameter if necessary - * @return gas stored - */ - public GasStack getGas(ItemStack itemstack); - - /** - * Set the gas of a declared type to a new amount; - * @param type - type of gas - * @param data - ItemStack parameter if necessary - * @param amount - amount to store - */ - public void setGas(ItemStack itemstack, GasStack stack); - - /** - * Gets the maximum amount of gas this tile entity can store. - * @param type - type of gas - * @param data - ItemStack parameter if necessary - * @return maximum gas - */ - public int getMaxGas(ItemStack itemstack); - - /** - * Returns whether or not this item contains metadata-specific subtypes instead of using metadata for damage display. - * @return if the item contains metadata-specific subtypes - */ - public boolean isMetadataSpecific(ItemStack itemstack); -} diff --git a/src/api/java/mekanism/api/gas/IGasTransmitter.java b/src/api/java/mekanism/api/gas/IGasTransmitter.java deleted file mode 100644 index 63eb02fd1..000000000 --- a/src/api/java/mekanism/api/gas/IGasTransmitter.java +++ /dev/null @@ -1,9 +0,0 @@ -package mekanism.api.gas; - -import mekanism.api.transmitters.IGridTransmitter; -import net.minecraft.tileentity.TileEntity; - -public interface IGasTransmitter extends IGridTransmitter -{ - public boolean canTransferGasToTube(TileEntity tile); -} diff --git a/src/api/java/mekanism/api/gas/ITubeConnection.java b/src/api/java/mekanism/api/gas/ITubeConnection.java deleted file mode 100644 index b669fedda..000000000 --- a/src/api/java/mekanism/api/gas/ITubeConnection.java +++ /dev/null @@ -1,18 +0,0 @@ -package mekanism.api.gas; - -import net.minecraftforge.common.util.ForgeDirection; - -/** - * Implement this if your block can connect to Pressurized Tubes. - * @author AidanBrady - * - */ -public interface ITubeConnection -{ - /** - * Whether or not a tube can connect to a certain orientation. - * @param side - orientation to check - * @return if a tube can connect - */ - public boolean canTubeConnect(ForgeDirection side); -} diff --git a/src/api/java/mekanism/api/gas/OreGas.java b/src/api/java/mekanism/api/gas/OreGas.java deleted file mode 100644 index 316169c2a..000000000 --- a/src/api/java/mekanism/api/gas/OreGas.java +++ /dev/null @@ -1,38 +0,0 @@ -package mekanism.api.gas; - -import net.minecraft.util.StatCollector; - -public class OreGas extends Gas -{ - private String oreName; - private OreGas cleanGas; - - public OreGas(String s, String name) - { - super(s); - - oreName = name; - } - - public boolean isClean() - { - return getCleanGas() == null; - } - - public OreGas getCleanGas() - { - return cleanGas; - } - - public OreGas setCleanGas(OreGas gas) - { - cleanGas = gas; - - return this; - } - - public String getOreName() - { - return StatCollector.translateToLocal(oreName); - } -} diff --git a/src/api/java/mekanism/api/infuse/InfuseObject.java b/src/api/java/mekanism/api/infuse/InfuseObject.java deleted file mode 100644 index a86c02f1a..000000000 --- a/src/api/java/mekanism/api/infuse/InfuseObject.java +++ /dev/null @@ -1,21 +0,0 @@ -package mekanism.api.infuse; - -/** - * InfuseObject - an object associated with an ItemStack that can modify a Metallurgic Infuser's internal infuse. - * @author AidanBrady - * - */ -public class InfuseObject -{ - /** The type of infuse this item stores */ - public InfuseType type; - - /** How much infuse this item stores */ - public int stored; - - public InfuseObject(InfuseType infusion, int i) - { - type = infusion; - stored = i; - } -} diff --git a/src/api/java/mekanism/api/infuse/InfuseRegistry.java b/src/api/java/mekanism/api/infuse/InfuseRegistry.java deleted file mode 100644 index 308b9c5be..000000000 --- a/src/api/java/mekanism/api/infuse/InfuseRegistry.java +++ /dev/null @@ -1,113 +0,0 @@ -package mekanism.api.infuse; - -import java.util.HashMap; -import java.util.Map; - -import net.minecraft.item.ItemStack; - -/** - * Use this class to add a new object that registers as an infuse object. - * @author AidanBrady - * - */ -public class InfuseRegistry -{ - /** The (private) map of ItemStacks and their related InfuseObjects. */ - private static Map infuseObjects = new HashMap(); - - /** The (private) map of infuse names and their corresponding InfuseTypes. */ - private static Map infuseTypes = new HashMap(); - - /** - * Registers an InfuseType into the registry. Call this in PreInit! - * @param infuse - */ - public static void registerInfuseType(InfuseType infuse) - { - if(infuseTypes.containsKey(infuse.name)) - { - return; - } - - infuseTypes.put(infuse.name, infuse); - } - - /** - * Gets an InfuseType from it's name, or null if it doesn't exist. - * @param name - the name of the InfuseType to get - * @return the name's corresponding InfuseType - */ - public static InfuseType get(String name) - { - if(name.equals("null")) - { - return null; - } - - return infuseTypes.get(name); - } - - /** - * Whether or not the registry contains a correspondent InfuseType to a name. - * @param name - the name to check - * @return if the name has a coorespondent InfuseType - */ - public static boolean contains(String name) - { - return get(name) != null; - } - - /** - * Registers a block or item that serves as an infuse object. An infuse object will store a certain type and amount of infuse, - * and will deliver this amount to the Metallurgic Infuser's buffer of infuse. The item's stack size will be decremented when - * it is placed in the Metallurgic Infuser's infuse slot, and the machine can accept the type and amount of infuse stored in the - * object. - * @param itemStack - stack the infuse object is linked to -- stack size is ignored - * @param infuseObject - the infuse object with the type and amount data - */ - public static void registerInfuseObject(ItemStack itemStack, InfuseObject infuseObject) - { - if(getObject(itemStack) != null) - { - return; - } - - infuseObjects.put(itemStack, infuseObject); - } - - /** - * Gets the InfuseObject data from an ItemStack. - * @param itemStack - the ItemStack to check - * @return the ItemStack's InfuseObject - */ - public static InfuseObject getObject(ItemStack itemStack) - { - for(Map.Entry obj : infuseObjects.entrySet()) - { - if(itemStack.isItemEqual(obj.getKey())) - { - return obj.getValue(); - } - } - - return null; - } - - /** - * Gets the private map for InfuseObjects. - * @return private InfuseObject map - */ - public static final Map getObjectMap() - { - return infuseObjects; - } - - /** - * Gets the private map for InfuseTypes. - * @return private InfuseType map - */ - public static final Map getInfuseMap() - { - return infuseTypes; - } -} diff --git a/src/api/java/mekanism/api/infuse/InfuseType.java b/src/api/java/mekanism/api/infuse/InfuseType.java deleted file mode 100644 index 1f5215cb7..000000000 --- a/src/api/java/mekanism/api/infuse/InfuseType.java +++ /dev/null @@ -1,47 +0,0 @@ -package mekanism.api.infuse; - -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.StatCollector; - -/** - * The types of infuse currently available in Mekanism. - * @author AidanBrady - * - */ -public final class InfuseType -{ - /** The name of this infusion */ - public String name; - - /** The location of this infuse's GUI texture */ - public ResourceLocation texture; - - /** The infuse's GUI texture X offset. */ - public int texX; - - /** The infuse's GUI texture Y offset. */ - public int texY; - - /** The unlocalized name of this type. */ - public String unlocalizedName; - - public InfuseType(String s, ResourceLocation location, int x, int y) - { - name = s; - texture = location; - texX = x; - texY = y; - } - - public InfuseType setUnlocalizedName(String name) - { - unlocalizedName = name; - - return this; - } - - public String getLocalizedName() - { - return StatCollector.translateToLocal(unlocalizedName); - } -} diff --git a/src/api/java/mekanism/api/infuse/InfusionInput.java b/src/api/java/mekanism/api/infuse/InfusionInput.java deleted file mode 100644 index edbad48cd..000000000 --- a/src/api/java/mekanism/api/infuse/InfusionInput.java +++ /dev/null @@ -1,32 +0,0 @@ -package mekanism.api.infuse; - -import net.minecraft.item.ItemStack; - -/** - * An infusion input, containing the type of and amount of infuse the operation requires, as well as the input ItemStack. - * @author AidanBrady - * - */ -public class InfusionInput -{ - /** The type of this infusion */ - public InfuseType infusionType; - - /** How much infuse it takes to perform this operation */ - public int infuseAmount; - - /** The input ItemStack */ - public ItemStack inputStack; - - public InfusionInput(InfuseType infusiontype, int required, ItemStack itemstack) - { - infusionType = infusiontype; - infuseAmount = required; - inputStack = itemstack; - } - - public static InfusionInput getInfusion(InfuseType type, int stored, ItemStack itemstack) - { - return new InfusionInput(type, stored, itemstack); - } -} diff --git a/src/api/java/mekanism/api/infuse/InfusionOutput.java b/src/api/java/mekanism/api/infuse/InfusionOutput.java deleted file mode 100644 index ad6d79a62..000000000 --- a/src/api/java/mekanism/api/infuse/InfusionOutput.java +++ /dev/null @@ -1,38 +0,0 @@ -package mekanism.api.infuse; - -import net.minecraft.item.ItemStack; - -/** - * An infusion output, containing a reference to it's input as well as the output resource. - * @author AidanBrady - * - */ -public class InfusionOutput -{ - /** The input infusion */ - public InfusionInput infusionInput; - - /** The output resource of this infusion */ - public ItemStack resource; - - public InfusionOutput(InfusionInput input, ItemStack itemstack) - { - infusionInput = input; - resource = itemstack; - } - - public static InfusionOutput getInfusion(InfusionInput input, ItemStack itemstack) - { - return new InfusionOutput(input, itemstack); - } - - public int getInfuseRequired() - { - return infusionInput.infuseAmount; - } - - public InfusionOutput copy() - { - return new InfusionOutput(infusionInput, resource); - } -} diff --git a/src/api/java/mekanism/api/transmitters/DynamicNetwork.java b/src/api/java/mekanism/api/transmitters/DynamicNetwork.java deleted file mode 100644 index bef1f0d88..000000000 --- a/src/api/java/mekanism/api/transmitters/DynamicNetwork.java +++ /dev/null @@ -1,526 +0,0 @@ -package mekanism.api.transmitters; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.NoSuchElementException; -import java.util.Set; - -import mekanism.api.Coord4D; -import mekanism.api.IClientTicker; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.world.World; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.common.util.ForgeDirection; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.eventhandler.Event; - -public abstract class DynamicNetwork> implements ITransmitterNetwork, IClientTicker, INetworkDataHandler -{ - public LinkedHashSet> transmitters = new LinkedHashSet>(); - - public HashMap possibleAcceptors = new HashMap(); - public HashMap acceptorDirections = new HashMap(); - - private List updateQueue = new ArrayList(); - - protected AxisAlignedBB packetRange = null; - - protected int ticksSinceCreate = 0; - - protected int capacity = 0; - protected double meanCapacity = 0; - - protected boolean fixed = false; - - protected boolean needsUpdate = false; - - protected abstract ITransmitterNetwork create(IGridTransmitter... varTransmitters); - - protected abstract ITransmitterNetwork create(Collection> collection); - - protected abstract ITransmitterNetwork create(Set networks); - - protected void clearAround(IGridTransmitter transmitter) - { - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - Coord4D coord = Coord4D.get(transmitter.getTile()).getFromSide(side); - possibleAcceptors.remove(coord); - acceptorDirections.remove(coord.getTileEntity(transmitter.getTile().getWorldObj())); - } - } - - public void addAllTransmitters(Set> newTransmitters) - { - transmitters.addAll(newTransmitters); - updateCapacity(); - } - - public boolean isFirst(IGridTransmitter transmitter) - { - return transmitters.iterator().next().equals(transmitter); - } - - @Override - public void fullRefresh() - { - possibleAcceptors.clear(); - acceptorDirections.clear(); - - for(IGridTransmitter transmitter : transmitters) - { - refresh(transmitter); - } - - refresh(); - } - - public AxisAlignedBB getPacketRange() - { - if(packetRange == null) - { - return genPacketRange(); - } - - return packetRange; - } - - public int getDimension() - { - if(getSize() == 0) - { - return 0; - } - - return transmitters.iterator().next().getTile().getWorldObj().provider.dimensionId; - } - - protected AxisAlignedBB genPacketRange() - { - if(getSize() == 0) - { - deregister(); - return null; - } - - Coord4D initCoord = Coord4D.get(transmitters.iterator().next().getTile()); - - int minX = initCoord.xCoord; - int minY = initCoord.yCoord; - int minZ = initCoord.zCoord; - int maxX = initCoord.xCoord; - int maxY = initCoord.yCoord; - int maxZ = initCoord.zCoord; - - for(IGridTransmitter transmitter : transmitters) - { - Coord4D coord = Coord4D.get(transmitter.getTile()); - - if(coord.xCoord < minX) minX = coord.xCoord; - if(coord.yCoord < minY) minY = coord.yCoord; - if(coord.zCoord < minZ) minZ = coord.zCoord; - if(coord.xCoord > maxX) maxX = coord.xCoord; - if(coord.yCoord > maxY) maxY = coord.yCoord; - if(coord.zCoord > maxZ) maxZ = coord.zCoord; - } - - minX -= 40; - minY -= 40; - minZ -= 40; - maxX += 40; - maxY += 40; - maxZ += 40; - - return AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ); - } - - @Override - public void removeTransmitter(IGridTransmitter transmitter) - { - transmitters.remove(transmitter); - updateCapacity(); - - if(transmitters.size() == 0) - { - deregister(); - } - } - - @Override - public void register() - { - try { - IGridTransmitter aTransmitter = transmitters.iterator().next(); - - if(aTransmitter instanceof TileEntity) - { - if(!((TileEntity)aTransmitter).getWorldObj().isRemote) - { - TransmitterNetworkRegistry.getInstance().registerNetwork(this); - } - else { - MinecraftForge.EVENT_BUS.post(new ClientTickUpdate(this, (byte)1)); - } - } - } catch(NoSuchElementException e) {} - } - - @Override - public void deregister() - { - transmitters.clear(); - - if(FMLCommonHandler.instance().getEffectiveSide().isServer()) - { - TransmitterNetworkRegistry.getInstance().removeNetwork(this); - } - else { - MinecraftForge.EVENT_BUS.post(new ClientTickUpdate(this, (byte)0)); - } - } - - @Override - public int getSize() - { - return transmitters.size(); - } - - @Override - public int getAcceptorSize() - { - return possibleAcceptors.size(); - } - - public synchronized void updateCapacity() { - updateMeanCapacity(); - capacity = (int)meanCapacity * transmitters.size(); - } - - /** - * Override this if things can have variable capacity along the network. - * @return An 'average' value of capacity. Calculate it how you will. - */ - protected synchronized void updateMeanCapacity() - { - if(transmitters.size() > 0) - { - meanCapacity = transmitters.iterator().next().getCapacity(); - } - else { - meanCapacity = 0; - } - } - - public int getCapacity() - { - return capacity; - } - - public double getMeanCapacity() - { - return meanCapacity; - } - - @Override - public void tick() - { - boolean didFix = false; - - if(!fixed) - { - ticksSinceCreate++; - - if(transmitters.size() == 0) - { - deregister(); - return; - } - - if(ticksSinceCreate > 1200) - { - ticksSinceCreate = 0; - fixMessedUpNetwork(transmitters.iterator().next()); - didFix = true; - } - } - - if(!didFix) - { - onUpdate(); - } - } - - public void onUpdate() - { - if(FMLCommonHandler.instance().getEffectiveSide().isServer()) - { - Iterator i = updateQueue.iterator(); - - try { - while(i.hasNext()) - { - DelayQueue q = i.next(); - - if(q.delay > 0) - { - q.delay--; - } - else { - needsUpdate = true; - i.remove(); - } - } - } catch(Exception e) {} - } - } - - @Override - public synchronized void fixMessedUpNetwork(IGridTransmitter transmitter) - { - if(transmitter instanceof TileEntity) - { - NetworkFinder finder = new NetworkFinder(((TileEntity)transmitter).getWorldObj(), getTransmissionType(), Coord4D.get((TileEntity)transmitter)); - List partNetwork = finder.exploreNetwork(); - Set> newTransporters = new HashSet>(); - - for(Coord4D node : partNetwork) - { - TileEntity nodeTile = node.getTileEntity(((TileEntity)transmitter).getWorldObj()); - - if(TransmissionType.checkTransmissionType(nodeTile, getTransmissionType(), (TileEntity)transmitter)) - { - ((IGridTransmitter)nodeTile).removeFromTransmitterNetwork(); - newTransporters.add((IGridTransmitter)nodeTile); - } - } - - ITransmitterNetwork newNetwork = create(newTransporters); - newNetwork.fullRefresh(); - newNetwork.setFixed(true); - deregister(); - } - } - - @Override - public synchronized void split(IGridTransmitter splitPoint) - { - if(splitPoint instanceof TileEntity) - { - removeTransmitter(splitPoint); - - TileEntity[] connectedBlocks = new TileEntity[6]; - boolean[] dealtWith = {false, false, false, false, false, false}; - List> newNetworks = new ArrayList>(); - - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - TileEntity sideTile = Coord4D.get((TileEntity)splitPoint).getFromSide(side).getTileEntity(((TileEntity)splitPoint).getWorldObj()); - - if(sideTile != null) - { - connectedBlocks[side.ordinal()] = sideTile; - } - } - - for(int count = 0; count < connectedBlocks.length; count++) - { - TileEntity connectedBlockA = connectedBlocks[count]; - - if(TransmissionType.checkTransmissionType(connectedBlockA, getTransmissionType()) && !dealtWith[count]) - { - NetworkFinder finder = new NetworkFinder(((TileEntity)splitPoint).getWorldObj(), getTransmissionType(), Coord4D.get(connectedBlockA), Coord4D.get((TileEntity)splitPoint)); - List partNetwork = finder.exploreNetwork(); - - for(int check = count; check < connectedBlocks.length; check++) - { - if(check == count) - { - continue; - } - - TileEntity connectedBlockB = connectedBlocks[check]; - - if(TransmissionType.checkTransmissionType(connectedBlockB, getTransmissionType()) && !dealtWith[check]) - { - if(partNetwork.contains(Coord4D.get(connectedBlockB))) - { - dealtWith[check] = true; - } - } - } - - Set> newNetCables = new HashSet>(); - - for(Coord4D node : finder.iterated) - { - TileEntity nodeTile = node.getTileEntity(((TileEntity)splitPoint).getWorldObj()); - - if(TransmissionType.checkTransmissionType(nodeTile, getTransmissionType())) - { - if(nodeTile != splitPoint) - { - newNetCables.add((IGridTransmitter)nodeTile); - } - } - } - - newNetworks.add(create(newNetCables)); - } - } - - if(newNetworks.size() > 0) - { - onNetworksCreated((List)newNetworks); - - for(ITransmitterNetwork network : newNetworks) - { - network.fullRefresh(); - } - } - - deregister(); - } - } - - @Override - public void onNetworksCreated(List networks) {} - - @Override - public void setFixed(boolean value) - { - fixed = value; - } - - @Override - public boolean needsTicks() - { - return getSize() > 0; - } - - @Override - public void clientTick() - { - ticksSinceCreate++; - - if(ticksSinceCreate == 5 && getSize() > 0) - { - TileEntity tile = (TileEntity)transmitters.iterator().next(); - MinecraftForge.EVENT_BUS.post(new NetworkClientRequest(tile)); - } - } - - @Override - public boolean canMerge(List> networks) - { - return true; - } - - public static class ClientTickUpdate extends Event - { - public DynamicNetwork network; - public byte operation; /*0 remove, 1 add*/ - - public ClientTickUpdate(DynamicNetwork net, byte b) - { - network = net; - operation = b; - } - } - - public static class NetworkClientRequest extends Event - { - public TileEntity tileEntity; - - public NetworkClientRequest(TileEntity tile) - { - tileEntity = tile; - } - } - - public void addUpdate(EntityPlayer player) - { - updateQueue.add(new DelayQueue(player)); - } - - public static class NetworkFinder - { - public TransmissionType transmissionType; - - public World worldObj; - public Coord4D start; - - public List iterated = new ArrayList(); - public List toIgnore = new ArrayList(); - - public NetworkFinder(World world, TransmissionType type, Coord4D location, Coord4D... ignore) - { - worldObj = world; - start = location; - - transmissionType = type; - - if(ignore != null) - { - for(int i = 0; i < ignore.length; i++) - { - toIgnore.add(ignore[i]); - } - } - } - - public void loopAll(Coord4D location) - { - if(TransmissionType.checkTransmissionType(location.getTileEntity(worldObj), transmissionType)) - { - iterated.add(location); - } - else { - toIgnore.add(location); - } - - for(ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) - { - Coord4D obj = location.getFromSide(direction); - - if(!iterated.contains(obj) && !toIgnore.contains(obj)) - { - TileEntity tileEntity = obj.getTileEntity(worldObj); - - if(!(tileEntity instanceof IBlockableConnection) || ((IBlockableConnection)tileEntity).canConnectMutual(direction.getOpposite())) - { - if(TransmissionType.checkTransmissionType(tileEntity, transmissionType, location.getTileEntity(worldObj))) - { - loopAll(obj); - } - } - } - } - } - - public List exploreNetwork() - { - loopAll(start); - - return iterated; - } - } - - public static class DelayQueue - { - public EntityPlayer player; - public int delay; - - public DelayQueue(EntityPlayer p) - { - player = p; - delay = 5; - } - } -} diff --git a/src/api/java/mekanism/api/transmitters/IBlockableConnection.java b/src/api/java/mekanism/api/transmitters/IBlockableConnection.java deleted file mode 100644 index f6811fbec..000000000 --- a/src/api/java/mekanism/api/transmitters/IBlockableConnection.java +++ /dev/null @@ -1,10 +0,0 @@ -package mekanism.api.transmitters; - -import net.minecraftforge.common.util.ForgeDirection; - -public interface IBlockableConnection -{ - public boolean canConnectMutual(ForgeDirection side); - - public boolean canConnect(ForgeDirection side); -} diff --git a/src/api/java/mekanism/api/transmitters/IGridTransmitter.java b/src/api/java/mekanism/api/transmitters/IGridTransmitter.java deleted file mode 100644 index ea222d8e6..000000000 --- a/src/api/java/mekanism/api/transmitters/IGridTransmitter.java +++ /dev/null @@ -1,66 +0,0 @@ -package mekanism.api.transmitters; - -import mekanism.api.Coord4D; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; - -public interface IGridTransmitter> extends ITransmitter -{ - /** - * Gets the network currently in use by this transmitter segment. - * @return network this transmitter is using - */ - public N getTransmitterNetwork(); - - /** - * Gets the network currently in use by this transmitter segment. - * @param createIfNull - If true, the transmitter will try and connect to an - * adjacent network, merging several if necessary, or creating a new one - * if none is available - * @return network this transmitter is using - */ - public N getTransmitterNetwork(boolean createIfNull); - - /** - * Sets this transmitter segment's network to a new value. - * @param network - network to set to - */ - public void setTransmitterNetwork(N network); - - /** - * Refreshes the transmitter's network. - */ - public void refreshTransmitterNetwork(); - - /** - * Called when the chunk this transmitter is in is loaded. - */ - public void chunkLoad(); - - /** - * Remove this transmitter from its network. - */ - public void removeFromTransmitterNetwork(); - - public boolean canConnectToAcceptor(ForgeDirection side, boolean ignoreActive); - - /** - * Call this if you're worried a transmitter's network is messed up and you want - * it to try and fix itself. - */ - public void fixTransmitterNetwork(); - - public boolean areTransmitterNetworksEqual(TileEntity tileEntity); - - public int getTransmitterNetworkSize(); - - public int getTransmitterNetworkAcceptorSize(); - - public String getTransmitterNetworkNeeded(); - - public String getTransmitterNetworkFlow(); - - public int getCapacity(); - - public TileEntity getTile(); -} diff --git a/src/api/java/mekanism/api/transmitters/INetworkDataHandler.java b/src/api/java/mekanism/api/transmitters/INetworkDataHandler.java deleted file mode 100644 index 38cd63702..000000000 --- a/src/api/java/mekanism/api/transmitters/INetworkDataHandler.java +++ /dev/null @@ -1,10 +0,0 @@ -package mekanism.api.transmitters; - -public interface INetworkDataHandler -{ - public String getNeededInfo(); - - public String getStoredInfo(); - - public String getFlowInfo(); -} diff --git a/src/api/java/mekanism/api/transmitters/ITransmitter.java b/src/api/java/mekanism/api/transmitters/ITransmitter.java deleted file mode 100644 index cddc76a7a..000000000 --- a/src/api/java/mekanism/api/transmitters/ITransmitter.java +++ /dev/null @@ -1,11 +0,0 @@ -package mekanism.api.transmitters; - -public interface ITransmitter -{ - /** - * Get the transmitter's transmission type - * - * @return TransmissionType this transmitter uses - */ - public TransmissionType getTransmissionType(); -} diff --git a/src/api/java/mekanism/api/transmitters/ITransmitterNetwork.java b/src/api/java/mekanism/api/transmitters/ITransmitterNetwork.java deleted file mode 100644 index 4bb2e8236..000000000 --- a/src/api/java/mekanism/api/transmitters/ITransmitterNetwork.java +++ /dev/null @@ -1,39 +0,0 @@ -package mekanism.api.transmitters; - -import java.util.List; -import java.util.Set; - -public interface ITransmitterNetwork> -{ - public void tick(); - - public int getSize(); - - public int getAcceptorSize(); - - public Set getAcceptors(Object... data); - - public void removeTransmitter(IGridTransmitter transmitter); - - public void refresh(); - - public void fullRefresh(); - - public void refresh(IGridTransmitter transmitter); - - public void split(IGridTransmitter splitPoint); - - public void fixMessedUpNetwork(IGridTransmitter transmitter); - - public void register(); - - public void deregister(); - - public void setFixed(boolean value); - - public TransmissionType getTransmissionType(); - - public boolean canMerge(List> networks); - - public void onNetworksCreated(List networks); -} diff --git a/src/api/java/mekanism/api/transmitters/TransmissionType.java b/src/api/java/mekanism/api/transmitters/TransmissionType.java deleted file mode 100644 index ae9388cca..000000000 --- a/src/api/java/mekanism/api/transmitters/TransmissionType.java +++ /dev/null @@ -1,43 +0,0 @@ -package mekanism.api.transmitters; - -import mekanism.api.gas.IGasTransmitter; -import net.minecraft.tileentity.TileEntity; - -public enum TransmissionType -{ - ENERGY, - FLUID, - GAS, - ITEM; - - public static boolean checkTransmissionType(TileEntity sideTile, TransmissionType type) - { - return checkTransmissionType(sideTile, type, null); - } - - public static boolean checkTransmissionType(TileEntity sideTile, TransmissionType type, TileEntity currentPipe) - { - return type.checkTransmissionType(sideTile, currentPipe); - } - - public boolean checkTransmissionType(TileEntity sideTile, TileEntity currentTile) - { - if(sideTile instanceof ITransmitter) - { - if(((ITransmitter)sideTile).getTransmissionType() == this) - { - return true; - } - } - - if(this == GAS && currentTile instanceof IGasTransmitter) - { - if(((IGasTransmitter)currentTile).canTransferGasToTube(sideTile)) - { - return true; - } - } - - return false; - } -} \ No newline at end of file diff --git a/src/api/java/mekanism/api/transmitters/TransmitterNetworkRegistry.java b/src/api/java/mekanism/api/transmitters/TransmitterNetworkRegistry.java deleted file mode 100644 index f0784f081..000000000 --- a/src/api/java/mekanism/api/transmitters/TransmitterNetworkRegistry.java +++ /dev/null @@ -1,160 +0,0 @@ -package mekanism.api.transmitters; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -import net.minecraft.world.chunk.Chunk; -import net.minecraft.world.chunk.IChunkProvider; -import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.event.world.ChunkEvent; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.TickEvent.Phase; -import cpw.mods.fml.common.gameevent.TickEvent.ServerTickEvent; -import cpw.mods.fml.relauncher.Side; - -public class TransmitterNetworkRegistry -{ - private static TransmitterNetworkRegistry INSTANCE = new TransmitterNetworkRegistry(); - private static boolean loaderRegistered = false; - - private HashSet networks = new HashSet(); - - public static void initiate() - { - if(!loaderRegistered) - { - loaderRegistered = true; - - MinecraftForge.EVENT_BUS.register(new NetworkLoader()); - FMLCommonHandler.instance().bus().register(INSTANCE); - } - } - - public static TransmitterNetworkRegistry getInstance() - { - return INSTANCE; - } - - public void registerNetwork(ITransmitterNetwork network) - { - networks.add(network); - } - - public void removeNetwork(ITransmitterNetwork network) - { - if(networks.contains(network)) - { - networks.remove(network); - } - } - - public void pruneEmptyNetworks() - { - HashSet copySet = new HashSet(networks); - - for(ITransmitterNetwork e : copySet) - { - if(e.getSize() == 0) - { - removeNetwork(e); - } - } - } - - @SubscribeEvent - public void onTick(ServerTickEvent event) - { - if(event.phase == Phase.END && event.side == Side.SERVER) - { - tickEnd(); - } - } - - public void tickEnd() - { - Set iterNetworks = (Set)networks.clone(); - - for(ITransmitterNetwork net : iterNetworks) - { - if(networks.contains(net)) - { - net.tick(); - } - } - } - - @Override - public String toString() - { - return "Network Registry:\n" + networks; - } - - public String[] toStrings() - { - String[] strings = new String[networks.size()]; - int i = 0; - - for(ITransmitterNetwork network : networks) - { - strings[i] = network.toString(); - ++i; - } - - return strings; - } - - public static class NetworkLoader - { - @SubscribeEvent - public void onChunkLoad(ChunkEvent.Load event) - { - if(event.getChunk() != null && !event.world.isRemote) - { - int x = event.getChunk().xPosition; - int z = event.getChunk().zPosition; - - IChunkProvider cProvider = event.getChunk().worldObj.getChunkProvider(); - Chunk[] neighbors = new Chunk[5]; - - neighbors[0] = event.getChunk(); - - if(cProvider.chunkExists(x + 1, z)) neighbors[1] = cProvider.provideChunk(x + 1, z); - if(cProvider.chunkExists(x - 1, z)) neighbors[2] = cProvider.provideChunk(x - 1, z); - if(cProvider.chunkExists(x, z + 1)) neighbors[3] = cProvider.provideChunk(x, z + 1); - if(cProvider.chunkExists(x, z - 1)) neighbors[4] = cProvider.provideChunk(x, z - 1); - - for(Chunk c : neighbors) - { - refreshChunk(c); - } - } - } - - public synchronized void refreshChunk(Chunk c) - { - try { - if(c != null) - { - Map copy = (Map)((HashMap)c.chunkTileEntityMap).clone(); - - for(Iterator iter = copy.values().iterator(); iter.hasNext();) - { - Object obj = iter.next(); - - if(obj instanceof IGridTransmitter) - { - ((IGridTransmitter)obj).refreshTransmitterNetwork(); - ((IGridTransmitter)obj).chunkLoad(); - } - } - } - } catch(Exception e) { - e.printStackTrace(); - } - } - } -} diff --git a/src/api/java/mekanism/common/util/MinerUtils.java b/src/api/java/mekanism/common/util/MinerUtils.java deleted file mode 100644 index c51edadb6..000000000 --- a/src/api/java/mekanism/common/util/MinerUtils.java +++ /dev/null @@ -1,49 +0,0 @@ -package mekanism.common.util; - -import java.util.ArrayList; -import java.util.List; - -import mekanism.api.Coord4D; -import mekanism.api.ListUtils; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -public final class MinerUtils -{ - public static List specialSilkIDs = ListUtils.asList(Blocks.ice); - - public static List getDrops(World world, Coord4D obj, boolean silk) - { - Block block = obj.getBlock(world); - - if(block == null) - { - return new ArrayList(); - } - - if(block.isAir(world, obj.xCoord, obj.yCoord, obj.zCoord)) - { - return new ArrayList(); - } - - int meta = obj.getMetadata(world); - - if(!silk) - { - return block.getDrops(world, obj.xCoord, obj.yCoord, obj.zCoord, meta, 0); - } - else { - List ret = new ArrayList(); - ret.add(new ItemStack(block, 1, meta)); - - if(specialSilkIDs.contains(block) || (block.getDrops(world, obj.xCoord, obj.yCoord, obj.zCoord, meta, 0) != null && block.getDrops(world, obj.xCoord, obj.yCoord, obj.zCoord, meta, 0).size() > 0)) - { - return ret; - } - } - - return new ArrayList(); - } -} diff --git a/src/api/java/mekanism/common/util/PipeUtils.java b/src/api/java/mekanism/common/util/PipeUtils.java deleted file mode 100644 index 38d50b615..000000000 --- a/src/api/java/mekanism/common/util/PipeUtils.java +++ /dev/null @@ -1,114 +0,0 @@ -package mekanism.common.util; - -import java.util.Arrays; - -import mekanism.api.Coord4D; -import mekanism.api.transmitters.IGridTransmitter; -import mekanism.api.transmitters.TransmissionType; -import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; -import net.minecraftforge.fluids.FluidTankInfo; -import net.minecraftforge.fluids.IFluidHandler; - -public final class PipeUtils -{ - public static final FluidTankInfo[] EMPTY = new FluidTankInfo[] {}; - - /** - * Gets all the pipes around a tile entity. - * @param tileEntity - center tile entity - * @return array of TileEntities - */ - public static TileEntity[] getConnectedPipes(TileEntity tileEntity) - { - TileEntity[] pipes = new TileEntity[] {null, null, null, null, null, null}; - - for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) - { - TileEntity pipe = Coord4D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.getWorldObj()); - - if(TransmissionType.checkTransmissionType(pipe, TransmissionType.FLUID)) - { - pipes[orientation.ordinal()] = pipe; - } - } - - return pipes; - } - - /** - * Gets all the adjacent connections to a TileEntity. - * @param tileEntity - center TileEntity - * @return boolean[] of adjacent connections - */ - public static boolean[] getConnections(TileEntity tileEntity) - { - boolean[] connectable = new boolean[] {false, false, false, false, false, false}; - - TileEntity[] connectedPipes = PipeUtils.getConnectedPipes(tileEntity); - IFluidHandler[] connectedAcceptors = PipeUtils.getConnectedAcceptors(tileEntity); - - for(IFluidHandler container : connectedAcceptors) - { - if(container != null) - { - int side = Arrays.asList(connectedAcceptors).indexOf(container); - - FluidTankInfo[] infoArray = container.getTankInfo(ForgeDirection.getOrientation(side).getOpposite()); - - if(infoArray != null && infoArray.length > 0) - { - boolean notNull = false; - - for(FluidTankInfo info : container.getTankInfo(ForgeDirection.getOrientation(side).getOpposite())) - { - if(info != null) - { - notNull = true; - break; - } - } - - if(notNull) - { - connectable[side] = true; - } - } - } - } - - for(TileEntity tile : connectedPipes) - { - if(tile != null) - { - int side = Arrays.asList(connectedPipes).indexOf(tile); - - connectable[side] = true; - } - } - - return connectable; - } - - /** - * Gets all the acceptors around a tile entity. - * @param tileEntity - center tile entity - * @return array of IFluidHandlers - */ - public static IFluidHandler[] getConnectedAcceptors(TileEntity tileEntity) - { - IFluidHandler[] acceptors = new IFluidHandler[] {null, null, null, null, null, null}; - - for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) - { - TileEntity acceptor = Coord4D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.getWorldObj()); - - if(acceptor instanceof IFluidHandler && !(acceptor instanceof IGridTransmitter)) - { - acceptors[orientation.ordinal()] = (IFluidHandler)acceptor; - } - } - - return acceptors; - } -} diff --git a/src/api/java/mekanism/common/util/StackUtils.java b/src/api/java/mekanism/common/util/StackUtils.java deleted file mode 100644 index 9b8e78611..000000000 --- a/src/api/java/mekanism/common/util/StackUtils.java +++ /dev/null @@ -1,149 +0,0 @@ -package mekanism.common.util; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraftforge.oredict.OreDictionary; - -public final class StackUtils -{ - public static List split(ItemStack stack) - { - if(stack == null || stack.stackSize == 0) - { - return null; - } - - List ret = new ArrayList(); - - if(stack.stackSize == 1) - { - ret.add(stack); - return ret; - } - - int remain = stack.stackSize % 2; - int split = (int)((float)(stack.stackSize)/2F); - - ret.add(size(stack, split+remain)); - ret.add(size(stack, split)); - - return ret; - } - - public static Item getItem(ItemStack stack) - { - if(stack == null) - { - return null; - } - - return stack.getItem(); - } - - public static boolean diffIgnoreNull(ItemStack stack1, ItemStack stack2) - { - if(stack1 == null || stack2 == null) - { - return false; - } - - return stack1.getItem() != stack2.getItem() || stack1.getItemDamage() != stack2.getItemDamage(); - } - - public static boolean equalsWildcard(ItemStack wild, ItemStack check) - { - return wild.getItem() == check.getItem() && (wild.getItemDamage() == OreDictionary.WILDCARD_VALUE || wild.getItemDamage() == check.getItemDamage()); - } - - public static List even(ItemStack stack1, ItemStack stack2) - { - ArrayList ret = new ArrayList(); - - if(getSize(stack1) == getSize(stack2) || Math.abs(getSize(stack1)-getSize(stack2)) == 1) - { - ret.add(stack1); - ret.add(stack2); - - return ret; - } - - if(getSize(stack1) > getSize(stack2)) - { - int diff = getSize(stack1)-getSize(stack2); - - List split = split(size(stack1, diff)); - - ret.add(subtract(stack1, split.get(0))); - ret.add(add(stack2, split.get(0))); - } - else if(getSize(stack2) > getSize(stack1)) - { - int diff = getSize(stack2)-getSize(stack1); - - List split = split(size(stack2, diff)); - - ret.add(subtract(stack2, split.get(0))); - ret.add(add(stack1, split.get(0))); - } - - return ret; - } - - public static ItemStack add(ItemStack stack1, ItemStack stack2) - { - if(stack1 == null) - { - return stack2; - } - else if(stack2 == null) - { - return stack1; - } - - return size(stack1, getSize(stack1)+getSize(stack2)); - } - - public static ItemStack subtract(ItemStack stack1, ItemStack stack2) - { - if(stack1 == null) - { - return null; - } - else if(stack2 == null) - { - return stack1; - } - - return size(stack1, getSize(stack1)-getSize(stack2)); - } - - public static ItemStack size(ItemStack stack, int size) - { - if(size <= 0 || stack == null) - { - return null; - } - - ItemStack ret = stack.copy(); - ret.stackSize = size; - return ret; - } - - public static ItemStack copy(ItemStack stack) - { - if(stack == null) - { - return null; - } - - return stack.copy(); - } - - public static int getSize(ItemStack stack) - { - return stack != null ? stack.stackSize : 0; - } -} diff --git a/src/api/java/micdoodle8/mods/galacticraft/api/block/IPartialSealedBlock.java b/src/api/java/micdoodle8/mods/galacticraft/api/block/IPartialSealedBlock.java deleted file mode 100644 index 568dfe926..000000000 --- a/src/api/java/micdoodle8/mods/galacticraft/api/block/IPartialSealedBlock.java +++ /dev/null @@ -1,8 +0,0 @@ -package micdoodle8.mods.galacticraft.api.block; - -import net.minecraft.world.World; - -public interface IPartialSealedBlock -{ - public boolean isSealed(World world, int x, int y, int z); -} diff --git a/src/api/java/mods/immibis/core/api/multipart/ICoverSystem.java b/src/api/java/mods/immibis/core/api/multipart/ICoverSystem.java deleted file mode 100644 index 64191e7d8..000000000 --- a/src/api/java/mods/immibis/core/api/multipart/ICoverSystem.java +++ /dev/null @@ -1,22 +0,0 @@ -package mods.immibis.core.api.multipart; - - -/** - * An object that allows extra parts to be added to multipart tiles. - * For example, you can add covers to InfiniTubes transport conduits - * because they use a MicroblockCoverSystem. - * - * This interface's existence is a bit unintuitive, but it was - */ -public interface ICoverSystem extends IPartContainer { - /** - * Converts the block containing this cover system into - * a block containing only parts from this cover system, - * or to air if the cover system has no parts. - * - * Call it when, for example, all wires in a RedLogic wire block are destroyed, - * to replace it with a microblock container block if there were any microblocks - * in the wire block. - */ - public void convertToContainerBlock(); -} diff --git a/src/api/java/mods/immibis/core/api/multipart/IMultipartTile.java b/src/api/java/mods/immibis/core/api/multipart/IMultipartTile.java deleted file mode 100644 index 4048cf738..000000000 --- a/src/api/java/mods/immibis/core/api/multipart/IMultipartTile.java +++ /dev/null @@ -1,10 +0,0 @@ -package mods.immibis.core.api.multipart; - - -public interface IMultipartTile extends IPartContainer { - /** - * Returns an ICoverSystem object, or null if this tile does not support a cover system - * @see mods.immibis.core.api.multipart.ICoverSystem - */ - public ICoverSystem getCoverSystem(); -} diff --git a/src/api/java/mods/immibis/core/api/multipart/IPartContainer.java b/src/api/java/mods/immibis/core/api/multipart/IPartContainer.java deleted file mode 100644 index 9434b6a3f..000000000 --- a/src/api/java/mods/immibis/core/api/multipart/IPartContainer.java +++ /dev/null @@ -1,90 +0,0 @@ -package mods.immibis.core.api.multipart; - -import java.util.List; - -import net.minecraft.client.renderer.RenderBlocks; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.util.AxisAlignedBB; -import net.minecraft.util.MovingObjectPosition; -import net.minecraft.util.Vec3; -import net.minecraftforge.common.util.ForgeDirection; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -/** - * Contains common methods from ICoverSystem and IMultipartTile. - */ -public interface IPartContainer { - - /** - * Gets the speed at which a player breaks a part. - * See Block.getPlayerRelativeBlockHardness. - * @param ply The player. - * @param The part. - * @return The speed. - */ - float getPlayerRelativePartHardness(EntityPlayer ply, int part); - - /** - * Called when the player middle-clicks on a part. - * @param rayTrace The location under the player's crosshair. - * @param part The part number they middle-clicked on. - * @return The itemstack to pick. - */ - public ItemStack pickPart(MovingObjectPosition rayTrace, int part); - - /** - * Checks if a given face of this block is solid. - * Used to determine the result of Block.isBlockSolidOnSide. - */ - public boolean isSolidOnSide(ForgeDirection side); - - /** - * Renders all the parts. - * @param render The render context. - */ - @SideOnly(Side.CLIENT) - public void render(RenderBlocks render); - - /** - * Renders one part. - * @param render The render context. - * @param part The part number. - */ - @SideOnly(Side.CLIENT) - public void renderPart(RenderBlocks render, int part); - - /** - * Returns all collision boxes that intersect the given mask, in world coordinates. - * @param mask The mask AABB, in world coordinates. - * @param list The list to add the returned boxes to. - */ - public void getCollidingBoundingBoxes(AxisAlignedBB mask, List list); - - /** - * Called when a player finishes breaking a part. - * @param ply The player breaking the part. - * @param subhit The part being broken. - * @return The item stacks dropped, or null if none. - */ - public List removePartByPlayer(EntityPlayer ply, int part); - - /** - * Returns the AABB of a part, in tile-local coordinates. - * Currently used for drawing the selection box. - * May return null, in which case no selection box is drawn. - * - * @param part The part ID to check. - * @return The AABB of the part, or null. - */ - public AxisAlignedBB getPartAABBFromPool(int part); - - /** - * Finds the closest intercept of the given ray with parts in this container. - * @param src The start of the ray, in world coordinates. - * @param dst The end of the ray, in world coordinates. - * @return A ray-trace result, or null if the ray does not intersect any parts. - */ - public MovingObjectPosition collisionRayTrace(Vec3 src, Vec3 dst); -} diff --git a/src/api/java/mods/railcraft/api/crafting/IBlastFurnaceCraftingManager.java b/src/api/java/mods/railcraft/api/crafting/IBlastFurnaceCraftingManager.java deleted file mode 100644 index 1529b45f6..000000000 --- a/src/api/java/mods/railcraft/api/crafting/IBlastFurnaceCraftingManager.java +++ /dev/null @@ -1,29 +0,0 @@ -package mods.railcraft.api.crafting; - -import java.util.List; -import net.minecraft.item.ItemStack; - -/** - * - * @author CovertJaguar - */ -public interface IBlastFurnaceCraftingManager { - - /** - * Adds a new Blast Furnace Recipe. - * - * @param input the input, if null the function will silently abort - * @param matchDamage if true, it will compare item damage, if false, just - * the item ID - * @param matchNBT if true, it will compare nbt - * @param cookTime the time it takes to cook the recipe - * @param output the output - */ - void addRecipe(ItemStack input, boolean matchDamage, boolean matchNBT, int cookTime, ItemStack output); - - List getFuels(); - - IBlastFurnaceRecipe getRecipe(ItemStack stack); - - List getRecipes(); -} diff --git a/src/api/java/mods/railcraft/api/crafting/IBlastFurnaceRecipe.java b/src/api/java/mods/railcraft/api/crafting/IBlastFurnaceRecipe.java deleted file mode 100644 index 4e2aebeb1..000000000 --- a/src/api/java/mods/railcraft/api/crafting/IBlastFurnaceRecipe.java +++ /dev/null @@ -1,21 +0,0 @@ -package mods.railcraft.api.crafting; - -import net.minecraft.item.ItemStack; - -/** - * - * @author CovertJaguar - */ -public interface IBlastFurnaceRecipe -{ - - public int getCookTime(); - - public ItemStack getInput(); - - public ItemStack getOutput(); - - int getOutputStackSize(); - - boolean isRoomForOutput(ItemStack outputSlot); -} diff --git a/src/api/java/mods/railcraft/api/crafting/ICokeOvenCraftingManager.java b/src/api/java/mods/railcraft/api/crafting/ICokeOvenCraftingManager.java deleted file mode 100644 index 65f51885c..000000000 --- a/src/api/java/mods/railcraft/api/crafting/ICokeOvenCraftingManager.java +++ /dev/null @@ -1,18 +0,0 @@ -package mods.railcraft.api.crafting; - -import java.util.List; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; - -/** - * - * @author CovertJaguar - */ -public interface ICokeOvenCraftingManager { - - void addRecipe(ItemStack input, boolean matchDamage, boolean matchNBT, ItemStack output, FluidStack liquidOutput, int cookTime); - - ICokeOvenRecipe getRecipe(ItemStack stack); - - List getRecipes(); -} diff --git a/src/api/java/mods/railcraft/api/crafting/ICokeOvenRecipe.java b/src/api/java/mods/railcraft/api/crafting/ICokeOvenRecipe.java deleted file mode 100644 index 46ea2a4bd..000000000 --- a/src/api/java/mods/railcraft/api/crafting/ICokeOvenRecipe.java +++ /dev/null @@ -1,20 +0,0 @@ -package mods.railcraft.api.crafting; - -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; - -/** - * - * @author CovertJaguar - */ -public interface ICokeOvenRecipe -{ - - public int getCookTime(); - - public ItemStack getInput(); - - public FluidStack getFluidOutput(); - - public ItemStack getOutput(); -} diff --git a/src/api/java/mods/railcraft/api/crafting/IRockCrusherCraftingManager.java b/src/api/java/mods/railcraft/api/crafting/IRockCrusherCraftingManager.java deleted file mode 100644 index 837354c93..000000000 --- a/src/api/java/mods/railcraft/api/crafting/IRockCrusherCraftingManager.java +++ /dev/null @@ -1,17 +0,0 @@ -package mods.railcraft.api.crafting; - -import java.util.List; -import net.minecraft.item.ItemStack; - -/** - * - * @author CovertJaguar - */ -public interface IRockCrusherCraftingManager { - - IRockCrusherRecipe createNewRecipe(ItemStack input, boolean matchDamage, boolean matchNBT); - - IRockCrusherRecipe getRecipe(ItemStack input); - - List getRecipes(); -} diff --git a/src/api/java/mods/railcraft/api/crafting/IRockCrusherRecipe.java b/src/api/java/mods/railcraft/api/crafting/IRockCrusherRecipe.java deleted file mode 100644 index a5799397a..000000000 --- a/src/api/java/mods/railcraft/api/crafting/IRockCrusherRecipe.java +++ /dev/null @@ -1,45 +0,0 @@ -package mods.railcraft.api.crafting; - -import java.util.List; -import java.util.Map; -import net.minecraft.item.ItemStack; - -/** - * - * @author CovertJaguar - */ -public interface IRockCrusherRecipe { - - public ItemStack getInput(); - - /** - * Adds a new entry to the output list. - * - * @param output the stack to output - * @param chance the change to output this stack - */ - void addOutput(ItemStack output, float chance); - - /** - * Returns a list containing each output entry and its chance of being - * included. - * - * @return - */ - public List> getOutputs(); - - /** - * Returns a list of all possible outputs. This is basically a condensed - * version of getOutputs() without the chances. - * - * @return - */ - public List getPossibleOuputs(); - - /** - * Returns a list of outputs after it has passed through the randomizer. - * - * @return - */ - public List getRandomizedOuputs(); -} diff --git a/src/api/java/mods/railcraft/api/crafting/IRollingMachineCraftingManager.java b/src/api/java/mods/railcraft/api/crafting/IRollingMachineCraftingManager.java deleted file mode 100644 index a0d279791..000000000 --- a/src/api/java/mods/railcraft/api/crafting/IRollingMachineCraftingManager.java +++ /dev/null @@ -1,24 +0,0 @@ -package mods.railcraft.api.crafting; - -import java.util.List; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.inventory.InventoryCrafting; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -/** - * - * @author CovertJaguar - */ -public interface IRollingMachineCraftingManager -{ - - void addRecipe(ItemStack output, Object... components); - - void addShapelessRecipe(ItemStack output, Object... compenents); - - ItemStack findMatchingRecipe(InventoryCrafting inventorycrafting, World world); - - List getRecipeList(); - -} diff --git a/src/api/java/mods/railcraft/api/crafting/RailcraftCraftingManager.java b/src/api/java/mods/railcraft/api/crafting/RailcraftCraftingManager.java deleted file mode 100644 index abe8e20d6..000000000 --- a/src/api/java/mods/railcraft/api/crafting/RailcraftCraftingManager.java +++ /dev/null @@ -1,16 +0,0 @@ -package mods.railcraft.api.crafting; - -/** - * These variables are defined during the pre-init phase. - * Do not attempt to access them during pre-init. - * - * @author CovertJaguar - */ -public abstract class RailcraftCraftingManager -{ - - public static ICokeOvenCraftingManager cokeOven; - public static IBlastFurnaceCraftingManager blastFurnace; - public static IRockCrusherCraftingManager rockCrusher; - public static IRollingMachineCraftingManager rollingMachine; -} diff --git a/src/api/java/net/mcft/copy/betterstorage/api/BetterStorageBackpack.java b/src/api/java/net/mcft/copy/betterstorage/api/BetterStorageBackpack.java deleted file mode 100644 index 0a87fb7b8..000000000 --- a/src/api/java/net/mcft/copy/betterstorage/api/BetterStorageBackpack.java +++ /dev/null @@ -1,54 +0,0 @@ -package net.mcft.copy.betterstorage.api; - -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.item.ItemStack; -import cpw.mods.fml.common.FMLLog; -import cpw.mods.fml.common.Loader; - -public final class BetterStorageBackpack { - - private static Method getBackpack = null; - - public static List spawnWithBackpack = new ArrayList(); - - private BetterStorageBackpack() { } - - /** Enables a type of entity to spawn with a backpack with a certain probability.
- * The class has to match exactly, subclasses need to be registered separately.
- * Don't use too high probability, mobs spawning with backpacks should be a rarity. */ - public static void spawnWithBackpack(Class entityClass, double probability) { - spawnWithBackpack.add(new BackpackSpawnEntry(entityClass, probability)); - } - - /** Returns the backpack stack if an entity is carrying one, or null of it doesn't.
- * This can and should be used to check if the entity has a backpack equipped. */ - // Used Thaumcraft's API to see how it did things - I'm unsure what's the best way. - public static ItemStack getBackpack(EntityLivingBase entity) { - if (Loader.isModLoaded("betterstorage")) { - try { - if (getBackpack == null) { - Class itemBackpack = Class.forName("net.mcft.copy.betterstorage.item.ItemBackpack"); - getBackpack = itemBackpack.getMethod("getBackpack", EntityLivingBase.class); - } - return (ItemStack)getBackpack.invoke(null, entity); - } catch (Exception e) { - FMLLog.warning("[betterstorage] Could not invoke net.mcft.copy.betterstorage.item.ItemBackpack.getBackpack."); - } - } - return null; - } - - public static class BackpackSpawnEntry { - public final Class entityClass; - public final double probability; - public BackpackSpawnEntry(Class entityClass, double probability) { - this.entityClass = entityClass; - this.probability = probability; - } - } - -} diff --git a/src/api/java/net/mcft/copy/betterstorage/api/BetterStorageEnchantment.java b/src/api/java/net/mcft/copy/betterstorage/api/BetterStorageEnchantment.java deleted file mode 100644 index a976ee1a9..000000000 --- a/src/api/java/net/mcft/copy/betterstorage/api/BetterStorageEnchantment.java +++ /dev/null @@ -1,38 +0,0 @@ -package net.mcft.copy.betterstorage.api; - -import java.util.HashMap; -import java.util.Map; - -import net.minecraft.enchantment.Enchantment; -import net.minecraft.enchantment.EnchantmentHelper; -import net.minecraft.enchantment.EnumEnchantmentType; -import net.minecraft.item.ItemStack; - -public final class BetterStorageEnchantment { - - public static Map enchantmentTypes = new HashMap(); - public static Map enchantments = new HashMap(); - - private BetterStorageEnchantment() { } - - /** Returns a BetterStorage enchantment type with that name.
- * Types: key, lock */ - public static EnumEnchantmentType getType(String name) { - return enchantmentTypes.get(name); - } - - /** Returns a BetterStorage enchantment with that name.
- * Key: unlocking, lockpicking, morphing.
- * Lock: persistance, security, shock, trigger. */ - public static Enchantment get(String name) { - return enchantments.get(name); - } - - /** Helper method to get the level of that enchantment on the item. */ - public static int getLevel(ItemStack stack, String name) { - Enchantment enchantment = get(name); - if (enchantment == null) return 0; - return EnchantmentHelper.getEnchantmentLevel(enchantment.effectId, stack); - } - -} diff --git a/src/api/java/net/mcft/copy/betterstorage/api/BetterStorageUtils.java b/src/api/java/net/mcft/copy/betterstorage/api/BetterStorageUtils.java deleted file mode 100644 index 53ffc33d4..000000000 --- a/src/api/java/net/mcft/copy/betterstorage/api/BetterStorageUtils.java +++ /dev/null @@ -1,22 +0,0 @@ -package net.mcft.copy.betterstorage.api; - -import net.minecraft.item.ItemStack; - -public final class BetterStorageUtils -{ - - private BetterStorageUtils() { - } - - /** - * Returns if the stack matches the match stack. Stack size is ignored.
- * If the match stack damage is WILDCARD_VALUE, it will match any damage.
- * If the match stack doesn't have an NBT compound, it will match any NBT data.
- * (If the match stack has an empty NBT compound it'll only match stacks without NBT data.) - */ - public static boolean wildcardMatch(ItemStack match, ItemStack stack) - { - return false; - } - -} diff --git a/src/api/java/net/mcft/copy/betterstorage/api/IContainerItem.java b/src/api/java/net/mcft/copy/betterstorage/api/IContainerItem.java deleted file mode 100644 index aa92ad61f..000000000 --- a/src/api/java/net/mcft/copy/betterstorage/api/IContainerItem.java +++ /dev/null @@ -1,17 +0,0 @@ -package net.mcft.copy.betterstorage.api; - -import net.minecraft.item.ItemStack; - -/** When implemented for an Item, signalizes that it can store or - * is storing other items. This is useful for other container items to - * keep themselves from accepting them, resulting in infinite storage. */ -public interface IContainerItem { - - /** Returns the contents of this container item.
- * May return null if not supported. */ - public ItemStack[] getContainerItemContents(ItemStack container); - - /** Returns if this item can be stored in another container item. */ - public boolean canBeStoredInContainerItem(ItemStack item); - -} diff --git a/src/api/java/net/mcft/copy/betterstorage/api/crafting/BetterStorageCrafting.java b/src/api/java/net/mcft/copy/betterstorage/api/crafting/BetterStorageCrafting.java deleted file mode 100644 index 413f2caa0..000000000 --- a/src/api/java/net/mcft/copy/betterstorage/api/crafting/BetterStorageCrafting.java +++ /dev/null @@ -1,44 +0,0 @@ -package net.mcft.copy.betterstorage.api.crafting; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.block.Block; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -public final class BetterStorageCrafting { - - public static final List recipes = new ArrayList(); - - private BetterStorageCrafting() { } - - /** Adds a station recipe to the recipe list. */ - public static void addStationRecipe(IStationRecipe recipe) { recipes.add(recipe); } - - /** Creates and returns a crafting matching the input, or null if none was found. */ - public static StationCrafting findMatchingStationCrafting(ItemStack[] input) { - RecipeBounds bounds = new RecipeBounds(input); - for (IStationRecipe recipe : recipes) { - StationCrafting crafting = recipe.checkMatch(input, bounds); - if (crafting != null) return crafting; - } - return null; - } - - // Utility functions - - /** Returns an IRecipeInput from the object.
- * Can be an IRecipeInput, ItemStack, Item, Block or ore dictionary String. */ - public static IRecipeInput makeInput(Object obj) { - if (obj instanceof IRecipeInput) return (IRecipeInput)obj; - else if (obj instanceof ItemStack) return new RecipeInputItemStack((ItemStack)obj); - else if (obj instanceof Item) return new RecipeInputItemStack(new ItemStack((Item)obj)); - else if (obj instanceof Block) return new RecipeInputItemStack(new ItemStack((Block)obj)); - else if (obj instanceof String) return new RecipeInputOreDict((String)obj, 1); - else throw new IllegalArgumentException( - String.format("Argument is %s, not an IRecipeInput, ItemStack, Item, Block or String.", - ((obj != null) ? obj.getClass().getSimpleName() : "null"))); - } - -} diff --git a/src/api/java/net/mcft/copy/betterstorage/api/crafting/ContainerInfo.java b/src/api/java/net/mcft/copy/betterstorage/api/crafting/ContainerInfo.java deleted file mode 100644 index 46651d088..000000000 --- a/src/api/java/net/mcft/copy/betterstorage/api/crafting/ContainerInfo.java +++ /dev/null @@ -1,18 +0,0 @@ -package net.mcft.copy.betterstorage.api.crafting; - -import net.minecraft.item.ItemStack; - -public class ContainerInfo { - - private ItemStack containerItem = null; - private boolean doesLeaveCrafting = true; - - public ItemStack getContainerItem() { return containerItem; } - public boolean doesLeaveCrafting() { return doesLeaveCrafting; } - - public void set(ItemStack containerItem, boolean doesLeaveCrafting) { - this.containerItem = containerItem; - this.doesLeaveCrafting = doesLeaveCrafting; - } - -} diff --git a/src/api/java/net/mcft/copy/betterstorage/api/crafting/CraftingSourceTileEntity.java b/src/api/java/net/mcft/copy/betterstorage/api/crafting/CraftingSourceTileEntity.java deleted file mode 100644 index 6fb0b5aa6..000000000 --- a/src/api/java/net/mcft/copy/betterstorage/api/crafting/CraftingSourceTileEntity.java +++ /dev/null @@ -1,32 +0,0 @@ -package net.mcft.copy.betterstorage.api.crafting; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - -public class CraftingSourceTileEntity implements ICraftingSource { - - public final TileEntity entity; - public final EntityPlayer player; - public final World world; - - public CraftingSourceTileEntity(TileEntity entity, EntityPlayer player) { - this.entity = entity; - this.player = player; - this.world = ((entity != null) ? entity.getWorldObj() : ((player != null) ? player.worldObj : null)); - } - - @Override - public EntityPlayer getPlayer() { return player; } - - @Override - public World getWorld() { return world; } - - @Override - public double getX() { return ((entity != null) ? (entity.xCoord + 0.5) : 0); } - @Override - public double getY() { return ((entity != null) ? (entity.yCoord + 0.5) : 0); } - @Override - public double getZ() { return ((entity != null) ? (entity.zCoord + 0.5) : 0); } - -} diff --git a/src/api/java/net/mcft/copy/betterstorage/api/crafting/ICraftingSource.java b/src/api/java/net/mcft/copy/betterstorage/api/crafting/ICraftingSource.java deleted file mode 100644 index 9c7395ed3..000000000 --- a/src/api/java/net/mcft/copy/betterstorage/api/crafting/ICraftingSource.java +++ /dev/null @@ -1,18 +0,0 @@ -package net.mcft.copy.betterstorage.api.crafting; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.world.World; - -public interface ICraftingSource { - - /** Returns the player currently crafting, null if none. */ - EntityPlayer getPlayer(); - - /** Returns the world the recipe is being crafted in. */ - World getWorld(); - - double getX(); - double getY(); - double getZ(); - -} diff --git a/src/api/java/net/mcft/copy/betterstorage/api/crafting/IRecipeInput.java b/src/api/java/net/mcft/copy/betterstorage/api/crafting/IRecipeInput.java deleted file mode 100644 index 170dff5bc..000000000 --- a/src/api/java/net/mcft/copy/betterstorage/api/crafting/IRecipeInput.java +++ /dev/null @@ -1,29 +0,0 @@ -package net.mcft.copy.betterstorage.api.crafting; - -import java.util.List; - -import net.minecraft.item.ItemStack; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -public interface IRecipeInput { - - /** Returns the amount needed to craft. */ - int getAmount(); - - /** Returns if the stack matches the input, ignores stack size. */ - boolean matches(ItemStack stack); - - /** Called when a recipe is crafted, allows modification (decrease stack size, damage item) - * of the input stack. Empty stacks and damageable items with no durability left are removed - * automatically. */ - void craft(ItemStack input, ContainerInfo containerInfo); - - // NEI related functions - - /** Returns a list of possible item stacks that will match this input. - * Used to display and cycle items for the NEI addon. */ - @SideOnly(Side.CLIENT) - List getPossibleMatches(); - -} diff --git a/src/api/java/net/mcft/copy/betterstorage/api/crafting/IStationRecipe.java b/src/api/java/net/mcft/copy/betterstorage/api/crafting/IStationRecipe.java deleted file mode 100644 index 7c41006bb..000000000 --- a/src/api/java/net/mcft/copy/betterstorage/api/crafting/IStationRecipe.java +++ /dev/null @@ -1,35 +0,0 @@ -package net.mcft.copy.betterstorage.api.crafting; - -import java.util.List; - -import net.minecraft.item.ItemStack; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -public interface IStationRecipe { - - /** If the input matches this recipe, returns a new station crafting - * instance, specific for this input, or null if it didn't match. */ - StationCrafting checkMatch(ItemStack[] input, RecipeBounds bounds); - - // NEI related functions - - /** Returns a list of sample inputs that will match the recipe. - * Used to display and cycle recipes for the NEI addon. - * Return null if the recipe should not be displayed in NEI. */ - @SideOnly(Side.CLIENT) - List getSampleInputs(); - - /** Returns a list of input items that may be used in this recipe. - * Used to show recipes using these inputs for the NEI addon. - * Return null if the inputs should be grabbed from getSampleInputs. */ - @SideOnly(Side.CLIENT) - List getPossibleInputs(); - - /** Returns a list of output items that can result from this recipe. - * Used to show recipes matching these outputs for the NEI addon. - * Return null if the output made from getSampleInputs should be used. */ - @SideOnly(Side.CLIENT) - List getPossibleOutputs(); - -} diff --git a/src/api/java/net/mcft/copy/betterstorage/api/crafting/RecipeBounds.java b/src/api/java/net/mcft/copy/betterstorage/api/crafting/RecipeBounds.java deleted file mode 100644 index 2b1c00eff..000000000 --- a/src/api/java/net/mcft/copy/betterstorage/api/crafting/RecipeBounds.java +++ /dev/null @@ -1,35 +0,0 @@ -package net.mcft.copy.betterstorage.api.crafting; - -import net.minecraft.item.ItemStack; - -public class RecipeBounds { - - public final int minX, maxX, minY, maxY; - - public int getWidth() { return (maxX - minX + 1); } - public int getHeight() { return (maxY - minY + 1); } - - public RecipeBounds(int minX, int maxX, int minY, int maxY) { - this.minX = minX; this.maxX = maxX; - this.minY = minY; this.maxY = maxY; - } - public RecipeBounds(ItemStack[] input) { - int minX = 2, maxX = -1; - int minY = 2, maxY = -1; - for (int x = 0; x <= 2; x++) - for (int y = 0; y <= 2; y++) - if (input[x + y * 3] != null) { - minX = Math.min(minX, x); - maxX = Math.max(maxX, x); - minY = Math.min(minY, y); - maxY = Math.max(maxY, y); - } - if ((minX <= maxX) && (minY <= maxY)) { - this.minX = minX; - this.minY = minY; - } else this.minX = this.minY = 0; - this.maxX = maxX; - this.maxY = maxY; - } - -} diff --git a/src/api/java/net/mcft/copy/betterstorage/api/crafting/RecipeInputBase.java b/src/api/java/net/mcft/copy/betterstorage/api/crafting/RecipeInputBase.java deleted file mode 100644 index ec9992426..000000000 --- a/src/api/java/net/mcft/copy/betterstorage/api/crafting/RecipeInputBase.java +++ /dev/null @@ -1,26 +0,0 @@ -package net.mcft.copy.betterstorage.api.crafting; - -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -public abstract class RecipeInputBase implements IRecipeInput { - - @Override - public abstract int getAmount(); - - @Override - public abstract boolean matches(ItemStack stack); - - @Override - public void craft(ItemStack input, ContainerInfo containerInfo) { - if (input == null) return; - - Item item = input.getItem(); - ItemStack containerItem = item.getContainerItem(input.copy()); - boolean doesLeaveCrafting = item.doesContainerItemLeaveCraftingGrid(input); - containerInfo.set(containerItem, doesLeaveCrafting); - - input.stackSize -= getAmount(); - } - -} diff --git a/src/api/java/net/mcft/copy/betterstorage/api/crafting/RecipeInputItemStack.java b/src/api/java/net/mcft/copy/betterstorage/api/crafting/RecipeInputItemStack.java deleted file mode 100644 index 893b7fde7..000000000 --- a/src/api/java/net/mcft/copy/betterstorage/api/crafting/RecipeInputItemStack.java +++ /dev/null @@ -1,49 +0,0 @@ -package net.mcft.copy.betterstorage.api.crafting; - -import java.util.Arrays; -import java.util.List; - -import net.mcft.copy.betterstorage.api.BetterStorageUtils; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraftforge.oredict.OreDictionary; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -public class RecipeInputItemStack extends RecipeInputBase { - - public final ItemStack stack; - - public RecipeInputItemStack(ItemStack stack) { - this.stack = stack; - } - public RecipeInputItemStack(ItemStack stack, boolean nbtSensitive) { - this(stack); - // If input is NBT sensitive, make sure it has an NBT compound. - // Empty means it only matches items with no NBT data. - if (nbtSensitive) { - if (!stack.hasTagCompound()) - stack.setTagCompound(new NBTTagCompound()); - // Otherwise, always remove the NBT compound, - // because then it will match any item. - } else if (stack.hasTagCompound()) - stack.setTagCompound(null); - } - - @Override - public int getAmount() { return stack.stackSize; } - - @Override - public boolean matches(ItemStack stack) { return BetterStorageUtils.wildcardMatch(this.stack, stack); } - - private List list = null; - @Override - @SideOnly(Side.CLIENT) - public List getPossibleMatches() { - ItemStack stack = this.stack.copy(); - if (stack.getItemDamage() == OreDictionary.WILDCARD_VALUE) - stack.setItemDamage(0); - return Arrays.asList(stack); - } - -} diff --git a/src/api/java/net/mcft/copy/betterstorage/api/crafting/RecipeInputOreDict.java b/src/api/java/net/mcft/copy/betterstorage/api/crafting/RecipeInputOreDict.java deleted file mode 100644 index 7cabf9f51..000000000 --- a/src/api/java/net/mcft/copy/betterstorage/api/crafting/RecipeInputOreDict.java +++ /dev/null @@ -1,37 +0,0 @@ -package net.mcft.copy.betterstorage.api.crafting; - -import java.util.List; - -import net.mcft.copy.betterstorage.api.BetterStorageUtils; -import net.minecraft.item.ItemStack; -import net.minecraftforge.oredict.OreDictionary; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -public class RecipeInputOreDict extends RecipeInputBase { - - public final String name; - private final int amount; - - public RecipeInputOreDict(String name, int amount) { - this.name = name; - this.amount = amount; - } - - @Override - public int getAmount() { return amount; } - - @Override - public boolean matches(ItemStack stack) { - for (ItemStack oreStack : OreDictionary.getOres(name)) - if (BetterStorageUtils.wildcardMatch(oreStack, stack)) return true; - return false; - } - - @Override - @SideOnly(Side.CLIENT) - public List getPossibleMatches() { - return OreDictionary.getOres(name); - } - -} diff --git a/src/api/java/net/mcft/copy/betterstorage/api/crafting/ShapedStationRecipe.java b/src/api/java/net/mcft/copy/betterstorage/api/crafting/ShapedStationRecipe.java deleted file mode 100644 index 33bb63858..000000000 --- a/src/api/java/net/mcft/copy/betterstorage/api/crafting/ShapedStationRecipe.java +++ /dev/null @@ -1,169 +0,0 @@ -package net.mcft.copy.betterstorage.api.crafting; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import net.minecraft.item.ItemStack; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -public class ShapedStationRecipe implements IStationRecipe { - - public final IRecipeInput[] recipeInput; - public final ItemStack[] recipeOutput; - public final int recipeWidth; - public final int recipeHeight; - - public int requiredExperience = 0; - public int craftingTime = 0; - - public ShapedStationRecipe(IRecipeInput[] input, int width, int height, ItemStack[] output) { - recipeInput = input; - recipeOutput = output; - recipeWidth = width; - recipeHeight = height; - } - - public ShapedStationRecipe(ItemStack[] output, Object... input) { - int width = 0; - int height = 0; - - int inputIndex = 0; - Map inputMap = new HashMap(); - - while ((inputIndex < input.length) && (input[inputIndex] instanceof String)) { - String line = (String)input[inputIndex++]; - if (line.isEmpty()) - throw new IllegalArgumentException("Empty string isn't valid."); - if (width <= 0) width = line.length(); - else if (width != line.length()) - throw new IllegalArgumentException("All strings must have the same length."); - for (char chr : line.toCharArray()) - inputMap.put(chr, null); - height++; - } - if (height <= 0) - throw new IllegalArgumentException("At least one string must be supplied."); - - if (inputIndex >= input.length) - throw new IllegalArgumentException("At least one mapping must be supplied."); - if ((input.length - inputIndex) % 2 > 0) - throw new IllegalArgumentException("Mappings have to be in pairs of two."); - - for (; inputIndex < input.length; inputIndex += 2) { - if (!(input[inputIndex] instanceof Character)) - throw new IllegalArgumentException("First argument of a mapping needs to be a character."); - char chr = (Character)input[inputIndex]; - if (!inputMap.containsKey(chr)) - throw new IllegalArgumentException("Mapping for unused character '" + chr + "'."); - if (inputMap.get(chr) != null) - throw new IllegalArgumentException("Duplicate mapping for character '" + chr + "'."); - IRecipeInput mapping = BetterStorageCrafting.makeInput(input[inputIndex + 1]); - inputMap.put(chr, mapping); - } - - for (Entry entry : inputMap.entrySet()) - if ((entry.getKey() != ' ') && (entry.getValue() == null)) - throw new IllegalArgumentException("No mapping for character '" + entry.getKey() + "'."); - - recipeInput = new IRecipeInput[width * height]; - recipeOutput = output; - - for (int x = 0; x < width; x++) - for (int y = 0; y < height; y++) - recipeInput[x + y * width] = inputMap.get(((String)input[y]).charAt(x)); - - recipeWidth = width; - recipeHeight = height; - } - public ShapedStationRecipe(ItemStack output, Object... input) { - this(new ItemStack[]{ null, null, null, null, output }, input); - } - - public ShapedStationRecipe setRequiredExperience(int experience) { - requiredExperience = experience; - return this; - } - public ShapedStationRecipe setCraftingTime(int time) { - craftingTime = time; - return this; - } - - @Override - @SideOnly(Side.CLIENT) - public List getSampleInputs() { - IRecipeInput[] input; - if ((recipeWidth != 3) || (recipeHeight != 3)) { - input = new IRecipeInput[9]; - for (int y = 0; y < recipeHeight; y++) - System.arraycopy(recipeInput, y * recipeWidth, input, y * 3, recipeWidth); - } else input = recipeInput; - return Arrays.asList(new IRecipeInput[][]{ input }); - } - - @Override - @SideOnly(Side.CLIENT) - public List getPossibleInputs() { return null; } - - @Override - @SideOnly(Side.CLIENT) - public List getPossibleOutputs() { return null; } - - // IStationRecipe implementation - - @Override - public StationCrafting checkMatch(ItemStack[] input, RecipeBounds bounds) { - // Check if boundaries match recipe size. - if ((recipeWidth != bounds.getWidth()) || - (recipeHeight != bounds.getHeight())) return null; - - IRecipeInput[] requiredInput = new IRecipeInput[9]; - for (int y = 0; y < recipeHeight; y++) { - System.arraycopy(recipeInput, y * recipeWidth, requiredInput, - bounds.minX + (bounds.minY + y) * 3, recipeWidth); - for (int x = 0; x < recipeWidth; x++) { - int adjustedIndex = (bounds.minX + x) + (bounds.minY + y) * 3; - IRecipeInput recipeStack = recipeInput[x + y * recipeWidth]; - ItemStack inputStack = input[adjustedIndex]; - if ((recipeStack == null) ? (inputStack != null) - : (!recipeStack.matches(inputStack) || - (inputStack.stackSize < recipeStack.getAmount()))) - return null; - } - } - return new StationCrafting(recipeOutput, requiredInput, requiredExperience, craftingTime); - } - - // Utility functions - - /** Returns the bounds of the input items: - * An array with minX, minY, width and height. */ - public static int[] calculateRecipeBounds(ItemStack[] input) { - int minX = 0, maxX = 2, minY = 0, maxY = 2; - - for (int x = minX; x <= maxX; x++) - for (int y = minY; y <= maxY; y++) - if (input[x + y * 3] != null) { minX = x; break; } - - for (int x = maxX; x >= minX; x--) - for (int y = minY; y <= maxY; y++) - if (input[x + y * 3] != null) { maxX = x; break; } - - for (int y = minY; y <= maxY; y++) - for (int x = minX; x <= maxX; x++) - if (input[x + y * 3] != null) { minY = y; break; } - - for (int y = maxY; y >= minY; y--) - for (int x = minX; x <= maxX; x++) - if (input[x + y * 3] != null) { maxY = y; break; } - - int width = (maxX - minX + 1); - int height = (maxY - minY + 1); - - return new int[]{ minX, minY, width, height }; - } - -} diff --git a/src/api/java/net/mcft/copy/betterstorage/api/crafting/ShapelessStationRecipe.java b/src/api/java/net/mcft/copy/betterstorage/api/crafting/ShapelessStationRecipe.java deleted file mode 100644 index 43398f9b6..000000000 --- a/src/api/java/net/mcft/copy/betterstorage/api/crafting/ShapelessStationRecipe.java +++ /dev/null @@ -1,82 +0,0 @@ -package net.mcft.copy.betterstorage.api.crafting; - -import java.util.Arrays; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; - -import net.minecraft.item.ItemStack; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -public class ShapelessStationRecipe implements IStationRecipe { - - public final IRecipeInput[] recipeInput; - public final ItemStack[] recipeOutput; - - public int requiredExperience = 0; - public int craftingTime = 0; - - public ShapelessStationRecipe(IRecipeInput[] input, ItemStack[] output) { - recipeInput = input; - recipeOutput = output; - } - - public ShapelessStationRecipe(ItemStack[] output, Object... input) { - recipeInput = new IRecipeInput[input.length]; - recipeOutput = output; - for (int i = 0; i < input.length; i++) - recipeInput[i] = BetterStorageCrafting.makeInput(input[i]); - } - public ShapelessStationRecipe(ItemStack output, Object... input) { - this(new ItemStack[]{ null, null, null, null, output }, input); - } - - public ShapelessStationRecipe setRequiredExperience(int experience) { - requiredExperience = experience; - return this; - } - public ShapelessStationRecipe setCraftingTime(int time) { - craftingTime = time; - return this; - } - - @Override - @SideOnly(Side.CLIENT) - public List getSampleInputs() { - IRecipeInput[] input = new IRecipeInput[9]; - System.arraycopy(recipeInput, 0, input, 0, recipeInput.length); - return Arrays.asList(new IRecipeInput[][]{ input }); - } - - @Override - @SideOnly(Side.CLIENT) - public List getPossibleInputs() { return null; } - - @Override - @SideOnly(Side.CLIENT) - public List getPossibleOutputs() { return null; } - - // IStationRecipe implementation - - @Override - public StationCrafting checkMatch(ItemStack[] input, RecipeBounds bounds) { - IRecipeInput[] requiredInput = new IRecipeInput[9]; - List checklist = new LinkedList(Arrays.asList(recipeInput)); - inputLoop: - for (int i = 0; i < input.length; i++) { - ItemStack item = input[i]; - if (item == null) continue; - Iterator iter = checklist.iterator(); - while (iter.hasNext()) - if ((requiredInput[i] = iter.next()).matches(item)) { - iter.remove(); - continue inputLoop; - } - return null; - } - if (!checklist.isEmpty()) return null; - return new StationCrafting(recipeOutput, requiredInput, requiredExperience, craftingTime); - } - -} diff --git a/src/api/java/net/mcft/copy/betterstorage/api/crafting/StationCrafting.java b/src/api/java/net/mcft/copy/betterstorage/api/crafting/StationCrafting.java deleted file mode 100644 index f53acd905..000000000 --- a/src/api/java/net/mcft/copy/betterstorage/api/crafting/StationCrafting.java +++ /dev/null @@ -1,55 +0,0 @@ -package net.mcft.copy.betterstorage.api.crafting; - -import net.minecraft.item.ItemStack; - -/** Represents a particular crafting instance for a recipe from a specific input. - * Only calculate the output, experience cost, crafting time and craft requirements once. */ -public class StationCrafting { - - protected final ItemStack[] output; - protected final IRecipeInput[] requiredInput; - - protected int requiredExperience; - protected int craftingTime; - - public StationCrafting(ItemStack[] output, IRecipeInput[] requiredInput, - int requiredExperience, int craftingTime) { - this.output = output; - this.requiredInput = requiredInput; - this.requiredExperience = requiredExperience; - this.craftingTime = craftingTime; - } - public StationCrafting(ItemStack[] output, IRecipeInput[] requiredInput, int requiredExperience) { - this(output, requiredInput, requiredExperience, 0); - } - public StationCrafting(ItemStack[] output, IRecipeInput[] requiredInput) { - this(output, requiredInput, 0, 0); - } - - /** Returns the crafting output. */ - public ItemStack[] getOutput() { return output; } - - /** Returns the amount of experience required. */ - public int getRequiredExperience() { return requiredExperience; } - - /** Returns the time (in game ticks) needed to craft this recipe.
- * Return 0 for the recipe to be instantly available. - * Keep within 0 to 32000 ticks. */ - public int getCraftingTime() { return craftingTime; } - - /** Returns if the recipe can be crafted. Experience is checked automatically. - * @param source Contains information of where this recipe is crafted and who crafts it. */ - public boolean canCraft(ICraftingSource source) { return true; } - - /** Returns the requirements for crafting this recipe again. - * Called after {@link #canCraft} and before {@link #craft}.
- * After crafting, the crafting grid is filled with items from the - * crafting station's internal storage that match the requirements. - * @param requiredInput The items needed to craft this recipe again. */ - public IRecipeInput[] getCraftRequirements() { return requiredInput; } - - /** Called after the recipe is successfully crafted. Experience is removed automatically. - * @param source contains information of where this recipe was crafted and who crafted it. */ - public void craft(ICraftingSource source) { } - -} diff --git a/src/api/java/net/mcft/copy/betterstorage/api/crate/ICrateStorage.java b/src/api/java/net/mcft/copy/betterstorage/api/crate/ICrateStorage.java deleted file mode 100644 index dbf817f2e..000000000 --- a/src/api/java/net/mcft/copy/betterstorage/api/crate/ICrateStorage.java +++ /dev/null @@ -1,87 +0,0 @@ -package net.mcft.copy.betterstorage.api.crate; - -import net.minecraft.item.ItemStack; - -public interface ICrateStorage { - - // The "identifier" item stacks are used to look up specific - // types of items within the crate. Item type, damage and NBT - // data are used to identify items, so they have to match. - - // You can see which exact items are stored within the crate - // using the getContents() and getRandomStacks() methods and - // use the stacks returned to extract these items. Do not - // modify stacks returned by these methods. - - // Storage crates are supposed to be random and less efficient, - // as a downside to their ability to expand and store lots of - // items. Therefore, where possible / it makes sense, it's - // recommended to use getRandomStacks(). Look at a few items - // every tick (or a different interval) and give up if none - // matched the requirements. This encourages players to keep - // the number of different items within a crate low. - - // If this is not possible, it's recommended to balance things - // by for example increasing resource or energy cost, perhaps - // depending on the number of unique items. - - - /** Returns the crate's identifier. If it's the same as another - * crate's identifier, they're part of the same crate pile and - * therefore share the same inventory. */ - public Object getCrateIdentifier(); - - - /** Returns the number of slots in this crate pile. */ - public int getCapacity(); - - /** Returns the number of slots that are occupied by items. This is - * also the number of stacks that will be returned by getRandomStacks(). */ - public int getOccupiedSlots(); - - // You can calculate the number of free slots by subtracting the - // capacity by the number of occupied slots. Note that even if this - // is 0, there might still be space for items in occupied slots. - - /** Returns the number of different unique items. This is also - * the number of items that will be returned by getContents(). */ - public int getUniqueItems(); - - - /** Returns all items in the crate pile. The stacks may have - * stack sizes above their usual limit. */ - public Iterable getContents(); - - /** Returns a randomized stream of stacks from the crate pile. This - * works best if used to look at a few items. If the intention is to - * look at the whole inventory, getContents() should be used instead. */ - public Iterable getRandomStacks(); - - - /** Returns the number of items of this specific type. */ - public int getItemCount(ItemStack identifier); - - /** Returns the space left for items of this specific type. */ - public int getSpaceForItem(ItemStack identifier); - - - /** Tries to insert an item stack into the crate. Returns null - * if all items were inserted successfully, or an item stack - * of whatever items could not be inserted. - * The stack may have a stack size above its usual limit. */ - public ItemStack insertItems(ItemStack stack); - - /** Tries to extract the specified type and amount of items. - * Returns null if no items could be extracted, or an item - * stack if some, or all of them could be extracted successfully. */ - public ItemStack extractItems(ItemStack identifier, int amount); - - - /** Registers a crate watcher. Its onCrateItemsModified method - * will be called when any items are changed. */ - public void registerCrateWatcher(ICrateWatcher watcher); - - /** Unregisters a crate watcher. */ - public void unregisterCrateWatcher(ICrateWatcher watcher); - -} diff --git a/src/api/java/net/mcft/copy/betterstorage/api/crate/ICrateWatcher.java b/src/api/java/net/mcft/copy/betterstorage/api/crate/ICrateWatcher.java deleted file mode 100644 index 0b389c6c6..000000000 --- a/src/api/java/net/mcft/copy/betterstorage/api/crate/ICrateWatcher.java +++ /dev/null @@ -1,13 +0,0 @@ -package net.mcft.copy.betterstorage.api.crate; - -import net.minecraft.item.ItemStack; - -public interface ICrateWatcher { - - /** Called when any items in the crate storage get - * changed. The stack will represent which items were - * added or removed. Stack size is negative if items - * were removed. */ - public void onCrateItemsModified(ItemStack stack); - -} diff --git a/src/api/java/net/mcft/copy/betterstorage/api/lock/EnumLockInteraction.java b/src/api/java/net/mcft/copy/betterstorage/api/lock/EnumLockInteraction.java deleted file mode 100644 index e0ce67bb9..000000000 --- a/src/api/java/net/mcft/copy/betterstorage/api/lock/EnumLockInteraction.java +++ /dev/null @@ -1,9 +0,0 @@ -package net.mcft.copy.betterstorage.api.lock; - -public enum EnumLockInteraction { - - OPEN, - PICK, - ATTACK - -} diff --git a/src/api/java/net/mcft/copy/betterstorage/api/lock/IKey.java b/src/api/java/net/mcft/copy/betterstorage/api/lock/IKey.java deleted file mode 100644 index fa730852a..000000000 --- a/src/api/java/net/mcft/copy/betterstorage/api/lock/IKey.java +++ /dev/null @@ -1,19 +0,0 @@ -package net.mcft.copy.betterstorage.api.lock; - -import net.minecraft.enchantment.Enchantment; -import net.minecraft.item.ItemStack; - -public interface IKey { - - /** Returns if the key is a normal key, instead of a - * special item which has some key-like features. */ - public boolean isNormalKey(); - - /** Gets called when a key is used to open a lock and returns if it's successful.
- * If useAbility is true, the key will use up an ability, like lockpicking or morphing. */ - public boolean unlock(ItemStack key, ItemStack lock, boolean useAbility); - - /** Returns if the key can be enchanted with this key enchantment. */ - public boolean canApplyEnchantment(ItemStack key, Enchantment enchantment); - -} diff --git a/src/api/java/net/mcft/copy/betterstorage/api/lock/ILock.java b/src/api/java/net/mcft/copy/betterstorage/api/lock/ILock.java deleted file mode 100644 index 1ba9026fd..000000000 --- a/src/api/java/net/mcft/copy/betterstorage/api/lock/ILock.java +++ /dev/null @@ -1,24 +0,0 @@ -package net.mcft.copy.betterstorage.api.lock; - -import net.minecraft.enchantment.Enchantment; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; - -public interface ILock { - - /** Returns a string describing the lock's type or how it functions.
- * Currently there is only "normal" locks, which work with damage. */ - public String getLockType(); - - /** Gets called after a player tries to open a lock, successfully or not. */ - public void onUnlock(ItemStack lock, ItemStack key, ILockable lockable, - EntityPlayer player, boolean success); - - /** Applies any effects from the lock when an interaction fails. */ - public void applyEffects(ItemStack lock, ILockable lockable, - EntityPlayer player, EnumLockInteraction interaction); - - /** Returns if the lock can be enchanted with this lock enchantment. */ - public boolean canApplyEnchantment(ItemStack lock, Enchantment enchantment); - -} diff --git a/src/api/java/net/mcft/copy/betterstorage/api/lock/ILockable.java b/src/api/java/net/mcft/copy/betterstorage/api/lock/ILockable.java deleted file mode 100644 index 2b4386543..000000000 --- a/src/api/java/net/mcft/copy/betterstorage/api/lock/ILockable.java +++ /dev/null @@ -1,29 +0,0 @@ -package net.mcft.copy.betterstorage.api.lock; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; - -public interface ILockable { - - /** Returns the lock of this container, or null if there is none. */ - public ItemStack getLock(); - - /** Returns if this container can be locked with this lock. */ - public boolean isLockValid(ItemStack lock); - - /** Sets the lock of this container.
- * Has no effect if canSetLock() returns false. */ - public void setLock(ItemStack lock); - - /** Returns if this container can be used by the player without using a key, - * for example, while the container is being held open by another player. */ - public boolean canUse(EntityPlayer player); - - /** Called when a lock gets unlocked by a key and the container - * should be used/opened by the player as if it wasn't locked. */ - public void useUnlocked(EntityPlayer player); - - /** Makes the container emit a redstone signal for 10 ticks. */ - public void applyTrigger(); - -} diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/FactoryRegistry.java b/src/api/java/powercrystals/minefactoryreloaded/api/FactoryRegistry.java deleted file mode 100644 index d6c37d45a..000000000 --- a/src/api/java/powercrystals/minefactoryreloaded/api/FactoryRegistry.java +++ /dev/null @@ -1,113 +0,0 @@ -package powercrystals.minefactoryreloaded.api; - -import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.event.FMLInterModComms; -import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; - -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; - -/** - * @author PowerCrystals - * - * Class used to register plants and other farming-related things with MFR. Will do nothing if MFR does not exist. - * - */ -public class FactoryRegistry -{ - /* - * This may be called at any time during pre-init, init or post-init, assuming all blocks and items - * that are being accessed from the registry have been appropriately registered. - * Possible messages: - * - * // Registration: - * addLaserPreferredOre | NBTTag with an ItemStack saved on it, with the color on the "value" attribute, - * | A ValuedItem with item and value set. - * registerAutoSpawnerBlacklist | The String identifier of an entity, - * | A subclass of EntityLivingBase. - * registerFertilizable | An instance of IFactoryFertilizable. - * registerFertilizer | An instance of IFactoryFertilizer. - * registerFruitLog | The String identifier of a block. - * registerGrindable | An instance of IFactoryGrindable. - * registerGrinderBlacklist | A subclass of EntityLivingBase. - * registerHarvestable | An instance of IFactoryHarvestable. - * registerLaserOre | NBTTag with an ItemStack saved on it, with the weight on the "value" attribute, - * | A ValuedItem with item and value set. - * registerLiquidDrinkHandler | A ValuedItem with key and object set; ILiquidDrinkHandler expected. - * registerMobEggHandler | An instance of IMobEggHandler. - * registerPickableFruit | An instance of IFactoryFruit. - * registerPlantable | An instance of IFactoryPlantable. - * registerRanchable | An instance of IFactoryRanchable. - * registerRedNetLogicCircuit | An instance of IRedNetLogicCircuit. - * registerRubberTreeBiome | The biomeName field of a biome to white list for rubber trees to spawn in. - * registerSafariNetBlacklist | A subclass of EntityLivingBase. - * registerSafariNetHandler | An instance of ISafariNetHandler. - * registerSludgeDrop | NBTTag with an ItemStack saved on it, with the weight on the "value" attribute, - * | A ValuedItem with item and value set. - * registerSpawnHandler | An instance of IMobSpawnHandler. - * registerVillagerTradeMob | An instance of IRandomMobProvider. - * - * // Simple implementations: - * { Harvestables - * registerHarvestable_Standard | The String identifier of a block. - * registerHarvestable_Log | The String identifier of a block. - * registerHarvestable_Leaves | The String identifier of a block. - * registerHarvestable_Vine | The String identifier of a block. - * registerHarvestable_Shrub | The String identifier of a block. - * registerHarvestable_Mushroom | The String identifier of a block. - * registerHarvestable_Crop | An ItemStack of a block, with a damage value indicating the meta value to harvest at. - * | A ValuedItem with value and object set; Block expected. - * registerHarvestable_Gourd | An NBTTag with the stem and fruit attributes, both String identifiers of blocks. - * } - * { Plantables - * registerPlantable_Standard | An NBTTag with the seed (Item, String identifier), and - * crop (Block, String identifier) attributes set, optionally - * also having the meta (Integer, placed metadata value) attribute set. - * No special checks for location, just sustainability. - * registerPlantable_Crop | An NBTTag with the seed (Item, String identifier), and - * crop (Block, String identifier) attributes set, optionally - * also having the meta (Integer, placed metadata value) attribute set. - * Will automatically hoe dirt and grass into farmland when planting. - * registerPlantable_Sapling | An NBTTag with the sapling (Block, String identifier), and optionally - * the seed (Item, String identifier) attributes set. - * } - * { Fertilizer - * registerFertilizer | An NBTTag with the fert (Item, String identifier), meta (Integer), and - * type (Integer, index into FertilizerType.values()) attributes set. - * } - * { Fertilizables - * registerFertilizable_Grass | The String identifier of a block. Will bonemeal the block and expect - * tall grass be planted above and around it, must be IGrowable. Works with - * the GrowPlant and Grass type fertilizers, not recommended for crop plants. - * registerFertilizable_Gourd | The String identifier of a block. Must be IGrowable, and expects identical - * behavior to vanilla stems. Works with the GrowPlant fertilizers. - * registerFertilizable_Crop | An NBTTag with the plant (Block, String identifier, IGrowable), and - * meta (Integer, max growth phase) attributes set, optionally also having - * the type (Integer, index into FertilizerType) attribute set. - * registerFertilizable_Cocoa | An NBTTag with the plant (Block, String identifier), and optionally also - * the type (Integer, index into FertilizerType) attributes set. - * Expects metadata of the block to exactly match cocoa pods. - * registerFertilizable_Standard | An NBTTag with the plant (Block, String identifier, IGrowable), and - * optionally also the type (Integer, index into FertilizerType) attributes set. - * Expects the block to change when successfully grown (e.g., saplings). - * } - */ - public static void sendMessage(String message, Object value) - { - if (!Loader.isModLoaded("MineFactoryReloaded") || - Loader.instance().activeModContainer() == null) - return; - try - { - Method m = FMLInterModComms.class.getDeclaredMethod("enqueueMessage", Object.class, String.class, IMCMessage.class); - m.setAccessible(true); - Constructor c = IMCMessage.class.getConstructor(String.class, Object.class); - c.setAccessible(true); - m.invoke(null, Loader.instance().activeModContainer(), "MineFactoryReloaded", c.newInstance(message, value)); - } - catch(Exception e) - { - e.printStackTrace(); - } - } -} diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/FertilizerType.java b/src/api/java/powercrystals/minefactoryreloaded/api/FertilizerType.java deleted file mode 100644 index 63ae32e60..000000000 --- a/src/api/java/powercrystals/minefactoryreloaded/api/FertilizerType.java +++ /dev/null @@ -1,27 +0,0 @@ -package powercrystals.minefactoryreloaded.api; - -/** - * @author PowerCrystals - * - * Determines what kind of action a given fertilizer can perform. Your IFactoryFertilizable instances should check this before - * performing any action to maintain future compatibility. - */ -public enum FertilizerType -{ - /** - * The fertilizer will fertilize nothing. - */ - None, - /** - * The fertilizer will fertilize grass. - */ - Grass, - /** - * The fertilizer will grow a plant. - */ - GrowPlant, - /** - * The fertilizer will grow magical crops. - */ - GrowMagicalCrop, -} \ No newline at end of file diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/HarvestType.java b/src/api/java/powercrystals/minefactoryreloaded/api/HarvestType.java deleted file mode 100644 index a56208eed..000000000 --- a/src/api/java/powercrystals/minefactoryreloaded/api/HarvestType.java +++ /dev/null @@ -1,44 +0,0 @@ -package powercrystals.minefactoryreloaded.api; - -/** - * @author PowerCrystals - * - * Determines what algorithm the Harvester uses when it encounters this IFactoryHarvestable in the world. - */ -public enum HarvestType -{ - /** - * Just break the single block - no special action needed. e.g. Carrots, flowers, wheat. - */ - Normal, - /** - * Search for harvestable blocks adjacent to this block but leave this block. e.g. Pumpkin, melon - */ - Gourd, - /** - * Search for identical blocks above. - */ - Column, - /** - * Search for identical blocks above but leave the bottom one for the future. e.g. Cactus, sugarcane. - */ - LeaveBottom, - /** - * This block is the base of a tree and the harvester should enter tree-cutting mode. - */ - Tree, - /** - * This block is the base of the tree and the harvester should enter tree-cutting mode. - * The tree is searched for in the negative y axis instead. - */ - TreeFlipped, - /** - * This block is part of a tree as above. - */ - TreeLeaf, - /** - * This block is part of a tree as above, but fruits are cut before logs. e.g. cocoa - * The tree is not searched for. - */ - TreeFruit -} diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/IDeepStorageUnit.java b/src/api/java/powercrystals/minefactoryreloaded/api/IDeepStorageUnit.java deleted file mode 100644 index ac718c2b9..000000000 --- a/src/api/java/powercrystals/minefactoryreloaded/api/IDeepStorageUnit.java +++ /dev/null @@ -1,29 +0,0 @@ -package powercrystals.minefactoryreloaded.api; - -import net.minecraft.item.ItemStack; - -public interface IDeepStorageUnit -{ - /** - * @return A populated ItemStack with stackSize for the full amount of materials in the DSU. - * May have a stackSize > getMaxStackSize(). May have a stackSize of 0 (indicating locked contents). - */ - ItemStack getStoredItemType(); - - /** - * Sets the total amount of the item currently being stored, or zero if all items are to be removed. - */ - void setStoredItemCount(int amount); - - /** - * Sets the type of the stored item and initializes the number of stored items to amount. - * Will overwrite any existing stored items. - */ - void setStoredItemType(ItemStack type, int amount); - - /** - * @return The maximum number of items the DSU can hold. - * May change based on the current type stored. - */ - int getMaxStoredCount(); -} diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/IFactoryFertilizable.java b/src/api/java/powercrystals/minefactoryreloaded/api/IFactoryFertilizable.java deleted file mode 100644 index a690df517..000000000 --- a/src/api/java/powercrystals/minefactoryreloaded/api/IFactoryFertilizable.java +++ /dev/null @@ -1,41 +0,0 @@ -package powercrystals.minefactoryreloaded.api; - -import java.util.Random; - -import net.minecraft.block.Block; -import net.minecraft.world.World; - -/** - * @author PowerCrystals - * - * Defines a fertilizable block, and the process to fertilize it. You can assume that you will never have to check that block ID matches the one returned by - * getFertilizableBlockId(). - */ -public interface IFactoryFertilizable -{ - /** - * @return The block this instance is managing. - */ - public Block getPlant(); - - /** - * @param world The world this block belongs to. - * @param x The X coordinate of this block. - * @param y The Y coordinate of this block. - * @param z The Z coordinate of this block. - * @param fertilizerType The kind of fertilizer being used. - * @return True if the block at (x,y,z) can be fertilized with the given type of fertilizer. - */ - public boolean canFertilize(World world, int x, int y, int z, FertilizerType fertilizerType); - - /** - * @param world The world this block belongs to. - * @param rand A Random instance to use when fertilizing, if necessary. - * @param x The X coordinate of this block. - * @param y The Y coordinate of this block. - * @param z The Z coordinate of this block. - * @param fertilizerType The kind of fertilizer being used. - * @return True if fertilization was successful. If false, the Fertilizer will not consume a fertilizer item and will not drain power. - */ - public boolean fertilize(World world, Random rand, int x, int y, int z, FertilizerType fertilizerType); -} diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/IFactoryFertilizer.java b/src/api/java/powercrystals/minefactoryreloaded/api/IFactoryFertilizer.java deleted file mode 100644 index f230ccc47..000000000 --- a/src/api/java/powercrystals/minefactoryreloaded/api/IFactoryFertilizer.java +++ /dev/null @@ -1,29 +0,0 @@ -package powercrystals.minefactoryreloaded.api; - -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -/** - * @author PowerCrystals - * - * Defines a fertilizer item for use in the Fertilizer. - */ -public interface IFactoryFertilizer -{ - /** - * @return The ID of this fertilizer item. - */ - Item getFertilizer(); - - /** - * @return The type of fertilizer this is. - */ - FertilizerType getFertilizerType(ItemStack stack); - - /** - * Called when a fertilization is successful. If you set the ItemStack size to 0, it will be deleted by the fertilizer. - * - * @param fertilizer The ItemStack used to fertilize. - */ - void consume(ItemStack fertilizer); -} diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/IFactoryFruit.java b/src/api/java/powercrystals/minefactoryreloaded/api/IFactoryFruit.java deleted file mode 100644 index 44c0d4bb8..000000000 --- a/src/api/java/powercrystals/minefactoryreloaded/api/IFactoryFruit.java +++ /dev/null @@ -1,75 +0,0 @@ -package powercrystals.minefactoryreloaded.api; - -import java.util.List; -import java.util.Random; - -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -/** - * Defines a fruit entry for the Fruit Picker. - * - * @author powercrystals - * - */ -public interface IFactoryFruit -{ - /** - * @return The block this fruit has in the world. - */ - public Block getPlant(); - - /** - * Used to determine if this fruit can be picked (is it ripe yet, etc) - * @param world The world where the fruit is being picked - * @param x The x-coordinate of the fruit - * @param y The y-coordinate of the fruit - * @param z The z-coordinate of the fruit - * @return True if the fruit can be picked - */ - public boolean canBePicked(World world, int x, int y, int z); - - /** - * @return Whether or not the Fruit Picker should break the block when harvesting. If false, no changes will be performed by the Fruit Picker itself. - */ - public boolean breakBlock(); - - /** - * Called by the Fruit Picker to determine what block to replace the picked block with. Only ID and meta/damage will be used. - * At the time this method is called, the fruit still exists. Do not pass an item ID as the return value. - * @param world The world where the fruit is being picked - * @param x The x-coordinate of the fruit - * @param y The y-coordinate of the fruit - * @param z The z-coordinate of the fruit - * @return The block to replace the fruit block with, or null for air. - */ - public ReplacementBlock getReplacementBlock(World world, int x, int y, int z); - - /** - * Called by the Fruit Picker before the fruit is picked. - * @param world The world where the fruit is being picked - * @param x The x-coordinate of the fruit - * @param y The y-coordinate of the fruit - * @param z The z-coordinate of the fruit - */ - public void prePick(World world, int x, int y, int z); - - /** - * Called by the Fruit Picker to determine what drops to generate. At the time this method is called, the fruit still exists. - * @param world The world where the fruit is being picked - * @param x The x-coordinate of the fruit - * @param y The y-coordinate of the fruit - * @param z The z-coordinate of the fruit - */ - public List getDrops(World world, Random rand, int x, int y, int z); - - /** - * Called by the Fruit Picker after the fruit is picked. - * @param world The world where the fruit is being picked - * @param x The x-coordinate of the fruit - * @param y The y-coordinate of the fruit - * @param z The z-coordinate of the fruit - */ - public void postPick(World world, int x, int y, int z); -} diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/IFactoryGrindable.java b/src/api/java/powercrystals/minefactoryreloaded/api/IFactoryGrindable.java deleted file mode 100644 index edfb8c995..000000000 --- a/src/api/java/powercrystals/minefactoryreloaded/api/IFactoryGrindable.java +++ /dev/null @@ -1,35 +0,0 @@ -package powercrystals.minefactoryreloaded.api; - -import java.util.List; -import java.util.Random; - -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.world.World; - -/** - * @author PowerCrystals - * - * Defines a grindable entity for the Grinder. - */ -public interface IFactoryGrindable -{ - /** - * @return The class that this grindable instance is handling. This must be a subtype of EntityLivingBase or the entity will never - * be noticed by the Grinder. - */ - public Class getGrindableEntity(); - - /** - * @param world The world this entity is in. - * @param entity The entity instance being ground. - * @param random A Random instance. - * @return The drops generated when this entity is killed. - */ - public List grind(World world, EntityLivingBase entity, Random random); - - /** - * @param entity The entity instance being ground. - * @return Whether this entity has been fully processed or not. - */ - public boolean processEntity(EntityLivingBase entity); -} diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/IFactoryHarvestable.java b/src/api/java/powercrystals/minefactoryreloaded/api/IFactoryHarvestable.java deleted file mode 100644 index d4e620a83..000000000 --- a/src/api/java/powercrystals/minefactoryreloaded/api/IFactoryHarvestable.java +++ /dev/null @@ -1,71 +0,0 @@ -package powercrystals.minefactoryreloaded.api; - -import java.util.List; -import java.util.Map; -import java.util.Random; - -import net.minecraft.block.Block; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -/** - * @author PowerCrystals - * - * Defines a harvestable block for the Harvester. - */ -public interface IFactoryHarvestable -{ - /** - * @return The block this harvestable instance is managing. - */ - public Block getPlant(); - - /** - * @return The type of harvest the Harvester should perform on this block. - */ - public HarvestType getHarvestType(); - - /** - * @return Whether or not the Harvester should break the block when harvesting. If false, no changes will be performed by the Harvester itself. - */ - public boolean breakBlock(); - - /** - * @param world The world this block is in. - * @param harvesterSettings The harvester's current settings. Do not modify these. - * @param x The X coordinate of the block being harvested. - * @param y The Y coordinate of the block being harvested. - * @param z The Z coordinate of the block being harvested. - * @return True if this block can be harvested. - */ - public boolean canBeHarvested(World world, Map harvesterSettings, int x, int y, int z); - - /** - * @param world The world this block is in. - * @param rand A Random instance to use when generating drops. - * @param harvesterSettings The harvester's current settings. Do not modify these. - * @param x The X coordinate of the block being harvested. - * @param y The Y coordinate of the block being harvested. - * @param z The Z coordinate of the block being harvested. - * @return The drops generated by breaking this block. For a default implementation, calling Block.getBlockDropped() is usually sufficient. - */ - public List getDrops(World world, Random rand, Map harvesterSettings, int x, int y, int z); - - /** - * Called before the block is going to be harvested. Usually empty. - * @param world The world this block is in. - * @param x The X coordinate of the block being harvested. - * @param y The Y coordinate of the block being harvested. - * @param z The Z coordinate of the block being harvested. - */ - public void preHarvest(World world, int x, int y, int z); - - /** - * Called after the block is going to be harvested. Used to re-till soil, for example. - * @param world The world this block is in. - * @param x The X coordinate of the block being harvested. - * @param y The Y coordinate of the block being harvested. - * @param z The Z coordinate of the block being harvested. - */ - public void postHarvest(World world, int x, int y, int z); -} diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/IFactoryLaserTarget.java b/src/api/java/powercrystals/minefactoryreloaded/api/IFactoryLaserTarget.java deleted file mode 100644 index 26ded7abb..000000000 --- a/src/api/java/powercrystals/minefactoryreloaded/api/IFactoryLaserTarget.java +++ /dev/null @@ -1,25 +0,0 @@ -package powercrystals.minefactoryreloaded.api; - -import net.minecraftforge.common.util.ForgeDirection; - -/** - * @author skyboy - * - * Defines a target for the Laser Drill Precharger - */ -public interface IFactoryLaserTarget -{ - /** - * @param from The direction the laser is coming from - * @return true if the precharger can form a beam from this side - */ - public boolean canFormBeamWith(ForgeDirection from); - - /** - * @param from The direction the energy is coming from - * @param energy The amount of energy being transferred - * @param simulate true if this transaction will only be simulated - * @return The amount of energy not consumed - */ - public int addEnergy(ForgeDirection from, int energy, boolean simulate); -} diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/IFactoryPlantable.java b/src/api/java/powercrystals/minefactoryreloaded/api/IFactoryPlantable.java deleted file mode 100644 index f9d343892..000000000 --- a/src/api/java/powercrystals/minefactoryreloaded/api/IFactoryPlantable.java +++ /dev/null @@ -1,64 +0,0 @@ -package powercrystals.minefactoryreloaded.api; - -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -/** - * @author PowerCrystals - * - * Defines a plantable object for use in the Planter. - */ -public interface IFactoryPlantable -{ - /** - * @return The item this plantable is managing. - */ - public Item getSeed(); - - /** - * @param stack The stack being planted. - * @return True if this plantable can be planted (useful for metadata items). - */ - public boolean canBePlanted(ItemStack stack); - - /** - * @param world The world instance this block or item will be placed into. - * @param x The destination X coordinate. - * @param y The destination Y coordinate. - * @param z The destination Z coordinate. - * @param stack The stack being planted. - * @return The block that will be placed into the world. - */ - public ReplacementBlock getPlantedBlock(World world, int x, int y, int z, ItemStack stack); - - /** - * @param world The world instance this block or item will be placed into. - * @param x The destination X coordinate. - * @param y The destination Y coordinate. - * @param z The destination Z coordinate. - * @param stack The stack being planted. - * @return True if this plantable can be placed at the provided coordinates. - */ - public boolean canBePlantedHere(World world, int x, int y, int z, ItemStack stack); - - /** - * Called before planting is performed. Used to till soil, for example. - * @param world The world instance this block or item will be placed into. - * @param x The destination X coordinate. - * @param y The destination Y coordinate. - * @param z The destination Z coordinate. - * @param stack The stack being planted. - */ - public void prePlant(World world, int x, int y, int z, ItemStack stack); - - /** - * Called after planting is performed. Usually empty. - * @param world The world instance this block or item will be placed into. - * @param x The destination X coordinate. - * @param y The destination Y coordinate. - * @param z The destination Z coordinate. - * @param stack The stack being planted. - */ - public void postPlant(World world, int x, int y, int z, ItemStack stack); -} diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/IFactoryRanchable.java b/src/api/java/powercrystals/minefactoryreloaded/api/IFactoryRanchable.java deleted file mode 100644 index 27c173fa6..000000000 --- a/src/api/java/powercrystals/minefactoryreloaded/api/IFactoryRanchable.java +++ /dev/null @@ -1,28 +0,0 @@ -package powercrystals.minefactoryreloaded.api; - -import java.util.List; - -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.inventory.IInventory; -import net.minecraft.world.World; - -/** - * @author PowerCrystals - * - * Defines a ranchable entity for use in the Rancher. - */ -public interface IFactoryRanchable -{ - /** - * @return The entity being ranched. Must be a subtype of EntityLivingBase. - */ - public Class getRanchableEntity(); - - /** - * @param world The world this entity is in. - * @param entity The entity instance being ranched. - * @param rancher The rancher instance doing the ranching. Used to access the Rancher's inventory when milking cows, for example. - * @return A list of drops. - */ - public List ranch(World world, EntityLivingBase entity, IInventory rancher); -} diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/ILiquidDrinkHandler.java b/src/api/java/powercrystals/minefactoryreloaded/api/ILiquidDrinkHandler.java deleted file mode 100644 index 31eba0040..000000000 --- a/src/api/java/powercrystals/minefactoryreloaded/api/ILiquidDrinkHandler.java +++ /dev/null @@ -1,8 +0,0 @@ -package powercrystals.minefactoryreloaded.api; - -import net.minecraft.entity.EntityLivingBase; - -public interface ILiquidDrinkHandler -{ - public void onDrink(EntityLivingBase player); -} diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/IMobEggHandler.java b/src/api/java/powercrystals/minefactoryreloaded/api/IMobEggHandler.java deleted file mode 100644 index 01693a738..000000000 --- a/src/api/java/powercrystals/minefactoryreloaded/api/IMobEggHandler.java +++ /dev/null @@ -1,18 +0,0 @@ -package powercrystals.minefactoryreloaded.api; - -import net.minecraft.entity.EntityList.EntityEggInfo; -import net.minecraft.item.ItemStack; - -/** - * @author PowerCrystals - * - * Defines a class that MFR will use to local egg info for a given mob. This is used to color the Safari Net based on the captured mob. - */ -public interface IMobEggHandler -{ - /** - * @param safariNet The Safari Net that is looking for egg info. - * @return An EntityEggInfo, or null if this instance cannot handle this mob. - */ - public EntityEggInfo getEgg(ItemStack safariNet); -} diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/IMobSpawnHandler.java b/src/api/java/powercrystals/minefactoryreloaded/api/IMobSpawnHandler.java deleted file mode 100644 index 46e295eae..000000000 --- a/src/api/java/powercrystals/minefactoryreloaded/api/IMobSpawnHandler.java +++ /dev/null @@ -1,27 +0,0 @@ -package powercrystals.minefactoryreloaded.api; - -import net.minecraft.entity.EntityLivingBase; - -/** - * @author skyboy - * - * Defines a handler for mob spawns from the autospawner. - * Added primarily to solve item duping on exact spawn & entity inventories - */ -public interface IMobSpawnHandler -{ - /** - * @return The class that this instance is handling. - */ - public Class getMobClass(); - - /** - * @param entity The entity instance being spawned. Typically your regular spawn code 100% handles this - */ - public void onMobSpawn(EntityLivingBase entity); - - /** - * @param entity The entity instance being exact-copied. Clear your inventories & etc. here - */ - public void onMobExactSpawn(EntityLivingBase entity); -} diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/INeedleAmmo.java b/src/api/java/powercrystals/minefactoryreloaded/api/INeedleAmmo.java deleted file mode 100644 index 74dae7e8d..000000000 --- a/src/api/java/powercrystals/minefactoryreloaded/api/INeedleAmmo.java +++ /dev/null @@ -1,13 +0,0 @@ -package powercrystals.minefactoryreloaded.api; - -import net.minecraft.entity.Entity; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -public interface INeedleAmmo -{ - public boolean onHitEntity(ItemStack stac, EntityPlayer owner, Entity hit, double distance); - public void onHitBlock(ItemStack stac, EntityPlayer owner, World world, int x, int y, int z, int side, double distance); - public float getSpread(ItemStack stack); -} diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/IRandomMobProvider.java b/src/api/java/powercrystals/minefactoryreloaded/api/IRandomMobProvider.java deleted file mode 100644 index b03d6f08a..000000000 --- a/src/api/java/powercrystals/minefactoryreloaded/api/IRandomMobProvider.java +++ /dev/null @@ -1,11 +0,0 @@ -package powercrystals.minefactoryreloaded.api; - -import java.util.List; - -import net.minecraft.world.World; - - -public interface IRandomMobProvider -{ - public List getRandomMobs(World world); -} \ No newline at end of file diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/ISafariNetHandler.java b/src/api/java/powercrystals/minefactoryreloaded/api/ISafariNetHandler.java deleted file mode 100644 index 370017956..000000000 --- a/src/api/java/powercrystals/minefactoryreloaded/api/ISafariNetHandler.java +++ /dev/null @@ -1,28 +0,0 @@ -package powercrystals.minefactoryreloaded.api; - -import java.util.List; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; - -/** - * @author PowerCrystals - * - * Defines an object that can display information about a captured mob in a Safari net. - */ -public interface ISafariNetHandler -{ - /** - * @return The class of mob that this handler applies to. - */ - public Class validFor(); - - /** - * @param safariNetStack The Safari Net that is requesting information. - * @param player The player holding the Safari Net. - * @param infoList The current list of information strings. Add yours to this. - * @param advancedTooltips True if the advanced tooltips option is on. - */ - @SuppressWarnings("rawtypes") - public void addInformation(ItemStack safariNetStack, EntityPlayer player, List infoList, boolean advancedTooltips); -} diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/ISyringe.java b/src/api/java/powercrystals/minefactoryreloaded/api/ISyringe.java deleted file mode 100644 index 5e876e807..000000000 --- a/src/api/java/powercrystals/minefactoryreloaded/api/ISyringe.java +++ /dev/null @@ -1,46 +0,0 @@ -package powercrystals.minefactoryreloaded.api; - -import net.minecraft.entity.EntityLivingBase; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -/** - * @author PowerCrystals - * - * Defines a syringe for use in the Vet machine. - */ -public interface ISyringe -{ - /** - * Called when the vet is deciding if it should use this syringe. - * @param world The world instance. - * @param entity The entity being injected. - * @param syringe The syringe ItemStack. - * @return True if the entity can be injected by this syringe. - */ - public boolean canInject(World world, EntityLivingBase entity, ItemStack syringe); - - /** - * Called to perform an injection. - * @param world The world instance. - * @param entity The entity being injected. - * @param syringe The syringe ItemStack. - * @return True if injection was successful. - */ - public boolean inject(World world, EntityLivingBase entity, ItemStack syringe); - - /** - * Called to check if a syringe is empty - * @param syringe The syringe ItemStack. - * @return True if the syringe is empty - */ - public boolean isEmpty(ItemStack syringe); - - /** - * Called to get the empty syringe - * Note: this will replace the syringe, max stacksize should be 1 - * @param syringe The syringe ItemStack. - * @return An empty syringe ItemStack - */ - public ItemStack getEmptySyringe(ItemStack syringe); -} diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/IToolHammer.java b/src/api/java/powercrystals/minefactoryreloaded/api/IToolHammer.java deleted file mode 100644 index 09ce77713..000000000 --- a/src/api/java/powercrystals/minefactoryreloaded/api/IToolHammer.java +++ /dev/null @@ -1,9 +0,0 @@ -package powercrystals.minefactoryreloaded.api; - -/** - * @author PowerCrystals - * Defines a tool that can rotate MFR machines. Implement on an Item class. Requires no additional work on your part. - */ -public interface IToolHammer -{ -} diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/IToolHammerAdvanced.java b/src/api/java/powercrystals/minefactoryreloaded/api/IToolHammerAdvanced.java deleted file mode 100644 index 9c4523495..000000000 --- a/src/api/java/powercrystals/minefactoryreloaded/api/IToolHammerAdvanced.java +++ /dev/null @@ -1,16 +0,0 @@ -package powercrystals.minefactoryreloaded.api; - -import net.minecraft.item.ItemStack; - -/** - * @author PowerCrystals - * - * This interface is like IToolHammer, but is for items that change state on a per-stack basis. Implement this - * instead of IToolHammer - not both! - * - * This interface will replace IToolHammer in MC 1.6. - */ -public interface IToolHammerAdvanced -{ - public boolean isActive(ItemStack stack); -} diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/IUpgrade.java b/src/api/java/powercrystals/minefactoryreloaded/api/IUpgrade.java deleted file mode 100644 index d4ee62f3b..000000000 --- a/src/api/java/powercrystals/minefactoryreloaded/api/IUpgrade.java +++ /dev/null @@ -1,36 +0,0 @@ -package powercrystals.minefactoryreloaded.api; - -import net.minecraft.item.ItemStack; - -/** - * @author skyboy - * - * Defines an upgrade item for use in various MFR machines. - */ -public interface IUpgrade -{ - public static enum UpgradeType - { - RADIUS, - SPEED, - EFFICIENCY, - STRENGTH, - ENERGY; - } - - /** - * Called to get the strength of the upgrade - * @param type The type of the upgrade - * @param stack The upgrade ItemStack. - * @return The strength of the upgrade - */ - public int getUpgradeLevel(UpgradeType type, ItemStack stack); - - /** - * Called to get what the upgrade is applicable for - * @param type The type of the upgrade - * @param stack The upgrade ItemStack. - * @return True if the upgrade is effective for the upgrade type - */ - public boolean isApplicableFor(UpgradeType type, ItemStack stack); -} diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/MobDrop.java b/src/api/java/powercrystals/minefactoryreloaded/api/MobDrop.java deleted file mode 100644 index 7f5dd7cc9..000000000 --- a/src/api/java/powercrystals/minefactoryreloaded/api/MobDrop.java +++ /dev/null @@ -1,21 +0,0 @@ -package powercrystals.minefactoryreloaded.api; - -import net.minecraft.item.ItemStack; -import net.minecraft.util.WeightedRandom; - -public class MobDrop extends WeightedRandom.Item -{ - private ItemStack _stack; - - public MobDrop(int weight, ItemStack stack) - { - super(weight); - _stack = stack; - } - - public ItemStack getStack() - { - if(_stack == null) return null; - return _stack.copy(); - } -} diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/RanchedItem.java b/src/api/java/powercrystals/minefactoryreloaded/api/RanchedItem.java deleted file mode 100644 index 86791cc54..000000000 --- a/src/api/java/powercrystals/minefactoryreloaded/api/RanchedItem.java +++ /dev/null @@ -1,68 +0,0 @@ -package powercrystals.minefactoryreloaded.api; - -import net.minecraft.block.Block; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraftforge.fluids.FluidStack; - -/** - * @author skyboy026 - * - * Defines an ItemStack or a FluidStack that is the result of an entity being ranched - */ -public final class RanchedItem { - private final ItemStack item; - private final FluidStack fluid; - - public RanchedItem(Block item, int amount, int meta) - { - this(new ItemStack(item, amount, meta)); - } - - public RanchedItem(Block item, int amount) - { - this(new ItemStack(item, amount)); - } - - public RanchedItem(Block item) - { - this(new ItemStack(item)); - } - - public RanchedItem(Item item, int amount, int meta) - { - this(new ItemStack(item, amount, meta)); - } - - public RanchedItem(Item item, int amount) - { - this(new ItemStack(item, amount)); - } - - public RanchedItem(Item item) - { - this(new ItemStack(item)); - } - - public RanchedItem(ItemStack item) - { - this.item = item; - fluid = null; - } - - public RanchedItem(FluidStack fluid) - { - this.fluid = fluid; - item = null; - } - - public boolean hasFluid() - { - return item == null & fluid != null; - } - - public Object getResult() - { - return item == null ? fluid : item; - } -} diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/RandomMob.java b/src/api/java/powercrystals/minefactoryreloaded/api/RandomMob.java deleted file mode 100644 index 2ffa56b1a..000000000 --- a/src/api/java/powercrystals/minefactoryreloaded/api/RandomMob.java +++ /dev/null @@ -1,28 +0,0 @@ -package powercrystals.minefactoryreloaded.api; - -import net.minecraft.entity.Entity; -import net.minecraft.util.WeightedRandom; - -public class RandomMob extends WeightedRandom.Item -{ - private Entity _mob; - public final boolean shouldInit; - - public RandomMob(Entity savedMob, int weight, boolean init) - { - super(weight); - _mob = savedMob; - shouldInit = init; - } - - public RandomMob(Entity savedMob, int weight) - { - this(savedMob, weight, true); - } - - public Entity getMob() - { - if(_mob == null) return null; - return _mob; - } -} diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/ReplacementBlock.java b/src/api/java/powercrystals/minefactoryreloaded/api/ReplacementBlock.java deleted file mode 100644 index 88cd7a86f..000000000 --- a/src/api/java/powercrystals/minefactoryreloaded/api/ReplacementBlock.java +++ /dev/null @@ -1,137 +0,0 @@ -package powercrystals.minefactoryreloaded.api; - -import net.minecraft.block.Block; -import net.minecraft.item.Item; -import net.minecraft.item.ItemBlock; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; - -public class ReplacementBlock -{ - protected byte _hasMeta; - protected int _meta; - protected final Block _block; - protected final NBTTagCompound _tileTag; - - /** - * Called to replace a block in the world. - * @param world The world object - * @param x The X coord - * @param y The Y coord - * @param z The Z coord - * @param stack The ItemStack being used to replace the block (may be null) - * @return True if the block was set successfully - */ - public boolean replaceBlock(World world, int x, int y, int z, ItemStack stack) - { - int meta = getMeta(world, x, y, z, stack); - if (world.setBlock(x, y, z, _block, meta, 3)) - { - if (hasTag(stack) && _block.hasTileEntity(meta)) - { - TileEntity tile = world.getTileEntity(x, y, z); - if (tile != null) - tile.readFromNBT(getTag(world, x, y, z, stack)); - } - return true; - } - return false; - } - - /** - * Called to get the metadata of the replacement block in the world. - * @param world The world object - * @param x The X coord - * @param y The Y coord - * @param z The Z coord - * @param stack The ItemStack being used to replace the block (may be null) - * @return The metadata of the block - */ - protected int getMeta(World world, int x, int y, int z, ItemStack stack) - { - int m = 0; - if (_hasMeta > 0) - { - if (_hasMeta > 1) - return _meta; - m = stack.getItemDamage(); - Item item = stack.getItem(); - if (item instanceof ItemBlock) - m = ((ItemBlock)item).getMetadata(m); - } - return m; - } - - /** - * Called to set the metdata of this ReplacementBlock to a fixed value - * @param meta The metadata of the block - * @return This instance - */ - public ReplacementBlock setMeta(int meta) - { - if (meta >= 0) - { - _hasMeta = 2; - _meta = meta; - } - return this; - } - - /** - * Called to set the metdata of this ReplacementBlock to a value read from an ItemStack - * @param meta The metadata of the block - * @return This instance - */ - public ReplacementBlock setMeta(boolean hasMeta) - { - _hasMeta = (byte) (hasMeta ? 1 : 0); - return this; - } - - /** - * Called to get the NBTTagCompound a TileEntity will read its state from - * @param world The world object - * @param x The X coord - * @param y The Y coord - * @param z The Z coord - * @param stack The ItemStack being used to replace the block (may be null) - * @return The NBTTagCompound a TileEntity will read its state from - */ - protected NBTTagCompound getTag(World world, int x, int y, int z, ItemStack stack) - { - return _tileTag; - } - - /** - * Called to see if a TileEntity should have its state set - * @param stack The ItemStack being used to replace the block (may be null) - * @return True if the TileEntity should have its state set - */ - protected boolean hasTag(ItemStack stack) - { - return _tileTag != null; - } - - public ReplacementBlock(Item block) - { - this(Block.getBlockFromItem(block)); - } - - public ReplacementBlock(Item block, NBTTagCompound tag) - { - this(Block.getBlockFromItem(block), tag); - } - - public ReplacementBlock(Block block) - { - this(block, null); - } - - public ReplacementBlock(Block block, NBTTagCompound tag) - { - _block = block; - _tileTag = tag; - } -} diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/ValuedItem.java b/src/api/java/powercrystals/minefactoryreloaded/api/ValuedItem.java deleted file mode 100644 index 3d075fa3b..000000000 --- a/src/api/java/powercrystals/minefactoryreloaded/api/ValuedItem.java +++ /dev/null @@ -1,72 +0,0 @@ -package powercrystals.minefactoryreloaded.api; - -import net.minecraft.item.ItemStack; - -public class ValuedItem -{ - public final int value; - public final ItemStack item; - public final String key; - public final Object object; - - public ValuedItem(int v, ItemStack i) - { - value = v; - item = i; - key = null; - object = null; - } - - public ValuedItem(String v, Object i) - { - value = -1; - item = null; - key = v; - object = i; - } - - /** - * Presently unused but included so that if they do get used in the future, - * people including this in their jar and loading before MFR don't destroy everyone - */ - - public ValuedItem(int v, Object i) - { - value = v; - item = null; - key = null; - object = i; - } - - public ValuedItem(String v, ItemStack i) - { - value = -1; - item = i; - key = v; - object = null; - } - - public ValuedItem(int v, String k, ItemStack i) - { - value = v; - item = i; - key = k; - object = null; - } - - public ValuedItem(int v, String k, Object i) - { - value = v; - item = null; - key = k; - object = i; - } - - public ValuedItem(int v, String k, ItemStack i, Object o) - { - value = v; - item = i; - key = k; - object = o; - } -} diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/rednet/IRedNetInputNode.java b/src/api/java/powercrystals/minefactoryreloaded/api/rednet/IRedNetInputNode.java deleted file mode 100644 index 85186b789..000000000 --- a/src/api/java/powercrystals/minefactoryreloaded/api/rednet/IRedNetInputNode.java +++ /dev/null @@ -1,52 +0,0 @@ -package powercrystals.minefactoryreloaded.api.rednet; - -import powercrystals.minefactoryreloaded.api.rednet.connectivity.IRedNetConnection; - -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; - -/** - * Defines a Block that can connect to RedNet cables. This must be implemented on your Block class. - *

- * Note that when you implement this, the RedNet network makes several assumptions about your code - - * It will not clamp values to 0 <= x <= 15. This means you must be able to accept any possible integer - * without crashing, even negatives. It will also assume that calling the onInput(s)Changed() methods - * are sufficient, and will not issue block updates. In Single mode, it will call onInputChanged. - *

- * RedNet cables have their subnets indicated to the user by colored bands on the cable. - * The color of a given subnet is the same as the wool with metadata equal to the subnet number. - *

- * For reference:
- * 0:White, 1:Orange, 2:Magenta, 3:LightBlue, 4:Yellow, 5:Lime, 6:Pink, 7:Gray, - * 8:LightGray, 9:Cyan, 10:Purple, 11:Blue, 12:Brown, 13:Green, 14:Red, 15:Black - */ -public interface IRedNetInputNode extends IRedNetConnection -{ - /** - * Called when the input values to this block change. Only called if your block is connected in "All" mode. - * Do not issue a network value update from inside this method call; it will be ignored. Issue your updates - * on the next tick. - * - * @param world The world this block is in. - * @param x This block's X coordinate. - * @param y This block's Y coordinate. - * @param z This block's Z coordinate. - * @param side The side the input values are being changed on. - * @param inputValues The new set of input values. This array will be 16 elements long. - */ - public void onInputsChanged(World world, int x, int y, int z, ForgeDirection side, int[] inputValues); - - /** - * Called when the input value to this block changes. Only called if your block is connected in "Single" mode. - * Do not issue a network value update from inside this method call; it will be ignored. Issue your updates - * on the next tick. - * - * @param world The world this block is in. - * @param x This block's X coordinate. - * @param y This block's Y coordinate. - * @param z This block's Z coordinate. - * @param side The side the input values are being changed on. - * @param inputValue The new input value - */ - public void onInputChanged(World world, int x, int y, int z, ForgeDirection side, int inputValue); -} diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/rednet/IRedNetLogicCircuit.java b/src/api/java/powercrystals/minefactoryreloaded/api/rednet/IRedNetLogicCircuit.java deleted file mode 100644 index 981ce06b6..000000000 --- a/src/api/java/powercrystals/minefactoryreloaded/api/rednet/IRedNetLogicCircuit.java +++ /dev/null @@ -1,19 +0,0 @@ -package powercrystals.minefactoryreloaded.api.rednet; - -import net.minecraft.nbt.NBTTagCompound; - -public interface IRedNetLogicCircuit -{ - public byte getInputCount(); - - public byte getOutputCount(); - - public int[] recalculateOutputValues(long worldTime, int[] inputValues); - - public String getUnlocalizedName(); - public String getInputPinLabel(int pin); - public String getOutputPinLabel(int pin); - - public void readFromNBT(NBTTagCompound tag); - public void writeToNBT(NBTTagCompound tag); -} diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/rednet/IRedNetLogicPoint.java b/src/api/java/powercrystals/minefactoryreloaded/api/rednet/IRedNetLogicPoint.java deleted file mode 100644 index dd05969e9..000000000 --- a/src/api/java/powercrystals/minefactoryreloaded/api/rednet/IRedNetLogicPoint.java +++ /dev/null @@ -1,36 +0,0 @@ -package powercrystals.minefactoryreloaded.api.rednet; - -/** - * - * @author skyboy - */ -public interface IRedNetLogicPoint -{ - /** - * - * @param out - * @return - */ - public void transformOutput(int[] out); - - /** - * - * @param out - * @return - */ - public void transformOutput(int out); - - /** - * - * @param in - * @return - */ - public int[] transformInput(int[] in); - - /** - * - * @param in - * @return - */ - public int transformInput(int in); -} diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/rednet/IRedNetNetworkContainer.java b/src/api/java/powercrystals/minefactoryreloaded/api/rednet/IRedNetNetworkContainer.java deleted file mode 100644 index f2157d2c7..000000000 --- a/src/api/java/powercrystals/minefactoryreloaded/api/rednet/IRedNetNetworkContainer.java +++ /dev/null @@ -1,31 +0,0 @@ -package powercrystals.minefactoryreloaded.api.rednet; - -import net.minecraft.world.World; - -/** - * - * You should not implement this yourself. Instead, use this to look for cables to notify from your IRedNetOmniNode as this does not - * require a block update. This will be implemented on the cable's Block class. - * - */ -public interface IRedNetNetworkContainer -{ - /** - * Tells the network to recalculate all subnets. - * @param world The world this cable is in. - * @param x The x-coordinate of this cable. - * @param x The y-coordinate of this cable. - * @param x The z-coordinate of this cable. - */ - public void updateNetwork(World world, int x, int y, int z); - - /** - * Tells the network to recalculate a specific subnet. - * @param world The world this cable is in. - * @param x The x-coordinate of this cable. - * @param x The y-coordinate of this cable. - * @param x The z-coordinate of this cable. - * @param subnet The subnet to recalculate. - */ - public void updateNetwork(World world, int x, int y, int z, int subnet); -} diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/rednet/IRedNetOmniNode.java b/src/api/java/powercrystals/minefactoryreloaded/api/rednet/IRedNetOmniNode.java deleted file mode 100644 index f2bdf397c..000000000 --- a/src/api/java/powercrystals/minefactoryreloaded/api/rednet/IRedNetOmniNode.java +++ /dev/null @@ -1,22 +0,0 @@ -package powercrystals.minefactoryreloaded.api.rednet; - -/** - * Defines a Block that can connect to RedNet cables. This must be implemented on your Block class. - *

- * Note that when you implement this, the RedNet network makes several assumptions about your code - - * It will not clamp values to 0 <= x <= 15. This means you must be able to accept any possible integer - * without crashing, even negatives. It will also assume that calling the onInput(s)Changed() methods - * are sufficient, and will not issue block updates. It will never call the vanilla redstone output - * methods, and will only query the methods contained in this interface. - *

- * RedNet cables have their subnets indicated to the user by colored bands on the cable. - * The color of a given subnet is the same as the wool with metadata equal to the subnet number. - *

- * For reference:
- * 0:White, 1:Orange, 2:Magenta, 3:LightBlue, 4:Yellow, 5:Lime, 6:Pink, 7:Gray, - * 8:LightGray, 9:Cyan, 10:Purple, 11:Blue, 12:Brown, 13:Green, 14:Red, 15:Black - */ -public interface IRedNetOmniNode extends IRedNetInputNode, IRedNetOutputNode -{ - // this is merely provided for convenience -} diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/rednet/IRedNetOutputNode.java b/src/api/java/powercrystals/minefactoryreloaded/api/rednet/IRedNetOutputNode.java deleted file mode 100644 index 34281875b..000000000 --- a/src/api/java/powercrystals/minefactoryreloaded/api/rednet/IRedNetOutputNode.java +++ /dev/null @@ -1,51 +0,0 @@ -package powercrystals.minefactoryreloaded.api.rednet; - -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; - -import powercrystals.minefactoryreloaded.api.rednet.connectivity.IRedNetConnection; - -/** - * Defines a Block that can connect to RedNet cables. This must be implemented on your Block class. - *

- * Note that when you implement this, the RedNet network makes several assumptions about your code - - * It will never call the vanilla redstone output methods, querying only the methods contained in - * this interface, and will not issue block updates. - *

- * RedNet cables have their subnets indicated to the user by colored bands on the cable. - * The color of a given subnet is the same as the wool with metadata equal to the subnet number. - *

- * For reference:
- * 0:White, 1:Orange, 2:Magenta, 3:LightBlue, 4:Yellow, 5:Lime, 6:Pink, 7:Gray, - * 8:LightGray, 9:Cyan, 10:Purple, 11:Blue, 12:Brown, 13:Green, 14:Red, 15:Black - */ -public interface IRedNetOutputNode extends IRedNetConnection -{ - /** - * Returns the output values of this RedNet node. - * This array must be 16 elements long. - * Only called if your block is connected in "All" mode. - * - * @param world The world this block is in. - * @param x This block's X coordinate. - * @param y This block's Y coordinate. - * @param z This block's Z coordinate. - * @param side The side the output values are required for. - * @return The output values. - */ - public int[] getOutputValues(World world, int x, int y, int z, ForgeDirection side); - - /** - * Returns the output value of this RedNet node for a given subnet. - * Must be the same as getOutputValues(world, x, y, z, side)[subnet]. - * - * @param world The world this block is in. - * @param x This block's X coordinate. - * @param y This block's Y coordinate. - * @param z This block's Z coordinate. - * @param side The side the output value is required for. - * @param subnet The subnet to get the output value for (0-15). - * @return The output value. - */ - public int getOutputValue(World world, int x, int y, int z, ForgeDirection side, int subnet); -} diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/rednet/connectivity/IRedNetConnection.java b/src/api/java/powercrystals/minefactoryreloaded/api/rednet/connectivity/IRedNetConnection.java deleted file mode 100644 index 003800d8f..000000000 --- a/src/api/java/powercrystals/minefactoryreloaded/api/rednet/connectivity/IRedNetConnection.java +++ /dev/null @@ -1,26 +0,0 @@ -package powercrystals.minefactoryreloaded.api.rednet.connectivity; - -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; - -/** - * Defines a Block that can connect to RedNet cables. This must be implemented on your Block class. - */ -public interface IRedNetConnection -{ - /** - * Returns the connection type of this Block. If this value must be changed - * while the block is alive, it must notify neighbors of a change. - *

- * For nodes that want to interact with rednet, - * see IRedNetInputNode, IRedNetOutputNode, and IRedNetOmniNode - * - * @param world The world this block is in. - * @param x This block's X coordinate. - * @param y This block's Y coordinate. - * @param z This block's Z coordinate. - * @param side The side that connection information is required for. - * @return The connection type. - */ - public RedNetConnectionType getConnectionType(World world, int x, int y, int z, ForgeDirection side); -} diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/rednet/connectivity/IRedNetDecorative.java b/src/api/java/powercrystals/minefactoryreloaded/api/rednet/connectivity/IRedNetDecorative.java deleted file mode 100644 index 18f76313f..000000000 --- a/src/api/java/powercrystals/minefactoryreloaded/api/rednet/connectivity/IRedNetDecorative.java +++ /dev/null @@ -1,6 +0,0 @@ -package powercrystals.minefactoryreloaded.api.rednet.connectivity; - -public interface IRedNetDecorative -{ - -} diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/rednet/connectivity/IRedNetNoConnection.java b/src/api/java/powercrystals/minefactoryreloaded/api/rednet/connectivity/IRedNetNoConnection.java deleted file mode 100644 index d3d1bae45..000000000 --- a/src/api/java/powercrystals/minefactoryreloaded/api/rednet/connectivity/IRedNetNoConnection.java +++ /dev/null @@ -1,6 +0,0 @@ -package powercrystals.minefactoryreloaded.api.rednet.connectivity; - -public interface IRedNetNoConnection -{ - -} diff --git a/src/api/java/powercrystals/minefactoryreloaded/api/rednet/connectivity/RedNetConnectionType.java b/src/api/java/powercrystals/minefactoryreloaded/api/rednet/connectivity/RedNetConnectionType.java deleted file mode 100644 index d3b3dfe95..000000000 --- a/src/api/java/powercrystals/minefactoryreloaded/api/rednet/connectivity/RedNetConnectionType.java +++ /dev/null @@ -1,80 +0,0 @@ -package powercrystals.minefactoryreloaded.api.rednet.connectivity; - -import java.util.HashMap; -import java.util.Map; - -/** - * Defines how RedNet cable connects to a block - *

- * None: RedNet will never connect to this block (if this is all you want: use IRedNetNoConnection) - *

- * CableSingle: Connections will use the cable renderer with a single band, best used for whole blocks - *
- * PlateSingle: Connections will use the plate renderer with a single band, used for conveyers and rails - *

- * CableAll: Connections permit access to all 16 bands - *
- * PlateAll: Connections permit access to all 16 bands - *

- * Forced connection modes are best used for decoration blocks: RedNet will not connect normally, - * but will if the user forces it. Typically, IRedNetDecorative is desired for this instead - *

- * ForcedCableSingle: Connections permit access to a single band, only when the cable is in forced connection mode - *
- * ForcedPlateSingle: Connections permit access to a single band, only when the cable is in forced connection mode - *

- * ForcedCableAll: Connections permit access to all 16 bands, only when the cable is in forced connection mode - *
- * ForcedPlateAll: Connections permit access to all 16 bands, only when the cable is in forced connection mode - *

- * The decorative nodes are for when you want rednet to decide how to connect to your block, - * but also need to receive full updates from the network. - *

- * DecorativeSingle: Connections permit access to a single band, using standard connection logic - *
- * DecorativeAll: Connections permit access to all 16 bands, using standard connection logic - */ -public enum RedNetConnectionType -{ - None, // 0; 0000000 - CableSingle, // 11; 0001011 - PlateSingle, // 13; 0001101 - CableAll, // 19; 0010011 - PlateAll, // 21; 0010101 - ForcedCableSingle, // 43; 0101011 - ForcedPlateSingle, // 45; 0101101 - ForcedCableAll, // 51; 0110011 - ForcedPlateAll, // 53; 0110101 - DecorativeSingle, // NA; 0001001 - DecorativeAll; // NA; 0010001 - - public final boolean isConnected = this.ordinal() != 0; // 0 bit (mask: 1) - public final boolean isSingleSubnet = this.name().endsWith("Single"); // 3 bit (mask: 8) - public final boolean isAllSubnets = this.name().endsWith("All"); // 4 bit (mask: 16) - public final boolean isPlate = this.name().contains("Plate"); // 2 bit (mask: 4) - public final boolean isCable = this.name().contains("Cable"); // 1 bit (mask: 2) - public final boolean isConnectionForced = this.name().startsWith("Forced"); // 5 bit (mask: 32) - public final boolean isDecorative = this.name().startsWith("Decorative"); - public final short flags = toFlags(isConnected, isCable, isPlate, - isSingleSubnet, isAllSubnets, isConnectionForced); - - public static final RedNetConnectionType fromFlags(short flags) - { - return connections.get(flags); - } - - private static final short toFlags(boolean ...flags) - { - short ret = 0; - for (int i = flags.length; i --> 0;) - ret |= (flags[i] ? 1 : 0) << i; - return ret; - } - - private static final Map connections = new HashMap(); - - static { - for (RedNetConnectionType type : RedNetConnectionType.values()) - connections.put(type.flags, type); - } -} diff --git a/src/api/java/rblocks/api/IOrientable.java b/src/api/java/rblocks/api/IOrientable.java deleted file mode 100644 index aa0a5d6cb..000000000 --- a/src/api/java/rblocks/api/IOrientable.java +++ /dev/null @@ -1,41 +0,0 @@ -package rblocks.api; - -import net.minecraftforge.common.util.ForgeDirection; - -/** - * Implement on a tile entity to manage storage of rotation information. - * - * remember for optional dependencies use: - * - * @Interface(iface = "rblocks.api.IOrientable", modid = "RotateableBlocks") - * - * this will strip the interface at runtime and allow your mod to work without RotatableBlocks. - * - */ -public interface IOrientable -{ - - /** - * @return true or false, if the tile rotation is meaningful, or even changeable - */ - boolean canBeRotated(); - - /** - * @return the direction the tile is facing - */ - ForgeDirection getForward(); - - /** - * @return the direction top of the tile - */ - ForgeDirection getUp(); - - /** - * Update the orientation - * - * @param Forward - * @param Up - */ - void setOrientation(ForgeDirection Forward, ForgeDirection Up); - -} \ No newline at end of file diff --git a/src/api/java/rblocks/api/IRBMethods.java b/src/api/java/rblocks/api/IRBMethods.java deleted file mode 100644 index 6fcbd1592..000000000 --- a/src/api/java/rblocks/api/IRBMethods.java +++ /dev/null @@ -1,29 +0,0 @@ -package rblocks.api; - -/** - * These methods are added to the Block Class. - */ -public interface IRBMethods -{ - - /** - * @returns true or false based on previously set value, or null if a value has not been set. - */ - Boolean isRotableBlockSupported(); - - /** - * updates the field for the supported flag. - * - * @param supported - * @return supported - */ - boolean setRotableBlockSupported(boolean supported); - - /** - * Override this method if you wish to render your rotatable block instead of using the default renderer. - * - * @return the normal renderType value, or Rotablable Blocks render type depending on if the block is supported. - */ - int getRealRenderType(); - -} diff --git a/src/api/java/rblocks/api/IRotatableBlocksApi.java b/src/api/java/rblocks/api/IRotatableBlocksApi.java deleted file mode 100644 index c67bad42f..000000000 --- a/src/api/java/rblocks/api/IRotatableBlocksApi.java +++ /dev/null @@ -1,19 +0,0 @@ -package rblocks.api; - -/** - * obtain via - * - * @Instance("RotateableBlocks") - * static IRotatableBlocksApi api; - * - */ -public interface IRotatableBlocksApi -{ - - /** - * @return render type for rotatable blocks, not this render type only handles in world render, and will not render - * anything as entities, or inventory items. - */ - int getRotatableRenderType(); - -} diff --git a/src/api/java/rblocks/api/RotatableBlockDisable.java b/src/api/java/rblocks/api/RotatableBlockDisable.java deleted file mode 100644 index 216db54e1..000000000 --- a/src/api/java/rblocks/api/RotatableBlockDisable.java +++ /dev/null @@ -1,12 +0,0 @@ -package rblocks.api; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * If found on a Block, Rotatable Blocks will ignore the block, even if it would have normally supported it. - */ -@Retention(RetentionPolicy.RUNTIME) -public @interface RotatableBlockDisable { - -} diff --git a/src/api/java/rblocks/api/RotatableBlockEnable.java b/src/api/java/rblocks/api/RotatableBlockEnable.java deleted file mode 100644 index 5c449fbbc..000000000 --- a/src/api/java/rblocks/api/RotatableBlockEnable.java +++ /dev/null @@ -1,14 +0,0 @@ -package rblocks.api; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * if this annotation is found on a block, Rotatable Blocks will consider it supported, even if it normally would not - * be, this dosn't magically make it work, but it will allow you to possibly render the rotation or work around the - * Limitations. - */ -@Retention(RetentionPolicy.RUNTIME) -public @interface RotatableBlockEnable { - -} diff --git a/src/api/java/uristqwerty/CraftGuide/CommonUtilities.java b/src/api/java/uristqwerty/CraftGuide/CommonUtilities.java deleted file mode 100644 index 0e79e9283..000000000 --- a/src/api/java/uristqwerty/CraftGuide/CommonUtilities.java +++ /dev/null @@ -1,262 +0,0 @@ -package uristqwerty.CraftGuide; - -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import net.minecraft.client.Minecraft; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import uristqwerty.CraftGuide.api.StackInfo; -import uristqwerty.CraftGuide.api.StackInfoSource; -import uristqwerty.CraftGuide.api.Util; - -public class CommonUtilities -{ - public static Field getPrivateField(Class fromClass, String... names) throws NoSuchFieldException - { - Field field = null; - - for(String name: names) - { - try - { - field = fromClass.getDeclaredField(name); - field.setAccessible(true); - return field; - } - catch(NoSuchFieldException e) - { - } - } - - if(names.length == 1) - { - throw new NoSuchFieldException("Could not find a field named " + names[0]); - } - else - { - String nameStr = "[" + names[0]; - - for(int i = 1; i < names.length; i++) - { - nameStr += ", " + names[i]; - } - - throw new NoSuchFieldException("Could not find a field with any of the following names: " + nameStr + "]"); - } - } - - public static Object getPrivateValue(Class objectClass, T object, String... names) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException - { - Field field = getPrivateField(objectClass, names); - return field.get(object); - } - - public static String itemName(ItemStack item) - { - String idText = ""; - - if(Minecraft.getMinecraft().gameSettings.advancedItemTooltips) - { - if(item.getHasSubtypes()) - { - idText = String.format(" (%04d/%d)", Item.itemRegistry.getNameForObject(item.getItem()), getItemDamage(item)); - } - else - { - idText = String.format(" (%04d)", Item.itemRegistry.getNameForObject(item.getItem())); - } - } - - return item.getDisplayName() + idText; - } - - public static List itemNames(ItemStack item) - { - ArrayList list = new ArrayList(); - - if(getItemDamage(item) == CraftGuide.DAMAGE_WILDCARD && item.getHasSubtypes()) - { - ArrayList subItems = new ArrayList(); - item.getItem().getSubItems(item.getItem(), null, subItems); - - for(ItemStack stack: subItems) - { - list.add(itemName(stack)); - } - } - else - { - list.add(itemName(item)); - } - - return list; - } - - public static int countItemNames(ItemStack item) - { - if(getItemDamage(item) == CraftGuide.DAMAGE_WILDCARD && item.getHasSubtypes()) - { - ArrayList temp = new ArrayList(); - item.getItem().getSubItems(item.getItem(), null, temp); - - return temp.size(); - } - else - { - return 1; - } - } - - public static int countItemNames(Object item) - { - if(item instanceof ItemStack) - { - return countItemNames((ItemStack)item); - } - else if(item instanceof List) - { - int count = 0; - for(Object o: (List)item) - { - count += countItemNames(o); - } - - return count; - } - else - { - return 0; - } - } - - public static List getExtendedItemStackText(Object item) - { - List text = getItemStackText(item); - - if(item instanceof ItemStack || (item instanceof List && ((List)item).get(0) instanceof ItemStack)) - { - ItemStack stack = item instanceof ItemStack? (ItemStack)item : (ItemStack)((List)item).get(0); - - Iterator iterator = StackInfo.sources.iterator(); - while(iterator.hasNext()) - { - StackInfoSource infoSource = iterator.next(); - try - { - String info = infoSource.getInfo(stack); - - if(info != null) - { - text.add(info); - } - } - catch(LinkageError e) - { - CraftGuideLog.log(e); - iterator.remove(); - } - catch(Exception e) - { - CraftGuideLog.log(e); - } - } - } - - if(item instanceof List && ((List)item).size() > 1) - { - int count = CommonUtilities.countItemNames(item); - text.add("\u00a77" + (count - 1) + " other type" + (count > 2? "s" : "") + " of item accepted"); - } - - return text; - } - - public static boolean searchExtendedItemStackText(Object item, String text) - { - for(String line: getExtendedItemStackText(item)) - { - if(line != null && line.toLowerCase().contains(text)) - { - return true; - } - } - - return false; - } - - private static List getItemStackText(Object item) - { - if(item instanceof List) - { - return getItemStackText(((List)item).get(0)); - } - else if(item instanceof ItemStack) - { - return Util.instance.getItemStackText((ItemStack)item); - } - else - { - return null; - } - } - - static Field itemDamageField = null; - - static - { - try - { - itemDamageField = getPrivateField(ItemStack.class, "itemDamage", "field_77991_e", "e"); - } - catch(NoSuchFieldException e) - { - e.printStackTrace(); - } - } - - public static int getItemDamage(ItemStack stack) - { - if(stack.getItem() != null) - { - return stack.getItemDamage(); - } - else - { - if(itemDamageField != null) - { - try - { - return itemDamageField.getInt(stack); - } - catch(IllegalArgumentException e) - { - e.printStackTrace(); - } - catch(IllegalAccessException e) - { - e.printStackTrace(); - } - } - - return 0; - } - } - - public static boolean checkItemStackMatch(ItemStack first, ItemStack second) - { - if(first == null || second == null) - { - return first == second; - } - - return first.getItem() == second.getItem() - && ( - getItemDamage(first) == CraftGuide.DAMAGE_WILDCARD || - getItemDamage(second) == CraftGuide.DAMAGE_WILDCARD || - getItemDamage(first) == getItemDamage(second) - ); - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/CraftGuide.java b/src/api/java/uristqwerty/CraftGuide/CraftGuide.java deleted file mode 100644 index 35e5e0cba..000000000 --- a/src/api/java/uristqwerty/CraftGuide/CraftGuide.java +++ /dev/null @@ -1,393 +0,0 @@ -package uristqwerty.CraftGuide; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; -import java.util.Set; - -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.ItemStack; - -import org.lwjgl.input.Keyboard; - -import uristqwerty.CraftGuide.RecipeGeneratorImplementation.RecipeGeneratorForgeExtension; -import uristqwerty.CraftGuide.api.ItemSlot; -import uristqwerty.gui_craftguide.theme.ThemeManager; - -public class CraftGuide -{ - public static CraftGuideSide side; - public static CraftGuideLoaderSide loaderSide; - - public static ItemCraftGuide itemCraftGuide; - private static Properties config = new Properties(); - - private static Map configComments; - - public static int resizeRate; - public static int mouseWheelScrollRate; - public static int defaultKeybind; - public static boolean pauseWhileOpen = true; - public static boolean gridPacking = true; - public static boolean alwaysShowID = false; - public static boolean textSearchRequiresShift = false; - public static boolean enableKeybind = true; - public static boolean newerBackgroundStyle = false; - public static boolean hideMundanePotionRecipes = true; - public static boolean insertBetterWithRenewablesRecipes = false; - public static boolean enableItemRecipe; - - public static boolean betterWithRenewablesDetected = false; - public static boolean needsRecipeRefresh = false; - - public static final int DAMAGE_WILDCARD = 32767; - - public void preInit(String iconName) - { - CraftGuideLog.init(new File(configDirectory(), "CraftGuide.log")); - - initForgeExtensions(); - loadProperties(); - - side.preInit(); - - ItemSlot.implementation = new ItemSlotImplementationImplementation(); - - if(enableKeybind) - { - side.initKeybind(); - } - - addItem(iconName); - } - - public void init() - { - try - { - Class.forName("uristqwerty.CraftGuide.recipes.DefaultRecipeProvider").newInstance(); - Class.forName("uristqwerty.CraftGuide.recipes.BrewingRecipes").newInstance(); - } - catch(InstantiationException e) - { - CraftGuideLog.log(e); - } - catch(IllegalAccessException e) - { - CraftGuideLog.log(e); - } - catch(ClassNotFoundException e) - { - CraftGuideLog.log(e); - } - - loadModRecipes("BTW", "uristqwerty.CraftGuide.recipes.BTWRecipes"); - addIC2Recipes(); - loadModRecipes("gregtech_addon", "uristqwerty.CraftGuide.recipes.GregTechRecipes"); - loadModRecipes("extendedWorkbench", "uristqwerty.CraftGuide.recipes.ExtendedWorkbench"); - loadModRecipes("BuildCraft|Factory", "uristqwerty.CraftGuide.recipes.BuildCraftRecipes"); - side.initNetworkChannels(); - } - - private void addIC2Recipes() - { - try - { - Class.forName("ic2.core.block.machine.tileentity.TileEntityMetalFormer"); - loadModRecipes("IC2", "uristqwerty.CraftGuide.recipes.IC2ExperimentalRecipes"); - } - catch(ClassNotFoundException e) - { - loadModRecipes("IC2", "uristqwerty.CraftGuide.recipes.IC2Recipes"); - } - } - - private void loadModRecipes(String modID, String recipeClass) - { - if(loaderSide.isModLoaded(modID)) - { - try - { - Class.forName(recipeClass).newInstance(); - } - catch(ClassNotFoundException e) - { - CraftGuideLog.log(e); - } - catch(Exception e) - { - CraftGuideLog.log(e, "", true); - } - catch(LinkageError e) - { - CraftGuideLog.log(e, "", true); - } - } - } - - private void initForgeExtensions() - { - if(loaderSide.isModLoaded("Forge")) - { - try - { - RecipeGeneratorImplementation.forgeExt = (RecipeGeneratorForgeExtension)Class.forName("uristqwerty.CraftGuide.ForgeStuff").newInstance(); - } - catch(InstantiationException e) - { - CraftGuideLog.log(e); - } - catch(IllegalAccessException e) - { - CraftGuideLog.log(e); - } - catch(ClassNotFoundException e) - { - CraftGuideLog.log(e); - } - } - } - - private void addItem(String iconName) - { - itemCraftGuide = new ItemCraftGuide(iconName); - loaderSide.addName(itemCraftGuide, "Crafting Guide"); - - if(enableItemRecipe) - { - loaderSide.addRecipe(new ItemStack(itemCraftGuide), new Object[] {"pbp", - "bcb", "pbp", Character.valueOf('c'), Blocks.crafting_table, - Character.valueOf('p'), Items.paper, Character.valueOf('b'), - Items.book}); - } - } - - static - { - configComments = new HashMap(); - configComments.put("newerBackgroundStyle", "If false, CraftGuide will use the images from CraftGuideRecipe.png for vanilla shaped crafting recipes, which is better for texture packs. If true, CraftGuide will use the default background (pieced together from parts of CraftGuide.png, then slot backgrounds drawn overtop), which is worse for texture packs, and looks identical without a texture pack."); - configComments.put("hideMundanePotionRecipes", "Hides recipes that convert a useful potion into a mundane potion with the damage value 8192, which is basically a failed potion. In the vanilla ingredients, they only occur when you try to add an effect without first adding netherwart (or add a second effect ingredient without using netherwart in between). Note that 8192 means, to the vanilla brewing system 'can make a splash potion without losing it's effects', and a potion with a value of EXACTLY 8192 does not have any effects anyway."); - configComments.put("logThemeDebugInfo", "If true, CraftGuide will output a lot of debugging text every time it reloads the themes."); - configComments.put("gridPacking", "Affects whether CraftGuide distributes leftover horizontal space between columns, or puts it all at the far right. Currently not useful, as any grid with columns now resizes itself so that it doesn't have any leftover horizntal space that needs to be distributed."); - configComments.put("resizeRate", "If greater than 0, the maximum number of pixels that the CraftGuide window will change size by each frame. When the effect was actually tried in-game, it just made the GUI feel slow, so defaults to 0 ('ALL the pixels!')."); - configComments.put("textSearchRequiresShift", "Normally, when typing in the item list search box, pressing enter instantly returns to the recipe list, using whatever you had typed as the text filter. If this option is true, you also have to hold shift, to avoid accidentally searching."); - configComments.put("RecipeList_mouseWheelScrollRate", "How many rows to scroll for each unit of mouse wheel scrolliness."); - configComments.put("enableItemRecipe", "Whether you can craft the CraftGuide item."); - configComments.put("enableKeybind", "Whether CraftGuide sets up a keybind so that you can open it without the item."); - configComments.put("PauseWhileOpen", "In singleplayer, whether the game is paused while you have CraftGuide open. If false, you can browse recipes while waiting for your machines to run, but it also means that a ninja creeper may be able to sneak up behind you while you are distracted."); - configComments.put("alwaysShowID", "If true, item tooltips have an additional line showing their item ID and damage value. Added before the vanilla F3+H, it has a different format, and puts the item ID on a separate line from the item name. If this setting is false, CraftGuide will only show item IDs in this way in the rare case of an item error"); - configComments.put("defaultKeybind", "If Minecraft isn't properly loading changed keybinds, or you are putting together a config/modpack and want a different default value, you can change the default CraftGuide keybind here."); - } - - private void setConfigDefaults() - { - config.setProperty("RecipeList_mouseWheelScrollRate", "3"); - config.setProperty("PauseWhileOpen", Boolean.toString(true)); - config.setProperty("resizeRate", "0"); - config.setProperty("gridPacking", Boolean.toString(true)); - config.setProperty("alwaysShowID", Boolean.toString(false)); - config.setProperty("textSearchRequiresShift", Boolean.toString(false)); - config.setProperty("enableKeybind", Boolean.toString(true)); - config.setProperty("enableItemRecipe", Boolean.toString(true)); - config.setProperty("newerBackgroundStyle", Boolean.toString(false)); - config.setProperty("hideMundanePotionRecipes", Boolean.toString(true)); - config.setProperty("insertBetterWithRenewablesRecipes", Boolean.toString(false)); - config.setProperty("logThemeDebugInfo", Boolean.toString(false)); - config.setProperty("defaultKeybind", Integer.toString(Keyboard.KEY_G)); - } - - /** - * Load configuration. If a configuration file exists in the new - * location, load from there. If not, but one exists in the old - * location, use that instead. If neither exists, just use the - * defaults. - * - * Afterwards, save it back to the new configuration directory - * (to create it if it doesn't exist, or to update it if it was - * created by an earlier version of CraftGuide that didn't have - * exactly the same set of properties). - */ - private void loadProperties() - { - File oldConfigDir = loaderSide.getConfigDir(); - File oldConfigFile = new File(oldConfigDir, "CraftGuide.cfg"); - File newConfigDir = configDirectory(); - File newConfigFile = newConfigDir == null? null : new File(newConfigDir, "CraftGuide.cfg"); - File configFile = null; - - if(newConfigFile != null && newConfigFile.exists()) - { - configFile = newConfigFile; - } - else if(oldConfigFile.exists() && oldConfigFile.canRead()) - { - configFile = oldConfigFile; - } - - setConfigDefaults(); - - if(configFile != null && configFile.exists() && configFile.canRead()) - { - try - { - config.load(new FileInputStream(configFile)); - } - catch(FileNotFoundException e) - { - e.printStackTrace(); - } - catch(IOException e) - { - e.printStackTrace(); - } - } - - try - { - resizeRate = Integer.valueOf(config.getProperty("resizeRate")); - } - catch(NumberFormatException e) - { - } - - try - { - mouseWheelScrollRate = Integer.valueOf(config - .getProperty("RecipeList_mouseWheelScrollRate")); - } - catch(NumberFormatException e) - { - } - - try - { - defaultKeybind = Integer.valueOf(config.getProperty("defaultKeybind")); - } - catch(NumberFormatException e) - { - } - - pauseWhileOpen = Boolean.valueOf(config.getProperty("PauseWhileOpen")); - gridPacking = Boolean.valueOf(config.getProperty("gridPacking")); - alwaysShowID = Boolean.valueOf(config.getProperty("alwaysShowID")); - textSearchRequiresShift = Boolean.valueOf(config.getProperty("textSearchRequiresShift")); - enableKeybind = Boolean.valueOf(config.getProperty("enableKeybind")); - newerBackgroundStyle = Boolean.valueOf(config.getProperty("newerBackgroundStyle")); - hideMundanePotionRecipes = Boolean.valueOf(config.getProperty("hideMundanePotionRecipes")); - insertBetterWithRenewablesRecipes = Boolean.valueOf(config.getProperty("insertBetterWithRenewablesRecipes")); - ThemeManager.debugOutput = Boolean.valueOf(config.getProperty("logThemeDebugInfo")); - enableItemRecipe = Boolean.valueOf(config.getProperty("enableItemRecipe")); - - if(newConfigFile != null && !newConfigFile.exists()) - { - try - { - newConfigFile.createNewFile(); - } - catch(IOException e) - { - e.printStackTrace(); - } - } - - if(newConfigFile != null && newConfigFile.exists() && newConfigFile.canWrite()) - { - try - { - saveConfig(new FileOutputStream(newConfigFile)); - } - catch(IOException e) - { - e.printStackTrace(); - } - } - } - - // config.store() does not permit per-setting comments. - private void saveConfig(OutputStream outputStream) throws IOException - { - Set properties = config.stringPropertyNames(); - - BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outputStream)); - - writer.write("# "); - writer.write(new Date().toString()); - writer.newLine(); - - for(String property: properties) - { - if(configComments.containsKey(property)) - { - writer.newLine(); - writer.write("# "); - writer.write(configComments.get(property)); - writer.newLine(); - writer.write(property); - writer.write('='); - writer.write(config.getProperty(property)); - writer.newLine(); - } - } - - writer.newLine(); - - for(String property: properties) - { - if(!configComments.containsKey(property)) - { - writer.write(property); - writer.write('='); - writer.write(config.getProperty(property)); - writer.newLine(); - } - } - - writer.close(); - } - - public static File configDirectory() - { - File dir = new File(loaderSide.getConfigDir(), "CraftGuide"); - - if(!dir.exists() && !dir.mkdirs()) - { - return null; - } - - return dir; - } - - public static String getTranslation(String string) - { - if(string.equals("filter_type.input")) - { - return "Input"; - } - else if(string.equals("filter_type.output")) - { - return "Output"; - } - else if(string.equals("filter_type.machine")) - { - return "Machine"; - } - else if(string.equals("filter")) - { - return "Filter"; - } - else - { - return null; - } - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/CraftGuideLoaderSide.java b/src/api/java/uristqwerty/CraftGuide/CraftGuideLoaderSide.java deleted file mode 100644 index 9aa4a8f13..000000000 --- a/src/api/java/uristqwerty/CraftGuide/CraftGuideLoaderSide.java +++ /dev/null @@ -1,17 +0,0 @@ -package uristqwerty.CraftGuide; - -import java.io.File; - -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -public interface CraftGuideLoaderSide -{ - public boolean isModLoaded(String name); - public File getConfigDir(); - public void addRecipe(ItemStack itemStack, Object[] objects); - public void addName(Item item, String name); - public void logConsole(String text); - public void logConsole(String text, Throwable e); - public void initClientNetworkChannels(); -} diff --git a/src/api/java/uristqwerty/CraftGuide/CraftGuideLog.java b/src/api/java/uristqwerty/CraftGuide/CraftGuideLog.java deleted file mode 100644 index 7cd4da1d8..000000000 --- a/src/api/java/uristqwerty/CraftGuide/CraftGuideLog.java +++ /dev/null @@ -1,66 +0,0 @@ -package uristqwerty.CraftGuide; - -import java.io.File; -import java.io.IOException; -import java.io.PrintWriter; - -public class CraftGuideLog -{ - private static PrintWriter output; - private static int exceptionsLogged = 0; - private static final int EXCEPTION_LIMIT = 1000; - - public static void init(File file) - { - try - { - output = new PrintWriter(file); - } - catch(IOException e) - { - e.printStackTrace(); - } - } - - public static void log(String text) - { - log(text, false); - } - - public static void log(String text, boolean console) - { - if(console && CraftGuide.loaderSide != null) - { - CraftGuide.loaderSide.logConsole(text); - } - - output.println(text); - output.flush(); - } - - public static void log(Throwable e) - { - log(e, "", false); - } - - public static void log(Throwable e, String text, boolean console) - { - if(exceptionsLogged <= EXCEPTION_LIMIT) - { - if(console && CraftGuide.loaderSide != null) - { - CraftGuide.loaderSide.logConsole(text, e); - } - - e.printStackTrace(output); - output.flush(); - - if(exceptionsLogged == EXCEPTION_LIMIT) - { - log("Exception limit passed. To prevent excessively large log files, no further exceptions will be logged."); - } - - exceptionsLogged++; - } - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/CraftGuideSide.java b/src/api/java/uristqwerty/CraftGuide/CraftGuideSide.java deleted file mode 100644 index 24c897afb..000000000 --- a/src/api/java/uristqwerty/CraftGuide/CraftGuideSide.java +++ /dev/null @@ -1,21 +0,0 @@ -package uristqwerty.CraftGuide; - -import net.minecraft.entity.player.EntityPlayer; - -public interface CraftGuideSide -{ - public void initKeybind(); - public void checkKeybind(); - public void preInit(); - public void reloadRecipes(); - public void openGUI(EntityPlayer player); - public void initNetworkChannels(); - - /* Ensure that Tessellator isn't drawing. More to prevent an otherwise nonfatal - * rendering errors from crashing Minecraft entirely. Better for CraftGuide to - * be unusable (invisible items, offset stuff, other graphical glitches), than - * to dump the player back to windows. Since keyboard input not affected by - * render issues, you can always exit the GUI and continue playing without it. - */ - public void stopTessellating(); -} diff --git a/src/api/java/uristqwerty/CraftGuide/CraftGuide_FML.java b/src/api/java/uristqwerty/CraftGuide/CraftGuide_FML.java deleted file mode 100644 index 87b2e5cea..000000000 --- a/src/api/java/uristqwerty/CraftGuide/CraftGuide_FML.java +++ /dev/null @@ -1,103 +0,0 @@ -package uristqwerty.CraftGuide; - -import java.io.File; - -import org.apache.logging.log4j.Level; -import org.apache.logging.log4j.Logger; - -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.Mod; -import cpw.mods.fml.common.Mod.EventHandler; -import cpw.mods.fml.common.SidedProxy; -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.common.gameevent.TickEvent; - -@Mod(modid = "craftguide", name = "CraftGuide", version = "1.5.2") -public class CraftGuide_FML implements CraftGuideLoaderSide -{ - private static Logger logger; - - @SidedProxy(clientSide = "uristqwerty.CraftGuide.client.fml.CraftGuideClient_FML", - serverSide = "uristqwerty.CraftGuide.server.CraftGuideServer") - public static CraftGuideSide side; - - private CraftGuide craftguide; - - public static class KeyCheckTick - { - @SubscribeEvent - public void clientTick(TickEvent.ClientTickEvent event) - { - side.checkKeybind(); - } - } - - @EventHandler - public void preInit(FMLPreInitializationEvent event) - { - logger = event.getModLog(); - CraftGuide.loaderSide = this; - CraftGuide.side = side; - craftguide = new CraftGuide(); - craftguide.preInit("craftguide:craftguide_item"); - - FMLCommonHandler.instance().bus().register(new KeyCheckTick()); - } - - @EventHandler - public void init(FMLInitializationEvent event) - { - craftguide.init(); - } - - - - @Override - public boolean isModLoaded(String name) - { - return Loader.isModLoaded(name); - } - - @Override - public File getConfigDir() - { - return Loader.instance().getConfigDir(); - } - - @Override - public void addRecipe(ItemStack output, Object[] recipe) - { - GameRegistry.addRecipe(output, recipe); - } - - @Override - public void addName(Item item, String name) - { - //LanguageRegistry.addName(item, name); - } - - @Override - public void logConsole(String text) - { - logger.log(Level.INFO, text); - } - - @Override - public void logConsole(String text, Throwable e) - { - logger.log(Level.WARN, text, e); - } - - @Override - public void initClientNetworkChannels() - { - // TODO Auto-generated method stub - - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/CraftType.java b/src/api/java/uristqwerty/CraftGuide/CraftType.java deleted file mode 100644 index bf70b91e2..000000000 --- a/src/api/java/uristqwerty/CraftGuide/CraftType.java +++ /dev/null @@ -1,166 +0,0 @@ -package uristqwerty.CraftGuide; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -public class CraftType implements Comparable -{ - private static Map> cache = new HashMap>(); - private static Map arrayListCache = new HashMap(); - private int itemID, damage; - private Item item; - private Object stack; - - private CraftType(Item item, int itemDamage) - { - this.item = item; - itemID = Item.getIdFromItem(item); - damage = itemDamage; - stack = new ItemStack(item, 1, damage); - } - - private CraftType(ArrayList items) - { - ItemStack itemStack = items.get(0); - item = itemStack.getItem(); - itemID = Item.getIdFromItem(item); - damage = CommonUtilities.getItemDamage(itemStack); - stack = items; - } - - public static CraftType getInstance(Object stack) - { - if(stack instanceof ItemStack) - { - return getInstance((ItemStack)stack); - } - else if(stack instanceof ArrayList && ((ArrayList)stack).size() > 0) - { - return getInstance((ArrayList)stack); - } - else - { - return null; - } - } - - private static CraftType getInstance(ArrayList stack) - { - CraftType type = arrayListCache.get(stack); - - if(type == null) - { - type = new CraftType(stack); - arrayListCache.put(stack, type); - } - - return type; - } - - private static CraftType getInstance(ItemStack stack) - { - int id = Item.getIdFromItem(stack.getItem()); - Map map = cache.get(id); - - if(map == null) - { - map = new HashMap(); - cache.put(id, map); - } - - CraftType type = map.get(CommonUtilities.getItemDamage(stack)); - - if(type == null) - { - type = new CraftType(stack.getItem(), CommonUtilities.getItemDamage(stack)); - map.put(CommonUtilities.getItemDamage(stack), type); - } - - return type; - } - - public static boolean hasInstance(ItemStack stack) - { - int id = Item.getIdFromItem(stack.getItem()); - if(!cache.containsKey(id)) - { - return false; - } - - return cache.get(id).containsKey(CommonUtilities.getItemDamage(stack)); - } - - @Override - public int compareTo(CraftType other) - { - if(this.itemID != other.itemID) - { - return this.itemID > other.itemID? 1 : -1; - } - else if(this.damage != other.damage) - { - return this.damage > other.damage? 1 : -1; - } - else if((this.stack instanceof ArrayList) != (other.stack instanceof ArrayList)) - { - return (this.stack instanceof ArrayList)? -1 : 1; - } - - return 0; - } - - @Override - public boolean equals(Object obj) - { - if(obj != null && obj instanceof CraftType) - { - CraftType type = (CraftType)obj; - - if(stack instanceof ItemStack && type.stack instanceof ItemStack) - { - return type.itemID == this.itemID && type.damage == this.damage; - } - else if(stack instanceof ArrayList && type.stack instanceof ArrayList) - { - return stack.equals(type.stack); - } - else - { - return false; - } - } - - return super.equals(obj); - } - - @Override - public int hashCode() - { - return damage * 3571 + itemID; - } - - public Object getStack() - { - return stack; - } - - public ItemStack getDisplayStack() - { - if(stack instanceof ItemStack) - { - return (ItemStack)stack; - } - else if(stack instanceof ArrayList) - { - return (ItemStack)((ArrayList)stack).get(0); - } - else - { - return null; - } - } -} \ No newline at end of file diff --git a/src/api/java/uristqwerty/CraftGuide/DefaultRecipeTemplate.java b/src/api/java/uristqwerty/CraftGuide/DefaultRecipeTemplate.java deleted file mode 100644 index 74f7fb393..000000000 --- a/src/api/java/uristqwerty/CraftGuide/DefaultRecipeTemplate.java +++ /dev/null @@ -1,53 +0,0 @@ -package uristqwerty.CraftGuide; - -import net.minecraft.item.ItemStack; -import uristqwerty.CraftGuide.api.CraftGuideRecipe; -import uristqwerty.CraftGuide.api.RecipeTemplate; -import uristqwerty.CraftGuide.api.Slot; -import uristqwerty.gui_craftguide.rendering.Renderable; -import uristqwerty.gui_craftguide.rendering.TexturedRect; -import uristqwerty.gui_craftguide.texture.Texture; - -public class DefaultRecipeTemplate implements RecipeTemplate -{ - private Slot[] slots; - private Texture backgroundTexture, backgroundSelectedTexture; - private Renderable background, backgroundSelected; - private int width = 79, height = 58; - - private ItemStack craftingType; - - public DefaultRecipeTemplate(Slot[] slots, ItemStack craftingType, Texture background, Texture backgroundSelected) - { - this.slots = slots; - this.backgroundTexture = background; - this.backgroundSelectedTexture = backgroundSelected; - this.background = new TexturedRect(0, 0, width, height, background, 0, 0); - this.backgroundSelected = new TexturedRect(0, 0, width, height, backgroundSelected, 0, 0); - this.craftingType = craftingType; - } - - @Override - public CraftGuideRecipe generate(Object[] items) - { - return new Recipe(slots, items, background, backgroundSelected).setSize(width, height); - } - - @Override - public RecipeTemplate setSize(int width, int height) - { - this.width = width; - this.height = height; - - background = new TexturedRect(0, 0, width, height, backgroundTexture, 0, 0); - backgroundSelected = new TexturedRect(0, 0, width, height, backgroundSelectedTexture, 0, 0); - - return this; - } - - @Override - public ItemStack getCraftingType() - { - return craftingType; - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/ForgeStuff.java b/src/api/java/uristqwerty/CraftGuide/ForgeStuff.java deleted file mode 100644 index 354fa43f6..000000000 --- a/src/api/java/uristqwerty/CraftGuide/ForgeStuff.java +++ /dev/null @@ -1,143 +0,0 @@ -package uristqwerty.CraftGuide; - -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.IdentityHashMap; -import java.util.List; -import java.util.Map.Entry; - -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraftforge.oredict.OreDictionary; -import net.minecraftforge.oredict.ShapedOreRecipe; -import net.minecraftforge.oredict.ShapelessOreRecipe; -import uristqwerty.CraftGuide.RecipeGeneratorImplementation.RecipeGeneratorForgeExtension; - -public class ForgeStuff implements RecipeGeneratorForgeExtension -{ - @Override - public boolean matchesType(IRecipe recipe) - { - return recipe instanceof ShapedOreRecipe || recipe instanceof ShapelessOreRecipe; - } - - @Override - public boolean isShapelessRecipe(IRecipe recipe) - { - return recipe instanceof ShapelessOreRecipe; - } - - @Override - public Object[] getCraftingRecipe(RecipeGeneratorImplementation gen, IRecipe recipe, boolean allowSmallGrid) - { - try - { - if(recipe instanceof ShapedOreRecipe) - { - int width = (Integer)CommonUtilities.getPrivateValue(ShapedOreRecipe.class, (ShapedOreRecipe)recipe, "width"); - int height = (Integer)CommonUtilities.getPrivateValue(ShapedOreRecipe.class, (ShapedOreRecipe)recipe, "height"); - Object[] items = (Object[])CommonUtilities.getPrivateValue(ShapedOreRecipe.class, (ShapedOreRecipe)recipe, "input"); - - if(allowSmallGrid && width < 3 && height < 3) - { - return gen.getSmallShapedRecipe(width, height, items, ((ShapedOreRecipe)recipe).getRecipeOutput()); - } - else - { - return gen.getCraftingShapedRecipe(width, height, items, ((ShapedOreRecipe)recipe).getRecipeOutput()); - } - } - else if(recipe instanceof ShapelessOreRecipe) - { - List items = (List)CommonUtilities.getPrivateValue(ShapelessOreRecipe.class, (ShapelessOreRecipe)recipe, "input"); - return gen.getCraftingShapelessRecipe(items, ((ShapelessOreRecipe)recipe).getRecipeOutput()); - } - } - catch(SecurityException e) - { - CraftGuideLog.log(e); - } - catch(NoSuchFieldException e) - { - CraftGuideLog.log(e); - } - catch(IllegalArgumentException e) - { - CraftGuideLog.log(e); - } - catch(IllegalAccessException e) - { - CraftGuideLog.log(e); - } - - return null; - } - - private IdentityHashMap mappingCache = new IdentityHashMap(); - - @Override - public List emptyOreDictEntryText(List oreDictionaryList) - { - if(!mappingCache.containsKey(oreDictionaryList)) - { - mappingCache.put(oreDictionaryList, getOreDictName(oreDictionaryList)); - } - - String name = mappingCache.get(oreDictionaryList); - - if(name == null) - { - return null; - } - else - { - List text = new ArrayList(1); - text.add("0 items for Ore Dictionary name '" + name + "'"); - return text; - } - } - - private String getOreDictName(List list) - { - try - { - Field oreStacks = OreDictionary.class.getDeclaredField("oreStacks"); - oreStacks.setAccessible(true); - HashMap> map = (HashMap>)oreStacks.get(null); - Integer integer = null; - - for(Entry> entry: map.entrySet()) - { - if(entry.getValue() == list) - { - integer = entry.getKey(); - break; - } - } - - if(integer != null) - { - return OreDictionary.getOreName(integer); - } - } - catch(NoSuchFieldException e) - { - e.printStackTrace(); - } - catch(SecurityException e) - { - e.printStackTrace(); - } - catch(IllegalArgumentException e) - { - e.printStackTrace(); - } - catch(IllegalAccessException e) - { - e.printStackTrace(); - } - - return null; - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/GuiCraftGuide.java b/src/api/java/uristqwerty/CraftGuide/GuiCraftGuide.java deleted file mode 100644 index df833896c..000000000 --- a/src/api/java/uristqwerty/CraftGuide/GuiCraftGuide.java +++ /dev/null @@ -1,530 +0,0 @@ -package uristqwerty.CraftGuide; - -import java.util.EnumMap; -import java.util.Map; - -import net.minecraft.client.Minecraft; -import net.minecraft.item.ItemStack; - -import org.lwjgl.input.Keyboard; - -import uristqwerty.CraftGuide.api.SlotType; -import uristqwerty.CraftGuide.api.Util; -import uristqwerty.CraftGuide.client.FilterDisplay; -import uristqwerty.CraftGuide.client.ui.ButtonTemplate; -import uristqwerty.CraftGuide.client.ui.CraftTypeDisplay; -import uristqwerty.CraftGuide.client.ui.CraftingDisplay; -import uristqwerty.CraftGuide.client.ui.FilterSelectGrid; -import uristqwerty.CraftGuide.client.ui.GuiButton; -import uristqwerty.CraftGuide.client.ui.GuiButton.ButtonState; -import uristqwerty.CraftGuide.client.ui.GuiResizeHandle; -import uristqwerty.CraftGuide.client.ui.GuiScrollBar; -import uristqwerty.CraftGuide.client.ui.GuiSlider; -import uristqwerty.CraftGuide.client.ui.GuiTabbedDisplay; -import uristqwerty.CraftGuide.client.ui.GuiText; -import uristqwerty.CraftGuide.client.ui.GuiTextInput; -import uristqwerty.CraftGuide.client.ui.IButtonListener; -import uristqwerty.CraftGuide.client.ui.RowCount; -import uristqwerty.CraftGuide.client.ui.ToggleButton; -import uristqwerty.gui_craftguide.components.GuiElement; -import uristqwerty.gui_craftguide.components.GuiElement.AnchorPoint; -import uristqwerty.gui_craftguide.components.Image; -import uristqwerty.gui_craftguide.components.Window; -import uristqwerty.gui_craftguide.minecraft.Gui; -import uristqwerty.gui_craftguide.texture.DynamicTexture; -import uristqwerty.gui_craftguide.texture.Texture; -import uristqwerty.gui_craftguide.texture.TextureClip; - -public class GuiCraftGuide extends Gui -{ - private RecipeCache recipeCache = new RecipeCache(); - private FilterDisplay filter; - private CraftingDisplay craftingDisplay; - private Window guiOverlay; - - private static GuiCraftGuide instance; - - private Texture paneBackground = DynamicTexture.instance("pane"); - private Texture windowBackground = DynamicTexture.instance("window"); - - public static Map filterSlotTypes = new EnumMap(SlotType.class); - - static - { - filterSlotTypes.put(SlotType.INPUT_SLOT, true); - filterSlotTypes.put(SlotType.OUTPUT_SLOT, true); - filterSlotTypes.put(SlotType.MACHINE_SLOT, false); - } - - public static GuiCraftGuide getInstance() - { - if(instance == null) - { - instance = new GuiCraftGuide(); - } - - return instance; - } - - public void setFilterItem(ItemStack item) - { - try - { - recipeCache.filter(Util.instance.getCommonFilter(item.copy())); - } - catch(Exception e) - { - CraftGuideLog.log(e, "Error while trying to filter displayed recipes.", true); - } - } - - private static final int initialWindowWidth = 248; - private static final int initialWindowHeight = 198; - - public GuiCraftGuide() - { - super(initialWindowWidth, initialWindowHeight); - - Texture texture = DynamicTexture.instance("base_image"); - - ButtonTemplate buttonTemplate = new ButtonTemplate( - new Texture[]{ - DynamicTexture.instance("button_up"), - DynamicTexture.instance("button_over"), - DynamicTexture.instance("button_up"), - DynamicTexture.instance("button_down"), - }); - - guiWindow.background = windowBackground; - - guiWindow.addElement( - new GuiResizeHandle( - initialWindowWidth - 8, initialWindowHeight - 8, 8, 8, - guiWindow - )); - - guiWindow.addElement( - new GuiButton(initialWindowWidth - 8, initialWindowHeight - 8, 8, 8, texture, 0, 191) - .anchor(AnchorPoint.BOTTOM_RIGHT)); - - guiWindow.addElement( - new GuiElement(5, 5, 58, 86) - .setBackground(paneBackground)); - - guiWindow.addElement( - new GuiTabbedDisplay(0, 0, initialWindowWidth, initialWindowHeight) - .addTab( - generateRecipeTab(texture, buttonTemplate) - .anchor(AnchorPoint.TOP_LEFT, AnchorPoint.BOTTOM_RIGHT), - (GuiButton)new GuiButton(6, 6, 28, 28, buttonTemplate) - .setToolTip("Recipe list") - .addElement(new GuiElement(0, 0, 28,28) - .setBackground(new TextureClip(texture, 1, 76, 28,28)) - .setClickable(false))) - .addTab( - generateTypeTab(texture, buttonTemplate) - .anchor(AnchorPoint.TOP_LEFT, AnchorPoint.BOTTOM_RIGHT), - (GuiButton)new GuiButton(34, 6, 28, 28, buttonTemplate) - .setToolTip("Show/Hide recipes by crafting type") - .addElement(new GuiElement(0, 0, 28,28) - .setBackground(new TextureClip(texture, 29, 76, 28,28)) - .setClickable(false))) - .anchor(AnchorPoint.TOP_LEFT, AnchorPoint.BOTTOM_RIGHT) - .setClickable(false)); - - - guiOverlay = new Window(0, 0, 0, 0, renderer); - - /*guiOverlay.addElement( - new GuiBorderedRect( - 0, 0, 0, 0, - texture, 78, 1, 2, 32 - ) - .anchor(AnchorPoint.TOP_LEFT, AnchorPoint.BOTTOM_RIGHT) - );*/ - } - - private GuiElement generateRecipeTab(Texture texture, ButtonTemplate buttonTemplate) - { - GuiElement recipeTab = new GuiElement(0, 0, initialWindowWidth, initialWindowHeight) - .setClickable(false); - - ButtonTemplate toggleTemplate = new ButtonTemplate( - new Texture[]{ - DynamicTexture.instance("toggle_off"), - DynamicTexture.instance("toggle_off_over"), - DynamicTexture.instance("toggle_on"), - DynamicTexture.instance("toggle_on_over"), - }); - - recipeTab.addElement( - new GuiElement(initialWindowWidth - 19, 5, 14, initialWindowHeight - 10) - .setBackground(paneBackground) - .anchor(AnchorPoint.TOP_RIGHT, AnchorPoint.BOTTOM_RIGHT)); - - - recipeTab.addElement( - new ToggleButton(8, 100, 13, 13, toggleTemplate) - .setState(filterSlotTypes.get(SlotType.INPUT_SLOT)? ButtonState.DOWN : ButtonState.UP) - .addButtonListener(new FilterToggle(SlotType.INPUT_SLOT)) - .anchor(AnchorPoint.BOTTOM_LEFT) - .addElement( - new GuiText(15, 3, CraftGuide.getTranslation("filter_type.input"), 0xff000000))); - - - recipeTab.addElement( - new ToggleButton(8, 115, 13, 13, toggleTemplate) - .setState(filterSlotTypes.get(SlotType.OUTPUT_SLOT)? ButtonState.DOWN : ButtonState.UP) - .addButtonListener(new FilterToggle(SlotType.OUTPUT_SLOT)) - .anchor(AnchorPoint.BOTTOM_LEFT) - .addElement( - new GuiText(15, 3, CraftGuide.getTranslation("filter_type.output"), 0xff000000))); - - recipeTab.addElement( - new ToggleButton(8, 130, 13, 13, toggleTemplate) - .setState(filterSlotTypes.get(SlotType.MACHINE_SLOT)? ButtonState.DOWN : ButtonState.UP) - .addButtonListener(new FilterToggle(SlotType.MACHINE_SLOT)) - .anchor(AnchorPoint.BOTTOM_LEFT) - .addElement( - new GuiText(15, 3, CraftGuide.getTranslation("filter_type.machine"), 0xff000000))); - - GuiButton clearButton = - (GuiButton) new GuiButton(8, initialWindowHeight - 18, 50, 13, buttonTemplate, "Clear") - .anchor(AnchorPoint.BOTTOM_LEFT); - - recipeTab.addElement(clearButton); - - recipeTab.addElement( - new GuiText(9, 151, CraftGuide.getTranslation("filter"), 0xff000000) - .anchor(AnchorPoint.BOTTOM_LEFT)); - - recipeTab.addElement( - new Image(40, 146, 18, 18, texture, 238, 219) - .anchor(AnchorPoint.BOTTOM_LEFT)); - - filter = new FilterDisplay(41, 147); - filter.anchor(AnchorPoint.BOTTOM_LEFT); - recipeTab.addElement(filter); - - GuiElement recipeArea = new GuiElement(0, 0, initialWindowWidth, initialWindowHeight) - .anchor(AnchorPoint.TOP_LEFT, AnchorPoint.BOTTOM_RIGHT) - .setClickable(false); - - GuiElement itemListArea = new GuiElement(0, 0, initialWindowWidth, initialWindowHeight) - .anchor(AnchorPoint.TOP_LEFT, AnchorPoint.BOTTOM_RIGHT) - .setClickable(false); - - GuiButton backButton = - (GuiButton) new GuiButton(8, 166, 50, 13, buttonTemplate, "Back") - .anchor(AnchorPoint.BOTTOM_LEFT); - - GuiButton itemListButton = - (GuiButton) new GuiButton(8, 166, 50, 13, buttonTemplate, "Set item") - .anchor(AnchorPoint.BOTTOM_LEFT); - - itemListArea.addElement(backButton); - recipeArea.addElement(itemListButton); - - GuiTabbedDisplay recipeDisplay = - (GuiTabbedDisplay) new GuiTabbedDisplay(0, 0, initialWindowWidth, initialWindowHeight) - .addTab(recipeArea, backButton, false) - .addTab(itemListArea, itemListButton, false) - .anchor(AnchorPoint.TOP_LEFT, AnchorPoint.BOTTOM_RIGHT) - .setClickable(false); - - recipeTab.addElement(recipeDisplay); - - GuiScrollBar filterSelectScrollBar = - (GuiScrollBar) new GuiScrollBar(initialWindowWidth - 18, 6, 12, 186, - (GuiSlider) new GuiSlider(0, 21, 12, 144, 12, 15, texture, 0, 199) - .anchor(AnchorPoint.TOP_LEFT, AnchorPoint.BOTTOM_RIGHT)) - .addButton(new GuiButton(0, 0, 12, 11, texture, 0, 234), -10, true) - .addButton(new GuiButton(0, 11, 12, 10, texture, 0, 214), -1, true) - .addButton( - (GuiButton)new GuiButton(0, 165, 12, 10, texture, 0, 224) - .anchor(AnchorPoint.BOTTOM_RIGHT), - 1, true) - .addButton( - (GuiButton)new GuiButton(0, 175, 12, 11, texture, 0, 245) - .anchor(AnchorPoint.BOTTOM_RIGHT), - 10, true) - .anchor(AnchorPoint.TOP_RIGHT, AnchorPoint.BOTTOM_RIGHT); - - itemListArea.addElement(filterSelectScrollBar); - - FilterSelectGrid filterGrid = - (FilterSelectGrid) new FilterSelectGrid(68, 18, initialWindowWidth - 90, 158, - filterSelectScrollBar, texture, - recipeCache, backButton, recipeDisplay) - .anchor(AnchorPoint.TOP_LEFT, AnchorPoint.BOTTOM_RIGHT) - .setBackground(paneBackground); - - itemListArea.addElement(new RowCount(initialWindowWidth - 23, 6, filterGrid).anchor(AnchorPoint.TOP_RIGHT)); - itemListArea.addElement(filterGrid); - - itemListArea.addElement( - new GuiText(68, 183, "Search", 0xff000000) - .anchor(AnchorPoint.BOTTOM_LEFT)); - - itemListArea.addElement( - new GuiElement(106, 179, initialWindowWidth - 163, 15) - .setBackground(paneBackground) - .anchor(AnchorPoint.BOTTOM_LEFT, AnchorPoint.BOTTOM_RIGHT) - ); - - GuiTextInput searchInput = - (GuiTextInput) new GuiTextInput(106, 179, 93, 15, 2, 2) - .addListener(filterGrid) - .anchor(AnchorPoint.BOTTOM_LEFT, AnchorPoint.BOTTOM_RIGHT); - - itemListButton.addButtonListener(searchInput); - - itemListArea.addElement(searchInput); - - class ClearButtonListener implements IButtonListener - { - private GuiTextInput textInput; - public ClearButtonListener(GuiTextInput textInput) - { - this.textInput = textInput; - } - @Override - public void onButtonEvent(GuiButton button, Event eventType) - { - textInput.setText(""); - } - } - - itemListArea.addElement( - new GuiButton(initialWindowWidth - 54, 180, 32, 13, buttonTemplate, "Clear") - .addButtonListener(new ClearButtonListener(searchInput)) - .anchor(AnchorPoint.BOTTOM_RIGHT)); - - GuiScrollBar scrollBar = - (GuiScrollBar) new GuiScrollBar(initialWindowWidth - 18, 6, 12, 186, - (GuiSlider) new GuiSlider(0, 21, 12, 144, 12, 15, texture, 0, 199) - .anchor(AnchorPoint.TOP_LEFT, AnchorPoint.BOTTOM_RIGHT)) - .addButton(new GuiButton(0, 0, 12, 11, texture, 0, 234), -10, true) - .addButton(new GuiButton(0, 11, 12, 10, texture, 0, 214), -1, true) - .addButton( - (GuiButton)new GuiButton(0, 165, 12, 10, texture, 0, 224) - .anchor(AnchorPoint.BOTTOM_RIGHT), - 1, true) - .addButton( - (GuiButton)new GuiButton(0, 175, 12, 11, texture, 0, 245) - .anchor(AnchorPoint.BOTTOM_RIGHT), - 10, true) - .anchor(AnchorPoint.TOP_RIGHT, AnchorPoint.BOTTOM_RIGHT); - - recipeArea.addElement(scrollBar); - - craftingDisplay = new CraftingDisplay(68, 18, initialWindowWidth - 90, 174, scrollBar, recipeCache); - recipeArea.addElement(new RowCount(initialWindowWidth - 23, 6, craftingDisplay).anchor(AnchorPoint.TOP_RIGHT)); - FilterClearCallback clearCallback = new FilterClearCallback(); - clearButton.addButtonListener(clearCallback); - clearCallback.display = craftingDisplay; - - craftingDisplay.anchor(AnchorPoint.TOP_LEFT, AnchorPoint.BOTTOM_RIGHT); - craftingDisplay.setBackground(paneBackground); - recipeArea.addElement(craftingDisplay); - - return recipeTab; - } - - private GuiElement generateTypeTab(Texture texture, ButtonTemplate buttonTemplate) - { - GuiElement typeTab = new GuiElement(0, 0, initialWindowWidth, initialWindowHeight) - .anchor(AnchorPoint.TOP_LEFT, AnchorPoint.BOTTOM_RIGHT) - .setClickable(false); - - typeTab.addElement( - new GuiElement(initialWindowWidth - 19, 5, 14, 188) - .setBackground(paneBackground) - .anchor(AnchorPoint.TOP_RIGHT, AnchorPoint.BOTTOM_RIGHT) - ); - - GuiScrollBar scrollBar = - new GuiScrollBar(initialWindowWidth - 18, 6, 12, 186, - (GuiSlider) new GuiSlider(0, 10, 12, 166, 12, 15, texture, 0, 199) - .anchor(AnchorPoint.TOP_LEFT, AnchorPoint.BOTTOM_RIGHT)) - .addButton(new GuiButton(0, 0, 12, 10, texture, 0, 214), -1, true) - .addButton( - (GuiButton) new GuiButton(0, 176, 12, 10, texture, 0, 224) - .anchor(AnchorPoint.BOTTOM_RIGHT), - 1, true); - - scrollBar.anchor(AnchorPoint.TOP_RIGHT, AnchorPoint.BOTTOM_RIGHT); - typeTab.addElement(scrollBar); - - typeTab.addElement( - new CraftTypeDisplay( - 68, 6, initialWindowWidth - 90, 186, scrollBar, texture, recipeCache - ) - .anchor(AnchorPoint.TOP_LEFT, AnchorPoint.BOTTOM_RIGHT) - .setBackground(paneBackground) - ); - - return typeTab; - } - - @Override - public void drawScreen(int mouseX, int mouseY, float f) - { - try - { - uristqwerty.gui_craftguide.minecraft.Image.initJarTextures(); - ((UtilImplementationCommon)Util.instance).partialTicks = f; - guiWindow.centerOn(width / 2, height / 2); - filter.setFilter(recipeCache.getFilter()); - - super.drawScreen(mouseX, mouseY, f); - } - catch(Exception e) - { - CraftGuideLog.log(e); - } - catch(Error e) - { - CraftGuideLog.log(e); - throw e; - } - - - CraftGuide.side.stopTessellating(); - } - - private class FilterClearCallback implements IButtonListener - { - CraftingDisplay display; - - @Override - public void onButtonEvent(GuiButton button, Event eventType) - { - if(eventType == Event.PRESS) - { - display.setFilter(null); - } - } - } - - private class FilterToggle implements IButtonListener - { - private final SlotType type; - - public FilterToggle(SlotType type) - { - this.type = type; - } - - @Override public void onButtonEvent(GuiButton button, Event eventType) - { - if(eventType == Event.PRESS) - { - GuiCraftGuide.filterSlotTypes.put(type, true); - } - else if(eventType == Event.RELEASE) - { - GuiCraftGuide.filterSlotTypes.put(type, false); - } - - recipeCache.filter(recipeCache.getFilter()); - } - } - - @Override - public void handleKeyboardInput() - { - try - { - if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) - { - GuiScrollBar.setScrollMultiplier(10); - } - else - { - GuiScrollBar.setScrollMultiplier(1); - } - - super.handleKeyboardInput(); - } - catch(Exception e) - { - CraftGuideLog.log(e); - } - catch(Error e) - { - CraftGuideLog.log(e); - throw e; - } - } - - @Override - public void handleMouseInput() - { - try - { - super.handleMouseInput(); - - } - catch(Exception e) - { - CraftGuideLog.log(e); - } - catch(Error e) - { - CraftGuideLog.log(e); - throw e; - } - } - - @Override - public int mouseWheelRate() - { - return CraftGuide.mouseWheelScrollRate; - } - - @Override - public boolean doesGuiPauseGame() - { - return CraftGuide.pauseWhileOpen; - } - - public void reloadRecipes() - { - recipeCache.reset(); - } - - public static void onTickInGame(float f, Minecraft minecraft) - { - if(instance != null) - { - instance.drawOverlay(f, minecraft); - } - } - - public void drawOverlay(float f, Minecraft minecraft) - { - renderer.startFrame(this); - guiOverlay.draw(); - renderer.endFrame(); - } - - @Override - public void onGuiClosed() - { - Keyboard.enableRepeatEvents(false); - super.onGuiClosed(); - } - - @Override - public void initGui() - { - super.initGui(); - Keyboard.enableRepeatEvents(true); - - if(CraftGuide.needsRecipeRefresh) - { - reloadRecipes(); - } - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/ItemCraftGuide.java b/src/api/java/uristqwerty/CraftGuide/ItemCraftGuide.java deleted file mode 100644 index 431b1d593..000000000 --- a/src/api/java/uristqwerty/CraftGuide/ItemCraftGuide.java +++ /dev/null @@ -1,52 +0,0 @@ -package uristqwerty.CraftGuide; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -import net.minecraft.creativetab.CreativeTabs; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.world.World; - -public class ItemCraftGuide extends Item -{ - public ItemCraftGuide(String iconName) - { - setUnlocalizedName("craftguide_item"); - - setTextureName(iconName); - setCreativeTab(CreativeTabs.tabMisc); - - registerItemName(); - } - - private void registerItemName() - { - try - { - Class registry = Class.forName("cpw.mods.fml.common.registry.GameRegistry"); - Method registerItem = registry.getMethod("registerItem", Item.class, String.class, String.class); - registerItem.invoke(null, this, "craftguide_item", "craftguide"); - } - catch(ClassNotFoundException e){} - catch(SecurityException e){} - catch(NoSuchMethodException e){} - catch(IllegalArgumentException e){} - catch(IllegalAccessException e){} - catch(InvocationTargetException e){} - } - - @Override - public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player) - { - CraftGuide.side.openGUI(player); - return itemstack; - } - - @Override - public int getColorFromItemStack(ItemStack par1ItemStack, int par2) - { - return 0x9999ff; - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/ItemSlotImplementationImplementation.java b/src/api/java/uristqwerty/CraftGuide/ItemSlotImplementationImplementation.java deleted file mode 100644 index 84dd3c3a3..000000000 --- a/src/api/java/uristqwerty/CraftGuide/ItemSlotImplementationImplementation.java +++ /dev/null @@ -1,175 +0,0 @@ -package uristqwerty.CraftGuide; - -import java.util.List; - -import net.minecraft.item.ItemStack; -import uristqwerty.CraftGuide.api.ItemFilter; -import uristqwerty.CraftGuide.api.ItemSlot; -import uristqwerty.CraftGuide.api.ItemSlotImplementation; -import uristqwerty.CraftGuide.api.NamedTexture; -import uristqwerty.CraftGuide.api.Renderer; -import uristqwerty.CraftGuide.api.SlotType; -import uristqwerty.CraftGuide.api.Util; - -/** - * It's a rather silly name, but since it's only directly used in one other class... - */ -public class ItemSlotImplementationImplementation implements ItemSlotImplementation -{ - private NamedTexture overlayAny; - private NamedTexture overlayForge; - private NamedTexture overlayForgeSingle; - private NamedTexture background; - - public ItemSlotImplementationImplementation() - { - overlayAny = Util.instance.getTexture("ItemStack-Any"); - overlayForge = Util.instance.getTexture("ItemStack-OreDict"); - overlayForgeSingle = Util.instance.getTexture("ItemStack-OreDict-Single"); - background = Util.instance.getTexture("ItemStack-Background"); - } - - @Override - public List getTooltip(ItemSlot itemSlot, Object data) - { - ItemStack stack = item(data); - - if(stack == null) - { - if(data instanceof List && ((List)data).size() < 1) - { - return emptyOreDictEntryText((List)data); - } - else - { - return null; - } - } - else - { - return CommonUtilities.getExtendedItemStackText(data); - } - } - - @Override - public void draw(ItemSlot itemSlot, Renderer renderer, int recipeX, int recipeY, Object data, boolean isMouseOver) - { - int x = recipeX + itemSlot.x; - int y = recipeY + itemSlot.y; - ItemStack stack = item(data); - - if(itemSlot.drawBackground) - { - renderer.renderRect(x - 1, y - 1, 18, 18, background); - } - - if(stack != null) - { - renderer.renderItemStack(x, y, stack); - - if(isMouseOver) - { - renderer.renderRect(x, y, 16, 16, 0xff, 0xff, 0xff, 0x80); - } - - if(CommonUtilities.getItemDamage(stack) == CraftGuide.DAMAGE_WILDCARD) - { - renderer.renderRect(x - 1, y - 1, 18, 18, overlayAny); - } - - if(data instanceof List) - { - if(((List)data).size() > 1) - { - renderer.renderRect(x - 1, y - 1, 18, 18, overlayForge); - } - else - { - renderer.renderRect(x - 1, y - 1, 18, 18, overlayForgeSingle); - } - } - } - else if(data instanceof List && ((List)data).size() < 1) - { - renderer.renderRect(x - 1, y - 1, 18, 18, overlayForge); - } - } - - private static ItemStack item(Object data) - { - if(data == null) - { - return null; - } - else if(data instanceof ItemStack) - { - return (ItemStack)data; - } - else if(data instanceof List && ((List)data).size() > 0) - { - return item(((List)data).get(0)); - } - - return null; - } - - @Override - public boolean matches(ItemSlot itemSlot, ItemFilter search, Object data, SlotType type) - { - if(type != itemSlot.slotType && ( - type != SlotType.ANY_SLOT || - itemSlot.slotType == SlotType.DISPLAY_SLOT || - itemSlot.slotType == SlotType.HIDDEN_SLOT)) - { - return false; - } - - if(search == null) - { - return false; - } - else if(data == null || data instanceof ItemStack) - { - return search.matches(data); - } - else if(data instanceof List) - { - for(Object content: (List)data) - { - if(search.matches(content)) - { - return true; - } - } - } - - return false; - } - - @Override - public boolean isPointInBounds(ItemSlot itemSlot, int x, int y) - { - return x >= itemSlot.x - && x < itemSlot.x + itemSlot.width - && y >= itemSlot.y - && y < itemSlot.y + itemSlot.height; - } - - @Override - public ItemFilter getClickedFilter(int x, int y, Object object) - { - return Util.instance.getCommonFilter(object); - } - - private List emptyOreDictEntryText(List oreDictionaryList) - { - if(RecipeGeneratorImplementation.forgeExt != null) - { - return RecipeGeneratorImplementation.forgeExt.emptyOreDictEntryText(oreDictionaryList); - } - else - { - return null; - } - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/MultipleItemFilter.java b/src/api/java/uristqwerty/CraftGuide/MultipleItemFilter.java deleted file mode 100644 index d087579c9..000000000 --- a/src/api/java/uristqwerty/CraftGuide/MultipleItemFilter.java +++ /dev/null @@ -1,157 +0,0 @@ -package uristqwerty.CraftGuide; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.item.ItemStack; -import uristqwerty.CraftGuide.api.ItemFilter; -import uristqwerty.CraftGuide.api.NamedTexture; -import uristqwerty.CraftGuide.api.Renderer; -import uristqwerty.CraftGuide.api.Util; - -public class MultipleItemFilter implements ItemFilter -{ - public final List comparison; - private static final NamedTexture overlayAny = Util.instance.getTexture("ItemStack-Any"); - private static final NamedTexture overlayForge = Util.instance.getTexture("ItemStack-OreDict"); - private static final NamedTexture overlayForgeSingle = Util.instance.getTexture("ItemStack-OreDict-Single"); - private List tooltip = null; - - public MultipleItemFilter(List stack) - { - comparison = stack; - } - - @Override - public boolean matches(Object stack) - { - if(comparison == null) - { - return stack == null; - } - - if(stack instanceof ItemStack) - { - return matches((ItemStack)stack); - } - else if(stack instanceof List) - { - for(Object item: (List)stack) - { - if(matches(item)) - { - return true; - } - } - - return false; - } - else - { - return false; - } - } - - private boolean matches(ItemStack stack) - { - for(ItemStack compare: comparison) - { - if(CommonUtilities.checkItemStackMatch(stack, compare)) - { - return true; - } - } - - return false; - } - - @Override - public void draw(Renderer renderer, int x, int y) - { - if(comparison.size() > 0) - { - ItemStack stack = comparison.get(0); - renderer.renderItemStack(x, y, stack); - - if(CommonUtilities.getItemDamage(stack) == CraftGuide.DAMAGE_WILDCARD) - { - renderer.renderRect(x - 1, y - 1, 18, 18, overlayAny); - } - - if(comparison.size() == 1) - { - renderer.renderRect(x - 1, y - 1, 18, 18, overlayForgeSingle); - } - else - { - renderer.renderRect(x - 1, y - 1, 18, 18, overlayForge); - } - } - } - - @Override - public List getTooltip() - { - if(tooltip == null) - { - if(comparison.size() > 0) - { - ItemStack primaryItem = comparison.get(0); - - List text; - - if(CommonUtilities.getItemDamage(primaryItem) == CraftGuide.DAMAGE_WILDCARD) - { - if(primaryItem.getHasSubtypes()) - { - ArrayList list = new ArrayList(); - primaryItem.getItem().getSubItems(primaryItem.getItem(), null, list); - text = Util.instance.getItemStackText(list.get(0)); - } - else - { - ItemStack alteredStack = primaryItem.copy(); - alteredStack.setItemDamage(0); - text = Util.instance.getItemStackText(alteredStack); - } - } - else - { - text = Util.instance.getItemStackText(primaryItem); - } - - if(comparison.size() > 1) - { - text.add("\u00a77Other items:"); - - if(CommonUtilities.getItemDamage(primaryItem) == CraftGuide.DAMAGE_WILDCARD && primaryItem.getHasSubtypes()) - { - ArrayList list = new ArrayList(); - primaryItem.getItem().getSubItems(primaryItem.getItem(), null, list); - - for(int i = 1; i < list.size(); i++) - { - text.add("\u00a77 " + CommonUtilities.itemName(list.get(i))); - } - } - - for(int i = 1; i < comparison.size(); i++) - { - for(String name: CommonUtilities.itemNames(comparison.get(i))) - { - text.add("\u00a77 " + name); - } - } - } - - tooltip = text; - } - else - { - return null; - } - } - - return tooltip; - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/Recipe.java b/src/api/java/uristqwerty/CraftGuide/Recipe.java deleted file mode 100644 index 132d2a0fc..000000000 --- a/src/api/java/uristqwerty/CraftGuide/Recipe.java +++ /dev/null @@ -1,211 +0,0 @@ -package uristqwerty.CraftGuide; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.item.ItemStack; -import uristqwerty.CraftGuide.api.CraftGuideRecipe; -import uristqwerty.CraftGuide.api.CraftGuideRecipeExtra1; -import uristqwerty.CraftGuide.api.ItemFilter; -import uristqwerty.CraftGuide.api.ItemSlot; -import uristqwerty.CraftGuide.api.Renderer; -import uristqwerty.CraftGuide.api.Slot; -import uristqwerty.CraftGuide.api.SlotType; -import uristqwerty.CraftGuide.api.Util; -import uristqwerty.CraftGuide.client.ui.GuiRenderer; -import uristqwerty.gui_craftguide.rendering.Renderable; - -public class Recipe implements CraftGuideRecipe, CraftGuideRecipeExtra1 -{ - protected Slot[] slots; - protected Object[] recipe; - private Renderable background; - private Renderable backgroundSelected; - - private int width = 79, height = 58; - - public Recipe(Slot[] slots, Object[] items, Renderable background, Renderable backgroundSelected) - { - this.slots = slots; - this.recipe = new Object[items.length]; - for(int i = 0; i < items.length; i++) - { - this.recipe[i] = items[i]; - } - - this.background = background; - this.backgroundSelected = backgroundSelected; - - for(int i = 0; i < slots.length; i++) - { - ItemStack display = displayStack(recipe[i]); - if(this.recipe[i] != null && slots[i] instanceof ItemSlot && !((ItemSlot)slots[i]).drawQuantity && display != null && display.stackSize > 1) - { - ItemStack old = display; - - this.recipe[i] = new ItemStack(old.getItem(), 1, CommonUtilities.getItemDamage(old)); - } - } - } - - private ItemStack displayStack(Object item) - { - if(item == null) - { - return null; - } - else if(item instanceof ItemStack) - { - return (ItemStack)item; - } - else if(item instanceof ArrayList) - { - if(((ArrayList)item).size() < 1) - { - return null; - } - else - { - return displayStack(((ArrayList)item).get(0)); - } - } - else - { - return null; - } - } - - @Override - public void draw(Renderer renderer, int x, int y, boolean mouseOverRecipe, int mouseX, int mouseY) - { - if(mouseOverRecipe) - { - backgroundSelected.render((GuiRenderer)renderer, x, y); - } - else - { - background.render((GuiRenderer)renderer, x, y); - } - - for(int i = 0; i < slots.length; i++) - { - if(mouseOverRecipe) - { - boolean mouseOverSlot = slots[i].isPointInBounds(mouseX, mouseY, recipe, i); - slots[i].draw(renderer, x, y, recipe, i, mouseOverSlot); - } - else - { - slots[i].draw(renderer, x, y, recipe, i, false); - } - } - } - - public int getSlotIndexUnderMouse(int x, int y) - { - for(int i = 0; i < slots.length; i++) - { - if(slots[i].isPointInBounds(x, y, recipe, i)) - { - return i; - } - } - - return -1; - } - - @Override - public boolean containsItem(ItemStack stack) - { - ItemFilter filter = Util.instance.getCommonFilter(stack); - - return containsItem(filter); - } - - @Override - public boolean containsItem(ItemFilter filter) - { - return containsItem(filter, SlotType.ANY_SLOT); - } - - @Override - public boolean containsItem(ItemStack stack, SlotType type) - { - ItemFilter filter = Util.instance.getCommonFilter(stack); - - return containsItem(filter, type); - } - - @Override - public boolean containsItem(ItemFilter filter, SlotType type) - { - if(filter != null) - { - for(int i = 0; i < slots.length; i++) - { - if(slots[i].matches(filter, recipe, i, type)) - { - return true; - } - } - } - - return false; - } - - @Override - public Object[] getItems() - { - return recipe; - } - - @Override - public int width() - { - return width; - } - - @Override - public int height() - { - return height; - } - - public Recipe setSize(int width, int height) - { - this.width = width; - this.height = height; - - return this; - } - - @Override - public List getItemText(int x, int y) - { - int slot = getSlotIndexUnderMouse(x, y); - - if(slot == -1 || slots[slot] == null) - { - return null; - } - else - { - return slots[slot].getTooltip(x, y, recipe, slot); - } - } - - @Override - public ItemFilter getRecipeClickedResult(int x, int y) - { - int slot = getSlotIndexUnderMouse(x, y); - - if(slot == -1 || slots[slot] == null) - { - return null; - } - else - { - return slots[slot].getClickedFilter(x, y, recipe, slot); - } - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/RecipeCache.java b/src/api/java/uristqwerty/CraftGuide/RecipeCache.java deleted file mode 100644 index 9bcec22d1..000000000 --- a/src/api/java/uristqwerty/CraftGuide/RecipeCache.java +++ /dev/null @@ -1,393 +0,0 @@ -package uristqwerty.CraftGuide; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; - -import net.minecraft.item.ItemStack; -import uristqwerty.CraftGuide.api.BasicRecipeFilter; -import uristqwerty.CraftGuide.api.CraftGuideRecipe; -import uristqwerty.CraftGuide.api.CraftGuideRecipeExtra1; -import uristqwerty.CraftGuide.api.ItemFilter; -import uristqwerty.CraftGuide.api.RecipeFilter; -import uristqwerty.CraftGuide.api.RecipeProvider; -import uristqwerty.CraftGuide.api.SlotType; -import uristqwerty.CraftGuide.client.ui.IRecipeCacheListener; - -public class RecipeCache -{ - private SortedSet craftingTypes = new TreeSet(); - private Map> craftResults = new HashMap>(); - private List typeResults; - private List filteredResults; - private RecipeGeneratorImplementation generator = new RecipeGeneratorImplementation(); - private ItemFilter filterItem = null; - private List listeners = new LinkedList(); - private Set currentTypes = null; - private SortedSet allItems = new TreeSet(); - private boolean firstReset = true; - - public RecipeCache() - { - reset(); - } - - public void reset() - { - CraftGuide.needsRecipeRefresh = false; - - CraftGuideLog.log("(re)loading recipe list..."); - Map> rawRecipes = generateRecipes(); - - filterRawRecipes(rawRecipes); - craftResults.clear(); - - for(ItemStack key: rawRecipes.keySet()) - { - CraftType type = CraftType.getInstance(key); - - if(type == null) - { - CraftGuideLog.log(" Error: null type, " + rawRecipes.get(key).size() + " recipes skipped"); - continue; - } - - if(!craftResults.containsKey(type)) - { - craftResults.put(type, new ArrayList()); - } - - craftResults.get(type).addAll(rawRecipes.get(key)); - } - - generator.clearRecipes(); - - generateAllItemList(); - - craftingTypes.addAll(craftResults.keySet()); - - if(firstReset) - { - currentTypes = new HashSet(); - currentTypes.addAll(craftingTypes); - - for(ItemStack stack: generator.disabledTypes) - { - currentTypes.remove(CraftType.getInstance(stack)); - } - - firstReset = false; - } - - setTypes(currentTypes); - - for(IRecipeCacheListener listener: listeners) - { - listener.onReset(this); - } - } - - private void generateAllItemList() - { - allItems.clear(); - - for(List type: craftResults.values()) - { - for(CraftGuideRecipe recipe: type) - { - for(Object item: recipe.getItems()) - { - if(item != null) - { - if(item instanceof ItemStack) - { - allItems.add(CraftType.getInstance(item)); - } - else if(item instanceof ArrayList) - { - for(ItemStack stack: (ArrayList)item) - { - CraftType craftType = CraftType.getInstance(stack); - - if(craftType != null) - { - allItems.add(craftType); - } - } - - CraftType craftType = CraftType.getInstance(item); - - if(craftType != null) - { - allItems.add(craftType); - } - } - } - } - } - } - - removeUselessDuplicates(); - } - - private void removeUselessDuplicates() - { - Map wild = new HashMap(); - for(CraftType item: allItems) - { - if(!(item.getStack() instanceof ItemStack)) - { - continue; - } - - if(CommonUtilities.getItemDamage(((ItemStack)item.getStack())) == CraftGuide.DAMAGE_WILDCARD) - { - wild.put(item, 1); - } - else - { - for(CraftType type: wild.keySet()) - { - if(((ItemStack)item.getStack()).getItem() == ((ItemStack)type.getStack()).getItem()) - { - wild.put(type, wild.get(type) + 1); - } - } - } - } - - for(CraftType type: wild.keySet()) - { - if(wild.get(type) == 2) - { - allItems.remove(type); - } - else if(wild.get(type) == 1) - { - allItems.remove(type); - allItems.add(CraftType.getInstance(new ItemStack(type.getDisplayStack().getItem(), 1, 0))); - } - } - - wild.clear(); - for(CraftType item: allItems) - { - if(item.getStack() instanceof ArrayList && - ((ArrayList)item.getStack()).size() == 1 && - ((ArrayList)item.getStack()).get(0) != null) - { - wild.put(item, 1); - ItemStack stack = (ItemStack)((ArrayList)item.getStack()).get(0); - - for(CraftType item2: allItems) - { - if(item2.getStack() instanceof ItemStack) - { - if(CommonUtilities.checkItemStackMatch(stack, (ItemStack)item2.getStack())) - { - wild.put(item, 2); - break; - } - } - } - } - } - - for(CraftType type: wild.keySet()) - { - if(wild.get(type) == 2) - { - allItems.remove(type); - } - } - } - - private Map> generateRecipes() - { - generator.clearRecipes(); - CraftGuideLog.log(" Getting recipes..."); - for(Object object: ReflectionAPI.APIObjects) - { - if(object instanceof RecipeProvider) - { - CraftGuideLog.log(" Generating recipes from " + object.getClass().getName()); - try - { - ((RecipeProvider)object).generateRecipes(generator); - } - catch(Exception e) - { - CraftGuideLog.log(e); - } - catch(LinkageError e) - { - CraftGuideLog.log(e); - } - } - } - - return generator.getRecipes(); - } - - private void filterRawRecipes(Map> rawRecipes) - { - CraftGuideLog.log(" Filtering recipes..."); - for(Object object: ReflectionAPI.APIObjects) - { - if(object instanceof RecipeFilter) - { - CraftGuideLog.log(" Filtering recipes from " + object.getClass().getName()); - - try - { - for(ItemStack type: rawRecipes.keySet()) - { - rawRecipes.put(type, ((RecipeFilter)object).filterRecipes(rawRecipes.get(type), type)); - } - } - catch(Exception e) - { - CraftGuideLog.log(e); - } - catch(LinkageError e) - { - CraftGuideLog.log(e); - } - } - else if(object instanceof BasicRecipeFilter) - { - - CraftGuideLog.log(" Filtering recipes from " + object.getClass().getName()); - - try - { - for(ItemStack type: rawRecipes.keySet()) - { - Iterator iterator = rawRecipes.get(type).iterator(); - - while(iterator.hasNext()) - { - if(!((BasicRecipeFilter)object).shouldKeepRecipe(iterator.next(), type)) - { - iterator.remove(); - } - } - } - } - catch(Exception e) - { - CraftGuideLog.log(e); - } - catch(LinkageError e) - { - CraftGuideLog.log(e); - } - } - } - } - - public void setTypes(Set types) - { - typeResults = new ArrayList(); - currentTypes = types; - - if(types == null) - { - for(CraftType type: craftingTypes) - { - typeResults.addAll(craftResults.get(type)); - } - } - else - { - for(CraftType type: craftingTypes) - { - if(types.contains(type)) - { - typeResults.addAll(craftResults.get(type)); - } - } - } - - filter(filterItem); - } - - public List getRecipes() - { - return filteredResults; - } - - public void filter(ItemFilter filter) - { - filterItem = filter; - - boolean input = GuiCraftGuide.filterSlotTypes.get(SlotType.INPUT_SLOT); - boolean output = GuiCraftGuide.filterSlotTypes.get(SlotType.OUTPUT_SLOT); - boolean machine = GuiCraftGuide.filterSlotTypes.get(SlotType.MACHINE_SLOT); - - if(filter == null) - { - filteredResults = typeResults; - } - else - { - filteredResults = new ArrayList(); - - for(CraftGuideRecipe recipe: typeResults) - { - if(recipe instanceof CraftGuideRecipeExtra1) - { - CraftGuideRecipeExtra1 e = (CraftGuideRecipeExtra1)recipe; - - if((input && e.containsItem(filter, SlotType.INPUT_SLOT)) - || (output && e.containsItem(filter, SlotType.OUTPUT_SLOT)) - || (machine && e.containsItem(filter, SlotType.MACHINE_SLOT))) - { - filteredResults.add(recipe); - } - } - else if(recipe.containsItem(filter)) - { - filteredResults.add(recipe); - } - } - } - - for(IRecipeCacheListener listener: listeners) - { - listener.onChange(this); - } - } - - public ItemFilter getFilter() - { - return filterItem; - } - - public Set getCraftTypes() - { - return craftingTypes; - } - - public void addListener(IRecipeCacheListener listener) - { - listeners.add(listener); - } - - public SortedSet getAllItems() - { - return allItems; - } - - public Set getFilterTypes() - { - return currentTypes; - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/RecipeGeneratorImplementation.java b/src/api/java/uristqwerty/CraftGuide/RecipeGeneratorImplementation.java deleted file mode 100644 index ca7ec1829..000000000 --- a/src/api/java/uristqwerty/CraftGuide/RecipeGeneratorImplementation.java +++ /dev/null @@ -1,271 +0,0 @@ -package uristqwerty.CraftGuide; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.item.crafting.ShapedRecipes; -import net.minecraft.item.crafting.ShapelessRecipes; -import uristqwerty.CraftGuide.api.CraftGuideRecipe; -import uristqwerty.CraftGuide.api.RecipeGenerator; -import uristqwerty.CraftGuide.api.RecipeTemplate; -import uristqwerty.CraftGuide.api.Slot; -import uristqwerty.gui_craftguide.minecraft.Image; -import uristqwerty.gui_craftguide.texture.BlankTexture; -import uristqwerty.gui_craftguide.texture.BorderedTexture; -import uristqwerty.gui_craftguide.texture.DynamicTexture; -import uristqwerty.gui_craftguide.texture.SubTexture; -import uristqwerty.gui_craftguide.texture.Texture; -import uristqwerty.gui_craftguide.texture.TextureClip; - -public class RecipeGeneratorImplementation implements RecipeGenerator -{ - public static interface RecipeGeneratorForgeExtension - { - boolean matchesType(IRecipe recipe); - boolean isShapelessRecipe(IRecipe recipe); - Object[] getCraftingRecipe(RecipeGeneratorImplementation recipeGeneratorImplementation, IRecipe recipe, boolean allowSmallGrid); - List emptyOreDictEntryText(List oreDictionaryList); - } - - private Map> recipes = new HashMap>(); - public List disabledTypes = new LinkedList(); - private Texture defaultBackground = new BlankTexture(); - private Texture defaultBackgroundSelected; - public static ItemStack workbench = new ItemStack(Blocks.crafting_table); - - public static RecipeGeneratorForgeExtension forgeExt; - - public RecipeGeneratorImplementation() - { - Texture source = DynamicTexture.instance("base_image"); - defaultBackgroundSelected = new BorderedTexture( - new Texture[]{ - new TextureClip(source, 117, 1, 2, 2), - new SubTexture (source, 120, 1, 32, 2), - new TextureClip(source, 153, 1, 2, 2), - new SubTexture (source, 117, 4, 2, 32), - new SubTexture (source, 120, 4, 32, 32), - new SubTexture (source, 153, 4, 2, 32), - new TextureClip(source, 117, 37, 2, 2), - new SubTexture (source, 120, 37, 32, 2), - new TextureClip(source, 153, 37, 2, 2), - }, 2); - } - - @Override - public RecipeTemplate createRecipeTemplate(Slot[] slots, - ItemStack craftingType, String backgroundTexture, int backgroundX, - int backgroundY, int backgroundSelectedX, int backgroundSelectedY) - { - return createRecipeTemplate(slots, craftingType, - backgroundTexture, backgroundX, backgroundY, - backgroundTexture, backgroundSelectedX, backgroundSelectedY); - } - - @Override - public RecipeTemplate createRecipeTemplate(Slot[] slots, ItemStack craftingType, - String backgroundTexture, int backgroundX, int backgroundY, - String backgroundSelectedTexture, int backgroundSelectedX, int backgroundSelectedY) - { - if(craftingType == null) - { - craftingType = workbench; - } - - if(backgroundTexture.equals("/gui/BrewGuide.png")) - { - backgroundTexture = "craftguide:textures/gui/BrewGuide.png"; - } - else if(backgroundTexture.equals("/gui/CraftGuide.png")) - { - backgroundTexture = "craftguide:textures/gui/CraftGuide.png"; - } - else if(backgroundTexture.equals("/gui/CraftGuideRecipe.png")) - { - backgroundTexture = "craftguide:textures/gui/CraftGuideRecipe.png"; - } - - if(backgroundSelectedTexture.equals("/gui/BrewGuide.png")) - { - backgroundSelectedTexture = "craftguide:textures/gui/BrewGuide.png"; - } - else if(backgroundSelectedTexture.equals("/gui/CraftGuide.png")) - { - backgroundSelectedTexture = "craftguide:textures/gui/CraftGuide.png"; - } - else if(backgroundSelectedTexture.equals("/gui/CraftGuideRecipe.png")) - { - backgroundSelectedTexture = "craftguide:textures/gui/CraftGuideRecipe.png"; - } - - for(ItemStack stack: recipes.keySet()) - { - if(ItemStack.areItemStacksEqual(stack, craftingType)) - { - craftingType = stack; - break; - } - } - - return new DefaultRecipeTemplate( - slots, - craftingType, - new TextureClip( - Image.fromJar(backgroundTexture), - backgroundX, backgroundY, 79, 58), - new TextureClip( - Image.fromJar(backgroundSelectedTexture), - backgroundSelectedX, backgroundSelectedY, 79, 58)); - } - - @Override - public RecipeTemplate createRecipeTemplate(Slot[] slots, ItemStack craftingType) - { - if(craftingType == null) - { - craftingType = workbench; - } - - return new DefaultRecipeTemplate(slots, craftingType, defaultBackground, defaultBackgroundSelected); - } - - @Override - public void addRecipe(RecipeTemplate template, Object[] items) - { - addRecipe(template.generate(items), template.getCraftingType()); - } - - @Override - public void addRecipe(CraftGuideRecipe recipe, ItemStack craftingType) - { - List recipeList = recipes.get(craftingType); - - if(recipeList == null) - { - recipeList = new ArrayList(); - recipes.put(craftingType, recipeList); - } - - recipeList.add(recipe); - } - - public Map> getRecipes() - { - return recipes; - } - - public void clearRecipes() - { - recipes.clear(); - } - - @Override - public void setDefaultTypeVisibility(ItemStack type, boolean visible) - { - if(visible) - { - disabledTypes.remove(type); - } - else if(!disabledTypes.contains(type)) - { - disabledTypes.add(type); - } - } - - @Override - public Object[] getCraftingRecipe(IRecipe recipe) - { - return getCraftingRecipe(recipe, false); - } - - @Override - public Object[] getCraftingRecipe(IRecipe recipe, boolean allowSmallGrid) - { - try - { - if(recipe instanceof ShapedRecipes) - { - int width = (Integer)CommonUtilities.getPrivateValue(ShapedRecipes.class, (ShapedRecipes)recipe, "b", "recipeWidth", "field_77576_b"); - int height = (Integer)CommonUtilities.getPrivateValue(ShapedRecipes.class, (ShapedRecipes)recipe, "c", "recipeHeight", "field_77577_c"); - Object[] items = (Object[])CommonUtilities.getPrivateValue(ShapedRecipes.class, (ShapedRecipes)recipe, "d", "recipeItems", "field_77574_d"); - - if(allowSmallGrid && width < 3 && height < 3) - { - return getSmallShapedRecipe(width, height, items, ((ShapedRecipes)recipe).getRecipeOutput()); - } - else - { - return getCraftingShapedRecipe(width, height, items, ((ShapedRecipes)recipe).getRecipeOutput()); - } - } - else if(recipe instanceof ShapelessRecipes) - { - List items = (List)CommonUtilities.getPrivateValue(ShapelessRecipes.class, (ShapelessRecipes)recipe, "b", "recipeItems", "field_77579_b"); - return getCraftingShapelessRecipe(items, ((ShapelessRecipes)recipe).getRecipeOutput()); - } - else if(forgeExt != null && forgeExt.matchesType(recipe)) - { - return forgeExt.getCraftingRecipe(this, recipe, allowSmallGrid); - } - } - catch(Exception e) - { - e.printStackTrace(); - CraftGuideLog.log("Exception while trying to parse an ItemStack[10] from an IRecipe:"); - CraftGuideLog.log(e); - } - - return null; - } - - Object[] getSmallShapedRecipe(int width, int height, Object[] items, ItemStack recipeOutput) - { - Object[] output = new Object[5]; - - for(int y = 0; y < height; y++) - { - for(int x = 0; x < width; x++) - { - output[y * 2 + x] = items[y * width + x]; - } - } - - output[4] = recipeOutput; - return output; - } - - Object[] getCraftingShapelessRecipe(List items, ItemStack recipeOutput) - { - Object[] output = new Object[10]; - - for(int i = 0; i < items.size(); i++) - { - output[i] = items.get(i); - } - - output[9] = recipeOutput; - return output; - } - - Object[] getCraftingShapedRecipe(int width, int height, Object[] items, ItemStack recipeOutput) - { - Object[] output = new Object[10]; - - for(int y = 0; y < height; y++) - { - for(int x = 0; x < width; x++) - { - output[y * 3 + x] = items[y * width + x]; - } - } - - output[9] = recipeOutput; - return output; - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/ReflectionAPI.java b/src/api/java/uristqwerty/CraftGuide/ReflectionAPI.java deleted file mode 100644 index 39b028af6..000000000 --- a/src/api/java/uristqwerty/CraftGuide/ReflectionAPI.java +++ /dev/null @@ -1,19 +0,0 @@ -package uristqwerty.CraftGuide; - -import java.util.ArrayList; -import java.util.List; - -public class ReflectionAPI -{ - public static List APIObjects = new ArrayList(); - - public static void registerAPIObject(Object object) - { - APIObjects.add(object); - } - - public static void reloadRecipes() - { - CraftGuide.side.reloadRecipes(); - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/SingleItemFilter.java b/src/api/java/uristqwerty/CraftGuide/SingleItemFilter.java deleted file mode 100644 index 703341bb9..000000000 --- a/src/api/java/uristqwerty/CraftGuide/SingleItemFilter.java +++ /dev/null @@ -1,62 +0,0 @@ -package uristqwerty.CraftGuide; - -import java.util.List; - -import net.minecraft.item.ItemStack; -import uristqwerty.CraftGuide.api.ItemFilter; -import uristqwerty.CraftGuide.api.NamedTexture; -import uristqwerty.CraftGuide.api.Renderer; -import uristqwerty.CraftGuide.api.Util; - -public class SingleItemFilter implements ItemFilter -{ - public ItemStack comparison; - private NamedTexture overlayAny = Util.instance.getTexture("ItemStack-Any"); - - public SingleItemFilter(ItemStack stack) - { - comparison = stack; - } - - @Override - public boolean matches(Object stack) - { - if(stack instanceof ItemStack) - { - return CommonUtilities.checkItemStackMatch((ItemStack)stack, comparison); - } - else if(stack instanceof List) - { - for(Object item: (List)stack) - { - if(matches(item)) - { - return true; - } - } - - return false; - } - else - { - return false; - } - } - - @Override - public void draw(Renderer renderer, int x, int y) - { - renderer.renderItemStack(x, y, comparison); - - if(CommonUtilities.getItemDamage(comparison) == CraftGuide.DAMAGE_WILDCARD) - { - renderer.renderRect(x - 1, y - 1, 18, 18, overlayAny); - } - } - - @Override - public List getTooltip() - { - return Util.instance.getItemStackText(comparison); - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/StringItemFilter.java b/src/api/java/uristqwerty/CraftGuide/StringItemFilter.java deleted file mode 100644 index dfced02a9..000000000 --- a/src/api/java/uristqwerty/CraftGuide/StringItemFilter.java +++ /dev/null @@ -1,64 +0,0 @@ -package uristqwerty.CraftGuide; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.item.ItemStack; -import uristqwerty.CraftGuide.api.ItemFilter; -import uristqwerty.CraftGuide.api.NamedTexture; -import uristqwerty.CraftGuide.api.Renderer; -import uristqwerty.CraftGuide.api.Util; - -public class StringItemFilter implements ItemFilter -{ - private String comparison; - private NamedTexture textImage = Util.instance.getTexture("TextFilter"); - - public StringItemFilter(String string) - { - comparison = string.toLowerCase(); - } - - @Override - public boolean matches(Object item) - { - if(item instanceof ItemStack) - { - return CommonUtilities.searchExtendedItemStackText(item, comparison); - } - else if(item instanceof String) - { - return ((String)item).toLowerCase().contains(comparison); - } - else if(item instanceof List) - { - for(Object o: (List)item) - { - if(matches(o)) - { - return true; - } - } - - return false; - } - else - { - return false; - } - } - - @Override - public void draw(Renderer renderer, int x, int y) - { - renderer.renderRect(x, y, 16, 16, textImage); - } - - @Override - public List getTooltip() - { - List text = new ArrayList(1); - text.add("\u00a77Text search: '" + comparison + "'"); - return text; - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/UtilImplementationCommon.java b/src/api/java/uristqwerty/CraftGuide/UtilImplementationCommon.java deleted file mode 100644 index 738d705ac..000000000 --- a/src/api/java/uristqwerty/CraftGuide/UtilImplementationCommon.java +++ /dev/null @@ -1,118 +0,0 @@ -package uristqwerty.CraftGuide; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.item.EnumRarity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.util.EnumChatFormatting; -import uristqwerty.CraftGuide.api.ItemFilter; -import uristqwerty.CraftGuide.api.Util; -import uristqwerty.CraftGuide.client.ui.GuiRenderer; - -public abstract class UtilImplementationCommon extends Util -{ - public float partialTicks; - - @Override - public ItemFilter getCommonFilter(Object stack) - { - if(stack == null) - { - return null; - } - else if(stack instanceof ItemStack) - { - return new SingleItemFilter((ItemStack)stack); - } - else if(stack instanceof List && ((List)stack).size() > 0) - { - return new MultipleItemFilter((List)stack); - } - else if(stack instanceof String) - { - return new StringItemFilter((String)stack); - } - else - { - return null; - } - } - - @Override - public List getItemStackText(ItemStack stack) - { - try - { - List list = ((GuiRenderer)GuiRenderer.instance).getItemNameandInformation(stack); - - if(CommonUtilities.getItemDamage(stack) == CraftGuide.DAMAGE_WILDCARD && (list.size() < 1 || (list.size() == 1 && (list.get(0) == null || (list.get(0) instanceof String && ((String)list.get(0)).isEmpty()))))) - { - list = ((GuiRenderer)GuiRenderer.instance).getItemNameandInformation(GuiRenderer.fixedItemStack(stack)); - } - - List text = new ArrayList(list.size()); - boolean first = true; - - for(Object o: list) - { - if(o instanceof String) - { - if(first) - { - EnumRarity rarity = null; - - try - { - rarity = stack.getRarity(); - } - catch(NullPointerException e) - { - } - - if(rarity == null) - { - rarity = EnumRarity.common; - } - - text.add(rarity.rarityColor + (String)o); - - if(CraftGuide.alwaysShowID) - { - text.add(EnumChatFormatting.DARK_GRAY + "ID: " + Item.itemRegistry.getNameForObject(stack.getItem()) + "; data: " + CommonUtilities.getItemDamage(stack)); - } - - first = false; - } - else - { - text.add(EnumChatFormatting.DARK_GRAY + (String)o); - } - } - } - - return text; - } - catch(Exception e) - { - CraftGuideLog.log(e); - - List text = new ArrayList(1); - text.add(EnumChatFormatting.YELLOW + "Item " + Item.itemRegistry.getNameForObject(stack.getItem()) + " data " + Integer.toString(CommonUtilities.getItemDamage(stack))); - return text; - } - } - - @Override - public void reloadRecipes() - { - CraftGuide.side.reloadRecipes(); - } - - @Override - public float getPartialTicks() - { - return partialTicks; - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/api/BasicRecipeFilter.java b/src/api/java/uristqwerty/CraftGuide/api/BasicRecipeFilter.java deleted file mode 100644 index f69fe627b..000000000 --- a/src/api/java/uristqwerty/CraftGuide/api/BasicRecipeFilter.java +++ /dev/null @@ -1,21 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import net.minecraft.item.ItemStack; - -/** - * Supports a simple filter, allowing recipes to be removed - * if they match certain conditions. - */ -public interface BasicRecipeFilter -{ - /** - * When CraftGuide loads or reloads its recipe list, this - * method will be called for every recipe. If this method - * returns false for a recipe, that recipe will be removed. - * - * @param recipe - * @param recipeType - * @return - */ - public boolean shouldKeepRecipe(CraftGuideRecipe recipe, ItemStack recipeType); -} diff --git a/src/api/java/uristqwerty/CraftGuide/api/ChanceSlot.java b/src/api/java/uristqwerty/CraftGuide/api/ChanceSlot.java deleted file mode 100644 index 19bf803d6..000000000 --- a/src/api/java/uristqwerty/CraftGuide/api/ChanceSlot.java +++ /dev/null @@ -1,82 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import java.util.List; - -/** - * An ItemSlot that appends probability information to the name of - * the item it contains. To use it, instead of putting an ItemStack - * or List in the data array, put an Object[] containing the item - * at index 0, and an Integer representing the probability at index - * 1. - * - * Also worth noting, this class does not require any additional support - * within the rest of CraftGuide. If you copy it into a different package, - * and use that copy, it will function just fine with older versions of - * CraftGuide, as well as newer ones. It also shows how the API is set up - * to make that sort of extension possible. - */ -public class ChanceSlot extends ItemSlot -{ - private int ratio = 100; - private String formatString = " (%1$.0f%% chance)"; - - public ChanceSlot(int x, int y, int width, int height) - { - super(x, y, width, height); - } - - public ChanceSlot(int x, int y, int width, int height, boolean drawQuantity) - { - super(x, y, width, height, drawQuantity); - } - - @Override - public void draw(Renderer renderer, int x, int y, Object[] data, int dataIndex, boolean isMouseOver) - { - implementation.draw(this, renderer, x, y, stack(data, dataIndex), isMouseOver); - } - - @Override - public List getTooltip(int x, int y, Object[] data, int dataIndex) - { - if(data[dataIndex] == null || stack(data, dataIndex) == null) - { - return implementation.getTooltip(this, null); - } - - List tooltip = implementation.getTooltip(this, stack(data, dataIndex)); - double probability = ((Integer)((Object[])data[dataIndex])[1]) * 100 / (double)ratio; - - tooltip.set(0, tooltip.get(0) + String.format(formatString, probability)); - return tooltip; - } - - @Override - public boolean matches(ItemFilter search, Object[] data, int dataIndex, SlotType type) - { - return implementation.matches(this, search, stack(data, dataIndex), type); - } - - @Override - public ItemFilter getClickedFilter(int x, int y, Object[] data, int dataIndex) - { - return implementation.getClickedFilter(x, y, stack(data, dataIndex)); - } - - private Object stack(Object[] data, int dataIndex) - { - return data[dataIndex] != null? ((Object[])data[dataIndex])[0] : null; - } - - public ChanceSlot setRatio(int ratio) - { - this.ratio = ratio; - return this; - } - - public ChanceSlot setFormatString(String format) - { - formatString = format; - return this; - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/api/CraftGuideAPIObject.java b/src/api/java/uristqwerty/CraftGuide/api/CraftGuideAPIObject.java deleted file mode 100644 index b21b29ae0..000000000 --- a/src/api/java/uristqwerty/CraftGuide/api/CraftGuideAPIObject.java +++ /dev/null @@ -1,52 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - -/** - * Uses reflection to register itself with CraftGuide when created. - *

- * You do not need to use this class, it is provided only for convenience, - * as the static method it calls will accept any Object that implements - * zero or more of the following interfaces: - *
  • {@link RecipeProvider} - */ - -public class CraftGuideAPIObject -{ - /** - * When an instance of this class is created, it immediately registers itself - * with CraftGuide (through a static method, invoked through reflection). - *

    - * If you don't want to extend this class, you need to use the code similar to - * this in order for CraftGuide to know that your object exists. - */ - public CraftGuideAPIObject() - { - try - { - Class c = Class.forName("uristqwerty.CraftGuide.ReflectionAPI"); - - Method m = c.getMethod("registerAPIObject", Object.class); - m.invoke(null, this); - } - catch(ClassNotFoundException e) - { - } - catch(NoSuchMethodException e) - { - } - catch(SecurityException e) - { - } - catch(InvocationTargetException e) - { - } - catch(IllegalAccessException e) - { - } - catch(IllegalArgumentException e) - { - } - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/api/CraftGuideRecipe.java b/src/api/java/uristqwerty/CraftGuide/api/CraftGuideRecipe.java deleted file mode 100644 index cb8da8d23..000000000 --- a/src/api/java/uristqwerty/CraftGuide/api/CraftGuideRecipe.java +++ /dev/null @@ -1,103 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import java.util.List; - -import net.minecraft.item.ItemStack; - -/** - * An instance of a single recipe to be displayed by CraftGuide. - *

    - * Contains a number of methods related to searching, drawing, - * and interaction with the user. - *

    - * It is possible to implement your own recipe, if the default - * functionality is not adequate, although you won't have access - * to any of the default implementation, so it may require a bit - * of work. - */ -public interface CraftGuideRecipe -{ - /** - * Checks whether a certain item is contained in this recipe. - *

    - * This method is provided as a convenience for anyone writing a - * RecipeFilter; {@link #containsItem(ItemFilter)} will generally - * be used elsewhere. - * @param filter - * @return - */ - public boolean containsItem(ItemStack filter); - - /** - * Checks whether this recipe contains an item that matches the - * supplied ItemFilter. Implementations of RecipeFilter may either - * use this or {@link #containsItem(ItemFilter)}; CraftGuide itself - * always uses this. - * @param filter - * @return - */ - public boolean containsItem(ItemFilter filter); - - /** - * When a mouse click occurs within the rectangle occupied by this recipe, - * this method is used to determine if the current ItemFilter should be - * changed as a result. Generally involves iterating over each Slot within - * the recipe, and, if any of them is at the coordinates, returning - * {@link Slot#getClickedFilter}. - * @param x coordinate, relative to the top left of this recipe - * @param y coordinate, relative to the top left of this recipe - * @return a new ItemFilter, or null to keep the current one - */ - public ItemFilter getRecipeClickedResult(int x, int y); - - /** - * Draws this recipe at the specified screen coordinates. If isMouseOver - * is true, mouseX and moyseY are the coordinates of the user's curosr, - * relative to the top left of this recipe; otherwise they are undefined, - * and may be anything, depending on the implementation of CraftGuide, - * and may change between CraftGuide versions. - * @param renderer - * @param x - * @param y - * @param isMouseOver - * @param mouseX - * @param mouseY - */ - public void draw(Renderer renderer, int x, int y, boolean isMouseOver, int mouseX, int mouseY); - - /** - * Called to get the text to display when the user moves their cursor - * over this recipe. Generally, and in the default recipe implementation, - * this means checking if the cursor is over a Slot, and if so, - * returning whatever the slot returns for {@link Slot#getTooltip} - * @param mouseX - * @param mouseY - * @return a List of Strings, or null - */ - public List getItemText(int mouseX, int mouseY); - - /** - * Gets an array of Objects, representing the contents of this recipe. - *

    - * Currently used by craftGuide to create a list of every type of item - * that is used (CraftGuide does not have any logic for finding items - * on its own). Some recipe filters may use this, although - * {@link containsItem} is preferred wherever possible. - * @return - */ - public Object[] getItems(); - - /** - * Gets the width of this recipe; used to determine grid spacing and - * if the cursor is currently positioned over this recipe - * @return - */ - public int width(); - - /** - * Gets the height of this recipe; used to determine grid spacing and - * if the cursor is currently positioned over this recipe - * @return - */ - public int height(); -} diff --git a/src/api/java/uristqwerty/CraftGuide/api/CraftGuideRecipeExtra1.java b/src/api/java/uristqwerty/CraftGuide/api/CraftGuideRecipeExtra1.java deleted file mode 100644 index fac578916..000000000 --- a/src/api/java/uristqwerty/CraftGuide/api/CraftGuideRecipeExtra1.java +++ /dev/null @@ -1,15 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import net.minecraft.item.ItemStack; - - -/** - * Contains two forgotten methods from CraftGuideRecipe. Allows - * searching for items, limiting the search to a specific - * SlotType. - */ -public interface CraftGuideRecipeExtra1 -{ - public boolean containsItem(ItemStack filter, SlotType type); - public boolean containsItem(ItemFilter filter, SlotType type); -} diff --git a/src/api/java/uristqwerty/CraftGuide/api/EUSlot.java b/src/api/java/uristqwerty/CraftGuide/api/EUSlot.java deleted file mode 100644 index 90a1a9c26..000000000 --- a/src/api/java/uristqwerty/CraftGuide/api/EUSlot.java +++ /dev/null @@ -1,126 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import java.util.ArrayList; -import java.util.List; - - -public class EUSlot implements Slot -{ - public static final int VALUE_UNSPECIFIED = Integer.MIN_VALUE; - private int constantValue = VALUE_UNSPECIFIED; - private int constantSize = VALUE_UNSPECIFIED; - private final int x, y; - private final static int width = 16; - private final static int height = 16; - - private static NamedTexture image; - - public EUSlot(int x, int y) - { - this.x = x; - this.y = y; - - if(image == null) - { - image = Util.instance.getTexture("EU-icon"); - } - } - - @Override - public void draw(Renderer renderer, int recipeX, int recipeY, Object[] data, int dataIndex, boolean isMouseOver) - { - renderer.renderRect(recipeX + x, recipeY + y, width, height, image); - } - - @Override - public ItemFilter getClickedFilter(int x, int y, Object[] data, int dataIndex) - { - return null; - } - - @Override - public boolean isPointInBounds(int x, int y, Object[] data, int dataIndex) - { - return x >= this.x && x < this.x + width - && y >= this.y && y < this.y + height; - } - - @Override - public List getTooltip(int x, int y, Object[] data, int dataIndex) - { - int value = EUVaue(data[dataIndex]); - int size = PacketSize(data[dataIndex]); - - ArrayList tooltip = new ArrayList(); - tooltip.add("\u00a7fIC2 energy"); - - if(value != -1) - { - tooltip.add("\u00a77 " + Math.abs(value) + " EU " + (value > 0? "produced" : "used")); - } - - if(size != -1) - { - tooltip.add("\u00a77 " + size + " EU/t"); - } - - return tooltip; - } - - @Override - public boolean matches(ItemFilter filter, Object[] data, int dataIndex, SlotType type) - { - return false; - } - - public int EUVaue(Object data) - { - if(data instanceof Object[] && ((Object[])data)[0] instanceof Integer) - { - return (Integer)((Object[])data)[0]; - } - else if(constantValue != VALUE_UNSPECIFIED) - { - return constantValue; - } - else if(data instanceof Integer) - { - return (Integer)data; - } - else - { - return VALUE_UNSPECIFIED; - } - } - - public int PacketSize(Object data) - { - if(data instanceof Object[] && ((Object[])data)[1] instanceof Integer) - { - return (Integer)((Object[])data)[1]; - } - else if(constantSize != VALUE_UNSPECIFIED) - { - return constantSize; - } - else if(data instanceof Integer) - { - return (Integer)data; - } - else - { - return VALUE_UNSPECIFIED; - } - } - - public EUSlot setConstantEUValue(int value) - { - constantValue = value; - return this; - } - public EUSlot setConstantPacketSize(int size) - { - constantSize = size; - return this; - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/api/ExtraSlot.java b/src/api/java/uristqwerty/CraftGuide/api/ExtraSlot.java deleted file mode 100644 index b372e7a08..000000000 --- a/src/api/java/uristqwerty/CraftGuide/api/ExtraSlot.java +++ /dev/null @@ -1,106 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import java.util.List; - - -/** - * An extension of ItemSlot that allows certain interactions - * to be disabled, and uses fixed Object provided during - * initialisation rather than the object matching this slot - * in the recipe. - *

    - * Unlike in the old API, there is no "can filter" option, - * as that can be accomplished through {@link #setSlotType} - * which is already present in ItemSlot. - */ -public class ExtraSlot extends ItemSlot -{ - public Object displayed; - public boolean showName = false; - public boolean canClick = false; - - public ExtraSlot(int x, int y, int width, int height, Object displayedItem) - { - super(x, y, width, height); - displayed = displayedItem; - } - - @Override - public void draw(Renderer renderer, int x, int y, Object[] data, int dataIndex, boolean isMouseOver) - { - implementation.draw(this, renderer, x, y, displayed, canClick && isMouseOver); - } - - @Override - public List getTooltip(int x, int y, Object[] data, int dataIndex) - { - if(showName) - { - return implementation.getTooltip(this, displayed); - } - else - { - return null; - } - } - - @Override - public ItemFilter getClickedFilter(int x, int y, Object[] data, int dataIndex) - { - if(canClick) - { - return implementation.getClickedFilter(x, y, displayed); - } - else - { - return null; - } - } - - /** - * Sets whether this slot, if clicked, sets the current - * filter to the displayed Object, or doesn't do anything - * - * @param clickable - * @return this ExtraSlot, to permit method chaining - */ - public ExtraSlot clickable(boolean clickable) - { - canClick = clickable; - return this; - } - - /** - * Sets whether this slot shows a tooltip on mouseover - * - * @param showName - * @return this ExtraSlot, to permit method chaining - */ - public ExtraSlot showName(boolean showName) - { - this.showName = showName; - return this; - } - - /** - * A shortened version of {@link #clickable(boolean)} - * that passes true - * - * @return this ExtraSlot, to permit method chaining - */ - public ExtraSlot clickable() - { - return clickable(true); - } - - /** - * A shortened version of {@link #showName(boolean)} - * that passes true - * - * @return this ExtraSlot, to permit method chaining - */ - public ExtraSlot showName() - { - return showName(true); - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/api/InfoSlot.java b/src/api/java/uristqwerty/CraftGuide/api/InfoSlot.java deleted file mode 100644 index a67d54e35..000000000 --- a/src/api/java/uristqwerty/CraftGuide/api/InfoSlot.java +++ /dev/null @@ -1,74 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.item.ItemStack; - -public class InfoSlot extends ItemSlot -{ - private final ItemStack displayed; - private final String[] format; - private boolean clickable; - private boolean searchable; - - public InfoSlot(int x, int y, ItemStack displayedStack, String[] lines) - { - super(x, y, 16, 16, true); - displayed = displayedStack; - format = lines; - } - - @Override - public void draw(Renderer renderer, int x, int y, Object[] data, int dataIndex, boolean isMouseOver) - { - ItemSlot.implementation.draw(this, renderer, x, y, displayed, isMouseOver && clickable); - } - - @Override - public ItemFilter getClickedFilter(int x, int y, Object[] data, int dataIndex) - { - return clickable? null : ItemSlot.implementation.getClickedFilter(x, y, displayed); - } - - @Override - public List getTooltip(int x, int y, Object[] data, int dataIndex) - { - List tooltip = new ArrayList(); - - if(data[dataIndex] instanceof Object[]) - { - for(int i = 0; i < format.length; i++) - { - tooltip.add(String.format(format[i], (Object[])data[dataIndex])); - } - } - else - { - for(int i = 0; i < format.length; i++) - { - tooltip.add(String.format(format[i], data[dataIndex])); - } - } - - return tooltip; - } - - @Override - public boolean matches(ItemFilter filter, Object[] data, int dataIndex, SlotType type) - { - return searchable && ItemSlot.implementation.matches(this, filter, displayed, type); - } - - public InfoSlot setSeachable(boolean searchable) - { - this.searchable = searchable; - return this; - } - - public InfoSlot setClickable(boolean clickable) - { - this.clickable = clickable; - return this; - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/api/ItemFilter.java b/src/api/java/uristqwerty/CraftGuide/api/ItemFilter.java deleted file mode 100644 index 745329900..000000000 --- a/src/api/java/uristqwerty/CraftGuide/api/ItemFilter.java +++ /dev/null @@ -1,37 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import java.util.List; - - -/** - * - */ -public interface ItemFilter -{ - /** - * Compares this filter with an Object. Common types include an - * ItemStack, a List of ItemStacks, or a String. - *

    - * If the object type is unknown, return false. - * @param item - * @return - */ - public boolean matches(Object item); - - /** - * Draw a visual representation of this filter at (x, y), within a - * 16 by 16 rectangle. May extend out of that rectangle, although it - * might not look very good. - * @param renderer - * @param x - * @param y - */ - public void draw(Renderer renderer, int x, int y); - - /** - * Gets a description of the filter, displayed when the user moves - * their cursor over the filter display. - * @return a List of lines of text - */ - public List getTooltip(); -} diff --git a/src/api/java/uristqwerty/CraftGuide/api/ItemSlot.java b/src/api/java/uristqwerty/CraftGuide/api/ItemSlot.java deleted file mode 100644 index 4c2bebef7..000000000 --- a/src/api/java/uristqwerty/CraftGuide/api/ItemSlot.java +++ /dev/null @@ -1,154 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import java.util.List; - - -/** - * When a recipe is rendered, the ItemSlots provided to the template are - * used to determine the layout of the recipe's items. - */ -public class ItemSlot implements Slot -{ - /** - * This slot's size and location relative to the containing - * recipe's top left corner - */ - public int x, y, width, height; - - /** - * Used by {@link ItemSlotImplementation#draw} to decide - * whether to draw a background before drawing the actual - * slot contents. - */ - public boolean drawBackground; - - /** - * A sneaky field that is read by the default recipe implementation - * when an instance is created. If an ItemStack with a quantity - * greater than one would match up to an ItemSlot where - * drawQuantity equals false, it replaces the stack with one - * with a size of 1. This is only provided for convenience, it - * is entirely possibly to implement the same logic if it - * is needed but unavailable, such as with a custom recipe, - * or an implementation of Slot that is not an ItemSlot. - *

    - * The actual effect of this field may change in the future - * (for example, copying only part of the method that Minecraft - * uses to draw the item overlay, making the part that draws the - * stack size conditional), but for the moment, I'm assuming that - * doing it this way will be more compatible if Minecraft changes - * its implementation in the future, or if another mod edits - * {@link net.minecraft.src.RenderItem#renderItemOverlayIntoGUI}. - */ - public boolean drawQuantity; - - /** - * Used by {@link ItemSlotImplementation#matches} to - * restrict what sort of searches can match this slot - */ - public SlotType slotType = SlotType.INPUT_SLOT; - - /** - * Implementation of ItemSlot functionality, allowing it - * to change if needed, without altering the API. This - * field is set during CraftGuide's {@literal @PreInit}. - */ - public static ItemSlotImplementation implementation; - - /** - * Creates a new ItemSlot. Same as - * {@link #ItemSlot(int, int, int, int, boolean)}, with - * false as the last parameter. - * @param x - * @param y - * @param width - * @param height - */ - public ItemSlot(int x, int y, int width, int height) - { - this(x, y, width, height, false); - } - - /** - * Creates a new ItemSlot - * @param x - * @param y - * @param width - * @param height - * @param drawQuantity - */ - public ItemSlot(int x, int y, int width, int height, boolean drawQuantity) - { - this.x = x; - this.y = y; - this.width = width; - this.height = height; - this.drawQuantity = drawQuantity; - } - - @Override - public void draw(Renderer renderer, int x, int y, Object[] data, int dataIndex, boolean isMouseOver) - { - implementation.draw(this, renderer, x, y, data[dataIndex], isMouseOver); - } - - @Override - public List getTooltip(int x, int y, Object[] data, int dataIndex) - { - return implementation.getTooltip(this, data[dataIndex]); - } - - @Override - public boolean matches(ItemFilter search, Object[] data, int dataIndex, SlotType type) - { - return implementation.matches(this, search, data[dataIndex], type); - } - - @Override - public boolean isPointInBounds(int x, int y, Object[] data, int dataIndex) - { - return implementation.isPointInBounds(this, x, y); - } - - @Override - public ItemFilter getClickedFilter(int x, int y, Object[] data, int dataIndex) - { - return implementation.getClickedFilter(x, y, data[dataIndex]); - } - - /** - * Sets whether or not this ItemSlot draws a background square - * during its draw method. - * @param draw - * @return this, to permit method chaining - */ - public ItemSlot drawOwnBackground(boolean draw) - { - drawBackground = draw; - return this; - } - - /** - * Sets whether or not this ItemSlot draws a background square - * during its draw method. Same as {@link #drawOwnBackground()}, - * but uses the default value of true. - * @return this, to permit method chaining - */ - public ItemSlot drawOwnBackground() - { - return drawOwnBackground(true); - } - - /** - * Sets the {@link SlotType} associated with this ItemSlot. - * The SlotType is used for searches, both from in-game, and - * from the use of the API - * @param type - * @return this ItemSlot, to permit method chaining - */ - public ItemSlot setSlotType(SlotType type) - { - slotType = type; - return this; - } -} \ No newline at end of file diff --git a/src/api/java/uristqwerty/CraftGuide/api/ItemSlotImplementation.java b/src/api/java/uristqwerty/CraftGuide/api/ItemSlotImplementation.java deleted file mode 100644 index 618f0d276..000000000 --- a/src/api/java/uristqwerty/CraftGuide/api/ItemSlotImplementation.java +++ /dev/null @@ -1,61 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import java.util.List; - - -/** - * A collections of methods implementing the functionality required - * by ItemStack, without needing the code to be included as part of - * the API. - */ -public interface ItemSlotImplementation -{ - /** - * Gets the tooltip for an ItemSlot - * @param itemSlot - * @param data - * @return - */ - public List getTooltip(ItemSlot itemSlot, Object data); - - /** - * Draws an ItemSlot. - * @param itemSlot - * @param renderer - * @param x - * @param y - * @param data - * @param isMouseOver - */ - public void draw(ItemSlot itemSlot, Renderer renderer, int x, int y, Object data, boolean isMouseOver); - - /** - * Return an ItemFilter representing the ItemSlot contents. - * @param x - * @param y - * @param object - * @return - */ - public ItemFilter getClickedFilter(int x, int y, Object object); - - /** - * Compare the contents of an ItemSlot with an ItemFilter. - * @param itemSlot - * @param search - * @param object - * @param type - * @return - */ - public boolean matches(ItemSlot itemSlot, ItemFilter search, Object object, SlotType type); - - /** - * Does some simple math to test if a point, relative to the containing - * recipe's top left corner, is within the boundary rectangle of an - * ItemSlot. - * @param itemSlot - * @param x - * @param y - * @return - */ - public boolean isPointInBounds(ItemSlot itemSlot, int x, int y); -} diff --git a/src/api/java/uristqwerty/CraftGuide/api/LiquidFilter.java b/src/api/java/uristqwerty/CraftGuide/api/LiquidFilter.java deleted file mode 100644 index 578b9d4ee..000000000 --- a/src/api/java/uristqwerty/CraftGuide/api/LiquidFilter.java +++ /dev/null @@ -1,117 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.texture.TextureManager; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.item.ItemStack; -import net.minecraft.util.IIcon; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidStack; - -import org.lwjgl.opengl.GL11; - -public class LiquidFilter implements ItemFilter -{ - private static NamedTexture containerTexture = null; - private FluidStack liquid; - private String liquidName; - private List tooltip = new ArrayList(); - - public LiquidFilter(FluidStack liquid) - { - if(containerTexture == null) - { - containerTexture = Util.instance.getTexture("liquidFilterContainer"); - } - - setLiquid(liquid); - } - - public void setLiquid(FluidStack liquid) - { - String name = liquid.getFluid().getLocalizedName(); - this.liquid = liquid; - liquidName = name.toLowerCase(); - tooltip.clear(); - tooltip.add(name); - } - - @Override - public boolean matches(Object item) - { - if(item instanceof ItemStack) - { - return liquid.isFluidEqual((ItemStack)item); - } - else if(item instanceof FluidStack) - { - return liquid.isFluidEqual((FluidStack)item); - } - else if(item instanceof String) - { - return liquidName.contains(((String)item).toLowerCase()); - } - else if(item instanceof List) - { - for(Object object: ((List)item)) - { - if(matches(object)) - { - return true; - } - } - } - - return false; - } - - @Override - public void draw(Renderer renderer, int x, int y) - { - if(liquid != null) - { - TextureManager textureManager = Minecraft.getMinecraft().getTextureManager(); - - Fluid fluid = liquid.getFluid(); - IIcon icon = fluid.getStillIcon(); - - if(icon != null) - { - textureManager.bindTexture(TextureMap.locationBlocksTexture); - - double u = icon.getInterpolatedU(3.0); - double u2 = icon.getInterpolatedU(13.0); - double v = icon.getInterpolatedV(1.0); - double v2 = icon.getInterpolatedV(15.0); - - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glColor4d(1.0, 1.0, 1.0, 1.0); - - GL11.glBegin(GL11.GL_QUADS); - GL11.glTexCoord2d(u, v); - GL11.glVertex2i(x + 3, y + 1); - - GL11.glTexCoord2d(u, v2); - GL11.glVertex2i(x + 3, y + 15); - - GL11.glTexCoord2d(u2, v2); - GL11.glVertex2i(x + 13, y + 15); - - GL11.glTexCoord2d(u2, v); - GL11.glVertex2i(x + 13, y + 1); - GL11.glEnd(); - } - } - - renderer.renderRect(x - 1, y - 1, 18, 18, containerTexture); - } - - @Override - public List getTooltip() - { - return tooltip; - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/api/LiquidSlot.java b/src/api/java/uristqwerty/CraftGuide/api/LiquidSlot.java deleted file mode 100644 index 26c153724..000000000 --- a/src/api/java/uristqwerty/CraftGuide/api/LiquidSlot.java +++ /dev/null @@ -1,158 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.texture.TextureManager; -import net.minecraft.client.renderer.texture.TextureMap; -import net.minecraft.util.IIcon; -import net.minecraftforge.fluids.Fluid; -import net.minecraftforge.fluids.FluidContainerRegistry; -import net.minecraftforge.fluids.FluidContainerRegistry.FluidContainerData; -import net.minecraftforge.fluids.FluidStack; - -import org.lwjgl.opengl.GL11; - -public class LiquidSlot implements Slot -{ - private int x; - private int y; - private int width = 16; - private int height = 16; - private SlotType slotType = SlotType.INPUT_SLOT; - - private static NamedTexture containerTexture = null; - - public LiquidSlot(int x, int y) - { - this.x = x; - this.y = y; - - if(containerTexture == null) - { - containerTexture = Util.instance.getTexture("liquidFilterContainer"); - } - } - - @Override - public void draw(Renderer renderer, int recipeX, int recipeY, Object[] data, int dataIndex, boolean isMouseOver) - { - int x = recipeX + this.x; - int y = recipeY + this.y; - - if(data[dataIndex] instanceof FluidStack) - { - FluidStack liquid = (FluidStack)data[dataIndex]; - - TextureManager textureManager = Minecraft.getMinecraft().getTextureManager(); - - Fluid fluid = liquid.getFluid(); - IIcon icon = fluid.getStillIcon(); - - if(icon != null) - { - textureManager.bindTexture(TextureMap.locationBlocksTexture); - - double u = icon.getInterpolatedU(3.0); - double u2 = icon.getInterpolatedU(13.0); - double v = icon.getInterpolatedV(1.0); - double v2 = icon.getInterpolatedV(15.0); - - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glColor4d(1.0, 1.0, 1.0, 1.0); - - GL11.glBegin(GL11.GL_QUADS); - GL11.glTexCoord2d(u, v); - GL11.glVertex2i(x + 3, y + 1); - - GL11.glTexCoord2d(u, v2); - GL11.glVertex2i(x + 3, y + 15); - - GL11.glTexCoord2d(u2, v2); - GL11.glVertex2i(x + 13, y + 15); - - GL11.glTexCoord2d(u2, v); - GL11.glVertex2i(x + 13, y + 1); - GL11.glEnd(); - } - } - - renderer.renderRect(x - 1, y - 1, 18, 18, containerTexture); - } - - @Override - public ItemFilter getClickedFilter(int x, int y, Object[] data, int dataIndex) - { - if(data[dataIndex] instanceof FluidStack) - { - return new LiquidFilter((FluidStack)data[dataIndex]); - } - else - { - return null; - } - } - - @Override - public boolean isPointInBounds(int x, int y, Object[] data, int dataIndex) - { - return x >= this.x && x < this.x + width - && y >= this.y && y < this.y + height; - } - - @Override - public List getTooltip(int x, int y, Object[] data, int dataIndex) - { - List tooltip = null; - - if(data[dataIndex] instanceof FluidStack) - { - tooltip = new ArrayList(1); - FluidStack stack = (FluidStack)data[dataIndex]; - tooltip.add(stack.getFluid().getLocalizedName() + " (" + stack.amount + " milliBuckets)"); - } - - return tooltip; - } - - //Check if the filter directly matches the contained LiquidStack, or - // matches any liquid container containing the liquid. - @Override - public boolean matches(ItemFilter filter, Object[] data, int dataIndex, SlotType type) - { - if(!(data[dataIndex] instanceof FluidStack) || - (type != slotType && ( - type != SlotType.ANY_SLOT || - slotType == SlotType.DISPLAY_SLOT || - slotType == SlotType.HIDDEN_SLOT))) - { - return false; - } - - FluidStack stack = (FluidStack)data[dataIndex]; - - if(filter.matches(stack)) - { - return true; - } - else - { - for(FluidContainerData liquidData: FluidContainerRegistry.getRegisteredFluidContainerData()) - { - if(stack.isFluidEqual(liquidData.fluid) && filter.matches(liquidData.filledContainer)) - { - return true; - } - } - - return false; - } - } - - public Slot setSlotType(SlotType type) - { - slotType = type; - return this; - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/api/NamedTexture.java b/src/api/java/uristqwerty/CraftGuide/api/NamedTexture.java deleted file mode 100644 index 690f1678b..000000000 --- a/src/api/java/uristqwerty/CraftGuide/api/NamedTexture.java +++ /dev/null @@ -1,11 +0,0 @@ -package uristqwerty.CraftGuide.api; - -/** - * This interface represents an internal object to be used with - * {@link Renderer#renderRect(int, int, int, int, NamedTexture)}. - * It exists only to provide a type-safe way of storing the objects - * returned by {@link Util#getTexture}. - */ -public interface NamedTexture -{ -} diff --git a/src/api/java/uristqwerty/CraftGuide/api/RecipeFilter.java b/src/api/java/uristqwerty/CraftGuide/api/RecipeFilter.java deleted file mode 100644 index 9d6203be7..000000000 --- a/src/api/java/uristqwerty/CraftGuide/api/RecipeFilter.java +++ /dev/null @@ -1,24 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import java.util.List; - -import net.minecraft.item.ItemStack; - -/** - * More advanced than {@link BasicRecipeFilter}, this - * interface also allows re-ordering and insertion of - * entirely new recipes for each recipe type. - */ -public interface RecipeFilter -{ - /** - * Given a List of {@link CraftGuideRecipe}s, returns a - * modified list. May either return the provided list, or - * create a new List object. If a new List is created, it - * must allow element removal from its iterator. - * @param source - * @param recipeType - * @return - */ - public List filterRecipes(List source, ItemStack recipeType); -} diff --git a/src/api/java/uristqwerty/CraftGuide/api/RecipeGenerator.java b/src/api/java/uristqwerty/CraftGuide/api/RecipeGenerator.java deleted file mode 100644 index ab4c1395b..000000000 --- a/src/api/java/uristqwerty/CraftGuide/api/RecipeGenerator.java +++ /dev/null @@ -1,120 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; - -/** - * This interface contains methods that can be used to provide CraftGuide with - * crafting recipes. - *

    - * To do so, use one of the methods returning an {@link RecipeTemplate} - * to create a template from a list of {@link ItemSlot}s and optionally an - * ItemStack representing the recipe type (generally the block/item used to - * craft the recipe, if not provided, defaults to the workbench). - *

    - * With the template, call addRecipe for each recipe, passing an ItemStack[] - * corresponding to the ItemSlot[] provided when creating the template. - */ - -public interface RecipeGenerator -{ - /** - * Creates a {@link RecipeTemplate} for the provided ISlot[], - * associated with the provided crafting type. Create a default - * background based on the size of the template. - * @param slots - * @param craftingType - * @return - */ - public RecipeTemplate createRecipeTemplate(Slot[] slots, ItemStack craftingType); - - /** - * Creates a {@link RecipeTemplate} for the provided ISlot[], - * associated with the provided crafting type. The background is - * a rectangle taken out of the supplied texture file, at the - * coordinate pairs given. - * @param slots - * @param craftingType - * @param backgroundTexture - * @param backgroundX - * @param backgroundY - * @param backgroundSelectedX - * @param backgroundSelectedY - * @return - */ - - public RecipeTemplate createRecipeTemplate(Slot[] slots, ItemStack craftingType, String backgroundTexture, int backgroundX, int backgroundY, int backgroundSelectedX, int backgroundSelectedY); - /** - * Creates a {@link RecipeTemplate} for the provided ISlot[], - * associated with the provided crafting type. The background is - * a rectangle taken out of the supplied texture file, at the - * coordinate pairs given. - * @param slots - * @param craftingType - * @param backgroundTexture - * @param backgroundX - * @param backgroundY - * @param backgroundSelectedTexture - * @param backgroundSelectedX - * @param backgroundSelectedY - * @return - */ - public RecipeTemplate createRecipeTemplate(Slot[] slots, ItemStack craftingType, String backgroundTexture, int backgroundX, int backgroundY, String backgroundSelectedTexture, int backgroundSelectedX, int backgroundSelectedY); - - /** - * Generates a recipe from the template and Object[] passed to - * this method, and then adds it to CraftGuide to display in - * game. - * @param template - * @param crafting - */ - public void addRecipe(RecipeTemplate template, Object[] crafting); - - /** - * If you have your own recipe implementation, you can use this - * method to add recipes without needing a RecipeTemplate. - * @param recipe - * @param craftingType - */ - public void addRecipe(CraftGuideRecipe recipe, ItemStack craftingType); - - /** - * Sets whether a certain type of recipe is initially visible. - *

    - * Useful for hiding recipe types that have a lot of recipes, but - * few people need, so they would normally just add excessive - * clutter to the recipe list. - * @param type an ItemStack associated with the recipe type - * @param visible whether it is initially visible or not - */ - public void setDefaultTypeVisibility(ItemStack type, boolean visible); - - /** - * Takes an IRecipe, and returns an array representing a - * 3x3 crafting grid, plus a single output, for that recipe's - * contents. Each element is either null, an ItemStack, or a - * List containing zero or more ItemStacks (for Forge ore - * dictionary recipes). - *

    - * May return null if given an IRecipe implementation that it - * cannot interpret. - * @see #getCraftingRecipe(IRecipe, boolean) - * @param recipe the IRecipe to be read - * @return an Object[10], where the first nine elements form - * the 3x3 input grid, and the last element is the recipe output. - */ - public Object[] getCraftingRecipe(IRecipe recipe); - - /** - * Takes an IRecipe, and returns an array representing a - * 3x3 or 2x2 crafting grid, plus a single output. - *

    - * See {@link #getCraftingRecipe(IRecipe)} for details. - * @see #getCraftingRecipe(IRecipe) - * @param recipe - * @param allowSmallGrid if true, may return an Object[5] if - * the recipe fits in a 2x2 grid. - * @return an Object[10] or an Object[5] - */ - public Object[] getCraftingRecipe(IRecipe recipe, boolean allowSmallGrid); -} diff --git a/src/api/java/uristqwerty/CraftGuide/api/RecipeProvider.java b/src/api/java/uristqwerty/CraftGuide/api/RecipeProvider.java deleted file mode 100644 index 4a31bdfb9..000000000 --- a/src/api/java/uristqwerty/CraftGuide/api/RecipeProvider.java +++ /dev/null @@ -1,18 +0,0 @@ -package uristqwerty.CraftGuide.api; - -/** - * When CraftGuide (re)loads its recipe list, every Object that implements this - * interface, and has been registered with CraftGuide, will have its generateRecipes - * method called. - */ -public interface RecipeProvider -{ - /** - * Called by CraftGuide when it is (re)populating its recipe list, as a request - * for the implementing Object to provide recipes through the IRecipeGenerator - * instance passed to it. - * @param generator - * @see RecipeGenerator - */ - void generateRecipes(RecipeGenerator generator); -} diff --git a/src/api/java/uristqwerty/CraftGuide/api/RecipeTemplate.java b/src/api/java/uristqwerty/CraftGuide/api/RecipeTemplate.java deleted file mode 100644 index c03051d02..000000000 --- a/src/api/java/uristqwerty/CraftGuide/api/RecipeTemplate.java +++ /dev/null @@ -1,36 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import net.minecraft.item.ItemStack; - -/** - */ -public interface RecipeTemplate -{ - /** - * Sets the width and height that will be used for recipes - * produced by this template - * @param width - * @param height - * @return this template, to allow method chaining - */ - public RecipeTemplate setSize(int width, int height); - - /** - * Gets an ItemStack that represents the type of the recipe. - * Generally, this should be the block or item that players - * would most closely associate with it, such as the machine - * that the recipe is crafted in, or an item that opens the - * crafting GUI used by the recipe. - * - * @return the ItemStack, or null to default to a workbench - */ - public ItemStack getCraftingType(); - - /** - * Generate a recipe from an Object[] representing the contents - * of the recipe. - * @param items - * @return - */ - public CraftGuideRecipe generate(Object[] items); -} diff --git a/src/api/java/uristqwerty/CraftGuide/api/Renderer.java b/src/api/java/uristqwerty/CraftGuide/api/Renderer.java deleted file mode 100644 index 16ac69dae..000000000 --- a/src/api/java/uristqwerty/CraftGuide/api/Renderer.java +++ /dev/null @@ -1,108 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import net.minecraft.item.ItemStack; - -/** - * Provides useful methods to render common things, in - * {@link Slot#draw} and {@link CraftGuideRecipe#draw}. - */ -public interface Renderer -{ - /** - * Draws an ItemStack at the specified screen coordinates. - * @param x - * @param y - * @param stack - */ - public void renderItemStack(int x, int y, ItemStack stack); - - - /** - * Draws a solid color rectangle - * @param x - * @param y - * @param width - * @param height - * @param color_argb Red, Green, Blue, and Alpha, packed into a single int, - * in the form 0xaarrggbb - */ - public void renderRect(int x, int y, int width, int height, int color_argb); - - - /** - * Draws a solid color rectangle - * @param x - * @param y - * @param width - * @param height - * @param color_rgb Red, Green, and Blue, packed into a single int, in the - * form 0x00rrggbb - * @param alpha - */ - public void renderRect(int x, int y, int width, int height, int color_rgb, int alpha); - - /** - * Draws a solid color rectangle - * @param x - * @param y - * @param width - * @param height - * @param red - * @param green - * @param blue - * @param alpha - */ - public void renderRect(int x, int y, int width, int height, int red, int green, int blue, int alpha); - - /** - * Draws a rectangle, textured with a NamedTexture obtained from - * {@link Util#getTexture}. - * @param x - * @param y - * @param width - * @param height - * @param texture - */ - public void renderRect(int x, int y, int width, int height, NamedTexture texture); - - /** - * Draws a rectangle, containing a vertical gradient - *
    - * Colors are packed into ints, in the form 0xaarrggbb - * @param x - * @param y - * @param width - * @param height - * @param topColor_argb - * @param bottomColor_argb - */ - public void renderVerticalGradient(int x, int y, int width, int height, int topColor_argb, int bottomColor_argb); - - /** - * Draws a rectangle, containing a horizontal gradient. - *
    - * Colors are packed into ints, in the form 0xaarrggbb - * @param x - * @param y - * @param width - * @param height - * @param leftColor_argb - * @param rightColor_argb - */ - public void renderHorizontalGradient(int x, int y, int width, int height, int leftColor_argb, int rightColor_argb); - - /** - * Draws a rectangle, containing an arbitrary gradient. - *
    - * Colors are packed into ints, in the form 0xaarrggbb - * @param x - * @param y - * @param width - * @param height - * @param topLeftColor_argb - * @param topRightColor_argb - * @param bottomLeftColor_argb - * @param bottomRightColor_argb - */ - public void renderGradient(int x, int y, int width, int height, int topLeftColor_argb, int topRightColor_argb, int bottomLeftColor_argb, int bottomRightColor_argb); -} diff --git a/src/api/java/uristqwerty/CraftGuide/api/Slot.java b/src/api/java/uristqwerty/CraftGuide/api/Slot.java deleted file mode 100644 index 6aa3a3d3e..000000000 --- a/src/api/java/uristqwerty/CraftGuide/api/Slot.java +++ /dev/null @@ -1,92 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import java.util.List; - -/** - * A Slot represents a single component of a recipe being displayed by - * CraftGuide. Similar to how Minecraft handles items and blocks, one - * instance of a slot is used to handle the logic of multiple recipes. - *

    - * Each method's parameters include an Object[] representing the specific - * recipe, and the index of the Object related to this slot, allowing - * implementations that react differently based on more than one component - * of the recipe. - *

    - * Slot is only used by the default implementation of CraftGuideRecipe, a - * custom implementation may opt to ignore any part of this, or not use it - * entirely, but if it does, then it should provide some sort of logic to - * perform the same functionality. For example, one mod may opt to extend - * this interface with a number of more specific methods, and implement a - * recipe that mainly uses the alternate methods in certain situations. - * For most mods, however, the existing recipe mechanics should be - * sufficient (most shouldn't even need more than the provided ItemSlot). - */ -public interface Slot -{ - /** - * This method is called in order to draw this slot. (x, y) is the - * absolute coordinate of the top left corner of the containing - * recipe. - * @param renderer - * @param x - * @param y - * @param data - * @param dataIndex - * @param isMouseOver - */ - public void draw(Renderer renderer, int x, int y, Object[] data, int dataIndex, boolean isMouseOver); - - /** - * When this slot is clicked on in a recipe, this method is called in - * order to get the filter Object that is used to search the recipe list - * for related recipes. If null is returned, then the filter will not - * change. - *

    - * For common types, {@link Util#getCommonFilter(Object)} can provide - * a filter if given a known type of Object. - * @param x clicked coordinate, relative to the recipe's top left corner - * @param y clicked coordinate, relative to the recipe's top left corner - * @param data the Object[] representing the recipe - * @param dataIndex this slot's index in data - * @return null, or an IItemFilter - */ - public ItemFilter getClickedFilter(int x, int y, Object[] data, int dataIndex); - - /** - * This method is used by CraftGuide to determine whether a specific point - * is considered within the bounds of this particular slot. It is typically - * used to determine what slot, if any, the user's cursor is currently over. - * - * @param x coordinate, relative to the recipe's top left corner - * @param y coordinate, relative to the recipe's top left corner - * @param data the Object[] representing the recipe - * @param dataIndex this slot's index in data - * @return true if (x, y) is within this slot's bounds, otherwise false - */ - public boolean isPointInBounds(int x, int y, Object[] data, int dataIndex); - - /** - * When the user moves their cursor over a recipe containing this slot, and - * the cursor's position is within the bounds of this slot (relative to the - * containing recipe), this method is called to determine whether to display - * a tooltip, and, if so, what text should be displayed. - * - * @param x cursor coordinate, relative to the recipe's top left corner - * @param y cursor coordinate, relative to the recipe's top left corner - * @param data the Object[] representing the recipe - * @param dataIndex this slot's index in data - * @return a List of Strings, representing one or more lines of text, or - * null if the tooltip should not be displayed - */ - public List getTooltip(int x, int y, Object[] data, int dataIndex); - - /** - * Used to test if a specific slot matches the searched {@link ItemFilter} - * - * @param filter the Object being compared the the contents of this slot - * @param data the recipe's raw data array - * @param dataIndex this slot's index - * @param type the type of slot that is being searched for - */ - public boolean matches(ItemFilter filter, Object[] data, int dataIndex, SlotType type); -} diff --git a/src/api/java/uristqwerty/CraftGuide/api/SlotType.java b/src/api/java/uristqwerty/CraftGuide/api/SlotType.java deleted file mode 100644 index 3310e352f..000000000 --- a/src/api/java/uristqwerty/CraftGuide/api/SlotType.java +++ /dev/null @@ -1,38 +0,0 @@ -package uristqwerty.CraftGuide.api; - -/** - * SlotType is used to declare the purpose of a {@link Slot}, used - * by searches (both in-game and through the API). - */ -public enum SlotType -{ - /** - * For searches; matches anything except - * {@link HIDDEN_SLOT} and {@link DISPLAY_SLOT} - */ - ANY_SLOT, - - /** Resources required for the recipe */ - INPUT_SLOT, - /** Products produced by the recipe */ - OUTPUT_SLOT, - /** Machine(s) that processes the recipe */ - MACHINE_SLOT, - - /** - * Just in case {@link INPUT_SLOT}, {@link OUTPUT_SLOT}, - * and {@link MACHINE_SLOT} aren't adequate descriptions - * of this slot's purpose. - */ - OTHER_SLOT, - - /** - * Does not show up in searches for {@link ANY_SLOT}. - * Use for visual effects and such. - */ - DISPLAY_SLOT, - /** - * Does not show up in searches for {@link ANY_SLOT}. - */ - HIDDEN_SLOT, -} diff --git a/src/api/java/uristqwerty/CraftGuide/api/StackInfo.java b/src/api/java/uristqwerty/CraftGuide/api/StackInfo.java deleted file mode 100644 index bb088d11e..000000000 --- a/src/api/java/uristqwerty/CraftGuide/api/StackInfo.java +++ /dev/null @@ -1,14 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import java.util.ArrayList; -import java.util.List; - -public class StackInfo -{ - public static List sources = new ArrayList(); - - public static void addSource(StackInfoSource source) - { - sources.add(source); - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/api/StackInfoSource.java b/src/api/java/uristqwerty/CraftGuide/api/StackInfoSource.java deleted file mode 100644 index 85e89f772..000000000 --- a/src/api/java/uristqwerty/CraftGuide/api/StackInfoSource.java +++ /dev/null @@ -1,8 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import net.minecraft.item.ItemStack; - -public interface StackInfoSource -{ - public String getInfo(ItemStack itemStack); -} diff --git a/src/api/java/uristqwerty/CraftGuide/api/Util.java b/src/api/java/uristqwerty/CraftGuide/api/Util.java deleted file mode 100644 index 85202e517..000000000 --- a/src/api/java/uristqwerty/CraftGuide/api/Util.java +++ /dev/null @@ -1,78 +0,0 @@ -package uristqwerty.CraftGuide.api; - -import java.util.List; - -import net.minecraft.item.ItemStack; - -/** - * Contains a number of methods that implement common functionality - * that would otherwise need to be implemented by everyone who uses - * the API, or that relies on parts of CraftGuide not included in - * the API. - */ -public abstract class Util -{ - /** - * An instance of Util, containing the method implementations. - *

    - * It is set during CraftGuide's {@literal @PreInit}. - */ - public static Util instance; - - /** - * Causes CraftGuide to clear its list of recipes, and reload them with - * exactly the same process that was originally used to build the list. - */ - public abstract void reloadRecipes(); - - /** - * Converts the passed ItemStack's name and information into a List - * of Strings for display, similar to how GuiContainer does it. - * Additionally, contains logic to try an alternative if given a stack - * with a damage of -1 which produces an unusable name and information, - * if CraftGuide is set to always show item IDs it will insert the item's - * ID and damage value as the second line. If an exception is thrown - * at any time during the process, it will log it to CraftGuide.log and - * generate an error text to display that at least shows the item ID and - * damage. - * @param stack - * @return - */ - public abstract List getItemStackText(ItemStack stack); - - /** - * Gets a standard {@link ItemFilter} for any of the common types: - *
  • ItemStack - *
  • List of ItemStacks - *
  • String - * - * @param item - * @return - */ - public abstract ItemFilter getCommonFilter(Object item); - - /** - * Gets a texture usable with {@link Renderer#renderRect} - * from a String identifier. At the moment, it only accepts the - * hardcoded values "ItemStack-Any", "ItemStack-Background", and - * "ItemStack-OreDict", but the eventual intention is to load the - * definitions from external text files, to allow for a far more - * advanced ability to re-skin the entire GUI than is normally - * possible from just swapping a texture file. - * - * @param identifier - * @return - */ - public abstract NamedTexture getTexture(String identifier); - - /** - * Returns the number of partial ticks for this frame. I don't know - * quite what they do, but it's the third parameter to - * {@link net.minecraft.src.GuiScreen#drawScreen}, so I'm assuming - * that at least something needs it. Rather than pass it as an - * extra argument to every drawing method, it is stored at the - * start of rendering the GUI, and can be retrieved with this method. - * @return - */ - public abstract float getPartialTicks(); -} diff --git a/src/api/java/uristqwerty/CraftGuide/client/CraftGuideClient.java b/src/api/java/uristqwerty/CraftGuide/client/CraftGuideClient.java deleted file mode 100644 index 28ba3ab69..000000000 --- a/src/api/java/uristqwerty/CraftGuide/client/CraftGuideClient.java +++ /dev/null @@ -1,192 +0,0 @@ -package uristqwerty.CraftGuide.client; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileOutputStream; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStream; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; - -import uristqwerty.CraftGuide.CraftGuide; -import uristqwerty.CraftGuide.CraftGuideLog; -import uristqwerty.CraftGuide.CraftGuideSide; -import uristqwerty.CraftGuide.GuiCraftGuide; -import uristqwerty.CraftGuide.api.Util; -import uristqwerty.CraftGuide.client.ui.GuiRenderer; -import uristqwerty.gui_craftguide.rendering.RendererBase; -import uristqwerty.gui_craftguide.texture.BlankTexture; -import uristqwerty.gui_craftguide.texture.BorderedTexture; -import uristqwerty.gui_craftguide.texture.MultipleTextures; -import uristqwerty.gui_craftguide.texture.SolidColorTexture; -import uristqwerty.gui_craftguide.texture.SubTexture; -import uristqwerty.gui_craftguide.texture.TextureClip; -import uristqwerty.gui_craftguide.texture.TintedTexture; -import uristqwerty.gui_craftguide.theme.ThemeManager; - -public abstract class CraftGuideClient implements CraftGuideSide -{ - @Override - public void preInit() - { - RendererBase.instance = new GuiRenderer(); - Util.instance = new UtilImplementationClient(); - extractResources(); - - ThemeManager.addTextureType(SolidColorTexture.class); - ThemeManager.addTextureType(MultipleTextures.class); - ThemeManager.addTextureType(BorderedTexture.class); - ThemeManager.addTextureType(TintedTexture.class); - ThemeManager.addTextureType(BlankTexture.class); - ThemeManager.addTextureType(TextureClip.class); - ThemeManager.addTextureType(SubTexture.class); - - - ThemeManager.instance.reload(); - - ThemeManager.currentTheme = ThemeManager.instance.buildTheme(readThemeChoice()); - - if(ThemeManager.currentTheme == null) - { - ThemeManager.currentTheme = ThemeManager.instance.buildTheme("theme_base"); - } - } - - private String readThemeChoice() - { - File dir = themeDirectory(); - - if(dir == null) - { - return "base_texpack"; - } - - File file = new File(dir, "currentTheme.txt"); - - if(!file.exists()) - { - try - { - file.createNewFile(); - } - catch(IOException e) - { - e.printStackTrace(); - } - - if(file.canWrite()) - { - try - { - FileWriter writer = new FileWriter(file); - writer.write("base_texpack"); - writer.close(); - } - catch(IOException e) - { - e.printStackTrace(); - } - } - } - else if(file.canRead()) - { - try - { - BufferedReader reader = new BufferedReader(new FileReader(file)); - String line = reader.readLine(); - reader.close(); - return line; - } - catch(IOException e) - { - e.printStackTrace(); - } - } - - return "base_texpack"; - } - - @Override - public void reloadRecipes() - { - GuiCraftGuide.getInstance().reloadRecipes(); - } - - public static File themeDirectory() - { - File configDir = CraftGuide.configDirectory(); - - if(configDir == null) - { - return null; - } - - File dir = new File(configDir, "themes"); - - if(!dir.exists() && !dir.mkdirs()) - { - return null; - } - - return dir; - } - - private void extractResources() - { - File outputBase = themeDirectory(); - - if(outputBase == null) - { - return; - } - - try - { - InputStream stream = CraftGuide.class.getResourceAsStream("CraftGuideResources.zip"); - - if(stream != null) - { - ZipInputStream resources = new ZipInputStream(stream); - byte[] buffer = new byte[1024 * 16]; - ZipEntry entry; - while((entry = resources.getNextEntry()) != null) - { - File destination = new File(outputBase, entry.getName()); - - if(entry.isDirectory()) - { - destination.mkdirs(); - } - else - { - CraftGuideLog.log("CraftGuide: Extracting '" + entry.getName() + "' to '" + destination.getCanonicalPath() + "'", false); - destination.getParentFile().mkdirs(); - destination.createNewFile(); - FileOutputStream output = new FileOutputStream(destination); - int len; - - while((len = resources.read(buffer, 0, buffer.length)) != -1) - { - output.write(buffer, 0, len); - } - - output.flush(); - output.close(); - } - } - } - } - catch(IOException e) - { - e.printStackTrace(); - } - } - - @Override - public void initNetworkChannels() - { - CraftGuide.loaderSide.initClientNetworkChannels(); - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/client/FilterDisplay.java b/src/api/java/uristqwerty/CraftGuide/client/FilterDisplay.java deleted file mode 100644 index 3ea12ef79..000000000 --- a/src/api/java/uristqwerty/CraftGuide/client/FilterDisplay.java +++ /dev/null @@ -1,72 +0,0 @@ -package uristqwerty.CraftGuide.client; - -import java.util.List; - -import uristqwerty.CraftGuide.api.ItemFilter; -import uristqwerty.CraftGuide.client.ui.GuiRenderer; -import uristqwerty.CraftGuide.client.ui.Rendering.FloatingItemText; -import uristqwerty.CraftGuide.client.ui.Rendering.Overlay; -import uristqwerty.gui_craftguide.components.GuiElement; -import uristqwerty.gui_craftguide.rendering.Renderable; -import uristqwerty.gui_craftguide.rendering.RendererBase; - -public class FilterDisplay extends GuiElement implements Renderable -{ - public ItemFilter filter; - private FloatingItemText itemName = new FloatingItemText("-No Item-"); - private Renderable itemNameOverlay = new Overlay(itemName); - private List text; - - public FilterDisplay(int x, int y) - { - super(x, y, 16, 16); - } - - public void setFilter(ItemFilter filter) - { - this.filter = filter; - } - - @Override - public void mouseMoved(int x, int y) - { - if(containsPoint(x, y) && filter != null) - { - text = filter.getTooltip(); - } - else - { - text = null; - } - - super.mouseMoved(x, y); - } - - @Override - public void draw() - { - super.draw(); - render(this); - - if(text != null) - { - itemName.setText(text); - render(itemNameOverlay); - } - } - - //@Override - private void render(GuiRenderer renderer, int xOffset, int yOffset) - { - if(filter != null) - { - filter.draw(renderer, xOffset, yOffset); - } - } - - @Override - public void render(RendererBase renderer, int x, int y) - { - render((GuiRenderer)renderer, x, y); - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/client/UtilImplementationClient.java b/src/api/java/uristqwerty/CraftGuide/client/UtilImplementationClient.java deleted file mode 100644 index 871c51991..000000000 --- a/src/api/java/uristqwerty/CraftGuide/client/UtilImplementationClient.java +++ /dev/null @@ -1,52 +0,0 @@ -package uristqwerty.CraftGuide.client; - -import java.util.HashMap; -import java.util.Map; - -import uristqwerty.CraftGuide.UtilImplementationCommon; -import uristqwerty.CraftGuide.api.NamedTexture; -import uristqwerty.CraftGuide.client.ui.NamedTextureObject; -import uristqwerty.gui_craftguide.texture.DynamicTexture; - -public class UtilImplementationClient extends UtilImplementationCommon -{ - private NamedTextureObject textFilter = new NamedTextureObject(DynamicTexture.instance("text-filter")); - private NamedTextureObject itemStackAny = new NamedTextureObject(DynamicTexture.instance("stack-any")); - private NamedTextureObject itemStackOreDict = new NamedTextureObject(DynamicTexture.instance("stack-oredict")); - private NamedTextureObject itemStackOreDictSingle = new NamedTextureObject(DynamicTexture.instance("stack-oredict-single")); - private NamedTextureObject itemStackBackground = new NamedTextureObject(DynamicTexture.instance("stack-background")); - - private Map textureLookup = new HashMap(); - - @Override - public NamedTexture getTexture(String identifier) - { - if("ItemStack-Any".equalsIgnoreCase(identifier)) - { - return itemStackAny; - } - else if("ItemStack-OreDict".equalsIgnoreCase(identifier)) - { - return itemStackOreDict; - } - else if("ItemStack-OreDict-Single".equalsIgnoreCase(identifier)) - { - return itemStackOreDictSingle; - } - else if("ItemStack-Background".equalsIgnoreCase(identifier)) - { - return itemStackBackground; - } - else if("TextFilter".equalsIgnoreCase(identifier)) - { - return textFilter; - } - - if(!textureLookup.containsKey(identifier)) - { - textureLookup.put(identifier, new NamedTextureObject(DynamicTexture.instance(identifier))); - } - - return textureLookup.get(identifier); - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/client/fml/CraftGuideClient_FML.java b/src/api/java/uristqwerty/CraftGuide/client/fml/CraftGuideClient_FML.java deleted file mode 100644 index 1bc337673..000000000 --- a/src/api/java/uristqwerty/CraftGuide/client/fml/CraftGuideClient_FML.java +++ /dev/null @@ -1,143 +0,0 @@ -package uristqwerty.CraftGuide.client.fml; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.settings.KeyBinding; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.inventory.Container; -import net.minecraft.inventory.Slot; -import net.minecraft.item.ItemStack; - -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; - -import uristqwerty.CraftGuide.CommonUtilities; -import uristqwerty.CraftGuide.CraftGuide; -import uristqwerty.CraftGuide.CraftGuideLog; -import uristqwerty.CraftGuide.GuiCraftGuide; -import uristqwerty.CraftGuide.client.CraftGuideClient; -import cpw.mods.fml.client.FMLClientHandler; -import cpw.mods.fml.client.registry.ClientRegistry; - -public class CraftGuideClient_FML extends CraftGuideClient -{ - - private KeyBinding key; - - @Override - public void initKeybind() - { - key = new KeyBinding( "Open CraftGuide", CraftGuide.defaultKeybind, "key.categories.misc" ); - ClientRegistry.registerKeyBinding( key ); - } - - @Override - public void checkKeybind() - { - if ( Keyboard.isKeyDown( key.getKeyCode() ) && CraftGuide.enableKeybind ) - { - Minecraft mc = Minecraft.getMinecraft(); - GuiScreen screen = mc.currentScreen; - - if ( screen == null ) - { - CraftGuide.side.openGUI( mc.thePlayer ); - } - else if ( screen instanceof GuiContainer ) - { - try - { - int x = Mouse.getX() * screen.width / mc.displayWidth; - int y = screen.height - (Mouse.getY() * screen.height / mc.displayHeight) - 1; - int left = (Integer) CommonUtilities.getPrivateValue( GuiContainer.class, (GuiContainer) screen, "field_147003_i", "i", "guiLeft" ); - int top = (Integer) CommonUtilities.getPrivateValue( GuiContainer.class, (GuiContainer) screen, "field_147009_r", "r", "guiTop" ); - openRecipe( (GuiContainer) screen, x - left, y - top ); - } - catch (IllegalArgumentException e) - { - CraftGuideLog.log( e, "Exception while trying to identify if there is an item at the current cursor position.", true ); - } - catch (SecurityException e) - { - CraftGuideLog.log( e, "Exception while trying to identify if there is an item at the current cursor position.", true ); - } - catch (NoSuchFieldException e) - { - CraftGuideLog.log( e, "Exception while trying to identify if there is an item at the current cursor position.", true ); - } - catch (IllegalAccessException e) - { - CraftGuideLog.log( e, "Exception while trying to identify if there is an item at the current cursor position.", true ); - } - } - } - } - - private void openRecipe(GuiContainer screen, int x, int y) - { - Container container = screen.inventorySlots; - - for (int i = 0; i < container.inventorySlots.size(); i++) - { - Slot slot = (Slot) container.inventorySlots.get( i ); - if ( x > slot.xDisplayPosition - 2 && x < slot.xDisplayPosition + 17 && y > slot.yDisplayPosition - 2 && y < slot.yDisplayPosition + 17 ) - { - ItemStack item = slot.getStack(); - - if ( item != null ) - { - Minecraft mc = Minecraft.getMinecraft(); - GuiCraftGuide.getInstance().setFilterItem( item ); - CraftGuide.side.openGUI( mc.thePlayer ); - } - - break; - } - } - } - - @Override - public void openGUI(EntityPlayer player) - { - FMLClientHandler.instance().displayGuiScreen( player, GuiCraftGuide.getInstance() ); - } - - boolean failed = false; - - @Override - public void stopTessellating() - { - if ( failed ) - return; - - try - { - if ( (Boolean) CommonUtilities.getPrivateValue( Tessellator.class, Tessellator.instance, "field_78415_z", "isDrawing", "x" ) ) - { - Tessellator.instance.draw(); - } - } - catch (SecurityException e) - { - CraftGuideLog.log( e, "", true ); - failed = true; - } - catch (IllegalArgumentException e) - { - CraftGuideLog.log( e, "", true ); - failed = true; - } - catch (NoSuchFieldException e) - { - CraftGuideLog.log( e, "", true ); - failed = true; - } - catch (IllegalAccessException e) - { - CraftGuideLog.log( e, "", true ); - failed = true; - } - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/client/ui/ButtonTemplate.java b/src/api/java/uristqwerty/CraftGuide/client/ui/ButtonTemplate.java deleted file mode 100644 index 532ece30e..000000000 --- a/src/api/java/uristqwerty/CraftGuide/client/ui/ButtonTemplate.java +++ /dev/null @@ -1,37 +0,0 @@ -package uristqwerty.CraftGuide.client.ui; - -import java.util.HashMap; -import java.util.Map; - -import uristqwerty.CraftGuide.client.ui.GuiButton.ButtonState; -import uristqwerty.gui_craftguide.texture.Texture; - -public class ButtonTemplate -{ - private Map stateImages = new HashMap(); - - public ButtonTemplate(Texture[] images) - { - int i = 0; - for(ButtonState state: ButtonState.values()) - { - setStateImage(state, images[i]); - i = Math.min(i + 1, images.length); - } - } - - public ButtonTemplate() - { - } - - public Texture getStateImage(ButtonState state) - { - return stateImages.get(state); - } - - public ButtonTemplate setStateImage(ButtonState state, Texture image) - { - stateImages.put(state, image); - return this; - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/client/ui/CraftTypeDisplay.java b/src/api/java/uristqwerty/CraftGuide/client/ui/CraftTypeDisplay.java deleted file mode 100644 index 8ad7673bc..000000000 --- a/src/api/java/uristqwerty/CraftGuide/client/ui/CraftTypeDisplay.java +++ /dev/null @@ -1,271 +0,0 @@ -package uristqwerty.CraftGuide.client.ui; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import uristqwerty.CraftGuide.CraftType; -import uristqwerty.CraftGuide.RecipeCache; -import uristqwerty.CraftGuide.client.ui.Rendering.FloatingItemText; -import uristqwerty.CraftGuide.client.ui.Rendering.Overlay; -import uristqwerty.CraftGuide.client.ui.Rendering.ShadedRect; -import uristqwerty.gui_craftguide.rendering.Renderable; -import uristqwerty.gui_craftguide.rendering.TexturedRect; -import uristqwerty.gui_craftguide.texture.BorderedTexture; -import uristqwerty.gui_craftguide.texture.Texture; - -public class CraftTypeDisplay extends GuiScrollableGrid implements IRecipeCacheListener -{ - private Texture displayBackground; - private Renderable hiddenOverlay = new ShadedRect(-2, -2, 20, 20, 0xc6c6c6, 0x80); - private RecipeCache recipeCache; - private Map settings = new HashMap(); - private FloatingItemText toolTip = new FloatingItemText(""); - private Overlay toolTipOverlay = new Overlay(toolTip); - private String toolTipText = ""; - - private TexturedRect buttons[] = new TexturedRect[6]; - - public CraftTypeDisplay(int x, int y, int width, int height, GuiScrollBar scrollBar, Texture texture, RecipeCache recipeCache) - { - super(x, y, width, height, scrollBar, 32, 1); - - displayBackground = new BorderedTexture(texture, 117, 1, 1, 32, 2); - - this.recipeCache = recipeCache; - recipeCache.addListener(this); - initTypes(recipeCache); - - buttons[0] = new TexturedRect(0, 0, 28, 28, texture, 113, 76); - buttons[1] = new TexturedRect(0, 0, 28, 28, texture, 113, 104); - buttons[2] = new TexturedRect(0, 0, 28, 28, texture, 113, 132); - buttons[3] = new TexturedRect(0, 0, 28, 28, texture, 141, 76); - buttons[4] = new TexturedRect(0, 0, 28, 28, texture, 141, 104); - buttons[5] = new TexturedRect(0, 0, 28, 28, texture, 141, 132); - - setRows(recipeCache.getCraftTypes().size()); - setCells(recipeCache.getCraftTypes().size()); - } - - private void initTypes(RecipeCache recipeCache) - { - Set types = recipeCache.getCraftTypes(); - Set filteredTypes = recipeCache.getFilterTypes(); - - if(filteredTypes != null) - { - for(CraftType type: types) - { - settings.put(type, 1); - } - - for(CraftType type: filteredTypes) - { - settings.put(type, 0); - } - } - } - - @Override - public void renderGridRow(GuiRenderer renderer, int xOffset, int yOffset, int row) - { - Set types = recipeCache.getCraftTypes(); - - if(row < types.size()) - { - CraftType type = (CraftType)types.toArray()[row]; - displayBackground.renderRect(renderer, xOffset, yOffset, width(), rowHeight, 0, 0); - renderer.drawItemStack(type.getDisplayStack(), xOffset + 8, yOffset + 8, false); - - if(hidden(type)) - { - hiddenOverlay.render(renderer, xOffset + 8, yOffset + 8); - } - - for(int i = 0; i < 3; i++) - { - TexturedRect rect = buttons[i == setting(type)? i + 3 : i]; - - rect.render(renderer, xOffset + i * 29 + (bounds.width() - (3 * 29 + 24)) / 2 + 24, yOffset + 2); - } - } - } - - private boolean hidden(CraftType type) - { - switch(setting(type)) - { - case 2: - return false; - - case 1: - return true; - - default: - for(CraftType otherType: settings.keySet()) - { - if(setting(otherType) == 2) - { - return true; - } - } - - return false; - } - } - - @Override - public void rowClicked(int row, int x, int y, boolean inBounds) - { - if(y > 1 && y < 30 && inBounds) - { - if(x >= (bounds.width() - (3 * 29 + 24)) / 2 + 24 && x < (bounds.width() - (3 * 29 + 24)) / 2 + 24 + 3 * 29) - { - int relX = (x - ((bounds.width() - (3 * 29 + 24)) / 2 + 24)); - - if(relX % 29 != 28) - { - set(row, relX / 29); - } - } - } - } - - @Override - public void onChange(RecipeCache cache) - { - setRows(recipeCache.getCraftTypes().size()); - } - - @Override - public void setColumns(int columns) - { - super.setColumns(1); - } - - private int setting(CraftType type) - { - if(!settings.containsKey(type)) - { - settings.put(type, 0); - } - - return settings.get(type); - } - - private void set(int row, int setting) - { - Set types = recipeCache.getCraftTypes(); - - if(row < types.size()) - { - CraftType type = (CraftType)types.toArray()[row]; - - settings.put(type, setting); - - settingChanged(type, setting); - } - } - - private void settingChanged(CraftType type, int setting) - { - if(setting == 2) - { - for(CraftType settingType: settings.keySet()) - { - if(settingType != type && settings.get(settingType) == 2) - { - settings.put(settingType, 0); - } - } - } - - updateFilter(); - } - - private void updateFilter() - { - Set set = new HashSet(); - - for(CraftType type: settings.keySet()) - { - if(setting(type) == 2) - { - set.add(type); - recipeCache.setTypes(set); - return; - } - } - - for(CraftType type: recipeCache.getCraftTypes()) - { - if(setting(type) != 1) - { - set.add(type); - } - } - - recipeCache.setTypes(set); - } - - @Override - public void onReset(RecipeCache cache) - { - } - - @Override - public void draw() - { - super.draw(); - if(toolTipText != "") - { - toolTip.setText(toolTipText); - render(toolTipOverlay); - } - } - - @Override - public void mouseMovedRow(int row, int x, int y, boolean inBounds) - { - super.mouseMovedRow(row, x, y, inBounds); - - if(row < recipeCache.getCraftTypes().size() && y > 1 && y < 30 && inBounds) - { - if(x >= (bounds.width() - (3 * 29 + 24)) / 2 + 24 && x < (bounds.width() - (3 * 29 + 24)) / 2 + 24 + 3 * 29) - { - int relX = (x - ((bounds.width() - (3 * 29 + 24)) / 2 + 24)); - - if(relX % 29 != 28) - { - switch(relX / 29) - { - case 0: - toolTipText = "Show recipes of this type"; - break; - - case 1: - toolTipText = "Hide recipes of this type"; - break; - - case 2: - toolTipText = "Show only recipes of this type"; - } - } - } - } - } - - @Override - public void mouseMoved(int x, int y) - { - toolTipText = ""; - super.mouseMoved(x, y); - } - - @Override - protected int getMinCellHeight(int i) - { - return 32; - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/client/ui/CraftingDisplay.java b/src/api/java/uristqwerty/CraftGuide/client/ui/CraftingDisplay.java deleted file mode 100644 index e29eb2167..000000000 --- a/src/api/java/uristqwerty/CraftGuide/client/ui/CraftingDisplay.java +++ /dev/null @@ -1,187 +0,0 @@ -package uristqwerty.CraftGuide.client.ui; - -import java.util.List; - -import uristqwerty.CraftGuide.RecipeCache; -import uristqwerty.CraftGuide.api.CraftGuideRecipe; -import uristqwerty.CraftGuide.api.ItemFilter; -import uristqwerty.CraftGuide.api.Renderer; -import uristqwerty.CraftGuide.client.ui.Rendering.FloatingItemText; -import uristqwerty.CraftGuide.client.ui.Rendering.Overlay; -import uristqwerty.gui_craftguide.rendering.Renderable; - -public class CraftingDisplay extends GuiVariableRowHeightGrid implements IRecipeCacheListener -{ - int mouseX; - int mouseY; - int mouseRow, mouseRowX, mouseRowY; - private FloatingItemText itemName = new FloatingItemText("-No Item-"); - private Renderable itemNameOverlay = new Overlay(itemName); - private RecipeCache recipeCache; - private CraftGuideRecipe recipeUnderMouse; - - public CraftingDisplay(int x, int y, int width, int height, GuiScrollBar scrollBar, RecipeCache recipeCache) - { - super(x, y, width, height, scrollBar, 58, 79); - flexibleSize = true; - - this.recipeCache = recipeCache; - recipeCache.addListener(this); - updateScrollbarSize(); - updateGridSize(); - } - - @Override - public void draw() - { - super.draw(); - drawSelectionName(); - } - - @Override - public void mouseMoved(int x, int y) - { - recipeUnderMouse = null; - super.mouseMoved(x, y); - } - - @Override - public void renderGridCell(GuiRenderer renderer, int xOffset, int yOffset, int cell) - { - List recipes = recipeCache.getRecipes(); - - if(cell < recipes.size()) - { - renderRecipe(renderer, xOffset, yOffset, recipes.get(cell)); - } - } - - private void renderRecipe(Renderer renderer, int xOffset, int yOffset, CraftGuideRecipe recipe) - { - if(recipe == recipeUnderMouse) - { - recipe.draw(renderer, xOffset, yOffset, true, mouseX, mouseY); - } - else - { - recipe.draw(renderer, xOffset, yOffset, false, -1, -1); - } - } - - public void setFilter(ItemFilter filter) - { - recipeCache.filter(filter); - } - - @Override - public void onChange(RecipeCache cache) - { - updateScrollbarSize(); - updateGridSize(); - } - - private void updateGridSize() - { - List recipes = recipeCache.getRecipes(); - int maxWidth = 16; - - for(CraftGuideRecipe recipe: recipes) - { - maxWidth = Math.max(maxWidth, recipe.width()); - } - - setColumnWidth(maxWidth); - recalculateRowHeight(); - } - - private void updateScrollbarSize() - { - setCells(recipeCache.getRecipes().size()); - } - - @Override - public void mouseMovedCell(int cell, int x, int y, boolean inBounds) - { - List recipes = recipeCache.getRecipes(); - - if(inBounds && cell < recipes.size()) - { - CraftGuideRecipe recipe = recipes.get(cell); - - if(x < recipe.width() && y < recipe.height()) - { - mouseX = x; - mouseY = y; - recipeUnderMouse = recipe; - } - } - } - - private void drawSelectionName() - { - if(recipeUnderMouse != null) - { - List text = recipeUnderMouse.getItemText(mouseX, mouseY); - - if(text != null) - { - itemName.setText(text); - render(itemNameOverlay); - } - } - } - - @Override - public void cellClicked(int cell, int x, int y) - { - List recipes = recipeCache.getRecipes(); - - if(cell < recipes.size()) - { - recipeClicked(recipes.get(cell), x, y); - } - } - - private void recipeClicked(CraftGuideRecipe recipe, int x, int y) - { - ItemFilter stack = recipe.getRecipeClickedResult(x, y); - - if(stack != null) - { - setFilter(stack); - } - } - - @Override - public void onReset(RecipeCache cache) - { - } - - public ItemFilter getItemFilterForPoint(int x, int y) - { - int cell = cellAtCoords(x, y); - List recipes = recipeCache.getRecipes(); - - if(cell < recipes.size()) - { - return recipes.get(cell).getRecipeClickedResult(x - columnOffset(columnAtX(x)), ((int)scrollBar.getValue() + y) % rowHeight); - } - - return null; - } - - @Override - protected int getMinCellHeight(int cell) - { - List recipes = recipeCache.getRecipes(); - - if(cell < recipes.size()) - { - return recipes.get(cell).height(); - } - else - { - return 0; - } - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/client/ui/FilterSelectGrid.java b/src/api/java/uristqwerty/CraftGuide/client/ui/FilterSelectGrid.java deleted file mode 100644 index 11c1a3db3..000000000 --- a/src/api/java/uristqwerty/CraftGuide/client/ui/FilterSelectGrid.java +++ /dev/null @@ -1,244 +0,0 @@ -package uristqwerty.CraftGuide.client.ui; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.item.ItemStack; - -import org.lwjgl.input.Keyboard; - -import uristqwerty.CraftGuide.CommonUtilities; -import uristqwerty.CraftGuide.CraftGuide; -import uristqwerty.CraftGuide.CraftType; -import uristqwerty.CraftGuide.RecipeCache; -import uristqwerty.CraftGuide.api.NamedTexture; -import uristqwerty.CraftGuide.api.Util; -import uristqwerty.CraftGuide.client.ui.Rendering.FloatingItemText; -import uristqwerty.CraftGuide.client.ui.Rendering.Overlay; -import uristqwerty.gui_craftguide.rendering.Renderable; -import uristqwerty.gui_craftguide.rendering.TexturedRect; -import uristqwerty.gui_craftguide.texture.Texture; - -public class FilterSelectGrid extends GuiScrollableGrid implements IRecipeCacheListener, ITextInputListener -{ - private GuiButton backButton; - private GuiTabbedDisplay display; - private RecipeCache recipeCache; - private Renderable gridBackground; - private Object[] items; - private List itemResults = new ArrayList(); - private FloatingItemText itemName = new FloatingItemText("-No Item-"); - private Renderable itemNameOverlay = new Overlay(itemName); - private boolean overItem = false; - private String searchText = ""; - - private int lastMouseX, lastMouseY; - - private NamedTexture textImage = Util.instance.getTexture("TextFilter"); - private NamedTexture overlayAny = Util.instance.getTexture("ItemStack-Any"); - private NamedTexture overlayForge = Util.instance.getTexture("ItemStack-OreDict"); - - public FilterSelectGrid(int x, int y, int width, int height, GuiScrollBar scrollBar, Texture texture, - RecipeCache recipeCache, GuiButton backButton, GuiTabbedDisplay display) - { - super(x, y, width, height, scrollBar, 18, 18); - flexibleSize = true; - - this.backButton = backButton; - this.display = display; - this.recipeCache = recipeCache; - recipeCache.addListener(this); - setColumns(); - onReset(recipeCache); - - gridBackground = new TexturedRect(0, 0, 18, 18, texture, 238, 219); - } - - @Override - public void cellClicked(int cell, int x, int y) - { - if(cell < itemResults.size()) - { - recipeCache.filter(Util.instance.getCommonFilter(itemResults.get(cell))); - display.openTab(backButton); - } - else if(cell == itemResults.size() && searchText != null && !searchText.isEmpty()) - { - recipeCache.filter(Util.instance.getCommonFilter(searchText)); - display.openTab(backButton); - } - } - - @Override - public void mouseMoved(int x, int y) - { - overItem = false; - lastMouseX = x; - lastMouseY = y; - super.mouseMoved(x, y); - } - - @Override - public void mouseMovedCell(int cell, int x, int y, boolean inBounds) - { - if(inBounds) - { - if(cell < itemResults.size()) - { - overItem = true; - itemName.setText(CommonUtilities.getExtendedItemStackText(itemResults.get(cell))); - } - else if(cell == itemResults.size() && searchText != null && !searchText.isEmpty()) - { - overItem = true; - itemName.setText("\u00a77Text search: '" + searchText + "'"); - } - } - } - - @Override - public void renderGridCell(GuiRenderer renderer, int xOffset, int yOffset, int cell) - { - if(cell < itemResults.size()) - { - gridBackground.render(renderer, xOffset, yOffset); - ItemStack stack = displayItem(cell); - - renderer.drawItemStack(stack, xOffset + 1, yOffset + 1); - - if(CommonUtilities.getItemDamage(stack) == CraftGuide.DAMAGE_WILDCARD) - { - renderer.renderRect(xOffset, yOffset, 18, 18, overlayAny); - } - - if(itemResults.get(cell) instanceof ArrayList) - { - renderer.renderRect(xOffset, yOffset, 18, 18, overlayForge); - } - } - else if(cell == itemResults.size() && searchText != null && !searchText.isEmpty()) - { - gridBackground.render(renderer, xOffset, yOffset); - renderer.renderRect(xOffset + 1, yOffset + 1, 16, 16, textImage); - } - } - - private ItemStack displayItem(int cell) - { - Object item = itemResults.get(cell); - - if(item instanceof ItemStack) - { - return (ItemStack)item; - } - else if(item instanceof ArrayList && ((ArrayList)item).size() > 0) - { - return (ItemStack)((ArrayList)item).get(0); - } - else - { - return null; - } - } - - @Override - public void draw() - { - super.draw(); - - if(overItem) - { - render(itemNameOverlay); - } - } - - @Override - public void onReset(RecipeCache cache) - { - items = cache.getAllItems().toArray(); - search(searchText); - } - - public void search(String text) - { - searchText = text; - itemResults.clear(); - - if(text == null || text.isEmpty()) - { - for(Object item: items) - { - itemResults.add(((CraftType)item).getStack()); - } - - setCells(itemResults.size()); - } - else - { - String search = text.toLowerCase(); - - for(Object item: items) - { - Object stack = ((CraftType)item).getStack(); - - if(CommonUtilities.searchExtendedItemStackText(stack, search)) - { - itemResults.add(stack); - } - } - - setCells(itemResults.size() + 1); - } - - mouseMoved(lastMouseX, lastMouseY); - } - - - @Override - public void onChange(RecipeCache cache) - { - } - - @Override - public void onSubmit(GuiTextInput input) - { - if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT) || CraftGuide.textSearchRequiresShift == false) - { - recipeCache.filter(Util.instance.getCommonFilter(input.getText())); - display.openTab(backButton); - } - } - - @Override - public void onTextChanged(GuiTextInput input) - { - search(input.getText()); - } - - public ItemStack stackAtCoords(int x, int y) - { - int cell = cellAtCoords(x, y); - - if(cell < itemResults.size()) - { - Object content = itemResults.get(cell); - - if(content instanceof ItemStack) - { - return (ItemStack)content; - } - else if(content instanceof List && ((List)content).size() > 0 && ((List)content).get(0) instanceof ItemStack) - { - return (ItemStack)((List)content).get(0); - } - } - - return null; - } - - @Override - protected int getMinCellHeight(int i) - { - return 18; - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/client/ui/GuiButton.java b/src/api/java/uristqwerty/CraftGuide/client/ui/GuiButton.java deleted file mode 100644 index 7c5fd4db3..000000000 --- a/src/api/java/uristqwerty/CraftGuide/client/ui/GuiButton.java +++ /dev/null @@ -1,164 +0,0 @@ -package uristqwerty.CraftGuide.client.ui; - -import java.util.LinkedList; -import java.util.List; - -import uristqwerty.CraftGuide.client.ui.Rendering.FloatingItemText; -import uristqwerty.CraftGuide.client.ui.Rendering.Overlay; -import uristqwerty.gui_craftguide.components.GuiElement; -import uristqwerty.gui_craftguide.texture.Texture; -import uristqwerty.gui_craftguide.texture.TextureClip; - - -public class GuiButton extends GuiElement -{ - public enum ButtonState - { - UP, - UP_OVER, - DOWN, - DOWN_OVER, - } - - private List buttonListeners = new LinkedList(); - private ButtonTemplate template; - - protected ButtonState currentState = ButtonState.UP; - - private static FloatingItemText toolTip = new FloatingItemText(""); - private static Overlay toolTipRender = new Overlay(toolTip); - private String toolTipText = ""; - - public GuiButton(int x, int y, int width, int height, Texture texture, int u, int v) - { - this(x, y, width, height, texture, u, v, width, 0); - } - - public GuiButton(int x, int y, int width, int height, Texture texture, int u, int v, int dx, int dy) - { - super(x, y, width, height); - - template = new ButtonTemplate(); - - int yOffset = 0; - int xOffset = 0; - for(ButtonState state: ButtonState.values()) - { - template.setStateImage(state, new TextureClip(texture, u + xOffset, v + yOffset, width, height)); - xOffset += dx; - yOffset += dy; - } - } - - protected GuiButton(int x, int y, int width, int height) - { - super(x, y, width, height); - } - - public GuiButton(int x, int y, int width, int height, ButtonTemplate template) - { - super(x, y, width, height); - - this.template = template; - } - - public GuiButton(int x, int y, int width, int height, ButtonTemplate template, String text) - { - this(x, y, width, height, template); - - addElement( - new GuiCentredText(0, 0, width, height, text) - .anchor(AnchorPoint.TOP_LEFT, AnchorPoint.BOTTOM_RIGHT)); - } - - @Override - public void draw() - { - if(isOver() && !toolTipText.isEmpty()) - { - toolTip.setText(toolTipText); - render(toolTipRender); - } - - setBackground(template.getStateImage(currentState)); - super.draw(); - } - - @Override - public void mouseMoved(int x, int y) - { - updateState(containsPoint(x, y), isHeld()); - } - - @Override - public void mousePressed(int x, int y) - { - if(containsPoint(x, y)) - { - if(!isHeld()) - { - sendButtonEvent(IButtonListener.Event.PRESS); - } - - updateState(true, true); - } - } - - @Override - public void mouseReleased(int x, int y) - { - if(isHeld()) - { - sendButtonEvent(IButtonListener.Event.RELEASE); - } - - updateState(containsPoint(x, y), false); - } - - protected void updateState(boolean over, boolean held) - { - currentState = - held? - over? - ButtonState.DOWN_OVER - : - ButtonState.DOWN - : - over? - ButtonState.UP_OVER - : - ButtonState.UP; - } - - protected boolean isHeld() - { - return currentState == ButtonState.DOWN || currentState == ButtonState.DOWN_OVER; - } - - protected boolean isOver() - { - return currentState == ButtonState.UP_OVER || currentState == ButtonState.DOWN_OVER; - } - - public GuiButton addButtonListener(IButtonListener listener) - { - buttonListeners.add(listener); - - return this; - } - - protected void sendButtonEvent(IButtonListener.Event eventType) - { - for(IButtonListener listener: buttonListeners) - { - listener.onButtonEvent(this, eventType); - } - } - - public GuiButton setToolTip(String text) - { - toolTipText = text; - - return this; - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/client/ui/GuiCentredText.java b/src/api/java/uristqwerty/CraftGuide/client/ui/GuiCentredText.java deleted file mode 100644 index 54d986fdb..000000000 --- a/src/api/java/uristqwerty/CraftGuide/client/ui/GuiCentredText.java +++ /dev/null @@ -1,32 +0,0 @@ -package uristqwerty.CraftGuide.client.ui; - -import uristqwerty.CraftGuide.client.ui.Rendering.CentredText; -import uristqwerty.gui_craftguide.components.GuiElement; - -public class GuiCentredText extends GuiElement -{ - private CentredText text; - - public GuiCentredText(int x, int y, int width, int height, String text) - { - super(x, y, width, height); - - this.text = new CentredText(0, 0, width, height, text); - } - - @Override - public void onResize(int oldWidth, int oldHeight) - { - text.setSize(bounds.width(), bounds.height()); - - super.onResize(oldWidth, oldHeight); - } - - @Override - public void draw() - { - render(text); - - super.draw(); - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/client/ui/GuiRenderer.java b/src/api/java/uristqwerty/CraftGuide/client/ui/GuiRenderer.java deleted file mode 100644 index de952e8cb..000000000 --- a/src/api/java/uristqwerty/CraftGuide/client/ui/GuiRenderer.java +++ /dev/null @@ -1,455 +0,0 @@ -package uristqwerty.CraftGuide.client.ui; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.client.renderer.entity.RenderItem; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; - -import org.lwjgl.opengl.GL11; - -import uristqwerty.CraftGuide.CommonUtilities; -import uristqwerty.CraftGuide.CraftGuide; -import uristqwerty.CraftGuide.CraftGuideLog; -import uristqwerty.CraftGuide.api.NamedTexture; -import uristqwerty.CraftGuide.client.ui.Rendering.Overlay; -import uristqwerty.gui_craftguide.minecraft.Gui; -import uristqwerty.gui_craftguide.rendering.Renderable; -import uristqwerty.gui_craftguide.rendering.RendererBase; -import uristqwerty.gui_craftguide.rendering.TexturedRect; -import uristqwerty.gui_craftguide.texture.DynamicTexture; -import uristqwerty.gui_craftguide.texture.Texture; - -public class GuiRenderer extends RendererBase implements uristqwerty.CraftGuide.api.Renderer -{ - private RenderItem itemRenderer = new RenderItem(); - private List overlays = new LinkedList(); - private Gui gui; - - private static Map itemStackFixes = new HashMap(); - - private Renderable itemError = new TexturedRect(-1, -1, 18, 18, DynamicTexture.instance("item_error"), 238, 200); - - public void startFrame(Gui gui) - { - this.gui = gui; - resetValues(); - } - - public void endFrame() - { - for(Overlay overlay: overlays) - { - overlay.renderOverlay(this); - } - - overlays.clear(); - - GL11.glColor4d(1.0, 1.0, 1.0, 1.0); - } - - public void setColor(int colour, int alpha) - { - setColorRgb(colour); - setAlpha(alpha); - } - - @Override - public void setTextureID(int textureID) - { - if(textureID != -1) - { - GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID); - } - } - - public void drawGradient(int x, int y, int width, int height, int topColor, int bottomColor) - { - renderVerticalGradient(x, y, width, height, topColor, bottomColor); - } - - public void render(Renderable renderable, int xOffset, int yOffset) - { - renderable.render(this, xOffset, yOffset); - } - - public void overlay(Overlay overlay) - { - overlays.add(overlay); - } - - @Override - public void drawText(String text, int x, int y) - { - Minecraft.getMinecraft().fontRenderer.drawString(text, x, y, currentColor()); - } - - @Override - public void drawTextWithShadow(String text, int x, int y) - { - Minecraft.getMinecraft().fontRenderer.drawStringWithShadow(text, x, y, currentColor()); - } - - private int currentColor() - { - return ((((int)(alpha * 255)) & 0xff) << 24) | ((((int)(red * 255)) & 0xff) << 16) | ((((int)(green * 255)) & 0xff) << 8) | (((int)(blue * 255)) & 0xff); - } - - public void drawFloatingText(int x, int y, String text) - { - List list = new ArrayList(1); - list.add(text); - drawFloatingText(x, y, list); - } - - public void drawFloatingText(int x, int y, List text) - { - int textWidth = 0; - int textHeight = (text.size() > 1)? text.size() * 10: 8; - - for(String s: text) - { - int w; - - if(s.charAt(0) == '\u00a7') - { - w = Minecraft.getMinecraft().fontRenderer.getStringWidth(s.substring(2)); - } - else - { - w = Minecraft.getMinecraft().fontRenderer.getStringWidth(s); - } - - if(w > textWidth) - { - textWidth = w; - } - } - - int xMax = gui.width - textWidth - 4; - int yMax = gui.height - textHeight - 4; - - if(x > xMax) - { - x = xMax; - } - - if(x < 3) - { - x = 3; - } - - if(y > yMax) - { - y = yMax; - } - - if(y < 4) - { - y = 4; - } - - setColor(0xf0100010); - drawRect(x - 3, y - 4, textWidth + 6, 1); - drawRect(x - 3, y + textHeight + 3, textWidth + 6, 1); - drawRect(x - 3, y - 3, textWidth + 6, textHeight + 6); - drawRect(x - 4, y - 3, 1, textHeight + 6); - drawRect(x + textWidth + 3, y - 3, 1, textHeight + 6); - - setColor(0x505000ff); - drawRect(x - 3, y - 3, textWidth + 6, 1); - - setColor(0x5028007f); - drawRect(x - 3, y + textHeight + 2, textWidth + 6, 1); - - drawGradient(x - 3, y - 2, 1, textHeight + 4, 0x505000ff, 0x5028007f); - drawGradient(x + textWidth + 2, y - 2, 1, textHeight + 4, 0x505000ff, 0x5028007f); - - setColor(0xffffffff); - - int textY = y; - boolean first = true; - for(String s: text) - { - drawTextWithShadow(s, x, textY); - - if(first) - { - textY += 2; - first = false; - } - - textY += 10; - } - } - - public void drawItemStack(ItemStack itemStack, int x, int y) - { - drawItemStack(itemStack, x, y, true); - } - - public void drawItemStack(ItemStack itemStack, int x, int y, boolean renderOverlay) - { - if(itemStack == null) - { - return; - } - - boolean error = true; - - GL11.glEnable(GL11.GL_DEPTH_TEST); - GL11.glPushMatrix(); - GL11.glRotatef(120F, 1.0F, 0.0F, 0.0F); - RenderHelper.enableStandardItemLighting(); - GL11.glPopMatrix(); - GL11.glPushMatrix(); - GL11.glTranslatef(x, y, 0.0F); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glEnable(32826 /*GL_RESCALE_NORMAL_EXT*/); - itemRenderer.zLevel = 100.0F; - - int initialMatrixStackDepth = GL11.glGetInteger(GL11.GL_MODELVIEW_STACK_DEPTH); - - try - { - if(CommonUtilities.getItemDamage(itemStack) == CraftGuide.DAMAGE_WILDCARD) - { - itemStack = fixedItemStack(itemStack); - } - - itemRenderer.renderItemAndEffectIntoGUI(Minecraft.getMinecraft().fontRenderer, Minecraft.getMinecraft().getTextureManager(), itemStack, 0, 0); - - if(renderOverlay) - { - itemRenderer.renderItemOverlayIntoGUI(Minecraft.getMinecraft().fontRenderer, Minecraft.getMinecraft().getTextureManager(), itemStack, 0, 0); - } - - error = false; - } - catch(Exception e) - { - if(!hasLogged(itemStack)) - { - CraftGuideLog.log("Failed to render ItemStack {" + ( - itemStack == null? "null" : ( - "itemID = " + Item.itemRegistry.getNameForObject(itemStack.getItem()) + - ", itemDamage = " + CommonUtilities.getItemDamage(itemStack) + - ", stackSize = " + itemStack.stackSize)) + - "} (Further stack traces from this particular ItemStack instance will not be logged)"); - CraftGuideLog.log(e); - } - } - catch(Error e) - { - CraftGuideLog.log(e); - throw e; - } - finally - { - int finalMatrixStackDepth = GL11.glGetInteger(GL11.GL_MODELVIEW_STACK_DEPTH); - - // If something went wrong, and an exception was thrown after at least one matrix push, - // fix it here, so that rendering errors do not affect later parts of the UI. - while(finalMatrixStackDepth > initialMatrixStackDepth) - { - GL11.glPopMatrix(); - finalMatrixStackDepth--; - } - - CraftGuide.side.stopTessellating(); - - itemRenderer.zLevel = 0.0F; - GL11.glDisable(32826 /*GL_RESCALE_NORMAL_EXT*/); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - RenderHelper.disableStandardItemLighting(); - GL11.glDisable(GL11.GL_DEPTH_TEST); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } - - if(error) - { - drawItemStackError(x, y); - } - } - - private HashSet loggedStacks = new HashSet(); - - private boolean hasLogged(ItemStack stack) - { - return !loggedStacks.add(stack); - } - - public static ItemStack fixedItemStack(ItemStack itemStack) - { - ItemStack stack = itemStackFixes.get(itemStack); - - if(stack == null) - { - stack = itemStack.copy(); - stack.setItemDamage(0); - itemStackFixes.put(itemStack, stack); - } - - return stack; - } - - private void drawItemStackError(int x, int y) - { - itemError.render(this, x, y); - } - - public void setClippingRegion(int x, int y, int width, int height) - { - GL11.glEnable(GL11.GL_SCISSOR_TEST); - - x *= Minecraft.getMinecraft().displayHeight / (float)gui.height; - y *= Minecraft.getMinecraft().displayWidth / (float)gui.width; - height *= Minecraft.getMinecraft().displayHeight / (float)gui.height; - width *= Minecraft.getMinecraft().displayWidth / (float)gui.width; - - GL11.glScissor(x, Minecraft.getMinecraft().displayHeight - y - height, width, height); - } - - public void clearClippingRegion() - { - GL11.glDisable(GL11.GL_SCISSOR_TEST); - } - - public int guiXFromMouseX(int x) - { - return (x * gui.width) / Minecraft.getMinecraft().displayWidth; - } - - public int guiYFromMouseY(int y) - { - return gui.height - (y * gui.height) / Minecraft.getMinecraft().displayHeight - 1; - } - - @Override - public void renderItemStack(int x, int y, ItemStack stack) - { - drawItemStack(stack, x, y); - } - - @Override - public void renderRect(int x, int y, int width, int height, NamedTexture texture) - { - if(texture != null) - { - setColor(255, 255, 255, 255); - drawTexturedRect((Texture)texture, x, y, width, height, 0, 0); - } - } - - @Override - public void renderRect(int x, int y, int width, int height, int red, int green, int blue, int alpha) - { - setColor(red, green, blue, alpha); - drawRect(x, y, width, height); - setColor(0xff, 0xff, 0xff, 0xff); - } - - @Override - public void renderRect(int x, int y, int width, int height, int color_rgb, int alpha) - { - renderRect(x, y, width, height, - (color_rgb >> 16) & 0xff, - (color_rgb >> 8) & 0xff, - (color_rgb >> 0) & 0xff, - alpha); - } - - @Override - public void renderRect(int x, int y, int width, int height, int color_argb) - { - renderRect(x, y, width, height, color_argb & 0x00ffffff, (color_argb >> 24) & 0xff); - } - - @Override - public void renderVerticalGradient(int x, int y, int width, int height, int topColor_argb, int bottomColor_argb) - { - renderGradient(x, y, width, height, topColor_argb, topColor_argb, bottomColor_argb, bottomColor_argb); - } - - @Override - public void renderHorizontalGradient(int x, int y, int width, int height, int leftColor_argb, int rightColor_argb) - { - renderGradient(x, y, width, height, leftColor_argb, rightColor_argb, leftColor_argb, rightColor_argb); - } - - @Override - public void renderGradient(int x, int y, int width, int height, int topLeftColor_argb, int topRightColor_argb, - int bottomLeftColor_argb, int bottomRightColor_argb) - { - GL11.glEnable(GL11.GL_BLEND); - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glDisable(GL11.GL_DEPTH_TEST); - GL11.glBlendFunc(770, 771); - - GL11.glBegin(GL11.GL_QUADS); - glColor1i(topLeftColor_argb); - GL11.glVertex2i(x, y); - - glColor1i(bottomLeftColor_argb); - GL11.glVertex2i(x, y + height); - - glColor1i(bottomRightColor_argb); - GL11.glVertex2i(x + width, y + height); - - glColor1i(topRightColor_argb); - GL11.glVertex2i(x + width, y); - GL11.glEnd(); - - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glDisable(GL11.GL_BLEND); - } - - private void glColor1i(int color) - { - setGlColor( - ((color >> 16) & 0xff) / 255.0, - ((color >> 8) & 0xff) / 255.0, - ((color >> 0) & 0xff) / 255.0, - ((color >> 24) & 0xff) / 255.0); - } - - public List getItemNameandInformation(ItemStack stack) - { - if(stack.getItem() != null) - { - try - { - return getTooltip(stack); - } - catch(Exception e) - { - try - { - stack = fixedItemStack(stack); - return getTooltip(stack); - } - catch(Exception e2) - { - CraftGuideLog.log(e2); - } - } - } - - List list = new ArrayList(); - list.add("Err: Item " + Item.itemRegistry.getNameForObject(stack.getItem()) + ", damage " + CommonUtilities.getItemDamage(stack)); - return list; - } - - private List getTooltip(ItemStack stack) - { - return stack.getTooltip(Minecraft.getMinecraft().thePlayer, Minecraft.getMinecraft().gameSettings.advancedItemTooltips); - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/client/ui/GuiResizeHandle.java b/src/api/java/uristqwerty/CraftGuide/client/ui/GuiResizeHandle.java deleted file mode 100644 index aaf4d49eb..000000000 --- a/src/api/java/uristqwerty/CraftGuide/client/ui/GuiResizeHandle.java +++ /dev/null @@ -1,130 +0,0 @@ -package uristqwerty.CraftGuide.client.ui; - -import uristqwerty.CraftGuide.CraftGuide; -import uristqwerty.gui_craftguide.components.GuiElement; -import uristqwerty.gui_craftguide.components.Window; - - -public class GuiResizeHandle extends GuiElement -{ - private AnchorPoint corner; - private boolean dragging = false; - private int targetX, targetY, targetOffsetX, targetOffsetY; - - private int minWidth, minHeight; - private GuiElement target; - - public GuiResizeHandle(int x, int y, int width, int height, GuiElement element) - { - this(x, y, width, height, element, AnchorPoint.BOTTOM_RIGHT); - } - - public GuiResizeHandle(int x, int y, int width, int height, GuiElement element, AnchorPoint corner) - { - this(x, y, width, height, element, corner, element.width(), element.height()); - } - - public GuiResizeHandle(int x, int y, int width, int height, - GuiElement element, int minimumWidth, int minimumHeight) - { - this(x, y, width, height, element, AnchorPoint.BOTTOM_RIGHT, minimumWidth, minimumHeight); - } - - public GuiResizeHandle(int x, int y, int width, int height, - GuiElement element, AnchorPoint corner, int minimumWidth, int minimumHeight) - { - super(x, y, width, height); - - this.corner = corner; - target = element; - minWidth = minimumWidth; - minHeight = minimumHeight; - - anchor(corner, corner); - } - - @Override - public void mouseMoved(int x, int y) - { - super.mouseMoved(x, y); - - if(dragging) - { - targetX = absoluteX() + x - bounds.x() - targetOffsetX; - targetY = absoluteY() + y - bounds.y() - targetOffsetY; - } - } - - @Override - public void mousePressed(int x, int y) - { - if(containsPoint(x, y)) - { - dragging = true; - targetX = absoluteX(); - targetY = absoluteY(); - targetOffsetX = x - bounds.x(); - targetOffsetY = y - bounds.y(); - } - - super.mousePressed(x, y); - } - - @Override - public void elementClicked(int x, int y) - { - super.elementClicked(x, y); - } - - @Override - public void mouseReleased(int x, int y) - { - super.mouseReleased(x, y); - - dragging = false; - } - - @Override - public void update() - { - if(dragging) - { - int xDif = targetX - absoluteX(); - int yDif = targetY - absoluteY(); - - if(CraftGuide.resizeRate > 0) - { - int xDir = (int)Math.signum(xDif); - int yDir = (int)Math.signum(yDif); - - xDif = Math.min(Math.abs(xDif), CraftGuide.resizeRate) * xDir; - yDif = Math.min(Math.abs(yDif), CraftGuide.resizeRate) * yDir; - } - - if(xDif != 0 || yDif != 0) - { - if(corner == AnchorPoint.TOP_LEFT || corner == AnchorPoint.TOP_RIGHT) - { - yDif = -yDif; - } - - if(corner == AnchorPoint.TOP_LEFT || corner == AnchorPoint.BOTTOM_LEFT) - { - xDif = -xDif; - } - - if(target instanceof Window && ((Window)target).isCentred()) - { - xDif *= 2; - yDif *= 2; - } - - target.setSize( - Math.max(target.width() + xDif, minWidth), - Math.max(target.height() + yDif, minHeight)); - } - } - - super.update(); - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/client/ui/GuiRightAlignedText.java b/src/api/java/uristqwerty/CraftGuide/client/ui/GuiRightAlignedText.java deleted file mode 100644 index c112342f1..000000000 --- a/src/api/java/uristqwerty/CraftGuide/client/ui/GuiRightAlignedText.java +++ /dev/null @@ -1,35 +0,0 @@ -package uristqwerty.CraftGuide.client.ui; - -import uristqwerty.CraftGuide.client.ui.Rendering.RightAlignedText; -import uristqwerty.gui_craftguide.components.GuiElement; -import uristqwerty.gui_craftguide.minecraft.Text; - -public class GuiRightAlignedText extends GuiElement -{ - private Text text; - - public GuiRightAlignedText(int x, int y, String text, int color) - { - super(x, y, 0, 0); - - this.text = new RightAlignedText(0, 0, text, color); - } - - public GuiRightAlignedText(int x, int y, String text) - { - this(x, y, text, 0xffffffff); - } - - public void setText(String text) - { - this.text.setText(text); - } - - @Override - public void draw() - { - render(text); - - super.draw(); - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/client/ui/GuiScrollBar.java b/src/api/java/uristqwerty/CraftGuide/client/ui/GuiScrollBar.java deleted file mode 100644 index b905f9807..000000000 --- a/src/api/java/uristqwerty/CraftGuide/client/ui/GuiScrollBar.java +++ /dev/null @@ -1,217 +0,0 @@ -package uristqwerty.CraftGuide.client.ui; - -import java.util.HashMap; -import java.util.Map; - -import org.lwjgl.input.Keyboard; - -import uristqwerty.gui_craftguide.components.GuiElement; - - -public class GuiScrollBar extends GuiElement implements IButtonListener, ISliderListener -{ - private GuiSlider handle; - private float min = 0, max = 1, value = 0; - private static float scrollMultiplier = 1; - private int pageSize; - private Map buttons = new HashMap(); - private int rowSize; - - public static interface ScrollBarAlignmentCallback - { - float alignScrollBar(GuiScrollBar guiScrollBar, float oldValue, float newValue); - } - - private ScrollBarAlignmentCallback alignmentCallback; - - public GuiScrollBar(int x, int y, int width, int height, GuiSlider handle) - { - super(x, y, width, height); - - this.handle = handle; - addElement(handle); - handle.addSliderListener(this); - } - - public GuiScrollBar addButton(GuiButton button, int scrollValue, boolean scrollPages) - { - addElement(button); - button.addButtonListener(this); - buttons.put(button, new Object[]{scrollValue, scrollPages}); - - return this; - } - - public GuiElement setPageSize(int pageSize) - { - this.pageSize = pageSize; - - return this; - } - - public GuiElement setRowSize(int rowSize) - { - this.rowSize = rowSize; - - return this; - } - - public GuiScrollBar setScale(float min, float max) - { - float value = this.max > 0? (this.value - this.min) / (this.max - this.min) : 0; - handle.setValue(0, value); - - this.min = min; - this.max = max; - this.value = (value * (max - min)) + min; - - return this; - } - - public float getValue() - { - return value; - } - - @Override - public void onButtonEvent(GuiButton button, Event eventType) - { - if(eventType == Event.PRESS) - { - if(buttons.containsKey(button)) - { - Object[] data = buttons.get(button); - - if((Boolean)data[1]) - { - scrollPages((Integer)data[0]); - } - else - { - scrollLines((Integer)data[0]); - } - } - } - } - - @Override - public void onKeyTyped(char eventChar, int eventKey) - { - super.onKeyTyped(eventChar, eventKey); - - switch(eventKey) - { - case Keyboard.KEY_UP: - scrollLines(-1, true); - break; - - case Keyboard.KEY_DOWN: - scrollLines(1, true); - break; - - case Keyboard.KEY_LEFT: - case Keyboard.KEY_PRIOR: - scrollPages(-1); - break; - - case Keyboard.KEY_RIGHT: - case Keyboard.KEY_NEXT: - scrollPages(1); - break; - - case Keyboard.KEY_HOME: - scrollToStart(); - break; - - case Keyboard.KEY_END: - scrollToEnd(); - break; - } - } - - @Override - public void scrollWheelTurned(int change) - { - scrollLines(change, true); - - super.scrollWheelTurned(change); - } - - public void scrollPages(int pages) - { - scrollPixels(pages * pageSize); - } - - public void scrollLines(int lines) - { - scrollLines(lines, false); - } - - public void scrollLines(int lines, boolean align) - { - if(align && alignmentCallback != null) - { - float newValue = value + lines * rowSize * scrollMultiplier; - - newValue = alignmentCallback.alignScrollBar(this, value, newValue); - - setValue(newValue); - } - else - { - scrollPixels(lines * rowSize); - } - } - - public void scrollPixels(int pixels) - { - setValue(value + pixels * scrollMultiplier); - } - - public void scrollToStart() - { - setValue(min); - } - - public void scrollToEnd() - { - setValue(max); - } - - @Override - public void onSliderMoved(GuiSlider slider) - { - setValue(slider.getPosY() * max + min); - } - - private void setValue(float value) - { - if(value < min) - { - value = min; - } - - if(value > max) - { - value = max; - } - - this.value = value; - handle.setValue(0, (value - min) / (max - min)); - } - - public float getMax() - { - return max; - } - - public static void setScrollMultiplier(int i) - { - scrollMultiplier = i; - } - - public void setAlignmentCallback(ScrollBarAlignmentCallback alignmentCallback) - { - this.alignmentCallback = alignmentCallback; - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/client/ui/GuiScrollableGrid.java b/src/api/java/uristqwerty/CraftGuide/client/ui/GuiScrollableGrid.java deleted file mode 100644 index c6d2f43da..000000000 --- a/src/api/java/uristqwerty/CraftGuide/client/ui/GuiScrollableGrid.java +++ /dev/null @@ -1,391 +0,0 @@ -package uristqwerty.CraftGuide.client.ui; - -import uristqwerty.CraftGuide.CraftGuide; -import uristqwerty.CraftGuide.client.ui.GuiScrollBar.ScrollBarAlignmentCallback; -import uristqwerty.CraftGuide.client.ui.Rendering.GridRect; -import uristqwerty.gui_craftguide.components.GuiElement; - -public abstract class GuiScrollableGrid extends GuiElement implements ScrollBarAlignmentCallback -{ - protected GuiScrollBar scrollBar; - protected int rowHeight; - - private GridRect display; - private int rows = 0, columns = 1, cells = 0; - private int columnWidth = 1; - private int reducedWidth = 0; - - public int borderSize = 1; - public boolean flexibleSize = false; - - private int lastMouseX, lastMouseY; - private float lastScroll; - - public GuiScrollableGrid(int x, int y, int width, int height, GuiScrollBar scrollBar, int rowHeight, int columnWidth) - { - super(x, y, width, height); - this.display = new GridRect(0, 0, width, height, this); - this.rowHeight = rowHeight; - this.scrollBar = scrollBar; - this.columnWidth = columnWidth; - - scrollBar.setAlignmentCallback(this); - scrollBar.setPageSize((height / rowHeight) * rowHeight); - - recalculateColumns(); - } - - @Override - public void draw() - { - if(lastScroll != scrollBar.getValue()) - { - lastScroll = scrollBar.getValue(); - mouseMoved(lastMouseX, lastMouseY); - } - - if(flexibleSize) - { - int width = columnWidth * ((bounds.width() + reducedWidth) / columnWidth); - - if(width != bounds.width()) - { - int xOff = (reducedWidth / 2) &~1; - reducedWidth = bounds.width() + reducedWidth - width; - - setPosition(bounds.x() - xOff + ((reducedWidth / 2) &~1), bounds.y()); - setSize(width, bounds.height()); - } - } - - drawBackground(); - render(display); - drawChildren(); - } - - @Override - public void drawBackground() - { - if(background != null) - { - render(background, -borderSize, -borderSize, bounds.width() + borderSize * 2, bounds.height() + borderSize * 2); - } - } - - @Override - public void mouseMoved(int x, int y) - { - int gridY = y - bounds.y(); - int scrollY = pixelsScrolledForY(gridY); - int row = rowAtY(gridY); - - lastMouseX = x; - lastMouseY = y; - lastScroll = scrollBar.getValue(); - - mouseMovedRow(row, x - bounds.x(), scrollY - rowStartPixels(row), containsPoint(x, y)); - - super.mouseMoved(x, y); - } - - @Override - public void mousePressed(int x, int y) - { - int gridY = y - bounds.y(); - int row = rowAtY(gridY); - int rowPos = pixelsScrolledForY(gridY) - rowStartPixels(row); - - rowClicked(row, x - bounds.x(), rowPos, containsPoint(x, y)); - super.mousePressed(x, y); - } - - /** - * @return Number of UI pixels between the top of the first - * row, and the start of the requested row. - */ - protected int rowStartPixels(int row) - { - return row * rowHeight; - } - - /** - * @return Number of UI pixels between the top of the first - * row, and . - */ - protected int pixelsScrolledForScreenY(int y) - { - return ((int)scrollBar.getValue()) + y - absoluteY(); - } - - protected int pixelsScrolledForY(int y) - { - return ((int)scrollBar.getValue()) + y; - } - - protected int rowAtScreenY(int y) - { - return pixelsScrolledForScreenY(y) / rowHeight; - } - - protected int rowAtGridY(int y) - { - return y / rowHeight; - } - - protected int rowAtY(int y) - { - return pixelsScrolledForY(y) / rowHeight; - } - - protected int getHeightForRow(int row) - { - return rowHeight; - } - - @Override - public void onResize(int oldWidth, int oldHeight) - { - scrollBar.setPageSize((bounds.height() / rowHeight) * rowHeight); - display.setSize(bounds.width(), bounds.height()); - - - if(flexibleSize) - { - int width = columnWidth * ((bounds.width() + reducedWidth) / columnWidth); - - if(width != bounds.width()) - { - int xOff = reducedWidth / 2; - reducedWidth = bounds.width() + reducedWidth - width; - - setPosition(bounds.x() - xOff + reducedWidth / 2, bounds.y()); - setSize(width, bounds.height()); - } - } - - recalculateColumns(); - scrollBar.setPageSize(bounds.height()); - } - - public void recalculateColumns() - { - setColumns(Math.max(bounds.width() / columnWidth, 1)); - } - - public void setRows(int rowCount) - { - rows = rowCount; - - recalculateRowHeight(); - updateScrollbarScale(); - } - - public void updateScrollbarScale() - { - float end = rowStartPixels(rows - 1) + getHeightForRow(rows - 1) - bounds.height(); - - if(end < 0) - { - end = 0; - } - - scrollBar.setRowSize(rowHeight); - scrollBar.setScale(0, end); - } - - protected void recalculateRowHeight() - { - int maxHeight = 1; - for(int i = 0; i < getCells(); i++) - { - maxHeight = Math.max(maxHeight, getMinCellHeight(i)); - } - - setRowHeight(maxHeight); - } - - public void setColumns() - { - setColumns(bounds.width() / columnWidth); - } - - public void setColumnWidth(int newWidth) - { - columnWidth = newWidth; - recalculateColumns(); - } - - public void setRowHeight(int newHeight) - { - rowHeight = newHeight; - updateScrollbarScale(); - } - - public void setColumns(int columns) - { - this.columns = columns; - setRows((getCells() + columns - 1) / columns); - } - - protected int getColumns() - { - return columns; - } - - public void setCells(int cells) - { - this.cells = cells; - setRows((cells + getColumns() - 1) / getColumns()); - } - - protected int getCells() - { - return cells; - } - - public void renderGridRows(GuiRenderer renderer, int xOffset, int yOffset) - { - int yMin = pixelsScrolledForScreenY(yOffset); - int row = rowAtScreenY(yOffset + 1); - - while(row < rowCount()) - { - int y = rowStartPixels(row) - yMin; - - if(y >= bounds.height()) - { - break; - } - - renderGridRow(renderer, xOffset, y + yOffset, row); - row++; - } - } - - public void renderGridRow(GuiRenderer renderer, int xOffset, int yOffset, int row) - { - for(int i = 0; i < getColumns(); i++) - { - int columnX = columnOffset(i); - - renderGridCell(renderer, xOffset + columnX, yOffset, row * getColumns() + i); - } - } - - public int columnOffset(int column) - { - if(CraftGuide.gridPacking) - { - return column * columnWidth; - } - else - { - return getColumns() < 2? 0 : (int)((bounds.width() - columnWidth) * column / (float)(getColumns() - 1)); - } - } - - protected int columnAtX(int x) - { - if(CraftGuide.gridPacking) - { - return Math.min(x / columnWidth, getColumns() - 1); - } - else - { - return (x * getColumns()) / bounds.width(); - } - } - - public void rowClicked(int row, int x, int y, boolean inBounds) - { - int column = columnAtX(x); - int columnX = columnOffset(column); - - if(inBounds && x - columnX < columnWidth && row * getColumns() + column < getCells()) - { - cellClicked(row * getColumns() + column, x - columnX, y); - } - } - - public void mouseMovedRow(int row, int x, int y, boolean inBounds) - { - int column = columnAtX(x); - - if(column >= 0 && row * getColumns() + column < getCells()) - { - int columnX = columnOffset(column); - - if(x >= columnX && x - columnX < columnWidth) - { - mouseMovedCell(row * getColumns() + column, x - columnX, y, inBounds); - } - } - } - - public int cellAtCoords(int x, int y) - { - int row = rowAtY(y); - return columnAtX(x) + row * getColumns(); - } - - public int rowCount() - { - return rows; - } - - public int firstVisibleRow() - { - return rowAtScreenY(absoluteY()); - } - - public int lastVisibleRow() - { - return rowAtScreenY(absoluteY() + bounds.height()); - } - - @Override - public float alignScrollBar(GuiScrollBar guiScrollBar, float oldValue, float newValue) - { - float alignedNewValue = rowStartPixels(rowAtGridY((int)newValue)); - - if(newValue > oldValue && alignedNewValue <= oldValue) - { - alignedNewValue = rowStartPixels(rowAtGridY((int)newValue) + 1); - } - else if(newValue < oldValue && alignedNewValue >= oldValue) - { - alignedNewValue = rowStartPixels(rowAtGridY((int)newValue) - 1); - } - - return alignedNewValue; - } - - public void mouseMovedCell(int cell, int x, int y, boolean inBounds) - { - /** Default implementation: Do nothing */ - } - - public void cellClicked(int cell, int x, int y) - { - /** Default implementation: Do nothing */ - } - - /** - * Called by the default implementation of {@link renderGridRow} one - * time for each column in the row. Override this in order to render - * each cell individually. - *

    - * (x, y) is the absolute screen position of this cell's top left corner. - * @param renderer - * @param x - * @param y - * @param cell [previous cells in this row] + ([number of previous rows] - * * [cells per row]) - */ - public void renderGridCell(GuiRenderer renderer, int x, int y, int cell) - { - /** Default implementation: Do nothing */ - } - - abstract protected int getMinCellHeight(int i); -} diff --git a/src/api/java/uristqwerty/CraftGuide/client/ui/GuiSlider.java b/src/api/java/uristqwerty/CraftGuide/client/ui/GuiSlider.java deleted file mode 100644 index a929068e0..000000000 --- a/src/api/java/uristqwerty/CraftGuide/client/ui/GuiSlider.java +++ /dev/null @@ -1,111 +0,0 @@ -package uristqwerty.CraftGuide.client.ui; - -import java.util.LinkedList; -import java.util.List; - -import uristqwerty.gui_craftguide.components.GuiElement; -import uristqwerty.gui_craftguide.texture.Texture; - - -public class GuiSlider extends GuiButton -{ - private int minX, minY, maxX, maxY; - private int dx, dy; - - private List sliderListeners = new LinkedList(); - - @Override - public void mousePressed(int x, int y) - { - super.mousePressed(x, y); - dx = x - bounds.x(); - dy = y - bounds.y(); - } - - @Override - public void mouseMoved(int x, int y) - { - super.mouseMoved(x, y); - - if(isHeld()) - { - updatePosition(x - dx, y - dy); - sendSliderEvent(); - } - } - - @Override - public GuiElement setSize(int width, int height) - { - float x = getPosX(); - float y = getPosY(); - - maxX += width - bounds.width(); - maxY += height - bounds.height(); - - setValue(x, y); - - return super.setSize(bounds.width(), bounds.height()); - } - - private void sendSliderEvent() - { - for(ISliderListener listener: sliderListeners) - { - listener.onSliderMoved(this); - } - } - - public void addSliderListener(ISliderListener listener) - { - sliderListeners.add(listener); - } - - private void updatePosition(int x, int y) - { - x = clampValue(x, minX, maxX); - y = clampValue(y, minY, maxY); - setPosition(x, y); - } - - public void setValue(float x, float y) - { - updatePosition((int)(x * (maxX - minX)) + minX, (int)(y * (maxY - minY)) + minY); - } - - private int clampValue(int value, int min, int max) - { - if(value < min) - { - value = min; - } - - if(value > max) - { - value = max; - } - - return value; - } - - public GuiSlider(int x, int y, int width, int height, int buttonWidth, int buttonHeight, - Texture texture, int u, int v) - { - super(x, y, buttonWidth, buttonHeight, texture, u, v); - - minX = x; - minY = y; - maxX = minX + width - buttonWidth; - maxY = minY + height - buttonHeight; - } - - public float getPosX() - { - return (bounds.x() - minX)/(float)(maxX - minX); - } - - public float getPosY() - { - return (bounds.y() - minY)/(float)(maxY - minY); - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/client/ui/GuiTabbedDisplay.java b/src/api/java/uristqwerty/CraftGuide/client/ui/GuiTabbedDisplay.java deleted file mode 100644 index 73e0cb8da..000000000 --- a/src/api/java/uristqwerty/CraftGuide/client/ui/GuiTabbedDisplay.java +++ /dev/null @@ -1,138 +0,0 @@ -package uristqwerty.CraftGuide.client.ui; - -import java.util.HashMap; -import java.util.Map; - -import uristqwerty.gui_craftguide.components.GuiElement; - -public class GuiTabbedDisplay extends GuiElement implements IButtonListener -{ - private GuiElement currentTab = null; - private GuiElement changeTab = null; - private Map tabMap = new HashMap(); - - public GuiTabbedDisplay(int x, int y, int width, int height) - { - super(x, y, width, height); - } - - public GuiTabbedDisplay(int x, int y, int width, int height, Object[][] tabs) - { - this(x, y, width, height); - - for(Object[] tab: tabs) - { - if(tab[0] instanceof GuiElement && tab[1] instanceof GuiButton) - { - addTab((GuiElement)tab[0], (GuiButton)tab[1]); - } - } - } - - public GuiTabbedDisplay(int x, int y, int width, int height, Object[] tabs) - { - this(x, y, width, height); - - for(int i = 0; i < (tabs.length & ~1); i += 2) - { - if(tabs[i] instanceof GuiElement && tabs[i + 1] instanceof GuiButton) - { - addTab((GuiElement)tabs[i], (GuiButton)tabs[i + 1]); - } - } - } - - public GuiTabbedDisplay addTab(GuiElement tab, GuiButton button) - { - return addTab(tab, button, true); - } - - public GuiTabbedDisplay addTab(GuiElement tab, GuiButton button, boolean addAsChild) - { - button.addButtonListener(this); - return addTab(tab, (GuiElement)button, addAsChild); - } - - public GuiTabbedDisplay addTab(GuiElement tab, GuiElement key) - { - return addTab(tab, key, true); - } - - public GuiTabbedDisplay addTab(GuiElement tab, GuiElement key, boolean addAsChild) - { - if(addAsChild) - { - addElement(key); - } - - return addTab(tab, (Object)key); - } - - public GuiTabbedDisplay addTab(GuiElement tab, Object key) - { - tabMap.put(key, tab); - - if(currentTab == null) - { - setTab(tab); - } - - return this; - } - - @Override - public void mousePressed(int x, int y) - { - super.mousePressed(x, y); - - if(changeTab != null) - { - setTab(changeTab); - } - } - - @Override - public void onButtonEvent(GuiButton button, Event eventType) - { - if(eventType == Event.PRESS) - { - changeTab = tabMap.get(button); - } - } - - public void openTab(Object key) - { - setTab(tabMap.get(key)); - } - - private void setTab(GuiElement tab) - { - if(currentTab != null) - { - currentTab.mouseReleased(0, 0); - removeElement(currentTab); - } - - if(tab != null) - { - addElement(tab); - } - - currentTab = tab; - changeTab = null; - } - - @Override - public void onResize(int oldWidth, int oldHeight) - { - for(GuiElement element: tabMap.values()) - { - if(element != currentTab) - { - element.onParentResize(oldWidth, oldHeight, bounds.width(), bounds.height()); - } - } - - super.onResize(oldWidth, oldHeight); - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/client/ui/GuiText.java b/src/api/java/uristqwerty/CraftGuide/client/ui/GuiText.java deleted file mode 100644 index 082b88a12..000000000 --- a/src/api/java/uristqwerty/CraftGuide/client/ui/GuiText.java +++ /dev/null @@ -1,34 +0,0 @@ -package uristqwerty.CraftGuide.client.ui; - -import uristqwerty.gui_craftguide.components.GuiElement; -import uristqwerty.gui_craftguide.minecraft.Text; - -public class GuiText extends GuiElement -{ - private Text text; - - public GuiText(int x, int y, String text, int color) - { - super(x, y, 0, 0); - - this.text = new Text(0, 0, text, color); - } - - public GuiText(int x, int y, String text) - { - this(x, y, text, 0xffffffff); - } - - public void setText(String text) - { - this.text.setText(text); - } - - @Override - public void draw() - { - render(text); - - super.draw(); - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/client/ui/GuiTextInput.java b/src/api/java/uristqwerty/CraftGuide/client/ui/GuiTextInput.java deleted file mode 100644 index 5ed7ada01..000000000 --- a/src/api/java/uristqwerty/CraftGuide/client/ui/GuiTextInput.java +++ /dev/null @@ -1,262 +0,0 @@ -package uristqwerty.CraftGuide.client.ui; - -import java.util.LinkedList; -import java.util.List; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; - -import org.lwjgl.input.Keyboard; - -import uristqwerty.gui_craftguide.components.GuiElement; -import uristqwerty.gui_craftguide.minecraft.Text; - -public class GuiTextInput extends GuiElement implements IButtonListener -{ - private List listeners = new LinkedList(); - private String before = ""; - private String after = ""; - public static GuiTextInput inFocus = null; - private Text textDisplayBefore = new Text(1, 2, "", 0xff000000); - private Text textDisplayAfter = new Text(1, 2, "", 0xff000000); - private int yText; - private int xText; - - public GuiTextInput(int x, int y, int width, int height) - { - this(x, y, width, height, 0, 0); - } - - public GuiTextInput(int x, int y, int width, int height, int xTextOffset, int yTextOffset) - { - super(x, y, width, height); - - xText = xTextOffset; - yText = yTextOffset; - } - - public GuiTextInput addListener(ITextInputListener listener) - { - listeners.add(listener); - return this; - } - - public String getText() - { - return before + after; - } - - @Override - public void mousePressed(int x, int y) - { - if(!containsPoint(x, y)) - { - setFocus(false); - } - - super.mousePressed(x, y); - } - - @Override - public void elementClicked(int x, int y) - { - setFocus(true); - moveCursor(xToCharIndex(x - xText)); - - super.elementClicked(x, y); - } - - private int xToCharIndex(int x) - { - if(x < Text.textWidth(before)) - { - return xToCharIndex(before, x); - } - else if(inFocus()) - { - if(x < Text.textWidth(before) + Text.textWidth("_")) - { - return before.length(); - } - else - { - return xToCharIndex(after, x - Text.textWidth(before) - Text.textWidth("_")) + before.length() + 1; - } - } - else - { - return xToCharIndex(after, x - Text.textWidth(before)) + before.length() + 1; - } - } - - private boolean inFocus() - { - return inFocus == this; - } - - private int xToCharIndex(String text, int x) - { - FontRenderer fr = Minecraft.getMinecraft().fontRenderer; - int i = 0; - - while(i < text.length() && fr.getStringWidth(text.substring(0, i + 1)) < x) - { - i++; - } - - return i; - } - - private void moveCursor(int index) - { - String text = before + after; - - if(index <= 0) - { - before = ""; - after = text; - } - else if(index >= text.length()) - { - before = text; - after = ""; - } - else - { - before = text.substring(0, index); - after = text.substring(index); - } - } - - @Override - public void onKeyTyped(char eventChar, int eventKey) - { - if(inFocus == this) - { - if(eventKey == Keyboard.KEY_BACK) - { - if(before.length() > 0) - { - before = before.substring(0, before.length() - 1); - } - } - else if(eventKey == Keyboard.KEY_DELETE) - { - if(after.length() > 0) - { - after = after.substring(1); - } - } - else if(eventKey == Keyboard.KEY_LEFT) - { - if(before.length() > 0) - { - after = before.substring(before.length() - 1) + after; - before = before.substring(0, before.length() - 1); - } - } - else if(eventKey == Keyboard.KEY_RIGHT) - { - if(after.length() > 0) - { - before = before + after.substring(0, 1); - after = after.substring(1); - } - - } - else if(eventKey == Keyboard.KEY_RETURN) - { - setFocus(false); - - for(ITextInputListener listener: listeners) - { - listener.onSubmit(this); - } - - return; - } - else if(eventChar != 0 && eventKey != Keyboard.KEY_ESCAPE) - { - before = before + eventChar; - } - - for(ITextInputListener listener: listeners) - { - listener.onTextChanged(this); - } - } - else - { - super.onKeyTyped(eventChar, eventKey); - } - } - - @Override - public void draw() - { - int afterOffset = 0; - - if(inFocus == this) - { - textDisplayBefore.setText(before); - - if((System.currentTimeMillis() % 1000) > 500) - { - textDisplayAfter.setText("_" + after); - } - else - { - textDisplayAfter.setText(after); - afterOffset = Text.textWidth("_"); - } - } - else - { - textDisplayBefore.setText(before); - textDisplayAfter.setText(after); - } - - render(textDisplayBefore, xText, yText); - render(textDisplayAfter, xText + textDisplayBefore.textWidth() + afterOffset, yText); - super.draw(); - } - - public void setFocus(boolean focused) - { - if(focused) - { - inFocus = this; - } - else if(inFocus == this) - { - inFocus = null; - } - } - - @Override - public void onButtonEvent(GuiButton button, Event eventType) - { - setFocus(true); - } - - public void setText(String string) - { - before = string; - after = ""; - - for(ITextInputListener listener: listeners) - { - listener.onTextChanged(this); - } - } - -/* - @Override - public void onGuiClosed() - { - setFocus(false); - - super.onGuiClosed(); - } -*/ -} diff --git a/src/api/java/uristqwerty/CraftGuide/client/ui/GuiVariableRowHeightGrid.java b/src/api/java/uristqwerty/CraftGuide/client/ui/GuiVariableRowHeightGrid.java deleted file mode 100644 index 27eed0e55..000000000 --- a/src/api/java/uristqwerty/CraftGuide/client/ui/GuiVariableRowHeightGrid.java +++ /dev/null @@ -1,108 +0,0 @@ -package uristqwerty.CraftGuide.client.ui; - -import java.util.Arrays; - - -public abstract class GuiVariableRowHeightGrid extends GuiScrollableGrid -{ - private int[] rowHeights; - private int[] rowStartY; - - public GuiVariableRowHeightGrid(int x, int y, int width, int height, GuiScrollBar scrollBar, int rowHeight, int columnWidth) - { - super(x, y, width, height, scrollBar, rowHeight, columnWidth); - } - - @Override - protected void recalculateRowHeight() - { - int rowCount = rowCount(); - int columns = getColumns(); - rowHeights = new int[rowCount]; - rowStartY = new int[rowCount]; - - if(rowCount < 1) - { - return; - } - - rowStartY[0] = 0; - - for(int row = 0; row < rowCount; row++) - { - int height = 1; - for(int column = 0; column < columns; column++) - { - int cell = row * columns + column; - - if(cell < getCells()) - { - height = Math.max(height, getMinCellHeight(cell)); - } - } - - rowHeights[row] = height; - - if(row < rowCount - 1) - { - rowStartY[row + 1] = rowStartY[row] + height; - } - } - } - - @Override - protected int getHeightForRow(int row) - { - if(row >= 0 && row < rowHeights.length) - { - return rowHeights[row]; - } - else - { - return 0; - } - } - - @Override - protected int rowAtScreenY(int y) - { - return rowAtGridY(pixelsScrolledForScreenY(y)); - } - - @Override - protected int rowAtY(int y) - { - return rowAtGridY(pixelsScrolledForY(y)); - } - - @Override - protected int rowAtGridY(int y) - { - int row = Arrays.binarySearch(rowStartY, y); - - if(row < 0) - { - row = Math.max(0,(-row) - 2); - } - - return row; - } - - @Override - protected int rowStartPixels(int row) - { - if(row >= 0) - { - if(row < rowStartY.length) - { - return rowStartY[row]; - } - else if(rowStartY.length > 0) - { - return rowStartY[rowStartY.length - 1]; - } - } - - return 0; - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/client/ui/IButtonListener.java b/src/api/java/uristqwerty/CraftGuide/client/ui/IButtonListener.java deleted file mode 100644 index 5112dcda2..000000000 --- a/src/api/java/uristqwerty/CraftGuide/client/ui/IButtonListener.java +++ /dev/null @@ -1,12 +0,0 @@ -package uristqwerty.CraftGuide.client.ui; - -public interface IButtonListener -{ - enum Event - { - PRESS, - RELEASE - } - - void onButtonEvent(GuiButton button, Event eventType); -} diff --git a/src/api/java/uristqwerty/CraftGuide/client/ui/IRecipeCacheListener.java b/src/api/java/uristqwerty/CraftGuide/client/ui/IRecipeCacheListener.java deleted file mode 100644 index 8430d9c80..000000000 --- a/src/api/java/uristqwerty/CraftGuide/client/ui/IRecipeCacheListener.java +++ /dev/null @@ -1,9 +0,0 @@ -package uristqwerty.CraftGuide.client.ui; - -import uristqwerty.CraftGuide.RecipeCache; - -public interface IRecipeCacheListener -{ - void onChange(RecipeCache cache); - void onReset(RecipeCache cache); -} diff --git a/src/api/java/uristqwerty/CraftGuide/client/ui/ISliderListener.java b/src/api/java/uristqwerty/CraftGuide/client/ui/ISliderListener.java deleted file mode 100644 index deff11537..000000000 --- a/src/api/java/uristqwerty/CraftGuide/client/ui/ISliderListener.java +++ /dev/null @@ -1,6 +0,0 @@ -package uristqwerty.CraftGuide.client.ui; - -public interface ISliderListener -{ - void onSliderMoved(GuiSlider slider); -} diff --git a/src/api/java/uristqwerty/CraftGuide/client/ui/ITextInputListener.java b/src/api/java/uristqwerty/CraftGuide/client/ui/ITextInputListener.java deleted file mode 100644 index 3807e9986..000000000 --- a/src/api/java/uristqwerty/CraftGuide/client/ui/ITextInputListener.java +++ /dev/null @@ -1,7 +0,0 @@ -package uristqwerty.CraftGuide.client.ui; - -public interface ITextInputListener -{ - public void onTextChanged(GuiTextInput input); - public void onSubmit(GuiTextInput input); -} diff --git a/src/api/java/uristqwerty/CraftGuide/client/ui/NamedTextureObject.java b/src/api/java/uristqwerty/CraftGuide/client/ui/NamedTextureObject.java deleted file mode 100644 index 7978391ac..000000000 --- a/src/api/java/uristqwerty/CraftGuide/client/ui/NamedTextureObject.java +++ /dev/null @@ -1,21 +0,0 @@ -package uristqwerty.CraftGuide.client.ui; - -import uristqwerty.CraftGuide.api.NamedTexture; -import uristqwerty.gui_craftguide.rendering.RendererBase; -import uristqwerty.gui_craftguide.texture.Texture; - -public class NamedTextureObject implements NamedTexture, Texture -{ - private final Texture actualTexture; - - public NamedTextureObject(Texture texture) - { - actualTexture = texture; - } - - @Override - public void renderRect(RendererBase renderer, int x, int y, int width, int height, int u, int v) - { - actualTexture.renderRect(renderer, x, y, width, height, u, v); - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/client/ui/Rendering/CentredText.java b/src/api/java/uristqwerty/CraftGuide/client/ui/Rendering/CentredText.java deleted file mode 100644 index 183cffb32..000000000 --- a/src/api/java/uristqwerty/CraftGuide/client/ui/Rendering/CentredText.java +++ /dev/null @@ -1,36 +0,0 @@ -package uristqwerty.CraftGuide.client.ui.Rendering; - -import uristqwerty.gui_craftguide.minecraft.Text; -import uristqwerty.gui_craftguide.rendering.RendererBase; - -public class CentredText extends Text -{ - private int width, height; - - public CentredText(int x, int y, int width, int height, String text) - { - this(x, y, width, height, text, 0xff000000); - } - - public CentredText(int x, int y, int width, int height, String text, int color) - { - super(x, y, text, color); - - this.width = width; - this.height = height; - } - - @Override - public void render(RendererBase renderer, int xOffset, int yOffset) - { - renderer.setColor(color); - renderer.drawText(text, x + xOffset + (width + 1 - textWidth()) / 2, y + yOffset + (height + 1 - textHeight()) / 2); - renderer.setColor(0xffffffff); - } - - public void setSize(int width, int height) - { - this.width = width; - this.height = height; - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/client/ui/Rendering/FloatingItemText.java b/src/api/java/uristqwerty/CraftGuide/client/ui/Rendering/FloatingItemText.java deleted file mode 100644 index e27946ca1..000000000 --- a/src/api/java/uristqwerty/CraftGuide/client/ui/Rendering/FloatingItemText.java +++ /dev/null @@ -1,50 +0,0 @@ -package uristqwerty.CraftGuide.client.ui.Rendering; - -import java.util.ArrayList; -import java.util.List; - -import org.lwjgl.input.Mouse; - -import uristqwerty.CraftGuide.client.ui.GuiRenderer; -import uristqwerty.gui_craftguide.rendering.Renderable; -import uristqwerty.gui_craftguide.rendering.RendererBase; - - -public class FloatingItemText implements Renderable -{ - private List text; - - public FloatingItemText(List text) - { - this.text = text; - } - - public FloatingItemText(String text) - { - this.text = new ArrayList(1); - this.text.add(text); - } - - public void setText(String text) - { - this.text = new ArrayList(1); - this.text.add(text); - } - - public void setText(List text) - { - this.text = text; - } - - //@Override - public void render(GuiRenderer renderer, int xOffset, int yOffset) - { - renderer.drawFloatingText(renderer.guiXFromMouseX(Mouse.getX()) + 12, renderer.guiYFromMouseY(Mouse.getY()) - 13, text); - } - - @Override - public void render(RendererBase renderer, int x, int y) - { - render((GuiRenderer)renderer, x, y); - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/client/ui/Rendering/GridRect.java b/src/api/java/uristqwerty/CraftGuide/client/ui/Rendering/GridRect.java deleted file mode 100644 index 69d743d25..000000000 --- a/src/api/java/uristqwerty/CraftGuide/client/ui/Rendering/GridRect.java +++ /dev/null @@ -1,48 +0,0 @@ -package uristqwerty.CraftGuide.client.ui.Rendering; - -import uristqwerty.CraftGuide.client.ui.GuiRenderer; -import uristqwerty.CraftGuide.client.ui.GuiScrollableGrid; -import uristqwerty.gui_craftguide.rendering.Renderable; -import uristqwerty.gui_craftguide.rendering.RendererBase; - -public class GridRect implements Renderable -{ - private int x, y, width, height; - private GuiScrollableGrid gridElement; - - public GridRect(int x, int y, int width, int height, GuiScrollableGrid displayElement) - { - this.x = x; - this.y = y; - this.width = width; - this.height = height; - this.gridElement = displayElement; - } - - //@Override - public void render(GuiRenderer renderer, int xOffset, int yOffset) - { - renderer.setClippingRegion(x + xOffset, y + yOffset, width, height); - - try - { - gridElement.renderGridRows(renderer, x + xOffset, y + yOffset); - } - finally - { - renderer.clearClippingRegion(); - } - } - - @Override - public void render(RendererBase renderer, int x, int y) - { - render((GuiRenderer)renderer, x, y); - } - - public void setSize(int width, int height) - { - this.width = width; - this.height = height; - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/client/ui/Rendering/Overlay.java b/src/api/java/uristqwerty/CraftGuide/client/ui/Rendering/Overlay.java deleted file mode 100644 index 253a6db8e..000000000 --- a/src/api/java/uristqwerty/CraftGuide/client/ui/Rendering/Overlay.java +++ /dev/null @@ -1,35 +0,0 @@ -package uristqwerty.CraftGuide.client.ui.Rendering; - -import uristqwerty.CraftGuide.client.ui.GuiRenderer; -import uristqwerty.gui_craftguide.rendering.Renderable; -import uristqwerty.gui_craftguide.rendering.RendererBase; - -public class Overlay implements Renderable -{ - private Renderable renderable; - private int x, y; - - public Overlay(Renderable renderable) - { - this.renderable = renderable; - } - - //@Override - public void render(GuiRenderer renderer, int xOffset, int yOffset) - { - renderer.overlay(this); - x = xOffset; - y = yOffset; - } - - public void renderOverlay(GuiRenderer renderer) - { - renderable.render(renderer, x, y); - } - - @Override - public void render(RendererBase renderer, int x, int y) - { - render((GuiRenderer)renderer, x, y); - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/client/ui/Rendering/RenderMultiple.java b/src/api/java/uristqwerty/CraftGuide/client/ui/Rendering/RenderMultiple.java deleted file mode 100644 index c54a643fc..000000000 --- a/src/api/java/uristqwerty/CraftGuide/client/ui/Rendering/RenderMultiple.java +++ /dev/null @@ -1,31 +0,0 @@ -package uristqwerty.CraftGuide.client.ui.Rendering; - -import uristqwerty.gui_craftguide.rendering.Renderable; -import uristqwerty.gui_craftguide.rendering.RendererBase; - -public class RenderMultiple implements Renderable -{ - Renderable render[]; - int x, y; - - public RenderMultiple(Renderable render[]) - { - this(0, 0, render); - } - - public RenderMultiple(int x, int y, Renderable render[]) - { - this.x = x; - this.y = y; - this.render = render; - } - - @Override - public void render(RendererBase renderer, int x, int y) - { - for(Renderable renderable: render) - { - renderable.render(renderer, x + this.x, y + this.y); - } - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/client/ui/Rendering/RightAlignedText.java b/src/api/java/uristqwerty/CraftGuide/client/ui/Rendering/RightAlignedText.java deleted file mode 100644 index cc9223ff4..000000000 --- a/src/api/java/uristqwerty/CraftGuide/client/ui/Rendering/RightAlignedText.java +++ /dev/null @@ -1,25 +0,0 @@ -package uristqwerty.CraftGuide.client.ui.Rendering; - -import uristqwerty.gui_craftguide.minecraft.Text; -import uristqwerty.gui_craftguide.rendering.RendererBase; - -public class RightAlignedText extends Text -{ - public RightAlignedText(int x, int y, String text) - { - super(x, y, text); - } - - public RightAlignedText(int x, int y, String text, int color) - { - super(x, y, text, color); - } - - @Override - public void render(RendererBase renderer, int xOffset, int yOffset) - { - renderer.setColor(color); - renderer.drawText(text, x + xOffset - textWidth(), y + yOffset); - renderer.setColor(0xffffffff); - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/client/ui/Rendering/ShadedRect.java b/src/api/java/uristqwerty/CraftGuide/client/ui/Rendering/ShadedRect.java deleted file mode 100644 index 27b2a7339..000000000 --- a/src/api/java/uristqwerty/CraftGuide/client/ui/Rendering/ShadedRect.java +++ /dev/null @@ -1,40 +0,0 @@ -package uristqwerty.CraftGuide.client.ui.Rendering; - -import uristqwerty.CraftGuide.client.ui.GuiRenderer; -import uristqwerty.gui_craftguide.rendering.Renderable; -import uristqwerty.gui_craftguide.rendering.RendererBase; - -public class ShadedRect implements Renderable -{ - private int x, y, width, height; - private int color, alpha; - - public ShadedRect(int x, int y, int width, int height, int colour) - { - this(x, y, width, height, colour, 0xff); - } - - public ShadedRect(int x, int y, int width, int height, int color, int alpha) - { - this.x = x; - this.y = y; - this.width = width; - this.height = height; - this.color = color; - this.alpha = alpha; - } - - //@Override - public void render(GuiRenderer renderer, int xOffset, int yOffset) - { - renderer.setColor(color, alpha); - renderer.drawRect(x + xOffset, y + yOffset, width, height); - renderer.setColor(0xffffff, 0xff); - } - - @Override - public void render(RendererBase renderer, int x, int y) - { - render((GuiRenderer)renderer, x, y); - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/client/ui/RowCount.java b/src/api/java/uristqwerty/CraftGuide/client/ui/RowCount.java deleted file mode 100644 index 7cdfe1a6a..000000000 --- a/src/api/java/uristqwerty/CraftGuide/client/ui/RowCount.java +++ /dev/null @@ -1,25 +0,0 @@ -package uristqwerty.CraftGuide.client.ui; - -import uristqwerty.gui_craftguide.components.GuiElement; - -public class RowCount extends GuiElement -{ - GuiScrollableGrid grid; - GuiRightAlignedText text; - - public RowCount(int x, int y, GuiScrollableGrid grid) - { - super(x, y, 0, 0); - - text = new GuiRightAlignedText(0, 0, "", 0xff000000); - addElement(text); - this.grid = grid; - } - - @Override - public void draw() - { - text.setText("Rows " + (grid.firstVisibleRow() + 1) + "-" + + (grid.lastVisibleRow()) + " of " + (grid.rowCount())); - super.draw(); - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/client/ui/ToggleButton.java b/src/api/java/uristqwerty/CraftGuide/client/ui/ToggleButton.java deleted file mode 100644 index 853d72125..000000000 --- a/src/api/java/uristqwerty/CraftGuide/client/ui/ToggleButton.java +++ /dev/null @@ -1,45 +0,0 @@ -package uristqwerty.CraftGuide.client.ui; - - -public class ToggleButton extends GuiButton -{ - public ToggleButton(int x, int y, int width, int height, ButtonTemplate template) - { - super(x, y, width, height, template); - } - - @Override - public void mouseMoved(int x, int y) - { - updateState(containsPoint(x, y), isHeld()); - } - - @Override - public void mousePressed(int x, int y) - { - if(containsPoint(x, y)) - { - if(!isHeld()) - { - sendButtonEvent(IButtonListener.Event.PRESS); - } - else - { - sendButtonEvent(IButtonListener.Event.RELEASE); - } - - updateState(true, !isHeld()); - } - } - - @Override - public void mouseReleased(int x, int y) - { - } - - public ToggleButton setState(ButtonState state) - { - currentState = state; - return this; - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/recipes/BrewingRecipes.java b/src/api/java/uristqwerty/CraftGuide/recipes/BrewingRecipes.java deleted file mode 100644 index 0e2b08b1e..000000000 --- a/src/api/java/uristqwerty/CraftGuide/recipes/BrewingRecipes.java +++ /dev/null @@ -1,131 +0,0 @@ -package uristqwerty.CraftGuide.recipes; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; - -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.potion.PotionHelper; -import uristqwerty.CraftGuide.CommonUtilities; -import uristqwerty.CraftGuide.CraftGuide; -import uristqwerty.CraftGuide.DefaultRecipeTemplate; -import uristqwerty.CraftGuide.api.CraftGuideAPIObject; -import uristqwerty.CraftGuide.api.ItemSlot; -import uristqwerty.CraftGuide.api.RecipeGenerator; -import uristqwerty.CraftGuide.api.RecipeProvider; -import uristqwerty.CraftGuide.api.RecipeTemplate; -import uristqwerty.CraftGuide.api.Slot; -import uristqwerty.CraftGuide.api.SlotType; -import uristqwerty.gui_craftguide.texture.DynamicTexture; -import uristqwerty.gui_craftguide.texture.TextureClip; - -public class BrewingRecipes extends CraftGuideAPIObject implements RecipeProvider -{ - private final Slot[] slots = new ItemSlot[]{ - new ItemSlot(12, 12, 16, 16).setSlotType(SlotType.INPUT_SLOT), - new ItemSlot(12, 30, 16, 16).setSlotType(SlotType.INPUT_SLOT), - new ItemSlot(49, 21, 16, 16).setSlotType(SlotType.OUTPUT_SLOT), - }; - - @Override - public void generateRecipes(RecipeGenerator generator) - { - ItemStack stack = new ItemStack(Items.brewing_stand); - List recipes = getRecipes(); - /*RecipeTemplate template = generator.createRecipeTemplate(slots, stack, - "/gui/BrewGuide.png", 1, 1, 82, 1);*/ - - RecipeTemplate template = new DefaultRecipeTemplate( - slots, - stack, - new TextureClip( - DynamicTexture.instance("brew_recipe_background"), - 1, 1, 79, 58), - new TextureClip( - DynamicTexture.instance("brew_recipe_background"), - 82, 1, 79, 58)); - - if(CraftGuide.hideMundanePotionRecipes) - { - Iterator iterator = recipes.iterator(); - - while(iterator.hasNext()) - { - ItemStack[] recipe = iterator.next(); - - if(recipe[2] != null && CommonUtilities.getItemDamage(recipe[2]) == 8192) - { - iterator.remove(); - } - } - } - - for(ItemStack[] recipe: recipes) - { - generator.addRecipe(template, recipe); - } - - generator.setDefaultTypeVisibility(stack, false); - } - - private List getRecipes() - { - List ingredients = getIngredients(); - - ItemStack water = new ItemStack(Items.potionitem); - List potionRecipes = new LinkedList(); - Set done = new HashSet(); - done.add(0); - - addRecipesForPotion(potionRecipes, water, ingredients, done); - - return potionRecipes; - } - - private void addRecipesForPotion(List potionRecipes, ItemStack potion, List ingredients, Set done) - { - List next = new LinkedList(); - - for(Item ingredient: ingredients) - { - int result = PotionHelper.applyIngredient(CommonUtilities.getItemDamage(potion), ingredient.getPotionEffect(new ItemStack(ingredient))); - - if(result != 0 && result != CommonUtilities.getItemDamage(potion)) - { - ItemStack output = new ItemStack(Items.potionitem); - output.setItemDamage(result); - potionRecipes.add(new ItemStack[] {potion, new ItemStack(ingredient), output}); - - if(!done.contains(result)) - { - next.add(output); - done.add(result); - } - } - } - - for(ItemStack nextPotion: next) - { - addRecipesForPotion(potionRecipes, nextPotion, ingredients, done); - } - } - - private List getIngredients() - { - List ingredients = new LinkedList(); - - for(Object item: Item.itemRegistry) - { - if(item != null && ((Item)item).isPotionIngredient(new ItemStack((Item)item))) - { - ingredients.add(((Item)item)); - } - } - - return ingredients; - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/recipes/DefaultRecipeProvider.java b/src/api/java/uristqwerty/CraftGuide/recipes/DefaultRecipeProvider.java deleted file mode 100644 index c8642e271..000000000 --- a/src/api/java/uristqwerty/CraftGuide/recipes/DefaultRecipeProvider.java +++ /dev/null @@ -1,214 +0,0 @@ -package uristqwerty.CraftGuide.recipes; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.CraftingManager; -import net.minecraft.item.crafting.FurnaceRecipes; -import net.minecraft.item.crafting.IRecipe; -import net.minecraft.item.crafting.ShapelessRecipes; -import net.minecraft.tileentity.TileEntityFurnace; -import uristqwerty.CraftGuide.CraftGuide; -import uristqwerty.CraftGuide.CraftGuideLog; -import uristqwerty.CraftGuide.DefaultRecipeTemplate; -import uristqwerty.CraftGuide.RecipeGeneratorImplementation; -import uristqwerty.CraftGuide.api.CraftGuideAPIObject; -import uristqwerty.CraftGuide.api.ItemSlot; -import uristqwerty.CraftGuide.api.RecipeGenerator; -import uristqwerty.CraftGuide.api.RecipeProvider; -import uristqwerty.CraftGuide.api.RecipeTemplate; -import uristqwerty.CraftGuide.api.Slot; -import uristqwerty.CraftGuide.api.SlotType; -import uristqwerty.CraftGuide.api.StackInfo; -import uristqwerty.CraftGuide.api.StackInfoSource; -import uristqwerty.gui_craftguide.texture.DynamicTexture; -import uristqwerty.gui_craftguide.texture.TextureClip; - -public class DefaultRecipeProvider extends CraftGuideAPIObject implements RecipeProvider, StackInfoSource -{ - - public DefaultRecipeProvider() { - StackInfo.addSource( this ); - } - - private final Slot[] shapelessCraftingSlots = new ItemSlot[] { new ItemSlot( 3, 3, 16, 16 ), new ItemSlot( 21, 3, 16, 16 ), new ItemSlot( 39, 3, 16, 16 ), - new ItemSlot( 3, 21, 16, 16 ), new ItemSlot( 21, 21, 16, 16 ), new ItemSlot( 39, 21, 16, 16 ), new ItemSlot( 3, 39, 16, 16 ), - new ItemSlot( 21, 39, 16, 16 ), new ItemSlot( 39, 39, 16, 16 ), new ItemSlot( 59, 21, 16, 16, true ).setSlotType( SlotType.OUTPUT_SLOT ), }; - - private final Slot[] craftingSlotsOwnBackground = new ItemSlot[] { new ItemSlot( 3, 3, 16, 16 ).drawOwnBackground(), - new ItemSlot( 21, 3, 16, 16 ).drawOwnBackground(), new ItemSlot( 39, 3, 16, 16 ).drawOwnBackground(), - new ItemSlot( 3, 21, 16, 16 ).drawOwnBackground(), new ItemSlot( 21, 21, 16, 16 ).drawOwnBackground(), - new ItemSlot( 39, 21, 16, 16 ).drawOwnBackground(), new ItemSlot( 3, 39, 16, 16 ).drawOwnBackground(), - new ItemSlot( 21, 39, 16, 16 ).drawOwnBackground(), new ItemSlot( 39, 39, 16, 16 ).drawOwnBackground(), - new ItemSlot( 59, 21, 16, 16, true ).setSlotType( SlotType.OUTPUT_SLOT ).drawOwnBackground(), }; - - private final Slot[] smallCraftingSlotsOwnBackground = new ItemSlot[] { new ItemSlot( 12, 12, 16, 16 ).drawOwnBackground(), - new ItemSlot( 30, 12, 16, 16 ).drawOwnBackground(), new ItemSlot( 12, 30, 16, 16 ).drawOwnBackground(), - new ItemSlot( 30, 30, 16, 16 ).drawOwnBackground(), new ItemSlot( 59, 21, 16, 16, true ).setSlotType( SlotType.OUTPUT_SLOT ).drawOwnBackground(), }; - - private final Slot[] craftingSlots = new ItemSlot[] { new ItemSlot( 3, 3, 16, 16 ), new ItemSlot( 21, 3, 16, 16 ), new ItemSlot( 39, 3, 16, 16 ), - new ItemSlot( 3, 21, 16, 16 ), new ItemSlot( 21, 21, 16, 16 ), new ItemSlot( 39, 21, 16, 16 ), new ItemSlot( 3, 39, 16, 16 ), - new ItemSlot( 21, 39, 16, 16 ), new ItemSlot( 39, 39, 16, 16 ), new ItemSlot( 59, 21, 16, 16, true ).setSlotType( SlotType.OUTPUT_SLOT ), }; - - private final Slot[] smallCraftingSlots = new ItemSlot[] { new ItemSlot( 12, 12, 16, 16 ), new ItemSlot( 30, 12, 16, 16 ), new ItemSlot( 12, 30, 16, 16 ), - new ItemSlot( 30, 30, 16, 16 ), new ItemSlot( 59, 21, 16, 16, true ).setSlotType( SlotType.OUTPUT_SLOT ), }; - - private final Slot[] furnaceSlots = new ItemSlot[] { new ItemSlot( 13, 21, 16, 16 ), - new ItemSlot( 50, 21, 16, 16, true ).setSlotType( SlotType.OUTPUT_SLOT ), }; - - @Override - public void generateRecipes(RecipeGenerator generator) - { - RecipeTemplate craftingTemplate; - RecipeTemplate smallCraftingTemplate; - - if ( CraftGuide.newerBackgroundStyle ) - { - craftingTemplate = generator.createRecipeTemplate( craftingSlotsOwnBackground, null ); - smallCraftingTemplate = generator.createRecipeTemplate( smallCraftingSlotsOwnBackground, null ); - } - else - { - craftingTemplate = new DefaultRecipeTemplate( craftingSlots, RecipeGeneratorImplementation.workbench, new TextureClip( - DynamicTexture.instance( "recipe_backgrounds" ), 1, 1, 79, 58 ), new TextureClip( DynamicTexture.instance( "recipe_backgrounds" ), 82, 1, - 79, 58 ) ); - - smallCraftingTemplate = new DefaultRecipeTemplate( smallCraftingSlots, RecipeGeneratorImplementation.workbench, new TextureClip( - DynamicTexture.instance( "recipe_backgrounds" ), 1, 61, 79, 58 ), new TextureClip( DynamicTexture.instance( "recipe_backgrounds" ), 82, 61, - 79, 58 ) ); - } - - RecipeTemplate shapelessTemplate = new DefaultRecipeTemplate( shapelessCraftingSlots, RecipeGeneratorImplementation.workbench, new TextureClip( - DynamicTexture.instance( "recipe_backgrounds" ), 1, 121, 79, 58 ), new TextureClip( DynamicTexture.instance( "recipe_backgrounds" ), 82, 121, - 79, 58 ) ); - - RecipeTemplate furnaceTemplate = new DefaultRecipeTemplate( furnaceSlots, new ItemStack( Blocks.furnace ), new TextureClip( - DynamicTexture.instance( "recipe_backgrounds" ), 1, 181, 79, 58 ), new TextureClip( DynamicTexture.instance( "recipe_backgrounds" ), 82, 181, - 79, 58 ) ); - - addCraftingRecipes( craftingTemplate, smallCraftingTemplate, shapelessTemplate, generator ); - addFurnaceRecipes( furnaceTemplate, generator ); - } - - private void addFurnaceRecipes(RecipeTemplate template, RecipeGenerator generator) - { - Map furnaceRecipes = FurnaceRecipes.smelting().getSmeltingList(); - - for (Entry entry : furnaceRecipes.entrySet()) - { - ItemStack input = entry.getKey(); - if ( input.getItemDamage() == 32767 && input.getItem().getHasSubtypes() ) - { - List items = new ArrayList(); - input.getItem().getSubItems( input.getItem(), null, items ); - - for (ItemStack subItem : items) - { - generator.addRecipe( template, new Object[] { subItem, entry.getValue() } ); - } - } - else - { - generator.addRecipe( template, new Object[] { entry.getKey(), entry.getValue() } ); - } - } - } - - private void addCraftingRecipes(RecipeTemplate template, RecipeTemplate templateSmall, RecipeTemplate templateShapeless, RecipeGenerator generator) - { - List recipes = CraftingManager.getInstance().getRecipeList(); - - int errCount = 0; - - for (Object o : recipes) - { - try - { - IRecipe recipe = (IRecipe) o; - - Object[] items = generator.getCraftingRecipe( recipe, true ); - - if ( items == null ) - { - continue; - } - else if ( items.length == 5 ) - { - generator.addRecipe( templateSmall, items ); - } - else if ( isShapelessRecipe( recipe ) ) - { - generator.addRecipe( templateShapeless, items ); - } - else - { - generator.addRecipe( template, items ); - } - } - catch (Exception e) - { - if ( errCount == -1 ) - { - } - else if ( errCount++ >= 5 ) - { - CraftGuideLog - .log( "CraftGuide DefaultRecipeProvider: Stack trace limit reached, further stack traces from this invocation will not be logged to the console. They will still be logged to (.minecraft)/config/CraftGuide/CraftGuide.log", - true ); - errCount = -1; - } - else - { - e.printStackTrace(); - } - - CraftGuideLog.log( e ); - } - } - } - - private boolean isShapelessRecipe(IRecipe recipe) - { - return recipe instanceof ShapelessRecipes - || (RecipeGeneratorImplementation.forgeExt != null && RecipeGeneratorImplementation.forgeExt.isShapelessRecipe( recipe )); - } - - @Override - public String getInfo(ItemStack itemStack) - { - int fuel = TileEntityFurnace.getItemBurnTime( itemStack ); - - if ( fuel > 0 ) - { - double value = fuel / 200.0; - int round = (int) value; - int dec = (int) ((value - round) * 100); - - StringBuilder builder = new StringBuilder( "\u00a77Can fuel " ); - builder.append( round ); - - if ( dec > 0 ) - { - builder.append( '.' ); - - if ( dec < 10 ) - { - builder.append( '0' ); - } - - builder.append( dec ); - } - - builder.append( " furnace operations" ); - return builder.toString(); - } - else - { - return null; - } - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/recipes/ExtendedWorkbench.java b/src/api/java/uristqwerty/CraftGuide/recipes/ExtendedWorkbench.java deleted file mode 100644 index 1224c9f84..000000000 --- a/src/api/java/uristqwerty/CraftGuide/recipes/ExtendedWorkbench.java +++ /dev/null @@ -1,137 +0,0 @@ -package uristqwerty.CraftGuide.recipes; - -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.util.List; - -import net.minecraft.init.Blocks; -import net.minecraft.item.ItemStack; -import net.minecraft.item.crafting.IRecipe; -import uristqwerty.CraftGuide.api.CraftGuideAPIObject; -import uristqwerty.CraftGuide.api.ItemSlot; -import uristqwerty.CraftGuide.api.RecipeGenerator; -import uristqwerty.CraftGuide.api.RecipeProvider; -import uristqwerty.CraftGuide.api.RecipeTemplate; -import uristqwerty.CraftGuide.api.Slot; -import uristqwerty.CraftGuide.api.SlotType; - -public class ExtendedWorkbench extends CraftGuideAPIObject implements RecipeProvider -{ - private static ItemStack workbenchStack = new ItemStack(Blocks.crafting_table, 1, 1); - - @Override - public void generateRecipes(RecipeGenerator generator) - { - try - { - Class craftingManagerClass = Class.forName("naruto1310.extendedWorkbench.ExtendedCraftingManager"); - Object craftingManager = craftingManagerClass.getMethod("getInstance").invoke(null); - addRecipes(generator, (List)craftingManagerClass.getMethod("getRecipeList").invoke(craftingManager)); - } - catch(IllegalArgumentException e) - { - e.printStackTrace(); - } - catch(SecurityException e) - { - e.printStackTrace(); - } - catch(IllegalAccessException e) - { - e.printStackTrace(); - } - catch(InvocationTargetException e) - { - e.printStackTrace(); - } - catch(NoSuchMethodException e) - { - e.printStackTrace(); - } - catch(ClassNotFoundException e) - { - e.printStackTrace(); - } - catch(NoSuchFieldException e) - { - e.printStackTrace(); - } - } - - private void addRecipes(RecipeGenerator generator, List recipes) throws ClassNotFoundException, SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException - { - Class extendedShapedRecipe = Class.forName("naruto1310.extendedWorkbench.ExtendedShapedRecipes"); - Field shapedWidth = extendedShapedRecipe.getDeclaredField("recipeWidth"); - Field shapedHeight = extendedShapedRecipe.getDeclaredField("recipeHeight"); - Field shapedItems = extendedShapedRecipe.getDeclaredField("recipeItems"); - shapedWidth.setAccessible(true); - shapedHeight.setAccessible(true); - shapedItems.setAccessible(true); - - Class extendedShapelessRecipe = Class.forName("naruto1310.extendedWorkbench.ExtendedShapelessRecipes"); - Field shapelessItems = extendedShapelessRecipe.getDeclaredField("recipeItems"); - shapelessItems.setAccessible(true); - - Slot[] slots = new Slot[] { - new ItemSlot( 3, 3, 16, 16).drawOwnBackground(), - new ItemSlot(21, 3, 16, 16).drawOwnBackground(), - new ItemSlot(39, 3, 16, 16).drawOwnBackground(), - new ItemSlot( 3, 21, 16, 16).drawOwnBackground(), - new ItemSlot(21, 21, 16, 16).drawOwnBackground(), - new ItemSlot(39, 21, 16, 16).drawOwnBackground(), - new ItemSlot( 3, 39, 16, 16).drawOwnBackground(), - new ItemSlot(21, 39, 16, 16).drawOwnBackground(), - new ItemSlot(39, 39, 16, 16).drawOwnBackground(), - new ItemSlot( 3, 57, 16, 16).drawOwnBackground(), - new ItemSlot(21, 57, 16, 16).drawOwnBackground(), - new ItemSlot(39, 57, 16, 16).drawOwnBackground(), - new ItemSlot( 3, 75, 16, 16).drawOwnBackground(), - new ItemSlot(21, 75, 16, 16).drawOwnBackground(), - new ItemSlot(39, 75, 16, 16).drawOwnBackground(), - new ItemSlot( 3, 93, 16, 16).drawOwnBackground(), - new ItemSlot(21, 93, 16, 16).drawOwnBackground(), - new ItemSlot(39, 93, 16, 16).drawOwnBackground(), - new ItemSlot(59, 48, 16, 16, true).setSlotType(SlotType.OUTPUT_SLOT).drawOwnBackground(), - }; - - RecipeTemplate template = generator.createRecipeTemplate(slots, workbenchStack); - template.setSize(79, 112); - - for(IRecipe recipe: recipes) - { - Object[] recipeContents = new Object[19]; - - if(extendedShapedRecipe.isInstance(recipe)) - { - ItemStack[] items = (ItemStack[])shapedItems.get(recipe); - int height = Math.min(6, shapedHeight.getInt(recipe)); - int width = Math.min(3, shapedWidth.getInt(recipe)); - - for(int i = 0; i < height; i++) - { - for(int j = 0; j < width; j++) - { - recipeContents[i * 3 + j] = items[i * width + j]; - } - } - } - else if(extendedShapelessRecipe.isInstance(recipe)) - { - List items = (List)shapelessItems.get(recipe); - - for(int i = 0; i < Math.min(18, items.size()); i++) - { - recipeContents[i] = items.get(i); - } - } - else - { - continue; - } - - recipeContents[18] = recipe.getRecipeOutput(); - - generator.addRecipe(template, recipeContents); - } - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/server/CraftGuideServer.java b/src/api/java/uristqwerty/CraftGuide/server/CraftGuideServer.java deleted file mode 100644 index d00e6b924..000000000 --- a/src/api/java/uristqwerty/CraftGuide/server/CraftGuideServer.java +++ /dev/null @@ -1,44 +0,0 @@ -package uristqwerty.CraftGuide.server; - -import net.minecraft.entity.player.EntityPlayer; -import uristqwerty.CraftGuide.CraftGuideSide; -import uristqwerty.CraftGuide.api.Util; - -public class CraftGuideServer implements CraftGuideSide -{ - @Override - public void initKeybind() - { - } - - @Override - public void checkKeybind() - { - } - - @Override - public void preInit() - { - Util.instance = new UtilImplementationServer(); - } - - @Override - public void reloadRecipes() - { - } - - @Override - public void openGUI(EntityPlayer player) - { - } - - @Override - public void initNetworkChannels() - { - } - - @Override - public void stopTessellating() - { - } -} diff --git a/src/api/java/uristqwerty/CraftGuide/server/UtilImplementationServer.java b/src/api/java/uristqwerty/CraftGuide/server/UtilImplementationServer.java deleted file mode 100644 index 3a309af38..000000000 --- a/src/api/java/uristqwerty/CraftGuide/server/UtilImplementationServer.java +++ /dev/null @@ -1,13 +0,0 @@ -package uristqwerty.CraftGuide.server; - -import uristqwerty.CraftGuide.UtilImplementationCommon; -import uristqwerty.CraftGuide.api.NamedTexture; - -public class UtilImplementationServer extends UtilImplementationCommon -{ - @Override - public NamedTexture getTexture(String identifier) - { - return null; - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/Color.java b/src/api/java/uristqwerty/gui_craftguide/Color.java deleted file mode 100644 index c20a4f295..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/Color.java +++ /dev/null @@ -1,14 +0,0 @@ -package uristqwerty.gui_craftguide; - -public class Color -{ - public final int red, green, blue, alpha; - - public Color(int red, int green, int blue, int alpha) - { - this.red = red; - this.green = green; - this.blue = blue; - this.alpha = alpha; - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/MutableRect.java b/src/api/java/uristqwerty/gui_craftguide/MutableRect.java deleted file mode 100644 index e81e519f1..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/MutableRect.java +++ /dev/null @@ -1,91 +0,0 @@ -package uristqwerty.gui_craftguide; - -public class MutableRect -{ - private int x, y, width, height; - private Rect rect = null; - - public MutableRect(int x, int y, int width, int height) - { - this.x = x; - this.y = y; - this.width = width; - this.height = height; - } - - public MutableRect(Rect rect) - { - x = rect.x; - y = rect.y; - width = rect.width; - height = rect.height; - } - - public Rect rect() - { - if(rect == null) - { - rect = new Rect(x, y, width, height); - } - - return rect; - } - - public void setPosition(int x, int y) - { - rect = null; - this.x = x; - this.y = y; - } - - public void setSize(int width, int height) - { - rect = null; - this.width = width; - this.height = height; - } - - public void setRect(int x, int y, int width, int height) - { - rect = null; - this.x = x; - this.y = y; - this.width = width; - this.height = height; - } - - public void setRect(Rect rect) - { - this.rect = null; - x = rect.x; - y = rect.y; - width = rect.width; - height = rect.height; - } - - public int x() - { - return x; - } - - public int y() - { - return y; - } - - public int width() - { - return width; - } - - public int height() - { - return height; - } - - @Override - public String toString() - { - return "(x: " + x + ", y: " + y + ", width: " + width + ", height: " + height + ")"; - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/Rect.java b/src/api/java/uristqwerty/gui_craftguide/Rect.java deleted file mode 100644 index 9728a6a71..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/Rect.java +++ /dev/null @@ -1,14 +0,0 @@ -package uristqwerty.gui_craftguide; - -public class Rect -{ - public final int x, y, width, height; - - public Rect(int x, int y, int width, int height) - { - this.x = x; - this.y = y; - this.width = width; - this.height = height; - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/components/Button.java b/src/api/java/uristqwerty/gui_craftguide/components/Button.java deleted file mode 100644 index 2fd16dde5..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/components/Button.java +++ /dev/null @@ -1,95 +0,0 @@ -package uristqwerty.gui_craftguide.components; - -import java.util.EnumMap; - -import uristqwerty.gui_craftguide.Rect; -import uristqwerty.gui_craftguide.editor.GuiElementMeta; -import uristqwerty.gui_craftguide.editor.GuiElementMeta.EnumMapProperty; -import uristqwerty.gui_craftguide.editor.GuiElementMeta.GuiElementProperty; -import uristqwerty.gui_craftguide.texture.Texture; - -@GuiElementMeta(name = "button") -public class Button extends GuiElement -{ - enum ButtonState - { - UP, - DOWN, - MOUSEOVER, - DOWN_MOUSEOUT, - } - - @GuiElementProperty(name = "states") - @EnumMapProperty(keyType = ButtonState.class, valueType = Texture.class) - public EnumMap stateBackgrounds = new EnumMap(ButtonState.class); - - private ButtonState currentState; - - public Button(int x, int y, int width, int height) - { - this(new Rect(x, y, width, height)); - } - - public Button(int x, int y, int width, int height, String template) - { - this(new Rect(x, y, width, height), template); - } - - public Button(Rect rect) - { - this(rect, "button-default"); - } - - public Button(Rect rect, String template) - { - super(rect, template); - } - - @Override - public void mouseMoved(int x, int y) - { - if(containsPoint(x, y)) - { - if(currentState == ButtonState.UP) - { - currentState = ButtonState.MOUSEOVER; - } - else if(currentState == ButtonState.DOWN_MOUSEOUT) - { - currentState = ButtonState.DOWN; - } - } - else - { - if(currentState == ButtonState.MOUSEOVER) - { - currentState = ButtonState.UP; - } - else if(currentState == ButtonState.DOWN) - { - currentState = ButtonState.DOWN_MOUSEOUT; - } - } - - super.mouseMoved(x, y); - } - - @Override - public void mouseReleased(int x, int y) - { - currentState = ButtonState.UP; - super.mouseReleased(x, y); - } - - @Override - public void drawBackground() - { - super.drawBackground(); - - Texture texture = stateBackgrounds.get(currentState); - if(texture != null) - { - render(texture, 0, 0, bounds.width(), bounds.height()); - } - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/components/DropdownSelector.java b/src/api/java/uristqwerty/gui_craftguide/components/DropdownSelector.java deleted file mode 100644 index d8af4de7c..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/components/DropdownSelector.java +++ /dev/null @@ -1,114 +0,0 @@ -package uristqwerty.gui_craftguide.components; - -import java.util.Arrays; - -import uristqwerty.gui_craftguide.components.Window.Layer; -import uristqwerty.gui_craftguide.minecraft.Text; -import uristqwerty.gui_craftguide.texture.BorderedTexture; -import uristqwerty.gui_craftguide.texture.DynamicTexture; -import uristqwerty.gui_craftguide.texture.SubTexture; -import uristqwerty.gui_craftguide.texture.Texture; -import uristqwerty.gui_craftguide.texture.TextureClip; - -public class DropdownSelector extends GuiElement -{ - private boolean open = false; - private String[] options; - private int selected = -1; - private String selection = null; - - private Text selectedText = new Text(0, 0, ""); - private ScrollPane selectionPane; - - public DropdownSelector(int x, int y, int width, int height) - { - super(x, y, width, height); - selectionPane = new ScrollPane(x, y + height, width, 100); - - Texture texture = DynamicTexture.instance("base_image"); - selectionPane.background = new BorderedTexture( - new Texture[]{ - new TextureClip(texture, 1, 1, 4, 4), - new SubTexture(texture, 6, 1, 64, 4), - new TextureClip(texture, 71, 1, 4, 4), - new SubTexture(texture, 1, 6, 4, 64), - new SubTexture(texture, 6, 6, 64, 64), - new SubTexture(texture, 71, 6, 4, 64), - new TextureClip(texture, 1, 71, 4, 4), - new SubTexture(texture, 6, 71, 64, 4), - new TextureClip(texture, 71, 71, 4, 4), - }, 4); - } - - @Override - public void mousePressed(int x, int y) - { - if(open && !popupContainsPoint(x, y)) - { - open = false; - getLayer(Layer.POPUP).removeElement(selectionPane); - } - - super.mousePressed(x, y); - } - - @Override - public void elementClicked(int x, int y) - { - if(!open) - { - open = true; - getLayer(Layer.POPUP).addElement(selectionPane); - } - - super.elementClicked(x, y); - } - - private boolean popupContainsPoint(int x, int y) - { - // TODO Auto-generated method stub - return false; - } - - public void setOptions(String[] list) - { - selected = -1; - options = Arrays.copyOf(list, list.length); - - for(int i = 0; i < options.length; i++) - { - if(options[i].equals(selection)) - { - selected = i; - break; - } - } - - if(selected == -1) - { - selection = null; - } - } - - public String getCurrentSelection() - { - return selection; - } - - @Override - public void draw() - { - if(open) - { - selectionPane.setPositionAbsolute(this.absoluteX(), this.absoluteY() + bounds.height()); - } - - if(selection != null) - { - selectedText.setText(selection); - render(selectedText); - } - - super.draw(); - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/components/GuiElement.java b/src/api/java/uristqwerty/gui_craftguide/components/GuiElement.java deleted file mode 100644 index 334374466..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/components/GuiElement.java +++ /dev/null @@ -1,428 +0,0 @@ -package uristqwerty.gui_craftguide.components; - -import java.lang.reflect.Field; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import uristqwerty.CraftGuide.CraftGuideLog; -import uristqwerty.gui_craftguide.MutableRect; -import uristqwerty.gui_craftguide.Rect; -import uristqwerty.gui_craftguide.editor.GuiElementMeta.GuiElementProperty; -import uristqwerty.gui_craftguide.rendering.Renderable; -import uristqwerty.gui_craftguide.texture.Texture; - -public class GuiElement -{ - protected MutableRect bounds; - - @GuiElementProperty(name = "background") - public Texture background = null; - - private GuiElement parent = null; - private List children = new LinkedList(); - - public enum AnchorPoint - { - TOP_LEFT, - TOP_RIGHT, - BOTTOM_LEFT, - BOTTOM_RIGHT, - } - - private AnchorPoint anchorTL = AnchorPoint.TOP_LEFT; - private AnchorPoint anchorBR = AnchorPoint.TOP_LEFT; - - private boolean clickable = true; - - public GuiElement(int x, int y, int width, int height) - { - bounds = new MutableRect(x, y, width, height); - } - - public GuiElement(Rect bounds) - { - this.bounds = new MutableRect(bounds); - } - - public GuiElement(Rect bounds, String template) - { - this.bounds = new MutableRect(bounds); - applyTemplate(template); - } - - public GuiElement getLayer(Window.Layer layer) - { - if(parent != null) - { - return parent.getLayer(layer); - } - else - { - return null; - } - } - - public GuiElement getElementAtPoint(int x, int y) - { - if(!containsPoint(x, y)) - { - return null; - } - - GuiElement clicked = clickable? this : null; - - for(GuiElement child: children) - { - GuiElement element = child.getElementAtPoint(x - bounds.x(), y - bounds.y()); - - if(element != null) - { - clicked = element; - } - } - - return clicked; - } - - private void applyTemplate(String template) - { - for(Field field: this.getClass().getFields()) - { - GuiElementProperty property = field.getAnnotation(GuiElementProperty.class); - if(property != null) - { - try - { - CraftGuideLog.log("Annotated property '" + property.name() + "', field '" + field.getName() + "', currentValue '" + field.get(this) + "'", true); - } - catch(IllegalArgumentException e) - { - e.printStackTrace(); - } - catch(IllegalAccessException e) - { - e.printStackTrace(); - } - } - } - Map values = getTemplate(template); - - if(values != null) - { - /* - //GuiElementMeta meta = this.getClass().getAnnotation(GuiElementMeta.class); - - for(Field field: this.getClass().getFields()) - { - GuiElementProperty property = field.getAnnotation(GuiElementProperty.class); - - if(property != null) - { - if(values.containsKey(property.name())) - { - - } - else - { - if() - { - - } - } - } - }*/ - } - } - - private Map getTemplate(String template) - { - if(template.equalsIgnoreCase("")) - { - - } - - return null; - } - - public GuiElement addElement(GuiElement element) - { - element.parent = this; - children.add(element); - - return this; - } - - public void removeElement(GuiElement element) - { - element.parent = null; - children.remove(element); - } - - public void update() - { - for(GuiElement element: children) - { - element.update(); - } - } - - public void draw() - { - drawBackground(); - drawChildren(); - } - - public void drawChildren() - { - for(GuiElement element: children) - { - element.draw(); - } - } - - public void drawBackground() - { - if(background != null) - { - render(background, 0, 0, bounds.width(), bounds.height()); - } - } - - public void mouseMoved(int x, int y) - { - for(GuiElement element: children) - { - element.mouseMoved(x - bounds.x(), y - bounds.y()); - } - } - - public void mousePressed(int x, int y) - { - for(GuiElement element: children) - { - element.mousePressed(x - bounds.x(), y - bounds.y()); - } - } - - public void mouseReleased(int x, int y) - { - for(GuiElement element: children) - { - element.mouseReleased(x - bounds.x(), y - bounds.y()); - } - } - - public void render(Renderable renderable) - { - render(renderable, 0, 0); - } - - public void render(Texture texture, int x, int y, int width, int height) - { - if(parent != null && texture != null && width > 0 && height > 0) - { - parent.render(texture, x + bounds.x(), y + bounds.y(), width, height); - } - } - - public void render(Renderable renderable, int xOffset, int yOffset) - { - if(parent != null && renderable != null) - { - parent.render(renderable, xOffset + bounds.x(), yOffset + bounds.y()); - } - } - - public boolean containsPoint(int x, int y) - { - return x >= bounds.x() - && x < bounds.x() + bounds.width() - && y >= bounds.y() - && y < bounds.y() + bounds.height(); - } - - public GuiElement setSize(int width, int height) - { - if(width != bounds.width() || height != bounds.height()) - { - int oldWidth = bounds.width(); - int oldHeight = bounds.height(); - - bounds.setSize(width, height); - onResize(oldWidth, oldHeight); - - for(GuiElement element: children) - { - element.onParentResize(oldWidth, oldHeight, width, height); - } - } - - return this; - } - - public void onParentResize(int oldWidth, int oldHeight, int newWidth, int newHeight) - { - int x1 = bounds.x(); - int y1 = bounds.y(); - int x2 = bounds.x() + bounds.width(); - int y2 = bounds.y() + bounds.height(); - - if(anchorTL == AnchorPoint.TOP_RIGHT || anchorTL == AnchorPoint.BOTTOM_RIGHT) - { - x1 += newWidth - oldWidth; - } - - if(anchorTL == AnchorPoint.BOTTOM_LEFT || anchorTL == AnchorPoint.BOTTOM_RIGHT) - { - y1 += newHeight - oldHeight; - } - - if(anchorBR == AnchorPoint.TOP_RIGHT || anchorBR == AnchorPoint.BOTTOM_RIGHT) - { - x2 += newWidth - oldWidth; - } - - if(anchorBR == AnchorPoint.BOTTOM_LEFT || anchorBR == AnchorPoint.BOTTOM_RIGHT) - { - y2 += newHeight - oldHeight; - } - - if(x1 != bounds.x() || y1 != bounds.y()) - { - setPosition(x1, y1); - } - - if(x2 - x1 != bounds.width() || y2 - y1 != bounds.height()) - { - setSize(x2 - x1, y2 - y1); - } - } - - public GuiElement setPosition(int x, int y) - { - if(x == bounds.x() && y == bounds.y()) - { - return this; - } - - bounds.setPosition(x, y); - - onMove(); - - for(GuiElement element: children) - { - element.onParentMove(); - } - - return this; - } - - public GuiElement setPositionAbsolute(int x, int y) - { - return setPosition(x - absoluteX() + bounds.x(), y - absoluteY() + bounds.y()); - } - - public GuiElement anchor(AnchorPoint topLeft, AnchorPoint bottomRight) - { - anchorTL = topLeft; - anchorBR = bottomRight; - - return this; - } - - public GuiElement anchor(AnchorPoint point) - { - return anchor(point, point); - } - - public int absoluteX() - { - if(parent == null) - { - return bounds.x(); - } - else - { - return parent.absoluteX() + bounds.x(); - } - } - - public int absoluteY() - { - if(parent == null) - { - return bounds.y(); - } - else - { - return parent.absoluteY() + bounds.y(); - } - } - - public void onKeyTyped(char eventChar, int eventKey) - { - for(GuiElement element: children) - { - element.onKeyTyped(eventChar, eventKey); - } - } - - public void scrollWheelTurned(int change) - { - for(GuiElement element: children) - { - element.scrollWheelTurned(change); - } - } - - public void onGuiClosed() - { - for(GuiElement element: children) - { - element.onGuiClosed(); - } - } - - public GuiElement setClickable(boolean clickable) - { - this.clickable = clickable; - return this; - } - - public GuiElement setBackground(Texture background) - { - this.background = background; - return this; - } - - public int width() - { - return bounds.width(); - } - - public int height() - { - return bounds.height(); - } - - public void onResize(int oldWidth, int oldHeight) - { - /** Default implementation: Do nothing */ - } - - public void onParentMove() - { - /** Default implementation: Do nothing */ - } - - public void onMove() - { - /** Default implementation: Do nothing */ - } - - public void elementClicked(int x, int y) - { - /** Default implementation: Do nothing */ - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/components/Image.java b/src/api/java/uristqwerty/gui_craftguide/components/Image.java deleted file mode 100644 index 892a58a82..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/components/Image.java +++ /dev/null @@ -1,24 +0,0 @@ -package uristqwerty.gui_craftguide.components; - -import uristqwerty.gui_craftguide.rendering.TexturedRect; -import uristqwerty.gui_craftguide.texture.Texture; - -public class Image extends GuiElement -{ - private TexturedRect image; - - public Image(int x, int y, int width, int height, Texture texture, int u, int v) - { - super(x, y, width, height); - - image = new TexturedRect(0, 0, width, height, texture, u, v); - } - - @Override - public void draw() - { - render(image); - - super.draw(); - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/components/ScrollBar.java b/src/api/java/uristqwerty/gui_craftguide/components/ScrollBar.java deleted file mode 100644 index 391b64492..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/components/ScrollBar.java +++ /dev/null @@ -1,10 +0,0 @@ -package uristqwerty.gui_craftguide.components; - -public class ScrollBar extends GuiElement -{ - public ScrollBar(int x, int y, int width, int height) - { - super(x, y, width, height); - // TODO Auto-generated constructor stub - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/components/ScrollPane.java b/src/api/java/uristqwerty/gui_craftguide/components/ScrollPane.java deleted file mode 100644 index cfef9a64c..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/components/ScrollPane.java +++ /dev/null @@ -1,13 +0,0 @@ -package uristqwerty.gui_craftguide.components; - -public class ScrollPane extends GuiElement -{ - //private ScrollBar scrollbar; - - public ScrollPane(int x, int y, int width, int height) - { - super(x, y, width, height); - - - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/components/Slider.java b/src/api/java/uristqwerty/gui_craftguide/components/Slider.java deleted file mode 100644 index a2ecf0bb6..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/components/Slider.java +++ /dev/null @@ -1,10 +0,0 @@ -package uristqwerty.gui_craftguide.components; - -public class Slider extends GuiElement -{ - public Slider(int x, int y, int width, int height) - { - super(x, y, width, height); - // TODO Auto-generated constructor stub - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/components/Window.java b/src/api/java/uristqwerty/gui_craftguide/components/Window.java deleted file mode 100644 index 035dfe2dc..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/components/Window.java +++ /dev/null @@ -1,177 +0,0 @@ -package uristqwerty.gui_craftguide.components; - -import java.util.EnumMap; -import java.util.Map; - -import uristqwerty.CraftGuide.client.ui.GuiRenderer; -import uristqwerty.gui_craftguide.Rect; -import uristqwerty.gui_craftguide.rendering.Renderable; -import uristqwerty.gui_craftguide.texture.Texture; - -public class Window extends GuiElement -{ - public enum Layer - { - MAIN, - POPUP, - TOOLTIP, - } - - private GuiRenderer renderer; - private boolean mousePressed; - private Map layers = new EnumMap(Layer.class); - - private int lastMouseX, lastMouseY; - private int centerX, centerY; - private int maxWidth, maxHeight; - private boolean centred = false; - - public Window(int x, int y, int width, int height, GuiRenderer renderer) - { - super(x, y, width, height); - - this.renderer = renderer; - } - - public void centerOn(int centerX, int centerY) - { - centred = true; - this.centerX = centerX; - this.centerY = centerY; - setPosition(centerX - (bounds.width() / 2), centerY - (bounds.height() / 2)); - } - - @Override - public void render(Renderable renderable, int xOffset, int yOffset) - { - renderer.render(renderable, xOffset + bounds.x(), yOffset + bounds.y()); - } - - @Override - public void render(Texture texture, int x, int y, int width, int height) - { - texture.renderRect(renderer, x + bounds.x(), y + bounds.y(), width, height, 0, 0); - } - - public void updateMouse(int x, int y) - { - if(x != lastMouseX || y != lastMouseY) - { - mouseMoved(x, y); - lastMouseX = x; - lastMouseY = y; - } - } - - public void updateMouseState(int x, int y, boolean buttonState) - { - if(mousePressed != buttonState) - { - mousePressed = buttonState; - - if(buttonState) - { - mousePressed(x, y); - GuiElement element = getElementAtPoint(x, y); - - if(element != null) - { - element.elementClicked(x - element.absoluteX(), y - element.absoluteY()); - } - } - else - { - mouseReleased(x, y); - } - } - } - - @Override - public void mousePressed(int x, int y) - { - getLayer(Layer.MAIN).mousePressed(x - bounds.x(), y - bounds.y()); - getLayer(Layer.POPUP).mousePressed(x - bounds.x(), y - bounds.y()); - } - - @Override - public void draw() - { - drawBackground(); - getLayer(Layer.MAIN).draw(); - getLayer(Layer.POPUP).draw(); - getLayer(Layer.TOOLTIP).draw(); - } - - @Override - public GuiElement getElementAtPoint(int x, int y) - { - GuiElement element = null; - - element = getLayer(Layer.POPUP).getElementAtPoint(x - bounds.x(), y - bounds.y()); - - if(element == null) - { - element = getLayer(Layer.MAIN).getElementAtPoint(x - bounds.x(), y - bounds.y()); - } - - return element; - } - - public void setMaxSize(int width, int height) - { - maxWidth = width; - maxHeight = height; - - if(bounds.width() > width || bounds.height() > height) - { - setSize(Math.min(bounds.width(), width), Math.min(bounds.height(), height)); - } - } - - @Override - public GuiElement getLayer(Layer layer) - { - GuiElement element = layers.get(layer); - - if(element == null) - { - element = new GuiElement(new Rect(0, 0, bounds.width(), bounds.height())) - .anchor(AnchorPoint.TOP_LEFT, AnchorPoint.BOTTOM_RIGHT) - .setClickable(false); - layers.put(layer, element); - super.addElement(element); - } - - return element; - } - - @Override - public GuiElement addElement(GuiElement element) - { - addElement(element, Layer.MAIN); - return this; - } - - @Override - public GuiElement setSize(int width, int height) - { - super.setSize(Math.min(width, maxWidth), Math.min(height, maxHeight)); - - if(isCentred()) - { - setPosition(centerX - bounds.width() / 2, centerY - bounds.height() / 2); - } - - return this; - } - - private void addElement(GuiElement element, Layer layer) - { - getLayer(layer).addElement(element); - } - - public boolean isCentred() - { - return centred; - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/editor/Editor.java b/src/api/java/uristqwerty/gui_craftguide/editor/Editor.java deleted file mode 100644 index 6c23064a7..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/editor/Editor.java +++ /dev/null @@ -1,21 +0,0 @@ -package uristqwerty.gui_craftguide.editor; - -import java.util.HashMap; -import java.util.Map; - -import uristqwerty.gui_craftguide.components.GuiElement; - -public class Editor -{ - public static Map> components = new HashMap>(); - - public static void registerComponent(Class component) - { - GuiElementMeta meta = component.getAnnotation(GuiElementMeta.class); - - if(meta != null) - { - components.put(meta.name(), component); - } - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/editor/EditorGui.java b/src/api/java/uristqwerty/gui_craftguide/editor/EditorGui.java deleted file mode 100644 index 5a6df4e86..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/editor/EditorGui.java +++ /dev/null @@ -1,51 +0,0 @@ -package uristqwerty.gui_craftguide.editor; - -import uristqwerty.gui_craftguide.components.DropdownSelector; -import uristqwerty.gui_craftguide.components.Image; -import uristqwerty.gui_craftguide.minecraft.Gui; -import uristqwerty.gui_craftguide.texture.BorderedTexture; -import uristqwerty.gui_craftguide.texture.DynamicTexture; -import uristqwerty.gui_craftguide.texture.SubTexture; -import uristqwerty.gui_craftguide.texture.Texture; -import uristqwerty.gui_craftguide.texture.TextureClip; - -public class EditorGui extends Gui -{ - public TextureDisplay textureDisplay; - public TextureProperties textureProperties; - - public EditorGui(int windowWidth, int windowHeight) - { - super(windowWidth, windowHeight); - - textureDisplay = new TextureDisplay(windowWidth / 3, 20, windowWidth * 2 / 3 - 20, windowHeight - 40); - textureProperties = new TextureProperties(20, 20, windowWidth / 3 - 40, windowHeight - 40); - - setupGui(); - } - - private void setupGui() - { - Texture texture = DynamicTexture.instance("base_image"); - textureProperties.addElement( - new Image(0, 0, textureProperties.width(), textureProperties.height(), - new BorderedTexture( - new Texture[]{ - new TextureClip(texture, 1, 1, 4, 4), - new SubTexture(texture, 6, 1, 64, 4), - new TextureClip(texture, 71, 1, 4, 4), - new SubTexture(texture, 1, 6, 4, 64), - new SubTexture(texture, 6, 6, 64, 64), - new SubTexture(texture, 71, 6, 4, 64), - new TextureClip(texture, 1, 71, 4, 4), - new SubTexture(texture, 6, 71, 64, 4), - new TextureClip(texture, 71, 71, 4, 4), - }, 4), - 0, 0)); - - textureProperties.addElement(new DropdownSelector(10, 10, 60, 20)); - - guiWindow.addElement(textureProperties); - guiWindow.addElement(textureDisplay); - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/editor/GuiElementMeta.java b/src/api/java/uristqwerty/gui_craftguide/editor/GuiElementMeta.java deleted file mode 100644 index 0c87e6e89..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/editor/GuiElementMeta.java +++ /dev/null @@ -1,33 +0,0 @@ -package uristqwerty.gui_craftguide.editor; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE}) -public @interface GuiElementMeta -{ - public String name(); - - @Retention(RetentionPolicy.RUNTIME) - @Target({ElementType.FIELD}) - public @interface GuiElementProperty - { - /** - * The name of this property, as seen in the in-game editor - * and as used when a template is being read from a file or - * written to a file. - */ - public String name(); - - public boolean required() default false; - } - - public @interface EnumMapProperty - { - public Class keyType(); - public Class valueType(); - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/editor/TextureDisplay.java b/src/api/java/uristqwerty/gui_craftguide/editor/TextureDisplay.java deleted file mode 100644 index bf4bfbb4a..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/editor/TextureDisplay.java +++ /dev/null @@ -1,55 +0,0 @@ -package uristqwerty.gui_craftguide.editor; - -import uristqwerty.gui_craftguide.Rect; -import uristqwerty.gui_craftguide.components.GuiElement; -import uristqwerty.gui_craftguide.rendering.Renderable; -import uristqwerty.gui_craftguide.rendering.RendererBase; -import uristqwerty.gui_craftguide.texture.Texture; - -public class TextureDisplay extends GuiElement implements Renderable -{ - private Texture currentTexture; - private Rect textureSize; - - public TextureDisplay(int x, int y, int width, int height) - { - super(x, y, width, height); - textureSize = bounds.rect(); - } - - public TextureDisplay(Rect rect) - { - super(rect); - textureSize = rect; - } - - @Override - public void draw() - { - render(this); - super.draw(); - } - - public void setTexture(Texture texture, Rect size) - { - currentTexture = texture; - textureSize = size; - } - - @Override - public void render(RendererBase renderer, int x, int y) - { - if(currentTexture != null && textureSize != null) - { - renderer.setAlpha(127); - renderer.drawTexturedRect(currentTexture, - x, y, bounds.width(), bounds.height(), - (textureSize.width - bounds.width()) / 2, (textureSize.height - bounds.height()) / 2); - - renderer.setAlpha(256); - renderer.drawTexturedRect(currentTexture, - x + (bounds.width() - textureSize.width) / 2, y + (bounds.height() - textureSize.height) / 2, - textureSize.width, textureSize.height, 0, 0); - } - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/editor/TextureMeta.java b/src/api/java/uristqwerty/gui_craftguide/editor/TextureMeta.java deleted file mode 100644 index e65cc2ccc..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/editor/TextureMeta.java +++ /dev/null @@ -1,26 +0,0 @@ -package uristqwerty.gui_craftguide.editor; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE}) -public @interface TextureMeta -{ - public String name(); - - @Retention(RetentionPolicy.RUNTIME) - @Target({ElementType.FIELD}) - public @interface TextureParameter - { - } - - @Retention(RetentionPolicy.RUNTIME) - @Target({ElementType.FIELD}) - public @interface ListSize - { - public int value(); - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/editor/TextureProperties.java b/src/api/java/uristqwerty/gui_craftguide/editor/TextureProperties.java deleted file mode 100644 index 991969f57..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/editor/TextureProperties.java +++ /dev/null @@ -1,11 +0,0 @@ -package uristqwerty.gui_craftguide.editor; - -import uristqwerty.gui_craftguide.components.GuiElement; - -public class TextureProperties extends GuiElement -{ - public TextureProperties(int x, int y, int width, int height) - { - super(x, y, width, height); - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/minecraft/Gui.java b/src/api/java/uristqwerty/gui_craftguide/minecraft/Gui.java deleted file mode 100644 index 910751d25..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/minecraft/Gui.java +++ /dev/null @@ -1,121 +0,0 @@ -package uristqwerty.gui_craftguide.minecraft; - - -import net.minecraft.client.gui.GuiScreen; - -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; - -import uristqwerty.CraftGuide.client.ui.GuiRenderer; -import uristqwerty.CraftGuide.client.ui.GuiTextInput; -import uristqwerty.gui_craftguide.components.Window; -import uristqwerty.gui_craftguide.rendering.RendererBase; - -public class Gui extends GuiScreen -{ - protected GuiRenderer renderer = (GuiRenderer)RendererBase.instance; - protected Window guiWindow; - private boolean firstFrame = false; - - public Gui(int windowWidth, int windowHeight) - { - super(); - - guiWindow = new Window(0, 0, windowWidth, windowHeight, renderer); - } - - @Override - public void drawScreen(int mouseX, int mouseY, float f) - { - guiWindow.setMaxSize(width, height); - guiWindow.update(); - - if(doesGuiPauseGame()) - { - drawDefaultBackground(); - } - - renderer.startFrame(this); - guiWindow.draw(); - renderer.endFrame(); - firstFrame = false; - } - - @Override - protected void keyTyped(char eventChar, int eventKey) - { - super.keyTyped(eventChar, eventKey); - - if(GuiTextInput.inFocus != null) - { - if(!firstFrame) - { - GuiTextInput.inFocus.onKeyTyped(eventChar, eventKey); - } - } - else if(eventKey == Keyboard.KEY_ESCAPE || eventKey == mc.gameSettings.keyBindInventory.getKeyCode()) - { - mc.thePlayer.closeScreen(); - } - else - { - guiWindow.onKeyTyped(eventChar, eventKey); - } - } - - @Override - public void handleMouseInput() - { - int x = (Mouse.getEventX() * width) / mc.displayWidth; - int y = height - (Mouse.getEventY() * height) / mc.displayHeight - 1; - - if(Mouse.getEventButton() == 0) - { - guiWindow.updateMouseState(x, y, Mouse.getEventButtonState()); - } - else if(Mouse.getEventButton() == -1) - { - guiWindow.updateMouse(x, y); - } - - if(Mouse.getEventDWheel() != 0) - { - guiWindow.scrollWheelTurned(Mouse.getEventDWheel() > 0? -mouseWheelRate() : mouseWheelRate()); - } - } - - @Override - public void handleKeyboardInput() - { - if(Keyboard.getEventKeyState()) - { - if(Keyboard.getEventKey() == Keyboard.KEY_F11) - { - mc.toggleFullscreen(); - return; - } - else - { - keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey()); - } - } - } - - public int mouseWheelRate() - { - return 1; - } - - @Override - public void onGuiClosed() - { - guiWindow.onGuiClosed(); - } - - @Override - public void initGui() - { - super.initGui(); - firstFrame = true; - } -} \ No newline at end of file diff --git a/src/api/java/uristqwerty/gui_craftguide/minecraft/Image.java b/src/api/java/uristqwerty/gui_craftguide/minecraft/Image.java deleted file mode 100644 index 8dfdce6ec..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/minecraft/Image.java +++ /dev/null @@ -1,202 +0,0 @@ -package uristqwerty.gui_craftguide.minecraft; - -import java.awt.image.BufferedImage; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.nio.ByteBuffer; -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; - -import javax.imageio.ImageIO; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.texture.ITextureObject; -import net.minecraft.client.renderer.texture.SimpleTexture; -import net.minecraft.util.ResourceLocation; - -import org.lwjgl.opengl.GL11; - -import uristqwerty.gui_craftguide.rendering.RendererBase; -import uristqwerty.gui_craftguide.texture.Texture; - -public class Image implements Texture -{ - private int texID; - private static Map jarCache = new HashMap(); - private static Map fileCache = new HashMap(); - private static Image err = new Image(-1); - private static boolean needsInit = true; - - public static void initJarTextures() - { - if(needsInit) - { - for(Entry entry: jarCache.entrySet()) - { - Image image = entry.getValue(); - - if(image.texID == -1) - { - ResourceLocation resourceLocation = new ResourceLocation(entry.getKey()); - ITextureObject texture = Minecraft.getMinecraft().getTextureManager().getTexture(resourceLocation); - - if(texture == null) - { - texture = new SimpleTexture(resourceLocation); - Minecraft.getMinecraft().getTextureManager().loadTexture(resourceLocation, texture); - } - - image.texID = texture.getGlTextureId(); - } - } - - needsInit = false; - } - } - - public static Image fromJar(String filename) - { - if(filename == null || filename.trim().isEmpty()) - { - return err; - } - - Image image = jarCache.get(filename); - - if(image == null) - { - image = new Image(-1); - jarCache.put(filename, image); - needsInit = true; - } - - return image; - } - - public static Image fromFile(File directory, String filename) - { - String key; - try - { - key = new File(directory, filename).getCanonicalPath(); - } - catch(IOException e) - { - e.printStackTrace(); - return null; - } - - Image image = fileCache.get(key); - - if(image == null) - { - image = new Image(-1); - fileCache.put(key, image); - } - - if(image.texID == -1) - { - image.texID = LoadImageFile(directory, filename); - } - - return image; - } - - private static int LoadImageFile(File directory, String filename) - { - try - { - int width = 4; - int height = 4; - - InputStream input = new FileInputStream(new File(directory, filename)); - BufferedImage image = ImageIO.read(input); - - while(width < image.getWidth()) - { - width *= 2; - } - - while(height < image.getHeight()) - { - height *= 2; - } - - ByteBuffer pixels = ByteBuffer.allocateDirect(width * height * 4); - - for(int y = 0; y < height; y++) - { - for(int x = 0; x < width; x++) - { - int pixel = (y * width + x) * 4; - - if(x < image.getWidth() && y < image.getHeight()) - { - int rgb = image.getRGB(x, y); - pixels.put(pixel + 0, (byte)((rgb >> 16) & 0xff)); - pixels.put(pixel + 1, (byte)((rgb >> 8) & 0xff)); - pixels.put(pixel + 2, (byte)((rgb >> 0) & 0xff)); - pixels.put(pixel + 3, (byte)((rgb >> 24) & 0xff)); - } - else - { - pixels.put(pixel + 0, (byte)0x7f); - pixels.put(pixel + 1, (byte)0x7f); - pixels.put(pixel + 2, (byte)0x7f); - pixels.put(pixel + 3, (byte)0x7f); - } - } - } - - int texID = GL11.glGenTextures(); - GL11.glBindTexture(GL11.GL_TEXTURE_2D, texID); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); - GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, pixels); - - return texID; - } - catch(IOException e) - { - e.printStackTrace(); - return -1; - } - } - - private Image(int textureID) - { - texID = textureID; - } - - @Override - public void renderRect(RendererBase renderer, int x, int y, int width, int height, int textureX, int textureY) - { - if(texID >= 0) - { - double u = (textureX % 256) / 256.0; - double v = (textureY % 256) / 256.0; - double u2 = ((textureX % 256) + width) / 256.0; - double v2 = ((textureY % 256) + height) / 256.0; - - renderer.setTextureID(texID); - renderer.drawTexturedRect(x, y, width, height, u, v, u2, v2); - } - } - - /** - * Unload the images associated with each Image loaded from a file. - * The Image objects are left behind, but given the texID of -1, so - * that they will be reloaded when next requested. - */ - public static void unloadFileTextures() - { - for(Image image: fileCache.values()) - { - GL11.glDeleteTextures(image.texID); - image.texID = -1; - } - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/minecraft/Text.java b/src/api/java/uristqwerty/gui_craftguide/minecraft/Text.java deleted file mode 100644 index b197a18d0..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/minecraft/Text.java +++ /dev/null @@ -1,52 +0,0 @@ -package uristqwerty.gui_craftguide.minecraft; - -import net.minecraft.client.Minecraft; -import uristqwerty.gui_craftguide.rendering.Renderable; -import uristqwerty.gui_craftguide.rendering.RendererBase; - -public class Text implements Renderable -{ - protected int x, y; - protected String text; - protected int color; - - public Text(int x, int y, String text, int color) - { - this.x = x; - this.y = y; - this.text = text; - this.color = color; - } - public Text(int x, int y, String text) - { - this(x, y, text, 0xff000000); - } - - @Override - public void render(RendererBase renderer, int x, int y) - { - renderer.setColor(color); - renderer.drawText(text, x + this.x, y + this.y); - renderer.setColor(0xffffffff); - } - - public void setText(String text) - { - this.text = text; - } - - public int textHeight() - { - return 8; - } - - public int textWidth() - { - return Minecraft.getMinecraft().fontRenderer.getStringWidth(text); - } - - public static int textWidth(String text) - { - return Minecraft.getMinecraft().fontRenderer.getStringWidth(text); - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/rendering/Renderable.java b/src/api/java/uristqwerty/gui_craftguide/rendering/Renderable.java deleted file mode 100644 index 17f7bc45f..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/rendering/Renderable.java +++ /dev/null @@ -1,6 +0,0 @@ -package uristqwerty.gui_craftguide.rendering; - -public interface Renderable -{ - public void render(RendererBase renderer, int x, int y); -} diff --git a/src/api/java/uristqwerty/gui_craftguide/rendering/RendererBase.java b/src/api/java/uristqwerty/gui_craftguide/rendering/RendererBase.java deleted file mode 100644 index dfd478b78..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/rendering/RendererBase.java +++ /dev/null @@ -1,157 +0,0 @@ -package uristqwerty.gui_craftguide.rendering; - -import org.lwjgl.opengl.GL11; - -import uristqwerty.gui_craftguide.Color; -import uristqwerty.gui_craftguide.texture.Texture; - -/** - * Defines the core functionality required to render GUI components. - */ -public abstract class RendererBase -{ - protected double red; - protected double green; - protected double blue; - protected double alpha; - - protected double redModifier; - protected double greenModifier; - protected double blueModifier; - protected double alphaModifier; - - public static RendererBase instance; - - public abstract void setTextureID(int textureID); - public abstract void drawText(String text, int x, int y); - public abstract void drawTextWithShadow(String text, int x, int y); - - public void resetValues() - { - red = 1.0; - green = 1.0; - blue = 1.0; - alpha = 1.0; - redModifier = 1.0; - greenModifier = 1.0; - blueModifier = 1.0; - alphaModifier = 1.0; - } - - public void drawRect(int x, int y, int width, int height) - { - GL11.glDisable(GL11.GL_DEPTH_TEST); - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(770, 771); - - setGlColor(red, green, blue, alpha); - GL11.glBegin(GL11.GL_QUADS); - GL11.glVertex2i(x, y); - GL11.glVertex2i(x, y + height); - GL11.glVertex2i(x + width, y + height); - GL11.glVertex2i(x + width, y); - GL11.glEnd(); - - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_TEXTURE_2D); - } - - public void drawTexturedRect( - int x, int y, int width, int height, - double u, double v, double u2, double v2) - { - GL11.glDisable(GL11.GL_DEPTH_TEST); - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(770, 771); - - setGlColor(red, green, blue, alpha); - GL11.glBegin(GL11.GL_QUADS); - GL11.glTexCoord2d(u, v); - GL11.glVertex2i(x, y); - - GL11.glTexCoord2d(u, v2); - GL11.glVertex2i(x, y + height); - - GL11.glTexCoord2d(u2, v2); - GL11.glVertex2i(x + width, y + height); - - GL11.glTexCoord2d(u2, v); - GL11.glVertex2i(x + width, y); - GL11.glEnd(); - - GL11.glDisable(GL11.GL_BLEND); - } - - public void drawTexturedRect(Texture texture, - int x, int y, int width, int height, int u, int v) - { - texture.renderRect(this, x, y, width, height, u, v); - } - - public void setColorModifier(double red, double green, double blue, double alpha) - { - redModifier = red; - greenModifier = green; - blueModifier = blue; - alphaModifier = alpha; - } - - public void setColorModifierv(double v[]) - { - redModifier = v[0]; - greenModifier = v[1]; - blueModifier = v[2]; - alphaModifier = v[3]; - } - - public void setColorModifierv(Color color) - { - redModifier = color.red / 255.0; - greenModifier = color.green / 255.0; - blueModifier = color.blue / 255.0; - alphaModifier = color.alpha / 255.0; - } - - public void getColorModifierv(double v[]) - { - v[0] = red; - v[1] = green; - v[2] = blue; - v[3] = alpha; - } - - public void setColorRgb(int colour) - { - setColor((colour >> 16) & 0xff, (colour >> 8) & 0xff, colour & 0xff); - } - - public void setColor(int color) - { - setColor((color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff, (color >> 24) & 0xff); - } - - public void setColor(int red, int green, int blue, int alpha) - { - setColor(red, green, blue); - setAlpha(alpha); - } - - public void setColor(int red, int green, int blue) - { - this.red = red / 255.0; - this.green = green / 255.0; - this.blue = blue / 255.0; - } - - public void setAlpha(int alpha) - { - this.alpha = alpha / 255.0; - } - - public void setGlColor(double red, double green, double blue, double alpha) - { - GL11.glColor4d(red * redModifier, green * greenModifier, blue * blueModifier, alpha * alphaModifier); - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/rendering/TexturedRect.java b/src/api/java/uristqwerty/gui_craftguide/rendering/TexturedRect.java deleted file mode 100644 index 09d90f3c5..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/rendering/TexturedRect.java +++ /dev/null @@ -1,43 +0,0 @@ -package uristqwerty.gui_craftguide.rendering; - -import uristqwerty.gui_craftguide.texture.Texture; - -public class TexturedRect implements Renderable -{ - protected int x, y, width, height, u, v; - protected Texture texture; - - public TexturedRect(int x, int y, int width, int height, Texture texture) - { - this(x, y, width, height, texture, 0, 0); - } - - public TexturedRect(int x, int y, int width, int height, Texture texture, int u, int v) - { - this.x = x; - this.y = y; - this.width = width; - this.height = height; - this.texture = texture; - this.u = u; - this.v = v; - } - - @Override - public void render(RendererBase renderer, int x, int y) - { - renderer.drawTexturedRect(texture, x + this.x, y + this.y, width, height, u, v); - } - - public void moveBy(int xChange, int yChange) - { - x += xChange; - y += yChange; - } - - public void resizeBy(int widthChange, int heightChange) - { - width += widthChange; - height += heightChange; - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/texture/BlankTexture.java b/src/api/java/uristqwerty/gui_craftguide/texture/BlankTexture.java deleted file mode 100644 index d80415288..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/texture/BlankTexture.java +++ /dev/null @@ -1,13 +0,0 @@ -package uristqwerty.gui_craftguide.texture; - -import uristqwerty.gui_craftguide.editor.TextureMeta; -import uristqwerty.gui_craftguide.rendering.RendererBase; - -@TextureMeta(name = "blank") -public class BlankTexture implements Texture -{ - @Override - public void renderRect(RendererBase renderer, int x, int y, int width, int height, int u, int v) - { - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/texture/BorderedTexture.java b/src/api/java/uristqwerty/gui_craftguide/texture/BorderedTexture.java deleted file mode 100644 index a0dd6b069..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/texture/BorderedTexture.java +++ /dev/null @@ -1,80 +0,0 @@ -package uristqwerty.gui_craftguide.texture; - -import uristqwerty.gui_craftguide.editor.TextureMeta; -import uristqwerty.gui_craftguide.editor.TextureMeta.ListSize; -import uristqwerty.gui_craftguide.editor.TextureMeta.TextureParameter; -import uristqwerty.gui_craftguide.rendering.RendererBase; - -@TextureMeta(name = "borderedtexture") -public class BorderedTexture implements Texture -{ - @ListSize(9) - @TextureParameter - public Texture[] textures = new Texture[9]; - - @TextureParameter - public int borderWidth; - - @TextureParameter - public int borderHeight; - - public BorderedTexture() - { - } - - public BorderedTexture(Texture[] textures, int borderWidth) - { - this(textures, borderWidth, borderWidth); - } - - public BorderedTexture(Texture[] textures, int borderWidth, int borderHeight) - { - for(int i = 0; i < Math.min(textures.length, 9); i++) - { - this.textures[i] = textures[i]; - } - - this.borderWidth = borderWidth; - this.borderHeight = borderHeight; - } - - public BorderedTexture(Texture source, int u, int v, int spacing, int centerSize, int borderSize) - { - this(source, u, v, spacing, centerSize, centerSize, borderSize, borderSize); - } - - public BorderedTexture(Texture source, int u, int v, int spacing, int centerWidth, int centerHeight, int borderWidth, int borderHeight) - { - int centerU = u + spacing + borderWidth; - int rightU = u + spacing * 2 + centerWidth + borderWidth; - int centerV = v + spacing + borderHeight; - int bottomV = v + spacing * 2 + centerHeight + borderHeight; - - textures[0] = new TextureClip(source, u, v, borderWidth, borderHeight); - textures[1] = new SubTexture(source, centerU, v, centerWidth, borderHeight); - textures[2] = new TextureClip(source, rightU, v, borderWidth, borderHeight); - textures[3] = new TextureClip(source, u, centerV, borderWidth, centerHeight); - textures[4] = new SubTexture(source, centerU, centerV, centerWidth, centerHeight); - textures[5] = new TextureClip(source, rightU, centerV, borderWidth, centerHeight); - textures[6] = new TextureClip(source, u, bottomV, borderWidth, borderHeight); - textures[7] = new SubTexture(source, centerU, bottomV, centerWidth, borderHeight); - textures[8] = new TextureClip(source, rightU, bottomV, borderWidth, borderHeight); - - this.borderWidth = borderWidth; - this.borderHeight = borderHeight; - } - - @Override - public void renderRect(RendererBase renderer, int x, int y, int width, int height, int u, int v) - { - textures[0].renderRect(renderer, x, y, borderWidth, borderHeight, 0, 0); - textures[1].renderRect(renderer, x + borderWidth, y, width - borderWidth * 2, borderHeight, 0, 0); - textures[2].renderRect(renderer, x + width - borderWidth, y, borderWidth, borderHeight, 0, 0); - textures[3].renderRect(renderer, x, y + borderHeight, borderWidth, height - borderHeight * 2, 0, 0); - textures[4].renderRect(renderer, x + borderWidth, y + borderHeight, width - borderWidth * 2, height - borderHeight * 2, 0, 0); - textures[5].renderRect(renderer, x + width - borderWidth, y + borderHeight, borderWidth, height - borderHeight * 2, 0, 0); - textures[6].renderRect(renderer, x, y + height - borderHeight, borderWidth, borderHeight, 0, 0); - textures[7].renderRect(renderer, x + borderWidth, y + height - borderHeight, width - borderWidth * 2, borderHeight, 0, 0); - textures[8].renderRect(renderer, x + width - borderWidth, y + height - borderHeight, borderWidth, borderHeight, 0, 0); - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/texture/DynamicTexture.java b/src/api/java/uristqwerty/gui_craftguide/texture/DynamicTexture.java deleted file mode 100644 index 7965d72dc..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/texture/DynamicTexture.java +++ /dev/null @@ -1,53 +0,0 @@ -package uristqwerty.gui_craftguide.texture; - -import java.util.HashMap; -import java.util.Map; - -import uristqwerty.gui_craftguide.rendering.RendererBase; - -public class DynamicTexture implements Texture -{ - public Texture mapped; - public final String id; - - private DynamicTexture(String id) - { - this.id = id; - } - - @Override - public void renderRect(RendererBase renderer, int x, int y, int width, int height, int u, int v) - { - if(mapped != null) - { - mapped.renderRect(renderer, x, y, width, height, u, v); - } - } - - private static Map instances = new HashMap(); - - public static Texture instance(String id, Texture mappedTo) - { - DynamicTexture texture = (DynamicTexture)instance(id); - - if(texture != null) - { - texture.mapped = mappedTo; - } - - return texture; - } - - public static Texture instance(String id) - { - DynamicTexture texture = instances.get(id); - - if(texture == null) - { - texture = new DynamicTexture(id); - instances.put(id, texture); - } - - return texture; - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/texture/MultipleTextures.java b/src/api/java/uristqwerty/gui_craftguide/texture/MultipleTextures.java deleted file mode 100644 index 0fc6dfaab..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/texture/MultipleTextures.java +++ /dev/null @@ -1,26 +0,0 @@ -package uristqwerty.gui_craftguide.texture; - -import uristqwerty.gui_craftguide.editor.TextureMeta; -import uristqwerty.gui_craftguide.editor.TextureMeta.TextureParameter; -import uristqwerty.gui_craftguide.rendering.RendererBase; - -@TextureMeta(name = "multipletextures") -public class MultipleTextures implements Texture -{ - @TextureParameter - public Texture[] textures; - - public MultipleTextures(Texture[] textures) - { - this.textures = textures; - } - - @Override - public void renderRect(RendererBase renderer, int x, int y, int width, int height, int u, int v) - { - for(Texture texture: textures) - { - texture.renderRect(renderer, x, y, width, height, u, v); - } - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/texture/OffsetTexture.java b/src/api/java/uristqwerty/gui_craftguide/texture/OffsetTexture.java deleted file mode 100644 index 81e3fdc39..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/texture/OffsetTexture.java +++ /dev/null @@ -1,22 +0,0 @@ -package uristqwerty.gui_craftguide.texture; - -import uristqwerty.gui_craftguide.rendering.RendererBase; - -public class OffsetTexture implements Texture -{ - private final Texture base; - private final int u, v; - - public OffsetTexture(Texture base, int u, int v) - { - this.base = base; - this.u = u; - this.v = v; - } - - @Override - public void renderRect(RendererBase renderer, int x, int y, int width, int height, int u, int v) - { - base.renderRect(renderer, x, y, width, height, u + this.u, v + this.v); - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/texture/SolidColorTexture.java b/src/api/java/uristqwerty/gui_craftguide/texture/SolidColorTexture.java deleted file mode 100644 index 666d24dd8..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/texture/SolidColorTexture.java +++ /dev/null @@ -1,31 +0,0 @@ -package uristqwerty.gui_craftguide.texture; - -import uristqwerty.gui_craftguide.Color; -import uristqwerty.gui_craftguide.editor.TextureMeta; -import uristqwerty.gui_craftguide.editor.TextureMeta.TextureParameter; -import uristqwerty.gui_craftguide.rendering.RendererBase; - -@TextureMeta(name = "solidcolor") -public class SolidColorTexture implements Texture -{ - @TextureParameter - public Color color; - - public SolidColorTexture() - { - } - - public SolidColorTexture(int red, int green, int blue, int alpha) - { - color = new Color(red, green, blue, alpha); - } - - @Override - public void renderRect(RendererBase renderer, int x, int y, int width, int height, int u, int v) - { - renderer.setColor(color.red, color.green, color.blue, color.alpha); - renderer.drawRect(x, y, width, height); - renderer.setColor(255, 255, 255, 255); - } - -} diff --git a/src/api/java/uristqwerty/gui_craftguide/texture/SubTexture.java b/src/api/java/uristqwerty/gui_craftguide/texture/SubTexture.java deleted file mode 100644 index d953b31a5..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/texture/SubTexture.java +++ /dev/null @@ -1,89 +0,0 @@ -package uristqwerty.gui_craftguide.texture; - -import uristqwerty.gui_craftguide.Rect; -import uristqwerty.gui_craftguide.editor.TextureMeta; -import uristqwerty.gui_craftguide.editor.TextureMeta.TextureParameter; -import uristqwerty.gui_craftguide.rendering.RendererBase; - -/** - * Represents a subsection of a larger texture, shifted so that - * the sections's top left corner is at (0, 0). When drawn, loops - * the subsection to form an arbitrarily large virtual texture, to - * fully cover the drawn rectangle. - */ -@TextureMeta(name = "subtexture") -public class SubTexture implements Texture -{ - @TextureParameter - public Texture source; - - @TextureParameter - public Rect rect; - - public SubTexture(Texture source, int u, int v, int width, int height) - { - this.source = source; - this.rect = new Rect(u, v, width, height); - } - - public SubTexture() - { - } - - @Override - public void renderRect(RendererBase renderer, int x, int y, int width, int height, int u, int v) - { - if(rect.width < 1 || rect.height < 1) - { - return; - } - - u = ((u % rect.width) + rect.width) % rect.width; //Properly handle negatives - - if(u + width <= rect.width) - { - renderRectColumn(renderer, x, y, width, height, rect.x + u, v); - } - else - { - if(u != 0) - { - renderRectColumn(renderer, x, y, rect.width - (u % rect.width), height, rect.x + (u % rect.width), v); - } - - int segment_start; - for(segment_start = u; segment_start + rect.width < width; segment_start += rect.width) - { - renderRectColumn(renderer, x + segment_start, y, rect.width, height, rect.x, v); - } - - renderRectColumn(renderer, x + segment_start, y, width - segment_start, height, rect.x, v); - } - } - - private void renderRectColumn(RendererBase renderer, int x, int y, int width, int height, int u, int v) - { - int v1 = (((v % rect.height) + rect.height) % rect.height) + rect.y; - int v2 = v1 + height; - - if(v2 < rect.y + rect.height) - { - source.renderRect(renderer, x, y, width, height, u, v1); - } - else - { - if(v != 0) - { - source.renderRect(renderer, x, y, width, rect.height - (v % rect.height), u, rect.y + (v % rect.height)); - } - - int segment_start; - for(segment_start = v; segment_start + rect.height < height; segment_start += rect.height) - { - source.renderRect(renderer, x, y + segment_start, width, rect.height, u, rect.y); - } - - source.renderRect(renderer, x, y + segment_start, width, height - segment_start, u, rect.y); - } - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/texture/Texture.java b/src/api/java/uristqwerty/gui_craftguide/texture/Texture.java deleted file mode 100644 index cc8663fec..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/texture/Texture.java +++ /dev/null @@ -1,8 +0,0 @@ -package uristqwerty.gui_craftguide.texture; - -import uristqwerty.gui_craftguide.rendering.RendererBase; - -public interface Texture -{ - public void renderRect(RendererBase renderer, int x, int y, int width, int height, int u, int v); -} diff --git a/src/api/java/uristqwerty/gui_craftguide/texture/TextureClip.java b/src/api/java/uristqwerty/gui_craftguide/texture/TextureClip.java deleted file mode 100644 index 8e32b2e52..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/texture/TextureClip.java +++ /dev/null @@ -1,69 +0,0 @@ -package uristqwerty.gui_craftguide.texture; - -import uristqwerty.gui_craftguide.Rect; -import uristqwerty.gui_craftguide.editor.TextureMeta; -import uristqwerty.gui_craftguide.editor.TextureMeta.TextureParameter; -import uristqwerty.gui_craftguide.rendering.RendererBase; - -/** - * Represents a subsection of a larger texture, shifted so that - * the sections's top left corner is at (0, 0). When drawn, only - * draws the portion, if any, of the drawn area that overlaps with - * the subsection. - */ -@TextureMeta(name = "clip") -public class TextureClip implements Texture -{ - @TextureParameter - public Texture source; - - @TextureParameter - public Rect rect; - - public TextureClip(Texture source, int u, int v, int width, int height) - { - this.source = source; - rect = new Rect(u, v, width, height); - } - - public TextureClip(Texture source, Rect rect) - { - this.source = source; - this.rect = rect; - } - - public TextureClip() - { - } - - @Override - public void renderRect(RendererBase renderer, int x, int y, int width, int height, int u, int v) - { - if(u < 0) - { - width += u; - u = 0; - } - - if(u + width > rect.width) - { - width = rect.width - u; - } - - if(v < 0) - { - height += v; - v = 0; - } - - if(v + height > rect.height) - { - height = rect.height - v; - } - - if(width > 0 && height > 0) - { - source.renderRect(renderer, x, y, width, height, u + rect.x, v + rect.y); - } - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/texture/TintedTexture.java b/src/api/java/uristqwerty/gui_craftguide/texture/TintedTexture.java deleted file mode 100644 index 798eb04f2..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/texture/TintedTexture.java +++ /dev/null @@ -1,32 +0,0 @@ -package uristqwerty.gui_craftguide.texture; - -import uristqwerty.gui_craftguide.Color; -import uristqwerty.gui_craftguide.editor.TextureMeta; -import uristqwerty.gui_craftguide.editor.TextureMeta.TextureParameter; -import uristqwerty.gui_craftguide.rendering.RendererBase; - -@TextureMeta(name = "coloredtexture") -public class TintedTexture implements Texture -{ - @TextureParameter - public Texture source; - - @TextureParameter - public Color color; - - private double prev[] = new double[4]; - - @Override - public void renderRect(RendererBase renderer, int x, int y, int width, int height, int u, int v) - { - renderer.getColorModifierv(prev); - renderer.setColorModifier( - prev[0] * (color.red / 255.0), - prev[1] * (color.green / 255.0), - prev[2] * (color.blue / 255.0), - prev[3] * (color.alpha / 255.0)); - - source.renderRect(renderer, x, y, width, height, u, v); - renderer.setColorModifierv(prev); - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/theme/Theme.java b/src/api/java/uristqwerty/gui_craftguide/theme/Theme.java deleted file mode 100644 index ad3447b12..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/theme/Theme.java +++ /dev/null @@ -1,158 +0,0 @@ -package uristqwerty.gui_craftguide.theme; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import net.minecraft.client.Minecraft; -import net.minecraft.util.ResourceLocation; -import uristqwerty.gui_craftguide.minecraft.Image; -import uristqwerty.gui_craftguide.texture.DynamicTexture; -import uristqwerty.gui_craftguide.texture.SolidColorTexture; -import uristqwerty.gui_craftguide.texture.Texture; - -public class Theme -{ - public enum SourceType - { - DIRECTORY, - GENERATED, - STREAM, - } - - private static Texture errorTexture = new SolidColorTexture(255, 0, 255, 255); - - public String id; - public String name; - public String description; - public File fileSource; - public SourceType fileSourceType; - public Map> images = new HashMap>(); - public String loadError = null; - public List dependencies = new ArrayList(); - public Map textures = new HashMap(); - - private static Object[] errorImage = {"builtin", "error", null}; - - public Theme(File location) - { - fileSource = location; - } - - public void setName(String name) - { - this.name = name; - } - - public void setDescription(String description) - { - this.description = description; - } - - public void setID(String id) - { - this.id = id.toLowerCase().replaceAll("[^a-z0-9_-]", ""); - } - - public void setMetadata(String propertyName, String value) - { - if(propertyName.equalsIgnoreCase("id")) - { - setID(value); - } - else if(propertyName.equalsIgnoreCase("name")) - { - setName(value); - } - else if(propertyName.equalsIgnoreCase("description")) - { - setDescription(value); - } - } - - public void addImage(String id, List sources) - { - List converted = new ArrayList(sources.size()); - - for(String source: sources) - { - Object[] o = new Object[]{source.substring(0, source.indexOf(':')), source.substring(source.indexOf(':') + 1), fileSource}; - converted.add(o); - } - - images.put(id, converted); - } - - public void addDependency(String dependency) - { - dependencies.add(dependency); - } - - public void generateTextures() - { - for(String imageID: images.keySet()) - { - ThemeManager.debug(" Loading image '" + imageID + "'"); - Texture texture = null; - - for(Object[] imageFormat: images.get(imageID)) - { - texture = loadImage(imageFormat); - - if(texture != null) - { - break; - } - } - - if(texture == null) - { - texture = loadImage(errorImage); - } - - textures.put(imageID, texture); - } - - for(String id: textures.keySet()) - { - ThemeManager.debug(" Adding texture '" + id + "'. Maps to '" + textures.get(id) + "'"); - DynamicTexture.instance(id, textures.get(id)); - } - } - - private Texture loadImage(Object[] imageFormat) - { - String sourceType = (String)imageFormat[0]; - String source = (String)imageFormat[1]; - - ThemeManager.debug(" Loading " + sourceType + " image '" + source + "'"); - - if(sourceType.equalsIgnoreCase("builtin")) - { - if(source.equalsIgnoreCase("error")) - { - return errorTexture; - } - } - else if(sourceType.equalsIgnoreCase("file-jar") || sourceType.equalsIgnoreCase("resource")) - { - - } - else if(sourceType.equalsIgnoreCase("file") && imageFormat[2] != null) - { - return Image.fromFile((File)imageFormat[2], source); - } - - ThemeManager.debug(" Not found."); - return null; - } - - public void addTexture(String id, Texture texture) - { - textures.put(id, texture); - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/theme/ThemeManager.java b/src/api/java/uristqwerty/gui_craftguide/theme/ThemeManager.java deleted file mode 100644 index da069d9cb..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/theme/ThemeManager.java +++ /dev/null @@ -1,393 +0,0 @@ -package uristqwerty.gui_craftguide.theme; - -import java.io.BufferedReader; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.resources.IResource; -import net.minecraft.client.resources.IResourceManager; -import net.minecraft.util.ResourceLocation; -import uristqwerty.CraftGuide.CraftGuideLog; -import uristqwerty.CraftGuide.client.CraftGuideClient; -import uristqwerty.gui_craftguide.editor.TextureMeta; -import uristqwerty.gui_craftguide.minecraft.Image; -import uristqwerty.gui_craftguide.texture.Texture; -import uristqwerty.gui_craftguide.theme.reader.ThemeReader; - -public class ThemeManager -{ - private ThemeReader xmlReader = new ThemeReader(); - public Map themeList; - public static boolean debugOutput = false; - - public static ThemeManager instance = new ThemeManager(); - public static Theme currentTheme; - public static Map> textureTypes = new HashMap>(); - - public void reload() - { - File themeDir = CraftGuideClient.themeDirectory(); - Image.unloadFileTextures(); - - if(themeDir == null || !themeDir.isDirectory()) - { - return; - } - - Map themes = new HashMap(); - - CraftGuideLog.log("(re)loading themes..."); - - for(File file: themeDir.listFiles()) - { - Theme theme = null; - - if(file.isDirectory()) - { - CraftGuideLog.log(" Trying to load directory: " + file.getName()); - theme = loadDirectory(file); - } - else if(file.getName().toLowerCase().endsWith(".txt")) - { - continue; - } - else - { - CraftGuideLog.log(" Trying to load file: " + file.getName()); - theme = loadFile(file); - } - - if(theme != null) - { - CraftGuideLog.log(" Loaded " + file.getName()); - themes.put(theme.id, theme); - } - else - { - CraftGuideLog.log(" Failed to load " + file.getName()); - } - } - - - - Map validatedThemes = new HashMap(); - List processed = new ArrayList(); - - debug("Validating themes:"); - while(themes.size() > 0) - { - debug(" Looping over unvalidated themes:"); - for(String themeID: themes.keySet()) - { - debug(" Theme '" + themeID + "':"); - Theme theme = themes.get(themeID); - - if(theme.loadError != null) - { - debug(" Already marked as having an error"); - processed.add(themeID); - continue; - } - - boolean hasDependencies = true; - - debug(" Checking dependencies..."); - for(String dependency: theme.dependencies) - { - debug(" Dependency '" + dependency + "'"); - if(themes.containsKey(dependency)) - { - hasDependencies = false; - break; - } - if(!validatedThemes.containsKey(dependency)) - { - theme.loadError = "Dependency '" + dependency + "' missing or unloadable"; - break; - } - else if(validatedThemes.get(dependency).loadError != null) - { - theme.loadError = "Error in dependency '" + dependency + "'"; - break; - } - } - - if(theme.loadError != null) - { - debug(" Dependency error '" + theme.loadError + "'"); - processed.add(themeID); - continue; - } - - if(!hasDependencies) - { - continue; - } - - debug(" All dependencies processed without error. Validating theme..."); - - for(String imageID: theme.images.keySet()) - { - debug(" Checking image sources for image '" + imageID + "'"); - boolean valid = false; - for(Object[] imageSource: theme.images.get(imageID)) - { - debug(" Source '" + imageSource + "'"); - - if(validImage(theme, imageSource, validatedThemes)) - { - valid = true; - break; - } - } - - if(!valid) - { - theme.loadError = "Unable to locate valid source for image '" + imageID + "'"; - break; - } - } - - processed.add(themeID); - } - - if(processed.size() > 0) - { - debug(" " + processed.size() + " themes validated"); - - for(String themeID: processed) - { - validatedThemes.put(themeID, themes.get(themeID)); - themes.remove(themeID); - } - - processed.clear(); - } - else - { - debug(" No themes validated, marking remaining themes as having a cyclic dependency"); - - for(String themeID: themes.keySet()) - { - Theme theme = themes.get(themeID); - theme.loadError = "Possible cyclic dependency"; - validatedThemes.put(themeID, theme); - } - - break; - } - } - - - debug("Result:"); - - for(String themeID: validatedThemes.keySet()) - { - if(validatedThemes.get(themeID).loadError == null) - { - debug(" '" + themeID + "' loaded successfully"); - } - else - { - debug(" '" + themeID + "' failed to load with error \"" + validatedThemes.get(themeID).loadError + "\""); - } - } - - themeList = validatedThemes; - } - - private boolean validImage(Theme theme, Object[] imageSource, Map validatedThemes) - { - debug(" Checking if image exists and is valid..."); - String type = (String)imageSource[0]; - String source = (String)imageSource[1]; - if(type.equalsIgnoreCase("parent-theme")) - { - debug(" Searching for definition in parent theme(s)"); - for(String id: theme.dependencies) - { - debug(" Checking theme '" + id + "'"); - - if(definesImage(validatedThemes.get(id), source, validatedThemes)) - { - return true; - } - } - - debug(" No parent theme defines image."); - return false; - } - else if(type.equalsIgnoreCase("file-jar") || type.equalsIgnoreCase("resource")) - { - debug(" Searching resource packs, Minecraft.jar, and mod jars/zips/dirs for '" + source + "'"); - - } - else if(type.equalsIgnoreCase("file")) - { - debug(" Checking theme location for '" + source + "'"); - - if(theme.fileSourceType == Theme.SourceType.DIRECTORY) - { - return new File((File)imageSource[2], source).isFile(); - } - } - else if(type.equalsIgnoreCase("builtin:")) - { - String builtin = source; - - if(builtin.equalsIgnoreCase("error")) - { - return true; - } - } - - return false; - } - - private boolean definesImage(Theme theme, String sourceID, Map validatedThemes) - { - if(theme.images.containsKey(sourceID)) - { - return true; - } - - for(String id: theme.dependencies) - { - if(definesImage(validatedThemes.get(id), sourceID, validatedThemes)) - { - return true; - } - } - - return false; - } - - private Theme loadDirectory(File dir) - { - for(File file: dir.listFiles()) - { - if(file.getName().startsWith("theme")) - { - CraftGuideLog.log(" Found " + file.getName()); - - if(!file.isDirectory() && file.getName().endsWith(".xml")) - { - - } - - CraftGuideLog.log(" Could not read " + file.getName()); - } - } - - return null; - } - - private Theme loadStream(InputStream stream) - { - Theme theme = xmlReader.read(stream, null); - - if(theme != null) - { - theme.fileSource = null; - theme.fileSourceType = Theme.SourceType.STREAM; - } - - return theme; - } - - private Theme loadFile(File file) - { - return null; - } - - public static void debug(String text) - { - if(debugOutput) - { - CraftGuideLog.log(text, true); - } - } - - public Theme buildTheme(String string) - { - debug("Building theme '" + string + "':"); - Theme theme = themeList.get(string); - - if(theme == null) - { - debug(" Could not find theme."); - return null; - } - - Theme combined = new Theme(null); - debug(" Merging..."); - merge(combined, theme); - combined.id = "[built-theme:" + string + "]"; - combined.fileSourceType = Theme.SourceType.GENERATED; - combined.description = "Internal Theme that is a combination of the currently selected theme and all of its prerequisites."; - - debug(" Generating textures..."); - combined.generateTextures(); - - return combined; - } - - private void merge(Theme combined, Theme theme) - { - debug(" Handling dependencies:"); - for(String dependency: theme.dependencies) - { - debug(" Dependency '" + dependency + "'"); - if(!combined.dependencies.contains(dependency)) - { - Theme dep = themeList.get(dependency); - - if(dep != null) - { - debug(" Not merged yet. Merging... ["); - merge(combined, dep); - debug(" ] finished merging '" + dependency + "'"); - } - else - { - debug(" Not merged yet. Could not find theme, though."); - } - } - else - { - debug(" Already merged."); - } - } - - debug(" Merging:"); - if(combined.dependencies.contains(theme.id)) - { - debug(" Already merged, skipping."); - return; - } - - debug(" Not already merged. adding images and textures."); - combined.dependencies.add(theme.id); - combined.images.putAll(theme.images); - combined.textures.putAll(theme.textures); - } - - public static void addTextureType(Class textureClass) - { - TextureMeta meta = textureClass.getAnnotation(TextureMeta.class); - - if(meta != null) - { - textureTypes.put(meta.name().toLowerCase(), textureClass); - } - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/theme/reader/ColorTemplate.java b/src/api/java/uristqwerty/gui_craftguide/theme/reader/ColorTemplate.java deleted file mode 100644 index 154cccde3..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/theme/reader/ColorTemplate.java +++ /dev/null @@ -1,80 +0,0 @@ -package uristqwerty.gui_craftguide.theme.reader; - -import org.xml.sax.Attributes; - -import uristqwerty.gui_craftguide.Color; -import uristqwerty.gui_craftguide.theme.Theme; - -public class ColorTemplate implements ValueTemplate -{ - public int red = 255, green = 255, blue = 255, alpha = 255; - - @Override - public void startElement(Theme theme, String name, Attributes attributes) - { - for(int i = 0; i < attributes.getLength(); i++) - { - if(attributes.getLocalName(i).equalsIgnoreCase("red")) - { - red = num(attributes.getValue(i)); - } - else if(attributes.getLocalName(i).equalsIgnoreCase("green")) - { - green = num(attributes.getValue(i)); - } - else if(attributes.getLocalName(i).equalsIgnoreCase("blue")) - { - blue = num(attributes.getValue(i)); - } - else if(attributes.getLocalName(i).equalsIgnoreCase("alpha")) - { - alpha = num(attributes.getValue(i)); - } - } - } - - @Override - public void characters(Theme theme, char[] chars, int start, int length) - { - } - - @Override - public ElementHandler getSubElement(String name, Attributes attributes) - { - return NullElement.instance; - } - - @Override - public void endElement(Theme theme, String name) - { - } - - @Override - public void endSubElement(Theme theme, ElementHandler handler, String name) - { - } - - private int num(String value) - { - try - { - return Integer.parseInt(value); - } - catch(NumberFormatException e) - { - return 0; - } - } - - @Override - public Class valueType() - { - return Color.class; - } - - @Override - public Object getValue() - { - return new Color(red, green, blue, alpha); - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/theme/reader/DependencyElement.java b/src/api/java/uristqwerty/gui_craftguide/theme/reader/DependencyElement.java deleted file mode 100644 index 4ef11d259..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/theme/reader/DependencyElement.java +++ /dev/null @@ -1,36 +0,0 @@ -package uristqwerty.gui_craftguide.theme.reader; - -import org.xml.sax.Attributes; - -import uristqwerty.gui_craftguide.theme.Theme; - -public class DependencyElement implements ElementHandler -{ - - @Override - public void startElement(Theme theme, String name, Attributes attributes) - { - } - - @Override - public void characters(Theme theme, char[] chars, int start, int length) - { - theme.addDependency(String.valueOf(chars, start, length).trim()); - } - - @Override - public ElementHandler getSubElement(String name, Attributes attributes) - { - return NullElement.instance; - } - - @Override - public void endElement(Theme theme, String name) - { - } - - @Override - public void endSubElement(Theme theme, ElementHandler handler, String name) - { - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/theme/reader/ElementHandler.java b/src/api/java/uristqwerty/gui_craftguide/theme/reader/ElementHandler.java deleted file mode 100644 index 964d47b2a..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/theme/reader/ElementHandler.java +++ /dev/null @@ -1,14 +0,0 @@ -package uristqwerty.gui_craftguide.theme.reader; - -import org.xml.sax.Attributes; - -import uristqwerty.gui_craftguide.theme.Theme; - -public interface ElementHandler -{ - public void startElement(Theme theme, String name, Attributes attributes); - public void characters(Theme theme, char[] chars, int start, int length); - public ElementHandler getSubElement(String name, Attributes attributes); - public void endElement(Theme theme, String name); - public void endSubElement(Theme theme, ElementHandler handler, String name); -} diff --git a/src/api/java/uristqwerty/gui_craftguide/theme/reader/GenericHandler.java b/src/api/java/uristqwerty/gui_craftguide/theme/reader/GenericHandler.java deleted file mode 100644 index 0b9122558..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/theme/reader/GenericHandler.java +++ /dev/null @@ -1,69 +0,0 @@ -package uristqwerty.gui_craftguide.theme.reader; - -import java.util.HashMap; -import java.util.Map; - -import org.xml.sax.Attributes; - -import uristqwerty.gui_craftguide.theme.Theme; - -public class GenericHandler implements ElementHandler -{ - private Map handlers = new HashMap(); - - public GenericHandler(Object... elements)//May throw IndexOutOfBoundsException or ClassCastException on bad data - { - for(int i = 0; i < elements.length; i += 2) - { - handlers.put(((String)elements[i]).toLowerCase(), elements[i + 1]); - } - } - - @Override - public ElementHandler getSubElement(String name, Attributes attributes) - { - Object handler = handlers.get(name.toLowerCase()); - - if(handler instanceof ElementHandler) - { - return (ElementHandler)handler; - } - else if(handler instanceof Class && ElementHandler.class.isAssignableFrom((Class)handler)) - { - try - { - return ((Class)handler).newInstance(); - } - catch(InstantiationException e) - { - e.printStackTrace(); - } - catch(IllegalAccessException e) - { - e.printStackTrace(); - } - } - - return NullElement.instance; - } - - @Override - public void startElement(Theme theme, String name, Attributes attributes) - { - } - - @Override - public void characters(Theme theme, char[] chars, int start, int length) - { - } - - @Override - public void endElement(Theme theme, String name) - { - } - - @Override - public void endSubElement(Theme theme, ElementHandler handler, String name) - { - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/theme/reader/ImageElement.java b/src/api/java/uristqwerty/gui_craftguide/theme/reader/ImageElement.java deleted file mode 100644 index 524e17e30..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/theme/reader/ImageElement.java +++ /dev/null @@ -1,62 +0,0 @@ -package uristqwerty.gui_craftguide.theme.reader; - -import java.util.ArrayList; -import java.util.List; - -import org.xml.sax.Attributes; - -import uristqwerty.gui_craftguide.theme.Theme; - -public class ImageElement implements ElementHandler -{ - private String id; - private List sources = new ArrayList(); - - @Override - public void startElement(Theme theme, String name, Attributes attributes) - { - for(int i = 0; i< attributes.getLength(); i++) - { - if(attributes.getLocalName(i).equalsIgnoreCase("id")) - { - id = attributes.getValue(i).toLowerCase().replaceAll("[^a-z0-9_-]", ""); - } - } - } - - @Override - public ElementHandler getSubElement(String name, Attributes attributes) - { - if(name.equalsIgnoreCase("source")) - { - return new ImageSourceElement(); - } - - return NullElement.instance; - } - - @Override - public void characters(Theme theme, char[] chars, int start, int length) - { - } - - @Override - public void endElement(Theme theme, String name) - { - if(id == null || id.isEmpty()) - { - return; - } - - theme.addImage(id, sources); - } - - @Override - public void endSubElement(Theme theme, ElementHandler handler, String name) - { - if(handler instanceof ImageSourceElement) - { - sources.add(((ImageSourceElement)handler).getSource()); - } - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/theme/reader/ImageSourceElement.java b/src/api/java/uristqwerty/gui_craftguide/theme/reader/ImageSourceElement.java deleted file mode 100644 index c2fc2884e..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/theme/reader/ImageSourceElement.java +++ /dev/null @@ -1,50 +0,0 @@ -package uristqwerty.gui_craftguide.theme.reader; - -import org.xml.sax.Attributes; - -import uristqwerty.gui_craftguide.theme.Theme; - -public class ImageSourceElement implements ElementHandler -{ - private String type = ""; /*file (relative to theme), jar, mcdir, image (other image already loaded)*/ - private String path = ""; - - public String getSource() - { - return type + ":" + path; - } - - @Override - public ElementHandler getSubElement(String name, Attributes attributes) - { - return NullElement.instance; - } - - @Override - public void startElement(Theme theme, String name, Attributes attributes) - { - for(int i = 0; i < attributes.getLength(); i++) - { - if(attributes.getLocalName(i).equalsIgnoreCase("type")) - { - type = attributes.getValue(i); - } - } - } - - @Override - public void characters(Theme theme, char[] chars, int start, int length) - { - path = String.valueOf(chars, start, length).trim(); - } - - @Override - public void endElement(Theme theme, String name) - { - } - - @Override - public void endSubElement(Theme theme, ElementHandler handler, String name) - { - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/theme/reader/IntegerElement.java b/src/api/java/uristqwerty/gui_craftguide/theme/reader/IntegerElement.java deleted file mode 100644 index 0eab62d5f..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/theme/reader/IntegerElement.java +++ /dev/null @@ -1,56 +0,0 @@ -package uristqwerty.gui_craftguide.theme.reader; - -import org.xml.sax.Attributes; - -import uristqwerty.gui_craftguide.theme.Theme; - -public class IntegerElement implements ValueTemplate -{ - Integer value = 0; - - @Override - public void startElement(Theme theme, String name, Attributes attributes) - { - } - - @Override - public void characters(Theme theme, char[] chars, int start, int length) - { - try - { - value = Integer.parseInt(String.valueOf(chars, start, length)); - } - catch(NumberFormatException e) - { - } - } - - @Override - public ElementHandler getSubElement(String name, Attributes attributes) - { - return NullElement.instance; - } - - @Override - public void endElement(Theme theme, String name) - { - } - - @Override - public void endSubElement(Theme theme, ElementHandler handler, String name) - { - } - - @Override - public Class valueType() - { - return Integer.class; - } - - @Override - public Object getValue() - { - return value; - } - -} diff --git a/src/api/java/uristqwerty/gui_craftguide/theme/reader/ListTemplate.java b/src/api/java/uristqwerty/gui_craftguide/theme/reader/ListTemplate.java deleted file mode 100644 index f85370dea..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/theme/reader/ListTemplate.java +++ /dev/null @@ -1,89 +0,0 @@ -package uristqwerty.gui_craftguide.theme.reader; - -import java.lang.reflect.Array; -import java.util.ArrayList; - -import org.xml.sax.Attributes; - -import uristqwerty.gui_craftguide.theme.Theme; - -public class ListTemplate implements ValueTemplate -{ - private int size = -1; - private ArrayList list = new ArrayList(); - private Class type; - public Object result; - - public ListTemplate(Class type) - { - this.type = type; - } - - public ListTemplate(Class type, int size) - { - this.type = type; - this.size = size; - } - - @Override - public void startElement(Theme theme, String name, Attributes attributes) - { - } - - @Override - public void characters(Theme theme, char[] chars, int start, int length) - { - } - - @Override - public ElementHandler getSubElement(String name, Attributes attributes) - { - ValueTemplate t = ValueType.getTemplate(type.getComponentType()); - - if(t != null) - { - return t; - } - else - { - return NullElement.instance; - } - } - - @Override - public void endElement(Theme theme, String name) - { - if(size == -1) - { - size = list.size(); - } - - result = Array.newInstance(type.getComponentType(), size); - - for(int i = 0; i < Math.min(size, list.size()); i++) - { - Array.set(result, i, list.get(i)); - } - } - - @Override - public void endSubElement(Theme theme, ElementHandler handler, String name) - { - if(handler instanceof ValueTemplate) - { - list.add(((ValueTemplate)handler).getValue()); - } - } - - @Override - public Class valueType() - { - return type; - } - - @Override - public Object getValue() - { - return result; - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/theme/reader/MetadataProperty.java b/src/api/java/uristqwerty/gui_craftguide/theme/reader/MetadataProperty.java deleted file mode 100644 index 7e21de1c3..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/theme/reader/MetadataProperty.java +++ /dev/null @@ -1,43 +0,0 @@ -package uristqwerty.gui_craftguide.theme.reader; - -import org.xml.sax.Attributes; - -import uristqwerty.gui_craftguide.theme.Theme; - -public class MetadataProperty implements ElementHandler -{ - private String propertyName; - - public MetadataProperty(String property) - { - propertyName = property; - } - - @Override - public void characters(Theme theme, char[] chars, int start, int length) - { - String value = String.valueOf(chars, start, length).trim(); - theme.setMetadata(propertyName, value); - } - - @Override - public ElementHandler getSubElement(String name, Attributes attributes) - { - return NullElement.instance; - } - - @Override - public void startElement(Theme theme, String name, Attributes attributes) - { - } - - @Override - public void endElement(Theme theme, String name) - { - } - - @Override - public void endSubElement(Theme theme, ElementHandler handler, String name) - { - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/theme/reader/NullElement.java b/src/api/java/uristqwerty/gui_craftguide/theme/reader/NullElement.java deleted file mode 100644 index 966416def..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/theme/reader/NullElement.java +++ /dev/null @@ -1,36 +0,0 @@ -package uristqwerty.gui_craftguide.theme.reader; - -import org.xml.sax.Attributes; - -import uristqwerty.gui_craftguide.theme.Theme; - -public class NullElement implements ElementHandler -{ - public static NullElement instance = new NullElement(); - - @Override - public ElementHandler getSubElement(String name, Attributes attributes) - { - return this; - } - - @Override - public void startElement(Theme theme, String name, Attributes attributes) - { - } - - @Override - public void characters(Theme theme, char[] chars, int start, int length) - { - } - - @Override - public void endElement(Theme theme, String name) - { - } - - @Override - public void endSubElement(Theme theme, ElementHandler handler, String name) - { - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/theme/reader/RectTemplate.java b/src/api/java/uristqwerty/gui_craftguide/theme/reader/RectTemplate.java deleted file mode 100644 index d1cd597b9..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/theme/reader/RectTemplate.java +++ /dev/null @@ -1,80 +0,0 @@ -package uristqwerty.gui_craftguide.theme.reader; - -import org.xml.sax.Attributes; - -import uristqwerty.gui_craftguide.Rect; -import uristqwerty.gui_craftguide.theme.Theme; - -public class RectTemplate implements ValueTemplate -{ - public int x, y, width, height; - - @Override - public void startElement(Theme theme, String name, Attributes attributes) - { - for(int i = 0; i < attributes.getLength(); i++) - { - if(attributes.getLocalName(i).equalsIgnoreCase("x")) - { - x = num(attributes.getValue(i)); - } - else if(attributes.getLocalName(i).equalsIgnoreCase("y")) - { - y = num(attributes.getValue(i)); - } - else if(attributes.getLocalName(i).equalsIgnoreCase("width")) - { - width = num(attributes.getValue(i)); - } - else if(attributes.getLocalName(i).equalsIgnoreCase("height")) - { - height = num(attributes.getValue(i)); - } - } - } - - @Override - public void characters(Theme theme, char[] chars, int start, int length) - { - } - - @Override - public ElementHandler getSubElement(String name, Attributes attributes) - { - return NullElement.instance; - } - - @Override - public void endElement(Theme theme, String name) - { - } - - @Override - public void endSubElement(Theme theme, ElementHandler handler, String name) - { - } - - private int num(String value) - { - try - { - return Integer.parseInt(value); - } - catch(NumberFormatException e) - { - return 0; - } - } - - @Override - public Class valueType() - { - return Rect.class; - } - - @Override - public Object getValue() - { - return new Rect(x, y, width, height); - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/theme/reader/TextureElement.java b/src/api/java/uristqwerty/gui_craftguide/theme/reader/TextureElement.java deleted file mode 100644 index 0b4ba40bd..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/theme/reader/TextureElement.java +++ /dev/null @@ -1,145 +0,0 @@ -package uristqwerty.gui_craftguide.theme.reader; - -import java.lang.reflect.Field; - -import org.xml.sax.Attributes; - -import uristqwerty.CraftGuide.CraftGuideLog; -import uristqwerty.gui_craftguide.editor.TextureMeta.TextureParameter; -import uristqwerty.gui_craftguide.texture.DynamicTexture; -import uristqwerty.gui_craftguide.texture.Texture; -import uristqwerty.gui_craftguide.theme.Theme; -import uristqwerty.gui_craftguide.theme.ThemeManager; - -public class TextureElement implements ValueTemplate -{ - private String type; - private String id; - - private Texture texture = null; - - @Override - public void startElement(Theme theme, String name, Attributes attributes) - { - for(int i = 0; i < attributes.getLength(); i++) - { - if(attributes.getLocalName(i).equalsIgnoreCase("type")) - { - type = attributes.getValue(i); - Class textureClass = ThemeManager.textureTypes.get(type.toLowerCase()); - - if(textureClass != null) - { - try - { - texture = textureClass.newInstance(); - } - catch(InstantiationException e) - { - CraftGuideLog.log(e); - } - catch(IllegalAccessException e) - { - CraftGuideLog.log(e); - } - } - } - else if(attributes.getLocalName(i).equalsIgnoreCase("id")) - { - id = attributes.getValue(i); - } - else if(attributes.getLocalName(i).equalsIgnoreCase("sourceid")) - { - texture = DynamicTexture.instance(attributes.getValue(i)); - } - } - } - - @Override - public void characters(Theme theme, char[] chars, int start, int length) - { - } - - @Override - public ElementHandler getSubElement(String name, Attributes attributes) - { - if(texture != null) - { - for(Field field: texture.getClass().getFields()) - { - if(field.getName().equalsIgnoreCase(name)) - { - ValueTemplate template = ValueType.getTemplate(field); - - if(template != null) - { - return template; - } - } - } - } - - return NullElement.instance; - } - - @Override - public void endSubElement(Theme theme, ElementHandler handler, String name) - { - if(texture != null) - { - for(Field field: texture.getClass().getFields()) - { - if(field.getName().equalsIgnoreCase(name)) - { - if(field.isAnnotationPresent(TextureParameter.class)) - { - try - { - if(handler instanceof ValueTemplate) - { - ValueTemplate template = (ValueTemplate)handler; - - if(field.getType().isAssignableFrom(template.valueType()) || - (field.getType().equals(int.class) && template.valueType().equals(Integer.class))) - { - field.set(texture, template.getValue()); - } - } - } - catch(IllegalArgumentException e) - { - CraftGuideLog.log(e); - } - catch(IllegalAccessException e) - { - CraftGuideLog.log(e); - } - } - - break; - } - } - } - } - - @Override - public void endElement(Theme theme, String name) - { - if(id != null) - { - theme.addTexture(id, texture); - } - } - - @Override - public Class valueType() - { - return Texture.class; - } - - @Override - public Object getValue() - { - return texture; - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/theme/reader/TextureSourceElement.java b/src/api/java/uristqwerty/gui_craftguide/theme/reader/TextureSourceElement.java deleted file mode 100644 index 9d70982b1..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/theme/reader/TextureSourceElement.java +++ /dev/null @@ -1,50 +0,0 @@ -package uristqwerty.gui_craftguide.theme.reader; - -import org.xml.sax.Attributes; - -import uristqwerty.gui_craftguide.texture.DynamicTexture; -import uristqwerty.gui_craftguide.texture.Texture; -import uristqwerty.gui_craftguide.theme.Theme; - -public class TextureSourceElement implements ElementHandler -{ - public boolean recursive = false; - public Texture source; - - @Override - public void startElement(Theme theme, String name, Attributes attributes) - { - // TODO Auto-generated method stub - - } - - @Override - public void characters(Theme theme, char[] chars, int start, int length) - { - if(!recursive) - { - source = DynamicTexture.instance(String.valueOf(chars, start, length)); - } - } - - @Override - public ElementHandler getSubElement(String name, Attributes attributes) - { - return NullElement.instance; - } - - @Override - public void endElement(Theme theme, String name) - { - // TODO Auto-generated method stub - - } - - @Override - public void endSubElement(Theme theme, ElementHandler handler, String name) - { - // TODO Auto-generated method stub - - } - -} diff --git a/src/api/java/uristqwerty/gui_craftguide/theme/reader/ThemeReader.java b/src/api/java/uristqwerty/gui_craftguide/theme/reader/ThemeReader.java deleted file mode 100644 index 76431d9db..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/theme/reader/ThemeReader.java +++ /dev/null @@ -1,141 +0,0 @@ -package uristqwerty.gui_craftguide.theme.reader; - -import java.io.File; -import java.io.InputStream; -import java.util.LinkedList; - -import org.xml.sax.Attributes; -import org.xml.sax.ContentHandler; -import org.xml.sax.InputSource; -import org.xml.sax.Locator; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; -import org.xml.sax.helpers.XMLReaderFactory; - -import uristqwerty.CraftGuide.CraftGuideLog; -import uristqwerty.gui_craftguide.theme.Theme; - -public class ThemeReader implements ContentHandler -{ - private static ElementHandler metadataElement = new GenericHandler( - "id", new MetadataProperty("id"), - "name", new MetadataProperty("name"), - "description", new MetadataProperty("description"), - "dependency", DependencyElement.class); - - private static ElementHandler themeElement = new GenericHandler( - "metadata", metadataElement, - "image", ImageElement.class, - "texture", TextureElement.class); - - private static ElementHandler rootElement = new GenericHandler( - "theme", themeElement); - - private LinkedList handlerStack = new LinkedList(); - - private Theme theme; - - public Theme read(InputStream source, File themeDir) - { - theme = new Theme(themeDir); - handlerStack.add(rootElement); - - try - { - XMLReader reader = XMLReaderFactory.createXMLReader(); - reader.setContentHandler(this); - reader.parse(new InputSource(source)); - } - catch(Exception e) - { - e.printStackTrace(); - CraftGuideLog.log(e); - return null; - } - - handlerStack.clear(); - return theme; - } - - @Override - public void startDocument() throws SAXException - { - } - - @Override - public void endDocument() throws SAXException - { - } - - @Override - public void characters(char[] chars, int start, int length) throws SAXException - { - if(handlerStack.peek() != null) - { - handlerStack.peek().characters(theme, chars, start, length); - } - } - - @Override - public void startElement(String uri, String name, String qName, Attributes attributes) throws SAXException - { - if(handlerStack.peek() == null) - { - CraftGuideLog.log("CraftGuide: Error loading theme file. Stack is null at element '" + name + "'", true); - } - else - { - ElementHandler h = handlerStack.peek().getSubElement(name, attributes); - handlerStack.push(h != null? h : NullElement.instance); - handlerStack.peek().startElement(theme, name, attributes); - } - } - - @Override - public void endElement(String uri, String name, String qName) throws SAXException - { - ElementHandler handler = handlerStack.pop(); - handler.endElement(theme, name); - - if(handlerStack.peek() != null) - { - handlerStack.peek().endSubElement(theme, handler, name); - } - } - - @Override - public void processingInstruction(String arg0, String arg1) throws SAXException - { - // TODO Auto-generated method stub - } - - @Override - public void setDocumentLocator(Locator locator) - { - // TODO Auto-generated method stub - } - - @Override - public void skippedEntity(String name) throws SAXException - { - // TODO Auto-generated method stub - } - - @Override - public void ignorableWhitespace(char[] chars, int start, int length) throws SAXException - { - // TODO Auto-generated method stub - } - - @Override - public void startPrefixMapping(String prefix, String uri) throws SAXException - { - // TODO Auto-generated method stub - } - - @Override - public void endPrefixMapping(String prefix) throws SAXException - { - // TODO Auto-generated method stub - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/theme/reader/ValueTemplate.java b/src/api/java/uristqwerty/gui_craftguide/theme/reader/ValueTemplate.java deleted file mode 100644 index da1abf72b..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/theme/reader/ValueTemplate.java +++ /dev/null @@ -1,7 +0,0 @@ -package uristqwerty.gui_craftguide.theme.reader; - -public interface ValueTemplate extends ElementHandler -{ - public Class valueType(); - public Object getValue(); -} diff --git a/src/api/java/uristqwerty/gui_craftguide/theme/reader/ValueType.java b/src/api/java/uristqwerty/gui_craftguide/theme/reader/ValueType.java deleted file mode 100644 index eb2845304..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/theme/reader/ValueType.java +++ /dev/null @@ -1,48 +0,0 @@ -package uristqwerty.gui_craftguide.theme.reader; - -import java.lang.reflect.Field; - -import uristqwerty.gui_craftguide.Color; -import uristqwerty.gui_craftguide.Rect; -import uristqwerty.gui_craftguide.editor.TextureMeta.ListSize; -import uristqwerty.gui_craftguide.texture.Texture; - -public class ValueType -{ - public static ValueTemplate getTemplate(Field field) - { - if(field.getType().isArray() && field.isAnnotationPresent(ListSize.class)) - { - ListSize size = field.getAnnotation(ListSize.class); - return new ListTemplate(field.getType(), size.value()); - } - - return getTemplate(field.getType()); - } - - public static ValueTemplate getTemplate(Class type) - { - if(type.equals(Color.class)) - { - return new ColorTemplate(); - } - else if(type.equals(Rect.class)) - { - return new RectTemplate(); - } - else if(type.equals(Texture.class)) - { - return new TextureElement(); - } - else if(type.equals(int.class) || type.equals(Integer.class)) - { - return new IntegerElement(); - } - else if(type.isArray()) - { - return new ListTemplate(type); - } - - return null; - } -} diff --git a/src/api/java/uristqwerty/gui_craftguide/theme/writer/ThemeWriter.java b/src/api/java/uristqwerty/gui_craftguide/theme/writer/ThemeWriter.java deleted file mode 100644 index a44beca8c..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/theme/writer/ThemeWriter.java +++ /dev/null @@ -1,19 +0,0 @@ -package uristqwerty.gui_craftguide.theme.writer; - -import java.io.OutputStream; - -import uristqwerty.gui_craftguide.theme.Theme; - -public interface ThemeWriter -{ - /** - * Writes a Theme to the specified OutputStream. - *

    - * returns true on success, or false if there was any - * sort of failure. - * @param theme - * @param output - * @return - */ - public boolean write(Theme theme, OutputStream output); -} diff --git a/src/api/java/uristqwerty/gui_craftguide/theme/writer/XMLThemeWriter.java b/src/api/java/uristqwerty/gui_craftguide/theme/writer/XMLThemeWriter.java deleted file mode 100644 index a2003dbf7..000000000 --- a/src/api/java/uristqwerty/gui_craftguide/theme/writer/XMLThemeWriter.java +++ /dev/null @@ -1,184 +0,0 @@ -package uristqwerty.gui_craftguide.theme.writer; - -import java.io.IOException; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.util.LinkedList; - -import uristqwerty.gui_craftguide.Rect; -import uristqwerty.gui_craftguide.texture.DynamicTexture; -import uristqwerty.gui_craftguide.texture.TextureClip; -import uristqwerty.gui_craftguide.theme.Theme; - -public class XMLThemeWriter implements ThemeWriter -{ - private class ElementException extends Exception - { - private static final long serialVersionUID = -1106134229546685224L; - } - - private class ElementCloseMismatchException extends ElementException - { - private static final long serialVersionUID = 3826879376987706602L; - } - - private class ElementAttributeCountException extends ElementException - { - private static final long serialVersionUID = 5363934302886278365L; - } - - private LinkedList elementStack = new LinkedList(); - - private OutputStreamWriter output; - private int indentation = 0; - - @Override - public boolean write(Theme theme, OutputStream outputStream) - { - try - { - output = new OutputStreamWriter(outputStream); - - openElement("theme"); - openElement("metadata"); - writeElement("id", theme.id); - writeElement("name", theme.name); - writeElement("description", theme.description); - - for(String dependency: theme.dependencies) - { - writeElement("dependency", dependency); - } - - closeElement("metadata"); - - for(String image: theme.images.keySet()) - { - openElement("image", "id", image); - - for(Object[] source: theme.images.get(image)) - { - writeElement("source", (String)source[0], "type", (String)source[1]); - } - - closeElement("image"); - } - - for(String texture: theme.textures.keySet()) - { - if(theme.textures.get(texture) instanceof TextureClip) - { - TextureClip clip = (TextureClip)theme.textures.get(texture); - openElement("texture", "id", texture, "type", "clip"); - - if(clip.source instanceof DynamicTexture) - { - writeElement("source", ((DynamicTexture)clip.source).id); - } - else - { - //TODO - } - - writeRect(clip.rect); - - closeElement("texture"); - } - } - - closeElement("theme"); - - output.flush(); - - return true; - } - catch(ElementException e) - { - e.printStackTrace(); - } - catch(IOException e) - { - e.printStackTrace(); - } - - return false; - } - - private void writeRect(Rect rect) throws ElementAttributeCountException, IOException - { - writeElement("rect", "", - "x", Integer.toString(rect.x), - "y", Integer.toString(rect.y), - "width", Integer.toString(rect.width), - "height", Integer.toString(rect.height)); - } - - private void writeElement(String elementName, String contents, String... attributes) throws IOException, ElementAttributeCountException - { - indent(); - output.write("<" + elementName + attributes(attributes) + ">" + escape(contents) + "\n"); - } - - private String attributes(String[] attributes) throws ElementAttributeCountException - { - if((attributes.length & 0x1) != 0) - { - throw new ElementAttributeCountException(); - } - - String result = ""; - - for(int i = 0; i < attributes.length; i += 2) - { - result = result + " " + attributes[i] + "=\"" + escape(attributes[i + 1]) + "\""; - } - - return result; - } - - private void openElement(String elementName, String... attributes) throws IOException, ElementAttributeCountException - { - elementStack.push(elementName); - indent(); - output.write("<" + elementName + attributes(attributes) + ">\n"); - - indentation++; - } - - private void closeElement(String elementName) throws ElementCloseMismatchException, IOException - { - if(!elementName.equals(elementStack.pop())) - { - throw new ElementCloseMismatchException(); - } - - indentation--; - indent(); - output.write("\n"); - } - - private void indent() throws IOException - { - for(int i = 0; i < indentation; i++) - { - output.write("\t"); - } - } - - private String escape(String string) - { - if(string == null) - { - return ""; - } - else - { - return string - .replace("&", "&") - .replace("<", "<") - .replace(">", ">") - .replace("'", "'") - .replace("\"", """); - } - } -}