diff --git a/.clang-format b/.clang-format new file mode 100644 index 000000000..d48bed8d6 --- /dev/null +++ b/.clang-format @@ -0,0 +1,130 @@ +--- +AccessModifierOffset: 0 +AlignAfterOpenBracket: BlockIndent +AlignArrayOfStructures: None +AlignConsecutiveAssignments: None +AlignConsecutiveMacros: None +AlignConsecutiveBitFields: None +AlignConsecutiveDeclarations: None +AlignEscapedNewlines: DontAlign +AlignOperands: DontAlign +AlignTrailingComments: false +AllowAllArgumentsOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: Empty +AllowShortCaseLabelsOnASingleLine: false +AllowShortEnumsOnASingleLine: false +AllowShortFunctionsOnASingleLine: Empty +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: MultiLine +AttributeMacros: [] +BinPackArguments: false +BinPackParameters: false +BitFieldColonSpacing: After +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false + BeforeLambdaBody: false + BeforeWhile: false + IndentBraces: false + SplitEmptyFunction: false + SplitEmptyRecord: false + SplitEmptyNamespace: false +BreakAfterJavaFieldAnnotations: true +#BreakArrays: false +BreakBeforeBinaryOperators: All +BreakBeforeBraces: Custom +BreakBeforeConceptDeclarations: true +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: AfterColon +BreakInheritanceList: AfterColon +BreakStringLiterals: true +ColumnLimit: 90 +CompactNamespaces: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: false +DeriveLineEnding: false +DerivePointerAlignment: false +DisableFormat: false # wtf +EmptyLineAfterAccessModifier: Never +EmptyLineBeforeAccessModifier: Always +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: false +ForEachMacros: ["BOOST_FOREACH"] +IfMacros: [] +IncludeBlocks: Regroup +IndentAccessModifiers: false +IndentCaseBlocks: false +IndentCaseLabels: true +IndentExternBlock: Indent +IndentGotoLabels: true +IndentPPDirectives: BeforeHash +#IndentRequiresClause: false +IndentWidth: 4 +IndentWrappedFunctionNames: false +#InsertBraces: false +InsertTrailingCommas: Wrapped +JavaImportGroups: ["java"] +JavaScriptQuotes: Double +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: false +LambdaBodyIndentation: OuterScope +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: All +PackConstructorInitializers: NextLine +PointerAlignment: Left +QualifierAlignment: Left +ReferenceAlignment: Left +ReflowComments: true +#RemoveSemicolon: true +#RequiresClausePosition: OwnLine +#RequiresExpressionIndentation: OuterScope +SeparateDefinitionBlocks: Always +SortIncludes: CaseInsensitive +SortJavaStaticImport: Before +SortUsingDeclarations: true +SpaceAfterCStyleCast: true +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: false +SpaceAroundPointerQualifiers: After +SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: false +SpaceBeforeInheritanceColon: false +SpaceBeforeParens: ControlStatementsExceptControlMacros +SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false +SpacesInAngles: Never +SpacesInCStyleCastParentheses: false +SpacesInConditionalStatement: false +SpacesInContainerLiterals: false +SpacesInLineCommentPrefix: + Minimum: 0 + Maximum: -1 +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: c++20 +StatementAttributeLikeMacros: [] +StatementMacros: [] +TabWidth: 4 +TypenameMacros: [] +UseCRLF: false # wtf +UseTab: Never +WhitespaceSensitiveMacros: ["BOOST_PP_STRINGSIZE"] diff --git a/src/main/java/cofh/api/CoFHAPIProps.java b/src/main/java/cofh/api/CoFHAPIProps.java index 5d21f6369..c3ea0ed99 100644 --- a/src/main/java/cofh/api/CoFHAPIProps.java +++ b/src/main/java/cofh/api/CoFHAPIProps.java @@ -1,11 +1,7 @@ package cofh.api; public class CoFHAPIProps { + private CoFHAPIProps() {} - private CoFHAPIProps() { - - } - - public static final String VERSION = "1.7.10R1.3.1"; - + public static final String VERSION = "1.7.10R1.3.1"; } diff --git a/src/main/java/cofh/api/energy/EnergyStorage.java b/src/main/java/cofh/api/energy/EnergyStorage.java index 25e0126ab..23f70883b 100644 --- a/src/main/java/cofh/api/energy/EnergyStorage.java +++ b/src/main/java/cofh/api/energy/EnergyStorage.java @@ -3,156 +3,141 @@ package cofh.api.energy; import net.minecraft.nbt.NBTTagCompound; /** - * Reference implementation of {@link IEnergyStorage}. Use/extend this or implement your own. + * 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; - protected int energy; - protected int capacity; - protected int maxReceive; - protected int maxExtract; + public EnergyStorage(int capacity) { + this(capacity, capacity, capacity); + } - public EnergyStorage(int capacity) { + public EnergyStorage(int capacity, int maxTransfer) { + this(capacity, maxTransfer, maxTransfer); + } - this(capacity, capacity, capacity); - } + public EnergyStorage(int capacity, int maxReceive, int maxExtract) { + this.capacity = capacity; + this.maxReceive = maxReceive; + this.maxExtract = maxExtract; + } - public EnergyStorage(int capacity, int maxTransfer) { + public EnergyStorage readFromNBT(NBTTagCompound nbt) { + this.energy = nbt.getInteger("Energy"); - this(capacity, maxTransfer, maxTransfer); - } + if (energy > capacity) { + energy = capacity; + } + return this; + } - public EnergyStorage(int capacity, int maxReceive, int maxExtract) { + public NBTTagCompound writeToNBT(NBTTagCompound nbt) { + if (energy < 0) { + energy = 0; + } + nbt.setInteger("Energy", energy); + return nbt; + } - this.capacity = capacity; - this.maxReceive = maxReceive; - this.maxExtract = maxExtract; - } + public void setCapacity(int capacity) { + this.capacity = capacity; - public EnergyStorage readFromNBT(NBTTagCompound nbt) { + if (energy > capacity) { + energy = capacity; + } + } - this.energy = nbt.getInteger("Energy"); + public void setMaxTransfer(int maxTransfer) { + setMaxReceive(maxTransfer); + setMaxExtract(maxTransfer); + } - if (energy > capacity) { - energy = capacity; - } - return this; - } + public void setMaxReceive(int maxReceive) { + this.maxReceive = maxReceive; + } - public NBTTagCompound writeToNBT(NBTTagCompound nbt) { + public void setMaxExtract(int maxExtract) { + this.maxExtract = maxExtract; + } - if (energy < 0) { - energy = 0; - } - nbt.setInteger("Energy", energy); - return nbt; - } + public int getMaxReceive() { + return maxReceive; + } - public void setCapacity(int capacity) { + public int getMaxExtract() { + return maxExtract; + } - this.capacity = capacity; + /** + * 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 (energy > capacity) { - energy = capacity; - } - } + if (this.energy > capacity) { + this.energy = capacity; + } else if (this.energy < 0) { + this.energy = 0; + } + } - public void setMaxTransfer(int maxTransfer) { + /** + * 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; - setMaxReceive(maxTransfer); - setMaxExtract(maxTransfer); - } + if (this.energy > capacity) { + this.energy = capacity; + } else if (this.energy < 0) { + this.energy = 0; + } + } - public void setMaxReceive(int maxReceive) { + /* IEnergyStorage */ + @Override + public int receiveEnergy(int maxReceive, boolean simulate) { + int energyReceived + = Math.min(capacity - energy, Math.min(this.maxReceive, maxReceive)); - this.maxReceive = maxReceive; - } + if (!simulate) { + energy += energyReceived; + } + return energyReceived; + } - public void setMaxExtract(int maxExtract) { + @Override + public int extractEnergy(int maxExtract, boolean simulate) { + int energyExtracted = Math.min(energy, Math.min(this.maxExtract, maxExtract)); - this.maxExtract = maxExtract; - } + if (!simulate) { + energy -= energyExtracted; + } + return energyExtracted; + } - 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; - } + @Override + public int getEnergyStored() { + return energy; + } + @Override + public int getMaxEnergyStored() { + return capacity; + } } diff --git a/src/main/java/cofh/api/energy/IEnergyConnection.java b/src/main/java/cofh/api/energy/IEnergyConnection.java index 301271e5a..79bdaf648 100644 --- a/src/main/java/cofh/api/energy/IEnergyConnection.java +++ b/src/main/java/cofh/api/energy/IEnergyConnection.java @@ -3,19 +3,17 @@ 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. + * 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); - + /** + * Returns TRUE if the TileEntity can connect on a given side. + */ + boolean canConnectEnergy(ForgeDirection from); } diff --git a/src/main/java/cofh/api/energy/IEnergyContainerItem.java b/src/main/java/cofh/api/energy/IEnergyContainerItem.java index 3ef725765..2bd8babd7 100644 --- a/src/main/java/cofh/api/energy/IEnergyContainerItem.java +++ b/src/main/java/cofh/api/energy/IEnergyContainerItem.java @@ -3,50 +3,51 @@ 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}. + * 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); - /** - * 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); - /** - * 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); + /** + * 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/main/java/cofh/api/energy/IEnergyHandler.java b/src/main/java/cofh/api/energy/IEnergyHandler.java index 6a4600a4e..734bc4768 100644 --- a/src/main/java/cofh/api/energy/IEnergyHandler.java +++ b/src/main/java/cofh/api/energy/IEnergyHandler.java @@ -3,55 +3,56 @@ package cofh.api.energy; import net.minecraftforge.common.util.ForgeDirection; /** - * Implement this interface on Tile Entities which should handle energy, generally storing it in one or more internal {@link IEnergyStorage} objects. - *

- * A reference implementation is provided {@link TileEnergyHandler}. + * Implement this interface on Tile Entities 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 IEnergyProvider, IEnergyReceiver { + // merely a convenience interface (remove these methods in 1.8; provided here for + // back-compat via compiler doing things) - // merely a convenience interface (remove these methods in 1.8; provided here for back-compat via compiler doing things) + /** + * Add energy to an IEnergyReceiver, internal distribution is left entirely to the + * IEnergyReceiver. + * + * @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. + */ + @Override + int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate); - /** - * Add energy to an IEnergyReceiver, internal distribution is left entirely to the IEnergyReceiver. - * - * @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. - */ - @Override - int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate); + /** + * Remove energy from an IEnergyProvider, internal distribution is left entirely to + * the IEnergyProvider. + * + * @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. + */ + @Override + int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate); - /** - * Remove energy from an IEnergyProvider, internal distribution is left entirely to the IEnergyProvider. - * - * @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. - */ - @Override - int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate); - - /** - * Returns the amount of energy currently stored. - */ - @Override - int getEnergyStored(ForgeDirection from); - - /** - * Returns the maximum amount of energy that can be stored. - */ - @Override - int getMaxEnergyStored(ForgeDirection from); + /** + * Returns the amount of energy currently stored. + */ + @Override + int getEnergyStored(ForgeDirection from); + /** + * Returns the maximum amount of energy that can be stored. + */ + @Override + int getMaxEnergyStored(ForgeDirection from); } diff --git a/src/main/java/cofh/api/energy/IEnergyProvider.java b/src/main/java/cofh/api/energy/IEnergyProvider.java index 05287b35e..d99793048 100644 --- a/src/main/java/cofh/api/energy/IEnergyProvider.java +++ b/src/main/java/cofh/api/energy/IEnergyProvider.java @@ -3,36 +3,35 @@ package cofh.api.energy; import net.minecraftforge.common.util.ForgeDirection; /** - * Implement this interface on Tile Entities which should provide energy, generally storing it in one or more internal {@link IEnergyStorage} objects. - *

- * A reference implementation is provided {@link TileEnergyHandler}. + * Implement this interface on Tile Entities which should provide energy, generally + * storing it in one or more internal {@link IEnergyStorage} objects.

A reference + * implementation is provided {@link TileEnergyHandler}. * * @author King Lemming * */ public interface IEnergyProvider extends IEnergyConnection { + /** + * Remove energy from an IEnergyProvider, internal distribution is left entirely to + * the IEnergyProvider. + * + * @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); - /** - * Remove energy from an IEnergyProvider, internal distribution is left entirely to the IEnergyProvider. - * - * @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); + /** + * 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/main/java/cofh/api/energy/IEnergyReceiver.java b/src/main/java/cofh/api/energy/IEnergyReceiver.java index c726e09e0..9a344728d 100644 --- a/src/main/java/cofh/api/energy/IEnergyReceiver.java +++ b/src/main/java/cofh/api/energy/IEnergyReceiver.java @@ -3,36 +3,35 @@ package cofh.api.energy; import net.minecraftforge.common.util.ForgeDirection; /** - * Implement this interface on Tile Entities which should receive energy, generally storing it in one or more internal {@link IEnergyStorage} objects. - *

- * A reference implementation is provided {@link TileEnergyHandler}. + * Implement this interface on Tile Entities which should receive energy, generally + * storing it in one or more internal {@link IEnergyStorage} objects.

A reference + * implementation is provided {@link TileEnergyHandler}. * * @author King Lemming * */ public interface IEnergyReceiver extends IEnergyConnection { + /** + * Add energy to an IEnergyReceiver, internal distribution is left entirely to the + * IEnergyReceiver. + * + * @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); - /** - * Add energy to an IEnergyReceiver, internal distribution is left entirely to the IEnergyReceiver. - * - * @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); - - /** - * 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); + /** + * 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/main/java/cofh/api/energy/IEnergyStorage.java b/src/main/java/cofh/api/energy/IEnergyStorage.java index 414b26566..be66f40af 100644 --- a/src/main/java/cofh/api/energy/IEnergyStorage.java +++ b/src/main/java/cofh/api/energy/IEnergyStorage.java @@ -10,37 +10,37 @@ package cofh.api.energy; * */ 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); - /** - * 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); - /** - * 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(); + /** + * 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/main/java/cofh/api/energy/IEnergyTransport.java b/src/main/java/cofh/api/energy/IEnergyTransport.java index ab45e04fe..89a705115 100644 --- a/src/main/java/cofh/api/energy/IEnergyTransport.java +++ b/src/main/java/cofh/api/energy/IEnergyTransport.java @@ -5,105 +5,108 @@ import net.minecraftforge.common.util.ForgeDirection; /** * Implement this interface on Tile Entities which transport energy. *

- * This is used to "negotiate" connection types between two separate IEnergyTransports, allowing users to set flow direction and allowing for networks Of - * IEnergyTransports to intelligently transfer energy to other networks. + * This is used to "negotiate" connection types between two separate IEnergyTransports, + * allowing users to set flow direction and allowing for networks Of IEnergyTransports to + * intelligently transfer energy to other networks. */ public interface IEnergyTransport extends IEnergyProvider, IEnergyReceiver { + /** + * The type of interface for a given side of a {@link IEnergyTransport}. + *

+ * Values are:
+ * {@link SEND} for sending only
+ * {@link RECEIVE} for receiving only
+ * {@link BALANCE} for sending and receiving, and the default state + */ + public enum InterfaceType { + /** + * Indicates that this {@link IEnergyTransport} is only sending power on this + * side. + */ + SEND, + /** + * Indicates that this {@link IEnergyTransport} is only receiving power on this + * side. + */ + RECEIVE, + /** + * Indicates that this {@link IEnergyTransport} wants to balance power between + * itself and the senders/receivers on this side. This is the default state.
+ * To block any connection, use {@link IEnergyConnection#canConnectEnergy} + *

+ * IEnergyTransport based senders should check that the total power in the + * destination IEnergyTransport is less than the power in themselves before + * sending.
Active IEnergyTransport receivers (i.e., those that call {@link + * IEnergyProvider#extractEnergy}) should check that they contain less power than + * the source IEnergyTransport. + */ + BALANCE; - /** - * The type of interface for a given side of a {@link IEnergyTransport}. - *

- * Values are:
- * {@link SEND} for sending only
- * {@link RECEIVE} for receiving only
- * {@link BALANCE} for sending and receiving, and the default state - */ - public enum InterfaceType { - /** - * Indicates that this {@link IEnergyTransport} is only sending power on this side. - */ - SEND, - /** - * Indicates that this {@link IEnergyTransport} is only receiving power on this side. - */ - RECEIVE, - /** - * Indicates that this {@link IEnergyTransport} wants to balance power between itself and the - * senders/receivers on this side. This is the default state.
- * To block any connection, use {@link IEnergyConnection#canConnectEnergy} - *

- * IEnergyTransport based senders should check that the total power in the destination IEnergyTransport is less than the power in themselves before sending. - *
- * Active IEnergyTransport receivers (i.e., those that call {@link IEnergyProvider#extractEnergy}) should check that they contain less power than the - * source IEnergyTransport. - */ - BALANCE; + /** + * Returns the opposite state to this InterfaceType. + *

+ * {@link #BALANCE} is considered its own opposite.
+ * {@link #SEND} is the opposite of {@link #RECEIVE} and visa versa. + */ + public InterfaceType getOpposite() { + return this == BALANCE ? BALANCE : this == SEND ? RECEIVE : SEND; + } - /** - * Returns the opposite state to this InterfaceType. - *

- * {@link #BALANCE} is considered its own opposite.
- * {@link #SEND} is the opposite of {@link #RECEIVE} and visa versa. - */ - public InterfaceType getOpposite() { + /** + * Returns the next InterfaceType as described in {@link + * IEnergyTransport#getTransportState} + */ + public InterfaceType rotate() { + return rotate(true); + } - return this == BALANCE ? BALANCE : this == SEND ? RECEIVE : SEND; - } + /** + * Returns the next InterfaceType as described in {@link + * IEnergyTransport#getTransportState} + * + * @param forward + * Whether to step in the order specified by {@link + * IEnergyTransport#getTransportState} (true) or to step in the opposite + * direction + */ + public InterfaceType rotate(boolean forward) { + if (forward) { + return this == BALANCE ? RECEIVE : this == RECEIVE ? SEND : BALANCE; + } else { + return this == BALANCE ? SEND : this == SEND ? RECEIVE : BALANCE; + } + } + } - /** - * Returns the next InterfaceType as described in {@link IEnergyTransport#getTransportState} - */ - public InterfaceType rotate() { + /** + * {@inheritDoc}
+ * This method cannot be a no-op for IEnergyTransport. + */ + @Override + int getEnergyStored(ForgeDirection from); - return rotate(true); - } - - /** - * Returns the next InterfaceType as described in {@link IEnergyTransport#getTransportState} - * - * @param forward - * Whether to step in the order specified by {@link IEnergyTransport#getTransportState} (true) or to step in the opposite direction - */ - public InterfaceType rotate(boolean forward) { - - if (forward) { - return this == BALANCE ? RECEIVE : this == RECEIVE ? SEND : BALANCE; - } else { - return this == BALANCE ? SEND : this == SEND ? RECEIVE : BALANCE; - } - } - } - - /** - * {@inheritDoc}
- * This method cannot be a no-op for IEnergyTransport. - */ - @Override - int getEnergyStored(ForgeDirection from); - - /** - * Indicates to other IEnergyTransports the state of the given side. See {@link #InterfaceType} for details. - *

- * For clarity of state tracking, on a tile update from another IEnergyTransport, if its mode has changed from the opposite of your own mode on that side, you - * should change your mode to the opposite of its mode. - *

- * When the user alters your mode and your state is:
- * BALANCE, your mode should change to {@link InterFaceType#RECEIVE}.
- * RECEIVE, your mode should change to {@link InterFaceType#SEND}.
- * SEND, your mode should change to {@link InterFaceType#BALANCE}.
- * This is not required, but will be easier for users. - * - * @return The type of connection to establish on this side. null is NOT a valid value - */ - InterfaceType getTransportState(ForgeDirection from); - - /** - * This method is provided primarily for the purposes of automation tools, and should not need to be called by another IEnergyTransport. - *

- * Calls to this method may fail if this IEnergyTransport has been secured by a user. - * - * @return Whether or not state was successfully altered. - */ - boolean setTransportState(InterfaceType state, ForgeDirection from); + /** + * Indicates to other IEnergyTransports the state of the given side. See {@link + * #InterfaceType} for details.

For clarity of state tracking, on a tile update + * from another IEnergyTransport, if its mode has changed from the opposite of your + * own mode on that side, you should change your mode to the opposite of its mode.

+ * When the user alters your mode and your state is:
+ * BALANCE, your mode should change to {@link InterFaceType#RECEIVE}.
+ * RECEIVE, your mode should change to {@link InterFaceType#SEND}.
+ * SEND, your mode should change to {@link InterFaceType#BALANCE}.
+ * This is not required, but will be easier for users. + * + * @return The type of connection to establish on this side. null is NOT a valid + * value + */ + InterfaceType getTransportState(ForgeDirection from); + /** + * This method is provided primarily for the purposes of automation tools, and should + * not need to be called by another IEnergyTransport.

Calls to this method may + * fail if this IEnergyTransport has been secured by a user. + * + * @return Whether or not state was successfully altered. + */ + boolean setTransportState(InterfaceType state, ForgeDirection from); } diff --git a/src/main/java/cofh/api/energy/ItemEnergyContainer.java b/src/main/java/cofh/api/energy/ItemEnergyContainer.java index 2d3659cb6..cd8b2d3f1 100644 --- a/src/main/java/cofh/api/energy/ItemEnergyContainer.java +++ b/src/main/java/cofh/api/energy/ItemEnergyContainer.java @@ -5,106 +5,95 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; /** - * Reference implementation of {@link IEnergyContainerItem}. Use/extend this or implement your own. + * 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; - protected int capacity; - protected int maxReceive; - protected int maxExtract; + public ItemEnergyContainer() {} - public ItemEnergyContainer() { + public ItemEnergyContainer(int capacity) { + this(capacity, capacity, capacity); + } - } + public ItemEnergyContainer(int capacity, int maxTransfer) { + this(capacity, maxTransfer, maxTransfer); + } - public ItemEnergyContainer(int capacity) { + public ItemEnergyContainer(int capacity, int maxReceive, int maxExtract) { + this.capacity = capacity; + this.maxReceive = maxReceive; + this.maxExtract = maxExtract; + } - this(capacity, capacity, capacity); - } + public ItemEnergyContainer setCapacity(int capacity) { + this.capacity = capacity; + return this; + } - public ItemEnergyContainer(int capacity, int maxTransfer) { + public void setMaxTransfer(int maxTransfer) { + setMaxReceive(maxTransfer); + setMaxExtract(maxTransfer); + } - this(capacity, maxTransfer, maxTransfer); - } + public void setMaxReceive(int maxReceive) { + this.maxReceive = maxReceive; + } - public ItemEnergyContainer(int capacity, int maxReceive, int maxExtract) { + public void setMaxExtract(int maxExtract) { + this.maxExtract = maxExtract; + } - this.capacity = capacity; - this.maxReceive = maxReceive; - 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)); - public ItemEnergyContainer setCapacity(int capacity) { + if (!simulate) { + energy += energyReceived; + container.stackTagCompound.setInteger("Energy", energy); + } + return energyReceived; + } - this.capacity = capacity; - return this; - } + @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)); - public void setMaxTransfer(int maxTransfer) { + if (!simulate) { + energy -= energyExtracted; + container.stackTagCompound.setInteger("Energy", energy); + } + return energyExtracted; + } - 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; - } + @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/main/java/cofh/api/energy/TileEnergyHandler.java b/src/main/java/cofh/api/energy/TileEnergyHandler.java index 7cc655e92..84ebb0c21 100644 --- a/src/main/java/cofh/api/energy/TileEnergyHandler.java +++ b/src/main/java/cofh/api/energy/TileEnergyHandler.java @@ -5,61 +5,53 @@ import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; /** - * Reference implementation of {@link IEnergyHandler}. Use/extend this or implement your own. + * 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); - protected EnergyStorage storage = new EnergyStorage(32000); + @Override + public void readFromNBT(NBTTagCompound nbt) { + super.readFromNBT(nbt); + storage.readFromNBT(nbt); + } - @Override - public void readFromNBT(NBTTagCompound nbt) { + @Override + public void writeToNBT(NBTTagCompound nbt) { + super.writeToNBT(nbt); + storage.writeToNBT(nbt); + } - super.readFromNBT(nbt); - storage.readFromNBT(nbt); - } + /* IEnergyConnection */ + @Override + public boolean canConnectEnergy(ForgeDirection from) { + return true; + } - @Override - public void writeToNBT(NBTTagCompound nbt) { + /* IEnergyReceiver */ + @Override + public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { + return storage.receiveEnergy(maxReceive, simulate); + } - super.writeToNBT(nbt); - storage.writeToNBT(nbt); - } + /* IEnergyProvider */ + @Override + public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) { + return storage.extractEnergy(maxExtract, simulate); + } - /* IEnergyConnection */ - @Override - public boolean canConnectEnergy(ForgeDirection from) { - - return true; - } - - /* IEnergyReceiver */ - @Override - public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { - - return storage.receiveEnergy(maxReceive, simulate); - } - - /* IEnergyProvider */ - @Override - public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) { - - return storage.extractEnergy(maxExtract, simulate); - } - - /* IEnergyReceiver and IEnergyProvider */ - @Override - public int getEnergyStored(ForgeDirection from) { - - return storage.getEnergyStored(); - } - - @Override - public int getMaxEnergyStored(ForgeDirection from) { - - return storage.getMaxEnergyStored(); - } + /* IEnergyReceiver and IEnergyProvider */ + @Override + public int getEnergyStored(ForgeDirection from) { + return storage.getEnergyStored(); + } + @Override + public int getMaxEnergyStored(ForgeDirection from) { + return storage.getMaxEnergyStored(); + } } diff --git a/src/main/java/cofh/api/energy/package-info.java b/src/main/java/cofh/api/energy/package-info.java index 7379702b8..921f1099c 100644 --- a/src/main/java/cofh/api/energy/package-info.java +++ b/src/main/java/cofh/api/energy/package-info.java @@ -7,4 +7,3 @@ package cofh.api.energy; import cofh.api.CoFHAPIProps; import cpw.mods.fml.common.API; - diff --git a/src/main/java/cofh/api/item/IAugmentItem.java b/src/main/java/cofh/api/item/IAugmentItem.java index e17fa8dec..3d92f90d0 100644 --- a/src/main/java/cofh/api/item/IAugmentItem.java +++ b/src/main/java/cofh/api/item/IAugmentItem.java @@ -5,25 +5,25 @@ import java.util.Set; import net.minecraft.item.ItemStack; public interface IAugmentItem { + /** + * Get the augmentation level for a given Augment and Augment Type. + * + * @param stack + * ItemStack representing the Augment. + * @param type + * String containing the Augment type name. + * @return The Augment level of the stack for the requested type - 0 if it does not + * affect that attribute. + */ + int getAugmentLevel(ItemStack stack, String type); - /** - * Get the augmentation level for a given Augment and Augment Type. - * - * @param stack - * ItemStack representing the Augment. - * @param type - * String containing the Augment type name. - * @return The Augment level of the stack for the requested type - 0 if it does not affect that attribute. - */ - int getAugmentLevel(ItemStack stack, String type); - - /** - * Get the Augment Types for a given Augment. Set ensure that there are no duplicates. - * - * @param stack - * ItemStack representing the Augment. - * @return Set of the Augmentation Types. Should return an empty set if there are none (but this would be really stupid to make). DO NOT RETURN NULL. - */ - Set getAugmentTypes(ItemStack stack); - + /** + * Get the Augment Types for a given Augment. Set ensure that there are no duplicates. + * + * @param stack + * ItemStack representing the Augment. + * @return Set of the Augmentation Types. Should return an empty set if there are none + * (but this would be really stupid to make). DO NOT RETURN NULL. + */ + Set getAugmentTypes(ItemStack stack); } diff --git a/src/main/java/cofh/api/item/IEmpowerableItem.java b/src/main/java/cofh/api/item/IEmpowerableItem.java index 428771100..a313973f8 100644 --- a/src/main/java/cofh/api/item/IEmpowerableItem.java +++ b/src/main/java/cofh/api/item/IEmpowerableItem.java @@ -4,38 +4,36 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; /** - * Implement this interface on Item classes which may be "Empowered" - what that means is completely up to you. This just provides a uniform way of dealing with - * them. + * Implement this interface on Item classes which may be "Empowered" - what that means is + * completely up to you. This just provides a uniform way of dealing with them. * * @author King Lemming * */ public interface IEmpowerableItem { + /** + * Check whether or not a given item is currently in an empowered state. + */ + boolean isEmpowered(ItemStack stack); - /** - * Check whether or not a given item is currently in an empowered state. - */ - boolean isEmpowered(ItemStack stack); - - /** - * Attempt to set the empowered state of the item. - * - * @param stack - * ItemStack to be empowered/disempowered. - * @param state - * Desired state. - * @return TRUE if the operation was successful, FALSE if it was not. - */ - boolean setEmpoweredState(ItemStack stack, boolean state); - - /** - * Callback method for reacting to a state change. Useful in KeyBinding handlers. - * - * @param player - * Player holding the item, if applicable. - * @param stack - * The item being held. - */ - void onStateChange(EntityPlayer player, ItemStack stack); + /** + * Attempt to set the empowered state of the item. + * + * @param stack + * ItemStack to be empowered/disempowered. + * @param state + * Desired state. + * @return TRUE if the operation was successful, FALSE if it was not. + */ + boolean setEmpoweredState(ItemStack stack, boolean state); + /** + * Callback method for reacting to a state change. Useful in KeyBinding handlers. + * + * @param player + * Player holding the item, if applicable. + * @param stack + * The item being held. + */ + void onStateChange(EntityPlayer player, ItemStack stack); } diff --git a/src/main/java/cofh/api/item/IInventoryContainerItem.java b/src/main/java/cofh/api/item/IInventoryContainerItem.java index adadf10a7..2c59fee6e 100644 --- a/src/main/java/cofh/api/item/IInventoryContainerItem.java +++ b/src/main/java/cofh/api/item/IInventoryContainerItem.java @@ -11,10 +11,8 @@ import net.minecraft.item.ItemStack; * */ public interface IInventoryContainerItem { - - /** - * Get the size of this inventory of this container item. - */ - int getSizeInventory(ItemStack container); - + /** + * Get the size of this inventory of this container item. + */ + int getSizeInventory(ItemStack container); } diff --git a/src/main/java/cofh/api/item/IMultiModeItem.java b/src/main/java/cofh/api/item/IMultiModeItem.java index c236bbfbd..82b865ee7 100644 --- a/src/main/java/cofh/api/item/IMultiModeItem.java +++ b/src/main/java/cofh/api/item/IMultiModeItem.java @@ -4,53 +4,51 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; /** - * Implement this interface on Item classes which may be "Empowered" - what that means is completely up to you. This just provides a uniform way of dealing with - * them. + * Implement this interface on Item classes which may be "Empowered" - what that means is + * completely up to you. This just provides a uniform way of dealing with them. * * @author King Lemming * */ public interface IMultiModeItem { + /** + * Get the current mode of an item. + */ + int getMode(ItemStack stack); - /** - * Get the current mode of an item. - */ - int getMode(ItemStack stack); + /** + * Attempt to set the empowered state of the item. + * + * @param stack + * ItemStack to set the mode on. + * @param mode + * Desired mode. + * @return TRUE if the operation was successful, FALSE if it was not. + */ + boolean setMode(ItemStack stack, int mode); - /** - * Attempt to set the empowered state of the item. - * - * @param stack - * ItemStack to set the mode on. - * @param mode - * Desired mode. - * @return TRUE if the operation was successful, FALSE if it was not. - */ - boolean setMode(ItemStack stack, int mode); + /** + * Increment the current mode of an item. + */ + boolean incrMode(ItemStack stack); - /** - * Increment the current mode of an item. - */ - boolean incrMode(ItemStack stack); + /** + * Decrement the current mode of an item. + */ + boolean decrMode(ItemStack stack); - /** - * Decrement the current mode of an item. - */ - boolean decrMode(ItemStack stack); - - /** - * Returns the number of possible modes. - */ - int getNumModes(ItemStack stack); - - /** - * Callback method for reacting to a state change. Useful in KeyBinding handlers. - * - * @param player - * Player holding the item, if applicable. - * @param stack - * The item being held. - */ - void onModeChange(EntityPlayer player, ItemStack stack); + /** + * Returns the number of possible modes. + */ + int getNumModes(ItemStack stack); + /** + * Callback method for reacting to a state change. Useful in KeyBinding handlers. + * + * @param player + * Player holding the item, if applicable. + * @param stack + * The item being held. + */ + void onModeChange(EntityPlayer player, ItemStack stack); } diff --git a/src/main/java/cofh/api/item/ISpecialFilterFluid.java b/src/main/java/cofh/api/item/ISpecialFilterFluid.java index 7e8d3d025..815d6dd4d 100644 --- a/src/main/java/cofh/api/item/ISpecialFilterFluid.java +++ b/src/main/java/cofh/api/item/ISpecialFilterFluid.java @@ -4,21 +4,23 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; /** - * Implement this interface on subclasses of Item to change how the item works in Thermal Dynamics Fluiducts filter slots. + * Implement this interface on subclasses of Item to change how the item works in Thermal + * Dynamics Fluiducts filter slots. * - * This can be used to create customizable Items which are determined to be "equal" for the purposes of filtering. + * This can be used to create customizable Items which are determined to be "equal" for + * the purposes of filtering. */ public interface ISpecialFilterFluid { - - /** - * This method is called to find out if the given FluidStack should be matched by the given Filter ItemStack. - * - * @param filter - * ItemStack representing the filter. - * @param fluid - * FluidStack representing the queried fluid. - * @return True if the filter should match the FluidStack. False if the default matching should be used. - */ - public boolean matchesFluid(ItemStack filter, FluidStack fluid); - + /** + * This method is called to find out if the given FluidStack should be matched by the + * given Filter ItemStack. + * + * @param filter + * ItemStack representing the filter. + * @param fluid + * FluidStack representing the queried fluid. + * @return True if the filter should match the FluidStack. False if the default + * matching should be used. + */ + public boolean matchesFluid(ItemStack filter, FluidStack fluid); } diff --git a/src/main/java/cofh/api/item/ISpecialFilterItem.java b/src/main/java/cofh/api/item/ISpecialFilterItem.java index ef9f953d8..8c2b46bc1 100644 --- a/src/main/java/cofh/api/item/ISpecialFilterItem.java +++ b/src/main/java/cofh/api/item/ISpecialFilterItem.java @@ -3,21 +3,23 @@ package cofh.api.item; import net.minecraft.item.ItemStack; /** - * Implement this interface on subclasses of Item to change how the item works in Thermal Dynamics Itemducts filter slots. + * Implement this interface on subclasses of Item to change how the item works in Thermal + * Dynamics Itemducts filter slots. * - * This can be used to create customizable Items which are determined to be "equal" for the purposes of filtering. + * This can be used to create customizable Items which are determined to be "equal" for + * the purposes of filtering. */ public interface ISpecialFilterItem { - - /** - * This method is called to find out if the given ItemStack should be matched by the given Filter ItemStack. - * - * @param filter - * ItemStack representing the filter. - * @param item - * ItemStack representing the queried item. - * @return True if the filter should match. False if the default matching should be used. - */ - public boolean matchesItem(ItemStack filter, ItemStack item); - + /** + * This method is called to find out if the given ItemStack should be matched by the + * given Filter ItemStack. + * + * @param filter + * ItemStack representing the filter. + * @param item + * ItemStack representing the queried item. + * @return True if the filter should match. False if the default matching should be + * used. + */ + public boolean matchesItem(ItemStack filter, ItemStack item); } diff --git a/src/main/java/cofh/api/item/IToolHammer.java b/src/main/java/cofh/api/item/IToolHammer.java index f1b4bb9bb..05e61d265 100644 --- a/src/main/java/cofh/api/item/IToolHammer.java +++ b/src/main/java/cofh/api/item/IToolHammer.java @@ -4,41 +4,42 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; /** - * Implement this interface on subclasses of Item to have that item work as a tool for CoFH mods. + * Implement this interface on subclasses of Item to have that item work as a tool for + * CoFH mods. */ public interface IToolHammer { + /** + * Called to ensure that the tool can be used. + * + * @param item + * The itemstack for the tool. Not required to match equipped item (e.g., + * multi-tools that contain other tools) + * @param user + * The entity using the tool + * @param x + * X location of the block/tile + * @param y + * Y location of the block/tile + * @param z + * Z location of the block/tile + * @return True if this tool can be used + */ + boolean isUsable(ItemStack item, EntityLivingBase user, int x, int y, int z); - /** - * Called to ensure that the tool can be used. - * - * @param item - * The itemstack for the tool. Not required to match equipped item (e.g., multi-tools that contain other tools) - * @param user - * The entity using the tool - * @param x - * X location of the block/tile - * @param y - * Y location of the block/tile - * @param z - * Z location of the block/tile - * @return True if this tool can be used - */ - boolean isUsable(ItemStack item, EntityLivingBase user, int x, int y, int z); - - /** - * Callback for when the tool has been used reactively. - * - * @param item - * The ItemStack for the tool. Not required to match equipped item (e.g., multi-tools that contain other tools) - * @param user - * The entity using the tool - * @param x - * X location of the block/tile - * @param y - * Y location of the block/tile - * @param z - * Z location of the block/tile - */ - void toolUsed(ItemStack item, EntityLivingBase user, int x, int y, int z); - + /** + * Callback for when the tool has been used reactively. + * + * @param item + * The ItemStack for the tool. Not required to match equipped item (e.g., + * multi-tools that contain other tools) + * @param user + * The entity using the tool + * @param x + * X location of the block/tile + * @param y + * Y location of the block/tile + * @param z + * Z location of the block/tile + */ + void toolUsed(ItemStack item, EntityLivingBase user, int x, int y, int z); } diff --git a/src/main/java/cofh/api/item/package-info.java b/src/main/java/cofh/api/item/package-info.java index 49608fd13..6cb155896 100644 --- a/src/main/java/cofh/api/item/package-info.java +++ b/src/main/java/cofh/api/item/package-info.java @@ -7,4 +7,3 @@ package cofh.api.item; import cofh.api.CoFHAPIProps; import cpw.mods.fml.common.API; - diff --git a/src/main/java/cofh/api/package-info.java b/src/main/java/cofh/api/package-info.java index 08ff5fcb6..22f29a0c8 100644 --- a/src/main/java/cofh/api/package-info.java +++ b/src/main/java/cofh/api/package-info.java @@ -6,4 +6,3 @@ package cofh.api; import cpw.mods.fml.common.API; - diff --git a/src/main/java/com/jadarstudios/developercapes/DevCapes.java b/src/main/java/com/jadarstudios/developercapes/DevCapes.java index 5539eb084..ffedde83d 100644 --- a/src/main/java/com/jadarstudios/developercapes/DevCapes.java +++ b/src/main/java/com/jadarstudios/developercapes/DevCapes.java @@ -6,19 +6,20 @@ */ package com.jadarstudios.developercapes; +import java.io.*; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLConnection; + import com.jadarstudios.developercapes.cape.CapeConfig; import com.jadarstudios.developercapes.cape.CapeConfigManager; import net.minecraftforge.common.MinecraftForge; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import java.io.*; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; - /** - * DeveloperCapes is a library for Minecraft. It allows developers to quickly add capes for players they specify. DevCapes uses Minecraft Forge. + * DeveloperCapes is a library for Minecraft. It allows developers to quickly add capes + * for players they specify. DevCapes uses Minecraft Forge. * * @author jadar */ @@ -40,14 +41,16 @@ public class DevCapes { /** * InputStream.close() needs to be called on this after you're done! - * + * * @return {@link InputStream} for the {@link URL} */ public InputStream getStreamForURL(URL url) { InputStream is = null; try { URLConnection connection = url.openConnection(); - connection.setRequestProperty("User-Agent", System.getProperty("java.version")); + connection.setRequestProperty( + "User-Agent", System.getProperty("java.version") + ); connection.connect(); is = connection.getInputStream(); @@ -59,7 +62,7 @@ public class DevCapes { /** * InputStream.close() needs to be called on this after you're done! - * + * * @return {@link InputStream} for the {@link File} */ public InputStream getStreamForFile(File file) { @@ -132,7 +135,9 @@ public class DevCapes { InputStream is = this.getStreamForURL(jsonUrl); if (is == null) { - DevCapes.logger.error(String.format("Unable to establish a connection to the server, %s", jsonUrl.getHost())); + DevCapes.logger.error(String.format( + "Unable to establish a connection to the server, %s", jsonUrl.getHost() + )); return id; } @@ -153,7 +158,6 @@ public class DevCapes { private static void silentClose(InputStream is) { try { is.close(); - } catch (IOException ignored) { - } + } catch (IOException ignored) {} } } \ No newline at end of file diff --git a/src/main/java/com/jadarstudios/developercapes/HDImageBuffer.java b/src/main/java/com/jadarstudios/developercapes/HDImageBuffer.java index 884c8ca7c..912f2b1d6 100644 --- a/src/main/java/com/jadarstudios/developercapes/HDImageBuffer.java +++ b/src/main/java/com/jadarstudios/developercapes/HDImageBuffer.java @@ -6,13 +6,13 @@ */ package com.jadarstudios.developercapes; +import java.awt.Graphics; +import java.awt.image.BufferedImage; + import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.IImageBuffer; -import java.awt.Graphics; -import java.awt.image.BufferedImage; - /** * This class is an implementation of {@link IImageBuffer} that allows capes to be in HD * diff --git a/src/main/java/com/jadarstudios/developercapes/RenderEventHandler.java b/src/main/java/com/jadarstudios/developercapes/RenderEventHandler.java index 4494c87e3..6ae5b167a 100644 --- a/src/main/java/com/jadarstudios/developercapes/RenderEventHandler.java +++ b/src/main/java/com/jadarstudios/developercapes/RenderEventHandler.java @@ -15,21 +15,22 @@ import net.minecraftforge.client.event.RenderPlayerEvent; /** * This is not the class you are looking for. - * + * * @author jadar */ public class RenderEventHandler { - @SubscribeEvent public void renderPlayer(RenderPlayerEvent.Specials.Pre event) { AbstractClientPlayer player = (AbstractClientPlayer) event.entityPlayer; UserManager manager = UserManager.getInstance(); User user = manager.getUser(player.getUniqueID().toString()); - if (user == null) return; + if (user == null) + return; ICape cape = user.capes.get(0); - if (cape == null) return; + if (cape == null) + return; boolean flag = cape.isTextureLoaded(player); if (!flag) { diff --git a/src/main/java/com/jadarstudios/developercapes/cape/AbstractCape.java b/src/main/java/com/jadarstudios/developercapes/cape/AbstractCape.java index 075bc52df..7424ce1a7 100644 --- a/src/main/java/com/jadarstudios/developercapes/cape/AbstractCape.java +++ b/src/main/java/com/jadarstudios/developercapes/cape/AbstractCape.java @@ -11,7 +11,7 @@ import net.minecraft.util.ResourceLocation; /** * Abstract Implementation of ICape used within Dev. Capes - * + * * @author jadar */ public abstract class AbstractCape implements ICape { diff --git a/src/main/java/com/jadarstudios/developercapes/cape/CapeConfig.java b/src/main/java/com/jadarstudios/developercapes/cape/CapeConfig.java index 345bb1b1c..ccdb38a3e 100644 --- a/src/main/java/com/jadarstudios/developercapes/cape/CapeConfig.java +++ b/src/main/java/com/jadarstudios/developercapes/cape/CapeConfig.java @@ -6,14 +6,14 @@ */ package com.jadarstudios.developercapes.cape; +import java.util.HashMap; + import com.jadarstudios.developercapes.user.Group; import com.jadarstudios.developercapes.user.User; -import java.util.HashMap; - /** * The players that need to be outfitted are stored here - * + * * @author jadar */ public class CapeConfig { diff --git a/src/main/java/com/jadarstudios/developercapes/cape/CapeConfigManager.java b/src/main/java/com/jadarstudios/developercapes/cape/CapeConfigManager.java index d91bc7f0a..8157b5335 100644 --- a/src/main/java/com/jadarstudios/developercapes/cape/CapeConfigManager.java +++ b/src/main/java/com/jadarstudios/developercapes/cape/CapeConfigManager.java @@ -6,6 +6,13 @@ */ package com.jadarstudios.developercapes.cape; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.util.BitSet; +import java.util.Map; + import com.google.common.collect.HashBiMap; import com.google.common.primitives.UnsignedBytes; import com.google.gson.Gson; @@ -17,22 +24,14 @@ import com.jadarstudios.developercapes.user.User; import com.jadarstudios.developercapes.user.UserManager; import org.apache.commons.lang3.ObjectUtils; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.BitSet; -import java.util.Map; - /** * All configs need a manager, this is it. - * + * * @author jadar */ public class CapeConfigManager { - protected static CapeConfigManager instance; - + protected static BitSet availableIds = new BitSet(256); protected HashBiMap configs; @@ -57,18 +56,18 @@ public class CapeConfigManager { addUsers(config.users); addGroups(config.groups); } - - protected void addUsers(Map users){ - try { - UserManager.getInstance().addUsers(users.values()); + + protected void addUsers(Map users) { + try { + UserManager.getInstance().addUsers(users.values()); } catch (Exception e) { e.printStackTrace(); } } - - protected void addGroups(Map groups){ - try { - GroupManager.getInstance().addGroups(groups.values()); + + protected void addGroups(Map groups) { + try { + GroupManager.getInstance().addGroups(groups.values()); } catch (Exception e) { e.printStackTrace(); } @@ -87,8 +86,10 @@ public class CapeConfigManager { } public static int claimId(int id) throws InvalidCapeConfigIdException { - if(id <= 0){ - throw new InvalidCapeConfigIdException("The config ID must be a positive non-zero integer"); + if (id <= 0) { + throw new InvalidCapeConfigIdException( + "The config ID must be a positive non-zero integer" + ); } try { UnsignedBytes.checkedCast(id); @@ -98,7 +99,9 @@ public class CapeConfigManager { boolean isRegistered = availableIds.get(id); if (isRegistered) { - throw new InvalidCapeConfigIdException(String.format("The config ID %d is already claimed.", id)); + throw new InvalidCapeConfigIdException( + String.format("The config ID %d is already claimed.", id) + ); } availableIds.set(id); @@ -122,34 +125,35 @@ public class CapeConfigManager { if (obj instanceof Map) { parseGroup(instance, nodeName, (Map) obj); } else if (obj instanceof String) { - parseUser(instance, nodeName, (String) obj); + parseUser(instance, nodeName, (String) obj); } } } catch (JsonSyntaxException e) { - DevCapes.logger.error("CapeConfig could not be parsed because:"); + DevCapes.logger.error("CapeConfig could not be parsed because:"); e.printStackTrace(); } return instance; } - + protected void parseGroup(CapeConfig config, String node, Map group) { Group g = GroupManager.getInstance().parse(node, group); if (g != null) { - config.groups.put(g.name, g); + config.groups.put(g.name, g); } } - + protected void parseUser(CapeConfig config, String node, String user) { - User u = UserManager.getInstance().parse(node, user); + User u = UserManager.getInstance().parse(node, user); if (u != null) { - config.users.put(node, u); + config.users.put(node, u); } } /** - * DEPRECATED! Please use {@link com.jadarstudios.developercapes.cape.CapeConfigManager#parse(java.io.InputStream is)} - * This will be removed in the next major release. + * DEPRECATED! Please use {@link + * com.jadarstudios.developercapes.cape.CapeConfigManager#parse(java.io.InputStream + * is)} This will be removed in the next major release. */ @Deprecated public CapeConfig parseFromStream(InputStream is) { diff --git a/src/main/java/com/jadarstudios/developercapes/cape/CapeManager.java b/src/main/java/com/jadarstudios/developercapes/cape/CapeManager.java index d08003754..4c60f2b25 100644 --- a/src/main/java/com/jadarstudios/developercapes/cape/CapeManager.java +++ b/src/main/java/com/jadarstudios/developercapes/cape/CapeManager.java @@ -6,20 +6,19 @@ */ package com.jadarstudios.developercapes.cape; -import com.jadarstudios.developercapes.DevCapes; - import java.net.MalformedURLException; import java.net.URL; import java.util.Collection; import java.util.HashMap; +import com.jadarstudios.developercapes.DevCapes; + /** * This manages all of the capes, be nice to it or you won't get one! - * + * * @author jadar */ public class CapeManager { - protected static CapeManager instance; private HashMap capes; @@ -56,13 +55,16 @@ public class CapeManager { this.capes.put(name, cape); return cape; } - + public ICape parse(String name, Object object) { ICape cape = null; - if(object instanceof String || object instanceof URL){ - cape = parse(name, object.toString()); - }else{ - DevCapes.logger.error(String.format("Cape, %s, could not be parsed because it is not in an accepted format!", object)); + if (object instanceof String || object instanceof URL) { + cape = parse(name, object.toString()); + } else { + DevCapes.logger.error(String.format( + "Cape, %s, could not be parsed because it is not in an accepted format!", + object + )); } return cape; } @@ -73,7 +75,9 @@ public class CapeManager { try { cape = new StaticCape(name, new URL(url)); } catch (MalformedURLException e) { - DevCapes.logger.error(String.format("Are you crazy?? \"%s\" is not a valid URL!", url)); + DevCapes.logger.error( + String.format("Are you crazy?? \"%s\" is not a valid URL!", url) + ); e.printStackTrace(); } return cape; diff --git a/src/main/java/com/jadarstudios/developercapes/cape/ICape.java b/src/main/java/com/jadarstudios/developercapes/cape/ICape.java index 79a652432..70614874f 100644 --- a/src/main/java/com/jadarstudios/developercapes/cape/ICape.java +++ b/src/main/java/com/jadarstudios/developercapes/cape/ICape.java @@ -12,11 +12,10 @@ import net.minecraft.util.ResourceLocation; /** * Any class implementing this will be requested to act as a cape. - * + * * @author jadar */ public interface ICape { - public String getName(); public ITextureObject getTexture(); diff --git a/src/main/java/com/jadarstudios/developercapes/cape/StaticCape.java b/src/main/java/com/jadarstudios/developercapes/cape/StaticCape.java index 1844f9528..f9499a9e1 100644 --- a/src/main/java/com/jadarstudios/developercapes/cape/StaticCape.java +++ b/src/main/java/com/jadarstudios/developercapes/cape/StaticCape.java @@ -6,6 +6,8 @@ */ package com.jadarstudios.developercapes.cape; +import java.net.URL; + import com.jadarstudios.developercapes.HDImageBuffer; import com.mojang.authlib.minecraft.MinecraftProfileTexture; import net.minecraft.client.Minecraft; @@ -13,15 +15,12 @@ import net.minecraft.client.entity.AbstractClientPlayer; import net.minecraft.client.renderer.ThreadDownloadImageData; import net.minecraft.util.ResourceLocation; -import java.net.URL; - /** * Default Cape implementation - * + * * @author jadar */ public class StaticCape extends AbstractCape { - public StaticCape(String name, URL url) { this.setName(name); this.setURL(url); @@ -50,7 +49,9 @@ public class StaticCape extends AbstractCape { this.texture = null; return; } - this.texture = new ThreadDownloadImageData(null, url.toString(), null, new HDImageBuffer()); + this.texture = new ThreadDownloadImageData( + null, url.toString(), null, new HDImageBuffer() + ); } public void setName(String name) { diff --git a/src/main/java/com/jadarstudios/developercapes/user/Group.java b/src/main/java/com/jadarstudios/developercapes/user/Group.java index 220db855d..f47c3361c 100644 --- a/src/main/java/com/jadarstudios/developercapes/user/Group.java +++ b/src/main/java/com/jadarstudios/developercapes/user/Group.java @@ -6,18 +6,17 @@ */ package com.jadarstudios.developercapes.user; -import com.jadarstudios.developercapes.cape.ICape; - import java.util.HashMap; import java.util.Set; +import com.jadarstudios.developercapes.cape.ICape; + /** * This represents a group of players that share a cape - * + * * @author jadar */ public class Group { - protected HashMap users; protected ICape cape; public final String name; diff --git a/src/main/java/com/jadarstudios/developercapes/user/GroupManager.java b/src/main/java/com/jadarstudios/developercapes/user/GroupManager.java index b513c73ed..d0eaad813 100644 --- a/src/main/java/com/jadarstudios/developercapes/user/GroupManager.java +++ b/src/main/java/com/jadarstudios/developercapes/user/GroupManager.java @@ -6,21 +6,20 @@ */ package com.jadarstudios.developercapes.user; -import com.jadarstudios.developercapes.DevCapes; -import com.jadarstudios.developercapes.cape.CapeManager; - import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; import java.util.Map; +import com.jadarstudios.developercapes.DevCapes; +import com.jadarstudios.developercapes.cape.CapeManager; + /** * All groups have to be managed - * + * * @author jadar */ public class GroupManager { - protected static GroupManager instance; private HashMap groups; @@ -46,18 +45,17 @@ public class GroupManager { e.printStackTrace(); } } - + public void addGroups(Collection groups) { - for (Group g : groups) { + for (Group g : groups) { GroupManager.getInstance().addGroup(g); } - } - + } + public Group getGroup(String capeName) { return groups.get(capeName); } - public Group newGroup(String name) { if (this.getGroup(name) != null) { return this.getGroup(name); @@ -73,17 +71,20 @@ public class GroupManager { Object capeUrlObj = data.get("capeUrl"); if (!(usersObj instanceof ArrayList) || !(capeUrlObj instanceof String)) { - DevCapes.logger.error(String.format("Group %s could not be parsed because it either is invalid or missing elements.", name)); + DevCapes.logger.error(String.format( + "Group %s could not be parsed because it either is invalid or missing elements.", + name + )); return null; } - ArrayList users = (ArrayList)usersObj; - String capeUrl = (String)capeUrlObj; + ArrayList users = (ArrayList) usersObj; + String capeUrl = (String) capeUrlObj; group.cape = CapeManager.getInstance().parse(name, capeUrl); for (Object obj : users) { - User user = UserManager.getInstance().parse((String)obj, group.cape); + User user = UserManager.getInstance().parse((String) obj, group.cape); if (user != null) { group.addUser(user); } diff --git a/src/main/java/com/jadarstudios/developercapes/user/User.java b/src/main/java/com/jadarstudios/developercapes/user/User.java index e72b135b1..3010171ed 100644 --- a/src/main/java/com/jadarstudios/developercapes/user/User.java +++ b/src/main/java/com/jadarstudios/developercapes/user/User.java @@ -6,18 +6,17 @@ */ package com.jadarstudios.developercapes.user; -import com.jadarstudios.developercapes.cape.ICape; - import java.util.ArrayList; import java.util.List; +import com.jadarstudios.developercapes.cape.ICape; + /** * This player is getting their own cape - * + * * @author jadar */ public class User { - public List capes; public final String userUUID; diff --git a/src/main/java/com/jadarstudios/developercapes/user/UserManager.java b/src/main/java/com/jadarstudios/developercapes/user/UserManager.java index 82b91c368..9e4bcab75 100644 --- a/src/main/java/com/jadarstudios/developercapes/user/UserManager.java +++ b/src/main/java/com/jadarstudios/developercapes/user/UserManager.java @@ -6,20 +6,19 @@ */ package com.jadarstudios.developercapes.user; +import java.util.Collection; +import java.util.HashMap; + import com.jadarstudios.developercapes.DevCapes; import com.jadarstudios.developercapes.cape.CapeManager; import com.jadarstudios.developercapes.cape.ICape; -import java.util.Collection; -import java.util.HashMap; - /** * Users can not be trusted to put capes on by themselves - * + * * @author jadar */ public class UserManager { - protected static UserManager instance; protected HashMap users; @@ -69,12 +68,15 @@ public class UserManager { public User parse(String user, Object cape) { User userInstance = new User(user); - ICape capeInstance = (cape instanceof ICape) ? (ICape)cape : CapeManager.getInstance().parse(user, cape.toString()); + ICape capeInstance = (cape instanceof ICape) + ? (ICape) cape + : CapeManager.getInstance().parse(user, cape.toString()); if (capeInstance != null) { userInstance.capes.add(capeInstance); } else { - DevCapes.logger.error(String.format("Error parsing cape, %s", cape.toString())); + DevCapes.logger.error(String.format("Error parsing cape, %s", cape.toString()) + ); } return userInstance; diff --git a/src/main/java/mekanism/api/Chunk3D.java b/src/main/java/mekanism/api/Chunk3D.java index 28a0949d3..3d19073a1 100644 --- a/src/main/java/mekanism/api/Chunk3D.java +++ b/src/main/java/mekanism/api/Chunk3D.java @@ -6,113 +6,102 @@ 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. + * 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); - } - - /** - * Returns this Chunk3D in the Minecraft-based ChunkCoordIntPair format. - * @return this Chunk3D as a ChunkCoordIntPair - */ - public ChunkCoordIntPair toPair() - { - return new ChunkCoordIntPair(xCoord, zCoord); - } - - @Override - public Chunk3D clone() - { - return new Chunk3D(xCoord, zCoord, dimensionId); - } +public class Chunk3D { + public int dimensionId; - @Override - public String toString() - { - return "[Chunk3D: " + xCoord + ", " + zCoord + ", dim=" + dimensionId + "]"; - } + public int xCoord; + public int zCoord; - @Override - public boolean equals(Object obj) - { - return obj instanceof Chunk3D && - ((Chunk3D)obj).xCoord == xCoord && - ((Chunk3D)obj).zCoord == zCoord && - ((Chunk3D)obj).dimensionId == dimensionId; - } + /** + * 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; - @Override - public int hashCode() - { - int code = 1; - code = 31 * code + xCoord; - code = 31 * code + zCoord; - code = 31 * code + dimensionId; - return code; - } + 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); + } + + /** + * Returns this Chunk3D in the Minecraft-based ChunkCoordIntPair format. + * @return this Chunk3D as a ChunkCoordIntPair + */ + public ChunkCoordIntPair toPair() { + return new ChunkCoordIntPair(xCoord, zCoord); + } + + @Override + public Chunk3D clone() { + return new Chunk3D(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/main/java/mekanism/api/Coord4D.java b/src/main/java/mekanism/api/Coord4D.java index 4a62f845b..85322fc94 100644 --- a/src/main/java/mekanism/api/Coord4D.java +++ b/src/main/java/mekanism/api/Coord4D.java @@ -1,9 +1,9 @@ package mekanism.api; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint; +import io.netty.buffer.ByteBuf; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.init.Blocks; @@ -17,406 +17,402 @@ 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. + * 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 class Coord4D { + public int xCoord; + public int yCoord; + public int zCoord; - public int dimensionId; + 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; + /** + * 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 an entity's position, rounded down. - * @param entity - entity to create the Coord4D from - */ - public Coord4D(Entity entity) - { - xCoord = (int)entity.posX; - yCoord = (int)entity.posY; - zCoord = (int)entity.posZ; - - dimensionId = entity.worldObj.provider.dimensionId; - } - - /** - * 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; - } - - public Coord4D(MovingObjectPosition mop) - { - xCoord = mop.blockX; - yCoord = mop.blockY; - zCoord = mop.blockZ; - } - - /** - * 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; - } - - /** - * Translates this Coord4D by the defined Coord4D's coordinates, regardless of dimension. - * @param coord - coordinates to translate by - * @return translated Coord4D - */ - public Coord4D translate(Coord4D coord) - { - translate(coord.xCoord, coord.yCoord, coord.zCoord); - - 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); - } - - /** - * Creates and returns a new Coord4D translated to the defined offsets of the side by the defined amount. - * @param side - side to translate this Coord4D to - * @param amount - how far to translate this Coord4D - * @return translated Coord4D - */ - public Coord4D getFromSide(ForgeDirection side, int amount) - { - return new Coord4D(xCoord+(side.offsetX*amount), yCoord+(side.offsetY*amount), zCoord+(side.offsetZ*amount), dimensionId); - } - - public ItemStack getStack(IBlockAccess world) - { - Block block = getBlock(world); - - if(block == null || block == Blocks.air) - { - return null; - } - - return new ItemStack(block, 1, getMetadata(world)); - } - - /** - * 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 tag - 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")); + dimensionId = 0; } - /** - * 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 a Coord4D from an entity's position, rounded down. + * @param entity - entity to create the Coord4D from + */ + public Coord4D(Entity entity) { + xCoord = (int) entity.posX; + yCoord = (int) entity.posY; + zCoord = (int) entity.posZ; - /** - * 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); - } + dimensionId = entity.worldObj.provider.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); + /** + * 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; - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - if(side.offsetX == diff.xCoord && side.offsetY == diff.yCoord && side.offsetZ == diff.zCoord) - { - return side; - } - } + dimensionId = dimension; + } - return ForgeDirection.UNKNOWN; - } + public Coord4D(MovingObjectPosition mop) { + xCoord = mop.blockX; + yCoord = mop.blockY; + zCoord = mop.blockZ; + } - /** - * 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); - } + /** + * 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); + } - /** - * 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); - } + /** + * 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; + } - /** - * 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); - } + return world.getTileEntity(xCoord, yCoord, zCoord); + } - /** - * 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() == null || world.getChunkProvider().chunkExists(xCoord >> 4, zCoord >> 4); - } + /** + * 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; + } - /** - * 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); - } + return world.getBlock(xCoord, yCoord, zCoord); + } - /** - * 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); - } - - /** - * Whether or not this block this Coord4D represents is replaceable. - * @param world - world this Coord4D is in - * @return if this Coord4D is replaceable - */ - public boolean isReplaceable(IBlockAccess world) - { - return getBlock(world).isReplaceable(world, 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); - } + /** + * 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); - @Override - public Coord4D clone() - { - return new Coord4D(xCoord, yCoord, zCoord, dimensionId); - } + return nbtTags; + } - @Override - public String toString() - { - return "[Coord4D: " + xCoord + ", " + yCoord + ", " + zCoord + ", dim=" + dimensionId + "]"; - } + /** + * 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); + } - @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; - } + /** + * 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); + } - @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; - } + /** + * 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; + } + + /** + * Translates this Coord4D by the defined Coord4D's coordinates, regardless of + * dimension. + * @param coord - coordinates to translate by + * @return translated Coord4D + */ + public Coord4D translate(Coord4D coord) { + translate(coord.xCoord, coord.yCoord, coord.zCoord); + + 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); + } + + /** + * Creates and returns a new Coord4D translated to the defined offsets of the side by + * the defined amount. + * @param side - side to translate this Coord4D to + * @param amount - how far to translate this Coord4D + * @return translated Coord4D + */ + public Coord4D getFromSide(ForgeDirection side, int amount) { + return new Coord4D( + xCoord + (side.offsetX * amount), + yCoord + (side.offsetY * amount), + zCoord + (side.offsetZ * amount), + dimensionId + ); + } + + public ItemStack getStack(IBlockAccess world) { + Block block = getBlock(world); + + if (block == null || block == Blocks.air) { + return null; + } + + return new ItemStack(block, 1, getMetadata(world)); + } + + /** + * 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 tag - 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() == null + || 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); + } + + /** + * Whether or not this block this Coord4D represents is replaceable. + * @param world - world this Coord4D is in + * @return if this Coord4D is replaceable + */ + public boolean isReplaceable(IBlockAccess world) { + return getBlock(world).isReplaceable(world, 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/main/java/mekanism/api/EnumColor.java b/src/main/java/mekanism/api/EnumColor.java index df9ba7433..58caa45bf 100644 --- a/src/main/java/mekanism/api/EnumColor.java +++ b/src/main/java/mekanism/api/EnumColor.java @@ -7,106 +7,101 @@ import net.minecraft.util.StatCollector; * @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, 255, 255}, 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 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, 255, 255 }, 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}; + 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; + /** The color code that will be displayed */ + public final String code; - public final int[] rgbCode; + public final int[] rgbCode; - public final int mcMeta; + public final int mcMeta; - /** A friendly name of the color. */ - public String unlocalizedName; - - public String dyeName; + /** A friendly name of the color. */ + public String unlocalizedName; - private EnumColor(String s, String n, String dye, int[] rgb, int meta) - { - code = s; - unlocalizedName = n; - dyeName = dye; - rgbCode = rgb; - mcMeta = meta; - } + public String dyeName; - /** - * Gets the localized name of this color by translating the unlocalized name. - * @return localized name - */ - public String getLocalizedName() - { - return StatCollector.translateToLocal("color." + unlocalizedName); - } + private EnumColor(String s, String n, String dye, int[] rgb, int meta) { + code = s; + unlocalizedName = n; + dyeName = dye; + rgbCode = rgb; + mcMeta = meta; + } - public String getDyeName() - { - return StatCollector.translateToLocal("dye." + unlocalizedName); - } - - public String getOreDictName() - { - return dyeName; - } + /** + * Gets the localized name of this color by translating the unlocalized name. + * @return localized name + */ + public String getLocalizedName() { + return StatCollector.translateToLocal("color." + unlocalizedName); + } - /** - * 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 getDyeName() { + return StatCollector.translateToLocal("dye." + unlocalizedName); + } - public String getDyedName() - { - return code + getDyeName(); - } + public String getOreDictName() { + return dyeName; + } - /** - * 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 name of this color with it's color prefix code. + * @return the color's name and color prefix + */ + public String getName() { + return code + getLocalizedName(); + } - /** - * 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; - } + public String getDyedName() { + return code + getDyeName(); + } - @Override - public String toString() - { - return code; - } + /** + * 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/main/java/mekanism/api/IAlloyInteraction.java b/src/main/java/mekanism/api/IAlloyInteraction.java index b2a2198d8..73ee9e282 100644 --- a/src/main/java/mekanism/api/IAlloyInteraction.java +++ b/src/main/java/mekanism/api/IAlloyInteraction.java @@ -7,12 +7,12 @@ import net.minecraft.entity.player.EntityPlayer; * @author aidancbrady * */ -public interface IAlloyInteraction -{ - /** - * Called when a player right-clicks this block with an alloy. - * @param player - the player right-clicking the block - * @param tierOrdinal - the ordinal tier of the alloy (1 = advanced, 2 = elite, 3 = ultimate) - */ - public void onAlloyInteraction(EntityPlayer player, int tierOrdinal); +public interface IAlloyInteraction { + /** + * Called when a player right-clicks this block with an alloy. + * @param player - the player right-clicking the block + * @param tierOrdinal - the ordinal tier of the alloy (1 = advanced, 2 = elite, 3 = + * ultimate) + */ + public void onAlloyInteraction(EntityPlayer player, int tierOrdinal); } diff --git a/src/main/java/mekanism/api/IClientTicker.java b/src/main/java/mekanism/api/IClientTicker.java index 228897370..b5c56ebf2 100644 --- a/src/main/java/mekanism/api/IClientTicker.java +++ b/src/main/java/mekanism/api/IClientTicker.java @@ -1,8 +1,7 @@ package mekanism.api; -public interface IClientTicker -{ - public void clientTick(); +public interface IClientTicker { + public void clientTick(); - public boolean needsTicks(); + public boolean needsTicks(); } diff --git a/src/main/java/mekanism/api/IConfigCardAccess.java b/src/main/java/mekanism/api/IConfigCardAccess.java index 881d8a035..bf100d11e 100644 --- a/src/main/java/mekanism/api/IConfigCardAccess.java +++ b/src/main/java/mekanism/api/IConfigCardAccess.java @@ -3,32 +3,33 @@ 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. + * 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 IConfigCardAccess -{ - public static interface ISpecialConfigData extends IConfigCardAccess - { - /** - * 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 getConfigurationData(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 setConfigurationData(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(); - } +public interface IConfigCardAccess { + public static interface ISpecialConfigData extends IConfigCardAccess { + /** + * 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 getConfigurationData(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 setConfigurationData(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/main/java/mekanism/api/IConfigurable.java b/src/main/java/mekanism/api/IConfigurable.java index 512fabf43..adc0dc32c 100644 --- a/src/main/java/mekanism/api/IConfigurable.java +++ b/src/main/java/mekanism/api/IConfigurable.java @@ -3,25 +3,25 @@ package mekanism.api; import net.minecraft.entity.player.EntityPlayer; /** - * Implement this in your TileEntity class if your block can be modified by a Configurator. + * 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); +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); + /** + * 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/main/java/mekanism/api/IEvaporationSolar.java b/src/main/java/mekanism/api/IEvaporationSolar.java index fd5d2cf7d..33f6a36df 100644 --- a/src/main/java/mekanism/api/IEvaporationSolar.java +++ b/src/main/java/mekanism/api/IEvaporationSolar.java @@ -1,11 +1,11 @@ package mekanism.api; /** - * Implement this class in a TileEntity if you wish for it to be able to heat up a Salination Plant. + * Implement this class in a TileEntity if you wish for it to be able to heat up a + * Salination Plant. * @author aidancbrady * */ -public interface IEvaporationSolar -{ - public boolean seesSun(); +public interface IEvaporationSolar { + public boolean seesSun(); } diff --git a/src/main/java/mekanism/api/IHeatTransfer.java b/src/main/java/mekanism/api/IHeatTransfer.java index da682e116..31af69dc5 100644 --- a/src/main/java/mekanism/api/IHeatTransfer.java +++ b/src/main/java/mekanism/api/IHeatTransfer.java @@ -2,27 +2,26 @@ package mekanism.api; import net.minecraftforge.common.util.ForgeDirection; -public interface IHeatTransfer -{ - /**The value of the zero point of our temperature scale in kelvin*/ - public static final double AMBIENT_TEMP = 300; +public interface IHeatTransfer { + /**The value of the zero point of our temperature scale in kelvin*/ + public static final double AMBIENT_TEMP = 300; - /**The heat transfer coefficient for air*/ - public static final double AIR_INVERSE_COEFFICIENT = 10000; + /**The heat transfer coefficient for air*/ + public static final double AIR_INVERSE_COEFFICIENT = 10000; - public double getTemp(); + public double getTemp(); - public double getInverseConductionCoefficient(); + public double getInverseConductionCoefficient(); - public double getInsulationCoefficient(ForgeDirection side); + public double getInsulationCoefficient(ForgeDirection side); - public void transferHeatTo(double heat); + public void transferHeatTo(double heat); - public double[] simulateHeat(); + public double[] simulateHeat(); - public double applyTemperatureChange(); + public double applyTemperatureChange(); - public boolean canConnectHeat(ForgeDirection side); + public boolean canConnectHeat(ForgeDirection side); - public IHeatTransfer getAdjacent(ForgeDirection side); + public IHeatTransfer getAdjacent(ForgeDirection side); } diff --git a/src/main/java/mekanism/api/IMekWrench.java b/src/main/java/mekanism/api/IMekWrench.java index 6ac4b052e..4d080af7d 100644 --- a/src/main/java/mekanism/api/IMekWrench.java +++ b/src/main/java/mekanism/api/IMekWrench.java @@ -2,7 +2,6 @@ package mekanism.api; import net.minecraft.entity.player.EntityPlayer; -public interface IMekWrench -{ - public boolean canUseWrench(EntityPlayer player, int x, int y, int z); +public interface IMekWrench { + public boolean canUseWrench(EntityPlayer player, int x, int y, int z); } diff --git a/src/main/java/mekanism/api/ItemRetriever.java b/src/main/java/mekanism/api/ItemRetriever.java index c2820f0bc..525df1033 100644 --- a/src/main/java/mekanism/api/ItemRetriever.java +++ b/src/main/java/mekanism/api/ItemRetriever.java @@ -10,103 +10,100 @@ import net.minecraft.item.ItemStack; * @author AidanBrady * */ -public final class ItemRetriever -{ - /** The 'MekanismItems' class that items are retrieved from. */ - private static Class MekanismItems; - - /** The 'MekanismBlocks' class that blocks are retrieved from. */ - private static Class MekanismBlocks; +public final class ItemRetriever { + /** The 'MekanismItems' class that items are retrieved from. */ + private static Class MekanismItems; - /** - * Attempts to retrieve an ItemStack of an item 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"); - * - * 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 'MekanismItems' class - * @return an ItemStack of the declared identifier, otherwise null. - */ - public static ItemStack getItem(String identifier) - { - try { - if(MekanismItems == null) - { - MekanismItems = Class.forName("mekanism.common.MekanismItems"); - } + /** The 'MekanismBlocks' class that blocks are retrieved from. */ + private static Class MekanismBlocks; - Object ret = MekanismItems.getField(identifier).get(null); + /** + * Attempts to retrieve an ItemStack of an item 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"); + * + * 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 'MekanismItems' class + * @return an ItemStack of the declared identifier, otherwise null. + */ + public static ItemStack getItem(String identifier) { + try { + if (MekanismItems == null) { + MekanismItems = Class.forName("mekanism.common.MekanismItems"); + } - if(ret instanceof Item) - { - return new ItemStack((Item)ret, 1); - } - else { - return null; - } - } catch(Exception e) { - System.err.println("Error retrieving item with identifier '" + identifier + "': " + e.getMessage()); - return null; - } - } - - /** - * Attempts to retrieve an ItemStack of a 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"); - * - * 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 'MekanismBlocks' class - * @return an ItemStack of the declared identifier, otherwise null. - */ - public static ItemStack getBlock(String identifier) - { - try { - if(MekanismBlocks == null) - { - MekanismBlocks = Class.forName("mekanism.common.MekanismBlocks"); - } + Object ret = MekanismItems.getField(identifier).get(null); - Object ret = MekanismBlocks.getField(identifier).get(null); + if (ret instanceof Item) { + return new ItemStack((Item) ret, 1); + } else { + return null; + } + } catch (Exception e) { + System.err.println( + "Error retrieving item with identifier '" + identifier + + "': " + e.getMessage() + ); + return null; + } + } - if(ret instanceof Block) - { - return new ItemStack((Block)ret, 1); - } - else { - return null; - } - } catch(Exception e) { - System.err.println("Error retrieving block with identifier '" + identifier + "': " + e.getMessage()); - return null; - } - } + /** + * Attempts to retrieve an ItemStack of a 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"); + * + * 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 'MekanismBlocks' class + * @return an ItemStack of the declared identifier, otherwise null. + */ + public static ItemStack getBlock(String identifier) { + try { + if (MekanismBlocks == null) { + MekanismBlocks = Class.forName("mekanism.common.MekanismBlocks"); + } + + Object ret = MekanismBlocks.getField(identifier).get(null); + + if (ret instanceof Block) { + return new ItemStack((Block) ret, 1); + } else { + return null; + } + } catch (Exception e) { + System.err.println( + "Error retrieving block with identifier '" + identifier + + "': " + e.getMessage() + ); + return null; + } + } } diff --git a/src/main/java/mekanism/api/MekanismAPI.java b/src/main/java/mekanism/api/MekanismAPI.java index 8594b6c44..6b57e6eaa 100644 --- a/src/main/java/mekanism/api/MekanismAPI.java +++ b/src/main/java/mekanism/api/MekanismAPI.java @@ -3,47 +3,42 @@ package mekanism.api; import java.util.HashSet; import java.util.Set; +import cpw.mods.fml.common.eventhandler.Event; import mekanism.api.util.BlockInfo; import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraftforge.oredict.OreDictionary; -import cpw.mods.fml.common.eventhandler.Event; -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(); - - /** Mekanism debug mode */ - public static boolean debug = false; +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; - } - } + /** Mekanism debug mode */ + public static boolean debug = false; - return true; - } + 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; + } + } - public static void addBoxBlacklist(Block block, int meta) - { - cardboardBoxIgnore.add(new BlockInfo(block, meta)); - } + return true; + } - public static void removeBoxBlacklist(Block block, int meta) - { - cardboardBoxIgnore.remove(new BlockInfo(block, meta)); - } + public static void addBoxBlacklist(Block block, int meta) { + cardboardBoxIgnore.add(new BlockInfo(block, meta)); + } - public static Set getBoxIgnore() - { - return cardboardBoxIgnore; - } + public static void removeBoxBlacklist(Block block, int meta) { + cardboardBoxIgnore.remove(new BlockInfo(block, meta)); + } - public static class BoxBlacklistEvent extends Event {} + public static Set getBoxIgnore() { + return cardboardBoxIgnore; + } + + public static class BoxBlacklistEvent extends Event {} } diff --git a/src/main/java/mekanism/api/MekanismConfig.java b/src/main/java/mekanism/api/MekanismConfig.java index 0edca9b8c..63742afd3 100644 --- a/src/main/java/mekanism/api/MekanismConfig.java +++ b/src/main/java/mekanism/api/MekanismConfig.java @@ -6,162 +6,153 @@ import java.util.Map; import mekanism.api.util.UnitDisplayUtils.EnergyType; import mekanism.api.util.UnitDisplayUtils.TempType; -public class MekanismConfig -{ - public static class general - { - public static boolean updateNotifications = true; - public static boolean controlCircuitOreDict = true; - public static boolean logPackets = false; - public static boolean dynamicTankEasterEgg = false; - public static boolean voiceServerEnabled = true; - public static boolean cardboardSpawners = true; - public static boolean enableWorldRegeneration = true; - public static boolean spawnBabySkeletons = true; - public static int obsidianTNTBlastRadius = 12; - public static int osmiumPerChunk = 12; - public static int copperPerChunk = 16; - public static int tinPerChunk = 14; - public static int saltPerChunk = 2; - public static int obsidianTNTDelay = 100; - public static int UPDATE_DELAY = 10; - public static int VOICE_PORT = 36123; - public static int maxUpgradeMultiplier = 10; - public static int userWorldGenVersion = 0; - public static double ENERGY_PER_REDSTONE = 10000; - public static int ETHENE_BURN_TIME = 40; - public static int METHANE_BURN_TIME = 10; - public static double DISASSEMBLER_USAGE = 10; - public static EnergyType energyUnit = EnergyType.J; - public static TempType tempUnit = TempType.K; - public static double TO_IC2; - public static double TO_TE; - public static double FROM_H2; - public static double FROM_IC2; - public static double FROM_TE; - public static int laserRange; - public static double laserEnergyNeededPerHardness; - public static double minerSilkMultiplier = 6; - public static boolean blacklistIC2; - public static boolean blacklistRF; - public static boolean destroyDisabledBlocks; - public static boolean prefilledFluidTanks; - public static boolean prefilledGasTanks; - public static double armoredJetpackDamageRatio; - public static int armoredJetpackDamageMax; - public static boolean aestheticWorldDamage; - public static boolean opsBypassRestrictions; - public static double thermalEvaporationSpeed; - public static int maxJetpackGas; - public static int maxScubaGas; - public static int maxFlamethrowerGas; - public static int maxPumpRange; - public static boolean pumpWaterSources; - public static int maxPlenisherNodes; - public static double evaporationHeatDissipation = 0.02; - public static double evaporationTempMultiplier = 0.1; - public static double evaporationSolarMultiplier = 0.2; - public static double evaporationMaxTemp = 3000; - public static double energyPerHeat = 1000; - public static double maxEnergyPerSteam = 100; - public static double superheatingHeatTransfer = 10000; - public static double heatPerFuelTick = 4; - public static boolean allowTransmitterAlloyUpgrade; - public static boolean allowProtection = true; - public static boolean EnableQuartzCompat; - public static boolean EnableDiamondCompat; - public static boolean EnablePoorOresCompat; - public static boolean OreDictOsmium; - public static boolean OreDictPlatinum; - public static int elementizerFailChanceMultiplier; - } +public class MekanismConfig { + public static class general { + public static boolean updateNotifications = true; + public static boolean controlCircuitOreDict = true; + public static boolean logPackets = false; + public static boolean dynamicTankEasterEgg = false; + public static boolean voiceServerEnabled = true; + public static boolean cardboardSpawners = true; + public static boolean enableWorldRegeneration = true; + public static boolean spawnBabySkeletons = true; + public static int obsidianTNTBlastRadius = 12; + public static int osmiumPerChunk = 12; + public static int copperPerChunk = 16; + public static int tinPerChunk = 14; + public static int saltPerChunk = 2; + public static int obsidianTNTDelay = 100; + public static int UPDATE_DELAY = 10; + public static int VOICE_PORT = 36123; + public static int maxUpgradeMultiplier = 10; + public static int userWorldGenVersion = 0; + public static double ENERGY_PER_REDSTONE = 10000; + public static int ETHENE_BURN_TIME = 40; + public static int METHANE_BURN_TIME = 10; + public static double DISASSEMBLER_USAGE = 10; + public static EnergyType energyUnit = EnergyType.J; + public static TempType tempUnit = TempType.K; + public static double TO_IC2; + public static double TO_TE; + public static double FROM_H2; + public static double FROM_IC2; + public static double FROM_TE; + public static int laserRange; + public static double laserEnergyNeededPerHardness; + public static double minerSilkMultiplier = 6; + public static boolean blacklistIC2; + public static boolean blacklistRF; + public static boolean destroyDisabledBlocks; + public static boolean prefilledFluidTanks; + public static boolean prefilledGasTanks; + public static double armoredJetpackDamageRatio; + public static int armoredJetpackDamageMax; + public static boolean aestheticWorldDamage; + public static boolean opsBypassRestrictions; + public static double thermalEvaporationSpeed; + public static int maxJetpackGas; + public static int maxScubaGas; + public static int maxFlamethrowerGas; + public static int maxPumpRange; + public static boolean pumpWaterSources; + public static int maxPlenisherNodes; + public static double evaporationHeatDissipation = 0.02; + public static double evaporationTempMultiplier = 0.1; + public static double evaporationSolarMultiplier = 0.2; + public static double evaporationMaxTemp = 3000; + public static double energyPerHeat = 1000; + public static double maxEnergyPerSteam = 100; + public static double superheatingHeatTransfer = 10000; + public static double heatPerFuelTick = 4; + public static boolean allowTransmitterAlloyUpgrade; + public static boolean allowProtection = true; + public static boolean EnableQuartzCompat; + public static boolean EnableDiamondCompat; + public static boolean EnablePoorOresCompat; + public static boolean OreDictOsmium; + public static boolean OreDictPlatinum; + public static int elementizerFailChanceMultiplier; + } - public static class client - { - public static boolean enablePlayerSounds = true; - public static boolean enableMachineSounds = true; - public static boolean holidays = true; - public static float baseSoundVolume = 1F; - public static boolean machineEffects = true; - public static boolean oldTransmitterRender = false; - public static boolean replaceSoundsWhenResuming = true; - public static boolean renderCTM = true; - public static boolean enableAmbientLighting; - public static int ambientLightingLevel; - public static boolean opaqueTransmitters = false; - public static boolean doMultiblockSparkle = true; - public static int multiblockSparkleIntensity = 6; - } - - public static class machines - { - private static Map config = new HashMap(); - - public static boolean isEnabled(String type) - { - return config.get(type) != null && config.get(type); - } - - public static void setEntry(String type, boolean enabled) - { - config.put(type, enabled); - } - } + public static class client { + public static boolean enablePlayerSounds = true; + public static boolean enableMachineSounds = true; + public static boolean holidays = true; + public static float baseSoundVolume = 1F; + public static boolean machineEffects = true; + public static boolean oldTransmitterRender = false; + public static boolean replaceSoundsWhenResuming = true; + public static boolean renderCTM = true; + public static boolean enableAmbientLighting; + public static int ambientLightingLevel; + public static boolean opaqueTransmitters = false; + public static boolean doMultiblockSparkle = true; + public static int multiblockSparkleIntensity = 6; + } - public static class usage - { - public static double enrichmentChamberUsage; - public static double osmiumCompressorUsage; - public static double combinerUsage; - public static double crusherUsage; - public static double factoryUsage; - public static double metallurgicInfuserUsage; - public static double purificationChamberUsage; - public static double energizedSmelterUsage; - public static double digitalMinerUsage; - public static double electricPumpUsage; - public static double rotaryCondensentratorUsage; - public static double oxidationChamberUsage; - public static double chemicalInfuserUsage; - public static double chemicalInjectionChamberUsage; - public static double precisionSawmillUsage; - public static double chemicalDissolutionChamberUsage; - public static double chemicalWasherUsage; - public static double chemicalCrystallizerUsage; - public static double seismicVibratorUsage; - public static double pressurizedReactionBaseUsage; - public static double fluidicPlenisherUsage; - public static double laserUsage; - public static double gasCentrifugeUsage; - public static double heavyWaterElectrolysisUsage; - public static double formulaicAssemblicatorUsage; - } + public static class machines { + private static Map config = new HashMap(); - public static class generators - { - public static double advancedSolarGeneration; - public static double bioGeneration; - public static double heatGeneration; - public static double heatGenerationLava; - public static double heatGenerationNether; - public static int heatGenerationFluidRate; - public static boolean heatGenEnable; - public static double solarGeneration; + public static boolean isEnabled(String type) { + return config.get(type) != null && config.get(type); + } - public static double windGenerationMin; - public static double windGenerationMax; + public static void setEntry(String type, boolean enabled) { + config.put(type, enabled); + } + } - public static int windGenerationMinY; - public static int windGenerationMaxY; - - public static int turbineBladesPerCoil; - public static double turbineVentGasFlow; - public static double turbineDisperserGasFlow; - public static int condenserRate; - } + public static class usage { + public static double enrichmentChamberUsage; + public static double osmiumCompressorUsage; + public static double combinerUsage; + public static double crusherUsage; + public static double factoryUsage; + public static double metallurgicInfuserUsage; + public static double purificationChamberUsage; + public static double energizedSmelterUsage; + public static double digitalMinerUsage; + public static double electricPumpUsage; + public static double rotaryCondensentratorUsage; + public static double oxidationChamberUsage; + public static double chemicalInfuserUsage; + public static double chemicalInjectionChamberUsage; + public static double precisionSawmillUsage; + public static double chemicalDissolutionChamberUsage; + public static double chemicalWasherUsage; + public static double chemicalCrystallizerUsage; + public static double seismicVibratorUsage; + public static double pressurizedReactionBaseUsage; + public static double fluidicPlenisherUsage; + public static double laserUsage; + public static double gasCentrifugeUsage; + public static double heavyWaterElectrolysisUsage; + public static double formulaicAssemblicatorUsage; + } - public static class tools - { - public static double armorSpawnRate; - } + public static class generators { + public static double advancedSolarGeneration; + public static double bioGeneration; + public static double heatGeneration; + public static double heatGenerationLava; + public static double heatGenerationNether; + public static int heatGenerationFluidRate; + public static boolean heatGenEnable; + public static double solarGeneration; + + public static double windGenerationMin; + public static double windGenerationMax; + + public static int windGenerationMinY; + public static int windGenerationMaxY; + + public static int turbineBladesPerCoil; + public static double turbineVentGasFlow; + public static double turbineDisperserGasFlow; + public static int condenserRate; + } + + public static class tools { + public static double armorSpawnRate; + } } diff --git a/src/main/java/mekanism/api/Pos3D.java b/src/main/java/mekanism/api/Pos3D.java index 75f83a048..96068418b 100644 --- a/src/main/java/mekanism/api/Pos3D.java +++ b/src/main/java/mekanism/api/Pos3D.java @@ -14,228 +14,213 @@ import net.minecraftforge.common.util.ForgeDirection; * @author aidancbrady * */ -public class Pos3D -{ - public double xPos; - public double yPos; - public double zPos; +public class Pos3D { + public double xPos; + public double yPos; + public double zPos; - public Pos3D() - { - this(0, 0, 0); - } - - public Pos3D(Vec3 vec) - { - xPos = vec.xCoord; - yPos = vec.yCoord; - zPos = vec.zCoord; - } - - public Pos3D(MovingObjectPosition mop) - { - xPos = mop.blockX; - yPos = mop.blockY; - zPos = mop.blockZ; - } + 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; - } + public Pos3D(Vec3 vec) { + xPos = vec.xCoord; + yPos = vec.yCoord; + zPos = vec.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); - } + public Pos3D(MovingObjectPosition mop) { + xPos = mop.blockX; + yPos = mop.blockY; + zPos = mop.blockZ; + } - /** - * 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); - } - - /** - * Returns a new Pos3D from a tag compound. - * @param tag - tag compound to read from - * @return the Pos3D from the tag compound - */ - public static Pos3D read(NBTTagCompound tag) - { + 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); + } + + /** + * Returns a new Pos3D from a tag compound. + * @param tag - tag compound to read from + * @return the Pos3D from the tag compound + */ + public static Pos3D read(NBTTagCompound tag) { return new Pos3D(tag.getDouble("x"), tag.getDouble("y"), tag.getDouble("z")); } - + /** - * Writes this Pos3D's data to an NBTTagCompound. - * @param nbtTags - tag compound to write to - * @return the tag compound with this Pos3D's data - */ - public NBTTagCompound write(NBTTagCompound nbtTags) - { - nbtTags.setDouble("x", xPos); - nbtTags.setDouble("y", yPos); - nbtTags.setDouble("z", zPos); + * Writes this Pos3D's data to an NBTTagCompound. + * @param nbtTags - tag compound to write to + * @return the tag compound with this Pos3D's data + */ + public NBTTagCompound write(NBTTagCompound nbtTags) { + nbtTags.setDouble("x", xPos); + nbtTags.setDouble("y", yPos); + nbtTags.setDouble("z", zPos); - return nbtTags; - } + return nbtTags; + } - /** - * 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 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 Pos3D representing the motion of the given entity - */ - public static Pos3D fromMotion(Entity entity) - { - return new Pos3D(entity.motionX, entity.motionY, entity.motionZ); - } + /** + * Creates a new Pos3D from the motion of an entity. + * @param entity + * @return Pos3D representing the motion of the given entity + */ + public static Pos3D fromMotion(Entity entity) { + return new Pos3D(entity.motionX, entity.motionY, entity.motionZ); + } /** * Creates a new Coord4D representing this Pos3D in the provided dimension. * @param dimensionId - the dimension this Pos3D is in * @return Coord4D representing this Pos3D */ - public Coord4D getCoord(int dimensionId) - { - return new Coord4D((int)xPos, (int)yPos, (int)zPos, dimensionId); + public Coord4D getCoord(int dimensionId) { + return new Coord4D((int) xPos, (int) yPos, (int) zPos, dimensionId); } - /** - * Centres a block-derived Pos3D - */ - public Pos3D centre() - { - return translate(0.5, 0.5, 0.5); - } + /** + * Centres a block-derived Pos3D + */ + public Pos3D centre() { + return translate(0.5, 0.5, 0.5); + } - /** - * 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; + /** + * 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; - } + 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); - } + /** + * 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); + } - /** - * Performs the same operation as translate(x, y, z), but by a set amount in a ForgeDirection - */ - public Pos3D translate(ForgeDirection direction, double amount) - { - return translate(direction.offsetX * amount, direction.offsetY * amount, direction.offsetZ * amount); - } + /** + * Performs the same operation as translate(x, y, z), but by a set amount in a + * ForgeDirection + */ + public Pos3D translate(ForgeDirection direction, double amount) { + return translate( + direction.offsetX * amount, + direction.offsetY * amount, + direction.offsetZ * amount + ); + } - /** - * Performs the same operation as translate(x, y, z), but by a set amount in a ForgeDirection - */ - public Pos3D translateExcludingSide(ForgeDirection direction, double amount) - { - if(direction.offsetX == 0) xPos += amount; - if(direction.offsetY == 0) yPos += amount; - if(direction.offsetZ == 0) zPos += amount; + /** + * Performs the same operation as translate(x, y, z), but by a set amount in a + * ForgeDirection + */ + public Pos3D translateExcludingSide(ForgeDirection direction, double amount) { + if (direction.offsetX == 0) + xPos += amount; + if (direction.offsetY == 0) + yPos += amount; + if (direction.offsetZ == 0) + zPos += amount; - return this; - } + return this; + } - /** - * 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); - } + /** + * 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); + /** + * 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; + double x = xPos; + double z = zPos; - if(yaw != 0) - { - xPos = x * Math.cos(yawRadians) - z * Math.sin(yawRadians); - zPos = z * Math.cos(yawRadians) + x * Math.sin(yawRadians); - } + if (yaw != 0) { + xPos = x * Math.cos(yawRadians) - z * Math.sin(yawRadians); + zPos = z * Math.cos(yawRadians) + x * Math.sin(yawRadians); + } - return this; - } - - public Pos3D rotatePitch(double pitch) - { - double pitchRadians = Math.toRadians(pitch); - - double y = yPos; - double z = zPos; - - if(pitch != 0) - { - yPos = y * Math.cos(pitchRadians) - z * Math.sin(pitchRadians); - zPos = z * Math.cos(pitchRadians) + y * Math.sin(pitchRadians); - } - - return this; - } - - public Pos3D rotate(double yaw, double pitch) - { - return rotate(yaw, pitch, 0); - } + return this; + } - public Pos3D rotate(double yaw, double pitch, double roll) - { + public Pos3D rotatePitch(double pitch) { + double pitchRadians = Math.toRadians(pitch); + + double y = yPos; + double z = zPos; + + if (pitch != 0) { + yPos = y * Math.cos(pitchRadians) - z * Math.sin(pitchRadians); + zPos = z * Math.cos(pitchRadians) + y * Math.sin(pitchRadians); + } + + return this; + } + + public Pos3D rotate(double yaw, double pitch) { + return rotate(yaw, pitch, 0); + } + + public Pos3D rotate(double yaw, double pitch, double roll) { double yawRadians = Math.toRadians(yaw); double pitchRadians = Math.toRadians(pitch); double rollRadians = Math.toRadians(roll); @@ -244,215 +229,206 @@ public class Pos3D double y = yPos; double z = zPos; - xPos = x * Math.cos(yawRadians) * Math.cos(pitchRadians) + z * (Math.cos(yawRadians) * Math.sin(pitchRadians) * Math.sin(rollRadians) - Math.sin(yawRadians) * Math.cos(rollRadians)) + y * (Math.cos(yawRadians) * Math.sin(pitchRadians) * Math.cos(rollRadians) + Math.sin(yawRadians) * Math.sin(rollRadians)); - zPos = x * Math.sin(yawRadians) * Math.cos(pitchRadians) + z * (Math.sin(yawRadians) * Math.sin(pitchRadians) * Math.sin(rollRadians) + Math.cos(yawRadians) * Math.cos(rollRadians)) + y * (Math.sin(yawRadians) * Math.sin(pitchRadians) * Math.cos(rollRadians) - Math.cos(yawRadians) * Math.sin(rollRadians)); - yPos = -x * Math.sin(pitchRadians) + z * Math.cos(pitchRadians) * Math.sin(rollRadians) + y * Math.cos(pitchRadians) * Math.cos(rollRadians); - + xPos = x * Math.cos(yawRadians) * Math.cos(pitchRadians) + + z + * (Math.cos(yawRadians) * Math.sin(pitchRadians) * Math.sin(rollRadians) + - Math.sin(yawRadians) * Math.cos(rollRadians)) + + y + * (Math.cos(yawRadians) * Math.sin(pitchRadians) * Math.cos(rollRadians) + + Math.sin(yawRadians) * Math.sin(rollRadians)); + zPos = x * Math.sin(yawRadians) * Math.cos(pitchRadians) + + z + * (Math.sin(yawRadians) * Math.sin(pitchRadians) * Math.sin(rollRadians) + + Math.cos(yawRadians) * Math.cos(rollRadians)) + + y + * (Math.sin(yawRadians) * Math.sin(pitchRadians) * Math.cos(rollRadians) + - Math.cos(yawRadians) * Math.sin(rollRadians)); + yPos = -x * Math.sin(pitchRadians) + + z * Math.cos(pitchRadians) * Math.sin(rollRadians) + + y * Math.cos(pitchRadians) * Math.cos(rollRadians); + return this; } - - public Pos3D multiply(Pos3D pos) - { - xPos *= pos.xPos; - yPos *= pos.yPos; - zPos *= pos.zPos; - - 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; + public Pos3D multiply(Pos3D pos) { + xPos *= pos.xPos; + yPos *= pos.yPos; + zPos *= pos.zPos; - return this; - } + 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); - } - - public Pos3D rotate(float angle, Pos3D axis) - { - return translateMatrix(getRotationMatrix(angle, axis), 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; - public double[] getRotationMatrix(float angle) - { - double[] matrix = new double[16]; - Pos3D axis = clone().normalize(); - - double x = axis.xPos; - double y = axis.yPos; - double z = axis.zPos; - - angle *= 0.0174532925D; - - float cos = (float)Math.cos(angle); - float ocos = 1.0F - cos; - float sin = (float)Math.sin(angle); - - matrix[0] = (x * x * ocos + cos); - matrix[1] = (y * x * ocos + z * sin); - matrix[2] = (x * z * ocos - y * sin); - matrix[4] = (x * y * ocos - z * sin); - matrix[5] = (y * y * ocos + cos); - matrix[6] = (y * z * ocos + x * sin); - matrix[8] = (x * z * ocos + y * sin); - matrix[9] = (y * z * ocos - x * sin); - matrix[10] = (z * z * ocos + cos); - matrix[15] = 1.0F; - - return matrix; - } + return this; + } - public static Pos3D translateMatrix(double[] matrix, Pos3D translation) - { - double x = translation.xPos * matrix[0] + translation.yPos * matrix[1] + translation.zPos * matrix[2] + matrix[3]; - double y = translation.xPos * matrix[4] + translation.yPos * matrix[5] + translation.zPos * matrix[6] + matrix[7]; - double z = translation.xPos * matrix[8] + translation.yPos * matrix[9] + translation.zPos * matrix[10] + matrix[11]; - - translation.xPos = x; - translation.yPos = y; - translation.zPos = z; - - return translation; - } + /** + * 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); + } - public static double[] getRotationMatrix(float angle, Pos3D axis) - { - return axis.getRotationMatrix(angle); - } - - public double anglePreNorm(Pos3D pos2) - { - return Math.acos(dotProduct(pos2)); - } + public Pos3D rotate(float angle, Pos3D axis) { + return translateMatrix(getRotationMatrix(angle, axis), this); + } - public static double anglePreNorm(Pos3D pos1, Pos3D pos2) - { - return Math.acos(pos1.clone().dotProduct(pos2)); - } - - public double dotProduct(Pos3D pos) - { - return xPos * pos.xPos + yPos * pos.yPos + zPos * pos.zPos; - } - - public Pos3D crossProduct(Pos3D compare) - { - return clone().toCrossProduct(compare); - } - - public Pos3D toCrossProduct(Pos3D compare) - { - double newX = yPos * compare.zPos - zPos * compare.yPos; - double newY = zPos * compare.xPos - xPos * compare.zPos; - double newZ = xPos * compare.yPos - yPos * compare.xPos; - - xPos = newX; - yPos = newY; - zPos = newZ; - - return this; - } + public double[] getRotationMatrix(float angle) { + double[] matrix = new double[16]; + Pos3D axis = clone().normalize(); - public Pos3D xCrossProduct() - { - return new Pos3D(0.0D, zPos, -yPos); - } + double x = axis.xPos; + double y = axis.yPos; + double z = axis.zPos; - public Pos3D zCrossProduct() - { - return new Pos3D(-yPos, xPos, 0.0D); - } - - public Pos3D getPerpendicular() - { - if(zPos == 0) - { - return zCrossProduct(); - } + angle *= 0.0174532925D; - return xCrossProduct(); - } - - public Pos3D floor() - { - return new Pos3D(Math.floor(xPos), Math.floor(yPos), Math.floor(zPos)); - } + float cos = (float) Math.cos(angle); + float ocos = 1.0F - cos; + float sin = (float) Math.sin(angle); - public double getMagnitude() - { + matrix[0] = (x * x * ocos + cos); + matrix[1] = (y * x * ocos + z * sin); + matrix[2] = (x * z * ocos - y * sin); + matrix[4] = (x * y * ocos - z * sin); + matrix[5] = (y * y * ocos + cos); + matrix[6] = (y * z * ocos + x * sin); + matrix[8] = (x * z * ocos + y * sin); + matrix[9] = (y * z * ocos - x * sin); + matrix[10] = (z * z * ocos + cos); + matrix[15] = 1.0F; + + return matrix; + } + + public static Pos3D translateMatrix(double[] matrix, Pos3D translation) { + double x = translation.xPos * matrix[0] + translation.yPos * matrix[1] + + translation.zPos * matrix[2] + matrix[3]; + double y = translation.xPos * matrix[4] + translation.yPos * matrix[5] + + translation.zPos * matrix[6] + matrix[7]; + double z = translation.xPos * matrix[8] + translation.yPos * matrix[9] + + translation.zPos * matrix[10] + matrix[11]; + + translation.xPos = x; + translation.yPos = y; + translation.zPos = z; + + return translation; + } + + public static double[] getRotationMatrix(float angle, Pos3D axis) { + return axis.getRotationMatrix(angle); + } + + public double anglePreNorm(Pos3D pos2) { + return Math.acos(dotProduct(pos2)); + } + + public static double anglePreNorm(Pos3D pos1, Pos3D pos2) { + return Math.acos(pos1.clone().dotProduct(pos2)); + } + + public double dotProduct(Pos3D pos) { + return xPos * pos.xPos + yPos * pos.yPos + zPos * pos.zPos; + } + + public Pos3D crossProduct(Pos3D compare) { + return clone().toCrossProduct(compare); + } + + public Pos3D toCrossProduct(Pos3D compare) { + double newX = yPos * compare.zPos - zPos * compare.yPos; + double newY = zPos * compare.xPos - xPos * compare.zPos; + double newZ = xPos * compare.yPos - yPos * compare.xPos; + + xPos = newX; + yPos = newY; + zPos = newZ; + + return this; + } + + public Pos3D xCrossProduct() { + return new Pos3D(0.0D, zPos, -yPos); + } + + public Pos3D zCrossProduct() { + return new Pos3D(-yPos, xPos, 0.0D); + } + + public Pos3D getPerpendicular() { + if (zPos == 0) { + return zCrossProduct(); + } + + return xCrossProduct(); + } + + public Pos3D floor() { + return new Pos3D(Math.floor(xPos), Math.floor(yPos), Math.floor(zPos)); + } + + public double getMagnitude() { return Math.sqrt(xPos * xPos + yPos * yPos + zPos * zPos); } - public Pos3D normalize() - { + public Pos3D normalize() { double d = getMagnitude(); - if (d != 0) - { + if (d != 0) { this.scale(1 / d); } return this; } - public static AxisAlignedBB getAABB(Pos3D pos1, Pos3D pos2) - { - return AxisAlignedBB.getBoundingBox( - Math.min(pos1.xPos, pos2.xPos), - Math.min(pos1.yPos, pos2.yPos), - Math.min(pos1.zPos, pos2.zPos), - Math.max(pos1.xPos, pos2.xPos), - Math.max(pos1.yPos, pos2.yPos), - Math.max(pos1.zPos, pos2.zPos) - ); - } + public static AxisAlignedBB getAABB(Pos3D pos1, Pos3D pos2) { + return AxisAlignedBB.getBoundingBox( + Math.min(pos1.xPos, pos2.xPos), + Math.min(pos1.yPos, pos2.yPos), + Math.min(pos1.zPos, pos2.zPos), + Math.max(pos1.xPos, pos2.xPos), + Math.max(pos1.yPos, pos2.yPos), + Math.max(pos1.zPos, pos2.zPos) + ); + } - @Override - public Pos3D clone() - { - return new Pos3D(xPos, yPos, zPos); - } + @Override + public Pos3D clone() { + return new Pos3D(xPos, yPos, zPos); + } - @Override - public String toString() - { - return "[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 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; - } + @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/main/java/mekanism/api/Range4D.java b/src/main/java/mekanism/api/Range4D.java index 40905a66d..274de560f 100644 --- a/src/main/java/mekanism/api/Range4D.java +++ b/src/main/java/mekanism/api/Range4D.java @@ -1,114 +1,107 @@ package mekanism.api; -import net.minecraft.entity.player.EntityPlayer; import cpw.mods.fml.common.FMLCommonHandler; +import net.minecraft.entity.player.EntityPlayer; -public class Range4D -{ - public int dimensionId; - - public int xMin; - public int yMin; - public int zMin; - public int xMax; - public int yMax; - public int zMax; - - public Range4D(int minX, int minY, int minZ, int maxX, int maxY, int maxZ, int dimension) - { - xMin = minX; - yMin = minY; - zMin = minZ; - xMax = maxX; - yMax = maxY; - zMax = maxZ; - - dimensionId = dimension; - } - - public Range4D(Chunk3D chunk) - { - xMin = chunk.xCoord*16; - yMin = 0; - zMin = chunk.zCoord*16; - xMax = xMin+16; - yMax = 255; - zMax = zMin+16; - - dimensionId = chunk.dimensionId; - } - - public Range4D(Coord4D coord) - { - xMin = coord.xCoord; - yMin = coord.yCoord; - zMin = coord.zCoord; - - xMax = coord.xCoord+1; - yMax = coord.yCoord+1; - zMax = coord.zCoord+1; - - dimensionId = coord.dimensionId; - } - - public static Range4D getChunkRange(EntityPlayer player) - { - int radius = FMLCommonHandler.instance().getMinecraftServerInstance().getConfigurationManager().getViewDistance(); - - return new Range4D(new Chunk3D(player)).expandChunks(radius); - } - - public Range4D expandChunks(int chunks) - { - xMin -= chunks*16; - xMax += chunks*16; - zMin -= chunks*16; - zMax += chunks*16; - - return this; - } - - public boolean intersects(Range4D range) - { - return (xMax+1 - 1.E-05D > range.xMin) && (range.xMax+1 - 1.E-05D > xMin) && (yMax+1 - 1.E-05D > range.yMin) && (range.yMax+1 - 1.E-05D > yMin) && (zMax+1 - 1.E-05D > range.zMin) && (range.zMax+1 - 1.E-05D > zMin); - } - - @Override - public Range4D clone() - { - return new Range4D(xMin, yMin, zMin, xMax, yMax, zMax, dimensionId); - } +public class Range4D { + public int dimensionId; - @Override - public String toString() - { - return "[Range4D: " + xMin + ", " + yMin + ", " + zMin + ", " + xMax + ", " + yMax + ", " + zMax + ", dim=" + dimensionId + "]"; - } + public int xMin; + public int yMin; + public int zMin; + public int xMax; + public int yMax; + public int zMax; - @Override - public boolean equals(Object obj) - { - return obj instanceof Range4D && - ((Range4D)obj).xMin == xMin && - ((Range4D)obj).yMin == yMin && - ((Range4D)obj).zMin == zMin && - ((Range4D)obj).xMax == xMax && - ((Range4D)obj).yMax == yMax && - ((Range4D)obj).zMax == zMax && - ((Range4D)obj).dimensionId == dimensionId; - } + public Range4D( + int minX, int minY, int minZ, int maxX, int maxY, int maxZ, int dimension + ) { + xMin = minX; + yMin = minY; + zMin = minZ; + xMax = maxX; + yMax = maxY; + zMax = maxZ; - @Override - public int hashCode() - { - int code = 1; - code = 31 * code + xMin; - code = 31 * code + yMin; - code = 31 * code + zMin; - code = 31 * code + xMax; - code = 31 * code + yMax; - code = 31 * code + zMax; - code = 31 * code + dimensionId; - return code; - } + dimensionId = dimension; + } + + public Range4D(Chunk3D chunk) { + xMin = chunk.xCoord * 16; + yMin = 0; + zMin = chunk.zCoord * 16; + xMax = xMin + 16; + yMax = 255; + zMax = zMin + 16; + + dimensionId = chunk.dimensionId; + } + + public Range4D(Coord4D coord) { + xMin = coord.xCoord; + yMin = coord.yCoord; + zMin = coord.zCoord; + + xMax = coord.xCoord + 1; + yMax = coord.yCoord + 1; + zMax = coord.zCoord + 1; + + dimensionId = coord.dimensionId; + } + + public static Range4D getChunkRange(EntityPlayer player) { + int radius = FMLCommonHandler.instance() + .getMinecraftServerInstance() + .getConfigurationManager() + .getViewDistance(); + + return new Range4D(new Chunk3D(player)).expandChunks(radius); + } + + public Range4D expandChunks(int chunks) { + xMin -= chunks * 16; + xMax += chunks * 16; + zMin -= chunks * 16; + zMax += chunks * 16; + + return this; + } + + public boolean intersects(Range4D range) { + return (xMax + 1 - 1.E-05D > range.xMin) && (range.xMax + 1 - 1.E-05D > xMin) + && (yMax + 1 - 1.E-05D > range.yMin) && (range.yMax + 1 - 1.E-05D > yMin) + && (zMax + 1 - 1.E-05D > range.zMin) && (range.zMax + 1 - 1.E-05D > zMin); + } + + @Override + public Range4D clone() { + return new Range4D(xMin, yMin, zMin, xMax, yMax, zMax, dimensionId); + } + + @Override + public String toString() { + return "[Range4D: " + xMin + ", " + yMin + ", " + zMin + ", " + xMax + ", " + yMax + + ", " + zMax + ", dim=" + dimensionId + "]"; + } + + @Override + public boolean equals(Object obj) { + return obj instanceof Range4D && ((Range4D) obj).xMin == xMin + && ((Range4D) obj).yMin == yMin && ((Range4D) obj).zMin == zMin + && ((Range4D) obj).xMax == xMax && ((Range4D) obj).yMax == yMax + && ((Range4D) obj).zMax == zMax && ((Range4D) obj).dimensionId == dimensionId; + } + + @Override + public int hashCode() { + int code = 1; + code = 31 * code + xMin; + code = 31 * code + yMin; + code = 31 * code + zMin; + code = 31 * code + xMax; + code = 31 * code + yMax; + code = 31 * code + zMax; + code = 31 * code + dimensionId; + return code; + } } diff --git a/src/main/java/mekanism/api/TabProxy.java b/src/main/java/mekanism/api/TabProxy.java index c562c0247..1d571050f 100644 --- a/src/main/java/mekanism/api/TabProxy.java +++ b/src/main/java/mekanism/api/TabProxy.java @@ -7,36 +7,32 @@ import net.minecraft.creativetab.CreativeTabs; * @author AidanBrady * */ -public final class TabProxy -{ - /** The 'Mekanism' class where the tab instance is stored. */ - public static Class Mekanism; +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"); - } + /** + * 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); + Object ret = Mekanism.getField("tabMekanism").get(null); - if(ret instanceof CreativeTabs) - { - return (CreativeTabs)ret; - } + if (ret instanceof CreativeTabs) { + return (CreativeTabs) ret; + } - return preferred; - } catch(Exception e) { - System.err.println("Error retrieving Mekanism creative tab."); - return preferred; - } - } + return preferred; + } catch (Exception e) { + System.err.println("Error retrieving Mekanism creative tab."); + return preferred; + } + } } diff --git a/src/main/java/mekanism/api/energy/EnergizedItemManager.java b/src/main/java/mekanism/api/energy/EnergizedItemManager.java index 165bdf608..060395c9b 100644 --- a/src/main/java/mekanism/api/energy/EnergizedItemManager.java +++ b/src/main/java/mekanism/api/energy/EnergizedItemManager.java @@ -2,59 +2,66 @@ 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(); +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); + 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 energyToUse; + } + } + } - return 0; - } + 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(); + /** + * 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); + 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 energyToSend; + } + } + } - return 0; - } + return 0; + } } diff --git a/src/main/java/mekanism/api/energy/EnergyStack.java b/src/main/java/mekanism/api/energy/EnergyStack.java index 3f5762186..ab6397c9e 100644 --- a/src/main/java/mekanism/api/energy/EnergyStack.java +++ b/src/main/java/mekanism/api/energy/EnergyStack.java @@ -3,12 +3,10 @@ package mekanism.api.energy; /** * Created by ben on 27/03/15. */ -public class EnergyStack -{ - public double amount; +public class EnergyStack { + public double amount; - public EnergyStack(double newAmount) - { - amount = newAmount; - } + public EnergyStack(double newAmount) { + amount = newAmount; + } } diff --git a/src/main/java/mekanism/api/energy/ICableOutputter.java b/src/main/java/mekanism/api/energy/ICableOutputter.java index 015379c03..0252046e8 100644 --- a/src/main/java/mekanism/api/energy/ICableOutputter.java +++ b/src/main/java/mekanism/api/energy/ICableOutputter.java @@ -3,16 +3,16 @@ 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. + * 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); +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/main/java/mekanism/api/energy/IEnergizedItem.java b/src/main/java/mekanism/api/energy/IEnergizedItem.java index bcfb5ca29..ae93978d6 100644 --- a/src/main/java/mekanism/api/energy/IEnergizedItem.java +++ b/src/main/java/mekanism/api/energy/IEnergizedItem.java @@ -7,47 +7,46 @@ import net.minecraft.item.ItemStack; * @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); +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); + /** + * 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 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 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 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); + /** + * 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); } diff --git a/src/main/java/mekanism/api/energy/IStrictEnergyAcceptor.java b/src/main/java/mekanism/api/energy/IStrictEnergyAcceptor.java index 53edc68e6..bdb7604bf 100644 --- a/src/main/java/mekanism/api/energy/IStrictEnergyAcceptor.java +++ b/src/main/java/mekanism/api/energy/IStrictEnergyAcceptor.java @@ -3,23 +3,23 @@ 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. + * 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); +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); + /** + * 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/main/java/mekanism/api/energy/IStrictEnergyStorage.java b/src/main/java/mekanism/api/energy/IStrictEnergyStorage.java index fd560fa18..7a6d8012c 100644 --- a/src/main/java/mekanism/api/energy/IStrictEnergyStorage.java +++ b/src/main/java/mekanism/api/energy/IStrictEnergyStorage.java @@ -1,27 +1,27 @@ package mekanism.api.energy; /** - * Mekanism-specific energy storage for TileEntities, already implemented in IStrictEnergyAcceptor. + * 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(); +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); + /** + * 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(); + /** + * Gets the maximum amount of energy this TileEntity can store. + * @return maximum energy + */ + public double getMaxEnergy(); } diff --git a/src/main/java/mekanism/api/energy/package-info.java b/src/main/java/mekanism/api/energy/package-info.java index 23773a37d..d69b94b65 100644 --- a/src/main/java/mekanism/api/energy/package-info.java +++ b/src/main/java/mekanism/api/energy/package-info.java @@ -1,4 +1,3 @@ @API(apiVersion = "9.0.0", owner = "Mekanism", provides = "MekanismAPI|energy") package mekanism.api.energy; import cpw.mods.fml.common.API; - diff --git a/src/main/java/mekanism/api/gas/Gas.java b/src/main/java/mekanism/api/gas/Gas.java index f05be52c6..a9eeda4de 100644 --- a/src/main/java/mekanism/api/gas/Gas.java +++ b/src/main/java/mekanism/api/gas/Gas.java @@ -11,211 +11,190 @@ import net.minecraftforge.fluids.FluidRegistry; * @author aidancbrady * */ -public class Gas -{ - private String name; +public class Gas { + private String name; - private String unlocalizedName; + private String unlocalizedName; - private Fluid fluid; + private Fluid fluid; - private IIcon icon; + private IIcon icon; - private boolean visible = true; + private boolean visible = true; - private boolean from_fluid = false; + 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 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; - } + /** + * 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; - } + /** + * 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; - } + /** + * 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; + /** + * 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; - } + return this; + } - /** - * Gets the unlocalized name of this Gas. - * @return this Gas's unlocalized name - */ - public String getUnlocalizedName() - { - return "gas." + unlocalizedName; - } + /** + * 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()); - } + /** + * 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; + /** + * 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; - } + return this; + } - /** - * Gets the IIcon associated with this Gas. - * @return associated IIcon - */ - public IIcon getIcon() - { - if(from_fluid) - { - return this.getFluid().getIcon(); - } - - return icon; - } + /** + * Gets the IIcon associated with this Gas. + * @return associated IIcon + */ + public IIcon getIcon() { + if (from_fluid) { + return this.getFluid().getIcon(); + } - /** - * Sets this gas's icon. - * @param i - IIcon to associate with this Gas - * @return this Gas object - */ - public Gas setIcon(IIcon i) - { - icon = i; + return icon; + } - if(hasFluid()) - { - fluid.setIcons(getIcon()); - } - - from_fluid = false; - - return this; - } + /** + * Sets this gas's icon. + * @param i - IIcon to associate with this Gas + * @return this Gas object + */ + public Gas setIcon(IIcon i) { + icon = i; - /** - * Gets the ID associated with this gas. - * @return the associated gas ID - */ - public int getID() - { - return GasRegistry.getGasID(this); - } + if (hasFluid()) { + fluid.setIcons(getIcon()); + } - /** - * 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()); + from_fluid = false; - return nbtTags; - } + return this; + } - /** - * 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; - } + /** + * Gets the ID associated with this gas. + * @return the associated gas ID + */ + public int getID() { + return GasRegistry.getGasID(this); + } - return GasRegistry.getGas(nbtTags.getString("gasName")); - } + /** + * 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()); - /** - * Whether or not this Gas has an associated fluid. - * @return if this gas has a fluid - */ - public boolean hasFluid() - { - return fluid != null; - } + return nbtTags; + } - /** - * Gets the fluid associated with this Gas. - * @return fluid associated with this gas - */ - public Fluid getFluid() - { - return fluid; - } + /** + * 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; + } - /** - * 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 GasRegistry.getGas(nbtTags.getString("gasName")); + } - return this; - } + /** + * Whether or not this Gas has an associated fluid. + * @return if this gas has a fluid + */ + public boolean hasFluid() { + return fluid != null; + } - @Override - public String toString() - { - return name; - } + /** + * 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/main/java/mekanism/api/gas/GasNetwork.java b/src/main/java/mekanism/api/gas/GasNetwork.java index 688c63bca..33588ce68 100644 --- a/src/main/java/mekanism/api/gas/GasNetwork.java +++ b/src/main/java/mekanism/api/gas/GasNetwork.java @@ -7,6 +7,9 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import com.google.common.collect.Lists; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.Event; import mekanism.api.Coord4D; import mekanism.api.transmitters.DynamicNetwork; import mekanism.api.transmitters.IGridTransmitter; @@ -14,352 +17,302 @@ import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.ForgeDirection; -import com.google.common.collect.Lists; - -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. + * 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 class GasNetwork extends DynamicNetwork { + public int transferDelay = 0; - public boolean didTransfer; - public boolean prevTransfer; + public boolean didTransfer; + public boolean prevTransfer; - public float gasScale; + public float gasScale; - public Gas refGas; + public Gas refGas; - public GasStack buffer; - public int prevStored; + public GasStack buffer; + public int prevStored; - public int prevTransferAmount = 0; + public int prevTransferAmount = 0; - public GasNetwork() {} + public GasNetwork() {} - public GasNetwork(Collection 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; - buffer = net.buffer; + public GasNetwork(Collection 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; + buffer = net.buffer; - net.gasScale = 0; - net.refGas = null; - net.buffer = null; - } - } - else { - if(net.buffer != null) - { - if(buffer == null) - { - buffer = net.buffer.copy(); - } - else { - if(buffer.isGasEqual(net.buffer)) - { - buffer.amount += net.buffer.amount; - } - else if(net.buffer.amount > buffer.amount) - { - buffer = net.buffer.copy(); - } + net.gasScale = 0; + net.refGas = null; + net.buffer = null; + } + } else { + if (net.buffer != null) { + if (buffer == null) { + buffer = net.buffer.copy(); + } else { + if (buffer.isGasEqual(net.buffer)) { + buffer.amount += net.buffer.amount; + } else if (net.buffer.amount > buffer.amount) { + buffer = net.buffer.copy(); + } + } - } + net.buffer = null; + } + } - net.buffer = null; - } - } + adoptTransmittersAndAcceptorsFrom(net); + net.deregister(); + } + } - adoptTransmittersAndAcceptorsFrom(net); - net.deregister(); - } - } + gasScale = getScale(); - gasScale = getScale(); + register(); + } - register(); - } + @Override + public void absorbBuffer(IGridTransmitter transmitter) { + Object b = transmitter.getBuffer(); - @Override - public void absorbBuffer(IGridTransmitter transmitter) - { - Object b = transmitter.getBuffer(); - - if(!(b instanceof GasStack) || ((GasStack)b).getGas() == null || ((GasStack)b).amount == 0) - { - return; - } + if (!(b instanceof GasStack) || ((GasStack) b).getGas() == null + || ((GasStack) b).amount == 0) { + return; + } - GasStack gas = (GasStack)b; + GasStack gas = (GasStack) b; - if(buffer == null || buffer.getGas() == null || buffer.amount == 0) - { - buffer = gas.copy(); + if (buffer == null || buffer.getGas() == null || buffer.amount == 0) { + buffer = gas.copy(); gas.amount = 0; - return; - } + return; + } - //TODO better multiple buffer impl - if(buffer.isGasEqual(gas)) - { - buffer.amount += gas.amount; - } - - gas.amount = 0; - } + //TODO better multiple buffer impl + if (buffer.isGasEqual(gas)) { + buffer.amount += gas.amount; + } - @Override - public void clampBuffer() - { - if(buffer != null && buffer.amount > getCapacity()) - { - buffer.amount = capacity; - } - } + gas.amount = 0; + } - public int getGasNeeded() - { - return getCapacity()-(buffer != null ? buffer.amount : 0); - } + @Override + public void clampBuffer() { + if (buffer != null && buffer.amount > getCapacity()) { + buffer.amount = capacity; + } + } - public int tickEmit(GasStack stack) - { - List availableAcceptors = Lists.newArrayList(); + public int getGasNeeded() { + return getCapacity() - (buffer != null ? buffer.amount : 0); + } - availableAcceptors.addAll(getAcceptors(stack.getGas())); + public int tickEmit(GasStack stack) { + List availableAcceptors = Lists.newArrayList(); - Collections.shuffle(availableAcceptors); + availableAcceptors.addAll(getAcceptors(stack.getGas())); - int toSend = stack.amount; - int prevSending = toSend; + Collections.shuffle(availableAcceptors); - if(!availableAcceptors.isEmpty()) - { - int divider = availableAcceptors.size(); - int remaining = toSend % divider; - int sending = (toSend-remaining)/divider; + int toSend = stack.amount; + int prevSending = toSend; - for(IGasHandler acceptor : availableAcceptors) - { - int currentSending = sending; - EnumSet sides = acceptorDirections.get(Coord4D.get((TileEntity)acceptor)); + if (!availableAcceptors.isEmpty()) { + int divider = availableAcceptors.size(); + int remaining = toSend % divider; + int sending = (toSend - remaining) / divider; - if(remaining > 0) - { - currentSending++; - remaining--; - } + for (IGasHandler acceptor : availableAcceptors) { + int currentSending = sending; + EnumSet sides + = acceptorDirections.get(Coord4D.get((TileEntity) acceptor)); - for(ForgeDirection side : sides) - { - int prev = toSend; + if (remaining > 0) { + currentSending++; + remaining--; + } - toSend -= acceptor.receiveGas(side, new GasStack(stack.getGas(), currentSending), true); + for (ForgeDirection side : sides) { + int prev = toSend; - if(toSend < prev) - { - break; - } - } - } - } + toSend -= acceptor.receiveGas( + side, new GasStack(stack.getGas(), currentSending), true + ); - int sent = prevSending-toSend; + if (toSend < prev) { + break; + } + } + } + } - if(sent > 0 && FMLCommonHandler.instance().getEffectiveSide().isServer()) - { - didTransfer = true; - transferDelay = 2; - } + int sent = prevSending - toSend; - return sent; - } + if (sent > 0 && FMLCommonHandler.instance().getEffectiveSide().isServer()) { + didTransfer = true; + transferDelay = 2; + } - public int emit(GasStack stack, boolean doTransfer) - { - if(buffer != null && buffer.getGas() != stack.getGas()) - { - return 0; - } + return sent; + } - int toUse = Math.min(getGasNeeded(), stack.amount); + public int emit(GasStack stack, boolean doTransfer) { + if (buffer != null && buffer.getGas() != stack.getGas()) { + return 0; + } - if(doTransfer) - { - if(buffer == null) - { - buffer = stack.copy(); - buffer.amount = toUse; - } - else { - buffer.amount += toUse; - } - } + int toUse = Math.min(getGasNeeded(), stack.amount); - return toUse; - } + if (doTransfer) { + if (buffer == null) { + buffer = stack.copy(); + buffer.amount = toUse; + } else { + buffer.amount += toUse; + } + } - @Override - public void onUpdate() - { - super.onUpdate(); + return toUse; + } - if(FMLCommonHandler.instance().getEffectiveSide().isServer()) - { - prevTransferAmount = 0; + @Override + public void onUpdate() { + super.onUpdate(); - if(transferDelay == 0) - { - didTransfer = false; - } - else { - transferDelay--; - } + if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { + prevTransferAmount = 0; - int stored = buffer != null ? buffer.amount : 0; + if (transferDelay == 0) { + didTransfer = false; + } else { + transferDelay--; + } - if(stored != prevStored) - { - needsUpdate = true; - } + int stored = buffer != null ? buffer.amount : 0; - prevStored = stored; + if (stored != prevStored) { + needsUpdate = true; + } - if(didTransfer != prevTransfer || needsUpdate) - { - MinecraftForge.EVENT_BUS.post(new GasTransferEvent(this, buffer, didTransfer)); - needsUpdate = false; - } + prevStored = stored; - prevTransfer = didTransfer; + if (didTransfer != prevTransfer || needsUpdate) { + MinecraftForge.EVENT_BUS.post( + new GasTransferEvent(this, buffer, didTransfer) + ); + needsUpdate = false; + } - if(buffer != null) - { - prevTransferAmount = tickEmit(buffer); - buffer.amount -= prevTransferAmount; + prevTransfer = didTransfer; - if(buffer.amount <= 0) - { - buffer = null; - } - } - } - } + if (buffer != null) { + prevTransferAmount = tickEmit(buffer); + buffer.amount -= prevTransferAmount; - @Override - public void clientTick() - { - super.clientTick(); + if (buffer.amount <= 0) { + buffer = null; + } + } + } + } - gasScale = Math.max(gasScale, getScale()); + @Override + public void clientTick() { + super.clientTick(); - 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)); + gasScale = Math.max(gasScale, getScale()); - if(gasScale == 0) - { - buffer = null; - } - } - } + 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)); - @Override - public Set getAcceptors(Object data) - { - Gas type = (Gas)data; - Set toReturn = new HashSet(); - - if(FMLCommonHandler.instance().getEffectiveSide().isClient()) - { - return toReturn; - } + if (gasScale == 0) { + buffer = null; + } + } + } - for(Coord4D coord : possibleAcceptors.keySet()) - { - EnumSet sides = acceptorDirections.get(coord); - TileEntity tile = coord.getTileEntity(getWorld()); - - if(!(tile instanceof IGasHandler) || sides == null || sides.isEmpty()) - { - continue; - } - - IGasHandler acceptor = (IGasHandler)tile; + @Override + public Set getAcceptors(Object data) { + Gas type = (Gas) data; + Set toReturn = new HashSet(); - for(ForgeDirection side : sides) - { - if(acceptor != null && acceptor.canReceiveGas(side, type)) - { - toReturn.add(acceptor); - break; - } - } - } + if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { + return toReturn; + } - return toReturn; - } + for (Coord4D coord : possibleAcceptors.keySet()) { + EnumSet sides = acceptorDirections.get(coord); + TileEntity tile = coord.getTileEntity(getWorld()); - public static class GasTransferEvent extends Event - { - public final GasNetwork gasNetwork; + if (!(tile instanceof IGasHandler) || sides == null || sides.isEmpty()) { + continue; + } - public final GasStack transferType; - public final boolean didTransfer; + IGasHandler acceptor = (IGasHandler) tile; - public GasTransferEvent(GasNetwork network, GasStack type, boolean did) - { - gasNetwork = network; - transferType = type; - didTransfer = did; - } - } + for (ForgeDirection side : sides) { + if (acceptor != null && acceptor.canReceiveGas(side, type)) { + toReturn.add(acceptor); + break; + } + } + } - public float getScale() - { - return Math.min(1, (buffer == null || getCapacity() == 0 ? 0 : (float)buffer.amount/getCapacity())); - } + return toReturn; + } - @Override - public String toString() - { - return "[GasNetwork] " + transmitters.size() + " transmitters, " + possibleAcceptors.size() + " acceptors."; - } + public static class GasTransferEvent extends Event { + public final GasNetwork gasNetwork; - @Override - public String getNeededInfo() - { - return Integer.toString(getGasNeeded()); - } + public final GasStack transferType; + public final boolean didTransfer; - @Override - public String getStoredInfo() - { - return buffer != null ? buffer.getGas().getLocalizedName() + " (" + buffer.amount + ")" : "None"; - } + public GasTransferEvent(GasNetwork network, GasStack type, boolean did) { + gasNetwork = network; + transferType = type; + didTransfer = did; + } + } - @Override - public String getFlowInfo() - { - return Integer.toString(prevTransferAmount) + "/t"; - } + public float getScale() { + return Math.min( + 1, + (buffer == null || getCapacity() == 0 ? 0 + : (float) buffer.amount / getCapacity()) + ); + } + + @Override + public String toString() { + return "[GasNetwork] " + transmitters.size() + " transmitters, " + + possibleAcceptors.size() + " acceptors."; + } + + @Override + public String getNeededInfo() { + return Integer.toString(getGasNeeded()); + } + + @Override + public String getStoredInfo() { + return buffer != null + ? buffer.getGas().getLocalizedName() + " (" + buffer.amount + ")" + : "None"; + } + + @Override + public String getFlowInfo() { + return Integer.toString(prevTransferAmount) + "/t"; + } } diff --git a/src/main/java/mekanism/api/gas/GasRegistry.java b/src/main/java/mekanism/api/gas/GasRegistry.java index 25db9667e..7716ca585 100644 --- a/src/main/java/mekanism/api/gas/GasRegistry.java +++ b/src/main/java/mekanism/api/gas/GasRegistry.java @@ -5,109 +5,94 @@ import java.util.List; import net.minecraftforge.fluids.Fluid; -public class GasRegistry -{ - private static ArrayList registeredGasses = new ArrayList(); +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; - } + /** + * 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); + registeredGasses.add(gas); - return getGas(gas.getName()); - } + 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; - } + /** + * 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); - } + 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; - } - } + /** + * 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; - } + 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; - } + /** + * 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 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; - } - } + /** + * 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; - } + 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; - } + /** + * 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); - } + return registeredGasses.indexOf(gas); + } } diff --git a/src/main/java/mekanism/api/gas/GasStack.java b/src/main/java/mekanism/api/gas/GasStack.java index 05e5ae689..b4acb77e2 100644 --- a/src/main/java/mekanism/api/gas/GasStack.java +++ b/src/main/java/mekanism/api/gas/GasStack.java @@ -7,126 +7,114 @@ import net.minecraft.nbt.NBTTagCompound; * @author aidancbrady * */ -public class GasStack -{ - private Gas type; +public class GasStack { + private Gas type; - public int amount; + 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 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; - } + /** + * 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() {} + private GasStack() {} - /** - * Gets the Gas type of this GasStack. - * @return this GasStack's Gas type - */ - public Gas getGas() - { - return type; - } - - public GasStack withAmount(int newAmount) - { - amount = newAmount; - - return this; - } + /** + * 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); + public GasStack withAmount(int newAmount) { + amount = newAmount; - return nbtTags; - } + return this; + } - /** - * 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"); - } + /** + * 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); - /** - * 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; - } + return nbtTags; + } - GasStack stack = new GasStack(); - stack.read(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"); + } - if(stack.getGas() == null || stack.amount <= 0) - { - return null; - } + /** + * 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; + } - return stack; - } + GasStack stack = new GasStack(); + stack.read(nbtTags); - /** - * Returns a copied form of this GasStack. - * @return copied GasStack - */ - public GasStack copy() - { - return new GasStack(type, amount); - } + if (stack.getGas() == null || stack.amount <= 0) { + return null; + } - /** - * 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(); - } + return stack; + } - @Override - public String toString() - { - return "[" + type + ", " + amount + "]"; - } + /** + * Returns a copied form of this GasStack. + * @return copied GasStack + */ + public GasStack copy() { + return new GasStack(type, amount); + } - @Override - public int hashCode() - { - return type == null ? 0 : type.getID(); - } + /** + * 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 + "]"; + } + + @Override + public int hashCode() { + return type == null ? 0 : type.getID(); + } } diff --git a/src/main/java/mekanism/api/gas/GasTank.java b/src/main/java/mekanism/api/gas/GasTank.java index a5d4c20b3..13396cd6f 100644 --- a/src/main/java/mekanism/api/gas/GasTank.java +++ b/src/main/java/mekanism/api/gas/GasTank.java @@ -3,250 +3,225 @@ 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. + * 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; +public class GasTank { + public GasStack stored; - private int maxGas; + private int maxGas; - private GasTank() {} + 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; - } + /** + * 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; + /** + * 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); - } - } + 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; - } + /** + * 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)); + GasStack ret = new GasStack(getGas().getGas(), Math.min(getStored(), amount)); - if(ret.amount > 0) - { - if(doDraw) - { - stored.amount -= ret.amount; + if (ret.amount > 0) { + if (doDraw) { + stored.amount -= ret.amount; - if(stored.amount <= 0) - { - stored = null; - } - } + if (stored.amount <= 0) { + stored = null; + } + } - return ret; - } + return ret; + } - return null; - } + 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() && stored.isGasEqual(amount)))) - { - return 0; - } + /** + * 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() && stored.isGasEqual(amount)))) { + return 0; + } - int toFill = Math.min(getMaxGas()-getStored(), amount.amount); + int toFill = Math.min(getMaxGas() - getStored(), amount.amount); - if(doReceive) - { - if(stored == null) - { - stored = amount.copy().withAmount(getStored()+toFill); - } - else { - stored.amount = Math.min(getMaxGas(), getStored()+amount.amount); - } - } + if (doReceive) { + if (stored == null) { + stored = amount.copy().withAmount(getStored() + toFill); + } else { + stored.amount = Math.min(getMaxGas(), getStored() + amount.amount); + } + } - return toFill; - } + 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; - } + /** + * 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; - } + 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; - } + /** + * 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; - } + 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; - } + /** + * 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; - } + return true; + } - /** - * Gets the amount of gas needed by this GasTank. - * @return - */ - public int getNeeded() - { - return getMaxGas()-getStored(); - } + /** + * 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 maximum amount of gas this tank can hold. + * @return - max gas + */ + public int getMaxGas() { + return maxGas; + } - /** - * Sets the maximum amount of gas this tank can hold - */ - public void setMaxGas(int capacity) - { - maxGas = capacity; - } + /** + * Sets the maximum amount of gas this tank can hold + */ + public void setMaxGas(int capacity) { + maxGas = capacity; + } - /** - * 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 GasStack held by this GasTank. + * @return - GasStakc held by this tank + */ + public GasStack getGas() { + return stored; + } - /** - * Gets the amount of gas stored by this GasTank. - * @return amount of gas stored - */ - public int getStored() - { - return stored != null ? stored.amount : 0; - } + /** + * Gets the type of gas currently stored in this GasTank. + * @return gas type contained + */ + public Gas getGasType() { + return stored != null ? stored.getGas() : null; + } - /** - * 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 && stored.getGas() != null) - { - nbtTags.setTag("stored", stored.write(new NBTTagCompound())); - } + /** + * Gets the amount of gas stored by this GasTank. + * @return amount of gas stored + */ + public int getStored() { + return stored != null ? stored.amount : 0; + } - nbtTags.setInteger("maxGas", maxGas); + /** + * 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 && stored.getGas() != null) { + nbtTags.setTag("stored", stored.write(new NBTTagCompound())); + } - return nbtTags; - } + nbtTags.setInteger("maxGas", maxGas); - /** - * 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")); - } + return nbtTags; + } - if(nbtTags.hasKey("maxGas") && nbtTags.getInteger("maxGas") != 0) - { - maxGas = nbtTags.getInteger("maxGas"); - } - } + /** + * 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")); + } - /** - * 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; - } + if (nbtTags.hasKey("maxGas") && nbtTags.getInteger("maxGas") != 0) { + maxGas = nbtTags.getInteger("maxGas"); + } + } - GasTank tank = new GasTank(); - tank.read(nbtTags); + /** + * 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; + } - return tank; - } + GasTank tank = new GasTank(); + tank.read(nbtTags); + + return tank; + } } diff --git a/src/main/java/mekanism/api/gas/GasTransmission.java b/src/main/java/mekanism/api/gas/GasTransmission.java index ef6cc4d3b..f2fdfe7c4 100644 --- a/src/main/java/mekanism/api/gas/GasTransmission.java +++ b/src/main/java/mekanism/api/gas/GasTransmission.java @@ -18,169 +18,176 @@ import net.minecraftforge.common.util.ForgeDirection; * @author AidanBrady * */ -public final class GasTransmission -{ - public static IGasHandler[] getConnectedAcceptors(TileEntity tileEntity, Collection sides) - { - IGasHandler[] acceptors = new IGasHandler[] {null, null, null, null, null, null}; +public final class GasTransmission { + public static IGasHandler[] getConnectedAcceptors( + TileEntity tileEntity, Collection sides + ) { + IGasHandler[] acceptors + = new IGasHandler[] { null, null, null, null, null, null }; - for(ForgeDirection orientation : sides) - { - TileEntity acceptor = Coord4D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.getWorldObj()); + for (ForgeDirection orientation : sides) { + TileEntity acceptor = Coord4D.get(tileEntity) + .getFromSide(orientation) + .getTileEntity(tileEntity.getWorldObj()); - if(acceptor instanceof IGasHandler) - { - acceptors[orientation.ordinal()] = (IGasHandler)acceptor; - } - } + if (acceptor instanceof IGasHandler) { + acceptors[orientation.ordinal()] = (IGasHandler) acceptor; + } + } - return acceptors; - } - - /** - * Gets all the acceptors around a tile entity. - * @param tileEntity - center tile entity - * @return array of IGasAcceptors - */ - public static IGasHandler[] getConnectedAcceptors(TileEntity tileEntity) - { - return getConnectedAcceptors(tileEntity, Arrays.asList(ForgeDirection.VALID_DIRECTIONS)); - } + 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}; + /** + * Gets all the acceptors around a tile entity. + * @param tileEntity - center tile entity + * @return array of IGasAcceptors + */ + public static IGasHandler[] getConnectedAcceptors(TileEntity tileEntity) { + return getConnectedAcceptors( + tileEntity, Arrays.asList(ForgeDirection.VALID_DIRECTIONS) + ); + } - for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) - { - TileEntity connection = Coord4D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.getWorldObj()); + /** + * 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 }; - if(canConnect(connection, orientation)) - { - connections[orientation.ordinal()] = (ITubeConnection)connection; - } - } + for (ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) { + TileEntity connection = Coord4D.get(tileEntity) + .getFromSide(orientation) + .getTileEntity(tileEntity.getWorldObj()); - return connections; - } + if (canConnect(connection, orientation)) { + connections[orientation.ordinal()] = (ITubeConnection) connection; + } + } - /** - * 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 ITransmitterTile) || TransmissionType.checkTransmissionType(((ITransmitterTile)tileEntity).getTransmitter(), TransmissionType.GAS))) - { - if(((ITubeConnection)tileEntity).canTubeConnect(side.getOpposite())) - { - return true; - } - } + return connections; + } - return false; - } + /** + * 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 ITransmitterTile) + || TransmissionType.checkTransmissionType( + ((ITransmitterTile) tileEntity).getTransmitter(), TransmissionType.GAS + ))) { + if (((ITubeConnection) tileEntity).canTubeConnect(side.getOpposite())) { + return true; + } + } - /** - * 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(); + return false; + } - if(type != null && item.getGas(itemStack) != null && item.getGas(itemStack).getGas() != type || !item.canProvideGas(itemStack, type)) - { - return null; - } + /** + * 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(); - return item.removeGas(itemStack, amount); - } + if (type != null && item.getGas(itemStack) != null + && item.getGas(itemStack).getGas() != type + || !item.canProvideGas(itemStack, type)) { + return null; + } - return null; - } + return item.removeGas(itemStack, amount); + } - /** - * 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 null; + } - return 0; - } - - /** - * Emits gas from a central block by splitting the received stack among the sides given. - * @param stack - the stack to output - * @param from - the TileEntity to output from - * @param sides - the list of sides to output from - * @return the amount of gas emitted - */ - public static int emit(GasStack stack, TileEntity from, Collection sides) - { - if(stack == null) - { - return 0; - } - - List availableAcceptors = new ArrayList(); - IGasHandler[] possibleAcceptors = getConnectedAcceptors(from, sides); - - for(int i = 0; i < possibleAcceptors.length; i++) - { - IGasHandler handler = possibleAcceptors[i]; - - if(handler != null && handler.canReceiveGas(ForgeDirection.getOrientation(i).getOpposite(), stack.getGas())) - { - availableAcceptors.add(handler); - } - } + /** + * 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()); + } - Collections.shuffle(availableAcceptors); + return 0; + } - int toSend = stack.amount; - int prevSending = toSend; + /** + * Emits gas from a central block by splitting the received stack among the sides + * given. + * @param stack - the stack to output + * @param from - the TileEntity to output from + * @param sides - the list of sides to output from + * @return the amount of gas emitted + */ + public static int + emit(GasStack stack, TileEntity from, Collection sides) { + if (stack == null) { + return 0; + } - if(!availableAcceptors.isEmpty()) - { - int divider = availableAcceptors.size(); - int remaining = toSend % divider; - int sending = (toSend-remaining)/divider; + List availableAcceptors = new ArrayList(); + IGasHandler[] possibleAcceptors = getConnectedAcceptors(from, sides); - for(IGasHandler acceptor : availableAcceptors) - { - int currentSending = sending; + for (int i = 0; i < possibleAcceptors.length; i++) { + IGasHandler handler = possibleAcceptors[i]; - if(remaining > 0) - { - currentSending++; - remaining--; - } - - ForgeDirection dir = ForgeDirection.getOrientation(Arrays.asList(possibleAcceptors).indexOf(acceptor)).getOpposite(); - toSend -= acceptor.receiveGas(dir, new GasStack(stack.getGas(), currentSending), true); - } - } + if (handler != null + && handler.canReceiveGas( + ForgeDirection.getOrientation(i).getOpposite(), stack.getGas() + )) { + availableAcceptors.add(handler); + } + } - return prevSending-toSend; - } + 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 (IGasHandler acceptor : availableAcceptors) { + int currentSending = sending; + + if (remaining > 0) { + currentSending++; + remaining--; + } + + ForgeDirection dir + = ForgeDirection + .getOrientation( + Arrays.asList(possibleAcceptors).indexOf(acceptor) + ) + .getOpposite(); + toSend -= acceptor.receiveGas( + dir, new GasStack(stack.getGas(), currentSending), true + ); + } + } + + return prevSending - toSend; + } } diff --git a/src/main/java/mekanism/api/gas/IGasHandler.java b/src/main/java/mekanism/api/gas/IGasHandler.java index e06952317..c07265708 100644 --- a/src/main/java/mekanism/api/gas/IGasHandler.java +++ b/src/main/java/mekanism/api/gas/IGasHandler.java @@ -7,41 +7,40 @@ import net.minecraftforge.common.util.ForgeDirection; * @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, boolean doTransfer); +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, boolean doTransfer); - @Deprecated - public int receiveGas(ForgeDirection side, GasStack stack); + @Deprecated + 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, boolean doTransfer); + /** + * Draws a certain amount of gas from this block. + * @param amount - amount to draw + * @return gas drawn + */ + public GasStack drawGas(ForgeDirection side, int amount, boolean doTransfer); - @Deprecated - public GasStack drawGas(ForgeDirection side, int amount); + @Deprecated + 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 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); + /** + * 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/main/java/mekanism/api/gas/IGasItem.java b/src/main/java/mekanism/api/gas/IGasItem.java index 04231cd81..759b5c0e4 100644 --- a/src/main/java/mekanism/api/gas/IGasItem.java +++ b/src/main/java/mekanism/api/gas/IGasItem.java @@ -7,69 +7,68 @@ import net.minecraft.item.ItemStack; * @author AidanBrady * */ -public interface IGasItem -{ - /** - * Gets the rate of transfer this item can handle. - * @return - */ - public int getRate(ItemStack itemstack); +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); + /** + * 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); + /** + * 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 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); + /** + * 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); + /** + * 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); + /** + * 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); + /** + * 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); } diff --git a/src/main/java/mekanism/api/gas/IGasTransmitter.java b/src/main/java/mekanism/api/gas/IGasTransmitter.java index 2785ac1c8..053b19379 100644 --- a/src/main/java/mekanism/api/gas/IGasTransmitter.java +++ b/src/main/java/mekanism/api/gas/IGasTransmitter.java @@ -3,7 +3,6 @@ package mekanism.api.gas; import mekanism.api.transmitters.IGridTransmitter; import net.minecraft.tileentity.TileEntity; -public interface IGasTransmitter extends IGridTransmitter -{ - public boolean canTransferGasToTube(TileEntity tile); +public interface IGasTransmitter extends IGridTransmitter { + public boolean canTransferGasToTube(TileEntity tile); } diff --git a/src/main/java/mekanism/api/gas/ITubeConnection.java b/src/main/java/mekanism/api/gas/ITubeConnection.java index b669fedda..9dbc9bd98 100644 --- a/src/main/java/mekanism/api/gas/ITubeConnection.java +++ b/src/main/java/mekanism/api/gas/ITubeConnection.java @@ -7,12 +7,11 @@ import net.minecraftforge.common.util.ForgeDirection; * @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); +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/main/java/mekanism/api/gas/OreGas.java b/src/main/java/mekanism/api/gas/OreGas.java index 316169c2a..7c5f8bd9c 100644 --- a/src/main/java/mekanism/api/gas/OreGas.java +++ b/src/main/java/mekanism/api/gas/OreGas.java @@ -2,37 +2,31 @@ package mekanism.api.gas; import net.minecraft.util.StatCollector; -public class OreGas extends Gas -{ - private String oreName; - private OreGas cleanGas; +public class OreGas extends Gas { + private String oreName; + private OreGas cleanGas; - public OreGas(String s, String name) - { - super(s); + public OreGas(String s, String name) { + super(s); - oreName = name; - } + oreName = name; + } - public boolean isClean() - { - return getCleanGas() == null; - } + public boolean isClean() { + return getCleanGas() == null; + } - public OreGas getCleanGas() - { - return cleanGas; - } + public OreGas getCleanGas() { + return cleanGas; + } - public OreGas setCleanGas(OreGas gas) - { - cleanGas = gas; + public OreGas setCleanGas(OreGas gas) { + cleanGas = gas; - return this; - } + return this; + } - public String getOreName() - { - return StatCollector.translateToLocal(oreName); - } + public String getOreName() { + return StatCollector.translateToLocal(oreName); + } } diff --git a/src/main/java/mekanism/api/gas/package-info.java b/src/main/java/mekanism/api/gas/package-info.java index f213e0553..5f8a67458 100644 --- a/src/main/java/mekanism/api/gas/package-info.java +++ b/src/main/java/mekanism/api/gas/package-info.java @@ -1,4 +1,3 @@ @API(apiVersion = "9.0.0", owner = "Mekanism", provides = "MekanismAPI|gas") package mekanism.api.gas; import cpw.mods.fml.common.API; - diff --git a/src/main/java/mekanism/api/infuse/InfuseObject.java b/src/main/java/mekanism/api/infuse/InfuseObject.java index a86c02f1a..a48bb1bbb 100644 --- a/src/main/java/mekanism/api/infuse/InfuseObject.java +++ b/src/main/java/mekanism/api/infuse/InfuseObject.java @@ -1,21 +1,20 @@ package mekanism.api.infuse; /** - * InfuseObject - an object associated with an ItemStack that can modify a Metallurgic Infuser's internal 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; +public class InfuseObject { + /** The type of infuse this item stores */ + public InfuseType type; - /** How much infuse this item stores */ - public int stored; + /** How much infuse this item stores */ + public int stored; - public InfuseObject(InfuseType infusion, int i) - { - type = infusion; - stored = i; - } + public InfuseObject(InfuseType infusion, int i) { + type = infusion; + stored = i; + } } diff --git a/src/main/java/mekanism/api/infuse/InfuseRegistry.java b/src/main/java/mekanism/api/infuse/InfuseRegistry.java index 308b9c5be..70ded2e81 100644 --- a/src/main/java/mekanism/api/infuse/InfuseRegistry.java +++ b/src/main/java/mekanism/api/infuse/InfuseRegistry.java @@ -10,104 +10,95 @@ import net.minecraft.item.ItemStack; * @author AidanBrady * */ -public class InfuseRegistry -{ - /** The (private) map of ItemStacks and their related InfuseObjects. */ - private static Map infuseObjects = new HashMap(); +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(); + /** 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; - } + /** + * 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); - } + 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; - } + /** + * 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); - } + 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; - } + /** + * 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; - } + /** + * 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); - } + 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(); - } - } + /** + * 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; - } + return null; + } - /** - * Gets the private map for InfuseObjects. - * @return private InfuseObject map - */ - public static final Map getObjectMap() - { - return infuseObjects; - } + /** + * 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; - } + /** + * Gets the private map for InfuseTypes. + * @return private InfuseType map + */ + public static final Map getInfuseMap() { + return infuseTypes; + } } diff --git a/src/main/java/mekanism/api/infuse/InfuseType.java b/src/main/java/mekanism/api/infuse/InfuseType.java index 2ebd49161..12f10bb64 100644 --- a/src/main/java/mekanism/api/infuse/InfuseType.java +++ b/src/main/java/mekanism/api/infuse/InfuseType.java @@ -8,40 +8,35 @@ import net.minecraft.util.StatCollector; * @author AidanBrady * */ -public final class InfuseType -{ - /** The name of this infusion */ - public String name; +public final class InfuseType { + /** The name of this infusion */ + public String name; - /** This infuse GUI's icon */ - public IIcon icon; - - /** The location of this infuse GUI's icon */ - public String textureLocation; + /** This infuse GUI's icon */ + public IIcon icon; - /** The unlocalized name of this type. */ - public String unlocalizedName; + /** The location of this infuse GUI's icon */ + public String textureLocation; - public InfuseType(String s, String tex) - { - name = s; - textureLocation = tex; - } - - public void setIcon(IIcon i) - { - icon = i; - } + /** The unlocalized name of this type. */ + public String unlocalizedName; - public InfuseType setUnlocalizedName(String name) - { - unlocalizedName = "infuse." + name; + public InfuseType(String s, String tex) { + name = s; + textureLocation = tex; + } - return this; - } + public void setIcon(IIcon i) { + icon = i; + } - public String getLocalizedName() - { - return StatCollector.translateToLocal(unlocalizedName); - } + public InfuseType setUnlocalizedName(String name) { + unlocalizedName = "infuse." + name; + + return this; + } + + public String getLocalizedName() { + return StatCollector.translateToLocal(unlocalizedName); + } } diff --git a/src/main/java/mekanism/api/infuse/package-info.java b/src/main/java/mekanism/api/infuse/package-info.java index bcbb9a8b5..e234a2664 100644 --- a/src/main/java/mekanism/api/infuse/package-info.java +++ b/src/main/java/mekanism/api/infuse/package-info.java @@ -1,4 +1,3 @@ @API(apiVersion = "9.0.0", owner = "Mekanism", provides = "MekanismAPI|infuse") package mekanism.api.infuse; import cpw.mods.fml.common.API; - diff --git a/src/main/java/mekanism/api/lasers/ILaserReceptor.java b/src/main/java/mekanism/api/lasers/ILaserReceptor.java index 641f3ca0c..84a8c9680 100644 --- a/src/main/java/mekanism/api/lasers/ILaserReceptor.java +++ b/src/main/java/mekanism/api/lasers/ILaserReceptor.java @@ -2,9 +2,8 @@ package mekanism.api.lasers; import net.minecraftforge.common.util.ForgeDirection; -public interface ILaserReceptor -{ - public void receiveLaserEnergy(double energy, ForgeDirection side); +public interface ILaserReceptor { + public void receiveLaserEnergy(double energy, ForgeDirection side); - public boolean canLasersDig(); + public boolean canLasersDig(); } diff --git a/src/main/java/mekanism/api/lasers/package-info.java b/src/main/java/mekanism/api/lasers/package-info.java index 2ba8eb0b5..e60163fd0 100644 --- a/src/main/java/mekanism/api/lasers/package-info.java +++ b/src/main/java/mekanism/api/lasers/package-info.java @@ -1,4 +1,3 @@ @API(apiVersion = "9.0.0", owner = "Mekanism", provides = "MekanismAPI|laser") package mekanism.api.lasers; import cpw.mods.fml.common.API; - diff --git a/src/main/java/mekanism/api/package-info.java b/src/main/java/mekanism/api/package-info.java index c2aba662d..440cfcf98 100644 --- a/src/main/java/mekanism/api/package-info.java +++ b/src/main/java/mekanism/api/package-info.java @@ -1,4 +1,3 @@ @API(apiVersion = "9.0.0", owner = "Mekanism", provides = "MekanismAPI|core") package mekanism.api; import cpw.mods.fml.common.API; - diff --git a/src/main/java/mekanism/api/reactor/IFusionReactor.java b/src/main/java/mekanism/api/reactor/IFusionReactor.java index da96a27c3..c18ef6510 100644 --- a/src/main/java/mekanism/api/reactor/IFusionReactor.java +++ b/src/main/java/mekanism/api/reactor/IFusionReactor.java @@ -5,61 +5,60 @@ import mekanism.api.gas.GasTank; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidTank; -public interface IFusionReactor extends IHeatTransfer -{ - public void addTemperatureFromEnergyInput(double energyAdded); +public interface IFusionReactor extends IHeatTransfer { + public void addTemperatureFromEnergyInput(double energyAdded); - public void simulate(); + public void simulate(); - public FluidTank getWaterTank(); + public FluidTank getWaterTank(); - public FluidTank getSteamTank(); + public FluidTank getSteamTank(); - public GasTank getDeuteriumTank(); + public GasTank getDeuteriumTank(); - public GasTank getTritiumTank(); + public GasTank getTritiumTank(); - public GasTank getFuelTank(); + public GasTank getFuelTank(); - public double getBufferedEnergy(); + public double getBufferedEnergy(); - public void setBufferedEnergy(double energy); + public void setBufferedEnergy(double energy); - public double getPlasmaTemp(); + public double getPlasmaTemp(); - public void setPlasmaTemp(double temp); + public void setPlasmaTemp(double temp); - public double getCaseTemp(); + public double getCaseTemp(); - public void setCaseTemp(double temp); + public void setCaseTemp(double temp); - public double getBufferSize(); + public double getBufferSize(); - public void formMultiblock(boolean keepBurning); + public void formMultiblock(boolean keepBurning); - public boolean isFormed(); + public boolean isFormed(); - public void setInjectionRate(int rate); + public void setInjectionRate(int rate); - public int getInjectionRate(); + public int getInjectionRate(); - public boolean isBurning(); + public boolean isBurning(); - public void setBurning(boolean burn); + public void setBurning(boolean burn); - public int getMinInjectionRate(boolean active); + public int getMinInjectionRate(boolean active); - public double getMaxPlasmaTemperature(boolean active); + public double getMaxPlasmaTemperature(boolean active); - public double getMaxCasingTemperature(boolean active); + public double getMaxCasingTemperature(boolean active); - public double getIgnitionTemperature(boolean active); + public double getIgnitionTemperature(boolean active); - public double getPassiveGeneration(boolean active, boolean current); + public double getPassiveGeneration(boolean active, boolean current); - public int getSteamPerTick(boolean current); + public int getSteamPerTick(boolean current); - public void updateTemperatures(); - - public ItemStack[] getInventory(); + public void updateTemperatures(); + + public ItemStack[] getInventory(); } diff --git a/src/main/java/mekanism/api/reactor/INeutronCapture.java b/src/main/java/mekanism/api/reactor/INeutronCapture.java index 6171a7f74..e99ec18bc 100644 --- a/src/main/java/mekanism/api/reactor/INeutronCapture.java +++ b/src/main/java/mekanism/api/reactor/INeutronCapture.java @@ -1,6 +1,5 @@ package mekanism.api.reactor; -public interface INeutronCapture extends IReactorBlock -{ - public int absorbNeutrons(int neutrons); +public interface INeutronCapture extends IReactorBlock { + public int absorbNeutrons(int neutrons); } diff --git a/src/main/java/mekanism/api/reactor/IReactorBlock.java b/src/main/java/mekanism/api/reactor/IReactorBlock.java index b3b85188d..c5acb64b8 100644 --- a/src/main/java/mekanism/api/reactor/IReactorBlock.java +++ b/src/main/java/mekanism/api/reactor/IReactorBlock.java @@ -1,12 +1,9 @@ package mekanism.api.reactor; +public interface IReactorBlock { + public boolean isFrame(); -public interface IReactorBlock -{ - public boolean isFrame(); - - public void setReactor(IFusionReactor reactor); - - public IFusionReactor getReactor(); + public void setReactor(IFusionReactor reactor); + public IFusionReactor getReactor(); } diff --git a/src/main/java/mekanism/api/reactor/package-info.java b/src/main/java/mekanism/api/reactor/package-info.java index 57ad758fe..2abf09c8d 100644 --- a/src/main/java/mekanism/api/reactor/package-info.java +++ b/src/main/java/mekanism/api/reactor/package-info.java @@ -1,4 +1,3 @@ @API(apiVersion = "9.0.0", owner = "Mekanism", provides = "MekanismAPI|reactor") package mekanism.api.reactor; import cpw.mods.fml.common.API; - diff --git a/src/main/java/mekanism/api/recipe/RecipeHelper.java b/src/main/java/mekanism/api/recipe/RecipeHelper.java index a125a8cbb..b293bec4a 100644 --- a/src/main/java/mekanism/api/recipe/RecipeHelper.java +++ b/src/main/java/mekanism/api/recipe/RecipeHelper.java @@ -14,305 +14,371 @@ import net.minecraftforge.fluids.FluidStack; * */ @Deprecated -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()); - } - } +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 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 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 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 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 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 leftInput - left input GasStack - * @param rightInput - right input GasStack - * @param output - output GasStack - */ - public static void addChemicalInfuserRecipe(GasStack leftInput, GasStack rightInput, GasStack output) - { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addChemicalInfuserRecipe", GasStack.class, GasStack.class, GasStack.class); - m.invoke(null, leftInput, rightInput, output); - } catch(Exception e) { - System.err.println("Error while adding recipe: " + e.getMessage()); - } - } + /** + * Add a Chemical Infuser recipe. + * @param leftInput - left input GasStack + * @param rightInput - right input GasStack + * @param output - output GasStack + */ + public static void + addChemicalInfuserRecipe(GasStack leftInput, GasStack rightInput, GasStack output) { + try { + Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); + Method m = recipeClass.getMethod( + "addChemicalInfuserRecipe", GasStack.class, GasStack.class, GasStack.class + ); + m.invoke(null, leftInput, rightInput, output); + } catch (Exception e) { + System.err.println("Error while adding recipe: " + e.getMessage()); + } + } - /** - * Add a Precision Sawmill recipe. - * @param input - input ItemStack - * @param primaryOutput - guaranteed output - * @param secondaryOutput - possible extra output - * @param chance - probability of obtaining extra output - */ - public static void addPrecisionSawmillRecipe(ItemStack input, ItemStack primaryOutput, ItemStack secondaryOutput, double chance) - { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addPrecisionSawmillRecipe", ItemStack.class, ItemStack.class, ItemStack.class, Double.TYPE); - m.invoke(null, input, primaryOutput, secondaryOutput, chance); - } catch(Exception e) { - System.err.println("Error while adding recipe: " + e.getMessage()); - } - } + /** + * Add a Precision Sawmill recipe. + * @param input - input ItemStack + * @param primaryOutput - guaranteed output + * @param secondaryOutput - possible extra output + * @param chance - probability of obtaining extra output + */ + public static void addPrecisionSawmillRecipe( + ItemStack input, ItemStack primaryOutput, ItemStack secondaryOutput, double chance + ) { + try { + Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); + Method m = recipeClass.getMethod( + "addPrecisionSawmillRecipe", + ItemStack.class, + ItemStack.class, + ItemStack.class, + Double.TYPE + ); + m.invoke(null, input, primaryOutput, secondaryOutput, chance); + } catch (Exception e) { + System.err.println("Error while adding recipe: " + e.getMessage()); + } + } - /** - * Add a Precision Sawmill recipe with no chance output - * @param input - input ItemStack - * @param primaryOutput - guaranteed output - */ - public static void addPrecisionSawmillRecipe(ItemStack input, ItemStack primaryOutput) - { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addPrecisionSawmillRecipe", ItemStack.class, ItemStack.class); - m.invoke(null, input, primaryOutput); - } catch(Exception e) { - System.err.println("Error while adding recipe: " + e.getMessage()); - } - } + /** + * Add a Precision Sawmill recipe with no chance output + * @param input - input ItemStack + * @param primaryOutput - guaranteed output + */ + public static void + addPrecisionSawmillRecipe(ItemStack input, ItemStack primaryOutput) { + try { + Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); + Method m = recipeClass.getMethod( + "addPrecisionSawmillRecipe", ItemStack.class, ItemStack.class + ); + m.invoke(null, input, primaryOutput); + } 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(ItemStack input, String gasName, ItemStack output) - { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addChemicalInjectionChamberRecipe", ItemStack.class, String.class, ItemStack.class); - m.invoke(null, input, gasName, 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(ItemStack input, String gasName, ItemStack output) { + try { + Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); + Method m = recipeClass.getMethod( + "addChemicalInjectionChamberRecipe", + ItemStack.class, + String.class, + ItemStack.class + ); + m.invoke(null, input, gasName, output); + } catch (Exception e) { + System.err.println("Error while adding recipe: " + e.getMessage()); + } + } - /** - * Add an Electrolytic Separator recipe. - * @param input - input FluidStack - * @param energy - required energy - * @param leftOutput - left output GasStack - * @param rightOutput - right output GasStack - */ - public static void addElectrolyticSeparatorRecipe(FluidStack input, double energy, GasStack leftOutput, GasStack rightOutput) - { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addElectrolyticSeparatorRecipe", FluidStack.class, Double.TYPE, GasStack.class, GasStack.class); - m.invoke(null, input, energy, leftOutput, rightOutput); - } catch(Exception e) { - System.err.println("Error while adding recipe: " + e.getMessage()); - } - } + /** + * Add an Electrolytic Separator recipe. + * @param input - input FluidStack + * @param energy - required energy + * @param leftOutput - left output GasStack + * @param rightOutput - right output GasStack + */ + public static void addElectrolyticSeparatorRecipe( + FluidStack input, double energy, GasStack leftOutput, GasStack rightOutput + ) { + try { + Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); + Method m = recipeClass.getMethod( + "addElectrolyticSeparatorRecipe", + FluidStack.class, + Double.TYPE, + GasStack.class, + GasStack.class + ); + m.invoke(null, input, energy, leftOutput, rightOutput); + } 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 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 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 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 infuse - which Infuse to use - * @param amount - how much Infuse to use - * @param input - input ItemStack - * @param output - output ItemStack - */ - public static void addMetallurgicInfuserRecipe(InfuseType infuse, int amount, ItemStack input, ItemStack output) - { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addMetallurgicInfuserRecipe", InfuseType.class, Integer.TYPE, ItemStack.class, ItemStack.class); - m.invoke(null, infuse, amount, input, output); - } catch(Exception e) { - System.err.println("Error while adding recipe: " + e.getMessage()); - } - } + /** + * Add a Metallurgic Infuser recipe. + * @param infuse - which Infuse to use + * @param amount - how much Infuse to use + * @param input - input ItemStack + * @param output - output ItemStack + */ + public static void addMetallurgicInfuserRecipe( + InfuseType infuse, int amount, ItemStack input, ItemStack output + ) { + try { + Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); + Method m = recipeClass.getMethod( + "addMetallurgicInfuserRecipe", + InfuseType.class, + Integer.TYPE, + ItemStack.class, + ItemStack.class + ); + m.invoke(null, infuse, amount, input, output); + } catch (Exception e) { + System.err.println("Error while adding recipe: " + e.getMessage()); + } + } - /** - * Add a Pressurized Reaction Chamber recipe. - * @param inputSolid - input ItemStack - * @param inputFluid - input FluidStack - * @param inputGas - input GasStack - * @param outputSolid - output ItemStack - * @param outputGas - output GasStack - * @param extraEnergy - extra energy needed by the recipe - * @param ticks - amount of ticks it takes for this recipe to complete - */ - public static void addPRCRecipe(ItemStack inputSolid, FluidStack inputFluid, GasStack inputGas, ItemStack outputSolid, GasStack outputGas, double extraEnergy, int ticks) - { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addPRCRecipe", ItemStack.class, FluidStack.class, GasStack.class, ItemStack.class, GasStack.class, Double.TYPE, Integer.TYPE); - m.invoke(null, inputSolid, inputFluid, inputGas, outputSolid, outputGas, extraEnergy, ticks); - } catch(Exception e) { - System.err.println("Error while adding recipe: " + e.getMessage()); - } - } - - /** - * Add a Thermal Evaporation Plant recipe. - * @param input - input GasStack - * @param output - output GasStack - */ - public static void addThermalEvaporationRecipe(FluidStack input, FluidStack output) - { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addThermalEvaporationRecipe", FluidStack.class, FluidStack.class); - m.invoke(null, input, output); - } catch(Exception e) { - System.err.println("Error while adding recipe: " + e.getMessage()); - } - } - - /** - * Add a Solar Neutron Activator recipe. - * @param input - input GasStack - * @param output - output GasStack - */ - public static void addSolarNeutronRecipe(GasStack input, GasStack output) - { - try { - Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); - Method m = recipeClass.getMethod("addSolarNeutronRecipe", GasStack.class, GasStack.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 inputSolid - input ItemStack + * @param inputFluid - input FluidStack + * @param inputGas - input GasStack + * @param outputSolid - output ItemStack + * @param outputGas - output GasStack + * @param extraEnergy - extra energy needed by the recipe + * @param ticks - amount of ticks it takes for this recipe to complete + */ + public static void addPRCRecipe( + ItemStack inputSolid, + FluidStack inputFluid, + GasStack inputGas, + ItemStack outputSolid, + GasStack outputGas, + double extraEnergy, + int ticks + ) { + try { + Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); + Method m = recipeClass.getMethod( + "addPRCRecipe", + ItemStack.class, + FluidStack.class, + GasStack.class, + ItemStack.class, + GasStack.class, + Double.TYPE, + Integer.TYPE + ); + m.invoke( + null, + inputSolid, + inputFluid, + inputGas, + outputSolid, + outputGas, + extraEnergy, + ticks + ); + } catch (Exception e) { + System.err.println("Error while adding recipe: " + e.getMessage()); + } + } + + /** + * Add a Thermal Evaporation Plant recipe. + * @param input - input GasStack + * @param output - output GasStack + */ + public static void addThermalEvaporationRecipe(FluidStack input, FluidStack output) { + try { + Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); + Method m = recipeClass.getMethod( + "addThermalEvaporationRecipe", FluidStack.class, FluidStack.class + ); + m.invoke(null, input, output); + } catch (Exception e) { + System.err.println("Error while adding recipe: " + e.getMessage()); + } + } + + /** + * Add a Solar Neutron Activator recipe. + * @param input - input GasStack + * @param output - output GasStack + */ + public static void addSolarNeutronRecipe(GasStack input, GasStack output) { + try { + Class recipeClass = Class.forName("mekanism.common.recipe.RecipeHandler"); + Method m + = recipeClass + .getMethod("addSolarNeutronRecipe", GasStack.class, GasStack.class); + m.invoke(null, input, output); + } catch (Exception e) { + System.err.println("Error while adding recipe: " + e.getMessage()); + } + } } diff --git a/src/main/java/mekanism/api/recipe/package-info.java b/src/main/java/mekanism/api/recipe/package-info.java index 5e5b595be..9178afa62 100644 --- a/src/main/java/mekanism/api/recipe/package-info.java +++ b/src/main/java/mekanism/api/recipe/package-info.java @@ -1,4 +1,3 @@ @API(apiVersion = "9.0.0", owner = "Mekanism", provides = "MekanismAPI|recipe") package mekanism.api.recipe; import cpw.mods.fml.common.API; - diff --git a/src/main/java/mekanism/api/transmitters/DynamicNetwork.java b/src/main/java/mekanism/api/transmitters/DynamicNetwork.java index 1bf01a879..45d20d4bf 100644 --- a/src/main/java/mekanism/api/transmitters/DynamicNetwork.java +++ b/src/main/java/mekanism/api/transmitters/DynamicNetwork.java @@ -8,6 +8,11 @@ import java.util.LinkedHashSet; import java.util.Map.Entry; import java.util.Set; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.Event; import mekanism.api.Coord4D; import mekanism.api.IClientTicker; import mekanism.api.Range4D; @@ -17,142 +22,119 @@ import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.ForgeDirection; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; +public abstract class DynamicNetwork> + implements IClientTicker, INetworkDataHandler { + public LinkedHashSet> transmitters = Sets.newLinkedHashSet(); + public LinkedHashSet> transmittersToAdd + = Sets.newLinkedHashSet(); + public LinkedHashSet> transmittersAdded + = Sets.newLinkedHashSet(); -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.eventhandler.Event; + public HashMap possibleAcceptors = new HashMap(); + public HashMap> acceptorDirections + = new HashMap>(); + public HashMap, EnumSet> changedAcceptors + = Maps.newHashMap(); -public abstract class DynamicNetwork> implements IClientTicker, INetworkDataHandler -{ - public LinkedHashSet> transmitters = Sets.newLinkedHashSet(); - public LinkedHashSet> transmittersToAdd = Sets.newLinkedHashSet(); - public LinkedHashSet> transmittersAdded = Sets.newLinkedHashSet(); + private Set updateQueue = new LinkedHashSet(); - public HashMap possibleAcceptors = new HashMap(); - public HashMap> acceptorDirections = new HashMap>(); - public HashMap, EnumSet> changedAcceptors = Maps.newHashMap(); + protected Range4D packetRange = null; - private Set updateQueue = new LinkedHashSet(); + protected int capacity = 0; + protected double meanCapacity = 0; - protected Range4D packetRange = null; + protected boolean needsUpdate = false; + protected int updateDelay = 0; - protected int capacity = 0; - protected double meanCapacity = 0; + protected boolean firstUpdate = true; + protected World worldObj = null; - protected boolean needsUpdate = false; - protected int updateDelay = 0; + public void addNewTransmitters(Collection> newTransmitters) { + transmittersToAdd.addAll(newTransmitters); + } - protected boolean firstUpdate = true; - protected World worldObj = null; + public void commit() { + if (!transmittersToAdd.isEmpty()) { + for (IGridTransmitter transmitter : transmittersToAdd) { + if (transmitter.isValid()) { + if (worldObj == null) { + worldObj = transmitter.world(); + } - public void addNewTransmitters(Collection> newTransmitters) - { - transmittersToAdd.addAll(newTransmitters); - } + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + updateTransmitterOnSide(transmitter, side); + } - public void commit() - { - if(!transmittersToAdd.isEmpty()) - { - for(IGridTransmitter transmitter : transmittersToAdd) - { - if(transmitter.isValid()) - { - if(worldObj == null) - { - worldObj = transmitter.world(); - } + transmitter.setTransmitterNetwork((N) this); + absorbBuffer(transmitter); + transmitters.add(transmitter); + } + } - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - updateTransmitterOnSide(transmitter, side); - } - - transmitter.setTransmitterNetwork((N)this); - absorbBuffer(transmitter); - transmitters.add(transmitter); - } - } - - updateCapacity(); - clampBuffer(); - queueClientUpdate(Lists.newArrayList(transmittersToAdd)); - transmittersToAdd.clear(); - } + updateCapacity(); + clampBuffer(); + queueClientUpdate(Lists.newArrayList(transmittersToAdd)); + transmittersToAdd.clear(); + } - if(!changedAcceptors.isEmpty()) - { - for(Entry, EnumSet> entry : changedAcceptors.entrySet()) - { - IGridTransmitter transmitter = entry.getKey(); - - if(transmitter.isValid()) - { - EnumSet directionsChanged = entry.getValue(); + if (!changedAcceptors.isEmpty()) { + for (Entry, EnumSet> entry : + changedAcceptors.entrySet()) { + IGridTransmitter transmitter = entry.getKey(); - for(ForgeDirection side : directionsChanged) - { - updateTransmitterOnSide(transmitter, side); - } - } - } - - changedAcceptors.clear(); - } - } + if (transmitter.isValid()) { + EnumSet directionsChanged = entry.getValue(); - public void updateTransmitterOnSide(IGridTransmitter transmitter, ForgeDirection side) - { - A acceptor = transmitter.getAcceptor(side); - Coord4D acceptorCoord = transmitter.coord().getFromSide(side); - EnumSet directions = acceptorDirections.get(acceptorCoord); + for (ForgeDirection side : directionsChanged) { + updateTransmitterOnSide(transmitter, side); + } + } + } - if(acceptor != null) - { - possibleAcceptors.put(acceptorCoord, acceptor); + changedAcceptors.clear(); + } + } - if(directions != null) - { - directions.add(side.getOpposite()); - } - else { - acceptorDirections.put(acceptorCoord, EnumSet.of(side.getOpposite())); - } - } - else { - if(directions != null) - { - directions.remove(side.getOpposite()); + public void + updateTransmitterOnSide(IGridTransmitter transmitter, ForgeDirection side) { + A acceptor = transmitter.getAcceptor(side); + Coord4D acceptorCoord = transmitter.coord().getFromSide(side); + EnumSet directions = acceptorDirections.get(acceptorCoord); - if(directions.isEmpty()) - { - possibleAcceptors.remove(acceptorCoord); - acceptorDirections.remove(acceptorCoord); - } - } - else { - possibleAcceptors.remove(acceptorCoord); - acceptorDirections.remove(acceptorCoord); - } - } + if (acceptor != null) { + possibleAcceptors.put(acceptorCoord, acceptor); - } + if (directions != null) { + directions.add(side.getOpposite()); + } else { + acceptorDirections.put(acceptorCoord, EnumSet.of(side.getOpposite())); + } + } else { + if (directions != null) { + directions.remove(side.getOpposite()); - public abstract void absorbBuffer(IGridTransmitter transmitter); + if (directions.isEmpty()) { + possibleAcceptors.remove(acceptorCoord); + acceptorDirections.remove(acceptorCoord); + } + } else { + possibleAcceptors.remove(acceptorCoord); + acceptorDirections.remove(acceptorCoord); + } + } + } - public abstract void clampBuffer(); + public abstract void absorbBuffer(IGridTransmitter transmitter); - public void invalidate() - { + public abstract void clampBuffer(); + + public void invalidate() { //Remove invalid transmitters first for share calculations - for(Iterator> iter = transmitters.iterator(); iter.hasNext();) - { + for (Iterator> iter = transmitters.iterator(); + iter.hasNext();) { IGridTransmitter transmitter = iter.next(); - if(!transmitter.isValid()) - { + if (!transmitter.isValid()) { iter.remove(); continue; } @@ -162,302 +144,268 @@ public abstract class DynamicNetwork> implemen clampBuffer(); //Update all shares - for(IGridTransmitter transmitter : transmitters) - { + for (IGridTransmitter transmitter : transmitters) { transmitter.updateShare(); } //Now invalidate the transmitters - for(IGridTransmitter transmitter : transmitters) - { - invalidateTransmitter(transmitter); - } - - transmitters.clear(); - deregister(); - } + for (IGridTransmitter transmitter : transmitters) { + invalidateTransmitter(transmitter); + } - public void invalidateTransmitter(IGridTransmitter transmitter) - { - if(!worldObj.isRemote && transmitter.isValid()) - { - transmitter.takeShare(); - transmitter.setTransmitterNetwork(null); - TransmitterNetworkRegistry.registerOrphanTransmitter(transmitter); - } - } + transmitters.clear(); + deregister(); + } - public void acceptorChanged(IGridTransmitter transmitter, ForgeDirection side) - { - EnumSet directions = changedAcceptors.get(transmitter); - - if(directions != null) - { - directions.add(side); - } - else { - changedAcceptors.put(transmitter, EnumSet.of(side)); - } - - TransmitterNetworkRegistry.registerChangedNetwork(this); - } + public void invalidateTransmitter(IGridTransmitter transmitter) { + if (!worldObj.isRemote && transmitter.isValid()) { + transmitter.takeShare(); + transmitter.setTransmitterNetwork(null); + TransmitterNetworkRegistry.registerOrphanTransmitter(transmitter); + } + } - public void adoptTransmittersAndAcceptorsFrom(N net) - { - for(IGridTransmitter transmitter : net.transmitters) - { - transmitter.setTransmitterNetwork((N)this); - transmitters.add(transmitter); - transmittersAdded.add(transmitter); - } - - possibleAcceptors.putAll(net.possibleAcceptors); - - for(Entry> entry : net.acceptorDirections.entrySet()) - { - Coord4D coord = entry.getKey(); - - if(acceptorDirections.containsKey(coord)) - { - acceptorDirections.get(coord).addAll(entry.getValue()); - } - else { - acceptorDirections.put(coord, entry.getValue()); - } - } + public void acceptorChanged(IGridTransmitter transmitter, ForgeDirection side) { + EnumSet directions = changedAcceptors.get(transmitter); - } + if (directions != null) { + directions.add(side); + } else { + changedAcceptors.put(transmitter, EnumSet.of(side)); + } - public Range4D getPacketRange() - { - if(packetRange == null) - { - return genPacketRange(); - } - - return packetRange; - } - - protected Range4D genPacketRange() - { - if(getSize() == 0) - { - deregister(); - return null; - } + TransmitterNetworkRegistry.registerChangedNetwork(this); + } - IGridTransmitter initTransmitter = transmitters.iterator().next(); - Coord4D initCoord = initTransmitter.coord(); - - 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 = transmitter.coord(); - - 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; - } - - return new Range4D(minX, minY, minZ, maxX, maxY, maxZ, initTransmitter.world().provider.dimensionId); - } + public void adoptTransmittersAndAcceptorsFrom(N net) { + for (IGridTransmitter transmitter : net.transmitters) { + transmitter.setTransmitterNetwork((N) this); + transmitters.add(transmitter); + transmittersAdded.add(transmitter); + } - public void register() - { - if(FMLCommonHandler.instance().getEffectiveSide().isServer()) - { - TransmitterNetworkRegistry.getInstance().registerNetwork(this); - } - else { - MinecraftForge.EVENT_BUS.post(new ClientTickUpdate(this, (byte)1)); - } - } + possibleAcceptors.putAll(net.possibleAcceptors); - public void deregister() - { - transmitters.clear(); + for (Entry> entry : + net.acceptorDirections.entrySet()) { + Coord4D coord = entry.getKey(); - if(FMLCommonHandler.instance().getEffectiveSide().isServer()) - { - TransmitterNetworkRegistry.getInstance().removeNetwork(this); - } - else { - MinecraftForge.EVENT_BUS.post(new ClientTickUpdate(this, (byte)0)); - } - } + if (acceptorDirections.containsKey(coord)) { + acceptorDirections.get(coord).addAll(entry.getValue()); + } else { + acceptorDirections.put(coord, entry.getValue()); + } + } + } - public int getSize() - { - return transmitters.size(); - } + public Range4D getPacketRange() { + if (packetRange == null) { + return genPacketRange(); + } - public int getAcceptorSize() - { - return possibleAcceptors.size(); - } + return packetRange; + } - public synchronized void updateCapacity() - { - updateMeanCapacity(); - capacity = (int)meanCapacity * transmitters.size(); - } + protected Range4D genPacketRange() { + if (getSize() == 0) { + deregister(); + return null; + } + + IGridTransmitter initTransmitter = transmitters.iterator().next(); + Coord4D initCoord = initTransmitter.coord(); + + 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 = transmitter.coord(); + + 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; + } + + return new Range4D( + minX, + minY, + minZ, + maxX, + maxY, + maxZ, + initTransmitter.world().provider.dimensionId + ); + } + + public void register() { + if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { + TransmitterNetworkRegistry.getInstance().registerNetwork(this); + } else { + MinecraftForge.EVENT_BUS.post(new ClientTickUpdate(this, (byte) 1)); + } + } + + public void deregister() { + transmitters.clear(); + + if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { + TransmitterNetworkRegistry.getInstance().removeNetwork(this); + } else { + MinecraftForge.EVENT_BUS.post(new ClientTickUpdate(this, (byte) 0)); + } + } + + public int getSize() { + return transmitters.size(); + } + + 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; + protected synchronized void updateMeanCapacity() { + if (transmitters.size() > 0) { + meanCapacity = transmitters.iterator().next().getCapacity(); + } else { + meanCapacity = 0; + } } - public World getWorld() - { - return worldObj; - } + public int getCapacity() { + return capacity; + } - public abstract Set getAcceptors(Object data); + public World getWorld() { + return worldObj; + } - public void tick() - { - onUpdate(); - } + public abstract Set getAcceptors(Object data); - public void onUpdate() - { - if(FMLCommonHandler.instance().getEffectiveSide().isServer()) - { - Iterator i = updateQueue.iterator(); + public void tick() { + onUpdate(); + } - try { - while(i.hasNext()) - { - DelayQueue q = i.next(); + public void onUpdate() { + if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { + Iterator i = updateQueue.iterator(); - if(q.delay > 0) - { - q.delay--; - } - else { - transmittersAdded.addAll(transmitters); - updateDelay = 1; - i.remove(); - } - } - } catch(Exception e) {} + try { + while (i.hasNext()) { + DelayQueue q = i.next(); - if(updateDelay > 0) - { - updateDelay--; + if (q.delay > 0) { + q.delay--; + } else { + transmittersAdded.addAll(transmitters); + updateDelay = 1; + i.remove(); + } + } + } catch (Exception e) {} - if(updateDelay == 0) - { - MinecraftForge.EVENT_BUS.post(new TransmittersAddedEvent(this, firstUpdate, (Collection)transmittersAdded)); - firstUpdate = false; - transmittersAdded.clear(); - needsUpdate = true; - } - } - } - } + if (updateDelay > 0) { + updateDelay--; - @Override - public boolean needsTicks() - { - return getSize() > 0; - } + if (updateDelay == 0) { + MinecraftForge.EVENT_BUS.post(new TransmittersAddedEvent( + this, firstUpdate, (Collection) transmittersAdded + )); + firstUpdate = false; + transmittersAdded.clear(); + needsUpdate = true; + } + } + } + } - @Override - public void clientTick() {} + @Override + public boolean needsTicks() { + return getSize() > 0; + } - public void queueClientUpdate(Collection> newTransmitters) - { - transmittersAdded.addAll(newTransmitters); - updateDelay = 3; - } + @Override + public void clientTick() {} - public static class TransmittersAddedEvent extends Event - { - public DynamicNetwork network; - public boolean newNetwork; - public Collection newTransmitters; + public void queueClientUpdate(Collection> newTransmitters) { + transmittersAdded.addAll(newTransmitters); + updateDelay = 3; + } - public TransmittersAddedEvent(DynamicNetwork net, boolean newNet, Collection added) - { - network = net; - newNetwork = newNet; - newTransmitters = added; - } - } + public static class TransmittersAddedEvent extends Event { + public DynamicNetwork network; + public boolean newNetwork; + public Collection newTransmitters; - public static class ClientTickUpdate extends Event - { - public DynamicNetwork network; - public byte operation; /*0 remove, 1 add*/ + public TransmittersAddedEvent( + DynamicNetwork net, boolean newNet, Collection added + ) { + network = net; + newNetwork = newNet; + newTransmitters = added; + } + } - public ClientTickUpdate(DynamicNetwork net, byte b) - { - network = net; - operation = b; - } - } + public static class ClientTickUpdate extends Event { + public DynamicNetwork network; + public byte operation; /*0 remove, 1 add*/ - public static class NetworkClientRequest extends Event - { - public TileEntity tileEntity; + public ClientTickUpdate(DynamicNetwork net, byte b) { + network = net; + operation = b; + } + } - public NetworkClientRequest(TileEntity tile) - { - tileEntity = tile; - } - } + public static class NetworkClientRequest extends Event { + public TileEntity tileEntity; - public void addUpdate(EntityPlayer player) - { - updateQueue.add(new DelayQueue(player)); - } + public NetworkClientRequest(TileEntity tile) { + tileEntity = tile; + } + } - public static class DelayQueue - { - public EntityPlayer player; - public int delay; + public void addUpdate(EntityPlayer player) { + updateQueue.add(new DelayQueue(player)); + } - public DelayQueue(EntityPlayer p) - { - player = p; - delay = 5; - } + public static class DelayQueue { + public EntityPlayer player; + public int delay; - @Override - public int hashCode() - { - return player.hashCode(); - } + public DelayQueue(EntityPlayer p) { + player = p; + delay = 5; + } - @Override - public boolean equals(Object o) - { - return o instanceof DelayQueue && ((DelayQueue)o).player.equals(this.player); - } - } + @Override + public int hashCode() { + return player.hashCode(); + } + + @Override + public boolean equals(Object o) { + return o instanceof DelayQueue && ((DelayQueue) o).player.equals(this.player); + } + } } diff --git a/src/main/java/mekanism/api/transmitters/IBlockableConnection.java b/src/main/java/mekanism/api/transmitters/IBlockableConnection.java index f6811fbec..41a329e43 100644 --- a/src/main/java/mekanism/api/transmitters/IBlockableConnection.java +++ b/src/main/java/mekanism/api/transmitters/IBlockableConnection.java @@ -2,9 +2,8 @@ package mekanism.api.transmitters; import net.minecraftforge.common.util.ForgeDirection; -public interface IBlockableConnection -{ - public boolean canConnectMutual(ForgeDirection side); - - public boolean canConnect(ForgeDirection side); +public interface IBlockableConnection { + public boolean canConnectMutual(ForgeDirection side); + + public boolean canConnect(ForgeDirection side); } diff --git a/src/main/java/mekanism/api/transmitters/IGridTransmitter.java b/src/main/java/mekanism/api/transmitters/IGridTransmitter.java index c0ea3d5fd..629e76604 100644 --- a/src/main/java/mekanism/api/transmitters/IGridTransmitter.java +++ b/src/main/java/mekanism/api/transmitters/IGridTransmitter.java @@ -6,59 +6,59 @@ import mekanism.api.Coord4D; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -public interface IGridTransmitter> extends ITransmitter -{ - public boolean hasTransmitterNetwork(); +public interface IGridTransmitter> + extends ITransmitter { + public boolean hasTransmitterNetwork(); - /** - * 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. + * @return network this transmitter is using + */ + public N getTransmitterNetwork(); - /** - * Sets this transmitter segment's network to a new value. - * @param network - network to set to - */ - public void setTransmitterNetwork(N network); + /** + * Sets this transmitter segment's network to a new value. + * @param network - network to set to + */ + public void setTransmitterNetwork(N network); - public int getTransmitterNetworkSize(); + public int getTransmitterNetworkSize(); - public int getTransmitterNetworkAcceptorSize(); + public int getTransmitterNetworkAcceptorSize(); - public String getTransmitterNetworkNeeded(); + public String getTransmitterNetworkNeeded(); - public String getTransmitterNetworkFlow(); + public String getTransmitterNetworkFlow(); - public String getTransmitterNetworkBuffer(); + public String getTransmitterNetworkBuffer(); - public double getTransmitterNetworkCapacity(); + public double getTransmitterNetworkCapacity(); - public int getCapacity(); + public int getCapacity(); - public World world(); - - public Coord4D coord(); + public World world(); - public Coord4D getAdjacentConnectableTransmitterCoord(ForgeDirection side); + public Coord4D coord(); - public A getAcceptor(ForgeDirection side); + public Coord4D getAdjacentConnectableTransmitterCoord(ForgeDirection side); - public boolean isValid(); + public A getAcceptor(ForgeDirection side); - public boolean isOrphan(); + public boolean isValid(); - public void setOrphan(boolean orphaned); + public boolean isOrphan(); - public N createEmptyNetwork(); + public void setOrphan(boolean orphaned); - public N mergeNetworks(Collection toMerge); + public N createEmptyNetwork(); - public N getExternalNetwork(Coord4D from); + public N mergeNetworks(Collection toMerge); - public void takeShare(); + public N getExternalNetwork(Coord4D from); + + public void takeShare(); public void updateShare(); - public Object getBuffer(); + public Object getBuffer(); } diff --git a/src/main/java/mekanism/api/transmitters/INetworkDataHandler.java b/src/main/java/mekanism/api/transmitters/INetworkDataHandler.java index 38cd63702..15c8a5ded 100644 --- a/src/main/java/mekanism/api/transmitters/INetworkDataHandler.java +++ b/src/main/java/mekanism/api/transmitters/INetworkDataHandler.java @@ -1,10 +1,9 @@ package mekanism.api.transmitters; -public interface INetworkDataHandler -{ - public String getNeededInfo(); +public interface INetworkDataHandler { + public String getNeededInfo(); - public String getStoredInfo(); + public String getStoredInfo(); - public String getFlowInfo(); + public String getFlowInfo(); } diff --git a/src/main/java/mekanism/api/transmitters/ITransmitter.java b/src/main/java/mekanism/api/transmitters/ITransmitter.java index cddc76a7a..674d297ee 100644 --- a/src/main/java/mekanism/api/transmitters/ITransmitter.java +++ b/src/main/java/mekanism/api/transmitters/ITransmitter.java @@ -1,11 +1,10 @@ package mekanism.api.transmitters; -public interface ITransmitter -{ - /** - * Get the transmitter's transmission type - * - * @return TransmissionType this transmitter uses - */ - public TransmissionType getTransmissionType(); +public interface ITransmitter { + /** + * Get the transmitter's transmission type + * + * @return TransmissionType this transmitter uses + */ + public TransmissionType getTransmissionType(); } diff --git a/src/main/java/mekanism/api/transmitters/ITransmitterTile.java b/src/main/java/mekanism/api/transmitters/ITransmitterTile.java index 3940b71a6..e49363a14 100644 --- a/src/main/java/mekanism/api/transmitters/ITransmitterTile.java +++ b/src/main/java/mekanism/api/transmitters/ITransmitterTile.java @@ -1,6 +1,5 @@ package mekanism.api.transmitters; -public interface ITransmitterTile> -{ - public IGridTransmitter getTransmitter(); +public interface ITransmitterTile> { + public IGridTransmitter getTransmitter(); } diff --git a/src/main/java/mekanism/api/transmitters/TransmissionType.java b/src/main/java/mekanism/api/transmitters/TransmissionType.java index 8ea4b4311..e65326edc 100644 --- a/src/main/java/mekanism/api/transmitters/TransmissionType.java +++ b/src/main/java/mekanism/api/transmitters/TransmissionType.java @@ -4,76 +4,64 @@ import mekanism.api.gas.IGasTransmitter; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.StatCollector; -public enum TransmissionType -{ - ENERGY("EnergyNetwork", "Energy"), - FLUID("FluidNetwork", "Fluids"), - GAS("GasNetwork", "Gases"), - ITEM("InventoryNetwork", "Items"), - HEAT("HeatNetwork", "Heat"); - - private String name; - private String transmission; - - private TransmissionType(String n, String t) - { - name = n; - transmission = t; - } - - public String getName() - { - return name; - } - - public String getTransmission() - { - return transmission; - } - - public String localize() - { - return StatCollector.translateToLocal("transmission." + getTransmission()); - } +public enum TransmissionType { + ENERGY("EnergyNetwork", "Energy"), + FLUID("FluidNetwork", "Fluids"), + GAS("GasNetwork", "Gases"), + ITEM("InventoryNetwork", "Items"), + HEAT("HeatNetwork", "Heat"); - public static boolean checkTransmissionType(ITransmitter sideTile, TransmissionType type) - { - return type.checkTransmissionType(sideTile); - } + private String name; + private String transmission; - public static boolean checkTransmissionType(TileEntity tile1, TransmissionType type) - { - return checkTransmissionType(tile1, type, null); - } + private TransmissionType(String n, String t) { + name = n; + transmission = t; + } - public static boolean checkTransmissionType(TileEntity tile1, TransmissionType type, TileEntity tile2) - { - return type.checkTransmissionType(tile1, tile2); - } + public String getName() { + return name; + } - public boolean checkTransmissionType(ITransmitter transmitter) - { - return transmitter.getTransmissionType() == this; - } + public String getTransmission() { + return transmission; + } - public boolean checkTransmissionType(TileEntity sideTile, TileEntity currentTile) - { - if(sideTile instanceof ITransmitter) - { - if(((ITransmitter)sideTile).getTransmissionType() == this) - { - return true; - } - } + public String localize() { + return StatCollector.translateToLocal("transmission." + getTransmission()); + } - if(this == GAS && currentTile instanceof IGasTransmitter) - { - if(((IGasTransmitter)currentTile).canTransferGasToTube(sideTile)) - { - return true; - } - } + public static boolean + checkTransmissionType(ITransmitter sideTile, TransmissionType type) { + return type.checkTransmissionType(sideTile); + } - return false; - } + public static boolean checkTransmissionType(TileEntity tile1, TransmissionType type) { + return checkTransmissionType(tile1, type, null); + } + + public static boolean + checkTransmissionType(TileEntity tile1, TransmissionType type, TileEntity tile2) { + return type.checkTransmissionType(tile1, tile2); + } + + public boolean checkTransmissionType(ITransmitter transmitter) { + return transmitter.getTransmissionType() == this; + } + + 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/main/java/mekanism/api/transmitters/TransmitterNetworkRegistry.java b/src/main/java/mekanism/api/transmitters/TransmitterNetworkRegistry.java index 0f9c1c5fb..846dfbd05 100644 --- a/src/main/java/mekanism/api/transmitters/TransmitterNetworkRegistry.java +++ b/src/main/java/mekanism/api/transmitters/TransmitterNetworkRegistry.java @@ -3,287 +3,256 @@ package mekanism.api.transmitters; import java.util.HashMap; import java.util.HashSet; -import mekanism.api.Coord4D; -import mekanism.api.MekanismAPI; -import net.minecraftforge.common.util.ForgeDirection; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - import com.google.common.collect.Maps; import com.google.common.collect.Sets; - 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; +import mekanism.api.Coord4D; +import mekanism.api.MekanismAPI; +import net.minecraftforge.common.util.ForgeDirection; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; -public class TransmitterNetworkRegistry -{ - private static TransmitterNetworkRegistry INSTANCE = new TransmitterNetworkRegistry(); - private static boolean loaderRegistered = false; +public class TransmitterNetworkRegistry { + private static TransmitterNetworkRegistry INSTANCE = new TransmitterNetworkRegistry(); + private static boolean loaderRegistered = false; - private HashSet networks = Sets.newHashSet(); - private HashSet networksToChange = Sets.newHashSet(); + private HashSet networks = Sets.newHashSet(); + private HashSet networksToChange = Sets.newHashSet(); - private HashSet invalidTransmitters = Sets.newHashSet(); - private HashMap orphanTransmitters = Maps.newHashMap(); + private HashSet invalidTransmitters = Sets.newHashSet(); + private HashMap orphanTransmitters = Maps.newHashMap(); - private Logger logger = LogManager.getLogger("MekanismTransmitters"); + private Logger logger = LogManager.getLogger("MekanismTransmitters"); - public static void initiate() - { - if(!loaderRegistered) - { - loaderRegistered = true; + public static void initiate() { + if (!loaderRegistered) { + loaderRegistered = true; - FMLCommonHandler.instance().bus().register(INSTANCE); - } - } + FMLCommonHandler.instance().bus().register(INSTANCE); + } + } - public static void reset() - { - getInstance().networks.clear(); - getInstance().networksToChange.clear(); - getInstance().invalidTransmitters.clear(); - getInstance().orphanTransmitters.clear(); - } + public static void reset() { + getInstance().networks.clear(); + getInstance().networksToChange.clear(); + getInstance().invalidTransmitters.clear(); + getInstance().orphanTransmitters.clear(); + } - public static void invalidateTransmitter(IGridTransmitter transmitter) - { - getInstance().invalidTransmitters.add(transmitter); - } + public static void invalidateTransmitter(IGridTransmitter transmitter) { + getInstance().invalidTransmitters.add(transmitter); + } - public static void registerOrphanTransmitter(IGridTransmitter transmitter) - { - getInstance().orphanTransmitters.put(transmitter.coord(), transmitter); - } + public static void registerOrphanTransmitter(IGridTransmitter transmitter) { + getInstance().orphanTransmitters.put(transmitter.coord(), transmitter); + } - public static void registerChangedNetwork(DynamicNetwork network) - { - getInstance().networksToChange.add(network); - } + public static void registerChangedNetwork(DynamicNetwork network) { + getInstance().networksToChange.add(network); + } - public static TransmitterNetworkRegistry getInstance() - { - return INSTANCE; - } + public static TransmitterNetworkRegistry getInstance() { + return INSTANCE; + } - public void registerNetwork(DynamicNetwork network) - { - networks.add(network); - } + public void registerNetwork(DynamicNetwork network) { + networks.add(network); + } - public void removeNetwork(DynamicNetwork network) - { - if(networks.contains(network)) - { - networks.remove(network); - } - } + public void removeNetwork(DynamicNetwork network) { + if (networks.contains(network)) { + networks.remove(network); + } + } - @SubscribeEvent - public void onTick(ServerTickEvent event) - { - if(event.phase == Phase.END && event.side == Side.SERVER) - { - tickEnd(); - } - } + @SubscribeEvent + public void onTick(ServerTickEvent event) { + if (event.phase == Phase.END && event.side == Side.SERVER) { + tickEnd(); + } + } - public void tickEnd() - { - removeInvalidTransmitters(); + public void tickEnd() { + removeInvalidTransmitters(); - assignOrphans(); + assignOrphans(); - commitChanges(); + commitChanges(); - for(DynamicNetwork net : networks) - { - net.tick(); - } - } + for (DynamicNetwork net : networks) { + net.tick(); + } + } - public void removeInvalidTransmitters() - { - if(MekanismAPI.debug && !invalidTransmitters.isEmpty()) - { - logger.info("Dealing with " + invalidTransmitters.size() + " invalid Transmitters"); - } - - for(IGridTransmitter invalid : invalidTransmitters) - { - if(!(invalid.isOrphan() && invalid.isValid())) - { - DynamicNetwork n = invalid.getTransmitterNetwork(); - - if(n != null) - { - n.invalidate(); - } - } - } - - invalidTransmitters.clear(); - } + public void removeInvalidTransmitters() { + if (MekanismAPI.debug && !invalidTransmitters.isEmpty()) { + logger.info( + "Dealing with " + invalidTransmitters.size() + " invalid Transmitters" + ); + } - public void assignOrphans() - { - if(MekanismAPI.debug && !orphanTransmitters.isEmpty()) - { - logger.info("Dealing with " + orphanTransmitters.size() + " orphan Transmitters"); - } - - for(IGridTransmitter orphanTransmitter : orphanTransmitters.values()) - { - DynamicNetwork network = getNetworkFromOrphan(orphanTransmitter); - - if(network != null) - { - networksToChange.add(network); - network.register(); - } - } - - orphanTransmitters.clear(); - } + for (IGridTransmitter invalid : invalidTransmitters) { + if (!(invalid.isOrphan() && invalid.isValid())) { + DynamicNetwork n = invalid.getTransmitterNetwork(); - public > DynamicNetwork getNetworkFromOrphan(IGridTransmitter startOrphan) - { - if(startOrphan.isValid() && startOrphan.isOrphan()) - { - OrphanPathFinder finder = new OrphanPathFinder(startOrphan); - finder.start(); - N network; - - switch(finder.networksFound.size()) - { - case 0: - if(MekanismAPI.debug) - { - logger.info("No networks found. Creating new network for " + finder.connectedTransmitters.size() + " transmitters"); - } - - network = startOrphan.createEmptyNetwork(); - - break; - case 1: - if(MekanismAPI.debug) - { - logger.info("Adding " + finder.connectedTransmitters.size() + " transmitters to single found network"); - } - - network = finder.networksFound.iterator().next(); - - break; - default: - if(MekanismAPI.debug) - { - logger.info("Merging " + finder.networksFound.size() + " networks with " + finder.connectedTransmitters.size() + " new transmitters"); - } - - network = startOrphan.mergeNetworks(finder.networksFound); - } - - network.addNewTransmitters(finder.connectedTransmitters); - - return network; - } - - return null; - } + if (n != null) { + n.invalidate(); + } + } + } - public void commitChanges() - { - for(DynamicNetwork network : networksToChange) - { - network.commit(); - } - - networksToChange.clear(); - } + invalidTransmitters.clear(); + } - @Override - public String toString() - { - return "Network Registry:\n" + networks; - } + public void assignOrphans() { + if (MekanismAPI.debug && !orphanTransmitters.isEmpty()) { + logger.info( + "Dealing with " + orphanTransmitters.size() + " orphan Transmitters" + ); + } - public String[] toStrings() - { - String[] strings = new String[networks.size()]; - int i = 0; + for (IGridTransmitter orphanTransmitter : orphanTransmitters.values()) { + DynamicNetwork network = getNetworkFromOrphan(orphanTransmitter); - for(DynamicNetwork network : networks) - { - strings[i++] = network.toString(); - } + if (network != null) { + networksToChange.add(network); + network.register(); + } + } - return strings; - } + orphanTransmitters.clear(); + } - public class OrphanPathFinder> - { - public IGridTransmitter startPoint; + public > DynamicNetwork + getNetworkFromOrphan(IGridTransmitter startOrphan) { + if (startOrphan.isValid() && startOrphan.isOrphan()) { + OrphanPathFinder finder = new OrphanPathFinder(startOrphan); + finder.start(); + N network; - public HashSet iterated = Sets.newHashSet(); + switch (finder.networksFound.size()) { + case 0: + if (MekanismAPI.debug) { + logger.info( + "No networks found. Creating new network for " + + finder.connectedTransmitters.size() + " transmitters" + ); + } - public HashSet> connectedTransmitters = Sets.newHashSet(); - public HashSet networksFound = Sets.newHashSet(); + network = startOrphan.createEmptyNetwork(); - public OrphanPathFinder(IGridTransmitter start) - { - startPoint = start; - } + break; + case 1: + if (MekanismAPI.debug) { + logger.info( + "Adding " + finder.connectedTransmitters.size() + + " transmitters to single found network" + ); + } - public void start() - { - iterate(startPoint.coord(), ForgeDirection.UNKNOWN); - } + network = finder.networksFound.iterator().next(); - public void iterate(Coord4D from, ForgeDirection fromDirection) - { - if(iterated.contains(from)) - { - return; - } + break; + default: + if (MekanismAPI.debug) { + logger.info( + "Merging " + finder.networksFound.size() + " networks with " + + finder.connectedTransmitters.size() + " new transmitters" + ); + } - iterated.add(from); - - if(orphanTransmitters.containsKey(from)) - { - IGridTransmitter transmitter = orphanTransmitters.get(from); - - if(transmitter.isValid() && transmitter.isOrphan()) - { - connectedTransmitters.add(transmitter); - transmitter.setOrphan(false); - - for(ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) - { - if(direction != fromDirection) - { - Coord4D directionCoord = transmitter.getAdjacentConnectableTransmitterCoord(direction); - - if(!(directionCoord == null || iterated.contains(directionCoord))) - { - iterate(directionCoord, direction.getOpposite()); - } - } - } - } - } - else { - addNetworkToIterated(from); - } - } + network = startOrphan.mergeNetworks(finder.networksFound); + } - public void addNetworkToIterated(Coord4D from) - { - N net = startPoint.getExternalNetwork(from); - if(net != null) networksFound.add(net); - } - } + network.addNewTransmitters(finder.connectedTransmitters); + + return network; + } + + return null; + } + + public void commitChanges() { + for (DynamicNetwork network : networksToChange) { + network.commit(); + } + + networksToChange.clear(); + } + + @Override + public String toString() { + return "Network Registry:\n" + networks; + } + + public String[] toStrings() { + String[] strings = new String[networks.size()]; + int i = 0; + + for (DynamicNetwork network : networks) { + strings[i++] = network.toString(); + } + + return strings; + } + + public class OrphanPathFinder> { + public IGridTransmitter startPoint; + + public HashSet iterated = Sets.newHashSet(); + + public HashSet> connectedTransmitters = Sets.newHashSet(); + public HashSet networksFound = Sets.newHashSet(); + + public OrphanPathFinder(IGridTransmitter start) { + startPoint = start; + } + + public void start() { + iterate(startPoint.coord(), ForgeDirection.UNKNOWN); + } + + public void iterate(Coord4D from, ForgeDirection fromDirection) { + if (iterated.contains(from)) { + return; + } + + iterated.add(from); + + if (orphanTransmitters.containsKey(from)) { + IGridTransmitter transmitter = orphanTransmitters.get(from); + + if (transmitter.isValid() && transmitter.isOrphan()) { + connectedTransmitters.add(transmitter); + transmitter.setOrphan(false); + + for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { + if (direction != fromDirection) { + Coord4D directionCoord + = transmitter.getAdjacentConnectableTransmitterCoord( + direction + ); + + if (!(directionCoord == null + || iterated.contains(directionCoord))) { + iterate(directionCoord, direction.getOpposite()); + } + } + } + } + } else { + addNetworkToIterated(from); + } + } + + public void addNetworkToIterated(Coord4D from) { + N net = startPoint.getExternalNetwork(from); + if (net != null) + networksFound.add(net); + } + } } diff --git a/src/main/java/mekanism/api/transmitters/package-info.java b/src/main/java/mekanism/api/transmitters/package-info.java index fe5e7cc61..6a44948bd 100644 --- a/src/main/java/mekanism/api/transmitters/package-info.java +++ b/src/main/java/mekanism/api/transmitters/package-info.java @@ -1,4 +1,3 @@ @API(apiVersion = "9.0.0", owner = "Mekanism", provides = "MekanismAPI|transmitter") package mekanism.api.transmitters; import cpw.mods.fml.common.API; - diff --git a/src/main/java/mekanism/api/util/BlockInfo.java b/src/main/java/mekanism/api/util/BlockInfo.java index 2cb40d7df..b026db3e9 100644 --- a/src/main/java/mekanism/api/util/BlockInfo.java +++ b/src/main/java/mekanism/api/util/BlockInfo.java @@ -3,36 +3,32 @@ package mekanism.api.util; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; -public class BlockInfo -{ - public Block block; - public int meta; +public class BlockInfo { + public Block block; + public int meta; - public BlockInfo(Block b, int j) - { - block = b; - meta = j; - } + 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()); - } + 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 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; - } + @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/main/java/mekanism/api/util/ItemInfo.java b/src/main/java/mekanism/api/util/ItemInfo.java index f27065b66..b3c971da3 100644 --- a/src/main/java/mekanism/api/util/ItemInfo.java +++ b/src/main/java/mekanism/api/util/ItemInfo.java @@ -3,36 +3,30 @@ package mekanism.api.util; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -public class ItemInfo -{ - public Item item; - public int meta; +public class ItemInfo { + public Item item; + public int meta; - public ItemInfo(Item i, int j) - { - item = i; - meta = j; - } + public ItemInfo(Item i, int j) { + item = i; + meta = j; + } - public static ItemInfo get(ItemStack stack) - { - return new ItemInfo(stack.getItem(), stack.getItemDamage()); - } + public static ItemInfo get(ItemStack stack) { + return new ItemInfo(stack.getItem(), stack.getItemDamage()); + } - @Override - public boolean equals(Object obj) - { - return obj instanceof ItemInfo && - ((ItemInfo)obj).item == item && - ((ItemInfo)obj).meta == meta; - } + @Override + public boolean equals(Object obj) { + return obj instanceof ItemInfo && ((ItemInfo) obj).item == item + && ((ItemInfo) obj).meta == meta; + } - @Override - public int hashCode() - { - int code = 1; - code = 31 * code + System.identityHashCode(item); - code = 7 * code + meta; - return code; - } + @Override + public int hashCode() { + int code = 1; + code = 31 * code + System.identityHashCode(item); + code = 7 * code + meta; + return code; + } } diff --git a/src/main/java/mekanism/api/util/ListUtils.java b/src/main/java/mekanism/api/util/ListUtils.java index e20807c53..23b1faee5 100644 --- a/src/main/java/mekanism/api/util/ListUtils.java +++ b/src/main/java/mekanism/api/util/ListUtils.java @@ -5,278 +5,235 @@ 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(); +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)); - } + for (int i = list.size() - 1; i >= 0; i--) { + toReturn.add(list.get(i)); + } - return toReturn; - } + return toReturn; + } - public static List cap(List list, int cap) - { - List toReturn = new ArrayList(); + public static List cap(List list, int cap) { + List toReturn = new ArrayList(); - if(list.size() <= cap) - { - toReturn = copy(list); - } - else { - int count = 0; + if (list.size() <= cap) { + toReturn = copy(list); + } else { + int count = 0; - for(V obj : list) - { - count++; + for (V obj : list) { + count++; - toReturn.add(obj); + toReturn.add(obj); - if(count == cap) - { - break; - } - } - } + if (count == cap) { + break; + } + } + } - return toReturn; - } + return toReturn; + } - public static List copy(List list) - { - List toReturn = new ArrayList(); + public static List copy(List list) { + List toReturn = new ArrayList(); - for(V obj : list) - { - toReturn.add(obj); - } + for (V obj : list) { + toReturn.add(obj); + } - return toReturn; - } + return toReturn; + } - public static List merge(List listOne, List listTwo) - { - List newList = new ArrayList(); + public static List merge(List listOne, List listTwo) { + List newList = new ArrayList(); - for(V obj : listOne) - { - newList.add(obj); - } + for (V obj : listOne) { + newList.add(obj); + } - for(V obj : listTwo) - { - newList.add(obj); - } + for (V obj : listTwo) { + newList.add(obj); + } - return newList; - } + return newList; + } - public static List capRemains(List list, int cap) - { - List toReturn = new ArrayList(); + public static List capRemains(List list, int cap) { + List toReturn = new ArrayList(); - if(list.size() <= cap) - { - return toReturn; - } - else { - List inverse = inverse(list); + if (list.size() <= cap) { + return toReturn; + } else { + List inverse = inverse(list); - int iterNeeded = list.size() - cap; - int count = 0; + int iterNeeded = list.size() - cap; + int count = 0; - for(V obj : list) - { - count++; + for (V obj : list) { + count++; - toReturn.add(obj); + toReturn.add(obj); - if(count == iterNeeded) - { - break; - } - } + if (count == iterNeeded) { + break; + } + } - return toReturn; - } - } + return toReturn; + } + } - public static ArrayList> split(List list, int divide) - { - int remain = list.size() % divide; - int size = (list.size() - remain) / divide; + public static ArrayList> split(List list, int divide) { + int remain = list.size() % divide; + int size = (list.size() - remain) / divide; - ArrayList> toReturn = new ArrayList>(); + ArrayList> toReturn = new ArrayList>(); - for(int i = 0; i < divide; i++) - { - toReturn.add(i, new ArrayList()); - } + for (int i = 0; i < divide; i++) { + toReturn.add(i, new ArrayList()); + } - for(List iterSet : toReturn) - { - List removed = new ArrayList(); + for (List iterSet : toReturn) { + List removed = new ArrayList(); - int toAdd = size; + int toAdd = size; - if(remain > 0) - { - remain--; - toAdd++; - } + if (remain > 0) { + remain--; + toAdd++; + } - for(V obj : list) - { - if(toAdd == 0) - { - break; - } + for (V obj : list) { + if (toAdd == 0) { + break; + } - iterSet.add(obj); - removed.add(obj); - toAdd--; - } + iterSet.add(obj); + removed.add(obj); + toAdd--; + } - for(V obj : removed) - { - list.remove(obj); - } - } + for (V obj : removed) { + list.remove(obj); + } + } - return toReturn; - } + return toReturn; + } - public static V getTop(List list) - { - for(V obj : list) - { - return obj; - } + public static V getTop(List list) { + for (V obj : list) { + return obj; + } - return null; - } + return null; + } - public static List asList(Set set) - { - return (List)Arrays.asList(set.toArray()); - } + 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 List asList(V... values) { + return (List) Arrays.asList(values); + } - public static double[] splitDouble(int size, double num) - { - double[] split = new double[size]; + 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; + for (int i = 0; i < size; i++) { + double remain = num % size; + double ret = (num - remain) / size; + ret += remain; - split[i] = ret; - num -= remain; - } + split[i] = ret; + num -= remain; + } - return split; - } + return split; + } - public static double[] percent(double[] values) - { - double[] ret = new double[values.length]; - double total = 0; + public static double[] percent(double[] values) { + double[] ret = new double[values.length]; + double total = 0; - for(double d : values) total += d; + for (double d : values) + total += d; - for(int i = 0; i < values.length; i++) - { - ret[i] = values[i]/total; - } + for (int i = 0; i < values.length; i++) { + ret[i] = values[i] / total; + } - return ret; - } + return ret; + } - public static int[] calcPercentInt(double[] percent, int val) - { - int[] ret = new int[percent.length]; + 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]); - } + 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 newTotal = 0; + for (int i : ret) + newTotal += i; - int diff = val-newTotal; + int diff = val - newTotal; - if(diff != val) - { - for(int i = 0; i < ret.length; i++) - { - int num = ret[i]; + if (diff != val) { + for (int i = 0; i < ret.length; i++) { + int num = ret[i]; - if(diff < 0 && num == 0) - { - continue; - } + if (diff < 0 && num == 0) { + continue; + } - if(diff > 0) - { - ret[i]++; - diff--; - } - else if(diff < 0) - { - ret[i]--; - diff++; - } + if (diff > 0) { + ret[i]++; + diff--; + } else if (diff < 0) { + ret[i]--; + diff++; + } - if(diff == 0) - { - return ret; - } - } - } + if (diff == 0) { + return ret; + } + } + } - return ret; - } + return ret; + } - public static int[] splitInt(int size, int num) - { - int[] split = new int[size]; + 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; + for (int i = 0; i < size; i++) { + int remain = num % size; + int ret = (num - remain) / size; + ret += remain; - split[i] = ret; - num -= remain; - } + split[i] = ret; + num -= remain; + } - return split; - } + return split; + } - public static double[] percent(int[] values) - { - double[] ret = new double[values.length]; - double total = 0; + public static double[] percent(int[] values) { + double[] ret = new double[values.length]; + double total = 0; - for(double d : values) total += d; + for (double d : values) + total += d; - for(int i = 0; i < values.length; i++) - { - ret[i] = values[i]/total; - } + for (int i = 0; i < values.length; i++) { + ret[i] = values[i] / total; + } - return ret; - } + return ret; + } } diff --git a/src/main/java/mekanism/api/util/StackUtils.java b/src/main/java/mekanism/api/util/StackUtils.java index 649046583..7ba29cd5b 100644 --- a/src/main/java/mekanism/api/util/StackUtils.java +++ b/src/main/java/mekanism/api/util/StackUtils.java @@ -7,251 +7,214 @@ 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; - } +public final class StackUtils { + public static List split(ItemStack stack) { + if (stack == null || stack.stackSize == 0) { + return null; + } - List ret = new ArrayList(); + List ret = new ArrayList(); - if(stack.stackSize == 1) - { - ret.add(stack); - return ret; - } + if (stack.stackSize == 1) { + ret.add(stack); + return ret; + } - int remain = stack.stackSize % 2; - int split = (int)((float)(stack.stackSize)/2F); + int remain = stack.stackSize % 2; + int split = (int) ((float) (stack.stackSize) / 2F); - ret.add(size(stack, split+remain)); - ret.add(size(stack, split)); + ret.add(size(stack, split + remain)); + ret.add(size(stack, split)); - return ret; - } + return ret; + } - public static Item getItem(ItemStack stack) - { - if(stack == null) - { - return null; - } + public static Item getItem(ItemStack stack) { + if (stack == null) { + return null; + } - return stack.getItem(); - } + return stack.getItem(); + } - public static boolean diffIgnoreNull(ItemStack stack1, ItemStack stack2) - { - if(stack1 == null || stack2 == null) - { - return false; - } + public static boolean diffIgnoreNull(ItemStack stack1, ItemStack stack2) { + if (stack1 == null || stack2 == null) { + return false; + } - return stack1.getItem() != stack2.getItem() || stack1.getItemDamage() != stack2.getItemDamage(); - } + return stack1.getItem() != stack2.getItem() + || stack1.getItemDamage() != stack2.getItemDamage(); + } - public static boolean equalsWildcard(ItemStack wild, ItemStack check) - { - if(wild == null || check == null) - { - return check == wild; - } - - return wild.getItem() == check.getItem() && (wild.getItemDamage() == OreDictionary.WILDCARD_VALUE || wild.getItemDamage() == check.getItemDamage()); - } + public static boolean equalsWildcard(ItemStack wild, ItemStack check) { + if (wild == null || check == null) { + return check == wild; + } - public static boolean equalsWildcardWithNBT(ItemStack wild, ItemStack check) - { - boolean wildcard = equalsWildcard(wild, check); - - if(wild == null || check == null) - { - return wildcard; - } - - return wildcard && (wild.stackTagCompound == null ? check.stackTagCompound == null : (wild.stackTagCompound == check.stackTagCompound || wild.stackTagCompound.equals(check.stackTagCompound))); - } + 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(); + public static boolean equalsWildcardWithNBT(ItemStack wild, ItemStack check) { + boolean wildcard = equalsWildcard(wild, check); - if(getSize(stack1) == getSize(stack2) || Math.abs(getSize(stack1)-getSize(stack2)) == 1) - { - ret.add(stack1); - ret.add(stack2); + if (wild == null || check == null) { + return wildcard; + } - return ret; - } + return wildcard + && (wild.stackTagCompound == null + ? check.stackTagCompound == null + : (wild.stackTagCompound == check.stackTagCompound + || wild.stackTagCompound.equals(check.stackTagCompound))); + } - if(getSize(stack1) > getSize(stack2)) - { - int diff = getSize(stack1)-getSize(stack2); + public static List even(ItemStack stack1, ItemStack stack2) { + ArrayList ret = new ArrayList(); - List split = split(size(stack1, diff)); + if (getSize(stack1) == getSize(stack2) + || Math.abs(getSize(stack1) - getSize(stack2)) == 1) { + ret.add(stack1); + ret.add(stack2); - 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); + return ret; + } - List split = split(size(stack2, diff)); + if (getSize(stack1) > getSize(stack2)) { + int diff = getSize(stack1) - getSize(stack2); - ret.add(subtract(stack2, split.get(0))); - ret.add(add(stack1, split.get(0))); - } + List split = split(size(stack1, diff)); - return ret; - } + 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); - public static ItemStack add(ItemStack stack1, ItemStack stack2) - { - if(stack1 == null) - { - return stack2; - } - else if(stack2 == null) - { - return stack1; - } + List split = split(size(stack2, diff)); - return size(stack1, getSize(stack1)+getSize(stack2)); - } + ret.add(subtract(stack2, split.get(0))); + ret.add(add(stack1, split.get(0))); + } - public static ItemStack subtract(ItemStack stack1, ItemStack stack2) - { - if(stack1 == null) - { - return null; - } - else if(stack2 == null) - { - return stack1; - } + return ret; + } - return size(stack1, getSize(stack1)-getSize(stack2)); - } + public static ItemStack add(ItemStack stack1, ItemStack stack2) { + if (stack1 == null) { + return stack2; + } else if (stack2 == null) { + return stack1; + } - public static ItemStack size(ItemStack stack, int size) - { - if(size <= 0 || stack == null) - { - return null; - } + return size(stack1, getSize(stack1) + getSize(stack2)); + } - ItemStack ret = stack.copy(); - ret.stackSize = size; - - return ret; - } + public static ItemStack subtract(ItemStack stack1, ItemStack stack2) { + if (stack1 == null) { + return null; + } else if (stack2 == null) { + return stack1; + } - public static ItemStack copy(ItemStack stack) - { - if(stack == null) - { - return null; - } + return size(stack1, getSize(stack1) - getSize(stack2)); + } - return stack.copy(); - } + public static ItemStack size(ItemStack stack, int size) { + if (size <= 0 || stack == null) { + return null; + } - public static int getSize(ItemStack stack) - { - return stack != null ? stack.stackSize : 0; - } - - public static List getMergeRejects(ItemStack[] orig, ItemStack[] toAdd) - { - List ret = new ArrayList(); - - for(int i = 0; i < toAdd.length; i++) - { - if(toAdd[i] != null) - { - ItemStack reject = getMergeReject(orig[i], toAdd[i]); - - if(reject != null) - { - ret.add(reject); - } - } - } - - return ret; - } - - public static void merge(ItemStack[] orig, ItemStack[] toAdd) - { - for(int i = 0; i < toAdd.length; i++) - { - if(toAdd[i] != null) - { - orig[i] = merge(orig[i], toAdd[i]); - } - } - } - - public static ItemStack merge(ItemStack orig, ItemStack toAdd) - { - if(orig == null) - { - return toAdd; - } - - if(toAdd == null) - { - return orig; - } - - if(!orig.isItemEqual(toAdd) || !ItemStack.areItemStackTagsEqual(orig, toAdd)) - { - return orig; - } - - return StackUtils.size(orig, Math.min(orig.getMaxStackSize(), orig.stackSize+toAdd.stackSize)); - } - - public static ItemStack getMergeReject(ItemStack orig, ItemStack toAdd) - { - if(orig == null) - { - return null; - } - - if(toAdd == null) - { - return orig; - } - - if(!orig.isItemEqual(toAdd) || !ItemStack.areItemStackTagsEqual(orig, toAdd)) - { - return orig; - } - - int newSize = orig.stackSize+toAdd.stackSize; - - if(newSize > orig.getMaxStackSize()) - { - return StackUtils.size(orig, newSize-orig.getMaxStackSize()); - } - else { - return StackUtils.size(orig, newSize); - } - } + ItemStack ret = stack.copy(); + ret.stackSize = size; - public static int hashItemStack(ItemStack stack) - { - if(stack == null || stack.getItem() == null) - { - return -1; - } - - String name = stack.getItemDamage() == OreDictionary.WILDCARD_VALUE ? stack.getItem().getUnlocalizedName() : stack.getItem().getUnlocalizedName(stack); - return name.hashCode() << 8 | stack.getItemDamage(); - } + 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; + } + + public static List getMergeRejects(ItemStack[] orig, ItemStack[] toAdd) { + List ret = new ArrayList(); + + for (int i = 0; i < toAdd.length; i++) { + if (toAdd[i] != null) { + ItemStack reject = getMergeReject(orig[i], toAdd[i]); + + if (reject != null) { + ret.add(reject); + } + } + } + + return ret; + } + + public static void merge(ItemStack[] orig, ItemStack[] toAdd) { + for (int i = 0; i < toAdd.length; i++) { + if (toAdd[i] != null) { + orig[i] = merge(orig[i], toAdd[i]); + } + } + } + + public static ItemStack merge(ItemStack orig, ItemStack toAdd) { + if (orig == null) { + return toAdd; + } + + if (toAdd == null) { + return orig; + } + + if (!orig.isItemEqual(toAdd) || !ItemStack.areItemStackTagsEqual(orig, toAdd)) { + return orig; + } + + return StackUtils.size( + orig, Math.min(orig.getMaxStackSize(), orig.stackSize + toAdd.stackSize) + ); + } + + public static ItemStack getMergeReject(ItemStack orig, ItemStack toAdd) { + if (orig == null) { + return null; + } + + if (toAdd == null) { + return orig; + } + + if (!orig.isItemEqual(toAdd) || !ItemStack.areItemStackTagsEqual(orig, toAdd)) { + return orig; + } + + int newSize = orig.stackSize + toAdd.stackSize; + + if (newSize > orig.getMaxStackSize()) { + return StackUtils.size(orig, newSize - orig.getMaxStackSize()); + } else { + return StackUtils.size(orig, newSize); + } + } + + public static int hashItemStack(ItemStack stack) { + if (stack == null || stack.getItem() == null) { + return -1; + } + + String name = stack.getItemDamage() == OreDictionary.WILDCARD_VALUE + ? stack.getItem().getUnlocalizedName() + : stack.getItem().getUnlocalizedName(stack); + return name.hashCode() << 8 | stack.getItemDamage(); + } } diff --git a/src/main/java/mekanism/api/util/UnitDisplayUtils.java b/src/main/java/mekanism/api/util/UnitDisplayUtils.java index 63df303fd..2a08a7585 100644 --- a/src/main/java/mekanism/api/util/UnitDisplayUtils.java +++ b/src/main/java/mekanism/api/util/UnitDisplayUtils.java @@ -3,298 +3,261 @@ package mekanism.api.util; /** * Code taken from UE and modified to fit Mekanism. */ -public class UnitDisplayUtils -{ - public static enum ElectricUnit - { - JOULES("Joule", "J"), - REDSTONE_FLUX("Redstone Flux", "RF"), - MINECRAFT_JOULES("Minecraft Joule", "MJ"), - ELECTRICAL_UNITS("Electrical Unit", "EU"); +public class UnitDisplayUtils { + public static enum ElectricUnit { + JOULES("Joule", "J"), + REDSTONE_FLUX("Redstone Flux", "RF"), + MINECRAFT_JOULES("Minecraft Joule", "MJ"), + ELECTRICAL_UNITS("Electrical Unit", "EU"); - public String name; - public String symbol; + public String name; + public String symbol; - private ElectricUnit(String s, String s1) - { - name = s; - symbol = s1; - } + private ElectricUnit(String s, String s1) { + name = s; + symbol = s1; + } - public String getPlural() - { - return this == REDSTONE_FLUX ? name : name + "s"; - } - } + public String getPlural() { + return this == REDSTONE_FLUX ? name : name + "s"; + } + } - public static enum TemperatureUnit - { - KELVIN("Kelvin", "K", 0, 1), - CELSIUS("Celsius", "°C", 273.15, 1), - RANKINE("Rankine", "R", 0, 9D/5D), - FAHRENHEIT("Fahrenheit", "°F", 459.67, 9D/5D), - AMBIENT("Ambient", "+STP", 300, 1); + public static enum TemperatureUnit { + KELVIN("Kelvin", "K", 0, 1), + CELSIUS("Celsius", "°C", 273.15, 1), + RANKINE("Rankine", "R", 0, 9D / 5D), + FAHRENHEIT("Fahrenheit", "°F", 459.67, 9D / 5D), + AMBIENT("Ambient", "+STP", 300, 1); - public String name; - public String symbol; - public double zeroOffset; - public double intervalSize; + public String name; + public String symbol; + public double zeroOffset; + public double intervalSize; - private TemperatureUnit(String s, String s1, double offset, double size) - { - name = s; - symbol = s1; - zeroOffset = offset; - intervalSize = size; - } + private TemperatureUnit(String s, String s1, double offset, double size) { + name = s; + symbol = s1; + zeroOffset = offset; + intervalSize = size; + } - public double convertFromK(double T, boolean shift) - { - return (T * intervalSize) - (shift ? zeroOffset : 0); - } + public double convertFromK(double T, boolean shift) { + return (T * intervalSize) - (shift ? zeroOffset : 0); + } - public double convertToK(double T, boolean shift) - { - return (T + (shift ? zeroOffset : 0)) / intervalSize; - } - } + public double convertToK(double T, boolean shift) { + return (T + (shift ? zeroOffset : 0)) / intervalSize; + } + } - /** Metric system of measurement. */ - public static enum MeasurementUnit - { - FEMTO("Femto", "f", 0.000000000000001D), - PICO("Pico", "p", 0.000000000001D), - NANO("Nano", "n", 0.000000001D), - MICRO("Micro", "u", 0.000001D), - MILLI("Milli", "m", 0.001D), - BASE("", "", 1), - KILO("Kilo", "k", 1000D), - MEGA("Mega", "M", 1000000D), - GIGA("Giga", "G", 1000000000D), - TERA("Tera", "T", 1000000000000D), - PETA("Peta", "P", 1000000000000000D), - EXA("Exa", "E", 1000000000000000000D), - ZETTA("Zetta", "Z", 1000000000000000000000D), - YOTTA("Yotta", "Y", 1000000000000000000000000D); + /** Metric system of measurement. */ + public static enum MeasurementUnit { + FEMTO("Femto", "f", 0.000000000000001D), + PICO("Pico", "p", 0.000000000001D), + NANO("Nano", "n", 0.000000001D), + MICRO("Micro", "u", 0.000001D), + MILLI("Milli", "m", 0.001D), + BASE("", "", 1), + KILO("Kilo", "k", 1000D), + MEGA("Mega", "M", 1000000D), + GIGA("Giga", "G", 1000000000D), + TERA("Tera", "T", 1000000000000D), + PETA("Peta", "P", 1000000000000000D), + EXA("Exa", "E", 1000000000000000000D), + ZETTA("Zetta", "Z", 1000000000000000000000D), + YOTTA("Yotta", "Y", 1000000000000000000000000D); - /** long name for the unit */ - public String name; + /** long name for the unit */ + public String name; - /** short unit version of the unit */ - public String symbol; + /** short unit version of the unit */ + public String symbol; - /** Point by which a number is consider to be of this unit */ - public double value; + /** Point by which a number is consider to be of this unit */ + public double value; - private MeasurementUnit(String s, String s1, double v) - { - name = s; - symbol = s1; - value = v; - } + private MeasurementUnit(String s, String s1, double v) { + name = s; + symbol = s1; + value = v; + } - public String getName(boolean getShort) - { - if(getShort) - { - return symbol; - } - else { - return name; - } - } + public String getName(boolean getShort) { + if (getShort) { + return symbol; + } else { + return name; + } + } - public double process(double d) - { - return d / value; - } + public double process(double d) { + return d / value; + } - public boolean above(double d) - { - return d > value; - } + public boolean above(double d) { + return d > value; + } - public boolean below(double d) - { - return d < value; - } - } + public boolean below(double d) { + return d < value; + } + } - /** - * Displays the unit as text. Does handle negative numbers, and will place a negative sign in - * front of the output string showing this. Use string.replace to remove the negative sign if - * unwanted - */ - public static String getDisplay(double value, ElectricUnit unit, int decimalPlaces, boolean isShort) - { - String unitName = unit.name; - String prefix = ""; + /** + * Displays the unit as text. Does handle negative numbers, and will place a negative + * sign in front of the output string showing this. Use string.replace to remove the + * negative sign if unwanted + */ + public static String + getDisplay(double value, ElectricUnit unit, int decimalPlaces, boolean isShort) { + String unitName = unit.name; + String prefix = ""; - if(value < 0) - { - value = Math.abs(value); - prefix = "-"; - } + if (value < 0) { + value = Math.abs(value); + prefix = "-"; + } - if(isShort) - { - unitName = unit.symbol; - } - else if(value > 1) - { - unitName = unit.getPlural(); - } + if (isShort) { + unitName = unit.symbol; + } else if (value > 1) { + unitName = unit.getPlural(); + } - if(value == 0) - { - return value + " " + unitName; - } - else { - for(int i = 0; i < MeasurementUnit.values().length; i++) - { - MeasurementUnit lowerMeasure = MeasurementUnit.values()[i]; + if (value == 0) { + return value + " " + unitName; + } else { + for (int i = 0; i < MeasurementUnit.values().length; i++) { + MeasurementUnit lowerMeasure = MeasurementUnit.values()[i]; - if(lowerMeasure.below(value) && lowerMeasure.ordinal() == 0) - { - return prefix + roundDecimals(lowerMeasure.process(value), decimalPlaces) + " " + lowerMeasure.getName(isShort) + unitName; - } + if (lowerMeasure.below(value) && lowerMeasure.ordinal() == 0) { + return prefix + + roundDecimals(lowerMeasure.process(value), decimalPlaces) + " " + + lowerMeasure.getName(isShort) + unitName; + } - if(lowerMeasure.ordinal() + 1 >= MeasurementUnit.values().length) - { - return prefix + roundDecimals(lowerMeasure.process(value), decimalPlaces) + " " + lowerMeasure.getName(isShort) + unitName; - } + if (lowerMeasure.ordinal() + 1 >= MeasurementUnit.values().length) { + return prefix + + roundDecimals(lowerMeasure.process(value), decimalPlaces) + " " + + lowerMeasure.getName(isShort) + unitName; + } - MeasurementUnit upperMeasure = MeasurementUnit.values()[i + 1]; + MeasurementUnit upperMeasure = MeasurementUnit.values()[i + 1]; - if((lowerMeasure.above(value) && upperMeasure.below(value)) || lowerMeasure.value == value) - { - return prefix + roundDecimals(lowerMeasure.process(value), decimalPlaces) + " " + lowerMeasure.getName(isShort) + unitName; - } - } - } + if ((lowerMeasure.above(value) && upperMeasure.below(value)) + || lowerMeasure.value == value) { + return prefix + + roundDecimals(lowerMeasure.process(value), decimalPlaces) + " " + + lowerMeasure.getName(isShort) + unitName; + } + } + } - return prefix + roundDecimals(value, decimalPlaces) + " " + unitName; - } + return prefix + roundDecimals(value, decimalPlaces) + " " + unitName; + } - public static String getDisplayShort(double value, ElectricUnit unit) - { - return getDisplay(value, unit, 2, true); - } + public static String getDisplayShort(double value, ElectricUnit unit) { + return getDisplay(value, unit, 2, true); + } - public static String getDisplayShort(double value, ElectricUnit unit, int decimalPlaces) - { - return getDisplay(value, unit, decimalPlaces, true); - } + public static String + getDisplayShort(double value, ElectricUnit unit, int decimalPlaces) { + return getDisplay(value, unit, decimalPlaces, true); + } - public static String getDisplaySimple(double value, ElectricUnit unit, int decimalPlaces) - { - if(value > 1) - { - if(decimalPlaces < 1) - { - return (int)value + " " + unit.getPlural(); - } + public static String + getDisplaySimple(double value, ElectricUnit unit, int decimalPlaces) { + if (value > 1) { + if (decimalPlaces < 1) { + return (int) value + " " + unit.getPlural(); + } - return roundDecimals(value, decimalPlaces) + " " + unit.getPlural(); - } + return roundDecimals(value, decimalPlaces) + " " + unit.getPlural(); + } - if(decimalPlaces < 1) - { - return (int)value + " " + unit.name; - } + if (decimalPlaces < 1) { + return (int) value + " " + unit.name; + } - return roundDecimals(value, decimalPlaces) + " " + unit.name; - } + return roundDecimals(value, decimalPlaces) + " " + unit.name; + } - public static String getDisplay(double T, TemperatureUnit unit, int decimalPlaces, boolean shift, boolean isShort) - { - String unitName = unit.name; - String prefix = ""; + public static String getDisplay( + double T, TemperatureUnit unit, int decimalPlaces, boolean shift, boolean isShort + ) { + String unitName = unit.name; + String prefix = ""; - double value = unit.convertFromK(T, shift); + double value = unit.convertFromK(T, shift); - if(value < 0) - { - value = Math.abs(value); - prefix = "-"; - } + if (value < 0) { + value = Math.abs(value); + prefix = "-"; + } - if(isShort) - { - unitName = unit.symbol; - } + if (isShort) { + unitName = unit.symbol; + } - if(value == 0) - { - return value + (isShort ? "" : " ") + unitName; - } - else { - for(int i = 0; i < MeasurementUnit.values().length; i++) - { - MeasurementUnit lowerMeasure = MeasurementUnit.values()[i]; + if (value == 0) { + return value + (isShort ? "" : " ") + unitName; + } else { + for (int i = 0; i < MeasurementUnit.values().length; i++) { + MeasurementUnit lowerMeasure = MeasurementUnit.values()[i]; - if(lowerMeasure.below(value) && lowerMeasure.ordinal() == 0) - { - return prefix + roundDecimals(lowerMeasure.process(value), decimalPlaces) + (isShort ? "" : " ") + lowerMeasure.getName(isShort) + unitName; - } + if (lowerMeasure.below(value) && lowerMeasure.ordinal() == 0) { + return prefix + + roundDecimals(lowerMeasure.process(value), decimalPlaces) + + (isShort ? "" : " ") + lowerMeasure.getName(isShort) + unitName; + } - if(lowerMeasure.ordinal() + 1 >= MeasurementUnit.values().length) - { - return prefix + roundDecimals(lowerMeasure.process(value), decimalPlaces) + (isShort ? "" : " ") + lowerMeasure.getName(isShort) + unitName; - } + if (lowerMeasure.ordinal() + 1 >= MeasurementUnit.values().length) { + return prefix + + roundDecimals(lowerMeasure.process(value), decimalPlaces) + + (isShort ? "" : " ") + lowerMeasure.getName(isShort) + unitName; + } - MeasurementUnit upperMeasure = MeasurementUnit.values()[i + 1]; + MeasurementUnit upperMeasure = MeasurementUnit.values()[i + 1]; - if((lowerMeasure.above(value) && upperMeasure.below(value)) || lowerMeasure.value == value) - { - return prefix + roundDecimals(lowerMeasure.process(value), decimalPlaces) + (isShort ? "" : " ") + lowerMeasure.getName(isShort) + unitName; - } - } - } + if ((lowerMeasure.above(value) && upperMeasure.below(value)) + || lowerMeasure.value == value) { + return prefix + + roundDecimals(lowerMeasure.process(value), decimalPlaces) + + (isShort ? "" : " ") + lowerMeasure.getName(isShort) + unitName; + } + } + } - return prefix + roundDecimals(value, decimalPlaces) + (isShort ? "" : " ") + unitName; - } + return prefix + roundDecimals(value, decimalPlaces) + (isShort ? "" : " ") + + unitName; + } - public static String getDisplayShort(double value, TemperatureUnit unit) - { - return getDisplayShort(value, true, unit); - } - - public static String getDisplayShort(double value, boolean shift, TemperatureUnit unit) - { - return getDisplayShort(value, unit, shift, 2); - } + public static String getDisplayShort(double value, TemperatureUnit unit) { + return getDisplayShort(value, true, unit); + } - public static String getDisplayShort(double value, TemperatureUnit unit, boolean shift, int decimalPlaces) - { - return getDisplay(value, unit, decimalPlaces, shift, true); - } + public static String + getDisplayShort(double value, boolean shift, TemperatureUnit unit) { + return getDisplayShort(value, unit, shift, 2); + } - public static double roundDecimals(double d, int decimalPlaces) - { - int j = (int)(d*Math.pow(10, decimalPlaces)); - return j/Math.pow(10, decimalPlaces); - } + public static String getDisplayShort( + double value, TemperatureUnit unit, boolean shift, int decimalPlaces + ) { + return getDisplay(value, unit, decimalPlaces, shift, true); + } - public static double roundDecimals(double d) - { - return roundDecimals(d, 2); - } + public static double roundDecimals(double d, int decimalPlaces) { + int j = (int) (d * Math.pow(10, decimalPlaces)); + return j / Math.pow(10, decimalPlaces); + } - public static enum EnergyType - { - J, - RF, - EU, - MJ - } + public static double roundDecimals(double d) { + return roundDecimals(d, 2); + } - public static enum TempType - { - K, - C, - R, - F, - STP - } + public static enum EnergyType { J, RF, EU, MJ } + + public static enum TempType { K, C, R, F, STP } } diff --git a/src/main/java/mekanism/api/util/package-info.java b/src/main/java/mekanism/api/util/package-info.java index edd42a570..811e6285f 100644 --- a/src/main/java/mekanism/api/util/package-info.java +++ b/src/main/java/mekanism/api/util/package-info.java @@ -1,4 +1,3 @@ @API(apiVersion = "9.0.0", owner = "Mekanism", provides = "MekanismAPI|util") package mekanism.api.util; import cpw.mods.fml.common.API; - diff --git a/src/main/java/mekanism/client/CapeBufferDownload.java b/src/main/java/mekanism/client/CapeBufferDownload.java index f84d8dbbe..b401bb827 100644 --- a/src/main/java/mekanism/client/CapeBufferDownload.java +++ b/src/main/java/mekanism/client/CapeBufferDownload.java @@ -2,89 +2,84 @@ package mekanism.client; import java.io.File; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.ThreadDownloadImageData; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.util.ResourceLocation; import net.minecraft.util.StringUtils; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class CapeBufferDownload extends Thread -{ - public String username; +public class CapeBufferDownload extends Thread { + public String username; - public String staticCapeUrl; + public String staticCapeUrl; - public ResourceLocation resourceLocation; + public ResourceLocation resourceLocation; - public ThreadDownloadImageData capeImage; + public ThreadDownloadImageData capeImage; - boolean downloaded = false; + boolean downloaded = false; - public CapeBufferDownload(String name, String url) - { - username = name; - staticCapeUrl = url; + public CapeBufferDownload(String name, String url) { + username = name; + staticCapeUrl = url; - setDaemon(true); - setName("Cape Download Thread"); - } + setDaemon(true); + setName("Cape Download Thread"); + } - @Override - public void run() - { - try { - download(); - } catch(Exception e) { - e.printStackTrace(); - } - } + @Override + public void run() { + try { + download(); + } catch (Exception e) { + e.printStackTrace(); + } + } - private void download() - { - try { - resourceLocation = new ResourceLocation("mekanism/" + StringUtils.stripControlCodes(username)); + private void download() { + try { + resourceLocation = new ResourceLocation( + "mekanism/" + StringUtils.stripControlCodes(username) + ); - capeImage = downloadCape(); - } catch(Exception e) { - e.printStackTrace(); - } + capeImage = downloadCape(); + } catch (Exception e) { + e.printStackTrace(); + } - downloaded = true; - } + downloaded = true; + } - public ThreadDownloadImageData getImage() - { - return capeImage; - } + public ThreadDownloadImageData getImage() { + return capeImage; + } - public ResourceLocation getResourceLocation() - { - return resourceLocation; - } - - public ThreadDownloadImageData downloadCape() - { - try { - File capeFile = new File(resourceLocation.getResourcePath() + ".png"); - - if(capeFile.exists()) - { - capeFile.delete(); - } - - TextureManager manager = Minecraft.getMinecraft().getTextureManager(); - ThreadDownloadImageData data = new ThreadDownloadImageData(capeFile, staticCapeUrl, null, null); + public ResourceLocation getResourceLocation() { + return resourceLocation; + } - manager.loadTexture(resourceLocation, data); - - return data; - } catch(Exception e) { - e.printStackTrace(); - } - - return null; - } + public ThreadDownloadImageData downloadCape() { + try { + File capeFile = new File(resourceLocation.getResourcePath() + ".png"); + + if (capeFile.exists()) { + capeFile.delete(); + } + + TextureManager manager = Minecraft.getMinecraft().getTextureManager(); + ThreadDownloadImageData data + = new ThreadDownloadImageData(capeFile, staticCapeUrl, null, null); + + manager.loadTexture(resourceLocation, data); + + return data; + } catch (Exception e) { + e.printStackTrace(); + } + + return null; + } } diff --git a/src/main/java/mekanism/client/ClientConnectionHandler.java b/src/main/java/mekanism/client/ClientConnectionHandler.java index 2289e0d58..bab0e09c4 100644 --- a/src/main/java/mekanism/client/ClientConnectionHandler.java +++ b/src/main/java/mekanism/client/ClientConnectionHandler.java @@ -2,42 +2,45 @@ package mekanism.client; import java.net.InetSocketAddress; -import mekanism.api.MekanismConfig.general; -import mekanism.client.voice.VoiceClient; -import mekanism.common.Mekanism; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.network.FMLNetworkEvent.ClientConnectedToServerEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import mekanism.api.MekanismConfig.general; +import mekanism.client.voice.VoiceClient; +import mekanism.common.Mekanism; @SideOnly(Side.CLIENT) -public class ClientConnectionHandler -{ - @SubscribeEvent - public void onConnection(ClientConnectedToServerEvent event) - { - if(general.voiceServerEnabled) - { - if(event.isLocal) - { - //If the client is connecting to its own corresponding integrated server. - try { - MekanismClient.voiceClient = new VoiceClient("127.0.0.1"); - //Will probably not work when multiple integrateds are running on one computer - } catch(Throwable e) { - Mekanism.logger.error("Unable to establish VoiceClient on local connection."); - e.printStackTrace(); - } - } - else { - //If the client is connecting to a foreign integrated or dedicated server. - try { - MekanismClient.voiceClient = new VoiceClient(((InetSocketAddress)event.manager.getSocketAddress()).getHostString()); - } catch(Throwable e) { - Mekanism.logger.error("Unable to establish VoiceClient on remote connection."); - e.printStackTrace(); - } - } - } - } +public class ClientConnectionHandler { + @SubscribeEvent + public void onConnection(ClientConnectedToServerEvent event) { + if (general.voiceServerEnabled) { + if (event.isLocal) { + //If the client is connecting to its own corresponding integrated server. + try { + MekanismClient.voiceClient = new VoiceClient("127.0.0.1"); + //Will probably not work when multiple integrateds are running on one + //computer + } catch (Throwable e) { + Mekanism.logger.error( + "Unable to establish VoiceClient on local connection." + ); + e.printStackTrace(); + } + } else { + //If the client is connecting to a foreign integrated or dedicated server. + try { + MekanismClient.voiceClient = new VoiceClient( + ((InetSocketAddress) event.manager.getSocketAddress()) + .getHostString() + ); + } catch (Throwable e) { + Mekanism.logger.error( + "Unable to establish VoiceClient on remote connection." + ); + e.printStackTrace(); + } + } + } + } } diff --git a/src/main/java/mekanism/client/ClientPlayerTracker.java b/src/main/java/mekanism/client/ClientPlayerTracker.java index 67e36a2e4..b866d6b5d 100644 --- a/src/main/java/mekanism/client/ClientPlayerTracker.java +++ b/src/main/java/mekanism/client/ClientPlayerTracker.java @@ -1,19 +1,17 @@ package mekanism.client; -import mekanism.common.Mekanism; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerChangedDimensionEvent; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import mekanism.common.Mekanism; @SideOnly(Side.CLIENT) -public class ClientPlayerTracker -{ - @SubscribeEvent - public void onPlayerChangedDimension(PlayerChangedDimensionEvent event) - { - Mekanism.jetpackOn.remove(event.player); - Mekanism.gasmaskOn.remove(event.player); - Mekanism.flamethrowerActive.remove(event.player); - } +public class ClientPlayerTracker { + @SubscribeEvent + public void onPlayerChangedDimension(PlayerChangedDimensionEvent event) { + Mekanism.jetpackOn.remove(event.player); + Mekanism.gasmaskOn.remove(event.player); + Mekanism.flamethrowerActive.remove(event.player); + } } diff --git a/src/main/java/mekanism/client/ClientProxy.java b/src/main/java/mekanism/client/ClientProxy.java index 18d268b0f..7ba8adbc4 100644 --- a/src/main/java/mekanism/client/ClientProxy.java +++ b/src/main/java/mekanism/client/ClientProxy.java @@ -3,7 +3,15 @@ package mekanism.client; import java.io.File; import com.jadarstudios.developercapes.DevCapes; +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.client.registry.ClientRegistry; +import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.MekanismConfig.client; import mekanism.api.MekanismConfig.general; @@ -201,14 +209,6 @@ import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.common.util.ForgeDirection; -import cpw.mods.fml.client.FMLClientHandler; -import cpw.mods.fml.client.registry.ClientRegistry; -import cpw.mods.fml.client.registry.RenderingRegistry; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; /** * Client proxy for the Mekanism mod. @@ -216,475 +216,754 @@ import cpw.mods.fml.relauncher.SideOnly; * */ @SideOnly(Side.CLIENT) -public class ClientProxy extends CommonProxy -{ - public static boolean isThorfusionLoaded; - @Override - public void loadConfiguration() - { - super.loadConfiguration(); +public class ClientProxy extends CommonProxy { + public static boolean isThorfusionLoaded; - client.enablePlayerSounds = Mekanism.configuration.get("client", "EnablePlayerSounds", true).getBoolean(); - client.enableMachineSounds = Mekanism.configuration.get("client", "EnableMachineSounds", true).getBoolean(); - client.holidays = Mekanism.configuration.get("client", "Holidays", true).getBoolean(); - client.baseSoundVolume = (float)Mekanism.configuration.get("client", "SoundVolume", 1D).getDouble(); - client.machineEffects = Mekanism.configuration.get("client", "MachineEffects", true).getBoolean(); - client.oldTransmitterRender = Mekanism.configuration.get("client", "OldTransmitterRender", false).getBoolean(); - client.replaceSoundsWhenResuming = Mekanism.configuration.get("client", "ReplaceSoundsWhenResuming", true, - "If true, will reduce lagging between player sounds. Setting to false will reduce GC load").getBoolean(); - client.renderCTM = Mekanism.configuration.get("client", "CTMRenderer", true).getBoolean(); - client.enableAmbientLighting = Mekanism.configuration.get("client", "EnableAmbientLighting", true).getBoolean(); - client.ambientLightingLevel = Mekanism.configuration.get("client", "AmbientLightingLevel", 15).getInt(); - client.opaqueTransmitters = Mekanism.configuration.get("client", "OpaqueTransmitterRender", false).getBoolean(); - client.doMultiblockSparkle = Mekanism.configuration.get("client", "DoMultiblockSparkle", true).getBoolean(); - client.multiblockSparkleIntensity = Mekanism.configuration.get("client", "MultiblockSparkleIntesity", 6).getInt(); + @Override + public void loadConfiguration() { + super.loadConfiguration(); - if(Mekanism.configuration.hasChanged()) - { - Mekanism.configuration.save(); - } - } + client.enablePlayerSounds + = Mekanism.configuration.get("client", "EnablePlayerSounds", true) + .getBoolean(); + client.enableMachineSounds + = Mekanism.configuration.get("client", "EnableMachineSounds", true) + .getBoolean(); + client.holidays + = Mekanism.configuration.get("client", "Holidays", true).getBoolean(); + client.baseSoundVolume + = (float) Mekanism.configuration.get("client", "SoundVolume", 1D).getDouble(); + client.machineEffects + = Mekanism.configuration.get("client", "MachineEffects", true).getBoolean(); + client.oldTransmitterRender + = Mekanism.configuration.get("client", "OldTransmitterRender", false) + .getBoolean(); + client.replaceSoundsWhenResuming + = Mekanism.configuration + .get( + "client", + "ReplaceSoundsWhenResuming", + true, + "If true, will reduce lagging between player sounds. Setting to false will reduce GC load" + ) + .getBoolean(); + client.renderCTM + = Mekanism.configuration.get("client", "CTMRenderer", true).getBoolean(); + client.enableAmbientLighting + = Mekanism.configuration.get("client", "EnableAmbientLighting", true) + .getBoolean(); + client.ambientLightingLevel + = Mekanism.configuration.get("client", "AmbientLightingLevel", 15).getInt(); + client.opaqueTransmitters + = Mekanism.configuration.get("client", "OpaqueTransmitterRender", false) + .getBoolean(); + client.doMultiblockSparkle + = Mekanism.configuration.get("client", "DoMultiblockSparkle", true) + .getBoolean(); + client.multiblockSparkleIntensity + = Mekanism.configuration.get("client", "MultiblockSparkleIntesity", 6) + .getInt(); - @Override - public int getArmorIndex(String string) - { - return RenderingRegistry.addNewArmourRendererPrefix(string); - } + if (Mekanism.configuration.hasChanged()) { + Mekanism.configuration.save(); + } + } - @Override - public void openPersonalChest(EntityPlayer entityplayer, int id, int windowId, boolean isBlock, int x, int y, int z) - { - TileEntityPersonalChest tileEntity = (TileEntityPersonalChest)entityplayer.worldObj.getTileEntity(x, y, z); + @Override + public int getArmorIndex(String string) { + return RenderingRegistry.addNewArmourRendererPrefix(string); + } - if(id == 0) - { - if(isBlock) - { - FMLClientHandler.instance().displayGuiScreen(entityplayer, new GuiPersonalChest(entityplayer.inventory, tileEntity)); - entityplayer.openContainer.windowId = windowId; - } - else { - ItemStack stack = entityplayer.getCurrentEquippedItem(); + @Override + public void openPersonalChest( + EntityPlayer entityplayer, + int id, + int windowId, + boolean isBlock, + int x, + int y, + int z + ) { + TileEntityPersonalChest tileEntity + = (TileEntityPersonalChest) entityplayer.worldObj.getTileEntity(x, y, z); - if(MachineType.get(stack) == MachineType.PERSONAL_CHEST) - { - InventoryPersonalChest inventory = new InventoryPersonalChest(entityplayer); - FMLClientHandler.instance().displayGuiScreen(entityplayer, new GuiPersonalChest(entityplayer.inventory, inventory)); - entityplayer.openContainer.windowId = windowId; - } - } - } - } + if (id == 0) { + if (isBlock) { + FMLClientHandler.instance().displayGuiScreen( + entityplayer, new GuiPersonalChest(entityplayer.inventory, tileEntity) + ); + entityplayer.openContainer.windowId = windowId; + } else { + ItemStack stack = entityplayer.getCurrentEquippedItem(); - @Override - public void registerSpecialTileEntities() - { - ClientRegistry.registerTileEntity(TileEntityEnrichmentChamber.class, "EnrichmentChamber", new RenderConfigurableMachine()); - ClientRegistry.registerTileEntity(TileEntityOsmiumCompressor.class, "OsmiumCompressor", new RenderConfigurableMachine()); - ClientRegistry.registerTileEntity(TileEntityCombiner.class, "Combiner", new RenderConfigurableMachine()); - ClientRegistry.registerTileEntity(TileEntityCrusher.class, "Crusher", new RenderConfigurableMachine()); - ClientRegistry.registerTileEntity(TileEntityFactory.class, "SmeltingFactory", new RenderConfigurableMachine()); - ClientRegistry.registerTileEntity(TileEntityAdvancedFactory.class, "AdvancedSmeltingFactory", new RenderConfigurableMachine()); - ClientRegistry.registerTileEntity(TileEntityEliteFactory.class, "UltimateSmeltingFactory", new RenderConfigurableMachine()); - ClientRegistry.registerTileEntity(TileEntityPurificationChamber.class, "PurificationChamber", new RenderConfigurableMachine()); - ClientRegistry.registerTileEntity(TileEntityEnergizedSmelter.class, "EnergizedSmelter", new RenderConfigurableMachine()); - ClientRegistry.registerTileEntity(TileEntityMetallurgicInfuser.class, "MetallurgicInfuser", new RenderMetallurgicInfuser()); - ClientRegistry.registerTileEntity(TileEntityObsidianTNT.class, "ObsidianTNT", new RenderObsidianTNT()); - ClientRegistry.registerTileEntity(TileEntityGasTank.class, "GasTank", new RenderGasTank()); - ClientRegistry.registerTileEntity(TileEntityEnergyCube.class, "EnergyCube", new RenderEnergyCube()); - ClientRegistry.registerTileEntity(TileEntityElectricPump.class, "ElectricPump", new RenderElectricPump()); - ClientRegistry.registerTileEntity(TileEntityPersonalChest.class, "ElectricChest", new RenderPersonalChest()); //TODO rename - ClientRegistry.registerTileEntity(TileEntityDynamicTank.class, "DynamicTank", new RenderDynamicTank()); - ClientRegistry.registerTileEntity(TileEntityDynamicValve.class, "DynamicValve", new RenderDynamicTank()); - ClientRegistry.registerTileEntity(TileEntityChargepad.class, "Chargepad", new RenderChargepad()); - ClientRegistry.registerTileEntity(TileEntityLogisticalSorter.class, "LogisticalSorter", new RenderLogisticalSorter()); - ClientRegistry.registerTileEntity(TileEntityBin.class, "Bin", new RenderBin()); - ClientRegistry.registerTileEntity(TileEntityDigitalMiner.class, "DigitalMiner", new RenderDigitalMiner()); - ClientRegistry.registerTileEntity(TileEntityRotaryCondensentrator.class, "RotaryCondensentrator", new RenderRotaryCondensentrator()); - ClientRegistry.registerTileEntity(TileEntityTeleporter.class, "MekanismTeleporter", new RenderTeleporter()); - ClientRegistry.registerTileEntity(TileEntityChemicalOxidizer.class, "ChemicalOxidizer", new RenderChemicalOxidizer()); - ClientRegistry.registerTileEntity(TileEntityChemicalInfuser.class, "ChemicalInfuser", new RenderChemicalInfuser()); - ClientRegistry.registerTileEntity(TileEntityChemicalInjectionChamber.class, "ChemicalInjectionChamber", new RenderConfigurableMachine()); - ClientRegistry.registerTileEntity(TileEntityElectrolyticSeparator.class, "ElectrolyticSeparator", new RenderElectrolyticSeparator()); - ClientRegistry.registerTileEntity(TileEntityThermalEvaporationController.class, "SalinationController", new RenderThermalEvaporationController()); //TODO rename - ClientRegistry.registerTileEntity(TileEntityPrecisionSawmill.class, "PrecisionSawmill", new RenderConfigurableMachine()); - ClientRegistry.registerTileEntity(TileEntityChemicalDissolutionChamber.class, "ChemicalDissolutionChamber", new RenderChemicalDissolutionChamber()); - ClientRegistry.registerTileEntity(TileEntityChemicalWasher.class, "ChemicalWasher", new RenderChemicalWasher()); - ClientRegistry.registerTileEntity(TileEntityChemicalCrystallizer.class, "ChemicalCrystallizer", new RenderChemicalCrystallizer()); - ClientRegistry.registerTileEntity(TileEntitySeismicVibrator.class, "SeismicVibrator", new RenderSeismicVibrator()); - ClientRegistry.registerTileEntity(TileEntityPRC.class, "PressurizedReactionChamber", new RenderPressurizedReactionChamber()); - ClientRegistry.registerTileEntity(TileEntityFluidTank.class, "PortableTank", new RenderFluidTank()); //TODO rename - ClientRegistry.registerTileEntity(TileEntityFluidicPlenisher.class, "FluidicPlenisher", new RenderFluidicPlenisher()); - ClientRegistry.registerTileEntity(TileEntityLaser.class, "Laser", new RenderLaser()); - ClientRegistry.registerTileEntity(TileEntityLaserAmplifier.class, "LaserAmplifier", new RenderLaserAmplifier()); - ClientRegistry.registerTileEntity(TileEntityLaserTractorBeam.class, "LaserTractorBeam", new RenderLaserTractorBeam()); - ClientRegistry.registerTileEntity(TileEntitySolarNeutronActivator.class, "SolarNeutronActivator", new RenderSolarNeutronActivator()); - GameRegistry.registerTileEntity(TileEntityAmbientAccumulator.class, "AmbientAccumulator"); - GameRegistry.registerTileEntity(TileEntityInductionCasing.class, "InductionCasing"); - GameRegistry.registerTileEntity(TileEntityInductionPort.class, "InductionPort"); - GameRegistry.registerTileEntity(TileEntityInductionCell.class, "InductionCell"); - GameRegistry.registerTileEntity(TileEntityInductionProvider.class, "InductionProvider"); - GameRegistry.registerTileEntity(TileEntityOredictionificator.class, "Oredictionificator"); - GameRegistry.registerTileEntity(TileEntityStructuralGlass.class, "StructuralGlass"); - ClientRegistry.registerTileEntity(TileEntityFormulaicAssemblicator.class, "FormulaicAssemblicator", new RenderConfigurableMachine()); - ClientRegistry.registerTileEntity(TileEntityResistiveHeater.class, "ResistiveHeater", new RenderResistiveHeater()); - ClientRegistry.registerTileEntity(TileEntityBoilerCasing.class, "BoilerCasing", new RenderThermoelectricBoiler()); - ClientRegistry.registerTileEntity(TileEntityBoilerValve.class, "BoilerValve", new RenderThermoelectricBoiler()); - ClientRegistry.registerTileEntity(TileEntitySecurityDesk.class, "SecurityDesk", new RenderSecurityDesk()); - ClientRegistry.registerTileEntity(TileEntityQuantumEntangloporter.class, "QuantumEntangloporter", new RenderQuantumEntangloporter()); - ClientRegistry.registerTileEntity(TileEntityTheoreticalElementizer.class, "TheoreticalElementizer", new RenderTheoreticalElementizer()); - GameRegistry.registerTileEntity(TileEntityFuelwoodHeater.class, "FuelwoodHeater"); - } + if (MachineType.get(stack) == MachineType.PERSONAL_CHEST) { + InventoryPersonalChest inventory + = new InventoryPersonalChest(entityplayer); + FMLClientHandler.instance().displayGuiScreen( + entityplayer, + new GuiPersonalChest(entityplayer.inventory, inventory) + ); + entityplayer.openContainer.windowId = windowId; + } + } + } + } - @Override - public void registerRenderInformation() - { - RenderPartTransmitter.init(); - RenderGlowPanel.init(); + @Override + public void registerSpecialTileEntities() { + ClientRegistry.registerTileEntity( + TileEntityEnrichmentChamber.class, + "EnrichmentChamber", + new RenderConfigurableMachine() + ); + ClientRegistry.registerTileEntity( + TileEntityOsmiumCompressor.class, + "OsmiumCompressor", + new RenderConfigurableMachine() + ); + ClientRegistry.registerTileEntity( + TileEntityCombiner.class, "Combiner", new RenderConfigurableMachine() + ); + ClientRegistry.registerTileEntity( + TileEntityCrusher.class, "Crusher", new RenderConfigurableMachine() + ); + ClientRegistry.registerTileEntity( + TileEntityFactory.class, "SmeltingFactory", new RenderConfigurableMachine() + ); + ClientRegistry.registerTileEntity( + TileEntityAdvancedFactory.class, + "AdvancedSmeltingFactory", + new RenderConfigurableMachine() + ); + ClientRegistry.registerTileEntity( + TileEntityEliteFactory.class, + "UltimateSmeltingFactory", + new RenderConfigurableMachine() + ); + ClientRegistry.registerTileEntity( + TileEntityPurificationChamber.class, + "PurificationChamber", + new RenderConfigurableMachine() + ); + ClientRegistry.registerTileEntity( + TileEntityEnergizedSmelter.class, + "EnergizedSmelter", + new RenderConfigurableMachine() + ); + ClientRegistry.registerTileEntity( + TileEntityMetallurgicInfuser.class, + "MetallurgicInfuser", + new RenderMetallurgicInfuser() + ); + ClientRegistry.registerTileEntity( + TileEntityObsidianTNT.class, "ObsidianTNT", new RenderObsidianTNT() + ); + ClientRegistry.registerTileEntity( + TileEntityGasTank.class, "GasTank", new RenderGasTank() + ); + ClientRegistry.registerTileEntity( + TileEntityEnergyCube.class, "EnergyCube", new RenderEnergyCube() + ); + ClientRegistry.registerTileEntity( + TileEntityElectricPump.class, "ElectricPump", new RenderElectricPump() + ); + ClientRegistry.registerTileEntity( + TileEntityPersonalChest.class, "ElectricChest", new RenderPersonalChest() + ); //TODO rename + ClientRegistry.registerTileEntity( + TileEntityDynamicTank.class, "DynamicTank", new RenderDynamicTank() + ); + ClientRegistry.registerTileEntity( + TileEntityDynamicValve.class, "DynamicValve", new RenderDynamicTank() + ); + ClientRegistry.registerTileEntity( + TileEntityChargepad.class, "Chargepad", new RenderChargepad() + ); + ClientRegistry.registerTileEntity( + TileEntityLogisticalSorter.class, + "LogisticalSorter", + new RenderLogisticalSorter() + ); + ClientRegistry.registerTileEntity(TileEntityBin.class, "Bin", new RenderBin()); + ClientRegistry.registerTileEntity( + TileEntityDigitalMiner.class, "DigitalMiner", new RenderDigitalMiner() + ); + ClientRegistry.registerTileEntity( + TileEntityRotaryCondensentrator.class, + "RotaryCondensentrator", + new RenderRotaryCondensentrator() + ); + ClientRegistry.registerTileEntity( + TileEntityTeleporter.class, "MekanismTeleporter", new RenderTeleporter() + ); + ClientRegistry.registerTileEntity( + TileEntityChemicalOxidizer.class, + "ChemicalOxidizer", + new RenderChemicalOxidizer() + ); + ClientRegistry.registerTileEntity( + TileEntityChemicalInfuser.class, + "ChemicalInfuser", + new RenderChemicalInfuser() + ); + ClientRegistry.registerTileEntity( + TileEntityChemicalInjectionChamber.class, + "ChemicalInjectionChamber", + new RenderConfigurableMachine() + ); + ClientRegistry.registerTileEntity( + TileEntityElectrolyticSeparator.class, + "ElectrolyticSeparator", + new RenderElectrolyticSeparator() + ); + ClientRegistry.registerTileEntity( + TileEntityThermalEvaporationController.class, + "SalinationController", + new RenderThermalEvaporationController() + ); //TODO rename + ClientRegistry.registerTileEntity( + TileEntityPrecisionSawmill.class, + "PrecisionSawmill", + new RenderConfigurableMachine() + ); + ClientRegistry.registerTileEntity( + TileEntityChemicalDissolutionChamber.class, + "ChemicalDissolutionChamber", + new RenderChemicalDissolutionChamber() + ); + ClientRegistry.registerTileEntity( + TileEntityChemicalWasher.class, "ChemicalWasher", new RenderChemicalWasher() + ); + ClientRegistry.registerTileEntity( + TileEntityChemicalCrystallizer.class, + "ChemicalCrystallizer", + new RenderChemicalCrystallizer() + ); + ClientRegistry.registerTileEntity( + TileEntitySeismicVibrator.class, + "SeismicVibrator", + new RenderSeismicVibrator() + ); + ClientRegistry.registerTileEntity( + TileEntityPRC.class, + "PressurizedReactionChamber", + new RenderPressurizedReactionChamber() + ); + ClientRegistry.registerTileEntity( + TileEntityFluidTank.class, "PortableTank", new RenderFluidTank() + ); //TODO rename + ClientRegistry.registerTileEntity( + TileEntityFluidicPlenisher.class, + "FluidicPlenisher", + new RenderFluidicPlenisher() + ); + ClientRegistry.registerTileEntity( + TileEntityLaser.class, "Laser", new RenderLaser() + ); + ClientRegistry.registerTileEntity( + TileEntityLaserAmplifier.class, "LaserAmplifier", new RenderLaserAmplifier() + ); + ClientRegistry.registerTileEntity( + TileEntityLaserTractorBeam.class, + "LaserTractorBeam", + new RenderLaserTractorBeam() + ); + ClientRegistry.registerTileEntity( + TileEntitySolarNeutronActivator.class, + "SolarNeutronActivator", + new RenderSolarNeutronActivator() + ); + GameRegistry.registerTileEntity( + TileEntityAmbientAccumulator.class, "AmbientAccumulator" + ); + GameRegistry.registerTileEntity( + TileEntityInductionCasing.class, "InductionCasing" + ); + GameRegistry.registerTileEntity(TileEntityInductionPort.class, "InductionPort"); + GameRegistry.registerTileEntity(TileEntityInductionCell.class, "InductionCell"); + GameRegistry.registerTileEntity( + TileEntityInductionProvider.class, "InductionProvider" + ); + GameRegistry.registerTileEntity( + TileEntityOredictionificator.class, "Oredictionificator" + ); + GameRegistry.registerTileEntity( + TileEntityStructuralGlass.class, "StructuralGlass" + ); + ClientRegistry.registerTileEntity( + TileEntityFormulaicAssemblicator.class, + "FormulaicAssemblicator", + new RenderConfigurableMachine() + ); + ClientRegistry.registerTileEntity( + TileEntityResistiveHeater.class, + "ResistiveHeater", + new RenderResistiveHeater() + ); + ClientRegistry.registerTileEntity( + TileEntityBoilerCasing.class, "BoilerCasing", new RenderThermoelectricBoiler() + ); + ClientRegistry.registerTileEntity( + TileEntityBoilerValve.class, "BoilerValve", new RenderThermoelectricBoiler() + ); + ClientRegistry.registerTileEntity( + TileEntitySecurityDesk.class, "SecurityDesk", new RenderSecurityDesk() + ); + ClientRegistry.registerTileEntity( + TileEntityQuantumEntangloporter.class, + "QuantumEntangloporter", + new RenderQuantumEntangloporter() + ); + ClientRegistry.registerTileEntity( + TileEntityTheoreticalElementizer.class, + "TheoreticalElementizer", + new RenderTheoreticalElementizer() + ); + GameRegistry.registerTileEntity(TileEntityFuelwoodHeater.class, "FuelwoodHeater"); + } - //Register entity rendering handlers - RenderingRegistry.registerEntityRenderingHandler(EntityObsidianTNT.class, new RenderObsidianTNTPrimed()); - RenderingRegistry.registerEntityRenderingHandler(EntityRobit.class, new RenderRobit()); - RenderingRegistry.registerEntityRenderingHandler(EntityBalloon.class, new RenderBalloon()); - RenderingRegistry.registerEntityRenderingHandler(EntityBabySkeleton.class, new RenderSkeleton()); - RenderingRegistry.registerEntityRenderingHandler(EntityFlame.class, new RenderFlame()); + @Override + public void registerRenderInformation() { + RenderPartTransmitter.init(); + RenderGlowPanel.init(); - //Register item handler - ItemRenderingHandler handler = new ItemRenderingHandler(); + //Register entity rendering handlers + RenderingRegistry.registerEntityRenderingHandler( + EntityObsidianTNT.class, new RenderObsidianTNTPrimed() + ); + RenderingRegistry.registerEntityRenderingHandler( + EntityRobit.class, new RenderRobit() + ); + RenderingRegistry.registerEntityRenderingHandler( + EntityBalloon.class, new RenderBalloon() + ); + RenderingRegistry.registerEntityRenderingHandler( + EntityBabySkeleton.class, new RenderSkeleton() + ); + RenderingRegistry.registerEntityRenderingHandler( + EntityFlame.class, new RenderFlame() + ); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(MekanismBlocks.EnergyCube), handler); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(MekanismBlocks.MachineBlock), handler); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(MekanismBlocks.MachineBlock2), handler); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(MekanismBlocks.MachineBlock3), handler); - MinecraftForgeClient.registerItemRenderer(MekanismItems.Robit, handler); - MinecraftForgeClient.registerItemRenderer(MekanismItems.WalkieTalkie, handler); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(MekanismBlocks.GasTank), handler); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(MekanismBlocks.ObsidianTNT), handler); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(MekanismBlocks.BasicBlock), handler); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(MekanismBlocks.BasicBlock2), handler); - MinecraftForgeClient.registerItemRenderer(MekanismItems.Jetpack, handler); - MinecraftForgeClient.registerItemRenderer(MekanismItems.ArmoredJetpack, handler); - MinecraftForgeClient.registerItemRenderer(MekanismItems.PartTransmitter, handler); - MinecraftForgeClient.registerItemRenderer(MekanismItems.GasMask, handler); - MinecraftForgeClient.registerItemRenderer(MekanismItems.ScubaTank, handler); - MinecraftForgeClient.registerItemRenderer(MekanismItems.Balloon, handler); - MinecraftForgeClient.registerItemRenderer(MekanismItems.FreeRunners, handler); - MinecraftForgeClient.registerItemRenderer(MekanismItems.AtomicDisassembler, handler); - MinecraftForgeClient.registerItemRenderer(MekanismItems.GlowPanel, handler); - MinecraftForgeClient.registerItemRenderer(MekanismItems.Flamethrower, handler); + //Register item handler + ItemRenderingHandler handler = new ItemRenderingHandler(); - //Register block handlers - RenderingRegistry.registerBlockHandler(new MachineRenderingHandler()); - RenderingRegistry.registerBlockHandler(new BasicRenderingHandler()); - RenderingRegistry.registerBlockHandler(new PlasticRenderingHandler()); - RenderingRegistry.registerBlockHandler(new CTMRenderingHandler()); + MinecraftForgeClient.registerItemRenderer( + Item.getItemFromBlock(MekanismBlocks.EnergyCube), handler + ); + MinecraftForgeClient.registerItemRenderer( + Item.getItemFromBlock(MekanismBlocks.MachineBlock), handler + ); + MinecraftForgeClient.registerItemRenderer( + Item.getItemFromBlock(MekanismBlocks.MachineBlock2), handler + ); + MinecraftForgeClient.registerItemRenderer( + Item.getItemFromBlock(MekanismBlocks.MachineBlock3), handler + ); + MinecraftForgeClient.registerItemRenderer(MekanismItems.Robit, handler); + MinecraftForgeClient.registerItemRenderer(MekanismItems.WalkieTalkie, handler); + MinecraftForgeClient.registerItemRenderer( + Item.getItemFromBlock(MekanismBlocks.GasTank), handler + ); + MinecraftForgeClient.registerItemRenderer( + Item.getItemFromBlock(MekanismBlocks.ObsidianTNT), handler + ); + MinecraftForgeClient.registerItemRenderer( + Item.getItemFromBlock(MekanismBlocks.BasicBlock), handler + ); + MinecraftForgeClient.registerItemRenderer( + Item.getItemFromBlock(MekanismBlocks.BasicBlock2), handler + ); + MinecraftForgeClient.registerItemRenderer(MekanismItems.Jetpack, handler); + MinecraftForgeClient.registerItemRenderer(MekanismItems.ArmoredJetpack, handler); + MinecraftForgeClient.registerItemRenderer(MekanismItems.PartTransmitter, handler); + MinecraftForgeClient.registerItemRenderer(MekanismItems.GasMask, handler); + MinecraftForgeClient.registerItemRenderer(MekanismItems.ScubaTank, handler); + MinecraftForgeClient.registerItemRenderer(MekanismItems.Balloon, handler); + MinecraftForgeClient.registerItemRenderer(MekanismItems.FreeRunners, handler); + MinecraftForgeClient.registerItemRenderer( + MekanismItems.AtomicDisassembler, handler + ); + MinecraftForgeClient.registerItemRenderer(MekanismItems.GlowPanel, handler); + MinecraftForgeClient.registerItemRenderer(MekanismItems.Flamethrower, handler); - Mekanism.logger.info("Render registrations complete."); - } + //Register block handlers + RenderingRegistry.registerBlockHandler(new MachineRenderingHandler()); + RenderingRegistry.registerBlockHandler(new BasicRenderingHandler()); + RenderingRegistry.registerBlockHandler(new PlasticRenderingHandler()); + RenderingRegistry.registerBlockHandler(new CTMRenderingHandler()); - @Override - public GuiScreen getClientGui(int ID, EntityPlayer player, World world, int x, int y, int z) - { - TileEntity tileEntity = world.getTileEntity(x, y, z); - switch(ID) - { - case 0: - return new GuiDictionary(player.inventory); - case 1: - return new GuiCredits(); - case 2: - return new GuiDigitalMiner(player.inventory, (TileEntityDigitalMiner)tileEntity); - case 3: - return new GuiEnrichmentChamber(player.inventory, (TileEntityElectricMachine)tileEntity); - case 4: - return new GuiOsmiumCompressor(player.inventory, (TileEntityAdvancedElectricMachine)tileEntity); - case 5: - return new GuiCombiner(player.inventory, (TileEntityAdvancedElectricMachine)tileEntity); - case 6: - return new GuiCrusher(player.inventory, (TileEntityElectricMachine)tileEntity); - case 7: - return new GuiRotaryCondensentrator(player.inventory, (TileEntityRotaryCondensentrator)tileEntity); - case 8: - return new GuiEnergyCube(player.inventory, (TileEntityEnergyCube)tileEntity); - case 9: - return new GuiSideConfiguration(player, (ISideConfiguration)tileEntity); - case 10: - return new GuiGasTank(player.inventory, (TileEntityGasTank)tileEntity); - case 11: - return new GuiFactory(player.inventory, (TileEntityFactory)tileEntity); - case 12: - return new GuiMetallurgicInfuser(player.inventory, (TileEntityMetallurgicInfuser)tileEntity); - case 13: - return new GuiTeleporter(player.inventory, (TileEntityTeleporter)tileEntity); - case 14: - ItemStack itemStack = player.getCurrentEquippedItem(); + Mekanism.logger.info("Render registrations complete."); + } - if(itemStack != null && itemStack.getItem() instanceof ItemPortableTeleporter) - { - return new GuiTeleporter(player, itemStack); - } - case 15: - return new GuiPurificationChamber(player.inventory, (TileEntityAdvancedElectricMachine)tileEntity); - case 16: - return new GuiEnergizedSmelter(player.inventory, (TileEntityElectricMachine)tileEntity); - case 17: - return new GuiElectricPump(player.inventory, (TileEntityElectricPump)tileEntity); - case 18: - return new GuiDynamicTank(player.inventory, (TileEntityDynamicTank)tileEntity); - //EMPTY 19, 20 - case 21: - EntityRobit robit = (EntityRobit)world.getEntityByID(x); + @Override + public GuiScreen + getClientGui(int ID, EntityPlayer player, World world, int x, int y, int z) { + TileEntity tileEntity = world.getTileEntity(x, y, z); + switch (ID) { + case 0: + return new GuiDictionary(player.inventory); + case 1: + return new GuiCredits(); + case 2: + return new GuiDigitalMiner( + player.inventory, (TileEntityDigitalMiner) tileEntity + ); + case 3: + return new GuiEnrichmentChamber( + player.inventory, (TileEntityElectricMachine) tileEntity + ); + case 4: + return new GuiOsmiumCompressor( + player.inventory, (TileEntityAdvancedElectricMachine) tileEntity + ); + case 5: + return new GuiCombiner( + player.inventory, (TileEntityAdvancedElectricMachine) tileEntity + ); + case 6: + return new GuiCrusher( + player.inventory, (TileEntityElectricMachine) tileEntity + ); + case 7: + return new GuiRotaryCondensentrator( + player.inventory, (TileEntityRotaryCondensentrator) tileEntity + ); + case 8: + return new GuiEnergyCube( + player.inventory, (TileEntityEnergyCube) tileEntity + ); + case 9: + return new GuiSideConfiguration(player, (ISideConfiguration) tileEntity); + case 10: + return new GuiGasTank(player.inventory, (TileEntityGasTank) tileEntity); + case 11: + return new GuiFactory(player.inventory, (TileEntityFactory) tileEntity); + case 12: + return new GuiMetallurgicInfuser( + player.inventory, (TileEntityMetallurgicInfuser) tileEntity + ); + case 13: + return new GuiTeleporter( + player.inventory, (TileEntityTeleporter) tileEntity + ); + case 14: + ItemStack itemStack = player.getCurrentEquippedItem(); - if(robit != null) - { - return new GuiRobitMain(player.inventory, robit); - } - case 22: - robit = (EntityRobit)world.getEntityByID(x); + if (itemStack != null + && itemStack.getItem() instanceof ItemPortableTeleporter) { + return new GuiTeleporter(player, itemStack); + } + case 15: + return new GuiPurificationChamber( + player.inventory, (TileEntityAdvancedElectricMachine) tileEntity + ); + case 16: + return new GuiEnergizedSmelter( + player.inventory, (TileEntityElectricMachine) tileEntity + ); + case 17: + return new GuiElectricPump( + player.inventory, (TileEntityElectricPump) tileEntity + ); + case 18: + return new GuiDynamicTank( + player.inventory, (TileEntityDynamicTank) tileEntity + ); + //EMPTY 19, 20 + case 21: + EntityRobit robit = (EntityRobit) world.getEntityByID(x); - if(robit != null) - { - return new GuiRobitCrafting(player.inventory, robit); - } - case 23: - robit = (EntityRobit)world.getEntityByID(x); + if (robit != null) { + return new GuiRobitMain(player.inventory, robit); + } + case 22: + robit = (EntityRobit) world.getEntityByID(x); - if(robit != null) - { - return new GuiRobitInventory(player.inventory, robit); - } - case 24: - robit = (EntityRobit)world.getEntityByID(x); + if (robit != null) { + return new GuiRobitCrafting(player.inventory, robit); + } + case 23: + robit = (EntityRobit) world.getEntityByID(x); - if(robit != null) - { - return new GuiRobitSmelting(player.inventory, robit); - } - case 25: - robit = (EntityRobit)world.getEntityByID(x); + if (robit != null) { + return new GuiRobitInventory(player.inventory, robit); + } + case 24: + robit = (EntityRobit) world.getEntityByID(x); - if(robit != null) - { - return new GuiRobitRepair(player.inventory, robit); - } - case 29: - return new GuiChemicalOxidizer(player.inventory, (TileEntityChemicalOxidizer)tileEntity); - case 30: - return new GuiChemicalInfuser(player.inventory, (TileEntityChemicalInfuser)tileEntity); - case 31: - return new GuiChemicalInjectionChamber(player.inventory, (TileEntityAdvancedElectricMachine)tileEntity); - case 32: - return new GuiElectrolyticSeparator(player.inventory, (TileEntityElectrolyticSeparator)tileEntity); - case 33: - return new GuiThermalEvaporationController(player.inventory, (TileEntityThermalEvaporationController)tileEntity); - case 34: - return new GuiPrecisionSawmill(player.inventory, (TileEntityPrecisionSawmill)tileEntity); - case 35: - return new GuiChemicalDissolutionChamber(player.inventory, (TileEntityChemicalDissolutionChamber)tileEntity); - case 36: - return new GuiChemicalWasher(player.inventory, (TileEntityChemicalWasher)tileEntity); - case 37: - return new GuiChemicalCrystallizer(player.inventory, (TileEntityChemicalCrystallizer)tileEntity); - case 38: - ItemStack itemStack1 = player.getCurrentEquippedItem().copy(); + if (robit != null) { + return new GuiRobitSmelting(player.inventory, robit); + } + case 25: + robit = (EntityRobit) world.getEntityByID(x); - if(itemStack1 != null && itemStack1.getItem() instanceof ItemSeismicReader) - { - return new GuiSeismicReader(world, new Coord4D(player), itemStack1); - } - case 39: - return new GuiSeismicVibrator(player.inventory, (TileEntitySeismicVibrator)tileEntity); - case 40: - return new GuiPRC(player.inventory, (TileEntityPRC)tileEntity); - case 41: - return new GuiFluidTank(player.inventory, (TileEntityFluidTank)tileEntity); - case 42: - return new GuiFluidicPlenisher(player.inventory, (TileEntityFluidicPlenisher)tileEntity); - case 43: - return new GuiUpgradeManagement(player.inventory, (IUpgradeTile)tileEntity); - case 44: - return new GuiLaserAmplifier(player.inventory, (TileEntityLaserAmplifier)tileEntity); - case 45: - return new GuiLaserTractorBeam(player.inventory, (TileEntityLaserTractorBeam)tileEntity); - case 46: - return new GuiQuantumEntangloporter(player.inventory, (TileEntityQuantumEntangloporter)tileEntity); - case 47: - return new GuiSolarNeutronActivator(player.inventory, (TileEntitySolarNeutronActivator)tileEntity); - case 48: - return new GuiAmbientAccumulator(player, (TileEntityAmbientAccumulator)tileEntity); - case 49: - return new GuiInductionMatrix(player.inventory, (TileEntityInductionCasing)tileEntity); - case 50: - return new GuiMatrixStats(player.inventory, (TileEntityInductionCasing)tileEntity); - case 51: - return new GuiTransporterConfig(player, (ISideConfiguration)tileEntity); - case 52: - return new GuiOredictionificator(player.inventory, (TileEntityOredictionificator)tileEntity); - case 53: - return new GuiResistiveHeater(player.inventory, (TileEntityResistiveHeater)tileEntity); - case 54: - return new GuiThermoelectricBoiler(player.inventory, (TileEntityBoilerCasing)tileEntity); - case 55: - return new GuiBoilerStats(player.inventory, (TileEntityBoilerCasing)tileEntity); - case 56: - return new GuiFormulaicAssemblicator(player.inventory, (TileEntityFormulaicAssemblicator)tileEntity); - case 57: - return new GuiSecurityDesk(player.inventory, (TileEntitySecurityDesk)tileEntity); - case 58: - return new GuiFuelwoodHeater(player.inventory, (TileEntityFuelwoodHeater)tileEntity); - case 60: - return new GuiTheoreticalElementizer(player.inventory, (TileEntityTheoreticalElementizer) tileEntity); - case 61: - return new GuiStopwatch(player); - case 62: - return new GuiWeatherOrb(player); - } - - return null; - } - - @Override - public void handleTeleporterUpdate(PortableTeleporterMessage message) - { - GuiScreen screen = Minecraft.getMinecraft().currentScreen; - - if(screen instanceof GuiTeleporter && ((GuiTeleporter)screen).itemStack != null) - { - GuiTeleporter teleporter = (GuiTeleporter)screen; - - teleporter.clientStatus = message.status; - teleporter.clientFreq = message.frequency; - teleporter.clientPublicCache = message.publicCache; - teleporter.clientPrivateCache = message.privateCache; - teleporter.clientProtectedCache = message.protectedCache; - - teleporter.updateButtons(); - } - } - - @Override - public void addHitEffects(Coord4D coord, MovingObjectPosition mop) - { - if(Minecraft.getMinecraft().theWorld != null) - { - Minecraft.getMinecraft().effectRenderer.addBlockHitEffects(coord.xCoord, coord.yCoord, coord.zCoord, mop); - } - } - - @Override - public void doGenericSparkle(TileEntity tileEntity, INodeChecker checker) - { - new SparkleAnimation(tileEntity, checker).run(); - } + if (robit != null) { + return new GuiRobitRepair(player.inventory, robit); + } + case 29: + return new GuiChemicalOxidizer( + player.inventory, (TileEntityChemicalOxidizer) tileEntity + ); + case 30: + return new GuiChemicalInfuser( + player.inventory, (TileEntityChemicalInfuser) tileEntity + ); + case 31: + return new GuiChemicalInjectionChamber( + player.inventory, (TileEntityAdvancedElectricMachine) tileEntity + ); + case 32: + return new GuiElectrolyticSeparator( + player.inventory, (TileEntityElectrolyticSeparator) tileEntity + ); + case 33: + return new GuiThermalEvaporationController( + player.inventory, (TileEntityThermalEvaporationController) tileEntity + ); + case 34: + return new GuiPrecisionSawmill( + player.inventory, (TileEntityPrecisionSawmill) tileEntity + ); + case 35: + return new GuiChemicalDissolutionChamber( + player.inventory, (TileEntityChemicalDissolutionChamber) tileEntity + ); + case 36: + return new GuiChemicalWasher( + player.inventory, (TileEntityChemicalWasher) tileEntity + ); + case 37: + return new GuiChemicalCrystallizer( + player.inventory, (TileEntityChemicalCrystallizer) tileEntity + ); + case 38: + ItemStack itemStack1 = player.getCurrentEquippedItem().copy(); - @Override - public void doMultiblockSparkle(final TileEntityMultiblock tileEntity) - { - if(client.doMultiblockSparkle == true){ - new SparkleAnimation(tileEntity, new INodeChecker() { - @Override - public boolean isNode(TileEntity tile) - { - return MultiblockManager.areEqual(tile, tileEntity); - } - }).run(); - } - } + if (itemStack1 != null + && itemStack1.getItem() instanceof ItemSeismicReader) { + return new GuiSeismicReader(world, new Coord4D(player), itemStack1); + } + case 39: + return new GuiSeismicVibrator( + player.inventory, (TileEntitySeismicVibrator) tileEntity + ); + case 40: + return new GuiPRC(player.inventory, (TileEntityPRC) tileEntity); + case 41: + return new GuiFluidTank( + player.inventory, (TileEntityFluidTank) tileEntity + ); + case 42: + return new GuiFluidicPlenisher( + player.inventory, (TileEntityFluidicPlenisher) tileEntity + ); + case 43: + return new GuiUpgradeManagement( + player.inventory, (IUpgradeTile) tileEntity + ); + case 44: + return new GuiLaserAmplifier( + player.inventory, (TileEntityLaserAmplifier) tileEntity + ); + case 45: + return new GuiLaserTractorBeam( + player.inventory, (TileEntityLaserTractorBeam) tileEntity + ); + case 46: + return new GuiQuantumEntangloporter( + player.inventory, (TileEntityQuantumEntangloporter) tileEntity + ); + case 47: + return new GuiSolarNeutronActivator( + player.inventory, (TileEntitySolarNeutronActivator) tileEntity + ); + case 48: + return new GuiAmbientAccumulator( + player, (TileEntityAmbientAccumulator) tileEntity + ); + case 49: + return new GuiInductionMatrix( + player.inventory, (TileEntityInductionCasing) tileEntity + ); + case 50: + return new GuiMatrixStats( + player.inventory, (TileEntityInductionCasing) tileEntity + ); + case 51: + return new GuiTransporterConfig(player, (ISideConfiguration) tileEntity); + case 52: + return new GuiOredictionificator( + player.inventory, (TileEntityOredictionificator) tileEntity + ); + case 53: + return new GuiResistiveHeater( + player.inventory, (TileEntityResistiveHeater) tileEntity + ); + case 54: + return new GuiThermoelectricBoiler( + player.inventory, (TileEntityBoilerCasing) tileEntity + ); + case 55: + return new GuiBoilerStats( + player.inventory, (TileEntityBoilerCasing) tileEntity + ); + case 56: + return new GuiFormulaicAssemblicator( + player.inventory, (TileEntityFormulaicAssemblicator) tileEntity + ); + case 57: + return new GuiSecurityDesk( + player.inventory, (TileEntitySecurityDesk) tileEntity + ); + case 58: + return new GuiFuelwoodHeater( + player.inventory, (TileEntityFuelwoodHeater) tileEntity + ); + case 60: + return new GuiTheoreticalElementizer( + player.inventory, (TileEntityTheoreticalElementizer) tileEntity + ); + case 61: + return new GuiStopwatch(player); + case 62: + return new GuiWeatherOrb(player); + } - @Override - public void loadUtilities() - { - super.loadUtilities(); - - FMLCommonHandler.instance().bus().register(new ClientConnectionHandler()); - FMLCommonHandler.instance().bus().register(new ClientPlayerTracker()); - FMLCommonHandler.instance().bus().register(new ClientTickHandler()); - FMLCommonHandler.instance().bus().register(new RenderTickHandler()); - - new MekanismKeyHandler(); + return null; + } - HolidayManager.init(); - } + @Override + public void handleTeleporterUpdate(PortableTeleporterMessage message) { + GuiScreen screen = Minecraft.getMinecraft().currentScreen; - @Override - public void preInit() - { - MekanismRenderer.init(); - isThorfusionLoaded = Loader.isModLoaded("thorfusion"); - } + if (screen instanceof GuiTeleporter + && ((GuiTeleporter) screen).itemStack != null) { + GuiTeleporter teleporter = (GuiTeleporter) screen; - @Override - public void Cape() - { - if(!isThorfusionLoaded) { - try { - DevCapes.getInstance().registerConfig("https://raw.githubusercontent.com/maggi373/files/main/capes/cape.json"); - } catch (Exception e) { - System.out.print("Cant load capes\n"+e); - } - } - } + teleporter.clientStatus = message.status; + teleporter.clientFreq = message.frequency; + teleporter.clientPublicCache = message.publicCache; + teleporter.clientPrivateCache = message.privateCache; + teleporter.clientProtectedCache = message.protectedCache; - @Override - public double getReach(EntityPlayer player) - { - return Minecraft.getMinecraft().playerController.getBlockReachDistance(); - } + teleporter.updateButtons(); + } + } - @Override - public boolean isPaused() - { - if(FMLClientHandler.instance().getClient().isSingleplayer() && !FMLClientHandler.instance().getClient().getIntegratedServer().getPublic()) - { - GuiScreen screen = FMLClientHandler.instance().getClient().currentScreen; + @Override + public void addHitEffects(Coord4D coord, MovingObjectPosition mop) { + if (Minecraft.getMinecraft().theWorld != null) { + Minecraft.getMinecraft().effectRenderer.addBlockHitEffects( + coord.xCoord, coord.yCoord, coord.zCoord, mop + ); + } + } - if(screen != null && screen.doesGuiPauseGame()) - { - return true; - } - } + @Override + public void doGenericSparkle(TileEntity tileEntity, INodeChecker checker) { + new SparkleAnimation(tileEntity, checker).run(); + } - return false; - } + @Override + public void doMultiblockSparkle(final TileEntityMultiblock tileEntity) { + if (client.doMultiblockSparkle == true) { + new SparkleAnimation(tileEntity, new INodeChecker() { + @Override + public boolean isNode(TileEntity tile) { + return MultiblockManager.areEqual(tile, tileEntity); + } + }).run(); + } + } - @Override - public File getMinecraftDir() - { - return Minecraft.getMinecraft().mcDataDir; - } + @Override + public void loadUtilities() { + super.loadUtilities(); - @Override - public void onConfigSync(boolean fromPacket) - { - super.onConfigSync(fromPacket); + FMLCommonHandler.instance().bus().register(new ClientConnectionHandler()); + FMLCommonHandler.instance().bus().register(new ClientPlayerTracker()); + FMLCommonHandler.instance().bus().register(new ClientTickHandler()); + FMLCommonHandler.instance().bus().register(new RenderTickHandler()); - if(fromPacket && general.voiceServerEnabled && MekanismClient.voiceClient != null) - { - MekanismClient.voiceClient.start(); - } - } + new MekanismKeyHandler(); - @Override - public EntityPlayer getPlayer(MessageContext context) - { - if(FMLCommonHandler.instance().getEffectiveSide().isServer()) - { - return context.getServerHandler().playerEntity; - } - else { - return Minecraft.getMinecraft().thePlayer; - } - } + HolidayManager.init(); + } - @Override - public void renderLaser(World world, Pos3D from, Pos3D to, ForgeDirection direction, double energy) - { - Minecraft.getMinecraft().effectRenderer.addEffect(new EntityLaser(world, from, to, direction, energy)); - } - - @Override - public FontRenderer getFontRenderer() - { - return Minecraft.getMinecraft().fontRenderer; - } + @Override + public void preInit() { + MekanismRenderer.init(); + isThorfusionLoaded = Loader.isModLoaded("thorfusion"); + } + + @Override + public void Cape() { + if (!isThorfusionLoaded) { + try { + DevCapes.getInstance().registerConfig( + "https://raw.githubusercontent.com/maggi373/files/main/capes/cape.json" + ); + } catch (Exception e) { + System.out.print("Cant load capes\n" + e); + } + } + } + + @Override + public double getReach(EntityPlayer player) { + return Minecraft.getMinecraft().playerController.getBlockReachDistance(); + } + + @Override + public boolean isPaused() { + if (FMLClientHandler.instance().getClient().isSingleplayer() + && !FMLClientHandler.instance().getClient().getIntegratedServer().getPublic( + )) { + GuiScreen screen = FMLClientHandler.instance().getClient().currentScreen; + + if (screen != null && screen.doesGuiPauseGame()) { + return true; + } + } + + return false; + } + + @Override + public File getMinecraftDir() { + return Minecraft.getMinecraft().mcDataDir; + } + + @Override + public void onConfigSync(boolean fromPacket) { + super.onConfigSync(fromPacket); + + if (fromPacket && general.voiceServerEnabled + && MekanismClient.voiceClient != null) { + MekanismClient.voiceClient.start(); + } + } + + @Override + public EntityPlayer getPlayer(MessageContext context) { + if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { + return context.getServerHandler().playerEntity; + } else { + return Minecraft.getMinecraft().thePlayer; + } + } + + @Override + public void renderLaser( + World world, Pos3D from, Pos3D to, ForgeDirection direction, double energy + ) { + Minecraft.getMinecraft().effectRenderer.addEffect( + new EntityLaser(world, from, to, direction, energy) + ); + } + + @Override + public FontRenderer getFontRenderer() { + return Minecraft.getMinecraft().fontRenderer; + } } diff --git a/src/main/java/mekanism/client/ClientTickHandler.java b/src/main/java/mekanism/client/ClientTickHandler.java index 6590d9712..47c1911ff 100644 --- a/src/main/java/mekanism/client/ClientTickHandler.java +++ b/src/main/java/mekanism/client/ClientTickHandler.java @@ -11,6 +11,13 @@ import java.util.List; import java.util.Map; import java.util.Set; +import com.mojang.authlib.minecraft.MinecraftProfileTexture; +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent; +import cpw.mods.fml.common.gameevent.TickEvent.Phase; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.IClientTicker; import mekanism.api.MekanismConfig.client; import mekanism.api.gas.GasStack; @@ -38,439 +45,411 @@ import net.minecraft.item.ItemStack; import net.minecraft.potion.PotionEffect; import net.minecraft.util.StringUtils; -import com.mojang.authlib.minecraft.MinecraftProfileTexture; - -import cpw.mods.fml.client.FMLClientHandler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.TickEvent.ClientTickEvent; -import cpw.mods.fml.common.gameevent.TickEvent.Phase; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - /** * Client-side tick handler for Mekanism. Used mainly for the update check upon startup. * @author AidanBrady * */ @SideOnly(Side.CLIENT) -public class ClientTickHandler -{ - public boolean initHoliday = false; +public class ClientTickHandler { + public boolean initHoliday = false; - public boolean preloadedSounds = false; + public boolean preloadedSounds = false; - public boolean lastTickUpdate; + public boolean lastTickUpdate; - public boolean shouldReset = false; + public boolean shouldReset = false; - public static Minecraft mc = FMLClientHandler.instance().getClient(); + public static Minecraft mc = FMLClientHandler.instance().getClient(); - public static final String DONATE_CAPE = "http://aidancbrady.com/data/capes/donate.png"; - public static final String AIDAN_CAPE = "http://aidancbrady.com/data/capes/aidan.png"; + public static final String DONATE_CAPE + = "http://aidancbrady.com/data/capes/donate.png"; + public static final String AIDAN_CAPE = "http://aidancbrady.com/data/capes/aidan.png"; - private Map donateDownload = new HashMap(); - private Map aidanDownload = new HashMap(); + private Map donateDownload + = new HashMap(); + private Map aidanDownload + = new HashMap(); - public static Set tickingSet = new HashSet(); + public static Set tickingSet = new HashSet(); - @SubscribeEvent - public void onTick(ClientTickEvent event) - { - if(event.phase == Phase.START) - { - tickStart(); - } - } + @SubscribeEvent + public void onTick(ClientTickEvent event) { + if (event.phase == Phase.START) { + tickStart(); + } + } - public void tickStart() - { - MekanismClient.ticksPassed++; + public void tickStart() { + MekanismClient.ticksPassed++; - if(!Mekanism.proxy.isPaused()) - { - for(Iterator iter = tickingSet.iterator(); iter.hasNext();) - { - IClientTicker ticker = iter.next(); + if (!Mekanism.proxy.isPaused()) { + for (Iterator iter = tickingSet.iterator(); iter.hasNext();) { + IClientTicker ticker = iter.next(); - if(ticker.needsTicks()) - { - ticker.clientTick(); - } - else { - iter.remove(); - } - } - } + if (ticker.needsTicks()) { + ticker.clientTick(); + } else { + iter.remove(); + } + } + } - if(mc.theWorld != null) - { - shouldReset = true; - } - else if(shouldReset) - { - MekanismClient.reset(); - shouldReset = false; - } + if (mc.theWorld != null) { + shouldReset = true; + } else if (shouldReset) { + MekanismClient.reset(); + shouldReset = false; + } - if(mc.theWorld != null && !Mekanism.proxy.isPaused()) - { - if((!initHoliday || MekanismClient.ticksPassed % 1200 == 0) && mc.thePlayer != null) - { - HolidayManager.check(); - initHoliday = true; - } + if (mc.theWorld != null && !Mekanism.proxy.isPaused()) { + if ((!initHoliday || MekanismClient.ticksPassed % 1200 == 0) + && mc.thePlayer != null) { + HolidayManager.check(); + initHoliday = true; + } - for(EntityPlayer entityPlayer : (List)mc.theWorld.playerEntities) - { - if(entityPlayer instanceof AbstractClientPlayer) - { - AbstractClientPlayer player = (AbstractClientPlayer)entityPlayer; + for (EntityPlayer entityPlayer : + (List) mc.theWorld.playerEntities) { + if (entityPlayer instanceof AbstractClientPlayer) { + AbstractClientPlayer player = (AbstractClientPlayer) entityPlayer; - if(player != null) - { - if(StringUtils.stripControlCodes(player.getCommandSenderName()).equals("aidancbrady")) - { - CapeBufferDownload download = aidanDownload.get(player.getCommandSenderName()); + if (player != null) { + if (StringUtils.stripControlCodes(player.getCommandSenderName()) + .equals("aidancbrady")) { + CapeBufferDownload download + = aidanDownload.get(player.getCommandSenderName()); - if(download == null) - { - download = new CapeBufferDownload(player.getCommandSenderName(), AIDAN_CAPE); - aidanDownload.put(player.getCommandSenderName(), download); + if (download == null) { + download = new CapeBufferDownload( + player.getCommandSenderName(), AIDAN_CAPE + ); + aidanDownload.put( + player.getCommandSenderName(), download + ); - download.start(); - } - else { - if(!download.downloaded) - { - continue; - } + download.start(); + } else { + if (!download.downloaded) { + continue; + } - player.func_152121_a(MinecraftProfileTexture.Type.CAPE, download.getResourceLocation()); - } - } - else if(Mekanism.donators.contains(StringUtils.stripControlCodes(player.getCommandSenderName()))) - { - CapeBufferDownload download = donateDownload.get(player.getCommandSenderName()); + player.func_152121_a( + MinecraftProfileTexture.Type.CAPE, + download.getResourceLocation() + ); + } + } else if (Mekanism.donators.contains( + StringUtils.stripControlCodes( + player.getCommandSenderName() + ) + )) { + CapeBufferDownload download + = donateDownload.get(player.getCommandSenderName()); - if(download == null) - { - download = new CapeBufferDownload(player.getCommandSenderName(), DONATE_CAPE); - donateDownload.put(player.getCommandSenderName(), download); + if (download == null) { + download = new CapeBufferDownload( + player.getCommandSenderName(), DONATE_CAPE + ); + donateDownload.put( + player.getCommandSenderName(), download + ); - download.start(); - } - else { - if(!download.downloaded) - { - continue; - } + download.start(); + } else { + if (!download.downloaded) { + continue; + } - player.func_152121_a(MinecraftProfileTexture.Type.CAPE, download.getResourceLocation()); - } - } - } - } - } + player.func_152121_a( + MinecraftProfileTexture.Type.CAPE, + download.getResourceLocation() + ); + } + } + } + } + } - if(mc.thePlayer.getEquipmentInSlot(1) != null && mc.thePlayer.getEquipmentInSlot(1).getItem() instanceof ItemFreeRunners) - { - mc.thePlayer.stepHeight = 1.002F; - } - else { - if(mc.thePlayer.stepHeight == 1.002F) - { - mc.thePlayer.stepHeight = 0.5F; - } - } - - if(Mekanism.flamethrowerActive.contains(mc.thePlayer.getCommandSenderName()) != isFlamethrowerOn(mc.thePlayer)) - { - if(isFlamethrowerOn(mc.thePlayer)) - { - Mekanism.flamethrowerActive.add(mc.thePlayer.getCommandSenderName()); - } - else { - Mekanism.flamethrowerActive.remove(mc.thePlayer.getCommandSenderName()); - } - - Mekanism.packetHandler.sendToServer(new FlamethrowerDataMessage(PacketFlamethrowerData.FlamethrowerPacket.UPDATE, mc.thePlayer.getCommandSenderName(), isFlamethrowerOn(mc.thePlayer))); - } + if (mc.thePlayer.getEquipmentInSlot(1) != null + && mc.thePlayer.getEquipmentInSlot(1).getItem() + instanceof ItemFreeRunners) { + mc.thePlayer.stepHeight = 1.002F; + } else { + if (mc.thePlayer.stepHeight == 1.002F) { + mc.thePlayer.stepHeight = 0.5F; + } + } - if(Mekanism.jetpackOn.contains(mc.thePlayer.getCommandSenderName()) != isJetpackOn(mc.thePlayer)) - { - if(isJetpackOn(mc.thePlayer)) - { - Mekanism.jetpackOn.add(mc.thePlayer.getCommandSenderName()); - } - else { - Mekanism.jetpackOn.remove(mc.thePlayer.getCommandSenderName()); - } + if (Mekanism.flamethrowerActive.contains(mc.thePlayer.getCommandSenderName()) + != isFlamethrowerOn(mc.thePlayer)) { + if (isFlamethrowerOn(mc.thePlayer)) { + Mekanism.flamethrowerActive.add(mc.thePlayer.getCommandSenderName()); + } else { + Mekanism.flamethrowerActive.remove(mc.thePlayer.getCommandSenderName() + ); + } - Mekanism.packetHandler.sendToServer(new JetpackDataMessage(JetpackPacket.UPDATE, mc.thePlayer.getCommandSenderName(), isJetpackOn(mc.thePlayer))); - } + Mekanism.packetHandler.sendToServer(new FlamethrowerDataMessage( + PacketFlamethrowerData.FlamethrowerPacket.UPDATE, + mc.thePlayer.getCommandSenderName(), + isFlamethrowerOn(mc.thePlayer) + )); + } - if(Mekanism.gasmaskOn.contains(mc.thePlayer.getCommandSenderName()) != isGasMaskOn(mc.thePlayer)) - { - if(isGasMaskOn(mc.thePlayer) && mc.currentScreen == null) - { - Mekanism.gasmaskOn.add(mc.thePlayer.getCommandSenderName()); - } - else { - Mekanism.gasmaskOn.remove(mc.thePlayer.getCommandSenderName()); - } + if (Mekanism.jetpackOn.contains(mc.thePlayer.getCommandSenderName()) + != isJetpackOn(mc.thePlayer)) { + if (isJetpackOn(mc.thePlayer)) { + Mekanism.jetpackOn.add(mc.thePlayer.getCommandSenderName()); + } else { + Mekanism.jetpackOn.remove(mc.thePlayer.getCommandSenderName()); + } - Mekanism.packetHandler.sendToServer(new ScubaTankDataMessage(ScubaTankPacket.UPDATE, mc.thePlayer.getCommandSenderName(), isGasMaskOn(mc.thePlayer))); - } + Mekanism.packetHandler.sendToServer(new JetpackDataMessage( + JetpackPacket.UPDATE, + mc.thePlayer.getCommandSenderName(), + isJetpackOn(mc.thePlayer) + )); + } - if(client.enablePlayerSounds) - { - for(String username : Mekanism.jetpackOn) - { - EntityPlayer player = mc.theWorld.getPlayerEntityByName(username); + if (Mekanism.gasmaskOn.contains(mc.thePlayer.getCommandSenderName()) + != isGasMaskOn(mc.thePlayer)) { + if (isGasMaskOn(mc.thePlayer) && mc.currentScreen == null) { + Mekanism.gasmaskOn.add(mc.thePlayer.getCommandSenderName()); + } else { + Mekanism.gasmaskOn.remove(mc.thePlayer.getCommandSenderName()); + } - if(player != null) - { - if(!SoundHandler.soundPlaying(player, JETPACK)) - { - SoundHandler.addSound(player, JETPACK, client.replaceSoundsWhenResuming); - } - - SoundHandler.playSound(player, JETPACK); - } - } + Mekanism.packetHandler.sendToServer(new ScubaTankDataMessage( + ScubaTankPacket.UPDATE, + mc.thePlayer.getCommandSenderName(), + isGasMaskOn(mc.thePlayer) + )); + } - for(String username : Mekanism.gasmaskOn) - { - EntityPlayer player = mc.theWorld.getPlayerEntityByName(username); + if (client.enablePlayerSounds) { + for (String username : Mekanism.jetpackOn) { + EntityPlayer player = mc.theWorld.getPlayerEntityByName(username); - if(player != null) - { - if(!SoundHandler.soundPlaying(player, GASMASK)) - { - SoundHandler.addSound(player, GASMASK, client.replaceSoundsWhenResuming); - } - - SoundHandler.playSound(player, GASMASK); - } - } + if (player != null) { + if (!SoundHandler.soundPlaying(player, JETPACK)) { + SoundHandler.addSound( + player, JETPACK, client.replaceSoundsWhenResuming + ); + } - for(EntityPlayer player : (List)mc.theWorld.playerEntities) - { - if(hasFlamethrower(player)) - { - if(!SoundHandler.soundPlaying(player, FLAMETHROWER)) - { - SoundHandler.addSound(player, FLAMETHROWER, client.replaceSoundsWhenResuming); - } - - SoundHandler.playSound(player, FLAMETHROWER); - } - } - } + SoundHandler.playSound(player, JETPACK); + } + } - if(mc.thePlayer.getEquipmentInSlot(3) != null && mc.thePlayer.getEquipmentInSlot(3).getItem() instanceof ItemJetpack) - { - MekanismClient.updateKey(mc.gameSettings.keyBindJump, KeySync.ASCEND); - MekanismClient.updateKey(mc.gameSettings.keyBindSneak, KeySync.DESCEND); - } - - if(isFlamethrowerOn(mc.thePlayer)) - { - ItemFlamethrower flamethrower = (ItemFlamethrower)mc.thePlayer.getCurrentEquippedItem().getItem(); - - if(!mc.thePlayer.capabilities.isCreativeMode) - { - flamethrower.useGas(mc.thePlayer.getCurrentEquippedItem()); - } - } - - if(isJetpackOn(mc.thePlayer)) - { - ItemJetpack jetpack = (ItemJetpack)mc.thePlayer.getEquipmentInSlot(3).getItem(); + for (String username : Mekanism.gasmaskOn) { + EntityPlayer player = mc.theWorld.getPlayerEntityByName(username); - if(jetpack.getMode(mc.thePlayer.getEquipmentInSlot(3)) == JetpackMode.NORMAL) - { - mc.thePlayer.motionY = Math.min(mc.thePlayer.motionY + 0.15D, 0.5D); - mc.thePlayer.fallDistance = 0.0F; - } + if (player != null) { + if (!SoundHandler.soundPlaying(player, GASMASK)) { + SoundHandler.addSound( + player, GASMASK, client.replaceSoundsWhenResuming + ); + } + + SoundHandler.playSound(player, GASMASK); + } + } + + for (EntityPlayer player : + (List) mc.theWorld.playerEntities) { + if (hasFlamethrower(player)) { + if (!SoundHandler.soundPlaying(player, FLAMETHROWER)) { + SoundHandler.addSound( + player, FLAMETHROWER, client.replaceSoundsWhenResuming + ); + } + + SoundHandler.playSound(player, FLAMETHROWER); + } + } + } + + if (mc.thePlayer.getEquipmentInSlot(3) != null + && mc.thePlayer.getEquipmentInSlot(3).getItem() instanceof ItemJetpack) { + MekanismClient.updateKey(mc.gameSettings.keyBindJump, KeySync.ASCEND); + MekanismClient.updateKey(mc.gameSettings.keyBindSneak, KeySync.DESCEND); + } + + if (isFlamethrowerOn(mc.thePlayer)) { + ItemFlamethrower flamethrower + = (ItemFlamethrower) mc.thePlayer.getCurrentEquippedItem().getItem(); + + if (!mc.thePlayer.capabilities.isCreativeMode) { + flamethrower.useGas(mc.thePlayer.getCurrentEquippedItem()); + } + } + + if (isJetpackOn(mc.thePlayer)) { + ItemJetpack jetpack + = (ItemJetpack) mc.thePlayer.getEquipmentInSlot(3).getItem(); + + if (jetpack.getMode(mc.thePlayer.getEquipmentInSlot(3)) + == JetpackMode.NORMAL) { + mc.thePlayer.motionY = Math.min(mc.thePlayer.motionY + 0.15D, 0.5D); + mc.thePlayer.fallDistance = 0.0F; + } else if(jetpack.getMode(mc.thePlayer.getEquipmentInSlot(3)) == JetpackMode.HOVER) { - if((!mc.gameSettings.keyBindJump.getIsKeyPressed() && !mc.gameSettings.keyBindSneak.getIsKeyPressed()) || (mc.gameSettings.keyBindJump.getIsKeyPressed() && mc.gameSettings.keyBindSneak.getIsKeyPressed()) || mc.currentScreen != null) - { - if(mc.thePlayer.motionY > 0) - { - mc.thePlayer.motionY = Math.max(mc.thePlayer.motionY - 0.15D, 0); - } - else if(mc.thePlayer.motionY < 0) - { - if(!CommonPlayerTickHandler.isOnGround(mc.thePlayer)) - { - mc.thePlayer.motionY = Math.min(mc.thePlayer.motionY + 0.15D, 0); - } - } - } - else { - if(mc.gameSettings.keyBindJump.getIsKeyPressed() && mc.currentScreen == null) - { - mc.thePlayer.motionY = Math.min(mc.thePlayer.motionY + 0.15D, 0.2D); - } - else if(mc.gameSettings.keyBindSneak.getIsKeyPressed() && mc.currentScreen == null) - { - if(!CommonPlayerTickHandler.isOnGround(mc.thePlayer)) - { - mc.thePlayer.motionY = Math.max(mc.thePlayer.motionY - 0.15D, -0.2D); - } - } - } + if ((!mc.gameSettings.keyBindJump.getIsKeyPressed() + && !mc.gameSettings.keyBindSneak.getIsKeyPressed()) + || (mc.gameSettings.keyBindJump.getIsKeyPressed() + && mc.gameSettings.keyBindSneak.getIsKeyPressed()) + || mc.currentScreen != null) { + if (mc.thePlayer.motionY > 0) { + mc.thePlayer.motionY + = Math.max(mc.thePlayer.motionY - 0.15D, 0); + } else if (mc.thePlayer.motionY < 0) { + if (!CommonPlayerTickHandler.isOnGround(mc.thePlayer)) { + mc.thePlayer.motionY + = Math.min(mc.thePlayer.motionY + 0.15D, 0); + } + } + } else { + if (mc.gameSettings.keyBindJump.getIsKeyPressed() + && mc.currentScreen == null) { + mc.thePlayer.motionY + = Math.min(mc.thePlayer.motionY + 0.15D, 0.2D); + } else if (mc.gameSettings.keyBindSneak.getIsKeyPressed() && mc.currentScreen == null) { + if (!CommonPlayerTickHandler.isOnGround(mc.thePlayer)) { + mc.thePlayer.motionY + = Math.max(mc.thePlayer.motionY - 0.15D, -0.2D); + } + } + } - mc.thePlayer.fallDistance = 0.0F; - } + mc.thePlayer.fallDistance = 0.0F; + } - jetpack.useGas(mc.thePlayer.getEquipmentInSlot(3)); - } + jetpack.useGas(mc.thePlayer.getEquipmentInSlot(3)); + } - if(isGasMaskOn(mc.thePlayer)) - { - ItemScubaTank tank = (ItemScubaTank)mc.thePlayer.getEquipmentInSlot(3).getItem(); + if (isGasMaskOn(mc.thePlayer)) { + ItemScubaTank tank + = (ItemScubaTank) mc.thePlayer.getEquipmentInSlot(3).getItem(); - final int max = 300; - - tank.useGas(mc.thePlayer.getEquipmentInSlot(3)); - GasStack received = tank.useGas(mc.thePlayer.getEquipmentInSlot(3), max-mc.thePlayer.getAir()); + final int max = 300; - if(received != null) - { - mc.thePlayer.setAir(mc.thePlayer.getAir()+received.amount); - } - - if(mc.thePlayer.getAir() == max) - { - for(Object obj : mc.thePlayer.getActivePotionEffects()) - { - if(obj instanceof PotionEffect) - { - for(int i = 0; i < 9; i++) - { - ((PotionEffect)obj).onUpdate(mc.thePlayer); - } - } - } - } - } - } - } + tank.useGas(mc.thePlayer.getEquipmentInSlot(3)); + GasStack received = tank.useGas( + mc.thePlayer.getEquipmentInSlot(3), max - mc.thePlayer.getAir() + ); - public static void killDeadNetworks() - { - for(Iterator iter = tickingSet.iterator(); iter.hasNext();) - { - if(!iter.next().needsTicks()) - { - iter.remove(); - } - } - } + if (received != null) { + mc.thePlayer.setAir(mc.thePlayer.getAir() + received.amount); + } - public static boolean isJetpackOn(EntityPlayer player) - { - if(player != mc.thePlayer) - { - return Mekanism.jetpackOn.contains(player.getCommandSenderName()); - } + if (mc.thePlayer.getAir() == max) { + for (Object obj : mc.thePlayer.getActivePotionEffects()) { + if (obj instanceof PotionEffect) { + for (int i = 0; i < 9; i++) { + ((PotionEffect) obj).onUpdate(mc.thePlayer); + } + } + } + } + } + } + } - ItemStack stack = player.inventory.armorInventory[2]; + public static void killDeadNetworks() { + for (Iterator iter = tickingSet.iterator(); iter.hasNext();) { + if (!iter.next().needsTicks()) { + iter.remove(); + } + } + } - if(stack != null && !player.capabilities.isCreativeMode) - { - if(stack.getItem() instanceof ItemJetpack) - { - ItemJetpack jetpack = (ItemJetpack)stack.getItem(); + public static boolean isJetpackOn(EntityPlayer player) { + if (player != mc.thePlayer) { + return Mekanism.jetpackOn.contains(player.getCommandSenderName()); + } - if(jetpack.getGas(stack) != null) - { - if((mc.gameSettings.keyBindJump.getIsKeyPressed() && jetpack.getMode(stack) == JetpackMode.NORMAL) && mc.currentScreen == null) - { - return true; - } - else if(jetpack.getMode(stack) == JetpackMode.HOVER) - { - if((!mc.gameSettings.keyBindJump.getIsKeyPressed() && !mc.gameSettings.keyBindSneak.getIsKeyPressed()) || (mc.gameSettings.keyBindJump.getIsKeyPressed() && mc.gameSettings.keyBindSneak.getIsKeyPressed()) || mc.currentScreen != null) - { - return !player.onGround; - } - else if(mc.gameSettings.keyBindSneak.getIsKeyPressed() && mc.currentScreen == null) - { - return !player.onGround; - } - - return true; - } - } - } - } + ItemStack stack = player.inventory.armorInventory[2]; - return false; - } + if (stack != null && !player.capabilities.isCreativeMode) { + if (stack.getItem() instanceof ItemJetpack) { + ItemJetpack jetpack = (ItemJetpack) stack.getItem(); - public static boolean isGasMaskOn(EntityPlayer player) - { - if(player != mc.thePlayer) - { - return Mekanism.gasmaskOn.contains(player.getCommandSenderName()); - } + if (jetpack.getGas(stack) != null) { + if ((mc.gameSettings.keyBindJump.getIsKeyPressed() + && jetpack.getMode(stack) == JetpackMode.NORMAL) + && mc.currentScreen == null) { + return true; + } else if (jetpack.getMode(stack) == JetpackMode.HOVER) { + if ((!mc.gameSettings.keyBindJump.getIsKeyPressed() + && !mc.gameSettings.keyBindSneak.getIsKeyPressed()) + || (mc.gameSettings.keyBindJump.getIsKeyPressed() + && mc.gameSettings.keyBindSneak.getIsKeyPressed()) + || mc.currentScreen != null) { + return !player.onGround; + } else if (mc.gameSettings.keyBindSneak.getIsKeyPressed() && mc.currentScreen == null) { + return !player.onGround; + } - ItemStack tank = player.inventory.armorInventory[2]; - ItemStack mask = player.inventory.armorInventory[3]; + return true; + } + } + } + } - if(tank != null && mask != null) - { - if(tank.getItem() instanceof ItemScubaTank && mask.getItem() instanceof ItemGasMask) - { - ItemScubaTank scubaTank = (ItemScubaTank)tank.getItem(); + return false; + } - if(scubaTank.getGas(tank) != null) - { - if(scubaTank.getFlowing(tank)) - { - return true; - } - } - } - } + public static boolean isGasMaskOn(EntityPlayer player) { + if (player != mc.thePlayer) { + return Mekanism.gasmaskOn.contains(player.getCommandSenderName()); + } - return false; - } - - public static boolean isFlamethrowerOn(EntityPlayer player) - { - if(player != mc.thePlayer) - { - return Mekanism.flamethrowerActive.contains(player.getCommandSenderName()); - } - - if(hasFlamethrower(player)) - { - if(mc.gameSettings.keyBindUseItem.getIsKeyPressed()) - { - return true; - } - } - - return false; - } - - public static boolean hasFlamethrower(EntityPlayer player) - { - if(player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemFlamethrower) - { - ItemFlamethrower flamethrower = (ItemFlamethrower)player.getCurrentEquippedItem().getItem(); - - if(flamethrower.getGas(player.getCurrentEquippedItem()) != null) - { - return true; - } - } - - return false; - } + ItemStack tank = player.inventory.armorInventory[2]; + ItemStack mask = player.inventory.armorInventory[3]; + + if (tank != null && mask != null) { + if (tank.getItem() instanceof ItemScubaTank + && mask.getItem() instanceof ItemGasMask) { + ItemScubaTank scubaTank = (ItemScubaTank) tank.getItem(); + + if (scubaTank.getGas(tank) != null) { + if (scubaTank.getFlowing(tank)) { + return true; + } + } + } + } + + return false; + } + + public static boolean isFlamethrowerOn(EntityPlayer player) { + if (player != mc.thePlayer) { + return Mekanism.flamethrowerActive.contains(player.getCommandSenderName()); + } + + if (hasFlamethrower(player)) { + if (mc.gameSettings.keyBindUseItem.getIsKeyPressed()) { + return true; + } + } + + return false; + } + + public static boolean hasFlamethrower(EntityPlayer player) { + if (player.getCurrentEquippedItem() != null + && player.getCurrentEquippedItem().getItem() instanceof ItemFlamethrower) { + ItemFlamethrower flamethrower + = (ItemFlamethrower) player.getCurrentEquippedItem().getItem(); + + if (flamethrower.getGas(player.getCurrentEquippedItem()) != null) { + return true; + } + } + + return false; + } } diff --git a/src/main/java/mekanism/client/HolidayManager.java b/src/main/java/mekanism/client/HolidayManager.java index d62563d33..0de261967 100644 --- a/src/main/java/mekanism/client/HolidayManager.java +++ b/src/main/java/mekanism/client/HolidayManager.java @@ -12,230 +12,235 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ChatComponentText; import net.minecraft.util.ResourceLocation; -public final class HolidayManager -{ - private static Calendar calendar = Calendar.getInstance(); - private static Minecraft mc = Minecraft.getMinecraft(); +public final class HolidayManager { + private static Calendar calendar = Calendar.getInstance(); + private static Minecraft mc = Minecraft.getMinecraft(); - public static List holidays = new ArrayList(); - private static List holidaysNotified = new ArrayList(); + public static List holidays = new ArrayList(); + private static List holidaysNotified = new ArrayList(); - public static void init() - { - if(client.holidays) - { - holidays.add(new Christmas()); - holidays.add(new NewYear()); - } + public static void init() { + if (client.holidays) { + holidays.add(new Christmas()); + holidays.add(new NewYear()); + } - Mekanism.logger.info("Initialized HolidayManager."); - } + Mekanism.logger.info("Initialized HolidayManager."); + } - public static void check() - { - try { - YearlyDate date = getDate(); + public static void check() { + try { + YearlyDate date = getDate(); - for(Holiday holiday : holidays) - { - if(!holidaysNotified.contains(holiday)) - { - if(holiday.getDate().equals(date)) - { - holiday.onEvent(mc.thePlayer); - holidaysNotified.add(holiday); - } - } - } - } catch(Exception e) {} - } + for (Holiday holiday : holidays) { + if (!holidaysNotified.contains(holiday)) { + if (holiday.getDate().equals(date)) { + holiday.onEvent(mc.thePlayer); + holidaysNotified.add(holiday); + } + } + } + } catch (Exception e) {} + } - public static ResourceLocation filterSound(ResourceLocation sound) - { - if(!client.holidays) - { - return sound; - } + public static ResourceLocation filterSound(ResourceLocation sound) { + if (!client.holidays) { + return sound; + } - try { - YearlyDate date = getDate(); + try { + YearlyDate date = getDate(); - for(Holiday holiday : holidays) - { - if(holiday.getDate().equals(date)) - { - return holiday.filterSound(sound); - } - } - } catch(Exception e) {} + for (Holiday holiday : holidays) { + if (holiday.getDate().equals(date)) { + return holiday.filterSound(sound); + } + } + } catch (Exception e) {} - return sound; - } + return sound; + } - private static YearlyDate getDate() - { - return new YearlyDate(calendar.get(Calendar.MONTH)+1, calendar.get(Calendar.DAY_OF_MONTH)); - } + private static YearlyDate getDate() { + return new YearlyDate( + calendar.get(Calendar.MONTH) + 1, calendar.get(Calendar.DAY_OF_MONTH) + ); + } - public static abstract class Holiday - { - public abstract YearlyDate getDate(); + public static abstract class Holiday { + public abstract YearlyDate getDate(); - public abstract void onEvent(EntityPlayer player); + public abstract void onEvent(EntityPlayer player); - public ResourceLocation filterSound(ResourceLocation sound) - { - return sound; - } - } + public ResourceLocation filterSound(ResourceLocation sound) { + return sound; + } + } - private static class Christmas extends Holiday - { - private String[] nutcracker = new String[] {"christmas.1", "christmas.2", "christmas.3", "christmas.4", "christmas.5"}; + private static class Christmas extends Holiday { + private String[] nutcracker = new String[] { + "christmas.1", "christmas.2", "christmas.3", "christmas.4", "christmas.5" + }; - @Override - public YearlyDate getDate() - { - return new YearlyDate(1, 8); - } + @Override + public YearlyDate getDate() { + return new YearlyDate(1, 8); + } - @Override - public void onEvent(EntityPlayer player) - { - String themedLines = getThemedLines(new EnumColor[] {EnumColor.DARK_GREEN, EnumColor.DARK_RED}, 13); - player.addChatMessage(new ChatComponentText(themedLines + EnumColor.DARK_BLUE + "[Mekanism]" + themedLines)); - player.addChatMessage(new ChatComponentText(EnumColor.RED + "Merry Christmas, " + EnumColor.DARK_BLUE + player.getCommandSenderName() + EnumColor.RED + "!")); - player.addChatMessage(new ChatComponentText(EnumColor.RED + "May you have plenty of Christmas cheer")); - player.addChatMessage(new ChatComponentText(EnumColor.RED + "and have a relaxing holiday with your")); - player.addChatMessage(new ChatComponentText(EnumColor.RED + "family :)")); - player.addChatMessage(new ChatComponentText(EnumColor.DARK_GREY + "-aidancbrady")); - player.addChatMessage(new ChatComponentText(themedLines + EnumColor.DARK_BLUE + "[=======]" + themedLines)); - } + @Override + public void onEvent(EntityPlayer player) { + String themedLines = getThemedLines( + new EnumColor[] { EnumColor.DARK_GREEN, EnumColor.DARK_RED }, 13 + ); + player.addChatMessage(new ChatComponentText( + themedLines + EnumColor.DARK_BLUE + "[Mekanism]" + themedLines + )); + player.addChatMessage(new ChatComponentText( + EnumColor.RED + "Merry Christmas, " + EnumColor.DARK_BLUE + + player.getCommandSenderName() + EnumColor.RED + "!" + )); + player.addChatMessage(new ChatComponentText( + EnumColor.RED + "May you have plenty of Christmas cheer" + )); + player.addChatMessage(new ChatComponentText( + EnumColor.RED + "and have a relaxing holiday with your" + )); + player.addChatMessage(new ChatComponentText(EnumColor.RED + "family :)")); + player.addChatMessage( + new ChatComponentText(EnumColor.DARK_GREY + "-aidancbrady") + ); + player.addChatMessage(new ChatComponentText( + themedLines + EnumColor.DARK_BLUE + "[=======]" + themedLines + )); + } - @Override - public ResourceLocation filterSound(ResourceLocation sound) - { - if(sound.toString().contains("machine.enrichment")) - { - return new ResourceLocation(sound.toString().replace("machine.enrichment", nutcracker[0])); - } - else if(sound.equals("machine.metalinfuser")) - { - return new ResourceLocation(sound.toString().replace("machine.metalinfuser", nutcracker[1])); - } - else if(sound.equals("machine.purification")) - { - return new ResourceLocation(sound.toString().replace("machine.purification", nutcracker[2])); - } - else if(sound.equals("machine.smelter")) - { - return new ResourceLocation(sound.toString().replace("machine.smelter", nutcracker[3])); - } - else if(sound.equals("machine.dissolution")) - { - return new ResourceLocation(sound.toString().replace("machine.dissolution", nutcracker[4])); - } + @Override + public ResourceLocation filterSound(ResourceLocation sound) { + if (sound.toString().contains("machine.enrichment")) { + return new ResourceLocation( + sound.toString().replace("machine.enrichment", nutcracker[0]) + ); + } else if (sound.equals("machine.metalinfuser")) { + return new ResourceLocation( + sound.toString().replace("machine.metalinfuser", nutcracker[1]) + ); + } else if (sound.equals("machine.purification")) { + return new ResourceLocation( + sound.toString().replace("machine.purification", nutcracker[2]) + ); + } else if (sound.equals("machine.smelter")) { + return new ResourceLocation( + sound.toString().replace("machine.smelter", nutcracker[3]) + ); + } else if (sound.equals("machine.dissolution")) { + return new ResourceLocation( + sound.toString().replace("machine.dissolution", nutcracker[4]) + ); + } - return sound; - } - } + return sound; + } + } - private static class NewYear extends Holiday - { - @Override - public YearlyDate getDate() - { - return new YearlyDate(1, 1); - } + private static class NewYear extends Holiday { + @Override + public YearlyDate getDate() { + return new YearlyDate(1, 1); + } - @Override - public void onEvent(EntityPlayer player) - { - String themedLines = getThemedLines(new EnumColor[] {EnumColor.WHITE, EnumColor.YELLOW}, 13); - player.addChatMessage(new ChatComponentText(themedLines + EnumColor.DARK_BLUE + "[Mekanism]" + themedLines)); - player.addChatMessage(new ChatComponentText(EnumColor.AQUA + "Happy New Year, " + EnumColor.DARK_BLUE + player.getCommandSenderName() + EnumColor.RED + "!")); - player.addChatMessage(new ChatComponentText(EnumColor.AQUA + "Best wishes to you as we enter this")); - player.addChatMessage(new ChatComponentText(EnumColor.AQUA + "new and exciting year of " + calendar.get(Calendar.YEAR) + "! :)")); - player.addChatMessage(new ChatComponentText(EnumColor.DARK_GREY + "-aidancbrady")); - player.addChatMessage(new ChatComponentText(themedLines + EnumColor.DARK_BLUE + "[=======]" + themedLines)); - } - } + @Override + public void onEvent(EntityPlayer player) { + String themedLines = getThemedLines( + new EnumColor[] { EnumColor.WHITE, EnumColor.YELLOW }, 13 + ); + player.addChatMessage(new ChatComponentText( + themedLines + EnumColor.DARK_BLUE + "[Mekanism]" + themedLines + )); + player.addChatMessage(new ChatComponentText( + EnumColor.AQUA + "Happy New Year, " + EnumColor.DARK_BLUE + + player.getCommandSenderName() + EnumColor.RED + "!" + )); + player.addChatMessage(new ChatComponentText( + EnumColor.AQUA + "Best wishes to you as we enter this" + )); + player.addChatMessage(new ChatComponentText( + EnumColor.AQUA + "new and exciting year of " + calendar.get(Calendar.YEAR) + + "! :)" + )); + player.addChatMessage( + new ChatComponentText(EnumColor.DARK_GREY + "-aidancbrady") + ); + player.addChatMessage(new ChatComponentText( + themedLines + EnumColor.DARK_BLUE + "[=======]" + themedLines + )); + } + } - public static enum Month - { - JANUARY("January"), - FEBRUARY("February"), - MARCH("March"), - APRIL("April"), - MAY("May"), - JUNE("June"), - JULY("July"), - AUGUST("August"), - SEPTEMBER("September"), - OCTOBER("October"), - NOVEMBER("November"), - DECEMBER("December"); + public static enum Month { + JANUARY("January"), + FEBRUARY("February"), + MARCH("March"), + APRIL("April"), + MAY("May"), + JUNE("June"), + JULY("July"), + AUGUST("August"), + SEPTEMBER("September"), + OCTOBER("October"), + NOVEMBER("November"), + DECEMBER("December"); - private final String name; + private final String name; - private Month(String n) - { - name = n; - } + private Month(String n) { + name = n; + } - public String getName() - { - return name; - } + public String getName() { + return name; + } - public int month() - { - return ordinal()+1; - } - } + public int month() { + return ordinal() + 1; + } + } - public static class YearlyDate - { - public Month month; + public static class YearlyDate { + public Month month; - public int day; + public int day; - public YearlyDate(Month m, int d) - { - month = m; - day = d; - } + public YearlyDate(Month m, int d) { + month = m; + day = d; + } - public YearlyDate(int m, int d) - { - this(Month.values()[m-1], d); - } + public YearlyDate(int m, int d) { + this(Month.values()[m - 1], d); + } - @Override - public boolean equals(Object obj) - { - return obj instanceof YearlyDate && ((YearlyDate)obj).month == month && ((YearlyDate)obj).day == day; - } + @Override + public boolean equals(Object obj) { + return obj instanceof YearlyDate && ((YearlyDate) obj).month == month + && ((YearlyDate) obj).day == day; + } - @Override - public int hashCode() - { - int code = 1; - code = 31 * code + month.ordinal(); - code = 31 * code + day; - return code; - } - } + @Override + public int hashCode() { + int code = 1; + code = 31 * code + month.ordinal(); + code = 31 * code + day; + return code; + } + } - private static String getThemedLines(EnumColor[] colors, int amount) - { - StringBuilder builder = new StringBuilder(); + private static String getThemedLines(EnumColor[] colors, int amount) { + StringBuilder builder = new StringBuilder(); - for(int i = 0; i < amount; i++) - { - builder.append(colors[i%colors.length] + "-"); - } + for (int i = 0; i < amount; i++) { + builder.append(colors[i % colors.length] + "-"); + } - return builder.toString(); - } + return builder.toString(); + } } diff --git a/src/main/java/mekanism/client/MekKeyHandler.java b/src/main/java/mekanism/client/MekKeyHandler.java index 36dfab718..ed688cb2e 100644 --- a/src/main/java/mekanism/client/MekKeyHandler.java +++ b/src/main/java/mekanism/client/MekKeyHandler.java @@ -1,77 +1,68 @@ package mekanism.client; import net.minecraft.client.settings.KeyBinding; - import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; -public abstract class MekKeyHandler -{ - public KeyBinding[] keyBindings; - public boolean[] keyDown; - public boolean[] repeatings; - public boolean isDummy; +public abstract class MekKeyHandler { + public KeyBinding[] keyBindings; + public boolean[] keyDown; + public boolean[] repeatings; + public boolean isDummy; - /** - * Pass an array of keybindings and a repeat flag for each one - * - * @param bindings - * @param rep - */ - public MekKeyHandler(KeyBinding[] bindings, boolean[] rep) - { - assert keyBindings.length == repeatings.length : "You need to pass two arrays of identical length"; - keyBindings = bindings; - repeatings = rep; - keyDown = new boolean[keyBindings.length]; - } + /** + * Pass an array of keybindings and a repeat flag for each one + * + * @param bindings + * @param rep + */ + public MekKeyHandler(KeyBinding[] bindings, boolean[] rep) { + assert keyBindings.length + == repeatings.length: "You need to pass two arrays of identical length"; + keyBindings = bindings; + repeatings = rep; + keyDown = new boolean[keyBindings.length]; + } - /** - * Register the keys into the system. You will do your own keyboard - * management elsewhere. No events will fire if you use this method - * - * @param bindings - */ - public MekKeyHandler(KeyBinding[] bindings) - { - keyBindings = bindings; - isDummy = true; - } + /** + * Register the keys into the system. You will do your own keyboard + * management elsewhere. No events will fire if you use this method + * + * @param bindings + */ + public MekKeyHandler(KeyBinding[] bindings) { + keyBindings = bindings; + isDummy = true; + } - public static boolean getIsKeyPressed(KeyBinding keyBinding) - { - int keyCode = keyBinding.getKeyCode(); - return keyCode < 0 ? Mouse.isButtonDown(keyCode + 100) : Keyboard.isKeyDown(keyCode); - } + public static boolean getIsKeyPressed(KeyBinding keyBinding) { + int keyCode = keyBinding.getKeyCode(); + return keyCode < 0 ? Mouse.isButtonDown(keyCode + 100) + : Keyboard.isKeyDown(keyCode); + } - public KeyBinding[] getKeyBindings () - { - return keyBindings; - } + public KeyBinding[] getKeyBindings() { + return keyBindings; + } - public void keyTick() - { - for(int i = 0; i < keyBindings.length; i++) - { - KeyBinding keyBinding = keyBindings[i]; - boolean state = keyBinding.getIsKeyPressed(); + public void keyTick() { + for (int i = 0; i < keyBindings.length; i++) { + KeyBinding keyBinding = keyBindings[i]; + boolean state = keyBinding.getIsKeyPressed(); - if(state != keyDown[i] || (state && repeatings[i])) - { - if(state) - { - keyDown(keyBinding, state == keyDown[i]); - } - else { - keyUp(keyBinding); - } - - keyDown[i] = state; - } - } - } + if (state != keyDown[i] || (state && repeatings[i])) { + if (state) { + keyDown(keyBinding, state == keyDown[i]); + } else { + keyUp(keyBinding); + } - public abstract void keyDown(KeyBinding kb, boolean isRepeat); + keyDown[i] = state; + } + } + } - public abstract void keyUp(KeyBinding kb); + public abstract void keyDown(KeyBinding kb, boolean isRepeat); + + public abstract void keyUp(KeyBinding kb); } \ No newline at end of file diff --git a/src/main/java/mekanism/client/MekanismClient.java b/src/main/java/mekanism/client/MekanismClient.java index 03b0bde1d..94eeea9f6 100644 --- a/src/main/java/mekanism/client/MekanismClient.java +++ b/src/main/java/mekanism/client/MekanismClient.java @@ -17,59 +17,55 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.settings.KeyBinding; import net.minecraftforge.common.MinecraftForge; -public class MekanismClient extends Mekanism -{ - public static Map clientSecurityMap = new HashMap(); - - public static VoiceClient voiceClient; +public class MekanismClient extends Mekanism { + public static Map clientSecurityMap + = new HashMap(); - public static long ticksPassed = 0; + public static VoiceClient voiceClient; - public static void updateKey(KeyBinding key, int type) - { - boolean down = Minecraft.getMinecraft().currentScreen == null ? key.getIsKeyPressed() : false; + public static long ticksPassed = 0; - if(down != keyMap.has(Minecraft.getMinecraft().thePlayer, type)) - { - Mekanism.packetHandler.sendToServer(new KeyMessage(type, down)); - keyMap.update(Minecraft.getMinecraft().thePlayer, type, down); - } - } + public static void updateKey(KeyBinding key, int type) { + boolean down = Minecraft.getMinecraft().currentScreen == null + ? key.getIsKeyPressed() + : false; - public static void reset() - { - clientSecurityMap.clear(); - - if(general.voiceServerEnabled) - { - if(MekanismClient.voiceClient != null) - { - MekanismClient.voiceClient.disconnect(); - MekanismClient.voiceClient = null; - } - } + if (down != keyMap.has(Minecraft.getMinecraft().thePlayer, type)) { + Mekanism.packetHandler.sendToServer(new KeyMessage(type, down)); + keyMap.update(Minecraft.getMinecraft().thePlayer, type, down); + } + } - ClientTickHandler.tickingSet.clear(); + public static void reset() { + clientSecurityMap.clear(); - MekanismAPI.getBoxIgnore().clear(); - MinecraftForge.EVENT_BUS.post(new BoxBlacklistEvent()); + if (general.voiceServerEnabled) { + if (MekanismClient.voiceClient != null) { + MekanismClient.voiceClient.disconnect(); + MekanismClient.voiceClient = null; + } + } - Mekanism.jetpackOn.clear(); - Mekanism.gasmaskOn.clear(); - Mekanism.flamethrowerActive.clear(); - Mekanism.activeVibrators.clear(); - - SynchronizedBoilerData.clientHotMap.clear(); - - for(IModule module : Mekanism.modulesLoaded) - { - module.resetClient(); - } + ClientTickHandler.tickingSet.clear(); - SoundHandler.soundMaps.clear(); + MekanismAPI.getBoxIgnore().clear(); + MinecraftForge.EVENT_BUS.post(new BoxBlacklistEvent()); - Mekanism.proxy.loadConfiguration(); + Mekanism.jetpackOn.clear(); + Mekanism.gasmaskOn.clear(); + Mekanism.flamethrowerActive.clear(); + Mekanism.activeVibrators.clear(); - Mekanism.logger.info("Reloaded config."); - } + SynchronizedBoilerData.clientHotMap.clear(); + + for (IModule module : Mekanism.modulesLoaded) { + module.resetClient(); + } + + SoundHandler.soundMaps.clear(); + + Mekanism.proxy.loadConfiguration(); + + Mekanism.logger.info("Reloaded config."); + } } diff --git a/src/main/java/mekanism/client/MekanismKeyHandler.java b/src/main/java/mekanism/client/MekanismKeyHandler.java index 2d7887e02..99deb8c47 100644 --- a/src/main/java/mekanism/client/MekanismKeyHandler.java +++ b/src/main/java/mekanism/client/MekanismKeyHandler.java @@ -1,5 +1,12 @@ package mekanism.client; +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.client.registry.ClientRegistry; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.InputEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.EnumColor; import mekanism.api.util.StackUtils; import mekanism.client.sound.SoundHandler; @@ -30,135 +37,154 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ChatComponentText; - import org.lwjgl.input.Keyboard; -import cpw.mods.fml.client.FMLClientHandler; -import cpw.mods.fml.client.registry.ClientRegistry; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.InputEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class MekanismKeyHandler extends MekKeyHandler -{ - public static final String keybindCategory = "Mekanism"; - public static KeyBinding modeSwitchKey = new KeyBinding("Mekanism " + LangUtils.localize("key.mode"), Keyboard.KEY_M, keybindCategory); - public static KeyBinding armorModeSwitchKey = new KeyBinding("Mekanism " + LangUtils.localize("key.armorMode"), Keyboard.KEY_F, keybindCategory); - public static KeyBinding voiceKey = new KeyBinding("Mekanism " + LangUtils.localize("key.voice"), Keyboard.KEY_U, keybindCategory); - public static KeyBinding sneakKey = Minecraft.getMinecraft().gameSettings.keyBindSneak; - public static KeyBinding jumpKey = Minecraft.getMinecraft().gameSettings.keyBindJump; +public class MekanismKeyHandler extends MekKeyHandler { + public static final String keybindCategory = "Mekanism"; + public static KeyBinding modeSwitchKey = new KeyBinding( + "Mekanism " + LangUtils.localize("key.mode"), Keyboard.KEY_M, keybindCategory + ); + public static KeyBinding armorModeSwitchKey = new KeyBinding( + "Mekanism " + LangUtils.localize("key.armorMode"), Keyboard.KEY_F, keybindCategory + ); + public static KeyBinding voiceKey = new KeyBinding( + "Mekanism " + LangUtils.localize("key.voice"), Keyboard.KEY_U, keybindCategory + ); + public static KeyBinding sneakKey + = Minecraft.getMinecraft().gameSettings.keyBindSneak; + public static KeyBinding jumpKey = Minecraft.getMinecraft().gameSettings.keyBindJump; - public MekanismKeyHandler() - { - super(new KeyBinding[] {modeSwitchKey, armorModeSwitchKey, voiceKey}, new boolean[] {false, false, true}); - - ClientRegistry.registerKeyBinding(modeSwitchKey); - ClientRegistry.registerKeyBinding(armorModeSwitchKey); - ClientRegistry.registerKeyBinding(voiceKey); - - FMLCommonHandler.instance().bus().register(this); - } - - @SubscribeEvent - public void onTick(InputEvent event) - { - keyTick(); - } + public MekanismKeyHandler() { + super( + new KeyBinding[] { modeSwitchKey, armorModeSwitchKey, voiceKey }, + new boolean[] { false, false, true } + ); - @Override - public void keyDown(KeyBinding kb, boolean isRepeat) - { - if(kb == modeSwitchKey) - { - EntityPlayer player = FMLClientHandler.instance().getClient().thePlayer; - ItemStack toolStack = player.getCurrentEquippedItem(); + ClientRegistry.registerKeyBinding(modeSwitchKey); + ClientRegistry.registerKeyBinding(armorModeSwitchKey); + ClientRegistry.registerKeyBinding(voiceKey); - Item item = StackUtils.getItem(toolStack); - - if(player.isSneaking() && item instanceof ItemConfigurator) - { - ItemConfigurator configurator = (ItemConfigurator)item; + FMLCommonHandler.instance().bus().register(this); + } - int toSet = configurator.getState(toolStack).ordinal() < ConfiguratorMode.values().length-1 ? configurator.getState(toolStack).ordinal() + 1 : 0; - configurator.setState(toolStack, ConfiguratorMode.values()[toSet]); - Mekanism.packetHandler.sendToServer(new ConfiguratorStateMessage(configurator.getState(toolStack))); - player.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + LangUtils.localize("tooltip.configureState") + ": " + configurator.getColor(configurator.getState(toolStack)) + configurator.getStateDisplay(configurator.getState(toolStack)))); - } - else if(player.isSneaking() && item instanceof ItemElectricBow) - { - ItemElectricBow bow = (ItemElectricBow)item; + @SubscribeEvent + public void onTick(InputEvent event) { + keyTick(); + } - bow.setFireState(toolStack, !bow.getFireState(toolStack)); - Mekanism.packetHandler.sendToServer(new ElectricBowStateMessage(bow.getFireState(toolStack))); - player.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + LangUtils.localize("tooltip.fireMode") + ": " + (bow.getFireState(toolStack) ? EnumColor.DARK_GREEN : EnumColor.DARK_RED) + LangUtils.transOnOff(bow.getFireState(toolStack)))); - } - else if(player.isSneaking() && item instanceof ItemBlockMachine) - { - ItemBlockMachine machine = (ItemBlockMachine)item; + @Override + public void keyDown(KeyBinding kb, boolean isRepeat) { + if (kb == modeSwitchKey) { + EntityPlayer player = FMLClientHandler.instance().getClient().thePlayer; + ItemStack toolStack = player.getCurrentEquippedItem(); - if(MachineType.get(toolStack) == MachineType.FLUID_TANK) - { - machine.setBucketMode(toolStack, !machine.getBucketMode(toolStack)); - Mekanism.packetHandler.sendToServer(new PortableTankStateMessage(machine.getBucketMode(toolStack))); - player.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + LangUtils.localize("tooltip.portableTank.bucketMode") + ": " + (machine.getBucketMode(toolStack) ? EnumColor.DARK_GREEN : EnumColor.DARK_RED) + LangUtils.transOnOff(machine.getBucketMode(toolStack)))); - } - } - else if(player.isSneaking() && item instanceof ItemWalkieTalkie) - { - ItemWalkieTalkie wt = (ItemWalkieTalkie)item; + Item item = StackUtils.getItem(toolStack); - if(wt.getOn(toolStack)) - { - int newChan = wt.getChannel(toolStack) < 9 ? wt.getChannel(toolStack) + 1 : 1; - wt.setChannel(toolStack, newChan); - Mekanism.packetHandler.sendToServer(new WalkieTalkieStateMessage(newChan)); - SoundHandler.playSound("mekanism:etc.Ding"); - } - } - else if(player.isSneaking() && item instanceof ItemFlamethrower) - { - ItemFlamethrower flamethrower = (ItemFlamethrower)item; + if (player.isSneaking() && item instanceof ItemConfigurator) { + ItemConfigurator configurator = (ItemConfigurator) item; + + int toSet = configurator.getState(toolStack).ordinal() + < ConfiguratorMode.values().length - 1 + ? configurator.getState(toolStack).ordinal() + 1 + : 0; + configurator.setState(toolStack, ConfiguratorMode.values()[toSet]); + Mekanism.packetHandler.sendToServer( + new ConfiguratorStateMessage(configurator.getState(toolStack)) + ); + player.addChatMessage(new ChatComponentText( + EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + + LangUtils.localize("tooltip.configureState") + ": " + + configurator.getColor(configurator.getState(toolStack)) + + configurator.getStateDisplay(configurator.getState(toolStack)) + )); + } else if (player.isSneaking() && item instanceof ItemElectricBow) { + ItemElectricBow bow = (ItemElectricBow) item; + + bow.setFireState(toolStack, !bow.getFireState(toolStack)); + Mekanism.packetHandler.sendToServer( + new ElectricBowStateMessage(bow.getFireState(toolStack)) + ); + player.addChatMessage(new ChatComponentText( + EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + + LangUtils.localize("tooltip.fireMode") + ": " + + (bow.getFireState(toolStack) ? EnumColor.DARK_GREEN + : EnumColor.DARK_RED) + + LangUtils.transOnOff(bow.getFireState(toolStack)) + )); + } else if (player.isSneaking() && item instanceof ItemBlockMachine) { + ItemBlockMachine machine = (ItemBlockMachine) item; + + if (MachineType.get(toolStack) == MachineType.FLUID_TANK) { + machine.setBucketMode(toolStack, !machine.getBucketMode(toolStack)); + Mekanism.packetHandler.sendToServer( + new PortableTankStateMessage(machine.getBucketMode(toolStack)) + ); + player.addChatMessage(new ChatComponentText( + EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + + LangUtils.localize("tooltip.portableTank.bucketMode") + ": " + + (machine.getBucketMode(toolStack) ? EnumColor.DARK_GREEN + : EnumColor.DARK_RED) + + LangUtils.transOnOff(machine.getBucketMode(toolStack)) + )); + } + } else if (player.isSneaking() && item instanceof ItemWalkieTalkie) { + ItemWalkieTalkie wt = (ItemWalkieTalkie) item; + + if (wt.getOn(toolStack)) { + int newChan + = wt.getChannel(toolStack) < 9 ? wt.getChannel(toolStack) + 1 : 1; + wt.setChannel(toolStack, newChan); + Mekanism.packetHandler.sendToServer( + new WalkieTalkieStateMessage(newChan) + ); + SoundHandler.playSound("mekanism:etc.Ding"); + } + } else if (player.isSneaking() && item instanceof ItemFlamethrower) { + ItemFlamethrower flamethrower = (ItemFlamethrower) item; flamethrower.incrementMode(toolStack); - Mekanism.packetHandler.sendToServer(new PacketFlamethrowerData.FlamethrowerDataMessage(PacketFlamethrowerData.FlamethrowerPacket.MODE, null, false)); - player.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + LangUtils.localize("tooltip.flamethrower.modeBump") + ": " + flamethrower.getMode(toolStack).getName())); + Mekanism.packetHandler.sendToServer( + new PacketFlamethrowerData.FlamethrowerDataMessage( + PacketFlamethrowerData.FlamethrowerPacket.MODE, null, false + ) + ); + player.addChatMessage(new ChatComponentText( + EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + + LangUtils.localize("tooltip.flamethrower.modeBump") + ": " + + flamethrower.getMode(toolStack).getName() + )); } - } - else if(kb == armorModeSwitchKey) - { - EntityPlayer player = FMLClientHandler.instance().getClient().thePlayer; - ItemStack chestStack = player.getCurrentArmor(2); - Item chestItem = StackUtils.getItem(chestStack); + } else if (kb == armorModeSwitchKey) { + EntityPlayer player = FMLClientHandler.instance().getClient().thePlayer; + ItemStack chestStack = player.getCurrentArmor(2); + Item chestItem = StackUtils.getItem(chestStack); - if(chestItem instanceof ItemJetpack) - { - ItemJetpack jetpack = (ItemJetpack)chestItem; + if (chestItem instanceof ItemJetpack) { + ItemJetpack jetpack = (ItemJetpack) chestItem; - if(player.isSneaking()) - { - jetpack.setMode(chestStack, JetpackMode.DISABLED); - } - else { - jetpack.incrementMode(chestStack); - } + if (player.isSneaking()) { + jetpack.setMode(chestStack, JetpackMode.DISABLED); + } else { + jetpack.incrementMode(chestStack); + } - Mekanism.packetHandler.sendToServer(new JetpackDataMessage(JetpackPacket.MODE, null, player.isSneaking())); - SoundHandler.playSound("mekanism:etc.Hydraulic"); - } - else if(chestItem instanceof ItemScubaTank) - { - ItemScubaTank scubaTank = (ItemScubaTank)chestItem; + Mekanism.packetHandler.sendToServer( + new JetpackDataMessage(JetpackPacket.MODE, null, player.isSneaking()) + ); + SoundHandler.playSound("mekanism:etc.Hydraulic"); + } else if (chestItem instanceof ItemScubaTank) { + ItemScubaTank scubaTank = (ItemScubaTank) chestItem; - scubaTank.toggleFlowing(chestStack); - Mekanism.packetHandler.sendToServer(new ScubaTankDataMessage(ScubaTankPacket.MODE, null, false)); - SoundHandler.playSound("mekanism:etc.Hydraulic"); - } - } - } + scubaTank.toggleFlowing(chestStack); + Mekanism.packetHandler.sendToServer( + new ScubaTankDataMessage(ScubaTankPacket.MODE, null, false) + ); + SoundHandler.playSound("mekanism:etc.Hydraulic"); + } + } + } - @Override - public void keyUp(KeyBinding kb) {} + @Override + public void keyUp(KeyBinding kb) {} } diff --git a/src/main/java/mekanism/client/SparkleAnimation.java b/src/main/java/mekanism/client/SparkleAnimation.java index 1222bebc5..f6b5553dc 100644 --- a/src/main/java/mekanism/client/SparkleAnimation.java +++ b/src/main/java/mekanism/client/SparkleAnimation.java @@ -4,95 +4,138 @@ import java.util.HashSet; import java.util.Random; import java.util.Set; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; -import mekanism.api.MekanismConfig.general; import mekanism.api.MekanismConfig.client; +import mekanism.api.MekanismConfig.general; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class SparkleAnimation -{ - public TileEntity pointer; +public class SparkleAnimation { + public TileEntity pointer; - public Random random = new Random(); + public Random random = new Random(); - public Set iteratedNodes = new HashSet(); - - public INodeChecker nodeChecker; + public Set iteratedNodes = new HashSet(); - public SparkleAnimation(TileEntity tileEntity, INodeChecker checker) - { - pointer = tileEntity; - nodeChecker = checker; - } + public INodeChecker nodeChecker; - public void run() - { - try { - if(general.dynamicTankEasterEgg) - { - pointer.getWorldObj().playSound(pointer.xCoord, pointer.yCoord, pointer.zCoord, "mekanism:etc.cj", 1F, 1F, false); - } + public SparkleAnimation(TileEntity tileEntity, INodeChecker checker) { + pointer = tileEntity; + nodeChecker = checker; + } - loop(pointer); - } catch(Exception e) {} - - try { - new Thread() { - @Override - public void run() - { - World world = pointer.getWorldObj(); - int count = client.multiblockSparkleIntensity; - - for(Coord4D coord : iteratedNodes) - { - for(int i = 0; i < count; i++) - { - world.spawnParticle("reddust", coord.xCoord + random.nextDouble(), coord.yCoord + -.01, coord.zCoord + random.nextDouble(), 0, 0, 0); - world.spawnParticle("reddust", coord.xCoord + random.nextDouble(), coord.yCoord + 1.01, coord.zCoord + random.nextDouble(), 0, 0, 0); - world.spawnParticle("reddust", coord.xCoord + random.nextDouble(), coord.yCoord + random.nextDouble(), coord.zCoord + -.01, 0, 0, 0); - world.spawnParticle("reddust", coord.xCoord + random.nextDouble(), coord.yCoord + random.nextDouble(), coord.zCoord + 1.01, 0, 0, 0); - world.spawnParticle("reddust", coord.xCoord + -.01, coord.yCoord + random.nextDouble(), coord.zCoord + random.nextDouble(), 0, 0, 0); - world.spawnParticle("reddust", coord.xCoord + 1.01, coord.yCoord + random.nextDouble(), coord.zCoord + random.nextDouble(), 0, 0, 0); - } - } - } - }.start(); - } catch(Exception e) {} - } + public void run() { + try { + if (general.dynamicTankEasterEgg) { + pointer.getWorldObj().playSound( + pointer.xCoord, + pointer.yCoord, + pointer.zCoord, + "mekanism:etc.cj", + 1F, + 1F, + false + ); + } - public void loop(TileEntity tileEntity) - { - iteratedNodes.add(Coord4D.get(tileEntity)); + loop(pointer); + } catch (Exception e) {} - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - Coord4D coord = Coord4D.get(tileEntity).getFromSide(side); - - if(coord.exists(pointer.getWorldObj())) - { - TileEntity tile = coord.getTileEntity(pointer.getWorldObj()); - - if(tile != null && isNode(tile) && !iteratedNodes.contains(coord)) - { - loop(tile); - } - } - } - } - - public boolean isNode(TileEntity tile) - { - return nodeChecker.isNode(tile); - } - - public static interface INodeChecker - { - public boolean isNode(TileEntity tile); - } + try { + new Thread() { + @Override + public void run() { + World world = pointer.getWorldObj(); + int count = client.multiblockSparkleIntensity; + + for (Coord4D coord : iteratedNodes) { + for (int i = 0; i < count; i++) { + world.spawnParticle( + "reddust", + coord.xCoord + random.nextDouble(), + coord.yCoord + -.01, + coord.zCoord + random.nextDouble(), + 0, + 0, + 0 + ); + world.spawnParticle( + "reddust", + coord.xCoord + random.nextDouble(), + coord.yCoord + 1.01, + coord.zCoord + random.nextDouble(), + 0, + 0, + 0 + ); + world.spawnParticle( + "reddust", + coord.xCoord + random.nextDouble(), + coord.yCoord + random.nextDouble(), + coord.zCoord + -.01, + 0, + 0, + 0 + ); + world.spawnParticle( + "reddust", + coord.xCoord + random.nextDouble(), + coord.yCoord + random.nextDouble(), + coord.zCoord + 1.01, + 0, + 0, + 0 + ); + world.spawnParticle( + "reddust", + coord.xCoord + -.01, + coord.yCoord + random.nextDouble(), + coord.zCoord + random.nextDouble(), + 0, + 0, + 0 + ); + world.spawnParticle( + "reddust", + coord.xCoord + 1.01, + coord.yCoord + random.nextDouble(), + coord.zCoord + random.nextDouble(), + 0, + 0, + 0 + ); + } + } + } + }.start(); + } catch (Exception e) {} + } + + public void loop(TileEntity tileEntity) { + iteratedNodes.add(Coord4D.get(tileEntity)); + + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + Coord4D coord = Coord4D.get(tileEntity).getFromSide(side); + + if (coord.exists(pointer.getWorldObj())) { + TileEntity tile = coord.getTileEntity(pointer.getWorldObj()); + + if (tile != null && isNode(tile) && !iteratedNodes.contains(coord)) { + loop(tile); + } + } + } + } + + public boolean isNode(TileEntity tile) { + return nodeChecker.isNode(tile); + } + + public static interface INodeChecker { + public boolean isNode(TileEntity tile); + } } diff --git a/src/main/java/mekanism/client/entity/EntityLaser.java b/src/main/java/mekanism/client/entity/EntityLaser.java index c91db933b..dd74fcb5d 100644 --- a/src/main/java/mekanism/client/entity/EntityLaser.java +++ b/src/main/java/mekanism/client/entity/EntityLaser.java @@ -1,5 +1,7 @@ package mekanism.client.entity; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Pos3D; import mekanism.client.render.MekanismRenderer; import net.minecraft.client.Minecraft; @@ -8,92 +10,112 @@ import net.minecraft.client.renderer.Tessellator; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class EntityLaser extends EntityFX -{ - double length; - ForgeDirection direction; +public class EntityLaser extends EntityFX { + double length; + ForgeDirection direction; - public EntityLaser(World world, Pos3D start, Pos3D end, ForgeDirection dir, double energy) - { - super(world, (start.xPos + end.xPos)/2D, (start.yPos + end.yPos)/2D, (start.zPos+end.zPos)/2D); - particleMaxAge = 5; - particleRed = 1; - particleGreen = 0; - particleBlue = 0; - particleAlpha = 0.1F; - particleScale = (float) Math.min(energy / 50000, 0.6); - length = end.distance(start); - direction = dir; - } + public EntityLaser( + World world, Pos3D start, Pos3D end, ForgeDirection dir, double energy + ) { + super( + world, + (start.xPos + end.xPos) / 2D, + (start.yPos + end.yPos) / 2D, + (start.zPos + end.zPos) / 2D + ); + particleMaxAge = 5; + particleRed = 1; + particleGreen = 0; + particleBlue = 0; + particleAlpha = 0.1F; + particleScale = (float) Math.min(energy / 50000, 0.6); + length = end.distance(start); + direction = dir; + } - @Override - public void renderParticle(Tessellator tessellator, float partialTick, float rotationX, float rotationXZ, float rotationZ, float rotationYZ, float rotationXY) - { - tessellator.draw(); + @Override + public void renderParticle( + Tessellator tessellator, + float partialTick, + float rotationX, + float rotationXZ, + float rotationZ, + float rotationYZ, + float rotationXY + ) { + tessellator.draw(); - GL11.glPushMatrix(); - GL11.glPushAttrib(GL11.GL_POLYGON_BIT + GL11.GL_ENABLE_BIT); - GL11.glDisable(GL11.GL_CULL_FACE); - MekanismRenderer.glowOn(); - Minecraft.getMinecraft().renderEngine.bindTexture(new ResourceLocation("mekanism", "particles/laser.png")); + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_POLYGON_BIT + GL11.GL_ENABLE_BIT); + GL11.glDisable(GL11.GL_CULL_FACE); + MekanismRenderer.glowOn(); + Minecraft.getMinecraft().renderEngine.bindTexture( + new ResourceLocation("mekanism", "particles/laser.png") + ); - float newX = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)partialTick - interpPosX); - float newY = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)partialTick - interpPosY); - float newZ = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)partialTick - interpPosZ); + float newX = (float + ) (this.prevPosX + (this.posX - this.prevPosX) * (double) partialTick - interpPosX + ); + float newY = (float + ) (this.prevPosY + (this.posY - this.prevPosY) * (double) partialTick - interpPosY + ); + float newZ = (float + ) (this.prevPosZ + (this.posZ - this.prevPosZ) * (double) partialTick - interpPosZ + ); - GL11.glTranslatef(newX, newY, newZ); + GL11.glTranslatef(newX, newY, newZ); - switch(direction) - { - case UP: - case DOWN: - default: - break; - case WEST: - case EAST: - GL11.glRotated(90, 0, 0, 1); - break; - case NORTH: - case SOUTH: - GL11.glRotated(90, 1, 0, 0); - break; - } - GL11.glRotated(45, 0, 1, 0); - tessellator.startDrawingQuads(); - tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, particleAlpha); - tessellator.addVertexWithUV(-particleScale, -length/2, 0, 0, 0); - tessellator.addVertexWithUV(-particleScale, length/2, 0, 0, 1); - tessellator.addVertexWithUV(particleScale, length/2, 0, 1, 1); - tessellator.addVertexWithUV(particleScale, -length/2, 0, 1, 0); - tessellator.draw(); + switch (direction) { + case UP: + case DOWN: + default: + break; + case WEST: + case EAST: + GL11.glRotated(90, 0, 0, 1); + break; + case NORTH: + case SOUTH: + GL11.glRotated(90, 1, 0, 0); + break; + } + GL11.glRotated(45, 0, 1, 0); + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_F( + particleRed, particleGreen, particleBlue, particleAlpha + ); + tessellator.addVertexWithUV(-particleScale, -length / 2, 0, 0, 0); + tessellator.addVertexWithUV(-particleScale, length / 2, 0, 0, 1); + tessellator.addVertexWithUV(particleScale, length / 2, 0, 1, 1); + tessellator.addVertexWithUV(particleScale, -length / 2, 0, 1, 0); + tessellator.draw(); - GL11.glRotated(90, 0, 1, 0); - tessellator.startDrawingQuads(); - tessellator.setColorRGBA_F(particleRed, particleGreen, particleBlue, particleAlpha); - tessellator.addVertexWithUV(-particleScale, -length/2, 0, 0, 0); - tessellator.addVertexWithUV(-particleScale, length/2, 0, 0, 1); - tessellator.addVertexWithUV(particleScale, length/2, 0, 1, 1); - tessellator.addVertexWithUV(particleScale, -length/2, 0, 1, 0); - tessellator.draw(); - - MekanismRenderer.glowOff(); - GL11.glPopAttrib(); - GL11.glPopMatrix(); + GL11.glRotated(90, 0, 1, 0); + tessellator.startDrawingQuads(); + tessellator.setColorRGBA_F( + particleRed, particleGreen, particleBlue, particleAlpha + ); + tessellator.addVertexWithUV(-particleScale, -length / 2, 0, 0, 0); + tessellator.addVertexWithUV(-particleScale, length / 2, 0, 0, 1); + tessellator.addVertexWithUV(particleScale, length / 2, 0, 1, 1); + tessellator.addVertexWithUV(particleScale, -length / 2, 0, 1, 0); + tessellator.draw(); - Minecraft.getMinecraft().renderEngine.bindTexture(MekanismRenderer.getBlocksTexture()); - tessellator.startDrawingQuads(); - } + MekanismRenderer.glowOff(); + GL11.glPopAttrib(); + GL11.glPopMatrix(); - @Override - public int getFXLayer() - { - return 1; - } + Minecraft.getMinecraft().renderEngine.bindTexture( + MekanismRenderer.getBlocksTexture() + ); + tessellator.startDrawingQuads(); + } + + @Override + public int getFXLayer() { + return 1; + } } diff --git a/src/main/java/mekanism/client/gui/ConfigGuiFactory.java b/src/main/java/mekanism/client/gui/ConfigGuiFactory.java index 48138f6bd..16f6d9783 100644 --- a/src/main/java/mekanism/client/gui/ConfigGuiFactory.java +++ b/src/main/java/mekanism/client/gui/ConfigGuiFactory.java @@ -2,33 +2,26 @@ package mekanism.client.gui; import java.util.Set; +import cpw.mods.fml.client.IModGuiFactory; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; -import cpw.mods.fml.client.IModGuiFactory; -public class ConfigGuiFactory implements IModGuiFactory -{ - @Override - public void initialize(Minecraft minecraftInstance) - { +public class ConfigGuiFactory implements IModGuiFactory { + @Override + public void initialize(Minecraft minecraftInstance) {} - } + @Override + public Class mainConfigGuiClass() { + return GuiMekanismConfig.class; + } - @Override - public Class mainConfigGuiClass() - { - return GuiMekanismConfig.class; - } + @Override + public Set runtimeGuiCategories() { + return null; + } - @Override - public Set runtimeGuiCategories() - { - return null; - } - - @Override - public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) - { - return null; - } + @Override + public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) { + return null; + } } diff --git a/src/main/java/mekanism/client/gui/GuiAdvancedElectricMachine.java b/src/main/java/mekanism/client/gui/GuiAdvancedElectricMachine.java index c66857b35..025eea7d9 100644 --- a/src/main/java/mekanism/client/gui/GuiAdvancedElectricMachine.java +++ b/src/main/java/mekanism/client/gui/GuiAdvancedElectricMachine.java @@ -2,6 +2,8 @@ package mekanism.client.gui; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.gas.GasStack; import mekanism.api.util.ListUtils; import mekanism.client.gui.element.GuiElement.IInfoHandler; @@ -24,105 +26,128 @@ import mekanism.common.tile.TileEntityAdvancedElectricMachine; import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import net.minecraft.entity.player.InventoryPlayer; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiAdvancedElectricMachine extends GuiMekanism -{ - public TileEntityAdvancedElectricMachine tileEntity; +public class GuiAdvancedElectricMachine extends GuiMekanism { + public TileEntityAdvancedElectricMachine tileEntity; - public GuiAdvancedElectricMachine(InventoryPlayer inventory, TileEntityAdvancedElectricMachine tentity) - { - super(tentity, new ContainerAdvancedElectricMachine(inventory, tentity)); - tileEntity = tentity; + public GuiAdvancedElectricMachine( + InventoryPlayer inventory, TileEntityAdvancedElectricMachine tentity + ) { + super(tentity, new ContainerAdvancedElectricMachine(inventory, tentity)); + tileEntity = tentity; - guiElements.add(new GuiRedstoneControl(this, tileEntity, tileEntity.guiLocation)); - guiElements.add(new GuiUpgradeTab(this, tileEntity, tileEntity.guiLocation)); - guiElements.add(new GuiSecurityTab(this, tileEntity, tileEntity.guiLocation)); - guiElements.add(new GuiSideConfigurationTab(this, tileEntity, tileEntity.guiLocation)); - guiElements.add(new GuiTransporterConfigTab(this, 34, tileEntity, tileEntity.guiLocation)); - guiElements.add(new GuiPowerBar(this, tileEntity, tileEntity.guiLocation, 164, 15)); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() { - @Override - public List getInfo() - { - String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.energyPerTick); - return ListUtils.asList(LangUtils.localize("gui.using") + ": " + multiplier + "/t", LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); - } - }, this, tileEntity.guiLocation)); + guiElements.add(new GuiRedstoneControl(this, tileEntity, tileEntity.guiLocation)); + guiElements.add(new GuiUpgradeTab(this, tileEntity, tileEntity.guiLocation)); + guiElements.add(new GuiSecurityTab(this, tileEntity, tileEntity.guiLocation)); + guiElements.add( + new GuiSideConfigurationTab(this, tileEntity, tileEntity.guiLocation) + ); + guiElements.add( + new GuiTransporterConfigTab(this, 34, tileEntity, tileEntity.guiLocation) + ); + guiElements.add(new GuiPowerBar(this, tileEntity, tileEntity.guiLocation, 164, 15) + ); + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() { + String multiplier + = MekanismUtils.getEnergyDisplay(tileEntity.energyPerTick); + return ListUtils.asList( + LangUtils.localize("gui.using") + ": " + multiplier + "/t", + LangUtils.localize("gui.needed") + ": " + + MekanismUtils.getEnergyDisplay( + tileEntity.getMaxEnergy() - tileEntity.getEnergy() + ) + ); + } + }, this, tileEntity.guiLocation)); - guiElements.add(new GuiSlot(SlotType.INPUT, this, tileEntity.guiLocation, 55, 16)); - guiElements.add(new GuiSlot(SlotType.POWER, this, tileEntity.guiLocation, 30, 34).with(SlotOverlay.POWER)); - guiElements.add(new GuiSlot(SlotType.EXTRA, this, tileEntity.guiLocation, 55, 52)); - guiElements.add(new GuiSlot(SlotType.OUTPUT_LARGE, this, tileEntity.guiLocation, 111, 30)); + guiElements.add(new GuiSlot(SlotType.INPUT, this, tileEntity.guiLocation, 55, 16) + ); + guiElements.add(new GuiSlot(SlotType.POWER, this, tileEntity.guiLocation, 30, 34) + .with(SlotOverlay.POWER)); + guiElements.add(new GuiSlot(SlotType.EXTRA, this, tileEntity.guiLocation, 55, 52) + ); + guiElements.add( + new GuiSlot(SlotType.OUTPUT_LARGE, this, tileEntity.guiLocation, 111, 30) + ); - guiElements.add(new GuiProgress(new IProgressInfoHandler() - { - @Override - public double getProgress() - { - return tileEntity.getScaledProgress(); - } - }, getProgressType(), this, tileEntity.guiLocation, 77, 37)); - } - - public ProgressBar getProgressType() - { - return ProgressBar.BLUE; - } + guiElements.add(new GuiProgress(new IProgressInfoHandler() { + @Override + public double getProgress() { + return tileEntity.getScaledProgress(); + } + }, getProgressType(), this, tileEntity.guiLocation, 77, 37)); + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + public ProgressBar getProgressType() { + return ProgressBar.BLUE; + } - fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize/2)-(fontRendererObj.getStringWidth(tileEntity.getInventoryName())/2), 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - if(xAxis >= 61 && xAxis <= 67 && yAxis >= 37 && yAxis <= 49) - { - drawCreativeTabHoveringText(tileEntity.gasTank.getGas() != null ? tileEntity.gasTank.getGas().getGas().getLocalizedName() + ": " + tileEntity.gasTank.getStored() : LangUtils.localize("gui.none"), xAxis, yAxis); - } + fontRendererObj.drawString( + tileEntity.getInventoryName(), + (xSize / 2) + - (fontRendererObj.getStringWidth(tileEntity.getInventoryName()) / 2), + 6, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040 + ); - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + if (xAxis >= 61 && xAxis <= 67 && yAxis >= 37 && yAxis <= 49) { + drawCreativeTabHoveringText( + tileEntity.gasTank.getGas() != null + ? tileEntity.gasTank.getGas().getGas().getLocalizedName() + ": " + + tileEntity.gasTank.getStored() + : LangUtils.localize("gui.none"), + xAxis, + yAxis + ); + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(tileEntity.guiLocation); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - int displayInt; + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture(tileEntity.guiLocation); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - if(tileEntity.getScaledGasLevel(12) > 0) - { - displayInt = tileEntity.getScaledGasLevel(12); - displayGauge(61, 37 + 12 - displayInt, 6, displayInt, tileEntity.gasTank.getGas()); - } + int displayInt; - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } + if (tileEntity.getScaledGasLevel(12) > 0) { + displayInt = tileEntity.getScaledGasLevel(12); + displayGauge( + 61, 37 + 12 - displayInt, 6, displayInt, tileEntity.gasTank.getGas() + ); + } - public void displayGauge(int xPos, int yPos, int sizeX, int sizeY, GasStack gas) - { - if(gas == null) - { - return; - } + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; + public void displayGauge(int xPos, int yPos, int sizeX, int sizeY, GasStack gas) { + if (gas == null) { + return; + } - mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture()); - drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos, gas.getGas().getIcon(), sizeX, sizeY); - } + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + + mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture()); + drawTexturedModelRectFromIcon( + guiWidth + xPos, guiHeight + yPos, gas.getGas().getIcon(), sizeX, sizeY + ); + } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/GuiAmbientAccumulator.java b/src/main/java/mekanism/client/gui/GuiAmbientAccumulator.java index 37fd31e9f..328a6bcb5 100644 --- a/src/main/java/mekanism/client/gui/GuiAmbientAccumulator.java +++ b/src/main/java/mekanism/client/gui/GuiAmbientAccumulator.java @@ -10,45 +10,51 @@ import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.entity.player.EntityPlayer; - import org.lwjgl.opengl.GL11; -public class GuiAmbientAccumulator extends GuiMekanism -{ - TileEntityAmbientAccumulator tileEntity; +public class GuiAmbientAccumulator extends GuiMekanism { + TileEntityAmbientAccumulator tileEntity; - public GuiAmbientAccumulator(EntityPlayer player, TileEntityAmbientAccumulator tile) - { - super(tile, new ContainerNull(player, tile)); - tileEntity = tile; + public GuiAmbientAccumulator(EntityPlayer player, TileEntityAmbientAccumulator tile) { + super(tile, new ContainerNull(player, tile)); + tileEntity = tile; - guiElements.add(new GuiGasGauge(new IGasInfoHandler() { - @Override - public GasTank getTank() - { - return tileEntity.collectedGas; - } - }, Type.WIDE, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 26, 16)); - } + guiElements.add(new GuiGasGauge( + new IGasInfoHandler() { + @Override + public GasTank getTank() { + return tileEntity.collectedGas; + } + }, + Type.WIDE, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), + 26, + 16 + )); + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - fontRendererObj.drawString(tileEntity.getInventoryName(), 45, 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + fontRendererObj.drawString(tileEntity.getInventoryName(), 45, 6, 0x404040); + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040 + ); - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } } diff --git a/src/main/java/mekanism/client/gui/GuiBoilerStats.java b/src/main/java/mekanism/client/gui/GuiBoilerStats.java index b14dab367..d0d7df0e9 100644 --- a/src/main/java/mekanism/client/gui/GuiBoilerStats.java +++ b/src/main/java/mekanism/client/gui/GuiBoilerStats.java @@ -2,6 +2,8 @@ package mekanism.client.gui; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.MekanismConfig.general; import mekanism.api.util.ListUtils; import mekanism.api.util.UnitDisplayUtils; @@ -19,91 +21,146 @@ import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.entity.player.InventoryPlayer; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiBoilerStats extends GuiMekanism -{ - public TileEntityBoilerCasing tileEntity; - - public GuiGraph boilGraph; - public GuiGraph maxGraph; +public class GuiBoilerStats extends GuiMekanism { + public TileEntityBoilerCasing tileEntity; - public GuiBoilerStats(InventoryPlayer inventory, TileEntityBoilerCasing tentity) - { - super(tentity, new ContainerNull(inventory.player, tentity)); - tileEntity = tentity; - guiElements.add(new GuiBoilerTab(this, tileEntity, BoilerTab.MAIN, 6, MekanismUtils.getResource(ResourceType.GUI, "GuiBoilerStats.png"))); - guiElements.add(new GuiHeatInfo(new IInfoHandler() { - @Override - public List getInfo() - { - TemperatureUnit unit = TemperatureUnit.values()[general.tempUnit.ordinal()]; - String environment = UnitDisplayUtils.getDisplayShort(tileEntity.structure.lastEnvironmentLoss*unit.intervalSize, false, unit); - return ListUtils.asList(LangUtils.localize("gui.dissipated") + ": " + environment + "/t"); - } - }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBoilerStats.png"))); - guiElements.add(boilGraph = new GuiGraph(this, MekanismUtils.getResource(ResourceType.GUI, "GuiBoilerStats.png"), 8, 83, 160, 36, new GraphDataHandler() { - @Override - public String getDataDisplay(int data) - { - return LangUtils.localize("gui.boilRate") + ": " + data + " mB/t"; - } - })); - guiElements.add(maxGraph = new GuiGraph(this, MekanismUtils.getResource(ResourceType.GUI, "GuiBoilerStats.png"), 8, 122, 160, 36, new GraphDataHandler() { - @Override - public String getDataDisplay(int data) - { - return LangUtils.localize("gui.maxBoil") + ": " + data + " mB/t"; - } - })); - maxGraph.enableFixedScale((int)((tentity.structure.superheatingElements*general.superheatingHeatTransfer)/SynchronizedBoilerData.getHeatEnthalpy())); - } - - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + public GuiGraph boilGraph; + public GuiGraph maxGraph; - String stats = LangUtils.localize("gui.boilerStats"); - - fontRendererObj.drawString(stats, (xSize/2)-(fontRendererObj.getStringWidth(stats)/2), 6, 0x404040); - - fontRendererObj.drawString(LangUtils.localize("gui.maxWater") + ": " + tileEntity.clientWaterCapacity + " mB", 8, 26, 0x404040); - fontRendererObj.drawString(LangUtils.localize("gui.maxSteam") + ": " + tileEntity.clientSteamCapacity + " mB", 8, 35, 0x404040); - - fontRendererObj.drawString(LangUtils.localize("gui.heatTransfer"), 8, 49, 0x797979); - fontRendererObj.drawString(LangUtils.localize("gui.superheaters") + ": " + tileEntity.structure.superheatingElements, 14, 58, 0x404040); - - int boilCapacity = (int)((tileEntity.structure.superheatingElements*general.superheatingHeatTransfer)/SynchronizedBoilerData.getHeatEnthalpy()); - fontRendererObj.drawString(LangUtils.localize("gui.boilCapacity") + ": " + boilCapacity + " mB/t", 8, 72, 0x404040); - - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } - - @Override - public void updateScreen() - { - super.updateScreen(); - - boilGraph.addData(tileEntity.structure.lastBoilRate); - maxGraph.addData(tileEntity.structure.lastMaxBoil); - } - - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiBoilerStats.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } + public GuiBoilerStats(InventoryPlayer inventory, TileEntityBoilerCasing tentity) { + super(tentity, new ContainerNull(inventory.player, tentity)); + tileEntity = tentity; + guiElements.add(new GuiBoilerTab( + this, + tileEntity, + BoilerTab.MAIN, + 6, + MekanismUtils.getResource(ResourceType.GUI, "GuiBoilerStats.png") + )); + guiElements.add(new GuiHeatInfo(new IInfoHandler() { + @Override + public List getInfo() { + TemperatureUnit unit + = TemperatureUnit.values()[general.tempUnit.ordinal()]; + String environment = UnitDisplayUtils.getDisplayShort( + tileEntity.structure.lastEnvironmentLoss * unit.intervalSize, + false, + unit + ); + return ListUtils.asList( + LangUtils.localize("gui.dissipated") + ": " + environment + "/t" + ); + } + }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBoilerStats.png"))); + guiElements.add( + boilGraph = new GuiGraph( + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiBoilerStats.png"), + 8, + 83, + 160, + 36, + new GraphDataHandler() { + @Override + public String getDataDisplay(int data) { + return LangUtils.localize("gui.boilRate") + ": " + data + " mB/t"; + } + } + ) + ); + guiElements.add( + maxGraph = new GuiGraph( + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiBoilerStats.png"), + 8, + 122, + 160, + 36, + new GraphDataHandler() { + @Override + public String getDataDisplay(int data) { + return LangUtils.localize("gui.maxBoil") + ": " + data + " mB/t"; + } + } + ) + ); + maxGraph.enableFixedScale((int + ) ((tentity.structure.superheatingElements * general.superheatingHeatTransfer) + / SynchronizedBoilerData.getHeatEnthalpy())); + } + + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + String stats = LangUtils.localize("gui.boilerStats"); + + fontRendererObj.drawString( + stats, (xSize / 2) - (fontRendererObj.getStringWidth(stats) / 2), 6, 0x404040 + ); + + fontRendererObj.drawString( + LangUtils.localize("gui.maxWater") + ": " + tileEntity.clientWaterCapacity + + " mB", + 8, + 26, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.maxSteam") + ": " + tileEntity.clientSteamCapacity + + " mB", + 8, + 35, + 0x404040 + ); + + fontRendererObj.drawString( + LangUtils.localize("gui.heatTransfer"), 8, 49, 0x797979 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.superheaters") + ": " + + tileEntity.structure.superheatingElements, + 14, + 58, + 0x404040 + ); + + int boilCapacity = (int + ) ((tileEntity.structure.superheatingElements * general.superheatingHeatTransfer) + / SynchronizedBoilerData.getHeatEnthalpy()); + fontRendererObj.drawString( + LangUtils.localize("gui.boilCapacity") + ": " + boilCapacity + " mB/t", + 8, + 72, + 0x404040 + ); + + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + public void updateScreen() { + super.updateScreen(); + + boilGraph.addData(tileEntity.structure.lastBoilRate); + maxGraph.addData(tileEntity.structure.lastMaxBoil); + } + + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiBoilerStats.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } } diff --git a/src/main/java/mekanism/client/gui/GuiChanceMachine.java b/src/main/java/mekanism/client/gui/GuiChanceMachine.java index d2cf784b5..41e1cd27a 100644 --- a/src/main/java/mekanism/client/gui/GuiChanceMachine.java +++ b/src/main/java/mekanism/client/gui/GuiChanceMachine.java @@ -2,6 +2,8 @@ package mekanism.client.gui; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.util.ListUtils; import mekanism.client.gui.element.GuiElement.IInfoHandler; import mekanism.client.gui.element.GuiEnergyInfo; @@ -22,74 +24,81 @@ import mekanism.common.tile.TileEntityChanceMachine; import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import net.minecraft.entity.player.InventoryPlayer; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiChanceMachine extends GuiMekanism -{ - public TileEntityChanceMachine tileEntity; +public class GuiChanceMachine extends GuiMekanism { + public TileEntityChanceMachine tileEntity; - public GuiChanceMachine(InventoryPlayer inventory, TileEntityChanceMachine tentity) - { - super(tentity, new ContainerChanceMachine(inventory, tentity)); - tileEntity = tentity; + public GuiChanceMachine(InventoryPlayer inventory, TileEntityChanceMachine tentity) { + super(tentity, new ContainerChanceMachine(inventory, tentity)); + tileEntity = tentity; - guiElements.add(new GuiRedstoneControl(this, tileEntity, tileEntity.guiLocation)); - guiElements.add(new GuiUpgradeTab(this, tileEntity, tileEntity.guiLocation)); - guiElements.add(new GuiSecurityTab(this, tileEntity, tileEntity.guiLocation)); - guiElements.add(new GuiSideConfigurationTab(this, tileEntity, tileEntity.guiLocation)); - guiElements.add(new GuiTransporterConfigTab(this, 34, tileEntity, tileEntity.guiLocation)); - guiElements.add(new GuiPowerBar(this, tileEntity, tileEntity.guiLocation, 164, 15)); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() { - @Override - public List getInfo() - { - String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.energyPerTick); - return ListUtils.asList(LangUtils.localize("gui.using") + ": " + multiplier + "/t", LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); - } - }, this, tileEntity.guiLocation)); + guiElements.add(new GuiRedstoneControl(this, tileEntity, tileEntity.guiLocation)); + guiElements.add(new GuiUpgradeTab(this, tileEntity, tileEntity.guiLocation)); + guiElements.add(new GuiSecurityTab(this, tileEntity, tileEntity.guiLocation)); + guiElements.add( + new GuiSideConfigurationTab(this, tileEntity, tileEntity.guiLocation) + ); + guiElements.add( + new GuiTransporterConfigTab(this, 34, tileEntity, tileEntity.guiLocation) + ); + guiElements.add(new GuiPowerBar(this, tileEntity, tileEntity.guiLocation, 164, 15) + ); + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() { + String multiplier + = MekanismUtils.getEnergyDisplay(tileEntity.energyPerTick); + return ListUtils.asList( + LangUtils.localize("gui.using") + ": " + multiplier + "/t", + LangUtils.localize("gui.needed") + ": " + + MekanismUtils.getEnergyDisplay( + tileEntity.getMaxEnergy() - tileEntity.getEnergy() + ) + ); + } + }, this, tileEntity.guiLocation)); - guiElements.add(new GuiSlot(SlotType.INPUT, this, tileEntity.guiLocation, 55, 16)); - guiElements.add(new GuiSlot(SlotType.POWER, this, tileEntity.guiLocation, 55, 52).with(SlotOverlay.POWER)); - guiElements.add(new GuiSlot(SlotType.OUTPUT_WIDE, this, tileEntity.guiLocation, 111, 30)); + guiElements.add(new GuiSlot(SlotType.INPUT, this, tileEntity.guiLocation, 55, 16) + ); + guiElements.add(new GuiSlot(SlotType.POWER, this, tileEntity.guiLocation, 55, 52) + .with(SlotOverlay.POWER)); + guiElements.add( + new GuiSlot(SlotType.OUTPUT_WIDE, this, tileEntity.guiLocation, 111, 30) + ); - guiElements.add(new GuiProgress(new IProgressInfoHandler() - { - @Override - public double getProgress() - { - return tileEntity.getScaledProgress(); - } - }, getProgressType(), this, tileEntity.guiLocation, 77, 37)); - } - - public ProgressBar getProgressType() - { - return ProgressBar.BLUE; - } + guiElements.add(new GuiProgress(new IProgressInfoHandler() { + @Override + public double getProgress() { + return tileEntity.getScaledProgress(); + } + }, getProgressType(), this, tileEntity.guiLocation, 77, 37)); + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - fontRendererObj.drawString(tileEntity.getInventoryName(), 45, 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); + public ProgressBar getProgressType() { + return ProgressBar.BLUE; + } - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + fontRendererObj.drawString(tileEntity.getInventoryName(), 45, 6, 0x404040); + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040 + ); - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(tileEntity.guiLocation); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture(tileEntity.guiLocation); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } } diff --git a/src/main/java/mekanism/client/gui/GuiChemicalCrystallizer.java b/src/main/java/mekanism/client/gui/GuiChemicalCrystallizer.java index cc1da4df8..737f1a5cd 100644 --- a/src/main/java/mekanism/client/gui/GuiChemicalCrystallizer.java +++ b/src/main/java/mekanism/client/gui/GuiChemicalCrystallizer.java @@ -3,6 +3,8 @@ package mekanism.client.gui; import java.util.ArrayList; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.gas.Gas; import mekanism.api.gas.GasTank; import mekanism.api.gas.OreGas; @@ -34,242 +36,298 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiChemicalCrystallizer extends GuiMekanism -{ - public TileEntityChemicalCrystallizer tileEntity; +public class GuiChemicalCrystallizer extends GuiMekanism { + public TileEntityChemicalCrystallizer tileEntity; - public Gas prevGas; + public Gas prevGas; - public ItemStack renderStack; + public ItemStack renderStack; - public int stackSwitch = 0; + public int stackSwitch = 0; - public int stackIndex = 0; + public int stackIndex = 0; - public List iterStacks = new ArrayList(); + public List iterStacks = new ArrayList(); - public GuiChemicalCrystallizer(InventoryPlayer inventory, TileEntityChemicalCrystallizer tentity) - { - super(tentity, new ContainerChemicalCrystallizer(inventory, tentity)); - tileEntity = tentity; + public GuiChemicalCrystallizer( + InventoryPlayer inventory, TileEntityChemicalCrystallizer tentity + ) { + super(tentity, new ContainerChemicalCrystallizer(inventory, tentity)); + tileEntity = tentity; - guiElements.add(new GuiSecurityTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystallizer.png"))); - guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystallizer.png"))); - guiElements.add(new GuiUpgradeTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystallizer.png"))); - guiElements.add(new GuiPowerBar(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystallizer.png"), 160, 23)); - guiElements.add(new GuiSideConfigurationTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystallizer.png"))); - guiElements.add(new GuiTransporterConfigTab(this, 34, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystallizer.png"))); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() { - @Override - public List getInfo() - { - String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.energyUsage); - return ListUtils.asList(LangUtils.localize("gui.using") + ": " + multiplier + "/t", LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); - } - }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystallizer.png"))); - guiElements.add(new GuiGasGauge(new IGasInfoHandler() { - @Override - public GasTank getTank() - { - return tileEntity.inputTank; - } - }, GuiGauge.Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystallizer.png"), 5, 4)); - guiElements.add(new GuiSlot(SlotType.EXTRA, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystallizer.png"), 5, 64).with(SlotOverlay.PLUS)); - guiElements.add(new GuiSlot(SlotType.POWER, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystallizer.png"), 154, 4).with(SlotOverlay.POWER)); - guiElements.add(new GuiSlot(SlotType.OUTPUT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystallizer.png"), 130, 56)); + guiElements.add(new GuiSecurityTab( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystallizer.png") + )); + guiElements.add(new GuiRedstoneControl( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystallizer.png") + )); + guiElements.add(new GuiUpgradeTab( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystallizer.png") + )); + guiElements.add(new GuiPowerBar( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystallizer.png"), + 160, + 23 + )); + guiElements.add(new GuiSideConfigurationTab( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystallizer.png") + )); + guiElements.add(new GuiTransporterConfigTab( + this, + 34, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystallizer.png") + )); + guiElements.add(new GuiEnergyInfo( + new IInfoHandler() { + @Override + public List getInfo() { + String multiplier + = MekanismUtils.getEnergyDisplay(tileEntity.energyUsage); + return ListUtils.asList( + LangUtils.localize("gui.using") + ": " + multiplier + "/t", + LangUtils.localize("gui.needed") + ": " + + MekanismUtils.getEnergyDisplay( + tileEntity.getMaxEnergy() - tileEntity.getEnergy() + ) + ); + } + }, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystallizer.png") + )); + guiElements.add(new GuiGasGauge( + new IGasInfoHandler() { + @Override + public GasTank getTank() { + return tileEntity.inputTank; + } + }, + GuiGauge.Type.STANDARD, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystallizer.png"), + 5, + 4 + )); + guiElements.add(new GuiSlot( + SlotType.EXTRA, + this, + MekanismUtils.getResource( + ResourceType.GUI, "GuiChemicalCrystallizer.png" + ), + 5, + 64 + ) + .with(SlotOverlay.PLUS)); + guiElements.add(new GuiSlot( + SlotType.POWER, + this, + MekanismUtils.getResource( + ResourceType.GUI, "GuiChemicalCrystallizer.png" + ), + 154, + 4 + ) + .with(SlotOverlay.POWER)); + guiElements.add(new GuiSlot( + SlotType.OUTPUT, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystallizer.png"), + 130, + 56 + )); - guiElements.add(new GuiProgress(new IProgressInfoHandler() - { - @Override - public double getProgress() - { - return tileEntity.getScaledProgress(); - } - }, ProgressBar.LARGE_RIGHT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystallizer.png"), 51, 60)); - } + guiElements.add(new GuiProgress( + new IProgressInfoHandler() { + @Override + public double getProgress() { + return tileEntity.getScaledProgress(); + } + }, + ProgressBar.LARGE_RIGHT, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystallizer.png"), + 51, + 60 + )); + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - fontRendererObj.drawString(tileEntity.getInventoryName(), 37, 4, 0x404040); + fontRendererObj.drawString(tileEntity.getInventoryName(), 37, 4, 0x404040); - if(tileEntity.inputTank.getGas() != null) - { - fontRendererObj.drawString(tileEntity.inputTank.getGas().getGas().getLocalizedName(), 29, 15, 0x00CD00); + if (tileEntity.inputTank.getGas() != null) { + fontRendererObj.drawString( + tileEntity.inputTank.getGas().getGas().getLocalizedName(), + 29, + 15, + 0x00CD00 + ); - if(tileEntity.inputTank.getGas().getGas() instanceof OreGas) - { - fontRendererObj.drawString("(" + ((OreGas)tileEntity.inputTank.getGas().getGas()).getOreName() + ")", 29, 24, 0x00CD00); - } - else { - CrystallizerRecipe recipe = tileEntity.getRecipe(); - - if(recipe == null) - { - fontRendererObj.drawString("(" + LangUtils.localize("gui.noRecipe") + ")", 29, 24, 0x00CD00); - } - else { - fontRendererObj.drawString("(" + recipe.recipeOutput.output.getDisplayName() + ")", 29, 24, 0x00CD00); - } - } - } + if (tileEntity.inputTank.getGas().getGas() instanceof OreGas) { + fontRendererObj.drawString( + "(" + ((OreGas) tileEntity.inputTank.getGas().getGas()).getOreName() + + ")", + 29, + 24, + 0x00CD00 + ); + } else { + CrystallizerRecipe recipe = tileEntity.getRecipe(); - if(renderStack != null) - { - try { - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_LIGHTING); - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), renderStack, 131, 14); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } catch(Exception e) {} - } + if (recipe == null) { + fontRendererObj.drawString( + "(" + LangUtils.localize("gui.noRecipe") + ")", 29, 24, 0x00CD00 + ); + } else { + fontRendererObj.drawString( + "(" + recipe.recipeOutput.output.getDisplayName() + ")", + 29, + 24, + 0x00CD00 + ); + } + } + } - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + if (renderStack != null) { + try { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_LIGHTING); + itemRender.renderItemAndEffectIntoGUI( + fontRendererObj, mc.getTextureManager(), renderStack, 131, 14 + ); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } catch (Exception e) {} + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystallizer.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalCrystallizer.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - private Gas getInputGas() - { - return tileEntity.inputTank.getGas() != null ? tileEntity.inputTank.getGas().getGas() : null; - } + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } - private void resetStacks() - { - iterStacks.clear(); - renderStack = null; - stackSwitch = 0; - stackIndex = -1; - } + private Gas getInputGas() { + return tileEntity.inputTank.getGas() != null + ? tileEntity.inputTank.getGas().getGas() + : null; + } - @Override - public void updateScreen() - { - super.updateScreen(); + private void resetStacks() { + iterStacks.clear(); + renderStack = null; + stackSwitch = 0; + stackIndex = -1; + } - if(prevGas != getInputGas()) - { - prevGas = getInputGas(); + @Override + public void updateScreen() { + super.updateScreen(); - boolean reset = false; + if (prevGas != getInputGas()) { + prevGas = getInputGas(); - if(prevGas == null || !(prevGas instanceof OreGas) || !((OreGas)prevGas).isClean()) - { - reset = true; - resetStacks(); - } + boolean reset = false; - if(!reset) - { - OreGas gas = (OreGas)prevGas; - String oreDictName = "ore" + gas.getName().substring(5); + if (prevGas == null || !(prevGas instanceof OreGas) + || !((OreGas) prevGas).isClean()) { + reset = true; + resetStacks(); + } - updateStackList(oreDictName); - } - } + if (!reset) { + OreGas gas = (OreGas) prevGas; + String oreDictName = "ore" + gas.getName().substring(5); - if(stackSwitch > 0) - { - stackSwitch--; - } + updateStackList(oreDictName); + } + } - if(stackSwitch == 0 && iterStacks != null && iterStacks.size() > 0) - { - stackSwitch = 20; + if (stackSwitch > 0) { + stackSwitch--; + } - if(stackIndex == -1 || stackIndex == iterStacks.size()-1) - { - stackIndex = 0; - } - else if(stackIndex < iterStacks.size()-1) - { - stackIndex++; - } + if (stackSwitch == 0 && iterStacks != null && iterStacks.size() > 0) { + stackSwitch = 20; - renderStack = iterStacks.get(stackIndex); - } - else if(iterStacks != null && iterStacks.size() == 0) - { - renderStack = null; - } - } + if (stackIndex == -1 || stackIndex == iterStacks.size() - 1) { + stackIndex = 0; + } else if (stackIndex < iterStacks.size() - 1) { + stackIndex++; + } - private void updateStackList(String oreName) - { - if(iterStacks == null) - { - iterStacks = new ArrayList(); - } - else { - iterStacks.clear(); - } + renderStack = iterStacks.get(stackIndex); + } else if (iterStacks != null && iterStacks.size() == 0) { + renderStack = null; + } + } - List keys = new ArrayList(); + private void updateStackList(String oreName) { + if (iterStacks == null) { + iterStacks = new ArrayList(); + } else { + iterStacks.clear(); + } - for(String s : OreDictionary.getOreNames()) - { - if(oreName.equals(s) || oreName.equals("*")) - { - keys.add(s); - } - else if(oreName.endsWith("*") && !oreName.startsWith("*")) - { - if(s.startsWith(oreName.substring(0, oreName.length()-1))) - { - keys.add(s); - } - } - else if(oreName.startsWith("*") && !oreName.endsWith("*")) - { - if(s.endsWith(oreName.substring(1))) - { - keys.add(s); - } - } - else if(oreName.startsWith("*") && oreName.endsWith("*")) - { - if(s.contains(oreName.substring(1, oreName.length()-1))) - { - keys.add(s); - } - } - } + List keys = new ArrayList(); - for(String key : keys) - { - for(ItemStack stack : OreDictionary.getOres(key)) - { - ItemStack toAdd = stack.copy(); + for (String s : OreDictionary.getOreNames()) { + if (oreName.equals(s) || oreName.equals("*")) { + keys.add(s); + } else if (oreName.endsWith("*") && !oreName.startsWith("*")) { + if (s.startsWith(oreName.substring(0, oreName.length() - 1))) { + keys.add(s); + } + } else if (oreName.startsWith("*") && !oreName.endsWith("*")) { + if (s.endsWith(oreName.substring(1))) { + keys.add(s); + } + } else if (oreName.startsWith("*") && oreName.endsWith("*")) { + if (s.contains(oreName.substring(1, oreName.length() - 1))) { + keys.add(s); + } + } + } - if(!iterStacks.contains(stack) && toAdd.getItem() instanceof ItemBlock) - { - iterStacks.add(stack.copy()); - } - } - } + for (String key : keys) { + for (ItemStack stack : OreDictionary.getOres(key)) { + ItemStack toAdd = stack.copy(); - stackSwitch = 0; - stackIndex = -1; - } + if (!iterStacks.contains(stack) && toAdd.getItem() instanceof ItemBlock) { + iterStacks.add(stack.copy()); + } + } + } + + stackSwitch = 0; + stackIndex = -1; + } } diff --git a/src/main/java/mekanism/client/gui/GuiChemicalDissolutionChamber.java b/src/main/java/mekanism/client/gui/GuiChemicalDissolutionChamber.java index a57a0ce17..64e5b0d83 100644 --- a/src/main/java/mekanism/client/gui/GuiChemicalDissolutionChamber.java +++ b/src/main/java/mekanism/client/gui/GuiChemicalDissolutionChamber.java @@ -2,18 +2,20 @@ package mekanism.client.gui; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.gas.GasTank; import mekanism.api.util.ListUtils; import mekanism.client.gui.element.GuiElement.IInfoHandler; import mekanism.client.gui.element.GuiEnergyInfo; import mekanism.client.gui.element.GuiGasGauge; -import mekanism.client.gui.element.GuiSecurityTab; import mekanism.client.gui.element.GuiGasGauge.IGasInfoHandler; import mekanism.client.gui.element.GuiGauge; import mekanism.client.gui.element.GuiProgress; import mekanism.client.gui.element.GuiProgress.IProgressInfoHandler; import mekanism.client.gui.element.GuiProgress.ProgressBar; import mekanism.client.gui.element.GuiRedstoneControl; +import mekanism.client.gui.element.GuiSecurityTab; import mekanism.client.gui.element.GuiSlot; import mekanism.client.gui.element.GuiSlot.SlotOverlay; import mekanism.client.gui.element.GuiSlot.SlotType; @@ -24,93 +26,181 @@ import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.entity.player.InventoryPlayer; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiChemicalDissolutionChamber extends GuiMekanism -{ - public TileEntityChemicalDissolutionChamber tileEntity; +public class GuiChemicalDissolutionChamber extends GuiMekanism { + public TileEntityChemicalDissolutionChamber tileEntity; - public GuiChemicalDissolutionChamber(InventoryPlayer inventory, TileEntityChemicalDissolutionChamber tentity) - { - super(tentity, new ContainerChemicalDissolutionChamber(inventory, tentity)); - tileEntity = tentity; + public GuiChemicalDissolutionChamber( + InventoryPlayer inventory, TileEntityChemicalDissolutionChamber tentity + ) { + super(tentity, new ContainerChemicalDissolutionChamber(inventory, tentity)); + tileEntity = tentity; - guiElements.add(new GuiSecurityTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalDissolutionChamber.png"))); - guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalDissolutionChamber.png"))); - guiElements.add(new GuiUpgradeTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalDissolutionChamber.png"))); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() { - @Override - public List getInfo() - { - String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.energyUsage); - return ListUtils.asList(LangUtils.localize("gui.using") + ": " + multiplier + "/t", LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); - } - }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalDissolutionChamber.png"))); - guiElements.add(new GuiGasGauge(new IGasInfoHandler() { - @Override - public GasTank getTank() - { - return tileEntity.injectTank; - } - }, GuiGauge.Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalDissolutionChamber.png"), 5, 4)); - guiElements.add(new GuiGasGauge(new IGasInfoHandler() { - @Override - public GasTank getTank() - { - return tileEntity.outputTank; - } - }, GuiGauge.Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalDissolutionChamber.png"), 133, 13)); + guiElements.add(new GuiSecurityTab( + this, + tileEntity, + MekanismUtils.getResource( + ResourceType.GUI, "GuiChemicalDissolutionChamber.png" + ) + )); + guiElements.add(new GuiRedstoneControl( + this, + tileEntity, + MekanismUtils.getResource( + ResourceType.GUI, "GuiChemicalDissolutionChamber.png" + ) + )); + guiElements.add(new GuiUpgradeTab( + this, + tileEntity, + MekanismUtils.getResource( + ResourceType.GUI, "GuiChemicalDissolutionChamber.png" + ) + )); + guiElements.add(new GuiEnergyInfo( + new IInfoHandler() { + @Override + public List getInfo() { + String multiplier + = MekanismUtils.getEnergyDisplay(tileEntity.energyUsage); + return ListUtils.asList( + LangUtils.localize("gui.using") + ": " + multiplier + "/t", + LangUtils.localize("gui.needed") + ": " + + MekanismUtils.getEnergyDisplay( + tileEntity.getMaxEnergy() - tileEntity.getEnergy() + ) + ); + } + }, + this, + MekanismUtils.getResource( + ResourceType.GUI, "GuiChemicalDissolutionChamber.png" + ) + )); + guiElements.add(new GuiGasGauge( + new IGasInfoHandler() { + @Override + public GasTank getTank() { + return tileEntity.injectTank; + } + }, + GuiGauge.Type.STANDARD, + this, + MekanismUtils.getResource( + ResourceType.GUI, "GuiChemicalDissolutionChamber.png" + ), + 5, + 4 + )); + guiElements.add(new GuiGasGauge( + new IGasInfoHandler() { + @Override + public GasTank getTank() { + return tileEntity.outputTank; + } + }, + GuiGauge.Type.STANDARD, + this, + MekanismUtils.getResource( + ResourceType.GUI, "GuiChemicalDissolutionChamber.png" + ), + 133, + 13 + )); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalDissolutionChamber.png"), 154, 4).with(SlotOverlay.POWER)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalDissolutionChamber.png"), 25, 35)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalDissolutionChamber.png"), 154, 24).with(SlotOverlay.PLUS)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalDissolutionChamber.png"), 5, 64).with(SlotOverlay.MINUS)); + guiElements.add(new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource( + ResourceType.GUI, "GuiChemicalDissolutionChamber.png" + ), + 154, + 4 + ) + .with(SlotOverlay.POWER)); + guiElements.add(new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource( + ResourceType.GUI, "GuiChemicalDissolutionChamber.png" + ), + 25, + 35 + )); + guiElements.add(new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource( + ResourceType.GUI, "GuiChemicalDissolutionChamber.png" + ), + 154, + 24 + ) + .with(SlotOverlay.PLUS)); + guiElements.add(new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource( + ResourceType.GUI, "GuiChemicalDissolutionChamber.png" + ), + 5, + 64 + ) + .with(SlotOverlay.MINUS)); - guiElements.add(new GuiProgress(new IProgressInfoHandler() - { - @Override - public double getProgress() - { - return tileEntity.getScaledProgress(); - } - }, ProgressBar.LARGE_RIGHT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalDissolutionChamber.png"), 62, 39)); - } + guiElements.add(new GuiProgress( + new IProgressInfoHandler() { + @Override + public double getProgress() { + return tileEntity.getScaledProgress(); + } + }, + ProgressBar.LARGE_RIGHT, + this, + MekanismUtils.getResource( + ResourceType.GUI, "GuiChemicalDissolutionChamber.png" + ), + 62, + 39 + )); + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - fontRendererObj.drawString(LangUtils.localize("gui.chemicalDissolutionChamber.short"), 35, 4, 0x404040); + fontRendererObj.drawString( + LangUtils.localize("gui.chemicalDissolutionChamber.short"), 35, 4, 0x404040 + ); - if(xAxis >= 116 && xAxis <= 168 && yAxis >= 76 && yAxis <= 80) - { - drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis); - } + if (xAxis >= 116 && xAxis <= 168 && yAxis >= 76 && yAxis <= 80) { + drawCreativeTabHoveringText( + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis + ); + } - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalDissolutionChamber.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - int displayInt; + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture(MekanismUtils.getResource( + ResourceType.GUI, "GuiChemicalDissolutionChamber.png" + )); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - displayInt = tileEntity.getScaledEnergyLevel(52); - drawTexturedModalRect(guiWidth + 116, guiHeight + 76, 176, 0, displayInt, 4); + int displayInt; - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } + displayInt = tileEntity.getScaledEnergyLevel(52); + drawTexturedModalRect(guiWidth + 116, guiHeight + 76, 176, 0, displayInt, 4); + + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } } diff --git a/src/main/java/mekanism/client/gui/GuiChemicalInfuser.java b/src/main/java/mekanism/client/gui/GuiChemicalInfuser.java index b64e82884..bd41edb79 100644 --- a/src/main/java/mekanism/client/gui/GuiChemicalInfuser.java +++ b/src/main/java/mekanism/client/gui/GuiChemicalInfuser.java @@ -2,6 +2,8 @@ package mekanism.client.gui; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.gas.GasTank; import mekanism.api.util.ListUtils; import mekanism.client.gui.element.GuiElement.IInfoHandler; @@ -24,109 +26,193 @@ import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.entity.player.InventoryPlayer; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiChemicalInfuser extends GuiMekanism -{ - public TileEntityChemicalInfuser tileEntity; +public class GuiChemicalInfuser extends GuiMekanism { + public TileEntityChemicalInfuser tileEntity; - public GuiChemicalInfuser(InventoryPlayer inventory, TileEntityChemicalInfuser tentity) - { - super(tentity, new ContainerChemicalInfuser(inventory, tentity)); - tileEntity = tentity; + public GuiChemicalInfuser( + InventoryPlayer inventory, TileEntityChemicalInfuser tentity + ) { + super(tentity, new ContainerChemicalInfuser(inventory, tentity)); + tileEntity = tentity; - guiElements.add(new GuiSecurityTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png"))); - guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png"))); - guiElements.add(new GuiUpgradeTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png"))); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() { - @Override - public List getInfo() - { - String usage = MekanismUtils.getEnergyDisplay(tileEntity.clientEnergyUsed); - return ListUtils.asList(LangUtils.localize("gui.using") + ": " + usage + "/t", LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); - } - }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png"))); - guiElements.add(new GuiGasGauge(new IGasInfoHandler() { - @Override - public GasTank getTank() - { - return tileEntity.leftTank; - } - }, GuiGauge.Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png"), 25, 13)); - guiElements.add(new GuiGasGauge(new IGasInfoHandler() { - @Override - public GasTank getTank() - { - return tileEntity.centerTank; - } - }, GuiGauge.Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png"), 79, 4)); - guiElements.add(new GuiGasGauge(new IGasInfoHandler() { - @Override - public GasTank getTank() - { - return tileEntity.rightTank; - } - }, GuiGauge.Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png"), 133, 13)); + guiElements.add(new GuiSecurityTab( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png") + )); + guiElements.add(new GuiRedstoneControl( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png") + )); + guiElements.add(new GuiUpgradeTab( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png") + )); + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() { + String usage + = MekanismUtils.getEnergyDisplay(tileEntity.clientEnergyUsed); + return ListUtils.asList( + LangUtils.localize("gui.using") + ": " + usage + "/t", + LangUtils.localize("gui.needed") + ": " + + MekanismUtils.getEnergyDisplay( + tileEntity.getMaxEnergy() - tileEntity.getEnergy() + ) + ); + } + }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png"))); + guiElements.add(new GuiGasGauge( + new IGasInfoHandler() { + @Override + public GasTank getTank() { + return tileEntity.leftTank; + } + }, + GuiGauge.Type.STANDARD, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png"), + 25, + 13 + )); + guiElements.add(new GuiGasGauge( + new IGasInfoHandler() { + @Override + public GasTank getTank() { + return tileEntity.centerTank; + } + }, + GuiGauge.Type.STANDARD, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png"), + 79, + 4 + )); + guiElements.add(new GuiGasGauge( + new IGasInfoHandler() { + @Override + public GasTank getTank() { + return tileEntity.rightTank; + } + }, + GuiGauge.Type.STANDARD, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png"), + 133, + 13 + )); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png"), 154, 4).with(SlotOverlay.POWER)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png"), 154, 55).with(SlotOverlay.MINUS)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png"), 4, 55).with(SlotOverlay.MINUS)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png"), 79, 64).with(SlotOverlay.PLUS)); + guiElements.add( + new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png"), + 154, + 4 + ) + .with(SlotOverlay.POWER) + ); + guiElements.add( + new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png"), + 154, + 55 + ) + .with(SlotOverlay.MINUS) + ); + guiElements.add( + new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png"), + 4, + 55 + ) + .with(SlotOverlay.MINUS) + ); + guiElements.add( + new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png"), + 79, + 64 + ) + .with(SlotOverlay.PLUS) + ); - guiElements.add(new GuiProgress(new IProgressInfoHandler() - { - @Override - public double getProgress() - { - return tileEntity.isActive ? 1 : 0; - } - }, ProgressBar.SMALL_RIGHT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png"), 45, 38)); - guiElements.add(new GuiProgress(new IProgressInfoHandler() - { - @Override - public double getProgress() - { - return tileEntity.isActive ? 1 : 0; - } - }, ProgressBar.SMALL_LEFT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png"), 99, 38)); - } + guiElements.add(new GuiProgress( + new IProgressInfoHandler() { + @Override + public double getProgress() { + return tileEntity.isActive ? 1 : 0; + } + }, + ProgressBar.SMALL_RIGHT, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png"), + 45, + 38 + )); + guiElements.add(new GuiProgress( + new IProgressInfoHandler() { + @Override + public double getProgress() { + return tileEntity.isActive ? 1 : 0; + } + }, + ProgressBar.SMALL_LEFT, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png"), + 99, + 38 + )); + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - fontRendererObj.drawString(LangUtils.localize("gui.chemicalInfuser.short"), 5, 5, 0x404040); - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 4, 0x404040); - - if(xAxis >= 116 && xAxis <= 168 && yAxis >= 76 && yAxis <= 80) - { - drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis); - } + fontRendererObj.drawString( + LangUtils.localize("gui.chemicalInfuser.short"), 5, 5, 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, (ySize - 96) + 4, 0x404040 + ); - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + if (xAxis >= 116 && xAxis <= 168 && yAxis >= 76 && yAxis <= 80) { + drawCreativeTabHoveringText( + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis + ); + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - int displayInt; + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - displayInt = tileEntity.getScaledEnergyLevel(52); - drawTexturedModalRect(guiWidth + 116, guiHeight + 76, 176, 0, displayInt, 4); + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } + int displayInt; + + displayInt = tileEntity.getScaledEnergyLevel(52); + drawTexturedModalRect(guiWidth + 116, guiHeight + 76, 176, 0, displayInt, 4); + + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } } diff --git a/src/main/java/mekanism/client/gui/GuiChemicalInjectionChamber.java b/src/main/java/mekanism/client/gui/GuiChemicalInjectionChamber.java index 49ad53994..2bfb04084 100644 --- a/src/main/java/mekanism/client/gui/GuiChemicalInjectionChamber.java +++ b/src/main/java/mekanism/client/gui/GuiChemicalInjectionChamber.java @@ -1,22 +1,21 @@ package mekanism.client.gui; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.gui.element.GuiProgress.ProgressBar; import mekanism.common.tile.TileEntityAdvancedElectricMachine; import net.minecraft.entity.player.InventoryPlayer; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiChemicalInjectionChamber extends GuiAdvancedElectricMachine -{ - public GuiChemicalInjectionChamber(InventoryPlayer inventory, TileEntityAdvancedElectricMachine tentity) - { - super(inventory, tentity); - } - - @Override - public ProgressBar getProgressType() - { - return ProgressBar.YELLOW; - } +public class GuiChemicalInjectionChamber extends GuiAdvancedElectricMachine { + public GuiChemicalInjectionChamber( + InventoryPlayer inventory, TileEntityAdvancedElectricMachine tentity + ) { + super(inventory, tentity); + } + + @Override + public ProgressBar getProgressType() { + return ProgressBar.YELLOW; + } } diff --git a/src/main/java/mekanism/client/gui/GuiChemicalOxidizer.java b/src/main/java/mekanism/client/gui/GuiChemicalOxidizer.java index 24a2c9715..ad3e032b4 100644 --- a/src/main/java/mekanism/client/gui/GuiChemicalOxidizer.java +++ b/src/main/java/mekanism/client/gui/GuiChemicalOxidizer.java @@ -2,6 +2,8 @@ package mekanism.client.gui; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.gas.GasTank; import mekanism.api.util.ListUtils; import mekanism.client.gui.element.GuiElement.IInfoHandler; @@ -24,89 +26,142 @@ import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.entity.player.InventoryPlayer; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiChemicalOxidizer extends GuiMekanism -{ - public TileEntityChemicalOxidizer tileEntity; +public class GuiChemicalOxidizer extends GuiMekanism { + public TileEntityChemicalOxidizer tileEntity; - public GuiChemicalOxidizer(InventoryPlayer inventory, TileEntityChemicalOxidizer tentity) - { - super(tentity, new ContainerChemicalOxidizer(inventory, tentity)); - tileEntity = tentity; + public GuiChemicalOxidizer( + InventoryPlayer inventory, TileEntityChemicalOxidizer tentity + ) { + super(tentity, new ContainerChemicalOxidizer(inventory, tentity)); + tileEntity = tentity; - guiElements.add(new GuiSecurityTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png"))); - guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png"))); - guiElements.add(new GuiUpgradeTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png"))); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() { - @Override - public List getInfo() - { - String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.energyUsage); - return ListUtils.asList(LangUtils.localize("gui.using") + ": " + multiplier + "/t", LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); - } - }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png"))); - guiElements.add(new GuiGasGauge(new IGasInfoHandler() { - @Override - public GasTank getTank() - { - return tileEntity.gasTank; - } - }, GuiGauge.Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png"), 133, 13)); + guiElements.add(new GuiSecurityTab( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png") + )); + guiElements.add(new GuiRedstoneControl( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png") + )); + guiElements.add(new GuiUpgradeTab( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png") + )); + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() { + String multiplier + = MekanismUtils.getEnergyDisplay(tileEntity.energyUsage); + return ListUtils.asList( + LangUtils.localize("gui.using") + ": " + multiplier + "/t", + LangUtils.localize("gui.needed") + ": " + + MekanismUtils.getEnergyDisplay( + tileEntity.getMaxEnergy() - tileEntity.getEnergy() + ) + ); + } + }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png"))); + guiElements.add(new GuiGasGauge( + new IGasInfoHandler() { + @Override + public GasTank getTank() { + return tileEntity.gasTank; + } + }, + GuiGauge.Type.STANDARD, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png"), + 133, + 13 + )); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png"), 154, 4).with(SlotOverlay.POWER)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png"), 25, 35)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png"), 154, 24).with(SlotOverlay.PLUS)); + guiElements.add( + new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png"), + 154, + 4 + ) + .with(SlotOverlay.POWER) + ); + guiElements.add(new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png"), + 25, + 35 + )); + guiElements.add( + new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png"), + 154, + 24 + ) + .with(SlotOverlay.PLUS) + ); - guiElements.add(new GuiProgress(new IProgressInfoHandler() - { - @Override - public double getProgress() - { - return tileEntity.getScaledProgress(); - } - }, ProgressBar.LARGE_RIGHT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png"), 62, 39)); - } + guiElements.add(new GuiProgress( + new IProgressInfoHandler() { + @Override + public double getProgress() { + return tileEntity.getScaledProgress(); + } + }, + ProgressBar.LARGE_RIGHT, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png"), + 62, + 39 + )); + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - fontRendererObj.drawString(tileEntity.getInventoryName(), 45, 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); - - if(xAxis >= 116 && xAxis <= 168 && yAxis >= 76 && yAxis <= 80) - { - drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis); - } + fontRendererObj.drawString(tileEntity.getInventoryName(), 45, 6, 0x404040); + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040 + ); - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + if (xAxis >= 116 && xAxis <= 168 && yAxis >= 76 && yAxis <= 80) { + drawCreativeTabHoveringText( + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis + ); + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - int xAxis = mouseX - guiWidth; - int yAxis = mouseY - guiHeight; - - int displayInt; + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - displayInt = tileEntity.getScaledEnergyLevel(52); - drawTexturedModalRect(guiWidth + 116, guiHeight + 76, 176, 0, displayInt, 4); + int xAxis = mouseX - guiWidth; + int yAxis = mouseY - guiHeight; - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } + int displayInt; + + displayInt = tileEntity.getScaledEnergyLevel(52); + drawTexturedModalRect(guiWidth + 116, guiHeight + 76, 176, 0, displayInt, 4); + + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } } diff --git a/src/main/java/mekanism/client/gui/GuiChemicalWasher.java b/src/main/java/mekanism/client/gui/GuiChemicalWasher.java index 01b90d539..5bec6a780 100644 --- a/src/main/java/mekanism/client/gui/GuiChemicalWasher.java +++ b/src/main/java/mekanism/client/gui/GuiChemicalWasher.java @@ -2,6 +2,8 @@ package mekanism.client.gui; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.gas.GasTank; import mekanism.api.util.ListUtils; import mekanism.client.gui.element.GuiBucketIO; @@ -29,100 +31,158 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.entity.player.InventoryPlayer; import net.minecraftforge.fluids.FluidTank; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiChemicalWasher extends GuiMekanism -{ - public TileEntityChemicalWasher tileEntity; +public class GuiChemicalWasher extends GuiMekanism { + public TileEntityChemicalWasher tileEntity; - public GuiChemicalWasher(InventoryPlayer inventory, TileEntityChemicalWasher tentity) - { - super(tentity, new ContainerChemicalWasher(inventory, tentity)); - tileEntity = tentity; + public GuiChemicalWasher( + InventoryPlayer inventory, TileEntityChemicalWasher tentity + ) { + super(tentity, new ContainerChemicalWasher(inventory, tentity)); + tileEntity = tentity; - guiElements.add(new GuiSecurityTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalWasher.png"))); - guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalWasher.png"))); - guiElements.add(new GuiUpgradeTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalWasher.png"))); - guiElements.add(new GuiBucketIO(this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalWasher.png"))); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() { - @Override - public List getInfo() - { - String usage = MekanismUtils.getEnergyDisplay(tileEntity.clientEnergyUsed); - return ListUtils.asList(LangUtils.localize("gui.using") + ": " + usage + "/t", LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); - } - }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalWasher.png"))); - guiElements.add(new GuiFluidGauge(new IFluidInfoHandler() - { - @Override - public FluidTank getTank() - { - return tileEntity.fluidTank; - } - }, Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalWasher.png"), 5, 4)); - guiElements.add(new GuiGasGauge(new IGasInfoHandler() { - @Override - public GasTank getTank() - { - return tileEntity.inputTank; - } - }, GuiGauge.Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalWasher.png"), 26, 13)); - guiElements.add(new GuiGasGauge(new IGasInfoHandler() { - @Override - public GasTank getTank() - { - return tileEntity.outputTank; - } - }, GuiGauge.Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalWasher.png"), 133, 13)); + guiElements.add(new GuiSecurityTab( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalWasher.png") + )); + guiElements.add(new GuiRedstoneControl( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalWasher.png") + )); + guiElements.add(new GuiUpgradeTab( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalWasher.png") + )); + guiElements.add(new GuiBucketIO( + this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalWasher.png") + )); + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() { + String usage + = MekanismUtils.getEnergyDisplay(tileEntity.clientEnergyUsed); + return ListUtils.asList( + LangUtils.localize("gui.using") + ": " + usage + "/t", + LangUtils.localize("gui.needed") + ": " + + MekanismUtils.getEnergyDisplay( + tileEntity.getMaxEnergy() - tileEntity.getEnergy() + ) + ); + } + }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalWasher.png"))); + guiElements.add(new GuiFluidGauge( + new IFluidInfoHandler() { + @Override + public FluidTank getTank() { + return tileEntity.fluidTank; + } + }, + Type.STANDARD, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalWasher.png"), + 5, + 4 + )); + guiElements.add(new GuiGasGauge( + new IGasInfoHandler() { + @Override + public GasTank getTank() { + return tileEntity.inputTank; + } + }, + GuiGauge.Type.STANDARD, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalWasher.png"), + 26, + 13 + )); + guiElements.add(new GuiGasGauge( + new IGasInfoHandler() { + @Override + public GasTank getTank() { + return tileEntity.outputTank; + } + }, + GuiGauge.Type.STANDARD, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalWasher.png"), + 133, + 13 + )); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalWasher.png"), 154, 4).with(SlotOverlay.POWER)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalWasher.png"), 154, 55).with(SlotOverlay.MINUS)); + guiElements.add( + new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalWasher.png"), + 154, + 4 + ) + .with(SlotOverlay.POWER) + ); + guiElements.add( + new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalWasher.png"), + 154, + 55 + ) + .with(SlotOverlay.MINUS) + ); - guiElements.add(new GuiProgress(new IProgressInfoHandler() - { - @Override - public double getProgress() - { - return tileEntity.isActive ? 1 : 0; - } - }, ProgressBar.LARGE_RIGHT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalWasher.png"), 62, 38)); - } + guiElements.add(new GuiProgress( + new IProgressInfoHandler() { + @Override + public double getProgress() { + return tileEntity.isActive ? 1 : 0; + } + }, + ProgressBar.LARGE_RIGHT, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalWasher.png"), + 62, + 38 + )); + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); - - fontRendererObj.drawString(tileEntity.getInventoryName(), 45, 4, 0x404040); - - if(xAxis >= 116 && xAxis <= 168 && yAxis >= 76 && yAxis <= 80) - { - drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis); - } + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + fontRendererObj.drawString(tileEntity.getInventoryName(), 45, 4, 0x404040); - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalWasher.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - int displayInt; + if (xAxis >= 116 && xAxis <= 168 && yAxis >= 76 && yAxis <= 80) { + drawCreativeTabHoveringText( + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis + ); + } - displayInt = tileEntity.getScaledEnergyLevel(52); - drawTexturedModalRect(guiWidth + 116, guiHeight + 76, 176, 0, displayInt, 4); + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalWasher.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int displayInt; + + displayInt = tileEntity.getScaledEnergyLevel(52); + drawTexturedModalRect(guiWidth + 116, guiHeight + 76, 176, 0, displayInt, 4); + + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } } diff --git a/src/main/java/mekanism/client/gui/GuiCombiner.java b/src/main/java/mekanism/client/gui/GuiCombiner.java index 70dad2b1c..080e505d4 100644 --- a/src/main/java/mekanism/client/gui/GuiCombiner.java +++ b/src/main/java/mekanism/client/gui/GuiCombiner.java @@ -1,22 +1,21 @@ package mekanism.client.gui; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.gui.element.GuiProgress.ProgressBar; import mekanism.common.tile.TileEntityAdvancedElectricMachine; import net.minecraft.entity.player.InventoryPlayer; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiCombiner extends GuiAdvancedElectricMachine -{ - public GuiCombiner(InventoryPlayer inventory, TileEntityAdvancedElectricMachine tentity) - { - super(inventory, tentity); - } - - @Override - public ProgressBar getProgressType() - { - return ProgressBar.STONE; - } +public class GuiCombiner extends GuiAdvancedElectricMachine { + public GuiCombiner( + InventoryPlayer inventory, TileEntityAdvancedElectricMachine tentity + ) { + super(inventory, tentity); + } + + @Override + public ProgressBar getProgressType() { + return ProgressBar.STONE; + } } diff --git a/src/main/java/mekanism/client/gui/GuiCredits.java b/src/main/java/mekanism/client/gui/GuiCredits.java index 5e9d8cece..7a31b72be 100644 --- a/src/main/java/mekanism/client/gui/GuiCredits.java +++ b/src/main/java/mekanism/client/gui/GuiCredits.java @@ -1,76 +1,90 @@ package mekanism.client.gui; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.EnumColor; import mekanism.common.Mekanism; import mekanism.common.base.IModule; import mekanism.common.util.MekanismUtils; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiCredits extends GuiScreen -{ - private static String updateProgress = ""; +public class GuiCredits extends GuiScreen { + private static String updateProgress = ""; - @Override - public void initGui() - { - buttonList.clear(); - buttonList.add(new GuiButton(0, width / 2 - 100, height / 4 + 72 + 12, "Update")); - buttonList.add(new GuiButton(1, width / 2 - 100, height / 4 + 96 + 12, "Cancel")); - } + @Override + public void initGui() { + buttonList.clear(); + buttonList.add(new GuiButton(0, width / 2 - 100, height / 4 + 72 + 12, "Update")); + buttonList.add(new GuiButton(1, width / 2 - 100, height / 4 + 96 + 12, "Cancel")); + } - public static void updateInfo(String info) - { - updateProgress = info; - } + public static void updateInfo(String info) { + updateProgress = info; + } - @Override - protected void actionPerformed(GuiButton guibutton) - { - if(guibutton.id == 0) - { - updateProgress = "You already have the latest version."; - } - else if(guibutton.id == 1) - { - mc.displayGuiScreen(null); - } - } + @Override + protected void actionPerformed(GuiButton guibutton) { + if (guibutton.id == 0) { + updateProgress = "You already have the latest version."; + } else if (guibutton.id == 1) { + mc.displayGuiScreen(null); + } + } - public void writeText(String text, int yAxis) - { - drawString(fontRendererObj, text, width / 2 - 140, (height / 4 - 60) + 20 + yAxis, 0xa0a0a0); - } + public void writeText(String text, int yAxis) { + drawString( + fontRendererObj, + text, + width / 2 - 140, + (height / 4 - 60) + 20 + yAxis, + 0xa0a0a0 + ); + } - @Override - public boolean doesGuiPauseGame() - { - return false; - } + @Override + public boolean doesGuiPauseGame() { + return false; + } - @Override - public void drawScreen(int mouseX, int mouseY, float partialTick) - { - drawDefaultBackground(); - drawCenteredString(fontRendererObj, EnumColor.DARK_BLUE + "Mekanism" + EnumColor.GREY + " by aidancbrady", width / 2, (height / 4 - 60) + 20, 0xffffff); + @Override + public void drawScreen(int mouseX, int mouseY, float partialTick) { + drawDefaultBackground(); + drawCenteredString( + fontRendererObj, + EnumColor.DARK_BLUE + "Mekanism" + EnumColor.GREY + " by aidancbrady", + width / 2, + (height / 4 - 60) + 20, + 0xffffff + ); - writeText(EnumColor.INDIGO + "Mekanism " + EnumColor.GREY + Mekanism.versionNumber, 36); + writeText( + EnumColor.INDIGO + "Mekanism " + EnumColor.GREY + Mekanism.versionNumber, 36 + ); - int size = 36; + int size = 36; - for(IModule module : Mekanism.modulesLoaded) - { - size += 9; - writeText(EnumColor.INDIGO + "Mekanism" + module.getName() + EnumColor.GREY + " " + module.getVersion(), size); - } + for (IModule module : Mekanism.modulesLoaded) { + size += 9; + writeText( + EnumColor.INDIGO + "Mekanism" + module.getName() + EnumColor.GREY + " " + + module.getVersion(), + size + ); + } - writeText(EnumColor.GREY + "*Code, textures, and ideas by aidancbrady", size+27); - writeText(EnumColor.GREY + "Recent news: " + EnumColor.DARK_BLUE + (!Mekanism.recentNews.contains("null") ? Mekanism.recentNews : "couldn't access."), size+36); - writeText(EnumColor.GREY + updateProgress, size+45); + writeText( + EnumColor.GREY + "*Code, textures, and ideas by aidancbrady", size + 27 + ); + writeText( + EnumColor.GREY + "Recent news: " + EnumColor.DARK_BLUE + + (!Mekanism.recentNews.contains("null") ? Mekanism.recentNews + : "couldn't access."), + size + 36 + ); + writeText(EnumColor.GREY + updateProgress, size + 45); - super.drawScreen(mouseX, mouseY, partialTick); - } + super.drawScreen(mouseX, mouseY, partialTick); + } } diff --git a/src/main/java/mekanism/client/gui/GuiCrusher.java b/src/main/java/mekanism/client/gui/GuiCrusher.java index 0283f3aa8..d1b8f3a92 100644 --- a/src/main/java/mekanism/client/gui/GuiCrusher.java +++ b/src/main/java/mekanism/client/gui/GuiCrusher.java @@ -1,22 +1,19 @@ package mekanism.client.gui; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.gui.element.GuiProgress.ProgressBar; import mekanism.common.tile.TileEntityElectricMachine; import net.minecraft.entity.player.InventoryPlayer; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiCrusher extends GuiElectricMachine -{ - public GuiCrusher(InventoryPlayer inventory, TileEntityElectricMachine tentity) - { - super(inventory, tentity); - } - - @Override - public ProgressBar getProgressType() - { - return ProgressBar.CRUSH; - } +public class GuiCrusher extends GuiElectricMachine { + public GuiCrusher(InventoryPlayer inventory, TileEntityElectricMachine tentity) { + super(inventory, tentity); + } + + @Override + public ProgressBar getProgressType() { + return ProgressBar.CRUSH; + } } diff --git a/src/main/java/mekanism/client/gui/GuiDictionary.java b/src/main/java/mekanism/client/gui/GuiDictionary.java index e89dbcf7d..194464df9 100644 --- a/src/main/java/mekanism/client/gui/GuiDictionary.java +++ b/src/main/java/mekanism/client/gui/GuiDictionary.java @@ -1,5 +1,7 @@ package mekanism.client.gui; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.gui.element.GuiScrollList; import mekanism.client.sound.SoundHandler; import mekanism.common.inventory.container.ContainerDictionary; @@ -9,146 +11,142 @@ import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; - import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiDictionary extends GuiMekanism -{ - public ItemStack itemType; - - public GuiScrollList scrollList; +public class GuiDictionary extends GuiMekanism { + public ItemStack itemType; - public GuiDictionary(InventoryPlayer inventory) - { - super(new ContainerDictionary(inventory)); - - guiElements.add(scrollList = new GuiScrollList(this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png"), 8, 30, 160, 4)); - } + public GuiScrollList scrollList; - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + public GuiDictionary(InventoryPlayer inventory) { + super(new ContainerDictionary(inventory)); - fontRendererObj.drawString(LangUtils.localize("item.Dictionary.name"), 64, 5, 0x404040); - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, ySize - 96 + 2, 0x404040); + guiElements.add( + scrollList = new GuiScrollList( + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png"), + 8, + 30, + 160, + 4 + ) + ); + } - if(itemType != null) - { - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_LIGHTING); - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), itemType, 6, 6); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + fontRendererObj.drawString( + LangUtils.localize("item.Dictionary.name"), 64, 5, 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, ySize - 96 + 2, 0x404040 + ); - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiDictionary.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + if (itemType != null) { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_LIGHTING); + itemRender.renderItemAndEffectIntoGUI( + fontRendererObj, mc.getTextureManager(), itemType, 6, 6 + ); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } - int xAxis = mouseX - guiWidth; - int yAxis = mouseY - guiHeight; + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - if(xAxis >= 6 && xAxis <= 22 && yAxis >= 6 && yAxis <= 22) - { - GL11.glPushMatrix(); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_DEPTH_TEST); + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiDictionary.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - int x = guiWidth + 6; - int y = guiHeight + 6; - drawGradientRect(x, y, x + 16, y + 16, -2130706433, -2130706433); + int xAxis = mouseX - guiWidth; + int yAxis = mouseY - guiHeight; - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_DEPTH_TEST); - GL11.glPopMatrix(); - } - - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } + if (xAxis >= 6 && xAxis <= 22 && yAxis >= 6 && yAxis <= 22) { + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); - @Override - public boolean doesGuiPauseGame() - { - return false; - } + int x = guiWidth + 6; + int y = guiHeight + 6; + drawGradientRect(x, y, x + 16, y + 16, -2130706433, -2130706433); - @Override - protected void mouseClicked(int mouseX, int mouseY, int button) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glPopMatrix(); + } - if(button == 0) - { - if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) - { - Slot hovering = null; + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } - for(int i = 0; i < inventorySlots.inventorySlots.size(); i++) - { - Slot slot = (Slot)inventorySlots.inventorySlots.get(i); + @Override + public boolean doesGuiPauseGame() { + return false; + } - if(isMouseOverSlot(slot, mouseX, mouseY)) - { - hovering = slot; - break; - } - } + @Override + protected void mouseClicked(int mouseX, int mouseY, int button) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - if(hovering != null) - { - ItemStack stack = hovering.getStack(); + if (button == 0) { + if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + Slot hovering = null; - if(stack != null) - { - itemType = stack.copy(); - itemType.stackSize = 1; + for (int i = 0; i < inventorySlots.inventorySlots.size(); i++) { + Slot slot = (Slot) inventorySlots.inventorySlots.get(i); - scrollList.setText(MekanismUtils.getOreDictName(itemType)); - SoundHandler.playSound("gui.button.press"); - - return; - } - } - } + if (isMouseOverSlot(slot, mouseX, mouseY)) { + hovering = slot; + break; + } + } - if(xAxis >= 6 && xAxis <= 22 && yAxis >= 6 && yAxis <= 22) - { - ItemStack stack = mc.thePlayer.inventory.getItemStack(); + if (hovering != null) { + ItemStack stack = hovering.getStack(); - if(stack != null && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) - { - itemType = stack.copy(); - itemType.stackSize = 1; + if (stack != null) { + itemType = stack.copy(); + itemType.stackSize = 1; - scrollList.setText(MekanismUtils.getOreDictName(itemType)); - } - else if(stack == null && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) - { - itemType = null; - - scrollList.setText(null); - } + scrollList.setText(MekanismUtils.getOreDictName(itemType)); + SoundHandler.playSound("gui.button.press"); + + return; + } + } + } + + if (xAxis >= 6 && xAxis <= 22 && yAxis >= 6 && yAxis <= 22) { + ItemStack stack = mc.thePlayer.inventory.getItemStack(); + + if (stack != null && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + itemType = stack.copy(); + itemType.stackSize = 1; + + scrollList.setText(MekanismUtils.getOreDictName(itemType)); + } else if (stack == null && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + itemType = null; + + scrollList.setText(null); + } SoundHandler.playSound("gui.button.press"); - } - } + } + } - super.mouseClicked(mouseX, mouseY, button); - } + super.mouseClicked(mouseX, mouseY, button); + } } diff --git a/src/main/java/mekanism/client/gui/GuiDigitalMiner.java b/src/main/java/mekanism/client/gui/GuiDigitalMiner.java index d823730a6..bb70ee267 100644 --- a/src/main/java/mekanism/client/gui/GuiDigitalMiner.java +++ b/src/main/java/mekanism/client/gui/GuiDigitalMiner.java @@ -3,6 +3,8 @@ package mekanism.client.gui; import java.util.ArrayList; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.util.ListUtils; @@ -30,316 +32,400 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.InventoryPlayer; - import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiDigitalMiner extends GuiMekanism -{ - public TileEntityDigitalMiner tileEntity; +public class GuiDigitalMiner extends GuiMekanism { + public TileEntityDigitalMiner tileEntity; - public GuiButton startButton; - public GuiButton stopButton; - public GuiButton configButton; + public GuiButton startButton; + public GuiButton stopButton; + public GuiButton configButton; - public GuiDigitalMiner(InventoryPlayer inventory, TileEntityDigitalMiner tentity) - { - super(tentity, new ContainerDigitalMiner(inventory, tentity)); - tileEntity = tentity; + public GuiDigitalMiner(InventoryPlayer inventory, TileEntityDigitalMiner tentity) { + super(tentity, new ContainerDigitalMiner(inventory, tentity)); + tileEntity = tentity; - guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMiner.png"))); - guiElements.add(new GuiSecurityTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMiner.png"))); - guiElements.add(new GuiUpgradeTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMiner.png"))); - guiElements.add(new GuiPowerBar(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMiner.png"), 163, 23)); - guiElements.add(new GuiVisualsTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMiner.png"))); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() { - @Override - public List getInfo() - { - String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.getPerTick()); - return ListUtils.asList(LangUtils.localize("gui.using") + ": " + multiplier + "/t", LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); - } - }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMiner.png"))); + guiElements.add(new GuiRedstoneControl( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMiner.png") + )); + guiElements.add(new GuiSecurityTab( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMiner.png") + )); + guiElements.add(new GuiUpgradeTab( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMiner.png") + )); + guiElements.add(new GuiPowerBar( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMiner.png"), + 163, + 23 + )); + guiElements.add(new GuiVisualsTab( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMiner.png") + )); + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() { + String multiplier + = MekanismUtils.getEnergyDisplay(tileEntity.getPerTick()); + return ListUtils.asList( + LangUtils.localize("gui.using") + ": " + multiplier + "/t", + LangUtils.localize("gui.needed") + ": " + + MekanismUtils.getEnergyDisplay( + tileEntity.getMaxEnergy() - tileEntity.getEnergy() + ) + ); + } + }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMiner.png"))); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMiner.png"), 151, 5).with(SlotOverlay.POWER)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMiner.png"), 143, 26)); + guiElements.add( + new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMiner.png"), + 151, + 5 + ) + .with(SlotOverlay.POWER) + ); + guiElements.add(new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMiner.png"), + 143, + 26 + )); - ySize+=64; - } + ySize += 64; + } - @Override - public void initGui() - { - super.initGui(); + @Override + public void initGui() { + super.initGui(); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; - buttonList.clear(); - startButton = new GuiButton(0, guiWidth + 69, guiHeight + 17, 60, 20, LangUtils.localize("gui.start")); + buttonList.clear(); + startButton = new GuiButton( + 0, guiWidth + 69, guiHeight + 17, 60, 20, LangUtils.localize("gui.start") + ); - if(tileEntity.searcher.state != State.IDLE && tileEntity.running) - { - startButton.enabled = false; - } + if (tileEntity.searcher.state != State.IDLE && tileEntity.running) { + startButton.enabled = false; + } - stopButton = new GuiButton(1, guiWidth + 69, guiHeight + 37, 60, 20, LangUtils.localize("gui.stop")); + stopButton = new GuiButton( + 1, guiWidth + 69, guiHeight + 37, 60, 20, LangUtils.localize("gui.stop") + ); - if(tileEntity.searcher.state == State.IDLE || !tileEntity.running) - { - stopButton.enabled = false; - } + if (tileEntity.searcher.state == State.IDLE || !tileEntity.running) { + stopButton.enabled = false; + } - configButton = new GuiButton(2, guiWidth + 69, guiHeight + 57, 60, 20, LangUtils.localize("gui.config")); + configButton = new GuiButton( + 2, guiWidth + 69, guiHeight + 57, 60, 20, LangUtils.localize("gui.config") + ); - if(tileEntity.searcher.state != State.IDLE) - { - configButton.enabled = false; - } + if (tileEntity.searcher.state != State.IDLE) { + configButton.enabled = false; + } - buttonList.add(startButton); - buttonList.add(stopButton); - buttonList.add(configButton); - } + buttonList.add(startButton); + buttonList.add(stopButton); + buttonList.add(configButton); + } - @Override - protected void actionPerformed(GuiButton guibutton) - { - super.actionPerformed(guibutton); + @Override + protected void actionPerformed(GuiButton guibutton) { + super.actionPerformed(guibutton); - if(guibutton.id == 0) - { - ArrayList data = new ArrayList(); - data.add(3); + if (guibutton.id == 0) { + ArrayList data = new ArrayList(); + data.add(3); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - } - else if(guibutton.id == 1) - { - ArrayList data = new ArrayList(); - data.add(4); + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); + } else if (guibutton.id == 1) { + ArrayList data = new ArrayList(); + data.add(4); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - } - else if(guibutton.id == 2) - { - Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0)); - } - } + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); + } else if (guibutton.id == 2) { + Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage( + MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0 + )); + } + } - @Override - public void updateScreen() - { - super.updateScreen(); + @Override + public void updateScreen() { + super.updateScreen(); - if(tileEntity.searcher.state != State.IDLE && tileEntity.running) - { - startButton.enabled = false; - } - else { - startButton.enabled = true; - } + if (tileEntity.searcher.state != State.IDLE && tileEntity.running) { + startButton.enabled = false; + } else { + startButton.enabled = true; + } - if(tileEntity.searcher.state == State.IDLE || !tileEntity.running) - { - stopButton.enabled = false; - } - else { - stopButton.enabled = true; - } + if (tileEntity.searcher.state == State.IDLE || !tileEntity.running) { + stopButton.enabled = false; + } else { + stopButton.enabled = true; + } - if(tileEntity.searcher.state != State.IDLE) - { - configButton.enabled = false; - } - else { - configButton.enabled = true; - } - } + if (tileEntity.searcher.state != State.IDLE) { + configButton.enabled = false; + } else { + configButton.enabled = true; + } + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - fontRendererObj.drawString(tileEntity.getInventoryName(), 69, 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); + fontRendererObj.drawString(tileEntity.getInventoryName(), 69, 6, 0x404040); + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040 + ); - fontRendererObj.drawString(tileEntity.running ? LangUtils.localize("gui.digitalMiner.running") : LangUtils.localize("gui.idle"), 9, 10, 0x00CD00); - fontRendererObj.drawString(tileEntity.searcher.state.desc, 9, 19, 0x00CD00); + fontRendererObj.drawString( + tileEntity.running ? LangUtils.localize("gui.digitalMiner.running") + : LangUtils.localize("gui.idle"), + 9, + 10, + 0x00CD00 + ); + fontRendererObj.drawString(tileEntity.searcher.state.desc, 9, 19, 0x00CD00); - fontRendererObj.drawString(LangUtils.localize("gui.eject") + ": " + LangUtils.localize("gui." + (tileEntity.doEject ? "on" : "off")), 9, 30, 0x00CD00); - fontRendererObj.drawString(LangUtils.localize("gui.digitalMiner.pull") + ": " + LangUtils.localize("gui." + (tileEntity.doPull ? "on" : "off")), 9, 39, 0x00CD00); - fontRendererObj.drawString(LangUtils.localize("gui.digitalMiner.silk") + ": " + LangUtils.localize("gui." + (tileEntity.silkTouch ? "on" : "off")), 9, 48, 0x00CD00); + fontRendererObj.drawString( + LangUtils.localize("gui.eject") + ": " + + LangUtils.localize("gui." + (tileEntity.doEject ? "on" : "off")), + 9, + 30, + 0x00CD00 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.digitalMiner.pull") + ": " + + LangUtils.localize("gui." + (tileEntity.doPull ? "on" : "off")), + 9, + 39, + 0x00CD00 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.digitalMiner.silk") + ": " + + LangUtils.localize("gui." + (tileEntity.silkTouch ? "on" : "off")), + 9, + 48, + 0x00CD00 + ); - fontRendererObj.drawString(LangUtils.localize("gui.digitalMiner.toMine") + ":", 9, 59, 0x00CD00); - fontRendererObj.drawString("" + tileEntity.clientToMine, 9, 68, 0x00CD00); + fontRendererObj.drawString( + LangUtils.localize("gui.digitalMiner.toMine") + ":", 9, 59, 0x00CD00 + ); + fontRendererObj.drawString("" + tileEntity.clientToMine, 9, 68, 0x00CD00); - if(tileEntity.missingStack != null) - { - GL11.glPushMatrix(); - GL11.glColor4f(1, 1, 1, 1); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); + if (tileEntity.missingStack != null) { + GL11.glPushMatrix(); + GL11.glColor4f(1, 1, 1, 1); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); - mc.getTextureManager().bindTexture(MekanismRenderer.getBlocksTexture()); - - itemRender.renderIcon(144, 27, MekanismRenderer.getColorIcon(EnumColor.DARK_RED), 16, 16); - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), tileEntity.missingStack, 144, 27); - - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } - else { - mc.getTextureManager().bindTexture(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiSlot.png")); - drawTexturedModalRect(143, 26, SlotOverlay.CHECK.textureX, SlotOverlay.CHECK.textureY, 18, 18); - } + mc.getTextureManager().bindTexture(MekanismRenderer.getBlocksTexture()); - if(xAxis >= 164 && xAxis <= 168 && yAxis >= 25 && yAxis <= 77) - { - drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis); - } + itemRender.renderIcon( + 144, 27, MekanismRenderer.getColorIcon(EnumColor.DARK_RED), 16, 16 + ); + itemRender.renderItemAndEffectIntoGUI( + fontRendererObj, mc.getTextureManager(), tileEntity.missingStack, 144, 27 + ); - if(xAxis >= 147 && xAxis <= 161 && yAxis >= 47 && yAxis <= 61) - { - drawCreativeTabHoveringText(LangUtils.localize("gui.autoEject"), xAxis, yAxis); - } + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } else { + mc.getTextureManager().bindTexture( + MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiSlot.png") + ); + drawTexturedModalRect( + 143, 26, SlotOverlay.CHECK.textureX, SlotOverlay.CHECK.textureY, 18, 18 + ); + } - if(xAxis >= 147 && xAxis <= 161 && yAxis >= 63 && yAxis <= 77) - { - drawCreativeTabHoveringText(LangUtils.localize("gui.digitalMiner.autoPull"), xAxis, yAxis); - } + if (xAxis >= 164 && xAxis <= 168 && yAxis >= 25 && yAxis <= 77) { + drawCreativeTabHoveringText( + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis + ); + } - if(xAxis >= 144 && xAxis <= 160 && yAxis >= 27 && yAxis <= 43) - { - if(tileEntity.missingStack != null) - { - drawCreativeTabHoveringText(LangUtils.localize("gui.digitalMiner.missingBlock"), xAxis, yAxis); - } - else { - drawCreativeTabHoveringText(LangUtils.localize("gui.well"), xAxis, yAxis); - } - } + if (xAxis >= 147 && xAxis <= 161 && yAxis >= 47 && yAxis <= 61) { + drawCreativeTabHoveringText( + LangUtils.localize("gui.autoEject"), xAxis, yAxis + ); + } - if(xAxis >= 131 && xAxis <= 145 && yAxis >= 47 && yAxis <= 61) - { - drawCreativeTabHoveringText(LangUtils.localize("gui.digitalMiner.reset"), xAxis, yAxis); - } + if (xAxis >= 147 && xAxis <= 161 && yAxis >= 63 && yAxis <= 77) { + drawCreativeTabHoveringText( + LangUtils.localize("gui.digitalMiner.autoPull"), xAxis, yAxis + ); + } - if(xAxis >= 131 && xAxis <= 145 && yAxis >= 63 && yAxis <= 77) - { - drawCreativeTabHoveringText(LangUtils.localize("gui.digitalMiner.silkTouch"), xAxis, yAxis); - } + if (xAxis >= 144 && xAxis <= 160 && yAxis >= 27 && yAxis <= 43) { + if (tileEntity.missingStack != null) { + drawCreativeTabHoveringText( + LangUtils.localize("gui.digitalMiner.missingBlock"), xAxis, yAxis + ); + } else { + drawCreativeTabHoveringText(LangUtils.localize("gui.well"), xAxis, yAxis); + } + } - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + if (xAxis >= 131 && xAxis <= 145 && yAxis >= 47 && yAxis <= 61) { + drawCreativeTabHoveringText( + LangUtils.localize("gui.digitalMiner.reset"), xAxis, yAxis + ); + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMiner.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + if (xAxis >= 131 && xAxis <= 145 && yAxis >= 63 && yAxis <= 77) { + drawCreativeTabHoveringText( + LangUtils.localize("gui.digitalMiner.silkTouch"), xAxis, yAxis + ); + } - int xAxis = mouseX - guiWidth; - int yAxis = mouseY - guiHeight; + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - int displayInt; + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMiner.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - displayInt = tileEntity.getScaledEnergyLevel(52); - drawTexturedModalRect(guiWidth + 164, guiHeight + 25 + 52 - displayInt, 176, 52 - displayInt, 4, displayInt); + int xAxis = mouseX - guiWidth; + int yAxis = mouseY - guiHeight; - if(xAxis >= 147 && xAxis <= 161 && yAxis >= 47 && yAxis <= 61) - { - drawTexturedModalRect(guiWidth + 147, guiHeight + 47, 176 + 4, 0, 14, 14); - } - else { - drawTexturedModalRect(guiWidth + 147, guiHeight + 47, 176 + 4, 14, 14, 14); - } + int displayInt; - if(xAxis >= 147 && xAxis <= 161 && yAxis >= 63 && yAxis <= 77) - { - drawTexturedModalRect(guiWidth + 147, guiHeight + 63, 176 + 4 + 14, 0, 14, 14); - } - else { - drawTexturedModalRect(guiWidth + 147, guiHeight + 63, 176 + 4 + 14, 14, 14, 14); - } + displayInt = tileEntity.getScaledEnergyLevel(52); + drawTexturedModalRect( + guiWidth + 164, + guiHeight + 25 + 52 - displayInt, + 176, + 52 - displayInt, + 4, + displayInt + ); - if(xAxis >= 131 && xAxis <= 145 && yAxis >= 47 && yAxis <= 61) - { - drawTexturedModalRect(guiWidth + 131, guiHeight + 47, 176 + 4 + 28, 0, 14, 14); - } - else { - drawTexturedModalRect(guiWidth + 131, guiHeight + 47, 176 + 4 + 28, 14, 14, 14); - } + if (xAxis >= 147 && xAxis <= 161 && yAxis >= 47 && yAxis <= 61) { + drawTexturedModalRect(guiWidth + 147, guiHeight + 47, 176 + 4, 0, 14, 14); + } else { + drawTexturedModalRect(guiWidth + 147, guiHeight + 47, 176 + 4, 14, 14, 14); + } - if(xAxis >= 131 && xAxis <= 145 && yAxis >= 63 && yAxis <= 77) - { - drawTexturedModalRect(guiWidth + 131, guiHeight + 63, 176 + 4 + 42, 0, 14, 14); - } - else { - drawTexturedModalRect(guiWidth + 131, guiHeight + 63, 176 + 4 + 42, 14, 14, 14); - } + if (xAxis >= 147 && xAxis <= 161 && yAxis >= 63 && yAxis <= 77) { + drawTexturedModalRect( + guiWidth + 147, guiHeight + 63, 176 + 4 + 14, 0, 14, 14 + ); + } else { + drawTexturedModalRect( + guiWidth + 147, guiHeight + 63, 176 + 4 + 14, 14, 14, 14 + ); + } - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } + if (xAxis >= 131 && xAxis <= 145 && yAxis >= 47 && yAxis <= 61) { + drawTexturedModalRect( + guiWidth + 131, guiHeight + 47, 176 + 4 + 28, 0, 14, 14 + ); + } else { + drawTexturedModalRect( + guiWidth + 131, guiHeight + 47, 176 + 4 + 28, 14, 14, 14 + ); + } - @Override - protected void mouseClicked(int mouseX, int mouseY, int button) - { - super.mouseClicked(mouseX, mouseY, button); + if (xAxis >= 131 && xAxis <= 145 && yAxis >= 63 && yAxis <= 77) { + drawTexturedModalRect( + guiWidth + 131, guiHeight + 63, 176 + 4 + 42, 0, 14, 14 + ); + } else { + drawTexturedModalRect( + guiWidth + 131, guiHeight + 63, 176 + 4 + 42, 14, 14, 14 + ); + } - if(button == 0) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } - if(xAxis >= 147 && xAxis <= 161 && yAxis >= 47 && yAxis <= 61) - { + @Override + protected void mouseClicked(int mouseX, int mouseY, int button) { + super.mouseClicked(mouseX, mouseY, button); + + if (button == 0) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + if (xAxis >= 147 && xAxis <= 161 && yAxis >= 47 && yAxis <= 61) { SoundHandler.playSound("gui.button.press"); - ArrayList data = new ArrayList(); - data.add(0); + ArrayList data = new ArrayList(); + data.add(0); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - } + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); + } - if(xAxis >= 147 && xAxis <= 161 && yAxis >= 63 && yAxis <= 77) - { + if (xAxis >= 147 && xAxis <= 161 && yAxis >= 63 && yAxis <= 77) { SoundHandler.playSound("gui.button.press"); - ArrayList data = new ArrayList(); - data.add(1); + ArrayList data = new ArrayList(); + data.add(1); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - } + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); + } - if(xAxis >= 131 && xAxis <= 145 && yAxis >= 47 && yAxis <= 61) - { + if (xAxis >= 131 && xAxis <= 145 && yAxis >= 47 && yAxis <= 61) { SoundHandler.playSound("gui.button.press"); - ArrayList data = new ArrayList(); - data.add(5); + ArrayList data = new ArrayList(); + data.add(5); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - } + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); + } - if(xAxis >= 131 && xAxis <= 145 && yAxis >= 63 && yAxis <= 77) - { + if (xAxis >= 131 && xAxis <= 145 && yAxis >= 63 && yAxis <= 77) { SoundHandler.playSound("gui.button.press"); - ArrayList data = new ArrayList(); - data.add(9); + ArrayList data = new ArrayList(); + data.add(9); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - } - } - } + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); + } + } + } } diff --git a/src/main/java/mekanism/client/gui/GuiDigitalMinerConfig.java b/src/main/java/mekanism/client/gui/GuiDigitalMinerConfig.java index 1d35a4df8..48502cec7 100644 --- a/src/main/java/mekanism/client/gui/GuiDigitalMinerConfig.java +++ b/src/main/java/mekanism/client/gui/GuiDigitalMinerConfig.java @@ -7,6 +7,8 @@ import java.util.List; import java.util.Map; import java.util.Set; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.client.render.MekanismRenderer; @@ -30,743 +32,762 @@ import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiTextField; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; - import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiDigitalMinerConfig extends GuiMekanism -{ - public TileEntityDigitalMiner tileEntity; +public class GuiDigitalMinerConfig extends GuiMekanism { + public TileEntityDigitalMiner tileEntity; - public boolean isDragging = false; + public boolean isDragging = false; - // Scrollbar dimensions - private final int scrollX = 154; - private final int scrollY = 18; + // Scrollbar dimensions + private final int scrollX = 154; + private final int scrollY = 18; - private final int scrollW = 12; - private final int scrollH = 138; + private final int scrollW = 12; + private final int scrollH = 138; - // Filter dimensions - private final int filterX = 56; - private final int filterY = 18; + // Filter dimensions + private final int filterX = 56; + private final int filterY = 18; - private final int filterW = 96; - private final int filterH = 29; + private final int filterW = 96; + private final int filterH = 29; - public int dragOffset = 0; + public int dragOffset = 0; - public int stackSwitch = 0; + public int stackSwitch = 0; - public Map oreDictStacks = new HashMap(); - public Map modIDStacks = new HashMap(); + public Map oreDictStacks + = new HashMap(); + public Map modIDStacks + = new HashMap(); - public float scroll; + public float scroll; - private GuiTextField radiusField; - private GuiTextField minField; - private GuiTextField maxField; + private GuiTextField radiusField; + private GuiTextField minField; + private GuiTextField maxField; - public GuiDigitalMinerConfig(EntityPlayer player, TileEntityDigitalMiner tentity) - { - super(tentity, new ContainerNull(player, tentity)); - tileEntity = tentity; - } + public GuiDigitalMinerConfig(EntityPlayer player, TileEntityDigitalMiner tentity) { + super(tentity, new ContainerNull(player, tentity)); + tileEntity = tentity; + } - public int getScroll() - { - return Math.max(Math.min((int)(scroll*123), 123), 0); - } + public int getScroll() { + return Math.max(Math.min((int) (scroll * 123), 123), 0); + } - public int getFilterIndex() - { - if(needsScrollBars()) - { - final int scrollSize = tileEntity.filters.size() - 4; - return (int)((scrollSize + 0.5) * scroll); - } - - return 0; - } + public int getFilterIndex() { + if (needsScrollBars()) { + final int scrollSize = tileEntity.filters.size() - 4; + return (int) ((scrollSize + 0.5) * scroll); + } - @Override - public void updateScreen() - { - super.updateScreen(); + return 0; + } - radiusField.updateCursorCounter(); - minField.updateCursorCounter(); - maxField.updateCursorCounter(); + @Override + public void updateScreen() { + super.updateScreen(); - if(stackSwitch > 0) - { - stackSwitch--; - } + radiusField.updateCursorCounter(); + minField.updateCursorCounter(); + maxField.updateCursorCounter(); - if(stackSwitch == 0) - { - for(Map.Entry entry : oreDictStacks.entrySet()) - { - if(entry.getValue().iterStacks != null && entry.getValue().iterStacks.size() > 0) - { - if(entry.getValue().stackIndex == -1 || entry.getValue().stackIndex == entry.getValue().iterStacks.size()-1) - { - entry.getValue().stackIndex = 0; - } - else if(entry.getValue().stackIndex < entry.getValue().iterStacks.size()-1) - { - entry.getValue().stackIndex++; - } + if (stackSwitch > 0) { + stackSwitch--; + } - entry.getValue().renderStack = entry.getValue().iterStacks.get(entry.getValue().stackIndex); - } - } - - for(Map.Entry entry : modIDStacks.entrySet()) - { - if(entry.getValue().iterStacks != null && entry.getValue().iterStacks.size() > 0) - { - if(entry.getValue().stackIndex == -1 || entry.getValue().stackIndex == entry.getValue().iterStacks.size()-1) - { - entry.getValue().stackIndex = 0; - } - else if(entry.getValue().stackIndex < entry.getValue().iterStacks.size()-1) - { - entry.getValue().stackIndex++; - } + if (stackSwitch == 0) { + for (Map.Entry entry : oreDictStacks.entrySet()) { + if (entry.getValue().iterStacks != null + && entry.getValue().iterStacks.size() > 0) { + if (entry.getValue().stackIndex == -1 + || entry.getValue().stackIndex + == entry.getValue().iterStacks.size() - 1) { + entry.getValue().stackIndex = 0; + } else if (entry.getValue().stackIndex < entry.getValue().iterStacks.size() - 1) { + entry.getValue().stackIndex++; + } - entry.getValue().renderStack = entry.getValue().iterStacks.get(entry.getValue().stackIndex); - } - } + entry.getValue().renderStack + = entry.getValue().iterStacks.get(entry.getValue().stackIndex); + } + } - stackSwitch = 20; - } - else { - for(Map.Entry entry : oreDictStacks.entrySet()) - { - if(entry.getValue().iterStacks != null && entry.getValue().iterStacks.size() == 0) - { - entry.getValue().renderStack = null; - } - } - - for(Map.Entry entry : modIDStacks.entrySet()) - { - if(entry.getValue().iterStacks != null && entry.getValue().iterStacks.size() == 0) - { - entry.getValue().renderStack = null; - } - } - } + for (Map.Entry entry : modIDStacks.entrySet()) { + if (entry.getValue().iterStacks != null + && entry.getValue().iterStacks.size() > 0) { + if (entry.getValue().stackIndex == -1 + || entry.getValue().stackIndex + == entry.getValue().iterStacks.size() - 1) { + entry.getValue().stackIndex = 0; + } else if (entry.getValue().stackIndex < entry.getValue().iterStacks.size() - 1) { + entry.getValue().stackIndex++; + } - Set oreDictFilters = new HashSet(); - Set modIDFilters = new HashSet(); + entry.getValue().renderStack + = entry.getValue().iterStacks.get(entry.getValue().stackIndex); + } + } - for(int i = 0; i < 4; i++) - { - if(tileEntity.filters.get(getFilterIndex()+i) instanceof MOreDictFilter) - { - oreDictFilters.add((MOreDictFilter)tileEntity.filters.get(getFilterIndex()+i)); - } - else if(tileEntity.filters.get(getFilterIndex()+i) instanceof MModIDFilter) - { - modIDFilters.add((MModIDFilter)tileEntity.filters.get(getFilterIndex()+i)); - } - } + stackSwitch = 20; + } else { + for (Map.Entry entry : oreDictStacks.entrySet()) { + if (entry.getValue().iterStacks != null + && entry.getValue().iterStacks.size() == 0) { + entry.getValue().renderStack = null; + } + } - for(MinerFilter filter : tileEntity.filters) - { - if(filter instanceof MOreDictFilter && !oreDictFilters.contains(filter)) - { - if(oreDictStacks.containsKey(filter)) - { - oreDictStacks.remove(filter); - } - } - else if(filter instanceof MModIDFilter && !modIDFilters.contains(filter)) - { - if(modIDStacks.containsKey(filter)) - { - modIDStacks.remove(filter); - } - } - } - } + for (Map.Entry entry : modIDStacks.entrySet()) { + if (entry.getValue().iterStacks != null + && entry.getValue().iterStacks.size() == 0) { + entry.getValue().renderStack = null; + } + } + } - @Override - public void mouseClicked(int mouseX, int mouseY, int button) - { - super.mouseClicked(mouseX, mouseY, button); + Set oreDictFilters = new HashSet(); + Set modIDFilters = new HashSet(); - radiusField.mouseClicked(mouseX, mouseY, button); - minField.mouseClicked(mouseX, mouseY, button); - maxField.mouseClicked(mouseX, mouseY, button); + for (int i = 0; i < 4; i++) { + if (tileEntity.filters.get(getFilterIndex() + i) instanceof MOreDictFilter) { + oreDictFilters.add((MOreDictFilter + ) tileEntity.filters.get(getFilterIndex() + i)); + } else if (tileEntity.filters.get(getFilterIndex() + i) instanceof MModIDFilter) { + modIDFilters.add((MModIDFilter + ) tileEntity.filters.get(getFilterIndex() + i)); + } + } - if(button == 0) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + for (MinerFilter filter : tileEntity.filters) { + if (filter instanceof MOreDictFilter && !oreDictFilters.contains(filter)) { + if (oreDictStacks.containsKey(filter)) { + oreDictStacks.remove(filter); + } + } else if (filter instanceof MModIDFilter && !modIDFilters.contains(filter)) { + if (modIDStacks.containsKey(filter)) { + modIDStacks.remove(filter); + } + } + } + } - if(xAxis >= 154 && xAxis <= 166 && yAxis >= getScroll()+18 && yAxis <= getScroll()+18+15) - { - if(needsScrollBars()) - { - dragOffset = yAxis - (getScroll()+18); - isDragging = true; - } - else { - scroll = 0; - } - } + @Override + public void mouseClicked(int mouseX, int mouseY, int button) { + super.mouseClicked(mouseX, mouseY, button); - for(int i = 0; i < 4; i++) - { - if(tileEntity.filters.get(getFilterIndex()+i) != null) - { - int yStart = i*29 + 18; + radiusField.mouseClicked(mouseX, mouseY, button); + minField.mouseClicked(mouseX, mouseY, button); + maxField.mouseClicked(mouseX, mouseY, button); - // Check for sorting button - final int arrowX = filterX + filterW - 12; - - if(getFilterIndex() + i > 0) - { - if(xAxis >= arrowX && xAxis <= arrowX + 10 && yAxis >= yStart + 14 && yAxis <= yStart + 20) - { - // Process up button click - final ArrayList data = new ArrayList(); - data.add(11); - data.add(getFilterIndex() + i); + if (button == 0) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - SoundHandler.playSound("gui.button.press"); - - return; - } - } - - if(getFilterIndex() + i < tileEntity.filters.size() - 1) - { - if(xAxis >= arrowX && xAxis <= arrowX + 10 && yAxis >= yStart + 21 && yAxis <= yStart + 27) - { - // Process down button click - final ArrayList data = new ArrayList(); - data.add(12); - data.add(getFilterIndex() + i); + if (xAxis >= 154 && xAxis <= 166 && yAxis >= getScroll() + 18 + && yAxis <= getScroll() + 18 + 15) { + if (needsScrollBars()) { + dragOffset = yAxis - (getScroll() + 18); + isDragging = true; + } else { + scroll = 0; + } + } - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - SoundHandler.playSound("gui.button.press"); - - return; - } - } + for (int i = 0; i < 4; i++) { + if (tileEntity.filters.get(getFilterIndex() + i) != null) { + int yStart = i * 29 + 18; - if(xAxis >= 56 && xAxis <= 152 && yAxis >= yStart && yAxis <= yStart+29) - { - MinerFilter filter = tileEntity.filters.get(getFilterIndex()+i); + // Check for sorting button + final int arrowX = filterX + filterW - 12; - if(filter instanceof MItemStackFilter) - { - SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER_INDEX, Coord4D.get(tileEntity), 1, getFilterIndex()+i, 0)); - } - else if(filter instanceof MOreDictFilter) - { - SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER_INDEX, Coord4D.get(tileEntity), 2, getFilterIndex()+i, 0)); - } - else if(filter instanceof MMaterialFilter) - { - SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER_INDEX, Coord4D.get(tileEntity), 3, getFilterIndex()+i, 0)); - } - else if(filter instanceof MModIDFilter) - { - SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER_INDEX, Coord4D.get(tileEntity), 6, getFilterIndex()+i, 0)); - } - } - } - } + if (getFilterIndex() + i > 0) { + if (xAxis >= arrowX && xAxis <= arrowX + 10 + && yAxis >= yStart + 14 && yAxis <= yStart + 20) { + // Process up button click + final ArrayList data = new ArrayList(); + data.add(11); + data.add(getFilterIndex() + i); - if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) - { + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); + SoundHandler.playSound("gui.button.press"); + + return; + } + } + + if (getFilterIndex() + i < tileEntity.filters.size() - 1) { + if (xAxis >= arrowX && xAxis <= arrowX + 10 + && yAxis >= yStart + 21 && yAxis <= yStart + 27) { + // Process down button click + final ArrayList data = new ArrayList(); + data.add(12); + data.add(getFilterIndex() + i); + + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); + SoundHandler.playSound("gui.button.press"); + + return; + } + } + + if (xAxis >= 56 && xAxis <= 152 && yAxis >= yStart + && yAxis <= yStart + 29) { + MinerFilter filter = tileEntity.filters.get(getFilterIndex() + i); + + if (filter instanceof MItemStackFilter) { + SoundHandler.playSound("gui.button.press"); + Mekanism.packetHandler.sendToServer( + new DigitalMinerGuiMessage( + MinerGuiPacket.SERVER_INDEX, + Coord4D.get(tileEntity), + 1, + getFilterIndex() + i, + 0 + ) + ); + } else if (filter instanceof MOreDictFilter) { + SoundHandler.playSound("gui.button.press"); + Mekanism.packetHandler.sendToServer( + new DigitalMinerGuiMessage( + MinerGuiPacket.SERVER_INDEX, + Coord4D.get(tileEntity), + 2, + getFilterIndex() + i, + 0 + ) + ); + } else if (filter instanceof MMaterialFilter) { + SoundHandler.playSound("gui.button.press"); + Mekanism.packetHandler.sendToServer( + new DigitalMinerGuiMessage( + MinerGuiPacket.SERVER_INDEX, + Coord4D.get(tileEntity), + 3, + getFilterIndex() + i, + 0 + ) + ); + } else if (filter instanceof MModIDFilter) { + SoundHandler.playSound("gui.button.press"); + Mekanism.packetHandler.sendToServer( + new DigitalMinerGuiMessage( + MinerGuiPacket.SERVER_INDEX, + Coord4D.get(tileEntity), + 6, + getFilterIndex() + i, + 0 + ) + ); + } + } + } + } + + if (xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 4, 0, 0)); - } + Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage( + MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 4, 0, 0 + )); + } - if(xAxis >= 39 && xAxis <= 50 && yAxis >= 67 && yAxis <= 78) - { + if (xAxis >= 39 && xAxis <= 50 && yAxis >= 67 && yAxis <= 78) { SoundHandler.playSound("gui.button.press"); - setRadius(); - } + setRadius(); + } - if(xAxis >= 39 && xAxis <= 50 && yAxis >= 92 && yAxis <= 103) - { + if (xAxis >= 39 && xAxis <= 50 && yAxis >= 92 && yAxis <= 103) { SoundHandler.playSound("gui.button.press"); - setMinY(); - } + setMinY(); + } - if(xAxis >= 39 && xAxis <= 50 && yAxis >= 117 && yAxis <= 128) - { + if (xAxis >= 39 && xAxis <= 50 && yAxis >= 117 && yAxis <= 128) { SoundHandler.playSound("gui.button.press"); - setMaxY(); - } - - if(xAxis >= 11 && xAxis <= 25 && yAxis >= 141 && yAxis <= 155) - { - ArrayList data = new ArrayList(); - data.add(10); - - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - SoundHandler.playSound("gui.button.press"); - } - } - } - - @Override - protected void mouseClickMove(int mouseX, int mouseY, int button, long ticks) - { - super.mouseClickMove(mouseX, mouseY, button, ticks); - - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); - - if(isDragging) - { - scroll = Math.min(Math.max((float)(yAxis-18-dragOffset)/123F, 0), 1); - } - } - - @Override - protected void mouseMovedOrUp(int x, int y, int type) - { - super.mouseMovedOrUp(x, y, type); - - if(type == 0 && isDragging) - { - dragOffset = 0; - isDragging = false; - } - } - - /** - * Handles mouse input. - */ - @Override - public void handleMouseInput() - { - super.handleMouseInput(); - - int i = Mouse.getEventDWheel(); - - if(i != 0 && needsScrollBars()) - { - final int j = tileEntity.filters.size() - 4; - - if(i > 0) - { - i = 1; - } - - if(i < 0) - { - i = -1; - } - - scroll = (float)(scroll - (double) i / (double) j); - - if(scroll < 0.0F) - { - scroll = 0.0F; - } - - if(scroll > 1.0F) - { - scroll = 1.0F; - } - } - } - - @Override - public void initGui() - { - super.initGui(); - - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - - buttonList.clear(); - buttonList.add(new GuiButton(0, guiWidth + 56, guiHeight + 136, 96, 20, LangUtils.localize("gui.newFilter"))); - - String prevRad = radiusField != null ? radiusField.getText() : ""; - String prevMin = minField != null ? minField.getText() : ""; - String prevMax = maxField != null ? maxField.getText() : ""; - - radiusField = new GuiTextField(fontRendererObj, guiWidth + 12, guiHeight + 67, 26, 11); - radiusField.setMaxStringLength(2); - radiusField.setText(prevRad); - - minField = new GuiTextField(fontRendererObj, guiWidth + 12, guiHeight + 92, 26, 11); - minField.setMaxStringLength(3); - minField.setText(prevMin); - - maxField = new GuiTextField(fontRendererObj, guiWidth + 12, guiHeight + 117, 26, 11); - maxField.setMaxStringLength(3); - maxField.setText(prevMax); - } - - @Override - protected void actionPerformed(GuiButton guibutton) - { - super.actionPerformed(guibutton); - - if(guibutton.id == 0) - { - Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 5, 0, 0)); - } - } - - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); - - fontRendererObj.drawString(LangUtils.localize("gui.digitalMinerConfig"), 43, 6, 0x404040); - - fontRendererObj.drawString(LangUtils.localize("gui.filters") + ":", 11, 19, 0x00CD00); - fontRendererObj.drawString("T: " + tileEntity.filters.size(), 11, 28, 0x00CD00); - - fontRendererObj.drawString("I: " + (tileEntity.inverse ? LangUtils.localize("gui.on") : LangUtils.localize("gui.off")), 11, 131, 0x00CD00); - - fontRendererObj.drawString("Radi: " + tileEntity.radius, 11, 58, 0x00CD00); - - fontRendererObj.drawString("Min: " + tileEntity.minY, 11, 83, 0x00CD00); - - fontRendererObj.drawString("Max: " + tileEntity.maxY, 11, 108, 0x00CD00); - - for(int i = 0; i < 4; i++) - { - if(tileEntity.filters.get(getFilterIndex()+i) != null) - { - MinerFilter filter = tileEntity.filters.get(getFilterIndex()+i); - int yStart = i*29 + 18; - - if(filter instanceof MItemStackFilter) - { - MItemStackFilter itemFilter = (MItemStackFilter)filter; - - if(itemFilter.itemType != null) - { - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_LIGHTING); - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), itemFilter.itemType, 59, yStart + 3); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } - - fontRendererObj.drawString(LangUtils.localize("gui.itemFilter"), 78, yStart + 2, 0x404040); - } - else if(filter instanceof MOreDictFilter) - { - MOreDictFilter oreFilter = (MOreDictFilter)filter; - - if(!oreDictStacks.containsKey(oreFilter)) - { - updateStackList(oreFilter); - } - - if(oreDictStacks.get(filter).renderStack != null) - { - try { - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_LIGHTING); - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), oreDictStacks.get(filter).renderStack, 59, yStart + 3); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } catch(Exception e) {} - } - - fontRendererObj.drawString(LangUtils.localize("gui.oredictFilter"), 78, yStart + 2, 0x404040); - } - else if(filter instanceof MMaterialFilter) - { - MMaterialFilter itemFilter = (MMaterialFilter)filter; - - if(itemFilter.materialItem != null) - { - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_LIGHTING); - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), itemFilter.materialItem, 59, yStart + 3); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } - - fontRendererObj.drawString(LangUtils.localize("gui.materialFilter"), 78, yStart + 2, 0x404040); - } - else if(filter instanceof MModIDFilter) - { - MModIDFilter modFilter = (MModIDFilter)filter; - - if(!modIDStacks.containsKey(modFilter)) - { - updateStackList(modFilter); - } - - if(modIDStacks.get(filter).renderStack != null) - { - try { - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_LIGHTING); - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), modIDStacks.get(filter).renderStack, 59, yStart + 3); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } catch(Exception e) {} - } - - fontRendererObj.drawString(LangUtils.localize("gui.modIDFilter"), 78, yStart + 2, 0x404040); - } - } - } - - if(xAxis >= 11 && xAxis <= 25 && yAxis >= 141 && yAxis <= 155) - { - drawCreativeTabHoveringText(LangUtils.localize("gui.digitalMiner.inverse"), xAxis, yAxis); - } - - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } - - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMinerConfig.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - drawTexturedModalRect( guiLeft + scrollX, guiTop + scrollY + getScroll(), 232 + ( needsScrollBars() ? 0 : 12 ), 0, 12, 15 ); - - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); - - for(int i = 0; i < 4; i++) - { - if(tileEntity.filters.get(getFilterIndex()+i) != null) - { - MinerFilter filter = tileEntity.filters.get(getFilterIndex()+i); - int yStart = i*29 + 18; - - boolean mouseOver = xAxis >= 56 && xAxis <= 152 && yAxis >= yStart && yAxis <= yStart+29; - - if(filter instanceof MItemStackFilter) - { - MekanismRenderer.color(EnumColor.INDIGO, 1.0F, 2.5F); - } - else if(filter instanceof MOreDictFilter) - { - MekanismRenderer.color(EnumColor.BRIGHT_GREEN, 1.0F, 2.5F); - } - else if(filter instanceof MMaterialFilter) - { - MekanismRenderer.color(EnumColor.PURPLE, 1.0F, 4F); - } - else if(filter instanceof MModIDFilter) - { - MekanismRenderer.color(EnumColor.PINK, 1.0F, 2.5F); - } - - drawTexturedModalRect(guiWidth + 56, guiHeight + yStart, mouseOver ? 0 : 96, 166, 96, 29); - MekanismRenderer.resetColor(); - - // Draw sort buttons - final int arrowX = filterX + filterW - 12; - if( getFilterIndex() + i > 0 ) - { - mouseOver = xAxis >= arrowX && xAxis <= arrowX + 10 && yAxis >= yStart + 14 && yAxis <= yStart + 20; - drawTexturedModalRect( guiLeft + arrowX, guiTop + yStart + 14, 190, mouseOver ? 143 : 115, 11, 7 ); - } - if( getFilterIndex() + i < tileEntity.filters.size() - 1 ) - { - mouseOver = xAxis >= arrowX && xAxis <= arrowX + 10 && yAxis >= yStart + 21 && yAxis <= yStart + 27; - drawTexturedModalRect( guiLeft + arrowX, guiTop + yStart + 21, 190, mouseOver ? 157 : 129, 11, 7 ); - } - } - } - - if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) - { - drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 0, 11, 11); - } - else { - drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 11, 11, 11); - } - - if(xAxis >= 39 && xAxis <= 50 && yAxis >= 67 && yAxis <= 78) - { - drawTexturedModalRect(guiWidth + 39, guiHeight + 67, 176 + 11, 0, 11, 11); - } - else { - drawTexturedModalRect(guiWidth + 39, guiHeight + 67, 176 + 11, 11, 11, 11); - } - - if(xAxis >= 39 && xAxis <= 50 && yAxis >= 92 && yAxis <= 103) - { - drawTexturedModalRect(guiWidth + 39, guiHeight + 92, 176 + 11, 0, 11, 11); - } - else { - drawTexturedModalRect(guiWidth + 39, guiHeight + 92, 176 + 11, 11, 11, 11); - } - - if(xAxis >= 39 && xAxis <= 50 && yAxis >= 117 && yAxis <= 128) - { - drawTexturedModalRect(guiWidth + 39, guiHeight + 117, 176 + 11, 0, 11, 11); - } - else { - drawTexturedModalRect(guiWidth + 39, guiHeight + 117, 176 + 11, 11, 11, 11); - } - - if(xAxis >= 11 && xAxis <= 25 && yAxis >= 141 && yAxis <= 155) - { - drawTexturedModalRect(guiWidth + 11, guiHeight + 141, 176 + 22, 0, 14, 14); - } - else { - drawTexturedModalRect(guiWidth + 11, guiHeight + 141, 176 + 22, 14, 14, 14); - } - - radiusField.drawTextBox(); - minField.drawTextBox(); - maxField.drawTextBox(); - } - - @Override - public void keyTyped(char c, int i) - { - if((!radiusField.isFocused() && !minField.isFocused() && !maxField.isFocused()) || i == Keyboard.KEY_ESCAPE) - { - super.keyTyped(c, i); - } - - if(i == Keyboard.KEY_RETURN) - { - if(radiusField.isFocused()) - { - setRadius(); - } - else if(minField.isFocused()) - { - setMinY(); - } - else if(maxField.isFocused()) - { - setMaxY(); - } - } - - if(Character.isDigit(c) || isTextboxKey(c, i)) - { - radiusField.textboxKeyTyped(c, i); - minField.textboxKeyTyped(c, i); - maxField.textboxKeyTyped(c, i); - } - } - - private void setRadius() - { - if(!radiusField.getText().isEmpty()) - { - int toUse = Math.max(0, Math.min(Integer.parseInt(radiusField.getText()), 32)); - - ArrayList data = new ArrayList(); - data.add(6); - data.add(toUse); - - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - - radiusField.setText(""); - } - } - - private void setMinY() - { - if(!minField.getText().isEmpty()) - { - int toUse = Math.max(0, Math.min(Integer.parseInt(minField.getText()), tileEntity.maxY)); - - ArrayList data = new ArrayList(); - data.add(7); - data.add(toUse); - - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - - minField.setText(""); - } - } - - private void setMaxY() - { - if(!maxField.getText().isEmpty()) - { - int toUse = Math.max(tileEntity.minY, Math.min(Integer.parseInt(maxField.getText()), 255)); - - ArrayList data = new ArrayList(); - data.add(8); - data.add(toUse); - - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - - maxField.setText(""); - } - } - - private void updateStackList(MOreDictFilter filter) - { - if(!oreDictStacks.containsKey(filter)) - { - oreDictStacks.put(filter, new StackData()); - } - - oreDictStacks.get(filter).iterStacks = OreDictCache.getOreDictStacks(filter.oreDictName, true); - - stackSwitch = 0; - updateScreen(); - oreDictStacks.get(filter).stackIndex = -1; - } - - private void updateStackList(MModIDFilter filter) - { - if(!modIDStacks.containsKey(filter)) - { - modIDStacks.put(filter, new StackData()); - } - - modIDStacks.get(filter).iterStacks = OreDictCache.getModIDStacks(filter.modID, true); - - stackSwitch = 0; - updateScreen(); - modIDStacks.get(filter).stackIndex = -1; - } - - public static class StackData - { - public List iterStacks; - public int stackIndex; - public ItemStack renderStack; - } - - /** - * returns true if there are more filters than can fit in the gui - */ - private boolean needsScrollBars() - { - return tileEntity.filters.size() > 4; - } + setMaxY(); + } + + if (xAxis >= 11 && xAxis <= 25 && yAxis >= 141 && yAxis <= 155) { + ArrayList data = new ArrayList(); + data.add(10); + + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); + SoundHandler.playSound("gui.button.press"); + } + } + } + + @Override + protected void mouseClickMove(int mouseX, int mouseY, int button, long ticks) { + super.mouseClickMove(mouseX, mouseY, button, ticks); + + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + if (isDragging) { + scroll = Math.min(Math.max((float) (yAxis - 18 - dragOffset) / 123F, 0), 1); + } + } + + @Override + protected void mouseMovedOrUp(int x, int y, int type) { + super.mouseMovedOrUp(x, y, type); + + if (type == 0 && isDragging) { + dragOffset = 0; + isDragging = false; + } + } + + /** + * Handles mouse input. + */ + @Override + public void handleMouseInput() { + super.handleMouseInput(); + + int i = Mouse.getEventDWheel(); + + if (i != 0 && needsScrollBars()) { + final int j = tileEntity.filters.size() - 4; + + if (i > 0) { + i = 1; + } + + if (i < 0) { + i = -1; + } + + scroll = (float) (scroll - (double) i / (double) j); + + if (scroll < 0.0F) { + scroll = 0.0F; + } + + if (scroll > 1.0F) { + scroll = 1.0F; + } + } + } + + @Override + public void initGui() { + super.initGui(); + + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + + buttonList.clear(); + buttonList.add(new GuiButton( + 0, guiWidth + 56, guiHeight + 136, 96, 20, LangUtils.localize("gui.newFilter") + )); + + String prevRad = radiusField != null ? radiusField.getText() : ""; + String prevMin = minField != null ? minField.getText() : ""; + String prevMax = maxField != null ? maxField.getText() : ""; + + radiusField + = new GuiTextField(fontRendererObj, guiWidth + 12, guiHeight + 67, 26, 11); + radiusField.setMaxStringLength(2); + radiusField.setText(prevRad); + + minField + = new GuiTextField(fontRendererObj, guiWidth + 12, guiHeight + 92, 26, 11); + minField.setMaxStringLength(3); + minField.setText(prevMin); + + maxField + = new GuiTextField(fontRendererObj, guiWidth + 12, guiHeight + 117, 26, 11); + maxField.setMaxStringLength(3); + maxField.setText(prevMax); + } + + @Override + protected void actionPerformed(GuiButton guibutton) { + super.actionPerformed(guibutton); + + if (guibutton.id == 0) { + Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage( + MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 5, 0, 0 + )); + } + } + + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + fontRendererObj.drawString( + LangUtils.localize("gui.digitalMinerConfig"), 43, 6, 0x404040 + ); + + fontRendererObj.drawString( + LangUtils.localize("gui.filters") + ":", 11, 19, 0x00CD00 + ); + fontRendererObj.drawString("T: " + tileEntity.filters.size(), 11, 28, 0x00CD00); + + fontRendererObj.drawString( + "I: " + + (tileEntity.inverse ? LangUtils.localize("gui.on") + : LangUtils.localize("gui.off")), + 11, + 131, + 0x00CD00 + ); + + fontRendererObj.drawString("Radi: " + tileEntity.radius, 11, 58, 0x00CD00); + + fontRendererObj.drawString("Min: " + tileEntity.minY, 11, 83, 0x00CD00); + + fontRendererObj.drawString("Max: " + tileEntity.maxY, 11, 108, 0x00CD00); + + for (int i = 0; i < 4; i++) { + if (tileEntity.filters.get(getFilterIndex() + i) != null) { + MinerFilter filter = tileEntity.filters.get(getFilterIndex() + i); + int yStart = i * 29 + 18; + + if (filter instanceof MItemStackFilter) { + MItemStackFilter itemFilter = (MItemStackFilter) filter; + + if (itemFilter.itemType != null) { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_LIGHTING); + itemRender.renderItemAndEffectIntoGUI( + fontRendererObj, + mc.getTextureManager(), + itemFilter.itemType, + 59, + yStart + 3 + ); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + + fontRendererObj.drawString( + LangUtils.localize("gui.itemFilter"), 78, yStart + 2, 0x404040 + ); + } else if (filter instanceof MOreDictFilter) { + MOreDictFilter oreFilter = (MOreDictFilter) filter; + + if (!oreDictStacks.containsKey(oreFilter)) { + updateStackList(oreFilter); + } + + if (oreDictStacks.get(filter).renderStack != null) { + try { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_LIGHTING); + itemRender.renderItemAndEffectIntoGUI( + fontRendererObj, + mc.getTextureManager(), + oreDictStacks.get(filter).renderStack, + 59, + yStart + 3 + ); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } catch (Exception e) {} + } + + fontRendererObj.drawString( + LangUtils.localize("gui.oredictFilter"), 78, yStart + 2, 0x404040 + ); + } else if (filter instanceof MMaterialFilter) { + MMaterialFilter itemFilter = (MMaterialFilter) filter; + + if (itemFilter.materialItem != null) { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_LIGHTING); + itemRender.renderItemAndEffectIntoGUI( + fontRendererObj, + mc.getTextureManager(), + itemFilter.materialItem, + 59, + yStart + 3 + ); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + + fontRendererObj.drawString( + LangUtils.localize("gui.materialFilter"), 78, yStart + 2, 0x404040 + ); + } else if (filter instanceof MModIDFilter) { + MModIDFilter modFilter = (MModIDFilter) filter; + + if (!modIDStacks.containsKey(modFilter)) { + updateStackList(modFilter); + } + + if (modIDStacks.get(filter).renderStack != null) { + try { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_LIGHTING); + itemRender.renderItemAndEffectIntoGUI( + fontRendererObj, + mc.getTextureManager(), + modIDStacks.get(filter).renderStack, + 59, + yStart + 3 + ); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } catch (Exception e) {} + } + + fontRendererObj.drawString( + LangUtils.localize("gui.modIDFilter"), 78, yStart + 2, 0x404040 + ); + } + } + } + + if (xAxis >= 11 && xAxis <= 25 && yAxis >= 141 && yAxis <= 155) { + drawCreativeTabHoveringText( + LangUtils.localize("gui.digitalMiner.inverse"), xAxis, yAxis + ); + } + + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiDigitalMinerConfig.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + drawTexturedModalRect( + guiLeft + scrollX, + guiTop + scrollY + getScroll(), + 232 + (needsScrollBars() ? 0 : 12), + 0, + 12, + 15 + ); + + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + for (int i = 0; i < 4; i++) { + if (tileEntity.filters.get(getFilterIndex() + i) != null) { + MinerFilter filter = tileEntity.filters.get(getFilterIndex() + i); + int yStart = i * 29 + 18; + + boolean mouseOver = xAxis >= 56 && xAxis <= 152 && yAxis >= yStart + && yAxis <= yStart + 29; + + if (filter instanceof MItemStackFilter) { + MekanismRenderer.color(EnumColor.INDIGO, 1.0F, 2.5F); + } else if (filter instanceof MOreDictFilter) { + MekanismRenderer.color(EnumColor.BRIGHT_GREEN, 1.0F, 2.5F); + } else if (filter instanceof MMaterialFilter) { + MekanismRenderer.color(EnumColor.PURPLE, 1.0F, 4F); + } else if (filter instanceof MModIDFilter) { + MekanismRenderer.color(EnumColor.PINK, 1.0F, 2.5F); + } + + drawTexturedModalRect( + guiWidth + 56, guiHeight + yStart, mouseOver ? 0 : 96, 166, 96, 29 + ); + MekanismRenderer.resetColor(); + + // Draw sort buttons + final int arrowX = filterX + filterW - 12; + if (getFilterIndex() + i > 0) { + mouseOver = xAxis >= arrowX && xAxis <= arrowX + 10 + && yAxis >= yStart + 14 && yAxis <= yStart + 20; + drawTexturedModalRect( + guiLeft + arrowX, + guiTop + yStart + 14, + 190, + mouseOver ? 143 : 115, + 11, + 7 + ); + } + if (getFilterIndex() + i < tileEntity.filters.size() - 1) { + mouseOver = xAxis >= arrowX && xAxis <= arrowX + 10 + && yAxis >= yStart + 21 && yAxis <= yStart + 27; + drawTexturedModalRect( + guiLeft + arrowX, + guiTop + yStart + 21, + 190, + mouseOver ? 157 : 129, + 11, + 7 + ); + } + } + } + + if (xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { + drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 0, 11, 11); + } else { + drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 11, 11, 11); + } + + if (xAxis >= 39 && xAxis <= 50 && yAxis >= 67 && yAxis <= 78) { + drawTexturedModalRect(guiWidth + 39, guiHeight + 67, 176 + 11, 0, 11, 11); + } else { + drawTexturedModalRect(guiWidth + 39, guiHeight + 67, 176 + 11, 11, 11, 11); + } + + if (xAxis >= 39 && xAxis <= 50 && yAxis >= 92 && yAxis <= 103) { + drawTexturedModalRect(guiWidth + 39, guiHeight + 92, 176 + 11, 0, 11, 11); + } else { + drawTexturedModalRect(guiWidth + 39, guiHeight + 92, 176 + 11, 11, 11, 11); + } + + if (xAxis >= 39 && xAxis <= 50 && yAxis >= 117 && yAxis <= 128) { + drawTexturedModalRect(guiWidth + 39, guiHeight + 117, 176 + 11, 0, 11, 11); + } else { + drawTexturedModalRect(guiWidth + 39, guiHeight + 117, 176 + 11, 11, 11, 11); + } + + if (xAxis >= 11 && xAxis <= 25 && yAxis >= 141 && yAxis <= 155) { + drawTexturedModalRect(guiWidth + 11, guiHeight + 141, 176 + 22, 0, 14, 14); + } else { + drawTexturedModalRect(guiWidth + 11, guiHeight + 141, 176 + 22, 14, 14, 14); + } + + radiusField.drawTextBox(); + minField.drawTextBox(); + maxField.drawTextBox(); + } + + @Override + public void keyTyped(char c, int i) { + if ((!radiusField.isFocused() && !minField.isFocused() && !maxField.isFocused()) + || i == Keyboard.KEY_ESCAPE) { + super.keyTyped(c, i); + } + + if (i == Keyboard.KEY_RETURN) { + if (radiusField.isFocused()) { + setRadius(); + } else if (minField.isFocused()) { + setMinY(); + } else if (maxField.isFocused()) { + setMaxY(); + } + } + + if (Character.isDigit(c) || isTextboxKey(c, i)) { + radiusField.textboxKeyTyped(c, i); + minField.textboxKeyTyped(c, i); + maxField.textboxKeyTyped(c, i); + } + } + + private void setRadius() { + if (!radiusField.getText().isEmpty()) { + int toUse + = Math.max(0, Math.min(Integer.parseInt(radiusField.getText()), 32)); + + ArrayList data = new ArrayList(); + data.add(6); + data.add(toUse); + + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); + + radiusField.setText(""); + } + } + + private void setMinY() { + if (!minField.getText().isEmpty()) { + int toUse = Math.max( + 0, Math.min(Integer.parseInt(minField.getText()), tileEntity.maxY) + ); + + ArrayList data = new ArrayList(); + data.add(7); + data.add(toUse); + + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); + + minField.setText(""); + } + } + + private void setMaxY() { + if (!maxField.getText().isEmpty()) { + int toUse = Math.max( + tileEntity.minY, Math.min(Integer.parseInt(maxField.getText()), 255) + ); + + ArrayList data = new ArrayList(); + data.add(8); + data.add(toUse); + + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); + + maxField.setText(""); + } + } + + private void updateStackList(MOreDictFilter filter) { + if (!oreDictStacks.containsKey(filter)) { + oreDictStacks.put(filter, new StackData()); + } + + oreDictStacks.get(filter).iterStacks + = OreDictCache.getOreDictStacks(filter.oreDictName, true); + + stackSwitch = 0; + updateScreen(); + oreDictStacks.get(filter).stackIndex = -1; + } + + private void updateStackList(MModIDFilter filter) { + if (!modIDStacks.containsKey(filter)) { + modIDStacks.put(filter, new StackData()); + } + + modIDStacks.get(filter).iterStacks + = OreDictCache.getModIDStacks(filter.modID, true); + + stackSwitch = 0; + updateScreen(); + modIDStacks.get(filter).stackIndex = -1; + } + + public static class StackData { + public List iterStacks; + public int stackIndex; + public ItemStack renderStack; + } + + /** + * returns true if there are more filters than can fit in the gui + */ + private boolean needsScrollBars() { + return tileEntity.filters.size() > 4; + } } diff --git a/src/main/java/mekanism/client/gui/GuiDynamicTank.java b/src/main/java/mekanism/client/gui/GuiDynamicTank.java index 46c5b07b8..cc52ab6b5 100644 --- a/src/main/java/mekanism/client/gui/GuiDynamicTank.java +++ b/src/main/java/mekanism/client/gui/GuiDynamicTank.java @@ -1,5 +1,7 @@ package mekanism.client.gui; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.gui.element.GuiContainerEditMode; import mekanism.client.render.MekanismRenderer; import mekanism.common.content.tank.TankUpdateProtocol; @@ -10,103 +12,148 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.entity.player.InventoryPlayer; import net.minecraftforge.fluids.FluidStack; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiDynamicTank extends GuiMekanism -{ - public TileEntityDynamicTank tileEntity; +public class GuiDynamicTank extends GuiMekanism { + public TileEntityDynamicTank tileEntity; - public GuiDynamicTank(InventoryPlayer inventory, TileEntityDynamicTank tentity) - { - super(tentity, new ContainerDynamicTank(inventory, tentity)); - tileEntity = tentity; - guiElements.add(new GuiContainerEditMode(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiDynamicTank.png"))); - } + public GuiDynamicTank(InventoryPlayer inventory, TileEntityDynamicTank tentity) { + super(tentity, new ContainerDynamicTank(inventory, tentity)); + tileEntity = tentity; + guiElements.add(new GuiContainerEditMode( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiDynamicTank.png") + )); + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize/2)-(fontRendererObj.getStringWidth(tileEntity.getInventoryName())/2), 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 94) + 2, 0x404040); - fontRendererObj.drawString(LangUtils.localize("gui.volume") + ": " + tileEntity.clientCapacity/TankUpdateProtocol.FLUID_PER_TANK, 53, 26, 0x00CD00); - renderScaledText(tileEntity.structure.fluidStored != null ? LangUtils.localizeFluidStack(tileEntity.structure.fluidStored) + ":" : LangUtils.localize("gui.noFluid"), 53, 44, 0x00CD00, 74); + fontRendererObj.drawString( + tileEntity.getInventoryName(), + (xSize / 2) + - (fontRendererObj.getStringWidth(tileEntity.getInventoryName()) / 2), + 6, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, (ySize - 94) + 2, 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.volume") + ": " + + tileEntity.clientCapacity / TankUpdateProtocol.FLUID_PER_TANK, + 53, + 26, + 0x00CD00 + ); + renderScaledText( + tileEntity.structure.fluidStored != null + ? LangUtils.localizeFluidStack(tileEntity.structure.fluidStored) + ":" + : LangUtils.localize("gui.noFluid"), + 53, + 44, + 0x00CD00, + 74 + ); - if(tileEntity.structure.fluidStored != null) - { - fontRendererObj.drawString(tileEntity.structure.fluidStored.amount + "mB", 53, 53, 0x00CD00); - } + if (tileEntity.structure.fluidStored != null) { + fontRendererObj.drawString( + tileEntity.structure.fluidStored.amount + "mB", 53, 53, 0x00CD00 + ); + } - if(xAxis >= 7 && xAxis <= 39 && yAxis >= 14 && yAxis <= 72) - { - drawCreativeTabHoveringText(tileEntity.structure.fluidStored != null ? LangUtils.localizeFluidStack(tileEntity.structure.fluidStored) + ": " + tileEntity.structure.fluidStored.amount + "mB" : LangUtils.localize("gui.empty"), xAxis, yAxis); - } + if (xAxis >= 7 && xAxis <= 39 && yAxis >= 14 && yAxis <= 72) { + drawCreativeTabHoveringText( + tileEntity.structure.fluidStored != null + ? LangUtils.localizeFluidStack(tileEntity.structure.fluidStored) + + ": " + tileEntity.structure.fluidStored.amount + "mB" + : LangUtils.localize("gui.empty"), + xAxis, + yAxis + ); + } - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiDynamicTank.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - if(tileEntity.getScaledFluidLevel(58) > 0) - { - displayGauge(7, 14, tileEntity.getScaledFluidLevel(58), tileEntity.structure.fluidStored, 0); - displayGauge(23, 14, tileEntity.getScaledFluidLevel(58), tileEntity.structure.fluidStored, 1); - } - } + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiDynamicTank.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - public void displayGauge(int xPos, int yPos, int scale, FluidStack fluid, int side /*0-left, 1-right*/) - { - if(fluid == null) - { - return; - } + if (tileEntity.getScaledFluidLevel(58) > 0) { + displayGauge( + 7, + 14, + tileEntity.getScaledFluidLevel(58), + tileEntity.structure.fluidStored, + 0 + ); + displayGauge( + 23, + 14, + tileEntity.getScaledFluidLevel(58), + tileEntity.structure.fluidStored, + 1 + ); + } + } - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; + public void displayGauge( + int xPos, int yPos, int scale, FluidStack fluid, int side /*0-left, 1-right*/ + ) { + if (fluid == null) { + return; + } - int start = 0; + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; - while(true) - { - int renderRemaining = 0; + int start = 0; - if(scale > 16) - { - renderRemaining = 16; - scale -= 16; - } - else { - renderRemaining = scale; - scale = 0; - } + while (true) { + int renderRemaining = 0; - mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture()); - drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos + 58 - renderRemaining - start, fluid.getFluid().getIcon(), 16, 16 - (16 - renderRemaining)); - start+=16; + if (scale > 16) { + renderRemaining = 16; + scale -= 16; + } else { + renderRemaining = scale; + scale = 0; + } - if(renderRemaining == 0 || scale == 0) - { - break; - } - } + mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture()); + drawTexturedModelRectFromIcon( + guiWidth + xPos, + guiHeight + yPos + 58 - renderRemaining - start, + fluid.getFluid().getIcon(), + 16, + 16 - (16 - renderRemaining) + ); + start += 16; - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiDynamicTank.png")); - drawTexturedModalRect(guiWidth + xPos, guiHeight + yPos, 176, side == 0 ? 0 : 54, 16, 54); - } + if (renderRemaining == 0 || scale == 0) { + break; + } + } + + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiDynamicTank.png") + ); + drawTexturedModalRect( + guiWidth + xPos, guiHeight + yPos, 176, side == 0 ? 0 : 54, 16, 54 + ); + } } diff --git a/src/main/java/mekanism/client/gui/GuiElectricMachine.java b/src/main/java/mekanism/client/gui/GuiElectricMachine.java index 66dd6e8b4..001c70d07 100644 --- a/src/main/java/mekanism/client/gui/GuiElectricMachine.java +++ b/src/main/java/mekanism/client/gui/GuiElectricMachine.java @@ -2,6 +2,8 @@ package mekanism.client.gui; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.util.ListUtils; import mekanism.client.gui.element.GuiElement.IInfoHandler; import mekanism.client.gui.element.GuiEnergyInfo; @@ -22,74 +24,89 @@ import mekanism.common.tile.TileEntityElectricMachine; import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import net.minecraft.entity.player.InventoryPlayer; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiElectricMachine extends GuiMekanism -{ - public TileEntityElectricMachine tileEntity; +public class GuiElectricMachine extends GuiMekanism { + public TileEntityElectricMachine tileEntity; - public GuiElectricMachine(InventoryPlayer inventory, TileEntityElectricMachine tentity) - { - super(tentity, new ContainerElectricMachine(inventory, tentity)); - tileEntity = tentity; + public GuiElectricMachine( + InventoryPlayer inventory, TileEntityElectricMachine tentity + ) { + super(tentity, new ContainerElectricMachine(inventory, tentity)); + tileEntity = tentity; - guiElements.add(new GuiRedstoneControl(this, tileEntity, tileEntity.guiLocation)); - guiElements.add(new GuiUpgradeTab(this, tileEntity, tileEntity.guiLocation)); - guiElements.add(new GuiSecurityTab(this, tileEntity, tileEntity.guiLocation)); - guiElements.add(new GuiSideConfigurationTab(this, tileEntity, tileEntity.guiLocation)); - guiElements.add(new GuiTransporterConfigTab(this, 34, tileEntity, tileEntity.guiLocation)); - guiElements.add(new GuiPowerBar(this, tileEntity, tileEntity.guiLocation, 164, 15)); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() { - @Override - public List getInfo() - { - String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.energyPerTick); - return ListUtils.asList(LangUtils.localize("gui.using") + ": " + multiplier + "/t", LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); - } - }, this, tileEntity.guiLocation)); + guiElements.add(new GuiRedstoneControl(this, tileEntity, tileEntity.guiLocation)); + guiElements.add(new GuiUpgradeTab(this, tileEntity, tileEntity.guiLocation)); + guiElements.add(new GuiSecurityTab(this, tileEntity, tileEntity.guiLocation)); + guiElements.add( + new GuiSideConfigurationTab(this, tileEntity, tileEntity.guiLocation) + ); + guiElements.add( + new GuiTransporterConfigTab(this, 34, tileEntity, tileEntity.guiLocation) + ); + guiElements.add(new GuiPowerBar(this, tileEntity, tileEntity.guiLocation, 164, 15) + ); + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() { + String multiplier + = MekanismUtils.getEnergyDisplay(tileEntity.energyPerTick); + return ListUtils.asList( + LangUtils.localize("gui.using") + ": " + multiplier + "/t", + LangUtils.localize("gui.needed") + ": " + + MekanismUtils.getEnergyDisplay( + tileEntity.getMaxEnergy() - tileEntity.getEnergy() + ) + ); + } + }, this, tileEntity.guiLocation)); - guiElements.add(new GuiSlot(SlotType.INPUT, this, tileEntity.guiLocation, 55, 16)); - guiElements.add(new GuiSlot(SlotType.POWER, this, tileEntity.guiLocation, 55, 52).with(SlotOverlay.POWER)); - guiElements.add(new GuiSlot(SlotType.OUTPUT_LARGE, this, tileEntity.guiLocation, 111, 30)); + guiElements.add(new GuiSlot(SlotType.INPUT, this, tileEntity.guiLocation, 55, 16) + ); + guiElements.add(new GuiSlot(SlotType.POWER, this, tileEntity.guiLocation, 55, 52) + .with(SlotOverlay.POWER)); + guiElements.add( + new GuiSlot(SlotType.OUTPUT_LARGE, this, tileEntity.guiLocation, 111, 30) + ); - guiElements.add(new GuiProgress(new IProgressInfoHandler() - { - @Override - public double getProgress() - { - return tileEntity.getScaledProgress(); - } - }, getProgressType(), this, tileEntity.guiLocation, 77, 37)); - } - - public ProgressBar getProgressType() - { - return ProgressBar.BLUE; - } + guiElements.add(new GuiProgress(new IProgressInfoHandler() { + @Override + public double getProgress() { + return tileEntity.getScaledProgress(); + } + }, getProgressType(), this, tileEntity.guiLocation, 77, 37)); + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize/2)-(fontRendererObj.getStringWidth(tileEntity.getInventoryName())/2), 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); + public ProgressBar getProgressType() { + return ProgressBar.BLUE; + } - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + fontRendererObj.drawString( + tileEntity.getInventoryName(), + (xSize / 2) + - (fontRendererObj.getStringWidth(tileEntity.getInventoryName()) / 2), + 6, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040 + ); - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(tileEntity.guiLocation); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture(tileEntity.guiLocation); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/GuiElectricPump.java b/src/main/java/mekanism/client/gui/GuiElectricPump.java index adc345534..57d7b5b02 100644 --- a/src/main/java/mekanism/client/gui/GuiElectricPump.java +++ b/src/main/java/mekanism/client/gui/GuiElectricPump.java @@ -2,6 +2,8 @@ package mekanism.client.gui; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.util.ListUtils; import mekanism.client.gui.element.GuiElement.IInfoHandler; import mekanism.client.gui.element.GuiEnergyInfo; @@ -23,70 +25,83 @@ import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fluids.FluidTank; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiElectricPump extends GuiMekanism -{ - public TileEntityElectricPump tileEntity; +public class GuiElectricPump extends GuiMekanism { + public TileEntityElectricPump tileEntity; - public ResourceLocation guiLocation = MekanismUtils.getResource(ResourceType.GUI, "GuiElectricPump.png"); + public ResourceLocation guiLocation + = MekanismUtils.getResource(ResourceType.GUI, "GuiElectricPump.png"); - public GuiElectricPump(InventoryPlayer inventory, TileEntityElectricPump tentity) - { - super(tentity, new ContainerElectricPump(inventory, tentity)); - tileEntity = tentity; + public GuiElectricPump(InventoryPlayer inventory, TileEntityElectricPump tentity) { + super(tentity, new ContainerElectricPump(inventory, tentity)); + tileEntity = tentity; - guiElements.add(new GuiSlot(SlotType.NORMAL, this, guiLocation, 27, 19)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, guiLocation, 27, 50)); - guiElements.add(new GuiSlot(SlotType.POWER, this, guiLocation, 142, 34).with(SlotOverlay.POWER)); - guiElements.add(new GuiPowerBar(this, tileEntity, guiLocation, 164, 15)); - guiElements.add(new GuiFluidGauge(new IFluidInfoHandler() { - @Override - public FluidTank getTank() - { - return tileEntity.fluidTank; - } - }, GuiGauge.Type.STANDARD, this, guiLocation, 6, 13)); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() { - @Override - public List getInfo() - { - String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.energyPerTick); - return ListUtils.asList(LangUtils.localize("gui.using") + ": " + multiplier + "/t", LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); - } - }, this, guiLocation)); - guiElements.add(new GuiSecurityTab(this, tileEntity, guiLocation)); - guiElements.add(new GuiRedstoneControl(this, tileEntity, guiLocation)); - guiElements.add(new GuiUpgradeTab(this, tileEntity, guiLocation)); - } + guiElements.add(new GuiSlot(SlotType.NORMAL, this, guiLocation, 27, 19)); + guiElements.add(new GuiSlot(SlotType.NORMAL, this, guiLocation, 27, 50)); + guiElements.add(new GuiSlot(SlotType.POWER, this, guiLocation, 142, 34) + .with(SlotOverlay.POWER)); + guiElements.add(new GuiPowerBar(this, tileEntity, guiLocation, 164, 15)); + guiElements.add(new GuiFluidGauge(new IFluidInfoHandler() { + @Override + public FluidTank getTank() { + return tileEntity.fluidTank; + } + }, GuiGauge.Type.STANDARD, this, guiLocation, 6, 13)); + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() { + String multiplier + = MekanismUtils.getEnergyDisplay(tileEntity.energyPerTick); + return ListUtils.asList( + LangUtils.localize("gui.using") + ": " + multiplier + "/t", + LangUtils.localize("gui.needed") + ": " + + MekanismUtils.getEnergyDisplay( + tileEntity.getMaxEnergy() - tileEntity.getEnergy() + ) + ); + } + }, this, guiLocation)); + guiElements.add(new GuiSecurityTab(this, tileEntity, guiLocation)); + guiElements.add(new GuiRedstoneControl(this, tileEntity, guiLocation)); + guiElements.add(new GuiUpgradeTab(this, tileEntity, guiLocation)); + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize / 2) - (fontRendererObj.getStringWidth(tileEntity.getInventoryName()) / 2), 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 94) + 2, 0x404040); - fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00); - - String text = tileEntity.fluidTank.getFluid() != null ? LangUtils.localizeFluidStack(tileEntity.fluidTank.getFluid()) + ": " + tileEntity.fluidTank.getFluid().amount : LangUtils.localize("gui.noFluid"); - renderScaledText(text, 51, 35, 0x00CD00, 74); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + fontRendererObj.drawString( + tileEntity.getInventoryName(), + (xSize / 2) + - (fontRendererObj.getStringWidth(tileEntity.getInventoryName()) / 2), + 6, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, (ySize - 94) + 2, 0x404040 + ); + fontRendererObj.drawString( + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00 + ); - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + String text = tileEntity.fluidTank.getFluid() != null + ? LangUtils.localizeFluidStack(tileEntity.fluidTank.getFluid()) + ": " + + tileEntity.fluidTank.getFluid().amount + : LangUtils.localize("gui.noFluid"); + renderScaledText(text, 51, 35, 0x00CD00, 74); - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(guiLocation); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture(guiLocation); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } } diff --git a/src/main/java/mekanism/client/gui/GuiElectrolyticSeparator.java b/src/main/java/mekanism/client/gui/GuiElectrolyticSeparator.java old mode 100755 new mode 100644 index c8cdd63c2..61271906f --- a/src/main/java/mekanism/client/gui/GuiElectrolyticSeparator.java +++ b/src/main/java/mekanism/client/gui/GuiElectrolyticSeparator.java @@ -3,6 +3,8 @@ package mekanism.client.gui; import java.util.ArrayList; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.gas.GasTank; import mekanism.api.util.ListUtils; @@ -34,145 +36,235 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.entity.player.InventoryPlayer; import net.minecraftforge.fluids.FluidTank; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiElectrolyticSeparator extends GuiMekanism -{ - public TileEntityElectrolyticSeparator tileEntity; +public class GuiElectrolyticSeparator extends GuiMekanism { + public TileEntityElectrolyticSeparator tileEntity; - public GuiElectrolyticSeparator(InventoryPlayer inventory, TileEntityElectrolyticSeparator tentity) - { - super(tentity, new ContainerElectrolyticSeparator(inventory, tentity)); + public GuiElectrolyticSeparator( + InventoryPlayer inventory, TileEntityElectrolyticSeparator tentity + ) { + super(tentity, new ContainerElectrolyticSeparator(inventory, tentity)); - tileEntity = tentity; + tileEntity = tentity; - guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"))); - guiElements.add(new GuiUpgradeTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"))); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() { - @Override - public List getInfo() - { - String usage = MekanismUtils.getEnergyDisplay(tileEntity.clientEnergyUsed); - return ListUtils.asList(LangUtils.localize("gui.using") + ": " + usage + "/t", LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); - } - }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"))); - guiElements.add(new GuiFluidGauge(new IFluidInfoHandler() { - @Override - public FluidTank getTank() - { - return tileEntity.fluidTank; - } - }, GuiGauge.Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), 5, 10)); - guiElements.add(new GuiGasGauge(new IGasInfoHandler() { - @Override - public GasTank getTank() - { - return tileEntity.leftTank; - } - }, GuiGauge.Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), 58, 18)); - guiElements.add(new GuiGasGauge(new IGasInfoHandler() { - @Override - public GasTank getTank() - { - return tileEntity.rightTank; - } - }, GuiGauge.Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), 100, 18)); - guiElements.add(new GuiPowerBar(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), 164, 15)); - guiElements.add(new GuiSecurityTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"))); + guiElements.add(new GuiRedstoneControl( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png") + )); + guiElements.add(new GuiUpgradeTab( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png") + )); + guiElements.add(new GuiEnergyInfo( + new IInfoHandler() { + @Override + public List getInfo() { + String usage + = MekanismUtils.getEnergyDisplay(tileEntity.clientEnergyUsed); + return ListUtils.asList( + LangUtils.localize("gui.using") + ": " + usage + "/t", + LangUtils.localize("gui.needed") + ": " + + MekanismUtils.getEnergyDisplay( + tileEntity.getMaxEnergy() - tileEntity.getEnergy() + ) + ); + } + }, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png") + )); + guiElements.add(new GuiFluidGauge( + new IFluidInfoHandler() { + @Override + public FluidTank getTank() { + return tileEntity.fluidTank; + } + }, + GuiGauge.Type.STANDARD, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), + 5, + 10 + )); + guiElements.add(new GuiGasGauge( + new IGasInfoHandler() { + @Override + public GasTank getTank() { + return tileEntity.leftTank; + } + }, + GuiGauge.Type.SMALL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), + 58, + 18 + )); + guiElements.add(new GuiGasGauge( + new IGasInfoHandler() { + @Override + public GasTank getTank() { + return tileEntity.rightTank; + } + }, + GuiGauge.Type.SMALL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), + 100, + 18 + )); + guiElements.add(new GuiPowerBar( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), + 164, + 15 + )); + guiElements.add(new GuiSecurityTab( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png") + )); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), 25, 34)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), 58, 51)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), 100, 51)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), 142, 34).with(SlotOverlay.POWER)); + guiElements.add(new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), + 25, + 34 + )); + guiElements.add(new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), + 58, + 51 + )); + guiElements.add(new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), + 100, + 51 + )); + guiElements.add(new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource( + ResourceType.GUI, "GuiElectrolyticSeparator.png" + ), + 142, + 34 + ) + .with(SlotOverlay.POWER)); - guiElements.add(new GuiProgress(new IProgressInfoHandler() - { - @Override - public double getProgress() - { - return tileEntity.isActive ? 1 : 0; - } - }, ProgressBar.BI, this, MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), 78, 29)); - } + guiElements.add(new GuiProgress( + new IProgressInfoHandler() { + @Override + public double getProgress() { + return tileEntity.isActive ? 1 : 0; + } + }, + ProgressBar.BI, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), + 78, + 29 + )); + } - @Override - protected void mouseClicked(int x, int y, int button) - { - super.mouseClicked(x, y, button); + @Override + protected void mouseClicked(int x, int y, int button) { + super.mouseClicked(x, y, button); - int xAxis = (x - (width - xSize) / 2); - int yAxis = (y - (height - ySize) / 2); + int xAxis = (x - (width - xSize) / 2); + int yAxis = (y - (height - ySize) / 2); - if(xAxis > 8 && xAxis < 17 && yAxis > 73 && yAxis < 82) - { - ArrayList data = new ArrayList(); - data.add((byte)0); + if (xAxis > 8 && xAxis < 17 && yAxis > 73 && yAxis < 82) { + ArrayList data = new ArrayList(); + data.add((byte) 0); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - SoundHandler.playSound("gui.button.press"); - } - else if(xAxis > 160 && xAxis < 169 && yAxis > 73 && yAxis < 82) - { - ArrayList data = new ArrayList(); - data.add((byte)1); + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); + SoundHandler.playSound("gui.button.press"); + } else if (xAxis > 160 && xAxis < 169 && yAxis > 73 && yAxis < 82) { + ArrayList data = new ArrayList(); + data.add((byte) 1); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - SoundHandler.playSound("gui.button.press"); - } - } + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); + SoundHandler.playSound("gui.button.press"); + } + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - fontRendererObj.drawString(tileEntity.getInventoryName(), 45, 6, 0x404040); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + fontRendererObj.drawString(tileEntity.getInventoryName(), 45, 6, 0x404040); - String name = chooseByMode(tileEntity.dumpLeft, LangUtils.localize("gui.idle"), LangUtils.localize("gui.dumping"), LangUtils.localize("gui.dumping_excess")); - renderScaledText(name, 21, 73, 0x404040, 66); + String name = chooseByMode( + tileEntity.dumpLeft, + LangUtils.localize("gui.idle"), + LangUtils.localize("gui.dumping"), + LangUtils.localize("gui.dumping_excess") + ); + renderScaledText(name, 21, 73, 0x404040, 66); - name = chooseByMode(tileEntity.dumpRight, LangUtils.localize("gui.idle"), LangUtils.localize("gui.dumping"), LangUtils.localize("gui.dumping_excess")); - renderScaledText(name, 156-(int)(fontRendererObj.getStringWidth(name)*getNeededScale(name, 66)), 73, 0x404040, 66); + name = chooseByMode( + tileEntity.dumpRight, + LangUtils.localize("gui.idle"), + LangUtils.localize("gui.dumping"), + LangUtils.localize("gui.dumping_excess") + ); + renderScaledText( + name, + 156 - (int) (fontRendererObj.getStringWidth(name) * getNeededScale(name, 66)), + 73, + 0x404040, + 66 + ); - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - int displayInt = chooseByMode(tileEntity.dumpLeft, 52, 60, 68); - drawTexturedModalRect(guiWidth + 8, guiHeight + 73, 176, displayInt, 8, 8); + int displayInt = chooseByMode(tileEntity.dumpLeft, 52, 60, 68); + drawTexturedModalRect(guiWidth + 8, guiHeight + 73, 176, displayInt, 8, 8); - displayInt = chooseByMode(tileEntity.dumpRight, 52, 60, 68); - drawTexturedModalRect(guiWidth + 160, guiHeight + 73, 176, displayInt, 8, 8); + displayInt = chooseByMode(tileEntity.dumpRight, 52, 60, 68); + drawTexturedModalRect(guiWidth + 160, guiHeight + 73, 176, displayInt, 8, 8); - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } - - private T chooseByMode(TileEntityGasTank.GasMode dumping, T idleOption, T dumpingOption, T dumpingExcessOption) - { - if(dumping.equals(TileEntityGasTank.GasMode.IDLE)) - { - return idleOption; - } - else if(dumping.equals(TileEntityGasTank.GasMode.DUMPING)) - { - return dumpingOption; - } - else if(dumping.equals(TileEntityGasTank.GasMode.DUMPING_EXCESS)) - { - return dumpingExcessOption; - } - - return idleOption; //should not happen; - } + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } + + private T chooseByMode( + TileEntityGasTank.GasMode dumping, + T idleOption, + T dumpingOption, + T dumpingExcessOption + ) { + if (dumping.equals(TileEntityGasTank.GasMode.IDLE)) { + return idleOption; + } else if (dumping.equals(TileEntityGasTank.GasMode.DUMPING)) { + return dumpingOption; + } else if (dumping.equals(TileEntityGasTank.GasMode.DUMPING_EXCESS)) { + return dumpingExcessOption; + } + + return idleOption; //should not happen; + } } diff --git a/src/main/java/mekanism/client/gui/GuiEnergizedSmelter.java b/src/main/java/mekanism/client/gui/GuiEnergizedSmelter.java index b5857c959..6149d24f0 100644 --- a/src/main/java/mekanism/client/gui/GuiEnergizedSmelter.java +++ b/src/main/java/mekanism/client/gui/GuiEnergizedSmelter.java @@ -1,22 +1,21 @@ package mekanism.client.gui; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.gui.element.GuiProgress.ProgressBar; import mekanism.common.tile.TileEntityElectricMachine; import net.minecraft.entity.player.InventoryPlayer; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiEnergizedSmelter extends GuiElectricMachine -{ - public GuiEnergizedSmelter(InventoryPlayer inventory, TileEntityElectricMachine tentity) - { - super(inventory, tentity); - } - - @Override - public ProgressBar getProgressType() - { - return ProgressBar.GREEN; - } +public class GuiEnergizedSmelter extends GuiElectricMachine { + public GuiEnergizedSmelter( + InventoryPlayer inventory, TileEntityElectricMachine tentity + ) { + super(inventory, tentity); + } + + @Override + public ProgressBar getProgressType() { + return ProgressBar.GREEN; + } } diff --git a/src/main/java/mekanism/client/gui/GuiEnergyCube.java b/src/main/java/mekanism/client/gui/GuiEnergyCube.java index 00f2f29aa..fc51519b5 100644 --- a/src/main/java/mekanism/client/gui/GuiEnergyCube.java +++ b/src/main/java/mekanism/client/gui/GuiEnergyCube.java @@ -2,6 +2,8 @@ package mekanism.client.gui; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.energy.IStrictEnergyStorage; import mekanism.api.util.ListUtils; import mekanism.client.gui.element.GuiElement.IInfoHandler; @@ -21,65 +23,109 @@ import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.entity.player.InventoryPlayer; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiEnergyCube extends GuiMekanism -{ - public TileEntityEnergyCube tileEntity; +public class GuiEnergyCube extends GuiMekanism { + public TileEntityEnergyCube tileEntity; - public GuiEnergyCube(InventoryPlayer inventory, TileEntityEnergyCube tentity) - { - super(tentity, new ContainerEnergyCube(inventory, tentity)); - tileEntity = tentity; - guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiEnergyCube.png"))); - guiElements.add(new GuiSecurityTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiEnergyCube.png"))); - guiElements.add(new GuiSideConfigurationTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiEnergyCube.png"))); - guiElements.add(new GuiTransporterConfigTab(this, 34, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiEnergyCube.png"))); - guiElements.add(new GuiEnergyGauge(new IEnergyInfoHandler() - { - @Override - public IStrictEnergyStorage getEnergyStorage() - { - return tileEntity; - } - }, GuiEnergyGauge.Type.WIDE, this, MekanismUtils.getResource(ResourceType.GUI, "GuiEnergyCube.png"), 55, 18)); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() - { - @Override - public List getInfo() - { - return ListUtils.asList( - LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), - LangUtils.localize("gui.maxOutput") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t"); - } - }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiEnergyCube.png"))); - guiElements.add(new GuiSlot(SlotType.INPUT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiEnergyCube.png"), 16, 34).with(SlotOverlay.MINUS)); - guiElements.add(new GuiSlot(SlotType.OUTPUT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiEnergyCube.png"), 142, 34).with(SlotOverlay.PLUS)); - } + public GuiEnergyCube(InventoryPlayer inventory, TileEntityEnergyCube tentity) { + super(tentity, new ContainerEnergyCube(inventory, tentity)); + tileEntity = tentity; + guiElements.add(new GuiRedstoneControl( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiEnergyCube.png") + )); + guiElements.add(new GuiSecurityTab( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiEnergyCube.png") + )); + guiElements.add(new GuiSideConfigurationTab( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiEnergyCube.png") + )); + guiElements.add(new GuiTransporterConfigTab( + this, + 34, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiEnergyCube.png") + )); + guiElements.add(new GuiEnergyGauge( + new IEnergyInfoHandler() { + @Override + public IStrictEnergyStorage getEnergyStorage() { + return tileEntity; + } + }, + GuiEnergyGauge.Type.WIDE, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiEnergyCube.png"), + 55, + 18 + )); + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() { + return ListUtils.asList( + LangUtils.localize("gui.storing") + ": " + + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), + LangUtils.localize("gui.maxOutput") + ": " + + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t" + ); + } + }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiEnergyCube.png"))); + guiElements.add( + new GuiSlot( + SlotType.INPUT, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiEnergyCube.png"), + 16, + 34 + ) + .with(SlotOverlay.MINUS) + ); + guiElements.add( + new GuiSlot( + SlotType.OUTPUT, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiEnergyCube.png"), + 142, + 34 + ) + .with(SlotOverlay.PLUS) + ); + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize/2)-(fontRendererObj.getStringWidth(tileEntity.getInventoryName())/2), 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, ySize - 96 + 2, 0x404040); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + fontRendererObj.drawString( + tileEntity.getInventoryName(), + (xSize / 2) + - (fontRendererObj.getStringWidth(tileEntity.getInventoryName()) / 2), + 6, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, ySize - 96 + 2, 0x404040 + ); - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiEnergyCube.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiEnergyCube.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } } diff --git a/src/main/java/mekanism/client/gui/GuiEnrichmentChamber.java b/src/main/java/mekanism/client/gui/GuiEnrichmentChamber.java index 3df82f662..1d3ec0f72 100644 --- a/src/main/java/mekanism/client/gui/GuiEnrichmentChamber.java +++ b/src/main/java/mekanism/client/gui/GuiEnrichmentChamber.java @@ -1,22 +1,21 @@ package mekanism.client.gui; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.gui.element.GuiProgress.ProgressBar; import mekanism.common.tile.TileEntityElectricMachine; import net.minecraft.entity.player.InventoryPlayer; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiEnrichmentChamber extends GuiElectricMachine -{ - public GuiEnrichmentChamber(InventoryPlayer inventory, TileEntityElectricMachine tentity) - { - super(inventory, tentity); - } - - @Override - public ProgressBar getProgressType() - { - return ProgressBar.BLUE; - } +public class GuiEnrichmentChamber extends GuiElectricMachine { + public GuiEnrichmentChamber( + InventoryPlayer inventory, TileEntityElectricMachine tentity + ) { + super(inventory, tentity); + } + + @Override + public ProgressBar getProgressType() { + return ProgressBar.BLUE; + } } diff --git a/src/main/java/mekanism/client/gui/GuiFactory.java b/src/main/java/mekanism/client/gui/GuiFactory.java index a8f7967c0..6dfd033e3 100644 --- a/src/main/java/mekanism/client/gui/GuiFactory.java +++ b/src/main/java/mekanism/client/gui/GuiFactory.java @@ -3,6 +3,8 @@ package mekanism.client.gui; import java.util.ArrayList; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.util.ListUtils; import mekanism.client.gui.element.GuiElement.IInfoHandler; @@ -28,156 +30,195 @@ import mekanism.common.util.MekanismUtils; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; - import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiFactory extends GuiMekanism -{ - public TileEntityFactory tileEntity; +public class GuiFactory extends GuiMekanism { + public TileEntityFactory tileEntity; - public GuiFactory(InventoryPlayer inventory, TileEntityFactory tentity) - { - super(tentity, new ContainerFactory(inventory, tentity)); - tileEntity = tentity; + public GuiFactory(InventoryPlayer inventory, TileEntityFactory tentity) { + super(tentity, new ContainerFactory(inventory, tentity)); + tileEntity = tentity; - ySize += 11; + ySize += 11; - guiElements.add(new GuiRedstoneControl(this, tileEntity, tileEntity.tier.guiLocation)); - guiElements.add(new GuiSecurityTab(this, tileEntity, tileEntity.tier.guiLocation)); - guiElements.add(new GuiUpgradeTab(this, tileEntity, tileEntity.tier.guiLocation)); - guiElements.add(new GuiRecipeType(this, tileEntity, tileEntity.tier.guiLocation)); - guiElements.add(new GuiSideConfigurationTab(this, tileEntity, tileEntity.tier.guiLocation)); - guiElements.add(new GuiTransporterConfigTab(this, 34, tileEntity, tileEntity.tier.guiLocation)); - guiElements.add(new GuiSortingTab(this, tileEntity, tileEntity.tier.guiLocation)); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() { - @Override - public List getInfo() - { - String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.lastUsage); - return ListUtils.asList(LangUtils.localize("gui.using") + ": " + multiplier + "/t", LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); - } - }, this, tileEntity.tier.guiLocation)); - } + guiElements.add( + new GuiRedstoneControl(this, tileEntity, tileEntity.tier.guiLocation) + ); + guiElements.add(new GuiSecurityTab(this, tileEntity, tileEntity.tier.guiLocation) + ); + guiElements.add(new GuiUpgradeTab(this, tileEntity, tileEntity.tier.guiLocation)); + guiElements.add(new GuiRecipeType(this, tileEntity, tileEntity.tier.guiLocation)); + guiElements.add( + new GuiSideConfigurationTab(this, tileEntity, tileEntity.tier.guiLocation) + ); + guiElements.add( + new GuiTransporterConfigTab(this, 34, tileEntity, tileEntity.tier.guiLocation) + ); + guiElements.add(new GuiSortingTab(this, tileEntity, tileEntity.tier.guiLocation)); + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() { + String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.lastUsage); + return ListUtils.asList( + LangUtils.localize("gui.using") + ": " + multiplier + "/t", + LangUtils.localize("gui.needed") + ": " + + MekanismUtils.getEnergyDisplay( + tileEntity.getMaxEnergy() - tileEntity.getEnergy() + ) + ); + } + }, this, tileEntity.tier.guiLocation)); + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize/2)-(fontRendererObj.getStringWidth(tileEntity.getInventoryName())/2), 4, 0x404040); - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 93) + 2, 0x404040); + fontRendererObj.drawString( + tileEntity.getInventoryName(), + (xSize / 2) + - (fontRendererObj.getStringWidth(tileEntity.getInventoryName()) / 2), + 4, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, (ySize - 93) + 2, 0x404040 + ); - if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69) - { - drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis); - } + if (xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69) { + drawCreativeTabHoveringText( + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis + ); + } - if(xAxis >= 8 && xAxis <= 168 && yAxis >= 78 && yAxis <= 83) - { - if(tileEntity.recipeType.usesFuel()) - { - drawCreativeTabHoveringText(tileEntity.gasTank.getGas() != null ? tileEntity.gasTank.getGas().getGas().getLocalizedName() + ": " + tileEntity.gasTank.getStored() : LangUtils.localize("gui.none"), xAxis, yAxis); - } - else if(tileEntity.recipeType == RecipeType.INFUSING) - { - drawCreativeTabHoveringText(tileEntity.infuseStored.type != null ? tileEntity.infuseStored.type.getLocalizedName() + ": " + tileEntity.infuseStored.amount : LangUtils.localize("gui.empty"), xAxis, yAxis); - } - } + if (xAxis >= 8 && xAxis <= 168 && yAxis >= 78 && yAxis <= 83) { + if (tileEntity.recipeType.usesFuel()) { + drawCreativeTabHoveringText( + tileEntity.gasTank.getGas() != null + ? tileEntity.gasTank.getGas().getGas().getLocalizedName() + ": " + + tileEntity.gasTank.getStored() + : LangUtils.localize("gui.none"), + xAxis, + yAxis + ); + } else if (tileEntity.recipeType == RecipeType.INFUSING) { + drawCreativeTabHoveringText( + tileEntity.infuseStored.type != null + ? tileEntity.infuseStored.type.getLocalizedName() + ": " + + tileEntity.infuseStored.amount + : LangUtils.localize("gui.empty"), + xAxis, + yAxis + ); + } + } - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(tileEntity.tier.guiLocation); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture(tileEntity.tier.guiLocation); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - int xAxis = mouseX - guiWidth; - int yAxis = mouseY - guiHeight; + int xAxis = mouseX - guiWidth; + int yAxis = mouseY - guiHeight; - int displayInt; + int displayInt; - displayInt = tileEntity.getScaledEnergyLevel(52); - drawTexturedModalRect(guiWidth + 165, guiHeight + 17 + 52 - displayInt, 176, 52 - displayInt, 4, displayInt); + displayInt = tileEntity.getScaledEnergyLevel(52); + drawTexturedModalRect( + guiWidth + 165, + guiHeight + 17 + 52 - displayInt, + 176, + 52 - displayInt, + 4, + displayInt + ); - int xOffset = tileEntity.tier == FactoryTier.BASIC ? 59 : (tileEntity.tier == FactoryTier.ADVANCED ? - 39 : 33); - int xDistance = tileEntity.tier == FactoryTier.BASIC ? 38 : (tileEntity.tier == FactoryTier.ADVANCED ? - 26 : 19); - - for(int i = 0; i < tileEntity.tier.processes; i++) - { - int xPos = xOffset + (i*xDistance); + int xOffset = tileEntity.tier == FactoryTier.BASIC + ? 59 + : (tileEntity.tier == FactoryTier.ADVANCED ? 39 : 33); + int xDistance = tileEntity.tier == FactoryTier.BASIC + ? 38 + : (tileEntity.tier == FactoryTier.ADVANCED ? 26 : 19); - displayInt = tileEntity.getScaledProgress(20, i); - drawTexturedModalRect(guiWidth + xPos, guiHeight + 33, 176, 52, 8, displayInt); - } + for (int i = 0; i < tileEntity.tier.processes; i++) { + int xPos = xOffset + (i * xDistance); - if(tileEntity.recipeType.usesFuel()) - { - if(tileEntity.getScaledGasLevel(160) > 0) - { - displayGauge(8, 78, tileEntity.getScaledGasLevel(160), 5, tileEntity.gasTank.getGas().getGas().getIcon()); - } - } - else if(tileEntity.recipeType == RecipeType.INFUSING) - { - if(tileEntity.getScaledInfuseLevel(160) > 0) - { - displayGauge(8, 78, tileEntity.getScaledInfuseLevel(160), 5, tileEntity.infuseStored.type.icon); - } - } - - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } + displayInt = tileEntity.getScaledProgress(20, i); + drawTexturedModalRect( + guiWidth + xPos, guiHeight + 33, 176, 52, 8, displayInt + ); + } - public void displayGauge(int xPos, int yPos, int sizeX, int sizeY, IIcon icon) - { - if(icon == null) - { - return; - } + if (tileEntity.recipeType.usesFuel()) { + if (tileEntity.getScaledGasLevel(160) > 0) { + displayGauge( + 8, + 78, + tileEntity.getScaledGasLevel(160), + 5, + tileEntity.gasTank.getGas().getGas().getIcon() + ); + } + } else if (tileEntity.recipeType == RecipeType.INFUSING) { + if (tileEntity.getScaledInfuseLevel(160) > 0) { + displayGauge( + 8, + 78, + tileEntity.getScaledInfuseLevel(160), + 5, + tileEntity.infuseStored.type.icon + ); + } + } - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } - mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture()); - drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos, icon, sizeX, sizeY); - } - - @Override - protected void mouseClicked(int x, int y, int button) - { - super.mouseClicked(x, y, button); + public void displayGauge(int xPos, int yPos, int sizeX, int sizeY, IIcon icon) { + if (icon == null) { + return; + } - if(button == 0 || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) - { - int xAxis = (x - (width - xSize) / 2); - int yAxis = (y - (height - ySize) / 2); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; - if(xAxis > 8 && xAxis < 168 && yAxis > 78 && yAxis < 83) - { - ItemStack stack = mc.thePlayer.inventory.getItemStack(); - - if(stack != null && stack.getItem() instanceof ItemGaugeDropper) - { - ArrayList data = new ArrayList(); - data.add(1); - - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - SoundHandler.playSound("gui.button.press"); - } - } - } - } + mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture()); + drawTexturedModelRectFromIcon( + guiWidth + xPos, guiHeight + yPos, icon, sizeX, sizeY + ); + } + + @Override + protected void mouseClicked(int x, int y, int button) { + super.mouseClicked(x, y, button); + + if (button == 0 || Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + int xAxis = (x - (width - xSize) / 2); + int yAxis = (y - (height - ySize) / 2); + + if (xAxis > 8 && xAxis < 168 && yAxis > 78 && yAxis < 83) { + ItemStack stack = mc.thePlayer.inventory.getItemStack(); + + if (stack != null && stack.getItem() instanceof ItemGaugeDropper) { + ArrayList data = new ArrayList(); + data.add(1); + + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); + SoundHandler.playSound("gui.button.press"); + } + } + } + } } diff --git a/src/main/java/mekanism/client/gui/GuiFluidTank.java b/src/main/java/mekanism/client/gui/GuiFluidTank.java index c453d9848..c196fcea0 100644 --- a/src/main/java/mekanism/client/gui/GuiFluidTank.java +++ b/src/main/java/mekanism/client/gui/GuiFluidTank.java @@ -1,5 +1,7 @@ package mekanism.client.gui; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.gui.element.GuiContainerEditMode; import mekanism.client.gui.element.GuiFluidGauge; import mekanism.client.gui.element.GuiFluidGauge.IFluidInfoHandler; @@ -14,53 +16,79 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.entity.player.InventoryPlayer; import net.minecraftforge.fluids.FluidTank; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiFluidTank extends GuiMekanism -{ - public TileEntityFluidTank tileEntity; +public class GuiFluidTank extends GuiMekanism { + public TileEntityFluidTank tileEntity; - public GuiFluidTank(InventoryPlayer inventory, TileEntityFluidTank tentity) - { - super(tentity, new ContainerFluidTank(inventory, tentity)); - tileEntity = tentity; - guiElements.add(new GuiContainerEditMode(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"))); - guiElements.add(new GuiSecurityTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"))); - guiElements.add(new GuiFluidGauge(new IFluidInfoHandler() - { - @Override - public FluidTank getTank() - { - return tileEntity.fluidTank; - } - }, GuiFluidGauge.Type.WIDE, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 48, 18)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 145, 18).with(SlotOverlay.INPUT)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 145, 50).with(SlotOverlay.OUTPUT)); - } + public GuiFluidTank(InventoryPlayer inventory, TileEntityFluidTank tentity) { + super(tentity, new ContainerFluidTank(inventory, tentity)); + tileEntity = tentity; + guiElements.add(new GuiContainerEditMode( + this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png") + )); + guiElements.add(new GuiSecurityTab( + this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png") + )); + guiElements.add(new GuiFluidGauge( + new IFluidInfoHandler() { + @Override + public FluidTank getTank() { + return tileEntity.fluidTank; + } + }, + GuiFluidGauge.Type.WIDE, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), + 48, + 18 + )); + guiElements.add(new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), + 145, + 18 + ) + .with(SlotOverlay.INPUT)); + guiElements.add(new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), + 145, + 50 + ) + .with(SlotOverlay.OUTPUT)); + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize/2)-(fontRendererObj.getStringWidth(tileEntity.getInventoryName())/2), 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, ySize - 96 + 2, 0x404040); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + fontRendererObj.drawString( + tileEntity.getInventoryName(), + (xSize / 2) + - (fontRendererObj.getStringWidth(tileEntity.getInventoryName()) / 2), + 6, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, ySize - 96 + 2, 0x404040 + ); - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } } diff --git a/src/main/java/mekanism/client/gui/GuiFluidicPlenisher.java b/src/main/java/mekanism/client/gui/GuiFluidicPlenisher.java index ced3e4ed5..32653b768 100644 --- a/src/main/java/mekanism/client/gui/GuiFluidicPlenisher.java +++ b/src/main/java/mekanism/client/gui/GuiFluidicPlenisher.java @@ -2,6 +2,8 @@ package mekanism.client.gui; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.util.ListUtils; import mekanism.client.gui.element.GuiElement.IInfoHandler; import mekanism.client.gui.element.GuiEnergyInfo; @@ -23,69 +25,95 @@ import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fluids.FluidTank; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiFluidicPlenisher extends GuiMekanism -{ - public TileEntityFluidicPlenisher tileEntity; +public class GuiFluidicPlenisher extends GuiMekanism { + public TileEntityFluidicPlenisher tileEntity; - public ResourceLocation guiLocation = MekanismUtils.getResource(ResourceType.GUI, "GuiElectricPump.png"); + public ResourceLocation guiLocation + = MekanismUtils.getResource(ResourceType.GUI, "GuiElectricPump.png"); - public GuiFluidicPlenisher(InventoryPlayer inventory, TileEntityFluidicPlenisher tentity) - { - super(tentity, new ContainerFluidicPlenisher(inventory, tentity)); - tileEntity = tentity; + public GuiFluidicPlenisher( + InventoryPlayer inventory, TileEntityFluidicPlenisher tentity + ) { + super(tentity, new ContainerFluidicPlenisher(inventory, tentity)); + tileEntity = tentity; - guiElements.add(new GuiSlot(SlotType.NORMAL, this, guiLocation, 27, 19)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, guiLocation, 27, 50)); - guiElements.add(new GuiSlot(SlotType.POWER, this, guiLocation, 142, 34).with(SlotOverlay.POWER)); - guiElements.add(new GuiPowerBar(this, tileEntity, guiLocation, 164, 15)); - guiElements.add(new GuiFluidGauge(new IFluidInfoHandler() { - @Override - public FluidTank getTank() - { - return tileEntity.fluidTank; - } - }, GuiGauge.Type.STANDARD, this, guiLocation, 6, 13)); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() { - @Override - public List getInfo() - { - String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.energyPerTick); - return ListUtils.asList(LangUtils.localize("gui.using") + ": " + multiplier + "/t", LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); - } - }, this, guiLocation)); - guiElements.add(new GuiSecurityTab(this, tileEntity, guiLocation)); - guiElements.add(new GuiRedstoneControl(this, tileEntity, guiLocation)); - guiElements.add(new GuiUpgradeTab(this, tileEntity, guiLocation)); - } + guiElements.add(new GuiSlot(SlotType.NORMAL, this, guiLocation, 27, 19)); + guiElements.add(new GuiSlot(SlotType.NORMAL, this, guiLocation, 27, 50)); + guiElements.add(new GuiSlot(SlotType.POWER, this, guiLocation, 142, 34) + .with(SlotOverlay.POWER)); + guiElements.add(new GuiPowerBar(this, tileEntity, guiLocation, 164, 15)); + guiElements.add(new GuiFluidGauge(new IFluidInfoHandler() { + @Override + public FluidTank getTank() { + return tileEntity.fluidTank; + } + }, GuiGauge.Type.STANDARD, this, guiLocation, 6, 13)); + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() { + String multiplier + = MekanismUtils.getEnergyDisplay(tileEntity.energyPerTick); + return ListUtils.asList( + LangUtils.localize("gui.using") + ": " + multiplier + "/t", + LangUtils.localize("gui.needed") + ": " + + MekanismUtils.getEnergyDisplay( + tileEntity.getMaxEnergy() - tileEntity.getEnergy() + ) + ); + } + }, this, guiLocation)); + guiElements.add(new GuiSecurityTab(this, tileEntity, guiLocation)); + guiElements.add(new GuiRedstoneControl(this, tileEntity, guiLocation)); + guiElements.add(new GuiUpgradeTab(this, tileEntity, guiLocation)); + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize / 2) - (fontRendererObj.getStringWidth(tileEntity.getInventoryName()) / 2), 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 94) + 2, 0x404040); - fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00); - fontRendererObj.drawString(LangUtils.localize("gui.finished") + ": " + LangUtils.transYesNo(tileEntity.finishedCalc), 51, 35, 0x00CD00); - fontRendererObj.drawString(tileEntity.fluidTank.getFluid() != null ? LangUtils.localizeFluidStack(tileEntity.fluidTank.getFluid()) + ": " + tileEntity.fluidTank.getFluid().amount : LangUtils.localize("gui.noFluid"), 51, 44, 0x00CD00); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + fontRendererObj.drawString( + tileEntity.getInventoryName(), + (xSize / 2) + - (fontRendererObj.getStringWidth(tileEntity.getInventoryName()) / 2), + 6, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, (ySize - 94) + 2, 0x404040 + ); + fontRendererObj.drawString( + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.finished") + ": " + + LangUtils.transYesNo(tileEntity.finishedCalc), + 51, + 35, + 0x00CD00 + ); + fontRendererObj.drawString( + tileEntity.fluidTank.getFluid() != null + ? LangUtils.localizeFluidStack(tileEntity.fluidTank.getFluid()) + ": " + + tileEntity.fluidTank.getFluid().amount + : LangUtils.localize("gui.noFluid"), + 51, + 44, + 0x00CD00 + ); - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(guiLocation); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture(guiLocation); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } } diff --git a/src/main/java/mekanism/client/gui/GuiFormulaicAssemblicator.java b/src/main/java/mekanism/client/gui/GuiFormulaicAssemblicator.java index 573ee0fca..2fcbe7acd 100644 --- a/src/main/java/mekanism/client/gui/GuiFormulaicAssemblicator.java +++ b/src/main/java/mekanism/client/gui/GuiFormulaicAssemblicator.java @@ -3,6 +3,8 @@ package mekanism.client.gui; import java.util.ArrayList; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.util.ListUtils; import mekanism.client.gui.element.GuiElement.IInfoHandler; @@ -30,273 +32,299 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiFormulaicAssemblicator extends GuiMekanism -{ - public TileEntityFormulaicAssemblicator tileEntity; - - public ResourceLocation guiLocation = MekanismUtils.getResource(ResourceType.GUI, "GuiFormulaicAssemblicator.png"); +public class GuiFormulaicAssemblicator extends GuiMekanism { + public TileEntityFormulaicAssemblicator tileEntity; - public GuiFormulaicAssemblicator(InventoryPlayer inventory, TileEntityFormulaicAssemblicator tentity) - { - super(tentity, new ContainerFormulaicAssemblicator(inventory, tentity)); - tileEntity = tentity; - guiElements.add(new GuiSecurityTab(this, tileEntity, guiLocation)); - guiElements.add(new GuiUpgradeTab(this, tileEntity, guiLocation)); - guiElements.add(new GuiRedstoneControl(this, tileEntity, guiLocation)); - guiElements.add(new GuiSideConfigurationTab(this, tileEntity, guiLocation)); - guiElements.add(new GuiTransporterConfigTab(this, 34, tileEntity, guiLocation)); - guiElements.add(new GuiPowerBar(this, tileEntity, guiLocation, 159, 15)); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() { - @Override - public List getInfo() - { - String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.energyPerTick); - return ListUtils.asList(LangUtils.localize("gui.using") + ": " + multiplier + "/t", LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); - } - }, this, guiLocation)); - guiElements.add(new GuiSlot(SlotType.POWER, this, guiLocation, 151, 75).with(SlotOverlay.POWER)); - - ySize+=64; - } + public ResourceLocation guiLocation + = MekanismUtils.getResource(ResourceType.GUI, "GuiFormulaicAssemblicator.png"); - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); - - fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize/2)-(fontRendererObj.getStringWidth(tileEntity.getInventoryName())/2), 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); - - if(xAxis >= 44 && xAxis <= 60 && yAxis >= 75 && yAxis <= 91) - { - drawCreativeTabHoveringText(LangUtils.localize("gui.fillEmpty"), xAxis, yAxis); - } - - if(xAxis >= 7 && xAxis <= 21 && yAxis >= 45 && yAxis <= 59) - { - drawCreativeTabHoveringText(LangUtils.localize("gui.encodeFormula"), xAxis, yAxis); - } - - if(xAxis >= 71 && xAxis <= 87 && yAxis >= 75 && yAxis <= 91) - { - drawCreativeTabHoveringText(LangUtils.localize("gui.craftSingle"), xAxis, yAxis); - } - - if(xAxis >= 89 && xAxis <= 105 && yAxis >= 75 && yAxis <= 91) - { - drawCreativeTabHoveringText(LangUtils.localize("gui.craftAvailable"), xAxis, yAxis); - } - - if(xAxis >= 107 && xAxis <= 123 && yAxis >= 75 && yAxis <= 91) - { - drawCreativeTabHoveringText(LangUtils.localize("gui.autoModeToggle") + " " + LangUtils.transOnOff(!tileEntity.autoMode), xAxis, yAxis); - } - - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + public GuiFormulaicAssemblicator( + InventoryPlayer inventory, TileEntityFormulaicAssemblicator tentity + ) { + super(tentity, new ContainerFormulaicAssemblicator(inventory, tentity)); + tileEntity = tentity; + guiElements.add(new GuiSecurityTab(this, tileEntity, guiLocation)); + guiElements.add(new GuiUpgradeTab(this, tileEntity, guiLocation)); + guiElements.add(new GuiRedstoneControl(this, tileEntity, guiLocation)); + guiElements.add(new GuiSideConfigurationTab(this, tileEntity, guiLocation)); + guiElements.add(new GuiTransporterConfigTab(this, 34, tileEntity, guiLocation)); + guiElements.add(new GuiPowerBar(this, tileEntity, guiLocation, 159, 15)); + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() { + String multiplier + = MekanismUtils.getEnergyDisplay(tileEntity.energyPerTick); + return ListUtils.asList( + LangUtils.localize("gui.using") + ": " + multiplier + "/t", + LangUtils.localize("gui.needed") + ": " + + MekanismUtils.getEnergyDisplay( + tileEntity.getMaxEnergy() - tileEntity.getEnergy() + ) + ); + } + }, this, guiLocation)); + guiElements.add(new GuiSlot(SlotType.POWER, this, guiLocation, 151, 75) + .with(SlotOverlay.POWER)); - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(guiLocation); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - int xAxis = mouseX - guiWidth; - int yAxis = mouseY - guiHeight; - - if(!tileEntity.autoMode) - { - if(xAxis >= 44 && xAxis <= 60 && yAxis >= 75 && yAxis <= 91) - { - drawTexturedModalRect(guiWidth + 44, guiHeight + 75, 176 + 62, 0, 16, 16); - } - else { - drawTexturedModalRect(guiWidth + 44, guiHeight + 75, 176 + 62, 16, 16, 16); - } - } - else { - drawTexturedModalRect(guiWidth + 44, guiHeight + 75, 176 + 62, 32, 16, 16); - } - - if(!tileEntity.autoMode && tileEntity.isRecipe) - { - if(canEncode()) - { - if(xAxis >= 7 && xAxis <= 21 && yAxis >= 45 && yAxis <= 59) - { - drawTexturedModalRect(guiWidth + 7, guiHeight + 45, 176, 0, 14, 14); - } - else { - drawTexturedModalRect(guiWidth + 7, guiHeight + 45, 176, 14, 14, 14); - } - } - else { - drawTexturedModalRect(guiWidth + 7, guiHeight + 45, 176, 28, 14, 14); - } - - if(xAxis >= 71 && xAxis <= 87 && yAxis >= 75 && yAxis <= 91) - { - drawTexturedModalRect(guiWidth + 71, guiHeight + 75, 176 + 14, 0, 16, 16); - } - else { - drawTexturedModalRect(guiWidth + 71, guiHeight + 75, 176 + 14, 16, 16, 16); - } - - if(xAxis >= 89 && xAxis <= 105 && yAxis >= 75 && yAxis <= 91) - { - drawTexturedModalRect(guiWidth + 89, guiHeight + 75, 176 + 30, 0, 16, 16); - } - else { - drawTexturedModalRect(guiWidth + 89, guiHeight + 75, 176 + 30, 16, 16, 16); - } - } - else { - drawTexturedModalRect(guiWidth + 7, guiHeight + 45, 176, 28, 14, 14); - drawTexturedModalRect(guiWidth + 71, guiHeight + 75, 176 + 14, 32, 16, 16); - drawTexturedModalRect(guiWidth + 89, guiHeight + 75, 176 + 30, 32, 16, 16); - } - - if(tileEntity.formula != null) - { - if(xAxis >= 107 && xAxis <= 123 && yAxis >= 75 && yAxis <= 91) - { - drawTexturedModalRect(guiWidth + 107, guiHeight + 75, 176 + 46, 0, 16, 16); - } - else { - drawTexturedModalRect(guiWidth + 107, guiHeight + 75, 176 + 46, 16, 16, 16); - } - } - else { - drawTexturedModalRect(guiWidth + 107, guiHeight + 75, 176 + 46, 32, 16, 16); - } - - if(tileEntity.operatingTicks > 0) - { - int display = (int)((double)tileEntity.operatingTicks*22/(double)tileEntity.ticksRequired); - drawTexturedModalRect(guiWidth + 86, guiHeight + 43, 176, 48, display, 16); - } - - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiSlot.png")); - drawTexturedModalRect(guiWidth + 90, guiHeight + 25, tileEntity.isRecipe ? 2 : 20, 39, 14, 12); - - if(tileEntity.formula != null) - { - for(int i = 0; i < 9; i++) - { - ItemStack stack = tileEntity.formula.input[i]; - - if(stack != null) - { - Slot slot = (Slot)inventorySlots.inventorySlots.get(i+20); - GL11.glPushMatrix(); - - if(slot.getStack() == null || !slot.getStack().isItemEqual(stack)) - { - drawGradientRect(guiWidth + slot.xDisplayPosition, guiHeight + slot.yDisplayPosition, guiWidth + slot.xDisplayPosition + 16, guiHeight + slot.yDisplayPosition + 16, -2137456640, -2137456640); - } - - GL11.glEnable(GL11.GL_LIGHTING); - MekanismRenderer.blendOn(); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.4F); - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), stack, guiWidth + slot.xDisplayPosition, guiHeight + slot.yDisplayPosition); - MekanismRenderer.blendOff(); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } - } - } + ySize += 64; + } - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } - - private boolean canEncode() - { - return tileEntity.formula == null && tileEntity.inventory[2] != null && tileEntity.inventory[2].getItem() instanceof ItemCraftingFormula && - ((ItemCraftingFormula)tileEntity.inventory[2].getItem()).getInventory(tileEntity.inventory[2]) == null; - } - - @Override - protected void mouseClicked(int mouseX, int mouseY, int button) - { - super.mouseClicked(mouseX, mouseY, button); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - if(button == 0) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + fontRendererObj.drawString( + tileEntity.getInventoryName(), + (xSize / 2) + - (fontRendererObj.getStringWidth(tileEntity.getInventoryName()) / 2), + 6, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040 + ); - if(!tileEntity.autoMode) - { - if(xAxis >= 44 && xAxis <= 60 && yAxis >= 75 && yAxis <= 91) - { - SoundHandler.playSound("gui.button.press"); - - ArrayList data = new ArrayList(); - data.add(4); + if (xAxis >= 44 && xAxis <= 60 && yAxis >= 75 && yAxis <= 91) { + drawCreativeTabHoveringText( + LangUtils.localize("gui.fillEmpty"), xAxis, yAxis + ); + } - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - } - - if(tileEntity.isRecipe) - { - if(canEncode()) - { - if(xAxis >= 7 && xAxis <= 21 && yAxis >= 45 && yAxis <= 59) - { - SoundHandler.playSound("gui.button.press"); - - ArrayList data = new ArrayList(); - data.add(1); - - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - } - } - - if(xAxis >= 71 && xAxis <= 87 && yAxis >= 75 && yAxis <= 91) - { - SoundHandler.playSound("gui.button.press"); - - ArrayList data = new ArrayList(); - data.add(2); - - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - } - - if(xAxis >= 89 && xAxis <= 105 && yAxis >= 75 && yAxis <= 91) - { - SoundHandler.playSound("gui.button.press"); - - ArrayList data = new ArrayList(); - data.add(3); - - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - } - } - } - - if(tileEntity.formula != null) - { - if(xAxis >= 107 && xAxis <= 123 && yAxis >= 75 && yAxis <= 91) - { - SoundHandler.playSound("gui.button.press"); - - ArrayList data = new ArrayList(); - data.add(0); - - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - } - } - } - } + if (xAxis >= 7 && xAxis <= 21 && yAxis >= 45 && yAxis <= 59) { + drawCreativeTabHoveringText( + LangUtils.localize("gui.encodeFormula"), xAxis, yAxis + ); + } + + if (xAxis >= 71 && xAxis <= 87 && yAxis >= 75 && yAxis <= 91) { + drawCreativeTabHoveringText( + LangUtils.localize("gui.craftSingle"), xAxis, yAxis + ); + } + + if (xAxis >= 89 && xAxis <= 105 && yAxis >= 75 && yAxis <= 91) { + drawCreativeTabHoveringText( + LangUtils.localize("gui.craftAvailable"), xAxis, yAxis + ); + } + + if (xAxis >= 107 && xAxis <= 123 && yAxis >= 75 && yAxis <= 91) { + drawCreativeTabHoveringText( + LangUtils.localize("gui.autoModeToggle") + " " + + LangUtils.transOnOff(!tileEntity.autoMode), + xAxis, + yAxis + ); + } + + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture(guiLocation); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int xAxis = mouseX - guiWidth; + int yAxis = mouseY - guiHeight; + + if (!tileEntity.autoMode) { + if (xAxis >= 44 && xAxis <= 60 && yAxis >= 75 && yAxis <= 91) { + drawTexturedModalRect(guiWidth + 44, guiHeight + 75, 176 + 62, 0, 16, 16); + } else { + drawTexturedModalRect( + guiWidth + 44, guiHeight + 75, 176 + 62, 16, 16, 16 + ); + } + } else { + drawTexturedModalRect(guiWidth + 44, guiHeight + 75, 176 + 62, 32, 16, 16); + } + + if (!tileEntity.autoMode && tileEntity.isRecipe) { + if (canEncode()) { + if (xAxis >= 7 && xAxis <= 21 && yAxis >= 45 && yAxis <= 59) { + drawTexturedModalRect(guiWidth + 7, guiHeight + 45, 176, 0, 14, 14); + } else { + drawTexturedModalRect(guiWidth + 7, guiHeight + 45, 176, 14, 14, 14); + } + } else { + drawTexturedModalRect(guiWidth + 7, guiHeight + 45, 176, 28, 14, 14); + } + + if (xAxis >= 71 && xAxis <= 87 && yAxis >= 75 && yAxis <= 91) { + drawTexturedModalRect(guiWidth + 71, guiHeight + 75, 176 + 14, 0, 16, 16); + } else { + drawTexturedModalRect( + guiWidth + 71, guiHeight + 75, 176 + 14, 16, 16, 16 + ); + } + + if (xAxis >= 89 && xAxis <= 105 && yAxis >= 75 && yAxis <= 91) { + drawTexturedModalRect(guiWidth + 89, guiHeight + 75, 176 + 30, 0, 16, 16); + } else { + drawTexturedModalRect( + guiWidth + 89, guiHeight + 75, 176 + 30, 16, 16, 16 + ); + } + } else { + drawTexturedModalRect(guiWidth + 7, guiHeight + 45, 176, 28, 14, 14); + drawTexturedModalRect(guiWidth + 71, guiHeight + 75, 176 + 14, 32, 16, 16); + drawTexturedModalRect(guiWidth + 89, guiHeight + 75, 176 + 30, 32, 16, 16); + } + + if (tileEntity.formula != null) { + if (xAxis >= 107 && xAxis <= 123 && yAxis >= 75 && yAxis <= 91) { + drawTexturedModalRect( + guiWidth + 107, guiHeight + 75, 176 + 46, 0, 16, 16 + ); + } else { + drawTexturedModalRect( + guiWidth + 107, guiHeight + 75, 176 + 46, 16, 16, 16 + ); + } + } else { + drawTexturedModalRect(guiWidth + 107, guiHeight + 75, 176 + 46, 32, 16, 16); + } + + if (tileEntity.operatingTicks > 0) { + int display = (int + ) ((double) tileEntity.operatingTicks * 22 / (double) tileEntity.ticksRequired + ); + drawTexturedModalRect(guiWidth + 86, guiHeight + 43, 176, 48, display, 16); + } + + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiSlot.png") + ); + drawTexturedModalRect( + guiWidth + 90, guiHeight + 25, tileEntity.isRecipe ? 2 : 20, 39, 14, 12 + ); + + if (tileEntity.formula != null) { + for (int i = 0; i < 9; i++) { + ItemStack stack = tileEntity.formula.input[i]; + + if (stack != null) { + Slot slot = (Slot) inventorySlots.inventorySlots.get(i + 20); + GL11.glPushMatrix(); + + if (slot.getStack() == null || !slot.getStack().isItemEqual(stack)) { + drawGradientRect( + guiWidth + slot.xDisplayPosition, + guiHeight + slot.yDisplayPosition, + guiWidth + slot.xDisplayPosition + 16, + guiHeight + slot.yDisplayPosition + 16, + -2137456640, + -2137456640 + ); + } + + GL11.glEnable(GL11.GL_LIGHTING); + MekanismRenderer.blendOn(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.4F); + itemRender.renderItemAndEffectIntoGUI( + fontRendererObj, + mc.getTextureManager(), + stack, + guiWidth + slot.xDisplayPosition, + guiHeight + slot.yDisplayPosition + ); + MekanismRenderer.blendOff(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + } + } + + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } + + private boolean canEncode() { + return tileEntity.formula == null && tileEntity.inventory[2] != null + && tileEntity.inventory[2].getItem() instanceof ItemCraftingFormula + && ((ItemCraftingFormula) tileEntity.inventory[2].getItem()) + .getInventory(tileEntity.inventory[2]) + == null; + } + + @Override + protected void mouseClicked(int mouseX, int mouseY, int button) { + super.mouseClicked(mouseX, mouseY, button); + + if (button == 0) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + if (!tileEntity.autoMode) { + if (xAxis >= 44 && xAxis <= 60 && yAxis >= 75 && yAxis <= 91) { + SoundHandler.playSound("gui.button.press"); + + ArrayList data = new ArrayList(); + data.add(4); + + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); + } + + if (tileEntity.isRecipe) { + if (canEncode()) { + if (xAxis >= 7 && xAxis <= 21 && yAxis >= 45 && yAxis <= 59) { + SoundHandler.playSound("gui.button.press"); + + ArrayList data = new ArrayList(); + data.add(1); + + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); + } + } + + if (xAxis >= 71 && xAxis <= 87 && yAxis >= 75 && yAxis <= 91) { + SoundHandler.playSound("gui.button.press"); + + ArrayList data = new ArrayList(); + data.add(2); + + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); + } + + if (xAxis >= 89 && xAxis <= 105 && yAxis >= 75 && yAxis <= 91) { + SoundHandler.playSound("gui.button.press"); + + ArrayList data = new ArrayList(); + data.add(3); + + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); + } + } + } + + if (tileEntity.formula != null) { + if (xAxis >= 107 && xAxis <= 123 && yAxis >= 75 && yAxis <= 91) { + SoundHandler.playSound("gui.button.press"); + + ArrayList data = new ArrayList(); + data.add(0); + + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); + } + } + } + } } diff --git a/src/main/java/mekanism/client/gui/GuiFuelwoodHeater.java b/src/main/java/mekanism/client/gui/GuiFuelwoodHeater.java index 71d1b3050..5dd676f46 100644 --- a/src/main/java/mekanism/client/gui/GuiFuelwoodHeater.java +++ b/src/main/java/mekanism/client/gui/GuiFuelwoodHeater.java @@ -2,6 +2,8 @@ package mekanism.client.gui; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.MekanismConfig.general; import mekanism.api.util.ListUtils; import mekanism.api.util.UnitDisplayUtils; @@ -17,65 +19,105 @@ import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.entity.player.InventoryPlayer; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiFuelwoodHeater extends GuiMekanism -{ - public TileEntityFuelwoodHeater tileEntity; - - public GuiFuelwoodHeater(InventoryPlayer inventory, TileEntityFuelwoodHeater tentity) - { - super(tentity, new ContainerFuelwoodHeater(inventory, tentity)); - tileEntity = tentity; - - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiFuelwoodHeater.png"), 14, 28)); - guiElements.add(new GuiSecurityTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiFuelwoodHeater.png"))); - guiElements.add(new GuiHeatInfo(new IInfoHandler() { - @Override - public List getInfo() - { - TemperatureUnit unit = TemperatureUnit.values()[general.tempUnit.ordinal()]; - String environment = UnitDisplayUtils.getDisplayShort(tileEntity.lastEnvironmentLoss*unit.intervalSize, false, unit); - return ListUtils.asList(LangUtils.localize("gui.dissipated") + ": " + environment + "/t"); - } - }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiFuelwoodHeater.png"))); - } - - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize / 2) - (fontRendererObj.getStringWidth(tileEntity.getInventoryName()) / 2), 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 94) + 2, 0x404040); - - renderScaledText(LangUtils.localize("gui.temp") + ": " + MekanismUtils.getTemperatureDisplay(tileEntity.temperature, TemperatureUnit.AMBIENT), 50, 25, 0x00CD00, 76); - renderScaledText(LangUtils.localize("gui.fuel") + ": " + tileEntity.burnTime, 50, 41, 0x00CD00, 76); +public class GuiFuelwoodHeater extends GuiMekanism { + public TileEntityFuelwoodHeater tileEntity; - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } - - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiFuelwoodHeater.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); - - if(tileEntity.burnTime > 0) - { - int displayInt = tileEntity.burnTime*13 / tileEntity.maxBurnTime; - drawTexturedModalRect(guiWidth + 143, guiHeight + 30 + 12 - displayInt, 176, 12 - displayInt, 14, displayInt + 1); - } - - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } + public GuiFuelwoodHeater( + InventoryPlayer inventory, TileEntityFuelwoodHeater tentity + ) { + super(tentity, new ContainerFuelwoodHeater(inventory, tentity)); + tileEntity = tentity; + + guiElements.add(new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiFuelwoodHeater.png"), + 14, + 28 + )); + guiElements.add(new GuiSecurityTab( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiFuelwoodHeater.png") + )); + guiElements.add(new GuiHeatInfo(new IInfoHandler() { + @Override + public List getInfo() { + TemperatureUnit unit + = TemperatureUnit.values()[general.tempUnit.ordinal()]; + String environment = UnitDisplayUtils.getDisplayShort( + tileEntity.lastEnvironmentLoss * unit.intervalSize, false, unit + ); + return ListUtils.asList( + LangUtils.localize("gui.dissipated") + ": " + environment + "/t" + ); + } + }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiFuelwoodHeater.png"))); + } + + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + fontRendererObj.drawString( + tileEntity.getInventoryName(), + (xSize / 2) + - (fontRendererObj.getStringWidth(tileEntity.getInventoryName()) / 2), + 6, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, (ySize - 94) + 2, 0x404040 + ); + + renderScaledText( + LangUtils.localize("gui.temp") + ": " + + MekanismUtils.getTemperatureDisplay( + tileEntity.temperature, TemperatureUnit.AMBIENT + ), + 50, + 25, + 0x00CD00, + 76 + ); + renderScaledText( + LangUtils.localize("gui.fuel") + ": " + tileEntity.burnTime, + 50, + 41, + 0x00CD00, + 76 + ); + + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiFuelwoodHeater.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + if (tileEntity.burnTime > 0) { + int displayInt = tileEntity.burnTime * 13 / tileEntity.maxBurnTime; + drawTexturedModalRect( + guiWidth + 143, + guiHeight + 30 + 12 - displayInt, + 176, + 12 - displayInt, + 14, + displayInt + 1 + ); + } + + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } } diff --git a/src/main/java/mekanism/client/gui/GuiGasTank.java b/src/main/java/mekanism/client/gui/GuiGasTank.java index 99a1eb195..fa540f082 100644 --- a/src/main/java/mekanism/client/gui/GuiGasTank.java +++ b/src/main/java/mekanism/client/gui/GuiGasTank.java @@ -2,6 +2,8 @@ package mekanism.client.gui; import java.util.ArrayList; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.client.gui.element.GuiRedstoneControl; import mekanism.client.gui.element.GuiSecurityTab; @@ -19,103 +21,152 @@ import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.entity.player.InventoryPlayer; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiGasTank extends GuiMekanism -{ - public TileEntityGasTank tileEntity; +public class GuiGasTank extends GuiMekanism { + public TileEntityGasTank tileEntity; - public GuiGasTank(InventoryPlayer inventory, TileEntityGasTank tentity) - { - super(tentity, new ContainerGasTank(inventory, tentity)); - tileEntity = tentity; - guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiGasTank.png"))); - guiElements.add(new GuiSecurityTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiGasTank.png"))); - guiElements.add(new GuiSideConfigurationTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiGasTank.png"))); - guiElements.add(new GuiTransporterConfigTab(this, 34, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiGasTank.png"))); - guiElements.add(new GuiSlot(SlotType.OUTPUT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiGasTank.png"), 7, 7).with(SlotOverlay.PLUS)); - guiElements.add(new GuiSlot(SlotType.INPUT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiGasTank.png"), 7, 39).with(SlotOverlay.MINUS)); - } + public GuiGasTank(InventoryPlayer inventory, TileEntityGasTank tentity) { + super(tentity, new ContainerGasTank(inventory, tentity)); + tileEntity = tentity; + guiElements.add(new GuiRedstoneControl( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiGasTank.png") + )); + guiElements.add(new GuiSecurityTab( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiGasTank.png") + )); + guiElements.add(new GuiSideConfigurationTab( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiGasTank.png") + )); + guiElements.add(new GuiTransporterConfigTab( + this, + 34, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiGasTank.png") + )); + guiElements.add(new GuiSlot( + SlotType.OUTPUT, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiGasTank.png"), + 7, + 7 + ) + .with(SlotOverlay.PLUS)); + guiElements.add(new GuiSlot( + SlotType.INPUT, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiGasTank.png"), + 7, + 39 + ) + .with(SlotOverlay.MINUS)); + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - String capacityInfo = tileEntity.gasTank.getStored() + "/" + tileEntity.tier.storage; + String capacityInfo + = tileEntity.gasTank.getStored() + "/" + tileEntity.tier.storage; - fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize / 2) - (fontRendererObj.getStringWidth(tileEntity.getInventoryName()) / 2), 6, 0x404040); - fontRendererObj.drawString(capacityInfo, 45, 40, 0x404040); - renderScaledText(LangUtils.localize("gui.gas") + ": " + (tileEntity.gasTank.getGas() != null ? tileEntity.gasTank.getGas().getGas().getLocalizedName() : LangUtils.localize("gui.none")), 45, 49, 0x404040, 112); - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, ySize - 96 + 2, 0x404040); + fontRendererObj.drawString( + tileEntity.getInventoryName(), + (xSize / 2) + - (fontRendererObj.getStringWidth(tileEntity.getInventoryName()) / 2), + 6, + 0x404040 + ); + fontRendererObj.drawString(capacityInfo, 45, 40, 0x404040); + renderScaledText( + LangUtils.localize("gui.gas") + ": " + + (tileEntity.gasTank.getGas() != null + ? tileEntity.gasTank.getGas().getGas().getLocalizedName() + : LangUtils.localize("gui.none")), + 45, + 49, + 0x404040, + 112 + ); + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, ySize - 96 + 2, 0x404040 + ); - String name = chooseByMode(tileEntity.dumping, LangUtils.localize("gui.idle"), LangUtils.localize("gui.dumping"), LangUtils.localize("gui.dumping_excess")); - fontRendererObj.drawString(name, 156 - fontRendererObj.getStringWidth(name), 73, 0x404040); + String name = chooseByMode( + tileEntity.dumping, + LangUtils.localize("gui.idle"), + LangUtils.localize("gui.dumping"), + LangUtils.localize("gui.dumping_excess") + ); + fontRendererObj.drawString( + name, 156 - fontRendererObj.getStringWidth(name), 73, 0x404040 + ); - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiGasTank.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiGasTank.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + int displayInt = chooseByMode(tileEntity.dumping, 10, 18, 26); + drawTexturedModalRect(guiWidth + 160, guiHeight + 73, 176, displayInt, 8, 8); - int displayInt = chooseByMode(tileEntity.dumping, 10, 18, 26); - drawTexturedModalRect(guiWidth + 160, guiHeight + 73, 176, displayInt, 8, 8); + if (tileEntity.gasTank.getGas() != null) { + int scale = (int + ) (((double) tileEntity.gasTank.getStored() / tileEntity.tier.storage) * 72); + drawTexturedModalRect(guiWidth + 65, guiHeight + 17, 176, 0, scale, 10); + } - if(tileEntity.gasTank.getGas() != null) - { - int scale = (int)(((double)tileEntity.gasTank.getStored() / tileEntity.tier.storage) * 72); - drawTexturedModalRect(guiWidth + 65, guiHeight + 17, 176, 0, scale, 10); - } - - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } - @Override - protected void mouseClicked(int x, int y, int button) - { - super.mouseClicked(x, y, button); + @Override + protected void mouseClicked(int x, int y, int button) { + super.mouseClicked(x, y, button); - int xAxis = (x - (width - xSize) / 2); - int yAxis = (y - (height - ySize) / 2); + int xAxis = (x - (width - xSize) / 2); + int yAxis = (y - (height - ySize) / 2); - if(xAxis > 160 && xAxis < 169 && yAxis > 73 && yAxis < 82) - { - ArrayList data = new ArrayList(); - data.add(0); + if (xAxis > 160 && xAxis < 169 && yAxis > 73 && yAxis < 82) { + ArrayList data = new ArrayList(); + data.add(0); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - SoundHandler.playSound("gui.button.press"); - } - } + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); + SoundHandler.playSound("gui.button.press"); + } + } - private T chooseByMode(TileEntityGasTank.GasMode dumping, T idleOption, T dumpingOption, T dumpingExcessOption) - { - if(dumping.equals(TileEntityGasTank.GasMode.IDLE)) - { - return idleOption; - } - else if(dumping.equals(TileEntityGasTank.GasMode.DUMPING)) - { - return dumpingOption; - } - else if(dumping.equals(TileEntityGasTank.GasMode.DUMPING_EXCESS)) - { - return dumpingExcessOption; - } - - return idleOption; //should not happen; - } + private T chooseByMode( + TileEntityGasTank.GasMode dumping, + T idleOption, + T dumpingOption, + T dumpingExcessOption + ) { + if (dumping.equals(TileEntityGasTank.GasMode.IDLE)) { + return idleOption; + } else if (dumping.equals(TileEntityGasTank.GasMode.DUMPING)) { + return dumpingOption; + } else if (dumping.equals(TileEntityGasTank.GasMode.DUMPING_EXCESS)) { + return dumpingExcessOption; + } + + return idleOption; //should not happen; + } } diff --git a/src/main/java/mekanism/client/gui/GuiInductionMatrix.java b/src/main/java/mekanism/client/gui/GuiInductionMatrix.java index fce2961c2..e5489aa79 100644 --- a/src/main/java/mekanism/client/gui/GuiInductionMatrix.java +++ b/src/main/java/mekanism/client/gui/GuiInductionMatrix.java @@ -2,6 +2,8 @@ package mekanism.client.gui; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.util.ListUtils; import mekanism.client.gui.element.GuiElement.IInfoHandler; import mekanism.client.gui.element.GuiEnergyInfo; @@ -14,106 +16,141 @@ import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.entity.player.InventoryPlayer; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiInductionMatrix extends GuiMekanism -{ - public TileEntityInductionCasing tileEntity; +public class GuiInductionMatrix extends GuiMekanism { + public TileEntityInductionCasing tileEntity; - public GuiInductionMatrix(InventoryPlayer inventory, TileEntityInductionCasing tentity) - { - super(tentity, new ContainerInductionMatrix(inventory, tentity)); - tileEntity = tentity; - guiElements.add(new GuiMatrixTab(this, tileEntity, MatrixTab.STAT, 6, MekanismUtils.getResource(ResourceType.GUI, "GuiInductionMatrix.png"))); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() - { - @Override - public List getInfo() - { - return ListUtils.asList( - LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), - LangUtils.localize("gui.input") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.structure.lastInput) + "/t", - LangUtils.localize("gui.output") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.structure.lastOutput) + "/t"); - } - }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiInductionMatrix.png"))); - } + public GuiInductionMatrix( + InventoryPlayer inventory, TileEntityInductionCasing tentity + ) { + super(tentity, new ContainerInductionMatrix(inventory, tentity)); + tileEntity = tentity; + guiElements.add(new GuiMatrixTab( + this, + tileEntity, + MatrixTab.STAT, + 6, + MekanismUtils.getResource(ResourceType.GUI, "GuiInductionMatrix.png") + )); + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() { + return ListUtils.asList( + LangUtils.localize("gui.storing") + ": " + + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), + LangUtils.localize("gui.input") + ": " + + MekanismUtils.getEnergyDisplay(tileEntity.structure.lastInput) + + "/t", + LangUtils.localize("gui.output") + ": " + + MekanismUtils.getEnergyDisplay(tileEntity.structure.lastOutput) + + "/t" + ); + } + }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiInductionMatrix.png"))); + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize/2)-(fontRendererObj.getStringWidth(tileEntity.getInventoryName())/2), 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 94) + 2, 0x404040); - fontRendererObj.drawString(LangUtils.localize("gui.input") + ":", 53, 26, 0x00CD00); - fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.structure.lastInput) + "/t", 53, 35, 0x00CD00); - fontRendererObj.drawString(LangUtils.localize("gui.output") + ":", 53, 44, 0x00CD00); - fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.structure.lastOutput) + "/t", 53, 53, 0x00CD00); + fontRendererObj.drawString( + tileEntity.getInventoryName(), + (xSize / 2) + - (fontRendererObj.getStringWidth(tileEntity.getInventoryName()) / 2), + 6, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, (ySize - 94) + 2, 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.input") + ":", 53, 26, 0x00CD00 + ); + fontRendererObj.drawString( + MekanismUtils.getEnergyDisplay(tileEntity.structure.lastInput) + "/t", + 53, + 35, + 0x00CD00 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.output") + ":", 53, 44, 0x00CD00 + ); + fontRendererObj.drawString( + MekanismUtils.getEnergyDisplay(tileEntity.structure.lastOutput) + "/t", + 53, + 53, + 0x00CD00 + ); - if(xAxis >= 7 && xAxis <= 39 && yAxis >= 14 && yAxis <= 72) - { - drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis); - } + if (xAxis >= 7 && xAxis <= 39 && yAxis >= 14 && yAxis <= 72) { + drawCreativeTabHoveringText( + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis + ); + } - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiInductionMatrix.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiInductionMatrix.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - if(tileEntity.getScaledEnergyLevel(58) > 0) - { - displayGauge(7, 14, tileEntity.getScaledEnergyLevel(58), 0); - displayGauge(23, 14, tileEntity.getScaledEnergyLevel(58), 1); - } - } + if (tileEntity.getScaledEnergyLevel(58) > 0) { + displayGauge(7, 14, tileEntity.getScaledEnergyLevel(58), 0); + displayGauge(23, 14, tileEntity.getScaledEnergyLevel(58), 1); + } + } - public void displayGauge(int xPos, int yPos, int scale, int side /*0-left, 1-right*/) - { - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; + public void + displayGauge(int xPos, int yPos, int scale, int side /*0-left, 1-right*/) { + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; - int start = 0; + int start = 0; - while(true) - { - int renderRemaining = 0; + while (true) { + int renderRemaining = 0; - if(scale > 16) - { - renderRemaining = 16; - scale -= 16; - } - else { - renderRemaining = scale; - scale = 0; - } + if (scale > 16) { + renderRemaining = 16; + scale -= 16; + } else { + renderRemaining = scale; + scale = 0; + } - mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture()); - drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos + 58 - renderRemaining - start, MekanismRenderer.energyIcon, 16, 16 - (16 - renderRemaining)); - start+=16; + mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture()); + drawTexturedModelRectFromIcon( + guiWidth + xPos, + guiHeight + yPos + 58 - renderRemaining - start, + MekanismRenderer.energyIcon, + 16, + 16 - (16 - renderRemaining) + ); + start += 16; - if(renderRemaining == 0 || scale == 0) - { - break; - } - } + if (renderRemaining == 0 || scale == 0) { + break; + } + } - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiInductionMatrix.png")); - drawTexturedModalRect(guiWidth + xPos, guiHeight + yPos, 176, side == 0 ? 0 : 54, 16, 54); - } + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiInductionMatrix.png") + ); + drawTexturedModalRect( + guiWidth + xPos, guiHeight + yPos, 176, side == 0 ? 0 : 54, 16, 54 + ); + } } diff --git a/src/main/java/mekanism/client/gui/GuiLaserAmplifier.java b/src/main/java/mekanism/client/gui/GuiLaserAmplifier.java index 93c8b2130..eda3ba493 100644 --- a/src/main/java/mekanism/client/gui/GuiLaserAmplifier.java +++ b/src/main/java/mekanism/client/gui/GuiLaserAmplifier.java @@ -2,6 +2,8 @@ package mekanism.client.gui; import java.util.ArrayList; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.client.gui.element.GuiAmplifierTab; import mekanism.client.gui.element.GuiGauge.Type; @@ -20,227 +22,248 @@ import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.gui.GuiTextField; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.IIcon; - import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiLaserAmplifier extends GuiMekanism -{ - public TileEntityLaserAmplifier tileEntity; +public class GuiLaserAmplifier extends GuiMekanism { + public TileEntityLaserAmplifier tileEntity; - public GuiTextField minField; - public GuiTextField maxField; - public GuiTextField timerField; + public GuiTextField minField; + public GuiTextField maxField; + public GuiTextField timerField; - public GuiLaserAmplifier(InventoryPlayer inventory, TileEntityLaserAmplifier tentity) - { - super(tentity, new ContainerLaserAmplifier(inventory, tentity)); - tileEntity = tentity; + public GuiLaserAmplifier( + InventoryPlayer inventory, TileEntityLaserAmplifier tentity + ) { + super(tentity, new ContainerLaserAmplifier(inventory, tentity)); + tileEntity = tentity; - guiElements.add(new GuiNumberGauge(new INumberInfoHandler() - { - @Override - public IIcon getIcon() - { - return MekanismRenderer.energyIcon; - } + guiElements.add(new GuiNumberGauge( + new INumberInfoHandler() { + @Override + public IIcon getIcon() { + return MekanismRenderer.energyIcon; + } - @Override - public double getLevel() - { - return tileEntity.collectedEnergy; - } + @Override + public double getLevel() { + return tileEntity.collectedEnergy; + } - @Override - public double getMaxLevel() - { - return tileEntity.MAX_ENERGY; - } + @Override + public double getMaxLevel() { + return tileEntity.MAX_ENERGY; + } - @Override - public String getText(double level) - { - return LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(level); - } - }, Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 6, 10)); - guiElements.add(new GuiSecurityTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"))); - guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"))); - guiElements.add(new GuiAmplifierTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"))); - } + @Override + public String getText(double level) { + return LangUtils.localize("gui.storing") + ": " + + MekanismUtils.getEnergyDisplay(level); + } + }, + Type.STANDARD, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), + 6, + 10 + )); + guiElements.add(new GuiSecurityTab( + this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png") + )); + guiElements.add(new GuiRedstoneControl( + this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png") + )); + guiElements.add(new GuiAmplifierTab( + this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png") + )); + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - fontRendererObj.drawString(tileEntity.getInventoryName(), 55, 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); + fontRendererObj.drawString(tileEntity.getInventoryName(), 55, 6, 0x404040); + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040 + ); - fontRendererObj.drawString(tileEntity.time > 0 ? LangUtils.localize("gui.delay") + ": " + tileEntity.time + "t" : LangUtils.localize("gui.noDelay"), 26, 30, 0x404040); - fontRendererObj.drawString(LangUtils.localize("gui.min") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.minThreshold), 26, 45, 0x404040); - fontRendererObj.drawString(LangUtils.localize("gui.max") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.maxThreshold), 26, 60, 0x404040); + fontRendererObj.drawString( + tileEntity.time > 0 + ? LangUtils.localize("gui.delay") + ": " + tileEntity.time + "t" + : LangUtils.localize("gui.noDelay"), + 26, + 30, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.min") + ": " + + MekanismUtils.getEnergyDisplay(tileEntity.minThreshold), + 26, + 45, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.max") + ": " + + MekanismUtils.getEnergyDisplay(tileEntity.maxThreshold), + 26, + 60, + 0x404040 + ); - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - minField.drawTextBox(); - maxField.drawTextBox(); - timerField.drawTextBox(); - } + minField.drawTextBox(); + maxField.drawTextBox(); + timerField.drawTextBox(); + } - @Override - public void updateScreen() - { - super.updateScreen(); + @Override + public void updateScreen() { + super.updateScreen(); - minField.updateCursorCounter(); - maxField.updateCursorCounter(); - timerField.updateCursorCounter(); - } + minField.updateCursorCounter(); + maxField.updateCursorCounter(); + timerField.updateCursorCounter(); + } - @Override - public void mouseClicked(int mouseX, int mouseY, int button) - { - super.mouseClicked(mouseX, mouseY, button); + @Override + public void mouseClicked(int mouseX, int mouseY, int button) { + super.mouseClicked(mouseX, mouseY, button); - minField.mouseClicked(mouseX, mouseY, button); - maxField.mouseClicked(mouseX, mouseY, button); - timerField.mouseClicked(mouseX, mouseY, button); - } + minField.mouseClicked(mouseX, mouseY, button); + maxField.mouseClicked(mouseX, mouseY, button); + timerField.mouseClicked(mouseX, mouseY, button); + } - @Override - public void keyTyped(char c, int i) - { - if(!(minField.isFocused() || maxField.isFocused() || timerField.isFocused()) || i == Keyboard.KEY_ESCAPE) - { - super.keyTyped(c, i); - } + @Override + public void keyTyped(char c, int i) { + if (!(minField.isFocused() || maxField.isFocused() || timerField.isFocused()) + || i == Keyboard.KEY_ESCAPE) { + super.keyTyped(c, i); + } - if(i == Keyboard.KEY_RETURN) - { - if(minField.isFocused()) - { - setMinThreshold(); - } - if(maxField.isFocused()) - { - setMaxThreshold(); - } - if(timerField.isFocused()) - { - setTime(); - } - } + if (i == Keyboard.KEY_RETURN) { + if (minField.isFocused()) { + setMinThreshold(); + } + if (maxField.isFocused()) { + setMaxThreshold(); + } + if (timerField.isFocused()) { + setTime(); + } + } - if(Character.isDigit(c) || c == '.' || c == 'E' || isTextboxKey(c, i)) - { - minField.textboxKeyTyped(c, i); - maxField.textboxKeyTyped(c, i); - timerField.textboxKeyTyped(c, i); - } - } + if (Character.isDigit(c) || c == '.' || c == 'E' || isTextboxKey(c, i)) { + minField.textboxKeyTyped(c, i); + maxField.textboxKeyTyped(c, i); + timerField.textboxKeyTyped(c, i); + } + } - private void setMinThreshold() - { - if(!minField.getText().isEmpty()) - { - double toUse; + private void setMinThreshold() { + if (!minField.getText().isEmpty()) { + double toUse; - try { - toUse = Math.max(0, Double.parseDouble(minField.getText())); - } catch(Exception e) { - minField.setText(""); - return; - } + try { + toUse = Math.max(0, Double.parseDouble(minField.getText())); + } catch (Exception e) { + minField.setText(""); + return; + } - ArrayList data = new ArrayList(); - data.add(0); - data.add(toUse); + ArrayList data = new ArrayList(); + data.add(0); + data.add(toUse); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); - minField.setText(""); - } - } + minField.setText(""); + } + } - private void setMaxThreshold() - { - if(!maxField.getText().isEmpty()) - { - double toUse; + private void setMaxThreshold() { + if (!maxField.getText().isEmpty()) { + double toUse; - try { - toUse = Math.max(0, Double.parseDouble(maxField.getText())); - } catch(Exception e) { - maxField.setText(""); - return; - } + try { + toUse = Math.max(0, Double.parseDouble(maxField.getText())); + } catch (Exception e) { + maxField.setText(""); + return; + } - ArrayList data = new ArrayList(); - data.add(1); - data.add(toUse); + ArrayList data = new ArrayList(); + data.add(1); + data.add(toUse); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); - maxField.setText(""); - } - } + maxField.setText(""); + } + } - private void setTime() - { - if(!timerField.getText().isEmpty()) - { - int toUse = Math.max(0, Integer.parseInt(timerField.getText())); + private void setTime() { + if (!timerField.getText().isEmpty()) { + int toUse = Math.max(0, Integer.parseInt(timerField.getText())); - ArrayList data = new ArrayList(); - data.add(2); - data.add(toUse); + ArrayList data = new ArrayList(); + data.add(2); + data.add(toUse); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); - timerField.setText(""); - } - } + timerField.setText(""); + } + } - @Override - public void initGui() - { - super.initGui(); + @Override + public void initGui() { + super.initGui(); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; - String prevTime = timerField != null ? timerField.getText() : ""; + String prevTime = timerField != null ? timerField.getText() : ""; - timerField = new GuiTextField(fontRendererObj, guiWidth + 96, guiHeight + 28, 36, 11); - timerField.setMaxStringLength(4); - timerField.setText(prevTime); + timerField + = new GuiTextField(fontRendererObj, guiWidth + 96, guiHeight + 28, 36, 11); + timerField.setMaxStringLength(4); + timerField.setText(prevTime); - String prevMin = minField != null ? minField.getText() : ""; - minField = new GuiTextField(fontRendererObj, guiWidth + 96, guiHeight + 43, 72, 11); - minField.setMaxStringLength(10); - minField.setText(prevMin); + String prevMin = minField != null ? minField.getText() : ""; + minField + = new GuiTextField(fontRendererObj, guiWidth + 96, guiHeight + 43, 72, 11); + minField.setMaxStringLength(10); + minField.setText(prevMin); - String prevMax = maxField != null ? maxField.getText() : ""; + String prevMax = maxField != null ? maxField.getText() : ""; - maxField = new GuiTextField(fontRendererObj, guiWidth + 96, guiHeight + 58, 72, 11); - maxField.setMaxStringLength(10); - maxField.setText(prevMax); - } + maxField + = new GuiTextField(fontRendererObj, guiWidth + 96, guiHeight + 58, 72, 11); + maxField.setMaxStringLength(10); + maxField.setText(prevMax); + } } diff --git a/src/main/java/mekanism/client/gui/GuiLaserTractorBeam.java b/src/main/java/mekanism/client/gui/GuiLaserTractorBeam.java index 1f5641b62..72ce8d080 100644 --- a/src/main/java/mekanism/client/gui/GuiLaserTractorBeam.java +++ b/src/main/java/mekanism/client/gui/GuiLaserTractorBeam.java @@ -7,39 +7,51 @@ import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.entity.player.InventoryPlayer; - import org.lwjgl.opengl.GL11; -public class GuiLaserTractorBeam extends GuiMekanism -{ - public TileEntityLaserTractorBeam tileEntity; +public class GuiLaserTractorBeam extends GuiMekanism { + public TileEntityLaserTractorBeam tileEntity; - public GuiLaserTractorBeam(InventoryPlayer inventory, TileEntityLaserTractorBeam tentity) - { - super(tentity, new ContainerLaserTractorBeam(inventory, tentity)); - tileEntity = tentity; - - guiElements.add(new GuiSecurityTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiFullInv.png"))); - } + public GuiLaserTractorBeam( + InventoryPlayer inventory, TileEntityLaserTractorBeam tentity + ) { + super(tentity, new ContainerLaserTractorBeam(inventory, tentity)); + tileEntity = tentity; - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize/2)-(fontRendererObj.getStringWidth(tileEntity.getInventoryName())/2), 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); + guiElements.add(new GuiSecurityTab( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiFullInv.png") + )); + } - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + fontRendererObj.drawString( + tileEntity.getInventoryName(), + (xSize / 2) + - (fontRendererObj.getStringWidth(tileEntity.getInventoryName()) / 2), + 6, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040 + ); - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiFullInv.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiFullInv.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/GuiLogisticalSorter.java b/src/main/java/mekanism/client/gui/GuiLogisticalSorter.java index a16f508bd..2bb50fc32 100644 --- a/src/main/java/mekanism/client/gui/GuiLogisticalSorter.java +++ b/src/main/java/mekanism/client/gui/GuiLogisticalSorter.java @@ -7,6 +7,8 @@ import java.util.List; import java.util.Map; import java.util.Set; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.client.gui.element.GuiRedstoneControl; @@ -31,703 +33,786 @@ import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; - import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiLogisticalSorter extends GuiMekanism -{ - public TileEntityLogisticalSorter tileEntity; - - /** - * True if the left mouse button was held down last time drawScreen was - * called. - */ - private boolean wasClicking; - - // Buttons - int BUTTON_NEW = 0; - - /** Amount scrolled in filter list (0 = top, 1 = bottom) */ - public float scroll; - - /** True if the scrollbar is being dragged */ - public boolean isDragging = false; - - // Scrollbar dimensions - private final int scrollX = 154; - private final int scrollY = 18; - - private final int scrollW = 12; - private final int scrollH = 138; - - // Filter dimensions - private final int filterX = 56; - private final int filterY = 18; - - private final int filterW = 96; - private final int filterH = 29; - - public int dragOffset = 0; - - public int stackSwitch = 0; - - public Map oreDictStacks = new HashMap(); - - public Map modIDStacks = new HashMap(); - - public GuiLogisticalSorter(EntityPlayer player, TileEntityLogisticalSorter entity) - { - super(entity, new ContainerNull(player, entity)); - tileEntity = entity; - - // Set size of gui - // xSize = 189; - // ySize = 166; - - // Add common Mekanism gui elements - guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiLogisticalSorter.png"))); - guiElements.add(new GuiSecurityTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiLogisticalSorter.png"))); - } - - public int getScroll() - { - // Calculate thumb position along scrollbar - return Math.max(Math.min((int) (scroll * 123), 123), 0); - } - - // Get index to displayed filters - public int getFilterIndex() - { - if(needsScrollBars()) - { - final int scrollSize = tileEntity.filters.size() - 4; - return (int)((scrollSize + 0.5) * scroll); - } - - return 0; - } - - @Override - public void updateScreen() - { - super.updateScreen(); - - // Decrease timer for stack display rotation - if(stackSwitch > 0) - { - stackSwitch--; - } - - // Update displayed stacks - if(stackSwitch == 0) - { - for(final Map.Entry entry : oreDictStacks.entrySet()) - { - if(entry.getValue().iterStacks != null && entry.getValue().iterStacks.size() > 0) - { - if(entry.getValue().stackIndex == -1 || entry.getValue().stackIndex == entry.getValue().iterStacks.size() - 1) - { - entry.getValue().stackIndex = 0; - } - else if(entry.getValue().stackIndex < entry.getValue().iterStacks.size() - 1) - { - entry.getValue().stackIndex++; - } - - entry.getValue().renderStack = entry.getValue().iterStacks.get(entry.getValue().stackIndex); - } - } - - for(final Map.Entry entry : modIDStacks.entrySet()) - { - if(entry.getValue().iterStacks != null && entry.getValue().iterStacks.size() > 0) - { - if(entry.getValue().stackIndex == -1 || entry.getValue().stackIndex == entry.getValue().iterStacks.size() - 1) - { - entry.getValue().stackIndex = 0; - } - else if(entry.getValue().stackIndex < entry.getValue().iterStacks.size() - 1) - { - entry.getValue().stackIndex++; - } - - entry.getValue().renderStack = entry.getValue().iterStacks.get(entry.getValue().stackIndex); - } - } - - stackSwitch = 20; - } - else { - for(final Map.Entry entry : oreDictStacks.entrySet()) - { - if(entry.getValue().iterStacks != null && entry.getValue().iterStacks.size() == 0) - { - entry.getValue().renderStack = null; - } - } - - for(final Map.Entry entry : modIDStacks.entrySet()) - { - if(entry.getValue().iterStacks != null && entry.getValue().iterStacks.size() == 0) - { - entry.getValue().renderStack = null; - } - } - } - - final Set oreDictFilters = new HashSet(); - final Set modIDFilters = new HashSet(); - - for(int i = 0; i < 4; i++) - { - if(tileEntity.filters.get(getFilterIndex() + i) instanceof TOreDictFilter) - { - oreDictFilters.add((TOreDictFilter) tileEntity.filters.get(getFilterIndex() + i)); - } - else if(tileEntity.filters.get(getFilterIndex() + i) instanceof TModIDFilter) - { - modIDFilters.add((TModIDFilter) tileEntity.filters.get(getFilterIndex() + i)); - } - } - - for(final TransporterFilter filter : tileEntity.filters) - { - if(filter instanceof TOreDictFilter && !oreDictFilters.contains(filter)) - { - if(oreDictStacks.containsKey(filter)) - { - oreDictStacks.remove(filter); - } - } - else if(filter instanceof TModIDFilter && !modIDFilters.contains(filter)) - { - if(modIDStacks.containsKey(filter)) - { - modIDStacks.remove(filter); - } - } - } - } - - @Override - public void mouseClicked(int mouseX, int mouseY, int mouseBtn) - { - super.mouseClicked(mouseX, mouseY, mouseBtn); - - // Get mouse position relative to gui - final int xAxis = mouseX - guiLeft; - final int yAxis = mouseY - guiTop; - - if(mouseBtn == 0) - { - // Check for scrollbar interaction - if(xAxis >= 154 && xAxis <= 166 && yAxis >= getScroll() + 18 && yAxis <= getScroll() + 18 + 15) - { - if(needsScrollBars()) - { - dragOffset = yAxis - (getScroll() + 18); - isDragging = true; - } - else { - scroll = 0; - } - } - - // Check for filter interaction - for(int i = 0; i < 4; i++) - { - if(tileEntity.filters.get(getFilterIndex() + i) != null) - { - final int yStart = i * 29 + 18; - - if(xAxis >= 56 && xAxis <= 152 && yAxis >= yStart && yAxis <= yStart + 29) - { - // Check for sorting button - final int arrowX = filterX + filterW - 12; - - if(getFilterIndex() + i > 0) - { - if(xAxis >= arrowX && xAxis <= arrowX + 10 && yAxis >= yStart + 14 && yAxis <= yStart + 20) - { - // Process up button click - final ArrayList data = new ArrayList(); - data.add(3); - data.add(getFilterIndex() + i); - - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - SoundHandler.playSound("gui.button.press"); - - return; - } - } - - if(getFilterIndex() + i < tileEntity.filters.size() - 1) - { - if(xAxis >= arrowX && xAxis <= arrowX + 10 && yAxis >= yStart + 21 && yAxis <= yStart + 27) - { - // Process down button click - final ArrayList data = new ArrayList(); - data.add(4); - data.add(getFilterIndex() + i); - - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - SoundHandler.playSound("gui.button.press"); - - return; - } - } - - final TransporterFilter filter = tileEntity.filters.get(getFilterIndex() + i); - - if(filter instanceof TItemStackFilter) - { - SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER_INDEX, Coord4D.get(tileEntity), 1, getFilterIndex() + i, 0)); - } - else if(filter instanceof TOreDictFilter) - { - SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER_INDEX, Coord4D.get(tileEntity), 2, getFilterIndex() + i, 0)); - } - else if(filter instanceof TMaterialFilter) - { - SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER_INDEX, Coord4D.get(tileEntity), 3, getFilterIndex() + i, 0)); - } - else if(filter instanceof TModIDFilter) - { - SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER_INDEX, Coord4D.get(tileEntity), 5, getFilterIndex() + i, 0)); - } - } - } - } - - // Check for auto eject button - if(xAxis >= 12 && xAxis <= 26 && yAxis >= 110 && yAxis <= 124) - { - final ArrayList data = new ArrayList(); - data.add(1); - - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - SoundHandler.playSound("gui.button.press"); - } - - // Check for round robin button - if(xAxis >= 12 && xAxis <= 26 && yAxis >= 84 && yAxis <= 98) - { - final ArrayList data = new ArrayList(); - data.add(2); - - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - SoundHandler.playSound("gui.button.press"); - } - } - - if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && mouseBtn == 0) - { - mouseBtn = 2; - } - - // Check for default colour button - if(xAxis >= 13 && xAxis <= 29 && yAxis >= 137 && yAxis <= 153) - { - final ArrayList data = new ArrayList(); - data.add(0); - data.add(mouseBtn); - - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - SoundHandler.playSound("mekanism:etc.Ding"); - } - } - - @Override - protected void mouseClickMove(int mouseX, int mouseY, int button, long ticks) - { - super.mouseClickMove(mouseX, mouseY, button, ticks); - - // Get mouse position relative to gui - final int xAxis = mouseX - guiLeft; - final int yAxis = mouseY - guiTop; - - if(isDragging) - { - scroll = Math.min(Math.max((yAxis - 18 - dragOffset) / 123F, 0), 1); - } - } - - @Override - protected void mouseMovedOrUp(int mouseX, int mouseY, int type) - { - super.mouseMovedOrUp(mouseX, mouseY, type); - - if(type == 0 && isDragging) - { - dragOffset = 0; - isDragging = false; - } - } - - /** - * Handles mouse input. - */ - @Override - public void handleMouseInput() - { - super.handleMouseInput(); - - int i = Mouse.getEventDWheel(); - - if(i != 0 && needsScrollBars()) - { - final int j = tileEntity.filters.size() - 4; - - if(i > 0) - { - i = 1; - } - - if(i < 0) - { - i = -1; - } - - scroll = (float)(scroll - (double) i / (double) j); - - if(scroll < 0.0F) - { - scroll = 0.0F; - } - - if(scroll > 1.0F) - { - scroll = 1.0F; - } - } - } - - @Override - public void initGui() - { - super.initGui(); - - // Add buttons to gui - buttonList.clear(); - buttonList.add(new GuiButton(BUTTON_NEW, guiLeft + 56, guiTop + 136, 96, 20, LangUtils.localize("gui.newFilter"))); - } - - @Override - protected void actionPerformed(GuiButton guibutton) - { - super.actionPerformed(guibutton); - - if(guibutton.id == BUTTON_NEW) - { - Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 4, 0, 0)); - } - } - - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - // Get mouse position relative to gui - final int xAxis = mouseX - guiLeft; - final int yAxis = mouseY - guiTop; - - // Write to info display - fontRendererObj.drawString(tileEntity.getInventoryName(), 43, 6, 0x404040); - - fontRendererObj.drawString(LangUtils.localize("gui.filters") + ":", 11, 19, 0x00CD00); - fontRendererObj.drawString("T: " + tileEntity.filters.size(), 11, 28, 0x00CD00); - - fontRendererObj.drawString("RR:", 12, 74, 0x00CD00); - fontRendererObj.drawString(LangUtils.localize("gui." + (tileEntity.roundRobin ? "on" : "off")), 27, 86, 0x00CD00); - - fontRendererObj.drawString(LangUtils.localize("gui.logisticalSorter.auto") + ":", 12, 100, 0x00CD00); - fontRendererObj.drawString(LangUtils.localize("gui." + (tileEntity.autoEject ? "on" : "off")), 27, 112, 0x00CD00); - - fontRendererObj.drawString(LangUtils.localize("gui.logisticalSorter.default") + ":", 12, 126, 0x00CD00); - - // Draw filters - for(int i = 0; i < 4; i++) - { - if(tileEntity.filters.get(getFilterIndex() + i) != null) - { - final TransporterFilter filter = tileEntity.filters.get(getFilterIndex() + i); - final int yStart = i * filterH + filterY; - - if(filter instanceof TItemStackFilter) - { - final TItemStackFilter itemFilter = (TItemStackFilter) filter; - - if(itemFilter.itemType != null) - { - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_LIGHTING); - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), itemFilter.itemType, 59, yStart + 3); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } - - fontRendererObj.drawString(LangUtils.localize("gui.itemFilter"), 78, yStart + 2, 0x404040); - fontRendererObj.drawString(filter.color != null ? filter.color.getName() : LangUtils.localize("gui.none"), 78, yStart + 11, 0x404040); - } - else if(filter instanceof TOreDictFilter) - { - final TOreDictFilter oreFilter = (TOreDictFilter) filter; - - if(!oreDictStacks.containsKey(oreFilter)) - { - updateStackList(oreFilter); - } - - if(oreDictStacks.get(filter).renderStack != null) - { - try { - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_LIGHTING); - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), oreDictStacks.get(filter).renderStack, 59, yStart + 3); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } catch(final Exception e) {} - } - - fontRendererObj.drawString(LangUtils.localize("gui.oredictFilter"), 78, yStart + 2, 0x404040); - fontRendererObj.drawString(filter.color != null ? filter.color.getName() : LangUtils.localize("gui.none"), 78, yStart + 11, 0x404040); - } - else if(filter instanceof TMaterialFilter) - { - final TMaterialFilter itemFilter = (TMaterialFilter) filter; - - if(itemFilter.materialItem != null) - { - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_LIGHTING); - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), itemFilter.materialItem, 59, yStart + 3); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } - - fontRendererObj.drawString(LangUtils.localize("gui.materialFilter"), 78, yStart + 2, 0x404040); - fontRendererObj.drawString(filter.color != null ? filter.color.getName() : LangUtils.localize("gui.none"), 78, yStart + 11, 0x404040); - } - else if(filter instanceof TModIDFilter) - { - final TModIDFilter modFilter = (TModIDFilter) filter; - - if(!modIDStacks.containsKey(modFilter)) - { - updateStackList(modFilter); - } - - if(modIDStacks.get(filter).renderStack != null) - { - try { - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_LIGHTING); - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), modIDStacks.get(filter).renderStack, 59, yStart + 3); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } catch(final Exception e) {} - } - - fontRendererObj.drawString(LangUtils.localize("gui.modIDFilter"), 78, yStart + 2, 0x404040); - fontRendererObj.drawString(filter.color != null ? filter.color.getName() : LangUtils.localize("gui.none"), 78, yStart + 11, 0x404040); - } - - // Draw hovertext for sorting buttons - final int arrowX = filterX + filterW - 12; - - if(getFilterIndex() + i > 0) - { - if(xAxis >= arrowX && xAxis <= arrowX + 10 && yAxis >= yStart + 14 && yAxis <= yStart + 20) - { - drawCreativeTabHoveringText(LangUtils.localize("gui.moveUp"), xAxis, yAxis); - } - } - - if(getFilterIndex() + i < tileEntity.filters.size() - 1) - { - if(xAxis >= arrowX && xAxis <= arrowX + 10 && yAxis >= yStart + 21 && yAxis <= yStart + 27) - { - drawCreativeTabHoveringText(LangUtils.localize("gui.moveDown"), xAxis, yAxis); - } - } - } - } - - if(tileEntity.color != null) - { - GL11.glPushMatrix(); - GL11.glColor4f(1, 1, 1, 1); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); - - mc.getTextureManager().bindTexture(MekanismRenderer.getBlocksTexture()); - itemRender.renderIcon(13, 137, MekanismRenderer.getColorIcon(tileEntity.color), 16, 16); - - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } - - // Draw tooltips for buttons - if(xAxis >= 13 && xAxis <= 29 && yAxis >= 137 && yAxis <= 153) - { - if(tileEntity.color != null) - { - drawCreativeTabHoveringText(tileEntity.color.getName(), xAxis, yAxis); - } - else { - drawCreativeTabHoveringText(LangUtils.localize("gui.none"), xAxis, yAxis); - } - } - - if(xAxis >= 12 && xAxis <= 26 && yAxis >= 110 && yAxis <= 124) - { - drawCreativeTabHoveringText(LangUtils.localize("gui.autoEject"), xAxis, yAxis); - } - - if(xAxis >= 12 && xAxis <= 26 && yAxis >= 84 && yAxis <= 98) - { - drawCreativeTabHoveringText(LangUtils.localize("gui.logisticalSorter.roundRobin"), xAxis, yAxis); - } - - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } - - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - - // Draw main gui background - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiLogisticalSorter.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); - - // Draw scrollbar - drawTexturedModalRect(guiLeft + scrollX, guiTop + scrollY + getScroll(), 232 + (needsScrollBars() ? 0 : 12), 0, 12, 15); - - // Get mouse position relative to gui - final int xAxis = mouseX - guiLeft; - final int yAxis = mouseY - guiTop; - - // Draw filter backgrounds - for(int i = 0; i < 4; i++) - { - if(tileEntity.filters.get(getFilterIndex() + i) != null) - { - final TransporterFilter filter = tileEntity.filters.get(getFilterIndex() + i); - final int yStart = i * filterH + filterY; - - // Flag for mouse over this filter - boolean mouseOver = xAxis >= filterX && xAxis <= filterX + filterW && yAxis >= yStart && yAxis <= yStart + filterH; - - // Change colour based on filter type - if(filter instanceof TItemStackFilter) - { - MekanismRenderer.color(EnumColor.INDIGO, 1.0F, 2.5F); - } - else if(filter instanceof TOreDictFilter) - { - MekanismRenderer.color(EnumColor.BRIGHT_GREEN, 1.0F, 2.5F); - } - else if(filter instanceof TMaterialFilter) - { - MekanismRenderer.color(EnumColor.PURPLE, 1.0F, 4F); - } - else if(filter instanceof TModIDFilter) - { - MekanismRenderer.color(EnumColor.PINK, 1.0F, 2.5F); - } - - drawTexturedModalRect(guiLeft + filterX, guiTop + yStart, mouseOver ? 0 : filterW, 166, filterW, filterH); - MekanismRenderer.resetColor(); - - // Draw sort buttons - final int arrowX = filterX + filterW - 12; - - if(getFilterIndex() + i > 0) - { - mouseOver = xAxis >= arrowX && xAxis <= arrowX + 10 && yAxis >= yStart + 14 && yAxis <= yStart + 20; - drawTexturedModalRect(guiLeft + arrowX, guiTop + yStart + 14, 190, mouseOver ? 143 : 115, 11, 7); - } - - if(getFilterIndex() + i < tileEntity.filters.size() - 1) - { - mouseOver = xAxis >= arrowX && xAxis <= arrowX + 10 && yAxis >= yStart + 21 && yAxis <= yStart + 27; - drawTexturedModalRect(guiLeft + arrowX, guiTop + yStart + 21, 190, mouseOver ? 157 : 129, 11, 7); - } - } - } - - // Draw gui buttons - if(xAxis >= 12 && xAxis <= 26 && yAxis >= 110 && yAxis <= 124) - { - drawTexturedModalRect(guiLeft + 12, guiTop + 110, 176, 0, 14, 14); - } - else { - drawTexturedModalRect(guiLeft + 12, guiTop + 110, 176, 14, 14, 14); - } - - if(xAxis >= 12 && xAxis <= 26 && yAxis >= 84 && yAxis <= 98) - { - drawTexturedModalRect(guiLeft + 12, guiTop + 84, 176 + 14, 0, 14, 14); - } - else { - drawTexturedModalRect(guiLeft + 12, guiTop + 84, 176 + 14, 14, 14, 14); - } - } - - private void updateStackList(TOreDictFilter filter) - { - if(!oreDictStacks.containsKey(filter)) - { - oreDictStacks.put(filter, new StackData()); - } - - oreDictStacks.get(filter).iterStacks = OreDictCache.getOreDictStacks(filter.oreDictName, false); - - stackSwitch = 0; - updateScreen(); - oreDictStacks.get(filter).stackIndex = -1; - } - - private void updateStackList(TModIDFilter filter) - { - if(!modIDStacks.containsKey(filter)) - { - modIDStacks.put(filter, new StackData()); - } - - modIDStacks.get(filter).iterStacks = OreDictCache.getModIDStacks(filter.modID, false); - - stackSwitch = 0; - updateScreen(); - modIDStacks.get(filter).stackIndex = -1; - } - - public static class StackData - { - public List iterStacks; - - public int stackIndex; - - public ItemStack renderStack; - } - - /** - * returns true if there are more filters than can fit in the gui - */ - private boolean needsScrollBars() - { - return tileEntity.filters.size() > 4; - } +public class GuiLogisticalSorter extends GuiMekanism { + public TileEntityLogisticalSorter tileEntity; + + /** + * True if the left mouse button was held down last time drawScreen was + * called. + */ + private boolean wasClicking; + + // Buttons + int BUTTON_NEW = 0; + + /** Amount scrolled in filter list (0 = top, 1 = bottom) */ + public float scroll; + + /** True if the scrollbar is being dragged */ + public boolean isDragging = false; + + // Scrollbar dimensions + private final int scrollX = 154; + private final int scrollY = 18; + + private final int scrollW = 12; + private final int scrollH = 138; + + // Filter dimensions + private final int filterX = 56; + private final int filterY = 18; + + private final int filterW = 96; + private final int filterH = 29; + + public int dragOffset = 0; + + public int stackSwitch = 0; + + public Map oreDictStacks + = new HashMap(); + + public Map modIDStacks + = new HashMap(); + + public GuiLogisticalSorter(EntityPlayer player, TileEntityLogisticalSorter entity) { + super(entity, new ContainerNull(player, entity)); + tileEntity = entity; + + // Set size of gui + // xSize = 189; + // ySize = 166; + + // Add common Mekanism gui elements + guiElements.add(new GuiRedstoneControl( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiLogisticalSorter.png") + )); + guiElements.add(new GuiSecurityTab( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiLogisticalSorter.png") + )); + } + + public int getScroll() { + // Calculate thumb position along scrollbar + return Math.max(Math.min((int) (scroll * 123), 123), 0); + } + + // Get index to displayed filters + public int getFilterIndex() { + if (needsScrollBars()) { + final int scrollSize = tileEntity.filters.size() - 4; + return (int) ((scrollSize + 0.5) * scroll); + } + + return 0; + } + + @Override + public void updateScreen() { + super.updateScreen(); + + // Decrease timer for stack display rotation + if (stackSwitch > 0) { + stackSwitch--; + } + + // Update displayed stacks + if (stackSwitch == 0) { + for (final Map.Entry entry : + oreDictStacks.entrySet()) { + if (entry.getValue().iterStacks != null + && entry.getValue().iterStacks.size() > 0) { + if (entry.getValue().stackIndex == -1 + || entry.getValue().stackIndex + == entry.getValue().iterStacks.size() - 1) { + entry.getValue().stackIndex = 0; + } else if (entry.getValue().stackIndex < entry.getValue().iterStacks.size() - 1) { + entry.getValue().stackIndex++; + } + + entry.getValue().renderStack + = entry.getValue().iterStacks.get(entry.getValue().stackIndex); + } + } + + for (final Map.Entry entry : + modIDStacks.entrySet()) { + if (entry.getValue().iterStacks != null + && entry.getValue().iterStacks.size() > 0) { + if (entry.getValue().stackIndex == -1 + || entry.getValue().stackIndex + == entry.getValue().iterStacks.size() - 1) { + entry.getValue().stackIndex = 0; + } else if (entry.getValue().stackIndex < entry.getValue().iterStacks.size() - 1) { + entry.getValue().stackIndex++; + } + + entry.getValue().renderStack + = entry.getValue().iterStacks.get(entry.getValue().stackIndex); + } + } + + stackSwitch = 20; + } else { + for (final Map.Entry entry : + oreDictStacks.entrySet()) { + if (entry.getValue().iterStacks != null + && entry.getValue().iterStacks.size() == 0) { + entry.getValue().renderStack = null; + } + } + + for (final Map.Entry entry : + modIDStacks.entrySet()) { + if (entry.getValue().iterStacks != null + && entry.getValue().iterStacks.size() == 0) { + entry.getValue().renderStack = null; + } + } + } + + final Set oreDictFilters = new HashSet(); + final Set modIDFilters = new HashSet(); + + for (int i = 0; i < 4; i++) { + if (tileEntity.filters.get(getFilterIndex() + i) instanceof TOreDictFilter) { + oreDictFilters.add((TOreDictFilter + ) tileEntity.filters.get(getFilterIndex() + i)); + } else if (tileEntity.filters.get(getFilterIndex() + i) instanceof TModIDFilter) { + modIDFilters.add((TModIDFilter + ) tileEntity.filters.get(getFilterIndex() + i)); + } + } + + for (final TransporterFilter filter : tileEntity.filters) { + if (filter instanceof TOreDictFilter && !oreDictFilters.contains(filter)) { + if (oreDictStacks.containsKey(filter)) { + oreDictStacks.remove(filter); + } + } else if (filter instanceof TModIDFilter && !modIDFilters.contains(filter)) { + if (modIDStacks.containsKey(filter)) { + modIDStacks.remove(filter); + } + } + } + } + + @Override + public void mouseClicked(int mouseX, int mouseY, int mouseBtn) { + super.mouseClicked(mouseX, mouseY, mouseBtn); + + // Get mouse position relative to gui + final int xAxis = mouseX - guiLeft; + final int yAxis = mouseY - guiTop; + + if (mouseBtn == 0) { + // Check for scrollbar interaction + if (xAxis >= 154 && xAxis <= 166 && yAxis >= getScroll() + 18 + && yAxis <= getScroll() + 18 + 15) { + if (needsScrollBars()) { + dragOffset = yAxis - (getScroll() + 18); + isDragging = true; + } else { + scroll = 0; + } + } + + // Check for filter interaction + for (int i = 0; i < 4; i++) { + if (tileEntity.filters.get(getFilterIndex() + i) != null) { + final int yStart = i * 29 + 18; + + if (xAxis >= 56 && xAxis <= 152 && yAxis >= yStart + && yAxis <= yStart + 29) { + // Check for sorting button + final int arrowX = filterX + filterW - 12; + + if (getFilterIndex() + i > 0) { + if (xAxis >= arrowX && xAxis <= arrowX + 10 + && yAxis >= yStart + 14 && yAxis <= yStart + 20) { + // Process up button click + final ArrayList data = new ArrayList(); + data.add(3); + data.add(getFilterIndex() + i); + + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); + SoundHandler.playSound("gui.button.press"); + + return; + } + } + + if (getFilterIndex() + i < tileEntity.filters.size() - 1) { + if (xAxis >= arrowX && xAxis <= arrowX + 10 + && yAxis >= yStart + 21 && yAxis <= yStart + 27) { + // Process down button click + final ArrayList data = new ArrayList(); + data.add(4); + data.add(getFilterIndex() + i); + + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); + SoundHandler.playSound("gui.button.press"); + + return; + } + } + + final TransporterFilter filter + = tileEntity.filters.get(getFilterIndex() + i); + + if (filter instanceof TItemStackFilter) { + SoundHandler.playSound("gui.button.press"); + Mekanism.packetHandler.sendToServer( + new LogisticalSorterGuiMessage( + SorterGuiPacket.SERVER_INDEX, + Coord4D.get(tileEntity), + 1, + getFilterIndex() + i, + 0 + ) + ); + } else if (filter instanceof TOreDictFilter) { + SoundHandler.playSound("gui.button.press"); + Mekanism.packetHandler.sendToServer( + new LogisticalSorterGuiMessage( + SorterGuiPacket.SERVER_INDEX, + Coord4D.get(tileEntity), + 2, + getFilterIndex() + i, + 0 + ) + ); + } else if (filter instanceof TMaterialFilter) { + SoundHandler.playSound("gui.button.press"); + Mekanism.packetHandler.sendToServer( + new LogisticalSorterGuiMessage( + SorterGuiPacket.SERVER_INDEX, + Coord4D.get(tileEntity), + 3, + getFilterIndex() + i, + 0 + ) + ); + } else if (filter instanceof TModIDFilter) { + SoundHandler.playSound("gui.button.press"); + Mekanism.packetHandler.sendToServer( + new LogisticalSorterGuiMessage( + SorterGuiPacket.SERVER_INDEX, + Coord4D.get(tileEntity), + 5, + getFilterIndex() + i, + 0 + ) + ); + } + } + } + } + + // Check for auto eject button + if (xAxis >= 12 && xAxis <= 26 && yAxis >= 110 && yAxis <= 124) { + final ArrayList data = new ArrayList(); + data.add(1); + + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); + SoundHandler.playSound("gui.button.press"); + } + + // Check for round robin button + if (xAxis >= 12 && xAxis <= 26 && yAxis >= 84 && yAxis <= 98) { + final ArrayList data = new ArrayList(); + data.add(2); + + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); + SoundHandler.playSound("gui.button.press"); + } + } + + if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && mouseBtn == 0) { + mouseBtn = 2; + } + + // Check for default colour button + if (xAxis >= 13 && xAxis <= 29 && yAxis >= 137 && yAxis <= 153) { + final ArrayList data = new ArrayList(); + data.add(0); + data.add(mouseBtn); + + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); + SoundHandler.playSound("mekanism:etc.Ding"); + } + } + + @Override + protected void mouseClickMove(int mouseX, int mouseY, int button, long ticks) { + super.mouseClickMove(mouseX, mouseY, button, ticks); + + // Get mouse position relative to gui + final int xAxis = mouseX - guiLeft; + final int yAxis = mouseY - guiTop; + + if (isDragging) { + scroll = Math.min(Math.max((yAxis - 18 - dragOffset) / 123F, 0), 1); + } + } + + @Override + protected void mouseMovedOrUp(int mouseX, int mouseY, int type) { + super.mouseMovedOrUp(mouseX, mouseY, type); + + if (type == 0 && isDragging) { + dragOffset = 0; + isDragging = false; + } + } + + /** + * Handles mouse input. + */ + @Override + public void handleMouseInput() { + super.handleMouseInput(); + + int i = Mouse.getEventDWheel(); + + if (i != 0 && needsScrollBars()) { + final int j = tileEntity.filters.size() - 4; + + if (i > 0) { + i = 1; + } + + if (i < 0) { + i = -1; + } + + scroll = (float) (scroll - (double) i / (double) j); + + if (scroll < 0.0F) { + scroll = 0.0F; + } + + if (scroll > 1.0F) { + scroll = 1.0F; + } + } + } + + @Override + public void initGui() { + super.initGui(); + + // Add buttons to gui + buttonList.clear(); + buttonList.add(new GuiButton( + BUTTON_NEW, + guiLeft + 56, + guiTop + 136, + 96, + 20, + LangUtils.localize("gui.newFilter") + )); + } + + @Override + protected void actionPerformed(GuiButton guibutton) { + super.actionPerformed(guibutton); + + if (guibutton.id == BUTTON_NEW) { + Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage( + SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 4, 0, 0 + )); + } + } + + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + // Get mouse position relative to gui + final int xAxis = mouseX - guiLeft; + final int yAxis = mouseY - guiTop; + + // Write to info display + fontRendererObj.drawString(tileEntity.getInventoryName(), 43, 6, 0x404040); + + fontRendererObj.drawString( + LangUtils.localize("gui.filters") + ":", 11, 19, 0x00CD00 + ); + fontRendererObj.drawString("T: " + tileEntity.filters.size(), 11, 28, 0x00CD00); + + fontRendererObj.drawString("RR:", 12, 74, 0x00CD00); + fontRendererObj.drawString( + LangUtils.localize("gui." + (tileEntity.roundRobin ? "on" : "off")), + 27, + 86, + 0x00CD00 + ); + + fontRendererObj.drawString( + LangUtils.localize("gui.logisticalSorter.auto") + ":", 12, 100, 0x00CD00 + ); + fontRendererObj.drawString( + LangUtils.localize("gui." + (tileEntity.autoEject ? "on" : "off")), + 27, + 112, + 0x00CD00 + ); + + fontRendererObj.drawString( + LangUtils.localize("gui.logisticalSorter.default") + ":", 12, 126, 0x00CD00 + ); + + // Draw filters + for (int i = 0; i < 4; i++) { + if (tileEntity.filters.get(getFilterIndex() + i) != null) { + final TransporterFilter filter + = tileEntity.filters.get(getFilterIndex() + i); + final int yStart = i * filterH + filterY; + + if (filter instanceof TItemStackFilter) { + final TItemStackFilter itemFilter = (TItemStackFilter) filter; + + if (itemFilter.itemType != null) { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_LIGHTING); + itemRender.renderItemAndEffectIntoGUI( + fontRendererObj, + mc.getTextureManager(), + itemFilter.itemType, + 59, + yStart + 3 + ); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + + fontRendererObj.drawString( + LangUtils.localize("gui.itemFilter"), 78, yStart + 2, 0x404040 + ); + fontRendererObj.drawString( + filter.color != null ? filter.color.getName() + : LangUtils.localize("gui.none"), + 78, + yStart + 11, + 0x404040 + ); + } else if (filter instanceof TOreDictFilter) { + final TOreDictFilter oreFilter = (TOreDictFilter) filter; + + if (!oreDictStacks.containsKey(oreFilter)) { + updateStackList(oreFilter); + } + + if (oreDictStacks.get(filter).renderStack != null) { + try { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_LIGHTING); + itemRender.renderItemAndEffectIntoGUI( + fontRendererObj, + mc.getTextureManager(), + oreDictStacks.get(filter).renderStack, + 59, + yStart + 3 + ); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } catch (final Exception e) {} + } + + fontRendererObj.drawString( + LangUtils.localize("gui.oredictFilter"), 78, yStart + 2, 0x404040 + ); + fontRendererObj.drawString( + filter.color != null ? filter.color.getName() + : LangUtils.localize("gui.none"), + 78, + yStart + 11, + 0x404040 + ); + } else if (filter instanceof TMaterialFilter) { + final TMaterialFilter itemFilter = (TMaterialFilter) filter; + + if (itemFilter.materialItem != null) { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_LIGHTING); + itemRender.renderItemAndEffectIntoGUI( + fontRendererObj, + mc.getTextureManager(), + itemFilter.materialItem, + 59, + yStart + 3 + ); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + + fontRendererObj.drawString( + LangUtils.localize("gui.materialFilter"), 78, yStart + 2, 0x404040 + ); + fontRendererObj.drawString( + filter.color != null ? filter.color.getName() + : LangUtils.localize("gui.none"), + 78, + yStart + 11, + 0x404040 + ); + } else if (filter instanceof TModIDFilter) { + final TModIDFilter modFilter = (TModIDFilter) filter; + + if (!modIDStacks.containsKey(modFilter)) { + updateStackList(modFilter); + } + + if (modIDStacks.get(filter).renderStack != null) { + try { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_LIGHTING); + itemRender.renderItemAndEffectIntoGUI( + fontRendererObj, + mc.getTextureManager(), + modIDStacks.get(filter).renderStack, + 59, + yStart + 3 + ); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } catch (final Exception e) {} + } + + fontRendererObj.drawString( + LangUtils.localize("gui.modIDFilter"), 78, yStart + 2, 0x404040 + ); + fontRendererObj.drawString( + filter.color != null ? filter.color.getName() + : LangUtils.localize("gui.none"), + 78, + yStart + 11, + 0x404040 + ); + } + + // Draw hovertext for sorting buttons + final int arrowX = filterX + filterW - 12; + + if (getFilterIndex() + i > 0) { + if (xAxis >= arrowX && xAxis <= arrowX + 10 && yAxis >= yStart + 14 + && yAxis <= yStart + 20) { + drawCreativeTabHoveringText( + LangUtils.localize("gui.moveUp"), xAxis, yAxis + ); + } + } + + if (getFilterIndex() + i < tileEntity.filters.size() - 1) { + if (xAxis >= arrowX && xAxis <= arrowX + 10 && yAxis >= yStart + 21 + && yAxis <= yStart + 27) { + drawCreativeTabHoveringText( + LangUtils.localize("gui.moveDown"), xAxis, yAxis + ); + } + } + } + } + + if (tileEntity.color != null) { + GL11.glPushMatrix(); + GL11.glColor4f(1, 1, 1, 1); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + + mc.getTextureManager().bindTexture(MekanismRenderer.getBlocksTexture()); + itemRender.renderIcon( + 13, 137, MekanismRenderer.getColorIcon(tileEntity.color), 16, 16 + ); + + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + + // Draw tooltips for buttons + if (xAxis >= 13 && xAxis <= 29 && yAxis >= 137 && yAxis <= 153) { + if (tileEntity.color != null) { + drawCreativeTabHoveringText(tileEntity.color.getName(), xAxis, yAxis); + } else { + drawCreativeTabHoveringText(LangUtils.localize("gui.none"), xAxis, yAxis); + } + } + + if (xAxis >= 12 && xAxis <= 26 && yAxis >= 110 && yAxis <= 124) { + drawCreativeTabHoveringText( + LangUtils.localize("gui.autoEject"), xAxis, yAxis + ); + } + + if (xAxis >= 12 && xAxis <= 26 && yAxis >= 84 && yAxis <= 98) { + drawCreativeTabHoveringText( + LangUtils.localize("gui.logisticalSorter.roundRobin"), xAxis, yAxis + ); + } + + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + + // Draw main gui background + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiLogisticalSorter.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize); + + // Draw scrollbar + drawTexturedModalRect( + guiLeft + scrollX, + guiTop + scrollY + getScroll(), + 232 + (needsScrollBars() ? 0 : 12), + 0, + 12, + 15 + ); + + // Get mouse position relative to gui + final int xAxis = mouseX - guiLeft; + final int yAxis = mouseY - guiTop; + + // Draw filter backgrounds + for (int i = 0; i < 4; i++) { + if (tileEntity.filters.get(getFilterIndex() + i) != null) { + final TransporterFilter filter + = tileEntity.filters.get(getFilterIndex() + i); + final int yStart = i * filterH + filterY; + + // Flag for mouse over this filter + boolean mouseOver = xAxis >= filterX && xAxis <= filterX + filterW + && yAxis >= yStart && yAxis <= yStart + filterH; + + // Change colour based on filter type + if (filter instanceof TItemStackFilter) { + MekanismRenderer.color(EnumColor.INDIGO, 1.0F, 2.5F); + } else if (filter instanceof TOreDictFilter) { + MekanismRenderer.color(EnumColor.BRIGHT_GREEN, 1.0F, 2.5F); + } else if (filter instanceof TMaterialFilter) { + MekanismRenderer.color(EnumColor.PURPLE, 1.0F, 4F); + } else if (filter instanceof TModIDFilter) { + MekanismRenderer.color(EnumColor.PINK, 1.0F, 2.5F); + } + + drawTexturedModalRect( + guiLeft + filterX, + guiTop + yStart, + mouseOver ? 0 : filterW, + 166, + filterW, + filterH + ); + MekanismRenderer.resetColor(); + + // Draw sort buttons + final int arrowX = filterX + filterW - 12; + + if (getFilterIndex() + i > 0) { + mouseOver = xAxis >= arrowX && xAxis <= arrowX + 10 + && yAxis >= yStart + 14 && yAxis <= yStart + 20; + drawTexturedModalRect( + guiLeft + arrowX, + guiTop + yStart + 14, + 190, + mouseOver ? 143 : 115, + 11, + 7 + ); + } + + if (getFilterIndex() + i < tileEntity.filters.size() - 1) { + mouseOver = xAxis >= arrowX && xAxis <= arrowX + 10 + && yAxis >= yStart + 21 && yAxis <= yStart + 27; + drawTexturedModalRect( + guiLeft + arrowX, + guiTop + yStart + 21, + 190, + mouseOver ? 157 : 129, + 11, + 7 + ); + } + } + } + + // Draw gui buttons + if (xAxis >= 12 && xAxis <= 26 && yAxis >= 110 && yAxis <= 124) { + drawTexturedModalRect(guiLeft + 12, guiTop + 110, 176, 0, 14, 14); + } else { + drawTexturedModalRect(guiLeft + 12, guiTop + 110, 176, 14, 14, 14); + } + + if (xAxis >= 12 && xAxis <= 26 && yAxis >= 84 && yAxis <= 98) { + drawTexturedModalRect(guiLeft + 12, guiTop + 84, 176 + 14, 0, 14, 14); + } else { + drawTexturedModalRect(guiLeft + 12, guiTop + 84, 176 + 14, 14, 14, 14); + } + } + + private void updateStackList(TOreDictFilter filter) { + if (!oreDictStacks.containsKey(filter)) { + oreDictStacks.put(filter, new StackData()); + } + + oreDictStacks.get(filter).iterStacks + = OreDictCache.getOreDictStacks(filter.oreDictName, false); + + stackSwitch = 0; + updateScreen(); + oreDictStacks.get(filter).stackIndex = -1; + } + + private void updateStackList(TModIDFilter filter) { + if (!modIDStacks.containsKey(filter)) { + modIDStacks.put(filter, new StackData()); + } + + modIDStacks.get(filter).iterStacks + = OreDictCache.getModIDStacks(filter.modID, false); + + stackSwitch = 0; + updateScreen(); + modIDStacks.get(filter).stackIndex = -1; + } + + public static class StackData { + public List iterStacks; + + public int stackIndex; + + public ItemStack renderStack; + } + + /** + * returns true if there are more filters than can fit in the gui + */ + private boolean needsScrollBars() { + return tileEntity.filters.size() > 4; + } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/GuiMFilterSelect.java b/src/main/java/mekanism/client/gui/GuiMFilterSelect.java index 37fc8e773..2c6fa7fb8 100644 --- a/src/main/java/mekanism/client/gui/GuiMFilterSelect.java +++ b/src/main/java/mekanism/client/gui/GuiMFilterSelect.java @@ -1,5 +1,7 @@ package mekanism.client.gui; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.client.sound.SoundHandler; import mekanism.common.Mekanism; @@ -12,111 +14,112 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.EntityPlayer; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiMFilterSelect extends GuiMekanism -{ - public TileEntityDigitalMiner tileEntity; - - public GuiMFilterSelect(EntityPlayer player, TileEntityDigitalMiner tentity) - { - super(tentity, new ContainerNull(player, tentity)); - - tileEntity = tentity; - } - - @Override - public void initGui() - { - super.initGui(); +public class GuiMFilterSelect extends GuiMekanism { + public TileEntityDigitalMiner tileEntity; - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - - buttonList.clear(); - buttonList.add(new GuiButton(0, guiWidth + 24, guiHeight + 32, 128, 20, LangUtils.localize("gui.itemstack"))); - buttonList.add(new GuiButton(1, guiWidth + 24, guiHeight + 52, 128, 20, LangUtils.localize("gui.oredict"))); - buttonList.add(new GuiButton(2, guiWidth + 24, guiHeight + 72, 128, 20, LangUtils.localize("gui.material"))); - buttonList.add(new GuiButton(3, guiWidth + 24, guiHeight + 92, 128, 20, LangUtils.localize("gui.modID"))); - } - - @Override - protected void actionPerformed(GuiButton guibutton) - { - super.actionPerformed(guibutton); + public GuiMFilterSelect(EntityPlayer player, TileEntityDigitalMiner tentity) { + super(tentity, new ContainerNull(player, tentity)); - if(guibutton.id == 0) - { - Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 1, 0, 0)); - } - else if(guibutton.id == 1) - { - Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 2, 0, 0)); - } - else if(guibutton.id == 2) - { - Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 3, 0, 0)); - } - else if(guibutton.id == 3) - { - Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 6, 0, 0)); - } - } - - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + tileEntity = tentity; + } - fontRendererObj.drawString(LangUtils.localize("gui.filterSelect.title"), 43, 6, 0x404040); - - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } - - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + @Override + public void initGui() { + super.initGui(); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiFilterSelect.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + buttonList.clear(); + buttonList.add(new GuiButton( + 0, guiWidth + 24, guiHeight + 32, 128, 20, LangUtils.localize("gui.itemstack") + )); + buttonList.add(new GuiButton( + 1, guiWidth + 24, guiHeight + 52, 128, 20, LangUtils.localize("gui.oredict") + )); + buttonList.add(new GuiButton( + 2, guiWidth + 24, guiHeight + 72, 128, 20, LangUtils.localize("gui.material") + )); + buttonList.add(new GuiButton( + 3, guiWidth + 24, guiHeight + 92, 128, 20, LangUtils.localize("gui.modID") + )); + } - if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) - { - drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 0, 11, 11); - } - else { - drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 11, 11, 11); - } - } - - @Override - public void mouseClicked(int mouseX, int mouseY, int button) - { - super.mouseClicked(mouseX, mouseY, button); - - if(button == 0) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); - - if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) - { + @Override + protected void actionPerformed(GuiButton guibutton) { + super.actionPerformed(guibutton); + + if (guibutton.id == 0) { + Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage( + MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 1, 0, 0 + )); + } else if (guibutton.id == 1) { + Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage( + MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 2, 0, 0 + )); + } else if (guibutton.id == 2) { + Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage( + MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 3, 0, 0 + )); + } else if (guibutton.id == 3) { + Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage( + MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 6, 0, 0 + )); + } + } + + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + fontRendererObj.drawString( + LangUtils.localize("gui.filterSelect.title"), 43, 6, 0x404040 + ); + + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiFilterSelect.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + if (xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { + drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 0, 11, 11); + } else { + drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 11, 11, 11); + } + } + + @Override + public void mouseClicked(int mouseX, int mouseY, int button) { + super.mouseClicked(mouseX, mouseY, button); + + if (button == 0) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + if (xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0)); - } - } - } + Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage( + MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0 + )); + } + } + } } diff --git a/src/main/java/mekanism/client/gui/GuiMItemStackFilter.java b/src/main/java/mekanism/client/gui/GuiMItemStackFilter.java index debcd3c43..ca0b80e70 100644 --- a/src/main/java/mekanism/client/gui/GuiMItemStackFilter.java +++ b/src/main/java/mekanism/client/gui/GuiMItemStackFilter.java @@ -1,5 +1,7 @@ package mekanism.client.gui; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.client.sound.SoundHandler; @@ -20,304 +22,297 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; - import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiMItemStackFilter extends GuiMekanism -{ - public TileEntityDigitalMiner tileEntity; +public class GuiMItemStackFilter extends GuiMekanism { + public TileEntityDigitalMiner tileEntity; - public boolean isNew = false; + public boolean isNew = false; - public MItemStackFilter origFilter; + public MItemStackFilter origFilter; - public MItemStackFilter filter = new MItemStackFilter(); + public MItemStackFilter filter = new MItemStackFilter(); - public String status = EnumColor.DARK_GREEN + LangUtils.localize("gui.allOK"); + public String status = EnumColor.DARK_GREEN + LangUtils.localize("gui.allOK"); - public int ticker; + public int ticker; - public GuiMItemStackFilter(EntityPlayer player, TileEntityDigitalMiner tentity, int index) - { - super(tentity, new ContainerFilter(player.inventory, tentity)); - tileEntity = tentity; + public GuiMItemStackFilter( + EntityPlayer player, TileEntityDigitalMiner tentity, int index + ) { + super(tentity, new ContainerFilter(player.inventory, tentity)); + tileEntity = tentity; - origFilter = (MItemStackFilter)tileEntity.filters.get(index); - filter = ((MItemStackFilter)tileEntity.filters.get(index)).clone(); - } + origFilter = (MItemStackFilter) tileEntity.filters.get(index); + filter = ((MItemStackFilter) tileEntity.filters.get(index)).clone(); + } - public GuiMItemStackFilter(EntityPlayer player, TileEntityDigitalMiner tentity) - { - super(tentity, new ContainerFilter(player.inventory, tentity)); - tileEntity = tentity; + public GuiMItemStackFilter(EntityPlayer player, TileEntityDigitalMiner tentity) { + super(tentity, new ContainerFilter(player.inventory, tentity)); + tileEntity = tentity; - isNew = true; - } + isNew = true; + } - @Override - public void initGui() - { - super.initGui(); + @Override + public void initGui() { + super.initGui(); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; - buttonList.clear(); - buttonList.add(new GuiButton(0, guiWidth + 27, guiHeight + 62, 60, 20, LangUtils.localize("gui.save"))); - buttonList.add(new GuiButton(1, guiWidth + 89, guiHeight + 62, 60, 20, LangUtils.localize("gui.delete"))); + buttonList.clear(); + buttonList.add(new GuiButton( + 0, guiWidth + 27, guiHeight + 62, 60, 20, LangUtils.localize("gui.save") + )); + buttonList.add(new GuiButton( + 1, guiWidth + 89, guiHeight + 62, 60, 20, LangUtils.localize("gui.delete") + )); - if(isNew) - { - ((GuiButton)buttonList.get(1)).enabled = false; - } - } + if (isNew) { + ((GuiButton) buttonList.get(1)).enabled = false; + } + } - @Override - protected void actionPerformed(GuiButton guibutton) - { - super.actionPerformed(guibutton); + @Override + protected void actionPerformed(GuiButton guibutton) { + super.actionPerformed(guibutton); - if(guibutton.id == 0) - { - if(filter.itemType != null) - { - if(isNew) - { - Mekanism.packetHandler.sendToServer(new NewFilterMessage(Coord4D.get(tileEntity), filter)); - } - else { - Mekanism.packetHandler.sendToServer(new EditFilterMessage(Coord4D.get(tileEntity), false, origFilter, filter)); - } + if (guibutton.id == 0) { + if (filter.itemType != null) { + if (isNew) { + Mekanism.packetHandler.sendToServer( + new NewFilterMessage(Coord4D.get(tileEntity), filter) + ); + } else { + Mekanism.packetHandler.sendToServer(new EditFilterMessage( + Coord4D.get(tileEntity), false, origFilter, filter + )); + } - Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0)); - } - else if(filter.itemType == null) - { - status = EnumColor.DARK_RED + LangUtils.localize("gui.itemFilter.noItem"); - ticker = 20; - } - } - else if(guibutton.id == 1) - { - Mekanism.packetHandler.sendToServer(new EditFilterMessage(Coord4D.get(tileEntity), true, origFilter, null)); - Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0)); - } - } + Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage( + MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0 + )); + } else if (filter.itemType == null) { + status = EnumColor.DARK_RED + LangUtils.localize("gui.itemFilter.noItem"); + ticker = 20; + } + } else if (guibutton.id == 1) { + Mekanism.packetHandler.sendToServer( + new EditFilterMessage(Coord4D.get(tileEntity), true, origFilter, null) + ); + Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage( + MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0 + )); + } + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - fontRendererObj.drawString((isNew ? LangUtils.localize("gui.new") : LangUtils.localize("gui.edit")) + " " + LangUtils.localize("gui.itemFilter"), 43, 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("gui.status") + ": " + status, 35, 20, 0x00CD00); - fontRendererObj.drawString(LangUtils.localize("gui.itemFilter.details") + ":", 35, 32, 0x00CD00); + fontRendererObj.drawString( + (isNew ? LangUtils.localize("gui.new") : LangUtils.localize("gui.edit")) + " " + + LangUtils.localize("gui.itemFilter"), + 43, + 6, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.status") + ": " + status, 35, 20, 0x00CD00 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.itemFilter.details") + ":", 35, 32, 0x00CD00 + ); - if(filter.itemType != null) - { - fontRendererObj.drawString(filter.itemType.getDisplayName(), 35, 41, 0x00CD00); - } + if (filter.itemType != null) { + fontRendererObj.drawString( + filter.itemType.getDisplayName(), 35, 41, 0x00CD00 + ); + } - if(filter.itemType != null) - { - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_LIGHTING); - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), filter.itemType, 12, 19); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } - - if(filter.replaceStack != null) - { - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_LIGHTING); - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), filter.replaceStack, 149, 19); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } - - if(xAxis >= 148 && xAxis <= 162 && yAxis >= 45 && yAxis <= 59) - { - drawCreativeTabHoveringText(LangUtils.localize("gui.digitalMiner.requireReplace") + ": " + LangUtils.transYesNo(filter.requireStack), xAxis, yAxis); - } - - if(xAxis >= 15 && xAxis <= 29 && yAxis >= 45 && yAxis <= 59) - { - drawCreativeTabHoveringText(LangUtils.localize("gui.digitalMiner.fuzzyMode") + ": " + LangUtils.transYesNo(filter.fuzzy), xAxis, yAxis); - } + if (filter.itemType != null) { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_LIGHTING); + itemRender.renderItemAndEffectIntoGUI( + fontRendererObj, mc.getTextureManager(), filter.itemType, 12, 19 + ); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + if (filter.replaceStack != null) { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_LIGHTING); + itemRender.renderItemAndEffectIntoGUI( + fontRendererObj, mc.getTextureManager(), filter.replaceStack, 149, 19 + ); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } - @Override - public void updateScreen() - { - super.updateScreen(); + if (xAxis >= 148 && xAxis <= 162 && yAxis >= 45 && yAxis <= 59) { + drawCreativeTabHoveringText( + LangUtils.localize("gui.digitalMiner.requireReplace") + ": " + + LangUtils.transYesNo(filter.requireStack), + xAxis, + yAxis + ); + } - if(ticker > 0) - { - ticker--; - } - else { - status = EnumColor.DARK_GREEN + LangUtils.localize("gui.allOK"); - } - } + if (xAxis >= 15 && xAxis <= 29 && yAxis >= 45 && yAxis <= 59) { + drawCreativeTabHoveringText( + LangUtils.localize("gui.digitalMiner.fuzzyMode") + ": " + + LangUtils.transYesNo(filter.fuzzy), + xAxis, + yAxis + ); + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiMItemStackFilter.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + @Override + public void updateScreen() { + super.updateScreen(); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + if (ticker > 0) { + ticker--; + } else { + status = EnumColor.DARK_GREEN + LangUtils.localize("gui.allOK"); + } + } - if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) - { - drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 0, 11, 11); - } - else { - drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 11, 11, 11); - } - - if(xAxis >= 148 && xAxis <= 162 && yAxis >= 45 && yAxis <= 59) - { - drawTexturedModalRect(guiWidth + 148, guiHeight + 45, 176 + 23, 0, 14, 14); - } - else { - drawTexturedModalRect(guiWidth + 148, guiHeight + 45, 176 + 23, 14, 14, 14); - } - - if(xAxis >= 15 && xAxis <= 29 && yAxis >= 45 && yAxis <= 59) - { - drawTexturedModalRect(guiWidth + 15, guiHeight + 45, 176 + 37, 0, 14, 14); - } - else { - drawTexturedModalRect(guiWidth + 15, guiHeight + 45, 176 + 37, 14, 14, 14); - } + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - if(xAxis >= 12 && xAxis <= 28 && yAxis >= 19 && yAxis <= 35) - { - GL11.glPushMatrix(); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_DEPTH_TEST); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiMItemStackFilter.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - int x = guiWidth + 12; - int y = guiHeight + 19; - drawGradientRect(x, y, x + 16, y + 16, -2130706433, -2130706433); + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_DEPTH_TEST); - GL11.glPopMatrix(); - } - - if(xAxis >= 149 && xAxis <= 165 && yAxis >= 19 && yAxis <= 35) - { - GL11.glPushMatrix(); - GL11.glPushAttrib(GL11.GL_LIGHTING_BIT); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_DEPTH_TEST); + if (xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { + drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 0, 11, 11); + } else { + drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 11, 11, 11); + } - int x = guiWidth + 149; - int y = guiHeight + 19; - drawGradientRect(x, y, x + 16, y + 16, -2130706433, -2130706433); + if (xAxis >= 148 && xAxis <= 162 && yAxis >= 45 && yAxis <= 59) { + drawTexturedModalRect(guiWidth + 148, guiHeight + 45, 176 + 23, 0, 14, 14); + } else { + drawTexturedModalRect(guiWidth + 148, guiHeight + 45, 176 + 23, 14, 14, 14); + } - GL11.glPopAttrib(); - GL11.glPopMatrix(); - } - } + if (xAxis >= 15 && xAxis <= 29 && yAxis >= 45 && yAxis <= 59) { + drawTexturedModalRect(guiWidth + 15, guiHeight + 45, 176 + 37, 0, 14, 14); + } else { + drawTexturedModalRect(guiWidth + 15, guiHeight + 45, 176 + 37, 14, 14, 14); + } - @Override - protected void mouseClicked(int mouseX, int mouseY, int button) - { - super.mouseClicked(mouseX, mouseY, button); + if (xAxis >= 12 && xAxis <= 28 && yAxis >= 19 && yAxis <= 35) { + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); - if(button == 0) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + int x = guiWidth + 12; + int y = guiHeight + 19; + drawGradientRect(x, y, x + 16, y + 16, -2130706433, -2130706433); - if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) - { + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glPopMatrix(); + } + + if (xAxis >= 149 && xAxis <= 165 && yAxis >= 19 && yAxis <= 35) { + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_LIGHTING_BIT); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + + int x = guiWidth + 149; + int y = guiHeight + 19; + drawGradientRect(x, y, x + 16, y + 16, -2130706433, -2130706433); + + GL11.glPopAttrib(); + GL11.glPopMatrix(); + } + } + + @Override + protected void mouseClicked(int mouseX, int mouseY, int button) { + super.mouseClicked(mouseX, mouseY, button); + + if (button == 0) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + if (xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), isNew ? 5 : 0, 0, 0)); - } - - if(xAxis >= 148 && xAxis <= 162 && yAxis >= 45 && yAxis <= 59) - { - SoundHandler.playSound("gui.button.press"); - filter.requireStack = !filter.requireStack; - } - - if(xAxis >= 15 && xAxis <= 29 && yAxis >= 45 && yAxis <= 59) - { - SoundHandler.playSound("gui.button.press"); - filter.fuzzy = !filter.fuzzy; - } + Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage( + MinerGuiPacket.SERVER, Coord4D.get(tileEntity), isNew ? 5 : 0, 0, 0 + )); + } - if(xAxis >= 12 && xAxis <= 28 && yAxis >= 19 && yAxis <= 35) - { - ItemStack stack = mc.thePlayer.inventory.getItemStack(); + if (xAxis >= 148 && xAxis <= 162 && yAxis >= 45 && yAxis <= 59) { + SoundHandler.playSound("gui.button.press"); + filter.requireStack = !filter.requireStack; + } - if(stack != null && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) - { - if(stack.getItem() instanceof ItemBlock) - { - if(Block.getBlockFromItem(stack.getItem()) != Blocks.bedrock) - { - filter.itemType = stack.copy(); - filter.itemType.stackSize = 1; - } - } - } - else if(stack == null && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) - { - filter.itemType = null; - } + if (xAxis >= 15 && xAxis <= 29 && yAxis >= 45 && yAxis <= 59) { + SoundHandler.playSound("gui.button.press"); + filter.fuzzy = !filter.fuzzy; + } + + if (xAxis >= 12 && xAxis <= 28 && yAxis >= 19 && yAxis <= 35) { + ItemStack stack = mc.thePlayer.inventory.getItemStack(); + + if (stack != null && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + if (stack.getItem() instanceof ItemBlock) { + if (Block.getBlockFromItem(stack.getItem()) != Blocks.bedrock) { + filter.itemType = stack.copy(); + filter.itemType.stackSize = 1; + } + } + } else if (stack == null && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + filter.itemType = null; + } SoundHandler.playSound("gui.button.press"); - } - - if(xAxis >= 149 && xAxis <= 165 && yAxis >= 19 && yAxis <= 35) - { - boolean doNull = false; - ItemStack stack = mc.thePlayer.inventory.getItemStack(); - ItemStack toUse = null; + } - if(stack != null && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) - { - if(stack.getItem() instanceof ItemBlock) - { - if(Block.getBlockFromItem(stack.getItem()) != Blocks.bedrock) - { - toUse = stack.copy(); - toUse.stackSize = 1; - } - } - } - else if(stack == null && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) - { - doNull = true; - } + if (xAxis >= 149 && xAxis <= 165 && yAxis >= 19 && yAxis <= 35) { + boolean doNull = false; + ItemStack stack = mc.thePlayer.inventory.getItemStack(); + ItemStack toUse = null; - if(toUse != null || doNull) - { - filter.replaceStack = toUse; - } + if (stack != null && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + if (stack.getItem() instanceof ItemBlock) { + if (Block.getBlockFromItem(stack.getItem()) != Blocks.bedrock) { + toUse = stack.copy(); + toUse.stackSize = 1; + } + } + } else if (stack == null && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + doNull = true; + } + + if (toUse != null || doNull) { + filter.replaceStack = toUse; + } SoundHandler.playSound("gui.button.press"); - } - } - } + } + } + } } diff --git a/src/main/java/mekanism/client/gui/GuiMMaterialFilter.java b/src/main/java/mekanism/client/gui/GuiMMaterialFilter.java index 9696101bc..b92e5c937 100644 --- a/src/main/java/mekanism/client/gui/GuiMMaterialFilter.java +++ b/src/main/java/mekanism/client/gui/GuiMMaterialFilter.java @@ -1,5 +1,7 @@ package mekanism.client.gui; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.client.sound.SoundHandler; @@ -20,285 +22,277 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; - import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiMMaterialFilter extends GuiMekanism -{ - public TileEntityDigitalMiner tileEntity; +public class GuiMMaterialFilter extends GuiMekanism { + public TileEntityDigitalMiner tileEntity; - public boolean isNew = false; + public boolean isNew = false; - public MMaterialFilter origFilter; + public MMaterialFilter origFilter; - public MMaterialFilter filter = new MMaterialFilter(); + public MMaterialFilter filter = new MMaterialFilter(); - public String status = EnumColor.DARK_GREEN + LangUtils.localize("gui.allOK"); + public String status = EnumColor.DARK_GREEN + LangUtils.localize("gui.allOK"); - public int ticker; + public int ticker; - public GuiMMaterialFilter(EntityPlayer player, TileEntityDigitalMiner tentity, int index) - { - super(tentity, new ContainerFilter(player.inventory, tentity)); - tileEntity = tentity; + public GuiMMaterialFilter( + EntityPlayer player, TileEntityDigitalMiner tentity, int index + ) { + super(tentity, new ContainerFilter(player.inventory, tentity)); + tileEntity = tentity; - origFilter = (MMaterialFilter)tileEntity.filters.get(index); - filter = ((MMaterialFilter)tileEntity.filters.get(index)).clone(); - } + origFilter = (MMaterialFilter) tileEntity.filters.get(index); + filter = ((MMaterialFilter) tileEntity.filters.get(index)).clone(); + } - public GuiMMaterialFilter(EntityPlayer player, TileEntityDigitalMiner tentity) - { - super(tentity, new ContainerFilter(player.inventory, tentity)); - tileEntity = tentity; + public GuiMMaterialFilter(EntityPlayer player, TileEntityDigitalMiner tentity) { + super(tentity, new ContainerFilter(player.inventory, tentity)); + tileEntity = tentity; - isNew = true; - } + isNew = true; + } - @Override - public void initGui() - { - super.initGui(); + @Override + public void initGui() { + super.initGui(); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; - buttonList.clear(); - buttonList.add(new GuiButton(0, guiWidth + 27, guiHeight + 62, 60, 20, LangUtils.localize("gui.save"))); - buttonList.add(new GuiButton(1, guiWidth + 89, guiHeight + 62, 60, 20, LangUtils.localize("gui.delete"))); + buttonList.clear(); + buttonList.add(new GuiButton( + 0, guiWidth + 27, guiHeight + 62, 60, 20, LangUtils.localize("gui.save") + )); + buttonList.add(new GuiButton( + 1, guiWidth + 89, guiHeight + 62, 60, 20, LangUtils.localize("gui.delete") + )); - if(isNew) - { - ((GuiButton)buttonList.get(1)).enabled = false; - } - } + if (isNew) { + ((GuiButton) buttonList.get(1)).enabled = false; + } + } - @Override - protected void actionPerformed(GuiButton guibutton) - { - super.actionPerformed(guibutton); + @Override + protected void actionPerformed(GuiButton guibutton) { + super.actionPerformed(guibutton); - if(guibutton.id == 0) - { - if(filter.materialItem != null) - { - if(isNew) - { - Mekanism.packetHandler.sendToServer(new NewFilterMessage(Coord4D.get(tileEntity), filter)); - } - else { - Mekanism.packetHandler.sendToServer(new EditFilterMessage(Coord4D.get(tileEntity), false, origFilter, filter)); - } + if (guibutton.id == 0) { + if (filter.materialItem != null) { + if (isNew) { + Mekanism.packetHandler.sendToServer( + new NewFilterMessage(Coord4D.get(tileEntity), filter) + ); + } else { + Mekanism.packetHandler.sendToServer(new EditFilterMessage( + Coord4D.get(tileEntity), false, origFilter, filter + )); + } - Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0)); - } - else if(filter.materialItem == null) - { - status = EnumColor.DARK_RED + LangUtils.localize("gui.itemFilter.noItem"); - ticker = 20; - } - } - else if(guibutton.id == 1) - { - Mekanism.packetHandler.sendToServer(new EditFilterMessage(Coord4D.get(tileEntity), true, origFilter, null)); - Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0)); - } - } + Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage( + MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0 + )); + } else if (filter.materialItem == null) { + status = EnumColor.DARK_RED + LangUtils.localize("gui.itemFilter.noItem"); + ticker = 20; + } + } else if (guibutton.id == 1) { + Mekanism.packetHandler.sendToServer( + new EditFilterMessage(Coord4D.get(tileEntity), true, origFilter, null) + ); + Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage( + MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0 + )); + } + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - fontRendererObj.drawString((isNew ? LangUtils.localize("gui.new") : LangUtils.localize("gui.edit")) + " " + LangUtils.localize("gui.materialFilter"), 43, 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("gui.status") + ": " + status, 35, 20, 0x00CD00); - fontRendererObj.drawString(LangUtils.localize("gui.materialFilter.details") + ":", 35, 32, 0x00CD00); + fontRendererObj.drawString( + (isNew ? LangUtils.localize("gui.new") : LangUtils.localize("gui.edit")) + " " + + LangUtils.localize("gui.materialFilter"), + 43, + 6, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.status") + ": " + status, 35, 20, 0x00CD00 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.materialFilter.details") + ":", 35, 32, 0x00CD00 + ); - if(filter.materialItem != null) - { - fontRendererObj.drawString(filter.materialItem.getDisplayName(), 35, 41, 0x00CD00); - } + if (filter.materialItem != null) { + fontRendererObj.drawString( + filter.materialItem.getDisplayName(), 35, 41, 0x00CD00 + ); + } - if(filter.materialItem != null) - { - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_LIGHTING); - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), filter.materialItem, 12, 19); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } - - if(filter.replaceStack != null) - { - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_LIGHTING); - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), filter.replaceStack, 149, 19); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } - - if(xAxis >= 148 && xAxis <= 162 && yAxis >= 45 && yAxis <= 59) - { - drawCreativeTabHoveringText(LangUtils.localize("gui.digitalMiner.requireReplace") + ": " + LangUtils.transYesNo(filter.requireStack), xAxis, yAxis); - } + if (filter.materialItem != null) { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_LIGHTING); + itemRender.renderItemAndEffectIntoGUI( + fontRendererObj, mc.getTextureManager(), filter.materialItem, 12, 19 + ); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + if (filter.replaceStack != null) { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_LIGHTING); + itemRender.renderItemAndEffectIntoGUI( + fontRendererObj, mc.getTextureManager(), filter.replaceStack, 149, 19 + ); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } - @Override - public void updateScreen() - { - super.updateScreen(); + if (xAxis >= 148 && xAxis <= 162 && yAxis >= 45 && yAxis <= 59) { + drawCreativeTabHoveringText( + LangUtils.localize("gui.digitalMiner.requireReplace") + ": " + + LangUtils.transYesNo(filter.requireStack), + xAxis, + yAxis + ); + } - if(ticker > 0) - { - ticker--; - } - else { - status = EnumColor.DARK_GREEN + LangUtils.localize("gui.allOK"); - } - } + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + @Override + public void updateScreen() { + super.updateScreen(); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiMMaterialFilter.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + if (ticker > 0) { + ticker--; + } else { + status = EnumColor.DARK_GREEN + LangUtils.localize("gui.allOK"); + } + } - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) - { - drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 0, 11, 11); - } - else { - drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 11, 11, 11); - } - - if(xAxis >= 148 && xAxis <= 162 && yAxis >= 45 && yAxis <= 59) - { - drawTexturedModalRect(guiWidth + 148, guiHeight + 45, 176 + 23, 0, 14, 14); - } - else { - drawTexturedModalRect(guiWidth + 148, guiHeight + 45, 176 + 23, 14, 14, 14); - } + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiMMaterialFilter.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - if(xAxis >= 12 && xAxis <= 28 && yAxis >= 19 && yAxis <= 35) - { - GL11.glPushMatrix(); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_DEPTH_TEST); + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - int x = guiWidth + 12; - int y = guiHeight + 19; - drawGradientRect(x, y, x + 16, y + 16, -2130706433, -2130706433); + if (xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { + drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 0, 11, 11); + } else { + drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 11, 11, 11); + } - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_DEPTH_TEST); - GL11.glPopMatrix(); - } - - if(xAxis >= 149 && xAxis <= 165 && yAxis >= 19 && yAxis <= 35) - { - GL11.glPushMatrix(); - GL11.glPushAttrib(GL11.GL_LIGHTING_BIT); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_DEPTH_TEST); + if (xAxis >= 148 && xAxis <= 162 && yAxis >= 45 && yAxis <= 59) { + drawTexturedModalRect(guiWidth + 148, guiHeight + 45, 176 + 23, 0, 14, 14); + } else { + drawTexturedModalRect(guiWidth + 148, guiHeight + 45, 176 + 23, 14, 14, 14); + } - int x = guiWidth + 149; - int y = guiHeight + 19; - drawGradientRect(x, y, x + 16, y + 16, -2130706433, -2130706433); + if (xAxis >= 12 && xAxis <= 28 && yAxis >= 19 && yAxis <= 35) { + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); - GL11.glPopAttrib(); - GL11.glPopMatrix(); - } - } + int x = guiWidth + 12; + int y = guiHeight + 19; + drawGradientRect(x, y, x + 16, y + 16, -2130706433, -2130706433); - @Override - protected void mouseClicked(int mouseX, int mouseY, int button) - { - super.mouseClicked(mouseX, mouseY, button); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glPopMatrix(); + } - if(button == 0) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + if (xAxis >= 149 && xAxis <= 165 && yAxis >= 19 && yAxis <= 35) { + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_LIGHTING_BIT); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); - if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) - { + int x = guiWidth + 149; + int y = guiHeight + 19; + drawGradientRect(x, y, x + 16, y + 16, -2130706433, -2130706433); + + GL11.glPopAttrib(); + GL11.glPopMatrix(); + } + } + + @Override + protected void mouseClicked(int mouseX, int mouseY, int button) { + super.mouseClicked(mouseX, mouseY, button); + + if (button == 0) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + if (xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), isNew ? 5 : 0, 0, 0)); - } - - if(xAxis >= 148 && xAxis <= 162 && yAxis >= 45 && yAxis <= 59) - { - SoundHandler.playSound("gui.button.press"); - filter.requireStack = !filter.requireStack; - } + Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage( + MinerGuiPacket.SERVER, Coord4D.get(tileEntity), isNew ? 5 : 0, 0, 0 + )); + } - if(xAxis >= 12 && xAxis <= 28 && yAxis >= 19 && yAxis <= 35) - { - ItemStack stack = mc.thePlayer.inventory.getItemStack(); + if (xAxis >= 148 && xAxis <= 162 && yAxis >= 45 && yAxis <= 59) { + SoundHandler.playSound("gui.button.press"); + filter.requireStack = !filter.requireStack; + } - if(stack != null && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) - { - if(stack.getItem() instanceof ItemBlock) - { - if(Block.getBlockFromItem(stack.getItem()) != Blocks.bedrock) - { - filter.materialItem = stack.copy(); - filter.materialItem.stackSize = 1; - } - } - } - else if(stack == null && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) - { - filter.materialItem = null; - } + if (xAxis >= 12 && xAxis <= 28 && yAxis >= 19 && yAxis <= 35) { + ItemStack stack = mc.thePlayer.inventory.getItemStack(); + + if (stack != null && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + if (stack.getItem() instanceof ItemBlock) { + if (Block.getBlockFromItem(stack.getItem()) != Blocks.bedrock) { + filter.materialItem = stack.copy(); + filter.materialItem.stackSize = 1; + } + } + } else if (stack == null && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + filter.materialItem = null; + } SoundHandler.playSound("gui.button.press"); - } - - if(xAxis >= 149 && xAxis <= 165 && yAxis >= 19 && yAxis <= 35) - { - boolean doNull = false; - ItemStack stack = mc.thePlayer.inventory.getItemStack(); - ItemStack toUse = null; + } - if(stack != null && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) - { - if(stack.getItem() instanceof ItemBlock) - { - if(Block.getBlockFromItem(stack.getItem()) != Blocks.bedrock) - { - toUse = stack.copy(); - toUse.stackSize = 1; - } - } - } - else if(stack == null && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) - { - doNull = true; - } + if (xAxis >= 149 && xAxis <= 165 && yAxis >= 19 && yAxis <= 35) { + boolean doNull = false; + ItemStack stack = mc.thePlayer.inventory.getItemStack(); + ItemStack toUse = null; - if(toUse != null || doNull) - { - filter.replaceStack = toUse; - } + if (stack != null && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + if (stack.getItem() instanceof ItemBlock) { + if (Block.getBlockFromItem(stack.getItem()) != Blocks.bedrock) { + toUse = stack.copy(); + toUse.stackSize = 1; + } + } + } else if (stack == null && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + doNull = true; + } + + if (toUse != null || doNull) { + filter.replaceStack = toUse; + } SoundHandler.playSound("gui.button.press"); - } - } - } + } + } + } } diff --git a/src/main/java/mekanism/client/gui/GuiMModIDFilter.java b/src/main/java/mekanism/client/gui/GuiMModIDFilter.java index ee49b66e4..e7f7388ce 100644 --- a/src/main/java/mekanism/client/gui/GuiMModIDFilter.java +++ b/src/main/java/mekanism/client/gui/GuiMModIDFilter.java @@ -2,6 +2,8 @@ package mekanism.client.gui; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.client.sound.SoundHandler; @@ -25,358 +27,339 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; - import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiMModIDFilter extends GuiMekanism -{ - public TileEntityDigitalMiner tileEntity; +public class GuiMModIDFilter extends GuiMekanism { + public TileEntityDigitalMiner tileEntity; - public boolean isNew = false; + public boolean isNew = false; - public MModIDFilter origFilter; + public MModIDFilter origFilter; - public MModIDFilter filter = new MModIDFilter(); + public MModIDFilter filter = new MModIDFilter(); - private GuiTextField modIDText; + private GuiTextField modIDText; - public ItemStack renderStack; + public ItemStack renderStack; - public int ticker = 0; + public int ticker = 0; - public int stackSwitch = 0; + public int stackSwitch = 0; - public int stackIndex = 0; + public int stackIndex = 0; - public List iterStacks; + public List iterStacks; - public String status = EnumColor.DARK_GREEN + LangUtils.localize("gui.allOK"); + public String status = EnumColor.DARK_GREEN + LangUtils.localize("gui.allOK"); - public GuiMModIDFilter(EntityPlayer player, TileEntityDigitalMiner tentity, int index) - { - super(tentity, new ContainerFilter(player.inventory, tentity)); - tileEntity = tentity; + public GuiMModIDFilter( + EntityPlayer player, TileEntityDigitalMiner tentity, int index + ) { + super(tentity, new ContainerFilter(player.inventory, tentity)); + tileEntity = tentity; - origFilter = (MModIDFilter)tileEntity.filters.get(index); - filter = ((MModIDFilter)tentity.filters.get(index)).clone(); + origFilter = (MModIDFilter) tileEntity.filters.get(index); + filter = ((MModIDFilter) tentity.filters.get(index)).clone(); - updateStackList(filter.modID); - } + updateStackList(filter.modID); + } - public GuiMModIDFilter(EntityPlayer player, TileEntityDigitalMiner tentity) - { - super(tentity, new ContainerFilter(player.inventory, tentity)); - tileEntity = tentity; + public GuiMModIDFilter(EntityPlayer player, TileEntityDigitalMiner tentity) { + super(tentity, new ContainerFilter(player.inventory, tentity)); + tileEntity = tentity; - isNew = true; - } + isNew = true; + } - @Override - public void initGui() - { - super.initGui(); + @Override + public void initGui() { + super.initGui(); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; - buttonList.clear(); - buttonList.add(new GuiButton(0, guiWidth + 27, guiHeight + 62, 60, 20, LangUtils.localize("gui.save"))); - buttonList.add(new GuiButton(1, guiWidth + 89, guiHeight + 62, 60, 20, LangUtils.localize("gui.delete"))); + buttonList.clear(); + buttonList.add(new GuiButton( + 0, guiWidth + 27, guiHeight + 62, 60, 20, LangUtils.localize("gui.save") + )); + buttonList.add(new GuiButton( + 1, guiWidth + 89, guiHeight + 62, 60, 20, LangUtils.localize("gui.delete") + )); - if(isNew) - { - ((GuiButton)buttonList.get(1)).enabled = false; - } + if (isNew) { + ((GuiButton) buttonList.get(1)).enabled = false; + } - modIDText = new GuiTextField(fontRendererObj, guiWidth + 35, guiHeight + 47, 95, 12); - modIDText.setMaxStringLength(TransporterFilter.MAX_LENGTH); - modIDText.setFocused(true); - } + modIDText + = new GuiTextField(fontRendererObj, guiWidth + 35, guiHeight + 47, 95, 12); + modIDText.setMaxStringLength(TransporterFilter.MAX_LENGTH); + modIDText.setFocused(true); + } - @Override - public void keyTyped(char c, int i) - { - if(!modIDText.isFocused() || i == Keyboard.KEY_ESCAPE) - { - super.keyTyped(c, i); - } + @Override + public void keyTyped(char c, int i) { + if (!modIDText.isFocused() || i == Keyboard.KEY_ESCAPE) { + super.keyTyped(c, i); + } - if(modIDText.isFocused() && i == Keyboard.KEY_RETURN) - { - setModID(); - return; - } + if (modIDText.isFocused() && i == Keyboard.KEY_RETURN) { + setModID(); + return; + } - if(Character.isLetter(c) || Character.isDigit(c) || TransporterFilter.SPECIAL_CHARS.contains(c) || isTextboxKey(c, i)) - { - modIDText.textboxKeyTyped(c, i); - } - } + if (Character.isLetter(c) || Character.isDigit(c) + || TransporterFilter.SPECIAL_CHARS.contains(c) || isTextboxKey(c, i)) { + modIDText.textboxKeyTyped(c, i); + } + } - @Override - protected void actionPerformed(GuiButton guibutton) - { - super.actionPerformed(guibutton); + @Override + protected void actionPerformed(GuiButton guibutton) { + super.actionPerformed(guibutton); - if(guibutton.id == 0) - { - if(!modIDText.getText().isEmpty()) - { - setModID(); - } + if (guibutton.id == 0) { + if (!modIDText.getText().isEmpty()) { + setModID(); + } - if(filter.modID != null && !filter.modID.isEmpty()) - { - if(isNew) - { - Mekanism.packetHandler.sendToServer(new NewFilterMessage(Coord4D.get(tileEntity), filter)); - } - else { - Mekanism.packetHandler.sendToServer(new EditFilterMessage(Coord4D.get(tileEntity), false, origFilter, filter)); - } + if (filter.modID != null && !filter.modID.isEmpty()) { + if (isNew) { + Mekanism.packetHandler.sendToServer( + new NewFilterMessage(Coord4D.get(tileEntity), filter) + ); + } else { + Mekanism.packetHandler.sendToServer(new EditFilterMessage( + Coord4D.get(tileEntity), false, origFilter, filter + )); + } - Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0)); - } - else { - status = EnumColor.DARK_RED + LangUtils.localize("gui.modIDFilter.noID"); - ticker = 20; - } - } - else if(guibutton.id == 1) - { - Mekanism.packetHandler.sendToServer(new EditFilterMessage(Coord4D.get(tileEntity), true, origFilter, null)); - Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0)); - } - } + Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage( + MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0 + )); + } else { + status = EnumColor.DARK_RED + LangUtils.localize("gui.modIDFilter.noID"); + ticker = 20; + } + } else if (guibutton.id == 1) { + Mekanism.packetHandler.sendToServer( + new EditFilterMessage(Coord4D.get(tileEntity), true, origFilter, null) + ); + Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage( + MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0 + )); + } + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - fontRendererObj.drawString((isNew ? LangUtils.localize("gui.new") : LangUtils.localize("gui.edit")) + " " + LangUtils.localize("gui.modIDFilter"), 43, 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("gui.status") + ": " + status, 35, 20, 0x00CD00); - renderScaledText(LangUtils.localize("gui.id") + ": " + filter.modID, 35, 32, 0x00CD00, 107); + fontRendererObj.drawString( + (isNew ? LangUtils.localize("gui.new") : LangUtils.localize("gui.edit")) + " " + + LangUtils.localize("gui.modIDFilter"), + 43, + 6, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.status") + ": " + status, 35, 20, 0x00CD00 + ); + renderScaledText( + LangUtils.localize("gui.id") + ": " + filter.modID, 35, 32, 0x00CD00, 107 + ); - if(renderStack != null) - { - try { - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_LIGHTING); - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), renderStack, 12, 19); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } catch(Exception e) {} - } - - if(filter.replaceStack != null) - { - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_LIGHTING); - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), filter.replaceStack, 149, 19); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } - - if(xAxis >= 148 && xAxis <= 162 && yAxis >= 45 && yAxis <= 59) - { - drawCreativeTabHoveringText(LangUtils.localize("gui.digitalMiner.requireReplace") + ": " + LangUtils.transYesNo(filter.requireStack), xAxis, yAxis); - } + if (renderStack != null) { + try { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_LIGHTING); + itemRender.renderItemAndEffectIntoGUI( + fontRendererObj, mc.getTextureManager(), renderStack, 12, 19 + ); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } catch (Exception e) {} + } - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + if (filter.replaceStack != null) { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_LIGHTING); + itemRender.renderItemAndEffectIntoGUI( + fontRendererObj, mc.getTextureManager(), filter.replaceStack, 149, 19 + ); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + if (xAxis >= 148 && xAxis <= 162 && yAxis >= 45 && yAxis <= 59) { + drawCreativeTabHoveringText( + LangUtils.localize("gui.digitalMiner.requireReplace") + ": " + + LangUtils.transYesNo(filter.requireStack), + xAxis, + yAxis + ); + } - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiMModIDFilter.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) - { - drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 0, 11, 11); - } - else { - drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 11, 11, 11); - } + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiMModIDFilter.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - if(xAxis >= 131 && xAxis <= 143 && yAxis >= 47 && yAxis <= 59) - { - drawTexturedModalRect(guiWidth + 131, guiHeight + 47, 176 + 11, 0, 12, 12); - } - else { - drawTexturedModalRect(guiWidth + 131, guiHeight + 47, 176 + 11, 12, 12, 12); - } - - if(xAxis >= 148 && xAxis <= 162 && yAxis >= 45 && yAxis <= 59) - { - drawTexturedModalRect(guiWidth + 148, guiHeight + 45, 176 + 23, 0, 14, 14); - } - else { - drawTexturedModalRect(guiWidth + 148, guiHeight + 45, 176 + 23, 14, 14, 14); - } - - if(xAxis >= 149 && xAxis <= 165 && yAxis >= 19 && yAxis <= 35) - { - GL11.glPushMatrix(); - GL11.glPushAttrib(GL11.GL_LIGHTING_BIT); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_DEPTH_TEST); + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - int x = guiWidth + 149; - int y = guiHeight + 19; - drawGradientRect(x, y, x + 16, y + 16, -2130706433, -2130706433); + if (xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { + drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 0, 11, 11); + } else { + drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 11, 11, 11); + } - GL11.glPopAttrib(); - GL11.glPopMatrix(); - } + if (xAxis >= 131 && xAxis <= 143 && yAxis >= 47 && yAxis <= 59) { + drawTexturedModalRect(guiWidth + 131, guiHeight + 47, 176 + 11, 0, 12, 12); + } else { + drawTexturedModalRect(guiWidth + 131, guiHeight + 47, 176 + 11, 12, 12, 12); + } - modIDText.drawTextBox(); - } + if (xAxis >= 148 && xAxis <= 162 && yAxis >= 45 && yAxis <= 59) { + drawTexturedModalRect(guiWidth + 148, guiHeight + 45, 176 + 23, 0, 14, 14); + } else { + drawTexturedModalRect(guiWidth + 148, guiHeight + 45, 176 + 23, 14, 14, 14); + } - @Override - public void updateScreen() - { - super.updateScreen(); + if (xAxis >= 149 && xAxis <= 165 && yAxis >= 19 && yAxis <= 35) { + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_LIGHTING_BIT); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); - modIDText.updateCursorCounter(); + int x = guiWidth + 149; + int y = guiHeight + 19; + drawGradientRect(x, y, x + 16, y + 16, -2130706433, -2130706433); - if(ticker > 0) - { - ticker--; - } - else { - status = EnumColor.DARK_GREEN + LangUtils.localize("gui.allOK"); - } + GL11.glPopAttrib(); + GL11.glPopMatrix(); + } - if(stackSwitch > 0) - { - stackSwitch--; - } + modIDText.drawTextBox(); + } - if(stackSwitch == 0 && iterStacks != null && iterStacks.size() > 0) - { - stackSwitch = 20; + @Override + public void updateScreen() { + super.updateScreen(); - if(stackIndex == -1 || stackIndex == iterStacks.size()-1) - { - stackIndex = 0; - } - else if(stackIndex < iterStacks.size()-1) - { - stackIndex++; - } + modIDText.updateCursorCounter(); - renderStack = iterStacks.get(stackIndex); - } - else if(iterStacks != null && iterStacks.size() == 0) - { - renderStack = null; - } - } + if (ticker > 0) { + ticker--; + } else { + status = EnumColor.DARK_GREEN + LangUtils.localize("gui.allOK"); + } - @Override - protected void mouseClicked(int mouseX, int mouseY, int button) - { - super.mouseClicked(mouseX, mouseY, button); + if (stackSwitch > 0) { + stackSwitch--; + } - modIDText.mouseClicked(mouseX, mouseY, button); + if (stackSwitch == 0 && iterStacks != null && iterStacks.size() > 0) { + stackSwitch = 20; - if(button == 0) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + if (stackIndex == -1 || stackIndex == iterStacks.size() - 1) { + stackIndex = 0; + } else if (stackIndex < iterStacks.size() - 1) { + stackIndex++; + } - if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) - { + renderStack = iterStacks.get(stackIndex); + } else if (iterStacks != null && iterStacks.size() == 0) { + renderStack = null; + } + } + + @Override + protected void mouseClicked(int mouseX, int mouseY, int button) { + super.mouseClicked(mouseX, mouseY, button); + + modIDText.mouseClicked(mouseX, mouseY, button); + + if (button == 0) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + if (xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), isNew ? 5 : 0, 0, 0)); - } + Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage( + MinerGuiPacket.SERVER, Coord4D.get(tileEntity), isNew ? 5 : 0, 0, 0 + )); + } - if(xAxis >= 131 && xAxis <= 143 && yAxis >= 47 && yAxis <= 59) - { + if (xAxis >= 131 && xAxis <= 143 && yAxis >= 47 && yAxis <= 59) { SoundHandler.playSound("gui.button.press"); - setModID(); - } - - if(xAxis >= 148 && xAxis <= 162 && yAxis >= 45 && yAxis <= 59) - { - SoundHandler.playSound("gui.button.press"); - filter.requireStack = !filter.requireStack; - } - - if(xAxis >= 149 && xAxis <= 165 && yAxis >= 19 && yAxis <= 35) - { - boolean doNull = false; - ItemStack stack = mc.thePlayer.inventory.getItemStack(); - ItemStack toUse = null; + setModID(); + } - if(stack != null && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) - { - if(stack.getItem() instanceof ItemBlock) - { - if(Block.getBlockFromItem(stack.getItem()) != Blocks.bedrock) - { - toUse = stack.copy(); - toUse.stackSize = 1; - } - } - } - else if(stack == null && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) - { - doNull = true; - } + if (xAxis >= 148 && xAxis <= 162 && yAxis >= 45 && yAxis <= 59) { + SoundHandler.playSound("gui.button.press"); + filter.requireStack = !filter.requireStack; + } - if(toUse != null || doNull) - { - filter.replaceStack = toUse; - } + if (xAxis >= 149 && xAxis <= 165 && yAxis >= 19 && yAxis <= 35) { + boolean doNull = false; + ItemStack stack = mc.thePlayer.inventory.getItemStack(); + ItemStack toUse = null; + + if (stack != null && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + if (stack.getItem() instanceof ItemBlock) { + if (Block.getBlockFromItem(stack.getItem()) != Blocks.bedrock) { + toUse = stack.copy(); + toUse.stackSize = 1; + } + } + } else if (stack == null && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + doNull = true; + } + + if (toUse != null || doNull) { + filter.replaceStack = toUse; + } SoundHandler.playSound("gui.button.press"); - } - } - } + } + } + } - private void updateStackList(String modName) - { - iterStacks = OreDictCache.getModIDStacks(modName, true); + private void updateStackList(String modName) { + iterStacks = OreDictCache.getModIDStacks(modName, true); - stackSwitch = 0; - stackIndex = -1; - } + stackSwitch = 0; + stackIndex = -1; + } - private void setModID() - { - String modName = modIDText.getText(); + private void setModID() { + String modName = modIDText.getText(); - if(modName == null || modName.isEmpty()) - { - status = EnumColor.DARK_RED + LangUtils.localize("gui.modIDFilter.noID"); - return; - } - else if(modName.equals(filter.modID)) - { - status = EnumColor.DARK_RED + LangUtils.localize("gui.modIDFilter.sameID"); - return; - } + if (modName == null || modName.isEmpty()) { + status = EnumColor.DARK_RED + LangUtils.localize("gui.modIDFilter.noID"); + return; + } else if (modName.equals(filter.modID)) { + status = EnumColor.DARK_RED + LangUtils.localize("gui.modIDFilter.sameID"); + return; + } - updateStackList(modName); + updateStackList(modName); - filter.modID = modName; - modIDText.setText(""); - } + filter.modID = modName; + modIDText.setText(""); + } } diff --git a/src/main/java/mekanism/client/gui/GuiMOreDictFilter.java b/src/main/java/mekanism/client/gui/GuiMOreDictFilter.java index f4c55c396..94c9db7b1 100644 --- a/src/main/java/mekanism/client/gui/GuiMOreDictFilter.java +++ b/src/main/java/mekanism/client/gui/GuiMOreDictFilter.java @@ -2,6 +2,8 @@ package mekanism.client.gui; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.client.sound.SoundHandler; @@ -25,358 +27,344 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; - import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiMOreDictFilter extends GuiMekanism -{ - public TileEntityDigitalMiner tileEntity; +public class GuiMOreDictFilter extends GuiMekanism { + public TileEntityDigitalMiner tileEntity; - public boolean isNew = false; + public boolean isNew = false; - public MOreDictFilter origFilter; + public MOreDictFilter origFilter; - public MOreDictFilter filter = new MOreDictFilter(); + public MOreDictFilter filter = new MOreDictFilter(); - private GuiTextField oreDictText; + private GuiTextField oreDictText; - public ItemStack renderStack; + public ItemStack renderStack; - public int ticker = 0; + public int ticker = 0; - public int stackSwitch = 0; + public int stackSwitch = 0; - public int stackIndex = 0; + public int stackIndex = 0; - public List iterStacks; + public List iterStacks; - public String status = EnumColor.DARK_GREEN + LangUtils.localize("gui.allOK"); + public String status = EnumColor.DARK_GREEN + LangUtils.localize("gui.allOK"); - public GuiMOreDictFilter(EntityPlayer player, TileEntityDigitalMiner tentity, int index) - { - super(tentity, new ContainerFilter(player.inventory, tentity)); - tileEntity = tentity; + public GuiMOreDictFilter( + EntityPlayer player, TileEntityDigitalMiner tentity, int index + ) { + super(tentity, new ContainerFilter(player.inventory, tentity)); + tileEntity = tentity; - origFilter = (MOreDictFilter)tileEntity.filters.get(index); - filter = ((MOreDictFilter)tentity.filters.get(index)).clone(); + origFilter = (MOreDictFilter) tileEntity.filters.get(index); + filter = ((MOreDictFilter) tentity.filters.get(index)).clone(); - updateStackList(filter.oreDictName); - } + updateStackList(filter.oreDictName); + } - public GuiMOreDictFilter(EntityPlayer player, TileEntityDigitalMiner tentity) - { - super(tentity, new ContainerFilter(player.inventory, tentity)); - tileEntity = tentity; + public GuiMOreDictFilter(EntityPlayer player, TileEntityDigitalMiner tentity) { + super(tentity, new ContainerFilter(player.inventory, tentity)); + tileEntity = tentity; - isNew = true; - } + isNew = true; + } - @Override - public void initGui() - { - super.initGui(); + @Override + public void initGui() { + super.initGui(); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; - buttonList.clear(); - buttonList.add(new GuiButton(0, guiWidth + 27, guiHeight + 62, 60, 20, LangUtils.localize("gui.save"))); - buttonList.add(new GuiButton(1, guiWidth + 89, guiHeight + 62, 60, 20, LangUtils.localize("gui.delete"))); + buttonList.clear(); + buttonList.add(new GuiButton( + 0, guiWidth + 27, guiHeight + 62, 60, 20, LangUtils.localize("gui.save") + )); + buttonList.add(new GuiButton( + 1, guiWidth + 89, guiHeight + 62, 60, 20, LangUtils.localize("gui.delete") + )); - if(isNew) - { - ((GuiButton)buttonList.get(1)).enabled = false; - } + if (isNew) { + ((GuiButton) buttonList.get(1)).enabled = false; + } - oreDictText = new GuiTextField(fontRendererObj, guiWidth + 35, guiHeight + 47, 95, 12); - oreDictText.setMaxStringLength(TransporterFilter.MAX_LENGTH); - oreDictText.setFocused(true); - } + oreDictText + = new GuiTextField(fontRendererObj, guiWidth + 35, guiHeight + 47, 95, 12); + oreDictText.setMaxStringLength(TransporterFilter.MAX_LENGTH); + oreDictText.setFocused(true); + } - @Override - public void keyTyped(char c, int i) - { - if(!oreDictText.isFocused() || i == Keyboard.KEY_ESCAPE) - { - super.keyTyped(c, i); - } + @Override + public void keyTyped(char c, int i) { + if (!oreDictText.isFocused() || i == Keyboard.KEY_ESCAPE) { + super.keyTyped(c, i); + } - if(oreDictText.isFocused() && i == Keyboard.KEY_RETURN) - { - setOreDictKey(); - return; - } + if (oreDictText.isFocused() && i == Keyboard.KEY_RETURN) { + setOreDictKey(); + return; + } - if(Character.isLetter(c) || Character.isDigit(c) || TransporterFilter.SPECIAL_CHARS.contains(c) || isTextboxKey(c, i)) - { - oreDictText.textboxKeyTyped(c, i); - } - } + if (Character.isLetter(c) || Character.isDigit(c) + || TransporterFilter.SPECIAL_CHARS.contains(c) || isTextboxKey(c, i)) { + oreDictText.textboxKeyTyped(c, i); + } + } - @Override - protected void actionPerformed(GuiButton guibutton) - { - super.actionPerformed(guibutton); + @Override + protected void actionPerformed(GuiButton guibutton) { + super.actionPerformed(guibutton); - if(guibutton.id == 0) - { - if(!oreDictText.getText().isEmpty()) - { - setOreDictKey(); - } + if (guibutton.id == 0) { + if (!oreDictText.getText().isEmpty()) { + setOreDictKey(); + } - if(filter.oreDictName != null && !filter.oreDictName.isEmpty()) - { - if(isNew) - { - Mekanism.packetHandler.sendToServer(new NewFilterMessage(Coord4D.get(tileEntity), filter)); - } - else { - Mekanism.packetHandler.sendToServer(new EditFilterMessage(Coord4D.get(tileEntity), false, origFilter, filter)); - } + if (filter.oreDictName != null && !filter.oreDictName.isEmpty()) { + if (isNew) { + Mekanism.packetHandler.sendToServer( + new NewFilterMessage(Coord4D.get(tileEntity), filter) + ); + } else { + Mekanism.packetHandler.sendToServer(new EditFilterMessage( + Coord4D.get(tileEntity), false, origFilter, filter + )); + } - Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0)); - } - else { - status = EnumColor.DARK_RED + LangUtils.localize("gui.oredictFilter.noKey"); - ticker = 20; - } - } - else if(guibutton.id == 1) - { - Mekanism.packetHandler.sendToServer(new EditFilterMessage(Coord4D.get(tileEntity), true, origFilter, null)); - Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0)); - } - } + Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage( + MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0 + )); + } else { + status + = EnumColor.DARK_RED + LangUtils.localize("gui.oredictFilter.noKey"); + ticker = 20; + } + } else if (guibutton.id == 1) { + Mekanism.packetHandler.sendToServer( + new EditFilterMessage(Coord4D.get(tileEntity), true, origFilter, null) + ); + Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage( + MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0 + )); + } + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - fontRendererObj.drawString((isNew ? LangUtils.localize("gui.new") : LangUtils.localize("gui.edit")) + " " + LangUtils.localize("gui.oredictFilter"), 43, 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("gui.status") + ": " + status, 35, 20, 0x00CD00); - renderScaledText(LangUtils.localize("gui.key") + ": " + filter.oreDictName, 35, 32, 0x00CD00, 107); + fontRendererObj.drawString( + (isNew ? LangUtils.localize("gui.new") : LangUtils.localize("gui.edit")) + " " + + LangUtils.localize("gui.oredictFilter"), + 43, + 6, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.status") + ": " + status, 35, 20, 0x00CD00 + ); + renderScaledText( + LangUtils.localize("gui.key") + ": " + filter.oreDictName, + 35, + 32, + 0x00CD00, + 107 + ); - if(renderStack != null) - { - try { - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_LIGHTING); - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), renderStack, 12, 19); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } catch(Exception e) {} - } - - if(filter.replaceStack != null) - { - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_LIGHTING); - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), filter.replaceStack, 149, 19); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } - - if(xAxis >= 148 && xAxis <= 162 && yAxis >= 45 && yAxis <= 59) - { - drawCreativeTabHoveringText(LangUtils.localize("gui.digitalMiner.requireReplace") + ": " + LangUtils.transYesNo(filter.requireStack), xAxis, yAxis); - } + if (renderStack != null) { + try { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_LIGHTING); + itemRender.renderItemAndEffectIntoGUI( + fontRendererObj, mc.getTextureManager(), renderStack, 12, 19 + ); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } catch (Exception e) {} + } - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + if (filter.replaceStack != null) { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_LIGHTING); + itemRender.renderItemAndEffectIntoGUI( + fontRendererObj, mc.getTextureManager(), filter.replaceStack, 149, 19 + ); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + if (xAxis >= 148 && xAxis <= 162 && yAxis >= 45 && yAxis <= 59) { + drawCreativeTabHoveringText( + LangUtils.localize("gui.digitalMiner.requireReplace") + ": " + + LangUtils.transYesNo(filter.requireStack), + xAxis, + yAxis + ); + } - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiMOreDictFilter.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) - { - drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 0, 11, 11); - } - else { - drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 11, 11, 11); - } + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiMOreDictFilter.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - if(xAxis >= 131 && xAxis <= 143 && yAxis >= 47 && yAxis <= 59) - { - drawTexturedModalRect(guiWidth + 131, guiHeight + 47, 176 + 11, 0, 12, 12); - } - else { - drawTexturedModalRect(guiWidth + 131, guiHeight + 47, 176 + 11, 12, 12, 12); - } - - if(xAxis >= 148 && xAxis <= 162 && yAxis >= 45 && yAxis <= 59) - { - drawTexturedModalRect(guiWidth + 148, guiHeight + 45, 176 + 23, 0, 14, 14); - } - else { - drawTexturedModalRect(guiWidth + 148, guiHeight + 45, 176 + 23, 14, 14, 14); - } - - if(xAxis >= 149 && xAxis <= 165 && yAxis >= 19 && yAxis <= 35) - { - GL11.glPushMatrix(); - GL11.glPushAttrib(GL11.GL_LIGHTING_BIT); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_DEPTH_TEST); + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - int x = guiWidth + 149; - int y = guiHeight + 19; - drawGradientRect(x, y, x + 16, y + 16, -2130706433, -2130706433); + if (xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { + drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 0, 11, 11); + } else { + drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 11, 11, 11); + } - GL11.glPopAttrib(); - GL11.glPopMatrix(); - } + if (xAxis >= 131 && xAxis <= 143 && yAxis >= 47 && yAxis <= 59) { + drawTexturedModalRect(guiWidth + 131, guiHeight + 47, 176 + 11, 0, 12, 12); + } else { + drawTexturedModalRect(guiWidth + 131, guiHeight + 47, 176 + 11, 12, 12, 12); + } - oreDictText.drawTextBox(); - } + if (xAxis >= 148 && xAxis <= 162 && yAxis >= 45 && yAxis <= 59) { + drawTexturedModalRect(guiWidth + 148, guiHeight + 45, 176 + 23, 0, 14, 14); + } else { + drawTexturedModalRect(guiWidth + 148, guiHeight + 45, 176 + 23, 14, 14, 14); + } - @Override - public void updateScreen() - { - super.updateScreen(); + if (xAxis >= 149 && xAxis <= 165 && yAxis >= 19 && yAxis <= 35) { + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_LIGHTING_BIT); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); - oreDictText.updateCursorCounter(); + int x = guiWidth + 149; + int y = guiHeight + 19; + drawGradientRect(x, y, x + 16, y + 16, -2130706433, -2130706433); - if(ticker > 0) - { - ticker--; - } - else { - status = EnumColor.DARK_GREEN + LangUtils.localize("gui.allOK"); - } + GL11.glPopAttrib(); + GL11.glPopMatrix(); + } - if(stackSwitch > 0) - { - stackSwitch--; - } + oreDictText.drawTextBox(); + } - if(stackSwitch == 0 && iterStacks != null && iterStacks.size() > 0) - { - stackSwitch = 20; + @Override + public void updateScreen() { + super.updateScreen(); - if(stackIndex == -1 || stackIndex == iterStacks.size()-1) - { - stackIndex = 0; - } - else if(stackIndex < iterStacks.size()-1) - { - stackIndex++; - } + oreDictText.updateCursorCounter(); - renderStack = iterStacks.get(stackIndex); - } - else if(iterStacks != null && iterStacks.size() == 0) - { - renderStack = null; - } - } + if (ticker > 0) { + ticker--; + } else { + status = EnumColor.DARK_GREEN + LangUtils.localize("gui.allOK"); + } - @Override - protected void mouseClicked(int mouseX, int mouseY, int button) - { - super.mouseClicked(mouseX, mouseY, button); + if (stackSwitch > 0) { + stackSwitch--; + } - oreDictText.mouseClicked(mouseX, mouseY, button); + if (stackSwitch == 0 && iterStacks != null && iterStacks.size() > 0) { + stackSwitch = 20; - if(button == 0) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + if (stackIndex == -1 || stackIndex == iterStacks.size() - 1) { + stackIndex = 0; + } else if (stackIndex < iterStacks.size() - 1) { + stackIndex++; + } - if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) - { + renderStack = iterStacks.get(stackIndex); + } else if (iterStacks != null && iterStacks.size() == 0) { + renderStack = null; + } + } + + @Override + protected void mouseClicked(int mouseX, int mouseY, int button) { + super.mouseClicked(mouseX, mouseY, button); + + oreDictText.mouseClicked(mouseX, mouseY, button); + + if (button == 0) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + if (xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), isNew ? 5 : 0, 0, 0)); - } + Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage( + MinerGuiPacket.SERVER, Coord4D.get(tileEntity), isNew ? 5 : 0, 0, 0 + )); + } - if(xAxis >= 131 && xAxis <= 143 && yAxis >= 47 && yAxis <= 59) - { + if (xAxis >= 131 && xAxis <= 143 && yAxis >= 47 && yAxis <= 59) { SoundHandler.playSound("gui.button.press"); - setOreDictKey(); - } - - if(xAxis >= 148 && xAxis <= 162 && yAxis >= 45 && yAxis <= 59) - { - SoundHandler.playSound("gui.button.press"); - filter.requireStack = !filter.requireStack; - } - - if(xAxis >= 149 && xAxis <= 165 && yAxis >= 19 && yAxis <= 35) - { - boolean doNull = false; - ItemStack stack = mc.thePlayer.inventory.getItemStack(); - ItemStack toUse = null; + setOreDictKey(); + } - if(stack != null && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) - { - if(stack.getItem() instanceof ItemBlock) - { - if(Block.getBlockFromItem(stack.getItem()) != Blocks.bedrock) - { - toUse = stack.copy(); - toUse.stackSize = 1; - } - } - } - else if(stack == null && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) - { - doNull = true; - } + if (xAxis >= 148 && xAxis <= 162 && yAxis >= 45 && yAxis <= 59) { + SoundHandler.playSound("gui.button.press"); + filter.requireStack = !filter.requireStack; + } - if(toUse != null || doNull) - { - filter.replaceStack = toUse; - } + if (xAxis >= 149 && xAxis <= 165 && yAxis >= 19 && yAxis <= 35) { + boolean doNull = false; + ItemStack stack = mc.thePlayer.inventory.getItemStack(); + ItemStack toUse = null; + + if (stack != null && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + if (stack.getItem() instanceof ItemBlock) { + if (Block.getBlockFromItem(stack.getItem()) != Blocks.bedrock) { + toUse = stack.copy(); + toUse.stackSize = 1; + } + } + } else if (stack == null && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + doNull = true; + } + + if (toUse != null || doNull) { + filter.replaceStack = toUse; + } SoundHandler.playSound("gui.button.press"); - } - } - } + } + } + } - private void updateStackList(String oreName) - { - iterStacks = OreDictCache.getOreDictStacks(oreName, true); + private void updateStackList(String oreName) { + iterStacks = OreDictCache.getOreDictStacks(oreName, true); - stackSwitch = 0; - stackIndex = -1; - } + stackSwitch = 0; + stackIndex = -1; + } - private void setOreDictKey() - { - String oreName = oreDictText.getText(); + private void setOreDictKey() { + String oreName = oreDictText.getText(); - if(oreName == null || oreName.isEmpty()) - { - status = EnumColor.DARK_RED + LangUtils.localize("gui.oredictFilter.noKey"); - return; - } - else if(oreName.equals(filter.oreDictName)) - { - status = EnumColor.DARK_RED + LangUtils.localize("gui.oredictFilter.sameKey"); - return; - } + if (oreName == null || oreName.isEmpty()) { + status = EnumColor.DARK_RED + LangUtils.localize("gui.oredictFilter.noKey"); + return; + } else if (oreName.equals(filter.oreDictName)) { + status = EnumColor.DARK_RED + LangUtils.localize("gui.oredictFilter.sameKey"); + return; + } - updateStackList(oreName); + updateStackList(oreName); - filter.oreDictName = oreName; - oreDictText.setText(""); - } + filter.oreDictName = oreName; + oreDictText.setText(""); + } } diff --git a/src/main/java/mekanism/client/gui/GuiMatrixStats.java b/src/main/java/mekanism/client/gui/GuiMatrixStats.java index 2697af13c..3b325f832 100644 --- a/src/main/java/mekanism/client/gui/GuiMatrixStats.java +++ b/src/main/java/mekanism/client/gui/GuiMatrixStats.java @@ -2,6 +2,8 @@ package mekanism.client.gui; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.energy.IStrictEnergyStorage; import mekanism.api.util.ListUtils; import mekanism.client.gui.element.GuiElement.IInfoHandler; @@ -18,103 +20,149 @@ import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.entity.player.InventoryPlayer; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiMatrixStats extends GuiMekanism -{ - public TileEntityInductionCasing tileEntity; +public class GuiMatrixStats extends GuiMekanism { + public TileEntityInductionCasing tileEntity; - public GuiMatrixStats(InventoryPlayer inventory, TileEntityInductionCasing tentity) - { - super(tentity, new ContainerNull(inventory.player, tentity)); - tileEntity = tentity; - guiElements.add(new GuiMatrixTab(this, tileEntity, MatrixTab.MAIN, 6, MekanismUtils.getResource(ResourceType.GUI, "GuiNull.png"))); - guiElements.add(new GuiEnergyGauge(new IEnergyInfoHandler() - { - @Override - public IStrictEnergyStorage getEnergyStorage() - { - return tileEntity; - } - }, GuiEnergyGauge.Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiNull.png"), 6, 13)); - guiElements.add(new GuiRateBar(this, new IRateInfoHandler() - { - @Override - public String getTooltip() - { - return LangUtils.localize("gui.receiving") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.structure.lastInput) + "/t"; - } - - @Override - public double getLevel() - { - return tileEntity.structure.lastInput/tileEntity.structure.transferCap; - } - }, MekanismUtils.getResource(ResourceType.GUI, "GuiNull.png"), 30, 13)); - guiElements.add(new GuiRateBar(this, new IRateInfoHandler() - { - @Override - public String getTooltip() - { - return LangUtils.localize("gui.outputting") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.structure.lastOutput) + "/t"; - } - - @Override - public double getLevel() - { - return tileEntity.structure.lastOutput/tileEntity.structure.transferCap; - } - }, MekanismUtils.getResource(ResourceType.GUI, "GuiNull.png"), 38, 13)); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() - { - @Override - public List getInfo() - { - return ListUtils.asList( - LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), - LangUtils.localize("gui.input") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.structure.lastInput) + "/t", - LangUtils.localize("gui.output") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.structure.lastOutput) + "/t"); - } - }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiNull.png"))); - } + public GuiMatrixStats(InventoryPlayer inventory, TileEntityInductionCasing tentity) { + super(tentity, new ContainerNull(inventory.player, tentity)); + tileEntity = tentity; + guiElements.add(new GuiMatrixTab( + this, + tileEntity, + MatrixTab.MAIN, + 6, + MekanismUtils.getResource(ResourceType.GUI, "GuiNull.png") + )); + guiElements.add(new GuiEnergyGauge( + new IEnergyInfoHandler() { + @Override + public IStrictEnergyStorage getEnergyStorage() { + return tileEntity; + } + }, + GuiEnergyGauge.Type.STANDARD, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiNull.png"), + 6, + 13 + )); + guiElements.add(new GuiRateBar(this, new IRateInfoHandler() { + @Override + public String getTooltip() { + return LangUtils.localize("gui.receiving") + ": " + + MekanismUtils.getEnergyDisplay(tileEntity.structure.lastInput) + + "/t"; + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + @Override + public double getLevel() { + return tileEntity.structure.lastInput / tileEntity.structure.transferCap; + } + }, MekanismUtils.getResource(ResourceType.GUI, "GuiNull.png"), 30, 13)); + guiElements.add(new GuiRateBar(this, new IRateInfoHandler() { + @Override + public String getTooltip() { + return LangUtils.localize("gui.outputting") + ": " + + MekanismUtils.getEnergyDisplay(tileEntity.structure.lastOutput) + + "/t"; + } - String stats = LangUtils.localize("gui.matrixStats"); - - fontRendererObj.drawString(stats, (xSize/2)-(fontRendererObj.getStringWidth(stats)/2), 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("gui.input") + ":", 53, 26, 0x797979); - fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.structure.lastInput) + "/" + MekanismUtils.getEnergyDisplay(tileEntity.structure.transferCap), 59, 35, 0x404040); - fontRendererObj.drawString(LangUtils.localize("gui.output") + ":", 53, 46, 0x797979); - fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.structure.lastOutput) + "/" + MekanismUtils.getEnergyDisplay(tileEntity.structure.transferCap), 59, 55, 0x404040); - - fontRendererObj.drawString(LangUtils.localize("gui.dimensions") + ":", 8, 82, 0x797979); - fontRendererObj.drawString(tileEntity.structure.volWidth + " x " + tileEntity.structure.volHeight + " x " + tileEntity.structure.volLength, 14, 91, 0x404040); - fontRendererObj.drawString(LangUtils.localize("gui.constituents") + ":", 8, 102, 0x797979); - fontRendererObj.drawString(tileEntity.clientCells + " " + LangUtils.localize("gui.cells"), 14, 111, 0x404040); - fontRendererObj.drawString(tileEntity.clientProviders + " " + LangUtils.localize("gui.providers"), 14, 120, 0x404040); + @Override + public double getLevel() { + return tileEntity.structure.lastOutput / tileEntity.structure.transferCap; + } + }, MekanismUtils.getResource(ResourceType.GUI, "GuiNull.png"), 38, 13)); + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() { + return ListUtils.asList( + LangUtils.localize("gui.storing") + ": " + + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), + LangUtils.localize("gui.input") + ": " + + MekanismUtils.getEnergyDisplay(tileEntity.structure.lastInput) + + "/t", + LangUtils.localize("gui.output") + ": " + + MekanismUtils.getEnergyDisplay(tileEntity.structure.lastOutput) + + "/t" + ); + } + }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiNull.png"))); + } - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiNull.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } + String stats = LangUtils.localize("gui.matrixStats"); + + fontRendererObj.drawString( + stats, (xSize / 2) - (fontRendererObj.getStringWidth(stats) / 2), 6, 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.input") + ":", 53, 26, 0x797979 + ); + fontRendererObj.drawString( + MekanismUtils.getEnergyDisplay(tileEntity.structure.lastInput) + "/" + + MekanismUtils.getEnergyDisplay(tileEntity.structure.transferCap), + 59, + 35, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.output") + ":", 53, 46, 0x797979 + ); + fontRendererObj.drawString( + MekanismUtils.getEnergyDisplay(tileEntity.structure.lastOutput) + "/" + + MekanismUtils.getEnergyDisplay(tileEntity.structure.transferCap), + 59, + 55, + 0x404040 + ); + + fontRendererObj.drawString( + LangUtils.localize("gui.dimensions") + ":", 8, 82, 0x797979 + ); + fontRendererObj.drawString( + tileEntity.structure.volWidth + " x " + tileEntity.structure.volHeight + " x " + + tileEntity.structure.volLength, + 14, + 91, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.constituents") + ":", 8, 102, 0x797979 + ); + fontRendererObj.drawString( + tileEntity.clientCells + " " + LangUtils.localize("gui.cells"), + 14, + 111, + 0x404040 + ); + fontRendererObj.drawString( + tileEntity.clientProviders + " " + LangUtils.localize("gui.providers"), + 14, + 120, + 0x404040 + ); + + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiNull.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } } diff --git a/src/main/java/mekanism/client/gui/GuiMekanism.java b/src/main/java/mekanism/client/gui/GuiMekanism.java index 7faec85d0..989402380 100644 --- a/src/main/java/mekanism/client/gui/GuiMekanism.java +++ b/src/main/java/mekanism/client/gui/GuiMekanism.java @@ -17,272 +17,236 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; - import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; -public abstract class GuiMekanism extends GuiContainer implements IGuiWrapper -{ - public Set guiElements = new HashSet(); +public abstract class GuiMekanism extends GuiContainer implements IGuiWrapper { + public Set guiElements = new HashSet(); - private TileEntityContainerBlock tileEntity; + private TileEntityContainerBlock tileEntity; - //Try not to use - public GuiMekanism(Container container) - { - super(container); - } + //Try not to use + public GuiMekanism(Container container) { + super(container); + } - public GuiMekanism(TileEntityContainerBlock tile, Container container) - { - super(container); - tileEntity = tile; - } - - public float getNeededScale(String text, int maxX) - { - int length = fontRendererObj.getStringWidth(text); - - if(length <= maxX) - { - return 1; - } - else { - return (float)maxX/length; - } - } - - /** returns scale */ - public void renderScaledText(String text, int x, int y, int color, int maxX) - { - int length = fontRendererObj.getStringWidth(text); - - if(length <= maxX) - { - fontRendererObj.drawString(text, x, y, color); - } - else { - float scale = (float)maxX/length; - float reverse = 1/scale; - float yAdd = 4-(scale*8)/2F; - - GL11.glPushMatrix(); - - GL11.glScalef(scale, scale, scale); - fontRendererObj.drawString(text, (int)(x*reverse), (int)((y*reverse)+yAdd), color); - - GL11.glPopMatrix(); - } - } - - public static boolean isTextboxKey(char c, int i) - { - if(i == Keyboard.KEY_BACK || i == Keyboard.KEY_DELETE || i == Keyboard.KEY_LEFT || i == Keyboard.KEY_RIGHT || - i == Keyboard.KEY_END || i == Keyboard.KEY_HOME || i == Keyboard.KEY_BACK || c == 1 || c == 3 || c == 22 - || c == 24) - { - return true; - } - - return false; - } + public GuiMekanism(TileEntityContainerBlock tile, Container container) { + super(container); + tileEntity = tile; + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + public float getNeededScale(String text, int maxX) { + int length = fontRendererObj.getStringWidth(text); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + if (length <= maxX) { + return 1; + } else { + return (float) maxX / length; + } + } - for(GuiElement element : guiElements) - { - element.renderForeground(xAxis, yAxis); - } + /** returns scale */ + public void renderScaledText(String text, int x, int y, int color, int maxX) { + int length = fontRendererObj.getStringWidth(text); - if(tileEntity instanceof ISideConfiguration) - { - Slot hovering = null; + if (length <= maxX) { + fontRendererObj.drawString(text, x, y, color); + } else { + float scale = (float) maxX / length; + float reverse = 1 / scale; + float yAdd = 4 - (scale * 8) / 2F; - for(int i = 0; i < inventorySlots.inventorySlots.size(); i++) - { - Slot slot = (Slot)inventorySlots.inventorySlots.get(i); + GL11.glPushMatrix(); - if(isMouseOverSlot(slot, mouseX, mouseY)) - { - hovering = slot; - break; - } - } + GL11.glScalef(scale, scale, scale); + fontRendererObj.drawString( + text, (int) (x * reverse), (int) ((y * reverse) + yAdd), color + ); - ItemStack stack = mc.thePlayer.inventory.getItemStack(); + GL11.glPopMatrix(); + } + } - if(stack != null && stack.getItem() instanceof ItemConfigurator && hovering != null) - { - SideData data = getFromSlot(hovering); + public static boolean isTextboxKey(char c, int i) { + if (i == Keyboard.KEY_BACK || i == Keyboard.KEY_DELETE || i == Keyboard.KEY_LEFT + || i == Keyboard.KEY_RIGHT || i == Keyboard.KEY_END || i == Keyboard.KEY_HOME + || i == Keyboard.KEY_BACK || c == 1 || c == 3 || c == 22 || c == 24) { + return true; + } - if(data != null) - { - drawCreativeTabHoveringText(data.color + data.localize() + " (" + data.color.getName() + ")", xAxis, yAxis); - } - } - } - } - - public TileEntityContainerBlock getTileEntity() - { - return tileEntity; - } + return false; + } - private SideData getFromSlot(Slot slot) - { - if(slot.slotNumber < tileEntity.getSizeInventory()) - { - ISideConfiguration config = (ISideConfiguration)tileEntity; + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + super.drawGuiContainerForegroundLayer(mouseX, mouseY); - for(SideData data : config.getConfig().getOutputs(TransmissionType.ITEM)) - { - for(int id : data.availableSlots) - { - if(id == slot.getSlotIndex()) - { - return data; - } - } - } - } + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - return null; - } + for (GuiElement element : guiElements) { + element.renderForeground(xAxis, yAxis); + } - protected boolean isMouseOverSlot(Slot slot, int mouseX, int mouseY) - { - return func_146978_c(slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, mouseX, mouseY);//isPointInRegion - } + if (tileEntity instanceof ISideConfiguration) { + Slot hovering = null; - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; + for (int i = 0; i < inventorySlots.inventorySlots.size(); i++) { + Slot slot = (Slot) inventorySlots.inventorySlots.get(i); - int xAxis = mouseX - guiWidth; - int yAxis = mouseY - guiHeight; + if (isMouseOverSlot(slot, mouseX, mouseY)) { + hovering = slot; + break; + } + } - for(GuiElement element : guiElements) - { - element.renderBackground(xAxis, yAxis, guiWidth, guiHeight); - } - } + ItemStack stack = mc.thePlayer.inventory.getItemStack(); - @Override - protected void mouseClicked(int mouseX, int mouseY, int button) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + if (stack != null && stack.getItem() instanceof ItemConfigurator + && hovering != null) { + SideData data = getFromSlot(hovering); - for(GuiElement element : guiElements) - { - element.preMouseClicked(xAxis, yAxis, button); - } + if (data != null) { + drawCreativeTabHoveringText( + data.color + data.localize() + " (" + data.color.getName() + ")", + xAxis, + yAxis + ); + } + } + } + } - super.mouseClicked(mouseX, mouseY, button); + public TileEntityContainerBlock getTileEntity() { + return tileEntity; + } - for(GuiElement element : guiElements) - { - element.mouseClicked(xAxis, yAxis, button); - } - } + private SideData getFromSlot(Slot slot) { + if (slot.slotNumber < tileEntity.getSizeInventory()) { + ISideConfiguration config = (ISideConfiguration) tileEntity; - @Override - protected void drawCreativeTabHoveringText(String text, int x, int y) - { - func_146283_a(Arrays.asList(new String[] {text}), x, y); - } + for (SideData data : config.getConfig().getOutputs(TransmissionType.ITEM)) { + for (int id : data.availableSlots) { + if (id == slot.getSlotIndex()) { + return data; + } + } + } + } - @Override - protected void func_146283_a(List list, int x, int y) - { - GL11.glPushAttrib(GL11.GL_ENABLE_BIT + GL11.GL_LIGHTING_BIT); - super.func_146283_a(list, x, y); - GL11.glPopAttrib(); - } + return null; + } - @Override - public void drawTexturedRect(int x, int y, int u, int v, int w, int h) - { - drawTexturedModalRect(x, y, u, v, w, h); - } + protected boolean isMouseOverSlot(Slot slot, int mouseX, int mouseY) { + return func_146978_c( + slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, mouseX, mouseY + ); //isPointInRegion + } - @Override - public void drawTexturedRectFromIcon(int x, int y, IIcon icon, int w, int h) - { - drawTexturedModelRectFromIcon(x, y, icon, w, h); - } + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; - @Override - public void displayTooltip(String s, int x, int y) - { - drawCreativeTabHoveringText(s, x, y); - } + int xAxis = mouseX - guiWidth; + int yAxis = mouseY - guiHeight; - @Override - public void displayTooltips(List list, int xAxis, int yAxis) - { - func_146283_a(list, xAxis, yAxis); - } + for (GuiElement element : guiElements) { + element.renderBackground(xAxis, yAxis, guiWidth, guiHeight); + } + } - @Override - public FontRenderer getFont() - { - return fontRendererObj; - } - - @Override - protected void mouseClickMove(int mouseX, int mouseY, int button, long ticks) - { - super.mouseClickMove(mouseX, mouseY, button, ticks); + @Override + protected void mouseClicked(int mouseX, int mouseY, int button) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + for (GuiElement element : guiElements) { + element.preMouseClicked(xAxis, yAxis, button); + } - for(GuiElement element : guiElements) - { - element.mouseClickMove(xAxis, yAxis, button, ticks); - } - } + super.mouseClicked(mouseX, mouseY, button); - @Override - protected void mouseMovedOrUp(int mouseX, int mouseY, int type) - { - super.mouseMovedOrUp(mouseX, mouseY, type); - - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + for (GuiElement element : guiElements) { + element.mouseClicked(xAxis, yAxis, button); + } + } - for(GuiElement element : guiElements) - { - element.mouseMovedOrUp(xAxis, yAxis, type); - } - } - - public void handleMouse(Slot slot, int slotIndex, int button, int modifier) - { - handleMouseClick(slot, slotIndex, button, modifier); - } - - public int getXPos() - { - return (width - xSize) / 2; - } - - public int getYPos() - { - return (height - ySize) / 2; - } + @Override + protected void drawCreativeTabHoveringText(String text, int x, int y) { + func_146283_a(Arrays.asList(new String[] { text }), x, y); + } - protected FontRenderer getFontRenderer() - { - return fontRendererObj; - } + @Override + protected void func_146283_a(List list, int x, int y) { + GL11.glPushAttrib(GL11.GL_ENABLE_BIT + GL11.GL_LIGHTING_BIT); + super.func_146283_a(list, x, y); + GL11.glPopAttrib(); + } + + @Override + public void drawTexturedRect(int x, int y, int u, int v, int w, int h) { + drawTexturedModalRect(x, y, u, v, w, h); + } + + @Override + public void drawTexturedRectFromIcon(int x, int y, IIcon icon, int w, int h) { + drawTexturedModelRectFromIcon(x, y, icon, w, h); + } + + @Override + public void displayTooltip(String s, int x, int y) { + drawCreativeTabHoveringText(s, x, y); + } + + @Override + public void displayTooltips(List list, int xAxis, int yAxis) { + func_146283_a(list, xAxis, yAxis); + } + + @Override + public FontRenderer getFont() { + return fontRendererObj; + } + + @Override + protected void mouseClickMove(int mouseX, int mouseY, int button, long ticks) { + super.mouseClickMove(mouseX, mouseY, button, ticks); + + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + for (GuiElement element : guiElements) { + element.mouseClickMove(xAxis, yAxis, button, ticks); + } + } + + @Override + protected void mouseMovedOrUp(int mouseX, int mouseY, int type) { + super.mouseMovedOrUp(mouseX, mouseY, type); + + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + for (GuiElement element : guiElements) { + element.mouseMovedOrUp(xAxis, yAxis, type); + } + } + + public void handleMouse(Slot slot, int slotIndex, int button, int modifier) { + handleMouseClick(slot, slotIndex, button, modifier); + } + + public int getXPos() { + return (width - xSize) / 2; + } + + public int getYPos() { + return (height - ySize) / 2; + } + + protected FontRenderer getFontRenderer() { + return fontRendererObj; + } } diff --git a/src/main/java/mekanism/client/gui/GuiMekanismConfig.java b/src/main/java/mekanism/client/gui/GuiMekanismConfig.java index 546ade237..46883ac34 100644 --- a/src/main/java/mekanism/client/gui/GuiMekanismConfig.java +++ b/src/main/java/mekanism/client/gui/GuiMekanismConfig.java @@ -3,117 +3,161 @@ package mekanism.client.gui; import java.util.ArrayList; import java.util.List; -import mekanism.common.Mekanism; -import mekanism.common.util.LangUtils; -import net.minecraft.client.gui.GuiScreen; -import net.minecraftforge.common.config.ConfigElement; -import net.minecraftforge.common.config.Configuration; import cpw.mods.fml.client.config.DummyConfigElement.DummyCategoryElement; import cpw.mods.fml.client.config.GuiConfig; import cpw.mods.fml.client.config.GuiConfigEntries; import cpw.mods.fml.client.config.GuiConfigEntries.CategoryEntry; import cpw.mods.fml.client.config.IConfigElement; +import mekanism.common.Mekanism; +import mekanism.common.util.LangUtils; +import net.minecraft.client.gui.GuiScreen; +import net.minecraftforge.common.config.ConfigElement; +import net.minecraftforge.common.config.Configuration; -public class GuiMekanismConfig extends GuiConfig -{ - public GuiMekanismConfig(GuiScreen parent) - { - super(parent, getConfigElements(), "Mekanism", false, false, "Mekanism"); - } +public class GuiMekanismConfig extends GuiConfig { + public GuiMekanismConfig(GuiScreen parent) { + super(parent, getConfigElements(), "Mekanism", false, false, "Mekanism"); + } - private static List getConfigElements() - { - List list = new ArrayList(); - list.add(new DummyCategoryElement(LangUtils.localize("mekanism.configgui.ctgy.general"), "mekanism.configgui.ctgy.general", GeneralEntry.class)); - list.add(new DummyCategoryElement(LangUtils.localize("mekanism.configgui.ctgy.machines"), "mekanism.configgui.ctgy.machines", MachinesEntry.class)); - list.add(new DummyCategoryElement(LangUtils.localize("mekanism.configgui.ctgy.tier"), "mekanism.configgui.ctgy.tier", TierEntry.class)); - list.add(new DummyCategoryElement(LangUtils.localize("mekanism.configgui.ctgy.usage"), "mekanism.configgui.ctgy.usage", UsageEntry.class)); - list.add(new DummyCategoryElement(LangUtils.localize("mekanism.configgui.ctgy.client"), "mekanism.configgui.ctgy.client", ClientEntry.class)); - return list; - } + private static List getConfigElements() { + List list = new ArrayList(); + list.add(new DummyCategoryElement( + LangUtils.localize("mekanism.configgui.ctgy.general"), + "mekanism.configgui.ctgy.general", + GeneralEntry.class + )); + list.add(new DummyCategoryElement( + LangUtils.localize("mekanism.configgui.ctgy.machines"), + "mekanism.configgui.ctgy.machines", + MachinesEntry.class + )); + list.add(new DummyCategoryElement( + LangUtils.localize("mekanism.configgui.ctgy.tier"), + "mekanism.configgui.ctgy.tier", + TierEntry.class + )); + list.add(new DummyCategoryElement( + LangUtils.localize("mekanism.configgui.ctgy.usage"), + "mekanism.configgui.ctgy.usage", + UsageEntry.class + )); + list.add(new DummyCategoryElement( + LangUtils.localize("mekanism.configgui.ctgy.client"), + "mekanism.configgui.ctgy.client", + ClientEntry.class + )); + return list; + } - public static class GeneralEntry extends CategoryEntry - { - public GeneralEntry(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement prop) - { - super(owningScreen, owningEntryList, prop); - } + public static class GeneralEntry extends CategoryEntry { + public GeneralEntry( + GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement prop + ) { + super(owningScreen, owningEntryList, prop); + } - @Override - protected GuiScreen buildChildScreen() - { - return new GuiConfig(owningScreen, - new ConfigElement(Mekanism.configuration.getCategory(Configuration.CATEGORY_GENERAL)).getChildElements(), - owningScreen.modID, Configuration.CATEGORY_GENERAL, false, false, - GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString())); - } - } - - public static class MachinesEntry extends CategoryEntry - { - public MachinesEntry(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement prop) - { - super(owningScreen, owningEntryList, prop); - } + @Override + protected GuiScreen buildChildScreen() { + return new GuiConfig( + owningScreen, + new ConfigElement( + Mekanism.configuration.getCategory(Configuration.CATEGORY_GENERAL) + ) + .getChildElements(), + owningScreen.modID, + Configuration.CATEGORY_GENERAL, + false, + false, + GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString()) + ); + } + } - @Override - protected GuiScreen buildChildScreen() - { - return new GuiConfig(owningScreen, - new ConfigElement(Mekanism.configuration.getCategory("machines")).getChildElements(), - owningScreen.modID, Configuration.CATEGORY_GENERAL, false, false, - GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString())); - } - } - - public static class TierEntry extends CategoryEntry - { - public TierEntry(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement prop) - { - super(owningScreen, owningEntryList, prop); - } + public static class MachinesEntry extends CategoryEntry { + public MachinesEntry( + GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement prop + ) { + super(owningScreen, owningEntryList, prop); + } - @Override - protected GuiScreen buildChildScreen() - { - return new GuiConfig(owningScreen, - new ConfigElement(Mekanism.configuration.getCategory("tier")).getChildElements(), - owningScreen.modID, Configuration.CATEGORY_GENERAL, false, false, - GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString())); - } - } + @Override + protected GuiScreen buildChildScreen() { + return new GuiConfig( + owningScreen, + new ConfigElement(Mekanism.configuration.getCategory("machines")) + .getChildElements(), + owningScreen.modID, + Configuration.CATEGORY_GENERAL, + false, + false, + GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString()) + ); + } + } - public static class UsageEntry extends CategoryEntry - { - public UsageEntry(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement prop) - { - super(owningScreen, owningEntryList, prop); - } + public static class TierEntry extends CategoryEntry { + public TierEntry( + GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement prop + ) { + super(owningScreen, owningEntryList, prop); + } - @Override - protected GuiScreen buildChildScreen() - { - return new GuiConfig(owningScreen, - new ConfigElement(Mekanism.configuration.getCategory("usage")).getChildElements(), - owningScreen.modID, Configuration.CATEGORY_GENERAL, false, false, - GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString())); - } - } + @Override + protected GuiScreen buildChildScreen() { + return new GuiConfig( + owningScreen, + new ConfigElement(Mekanism.configuration.getCategory("tier")) + .getChildElements(), + owningScreen.modID, + Configuration.CATEGORY_GENERAL, + false, + false, + GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString()) + ); + } + } - public static class ClientEntry extends CategoryEntry - { - public ClientEntry(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement prop) - { - super(owningScreen, owningEntryList, prop); - } + public static class UsageEntry extends CategoryEntry { + public UsageEntry( + GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement prop + ) { + super(owningScreen, owningEntryList, prop); + } - @Override - protected GuiScreen buildChildScreen() - { - return new GuiConfig(owningScreen, - new ConfigElement(Mekanism.configuration.getCategory("client")).getChildElements(), - owningScreen.modID, "client", false, false, - GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString())); - } - } + @Override + protected GuiScreen buildChildScreen() { + return new GuiConfig( + owningScreen, + new ConfigElement(Mekanism.configuration.getCategory("usage")) + .getChildElements(), + owningScreen.modID, + Configuration.CATEGORY_GENERAL, + false, + false, + GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString()) + ); + } + } + + public static class ClientEntry extends CategoryEntry { + public ClientEntry( + GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement prop + ) { + super(owningScreen, owningEntryList, prop); + } + + @Override + protected GuiScreen buildChildScreen() { + return new GuiConfig( + owningScreen, + new ConfigElement(Mekanism.configuration.getCategory("client")) + .getChildElements(), + owningScreen.modID, + "client", + false, + false, + GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString()) + ); + } + } } diff --git a/src/main/java/mekanism/client/gui/GuiMetallurgicInfuser.java b/src/main/java/mekanism/client/gui/GuiMetallurgicInfuser.java index 072c76765..22735984f 100644 --- a/src/main/java/mekanism/client/gui/GuiMetallurgicInfuser.java +++ b/src/main/java/mekanism/client/gui/GuiMetallurgicInfuser.java @@ -3,6 +3,8 @@ package mekanism.client.gui; import java.util.ArrayList; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.util.ListUtils; import mekanism.client.gui.element.GuiElement.IInfoHandler; @@ -29,106 +31,184 @@ import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.entity.player.InventoryPlayer; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiMetallurgicInfuser extends GuiMekanism -{ - public TileEntityMetallurgicInfuser tileEntity; +public class GuiMetallurgicInfuser extends GuiMekanism { + public TileEntityMetallurgicInfuser tileEntity; - public GuiMetallurgicInfuser(InventoryPlayer inventory, TileEntityMetallurgicInfuser tentity) - { - super(tentity, new ContainerMetallurgicInfuser(inventory, tentity)); - tileEntity = tentity; + public GuiMetallurgicInfuser( + InventoryPlayer inventory, TileEntityMetallurgicInfuser tentity + ) { + super(tentity, new ContainerMetallurgicInfuser(inventory, tentity)); + tileEntity = tentity; - guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png"))); - guiElements.add(new GuiUpgradeTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png"))); - guiElements.add(new GuiSecurityTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png"))); - guiElements.add(new GuiSideConfigurationTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png"))); - guiElements.add(new GuiTransporterConfigTab(this, 34, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png"))); - guiElements.add(new GuiPowerBar(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png"), 164, 15)); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() { - @Override - public List getInfo() - { - String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.energyPerTick); - return ListUtils.asList(LangUtils.localize("gui.using") + ": " + multiplier + "/t", LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); - } - }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png"))); + guiElements.add(new GuiRedstoneControl( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png") + )); + guiElements.add(new GuiUpgradeTab( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png") + )); + guiElements.add(new GuiSecurityTab( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png") + )); + guiElements.add(new GuiSideConfigurationTab( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png") + )); + guiElements.add(new GuiTransporterConfigTab( + this, + 34, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png") + )); + guiElements.add(new GuiPowerBar( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png"), + 164, + 15 + )); + guiElements.add(new GuiEnergyInfo( + new IInfoHandler() { + @Override + public List getInfo() { + String multiplier + = MekanismUtils.getEnergyDisplay(tileEntity.energyPerTick); + return ListUtils.asList( + LangUtils.localize("gui.using") + ": " + multiplier + "/t", + LangUtils.localize("gui.needed") + ": " + + MekanismUtils.getEnergyDisplay( + tileEntity.getMaxEnergy() - tileEntity.getEnergy() + ) + ); + } + }, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png") + )); - guiElements.add(new GuiSlot(SlotType.EXTRA, this, MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png"), 16, 34)); - guiElements.add(new GuiSlot(SlotType.INPUT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png"), 50, 42)); - guiElements.add(new GuiSlot(SlotType.POWER, this, MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png"), 142, 34).with(SlotOverlay.POWER)); - guiElements.add(new GuiSlot(SlotType.OUTPUT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png"), 108, 42)); + guiElements.add(new GuiSlot( + SlotType.EXTRA, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png"), + 16, + 34 + )); + guiElements.add(new GuiSlot( + SlotType.INPUT, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png"), + 50, + 42 + )); + guiElements.add( + new GuiSlot( + SlotType.POWER, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png"), + 142, + 34 + ) + .with(SlotOverlay.POWER) + ); + guiElements.add(new GuiSlot( + SlotType.OUTPUT, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png"), + 108, + 42 + )); - guiElements.add(new GuiProgress(new IProgressInfoHandler() - { - @Override - public double getProgress() - { - return tileEntity.getScaledProgress(); - } - }, ProgressBar.MEDIUM, this, MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png"), 70, 46)); - } + guiElements.add(new GuiProgress( + new IProgressInfoHandler() { + @Override + public double getProgress() { + return tileEntity.getScaledProgress(); + } + }, + ProgressBar.MEDIUM, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png"), + 70, + 46 + )); + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - fontRendererObj.drawString(tileEntity.getInventoryName(), 45, 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); + fontRendererObj.drawString(tileEntity.getInventoryName(), 45, 6, 0x404040); + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040 + ); - if(xAxis >= 7 && xAxis <= 11 && yAxis >= 17 && yAxis <= 69) - { - drawCreativeTabHoveringText(tileEntity.infuseStored.type != null ? tileEntity.infuseStored.type.getLocalizedName() + ": " + tileEntity.infuseStored.amount : LangUtils.localize("gui.empty"), xAxis, yAxis); - } + if (xAxis >= 7 && xAxis <= 11 && yAxis >= 17 && yAxis <= 69) { + drawCreativeTabHoveringText( + tileEntity.infuseStored.type != null + ? tileEntity.infuseStored.type.getLocalizedName() + ": " + + tileEntity.infuseStored.amount + : LangUtils.localize("gui.empty"), + xAxis, + yAxis + ); + } - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - if(tileEntity.infuseStored.type != null) - { - mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture()); - int displayInt = tileEntity.getScaledInfuseLevel(52); - drawTexturedRectFromIcon(guiWidth + 7, guiHeight + 17 + 52 - displayInt, tileEntity.infuseStored.type.icon, 4, displayInt); - } + if (tileEntity.infuseStored.type != null) { + mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture()); + int displayInt = tileEntity.getScaledInfuseLevel(52); + drawTexturedRectFromIcon( + guiWidth + 7, + guiHeight + 17 + 52 - displayInt, + tileEntity.infuseStored.type.icon, + 4, + displayInt + ); + } - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } - @Override - protected void mouseClicked(int x, int y, int button) - { - super.mouseClicked(x, y, button); + @Override + protected void mouseClicked(int x, int y, int button) { + super.mouseClicked(x, y, button); - if(button == 0) - { - int xAxis = (x - (width - xSize) / 2); - int yAxis = (y - (height - ySize) / 2); + if (button == 0) { + int xAxis = (x - (width - xSize) / 2); + int yAxis = (y - (height - ySize) / 2); - if(xAxis > 148 && xAxis < 168 && yAxis > 73 && yAxis < 82) - { - ArrayList data = new ArrayList(); - data.add(0); + if (xAxis > 148 && xAxis < 168 && yAxis > 73 && yAxis < 82) { + ArrayList data = new ArrayList(); + data.add(0); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - SoundHandler.playSound("gui.button.press"); - } - } - } + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); + SoundHandler.playSound("gui.button.press"); + } + } + } } diff --git a/src/main/java/mekanism/client/gui/GuiOredictionificator.java b/src/main/java/mekanism/client/gui/GuiOredictionificator.java index f18638c1a..65cf05ab6 100644 --- a/src/main/java/mekanism/client/gui/GuiOredictionificator.java +++ b/src/main/java/mekanism/client/gui/GuiOredictionificator.java @@ -4,6 +4,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.client.gui.element.GuiProgress; @@ -28,252 +30,277 @@ import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiOredictionificator extends GuiMekanism -{ - public TileEntityOredictionificator tileEntity; - - public Map renderStacks = new HashMap(); - - public boolean isDragging = false; +public class GuiOredictionificator extends GuiMekanism { + public TileEntityOredictionificator tileEntity; - public int dragOffset = 0; - - public float scroll; - - public GuiOredictionificator(InventoryPlayer inventory, TileEntityOredictionificator tentity) - { - super(tentity, new ContainerOredictionificator(inventory, tentity)); - tileEntity = tentity; - - guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiOredictionificator.png"))); - guiElements.add(new GuiSecurityTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiOredictionificator.png"))); - guiElements.add(new GuiProgress(new IProgressInfoHandler() - { - @Override - public double getProgress() - { - return tileEntity.didProcess ? 1 : 0; - } - }, ProgressBar.LARGE_RIGHT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiOredictionificator.png"), 62, 118)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiOredictionificator.png"), 25, 114)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiOredictionificator.png"), 133, 114)); - - ySize+=64; - } - - public int getScroll() - { - return Math.max(Math.min((int)(scroll*73), 73), 0); - } - - public int getFilterIndex() - { - if(tileEntity.filters.size() <= 3) - { - return 0; - } + public Map renderStacks + = new HashMap(); - return (int)((tileEntity.filters.size()*scroll) - ((3F/(float)tileEntity.filters.size()))*scroll); - } - - @Override - public void initGui() - { - super.initGui(); + public boolean isDragging = false; - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; + public int dragOffset = 0; - buttonList.clear(); - buttonList.add(new GuiButton(0, guiWidth + 10, guiHeight + 86, 142, 20, LangUtils.localize("gui.newFilter"))); - } - - @Override - protected void actionPerformed(GuiButton guibutton) - { - super.actionPerformed(guibutton); + public float scroll; - if(guibutton.id == 0) - { - Mekanism.packetHandler.sendToServer(new OredictionificatorGuiMessage(OredictionificatorGuiPacket.SERVER, Coord4D.get(tileEntity), 1, 0, 0)); - } - } - - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + public GuiOredictionificator( + InventoryPlayer inventory, TileEntityOredictionificator tentity + ) { + super(tentity, new ContainerOredictionificator(inventory, tentity)); + tileEntity = tentity; - fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize/2)-(fontRendererObj.getStringWidth(tileEntity.getInventoryName())/2), 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); + guiElements.add(new GuiRedstoneControl( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiOredictionificator.png") + )); + guiElements.add(new GuiSecurityTab( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiOredictionificator.png") + )); + guiElements.add(new GuiProgress( + new IProgressInfoHandler() { + @Override + public double getProgress() { + return tileEntity.didProcess ? 1 : 0; + } + }, + ProgressBar.LARGE_RIGHT, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiOredictionificator.png"), + 62, + 118 + )); + guiElements.add(new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiOredictionificator.png"), + 25, + 114 + )); + guiElements.add(new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiOredictionificator.png"), + 133, + 114 + )); - for(int i = 0; i < 3; i++) - { - if(tileEntity.filters.get(getFilterIndex()+i) != null) - { - OredictionificatorFilter filter = tileEntity.filters.get(getFilterIndex()+i); - int yStart = i*22 + 18; - - if(!renderStacks.containsKey(filter)) - { - updateRenderStacks(); - } - - ItemStack stack = renderStacks.get(filter); - - if(stack != null) - { - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_LIGHTING); - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), stack, 13, yStart + 3); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } + ySize += 64; + } - fontRendererObj.drawString(LangUtils.localize("gui.filter"), 32, yStart + 2, 0x404040); - renderScaledText(filter.filter, 32, yStart + 2 + 9, 0x404040, 117); - } - } - - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + public int getScroll() { + return Math.max(Math.min((int) (scroll * 73), 73), 0); + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiOredictionificator.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + public int getFilterIndex() { + if (tileEntity.filters.size() <= 3) { + return 0; + } - int xAxis = mouseX - guiWidth; - int yAxis = mouseY - guiHeight; - - drawTexturedModalRect(guiWidth + 154, guiHeight + 18 + getScroll(), 232, 0, 12, 15); - - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - - for(int i = 0; i < 3; i++) - { - if(tileEntity.filters.get(getFilterIndex()+i) != null) - { - int yStart = i*22 + 18; - boolean mouseOver = xAxis > 10 && xAxis <= 152 && yAxis > yStart && yAxis <= yStart+22; - - if(mouseOver) - { - MekanismRenderer.color(EnumColor.GREY, 3.0F); - } - - drawTexturedModalRect(guiWidth + 10, guiHeight + yStart, 0, 230, 142, 22); - - MekanismRenderer.resetColor(); - } - } - } - - @Override - public void mouseClicked(int mouseX, int mouseY, int button) - { - super.mouseClicked(mouseX, mouseY, button); + return (int + ) ((tileEntity.filters.size() * scroll) + - ((3F / (float) tileEntity.filters.size())) * scroll); + } - if(button == 0) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + @Override + public void initGui() { + super.initGui(); - if(xAxis >= 154 && xAxis <= 166 && yAxis >= getScroll()+18 && yAxis <= getScroll()+18+15) - { - if(tileEntity.filters.size()>3) - { - dragOffset = yAxis - (getScroll()+18); - isDragging = true; - } - else { - scroll = 0; - } - } + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; - for(int i = 0; i < 3; i++) - { - if(tileEntity.filters.get(getFilterIndex()+i) != null) - { - int yStart = i*22 + 18; + buttonList.clear(); + buttonList.add(new GuiButton( + 0, guiWidth + 10, guiHeight + 86, 142, 20, LangUtils.localize("gui.newFilter") + )); + } - if(xAxis > 10 && xAxis <= 152 && yAxis > yStart && yAxis <= yStart+22) - { - OredictionificatorFilter filter = tileEntity.filters.get(getFilterIndex()+i); + @Override + protected void actionPerformed(GuiButton guibutton) { + super.actionPerformed(guibutton); + + if (guibutton.id == 0) { + Mekanism.packetHandler.sendToServer(new OredictionificatorGuiMessage( + OredictionificatorGuiPacket.SERVER, Coord4D.get(tileEntity), 1, 0, 0 + )); + } + } + + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + fontRendererObj.drawString( + tileEntity.getInventoryName(), + (xSize / 2) + - (fontRendererObj.getStringWidth(tileEntity.getInventoryName()) / 2), + 6, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040 + ); + + for (int i = 0; i < 3; i++) { + if (tileEntity.filters.get(getFilterIndex() + i) != null) { + OredictionificatorFilter filter + = tileEntity.filters.get(getFilterIndex() + i); + int yStart = i * 22 + 18; + + if (!renderStacks.containsKey(filter)) { + updateRenderStacks(); + } + + ItemStack stack = renderStacks.get(filter); + + if (stack != null) { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_LIGHTING); + itemRender.renderItemAndEffectIntoGUI( + fontRendererObj, mc.getTextureManager(), stack, 13, yStart + 3 + ); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + + fontRendererObj.drawString( + LangUtils.localize("gui.filter"), 32, yStart + 2, 0x404040 + ); + renderScaledText(filter.filter, 32, yStart + 2 + 9, 0x404040, 117); + } + } + + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiOredictionificator.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int xAxis = mouseX - guiWidth; + int yAxis = mouseY - guiHeight; + + drawTexturedModalRect( + guiWidth + 154, guiHeight + 18 + getScroll(), 232, 0, 12, 15 + ); + + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + + for (int i = 0; i < 3; i++) { + if (tileEntity.filters.get(getFilterIndex() + i) != null) { + int yStart = i * 22 + 18; + boolean mouseOver = xAxis > 10 && xAxis <= 152 && yAxis > yStart + && yAxis <= yStart + 22; + + if (mouseOver) { + MekanismRenderer.color(EnumColor.GREY, 3.0F); + } + + drawTexturedModalRect(guiWidth + 10, guiHeight + yStart, 0, 230, 142, 22); + + MekanismRenderer.resetColor(); + } + } + } + + @Override + public void mouseClicked(int mouseX, int mouseY, int button) { + super.mouseClicked(mouseX, mouseY, button); + + if (button == 0) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + if (xAxis >= 154 && xAxis <= 166 && yAxis >= getScroll() + 18 + && yAxis <= getScroll() + 18 + 15) { + if (tileEntity.filters.size() > 3) { + dragOffset = yAxis - (getScroll() + 18); + isDragging = true; + } else { + scroll = 0; + } + } + + for (int i = 0; i < 3; i++) { + if (tileEntity.filters.get(getFilterIndex() + i) != null) { + int yStart = i * 22 + 18; + + if (xAxis > 10 && xAxis <= 152 && yAxis > yStart + && yAxis <= yStart + 22) { + OredictionificatorFilter filter + = tileEntity.filters.get(getFilterIndex() + i); SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new OredictionificatorGuiMessage(OredictionificatorGuiPacket.SERVER_INDEX, Coord4D.get(tileEntity), 1, getFilterIndex()+i, 0)); - } - } - } - } - } - - @Override - protected void mouseClickMove(int mouseX, int mouseY, int button, long ticks) - { - super.mouseClickMove(mouseX, mouseY, button, ticks); + Mekanism.packetHandler.sendToServer( + new OredictionificatorGuiMessage( + OredictionificatorGuiPacket.SERVER_INDEX, + Coord4D.get(tileEntity), + 1, + getFilterIndex() + i, + 0 + ) + ); + } + } + } + } + } - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + @Override + protected void mouseClickMove(int mouseX, int mouseY, int button, long ticks) { + super.mouseClickMove(mouseX, mouseY, button, ticks); - if(isDragging) - { - scroll = Math.min(Math.max((float)(yAxis-18-dragOffset)/73F, 0), 1); - } - } - - @Override - protected void mouseMovedOrUp(int x, int y, int type) - { - super.mouseMovedOrUp(x, y, type); + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - if(type == 0 && isDragging) - { - dragOffset = 0; - isDragging = false; - } - } - - public void updateRenderStacks() - { - renderStacks.clear(); - - for(OredictionificatorFilter filter : tileEntity.filters) - { - if(filter.filter == null || filter.filter.isEmpty()) - { - renderStacks.put(filter, null); - continue; - } - - List stacks = OreDictionary.getOres(filter.filter); - - if(stacks.isEmpty()) - { - renderStacks.put(filter, null); - continue; - } - - if(stacks.size()-1 >= filter.index) - { - renderStacks.put(filter, stacks.get(filter.index).copy()); - } - else { - renderStacks.put(filter, null); - } - } - } + if (isDragging) { + scroll = Math.min(Math.max((float) (yAxis - 18 - dragOffset) / 73F, 0), 1); + } + } + + @Override + protected void mouseMovedOrUp(int x, int y, int type) { + super.mouseMovedOrUp(x, y, type); + + if (type == 0 && isDragging) { + dragOffset = 0; + isDragging = false; + } + } + + public void updateRenderStacks() { + renderStacks.clear(); + + for (OredictionificatorFilter filter : tileEntity.filters) { + if (filter.filter == null || filter.filter.isEmpty()) { + renderStacks.put(filter, null); + continue; + } + + List stacks = OreDictionary.getOres(filter.filter); + + if (stacks.isEmpty()) { + renderStacks.put(filter, null); + continue; + } + + if (stacks.size() - 1 >= filter.index) { + renderStacks.put(filter, stacks.get(filter.index).copy()); + } else { + renderStacks.put(filter, null); + } + } + } } diff --git a/src/main/java/mekanism/client/gui/GuiOredictionificatorFilter.java b/src/main/java/mekanism/client/gui/GuiOredictionificatorFilter.java index 5535de6b6..8a581d5a3 100644 --- a/src/main/java/mekanism/client/gui/GuiOredictionificatorFilter.java +++ b/src/main/java/mekanism/client/gui/GuiOredictionificatorFilter.java @@ -2,6 +2,8 @@ package mekanism.client.gui; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.client.sound.SoundHandler; import mekanism.common.Mekanism; @@ -19,370 +21,341 @@ import net.minecraft.client.gui.GuiTextField; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; - import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiOredictionificatorFilter extends GuiMekanism -{ - public TileEntityOredictionificator tileEntity; - - public OredictionificatorFilter origFilter; +public class GuiOredictionificatorFilter extends GuiMekanism { + public TileEntityOredictionificator tileEntity; - public OredictionificatorFilter filter = new OredictionificatorFilter(); - - public GuiTextField filterText; - - public boolean isNew; - - public ItemStack renderStack; - - public GuiOredictionificatorFilter(EntityPlayer player, TileEntityOredictionificator tentity, int index) - { - super(tentity, new ContainerFilter(player.inventory, tentity)); - tileEntity = tentity; - - origFilter = tileEntity.filters.get(index); - filter = ((OredictionificatorFilter)tentity.filters.get(index)).clone(); - - updateRenderStack(); - } - - public GuiOredictionificatorFilter(EntityPlayer player, TileEntityOredictionificator tentity) - { - super(tentity, new ContainerFilter(player.inventory, tentity)); - tileEntity = tentity; - - isNew = true; - } - - public void setFilter() - { - String newFilter = filterText.getText(); - boolean has = false; - - for(String s : TileEntityOredictionificator.possibleFilters) - { - if(newFilter.startsWith(s)) - { - has = true; - break; - } - } - - if(has) - { - filter.filter = newFilter; - filter.index = 0; - filterText.setText(""); - - updateRenderStack(); - } - - updateButtons(); - } - - public void updateButtons() - { - if(filter.filter != null && !filter.filter.isEmpty()) - { - ((GuiButton)buttonList.get(0)).enabled = true; - } - else { - ((GuiButton)buttonList.get(0)).enabled = false; - } - - if(!isNew) - { - ((GuiButton)buttonList.get(1)).enabled = true; - } - else { - ((GuiButton)buttonList.get(1)).enabled = false; - } - } - - @Override - public void initGui() - { - super.initGui(); + public OredictionificatorFilter origFilter; - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; + public OredictionificatorFilter filter = new OredictionificatorFilter(); - buttonList.clear(); - buttonList.add(new GuiButton(0, guiWidth + 31, guiHeight + 62, 54, 20, LangUtils.localize("gui.save"))); - buttonList.add(new GuiButton(1, guiWidth + 89, guiHeight + 62, 54, 20, LangUtils.localize("gui.delete"))); + public GuiTextField filterText; - if(isNew) - { - ((GuiButton)buttonList.get(1)).enabled = false; - } + public boolean isNew; - filterText = new GuiTextField(fontRendererObj, guiWidth + 33, guiHeight + 48, 96, 12); - filterText.setMaxStringLength(TileEntityOredictionificator.MAX_LENGTH); - filterText.setFocused(true); - - updateButtons(); - } - - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + public ItemStack renderStack; - String text = (isNew ? LangUtils.localize("gui.new") : LangUtils.localize("gui.edit")) + " " + LangUtils.localize("gui.filter"); - fontRendererObj.drawString(text, (xSize/2)-(fontRendererObj.getStringWidth(text)/2), 6, 0x404040); - - fontRendererObj.drawString(LangUtils.localize("gui.index") + ": " + filter.index, 79, 23, 0x404040); - - if(filter.filter != null) - { - renderScaledText(filter.filter, 32, 38, 0x404040, 111); - } + public GuiOredictionificatorFilter( + EntityPlayer player, TileEntityOredictionificator tentity, int index + ) { + super(tentity, new ContainerFilter(player.inventory, tentity)); + tileEntity = tentity; - if(renderStack != null) - { - try { - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_LIGHTING); - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), renderStack, 45, 19); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } catch(Exception e) {} - } - - if(xAxis >= 31 && xAxis <= 43 && yAxis >= 21 && yAxis <= 33) - { - drawCreativeTabHoveringText(LangUtils.localize("gui.lastItem"), xAxis, yAxis); - } - - if(xAxis >= 63 && xAxis <= 75 && yAxis >= 21 && yAxis <= 33) - { - drawCreativeTabHoveringText(LangUtils.localize("gui.nextItem"), xAxis, yAxis); - } - - if(xAxis >= 33 && xAxis <= 129 && yAxis >= 48 && yAxis <= 60) - { - drawCreativeTabHoveringText(LangUtils.localize("gui.oreDictCompat"), xAxis, yAxis); - } - - if(xAxis >= 45 && xAxis <= 61 && yAxis >= 19 && yAxis <= 35) - { - if(renderStack != null) - { - String name = MekanismUtils.getMod(renderStack); - String extra = name.equals("null") ? "" : " (" + name + ")"; - - drawCreativeTabHoveringText(renderStack.getDisplayName() + extra, xAxis, yAxis); - } - } + origFilter = tileEntity.filters.get(index); + filter = ((OredictionificatorFilter) tentity.filters.get(index)).clone(); - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + updateRenderStack(); + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + public GuiOredictionificatorFilter( + EntityPlayer player, TileEntityOredictionificator tentity + ) { + super(tentity, new ContainerFilter(player.inventory, tentity)); + tileEntity = tentity; - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiOredictionificatorFilter.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + isNew = true; + } - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + public void setFilter() { + String newFilter = filterText.getText(); + boolean has = false; - if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) - { - drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176 + 36, 0, 11, 11); - } - else { - drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176 + 36, 11, 11, 11); - } + for (String s : TileEntityOredictionificator.possibleFilters) { + if (newFilter.startsWith(s)) { + has = true; + break; + } + } - if(xAxis >= 31 && xAxis <= 43 && yAxis >= 21 && yAxis <= 33) - { - drawTexturedModalRect(guiWidth + 31, guiHeight + 21, 176 + 24, 0, 12, 12); - } - else { - drawTexturedModalRect(guiWidth + 31, guiHeight + 21, 176 + 24, 12, 12, 12); - } - - if(xAxis >= 63 && xAxis <= 75 && yAxis >= 21 && yAxis <= 33) - { - drawTexturedModalRect(guiWidth + 63, guiHeight + 21, 176 + 12, 0, 12, 12); - } - else { - drawTexturedModalRect(guiWidth + 63, guiHeight + 21, 176 + 12, 12, 12, 12); - } - - if(xAxis >= 130 && xAxis <= 142 && yAxis >= 48 && yAxis <= 60) - { - drawTexturedModalRect(guiWidth + 130, guiHeight + 48, 176, 0, 12, 12); - } - else { - drawTexturedModalRect(guiWidth + 130, guiHeight + 48, 176, 12, 12, 12); - } + if (has) { + filter.filter = newFilter; + filter.index = 0; + filterText.setText(""); - filterText.drawTextBox(); - } - - @Override - public void keyTyped(char c, int i) - { - if(!filterText.isFocused() || i == Keyboard.KEY_ESCAPE) - { - super.keyTyped(c, i); - } + updateRenderStack(); + } - if(filterText.isFocused() && i == Keyboard.KEY_RETURN) - { - setFilter(); - return; - } + updateButtons(); + } - if(Character.isLetter(c) || Character.isDigit(c) || isTextboxKey(c, i)) - { - filterText.textboxKeyTyped(c, i); - } - } - - @Override - protected void actionPerformed(GuiButton guibutton) - { - super.actionPerformed(guibutton); - - if(guibutton.id == 0) - { - if(!filterText.getText().isEmpty()) - { - setFilter(); - } + public void updateButtons() { + if (filter.filter != null && !filter.filter.isEmpty()) { + ((GuiButton) buttonList.get(0)).enabled = true; + } else { + ((GuiButton) buttonList.get(0)).enabled = false; + } - if(filter.filter != null && !filter.filter.isEmpty()) - { - if(isNew) - { - Mekanism.packetHandler.sendToServer(new NewFilterMessage(Coord4D.get(tileEntity), filter)); - } - else { - Mekanism.packetHandler.sendToServer(new EditFilterMessage(Coord4D.get(tileEntity), false, origFilter, filter)); - } + if (!isNew) { + ((GuiButton) buttonList.get(1)).enabled = true; + } else { + ((GuiButton) buttonList.get(1)).enabled = false; + } + } - Mekanism.packetHandler.sendToServer(new SimpleGuiMessage(Coord4D.get(tileEntity), 0, 52)); - } - } - else if(guibutton.id == 1) - { - Mekanism.packetHandler.sendToServer(new EditFilterMessage(Coord4D.get(tileEntity), true, origFilter, null)); - Mekanism.packetHandler.sendToServer(new SimpleGuiMessage(Coord4D.get(tileEntity), 0, 52)); - } - } - - @Override - public void updateScreen() - { - super.updateScreen(); + @Override + public void initGui() { + super.initGui(); - filterText.updateCursorCounter(); - } - - @Override - protected void mouseClicked(int mouseX, int mouseY, int button) - { - super.mouseClicked(mouseX, mouseY, button); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; - filterText.mouseClicked(mouseX, mouseY, button); - - if(button == 0) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + buttonList.clear(); + buttonList.add(new GuiButton( + 0, guiWidth + 31, guiHeight + 62, 54, 20, LangUtils.localize("gui.save") + )); + buttonList.add(new GuiButton( + 1, guiWidth + 89, guiHeight + 62, 54, 20, LangUtils.localize("gui.delete") + )); - if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) - { + if (isNew) { + ((GuiButton) buttonList.get(1)).enabled = false; + } + + filterText + = new GuiTextField(fontRendererObj, guiWidth + 33, guiHeight + 48, 96, 12); + filterText.setMaxStringLength(TileEntityOredictionificator.MAX_LENGTH); + filterText.setFocused(true); + + updateButtons(); + } + + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + String text + = (isNew ? LangUtils.localize("gui.new") : LangUtils.localize("gui.edit")) + + " " + LangUtils.localize("gui.filter"); + fontRendererObj.drawString( + text, (xSize / 2) - (fontRendererObj.getStringWidth(text) / 2), 6, 0x404040 + ); + + fontRendererObj.drawString( + LangUtils.localize("gui.index") + ": " + filter.index, 79, 23, 0x404040 + ); + + if (filter.filter != null) { + renderScaledText(filter.filter, 32, 38, 0x404040, 111); + } + + if (renderStack != null) { + try { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_LIGHTING); + itemRender.renderItemAndEffectIntoGUI( + fontRendererObj, mc.getTextureManager(), renderStack, 45, 19 + ); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } catch (Exception e) {} + } + + if (xAxis >= 31 && xAxis <= 43 && yAxis >= 21 && yAxis <= 33) { + drawCreativeTabHoveringText(LangUtils.localize("gui.lastItem"), xAxis, yAxis); + } + + if (xAxis >= 63 && xAxis <= 75 && yAxis >= 21 && yAxis <= 33) { + drawCreativeTabHoveringText(LangUtils.localize("gui.nextItem"), xAxis, yAxis); + } + + if (xAxis >= 33 && xAxis <= 129 && yAxis >= 48 && yAxis <= 60) { + drawCreativeTabHoveringText( + LangUtils.localize("gui.oreDictCompat"), xAxis, yAxis + ); + } + + if (xAxis >= 45 && xAxis <= 61 && yAxis >= 19 && yAxis <= 35) { + if (renderStack != null) { + String name = MekanismUtils.getMod(renderStack); + String extra = name.equals("null") ? "" : " (" + name + ")"; + + drawCreativeTabHoveringText( + renderStack.getDisplayName() + extra, xAxis, yAxis + ); + } + } + + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiOredictionificatorFilter.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + if (xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { + drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176 + 36, 0, 11, 11); + } else { + drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176 + 36, 11, 11, 11); + } + + if (xAxis >= 31 && xAxis <= 43 && yAxis >= 21 && yAxis <= 33) { + drawTexturedModalRect(guiWidth + 31, guiHeight + 21, 176 + 24, 0, 12, 12); + } else { + drawTexturedModalRect(guiWidth + 31, guiHeight + 21, 176 + 24, 12, 12, 12); + } + + if (xAxis >= 63 && xAxis <= 75 && yAxis >= 21 && yAxis <= 33) { + drawTexturedModalRect(guiWidth + 63, guiHeight + 21, 176 + 12, 0, 12, 12); + } else { + drawTexturedModalRect(guiWidth + 63, guiHeight + 21, 176 + 12, 12, 12, 12); + } + + if (xAxis >= 130 && xAxis <= 142 && yAxis >= 48 && yAxis <= 60) { + drawTexturedModalRect(guiWidth + 130, guiHeight + 48, 176, 0, 12, 12); + } else { + drawTexturedModalRect(guiWidth + 130, guiHeight + 48, 176, 12, 12, 12); + } + + filterText.drawTextBox(); + } + + @Override + public void keyTyped(char c, int i) { + if (!filterText.isFocused() || i == Keyboard.KEY_ESCAPE) { + super.keyTyped(c, i); + } + + if (filterText.isFocused() && i == Keyboard.KEY_RETURN) { + setFilter(); + return; + } + + if (Character.isLetter(c) || Character.isDigit(c) || isTextboxKey(c, i)) { + filterText.textboxKeyTyped(c, i); + } + } + + @Override + protected void actionPerformed(GuiButton guibutton) { + super.actionPerformed(guibutton); + + if (guibutton.id == 0) { + if (!filterText.getText().isEmpty()) { + setFilter(); + } + + if (filter.filter != null && !filter.filter.isEmpty()) { + if (isNew) { + Mekanism.packetHandler.sendToServer( + new NewFilterMessage(Coord4D.get(tileEntity), filter) + ); + } else { + Mekanism.packetHandler.sendToServer(new EditFilterMessage( + Coord4D.get(tileEntity), false, origFilter, filter + )); + } + + Mekanism.packetHandler.sendToServer( + new SimpleGuiMessage(Coord4D.get(tileEntity), 0, 52) + ); + } + } else if (guibutton.id == 1) { + Mekanism.packetHandler.sendToServer( + new EditFilterMessage(Coord4D.get(tileEntity), true, origFilter, null) + ); + Mekanism.packetHandler.sendToServer( + new SimpleGuiMessage(Coord4D.get(tileEntity), 0, 52) + ); + } + } + + @Override + public void updateScreen() { + super.updateScreen(); + + filterText.updateCursorCounter(); + } + + @Override + protected void mouseClicked(int mouseX, int mouseY, int button) { + super.mouseClicked(mouseX, mouseY, button); + + filterText.mouseClicked(mouseX, mouseY, button); + + if (button == 0) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + if (xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new SimpleGuiMessage(Coord4D.get(tileEntity), 0, 52)); - } - - if(xAxis >= 130 && xAxis <= 142 && yAxis >= 48 && yAxis <= 60) - { - SoundHandler.playSound("gui.button.press"); - setFilter(); - } + Mekanism.packetHandler.sendToServer( + new SimpleGuiMessage(Coord4D.get(tileEntity), 0, 52) + ); + } - if(xAxis >= 31 && xAxis <= 43 && yAxis >= 21 && yAxis <= 33) - { - SoundHandler.playSound("gui.button.press"); - - if(filter.filter != null) - { - List ores = OreDictionary.getOres(filter.filter); - - if(filter.index > 0) - { - filter.index--; - } - else { - filter.index = ores.size()-1; - } - - updateRenderStack(); - } - } - - if(xAxis >= 63 && xAxis <= 75 && yAxis >= 21 && yAxis <= 33) - { - SoundHandler.playSound("gui.button.press"); - - if(filter.filter != null) - { - List ores = OreDictionary.getOres(filter.filter); - - if(filter.index < ores.size()-1) - { - filter.index++; - } - else { - filter.index = 0; - } - - updateRenderStack(); - } - } - } - } - - public void updateRenderStack() - { - if(filter.filter == null || filter.filter.isEmpty()) - { - renderStack = null; - return; - } - - List stacks = OreDictionary.getOres(filter.filter); - - if(stacks.isEmpty()) - { - renderStack = null; - return; - } - - if(stacks.size()-1 >= filter.index) - { - renderStack = stacks.get(filter.index).copy(); - } - else { - renderStack = null; - return; - } - } + if (xAxis >= 130 && xAxis <= 142 && yAxis >= 48 && yAxis <= 60) { + SoundHandler.playSound("gui.button.press"); + setFilter(); + } + + if (xAxis >= 31 && xAxis <= 43 && yAxis >= 21 && yAxis <= 33) { + SoundHandler.playSound("gui.button.press"); + + if (filter.filter != null) { + List ores = OreDictionary.getOres(filter.filter); + + if (filter.index > 0) { + filter.index--; + } else { + filter.index = ores.size() - 1; + } + + updateRenderStack(); + } + } + + if (xAxis >= 63 && xAxis <= 75 && yAxis >= 21 && yAxis <= 33) { + SoundHandler.playSound("gui.button.press"); + + if (filter.filter != null) { + List ores = OreDictionary.getOres(filter.filter); + + if (filter.index < ores.size() - 1) { + filter.index++; + } else { + filter.index = 0; + } + + updateRenderStack(); + } + } + } + } + + public void updateRenderStack() { + if (filter.filter == null || filter.filter.isEmpty()) { + renderStack = null; + return; + } + + List stacks = OreDictionary.getOres(filter.filter); + + if (stacks.isEmpty()) { + renderStack = null; + return; + } + + if (stacks.size() - 1 >= filter.index) { + renderStack = stacks.get(filter.index).copy(); + } else { + renderStack = null; + return; + } + } } diff --git a/src/main/java/mekanism/client/gui/GuiOsmiumCompressor.java b/src/main/java/mekanism/client/gui/GuiOsmiumCompressor.java index bd17dfa1e..d945182c2 100644 --- a/src/main/java/mekanism/client/gui/GuiOsmiumCompressor.java +++ b/src/main/java/mekanism/client/gui/GuiOsmiumCompressor.java @@ -1,22 +1,21 @@ package mekanism.client.gui; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.gui.element.GuiProgress.ProgressBar; import mekanism.common.tile.TileEntityAdvancedElectricMachine; import net.minecraft.entity.player.InventoryPlayer; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiOsmiumCompressor extends GuiAdvancedElectricMachine -{ - public GuiOsmiumCompressor(InventoryPlayer inventory, TileEntityAdvancedElectricMachine tentity) - { - super(inventory, tentity); - } - - @Override - public ProgressBar getProgressType() - { - return ProgressBar.RED; - } +public class GuiOsmiumCompressor extends GuiAdvancedElectricMachine { + public GuiOsmiumCompressor( + InventoryPlayer inventory, TileEntityAdvancedElectricMachine tentity + ) { + super(inventory, tentity); + } + + @Override + public ProgressBar getProgressType() { + return ProgressBar.RED; + } } diff --git a/src/main/java/mekanism/client/gui/GuiPRC.java b/src/main/java/mekanism/client/gui/GuiPRC.java index 0f951adc3..e62bc0428 100644 --- a/src/main/java/mekanism/client/gui/GuiPRC.java +++ b/src/main/java/mekanism/client/gui/GuiPRC.java @@ -2,6 +2,8 @@ package mekanism.client.gui; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.gas.GasTank; import mekanism.api.util.ListUtils; import mekanism.client.gui.element.GuiElement.IInfoHandler; @@ -30,102 +32,175 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.entity.player.InventoryPlayer; import net.minecraftforge.fluids.FluidTank; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiPRC extends GuiMekanism -{ - public TileEntityPRC tileEntity; +public class GuiPRC extends GuiMekanism { + public TileEntityPRC tileEntity; - public GuiPRC(InventoryPlayer inventory, TileEntityPRC tentity) - { - super(tentity, new ContainerPRC(inventory, tentity)); - tileEntity = tentity; + public GuiPRC(InventoryPlayer inventory, TileEntityPRC tentity) { + super(tentity, new ContainerPRC(inventory, tentity)); + tileEntity = tentity; - guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"))); - guiElements.add(new GuiSecurityTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"))); - guiElements.add(new GuiSideConfigurationTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"))); - guiElements.add(new GuiTransporterConfigTab(this, 34, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"))); - guiElements.add(new GuiUpgradeTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"))); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() { - @Override - public List getInfo() - { - double extra = tileEntity.getRecipe() != null ? tileEntity.getRecipe().extraEnergy : 0; - String multiplier = MekanismUtils.getEnergyDisplay(MekanismUtils.getEnergyPerTick(tileEntity, tileEntity.BASE_ENERGY_PER_TICK + extra)); - return ListUtils.asList(LangUtils.localize("gui.using") + ": " + multiplier + "/t", LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); - } - }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"))); - guiElements.add(new GuiFluidGauge(new IFluidInfoHandler() { - @Override - public FluidTank getTank() - { - return tileEntity.inputFluidTank; - } - }, GuiGauge.Type.STANDARD_YELLOW, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 5, 10)); - guiElements.add(new GuiGasGauge(new IGasInfoHandler() { - @Override - public GasTank getTank() - { - return tileEntity.inputGasTank; - } - }, GuiGauge.Type.STANDARD_RED, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 28, 10)); - guiElements.add(new GuiGasGauge(new IGasInfoHandler() { - @Override - public GasTank getTank() - { - return tileEntity.outputGasTank; - } - }, GuiGauge.Type.SMALL_BLUE, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 140, 40)); - guiElements.add(new GuiPowerBar(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 164, 15)); + guiElements.add(new GuiRedstoneControl( + this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png") + )); + guiElements.add(new GuiSecurityTab( + this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png") + )); + guiElements.add(new GuiSideConfigurationTab( + this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png") + )); + guiElements.add(new GuiTransporterConfigTab( + this, + 34, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png") + )); + guiElements.add(new GuiUpgradeTab( + this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png") + )); + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() { + double extra = tileEntity.getRecipe() != null + ? tileEntity.getRecipe().extraEnergy + : 0; + String multiplier + = MekanismUtils.getEnergyDisplay(MekanismUtils.getEnergyPerTick( + tileEntity, tileEntity.BASE_ENERGY_PER_TICK + extra + )); + return ListUtils.asList( + LangUtils.localize("gui.using") + ": " + multiplier + "/t", + LangUtils.localize("gui.needed") + ": " + + MekanismUtils.getEnergyDisplay( + tileEntity.getMaxEnergy() - tileEntity.getEnergy() + ) + ); + } + }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"))); + guiElements.add(new GuiFluidGauge( + new IFluidInfoHandler() { + @Override + public FluidTank getTank() { + return tileEntity.inputFluidTank; + } + }, + GuiGauge.Type.STANDARD_YELLOW, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), + 5, + 10 + )); + guiElements.add(new GuiGasGauge( + new IGasInfoHandler() { + @Override + public GasTank getTank() { + return tileEntity.inputGasTank; + } + }, + GuiGauge.Type.STANDARD_RED, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), + 28, + 10 + )); + guiElements.add(new GuiGasGauge( + new IGasInfoHandler() { + @Override + public GasTank getTank() { + return tileEntity.outputGasTank; + } + }, + GuiGauge.Type.SMALL_BLUE, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), + 140, + 40 + )); + guiElements.add(new GuiPowerBar( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), + 164, + 15 + )); - guiElements.add(new GuiSlot(SlotType.INPUT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 53, 34)); - guiElements.add(new GuiSlot(SlotType.POWER, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 140, 18).with(SlotOverlay.POWER)); - guiElements.add(new GuiSlot(SlotType.OUTPUT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 115, 34)); + guiElements.add(new GuiSlot( + SlotType.INPUT, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), + 53, + 34 + )); + guiElements.add(new GuiSlot( + SlotType.POWER, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), + 140, + 18 + ) + .with(SlotOverlay.POWER)); + guiElements.add(new GuiSlot( + SlotType.OUTPUT, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), + 115, + 34 + )); - guiElements.add(new GuiProgress(new IProgressInfoHandler() - { - @Override - public double getProgress() - { - return tileEntity.getScaledProgress(); - } - }, getProgressType(), this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 75, 37)); - } + guiElements.add(new GuiProgress( + new IProgressInfoHandler() { + @Override + public double getProgress() { + return tileEntity.getScaledProgress(); + } + }, + getProgressType(), + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), + 75, + 37 + )); + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize/2)-(fontRendererObj.getStringWidth(tileEntity.getInventoryName())/2), 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); + fontRendererObj.drawString( + tileEntity.getInventoryName(), + (xSize / 2) + - (fontRendererObj.getStringWidth(tileEntity.getInventoryName()) / 2), + 6, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040 + ); - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - int xAxis = mouseX - guiWidth; - int yAxis = mouseY - guiHeight; + int xAxis = mouseX - guiWidth; + int yAxis = mouseY - guiHeight; - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } - public ProgressBar getProgressType() - { - return ProgressBar.MEDIUM; - } + public ProgressBar getProgressType() { + return ProgressBar.MEDIUM; + } } diff --git a/src/main/java/mekanism/client/gui/GuiPersonalChest.java b/src/main/java/mekanism/client/gui/GuiPersonalChest.java index 6c51d68e2..a18c4541f 100644 --- a/src/main/java/mekanism/client/gui/GuiPersonalChest.java +++ b/src/main/java/mekanism/client/gui/GuiPersonalChest.java @@ -1,5 +1,7 @@ package mekanism.client.gui; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.gui.element.GuiSecurityTab; import mekanism.common.inventory.container.ContainerPersonalChest; import mekanism.common.tile.TileEntityPersonalChest; @@ -8,62 +10,66 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.IInventory; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiPersonalChest extends GuiMekanism -{ - public TileEntityPersonalChest tileEntity; +public class GuiPersonalChest extends GuiMekanism { + public TileEntityPersonalChest tileEntity; - public GuiPersonalChest(InventoryPlayer inventory, TileEntityPersonalChest tentity) - { - super(tentity, new ContainerPersonalChest(inventory, tentity, null, true)); + public GuiPersonalChest(InventoryPlayer inventory, TileEntityPersonalChest tentity) { + super(tentity, new ContainerPersonalChest(inventory, tentity, null, true)); - xSize+=26; - ySize+=64; - tileEntity = tentity; + xSize += 26; + ySize += 64; + tileEntity = tentity; - guiElements.add(new GuiSecurityTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiPersonalChest.png"))); - } + guiElements.add(new GuiSecurityTab( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiPersonalChest.png") + )); + } - public GuiPersonalChest(InventoryPlayer inventory, IInventory inv) - { - super(new ContainerPersonalChest(inventory, null, inv, false)); + public GuiPersonalChest(InventoryPlayer inventory, IInventory inv) { + super(new ContainerPersonalChest(inventory, null, inv, false)); - xSize+=26; - ySize+=64; - - guiElements.add(new GuiSecurityTab(this, MekanismUtils.getResource(ResourceType.GUI, "GuiPersonalChest.png"))); - } + xSize += 26; + ySize += 64; - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); - - fontRendererObj.drawString(LangUtils.localize("tile.MachineBlock.PersonalChest.name"), 8, 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); + guiElements.add(new GuiSecurityTab( + this, MekanismUtils.getResource(ResourceType.GUI, "GuiPersonalChest.png") + )); + } - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiPersonalChest.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + fontRendererObj.drawString( + LangUtils.localize("tile.MachineBlock.PersonalChest.name"), 8, 6, 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040 + ); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); - - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiPersonalChest.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } } diff --git a/src/main/java/mekanism/client/gui/GuiPrecisionSawmill.java b/src/main/java/mekanism/client/gui/GuiPrecisionSawmill.java index 1b521b90b..344f73c19 100644 --- a/src/main/java/mekanism/client/gui/GuiPrecisionSawmill.java +++ b/src/main/java/mekanism/client/gui/GuiPrecisionSawmill.java @@ -1,22 +1,21 @@ package mekanism.client.gui; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.gui.element.GuiProgress.ProgressBar; import mekanism.common.tile.TileEntityChanceMachine; import net.minecraft.entity.player.InventoryPlayer; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiPrecisionSawmill extends GuiChanceMachine -{ - public GuiPrecisionSawmill(InventoryPlayer inventory, TileEntityChanceMachine tentity) - { - super(inventory, tentity); - } - - @Override - public ProgressBar getProgressType() - { - return ProgressBar.PURPLE; - } +public class GuiPrecisionSawmill extends GuiChanceMachine { + public GuiPrecisionSawmill( + InventoryPlayer inventory, TileEntityChanceMachine tentity + ) { + super(inventory, tentity); + } + + @Override + public ProgressBar getProgressType() { + return ProgressBar.PURPLE; + } } diff --git a/src/main/java/mekanism/client/gui/GuiPurificationChamber.java b/src/main/java/mekanism/client/gui/GuiPurificationChamber.java index c33d40407..c37b67c2e 100644 --- a/src/main/java/mekanism/client/gui/GuiPurificationChamber.java +++ b/src/main/java/mekanism/client/gui/GuiPurificationChamber.java @@ -1,22 +1,21 @@ package mekanism.client.gui; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.gui.element.GuiProgress.ProgressBar; import mekanism.common.tile.TileEntityAdvancedElectricMachine; import net.minecraft.entity.player.InventoryPlayer; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiPurificationChamber extends GuiAdvancedElectricMachine -{ - public GuiPurificationChamber(InventoryPlayer inventory, TileEntityAdvancedElectricMachine tentity) - { - super(inventory, tentity); - } - - @Override - public ProgressBar getProgressType() - { - return ProgressBar.RED; - } +public class GuiPurificationChamber extends GuiAdvancedElectricMachine { + public GuiPurificationChamber( + InventoryPlayer inventory, TileEntityAdvancedElectricMachine tentity + ) { + super(inventory, tentity); + } + + @Override + public ProgressBar getProgressType() { + return ProgressBar.RED; + } } diff --git a/src/main/java/mekanism/client/gui/GuiQuantumEntangloporter.java b/src/main/java/mekanism/client/gui/GuiQuantumEntangloporter.java index 5e10c5f18..280a463c6 100644 --- a/src/main/java/mekanism/client/gui/GuiQuantumEntangloporter.java +++ b/src/main/java/mekanism/client/gui/GuiQuantumEntangloporter.java @@ -3,6 +3,8 @@ package mekanism.client.gui; import java.util.ArrayList; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.client.gui.element.GuiScrollList; @@ -26,131 +28,139 @@ import net.minecraft.client.gui.GuiTextField; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; - import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiQuantumEntangloporter extends GuiMekanism -{ - public ResourceLocation resource; +public class GuiQuantumEntangloporter extends GuiMekanism { + public ResourceLocation resource; - public TileEntityQuantumEntangloporter tileEntity; + public TileEntityQuantumEntangloporter tileEntity; - public EntityPlayer entityPlayer; + public EntityPlayer entityPlayer; - public GuiButton publicButton; - public GuiButton privateButton; - public GuiButton protectedButton; + public GuiButton publicButton; + public GuiButton privateButton; + public GuiButton protectedButton; - public GuiButton setButton; - public GuiButton deleteButton; + public GuiButton setButton; + public GuiButton deleteButton; - public GuiScrollList scrollList; + public GuiScrollList scrollList; - public GuiTextField frequencyField; + public GuiTextField frequencyField; - public ISecurityTile.SecurityMode access; + public ISecurityTile.SecurityMode access; - public GuiQuantumEntangloporter(InventoryPlayer inventory, TileEntityQuantumEntangloporter tentity) - { - super(tentity, new ContainerQuantumEntangloporter(inventory, tentity)); - tileEntity = tentity; - resource = MekanismUtils.getResource(ResourceType.GUI, "GuiTeleporter.png"); + public GuiQuantumEntangloporter( + InventoryPlayer inventory, TileEntityQuantumEntangloporter tentity + ) { + super(tentity, new ContainerQuantumEntangloporter(inventory, tentity)); + tileEntity = tentity; + resource = MekanismUtils.getResource(ResourceType.GUI, "GuiTeleporter.png"); - guiElements.add(scrollList = new GuiScrollList(this, resource, 28, 37, 120, 4)); - guiElements.add(new GuiSideConfigurationTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiTeleporter.png"))); - guiElements.add(new GuiTransporterConfigTab(this, 34, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiTeleporter.png"))); + guiElements.add(scrollList = new GuiScrollList(this, resource, 28, 37, 120, 4)); + guiElements.add(new GuiSideConfigurationTab( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiTeleporter.png") + )); + guiElements.add(new GuiTransporterConfigTab( + this, + 34, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiTeleporter.png") + )); - if(tileEntity.frequency != null) - { - access= tileEntity.frequency.access; - } + if (tileEntity.frequency != null) { + access = tileEntity.frequency.access; + } - ySize+=64; - } + ySize += 64; + } - @Override - public void initGui() - { - super.initGui(); + @Override + public void initGui() { + super.initGui(); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; - buttonList.clear(); + buttonList.clear(); - publicButton = new GuiButton(0, guiWidth + 27, guiHeight + 14, 40, 20, LangUtils.localize("gui.public")); - privateButton = new GuiButton(1, guiWidth + 69, guiHeight + 14, 40, 20, LangUtils.localize("gui.private")); - protectedButton = new GuiButton(4, guiWidth + 111, guiHeight + 14, 40, 20, LangUtils.localize("gui.trusted")); + publicButton = new GuiButton( + 0, guiWidth + 27, guiHeight + 14, 40, 20, LangUtils.localize("gui.public") + ); + privateButton = new GuiButton( + 1, guiWidth + 69, guiHeight + 14, 40, 20, LangUtils.localize("gui.private") + ); + protectedButton = new GuiButton( + 4, guiWidth + 111, guiHeight + 14, 40, 20, LangUtils.localize("gui.trusted") + ); - setButton = new GuiButton(2, guiWidth + 27, guiHeight + 116, 60, 20, LangUtils.localize("gui.set")); - deleteButton = new GuiButton(3, guiWidth + 89, guiHeight + 116, 60, 20, LangUtils.localize("gui.delete")); + setButton = new GuiButton( + 2, guiWidth + 27, guiHeight + 116, 60, 20, LangUtils.localize("gui.set") + ); + deleteButton = new GuiButton( + 3, guiWidth + 89, guiHeight + 116, 60, 20, LangUtils.localize("gui.delete") + ); - frequencyField = new GuiTextField(fontRendererObj, guiWidth + 50, guiHeight + 104, 86, 11); - frequencyField.setMaxStringLength(FrequencyManager.MAX_FREQ_LENGTH); - frequencyField.setEnableBackgroundDrawing(false); + frequencyField + = new GuiTextField(fontRendererObj, guiWidth + 50, guiHeight + 104, 86, 11); + frequencyField.setMaxStringLength(FrequencyManager.MAX_FREQ_LENGTH); + frequencyField.setEnableBackgroundDrawing(false); - updateButtons(); + updateButtons(); - buttonList.add(publicButton); - buttonList.add(privateButton); - buttonList.add(protectedButton); - buttonList.add(setButton); - buttonList.add(deleteButton); - } + buttonList.add(publicButton); + buttonList.add(privateButton); + buttonList.add(protectedButton); + buttonList.add(setButton); + buttonList.add(deleteButton); + } - public void setFrequency(String freq) - { - if(freq.isEmpty()) - { - return; - } + public void setFrequency(String freq) { + if (freq.isEmpty()) { + return; + } - ArrayList data = new ArrayList(); - data.add(0); - data.add(freq); - data.add(access.ordinal()); + ArrayList data = new ArrayList(); + data.add(0); + data.add(freq); + data.add(access.ordinal()); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - } + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); + } - public String getSecurity(Frequency freq) - { - if(freq.isPrivate()) { - return EnumColor.DARK_RED + LangUtils.localize("gui.private"); - } else if(freq.isPublic()) { - return LangUtils.localize("gui.public"); - } + public String getSecurity(Frequency freq) { + if (freq.isPrivate()) { + return EnumColor.DARK_RED + LangUtils.localize("gui.private"); + } else if (freq.isPublic()) { + return LangUtils.localize("gui.public"); + } - return EnumColor.ORANGE + LangUtils.localize("gui.trusted"); - } + return EnumColor.ORANGE + LangUtils.localize("gui.trusted"); + } - public void updateButtons() - { - if(tileEntity.getSecurity().getOwner() == null) - { - return; - } + public void updateButtons() { + if (tileEntity.getSecurity().getOwner() == null) { + return; + } - List text = new ArrayList(); + List text = new ArrayList(); - - if(access == ISecurityTile.SecurityMode.PRIVATE) { - for(Frequency freq : tileEntity.privateCache) - { + if (access == ISecurityTile.SecurityMode.PRIVATE) { + for (Frequency freq : tileEntity.privateCache) { text.add(freq.name); } publicButton.enabled = true; privateButton.enabled = false; protectedButton.enabled = true; - } else if(access == ISecurityTile.SecurityMode.PUBLIC) { - for(Frequency freq : tileEntity.publicCache) - { + } else if (access == ISecurityTile.SecurityMode.PUBLIC) { + for (Frequency freq : tileEntity.publicCache) { text.add(freq.name + " (" + freq.owner + ")"); } @@ -158,8 +168,7 @@ public class GuiQuantumEntangloporter extends GuiMekanism privateButton.enabled = true; protectedButton.enabled = true; } else { - for(Frequency freq : tileEntity.protectedCache) - { + for (Frequency freq : tileEntity.protectedCache) { text.add(freq.name + " (" + freq.owner + ")"); } @@ -168,215 +177,224 @@ public class GuiQuantumEntangloporter extends GuiMekanism protectedButton.enabled = false; } - scrollList.setText(text); - - - if(scrollList.hasSelection()) - { + scrollList.setText(text); + if (scrollList.hasSelection()) { Frequency freq; - if(access == ISecurityTile.SecurityMode.PRIVATE) { + if (access == ISecurityTile.SecurityMode.PRIVATE) { freq = tileEntity.privateCache.get(scrollList.selected); - } else if(access == ISecurityTile.SecurityMode.PUBLIC) { + } else if (access == ISecurityTile.SecurityMode.PUBLIC) { freq = tileEntity.publicCache.get(scrollList.selected); } else { freq = tileEntity.protectedCache.get(scrollList.selected); } - if(tileEntity.getFrequency(null) == null || !tileEntity.getFrequency(null).equals(freq)) - { - setButton.enabled = true; - } - else { - setButton.enabled = false; - } + if (tileEntity.getFrequency(null) == null + || !tileEntity.getFrequency(null).equals(freq)) { + setButton.enabled = true; + } else { + setButton.enabled = false; + } - if(tileEntity.getSecurity().getOwner().equals(freq.owner)) - { - deleteButton.enabled = true; - } - else { - deleteButton.enabled = false; - } - } - else { - setButton.enabled = false; - deleteButton.enabled = false; - } - } + if (tileEntity.getSecurity().getOwner().equals(freq.owner)) { + deleteButton.enabled = true; + } else { + deleteButton.enabled = false; + } + } else { + setButton.enabled = false; + deleteButton.enabled = false; + } + } - @Override - public void updateScreen() - { - super.updateScreen(); + @Override + public void updateScreen() { + super.updateScreen(); - updateButtons(); + updateButtons(); - frequencyField.updateCursorCounter(); - } + frequencyField.updateCursorCounter(); + } - @Override - public void mouseClicked(int mouseX, int mouseY, int button) - { - super.mouseClicked(mouseX, mouseY, button); + @Override + public void mouseClicked(int mouseX, int mouseY, int button) { + super.mouseClicked(mouseX, mouseY, button); - updateButtons(); + updateButtons(); - frequencyField.mouseClicked(mouseX, mouseY, button); + frequencyField.mouseClicked(mouseX, mouseY, button); - if(button == 0) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + if (button == 0) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - if(xAxis >= 137 && xAxis <= 148 && yAxis >= 103 && yAxis <= 114) - { - setFrequency(frequencyField.getText()); - frequencyField.setText(""); - SoundHandler.playSound("gui.button.press"); - } - } - } + if (xAxis >= 137 && xAxis <= 148 && yAxis >= 103 && yAxis <= 114) { + setFrequency(frequencyField.getText()); + frequencyField.setText(""); + SoundHandler.playSound("gui.button.press"); + } + } + } - @Override - public void keyTyped(char c, int i) - { - if(!frequencyField.isFocused() || i == Keyboard.KEY_ESCAPE) - { - super.keyTyped(c, i); - } + @Override + public void keyTyped(char c, int i) { + if (!frequencyField.isFocused() || i == Keyboard.KEY_ESCAPE) { + super.keyTyped(c, i); + } - if(i == Keyboard.KEY_RETURN) - { - if(frequencyField.isFocused()) - { - setFrequency(frequencyField.getText()); - frequencyField.setText(""); - } - } + if (i == Keyboard.KEY_RETURN) { + if (frequencyField.isFocused()) { + setFrequency(frequencyField.getText()); + frequencyField.setText(""); + } + } - if(Character.isDigit(c) || Character.isLetter(c) || isTextboxKey(c, i) || FrequencyManager.SPECIAL_CHARS.contains(c)) - { - frequencyField.textboxKeyTyped(c, i); - } + if (Character.isDigit(c) || Character.isLetter(c) || isTextboxKey(c, i) + || FrequencyManager.SPECIAL_CHARS.contains(c)) { + frequencyField.textboxKeyTyped(c, i); + } - updateButtons(); - } + updateButtons(); + } - @Override - protected void actionPerformed(GuiButton guibutton) - { - super.actionPerformed(guibutton); + @Override + protected void actionPerformed(GuiButton guibutton) { + super.actionPerformed(guibutton); - if(guibutton.id == 0) - { - access = ISecurityTile.SecurityMode.PUBLIC; - } - else if(guibutton.id == 1) - { - access = ISecurityTile.SecurityMode.PRIVATE; - } - else if(guibutton.id == 2) - { - int selection = scrollList.getSelection(); + if (guibutton.id == 0) { + access = ISecurityTile.SecurityMode.PUBLIC; + } else if (guibutton.id == 1) { + access = ISecurityTile.SecurityMode.PRIVATE; + } else if (guibutton.id == 2) { + int selection = scrollList.getSelection(); - if(selection != -1) - { + if (selection != -1) { Frequency freq; - if(access == ISecurityTile.SecurityMode.PRIVATE) { + if (access == ISecurityTile.SecurityMode.PRIVATE) { freq = tileEntity.privateCache.get(selection); - } else if(access == ISecurityTile.SecurityMode.PUBLIC) { + } else if (access == ISecurityTile.SecurityMode.PUBLIC) { freq = tileEntity.publicCache.get(selection); } else { freq = tileEntity.protectedCache.get(selection); } - setFrequency(freq.name); - } - } - else if(guibutton.id == 3) - { - int selection = scrollList.getSelection(); + setFrequency(freq.name); + } + } else if (guibutton.id == 3) { + int selection = scrollList.getSelection(); - if(selection != -1) - { + if (selection != -1) { Frequency freq; - if(access == ISecurityTile.SecurityMode.PRIVATE) { + if (access == ISecurityTile.SecurityMode.PRIVATE) { freq = tileEntity.privateCache.get(selection); - } else if(access == ISecurityTile.SecurityMode.PUBLIC) { + } else if (access == ISecurityTile.SecurityMode.PUBLIC) { freq = tileEntity.publicCache.get(selection); } else { freq = tileEntity.protectedCache.get(selection); } - if(tileEntity != null) - { - ArrayList data = new ArrayList(); - data.add(1); - data.add(freq.name); - data.add(freq.access.ordinal()); + if (tileEntity != null) { + ArrayList data = new ArrayList(); + data.add(1); + data.add(freq.name); + data.add(freq.access.ordinal()); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - } - else { - Mekanism.packetHandler.sendToServer(new PortableTeleporterMessage(PortableTeleporterPacketType.DEL_FREQ, freq)); - Mekanism.packetHandler.sendToServer(new PortableTeleporterMessage(PortableTeleporterPacketType.DATA_REQUEST, null)); - } + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); + } else { + Mekanism.packetHandler.sendToServer(new PortableTeleporterMessage( + PortableTeleporterPacketType.DEL_FREQ, freq + )); + Mekanism.packetHandler.sendToServer(new PortableTeleporterMessage( + PortableTeleporterPacketType.DATA_REQUEST, null + )); + } - scrollList.selected = -1; - } - }else if(guibutton.id == 4) - { + scrollList.selected = -1; + } + } else if (guibutton.id == 4) { access = ISecurityTile.SecurityMode.TRUSTED; } - updateButtons(); - } + updateButtons(); + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX-(width-xSize)/2); - int yAxis = (mouseY-(height-ySize)/2); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize/2)-(fontRendererObj.getStringWidth(tileEntity.getInventoryName())/2), 4, 0x404040); - fontRendererObj.drawString(LangUtils.localize("gui.owner") + ": " + (tileEntity.getSecurity().getOwner() != null ? tileEntity.getSecurity().getOwner() : LangUtils.localize("gui.none")), 8, (ySize-96)+4, 0x404040); + fontRendererObj.drawString( + tileEntity.getInventoryName(), + (xSize / 2) + - (fontRendererObj.getStringWidth(tileEntity.getInventoryName()) / 2), + 4, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.owner") + ": " + + (tileEntity.getSecurity().getOwner() != null + ? tileEntity.getSecurity().getOwner() + : LangUtils.localize("gui.none")), + 8, + (ySize - 96) + 4, + 0x404040 + ); - fontRendererObj.drawString(LangUtils.localize("gui.freq") + ":", 32, 81, 0x404040); - fontRendererObj.drawString(LangUtils.localize("gui.security") + ":", 32, 91, 0x404040); + fontRendererObj.drawString( + LangUtils.localize("gui.freq") + ":", 32, 81, 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.security") + ":", 32, 91, 0x404040 + ); - fontRendererObj.drawString(" " + (tileEntity.getFrequency(null) != null ? tileEntity.getFrequency(null).name : EnumColor.DARK_RED + LangUtils.localize("gui.none")), 32 + fontRendererObj.getStringWidth(LangUtils.localize("gui.freq") + ":"), 81, 0x797979); - fontRendererObj.drawString(" " + (tileEntity.getFrequency(null) != null ? getSecurity(tileEntity.getFrequency(null)) : EnumColor.DARK_RED + LangUtils.localize("gui.none")), 32 + fontRendererObj.getStringWidth(LangUtils.localize("gui.security") + ":"), 91, 0x797979); + fontRendererObj.drawString( + " " + + (tileEntity.getFrequency(null) != null + ? tileEntity.getFrequency(null).name + : EnumColor.DARK_RED + LangUtils.localize("gui.none")), + 32 + fontRendererObj.getStringWidth(LangUtils.localize("gui.freq") + ":"), + 81, + 0x797979 + ); + fontRendererObj.drawString( + " " + + (tileEntity.getFrequency(null) != null + ? getSecurity(tileEntity.getFrequency(null)) + : EnumColor.DARK_RED + LangUtils.localize("gui.none")), + 32 + fontRendererObj.getStringWidth(LangUtils.localize("gui.security") + ":"), + 91, + 0x797979 + ); - String str = LangUtils.localize("gui.set") + ":"; - renderScaledText(str, 27, 104, 0x404040, 20); + String str = LangUtils.localize("gui.set") + ":"; + renderScaledText(str, 27, 104, 0x404040, 20); - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(resource); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width-xSize)/2; - int guiHeight = (height-ySize)/2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture(resource); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - if(xAxis >= 137 && xAxis <= 148 && yAxis >= 103 && yAxis <= 114) - { - drawTexturedModalRect(guiWidth + 137, guiHeight + 103, xSize, 0, 11, 11); - } - else { - drawTexturedModalRect(guiWidth + 137, guiHeight + 103, xSize, 11, 11, 11); - } + if (xAxis >= 137 && xAxis <= 148 && yAxis >= 103 && yAxis <= 114) { + drawTexturedModalRect(guiWidth + 137, guiHeight + 103, xSize, 0, 11, 11); + } else { + drawTexturedModalRect(guiWidth + 137, guiHeight + 103, xSize, 11, 11, 11); + } - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - frequencyField.drawTextBox(); - } + frequencyField.drawTextBox(); + } } diff --git a/src/main/java/mekanism/client/gui/GuiResistiveHeater.java b/src/main/java/mekanism/client/gui/GuiResistiveHeater.java index 0fbf6800c..b6dff3b61 100644 --- a/src/main/java/mekanism/client/gui/GuiResistiveHeater.java +++ b/src/main/java/mekanism/client/gui/GuiResistiveHeater.java @@ -3,6 +3,8 @@ package mekanism.client.gui; import java.util.ArrayList; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.MekanismConfig.general; import mekanism.api.util.ListUtils; @@ -27,161 +29,206 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.gui.GuiTextField; import net.minecraft.entity.player.InventoryPlayer; - import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiResistiveHeater extends GuiMekanism -{ - public TileEntityResistiveHeater tileEntity; - - private GuiTextField energyUsageField; - - public GuiResistiveHeater(InventoryPlayer inventory, TileEntityResistiveHeater tentity) - { - super(tentity, new ContainerResistiveHeater(inventory, tentity)); - tileEntity = tentity; - - guiElements.add(new GuiPowerBar(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiResistiveHeater.png"), 164, 15)); - guiElements.add(new GuiSlot(SlotType.POWER, this, MekanismUtils.getResource(ResourceType.GUI, "GuiResistiveHeater.png"), 14, 34).with(SlotOverlay.POWER)); - guiElements.add(new GuiSecurityTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiResistiveHeater.png"))); - guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiResistiveHeater.png"))); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() { - @Override - public List getInfo() - { - String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.energyUsage); - return ListUtils.asList(LangUtils.localize("gui.using") + ": " + multiplier + "/t", LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); - } - }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiResistiveHeater.png"))); - guiElements.add(new GuiHeatInfo(new IInfoHandler() { - @Override - public List getInfo() - { - TemperatureUnit unit = TemperatureUnit.values()[general.tempUnit.ordinal()]; - String environment = UnitDisplayUtils.getDisplayShort(tileEntity.lastEnvironmentLoss*unit.intervalSize, false, unit); - return ListUtils.asList(LangUtils.localize("gui.dissipated") + ": " + environment + "/t"); - } - }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiResistiveHeater.png"))); - } - - @Override - public void initGui() - { - super.initGui(); +public class GuiResistiveHeater extends GuiMekanism { + public TileEntityResistiveHeater tileEntity; - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - - String prevEnergyUsage = energyUsageField != null ? energyUsageField.getText() : ""; - - energyUsageField = new GuiTextField(fontRendererObj, guiWidth + 49, guiHeight + 52, 66, 11); - energyUsageField.setMaxStringLength(7); - energyUsageField.setEnableBackgroundDrawing(false); - energyUsageField.setText(prevEnergyUsage); - } - - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize / 2) - (fontRendererObj.getStringWidth(tileEntity.getInventoryName()) / 2), 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 94) + 2, 0x404040); - - renderScaledText(LangUtils.localize("gui.temp") + ": " + MekanismUtils.getTemperatureDisplay(tileEntity.temperature, TemperatureUnit.AMBIENT), 50, 25, 0x00CD00, 76); - renderScaledText(LangUtils.localize("gui.usage") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.energyUsage) + "/t", 50, 41, 0x00CD00, 76); + private GuiTextField energyUsageField; - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } - - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiResistiveHeater.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); - - if(xAxis >= 116 && xAxis <= 126 && yAxis >= 51 && yAxis <= 61) - { - drawTexturedModalRect(guiWidth + 116, guiHeight + 51, xSize, 0, 11, 11); - } - else { - drawTexturedModalRect(guiWidth + 116, guiHeight + 51, xSize, 11, 11, 11); - } + public GuiResistiveHeater( + InventoryPlayer inventory, TileEntityResistiveHeater tentity + ) { + super(tentity, new ContainerResistiveHeater(inventory, tentity)); + tileEntity = tentity; - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - - energyUsageField.drawTextBox(); - } - - private void setEnergyUsage() - { - if(!energyUsageField.getText().isEmpty()) - { - int toUse = Integer.parseInt(energyUsageField.getText()); + guiElements.add(new GuiPowerBar( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiResistiveHeater.png"), + 164, + 15 + )); + guiElements.add( + new GuiSlot( + SlotType.POWER, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiResistiveHeater.png"), + 14, + 34 + ) + .with(SlotOverlay.POWER) + ); + guiElements.add(new GuiSecurityTab( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiResistiveHeater.png") + )); + guiElements.add(new GuiRedstoneControl( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiResistiveHeater.png") + )); + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() { + String multiplier + = MekanismUtils.getEnergyDisplay(tileEntity.energyUsage); + return ListUtils.asList( + LangUtils.localize("gui.using") + ": " + multiplier + "/t", + LangUtils.localize("gui.needed") + ": " + + MekanismUtils.getEnergyDisplay( + tileEntity.getMaxEnergy() - tileEntity.getEnergy() + ) + ); + } + }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiResistiveHeater.png"))); + guiElements.add(new GuiHeatInfo(new IInfoHandler() { + @Override + public List getInfo() { + TemperatureUnit unit + = TemperatureUnit.values()[general.tempUnit.ordinal()]; + String environment = UnitDisplayUtils.getDisplayShort( + tileEntity.lastEnvironmentLoss * unit.intervalSize, false, unit + ); + return ListUtils.asList( + LangUtils.localize("gui.dissipated") + ": " + environment + "/t" + ); + } + }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiResistiveHeater.png"))); + } - ArrayList data = new ArrayList(); - data.add(toUse); + @Override + public void initGui() { + super.initGui(); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; - energyUsageField.setText(""); - } - } - - @Override - public void updateScreen() - { - super.updateScreen(); - - energyUsageField.updateCursorCounter(); - } - - @Override - public void mouseClicked(int mouseX, int mouseY, int button) - { - super.mouseClicked(mouseX, mouseY, button); + String prevEnergyUsage + = energyUsageField != null ? energyUsageField.getText() : ""; - energyUsageField.mouseClicked(mouseX, mouseY, button); - - if(button == 0) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); - - if(xAxis >= 116 && xAxis <= 126 && yAxis >= 51 && yAxis <= 61) - { - setEnergyUsage(); - SoundHandler.playSound("gui.button.press"); - } - } - } - - @Override - public void keyTyped(char c, int i) - { - if(!energyUsageField.isFocused() || i == Keyboard.KEY_ESCAPE) - { - super.keyTyped(c, i); - } + energyUsageField + = new GuiTextField(fontRendererObj, guiWidth + 49, guiHeight + 52, 66, 11); + energyUsageField.setMaxStringLength(7); + energyUsageField.setEnableBackgroundDrawing(false); + energyUsageField.setText(prevEnergyUsage); + } - if(energyUsageField.isFocused() && i == Keyboard.KEY_RETURN) - { - setEnergyUsage(); - return; - } + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + fontRendererObj.drawString( + tileEntity.getInventoryName(), + (xSize / 2) + - (fontRendererObj.getStringWidth(tileEntity.getInventoryName()) / 2), + 6, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, (ySize - 94) + 2, 0x404040 + ); - if(Character.isDigit(c) || isTextboxKey(c, i)) - { - energyUsageField.textboxKeyTyped(c, i); - } - } + renderScaledText( + LangUtils.localize("gui.temp") + ": " + + MekanismUtils.getTemperatureDisplay( + tileEntity.temperature, TemperatureUnit.AMBIENT + ), + 50, + 25, + 0x00CD00, + 76 + ); + renderScaledText( + LangUtils.localize("gui.usage") + ": " + + MekanismUtils.getEnergyDisplay(tileEntity.energyUsage) + "/t", + 50, + 41, + 0x00CD00, + 76 + ); + + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiResistiveHeater.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + if (xAxis >= 116 && xAxis <= 126 && yAxis >= 51 && yAxis <= 61) { + drawTexturedModalRect(guiWidth + 116, guiHeight + 51, xSize, 0, 11, 11); + } else { + drawTexturedModalRect(guiWidth + 116, guiHeight + 51, xSize, 11, 11, 11); + } + + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + + energyUsageField.drawTextBox(); + } + + private void setEnergyUsage() { + if (!energyUsageField.getText().isEmpty()) { + int toUse = Integer.parseInt(energyUsageField.getText()); + + ArrayList data = new ArrayList(); + data.add(toUse); + + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); + + energyUsageField.setText(""); + } + } + + @Override + public void updateScreen() { + super.updateScreen(); + + energyUsageField.updateCursorCounter(); + } + + @Override + public void mouseClicked(int mouseX, int mouseY, int button) { + super.mouseClicked(mouseX, mouseY, button); + + energyUsageField.mouseClicked(mouseX, mouseY, button); + + if (button == 0) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + if (xAxis >= 116 && xAxis <= 126 && yAxis >= 51 && yAxis <= 61) { + setEnergyUsage(); + SoundHandler.playSound("gui.button.press"); + } + } + } + + @Override + public void keyTyped(char c, int i) { + if (!energyUsageField.isFocused() || i == Keyboard.KEY_ESCAPE) { + super.keyTyped(c, i); + } + + if (energyUsageField.isFocused() && i == Keyboard.KEY_RETURN) { + setEnergyUsage(); + return; + } + + if (Character.isDigit(c) || isTextboxKey(c, i)) { + energyUsageField.textboxKeyTyped(c, i); + } + } } diff --git a/src/main/java/mekanism/client/gui/GuiRobitCrafting.java b/src/main/java/mekanism/client/gui/GuiRobitCrafting.java index ca02ba00c..00f28e5e9 100644 --- a/src/main/java/mekanism/client/gui/GuiRobitCrafting.java +++ b/src/main/java/mekanism/client/gui/GuiRobitCrafting.java @@ -1,5 +1,7 @@ package mekanism.client.gui; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.sound.SoundHandler; import mekanism.common.Mekanism; import mekanism.common.entity.EntityRobit; @@ -10,126 +12,120 @@ import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.entity.player.InventoryPlayer; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiRobitCrafting extends GuiMekanism -{ - public EntityRobit robit; +public class GuiRobitCrafting extends GuiMekanism { + public EntityRobit robit; - public GuiRobitCrafting(InventoryPlayer inventory, EntityRobit entity) - { - super(new ContainerRobitCrafting(inventory, entity)); - robit = entity; - xSize += 25; - } + public GuiRobitCrafting(InventoryPlayer inventory, EntityRobit entity) { + super(new ContainerRobitCrafting(inventory, entity)); + robit = entity; + xSize += 25; + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - fontRendererObj.drawString(LangUtils.localize("gui.robit.crafting"), 8, 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, ySize - 96 + 3, 0x404040); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + fontRendererObj.drawString( + LangUtils.localize("gui.robit.crafting"), 8, 6, 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, ySize - 96 + 3, 0x404040 + ); - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiRobitCrafting.png")); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiRobitCrafting.png") + ); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) - { - drawTexturedModalRect(guiWidth + 179, guiHeight + 10, 176 + 25, 0, 18, 18); - } - else { - drawTexturedModalRect(guiWidth + 179, guiHeight + 10, 176 + 25, 18, 18, 18); - } + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) { + drawTexturedModalRect(guiWidth + 179, guiHeight + 10, 176 + 25, 0, 18, 18); + } else { + drawTexturedModalRect(guiWidth + 179, guiHeight + 10, 176 + 25, 18, 18, 18); + } - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 30 && yAxis <= 48) - { - drawTexturedModalRect(guiWidth + 179, guiHeight + 30, 176 + 25, 36, 18, 18); - } - else { - drawTexturedModalRect(guiWidth + 179, guiHeight + 30, 176 + 25, 54, 18, 18); - } + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 30 && yAxis <= 48) { + drawTexturedModalRect(guiWidth + 179, guiHeight + 30, 176 + 25, 36, 18, 18); + } else { + drawTexturedModalRect(guiWidth + 179, guiHeight + 30, 176 + 25, 54, 18, 18); + } - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 50 && yAxis <= 68) - { - drawTexturedModalRect(guiWidth + 179, guiHeight + 50, 176 + 25, 72, 18, 18); - } - else { - drawTexturedModalRect(guiWidth + 179, guiHeight + 50, 176 + 25, 90, 18, 18); - } + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 50 && yAxis <= 68) { + drawTexturedModalRect(guiWidth + 179, guiHeight + 50, 176 + 25, 72, 18, 18); + } else { + drawTexturedModalRect(guiWidth + 179, guiHeight + 50, 176 + 25, 90, 18, 18); + } - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88) - { - drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 108, 18, 18); - } - else { - drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 126, 18, 18); - } + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88) { + drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 108, 18, 18); + } else { + drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 126, 18, 18); + } - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 90 && yAxis <= 108) - { - drawTexturedModalRect(guiWidth + 179, guiHeight + 90, 176 + 25, 144, 18, 18); - } - else { - drawTexturedModalRect(guiWidth + 179, guiHeight + 90, 176 + 25, 162, 18, 18); - } - } + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 90 && yAxis <= 108) { + drawTexturedModalRect(guiWidth + 179, guiHeight + 90, 176 + 25, 144, 18, 18); + } else { + drawTexturedModalRect(guiWidth + 179, guiHeight + 90, 176 + 25, 162, 18, 18); + } + } - @Override - protected void mouseClicked(int mouseX, int mouseY, int button) - { - super.mouseClicked(mouseX, mouseY, button); + @Override + protected void mouseClicked(int mouseX, int mouseY, int button) { + super.mouseClicked(mouseX, mouseY, button); - if(button == 0) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + if (button == 0) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) - { + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 0, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 21, mc.theWorld, robit.getEntityId(), 0, 0); - } - else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 30 && yAxis <= 48) - { + Mekanism.packetHandler.sendToServer( + new RobitMessage(RobitPacketType.GUI, 0, robit.getEntityId(), null) + ); + mc.thePlayer.openGui( + Mekanism.instance, 21, mc.theWorld, robit.getEntityId(), 0, 0 + ); + } else if (xAxis >= 179 && xAxis <= 197 && yAxis >= 30 && yAxis <= 48) { SoundHandler.playSound("gui.button.press"); - } - else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 50 && yAxis <= 68) - { + } else if (xAxis >= 179 && xAxis <= 197 && yAxis >= 50 && yAxis <= 68) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 2, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 23, mc.theWorld, robit.getEntityId(), 0, 0); - } - else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88) - { + Mekanism.packetHandler.sendToServer( + new RobitMessage(RobitPacketType.GUI, 2, robit.getEntityId(), null) + ); + mc.thePlayer.openGui( + Mekanism.instance, 23, mc.theWorld, robit.getEntityId(), 0, 0 + ); + } else if (xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 3, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 24, mc.theWorld, robit.getEntityId(), 0, 0); - } - else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 90 && yAxis <= 108) - { + Mekanism.packetHandler.sendToServer( + new RobitMessage(RobitPacketType.GUI, 3, robit.getEntityId(), null) + ); + mc.thePlayer.openGui( + Mekanism.instance, 24, mc.theWorld, robit.getEntityId(), 0, 0 + ); + } else if (xAxis >= 179 && xAxis <= 197 && yAxis >= 90 && yAxis <= 108) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 4, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 25, mc.theWorld, robit.getEntityId(), 0, 0); - } - } - } + Mekanism.packetHandler.sendToServer( + new RobitMessage(RobitPacketType.GUI, 4, robit.getEntityId(), null) + ); + mc.thePlayer.openGui( + Mekanism.instance, 25, mc.theWorld, robit.getEntityId(), 0, 0 + ); + } + } + } } diff --git a/src/main/java/mekanism/client/gui/GuiRobitInventory.java b/src/main/java/mekanism/client/gui/GuiRobitInventory.java index 921318bc0..ebc24e48e 100644 --- a/src/main/java/mekanism/client/gui/GuiRobitInventory.java +++ b/src/main/java/mekanism/client/gui/GuiRobitInventory.java @@ -1,5 +1,7 @@ package mekanism.client.gui; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.sound.SoundHandler; import mekanism.common.Mekanism; import mekanism.common.entity.EntityRobit; @@ -10,126 +12,120 @@ import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.entity.player.InventoryPlayer; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiRobitInventory extends GuiMekanism -{ - public EntityRobit robit; +public class GuiRobitInventory extends GuiMekanism { + public EntityRobit robit; - public GuiRobitInventory(InventoryPlayer inventory, EntityRobit entity) - { - super(new ContainerRobitInventory(inventory, entity)); - xSize += 25; - robit = entity; - } + public GuiRobitInventory(InventoryPlayer inventory, EntityRobit entity) { + super(new ContainerRobitInventory(inventory, entity)); + xSize += 25; + robit = entity; + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - fontRendererObj.drawString(LangUtils.localize("gui.robit.inventory"), 8, 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, ySize - 96 + 3, 0x404040); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + fontRendererObj.drawString( + LangUtils.localize("gui.robit.inventory"), 8, 6, 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, ySize - 96 + 3, 0x404040 + ); - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiRobitInventory.png")); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiRobitInventory.png") + ); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) - { - drawTexturedModalRect(guiWidth + 179, guiHeight + 10, 176 + 25, 0, 18, 18); - } - else { - drawTexturedModalRect(guiWidth + 179, guiHeight + 10, 176 + 25, 18, 18, 18); - } + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) { + drawTexturedModalRect(guiWidth + 179, guiHeight + 10, 176 + 25, 0, 18, 18); + } else { + drawTexturedModalRect(guiWidth + 179, guiHeight + 10, 176 + 25, 18, 18, 18); + } - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 30 && yAxis <= 48) - { - drawTexturedModalRect(guiWidth + 179, guiHeight + 30, 176 + 25, 36, 18, 18); - } - else { - drawTexturedModalRect(guiWidth + 179, guiHeight + 30, 176 + 25, 54, 18, 18); - } + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 30 && yAxis <= 48) { + drawTexturedModalRect(guiWidth + 179, guiHeight + 30, 176 + 25, 36, 18, 18); + } else { + drawTexturedModalRect(guiWidth + 179, guiHeight + 30, 176 + 25, 54, 18, 18); + } - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 50 && yAxis <= 68) - { - drawTexturedModalRect(guiWidth + 179, guiHeight + 50, 176 + 25, 72, 18, 18); - } - else { - drawTexturedModalRect(guiWidth + 179, guiHeight + 50, 176 + 25, 90, 18, 18); - } + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 50 && yAxis <= 68) { + drawTexturedModalRect(guiWidth + 179, guiHeight + 50, 176 + 25, 72, 18, 18); + } else { + drawTexturedModalRect(guiWidth + 179, guiHeight + 50, 176 + 25, 90, 18, 18); + } - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88) - { - drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 108, 18, 18); - } - else { - drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 126, 18, 18); - } + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88) { + drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 108, 18, 18); + } else { + drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 126, 18, 18); + } - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 90 && yAxis <= 108) - { - drawTexturedModalRect(guiWidth + 179, guiHeight + 90, 176 + 25, 144, 18, 18); - } - else { - drawTexturedModalRect(guiWidth + 179, guiHeight + 90, 176 + 25, 162, 18, 18); - } - } + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 90 && yAxis <= 108) { + drawTexturedModalRect(guiWidth + 179, guiHeight + 90, 176 + 25, 144, 18, 18); + } else { + drawTexturedModalRect(guiWidth + 179, guiHeight + 90, 176 + 25, 162, 18, 18); + } + } - @Override - protected void mouseClicked(int mouseX, int mouseY, int button) - { - super.mouseClicked(mouseX, mouseY, button); + @Override + protected void mouseClicked(int mouseX, int mouseY, int button) { + super.mouseClicked(mouseX, mouseY, button); - if(button == 0) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + if (button == 0) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) - { + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 0, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 21, mc.theWorld, robit.getEntityId(), 0, 0); - } - else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 30 && yAxis <= 48) - { + Mekanism.packetHandler.sendToServer( + new RobitMessage(RobitPacketType.GUI, 0, robit.getEntityId(), null) + ); + mc.thePlayer.openGui( + Mekanism.instance, 21, mc.theWorld, robit.getEntityId(), 0, 0 + ); + } else if (xAxis >= 179 && xAxis <= 197 && yAxis >= 30 && yAxis <= 48) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 1, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 22, mc.theWorld, robit.getEntityId(), 0, 0); - } - else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 50 && yAxis <= 68) - { + Mekanism.packetHandler.sendToServer( + new RobitMessage(RobitPacketType.GUI, 1, robit.getEntityId(), null) + ); + mc.thePlayer.openGui( + Mekanism.instance, 22, mc.theWorld, robit.getEntityId(), 0, 0 + ); + } else if (xAxis >= 179 && xAxis <= 197 && yAxis >= 50 && yAxis <= 68) { SoundHandler.playSound("gui.button.press"); - } - else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88) - { + } else if (xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 3, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 24, mc.theWorld, robit.getEntityId(), 0, 0); - } - else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 90 && yAxis <= 108) - { + Mekanism.packetHandler.sendToServer( + new RobitMessage(RobitPacketType.GUI, 3, robit.getEntityId(), null) + ); + mc.thePlayer.openGui( + Mekanism.instance, 24, mc.theWorld, robit.getEntityId(), 0, 0 + ); + } else if (xAxis >= 179 && xAxis <= 197 && yAxis >= 90 && yAxis <= 108) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 4, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 25, mc.theWorld, robit.getEntityId(), 0, 0); - } - } - } + Mekanism.packetHandler.sendToServer( + new RobitMessage(RobitPacketType.GUI, 4, robit.getEntityId(), null) + ); + mc.thePlayer.openGui( + Mekanism.instance, 25, mc.theWorld, robit.getEntityId(), 0, 0 + ); + } + } + } } diff --git a/src/main/java/mekanism/client/gui/GuiRobitMain.java b/src/main/java/mekanism/client/gui/GuiRobitMain.java index 3e96ce071..842c42ae1 100644 --- a/src/main/java/mekanism/client/gui/GuiRobitMain.java +++ b/src/main/java/mekanism/client/gui/GuiRobitMain.java @@ -1,5 +1,7 @@ package mekanism.client.gui; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.sound.SoundHandler; import mekanism.common.Mekanism; import mekanism.common.entity.EntityRobit; @@ -12,308 +14,319 @@ import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiTextField; import net.minecraft.entity.player.InventoryPlayer; - import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiRobitMain extends GuiMekanism -{ - public EntityRobit robit; +public class GuiRobitMain extends GuiMekanism { + public EntityRobit robit; - public boolean displayNameChange; + public boolean displayNameChange; - private GuiTextField nameChangeField; - private GuiButton confirmName; + private GuiTextField nameChangeField; + private GuiButton confirmName; - public GuiRobitMain(InventoryPlayer inventory, EntityRobit entity) - { - super(new ContainerRobitMain(inventory, entity)); - xSize += 25; - robit = entity; - } + public GuiRobitMain(InventoryPlayer inventory, EntityRobit entity) { + super(new ContainerRobitMain(inventory, entity)); + xSize += 25; + robit = entity; + } - private void toggleNameChange() - { - displayNameChange = !displayNameChange; - confirmName.visible = displayNameChange; - nameChangeField.setFocused(displayNameChange); - } + private void toggleNameChange() { + displayNameChange = !displayNameChange; + confirmName.visible = displayNameChange; + nameChangeField.setFocused(displayNameChange); + } - private void changeName() - { - if(nameChangeField.getText() != null && !nameChangeField.getText().isEmpty()) - { - Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.NAME, robit.getEntityId(), 0, nameChangeField.getText())); - toggleNameChange(); - nameChangeField.setText(""); - } - } + private void changeName() { + if (nameChangeField.getText() != null && !nameChangeField.getText().isEmpty()) { + Mekanism.packetHandler.sendToServer(new RobitMessage( + RobitPacketType.NAME, robit.getEntityId(), 0, nameChangeField.getText() + )); + toggleNameChange(); + nameChangeField.setText(""); + } + } - @Override - protected void actionPerformed(GuiButton guibutton) - { - if(guibutton.id == 0) - { - changeName(); - } - } + @Override + protected void actionPerformed(GuiButton guibutton) { + if (guibutton.id == 0) { + changeName(); + } + } - @Override - public void initGui() - { - super.initGui(); + @Override + public void initGui() { + super.initGui(); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; - buttonList.clear(); - buttonList.add(confirmName = new GuiButton(0, guiWidth + 58, guiHeight + 47, 60, 20, LangUtils.localize("gui.confirm"))); - confirmName.visible = displayNameChange; + buttonList.clear(); + buttonList.add( + confirmName = new GuiButton( + 0, + guiWidth + 58, + guiHeight + 47, + 60, + 20, + LangUtils.localize("gui.confirm") + ) + ); + confirmName.visible = displayNameChange; - nameChangeField = new GuiTextField(fontRendererObj, guiWidth + 48, guiHeight + 21, 80, 12); - nameChangeField.setMaxStringLength(12); - nameChangeField.setFocused(true); - } + nameChangeField + = new GuiTextField(fontRendererObj, guiWidth + 48, guiHeight + 21, 80, 12); + nameChangeField.setMaxStringLength(12); + nameChangeField.setFocused(true); + } - @Override - public void keyTyped(char c, int i) - { - if(!displayNameChange) - { - super.keyTyped(c, i); - } - else { - if(i == Keyboard.KEY_RETURN) - { - changeName(); - } - else if(i == Keyboard.KEY_ESCAPE) - { - mc.thePlayer.closeScreen(); - } + @Override + public void keyTyped(char c, int i) { + if (!displayNameChange) { + super.keyTyped(c, i); + } else { + if (i == Keyboard.KEY_RETURN) { + changeName(); + } else if (i == Keyboard.KEY_ESCAPE) { + mc.thePlayer.closeScreen(); + } - nameChangeField.textboxKeyTyped(c, i); - } - } + nameChangeField.textboxKeyTyped(c, i); + } + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - fontRendererObj.drawString(LangUtils.localize("gui.robit"), 76, 6, 0x404040); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + fontRendererObj.drawString(LangUtils.localize("gui.robit"), 76, 6, 0x404040); - if(!displayNameChange) - { - CharSequence owner = robit.getOwnerName().length() > 14 ? robit.getOwnerName().subSequence(0, 14) : robit.getOwnerName(); - fontRendererObj.drawString(LangUtils.localize("gui.robit.greeting") + " " + robit.getCommandSenderName() + "!", 29, 18, 0x00CD00); - fontRendererObj.drawString(LangUtils.localize("gui.energy") + ": " + MekanismUtils.getEnergyDisplay(robit.getEnergy()), 29, 36-4, 0x00CD00); - fontRendererObj.drawString(LangUtils.localize("gui.robit.following") + ": " + robit.getFollowing(), 29, 45-4, 0x00CD00); - fontRendererObj.drawString(LangUtils.localize("gui.robit.dropPickup") + ": " + robit.getDropPickup(), 29, 54-4, 0x00CD00); - fontRendererObj.drawString(LangUtils.localize("gui.robit.owner") + ": " + owner, 29, 63-4, 0x00CD00); - } + if (!displayNameChange) { + CharSequence owner = robit.getOwnerName().length() > 14 + ? robit.getOwnerName().subSequence(0, 14) + : robit.getOwnerName(); + fontRendererObj.drawString( + LangUtils.localize("gui.robit.greeting") + " " + + robit.getCommandSenderName() + "!", + 29, + 18, + 0x00CD00 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.energy") + ": " + + MekanismUtils.getEnergyDisplay(robit.getEnergy()), + 29, + 36 - 4, + 0x00CD00 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.robit.following") + ": " + robit.getFollowing(), + 29, + 45 - 4, + 0x00CD00 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.robit.dropPickup") + ": " + robit.getDropPickup(), + 29, + 54 - 4, + 0x00CD00 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.robit.owner") + ": " + owner, 29, 63 - 4, 0x00CD00 + ); + } - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - if(xAxis >= 28 && xAxis <= 148 && yAxis >= 75 && yAxis <= 79) - { - drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(robit.getEnergy()), xAxis, yAxis); - } - else if(xAxis >= 152 && xAxis <= 170 && yAxis >= 54 && yAxis <= 72) - { - drawCreativeTabHoveringText(LangUtils.localize("gui.robit.toggleFollow"), xAxis, yAxis); - } - else if(xAxis >= 6 && xAxis <= 24 && yAxis >= 54 && yAxis <= 72) - { - drawCreativeTabHoveringText(LangUtils.localize("gui.robit.rename"), xAxis, yAxis); - } - else if(xAxis >= 6 && xAxis <= 24 && yAxis >= 16 && yAxis <= 34) - { - drawCreativeTabHoveringText(LangUtils.localize("gui.robit.teleport"), xAxis, yAxis); - } - else if(xAxis >= 6 && xAxis <= 24 && yAxis >= 35 && yAxis <= 53) - { - drawCreativeTabHoveringText(LangUtils.localize("gui.robit.togglePickup"), xAxis, yAxis); - } + if (xAxis >= 28 && xAxis <= 148 && yAxis >= 75 && yAxis <= 79) { + drawCreativeTabHoveringText( + MekanismUtils.getEnergyDisplay(robit.getEnergy()), xAxis, yAxis + ); + } else if (xAxis >= 152 && xAxis <= 170 && yAxis >= 54 && yAxis <= 72) { + drawCreativeTabHoveringText( + LangUtils.localize("gui.robit.toggleFollow"), xAxis, yAxis + ); + } else if (xAxis >= 6 && xAxis <= 24 && yAxis >= 54 && yAxis <= 72) { + drawCreativeTabHoveringText( + LangUtils.localize("gui.robit.rename"), xAxis, yAxis + ); + } else if (xAxis >= 6 && xAxis <= 24 && yAxis >= 16 && yAxis <= 34) { + drawCreativeTabHoveringText( + LangUtils.localize("gui.robit.teleport"), xAxis, yAxis + ); + } else if (xAxis >= 6 && xAxis <= 24 && yAxis >= 35 && yAxis <= 53) { + drawCreativeTabHoveringText( + LangUtils.localize("gui.robit.togglePickup"), xAxis, yAxis + ); + } - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiRobitMain.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiRobitMain.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) - { - drawTexturedModalRect(guiWidth + 179, guiHeight + 10, 176 + 25, 0, 18, 18); - } - else { - drawTexturedModalRect(guiWidth + 179, guiHeight + 10, 176 + 25, 18, 18, 18); - } + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) { + drawTexturedModalRect(guiWidth + 179, guiHeight + 10, 176 + 25, 0, 18, 18); + } else { + drawTexturedModalRect(guiWidth + 179, guiHeight + 10, 176 + 25, 18, 18, 18); + } - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 30 && yAxis <= 48) - { - drawTexturedModalRect(guiWidth + 179, guiHeight + 30, 176 + 25, 36, 18, 18); - } - else { - drawTexturedModalRect(guiWidth + 179, guiHeight + 30, 176 + 25, 54, 18, 18); - } + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 30 && yAxis <= 48) { + drawTexturedModalRect(guiWidth + 179, guiHeight + 30, 176 + 25, 36, 18, 18); + } else { + drawTexturedModalRect(guiWidth + 179, guiHeight + 30, 176 + 25, 54, 18, 18); + } - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 50 && yAxis <= 68) - { - drawTexturedModalRect(guiWidth + 179, guiHeight + 50, 176 + 25, 72, 18, 18); - } - else { - drawTexturedModalRect(guiWidth + 179, guiHeight + 50, 176 + 25, 90, 18, 18); - } + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 50 && yAxis <= 68) { + drawTexturedModalRect(guiWidth + 179, guiHeight + 50, 176 + 25, 72, 18, 18); + } else { + drawTexturedModalRect(guiWidth + 179, guiHeight + 50, 176 + 25, 90, 18, 18); + } - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88) - { - drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 108, 18, 18); - } - else { - drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 126, 18, 18); - } + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88) { + drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 108, 18, 18); + } else { + drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 126, 18, 18); + } - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 90 && yAxis <= 108) - { - drawTexturedModalRect(guiWidth + 179, guiHeight + 90, 176 + 25, 144, 18, 18); - } - else { - drawTexturedModalRect(guiWidth + 179, guiHeight + 90, 176 + 25, 162, 18, 18); - } + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 90 && yAxis <= 108) { + drawTexturedModalRect(guiWidth + 179, guiHeight + 90, 176 + 25, 144, 18, 18); + } else { + drawTexturedModalRect(guiWidth + 179, guiHeight + 90, 176 + 25, 162, 18, 18); + } - if(xAxis >= 152 && xAxis <= 170 && yAxis >= 54 && yAxis <= 72) - { - drawTexturedModalRect(guiWidth + 152, guiHeight + 54, 176 + 25, 180, 18, 18); - } - else { - drawTexturedModalRect(guiWidth + 152, guiHeight + 54, 176 + 25, 198, 18, 18); - } + if (xAxis >= 152 && xAxis <= 170 && yAxis >= 54 && yAxis <= 72) { + drawTexturedModalRect(guiWidth + 152, guiHeight + 54, 176 + 25, 180, 18, 18); + } else { + drawTexturedModalRect(guiWidth + 152, guiHeight + 54, 176 + 25, 198, 18, 18); + } - if(xAxis >= 6 && xAxis <= 24 && yAxis >= 54 && yAxis <= 72) - { - drawTexturedModalRect(guiWidth + 6, guiHeight + 54, 176 + 25, 216, 18, 18); - } - else { - drawTexturedModalRect(guiWidth + 6, guiHeight + 54, 176 + 25, 234, 18, 18); - } + if (xAxis >= 6 && xAxis <= 24 && yAxis >= 54 && yAxis <= 72) { + drawTexturedModalRect(guiWidth + 6, guiHeight + 54, 176 + 25, 216, 18, 18); + } else { + drawTexturedModalRect(guiWidth + 6, guiHeight + 54, 176 + 25, 234, 18, 18); + } - if(xAxis >= 6 && xAxis <= 24 && yAxis >= 16 && yAxis <= 34) - { - drawTexturedModalRect(guiWidth + 6, guiHeight + 16, 176 + 25 + 18, 36, 18, 18); - } - else { - drawTexturedModalRect(guiWidth + 6, guiHeight + 16, 176 + 25 + 18, 54, 18, 18); - } + if (xAxis >= 6 && xAxis <= 24 && yAxis >= 16 && yAxis <= 34) { + drawTexturedModalRect( + guiWidth + 6, guiHeight + 16, 176 + 25 + 18, 36, 18, 18 + ); + } else { + drawTexturedModalRect( + guiWidth + 6, guiHeight + 16, 176 + 25 + 18, 54, 18, 18 + ); + } - if(xAxis >= 6 && xAxis <= 24 && yAxis >= 35 && yAxis <= 53) - { - drawTexturedModalRect(guiWidth + 6, guiHeight + 35, 176 + 25 + 18, 72, 18, 18); - } - else { - drawTexturedModalRect(guiWidth + 6, guiHeight + 35, 176 + 25 + 18, 90, 18, 18); - } + if (xAxis >= 6 && xAxis <= 24 && yAxis >= 35 && yAxis <= 53) { + drawTexturedModalRect( + guiWidth + 6, guiHeight + 35, 176 + 25 + 18, 72, 18, 18 + ); + } else { + drawTexturedModalRect( + guiWidth + 6, guiHeight + 35, 176 + 25 + 18, 90, 18, 18 + ); + } - int displayInt; + int displayInt; - displayInt = getScaledEnergyLevel(120); - drawTexturedModalRect(guiWidth + 28, guiHeight + 75, 0, 166, displayInt, 4); + displayInt = getScaledEnergyLevel(120); + drawTexturedModalRect(guiWidth + 28, guiHeight + 75, 0, 166, displayInt, 4); - if(displayNameChange) - { - drawTexturedModalRect(guiWidth + 28, guiHeight + 17, 0, 166 + 4, 120, 54); - nameChangeField.drawTextBox(); - } - } + if (displayNameChange) { + drawTexturedModalRect(guiWidth + 28, guiHeight + 17, 0, 166 + 4, 120, 54); + nameChangeField.drawTextBox(); + } + } - private int getScaledEnergyLevel(int i) - { - return (int)(robit.getEnergy()*i / robit.MAX_ELECTRICITY); - } + private int getScaledEnergyLevel(int i) { + return (int) (robit.getEnergy() * i / robit.MAX_ELECTRICITY); + } - @Override - public void updateScreen() - { - super.updateScreen(); + @Override + public void updateScreen() { + super.updateScreen(); - nameChangeField.updateCursorCounter(); - } + nameChangeField.updateCursorCounter(); + } - @Override - protected void mouseClicked(int mouseX, int mouseY, int button) - { - super.mouseClicked(mouseX, mouseY, button); + @Override + protected void mouseClicked(int mouseX, int mouseY, int button) { + super.mouseClicked(mouseX, mouseY, button); - nameChangeField.mouseClicked(mouseX, mouseY, button); + nameChangeField.mouseClicked(mouseX, mouseY, button); - if(button == 0) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + if (button == 0) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) - { + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) { SoundHandler.playSound("gui.button.press"); - } - else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 30 && yAxis <= 48) - { + } else if (xAxis >= 179 && xAxis <= 197 && yAxis >= 30 && yAxis <= 48) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 1, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 22, mc.theWorld, robit.getEntityId(), 0, 0); - } - else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 50 && yAxis <= 68) - { + Mekanism.packetHandler.sendToServer( + new RobitMessage(RobitPacketType.GUI, 1, robit.getEntityId(), null) + ); + mc.thePlayer.openGui( + Mekanism.instance, 22, mc.theWorld, robit.getEntityId(), 0, 0 + ); + } else if (xAxis >= 179 && xAxis <= 197 && yAxis >= 50 && yAxis <= 68) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 2, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 23, mc.theWorld, robit.getEntityId(), 0, 0); - } - else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88) - { + Mekanism.packetHandler.sendToServer( + new RobitMessage(RobitPacketType.GUI, 2, robit.getEntityId(), null) + ); + mc.thePlayer.openGui( + Mekanism.instance, 23, mc.theWorld, robit.getEntityId(), 0, 0 + ); + } else if (xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 3, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 24, mc.theWorld, robit.getEntityId(), 0, 0); - } - else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 90 && yAxis <= 108) - { + Mekanism.packetHandler.sendToServer( + new RobitMessage(RobitPacketType.GUI, 3, robit.getEntityId(), null) + ); + mc.thePlayer.openGui( + Mekanism.instance, 24, mc.theWorld, robit.getEntityId(), 0, 0 + ); + } else if (xAxis >= 179 && xAxis <= 197 && yAxis >= 90 && yAxis <= 108) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 4, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 25, mc.theWorld, robit.getEntityId(), 0, 0); - } - else if(xAxis >= 152 && xAxis <= 170 && yAxis >= 54 && yAxis <= 72) - { + Mekanism.packetHandler.sendToServer( + new RobitMessage(RobitPacketType.GUI, 4, robit.getEntityId(), null) + ); + mc.thePlayer.openGui( + Mekanism.instance, 25, mc.theWorld, robit.getEntityId(), 0, 0 + ); + } else if (xAxis >= 152 && xAxis <= 170 && yAxis >= 54 && yAxis <= 72) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.FOLLOW, robit.getEntityId(), 0, null)); - } - else if(xAxis >= 6 && xAxis <= 24 && yAxis >= 54 && yAxis <= 72) - { + Mekanism.packetHandler.sendToServer( + new RobitMessage(RobitPacketType.FOLLOW, robit.getEntityId(), 0, null) + ); + } else if (xAxis >= 6 && xAxis <= 24 && yAxis >= 54 && yAxis <= 72) { SoundHandler.playSound("gui.button.press"); - toggleNameChange(); - } - else if(xAxis >= 6 && xAxis <= 24 && yAxis >= 16 && yAxis <= 34) - { + toggleNameChange(); + } else if (xAxis >= 6 && xAxis <= 24 && yAxis >= 16 && yAxis <= 34) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GO_HOME, robit.getEntityId(), 0, null)); - mc.displayGuiScreen(null); - } - else if(xAxis >= 6 && xAxis <= 24 && yAxis >= 35 && yAxis <= 53) - { + Mekanism.packetHandler.sendToServer(new RobitMessage( + RobitPacketType.GO_HOME, robit.getEntityId(), 0, null + )); + mc.displayGuiScreen(null); + } else if (xAxis >= 6 && xAxis <= 24 && yAxis >= 35 && yAxis <= 53) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.DROP_PICKUP, robit.getEntityId(), 0, null)); - } - } - } + Mekanism.packetHandler.sendToServer(new RobitMessage( + RobitPacketType.DROP_PICKUP, robit.getEntityId(), 0, null + )); + } + } + } } diff --git a/src/main/java/mekanism/client/gui/GuiRobitRepair.java b/src/main/java/mekanism/client/gui/GuiRobitRepair.java index 38b8d46ab..f485d249e 100644 --- a/src/main/java/mekanism/client/gui/GuiRobitRepair.java +++ b/src/main/java/mekanism/client/gui/GuiRobitRepair.java @@ -2,6 +2,8 @@ package mekanism.client.gui; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.sound.SoundHandler; import mekanism.common.Mekanism; import mekanism.common.entity.EntityRobit; @@ -19,258 +21,247 @@ import net.minecraft.inventory.ICrafting; import net.minecraft.item.ItemStack; import net.minecraft.network.play.client.C17PacketCustomPayload; import net.minecraft.util.StatCollector; - import org.apache.commons.io.Charsets; import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiRobitRepair extends GuiMekanism implements ICrafting -{ - private EntityRobit robit; - private ContainerRepair repairContainer; - private GuiTextField itemNameField; - private InventoryPlayer playerInventory; +public class GuiRobitRepair extends GuiMekanism implements ICrafting { + private EntityRobit robit; + private ContainerRepair repairContainer; + private GuiTextField itemNameField; + private InventoryPlayer playerInventory; - public GuiRobitRepair(InventoryPlayer inventory, EntityRobit entity) - { - super(new ContainerRobitRepair(inventory, entity)); - robit = entity; - xSize += 25; - playerInventory = inventory; - repairContainer = (ContainerRobitRepair)inventorySlots; - } + public GuiRobitRepair(InventoryPlayer inventory, EntityRobit entity) { + super(new ContainerRobitRepair(inventory, entity)); + robit = entity; + xSize += 25; + playerInventory = inventory; + repairContainer = (ContainerRobitRepair) inventorySlots; + } - @Override - public void initGui() - { - super.initGui(); - Keyboard.enableRepeatEvents(true); + @Override + public void initGui() { + super.initGui(); + Keyboard.enableRepeatEvents(true); - int i = (width - xSize) / 2; - int j = (height - ySize) / 2; + int i = (width - xSize) / 2; + int j = (height - ySize) / 2; - itemNameField = new GuiTextField(fontRendererObj, i + 62, j + 24, 103, 12); - itemNameField.setTextColor(-1); - itemNameField.setDisabledTextColour(-1); - itemNameField.setEnableBackgroundDrawing(false); - itemNameField.setMaxStringLength(30); - inventorySlots.removeCraftingFromCrafters(this); - inventorySlots.addCraftingToCrafters(this); - } + itemNameField = new GuiTextField(fontRendererObj, i + 62, j + 24, 103, 12); + itemNameField.setTextColor(-1); + itemNameField.setDisabledTextColour(-1); + itemNameField.setEnableBackgroundDrawing(false); + itemNameField.setMaxStringLength(30); + inventorySlots.removeCraftingFromCrafters(this); + inventorySlots.addCraftingToCrafters(this); + } - @Override - public void onGuiClosed() - { - super.onGuiClosed(); - Keyboard.enableRepeatEvents(false); - inventorySlots.removeCraftingFromCrafters(this); - } + @Override + public void onGuiClosed() { + super.onGuiClosed(); + Keyboard.enableRepeatEvents(false); + inventorySlots.removeCraftingFromCrafters(this); + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - GL11.glDisable(GL11.GL_LIGHTING); - fontRendererObj.drawString(LangUtils.localize("container.repair"), 60, 6, 4210752); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + GL11.glDisable(GL11.GL_LIGHTING); + fontRendererObj.drawString( + LangUtils.localize("container.repair"), 60, 6, 4210752 + ); - if(repairContainer.maximumCost > 0) - { - int k = 8453920; - boolean flag = true; - String s = StatCollector.translateToLocalFormatted("container.repair.cost", new Object[] {Integer.valueOf(repairContainer.maximumCost)}); + if (repairContainer.maximumCost > 0) { + int k = 8453920; + boolean flag = true; + String s = StatCollector.translateToLocalFormatted( + "container.repair.cost", + new Object[] { Integer.valueOf(repairContainer.maximumCost) } + ); - if(repairContainer.maximumCost >= 40 && !mc.thePlayer.capabilities.isCreativeMode) - { - s = LangUtils.localize("container.repair.expensive"); - k = 16736352; - } - else if(!repairContainer.getSlot(2).getHasStack()) - { - flag = false; - } - else if(!repairContainer.getSlot(2).canTakeStack(playerInventory.player)) - { - k = 16736352; - } + if (repairContainer.maximumCost >= 40 + && !mc.thePlayer.capabilities.isCreativeMode) { + s = LangUtils.localize("container.repair.expensive"); + k = 16736352; + } else if (!repairContainer.getSlot(2).getHasStack()) { + flag = false; + } else if (!repairContainer.getSlot(2).canTakeStack(playerInventory.player)) { + k = 16736352; + } - if(flag) - { - int l = -16777216 | (k & 16579836) >> 2 | k & -16777216; - int i1 = (xSize - 25) - 8 - fontRendererObj.getStringWidth(s); - byte b0 = 67; + if (flag) { + int l = -16777216 | (k & 16579836) >> 2 | k & -16777216; + int i1 = (xSize - 25) - 8 - fontRendererObj.getStringWidth(s); + byte b0 = 67; - if(fontRendererObj.getUnicodeFlag()) - { - drawRect(i1 - 3, b0 - 2, (xSize - 25) - 7, b0 + 10, -16777216); - drawRect(i1 - 2, b0 - 1, (xSize - 25) - 8, b0 + 9, -12895429); - } - else { - fontRendererObj.drawString(s, i1, b0 + 1, l); - fontRendererObj.drawString(s, i1 + 1, b0, l); - fontRendererObj.drawString(s, i1 + 1, b0 + 1, l); - } + if (fontRendererObj.getUnicodeFlag()) { + drawRect(i1 - 3, b0 - 2, (xSize - 25) - 7, b0 + 10, -16777216); + drawRect(i1 - 2, b0 - 1, (xSize - 25) - 8, b0 + 9, -12895429); + } else { + fontRendererObj.drawString(s, i1, b0 + 1, l); + fontRendererObj.drawString(s, i1 + 1, b0, l); + fontRendererObj.drawString(s, i1 + 1, b0 + 1, l); + } - fontRendererObj.drawString(s, i1, b0, k); - } - } + fontRendererObj.drawString(s, i1, b0, k); + } + } - GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_LIGHTING); - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - @Override - protected void keyTyped(char c, int i) - { - if(itemNameField.textboxKeyTyped(c, i)) - { - repairContainer.updateItemName(itemNameField.getText()); - mc.thePlayer.sendQueue.addToSendQueue(new C17PacketCustomPayload("MC|ItemName", itemNameField.getText().getBytes())); - } - else { - super.keyTyped(c, i); - } - } + @Override + protected void keyTyped(char c, int i) { + if (itemNameField.textboxKeyTyped(c, i)) { + repairContainer.updateItemName(itemNameField.getText()); + mc.thePlayer.sendQueue.addToSendQueue(new C17PacketCustomPayload( + "MC|ItemName", itemNameField.getText().getBytes() + )); + } else { + super.keyTyped(c, i); + } + } - @Override - protected void mouseClicked(int mouseX, int mouseY, int button) - { - super.mouseClicked(mouseX, mouseY, button); + @Override + protected void mouseClicked(int mouseX, int mouseY, int button) { + super.mouseClicked(mouseX, mouseY, button); - itemNameField.mouseClicked(mouseX, mouseY, button); + itemNameField.mouseClicked(mouseX, mouseY, button); - if(button == 0) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + if (button == 0) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) - { + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 0, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 21, mc.theWorld, robit.getEntityId(), 0, 0); - } - else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 30 && yAxis <= 48) - { + Mekanism.packetHandler.sendToServer( + new RobitMessage(RobitPacketType.GUI, 0, robit.getEntityId(), null) + ); + mc.thePlayer.openGui( + Mekanism.instance, 21, mc.theWorld, robit.getEntityId(), 0, 0 + ); + } else if (xAxis >= 179 && xAxis <= 197 && yAxis >= 30 && yAxis <= 48) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 1, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 22, mc.theWorld, robit.getEntityId(), 0, 0); - } - else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 50 && yAxis <= 68) - { + Mekanism.packetHandler.sendToServer( + new RobitMessage(RobitPacketType.GUI, 1, robit.getEntityId(), null) + ); + mc.thePlayer.openGui( + Mekanism.instance, 22, mc.theWorld, robit.getEntityId(), 0, 0 + ); + } else if (xAxis >= 179 && xAxis <= 197 && yAxis >= 50 && yAxis <= 68) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 2, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 23, mc.theWorld, robit.getEntityId(), 0, 0); - } - else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88) - { + Mekanism.packetHandler.sendToServer( + new RobitMessage(RobitPacketType.GUI, 2, robit.getEntityId(), null) + ); + mc.thePlayer.openGui( + Mekanism.instance, 23, mc.theWorld, robit.getEntityId(), 0, 0 + ); + } else if (xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 3, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 24, mc.theWorld, robit.getEntityId(), 0, 0); - } - else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 90 && yAxis <= 108) - { + Mekanism.packetHandler.sendToServer( + new RobitMessage(RobitPacketType.GUI, 3, robit.getEntityId(), null) + ); + mc.thePlayer.openGui( + Mekanism.instance, 24, mc.theWorld, robit.getEntityId(), 0, 0 + ); + } else if (xAxis >= 179 && xAxis <= 197 && yAxis >= 90 && yAxis <= 108) { SoundHandler.playSound("gui.button.press"); - } - } - } + } + } + } - @Override - public void drawScreen(int mouseX, int mouseY, float partialTick) - { - super.drawScreen(mouseX, mouseY, partialTick); + @Override + public void drawScreen(int mouseX, int mouseY, float partialTick) { + super.drawScreen(mouseX, mouseY, partialTick); - GL11.glDisable(GL11.GL_LIGHTING); - itemNameField.drawTextBox(); - } + GL11.glDisable(GL11.GL_LIGHTING); + itemNameField.drawTextBox(); + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiRobitRepair.png")); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiRobitRepair.png") + ); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) - { - drawTexturedModalRect(guiWidth + 179, guiHeight + 10, 176 + 25, 0, 18, 18); - } - else { - drawTexturedModalRect(guiWidth + 179, guiHeight + 10, 176 + 25, 18, 18, 18); - } + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) { + drawTexturedModalRect(guiWidth + 179, guiHeight + 10, 176 + 25, 0, 18, 18); + } else { + drawTexturedModalRect(guiWidth + 179, guiHeight + 10, 176 + 25, 18, 18, 18); + } - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 30 && yAxis <= 48) - { - drawTexturedModalRect(guiWidth + 179, guiHeight + 30, 176 + 25, 36, 18, 18); - } - else { - drawTexturedModalRect(guiWidth + 179, guiHeight + 30, 176 + 25, 54, 18, 18); - } + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 30 && yAxis <= 48) { + drawTexturedModalRect(guiWidth + 179, guiHeight + 30, 176 + 25, 36, 18, 18); + } else { + drawTexturedModalRect(guiWidth + 179, guiHeight + 30, 176 + 25, 54, 18, 18); + } - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 50 && yAxis <= 68) - { - drawTexturedModalRect(guiWidth + 179, guiHeight + 50, 176 + 25, 72, 18, 18); - } - else { - drawTexturedModalRect(guiWidth + 179, guiHeight + 50, 176 + 25, 90, 18, 18); - } + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 50 && yAxis <= 68) { + drawTexturedModalRect(guiWidth + 179, guiHeight + 50, 176 + 25, 72, 18, 18); + } else { + drawTexturedModalRect(guiWidth + 179, guiHeight + 50, 176 + 25, 90, 18, 18); + } - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88) - { - drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 108, 18, 18); - } - else { - drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 126, 18, 18); - } + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88) { + drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 108, 18, 18); + } else { + drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 126, 18, 18); + } - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 90 && yAxis <= 108) - { - drawTexturedModalRect(guiWidth + 179, guiHeight + 90, 176 + 25, 144, 18, 18); - } - else { - drawTexturedModalRect(guiWidth + 179, guiHeight + 90, 176 + 25, 162, 18, 18); - } + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 90 && yAxis <= 108) { + drawTexturedModalRect(guiWidth + 179, guiHeight + 90, 176 + 25, 144, 18, 18); + } else { + drawTexturedModalRect(guiWidth + 179, guiHeight + 90, 176 + 25, 162, 18, 18); + } - drawTexturedModalRect(guiWidth + 59, guiHeight + 20, 0, ySize + (repairContainer.getSlot(0).getHasStack() ? 0 : 16), 110, 16); + drawTexturedModalRect( + guiWidth + 59, + guiHeight + 20, + 0, + ySize + (repairContainer.getSlot(0).getHasStack() ? 0 : 16), + 110, + 16 + ); - if((repairContainer.getSlot(0).getHasStack() || repairContainer.getSlot(1).getHasStack()) && !repairContainer.getSlot(2).getHasStack()) - { - drawTexturedModalRect(guiWidth + 99, guiHeight + 45, xSize + 18, 36, 28, 21); - } - } + if ((repairContainer.getSlot(0).getHasStack() + || repairContainer.getSlot(1).getHasStack()) + && !repairContainer.getSlot(2).getHasStack()) { + drawTexturedModalRect(guiWidth + 99, guiHeight + 45, xSize + 18, 36, 28, 21); + } + } - @Override - public void sendContainerAndContentsToPlayer(Container container, List list) - { - sendSlotContents(container, 0, container.getSlot(0).getStack()); - } + @Override + public void sendContainerAndContentsToPlayer(Container container, List list) { + sendSlotContents(container, 0, container.getSlot(0).getStack()); + } - @Override - public void sendSlotContents(Container container, int slotID, ItemStack itemstack) - { - if(slotID == 0) - { - itemNameField.setText(itemstack == null ? "" : itemstack.getDisplayName()); - itemNameField.setEnabled(itemstack != null); + @Override + public void sendSlotContents(Container container, int slotID, ItemStack itemstack) { + if (slotID == 0) { + itemNameField.setText(itemstack == null ? "" : itemstack.getDisplayName()); + itemNameField.setEnabled(itemstack != null); - if(itemstack != null) - { - repairContainer.updateItemName(itemNameField.getText()); - mc.thePlayer.sendQueue.addToSendQueue(new C17PacketCustomPayload("MC|ItemName", itemNameField.getText().getBytes(Charsets.UTF_8))); - } - } - } + if (itemstack != null) { + repairContainer.updateItemName(itemNameField.getText()); + mc.thePlayer.sendQueue.addToSendQueue(new C17PacketCustomPayload( + "MC|ItemName", itemNameField.getText().getBytes(Charsets.UTF_8) + )); + } + } + } - @Override - public void sendProgressBarUpdate(Container par1Container, int par2, int par3) {} + @Override + public void sendProgressBarUpdate(Container par1Container, int par2, int par3) {} } diff --git a/src/main/java/mekanism/client/gui/GuiRobitSmelting.java b/src/main/java/mekanism/client/gui/GuiRobitSmelting.java index 0f0740e27..61340d19b 100644 --- a/src/main/java/mekanism/client/gui/GuiRobitSmelting.java +++ b/src/main/java/mekanism/client/gui/GuiRobitSmelting.java @@ -10,148 +10,150 @@ import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.entity.player.InventoryPlayer; - import org.lwjgl.opengl.GL11; -public class GuiRobitSmelting extends GuiMekanism -{ - public EntityRobit robit; +public class GuiRobitSmelting extends GuiMekanism { + public EntityRobit robit; - public GuiRobitSmelting(InventoryPlayer inventory, EntityRobit entity) - { - super(new ContainerRobitSmelting(inventory, entity)); - robit = entity; - xSize += 25; - } + public GuiRobitSmelting(InventoryPlayer inventory, EntityRobit entity) { + super(new ContainerRobitSmelting(inventory, entity)); + robit = entity; + xSize += 25; + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - fontRendererObj.drawString(LangUtils.localize("gui.robit.smelting"), 8, 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, ySize - 96 + 3, 0x404040); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + fontRendererObj.drawString( + LangUtils.localize("gui.robit.smelting"), 8, 6, 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, ySize - 96 + 3, 0x404040 + ); - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiRobitSmelting.png")); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiRobitSmelting.png") + ); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) - { - drawTexturedModalRect(guiWidth + 179, guiHeight + 10, 176 + 25, 0, 18, 18); - } - else { - drawTexturedModalRect(guiWidth + 179, guiHeight + 10, 176 + 25, 18, 18, 18); - } + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) { + drawTexturedModalRect(guiWidth + 179, guiHeight + 10, 176 + 25, 0, 18, 18); + } else { + drawTexturedModalRect(guiWidth + 179, guiHeight + 10, 176 + 25, 18, 18, 18); + } - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 30 && yAxis <= 48) - { - drawTexturedModalRect(guiWidth + 179, guiHeight + 30, 176 + 25, 36, 18, 18); - } - else { - drawTexturedModalRect(guiWidth + 179, guiHeight + 30, 176 + 25, 54, 18, 18); - } + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 30 && yAxis <= 48) { + drawTexturedModalRect(guiWidth + 179, guiHeight + 30, 176 + 25, 36, 18, 18); + } else { + drawTexturedModalRect(guiWidth + 179, guiHeight + 30, 176 + 25, 54, 18, 18); + } - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 50 && yAxis <= 68) - { - drawTexturedModalRect(guiWidth + 179, guiHeight + 50, 176 + 25, 72, 18, 18); - } - else { - drawTexturedModalRect(guiWidth + 179, guiHeight + 50, 176 + 25, 90, 18, 18); - } + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 50 && yAxis <= 68) { + drawTexturedModalRect(guiWidth + 179, guiHeight + 50, 176 + 25, 72, 18, 18); + } else { + drawTexturedModalRect(guiWidth + 179, guiHeight + 50, 176 + 25, 90, 18, 18); + } - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88) - { - drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 108, 18, 18); - } - else { - drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 126, 18, 18); - } + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88) { + drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 108, 18, 18); + } else { + drawTexturedModalRect(guiWidth + 179, guiHeight + 70, 176 + 25, 126, 18, 18); + } - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 90 && yAxis <= 108) - { - drawTexturedModalRect(guiWidth + 179, guiHeight + 90, 176 + 25, 144, 18, 18); - } - else { - drawTexturedModalRect(guiWidth + 179, guiHeight + 90, 176 + 25, 162, 18, 18); - } + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 90 && yAxis <= 108) { + drawTexturedModalRect(guiWidth + 179, guiHeight + 90, 176 + 25, 144, 18, 18); + } else { + drawTexturedModalRect(guiWidth + 179, guiHeight + 90, 176 + 25, 162, 18, 18); + } - int displayInt; + int displayInt; - if(robit.furnaceBurnTime > 0) - { - displayInt = getBurnTimeRemainingScaled(12); - drawTexturedModalRect(guiWidth + 56, guiHeight + 36 + 12 - displayInt, 176 + 25 + 18, 36 + 12 - displayInt, 14, displayInt + 2); - } + if (robit.furnaceBurnTime > 0) { + displayInt = getBurnTimeRemainingScaled(12); + drawTexturedModalRect( + guiWidth + 56, + guiHeight + 36 + 12 - displayInt, + 176 + 25 + 18, + 36 + 12 - displayInt, + 14, + displayInt + 2 + ); + } - displayInt = getCookProgressScaled(24); - drawTexturedModalRect(guiWidth + 79, guiHeight + 34, 176 + 25 + 18, 36 + 14, displayInt + 1, 16); - } + displayInt = getCookProgressScaled(24); + drawTexturedModalRect( + guiWidth + 79, guiHeight + 34, 176 + 25 + 18, 36 + 14, displayInt + 1, 16 + ); + } - @Override - protected void mouseClicked(int mouseX, int mouseY, int button) - { - super.mouseClicked(mouseX, mouseY, button); + @Override + protected void mouseClicked(int mouseX, int mouseY, int button) { + super.mouseClicked(mouseX, mouseY, button); - if(button == 0) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + if (button == 0) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) - { + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 0, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 21, mc.theWorld, robit.getEntityId(), 0, 0); - } - else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 30 && yAxis <= 48) - { + Mekanism.packetHandler.sendToServer( + new RobitMessage(RobitPacketType.GUI, 0, robit.getEntityId(), null) + ); + mc.thePlayer.openGui( + Mekanism.instance, 21, mc.theWorld, robit.getEntityId(), 0, 0 + ); + } else if (xAxis >= 179 && xAxis <= 197 && yAxis >= 30 && yAxis <= 48) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 1, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 22, mc.theWorld, robit.getEntityId(), 0, 0); - } - else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 50 && yAxis <= 68) - { + Mekanism.packetHandler.sendToServer( + new RobitMessage(RobitPacketType.GUI, 1, robit.getEntityId(), null) + ); + mc.thePlayer.openGui( + Mekanism.instance, 22, mc.theWorld, robit.getEntityId(), 0, 0 + ); + } else if (xAxis >= 179 && xAxis <= 197 && yAxis >= 50 && yAxis <= 68) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 2, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 23, mc.theWorld, robit.getEntityId(), 0, 0); - } - else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88) - { + Mekanism.packetHandler.sendToServer( + new RobitMessage(RobitPacketType.GUI, 2, robit.getEntityId(), null) + ); + mc.thePlayer.openGui( + Mekanism.instance, 23, mc.theWorld, robit.getEntityId(), 0, 0 + ); + } else if (xAxis >= 179 && xAxis <= 197 && yAxis >= 70 && yAxis <= 88) { SoundHandler.playSound("gui.button.press"); - } - else if(xAxis >= 179 && xAxis <= 197 && yAxis >= 90 && yAxis <= 108) - { + } else if (xAxis >= 179 && xAxis <= 197 && yAxis >= 90 && yAxis <= 108) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new RobitMessage(RobitPacketType.GUI, 4, robit.getEntityId(), null)); - mc.thePlayer.openGui(Mekanism.instance, 25, mc.theWorld, robit.getEntityId(), 0, 0); - } - } - } + Mekanism.packetHandler.sendToServer( + new RobitMessage(RobitPacketType.GUI, 4, robit.getEntityId(), null) + ); + mc.thePlayer.openGui( + Mekanism.instance, 25, mc.theWorld, robit.getEntityId(), 0, 0 + ); + } + } + } - private int getCookProgressScaled(int i) - { - return robit.furnaceCookTime * i / 200; - } + private int getCookProgressScaled(int i) { + return robit.furnaceCookTime * i / 200; + } - private int getBurnTimeRemainingScaled(int i) - { - if(robit.currentItemBurnTime == 0) - { - robit.currentItemBurnTime = 200; - } + private int getBurnTimeRemainingScaled(int i) { + if (robit.currentItemBurnTime == 0) { + robit.currentItemBurnTime = 200; + } - return robit.furnaceBurnTime * i / robit.currentItemBurnTime; - } + return robit.furnaceBurnTime * i / robit.currentItemBurnTime; + } } diff --git a/src/main/java/mekanism/client/gui/GuiRotaryCondensentrator.java b/src/main/java/mekanism/client/gui/GuiRotaryCondensentrator.java index 02d6614fe..84660281c 100644 --- a/src/main/java/mekanism/client/gui/GuiRotaryCondensentrator.java +++ b/src/main/java/mekanism/client/gui/GuiRotaryCondensentrator.java @@ -3,6 +3,8 @@ package mekanism.client.gui; import java.util.ArrayList; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.gas.GasTank; import mekanism.api.util.ListUtils; @@ -32,153 +34,244 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.entity.player.InventoryPlayer; import net.minecraftforge.fluids.FluidTank; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiRotaryCondensentrator extends GuiMekanism -{ - public TileEntityRotaryCondensentrator tileEntity; +public class GuiRotaryCondensentrator extends GuiMekanism { + public TileEntityRotaryCondensentrator tileEntity; - public GuiRotaryCondensentrator(InventoryPlayer inventory, TileEntityRotaryCondensentrator tentity) - { - super(tentity, new ContainerRotaryCondensentrator(inventory, tentity)); - tileEntity = tentity; + public GuiRotaryCondensentrator( + InventoryPlayer inventory, TileEntityRotaryCondensentrator tentity + ) { + super(tentity, new ContainerRotaryCondensentrator(inventory, tentity)); + tileEntity = tentity; - guiElements.add(new GuiSecurityTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png"))); - guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png"))); - guiElements.add(new GuiUpgradeTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png"))); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png"), 4, 24).with(SlotOverlay.PLUS)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png"), 4, 55).with(SlotOverlay.MINUS)); + guiElements.add(new GuiSecurityTab( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png") + )); + guiElements.add(new GuiRedstoneControl( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png") + )); + guiElements.add(new GuiUpgradeTab( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png") + )); + guiElements.add(new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource( + ResourceType.GUI, "GuiRotaryCondensentrator.png" + ), + 4, + 24 + ) + .with(SlotOverlay.PLUS)); + guiElements.add(new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource( + ResourceType.GUI, "GuiRotaryCondensentrator.png" + ), + 4, + 55 + ) + .with(SlotOverlay.MINUS)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png"), 154, 24)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png"), 154, 55)); + guiElements.add(new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png"), + 154, + 24 + )); + guiElements.add(new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png"), + 154, + 55 + )); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png"), 154, 4).with(SlotOverlay.POWER)); - - guiElements.add(new GuiEnergyInfo(new IInfoHandler() { - @Override - public List getInfo() - { - String usage = MekanismUtils.getEnergyDisplay(tileEntity.clientEnergyUsed); - return ListUtils.asList(LangUtils.localize("gui.using") + ": " + usage + "/t", LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); - } - }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png"))); - guiElements.add(new GuiFluidGauge(new IFluidInfoHandler() { - @Override - public FluidTank getTank() - { - return tileEntity.fluidTank; - } - }, GuiGauge.Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png"), 133, 13)); - guiElements.add(new GuiGasGauge(new IGasInfoHandler() { - @Override - public GasTank getTank() - { - return tileEntity.gasTank; - } - }, GuiGauge.Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png"), 25, 13)); + guiElements.add(new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource( + ResourceType.GUI, "GuiRotaryCondensentrator.png" + ), + 154, + 4 + ) + .with(SlotOverlay.POWER)); - guiElements.add(new GuiProgress(new IProgressInfoHandler() - { - @Override - public double getProgress() - { - return tileEntity.isActive ? 1 : 0; - } + guiElements.add(new GuiEnergyInfo( + new IInfoHandler() { + @Override + public List getInfo() { + String usage + = MekanismUtils.getEnergyDisplay(tileEntity.clientEnergyUsed); + return ListUtils.asList( + LangUtils.localize("gui.using") + ": " + usage + "/t", + LangUtils.localize("gui.needed") + ": " + + MekanismUtils.getEnergyDisplay( + tileEntity.getMaxEnergy() - tileEntity.getEnergy() + ) + ); + } + }, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png") + )); + guiElements.add(new GuiFluidGauge( + new IFluidInfoHandler() { + @Override + public FluidTank getTank() { + return tileEntity.fluidTank; + } + }, + GuiGauge.Type.STANDARD, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png"), + 133, + 13 + )); + guiElements.add(new GuiGasGauge( + new IGasInfoHandler() { + @Override + public GasTank getTank() { + return tileEntity.gasTank; + } + }, + GuiGauge.Type.STANDARD, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png"), + 25, + 13 + )); - @Override - public boolean isActive() - { - return tileEntity.mode == 0; - } - }, ProgressBar.LARGE_RIGHT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png"), 62, 38)); - guiElements.add(new GuiProgress(new IProgressInfoHandler() - { - @Override - public double getProgress() - { - return tileEntity.isActive ? 1 : 0; - } + guiElements.add(new GuiProgress( + new IProgressInfoHandler() { + @Override + public double getProgress() { + return tileEntity.isActive ? 1 : 0; + } - @Override - public boolean isActive() - { - return tileEntity.mode == 1; - } - }, ProgressBar.LARGE_LEFT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png"), 62, 38)); - } + @Override + public boolean isActive() { + return tileEntity.mode == 0; + } + }, + ProgressBar.LARGE_RIGHT, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png"), + 62, + 38 + )); + guiElements.add(new GuiProgress( + new IProgressInfoHandler() { + @Override + public double getProgress() { + return tileEntity.isActive ? 1 : 0; + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + @Override + public boolean isActive() { + return tileEntity.mode == 1; + } + }, + ProgressBar.LARGE_LEFT, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png"), + 62, + 38 + )); + } - fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize/2)-(fontRendererObj.getStringWidth(tileEntity.getInventoryName())/2), 4, 0x404040); - fontRendererObj.drawString(tileEntity.mode == 0 ? LangUtils.localize("gui.condensentrating") : LangUtils.localize("gui.decondensentrating"), 6, (ySize - 94) + 2, 0x404040); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - if(xAxis >= 116 && xAxis <= 168 && yAxis >= 76 && yAxis <= 80) - { - drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis); - } + fontRendererObj.drawString( + tileEntity.getInventoryName(), + (xSize / 2) + - (fontRendererObj.getStringWidth(tileEntity.getInventoryName()) / 2), + 4, + 0x404040 + ); + fontRendererObj.drawString( + tileEntity.mode == 0 ? LangUtils.localize("gui.condensentrating") + : LangUtils.localize("gui.decondensentrating"), + 6, + (ySize - 94) + 2, + 0x404040 + ); - if(xAxis >= 4 && xAxis <= 22 && yAxis >= 4 && yAxis <= 22) - { - drawCreativeTabHoveringText(LangUtils.localize("gui.rotaryCondensentrator.toggleOperation"), xAxis, yAxis); - } + if (xAxis >= 116 && xAxis <= 168 && yAxis >= 76 && yAxis <= 80) { + drawCreativeTabHoveringText( + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis + ); + } - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + if (xAxis >= 4 && xAxis <= 22 && yAxis >= 4 && yAxis <= 22) { + drawCreativeTabHoveringText( + LangUtils.localize("gui.rotaryCondensentrator.toggleOperation"), + xAxis, + yAxis + ); + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - int displayInt; + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + int displayInt; - displayInt = tileEntity.getScaledEnergyLevel(52); - drawTexturedModalRect(guiWidth + 116, guiHeight + 76, 176, 36, displayInt, 4); + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - if(xAxis >= 4 && xAxis <= 22 && yAxis >= 4 && yAxis <= 22) - { - drawTexturedModalRect(guiWidth + 4, guiHeight + 4, 176, 0, 18, 18); - } - else { - drawTexturedModalRect(guiWidth + 4, guiHeight + 4, 176, 18, 18, 18); - } + displayInt = tileEntity.getScaledEnergyLevel(52); + drawTexturedModalRect(guiWidth + 116, guiHeight + 76, 176, 36, displayInt, 4); - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } + if (xAxis >= 4 && xAxis <= 22 && yAxis >= 4 && yAxis <= 22) { + drawTexturedModalRect(guiWidth + 4, guiHeight + 4, 176, 0, 18, 18); + } else { + drawTexturedModalRect(guiWidth + 4, guiHeight + 4, 176, 18, 18, 18); + } - @Override - protected void mouseClicked(int mouseX, int mouseY, int button) - { - super.mouseClicked(mouseX, mouseY, button); + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } - if(button == 0) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + @Override + protected void mouseClicked(int mouseX, int mouseY, int button) { + super.mouseClicked(mouseX, mouseY, button); - if(xAxis >= 4 && xAxis <= 22 && yAxis >= 4 && yAxis <= 22) - { - ArrayList data = new ArrayList(); - data.add(0); + if (button == 0) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); + if (xAxis >= 4 && xAxis <= 22 && yAxis >= 4 && yAxis <= 22) { + ArrayList data = new ArrayList(); + data.add(0); + + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); SoundHandler.playSound("gui.button.press"); - } - } - } + } + } + } } diff --git a/src/main/java/mekanism/client/gui/GuiSecurityDesk.java b/src/main/java/mekanism/client/gui/GuiSecurityDesk.java index fa9fa0a9d..963c44274 100644 --- a/src/main/java/mekanism/client/gui/GuiSecurityDesk.java +++ b/src/main/java/mekanism/client/gui/GuiSecurityDesk.java @@ -4,6 +4,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.client.gui.element.GuiScrollList; @@ -21,365 +23,365 @@ import net.minecraft.client.gui.GuiTextField; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.ResourceLocation; - import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiSecurityDesk extends GuiMekanism -{ - public static int MAX_LENGTH = 24; - - public ResourceLocation resource; - - public TileEntitySecurityDesk tileEntity; - - public EntityPlayer entityPlayer; - - public GuiButton removeButton; - - public GuiScrollList scrollList; - - public GuiTextField trustedField; - - public static final List SPECIAL_CHARS = Arrays.asList('-', '|', '_'); +public class GuiSecurityDesk extends GuiMekanism { + public static int MAX_LENGTH = 24; - public GuiSecurityDesk(InventoryPlayer inventory, TileEntitySecurityDesk tentity) - { - super(tentity, new ContainerSecurityDesk(inventory, tentity)); - tileEntity = tentity; - resource = MekanismUtils.getResource(ResourceType.GUI, "GuiSecurityDesk.png"); + public ResourceLocation resource; - guiElements.add(scrollList = new GuiScrollList(this, resource, 14, 14, 120, 4)); - - ySize+=64; - } - - @Override - public void initGui() - { - super.initGui(); + public TileEntitySecurityDesk tileEntity; - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; + public EntityPlayer entityPlayer; - buttonList.clear(); + public GuiButton removeButton; - removeButton = new GuiButton(0, guiWidth + 13, guiHeight + 81, 122, 20, LangUtils.localize("gui.remove")); - - trustedField = new GuiTextField(fontRendererObj, guiWidth + 35, guiHeight + 69, 86, 11); - trustedField.setMaxStringLength(MAX_LENGTH); - trustedField.setEnableBackgroundDrawing(false); - - updateButtons(); + public GuiScrollList scrollList; - buttonList.add(removeButton); - } - - public void addTrusted(String trusted) - { - if(trusted.isEmpty()) - { - return; - } - - ArrayList data = new ArrayList(); - data.add(0); - data.add(trusted); - - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - } - - public void updateButtons() - { - if(tileEntity.owner == null) - { - return; - } - - List text = new ArrayList(); - - if(tileEntity.frequency != null) - { - for(String s : tileEntity.frequency.trusted) - { - text.add(s); - } - } - - scrollList.setText(text); - - if(scrollList.hasSelection()) - { - removeButton.enabled = true; - } - else { - removeButton.enabled = false; - } - } - - @Override - public void updateScreen() - { - super.updateScreen(); - - updateButtons(); - - trustedField.updateCursorCounter(); - } - - @Override - public void mouseClicked(int mouseX, int mouseY, int button) - { - super.mouseClicked(mouseX, mouseY, button); - - updateButtons(); + public GuiTextField trustedField; - trustedField.mouseClicked(mouseX, mouseY, button); - - if(button == 0) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); - - if(tileEntity.frequency != null && tileEntity.owner != null && tileEntity.owner.equals(mc.thePlayer.getCommandSenderName())) - { - if(xAxis >= 123 && xAxis <= 134 && yAxis >= 68 && yAxis <= 79) - { - addTrusted(trustedField.getText()); - trustedField.setText(""); - SoundHandler.playSound("gui.button.press"); - } - - ArrayList data = new ArrayList(); - - if(xAxis >= 146 && xAxis <= 162 && yAxis >= 59 && yAxis <= 75) - { - data.add(2); - } - - if(tileEntity.frequency.securityMode != SecurityMode.PUBLIC) - { - if(xAxis >= 13 && xAxis <= 53 && yAxis >= 113 && yAxis <= 129) - { - data.add(3); - data.add(0); - } - } - - if(tileEntity.frequency.securityMode != SecurityMode.PRIVATE) - { - if(xAxis >= 54 && xAxis <= 94 && yAxis >= 113 && yAxis <= 129) - { - data.add(3); - data.add(1); - } - } - - if(tileEntity.frequency.securityMode != SecurityMode.TRUSTED) - { - if(xAxis >= 95 && xAxis <= 135 && yAxis >= 113 && yAxis <= 129) - { - data.add(3); - data.add(2); - } - } - - if(!data.isEmpty()) - { - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - } - } - } - } - - @Override - public void keyTyped(char c, int i) - { - if(!trustedField.isFocused() || i == Keyboard.KEY_ESCAPE) - { - super.keyTyped(c, i); - } + public static final List SPECIAL_CHARS = Arrays.asList('-', '|', '_'); - if(i == Keyboard.KEY_RETURN) - { - if(trustedField.isFocused()) - { - addTrusted(trustedField.getText()); - trustedField.setText(""); - } - } + public GuiSecurityDesk(InventoryPlayer inventory, TileEntitySecurityDesk tentity) { + super(tentity, new ContainerSecurityDesk(inventory, tentity)); + tileEntity = tentity; + resource = MekanismUtils.getResource(ResourceType.GUI, "GuiSecurityDesk.png"); - if(SPECIAL_CHARS.contains(c) || Character.isDigit(c) || Character.isLetter(c) || isTextboxKey(c, i)) - { - trustedField.textboxKeyTyped(c, i); - } - - updateButtons(); - } - - @Override - protected void actionPerformed(GuiButton guibutton) - { - super.actionPerformed(guibutton); + guiElements.add(scrollList = new GuiScrollList(this, resource, 14, 14, 120, 4)); - if(guibutton.id == 0) - { - int selection = scrollList.getSelection(); - - if(tileEntity.frequency != null && selection != -1) - { - if(tileEntity != null) - { - ArrayList data = new ArrayList(); - data.add(1); - data.add(tileEntity.frequency.trusted.get(selection)); - - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - } - - scrollList.selected = -1; - } - } - - updateButtons(); - } + ySize += 64; + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX-(width-xSize)/2); - int yAxis = (mouseY-(height-ySize)/2); + @Override + public void initGui() { + super.initGui(); - String ownerText = EnumColor.RED + tileEntity.owner != null ? (LangUtils.localize("gui.owner") + ": " + tileEntity.owner) : LangUtils.localize("gui.noOwner"); - fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize/2)-(fontRendererObj.getStringWidth(tileEntity.getInventoryName())/2), 4, 0x404040); - fontRendererObj.drawString(ownerText, (xSize - 7) - fontRendererObj.getStringWidth(ownerText), (ySize - 96) + 2, 0x404040); - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); - - String trusted = LangUtils.localize("gui.trustedPlayers"); - fontRendererObj.drawString(trusted, 74-(fontRendererObj.getStringWidth(trusted)/2), 57, 0x787878); - - String security = EnumColor.RED + LangUtils.localize("gui.securityOffline"); - - if(tileEntity.frequency != null) - { - security = LangUtils.localize("gui.security") + ": " + tileEntity.frequency.securityMode.getDisplay(); - } - - fontRendererObj.drawString(security, 13, 103, 0x404040); - - renderScaledText(LangUtils.localize("gui.add") + ":", 13, 70, 0x404040, 20); - - if(tileEntity.frequency != null && xAxis >= 146 && xAxis <= 162 && yAxis >= 59 && yAxis <= 75) - { - displayTooltip(LangUtils.localize("gui.securityOverride") + ": " + LangUtils.transOnOff(tileEntity.frequency.override), xAxis, yAxis); - } - - if(xAxis >= 13 && xAxis <= 53 && yAxis >= 113 && yAxis <= 129) - { - displayTooltip(LangUtils.localize("gui.publicMode"), xAxis, yAxis); - } - - if(xAxis >= 54 && xAxis <= 94 && yAxis >= 113 && yAxis <= 129) - { - displayTooltip(LangUtils.localize("gui.privateMode"), xAxis, yAxis); - } - - if(xAxis >= 95 && xAxis <= 135 && yAxis >= 113 && yAxis <= 129) - { - displayTooltip(LangUtils.localize("gui.trustedMode"), xAxis, yAxis); - } + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + buttonList.clear(); - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(resource); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width-xSize)/2; - int guiHeight = (height-ySize)/2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); - - if(tileEntity.frequency != null && tileEntity.owner != null && mc.thePlayer.getCommandSenderName().equals(tileEntity.owner)) - { - drawTexturedModalRect(guiWidth + 145, guiHeight + 78, xSize + (tileEntity.frequency.override ? 0 : 6), 22, 6, 6); - - if(xAxis >= 146 && xAxis <= 162 && yAxis >= 59 && yAxis <= 75) - { - drawTexturedModalRect(guiWidth + 146, guiHeight + 59, xSize + 12, 0, 16, 16); - } - else { - drawTexturedModalRect(guiWidth + 146, guiHeight + 59, xSize + 12, 16, 16, 16); - } - - if(tileEntity.frequency.securityMode != SecurityMode.PUBLIC) - { - if(xAxis >= 13 && xAxis <= 53 && yAxis >= 113 && yAxis <= 129) - { - drawTexturedModalRect(guiWidth + 13, guiHeight + 113, xSize, 48, 40, 16); - } - else { - drawTexturedModalRect(guiWidth + 13, guiHeight + 113, xSize, 64, 40, 16); - } - } - else { - drawTexturedModalRect(guiWidth + 13, guiHeight + 113, xSize, 80, 40, 16); - } - - if(tileEntity.frequency.securityMode != SecurityMode.PRIVATE) - { - if(xAxis >= 54 && xAxis <= 94 && yAxis >= 113 && yAxis <= 129) - { - drawTexturedModalRect(guiWidth + 54, guiHeight + 113, xSize + 40, 48, 40, 16); - } - else { - drawTexturedModalRect(guiWidth + 54, guiHeight + 113, xSize + 40, 64, 40, 16); - } - } - else { - drawTexturedModalRect(guiWidth + 54, guiHeight + 113, xSize + 40, 80, 40, 16); - } - - if(tileEntity.frequency.securityMode != SecurityMode.TRUSTED) - { - if(xAxis >= 95 && xAxis <= 135 && yAxis >= 113 && yAxis <= 129) - { - drawTexturedModalRect(guiWidth + 95, guiHeight + 113, xSize, 96, 40, 16); - } - else { - drawTexturedModalRect(guiWidth + 95, guiHeight + 113, xSize, 112, 40, 16); - } - } - else { - drawTexturedModalRect(guiWidth + 95, guiHeight + 113, xSize, 128, 40, 16); - } - } - else { - drawTexturedModalRect(guiWidth + 145, guiHeight + 78, xSize, 28, 6, 6); - drawTexturedModalRect(guiWidth + 146, guiHeight + 59, xSize + 12, 32, 16, 16); - drawTexturedModalRect(guiWidth + 13, guiHeight + 113, xSize, 80, 40, 16); - drawTexturedModalRect(guiWidth + 54, guiHeight + 113, xSize + 40, 80, 40, 16); - drawTexturedModalRect(guiWidth + 95, guiHeight + 113, xSize, 128, 40, 16); - } - - if(xAxis >= 123 && xAxis <= 134 && yAxis >= 68 && yAxis <= 79) - { - drawTexturedModalRect(guiWidth + 123, guiHeight + 68, xSize, 0, 11, 11); - } - else { - drawTexturedModalRect(guiWidth + 123, guiHeight + 68, xSize, 11, 11, 11); - } + removeButton = new GuiButton( + 0, guiWidth + 13, guiHeight + 81, 122, 20, LangUtils.localize("gui.remove") + ); - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - - trustedField.drawTextBox(); - } + trustedField + = new GuiTextField(fontRendererObj, guiWidth + 35, guiHeight + 69, 86, 11); + trustedField.setMaxStringLength(MAX_LENGTH); + trustedField.setEnableBackgroundDrawing(false); + + updateButtons(); + + buttonList.add(removeButton); + } + + public void addTrusted(String trusted) { + if (trusted.isEmpty()) { + return; + } + + ArrayList data = new ArrayList(); + data.add(0); + data.add(trusted); + + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); + } + + public void updateButtons() { + if (tileEntity.owner == null) { + return; + } + + List text = new ArrayList(); + + if (tileEntity.frequency != null) { + for (String s : tileEntity.frequency.trusted) { + text.add(s); + } + } + + scrollList.setText(text); + + if (scrollList.hasSelection()) { + removeButton.enabled = true; + } else { + removeButton.enabled = false; + } + } + + @Override + public void updateScreen() { + super.updateScreen(); + + updateButtons(); + + trustedField.updateCursorCounter(); + } + + @Override + public void mouseClicked(int mouseX, int mouseY, int button) { + super.mouseClicked(mouseX, mouseY, button); + + updateButtons(); + + trustedField.mouseClicked(mouseX, mouseY, button); + + if (button == 0) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + if (tileEntity.frequency != null && tileEntity.owner != null + && tileEntity.owner.equals(mc.thePlayer.getCommandSenderName())) { + if (xAxis >= 123 && xAxis <= 134 && yAxis >= 68 && yAxis <= 79) { + addTrusted(trustedField.getText()); + trustedField.setText(""); + SoundHandler.playSound("gui.button.press"); + } + + ArrayList data = new ArrayList(); + + if (xAxis >= 146 && xAxis <= 162 && yAxis >= 59 && yAxis <= 75) { + data.add(2); + } + + if (tileEntity.frequency.securityMode != SecurityMode.PUBLIC) { + if (xAxis >= 13 && xAxis <= 53 && yAxis >= 113 && yAxis <= 129) { + data.add(3); + data.add(0); + } + } + + if (tileEntity.frequency.securityMode != SecurityMode.PRIVATE) { + if (xAxis >= 54 && xAxis <= 94 && yAxis >= 113 && yAxis <= 129) { + data.add(3); + data.add(1); + } + } + + if (tileEntity.frequency.securityMode != SecurityMode.TRUSTED) { + if (xAxis >= 95 && xAxis <= 135 && yAxis >= 113 && yAxis <= 129) { + data.add(3); + data.add(2); + } + } + + if (!data.isEmpty()) { + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); + } + } + } + } + + @Override + public void keyTyped(char c, int i) { + if (!trustedField.isFocused() || i == Keyboard.KEY_ESCAPE) { + super.keyTyped(c, i); + } + + if (i == Keyboard.KEY_RETURN) { + if (trustedField.isFocused()) { + addTrusted(trustedField.getText()); + trustedField.setText(""); + } + } + + if (SPECIAL_CHARS.contains(c) || Character.isDigit(c) || Character.isLetter(c) + || isTextboxKey(c, i)) { + trustedField.textboxKeyTyped(c, i); + } + + updateButtons(); + } + + @Override + protected void actionPerformed(GuiButton guibutton) { + super.actionPerformed(guibutton); + + if (guibutton.id == 0) { + int selection = scrollList.getSelection(); + + if (tileEntity.frequency != null && selection != -1) { + if (tileEntity != null) { + ArrayList data = new ArrayList(); + data.add(1); + data.add(tileEntity.frequency.trusted.get(selection)); + + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); + } + + scrollList.selected = -1; + } + } + + updateButtons(); + } + + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + String ownerText = EnumColor.RED + tileEntity.owner != null + ? (LangUtils.localize("gui.owner") + ": " + tileEntity.owner) + : LangUtils.localize("gui.noOwner"); + fontRendererObj.drawString( + tileEntity.getInventoryName(), + (xSize / 2) + - (fontRendererObj.getStringWidth(tileEntity.getInventoryName()) / 2), + 4, + 0x404040 + ); + fontRendererObj.drawString( + ownerText, + (xSize - 7) - fontRendererObj.getStringWidth(ownerText), + (ySize - 96) + 2, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040 + ); + + String trusted = LangUtils.localize("gui.trustedPlayers"); + fontRendererObj.drawString( + trusted, 74 - (fontRendererObj.getStringWidth(trusted) / 2), 57, 0x787878 + ); + + String security = EnumColor.RED + LangUtils.localize("gui.securityOffline"); + + if (tileEntity.frequency != null) { + security = LangUtils.localize("gui.security") + ": " + + tileEntity.frequency.securityMode.getDisplay(); + } + + fontRendererObj.drawString(security, 13, 103, 0x404040); + + renderScaledText(LangUtils.localize("gui.add") + ":", 13, 70, 0x404040, 20); + + if (tileEntity.frequency != null && xAxis >= 146 && xAxis <= 162 && yAxis >= 59 + && yAxis <= 75) { + displayTooltip( + LangUtils.localize("gui.securityOverride") + ": " + + LangUtils.transOnOff(tileEntity.frequency.override), + xAxis, + yAxis + ); + } + + if (xAxis >= 13 && xAxis <= 53 && yAxis >= 113 && yAxis <= 129) { + displayTooltip(LangUtils.localize("gui.publicMode"), xAxis, yAxis); + } + + if (xAxis >= 54 && xAxis <= 94 && yAxis >= 113 && yAxis <= 129) { + displayTooltip(LangUtils.localize("gui.privateMode"), xAxis, yAxis); + } + + if (xAxis >= 95 && xAxis <= 135 && yAxis >= 113 && yAxis <= 129) { + displayTooltip(LangUtils.localize("gui.trustedMode"), xAxis, yAxis); + } + + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture(resource); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + if (tileEntity.frequency != null && tileEntity.owner != null + && mc.thePlayer.getCommandSenderName().equals(tileEntity.owner)) { + drawTexturedModalRect( + guiWidth + 145, + guiHeight + 78, + xSize + (tileEntity.frequency.override ? 0 : 6), + 22, + 6, + 6 + ); + + if (xAxis >= 146 && xAxis <= 162 && yAxis >= 59 && yAxis <= 75) { + drawTexturedModalRect( + guiWidth + 146, guiHeight + 59, xSize + 12, 0, 16, 16 + ); + } else { + drawTexturedModalRect( + guiWidth + 146, guiHeight + 59, xSize + 12, 16, 16, 16 + ); + } + + if (tileEntity.frequency.securityMode != SecurityMode.PUBLIC) { + if (xAxis >= 13 && xAxis <= 53 && yAxis >= 113 && yAxis <= 129) { + drawTexturedModalRect( + guiWidth + 13, guiHeight + 113, xSize, 48, 40, 16 + ); + } else { + drawTexturedModalRect( + guiWidth + 13, guiHeight + 113, xSize, 64, 40, 16 + ); + } + } else { + drawTexturedModalRect(guiWidth + 13, guiHeight + 113, xSize, 80, 40, 16); + } + + if (tileEntity.frequency.securityMode != SecurityMode.PRIVATE) { + if (xAxis >= 54 && xAxis <= 94 && yAxis >= 113 && yAxis <= 129) { + drawTexturedModalRect( + guiWidth + 54, guiHeight + 113, xSize + 40, 48, 40, 16 + ); + } else { + drawTexturedModalRect( + guiWidth + 54, guiHeight + 113, xSize + 40, 64, 40, 16 + ); + } + } else { + drawTexturedModalRect( + guiWidth + 54, guiHeight + 113, xSize + 40, 80, 40, 16 + ); + } + + if (tileEntity.frequency.securityMode != SecurityMode.TRUSTED) { + if (xAxis >= 95 && xAxis <= 135 && yAxis >= 113 && yAxis <= 129) { + drawTexturedModalRect( + guiWidth + 95, guiHeight + 113, xSize, 96, 40, 16 + ); + } else { + drawTexturedModalRect( + guiWidth + 95, guiHeight + 113, xSize, 112, 40, 16 + ); + } + } else { + drawTexturedModalRect(guiWidth + 95, guiHeight + 113, xSize, 128, 40, 16); + } + } else { + drawTexturedModalRect(guiWidth + 145, guiHeight + 78, xSize, 28, 6, 6); + drawTexturedModalRect(guiWidth + 146, guiHeight + 59, xSize + 12, 32, 16, 16); + drawTexturedModalRect(guiWidth + 13, guiHeight + 113, xSize, 80, 40, 16); + drawTexturedModalRect(guiWidth + 54, guiHeight + 113, xSize + 40, 80, 40, 16); + drawTexturedModalRect(guiWidth + 95, guiHeight + 113, xSize, 128, 40, 16); + } + + if (xAxis >= 123 && xAxis <= 134 && yAxis >= 68 && yAxis <= 79) { + drawTexturedModalRect(guiWidth + 123, guiHeight + 68, xSize, 0, 11, 11); + } else { + drawTexturedModalRect(guiWidth + 123, guiHeight + 68, xSize, 11, 11, 11); + } + + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + + trustedField.drawTextBox(); + } } diff --git a/src/main/java/mekanism/client/gui/GuiSeismicReader.java b/src/main/java/mekanism/client/gui/GuiSeismicReader.java index f685f3008..01c99a1a7 100644 --- a/src/main/java/mekanism/client/gui/GuiSeismicReader.java +++ b/src/main/java/mekanism/client/gui/GuiSeismicReader.java @@ -2,6 +2,8 @@ package mekanism.client.gui; import java.util.ArrayList; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; @@ -11,253 +13,253 @@ import net.minecraft.client.gui.GuiScreen; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.world.World; - import org.apache.commons.lang3.tuple.Pair; import org.lwjgl.opengl.GL11; import org.lwjgl.util.Rectangle; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiSeismicReader extends GuiScreen -{ - private World worldObj; +public class GuiSeismicReader extends GuiScreen { + private World worldObj; - public ItemStack itemStack; + public ItemStack itemStack; - private ArrayList> blockList = new ArrayList>(); + private ArrayList> blockList + = new ArrayList>(); - public Coord4D pos; + public Coord4D pos; - protected int xSize = 137; + protected int xSize = 137; - protected int ySize = 182; + protected int ySize = 182; - private Rectangle upButton, downButton, tooltip; + private Rectangle upButton, downButton, tooltip; - private int currentLayer = 0; + private int currentLayer = 0; - public GuiSeismicReader(World world, Coord4D coord, ItemStack stack) - { - pos = coord; - pos.yCoord = Math.min(255, pos.yCoord); - worldObj = world; + public GuiSeismicReader(World world, Coord4D coord, ItemStack stack) { + pos = coord; + pos.yCoord = Math.min(255, pos.yCoord); + worldObj = world; - itemStack = stack; - calculate(); - currentLayer = Math.max(0, blockList.size() - 1); - } + itemStack = stack; + calculate(); + currentLayer = Math.max(0, blockList.size() - 1); + } - @Override - public void initGui() - { - super.initGui(); + @Override + public void initGui() { + super.initGui(); - upButton = new Rectangle((width - xSize) / 2 + 70, (height - ySize) / 2 + 75, 13, 13); - downButton = new Rectangle((width - xSize) / 2 + 70, (height - ySize) / 2 + 92, 13, 13); - tooltip = new Rectangle((width - xSize) / 2 + 30, (height - ySize) / 2 + 82, 16, 16); - } + upButton + = new Rectangle((width - xSize) / 2 + 70, (height - ySize) / 2 + 75, 13, 13); + downButton + = new Rectangle((width - xSize) / 2 + 70, (height - ySize) / 2 + 92, 13, 13); + tooltip + = new Rectangle((width - xSize) / 2 + 30, (height - ySize) / 2 + 82, 16, 16); + } - @Override - public void drawScreen(int mouseX, int mouseY, float partialTick) - { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; + @Override + public void drawScreen(int mouseX, int mouseY, float partialTick) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiSeismicReader.png")); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiSeismicReader.png") + ); - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - // Draws the up button - - if(upButton.intersects(new Rectangle(mouseX, mouseY, 1, 1))) - { - GL11.glColor3f(0.5f, 0.5f, 1f); - } - - drawTexturedModalRect(upButton.getX(), upButton.getY(), 137, 0, upButton.getWidth(), upButton.getHeight()); - GL11.glColor3f(1, 1, 1); - - // Draws the down button - if(downButton.intersects(new Rectangle(mouseX, mouseY, 1, 1))) - { - GL11.glColor3f(0.5f, 0.5f, 1f); - } - - drawTexturedModalRect(downButton.getX(), downButton.getY(), 150, 0, downButton.getWidth(), downButton.getHeight()); - GL11.glColor3f(1, 1, 1); + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + // Draws the up button - // Fix the overlapping if > 100 - GL11.glPushMatrix(); - GL11.glTranslatef(guiWidth + 48, guiHeight + 87, 0); - - if(currentLayer >= 100) - { - GL11.glTranslatef(0, 1, 0); - GL11.glScalef(0.7f, 0.7f, 0.7f); - } - - fontRendererObj.drawString(String.format("%s", currentLayer), 0, 0, 0xAFAFAF); - GL11.glPopMatrix(); + if (upButton.intersects(new Rectangle(mouseX, mouseY, 1, 1))) { + GL11.glColor3f(0.5f, 0.5f, 1f); + } - // Render the item stacks - for(int i = 0; i < 9; i++) - { - int centralX = guiWidth + 32, centralY = guiHeight + 103; - int layer = currentLayer + (i - 5); - - if(0 <= layer && layer < blockList.size()) - { - ItemStack stack = new ItemStack(blockList.get(layer).getRight(), 1, blockList.get(layer).getLeft()); - - if(stack.getItem() == null) - { - continue; - } - - GL11.glPushMatrix(); - GL11.glTranslatef(centralX - 2, centralY - i * 16 + (22 * 2), 0); - - if(i < 4) - { - GL11.glTranslatef(0.2f, 2.5f, 0); - } - - if(i != 4) - { - GL11.glTranslatef(1.5f, 0, 0); - GL11.glScalef(0.8f, 0.8f, 0.8f); - } - - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, this.mc.getTextureManager(), stack, 0, 0); - GL11.glPopMatrix(); - } - } + drawTexturedModalRect( + upButton.getX(), + upButton.getY(), + 137, + 0, + upButton.getWidth(), + upButton.getHeight() + ); + GL11.glColor3f(1, 1, 1); - // Get the name from the stack and render it - if(currentLayer - 1 >= 0) - { - ItemStack nameStack = new ItemStack(blockList.get(currentLayer - 1).getRight(), 0, blockList.get(currentLayer - 1).getLeft()); - String renderString = "unknown"; - - if(nameStack.getItem() != null) - { - renderString = nameStack.getDisplayName(); - } - else if(blockList.get(currentLayer - 1).getRight() == Blocks.air) - { - renderString = "Air"; - } - - String capitalised = renderString.substring(0, 1).toUpperCase() + renderString.substring(1); - float renderScale = 1.0f; - int lengthX = fontRendererObj.getStringWidth(capitalised); + // Draws the down button + if (downButton.intersects(new Rectangle(mouseX, mouseY, 1, 1))) { + GL11.glColor3f(0.5f, 0.5f, 1f); + } - renderScale = lengthX > 53 ? 53f / lengthX : 1.0f; + drawTexturedModalRect( + downButton.getX(), + downButton.getY(), + 150, + 0, + downButton.getWidth(), + downButton.getHeight() + ); + GL11.glColor3f(1, 1, 1); - GL11.glPushMatrix(); - GL11.glTranslatef(guiWidth + 72, guiHeight + 16, 0); - GL11.glScalef(renderScale, renderScale, renderScale); - fontRendererObj.drawString(capitalised, 0, 0, 0x919191); - GL11.glPopMatrix(); - - if(tooltip.intersects(new Rectangle(mouseX, mouseY, 1, 1))) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiTooltips.png")); - int fontLengthX = fontRendererObj.getStringWidth(capitalised) + 5; - int renderX = mouseX + 10, renderY = mouseY - 5; - GL11.glPushMatrix(); - GL11.glColor3f(1, 1, 1); - drawTexturedModalRect(renderX, renderY, 0, 0, fontLengthX, 16); - drawTexturedModalRect(renderX + fontLengthX, renderY, 0, 16, 2, 16); - fontRendererObj.drawString(capitalised, renderX + 4, renderY + 4, 0x919191); - GL11.glPopMatrix(); - } - } + // Fix the overlapping if > 100 + GL11.glPushMatrix(); + GL11.glTranslatef(guiWidth + 48, guiHeight + 87, 0); - int frequency = 0; + if (currentLayer >= 100) { + GL11.glTranslatef(0, 1, 0); + GL11.glScalef(0.7f, 0.7f, 0.7f); + } - for(Pair pair : blockList) - { - if(blockList.get(currentLayer - 1) != null) - { - Block block = blockList.get(currentLayer - 1).getRight(); + fontRendererObj.drawString(String.format("%s", currentLayer), 0, 0, 0xAFAFAF); + GL11.glPopMatrix(); - if(pair.getRight() == block && pair.getLeft() == blockList.get(currentLayer - 1).getLeft()) - { - frequency++; - } - } - } + // Render the item stacks + for (int i = 0; i < 9; i++) { + int centralX = guiWidth + 32, centralY = guiHeight + 103; + int layer = currentLayer + (i - 5); - GL11.glPushMatrix(); - GL11.glTranslatef(guiWidth + 72, guiHeight + 26, 0); - GL11.glScalef(0.70f, 0.70f, 0.70f); - fontRendererObj.drawString(LangUtils.localize("gui.abundancy") + ": " + frequency, 0, 0, 0x919191); - GL11.glPopMatrix(); - super.drawScreen(mouseX, mouseY, partialTick); - } + if (0 <= layer && layer < blockList.size()) { + ItemStack stack = new ItemStack( + blockList.get(layer).getRight(), 1, blockList.get(layer).getLeft() + ); - public String wrapString(String str, int index) - { - String string = str; + if (stack.getItem() == null) { + continue; + } - for(int i = 0; i < string.length(); i++) - { - if(i == index) - { - string = string.substring(0, i) + "\n" + string.substring(i); - } - } + GL11.glPushMatrix(); + GL11.glTranslatef(centralX - 2, centralY - i * 16 + (22 * 2), 0); - return string; - } + if (i < 4) { + GL11.glTranslatef(0.2f, 2.5f, 0); + } - @Override - public void onGuiClosed() - { - super.onGuiClosed(); + if (i != 4) { + GL11.glTranslatef(1.5f, 0, 0); + GL11.glScalef(0.8f, 0.8f, 0.8f); + } - blockList.clear(); - } + itemRender.renderItemAndEffectIntoGUI( + fontRendererObj, this.mc.getTextureManager(), stack, 0, 0 + ); + GL11.glPopMatrix(); + } + } - public void calculate() - { - for(int y = 0; y < pos.yCoord; y++) - { - Block block = worldObj.getBlock(pos.xCoord, y, pos.zCoord); - int metadata = worldObj.getBlockMetadata(pos.xCoord, y, pos.zCoord); - - blockList.add(Pair.of(metadata, block)); - } - } + // Get the name from the stack and render it + if (currentLayer - 1 >= 0) { + ItemStack nameStack = new ItemStack( + blockList.get(currentLayer - 1).getRight(), + 0, + blockList.get(currentLayer - 1).getLeft() + ); + String renderString = "unknown"; - @Override - protected void mouseClicked(int xPos, int yPos, int buttonClicked) - { - super.mouseClicked(xPos, yPos, buttonClicked); + if (nameStack.getItem() != null) { + renderString = nameStack.getDisplayName(); + } else if (blockList.get(currentLayer - 1).getRight() == Blocks.air) { + renderString = "Air"; + } - if(upButton.intersects(new Rectangle(xPos, yPos, 1, 1))) - { - if(currentLayer + 1 <= blockList.size() - 1) - { - currentLayer++; - } - } + String capitalised + = renderString.substring(0, 1).toUpperCase() + renderString.substring(1); + float renderScale = 1.0f; + int lengthX = fontRendererObj.getStringWidth(capitalised); - if(downButton.intersects(new Rectangle(xPos, yPos, 1, 1))) - { - if(currentLayer - 1 >= 1) - { - currentLayer--; - } - } - } + renderScale = lengthX > 53 ? 53f / lengthX : 1.0f; - @Override - public boolean doesGuiPauseGame() - { - return false; - } + GL11.glPushMatrix(); + GL11.glTranslatef(guiWidth + 72, guiHeight + 16, 0); + GL11.glScalef(renderScale, renderScale, renderScale); + fontRendererObj.drawString(capitalised, 0, 0, 0x919191); + GL11.glPopMatrix(); + + if (tooltip.intersects(new Rectangle(mouseX, mouseY, 1, 1))) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiTooltips.png") + ); + int fontLengthX = fontRendererObj.getStringWidth(capitalised) + 5; + int renderX = mouseX + 10, renderY = mouseY - 5; + GL11.glPushMatrix(); + GL11.glColor3f(1, 1, 1); + drawTexturedModalRect(renderX, renderY, 0, 0, fontLengthX, 16); + drawTexturedModalRect(renderX + fontLengthX, renderY, 0, 16, 2, 16); + fontRendererObj.drawString( + capitalised, renderX + 4, renderY + 4, 0x919191 + ); + GL11.glPopMatrix(); + } + } + + int frequency = 0; + + for (Pair pair : blockList) { + if (blockList.get(currentLayer - 1) != null) { + Block block = blockList.get(currentLayer - 1).getRight(); + + if (pair.getRight() == block + && pair.getLeft() == blockList.get(currentLayer - 1).getLeft()) { + frequency++; + } + } + } + + GL11.glPushMatrix(); + GL11.glTranslatef(guiWidth + 72, guiHeight + 26, 0); + GL11.glScalef(0.70f, 0.70f, 0.70f); + fontRendererObj.drawString( + LangUtils.localize("gui.abundancy") + ": " + frequency, 0, 0, 0x919191 + ); + GL11.glPopMatrix(); + super.drawScreen(mouseX, mouseY, partialTick); + } + + public String wrapString(String str, int index) { + String string = str; + + for (int i = 0; i < string.length(); i++) { + if (i == index) { + string = string.substring(0, i) + "\n" + string.substring(i); + } + } + + return string; + } + + @Override + public void onGuiClosed() { + super.onGuiClosed(); + + blockList.clear(); + } + + public void calculate() { + for (int y = 0; y < pos.yCoord; y++) { + Block block = worldObj.getBlock(pos.xCoord, y, pos.zCoord); + int metadata = worldObj.getBlockMetadata(pos.xCoord, y, pos.zCoord); + + blockList.add(Pair.of(metadata, block)); + } + } + + @Override + protected void mouseClicked(int xPos, int yPos, int buttonClicked) { + super.mouseClicked(xPos, yPos, buttonClicked); + + if (upButton.intersects(new Rectangle(xPos, yPos, 1, 1))) { + if (currentLayer + 1 <= blockList.size() - 1) { + currentLayer++; + } + } + + if (downButton.intersects(new Rectangle(xPos, yPos, 1, 1))) { + if (currentLayer - 1 >= 1) { + currentLayer--; + } + } + } + + @Override + public boolean doesGuiPauseGame() { + return false; + } } diff --git a/src/main/java/mekanism/client/gui/GuiSeismicVibrator.java b/src/main/java/mekanism/client/gui/GuiSeismicVibrator.java index 41870e3b4..866c6f0c5 100644 --- a/src/main/java/mekanism/client/gui/GuiSeismicVibrator.java +++ b/src/main/java/mekanism/client/gui/GuiSeismicVibrator.java @@ -2,6 +2,8 @@ package mekanism.client.gui; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.MekanismConfig.usage; import mekanism.api.util.ListUtils; import mekanism.client.gui.element.GuiElement.IInfoHandler; @@ -18,64 +20,104 @@ import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.entity.player.InventoryPlayer; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiSeismicVibrator extends GuiMekanism -{ - public TileEntitySeismicVibrator tileEntity; +public class GuiSeismicVibrator extends GuiMekanism { + public TileEntitySeismicVibrator tileEntity; - public GuiSeismicVibrator(InventoryPlayer inventory, TileEntitySeismicVibrator tentity) - { - super(tentity, new ContainerSeismicVibrator(inventory, tentity)); - tileEntity = tentity; + public GuiSeismicVibrator( + InventoryPlayer inventory, TileEntitySeismicVibrator tentity + ) { + super(tentity, new ContainerSeismicVibrator(inventory, tentity)); + tileEntity = tentity; - guiElements.add(new GuiSecurityTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiSeismicVibrator.png"))); - guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiSeismicVibrator.png"))); - guiElements.add(new GuiPowerBar(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiSeismicVibrator.png"), 164, 15)); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() { - @Override - public List getInfo() - { - String multiplier = MekanismUtils.getEnergyDisplay(usage.seismicVibratorUsage); - return ListUtils.asList(LangUtils.localize("gui.using") + ": " + multiplier + "/t", LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); - } - }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiSeismicVibrator.png"))); + guiElements.add(new GuiSecurityTab( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiSeismicVibrator.png") + )); + guiElements.add(new GuiRedstoneControl( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiSeismicVibrator.png") + )); + guiElements.add(new GuiPowerBar( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiSeismicVibrator.png"), + 164, + 15 + )); + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() { + String multiplier + = MekanismUtils.getEnergyDisplay(usage.seismicVibratorUsage); + return ListUtils.asList( + LangUtils.localize("gui.using") + ": " + multiplier + "/t", + LangUtils.localize("gui.needed") + ": " + + MekanismUtils.getEnergyDisplay( + tileEntity.getMaxEnergy() - tileEntity.getEnergy() + ) + ); + } + }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiSeismicVibrator.png"))); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiSeismicVibrator.png"), 142, 34).with(SlotOverlay.POWER)); - } + guiElements.add( + new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiSeismicVibrator.png"), + 142, + 34 + ) + .with(SlotOverlay.POWER) + ); + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - fontRendererObj.drawString(tileEntity.getInventoryName(), 45, 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); - - fontRendererObj.drawString(tileEntity.isActive ? LangUtils.localize("gui.vibrating") : LangUtils.localize("gui.idle"), 19, 26, 0x00CD00); - fontRendererObj.drawString(LangUtils.localize("gui.chunk") + ": " + (tileEntity.xCoord >> 4) + ", " + (tileEntity.zCoord >> 4), 19, 35, 0x00CD00); + fontRendererObj.drawString(tileEntity.getInventoryName(), 45, 6, 0x404040); + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040 + ); - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + fontRendererObj.drawString( + tileEntity.isActive ? LangUtils.localize("gui.vibrating") + : LangUtils.localize("gui.idle"), + 19, + 26, + 0x00CD00 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.chunk") + ": " + (tileEntity.xCoord >> 4) + ", " + + (tileEntity.zCoord >> 4), + 19, + 35, + 0x00CD00 + ); - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiSeismicVibrator.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - int xAxis = mouseX - guiWidth; - int yAxis = mouseY - guiHeight; + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiSeismicVibrator.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } + int xAxis = mouseX - guiWidth; + int yAxis = mouseY - guiHeight; + + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } } diff --git a/src/main/java/mekanism/client/gui/GuiSideConfiguration.java b/src/main/java/mekanism/client/gui/GuiSideConfiguration.java index 2337fe9be..8835d7a13 100644 --- a/src/main/java/mekanism/client/gui/GuiSideConfiguration.java +++ b/src/main/java/mekanism/client/gui/GuiSideConfiguration.java @@ -5,6 +5,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.transmitters.TransmissionType; @@ -25,248 +27,248 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; - import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiSideConfiguration extends GuiMekanism -{ - public Map slotPosMap = new HashMap(); +public class GuiSideConfiguration extends GuiMekanism { + public Map slotPosMap = new HashMap(); - public ISideConfiguration configurable; - - public TransmissionType currentType; - - public List configTabs = new ArrayList(); + public ISideConfiguration configurable; - public GuiSideConfiguration(EntityPlayer player, ISideConfiguration tile) - { - super((TileEntityContainerBlock)tile, new ContainerNull(player, (TileEntityContainerBlock)tile)); + public TransmissionType currentType; - ySize = 95; + public List configTabs = new ArrayList(); - configurable = tile; - - for(TransmissionType type : configurable.getConfig().transmissions) - { - GuiConfigTypeTab tab = new GuiConfigTypeTab(this, (TileEntity)configurable, type, MekanismUtils.getResource(ResourceType.GUI, "GuiConfiguration.png")); - - guiElements.add(tab); - configTabs.add(tab); - } - - currentType = getTopTransmission(); - - updateTabs(); + public GuiSideConfiguration(EntityPlayer player, ISideConfiguration tile) { + super( + (TileEntityContainerBlock) tile, + new ContainerNull(player, (TileEntityContainerBlock) tile) + ); - slotPosMap.put(0, new GuiPos(81, 64)); - slotPosMap.put(1, new GuiPos(81, 34)); - slotPosMap.put(2, new GuiPos(81, 49)); - slotPosMap.put(3, new GuiPos(66, 64)); - slotPosMap.put(4, new GuiPos(66, 49)); - slotPosMap.put(5, new GuiPos(96, 49)); - } - - public TransmissionType getTopTransmission() - { - return configurable.getConfig().transmissions.get(0); - } - - public void updateTabs() - { - int rendered = 0; - - for(GuiConfigTypeTab tab : configTabs) - { - tab.visible = currentType != tab.transmission; - - if(tab.visible) - { - tab.left = rendered >= 0 && rendered <= 2; - tab.setY(2+((rendered%3)*(26+2))); - } - - rendered++; - } - } + ySize = 95; - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + configurable = tile; - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiConfiguration.png")); + for (TransmissionType type : configurable.getConfig().transmissions) { + GuiConfigTypeTab tab = new GuiConfigTypeTab( + this, + (TileEntity) configurable, + type, + MekanismUtils.getResource(ResourceType.GUI, "GuiConfiguration.png") + ); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; + guiElements.add(tab); + configTabs.add(tab); + } - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + currentType = getTopTransmission(); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); - - if(xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) - { - drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176 + 28, 0, 14, 14); - } - else { - drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176 + 28, 14, 14, 14); - } + updateTabs(); - if(xAxis >= 156 && xAxis <= 170 && yAxis >= 6 && yAxis <= 20) - { - drawTexturedModalRect(guiWidth + 156, guiHeight + 6, 176 + 14, 0, 14, 14); - } - else { - drawTexturedModalRect(guiWidth + 156, guiHeight + 6, 176 + 14, 14, 14, 14); - } + slotPosMap.put(0, new GuiPos(81, 64)); + slotPosMap.put(1, new GuiPos(81, 34)); + slotPosMap.put(2, new GuiPos(81, 49)); + slotPosMap.put(3, new GuiPos(66, 64)); + slotPosMap.put(4, new GuiPos(66, 49)); + slotPosMap.put(5, new GuiPos(96, 49)); + } - for(int i = 0; i < slotPosMap.size(); i++) - { - MekanismRenderer.resetColor(); + public TransmissionType getTopTransmission() { + return configurable.getConfig().transmissions.get(0); + } - int x = slotPosMap.get(i).xPos; - int y = slotPosMap.get(i).yPos; + public void updateTabs() { + int rendered = 0; - SideData data = configurable.getConfig().getOutput(currentType, i); + for (GuiConfigTypeTab tab : configTabs) { + tab.visible = currentType != tab.transmission; - if(data != TileComponentConfig.EMPTY) - { - if(data.color != EnumColor.GREY) - { - MekanismRenderer.color(data.color); - } - - if(xAxis >= x && xAxis <= x+14 && yAxis >= y && yAxis <= y+14) - { - drawTexturedModalRect(guiWidth + x, guiHeight + y, 176, 0, 14, 14); - } - else { - drawTexturedModalRect(guiWidth + x, guiHeight + y, 176, 14, 14, 14); - } - } - else { - drawTexturedModalRect(guiWidth + x, guiHeight + y, 176, 28, 14, 14); - } - } + if (tab.visible) { + tab.left = rendered >= 0 && rendered <= 2; + tab.setY(2 + ((rendered % 3) * (26 + 2))); + } - MekanismRenderer.resetColor(); - } + rendered++; + } + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - String title = currentType.localize() + " " + LangUtils.localize("gui.config"); - fontRendererObj.drawString(title, (xSize/2)-(fontRendererObj.getStringWidth(title)/2), 5, 0x404040); - - if(configurable.getConfig().canEject(currentType)) - { - fontRendererObj.drawString(LangUtils.localize("gui.eject") + ": " + (configurable.getConfig().isEjecting(currentType) ? "On" : "Off"), 53, 17, 0x00CD00); - } - else { - fontRendererObj.drawString(LangUtils.localize("gui.noEject"), 53, 17, 0x00CD00); - } - - fontRendererObj.drawString(LangUtils.localize("gui.slots"), 77, 81, 0x787878); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiConfiguration.png") + ); - for(int i = 0; i < slotPosMap.size(); i++) - { - int x = slotPosMap.get(i).xPos; - int y = slotPosMap.get(i).yPos; + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; - SideData data = configurable.getConfig().getOutput(currentType, i); + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - if(data != TileComponentConfig.EMPTY) - { - if(xAxis >= x && xAxis <= x+14 && yAxis >= y && yAxis <= y+14) - { - drawCreativeTabHoveringText(data.color + data.localize() + " (" + data.color.getName() + ")", xAxis, yAxis); - } - } - } + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - if(xAxis >= 156 && xAxis <= 170 && yAxis >= 6 && yAxis <= 20) - { - drawCreativeTabHoveringText(LangUtils.localize("gui.autoEject"), xAxis, yAxis); - } + if (xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) { + drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176 + 28, 0, 14, 14); + } else { + drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176 + 28, 14, 14, 14); + } - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + if (xAxis >= 156 && xAxis <= 170 && yAxis >= 6 && yAxis <= 20) { + drawTexturedModalRect(guiWidth + 156, guiHeight + 6, 176 + 14, 0, 14, 14); + } else { + drawTexturedModalRect(guiWidth + 156, guiHeight + 6, 176 + 14, 14, 14, 14); + } - @Override - public void updateScreen() - { - super.updateScreen(); + for (int i = 0; i < slotPosMap.size(); i++) { + MekanismRenderer.resetColor(); - TileEntity tile = (TileEntity)configurable; + int x = slotPosMap.get(i).xPos; + int y = slotPosMap.get(i).yPos; - if(tile == null || mc.theWorld.getTileEntity(tile.xCoord, tile.yCoord, tile.zCoord) == null) - { - mc.displayGuiScreen(null); - } - } + SideData data = configurable.getConfig().getOutput(currentType, i); - @Override - protected void mouseClicked(int mouseX, int mouseY, int button) - { - super.mouseClicked(mouseX, mouseY, button); + if (data != TileComponentConfig.EMPTY) { + if (data.color != EnumColor.GREY) { + MekanismRenderer.color(data.color); + } - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + if (xAxis >= x && xAxis <= x + 14 && yAxis >= y && yAxis <= y + 14) { + drawTexturedModalRect(guiWidth + x, guiHeight + y, 176, 0, 14, 14); + } else { + drawTexturedModalRect(guiWidth + x, guiHeight + y, 176, 14, 14, 14); + } + } else { + drawTexturedModalRect(guiWidth + x, guiHeight + y, 176, 28, 14, 14); + } + } - TileEntity tile = (TileEntity)configurable; + MekanismRenderer.resetColor(); + } - if(button == 0) - { - if(xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) - { - int guiId = Mekanism.proxy.getGuiId(tile.getBlockType(), tile.getBlockMetadata()); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + String title = currentType.localize() + " " + LangUtils.localize("gui.config"); + fontRendererObj.drawString( + title, (xSize / 2) - (fontRendererObj.getStringWidth(title) / 2), 5, 0x404040 + ); + + if (configurable.getConfig().canEject(currentType)) { + fontRendererObj.drawString( + LangUtils.localize("gui.eject") + ": " + + (configurable.getConfig().isEjecting(currentType) ? "On" : "Off"), + 53, + 17, + 0x00CD00 + ); + } else { + fontRendererObj.drawString( + LangUtils.localize("gui.noEject"), 53, 17, 0x00CD00 + ); + } + + fontRendererObj.drawString(LangUtils.localize("gui.slots"), 77, 81, 0x787878); + + for (int i = 0; i < slotPosMap.size(); i++) { + int x = slotPosMap.get(i).xPos; + int y = slotPosMap.get(i).yPos; + + SideData data = configurable.getConfig().getOutput(currentType, i); + + if (data != TileComponentConfig.EMPTY) { + if (xAxis >= x && xAxis <= x + 14 && yAxis >= y && yAxis <= y + 14) { + drawCreativeTabHoveringText( + data.color + data.localize() + " (" + data.color.getName() + ")", + xAxis, + yAxis + ); + } + } + } + + if (xAxis >= 156 && xAxis <= 170 && yAxis >= 6 && yAxis <= 20) { + drawCreativeTabHoveringText( + LangUtils.localize("gui.autoEject"), xAxis, yAxis + ); + } + + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + public void updateScreen() { + super.updateScreen(); + + TileEntity tile = (TileEntity) configurable; + + if (tile == null + || mc.theWorld.getTileEntity(tile.xCoord, tile.yCoord, tile.zCoord) == null) { + mc.displayGuiScreen(null); + } + } + + @Override + protected void mouseClicked(int mouseX, int mouseY, int button) { + super.mouseClicked(mouseX, mouseY, button); + + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + TileEntity tile = (TileEntity) configurable; + + if (button == 0) { + if (xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) { + int guiId = Mekanism.proxy.getGuiId( + tile.getBlockType(), tile.getBlockMetadata() + ); SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new SimpleGuiMessage(Coord4D.get(tile), 0, guiId)); - } + Mekanism.packetHandler.sendToServer( + new SimpleGuiMessage(Coord4D.get(tile), 0, guiId) + ); + } - if(xAxis >= 156 && xAxis <= 170 && yAxis >= 6 && yAxis <= 20) - { + if (xAxis >= 156 && xAxis <= 170 && yAxis >= 6 && yAxis <= 20) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new ConfigurationUpdateMessage(ConfigurationPacket.EJECT, Coord4D.get(tile), 0, 0, currentType)); - } - } + Mekanism.packetHandler.sendToServer(new ConfigurationUpdateMessage( + ConfigurationPacket.EJECT, Coord4D.get(tile), 0, 0, currentType + )); + } + } - if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && button == 0) - { - button = 2; - } + if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && button == 0) { + button = 2; + } - for(int i = 0; i < slotPosMap.size(); i++) - { - int x = slotPosMap.get(i).xPos; - int y = slotPosMap.get(i).yPos; + for (int i = 0; i < slotPosMap.size(); i++) { + int x = slotPosMap.get(i).xPos; + int y = slotPosMap.get(i).yPos; - if(xAxis >= x && xAxis <= x+14 && yAxis >= y && yAxis <= y+14) - { + if (xAxis >= x && xAxis <= x + 14 && yAxis >= y && yAxis <= y + 14) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new ConfigurationUpdateMessage(ConfigurationPacket.SIDE_DATA, Coord4D.get(tile), button, i, currentType)); - } - } - } + Mekanism.packetHandler.sendToServer(new ConfigurationUpdateMessage( + ConfigurationPacket.SIDE_DATA, + Coord4D.get(tile), + button, + i, + currentType + )); + } + } + } - public static class GuiPos - { - public int xPos; - public int yPos; + public static class GuiPos { + public int xPos; + public int yPos; - public GuiPos(int x, int y) - { - xPos = x; - yPos = y; - } - } + public GuiPos(int x, int y) { + xPos = x; + yPos = y; + } + } } diff --git a/src/main/java/mekanism/client/gui/GuiSolarNeutronActivator.java b/src/main/java/mekanism/client/gui/GuiSolarNeutronActivator.java index abd14af44..9b17d02f4 100644 --- a/src/main/java/mekanism/client/gui/GuiSolarNeutronActivator.java +++ b/src/main/java/mekanism/client/gui/GuiSolarNeutronActivator.java @@ -1,5 +1,7 @@ package mekanism.client.gui; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.gas.GasTank; import mekanism.client.gui.element.GuiGasGauge; import mekanism.client.gui.element.GuiGasGauge.IGasInfoHandler; @@ -19,78 +21,114 @@ import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.entity.player.InventoryPlayer; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiSolarNeutronActivator extends GuiMekanism -{ - public TileEntitySolarNeutronActivator tileEntity; +public class GuiSolarNeutronActivator extends GuiMekanism { + public TileEntitySolarNeutronActivator tileEntity; - public GuiSolarNeutronActivator(InventoryPlayer inventory, TileEntitySolarNeutronActivator tentity) - { - super(tentity, new ContainerSolarNeutronActivator(inventory, tentity)); - tileEntity = tentity; + public GuiSolarNeutronActivator( + InventoryPlayer inventory, TileEntitySolarNeutronActivator tentity + ) { + super(tentity, new ContainerSolarNeutronActivator(inventory, tentity)); + tileEntity = tentity; - guiElements.add(new GuiSecurityTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"))); - guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"))); - guiElements.add(new GuiUpgradeTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"))); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 4, 55).with(SlotOverlay.MINUS)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 154, 55).with(SlotOverlay.PLUS)); - - guiElements.add(new GuiGasGauge(new IGasInfoHandler() { - @Override - public GasTank getTank() - { - return tileEntity.inputTank; - } - }, GuiGauge.Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 25, 13)); - guiElements.add(new GuiGasGauge(new IGasInfoHandler() { - @Override - public GasTank getTank() - { - return tileEntity.outputTank; - } - }, GuiGauge.Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 133, 13)); + guiElements.add(new GuiSecurityTab( + this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png") + )); + guiElements.add(new GuiRedstoneControl( + this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png") + )); + guiElements.add(new GuiUpgradeTab( + this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png") + )); + guiElements.add(new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), + 4, + 55 + ) + .with(SlotOverlay.MINUS)); + guiElements.add(new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), + 154, + 55 + ) + .with(SlotOverlay.PLUS)); - guiElements.add(new GuiProgress(new IProgressInfoHandler() - { - @Override - public double getProgress() - { - return tileEntity.isActive ? 1 : 0; - } - }, ProgressBar.LARGE_RIGHT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 62, 38)); - } + guiElements.add(new GuiGasGauge( + new IGasInfoHandler() { + @Override + public GasTank getTank() { + return tileEntity.inputTank; + } + }, + GuiGauge.Type.STANDARD, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), + 25, + 13 + )); + guiElements.add(new GuiGasGauge( + new IGasInfoHandler() { + @Override + public GasTank getTank() { + return tileEntity.outputTank; + } + }, + GuiGauge.Type.STANDARD, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), + 133, + 13 + )); - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + guiElements.add(new GuiProgress( + new IProgressInfoHandler() { + @Override + public double getProgress() { + return tileEntity.isActive ? 1 : 0; + } + }, + ProgressBar.LARGE_RIGHT, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), + 62, + 38 + )); + } - fontRendererObj.drawString(tileEntity.getInventoryName(), 26, 4, 0x404040); - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 4, 0x404040); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + fontRendererObj.drawString(tileEntity.getInventoryName(), 26, 4, 0x404040); + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, (ySize - 96) + 4, 0x404040 + ); - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - int displayInt; + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + int displayInt; - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } } diff --git a/src/main/java/mekanism/client/gui/GuiStopwatch.java b/src/main/java/mekanism/client/gui/GuiStopwatch.java index 138dce697..0cab4bf39 100644 --- a/src/main/java/mekanism/client/gui/GuiStopwatch.java +++ b/src/main/java/mekanism/client/gui/GuiStopwatch.java @@ -1,7 +1,5 @@ package mekanism.client.gui; -import org.lwjgl.opengl.GL11; - import mekanism.common.Mekanism; import mekanism.common.network.PacketChangeTime.ChangeTimeMessage; import mekanism.common.util.MekanismUtils; @@ -9,52 +7,71 @@ import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.entity.player.EntityPlayer; +import org.lwjgl.opengl.GL11; public class GuiStopwatch extends GuiScreen { private static EntityPlayer player; private int xSize; private int ySize; - + public GuiStopwatch(final EntityPlayer entityplayer) { this.xSize = 176; this.ySize = 166; GuiStopwatch.player = entityplayer; } - + @Override public void initGui() { this.buttonList.clear(); - this.buttonList.add(new GuiButton(0, this.width / 2 - 80, this.height / 2 - 65, 50, 20, "Sunrise")); - this.buttonList.add(new GuiButton(1, this.width / 2 - 80, this.height / 2 - 35, 50, 20, "Noon")); - this.buttonList.add(new GuiButton(2, this.width / 2 + 5, this.height / 2 - 65, 50, 20, "Sunset")); - this.buttonList.add(new GuiButton(3, this.width / 2 + 5, this.height / 2 - 35, 50, 20, "Midnight")); + this.buttonList.add( + new GuiButton(0, this.width / 2 - 80, this.height / 2 - 65, 50, 20, "Sunrise") + ); + this.buttonList.add( + new GuiButton(1, this.width / 2 - 80, this.height / 2 - 35, 50, 20, "Noon") + ); + this.buttonList.add( + new GuiButton(2, this.width / 2 + 5, this.height / 2 - 65, 50, 20, "Sunset") + ); + this.buttonList.add( + new GuiButton(3, this.width / 2 + 5, this.height / 2 - 35, 50, 20, "Midnight") + ); } - + @Override public void drawScreen(final int i, final int j, final float f) { GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - this.mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiStopwatch.png")); - this.drawTexturedModalRect(this.width / 2 - 100, this.height / 2 - 100, 0, 0, xSize, ySize); - this.drawString(this.fontRendererObj, "Steve's Stopwatch", this.width / 2 - 60, this.height / 2 - 95, 16777215); + this.mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiStopwatch.png") + ); + this.drawTexturedModalRect( + this.width / 2 - 100, this.height / 2 - 100, 0, 0, xSize, ySize + ); + this.drawString( + this.fontRendererObj, + "Steve's Stopwatch", + this.width / 2 - 60, + this.height / 2 - 95, + 16777215 + ); super.drawScreen(i, j, f); GL11.glBlendFunc(770, 771); GL11.glEnable(2884); GL11.glEnable(3008); GL11.glEnable(2929); } - + @Override public void keyTyped(final char c, final int i) { if (i == 1) { this.mc.thePlayer.closeScreen(); } } - + @Override public boolean doesGuiPauseGame() { return false; } - + @Override public void actionPerformed(final GuiButton guibutton) { if (guibutton.id == 0) { diff --git a/src/main/java/mekanism/client/gui/GuiTFilterSelect.java b/src/main/java/mekanism/client/gui/GuiTFilterSelect.java index 97ccc5d0c..d685085bc 100644 --- a/src/main/java/mekanism/client/gui/GuiTFilterSelect.java +++ b/src/main/java/mekanism/client/gui/GuiTFilterSelect.java @@ -1,5 +1,7 @@ package mekanism.client.gui; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.client.sound.SoundHandler; import mekanism.common.Mekanism; @@ -12,111 +14,112 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.EntityPlayer; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiTFilterSelect extends GuiMekanism -{ - public TileEntityLogisticalSorter tileEntity; - - public GuiTFilterSelect(EntityPlayer player, TileEntityLogisticalSorter tentity) - { - super(tentity, new ContainerNull(player, tentity)); - - tileEntity = tentity; - } - - @Override - public void initGui() - { - super.initGui(); +public class GuiTFilterSelect extends GuiMekanism { + public TileEntityLogisticalSorter tileEntity; - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - - buttonList.clear(); - buttonList.add(new GuiButton(0, guiWidth + 24, guiHeight + 32, 128, 20, LangUtils.localize("gui.itemstack"))); - buttonList.add(new GuiButton(1, guiWidth + 24, guiHeight + 52, 128, 20, LangUtils.localize("gui.oredict"))); - buttonList.add(new GuiButton(2, guiWidth + 24, guiHeight + 72, 128, 20, LangUtils.localize("gui.material"))); - buttonList.add(new GuiButton(3, guiWidth + 24, guiHeight + 92, 128, 20, LangUtils.localize("gui.modID"))); - } - - @Override - protected void actionPerformed(GuiButton guibutton) - { - super.actionPerformed(guibutton); + public GuiTFilterSelect(EntityPlayer player, TileEntityLogisticalSorter tentity) { + super(tentity, new ContainerNull(player, tentity)); - if(guibutton.id == 0) - { - Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 1, 0, 0)); - } - else if(guibutton.id == 1) - { - Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 2, 0, 0)); - } - else if(guibutton.id == 2) - { - Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 3, 0, 0)); - } - else if(guibutton.id == 3) - { - Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 5, 0, 0)); - } - } - - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + tileEntity = tentity; + } - fontRendererObj.drawString(LangUtils.localize("gui.filterSelect.title"), 43, 6, 0x404040); - - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } - - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + @Override + public void initGui() { + super.initGui(); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiFilterSelect.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + buttonList.clear(); + buttonList.add(new GuiButton( + 0, guiWidth + 24, guiHeight + 32, 128, 20, LangUtils.localize("gui.itemstack") + )); + buttonList.add(new GuiButton( + 1, guiWidth + 24, guiHeight + 52, 128, 20, LangUtils.localize("gui.oredict") + )); + buttonList.add(new GuiButton( + 2, guiWidth + 24, guiHeight + 72, 128, 20, LangUtils.localize("gui.material") + )); + buttonList.add(new GuiButton( + 3, guiWidth + 24, guiHeight + 92, 128, 20, LangUtils.localize("gui.modID") + )); + } - if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) - { - drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 0, 11, 11); - } - else { - drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 11, 11, 11); - } - } - - @Override - public void mouseClicked(int mouseX, int mouseY, int button) - { - super.mouseClicked(mouseX, mouseY, button); - - if(button == 0) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); - - if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) - { + @Override + protected void actionPerformed(GuiButton guibutton) { + super.actionPerformed(guibutton); + + if (guibutton.id == 0) { + Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage( + SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 1, 0, 0 + )); + } else if (guibutton.id == 1) { + Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage( + SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 2, 0, 0 + )); + } else if (guibutton.id == 2) { + Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage( + SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 3, 0, 0 + )); + } else if (guibutton.id == 3) { + Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage( + SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 5, 0, 0 + )); + } + } + + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + fontRendererObj.drawString( + LangUtils.localize("gui.filterSelect.title"), 43, 6, 0x404040 + ); + + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiFilterSelect.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + if (xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { + drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 0, 11, 11); + } else { + drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 11, 11, 11); + } + } + + @Override + public void mouseClicked(int mouseX, int mouseY, int button) { + super.mouseClicked(mouseX, mouseY, button); + + if (button == 0) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + if (xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0)); - } - } - } + Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage( + SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0 + )); + } + } + } } diff --git a/src/main/java/mekanism/client/gui/GuiTItemStackFilter.java b/src/main/java/mekanism/client/gui/GuiTItemStackFilter.java index e56c4f9bd..eaf11f871 100644 --- a/src/main/java/mekanism/client/gui/GuiTItemStackFilter.java +++ b/src/main/java/mekanism/client/gui/GuiTItemStackFilter.java @@ -1,5 +1,7 @@ package mekanism.client.gui; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.client.render.MekanismRenderer; @@ -20,332 +22,323 @@ import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiTextField; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; - import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiTItemStackFilter extends GuiMekanism -{ - public TileEntityLogisticalSorter tileEntity; +public class GuiTItemStackFilter extends GuiMekanism { + public TileEntityLogisticalSorter tileEntity; - public boolean isNew = false; + public boolean isNew = false; - public TItemStackFilter origFilter; + public TItemStackFilter origFilter; - public TItemStackFilter filter = new TItemStackFilter(); + public TItemStackFilter filter = new TItemStackFilter(); - public String status = EnumColor.DARK_GREEN + LangUtils.localize("gui.allOK"); + public String status = EnumColor.DARK_GREEN + LangUtils.localize("gui.allOK"); - public int ticker; + public int ticker; - private GuiTextField minField; - private GuiTextField maxField; + private GuiTextField minField; + private GuiTextField maxField; - public GuiTItemStackFilter(EntityPlayer player, TileEntityLogisticalSorter tentity, int index) - { - super(tentity, new ContainerFilter(player.inventory, tentity)); - tileEntity = tentity; + public GuiTItemStackFilter( + EntityPlayer player, TileEntityLogisticalSorter tentity, int index + ) { + super(tentity, new ContainerFilter(player.inventory, tentity)); + tileEntity = tentity; - origFilter = (TItemStackFilter)tileEntity.filters.get(index); - filter = ((TItemStackFilter)tileEntity.filters.get(index)).clone(); - } + origFilter = (TItemStackFilter) tileEntity.filters.get(index); + filter = ((TItemStackFilter) tileEntity.filters.get(index)).clone(); + } - public GuiTItemStackFilter(EntityPlayer player, TileEntityLogisticalSorter tentity) - { - super(tentity, new ContainerFilter(player.inventory, tentity)); - tileEntity = tentity; + public GuiTItemStackFilter(EntityPlayer player, TileEntityLogisticalSorter tentity) { + super(tentity, new ContainerFilter(player.inventory, tentity)); + tileEntity = tentity; - isNew = true; - } + isNew = true; + } - @Override - public void initGui() - { - super.initGui(); + @Override + public void initGui() { + super.initGui(); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; - buttonList.clear(); - buttonList.add(new GuiButton(0, guiWidth + 27, guiHeight + 62, 60, 20, LangUtils.localize("gui.save"))); - buttonList.add(new GuiButton(1, guiWidth + 89, guiHeight + 62, 60, 20, LangUtils.localize("gui.delete"))); + buttonList.clear(); + buttonList.add(new GuiButton( + 0, guiWidth + 27, guiHeight + 62, 60, 20, LangUtils.localize("gui.save") + )); + buttonList.add(new GuiButton( + 1, guiWidth + 89, guiHeight + 62, 60, 20, LangUtils.localize("gui.delete") + )); - if(isNew) - { - ((GuiButton)buttonList.get(1)).enabled = false; - } + if (isNew) { + ((GuiButton) buttonList.get(1)).enabled = false; + } - minField = new GuiTextField(fontRendererObj, guiWidth + 149, guiHeight + 19, 20, 11); - minField.setMaxStringLength(2); - minField.setText("" + filter.min); + minField + = new GuiTextField(fontRendererObj, guiWidth + 149, guiHeight + 19, 20, 11); + minField.setMaxStringLength(2); + minField.setText("" + filter.min); - maxField = new GuiTextField(fontRendererObj, guiWidth + 149, guiHeight + 31, 20, 11); - maxField.setMaxStringLength(2); - maxField.setText("" + filter.max); - } + maxField + = new GuiTextField(fontRendererObj, guiWidth + 149, guiHeight + 31, 20, 11); + maxField.setMaxStringLength(2); + maxField.setText("" + filter.max); + } - @Override - protected void actionPerformed(GuiButton guibutton) - { - super.actionPerformed(guibutton); + @Override + protected void actionPerformed(GuiButton guibutton) { + super.actionPerformed(guibutton); - if(guibutton.id == 0) - { - if(filter.itemType != null && !minField.getText().isEmpty() && !maxField.getText().isEmpty()) - { - int min = Integer.parseInt(minField.getText()); - int max = Integer.parseInt(maxField.getText()); + if (guibutton.id == 0) { + if (filter.itemType != null && !minField.getText().isEmpty() + && !maxField.getText().isEmpty()) { + int min = Integer.parseInt(minField.getText()); + int max = Integer.parseInt(maxField.getText()); - if(max >= min && max <= 64 && min <= 64) - { - filter.min = Integer.parseInt(minField.getText()); - filter.max = Integer.parseInt(maxField.getText()); + if (max >= min && max <= 64 && min <= 64) { + filter.min = Integer.parseInt(minField.getText()); + filter.max = Integer.parseInt(maxField.getText()); - if(isNew) - { - Mekanism.packetHandler.sendToServer(new NewFilterMessage(Coord4D.get(tileEntity), filter)); - } - else { - Mekanism.packetHandler.sendToServer(new EditFilterMessage(Coord4D.get(tileEntity), false, origFilter, filter)); - } + if (isNew) { + Mekanism.packetHandler.sendToServer( + new NewFilterMessage(Coord4D.get(tileEntity), filter) + ); + } else { + Mekanism.packetHandler.sendToServer(new EditFilterMessage( + Coord4D.get(tileEntity), false, origFilter, filter + )); + } - Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0)); - } - else if(min > max) - { - status = EnumColor.DARK_RED + "Max 64 || min > 64) - { - status = EnumColor.DARK_RED + "Max>64"; - ticker = 20; - } - } - else if(filter.itemType == null) - { - status = EnumColor.DARK_RED + "No item"; - ticker = 20; - } - else if(minField.getText().isEmpty() || maxField.getText().isEmpty()) - { - status = EnumColor.DARK_RED + "Max/min"; - ticker = 20; - } - } - else if(guibutton.id == 1) - { - Mekanism.packetHandler.sendToServer(new EditFilterMessage(Coord4D.get(tileEntity), true, origFilter, null)); - Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0)); - } - } + Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage( + SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0 + )); + } else if (min > max) { + status = EnumColor.DARK_RED + "Max 64 || min > 64) { + status = EnumColor.DARK_RED + "Max>64"; + ticker = 20; + } + } else if (filter.itemType == null) { + status = EnumColor.DARK_RED + "No item"; + ticker = 20; + } else if (minField.getText().isEmpty() || maxField.getText().isEmpty()) { + status = EnumColor.DARK_RED + "Max/min"; + ticker = 20; + } + } else if (guibutton.id == 1) { + Mekanism.packetHandler.sendToServer( + new EditFilterMessage(Coord4D.get(tileEntity), true, origFilter, null) + ); + Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage( + SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0 + )); + } + } - @Override - public void keyTyped(char c, int i) - { - if((!minField.isFocused() && !maxField.isFocused()) || i == Keyboard.KEY_ESCAPE) - { - super.keyTyped(c, i); - } + @Override + public void keyTyped(char c, int i) { + if ((!minField.isFocused() && !maxField.isFocused()) + || i == Keyboard.KEY_ESCAPE) { + super.keyTyped(c, i); + } - if(Character.isDigit(c) || isTextboxKey(c, i)) - { - minField.textboxKeyTyped(c, i); - maxField.textboxKeyTyped(c, i); - } - } + if (Character.isDigit(c) || isTextboxKey(c, i)) { + minField.textboxKeyTyped(c, i); + maxField.textboxKeyTyped(c, i); + } + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - fontRendererObj.drawString((isNew ? LangUtils.localize("gui.new") : LangUtils.localize("gui.edit")) + " " + LangUtils.localize("gui.itemFilter"), 43, 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("gui.status") + ": " + status, 35, 20, 0x00CD00); - fontRendererObj.drawString(LangUtils.localize("gui.itemFilter.details") + ":", 35, 32, 0x00CD00); + fontRendererObj.drawString( + (isNew ? LangUtils.localize("gui.new") : LangUtils.localize("gui.edit")) + " " + + LangUtils.localize("gui.itemFilter"), + 43, + 6, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.status") + ": " + status, 35, 20, 0x00CD00 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.itemFilter.details") + ":", 35, 32, 0x00CD00 + ); - fontRendererObj.drawString(LangUtils.localize("gui.itemFilter.min") + ":", 128, 20, 0x404040); - fontRendererObj.drawString(LangUtils.localize("gui.itemFilter.max") + ":", 128, 32, 0x404040); - fontRendererObj.drawString(LangUtils.localize("gui." + (filter.sizeMode ? "on" : "off")), 141, 46, 0x404040); + fontRendererObj.drawString( + LangUtils.localize("gui.itemFilter.min") + ":", 128, 20, 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.itemFilter.max") + ":", 128, 32, 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("gui." + (filter.sizeMode ? "on" : "off")), + 141, + 46, + 0x404040 + ); - if(filter.itemType != null) - { - fontRendererObj.drawString(filter.itemType.getDisplayName(), 35, 41, 0x00CD00); - } + if (filter.itemType != null) { + fontRendererObj.drawString( + filter.itemType.getDisplayName(), 35, 41, 0x00CD00 + ); + } - if(filter.itemType != null) - { - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_LIGHTING); - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), filter.itemType, 12, 19); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } + if (filter.itemType != null) { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_LIGHTING); + itemRender.renderItemAndEffectIntoGUI( + fontRendererObj, mc.getTextureManager(), filter.itemType, 12, 19 + ); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } - if(filter.color != null) - { - GL11.glPushMatrix(); - GL11.glColor4f(1, 1, 1, 1); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); + if (filter.color != null) { + GL11.glPushMatrix(); + GL11.glColor4f(1, 1, 1, 1); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); - mc.getTextureManager().bindTexture(MekanismRenderer.getBlocksTexture()); - itemRender.renderIcon(12, 44, MekanismRenderer.getColorIcon(filter.color), 16, 16); + mc.getTextureManager().bindTexture(MekanismRenderer.getBlocksTexture()); + itemRender.renderIcon( + 12, 44, MekanismRenderer.getColorIcon(filter.color), 16, 16 + ); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } - if(xAxis >= 12 && xAxis <= 28 && yAxis >= 44 && yAxis <= 60) - { - if(filter.color != null) - { - drawCreativeTabHoveringText(filter.color.getName(), xAxis, yAxis); - } - else { - drawCreativeTabHoveringText(LangUtils.localize("gui.none"), xAxis, yAxis); - } - } + if (xAxis >= 12 && xAxis <= 28 && yAxis >= 44 && yAxis <= 60) { + if (filter.color != null) { + drawCreativeTabHoveringText(filter.color.getName(), xAxis, yAxis); + } else { + drawCreativeTabHoveringText(LangUtils.localize("gui.none"), xAxis, yAxis); + } + } - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - @Override - public void updateScreen() - { - super.updateScreen(); + @Override + public void updateScreen() { + super.updateScreen(); - minField.updateCursorCounter(); - maxField.updateCursorCounter(); + minField.updateCursorCounter(); + maxField.updateCursorCounter(); - if(ticker > 0) - { - ticker--; - } - else { - status = EnumColor.DARK_GREEN + LangUtils.localize("gui.allOK"); - } - } + if (ticker > 0) { + ticker--; + } else { + status = EnumColor.DARK_GREEN + LangUtils.localize("gui.allOK"); + } + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiTItemStackFilter.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiTItemStackFilter.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) - { - drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 0, 11, 11); - } - else { - drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 11, 11, 11); - } + if (xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { + drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 0, 11, 11); + } else { + drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 11, 11, 11); + } - if(xAxis >= 128 && xAxis <= 139 && yAxis >= 44 && yAxis <= 55) - { - drawTexturedModalRect(guiWidth + 128, guiHeight + 44, 187, 0, 11, 11); - } - else { - drawTexturedModalRect(guiWidth + 128, guiHeight + 44, 187, 11, 11, 11); - } + if (xAxis >= 128 && xAxis <= 139 && yAxis >= 44 && yAxis <= 55) { + drawTexturedModalRect(guiWidth + 128, guiHeight + 44, 187, 0, 11, 11); + } else { + drawTexturedModalRect(guiWidth + 128, guiHeight + 44, 187, 11, 11, 11); + } - minField.drawTextBox(); - maxField.drawTextBox(); + minField.drawTextBox(); + maxField.drawTextBox(); - if(xAxis >= 12 && xAxis <= 28 && yAxis >= 19 && yAxis <= 35) - { - GL11.glPushMatrix(); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_DEPTH_TEST); + if (xAxis >= 12 && xAxis <= 28 && yAxis >= 19 && yAxis <= 35) { + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); - int x = guiWidth + 12; - int y = guiHeight + 19; - drawGradientRect(x, y, x + 16, y + 16, -2130706433, -2130706433); + int x = guiWidth + 12; + int y = guiHeight + 19; + drawGradientRect(x, y, x + 16, y + 16, -2130706433, -2130706433); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_DEPTH_TEST); - GL11.glPopMatrix(); - } - } + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glPopMatrix(); + } + } - @Override - protected void mouseClicked(int mouseX, int mouseY, int button) - { - super.mouseClicked(mouseX, mouseY, button); + @Override + protected void mouseClicked(int mouseX, int mouseY, int button) { + super.mouseClicked(mouseX, mouseY, button); - minField.mouseClicked(mouseX, mouseY, button); - maxField.mouseClicked(mouseX, mouseY, button); + minField.mouseClicked(mouseX, mouseY, button); + maxField.mouseClicked(mouseX, mouseY, button); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - if(button == 0) - { - if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) - { + if (button == 0) { + if (xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), isNew ? 4 : 0, 0, 0)); - } + Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage( + SorterGuiPacket.SERVER, Coord4D.get(tileEntity), isNew ? 4 : 0, 0, 0 + )); + } - if(xAxis >= 12 && xAxis <= 28 && yAxis >= 19 && yAxis <= 35) - { - ItemStack stack = mc.thePlayer.inventory.getItemStack(); + if (xAxis >= 12 && xAxis <= 28 && yAxis >= 19 && yAxis <= 35) { + ItemStack stack = mc.thePlayer.inventory.getItemStack(); - if(stack != null && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) - { - filter.itemType = stack.copy(); - filter.itemType.stackSize = 1; - } - else if(stack == null && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) - { - filter.itemType = null; - } + if (stack != null && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + filter.itemType = stack.copy(); + filter.itemType.stackSize = 1; + } else if (stack == null && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + filter.itemType = null; + } SoundHandler.playSound("gui.button.press"); - } + } - if(xAxis >= 128 && xAxis <= 139 && yAxis >= 44 && yAxis <= 55) - { + if (xAxis >= 128 && xAxis <= 139 && yAxis >= 44 && yAxis <= 55) { SoundHandler.playSound("gui.button.press"); - filter.sizeMode = !filter.sizeMode; - } - } + filter.sizeMode = !filter.sizeMode; + } + } - if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && button == 0) - { - button = 2; - } + if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && button == 0) { + button = 2; + } - if(xAxis >= 12 && xAxis <= 28 && yAxis >= 44 && yAxis <= 60) - { - SoundHandler.playSound("mekanism:etc.Ding"); + if (xAxis >= 12 && xAxis <= 28 && yAxis >= 44 && yAxis <= 60) { + SoundHandler.playSound("mekanism:etc.Ding"); - if(button == 0) - { - filter.color = TransporterUtils.increment(filter.color); - } - else if(button == 1) - { - filter.color = TransporterUtils.decrement(filter.color); - } - else if(button == 2) - { - filter.color = null; - } - } - } + if (button == 0) { + filter.color = TransporterUtils.increment(filter.color); + } else if (button == 1) { + filter.color = TransporterUtils.decrement(filter.color); + } else if (button == 2) { + filter.color = null; + } + } + } } diff --git a/src/main/java/mekanism/client/gui/GuiTMaterialFilter.java b/src/main/java/mekanism/client/gui/GuiTMaterialFilter.java index f0f8b6a3d..7f62ab665 100644 --- a/src/main/java/mekanism/client/gui/GuiTMaterialFilter.java +++ b/src/main/java/mekanism/client/gui/GuiTMaterialFilter.java @@ -1,5 +1,7 @@ package mekanism.client.gui; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.client.render.MekanismRenderer; @@ -22,261 +24,250 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; - import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiTMaterialFilter extends GuiMekanism -{ - public TileEntityLogisticalSorter tileEntity; +public class GuiTMaterialFilter extends GuiMekanism { + public TileEntityLogisticalSorter tileEntity; - public boolean isNew = false; + public boolean isNew = false; - public TMaterialFilter origFilter; + public TMaterialFilter origFilter; - public TMaterialFilter filter = new TMaterialFilter(); + public TMaterialFilter filter = new TMaterialFilter(); - public String status = EnumColor.DARK_GREEN + LangUtils.localize("gui.allOK"); + public String status = EnumColor.DARK_GREEN + LangUtils.localize("gui.allOK"); - public int ticker; + public int ticker; - public GuiTMaterialFilter(EntityPlayer player, TileEntityLogisticalSorter tentity, int index) - { - super(tentity, new ContainerFilter(player.inventory, tentity)); - tileEntity = tentity; + public GuiTMaterialFilter( + EntityPlayer player, TileEntityLogisticalSorter tentity, int index + ) { + super(tentity, new ContainerFilter(player.inventory, tentity)); + tileEntity = tentity; - origFilter = (TMaterialFilter)tileEntity.filters.get(index); - filter = ((TMaterialFilter)tileEntity.filters.get(index)).clone(); - } + origFilter = (TMaterialFilter) tileEntity.filters.get(index); + filter = ((TMaterialFilter) tileEntity.filters.get(index)).clone(); + } - public GuiTMaterialFilter(EntityPlayer player, TileEntityLogisticalSorter tentity) - { - super(tentity, new ContainerFilter(player.inventory, tentity)); - tileEntity = tentity; + public GuiTMaterialFilter(EntityPlayer player, TileEntityLogisticalSorter tentity) { + super(tentity, new ContainerFilter(player.inventory, tentity)); + tileEntity = tentity; - isNew = true; - } + isNew = true; + } - @Override - public void initGui() - { - super.initGui(); + @Override + public void initGui() { + super.initGui(); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; - buttonList.clear(); - buttonList.add(new GuiButton(0, guiWidth + 27, guiHeight + 62, 60, 20, LangUtils.localize("gui.save"))); - buttonList.add(new GuiButton(1, guiWidth + 89, guiHeight + 62, 60, 20, LangUtils.localize("gui.delete"))); + buttonList.clear(); + buttonList.add(new GuiButton( + 0, guiWidth + 27, guiHeight + 62, 60, 20, LangUtils.localize("gui.save") + )); + buttonList.add(new GuiButton( + 1, guiWidth + 89, guiHeight + 62, 60, 20, LangUtils.localize("gui.delete") + )); - if(isNew) - { - ((GuiButton)buttonList.get(1)).enabled = false; - } - } + if (isNew) { + ((GuiButton) buttonList.get(1)).enabled = false; + } + } - @Override - protected void actionPerformed(GuiButton guibutton) - { - super.actionPerformed(guibutton); + @Override + protected void actionPerformed(GuiButton guibutton) { + super.actionPerformed(guibutton); - if(guibutton.id == 0) - { - if(filter.materialItem != null) - { - if(isNew) - { - Mekanism.packetHandler.sendToServer(new NewFilterMessage(Coord4D.get(tileEntity), filter)); - } - else { - Mekanism.packetHandler.sendToServer(new EditFilterMessage(Coord4D.get(tileEntity), false, origFilter, filter)); - } + if (guibutton.id == 0) { + if (filter.materialItem != null) { + if (isNew) { + Mekanism.packetHandler.sendToServer( + new NewFilterMessage(Coord4D.get(tileEntity), filter) + ); + } else { + Mekanism.packetHandler.sendToServer(new EditFilterMessage( + Coord4D.get(tileEntity), false, origFilter, filter + )); + } - Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0)); - } - else if(filter.materialItem == null) - { - status = EnumColor.DARK_RED + LangUtils.localize("gui.itemFilter.noItem"); - ticker = 20; - } - } - else if(guibutton.id == 1) - { - Mekanism.packetHandler.sendToServer(new EditFilterMessage(Coord4D.get(tileEntity), true, origFilter, null)); - Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0)); - } - } + Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage( + SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0 + )); + } else if (filter.materialItem == null) { + status = EnumColor.DARK_RED + LangUtils.localize("gui.itemFilter.noItem"); + ticker = 20; + } + } else if (guibutton.id == 1) { + Mekanism.packetHandler.sendToServer( + new EditFilterMessage(Coord4D.get(tileEntity), true, origFilter, null) + ); + Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage( + SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0 + )); + } + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - fontRendererObj.drawString((isNew ? LangUtils.localize("gui.new") : LangUtils.localize("gui.edit")) + " " + LangUtils.localize("gui.materialFilter"), 43, 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("gui.status") + ": " + status, 35, 20, 0x00CD00); - fontRendererObj.drawString(LangUtils.localize("gui.materialFilter.details") + ":", 35, 32, 0x00CD00); + fontRendererObj.drawString( + (isNew ? LangUtils.localize("gui.new") : LangUtils.localize("gui.edit")) + " " + + LangUtils.localize("gui.materialFilter"), + 43, + 6, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.status") + ": " + status, 35, 20, 0x00CD00 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.materialFilter.details") + ":", 35, 32, 0x00CD00 + ); - if(filter.materialItem != null) - { - fontRendererObj.drawString(filter.materialItem.getDisplayName(), 35, 41, 0x00CD00); - } + if (filter.materialItem != null) { + fontRendererObj.drawString( + filter.materialItem.getDisplayName(), 35, 41, 0x00CD00 + ); + } - if(filter.materialItem != null) - { - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_LIGHTING); - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), filter.materialItem, 12, 19); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } - - if(filter.color != null) - { - GL11.glPushMatrix(); - GL11.glColor4f(1, 1, 1, 1); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); + if (filter.materialItem != null) { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_LIGHTING); + itemRender.renderItemAndEffectIntoGUI( + fontRendererObj, mc.getTextureManager(), filter.materialItem, 12, 19 + ); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } - mc.getTextureManager().bindTexture(MekanismRenderer.getBlocksTexture()); - itemRender.renderIcon(12, 44, MekanismRenderer.getColorIcon(filter.color), 16, 16); + if (filter.color != null) { + GL11.glPushMatrix(); + GL11.glColor4f(1, 1, 1, 1); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } + mc.getTextureManager().bindTexture(MekanismRenderer.getBlocksTexture()); + itemRender.renderIcon( + 12, 44, MekanismRenderer.getColorIcon(filter.color), 16, 16 + ); - if(xAxis >= 12 && xAxis <= 28 && yAxis >= 44 && yAxis <= 60) - { - if(filter.color != null) - { - drawCreativeTabHoveringText(filter.color.getName(), xAxis, yAxis); - } - else { - drawCreativeTabHoveringText(LangUtils.localize("gui.none"), xAxis, yAxis); - } - } + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + if (xAxis >= 12 && xAxis <= 28 && yAxis >= 44 && yAxis <= 60) { + if (filter.color != null) { + drawCreativeTabHoveringText(filter.color.getName(), xAxis, yAxis); + } else { + drawCreativeTabHoveringText(LangUtils.localize("gui.none"), xAxis, yAxis); + } + } - @Override - public void updateScreen() - { - super.updateScreen(); + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - if(ticker > 0) - { - ticker--; - } - else { - status = EnumColor.DARK_GREEN + LangUtils.localize("gui.allOK"); - } - } + @Override + public void updateScreen() { + super.updateScreen(); - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + if (ticker > 0) { + ticker--; + } else { + status = EnumColor.DARK_GREEN + LangUtils.localize("gui.allOK"); + } + } - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiTMaterialFilter.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiTMaterialFilter.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) - { - drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 0, 11, 11); - } - else { - drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 11, 11, 11); - } + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - if(xAxis >= 12 && xAxis <= 28 && yAxis >= 19 && yAxis <= 35) - { - GL11.glPushMatrix(); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glDisable(GL11.GL_DEPTH_TEST); + if (xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { + drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 0, 11, 11); + } else { + drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 11, 11, 11); + } - int x = guiWidth + 12; - int y = guiHeight + 19; - drawGradientRect(x, y, x + 16, y + 16, -2130706433, -2130706433); + if (xAxis >= 12 && xAxis <= 28 && yAxis >= 19 && yAxis <= 35) { + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_DEPTH_TEST); - GL11.glPopMatrix(); - } - } + int x = guiWidth + 12; + int y = guiHeight + 19; + drawGradientRect(x, y, x + 16, y + 16, -2130706433, -2130706433); - @Override - protected void mouseClicked(int mouseX, int mouseY, int button) - { - super.mouseClicked(mouseX, mouseY, button); - - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glPopMatrix(); + } + } - if(button == 0) - { - if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) - { + @Override + protected void mouseClicked(int mouseX, int mouseY, int button) { + super.mouseClicked(mouseX, mouseY, button); + + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + if (button == 0) { + if (xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), isNew ? 4 : 0, 0, 0)); - } + Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage( + SorterGuiPacket.SERVER, Coord4D.get(tileEntity), isNew ? 4 : 0, 0, 0 + )); + } - if(xAxis >= 12 && xAxis <= 28 && yAxis >= 19 && yAxis <= 35) - { - ItemStack stack = mc.thePlayer.inventory.getItemStack(); + if (xAxis >= 12 && xAxis <= 28 && yAxis >= 19 && yAxis <= 35) { + ItemStack stack = mc.thePlayer.inventory.getItemStack(); - if(stack != null && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) - { - if(stack.getItem() instanceof ItemBlock) - { - if(Block.getBlockFromItem(stack.getItem()) != Blocks.bedrock) - { - filter.materialItem = stack.copy(); - filter.materialItem.stackSize = 1; - } - } - } - else if(stack == null && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) - { - filter.materialItem = null; - } + if (stack != null && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + if (stack.getItem() instanceof ItemBlock) { + if (Block.getBlockFromItem(stack.getItem()) != Blocks.bedrock) { + filter.materialItem = stack.copy(); + filter.materialItem.stackSize = 1; + } + } + } else if (stack == null && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + filter.materialItem = null; + } SoundHandler.playSound("gui.button.press"); - } - } - - if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && button == 0) - { - button = 2; - } + } + } - if(xAxis >= 12 && xAxis <= 28 && yAxis >= 44 && yAxis <= 60) - { - SoundHandler.playSound("mekanism:etc.Ding"); + if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && button == 0) { + button = 2; + } - if(button == 0) - { - filter.color = TransporterUtils.increment(filter.color); - } - else if(button == 1) - { - filter.color = TransporterUtils.decrement(filter.color); - } - else if(button == 2) - { - filter.color = null; - } - } - } + if (xAxis >= 12 && xAxis <= 28 && yAxis >= 44 && yAxis <= 60) { + SoundHandler.playSound("mekanism:etc.Ding"); + + if (button == 0) { + filter.color = TransporterUtils.increment(filter.color); + } else if (button == 1) { + filter.color = TransporterUtils.decrement(filter.color); + } else if (button == 2) { + filter.color = null; + } + } + } } diff --git a/src/main/java/mekanism/client/gui/GuiTModIDFilter.java b/src/main/java/mekanism/client/gui/GuiTModIDFilter.java index de19a598f..8ae0fc2d4 100644 --- a/src/main/java/mekanism/client/gui/GuiTModIDFilter.java +++ b/src/main/java/mekanism/client/gui/GuiTModIDFilter.java @@ -2,6 +2,8 @@ package mekanism.client.gui; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.client.render.MekanismRenderer; @@ -24,334 +26,312 @@ import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiTextField; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; - import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiTModIDFilter extends GuiMekanism -{ - public TileEntityLogisticalSorter tileEntity; +public class GuiTModIDFilter extends GuiMekanism { + public TileEntityLogisticalSorter tileEntity; - public boolean isNew = false; + public boolean isNew = false; - public TModIDFilter origFilter; + public TModIDFilter origFilter; - public TModIDFilter filter = new TModIDFilter(); + public TModIDFilter filter = new TModIDFilter(); - private GuiTextField modIDText; + private GuiTextField modIDText; - public ItemStack renderStack; + public ItemStack renderStack; - public int ticker = 0; + public int ticker = 0; - public int stackSwitch = 0; + public int stackSwitch = 0; - public int stackIndex = 0; + public int stackIndex = 0; - public List iterStacks; + public List iterStacks; - public String status = EnumColor.DARK_GREEN + LangUtils.localize("gui.allOK"); + public String status = EnumColor.DARK_GREEN + LangUtils.localize("gui.allOK"); - public GuiTModIDFilter(EntityPlayer player, TileEntityLogisticalSorter tentity, int index) - { - super(tentity, new ContainerFilter(player.inventory, tentity)); - tileEntity = tentity; + public GuiTModIDFilter( + EntityPlayer player, TileEntityLogisticalSorter tentity, int index + ) { + super(tentity, new ContainerFilter(player.inventory, tentity)); + tileEntity = tentity; - origFilter = (TModIDFilter)tileEntity.filters.get(index); - filter = ((TModIDFilter)tentity.filters.get(index)).clone(); + origFilter = (TModIDFilter) tileEntity.filters.get(index); + filter = ((TModIDFilter) tentity.filters.get(index)).clone(); - updateStackList(filter.modID); - } + updateStackList(filter.modID); + } - public GuiTModIDFilter(EntityPlayer player, TileEntityLogisticalSorter tentity) - { - super(tentity, new ContainerFilter(player.inventory, tentity)); - tileEntity = tentity; + public GuiTModIDFilter(EntityPlayer player, TileEntityLogisticalSorter tentity) { + super(tentity, new ContainerFilter(player.inventory, tentity)); + tileEntity = tentity; - isNew = true; - } + isNew = true; + } - @Override - public void initGui() - { - super.initGui(); + @Override + public void initGui() { + super.initGui(); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; - buttonList.clear(); - buttonList.add(new GuiButton(0, guiWidth + 27, guiHeight + 62, 60, 20, LangUtils.localize("gui.save"))); - buttonList.add(new GuiButton(1, guiWidth + 89, guiHeight + 62, 60, 20, LangUtils.localize("gui.delete"))); + buttonList.clear(); + buttonList.add(new GuiButton( + 0, guiWidth + 27, guiHeight + 62, 60, 20, LangUtils.localize("gui.save") + )); + buttonList.add(new GuiButton( + 1, guiWidth + 89, guiHeight + 62, 60, 20, LangUtils.localize("gui.delete") + )); - if(isNew) - { - ((GuiButton)buttonList.get(1)).enabled = false; - } + if (isNew) { + ((GuiButton) buttonList.get(1)).enabled = false; + } - modIDText = new GuiTextField(fontRendererObj, guiWidth + 35, guiHeight + 47, 95, 12); - modIDText.setMaxStringLength(TransporterFilter.MAX_LENGTH); - modIDText.setFocused(true); - } + modIDText + = new GuiTextField(fontRendererObj, guiWidth + 35, guiHeight + 47, 95, 12); + modIDText.setMaxStringLength(TransporterFilter.MAX_LENGTH); + modIDText.setFocused(true); + } - @Override - public void keyTyped(char c, int i) - { - if(!modIDText.isFocused() || i == Keyboard.KEY_ESCAPE) - { - super.keyTyped(c, i); - } + @Override + public void keyTyped(char c, int i) { + if (!modIDText.isFocused() || i == Keyboard.KEY_ESCAPE) { + super.keyTyped(c, i); + } - if(modIDText.isFocused() && i == Keyboard.KEY_RETURN) - { - setModID(); - return; - } + if (modIDText.isFocused() && i == Keyboard.KEY_RETURN) { + setModID(); + return; + } - if(Character.isLetter(c) || Character.isDigit(c) || TransporterFilter.SPECIAL_CHARS.contains(c) || isTextboxKey(c, i)) - { - modIDText.textboxKeyTyped(c, i); - } - } + if (Character.isLetter(c) || Character.isDigit(c) + || TransporterFilter.SPECIAL_CHARS.contains(c) || isTextboxKey(c, i)) { + modIDText.textboxKeyTyped(c, i); + } + } - @Override - protected void actionPerformed(GuiButton guibutton) - { - super.actionPerformed(guibutton); + @Override + protected void actionPerformed(GuiButton guibutton) { + super.actionPerformed(guibutton); - if(guibutton.id == 0) - { - if(!modIDText.getText().isEmpty()) - { - setModID(); - } + if (guibutton.id == 0) { + if (!modIDText.getText().isEmpty()) { + setModID(); + } - if(filter.modID != null && !filter.modID.isEmpty()) - { - if(isNew) - { - Mekanism.packetHandler.sendToServer(new NewFilterMessage(Coord4D.get(tileEntity), filter)); - } - else { - Mekanism.packetHandler.sendToServer(new EditFilterMessage(Coord4D.get(tileEntity), false, origFilter, filter)); - } + if (filter.modID != null && !filter.modID.isEmpty()) { + if (isNew) { + Mekanism.packetHandler.sendToServer( + new NewFilterMessage(Coord4D.get(tileEntity), filter) + ); + } else { + Mekanism.packetHandler.sendToServer(new EditFilterMessage( + Coord4D.get(tileEntity), false, origFilter, filter + )); + } - Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0)); - } - else { - status = EnumColor.DARK_RED + LangUtils.localize("gui.modIDFilter.noKey"); - ticker = 20; - } - } - else if(guibutton.id == 1) - { - Mekanism.packetHandler.sendToServer(new EditFilterMessage(Coord4D.get(tileEntity), true, origFilter, null)); - Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0)); - } - } + Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage( + SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0 + )); + } else { + status = EnumColor.DARK_RED + LangUtils.localize("gui.modIDFilter.noKey"); + ticker = 20; + } + } else if (guibutton.id == 1) { + Mekanism.packetHandler.sendToServer( + new EditFilterMessage(Coord4D.get(tileEntity), true, origFilter, null) + ); + Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage( + SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0 + )); + } + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - fontRendererObj.drawString((isNew ? LangUtils.localize("gui.new") : LangUtils.localize("gui.edit")) + " " + LangUtils.localize("gui.modIDFilter"), 43, 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("gui.status") + ": " + status, 35, 20, 0x00CD00); - renderScaledText(LangUtils.localize("gui.id") + ": " + filter.modID, 35, 32, 0x00CD00, 107); + fontRendererObj.drawString( + (isNew ? LangUtils.localize("gui.new") : LangUtils.localize("gui.edit")) + " " + + LangUtils.localize("gui.modIDFilter"), + 43, + 6, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.status") + ": " + status, 35, 20, 0x00CD00 + ); + renderScaledText( + LangUtils.localize("gui.id") + ": " + filter.modID, 35, 32, 0x00CD00, 107 + ); - if(renderStack != null) - { - try { - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_LIGHTING); - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), renderStack, 12, 19); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } catch(Exception e) {} - } + if (renderStack != null) { + try { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_LIGHTING); + itemRender.renderItemAndEffectIntoGUI( + fontRendererObj, mc.getTextureManager(), renderStack, 12, 19 + ); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } catch (Exception e) {} + } - if(filter.color != null) - { - GL11.glPushMatrix(); - GL11.glColor4f(1, 1, 1, 1); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); + if (filter.color != null) { + GL11.glPushMatrix(); + GL11.glColor4f(1, 1, 1, 1); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); - mc.getTextureManager().bindTexture(MekanismRenderer.getBlocksTexture()); - itemRender.renderIcon(12, 44, MekanismRenderer.getColorIcon(filter.color), 16, 16); + mc.getTextureManager().bindTexture(MekanismRenderer.getBlocksTexture()); + itemRender.renderIcon( + 12, 44, MekanismRenderer.getColorIcon(filter.color), 16, 16 + ); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } - if(xAxis >= 12 && xAxis <= 28 && yAxis >= 44 && yAxis <= 60) - { - if(filter.color != null) - { - drawCreativeTabHoveringText(filter.color.getName(), xAxis, yAxis); - } - else { - drawCreativeTabHoveringText(LangUtils.localize("gui.none"), xAxis, yAxis); - } - } + if (xAxis >= 12 && xAxis <= 28 && yAxis >= 44 && yAxis <= 60) { + if (filter.color != null) { + drawCreativeTabHoveringText(filter.color.getName(), xAxis, yAxis); + } else { + drawCreativeTabHoveringText(LangUtils.localize("gui.none"), xAxis, yAxis); + } + } - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiTModIDFilter.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiTModIDFilter.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) - { - drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 0, 11, 11); - } - else { - drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 11, 11, 11); - } + if (xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { + drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 0, 11, 11); + } else { + drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 11, 11, 11); + } - if(xAxis >= 131 && xAxis <= 143 && yAxis >= 47 && yAxis <= 59) - { - drawTexturedModalRect(guiWidth + 131, guiHeight + 47, 176 + 11, 0, 12, 12); - } - else { - drawTexturedModalRect(guiWidth + 131, guiHeight + 47, 176 + 11, 12, 12, 12); - } + if (xAxis >= 131 && xAxis <= 143 && yAxis >= 47 && yAxis <= 59) { + drawTexturedModalRect(guiWidth + 131, guiHeight + 47, 176 + 11, 0, 12, 12); + } else { + drawTexturedModalRect(guiWidth + 131, guiHeight + 47, 176 + 11, 12, 12, 12); + } - modIDText.drawTextBox(); - } + modIDText.drawTextBox(); + } - @Override - public void updateScreen() - { - super.updateScreen(); + @Override + public void updateScreen() { + super.updateScreen(); - modIDText.updateCursorCounter(); + modIDText.updateCursorCounter(); - if(ticker > 0) - { - ticker--; - } - else { - status = EnumColor.DARK_GREEN + LangUtils.localize("gui.allOK"); - } + if (ticker > 0) { + ticker--; + } else { + status = EnumColor.DARK_GREEN + LangUtils.localize("gui.allOK"); + } - if(stackSwitch > 0) - { - stackSwitch--; - } + if (stackSwitch > 0) { + stackSwitch--; + } - if(stackSwitch == 0 && iterStacks != null && iterStacks.size() > 0) - { - stackSwitch = 20; + if (stackSwitch == 0 && iterStacks != null && iterStacks.size() > 0) { + stackSwitch = 20; - if(stackIndex == -1 || stackIndex == iterStacks.size()-1) - { - stackIndex = 0; - } - else if(stackIndex < iterStacks.size()-1) - { - stackIndex++; - } + if (stackIndex == -1 || stackIndex == iterStacks.size() - 1) { + stackIndex = 0; + } else if (stackIndex < iterStacks.size() - 1) { + stackIndex++; + } - renderStack = iterStacks.get(stackIndex); - } - else if(iterStacks != null && iterStacks.size() == 0) - { - renderStack = null; - } - } + renderStack = iterStacks.get(stackIndex); + } else if (iterStacks != null && iterStacks.size() == 0) { + renderStack = null; + } + } - @Override - protected void mouseClicked(int mouseX, int mouseY, int button) - { - super.mouseClicked(mouseX, mouseY, button); + @Override + protected void mouseClicked(int mouseX, int mouseY, int button) { + super.mouseClicked(mouseX, mouseY, button); - modIDText.mouseClicked(mouseX, mouseY, button); + modIDText.mouseClicked(mouseX, mouseY, button); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - if(button == 0) - { - if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) - { + if (button == 0) { + if (xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), isNew ? 4 : 0, 0, 0)); - } + Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage( + SorterGuiPacket.SERVER, Coord4D.get(tileEntity), isNew ? 4 : 0, 0, 0 + )); + } - if(xAxis >= 131 && xAxis <= 143 && yAxis >= 47 && yAxis <= 59) - { + if (xAxis >= 131 && xAxis <= 143 && yAxis >= 47 && yAxis <= 59) { SoundHandler.playSound("gui.button.press"); - setModID(); - } - } + setModID(); + } + } - if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && button == 0) - { - button = 2; - } + if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && button == 0) { + button = 2; + } - if(xAxis >= 12 && xAxis <= 28 && yAxis >= 44 && yAxis <= 60) - { - SoundHandler.playSound("mekanism:etc.Ding"); + if (xAxis >= 12 && xAxis <= 28 && yAxis >= 44 && yAxis <= 60) { + SoundHandler.playSound("mekanism:etc.Ding"); - if(button == 0) - { - filter.color = TransporterUtils.increment(filter.color); - } - else if(button == 1) - { - filter.color = TransporterUtils.decrement(filter.color); - } - else if(button == 2) - { - filter.color = null; - } - } - } + if (button == 0) { + filter.color = TransporterUtils.increment(filter.color); + } else if (button == 1) { + filter.color = TransporterUtils.decrement(filter.color); + } else if (button == 2) { + filter.color = null; + } + } + } - private void updateStackList(String modName) - { - iterStacks = OreDictCache.getModIDStacks(modName, false); + private void updateStackList(String modName) { + iterStacks = OreDictCache.getModIDStacks(modName, false); - stackSwitch = 0; - stackIndex = -1; - } + stackSwitch = 0; + stackIndex = -1; + } - private void setModID() - { - String modName = modIDText.getText(); + private void setModID() { + String modName = modIDText.getText(); - if(modName == null || modName.isEmpty()) - { - status = EnumColor.DARK_RED + LangUtils.localize("gui.modIDFilter.noID"); - return; - } - else if(modName.equals(filter.modID)) - { - status = EnumColor.DARK_RED + LangUtils.localize("gui.modIDFilter.sameID"); - return; - } + if (modName == null || modName.isEmpty()) { + status = EnumColor.DARK_RED + LangUtils.localize("gui.modIDFilter.noID"); + return; + } else if (modName.equals(filter.modID)) { + status = EnumColor.DARK_RED + LangUtils.localize("gui.modIDFilter.sameID"); + return; + } - updateStackList(modName); + updateStackList(modName); - filter.modID = modName; - modIDText.setText(""); - } + filter.modID = modName; + modIDText.setText(""); + } } diff --git a/src/main/java/mekanism/client/gui/GuiTOreDictFilter.java b/src/main/java/mekanism/client/gui/GuiTOreDictFilter.java index 0d66c1d4f..364492817 100644 --- a/src/main/java/mekanism/client/gui/GuiTOreDictFilter.java +++ b/src/main/java/mekanism/client/gui/GuiTOreDictFilter.java @@ -2,6 +2,8 @@ package mekanism.client.gui; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.client.render.MekanismRenderer; @@ -24,334 +26,317 @@ import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiTextField; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; - import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiTOreDictFilter extends GuiMekanism -{ - public TileEntityLogisticalSorter tileEntity; +public class GuiTOreDictFilter extends GuiMekanism { + public TileEntityLogisticalSorter tileEntity; - public boolean isNew = false; + public boolean isNew = false; - public TOreDictFilter origFilter; + public TOreDictFilter origFilter; - public TOreDictFilter filter = new TOreDictFilter(); + public TOreDictFilter filter = new TOreDictFilter(); - private GuiTextField oreDictText; + private GuiTextField oreDictText; - public ItemStack renderStack; + public ItemStack renderStack; - public int ticker = 0; + public int ticker = 0; - public int stackSwitch = 0; + public int stackSwitch = 0; - public int stackIndex = 0; + public int stackIndex = 0; - public List iterStacks; + public List iterStacks; - public String status = EnumColor.DARK_GREEN + LangUtils.localize("gui.allOK"); + public String status = EnumColor.DARK_GREEN + LangUtils.localize("gui.allOK"); - public GuiTOreDictFilter(EntityPlayer player, TileEntityLogisticalSorter tentity, int index) - { - super(tentity, new ContainerFilter(player.inventory, tentity)); - tileEntity = tentity; + public GuiTOreDictFilter( + EntityPlayer player, TileEntityLogisticalSorter tentity, int index + ) { + super(tentity, new ContainerFilter(player.inventory, tentity)); + tileEntity = tentity; - origFilter = (TOreDictFilter)tileEntity.filters.get(index); - filter = ((TOreDictFilter)tentity.filters.get(index)).clone(); + origFilter = (TOreDictFilter) tileEntity.filters.get(index); + filter = ((TOreDictFilter) tentity.filters.get(index)).clone(); - updateStackList(filter.oreDictName); - } + updateStackList(filter.oreDictName); + } - public GuiTOreDictFilter(EntityPlayer player, TileEntityLogisticalSorter tentity) - { - super(tentity, new ContainerFilter(player.inventory, tentity)); - tileEntity = tentity; + public GuiTOreDictFilter(EntityPlayer player, TileEntityLogisticalSorter tentity) { + super(tentity, new ContainerFilter(player.inventory, tentity)); + tileEntity = tentity; - isNew = true; - } + isNew = true; + } - @Override - public void initGui() - { - super.initGui(); + @Override + public void initGui() { + super.initGui(); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; - buttonList.clear(); - buttonList.add(new GuiButton(0, guiWidth + 27, guiHeight + 62, 60, 20, LangUtils.localize("gui.save"))); - buttonList.add(new GuiButton(1, guiWidth + 89, guiHeight + 62, 60, 20, LangUtils.localize("gui.delete"))); + buttonList.clear(); + buttonList.add(new GuiButton( + 0, guiWidth + 27, guiHeight + 62, 60, 20, LangUtils.localize("gui.save") + )); + buttonList.add(new GuiButton( + 1, guiWidth + 89, guiHeight + 62, 60, 20, LangUtils.localize("gui.delete") + )); - if(isNew) - { - ((GuiButton)buttonList.get(1)).enabled = false; - } + if (isNew) { + ((GuiButton) buttonList.get(1)).enabled = false; + } - oreDictText = new GuiTextField(fontRendererObj, guiWidth + 35, guiHeight + 47, 95, 12); - oreDictText.setMaxStringLength(TransporterFilter.MAX_LENGTH); - oreDictText.setFocused(true); - } + oreDictText + = new GuiTextField(fontRendererObj, guiWidth + 35, guiHeight + 47, 95, 12); + oreDictText.setMaxStringLength(TransporterFilter.MAX_LENGTH); + oreDictText.setFocused(true); + } - @Override - public void keyTyped(char c, int i) - { - if(!oreDictText.isFocused() || i == Keyboard.KEY_ESCAPE) - { - super.keyTyped(c, i); - } + @Override + public void keyTyped(char c, int i) { + if (!oreDictText.isFocused() || i == Keyboard.KEY_ESCAPE) { + super.keyTyped(c, i); + } - if(oreDictText.isFocused() && i == Keyboard.KEY_RETURN) - { - setOreDictKey(); - return; - } + if (oreDictText.isFocused() && i == Keyboard.KEY_RETURN) { + setOreDictKey(); + return; + } - if(Character.isLetter(c) || Character.isDigit(c) || TransporterFilter.SPECIAL_CHARS.contains(c) || isTextboxKey(c, i)) - { - oreDictText.textboxKeyTyped(c, i); - } - } + if (Character.isLetter(c) || Character.isDigit(c) + || TransporterFilter.SPECIAL_CHARS.contains(c) || isTextboxKey(c, i)) { + oreDictText.textboxKeyTyped(c, i); + } + } - @Override - protected void actionPerformed(GuiButton guibutton) - { - super.actionPerformed(guibutton); + @Override + protected void actionPerformed(GuiButton guibutton) { + super.actionPerformed(guibutton); - if(guibutton.id == 0) - { - if(!oreDictText.getText().isEmpty()) - { - setOreDictKey(); - } + if (guibutton.id == 0) { + if (!oreDictText.getText().isEmpty()) { + setOreDictKey(); + } - if(filter.oreDictName != null && !filter.oreDictName.isEmpty()) - { - if(isNew) - { - Mekanism.packetHandler.sendToServer(new NewFilterMessage(Coord4D.get(tileEntity), filter)); - } - else { - Mekanism.packetHandler.sendToServer(new EditFilterMessage(Coord4D.get(tileEntity), false, origFilter, filter)); - } + if (filter.oreDictName != null && !filter.oreDictName.isEmpty()) { + if (isNew) { + Mekanism.packetHandler.sendToServer( + new NewFilterMessage(Coord4D.get(tileEntity), filter) + ); + } else { + Mekanism.packetHandler.sendToServer(new EditFilterMessage( + Coord4D.get(tileEntity), false, origFilter, filter + )); + } - Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0)); - } - else { - status = EnumColor.DARK_RED + LangUtils.localize("gui.oredictFilter.noKey"); - ticker = 20; - } - } - else if(guibutton.id == 1) - { - Mekanism.packetHandler.sendToServer(new EditFilterMessage(Coord4D.get(tileEntity), true, origFilter, null)); - Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0)); - } - } + Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage( + SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0 + )); + } else { + status + = EnumColor.DARK_RED + LangUtils.localize("gui.oredictFilter.noKey"); + ticker = 20; + } + } else if (guibutton.id == 1) { + Mekanism.packetHandler.sendToServer( + new EditFilterMessage(Coord4D.get(tileEntity), true, origFilter, null) + ); + Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage( + SorterGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0 + )); + } + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - fontRendererObj.drawString((isNew ? LangUtils.localize("gui.new") : LangUtils.localize("gui.edit")) + " " + LangUtils.localize("gui.oredictFilter"), 43, 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("gui.status") + ": " + status, 35, 20, 0x00CD00); - renderScaledText(LangUtils.localize("gui.key") + ": " + filter.oreDictName, 35, 32, 0x00CD00, 107); + fontRendererObj.drawString( + (isNew ? LangUtils.localize("gui.new") : LangUtils.localize("gui.edit")) + " " + + LangUtils.localize("gui.oredictFilter"), + 43, + 6, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.status") + ": " + status, 35, 20, 0x00CD00 + ); + renderScaledText( + LangUtils.localize("gui.key") + ": " + filter.oreDictName, + 35, + 32, + 0x00CD00, + 107 + ); - if(renderStack != null) - { - try { - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_LIGHTING); - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), renderStack, 12, 19); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } catch(Exception e) {} - } + if (renderStack != null) { + try { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_LIGHTING); + itemRender.renderItemAndEffectIntoGUI( + fontRendererObj, mc.getTextureManager(), renderStack, 12, 19 + ); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } catch (Exception e) {} + } - if(filter.color != null) - { - GL11.glPushMatrix(); - GL11.glColor4f(1, 1, 1, 1); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); + if (filter.color != null) { + GL11.glPushMatrix(); + GL11.glColor4f(1, 1, 1, 1); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); - mc.getTextureManager().bindTexture(MekanismRenderer.getBlocksTexture()); - itemRender.renderIcon(12, 44, MekanismRenderer.getColorIcon(filter.color), 16, 16); + mc.getTextureManager().bindTexture(MekanismRenderer.getBlocksTexture()); + itemRender.renderIcon( + 12, 44, MekanismRenderer.getColorIcon(filter.color), 16, 16 + ); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } - if(xAxis >= 12 && xAxis <= 28 && yAxis >= 44 && yAxis <= 60) - { - if(filter.color != null) - { - drawCreativeTabHoveringText(filter.color.getName(), xAxis, yAxis); - } - else { - drawCreativeTabHoveringText(LangUtils.localize("gui.none"), xAxis, yAxis); - } - } + if (xAxis >= 12 && xAxis <= 28 && yAxis >= 44 && yAxis <= 60) { + if (filter.color != null) { + drawCreativeTabHoveringText(filter.color.getName(), xAxis, yAxis); + } else { + drawCreativeTabHoveringText(LangUtils.localize("gui.none"), xAxis, yAxis); + } + } - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiTOreDictFilter.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiTOreDictFilter.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) - { - drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 0, 11, 11); - } - else { - drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 11, 11, 11); - } + if (xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { + drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 0, 11, 11); + } else { + drawTexturedModalRect(guiWidth + 5, guiHeight + 5, 176, 11, 11, 11); + } - if(xAxis >= 131 && xAxis <= 143 && yAxis >= 47 && yAxis <= 59) - { - drawTexturedModalRect(guiWidth + 131, guiHeight + 47, 176 + 11, 0, 12, 12); - } - else { - drawTexturedModalRect(guiWidth + 131, guiHeight + 47, 176 + 11, 12, 12, 12); - } + if (xAxis >= 131 && xAxis <= 143 && yAxis >= 47 && yAxis <= 59) { + drawTexturedModalRect(guiWidth + 131, guiHeight + 47, 176 + 11, 0, 12, 12); + } else { + drawTexturedModalRect(guiWidth + 131, guiHeight + 47, 176 + 11, 12, 12, 12); + } - oreDictText.drawTextBox(); - } + oreDictText.drawTextBox(); + } - @Override - public void updateScreen() - { - super.updateScreen(); + @Override + public void updateScreen() { + super.updateScreen(); - oreDictText.updateCursorCounter(); + oreDictText.updateCursorCounter(); - if(ticker > 0) - { - ticker--; - } - else { - status = EnumColor.DARK_GREEN + LangUtils.localize("gui.allOK"); - } + if (ticker > 0) { + ticker--; + } else { + status = EnumColor.DARK_GREEN + LangUtils.localize("gui.allOK"); + } - if(stackSwitch > 0) - { - stackSwitch--; - } + if (stackSwitch > 0) { + stackSwitch--; + } - if(stackSwitch == 0 && iterStacks != null && iterStacks.size() > 0) - { - stackSwitch = 20; + if (stackSwitch == 0 && iterStacks != null && iterStacks.size() > 0) { + stackSwitch = 20; - if(stackIndex == -1 || stackIndex == iterStacks.size()-1) - { - stackIndex = 0; - } - else if(stackIndex < iterStacks.size()-1) - { - stackIndex++; - } + if (stackIndex == -1 || stackIndex == iterStacks.size() - 1) { + stackIndex = 0; + } else if (stackIndex < iterStacks.size() - 1) { + stackIndex++; + } - renderStack = iterStacks.get(stackIndex); - } - else if(iterStacks != null && iterStacks.size() == 0) - { - renderStack = null; - } - } + renderStack = iterStacks.get(stackIndex); + } else if (iterStacks != null && iterStacks.size() == 0) { + renderStack = null; + } + } - @Override - protected void mouseClicked(int mouseX, int mouseY, int button) - { - super.mouseClicked(mouseX, mouseY, button); + @Override + protected void mouseClicked(int mouseX, int mouseY, int button) { + super.mouseClicked(mouseX, mouseY, button); - oreDictText.mouseClicked(mouseX, mouseY, button); + oreDictText.mouseClicked(mouseX, mouseY, button); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - if(button == 0) - { - if(xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) - { + if (button == 0) { + if (xAxis >= 5 && xAxis <= 16 && yAxis >= 5 && yAxis <= 16) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage(SorterGuiPacket.SERVER, Coord4D.get(tileEntity), isNew ? 4 : 0, 0, 0)); - } + Mekanism.packetHandler.sendToServer(new LogisticalSorterGuiMessage( + SorterGuiPacket.SERVER, Coord4D.get(tileEntity), isNew ? 4 : 0, 0, 0 + )); + } - if(xAxis >= 131 && xAxis <= 143 && yAxis >= 47 && yAxis <= 59) - { + if (xAxis >= 131 && xAxis <= 143 && yAxis >= 47 && yAxis <= 59) { SoundHandler.playSound("gui.button.press"); - setOreDictKey(); - } - } + setOreDictKey(); + } + } - if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && button == 0) - { - button = 2; - } + if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && button == 0) { + button = 2; + } - if(xAxis >= 12 && xAxis <= 28 && yAxis >= 44 && yAxis <= 60) - { - SoundHandler.playSound("mekanism:etc.Ding"); + if (xAxis >= 12 && xAxis <= 28 && yAxis >= 44 && yAxis <= 60) { + SoundHandler.playSound("mekanism:etc.Ding"); - if(button == 0) - { - filter.color = TransporterUtils.increment(filter.color); - } - else if(button == 1) - { - filter.color = TransporterUtils.decrement(filter.color); - } - else if(button == 2) - { - filter.color = null; - } - } - } + if (button == 0) { + filter.color = TransporterUtils.increment(filter.color); + } else if (button == 1) { + filter.color = TransporterUtils.decrement(filter.color); + } else if (button == 2) { + filter.color = null; + } + } + } - private void updateStackList(String oreName) - { - iterStacks = OreDictCache.getOreDictStacks(oreName, false); + private void updateStackList(String oreName) { + iterStacks = OreDictCache.getOreDictStacks(oreName, false); - stackSwitch = 0; - stackIndex = -1; - } + stackSwitch = 0; + stackIndex = -1; + } - private void setOreDictKey() - { - String oreName = oreDictText.getText(); + private void setOreDictKey() { + String oreName = oreDictText.getText(); - if(oreName == null || oreName.isEmpty()) - { - status = EnumColor.DARK_RED + LangUtils.localize("gui.oredictFilter.noKey"); - return; - } - else if(oreName.equals(filter.oreDictName)) - { - status = EnumColor.DARK_RED + LangUtils.localize("gui.oredictFilter.sameKey"); - return; - } + if (oreName == null || oreName.isEmpty()) { + status = EnumColor.DARK_RED + LangUtils.localize("gui.oredictFilter.noKey"); + return; + } else if (oreName.equals(filter.oreDictName)) { + status = EnumColor.DARK_RED + LangUtils.localize("gui.oredictFilter.sameKey"); + return; + } - updateStackList(oreName); + updateStackList(oreName); - filter.oreDictName = oreName; - oreDictText.setText(""); - } + filter.oreDictName = oreName; + oreDictText.setText(""); + } } diff --git a/src/main/java/mekanism/client/gui/GuiTeleporter.java b/src/main/java/mekanism/client/gui/GuiTeleporter.java index 19e9e3df9..253421c0a 100644 --- a/src/main/java/mekanism/client/gui/GuiTeleporter.java +++ b/src/main/java/mekanism/client/gui/GuiTeleporter.java @@ -3,6 +3,8 @@ package mekanism.client.gui; import java.util.ArrayList; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.client.gui.element.GuiPowerBar; @@ -34,559 +36,549 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; - import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiTeleporter extends GuiMekanism -{ - public ResourceLocation resource; - - public TileEntityTeleporter tileEntity; - public ItemStack itemStack; - - public EntityPlayer entityPlayer; - - public GuiButton publicButton; - public GuiButton privateButton; - public GuiButton protectedButton; +public class GuiTeleporter extends GuiMekanism { + public ResourceLocation resource; - public GuiButton setButton; - public GuiButton deleteButton; - - public GuiButton teleportButton; - - public GuiScrollList scrollList; - - public GuiTextField frequencyField; - - public ISecurityTile.SecurityMode access = ISecurityTile.SecurityMode.PUBLIC; - - public Frequency clientFreq; - public byte clientStatus; - - public List clientPublicCache = new ArrayList(); - public List clientPrivateCache = new ArrayList(); - public List clientProtectedCache = new ArrayList(); + public TileEntityTeleporter tileEntity; + public ItemStack itemStack; - public boolean isInit = true; + public EntityPlayer entityPlayer; - public GuiTeleporter(InventoryPlayer inventory, TileEntityTeleporter tentity) - { - super(tentity, new ContainerTeleporter(inventory, tentity)); - tileEntity = tentity; - resource = MekanismUtils.getResource(ResourceType.GUI, "GuiTeleporter.png"); + public GuiButton publicButton; + public GuiButton privateButton; + public GuiButton protectedButton; - guiElements.add(new GuiRedstoneControl(this, tileEntity, resource)); - guiElements.add(new GuiPowerBar(this, new IPowerInfoHandler() { - @Override - public String getTooltip() - { - return MekanismUtils.getEnergyDisplay(getEnergy()); - } - - @Override - public double getLevel() - { - return getEnergy()/getMaxEnergy(); - } - }, resource, 158, 26)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, resource, 152, 6).with(SlotOverlay.POWER)); - guiElements.add(scrollList = new GuiScrollList(this, resource, 28, 37, 120, 4)); - - if(tileEntity.frequency != null) - { - access = tileEntity.frequency.access; - } - - ySize+=64; - } - - public GuiTeleporter(EntityPlayer player, ItemStack stack) - { - super(new ContainerNull()); - itemStack = stack; - entityPlayer = player; - resource = MekanismUtils.getResource(ResourceType.GUI, "GuiPortableTeleporter.png"); - - guiElements.add(new GuiPowerBar(this, new IPowerInfoHandler() { - @Override - public String getTooltip() - { - return MekanismUtils.getEnergyDisplay(getEnergy()); - } - - @Override - public double getLevel() - { - return getEnergy()/getMaxEnergy(); - } - }, resource, 158, 26)); - guiElements.add(scrollList = new GuiScrollList(this, resource, 28, 37, 120, 4)); - - ItemPortableTeleporter item = (ItemPortableTeleporter)itemStack.getItem(); - - if(item.getFrequency(stack) != null) - { - access = item.getAccess(itemStack); - setFrequency(item.getFrequency(stack)); - } - else { - Mekanism.packetHandler.sendToServer(new PortableTeleporterMessage(PortableTeleporterPacketType.DATA_REQUEST, clientFreq)); - } + public GuiButton setButton; + public GuiButton deleteButton; - ySize = 175; - } - - @Override - public void initGui() - { - super.initGui(); + public GuiButton teleportButton; - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; + public GuiScrollList scrollList; - buttonList.clear(); - - publicButton = new GuiButton(0, guiWidth + 27, guiHeight + 14, 40, 20, LangUtils.localize("gui.public")); - privateButton = new GuiButton(1, guiWidth + 69, guiHeight + 14, 40, 20, LangUtils.localize("gui.private")); - protectedButton = new GuiButton(5, guiWidth + 111, guiHeight + 14, 40, 20, LangUtils.localize("gui.trusted")); + public GuiTextField frequencyField; - setButton = new GuiButton(2, guiWidth + 27, guiHeight + 116, 60, 20, LangUtils.localize("gui.set")); - deleteButton = new GuiButton(3, guiWidth + 89, guiHeight + 116, 60, 20, LangUtils.localize("gui.delete")); - - if(itemStack != null) - { - teleportButton = new GuiButton(4, guiWidth + 42, guiHeight + 140, 92, 20, LangUtils.localize("gui.teleport")); - } - - frequencyField = new GuiTextField(fontRendererObj, guiWidth + 50, guiHeight + 104, 86, 11); - frequencyField.setMaxStringLength(FrequencyManager.MAX_FREQ_LENGTH); - frequencyField.setEnableBackgroundDrawing(false); - - updateButtons(); + public ISecurityTile.SecurityMode access = ISecurityTile.SecurityMode.PUBLIC; - buttonList.add(publicButton); - buttonList.add(privateButton); - buttonList.add(protectedButton); - buttonList.add(setButton); - buttonList.add(deleteButton); - - if(itemStack != null) - { - buttonList.add(teleportButton); + public Frequency clientFreq; + public byte clientStatus; - if(!isInit) - { - Mekanism.packetHandler.sendToServer(new PortableTeleporterMessage(PortableTeleporterPacketType.DATA_REQUEST, clientFreq)); - } - else { - isInit = false; - } - } - } - - public void setFrequency(String freq) - { - if(freq.isEmpty()) - { - return; - } - - if(tileEntity != null) - { - ArrayList data = new ArrayList(); - data.add(0); - data.add(freq); - data.add(access.ordinal()); - - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - } - else { - Frequency newFreq = new Frequency(freq, null).setAccess(access); - - Mekanism.packetHandler.sendToServer(new PortableTeleporterMessage(PortableTeleporterPacketType.SET_FREQ, newFreq)); - } - } - - public String getSecurity(Frequency freq) - { + public List clientPublicCache = new ArrayList(); + public List clientPrivateCache = new ArrayList(); + public List clientProtectedCache = new ArrayList(); - if(freq.isPrivate()) { - return EnumColor.DARK_RED + LangUtils.localize("gui.private"); - } else if(freq.isPublic()) { - return LangUtils.localize("gui.public"); - } + public boolean isInit = true; - return EnumColor.ORANGE + LangUtils.localize("gui.trusted"); - } - - public void updateButtons() - { - if(getOwner() == null) - { - return; - } - - List text = new ArrayList(); + public GuiTeleporter(InventoryPlayer inventory, TileEntityTeleporter tentity) { + super(tentity, new ContainerTeleporter(inventory, tentity)); + tileEntity = tentity; + resource = MekanismUtils.getResource(ResourceType.GUI, "GuiTeleporter.png"); - if(access == ISecurityTile.SecurityMode.PRIVATE) { - for(Frequency freq : getPrivateCache()) - { - text.add(freq.name); - } + guiElements.add(new GuiRedstoneControl(this, tileEntity, resource)); + guiElements.add(new GuiPowerBar(this, new IPowerInfoHandler() { + @Override + public String getTooltip() { + return MekanismUtils.getEnergyDisplay(getEnergy()); + } - publicButton.enabled = true; - privateButton.enabled = false; - protectedButton.enabled = true; - } else if(access == ISecurityTile.SecurityMode.PUBLIC) { - for(Frequency freq : getPublicCache()) - { - text.add(freq.name + " (" + freq.owner + ")"); - } + @Override + public double getLevel() { + return getEnergy() / getMaxEnergy(); + } + }, resource, 158, 26)); + guiElements.add( + new GuiSlot(SlotType.NORMAL, this, resource, 152, 6).with(SlotOverlay.POWER) + ); + guiElements.add(scrollList = new GuiScrollList(this, resource, 28, 37, 120, 4)); - publicButton.enabled = false; - privateButton.enabled = true; - protectedButton.enabled = true; - } else { - for(Frequency freq : getProtectedCache()) - { - text.add(freq.name + " (" + freq.owner + ")"); - } + if (tileEntity.frequency != null) { + access = tileEntity.frequency.access; + } - publicButton.enabled = true; - privateButton.enabled = true; - protectedButton.enabled = false; - } + ySize += 64; + } - scrollList.setText(text); + public GuiTeleporter(EntityPlayer player, ItemStack stack) { + super(new ContainerNull()); + itemStack = stack; + entityPlayer = player; + resource + = MekanismUtils.getResource(ResourceType.GUI, "GuiPortableTeleporter.png"); - - if(scrollList.hasSelection()) - { + guiElements.add(new GuiPowerBar(this, new IPowerInfoHandler() { + @Override + public String getTooltip() { + return MekanismUtils.getEnergyDisplay(getEnergy()); + } - Frequency freq; + @Override + public double getLevel() { + return getEnergy() / getMaxEnergy(); + } + }, resource, 158, 26)); + guiElements.add(scrollList = new GuiScrollList(this, resource, 28, 37, 120, 4)); - if(access == ISecurityTile.SecurityMode.PRIVATE) { - freq = getPrivateCache().get(scrollList.selected); - } else if(access == ISecurityTile.SecurityMode.PUBLIC) { - freq = getPublicCache().get(scrollList.selected); - } else { - freq = getProtectedCache().get(scrollList.selected); - } + ItemPortableTeleporter item = (ItemPortableTeleporter) itemStack.getItem(); - if(getFrequency() == null || !getFrequency().equals(freq)) - { - setButton.enabled = true; - } - else { - setButton.enabled = false; - } - - if(getOwner().equals(freq.owner)) - { - deleteButton.enabled = true; - } - else { - deleteButton.enabled = false; - } - } - else { - setButton.enabled = false; - deleteButton.enabled = false; - } - - if(itemStack != null) - { - if(clientFreq != null && clientStatus == 1) - { - teleportButton.enabled = true; - } - else { - teleportButton.enabled = false; - } - } - } - - @Override - public void updateScreen() - { - super.updateScreen(); - - updateButtons(); - - frequencyField.updateCursorCounter(); - } - - @Override - public void mouseClicked(int mouseX, int mouseY, int button) - { - super.mouseClicked(mouseX, mouseY, button); - - updateButtons(); + if (item.getFrequency(stack) != null) { + access = item.getAccess(itemStack); + setFrequency(item.getFrequency(stack)); + } else { + Mekanism.packetHandler.sendToServer(new PortableTeleporterMessage( + PortableTeleporterPacketType.DATA_REQUEST, clientFreq + )); + } - frequencyField.mouseClicked(mouseX, mouseY, button); - - if(button == 0) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); - - if(xAxis >= 137 && xAxis <= 148 && yAxis >= 103 && yAxis <= 114) - { - setFrequency(frequencyField.getText()); - frequencyField.setText(""); - SoundHandler.playSound("gui.button.press"); - } - } - } - - @Override - public void keyTyped(char c, int i) - { - if(!frequencyField.isFocused() || i == Keyboard.KEY_ESCAPE) - { - super.keyTyped(c, i); - } - - if(i == Keyboard.KEY_RETURN) - { - if(frequencyField.isFocused()) - { - setFrequency(frequencyField.getText()); - frequencyField.setText(""); - } - } + ySize = 175; + } - if(Character.isDigit(c) || Character.isLetter(c) || isTextboxKey(c, i) || FrequencyManager.SPECIAL_CHARS.contains(c)) - { - frequencyField.textboxKeyTyped(c, i); - } - - updateButtons(); - } - - @Override - protected void actionPerformed(GuiButton guibutton) - { - super.actionPerformed(guibutton); + @Override + public void initGui() { + super.initGui(); - if(guibutton.id == 0) - { - access = ISecurityTile.SecurityMode.PUBLIC; - } - else if(guibutton.id == 1) - { - access = ISecurityTile.SecurityMode.PRIVATE; - } - else if(guibutton.id == 2) - { - int selection = scrollList.getSelection(); - - if(selection != -1) - { - Frequency freq; + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; - if(access == ISecurityTile.SecurityMode.PRIVATE) { - freq = getPrivateCache().get(scrollList.selected); - } else if(access == ISecurityTile.SecurityMode.PUBLIC) { - freq = getPublicCache().get(scrollList.selected); - } else { - freq = getProtectedCache().get(scrollList.selected); - } + buttonList.clear(); - setFrequency(freq.name); - } - } - else if(guibutton.id == 3) - { - int selection = scrollList.getSelection(); - - if(selection != -1) - { + publicButton = new GuiButton( + 0, guiWidth + 27, guiHeight + 14, 40, 20, LangUtils.localize("gui.public") + ); + privateButton = new GuiButton( + 1, guiWidth + 69, guiHeight + 14, 40, 20, LangUtils.localize("gui.private") + ); + protectedButton = new GuiButton( + 5, guiWidth + 111, guiHeight + 14, 40, 20, LangUtils.localize("gui.trusted") + ); - Frequency freq; + setButton = new GuiButton( + 2, guiWidth + 27, guiHeight + 116, 60, 20, LangUtils.localize("gui.set") + ); + deleteButton = new GuiButton( + 3, guiWidth + 89, guiHeight + 116, 60, 20, LangUtils.localize("gui.delete") + ); - if(access == ISecurityTile.SecurityMode.PRIVATE) { - freq = getPrivateCache().get(scrollList.selected); - } else if(access == ISecurityTile.SecurityMode.PUBLIC) { - freq = getPublicCache().get(scrollList.selected); - } else { - freq = getProtectedCache().get(scrollList.selected); - } + if (itemStack != null) { + teleportButton = new GuiButton( + 4, + guiWidth + 42, + guiHeight + 140, + 92, + 20, + LangUtils.localize("gui.teleport") + ); + } - if(tileEntity != null) - { - ArrayList data = new ArrayList(); - data.add(1); - data.add(freq.name); - data.add(freq.access.ordinal()); - - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - } - else { - Mekanism.packetHandler.sendToServer(new PortableTeleporterMessage(PortableTeleporterPacketType.DEL_FREQ, freq)); - Mekanism.packetHandler.sendToServer(new PortableTeleporterMessage(PortableTeleporterPacketType.DATA_REQUEST, null)); - } - - scrollList.selected = -1; - } - } - else if(guibutton.id == 4) - { - if(clientFreq != null && clientStatus == 1) - { - mc.setIngameFocus(); - Mekanism.packetHandler.sendToServer(new PortableTeleporterMessage(PortableTeleporterPacketType.TELEPORT, clientFreq)); - } - } else if(guibutton.id == 5) { - access = ISecurityTile.SecurityMode.TRUSTED; - } - - updateButtons(); - } + frequencyField + = new GuiTextField(fontRendererObj, guiWidth + 50, guiHeight + 104, 86, 11); + frequencyField.setMaxStringLength(FrequencyManager.MAX_FREQ_LENGTH); + frequencyField.setEnableBackgroundDrawing(false); - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX-(width-xSize)/2); - int yAxis = (mouseY-(height-ySize)/2); + updateButtons(); - fontRendererObj.drawString(getInventoryName(), (xSize/2)-(fontRendererObj.getStringWidth(getInventoryName())/2), 4, 0x404040); - fontRendererObj.drawString(LangUtils.localize("gui.owner") + ": " + (getOwner() != null ? getOwner() : LangUtils.localize("gui.none")), 8, itemStack != null ? ySize-12 : (ySize-96)+4, 0x404040); - - fontRendererObj.drawString(LangUtils.localize("gui.freq") + ":", 32, 81, 0x404040); - fontRendererObj.drawString(LangUtils.localize("gui.security") + ":", 32, 91, 0x404040); - - fontRendererObj.drawString(" " + (getFrequency() != null ? getFrequency().name : EnumColor.DARK_RED + LangUtils.localize("gui.none")), 32 + fontRendererObj.getStringWidth(LangUtils.localize("gui.freq") + ":"), 81, 0x797979); - fontRendererObj.drawString(" " + (getFrequency() != null ? getSecurity(getFrequency()) : EnumColor.DARK_RED + LangUtils.localize("gui.none")), 32 + fontRendererObj.getStringWidth(LangUtils.localize("gui.security") + ":"), 91, 0x797979); - - String str = LangUtils.localize("gui.set") + ":"; - renderScaledText(str, 27, 104, 0x404040, 20); - - if(xAxis >= 6 && xAxis <= 24 && yAxis >= 6 && yAxis <= 24) - { - if(getFrequency() == null) - { - drawCreativeTabHoveringText(EnumColor.DARK_RED + LangUtils.localize("gui.teleporter.noFreq"), xAxis, yAxis); - } - else { - drawCreativeTabHoveringText(getStatusDisplay(), xAxis, yAxis); - } - } + buttonList.add(publicButton); + buttonList.add(privateButton); + buttonList.add(protectedButton); + buttonList.add(setButton); + buttonList.add(deleteButton); - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + if (itemStack != null) { + buttonList.add(teleportButton); - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(resource); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width-xSize)/2; - int guiHeight = (height-ySize)/2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); - - if(xAxis >= 137 && xAxis <= 148 && yAxis >= 103 && yAxis <= 114) - { - drawTexturedModalRect(guiWidth + 137, guiHeight + 103, xSize, 0, 11, 11); - } - else { - drawTexturedModalRect(guiWidth + 137, guiHeight + 103, xSize, 11, 11, 11); - } - - int y = getFrequency() == null ? 94 : (getStatus() == 2 ? 22 : (getStatus() == 3 ? 40 : - (getStatus() == 4 ? 58 : 76))); - - drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176, y, 18, 18); + if (!isInit) { + Mekanism.packetHandler.sendToServer(new PortableTeleporterMessage( + PortableTeleporterPacketType.DATA_REQUEST, clientFreq + )); + } else { + isInit = false; + } + } + } - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - - frequencyField.drawTextBox(); - } - - public String getStatusDisplay() - { - switch(getStatus()) - { - case 1: - return EnumColor.DARK_GREEN + LangUtils.localize("gui.teleporter.ready"); - case 2: - return EnumColor.DARK_RED + LangUtils.localize("gui.teleporter.noFrame"); - case 3: - return EnumColor.DARK_RED + LangUtils.localize("gui.teleporter.noLink"); - case 4: - return EnumColor.DARK_RED + LangUtils.localize("gui.teleporter.needsEnergy"); - } - - return EnumColor.DARK_RED + LangUtils.localize("gui.teleporter.noLink"); - } - - private String getOwner() - { - if(tileEntity != null) - { - return tileEntity.getSecurity().getOwner(); - } - else { - return ((IOwnerItem)itemStack.getItem()).getOwner(itemStack); - } - } - - private byte getStatus() - { - return tileEntity != null ? tileEntity.status : clientStatus; - } - - private List getPublicCache() - { - return tileEntity != null ? tileEntity.publicCache : clientPublicCache; - } - - private List getPrivateCache() - { - return tileEntity != null ? tileEntity.privateCache : clientPrivateCache; - } + public void setFrequency(String freq) { + if (freq.isEmpty()) { + return; + } - private List getProtectedCache() - { - return tileEntity != null ? tileEntity.protectedCache : clientProtectedCache; - } + if (tileEntity != null) { + ArrayList data = new ArrayList(); + data.add(0); + data.add(freq); + data.add(access.ordinal()); - private Frequency getFrequency() - { - return tileEntity != null ? tileEntity.frequency : clientFreq; - } - - private String getInventoryName() - { - return tileEntity != null ? tileEntity.getInventoryName() : itemStack.getDisplayName(); - } - - private double getEnergy() - { - if(itemStack != null) - { - return ((ItemPortableTeleporter)itemStack.getItem()).getEnergy(itemStack); - } - - return tileEntity.getEnergy(); - } - - private double getMaxEnergy() - { - if(itemStack != null) - { - return ((ItemPortableTeleporter)itemStack.getItem()).getMaxEnergy(itemStack); - } - - return tileEntity.getMaxEnergy(); - } + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); + } else { + Frequency newFreq = new Frequency(freq, null).setAccess(access); + + Mekanism.packetHandler.sendToServer(new PortableTeleporterMessage( + PortableTeleporterPacketType.SET_FREQ, newFreq + )); + } + } + + public String getSecurity(Frequency freq) { + if (freq.isPrivate()) { + return EnumColor.DARK_RED + LangUtils.localize("gui.private"); + } else if (freq.isPublic()) { + return LangUtils.localize("gui.public"); + } + + return EnumColor.ORANGE + LangUtils.localize("gui.trusted"); + } + + public void updateButtons() { + if (getOwner() == null) { + return; + } + + List text = new ArrayList(); + + if (access == ISecurityTile.SecurityMode.PRIVATE) { + for (Frequency freq : getPrivateCache()) { + text.add(freq.name); + } + + publicButton.enabled = true; + privateButton.enabled = false; + protectedButton.enabled = true; + } else if (access == ISecurityTile.SecurityMode.PUBLIC) { + for (Frequency freq : getPublicCache()) { + text.add(freq.name + " (" + freq.owner + ")"); + } + + publicButton.enabled = false; + privateButton.enabled = true; + protectedButton.enabled = true; + } else { + for (Frequency freq : getProtectedCache()) { + text.add(freq.name + " (" + freq.owner + ")"); + } + + publicButton.enabled = true; + privateButton.enabled = true; + protectedButton.enabled = false; + } + + scrollList.setText(text); + + if (scrollList.hasSelection()) { + Frequency freq; + + if (access == ISecurityTile.SecurityMode.PRIVATE) { + freq = getPrivateCache().get(scrollList.selected); + } else if (access == ISecurityTile.SecurityMode.PUBLIC) { + freq = getPublicCache().get(scrollList.selected); + } else { + freq = getProtectedCache().get(scrollList.selected); + } + + if (getFrequency() == null || !getFrequency().equals(freq)) { + setButton.enabled = true; + } else { + setButton.enabled = false; + } + + if (getOwner().equals(freq.owner)) { + deleteButton.enabled = true; + } else { + deleteButton.enabled = false; + } + } else { + setButton.enabled = false; + deleteButton.enabled = false; + } + + if (itemStack != null) { + if (clientFreq != null && clientStatus == 1) { + teleportButton.enabled = true; + } else { + teleportButton.enabled = false; + } + } + } + + @Override + public void updateScreen() { + super.updateScreen(); + + updateButtons(); + + frequencyField.updateCursorCounter(); + } + + @Override + public void mouseClicked(int mouseX, int mouseY, int button) { + super.mouseClicked(mouseX, mouseY, button); + + updateButtons(); + + frequencyField.mouseClicked(mouseX, mouseY, button); + + if (button == 0) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + if (xAxis >= 137 && xAxis <= 148 && yAxis >= 103 && yAxis <= 114) { + setFrequency(frequencyField.getText()); + frequencyField.setText(""); + SoundHandler.playSound("gui.button.press"); + } + } + } + + @Override + public void keyTyped(char c, int i) { + if (!frequencyField.isFocused() || i == Keyboard.KEY_ESCAPE) { + super.keyTyped(c, i); + } + + if (i == Keyboard.KEY_RETURN) { + if (frequencyField.isFocused()) { + setFrequency(frequencyField.getText()); + frequencyField.setText(""); + } + } + + if (Character.isDigit(c) || Character.isLetter(c) || isTextboxKey(c, i) + || FrequencyManager.SPECIAL_CHARS.contains(c)) { + frequencyField.textboxKeyTyped(c, i); + } + + updateButtons(); + } + + @Override + protected void actionPerformed(GuiButton guibutton) { + super.actionPerformed(guibutton); + + if (guibutton.id == 0) { + access = ISecurityTile.SecurityMode.PUBLIC; + } else if (guibutton.id == 1) { + access = ISecurityTile.SecurityMode.PRIVATE; + } else if (guibutton.id == 2) { + int selection = scrollList.getSelection(); + + if (selection != -1) { + Frequency freq; + + if (access == ISecurityTile.SecurityMode.PRIVATE) { + freq = getPrivateCache().get(scrollList.selected); + } else if (access == ISecurityTile.SecurityMode.PUBLIC) { + freq = getPublicCache().get(scrollList.selected); + } else { + freq = getProtectedCache().get(scrollList.selected); + } + + setFrequency(freq.name); + } + } else if (guibutton.id == 3) { + int selection = scrollList.getSelection(); + + if (selection != -1) { + Frequency freq; + + if (access == ISecurityTile.SecurityMode.PRIVATE) { + freq = getPrivateCache().get(scrollList.selected); + } else if (access == ISecurityTile.SecurityMode.PUBLIC) { + freq = getPublicCache().get(scrollList.selected); + } else { + freq = getProtectedCache().get(scrollList.selected); + } + + if (tileEntity != null) { + ArrayList data = new ArrayList(); + data.add(1); + data.add(freq.name); + data.add(freq.access.ordinal()); + + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); + } else { + Mekanism.packetHandler.sendToServer(new PortableTeleporterMessage( + PortableTeleporterPacketType.DEL_FREQ, freq + )); + Mekanism.packetHandler.sendToServer(new PortableTeleporterMessage( + PortableTeleporterPacketType.DATA_REQUEST, null + )); + } + + scrollList.selected = -1; + } + } else if (guibutton.id == 4) { + if (clientFreq != null && clientStatus == 1) { + mc.setIngameFocus(); + Mekanism.packetHandler.sendToServer(new PortableTeleporterMessage( + PortableTeleporterPacketType.TELEPORT, clientFreq + )); + } + } else if (guibutton.id == 5) { + access = ISecurityTile.SecurityMode.TRUSTED; + } + + updateButtons(); + } + + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + fontRendererObj.drawString( + getInventoryName(), + (xSize / 2) - (fontRendererObj.getStringWidth(getInventoryName()) / 2), + 4, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.owner") + ": " + + (getOwner() != null ? getOwner() : LangUtils.localize("gui.none")), + 8, + itemStack != null ? ySize - 12 : (ySize - 96) + 4, + 0x404040 + ); + + fontRendererObj.drawString( + LangUtils.localize("gui.freq") + ":", 32, 81, 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.security") + ":", 32, 91, 0x404040 + ); + + fontRendererObj.drawString( + " " + + (getFrequency() != null + ? getFrequency().name + : EnumColor.DARK_RED + LangUtils.localize("gui.none")), + 32 + fontRendererObj.getStringWidth(LangUtils.localize("gui.freq") + ":"), + 81, + 0x797979 + ); + fontRendererObj.drawString( + " " + + (getFrequency() != null + ? getSecurity(getFrequency()) + : EnumColor.DARK_RED + LangUtils.localize("gui.none")), + 32 + fontRendererObj.getStringWidth(LangUtils.localize("gui.security") + ":"), + 91, + 0x797979 + ); + + String str = LangUtils.localize("gui.set") + ":"; + renderScaledText(str, 27, 104, 0x404040, 20); + + if (xAxis >= 6 && xAxis <= 24 && yAxis >= 6 && yAxis <= 24) { + if (getFrequency() == null) { + drawCreativeTabHoveringText( + EnumColor.DARK_RED + LangUtils.localize("gui.teleporter.noFreq"), + xAxis, + yAxis + ); + } else { + drawCreativeTabHoveringText(getStatusDisplay(), xAxis, yAxis); + } + } + + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture(resource); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + if (xAxis >= 137 && xAxis <= 148 && yAxis >= 103 && yAxis <= 114) { + drawTexturedModalRect(guiWidth + 137, guiHeight + 103, xSize, 0, 11, 11); + } else { + drawTexturedModalRect(guiWidth + 137, guiHeight + 103, xSize, 11, 11, 11); + } + + int y = getFrequency() == null + ? 94 + : (getStatus() == 2 ? 22 + : (getStatus() == 3 ? 40 : (getStatus() == 4 ? 58 : 76))); + + drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176, y, 18, 18); + + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + + frequencyField.drawTextBox(); + } + + public String getStatusDisplay() { + switch (getStatus()) { + case 1: + return EnumColor.DARK_GREEN + LangUtils.localize("gui.teleporter.ready"); + case 2: + return EnumColor.DARK_RED + LangUtils.localize("gui.teleporter.noFrame"); + case 3: + return EnumColor.DARK_RED + LangUtils.localize("gui.teleporter.noLink"); + case 4: + return EnumColor.DARK_RED + + LangUtils.localize("gui.teleporter.needsEnergy"); + } + + return EnumColor.DARK_RED + LangUtils.localize("gui.teleporter.noLink"); + } + + private String getOwner() { + if (tileEntity != null) { + return tileEntity.getSecurity().getOwner(); + } else { + return ((IOwnerItem) itemStack.getItem()).getOwner(itemStack); + } + } + + private byte getStatus() { + return tileEntity != null ? tileEntity.status : clientStatus; + } + + private List getPublicCache() { + return tileEntity != null ? tileEntity.publicCache : clientPublicCache; + } + + private List getPrivateCache() { + return tileEntity != null ? tileEntity.privateCache : clientPrivateCache; + } + + private List getProtectedCache() { + return tileEntity != null ? tileEntity.protectedCache : clientProtectedCache; + } + + private Frequency getFrequency() { + return tileEntity != null ? tileEntity.frequency : clientFreq; + } + + private String getInventoryName() { + return tileEntity != null ? tileEntity.getInventoryName() + : itemStack.getDisplayName(); + } + + private double getEnergy() { + if (itemStack != null) { + return ((ItemPortableTeleporter) itemStack.getItem()).getEnergy(itemStack); + } + + return tileEntity.getEnergy(); + } + + private double getMaxEnergy() { + if (itemStack != null) { + return ((ItemPortableTeleporter) itemStack.getItem()).getMaxEnergy(itemStack); + } + + return tileEntity.getMaxEnergy(); + } } diff --git a/src/main/java/mekanism/client/gui/GuiTheoreticalElementizer.java b/src/main/java/mekanism/client/gui/GuiTheoreticalElementizer.java index 902ff064e..35a6842ac 100644 --- a/src/main/java/mekanism/client/gui/GuiTheoreticalElementizer.java +++ b/src/main/java/mekanism/client/gui/GuiTheoreticalElementizer.java @@ -9,37 +9,42 @@ import mekanism.common.tile.TileEntityTheoreticalElementizer; import net.minecraft.entity.player.InventoryPlayer; @SideOnly(Side.CLIENT) -public class GuiTheoreticalElementizer extends GuiAdvancedElectricMachine //TODO implement specific GUI +public class GuiTheoreticalElementizer + extends GuiAdvancedElectricMachine //TODO implement specific GUI { - public GuiTheoreticalElementizer(final InventoryPlayer inventory, final TileEntityTheoreticalElementizer tentity) { + public GuiTheoreticalElementizer( + final InventoryPlayer inventory, final TileEntityTheoreticalElementizer tentity + ) { super(inventory, tentity); } - + @Override protected void drawGuiContainerForegroundLayer(final int par1, final int par2) { super.drawGuiContainerForegroundLayer(par1, par2); String displayText = ""; if (super.tileEntity.isActive) { - displayText = "Status: " + (int)(super.tileEntity.operatingTicks / (float)super.tileEntity.ticksRequired * 100.0f) + "%"; - } - else { + displayText = "Status: " + + (int) (super.tileEntity.operatingTicks + / (float) super.tileEntity.ticksRequired * 100.0f) + + "%"; + } else { displayText = "Status: " + EnumColor.DARK_RED + "Off"; } this.fontRendererObj.drawString(displayText, 80, 60, 4210752); } @Override - public void displayGauge(int xPos, int yPos, int sizeX, int sizeY, GasStack gas) - { - if(gas == null) - { - return; - } + public void displayGauge(int xPos, int yPos, int sizeX, int sizeY, GasStack gas) { + if (gas == null) { + return; + } - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; - mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture()); - drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos, gas.getGas().getIcon(), sizeX, sizeY); - } + mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture()); + drawTexturedModelRectFromIcon( + guiWidth + xPos, guiHeight + yPos, gas.getGas().getIcon(), sizeX, sizeY + ); + } } diff --git a/src/main/java/mekanism/client/gui/GuiThermalEvaporationController.java b/src/main/java/mekanism/client/gui/GuiThermalEvaporationController.java index b86467675..6213d8458 100644 --- a/src/main/java/mekanism/client/gui/GuiThermalEvaporationController.java +++ b/src/main/java/mekanism/client/gui/GuiThermalEvaporationController.java @@ -2,6 +2,8 @@ package mekanism.client.gui; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.MekanismConfig.general; import mekanism.api.util.ListUtils; import mekanism.api.util.UnitDisplayUtils; @@ -18,115 +20,162 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.entity.player.InventoryPlayer; import net.minecraftforge.fluids.FluidTank; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiThermalEvaporationController extends GuiMekanism -{ - public TileEntityThermalEvaporationController tileEntity; +public class GuiThermalEvaporationController extends GuiMekanism { + public TileEntityThermalEvaporationController tileEntity; - public GuiThermalEvaporationController(InventoryPlayer inventory, TileEntityThermalEvaporationController tentity) - { - super(tentity, new ContainerThermalEvaporationController(inventory, tentity)); - tileEntity = tentity; - - guiElements.add(new GuiFluidGauge(new IFluidInfoHandler() { - @Override - public FluidTank getTank() - { - return tileEntity.inputTank; - } - }, GuiGauge.Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiThermalEvaporationController.png"), 6, 13)); - guiElements.add(new GuiFluidGauge(new IFluidInfoHandler() { - @Override - public FluidTank getTank() - { - return tileEntity.outputTank; - } - }, GuiGauge.Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiThermalEvaporationController.png"), 152, 13)); - guiElements.add(new GuiHeatInfo(new IInfoHandler() { - @Override - public List getInfo() - { - TemperatureUnit unit = TemperatureUnit.values()[general.tempUnit.ordinal()]; - String environment = UnitDisplayUtils.getDisplayShort(tileEntity.totalLoss*unit.intervalSize, false, unit); - return ListUtils.asList(LangUtils.localize("gui.dissipated") + ": " + environment + "/t"); - } - }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiThermalEvaporationController.png"))); - } + public GuiThermalEvaporationController( + InventoryPlayer inventory, TileEntityThermalEvaporationController tentity + ) { + super(tentity, new ContainerThermalEvaporationController(inventory, tentity)); + tileEntity = tentity; - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + guiElements.add(new GuiFluidGauge( + new IFluidInfoHandler() { + @Override + public FluidTank getTank() { + return tileEntity.inputTank; + } + }, + GuiGauge.Type.STANDARD, + this, + MekanismUtils.getResource( + ResourceType.GUI, "GuiThermalEvaporationController.png" + ), + 6, + 13 + )); + guiElements.add(new GuiFluidGauge( + new IFluidInfoHandler() { + @Override + public FluidTank getTank() { + return tileEntity.outputTank; + } + }, + GuiGauge.Type.STANDARD, + this, + MekanismUtils.getResource( + ResourceType.GUI, "GuiThermalEvaporationController.png" + ), + 152, + 13 + )); + guiElements.add(new GuiHeatInfo( + new IInfoHandler() { + @Override + public List getInfo() { + TemperatureUnit unit + = TemperatureUnit.values()[general.tempUnit.ordinal()]; + String environment = UnitDisplayUtils.getDisplayShort( + tileEntity.totalLoss * unit.intervalSize, false, unit + ); + return ListUtils.asList( + LangUtils.localize("gui.dissipated") + ": " + environment + "/t" + ); + } + }, + this, + MekanismUtils.getResource( + ResourceType.GUI, "GuiThermalEvaporationController.png" + ) + )); + } - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 4, 0x404040); - fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize/2)-(fontRendererObj.getStringWidth(tileEntity.getInventoryName())/2), 4, 0x404040); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - fontRendererObj.drawString(getStruct(), 50, 21, 0x00CD00); - fontRendererObj.drawString(LangUtils.localize("gui.height") + ": " + tileEntity.height, 50, 30, 0x00CD00); - fontRendererObj.drawString(LangUtils.localize("gui.temp") + ": " + getTemp(), 50, 39, 0x00CD00); - renderScaledText(LangUtils.localize("gui.production") + ": " + Math.round(tileEntity.lastGain*100D)/100D + " mB/t", 50, 48, 0x00CD00, 76); + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, (ySize - 96) + 4, 0x404040 + ); + fontRendererObj.drawString( + tileEntity.getInventoryName(), + (xSize / 2) + - (fontRendererObj.getStringWidth(tileEntity.getInventoryName()) / 2), + 4, + 0x404040 + ); - if(xAxis >= 7 && xAxis <= 23 && yAxis >= 14 && yAxis <= 72) - { - drawCreativeTabHoveringText(tileEntity.inputTank.getFluid() != null ? LangUtils.localizeFluidStack(tileEntity.inputTank.getFluid()) + ": " + tileEntity.inputTank.getFluidAmount() : LangUtils.localize("gui.empty"), xAxis, yAxis); - } + fontRendererObj.drawString(getStruct(), 50, 21, 0x00CD00); + fontRendererObj.drawString( + LangUtils.localize("gui.height") + ": " + tileEntity.height, 50, 30, 0x00CD00 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.temp") + ": " + getTemp(), 50, 39, 0x00CD00 + ); + renderScaledText( + LangUtils.localize("gui.production") + ": " + + Math.round(tileEntity.lastGain * 100D) / 100D + " mB/t", + 50, + 48, + 0x00CD00, + 76 + ); - if(xAxis >= 153 && xAxis <= 169 && yAxis >= 14 && yAxis <= 72) - { - drawCreativeTabHoveringText(tileEntity.outputTank.getFluid() != null ? LangUtils.localizeFluidStack(tileEntity.outputTank.getFluid()) + ": " + tileEntity.outputTank.getFluidAmount() : LangUtils.localize("gui.empty"), xAxis, yAxis); - } + if (xAxis >= 7 && xAxis <= 23 && yAxis >= 14 && yAxis <= 72) { + drawCreativeTabHoveringText( + tileEntity.inputTank.getFluid() != null + ? LangUtils.localizeFluidStack(tileEntity.inputTank.getFluid()) + ": " + + tileEntity.inputTank.getFluidAmount() + : LangUtils.localize("gui.empty"), + xAxis, + yAxis + ); + } - if(xAxis >= 49 && xAxis <= 127 && yAxis >= 64 && yAxis <= 72) - { - drawCreativeTabHoveringText(getTemp(), xAxis, yAxis); - } + if (xAxis >= 153 && xAxis <= 169 && yAxis >= 14 && yAxis <= 72) { + drawCreativeTabHoveringText( + tileEntity.outputTank.getFluid() != null + ? LangUtils.localizeFluidStack(tileEntity.outputTank.getFluid()) + + ": " + tileEntity.outputTank.getFluidAmount() + : LangUtils.localize("gui.empty"), + xAxis, + yAxis + ); + } - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + if (xAxis >= 49 && xAxis <= 127 && yAxis >= 64 && yAxis <= 72) { + drawCreativeTabHoveringText(getTemp(), xAxis, yAxis); + } - private String getStruct() - { - if(tileEntity.structured) - { - return LangUtils.localize("gui.formed"); - } - else { - if(tileEntity.controllerConflict) - { - return LangUtils.localize("gui.conflict"); - } - else { - return LangUtils.localize("gui.incomplete"); - } - } - } + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - private String getTemp() - { - float temp = tileEntity.getTemperature(); + private String getStruct() { + if (tileEntity.structured) { + return LangUtils.localize("gui.formed"); + } else { + if (tileEntity.controllerConflict) { + return LangUtils.localize("gui.conflict"); + } else { + return LangUtils.localize("gui.incomplete"); + } + } + } - return MekanismUtils.getTemperatureDisplay(temp, TemperatureUnit.AMBIENT); - } + private String getTemp() { + float temp = tileEntity.getTemperature(); - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiThermalEvaporationController.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + return MekanismUtils.getTemperatureDisplay(temp, TemperatureUnit.AMBIENT); + } - int displayInt = tileEntity.getScaledTempLevel(78); - drawTexturedModalRect(guiWidth + 49, guiHeight + 64, 176, 59, displayInt, 8); - - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture(MekanismUtils.getResource( + ResourceType.GUI, "GuiThermalEvaporationController.png" + )); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int displayInt = tileEntity.getScaledTempLevel(78); + drawTexturedModalRect(guiWidth + 49, guiHeight + 64, 176, 59, displayInt, 8); + + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } } diff --git a/src/main/java/mekanism/client/gui/GuiThermoelectricBoiler.java b/src/main/java/mekanism/client/gui/GuiThermoelectricBoiler.java index 31c553e2f..60f3195fc 100644 --- a/src/main/java/mekanism/client/gui/GuiThermoelectricBoiler.java +++ b/src/main/java/mekanism/client/gui/GuiThermoelectricBoiler.java @@ -2,6 +2,8 @@ package mekanism.client.gui; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.MekanismConfig.general; import mekanism.api.util.ListUtils; import mekanism.api.util.UnitDisplayUtils; @@ -21,147 +23,224 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.entity.player.InventoryPlayer; import net.minecraftforge.fluids.FluidStack; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiThermoelectricBoiler extends GuiMekanism -{ - public TileEntityBoilerCasing tileEntity; +public class GuiThermoelectricBoiler extends GuiMekanism { + public TileEntityBoilerCasing tileEntity; - public GuiThermoelectricBoiler(InventoryPlayer inventory, TileEntityBoilerCasing tentity) - { - super(tentity, new ContainerFilter(inventory, tentity)); - tileEntity = tentity; - guiElements.add(new GuiBoilerTab(this, tileEntity, BoilerTab.STAT, 6, MekanismUtils.getResource(ResourceType.GUI, "GuiThermoelectricBoiler.png"))); - guiElements.add(new GuiRateBar(this, new IRateInfoHandler() - { - @Override - public String getTooltip() - { - return LangUtils.localize("gui.boilRate") + ": " + tileEntity.structure.lastBoilRate + " mB/t"; - } - - @Override - public double getLevel() - { - return (double)tileEntity.structure.lastBoilRate/(double)tileEntity.structure.lastMaxBoil; - } - }, MekanismUtils.getResource(ResourceType.GUI, "GuiThermoelectricBoiler.png"), 24, 13)); - guiElements.add(new GuiRateBar(this, new IRateInfoHandler() - { - @Override - public String getTooltip() - { - return LangUtils.localize("gui.maxBoil") + ": " + tileEntity.structure.lastMaxBoil + " mB/t"; - } - - @Override - public double getLevel() - { - double cap = (tileEntity.structure.superheatingElements*general.superheatingHeatTransfer) / SynchronizedBoilerData.getHeatEnthalpy(); - return (double)tileEntity.structure.lastMaxBoil/cap; - } - }, MekanismUtils.getResource(ResourceType.GUI, "GuiThermoelectricBoiler.png"), 144, 13)); - guiElements.add(new GuiHeatInfo(new IInfoHandler() { - @Override - public List getInfo() - { - TemperatureUnit unit = TemperatureUnit.values()[general.tempUnit.ordinal()]; - String environment = UnitDisplayUtils.getDisplayShort(tileEntity.structure.lastEnvironmentLoss*unit.intervalSize, false, unit); - return ListUtils.asList(LangUtils.localize("gui.dissipated") + ": " + environment + "/t"); - } - }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiThermoelectricBoiler.png"))); - } - - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + public GuiThermoelectricBoiler( + InventoryPlayer inventory, TileEntityBoilerCasing tentity + ) { + super(tentity, new ContainerFilter(inventory, tentity)); + tileEntity = tentity; + guiElements.add(new GuiBoilerTab( + this, + tileEntity, + BoilerTab.STAT, + 6, + MekanismUtils.getResource(ResourceType.GUI, "GuiThermoelectricBoiler.png") + )); + guiElements.add(new GuiRateBar( + this, + new IRateInfoHandler() { + @Override + public String getTooltip() { + return LangUtils.localize("gui.boilRate") + ": " + + tileEntity.structure.lastBoilRate + " mB/t"; + } - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 4, 0x404040); - fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize/2)-(fontRendererObj.getStringWidth(tileEntity.getInventoryName())/2), 5, 0x404040); - - renderScaledText(LangUtils.localize("gui.temp") + ": " + MekanismUtils.getTemperatureDisplay(tileEntity.structure.temperature, TemperatureUnit.AMBIENT), 43, 30, 0x00CD00, 90); - renderScaledText(LangUtils.localize("gui.boilRate") + ": " + tileEntity.structure.lastBoilRate + " mB/t", 43, 39, 0x00CD00, 90); - renderScaledText(LangUtils.localize("gui.maxBoil") + ": " + tileEntity.structure.lastMaxBoil + " mB/t", 43, 48, 0x00CD00, 90); - - if(xAxis >= 7 && xAxis <= 23 && yAxis >= 14 && yAxis <= 72) - { - drawCreativeTabHoveringText(tileEntity.structure.waterStored != null ? LangUtils.localizeFluidStack(tileEntity.structure.waterStored) + ": " + tileEntity.structure.waterStored.amount + "mB" : LangUtils.localize("gui.empty"), xAxis, yAxis); - } - - if(xAxis >= 153 && xAxis <= 169 && yAxis >= 14 && yAxis <= 72) - { - drawCreativeTabHoveringText(tileEntity.structure.steamStored != null ? LangUtils.localizeFluidStack(tileEntity.structure.steamStored) + ": " + tileEntity.structure.steamStored.amount + "mB" : LangUtils.localize("gui.empty"), xAxis, yAxis); - } - - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } - - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiThermoelectricBoiler.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - if(tileEntity.getScaledWaterLevel(58) > 0) - { - displayGauge(7, 14, tileEntity.getScaledWaterLevel(58), tileEntity.structure.waterStored); - } - - if(tileEntity.getScaledSteamLevel(58) > 0) - { - displayGauge(153, 14, tileEntity.getScaledSteamLevel(58), tileEntity.structure.steamStored); - } - - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } - - public void displayGauge(int xPos, int yPos, int scale, FluidStack fluid) - { - if(fluid == null) - { - return; - } + @Override + public double getLevel() { + return (double) tileEntity.structure.lastBoilRate + / (double) tileEntity.structure.lastMaxBoil; + } + }, + MekanismUtils.getResource(ResourceType.GUI, "GuiThermoelectricBoiler.png"), + 24, + 13 + )); + guiElements.add(new GuiRateBar( + this, + new IRateInfoHandler() { + @Override + public String getTooltip() { + return LangUtils.localize("gui.maxBoil") + ": " + + tileEntity.structure.lastMaxBoil + " mB/t"; + } - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; + @Override + public double getLevel() { + double cap = (tileEntity.structure.superheatingElements + * general.superheatingHeatTransfer) + / SynchronizedBoilerData.getHeatEnthalpy(); + return (double) tileEntity.structure.lastMaxBoil / cap; + } + }, + MekanismUtils.getResource(ResourceType.GUI, "GuiThermoelectricBoiler.png"), + 144, + 13 + )); + guiElements.add(new GuiHeatInfo( + new IInfoHandler() { + @Override + public List getInfo() { + TemperatureUnit unit + = TemperatureUnit.values()[general.tempUnit.ordinal()]; + String environment = UnitDisplayUtils.getDisplayShort( + tileEntity.structure.lastEnvironmentLoss * unit.intervalSize, + false, + unit + ); + return ListUtils.asList( + LangUtils.localize("gui.dissipated") + ": " + environment + "/t" + ); + } + }, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiThermoelectricBoiler.png") + )); + } - int start = 0; + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - while(true) - { - int renderRemaining = 0; + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, (ySize - 96) + 4, 0x404040 + ); + fontRendererObj.drawString( + tileEntity.getInventoryName(), + (xSize / 2) + - (fontRendererObj.getStringWidth(tileEntity.getInventoryName()) / 2), + 5, + 0x404040 + ); - if(scale > 16) - { - renderRemaining = 16; - scale -= 16; - } - else { - renderRemaining = scale; - scale = 0; - } + renderScaledText( + LangUtils.localize("gui.temp") + ": " + + MekanismUtils.getTemperatureDisplay( + tileEntity.structure.temperature, TemperatureUnit.AMBIENT + ), + 43, + 30, + 0x00CD00, + 90 + ); + renderScaledText( + LangUtils.localize("gui.boilRate") + ": " + tileEntity.structure.lastBoilRate + + " mB/t", + 43, + 39, + 0x00CD00, + 90 + ); + renderScaledText( + LangUtils.localize("gui.maxBoil") + ": " + tileEntity.structure.lastMaxBoil + + " mB/t", + 43, + 48, + 0x00CD00, + 90 + ); - mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture()); - drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos + 58 - renderRemaining - start, fluid.getFluid().getIcon(), 16, 16 - (16 - renderRemaining)); - start+=16; + if (xAxis >= 7 && xAxis <= 23 && yAxis >= 14 && yAxis <= 72) { + drawCreativeTabHoveringText( + tileEntity.structure.waterStored != null + ? LangUtils.localizeFluidStack(tileEntity.structure.waterStored) + + ": " + tileEntity.structure.waterStored.amount + "mB" + : LangUtils.localize("gui.empty"), + xAxis, + yAxis + ); + } - if(renderRemaining == 0 || scale == 0) - { - break; - } - } + if (xAxis >= 153 && xAxis <= 169 && yAxis >= 14 && yAxis <= 72) { + drawCreativeTabHoveringText( + tileEntity.structure.steamStored != null + ? LangUtils.localizeFluidStack(tileEntity.structure.steamStored) + + ": " + tileEntity.structure.steamStored.amount + "mB" + : LangUtils.localize("gui.empty"), + xAxis, + yAxis + ); + } - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiIndustrialTurbine.png")); - drawTexturedModalRect(guiWidth + xPos, guiHeight + yPos, 176, 0, 16, 54); - } + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiThermoelectricBoiler.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + if (tileEntity.getScaledWaterLevel(58) > 0) { + displayGauge( + 7, + 14, + tileEntity.getScaledWaterLevel(58), + tileEntity.structure.waterStored + ); + } + + if (tileEntity.getScaledSteamLevel(58) > 0) { + displayGauge( + 153, + 14, + tileEntity.getScaledSteamLevel(58), + tileEntity.structure.steamStored + ); + } + + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } + + public void displayGauge(int xPos, int yPos, int scale, FluidStack fluid) { + if (fluid == null) { + return; + } + + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + + int start = 0; + + while (true) { + int renderRemaining = 0; + + if (scale > 16) { + renderRemaining = 16; + scale -= 16; + } else { + renderRemaining = scale; + scale = 0; + } + + mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture()); + drawTexturedModelRectFromIcon( + guiWidth + xPos, + guiHeight + yPos + 58 - renderRemaining - start, + fluid.getFluid().getIcon(), + 16, + 16 - (16 - renderRemaining) + ); + start += 16; + + if (renderRemaining == 0 || scale == 0) { + break; + } + } + + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiIndustrialTurbine.png") + ); + drawTexturedModalRect(guiWidth + xPos, guiHeight + yPos, 176, 0, 16, 54); + } } diff --git a/src/main/java/mekanism/client/gui/GuiTransporterConfig.java b/src/main/java/mekanism/client/gui/GuiTransporterConfig.java index c8daf4350..d3c08e42b 100644 --- a/src/main/java/mekanism/client/gui/GuiTransporterConfig.java +++ b/src/main/java/mekanism/client/gui/GuiTransporterConfig.java @@ -3,6 +3,8 @@ package mekanism.client.gui; import java.util.HashMap; import java.util.Map; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.transmitters.TransmissionType; @@ -23,211 +25,216 @@ import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; - import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiTransporterConfig extends GuiMekanism -{ - public Map slotPosMap = new HashMap(); - - public ISideConfiguration configurable; +public class GuiTransporterConfig extends GuiMekanism { + public Map slotPosMap = new HashMap(); - public GuiTransporterConfig(EntityPlayer player, ISideConfiguration tile) - { - super((TileEntityContainerBlock)tile, new ContainerNull(player, (TileEntityContainerBlock)tile)); + public ISideConfiguration configurable; - ySize = 95; + public GuiTransporterConfig(EntityPlayer player, ISideConfiguration tile) { + super( + (TileEntityContainerBlock) tile, + new ContainerNull(player, (TileEntityContainerBlock) tile) + ); - configurable = tile; - - slotPosMap.put(0, new GuiPos(54, 64)); - slotPosMap.put(1, new GuiPos(54, 34)); - slotPosMap.put(2, new GuiPos(54, 49)); - slotPosMap.put(3, new GuiPos(39, 64)); - slotPosMap.put(4, new GuiPos(39, 49)); - slotPosMap.put(5, new GuiPos(69, 49)); - } - - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + ySize = 95; - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiTransporterConfig.png")); + configurable = tile; - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; + slotPosMap.put(0, new GuiPos(54, 64)); + slotPosMap.put(1, new GuiPos(54, 34)); + slotPosMap.put(2, new GuiPos(54, 49)); + slotPosMap.put(3, new GuiPos(39, 64)); + slotPosMap.put(4, new GuiPos(39, 49)); + slotPosMap.put(5, new GuiPos(69, 49)); + } - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); - - if(xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) - { - drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176 + 14, 0, 14, 14); - } - else { - drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176 + 14, 14, 14, 14); - } - - if(xAxis >= 156 && xAxis <= 170 && yAxis >= 6 && yAxis <= 20) - { - drawTexturedModalRect(guiWidth + 156, guiHeight + 6, 176 + 28, 0, 14, 14); - } - else { - drawTexturedModalRect(guiWidth + 156, guiHeight + 6, 176 + 28, 14, 14, 14); - } - - for(int i = 0; i < slotPosMap.size(); i++) - { - MekanismRenderer.resetColor(); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiTransporterConfig.png") + ); - int x = slotPosMap.get(i).xPos; - int y = slotPosMap.get(i).yPos; + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; - EnumColor color = configurable.getEjector().getInputColor(ForgeDirection.getOrientation(i)); + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - if(configurable.getConfig().getOutput(TransmissionType.ITEM, i) != TileComponentConfig.EMPTY) - { - if(color != null) - { - MekanismRenderer.color(color); - } - - if(xAxis >= x && xAxis <= x+14 && yAxis >= y && yAxis <= y+14) - { - drawTexturedModalRect(guiWidth + x, guiHeight + y, 176, 0, 14, 14); - } - else { - drawTexturedModalRect(guiWidth + x, guiHeight + y, 176, 14, 14, 14); - } - } - else { - drawTexturedModalRect(guiWidth + x, guiHeight + y, 176, 28, 14, 14); - } - } + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - MekanismRenderer.resetColor(); - } + if (xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) { + drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176 + 14, 0, 14, 14); + } else { + drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176 + 14, 14, 14, 14); + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + if (xAxis >= 156 && xAxis <= 170 && yAxis >= 6 && yAxis <= 20) { + drawTexturedModalRect(guiWidth + 156, guiHeight + 6, 176 + 28, 0, 14, 14); + } else { + drawTexturedModalRect(guiWidth + 156, guiHeight + 6, 176 + 28, 14, 14, 14); + } - String text = LangUtils.localize("gui.configuration.transporter"); - fontRendererObj.drawString(text, (xSize/2)-(fontRendererObj.getStringWidth(text)/2), 5, 0x404040); - text = LangUtils.localize("gui.strictInput") + " (" + LangUtils.transOnOff(configurable.getEjector().hasStrictInput()) + ")"; - renderScaledText(text, 53, 17, 0x00CD00, 70); - - fontRendererObj.drawString(LangUtils.localize("gui.input"), 48, 81, 0x787878); - fontRendererObj.drawString(LangUtils.localize("gui.output"), 114, 68, 0x787878); - - if(configurable.getEjector().getOutputColor() != null) - { - GL11.glPushMatrix(); - GL11.glColor4f(1, 1, 1, 1); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL12.GL_RESCALE_NORMAL); + for (int i = 0; i < slotPosMap.size(); i++) { + MekanismRenderer.resetColor(); - mc.getTextureManager().bindTexture(MekanismRenderer.getBlocksTexture()); - itemRender.renderIcon(122, 49, MekanismRenderer.getColorIcon(configurable.getEjector().getOutputColor()), 16, 16); + int x = slotPosMap.get(i).xPos; + int y = slotPosMap.get(i).yPos; - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } - - for(int i = 0; i < slotPosMap.size(); i++) - { - int x = slotPosMap.get(i).xPos; - int y = slotPosMap.get(i).yPos; + EnumColor color + = configurable.getEjector().getInputColor(ForgeDirection.getOrientation(i) + ); - EnumColor color = configurable.getEjector().getInputColor(ForgeDirection.getOrientation(i)); + if (configurable.getConfig().getOutput(TransmissionType.ITEM, i) + != TileComponentConfig.EMPTY) { + if (color != null) { + MekanismRenderer.color(color); + } - if(configurable.getConfig().getOutput(TransmissionType.ITEM, i) != TileComponentConfig.EMPTY) - { - if(xAxis >= x && xAxis <= x+14 && yAxis >= y && yAxis <= y+14) - { - drawCreativeTabHoveringText(color != null ? color.getName() : LangUtils.localize("gui.none"), xAxis, yAxis); - } - } - } - - if(xAxis >= 122 && xAxis <= 138 && yAxis >= 49 && yAxis <= 65) - { - if(configurable.getEjector().getOutputColor() != null) - { - drawCreativeTabHoveringText(configurable.getEjector().getOutputColor().getName(), xAxis, yAxis); - } - else { - drawCreativeTabHoveringText(LangUtils.localize("gui.none"), xAxis, yAxis); - } - } - - if(xAxis >= 156 && xAxis <= 170 && yAxis >= 6 && yAxis <= 20) - { - drawCreativeTabHoveringText(LangUtils.localize("gui.configuration.strictInput"), xAxis, yAxis); - } + if (xAxis >= x && xAxis <= x + 14 && yAxis >= y && yAxis <= y + 14) { + drawTexturedModalRect(guiWidth + x, guiHeight + y, 176, 0, 14, 14); + } else { + drawTexturedModalRect(guiWidth + x, guiHeight + y, 176, 14, 14, 14); + } + } else { + drawTexturedModalRect(guiWidth + x, guiHeight + y, 176, 28, 14, 14); + } + } - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } - - @Override - protected void mouseClicked(int mouseX, int mouseY, int button) - { - super.mouseClicked(mouseX, mouseY, button); + MekanismRenderer.resetColor(); + } - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - TileEntity tile = (TileEntity)configurable; + String text = LangUtils.localize("gui.configuration.transporter"); + fontRendererObj.drawString( + text, (xSize / 2) - (fontRendererObj.getStringWidth(text) / 2), 5, 0x404040 + ); + text = LangUtils.localize("gui.strictInput") + " (" + + LangUtils.transOnOff(configurable.getEjector().hasStrictInput()) + ")"; + renderScaledText(text, 53, 17, 0x00CD00, 70); - if(button == 0) - { - if(xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) - { - int guiId = Mekanism.proxy.getGuiId(tile.getBlockType(), tile.getBlockMetadata()); + fontRendererObj.drawString(LangUtils.localize("gui.input"), 48, 81, 0x787878); + fontRendererObj.drawString(LangUtils.localize("gui.output"), 114, 68, 0x787878); + + if (configurable.getEjector().getOutputColor() != null) { + GL11.glPushMatrix(); + GL11.glColor4f(1, 1, 1, 1); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); + + mc.getTextureManager().bindTexture(MekanismRenderer.getBlocksTexture()); + itemRender.renderIcon( + 122, + 49, + MekanismRenderer.getColorIcon(configurable.getEjector().getOutputColor()), + 16, + 16 + ); + + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + + for (int i = 0; i < slotPosMap.size(); i++) { + int x = slotPosMap.get(i).xPos; + int y = slotPosMap.get(i).yPos; + + EnumColor color + = configurable.getEjector().getInputColor(ForgeDirection.getOrientation(i) + ); + + if (configurable.getConfig().getOutput(TransmissionType.ITEM, i) + != TileComponentConfig.EMPTY) { + if (xAxis >= x && xAxis <= x + 14 && yAxis >= y && yAxis <= y + 14) { + drawCreativeTabHoveringText( + color != null ? color.getName() : LangUtils.localize("gui.none"), + xAxis, + yAxis + ); + } + } + } + + if (xAxis >= 122 && xAxis <= 138 && yAxis >= 49 && yAxis <= 65) { + if (configurable.getEjector().getOutputColor() != null) { + drawCreativeTabHoveringText( + configurable.getEjector().getOutputColor().getName(), xAxis, yAxis + ); + } else { + drawCreativeTabHoveringText(LangUtils.localize("gui.none"), xAxis, yAxis); + } + } + + if (xAxis >= 156 && xAxis <= 170 && yAxis >= 6 && yAxis <= 20) { + drawCreativeTabHoveringText( + LangUtils.localize("gui.configuration.strictInput"), xAxis, yAxis + ); + } + + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + protected void mouseClicked(int mouseX, int mouseY, int button) { + super.mouseClicked(mouseX, mouseY, button); + + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + TileEntity tile = (TileEntity) configurable; + + if (button == 0) { + if (xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) { + int guiId = Mekanism.proxy.getGuiId( + tile.getBlockType(), tile.getBlockMetadata() + ); SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new SimpleGuiMessage(Coord4D.get(tile), 0, guiId)); - } - - if(xAxis >= 156 && xAxis <= 170 && yAxis >= 6 && yAxis <= 20) - { + Mekanism.packetHandler.sendToServer( + new SimpleGuiMessage(Coord4D.get(tile), 0, guiId) + ); + } + + if (xAxis >= 156 && xAxis <= 170 && yAxis >= 6 && yAxis <= 20) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new ConfigurationUpdateMessage(ConfigurationPacket.STRICT_INPUT, Coord4D.get(tile), 0, 0, null)); - } - } - - if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && button == 0) - { - button = 2; - } - - if(xAxis >= 122 && xAxis <= 138 && yAxis >= 49 && yAxis <= 65) - { + Mekanism.packetHandler.sendToServer(new ConfigurationUpdateMessage( + ConfigurationPacket.STRICT_INPUT, Coord4D.get(tile), 0, 0, null + )); + } + } + + if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) && button == 0) { + button = 2; + } + + if (xAxis >= 122 && xAxis <= 138 && yAxis >= 49 && yAxis <= 65) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new ConfigurationUpdateMessage(ConfigurationPacket.EJECT_COLOR, Coord4D.get(tile), button, 0, null)); - } - - for(int i = 0; i < slotPosMap.size(); i++) - { - int x = slotPosMap.get(i).xPos; - int y = slotPosMap.get(i).yPos; + Mekanism.packetHandler.sendToServer(new ConfigurationUpdateMessage( + ConfigurationPacket.EJECT_COLOR, Coord4D.get(tile), button, 0, null + )); + } - if(xAxis >= x && xAxis <= x+14 && yAxis >= y && yAxis <= y+14) - { + for (int i = 0; i < slotPosMap.size(); i++) { + int x = slotPosMap.get(i).xPos; + int y = slotPosMap.get(i).yPos; + + if (xAxis >= x && xAxis <= x + 14 && yAxis >= y && yAxis <= y + 14) { SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new ConfigurationUpdateMessage(ConfigurationPacket.INPUT_COLOR, Coord4D.get(tile), button, i, null)); - } - } - } + Mekanism.packetHandler.sendToServer(new ConfigurationUpdateMessage( + ConfigurationPacket.INPUT_COLOR, Coord4D.get(tile), button, i, null + )); + } + } + } } diff --git a/src/main/java/mekanism/client/gui/GuiUpgradeManagement.java b/src/main/java/mekanism/client/gui/GuiUpgradeManagement.java index 745110fd0..398e586f0 100644 --- a/src/main/java/mekanism/client/gui/GuiUpgradeManagement.java +++ b/src/main/java/mekanism/client/gui/GuiUpgradeManagement.java @@ -2,6 +2,8 @@ package mekanism.client.gui; import java.util.Set; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.client.render.MekanismRenderer; import mekanism.client.sound.SoundHandler; @@ -17,315 +19,324 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.tileentity.TileEntity; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiUpgradeManagement extends GuiMekanism -{ - public IUpgradeTile tileEntity; - - public Upgrade selectedType; - - public boolean isDragging = false; +public class GuiUpgradeManagement extends GuiMekanism { + public IUpgradeTile tileEntity; - public int dragOffset = 0; - - public int supportedIndex; - - public int delay; - - public float scroll; - - public GuiUpgradeManagement(InventoryPlayer inventory, IUpgradeTile tile) - { - super(new ContainerUpgradeManagement(inventory, tile)); - tileEntity = tile; - } - - @Override - public void updateScreen() - { - super.updateScreen(); - - if(delay < 40) - { - delay++; - } - else { - delay = 0; - supportedIndex = ++supportedIndex%tileEntity.getComponent().getSupportedTypes().size(); - } - } - - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); - - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiUpgradeManagement.png")); - GL11.glColor4f(1, 1, 1, 1); - drawTexturedModalRect(84, 8+getScroll(), 202, 0, 4, 4); - - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); - fontRendererObj.drawString(LangUtils.localize("gui.upgrades.supported") + ":", 26, 59, 0x404040); - - if(selectedType == null) - { - renderText(LangUtils.localize("gui.upgrades.noSelection") + ".", 92, 8, 0.8F, true); - } - else { - int amount = tileEntity.getComponent().getUpgrades(selectedType); - - renderText(selectedType.getName() + " " + LangUtils.localize("gui.upgrade"), 92, 8, 0.6F, true); - renderText(LangUtils.localize("gui.upgrades.amount") + ": " + amount + "/" + selectedType.getMax(), 92, 16, 0.6F, true); - - int text = 0; - - for(String s : selectedType.getInfo((TileEntity)tileEntity)) - { - renderText(s, 92, 22+(6*text++), 0.6F, true); - } - } - - if(!tileEntity.getComponent().getSupportedTypes().isEmpty()) - { - Upgrade[] supported = tileEntity.getComponent().getSupportedTypes().toArray(new Upgrade[tileEntity.getComponent().getSupportedTypes().size()]); - - if(supported.length > supportedIndex) - { - renderUpgrade(supported[supportedIndex], 80, 57, 0.8F, true); - fontRendererObj.drawString(supported[supportedIndex].getName(), 96, 59, 0x404040); - } - } - - Upgrade[] upgrades = getCurrentUpgrades().toArray(new Upgrade[getCurrentUpgrades().size()]); - - for(int i = 0; i < 4; i++) - { - int index = getUpgradeIndex()+i; - - if(index > upgrades.length-1) - { - break; - } - - Upgrade upgrade = upgrades[index]; - - int xPos = 25; - int yPos = 7 + (i*12); - int yRender = 0; - - fontRendererObj.drawString(upgrade.getName(), xPos + 12, yPos + 2, 0x404040); - - renderUpgrade(upgrade, xPos + 2, yPos + 2, 0.5F, true); - - if(xAxis >= xPos && xAxis <= xPos+58 && yAxis >= yPos && yAxis <= yPos+12) - { - func_146283_a(MekanismUtils.splitTooltip(upgrade.getDescription(), upgrade.getStack()), xAxis, yAxis); - } - } + public Upgrade selectedType; - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } - - private void renderText(String text, int x, int y, float size, boolean scale) - { - GL11.glPushMatrix(); - GL11.glScalef(size, size, size); - fontRendererObj.drawString(text, scale ? (int)((1F/size)*x) : x, scale ? (int)((1F/size)*y) : y, 0x00CD00); - GL11.glPopMatrix(); - } - - private void renderUpgrade(Upgrade type, int x, int y, float size, boolean scale) - { - GL11.glPushMatrix(); - GL11.glScalef(size, size, size); - GL11.glEnable(GL11.GL_LIGHTING); - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), type.getStack(), scale ? (int)((1F/size)*x) : x, scale ? (int)((1F/size)*y) : y); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } + public boolean isDragging = false; - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiUpgradeManagement.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + public int dragOffset = 0; - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); - - if(xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) - { - drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176, 0, 14, 14); - } - else { - drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176, 14, 14, 14); - } - - if(selectedType == null) - { - drawTexturedModalRect(guiWidth + 136, guiHeight + 57, 176 + 14, 24, 12, 12); - } - else if(xAxis >= 136 && xAxis <= 148 && yAxis >= 57 && yAxis <= 69) - { - drawTexturedModalRect(guiWidth + 136, guiHeight + 57, 176 + 14, 0, 12, 12); - } - else { - drawTexturedModalRect(guiWidth + 136, guiHeight + 57, 176 + 14, 12, 12, 12); - } - - int displayInt = tileEntity.getComponent().getScaledUpgradeProgress(14); - drawTexturedModalRect(guiWidth + 154, guiHeight + 26, 176, 28, 10, displayInt); - - if(selectedType != null && tileEntity.getComponent().getUpgrades(selectedType) == 0) - { - selectedType = null; - } - - Upgrade[] upgrades = getCurrentUpgrades().toArray(new Upgrade[getCurrentUpgrades().size()]); - - for(int i = 0; i < 4; i++) - { - int index = getUpgradeIndex()+i; - - if(index > upgrades.length-1) - { - break; - } - - Upgrade upgrade = upgrades[index]; - - int xPos = 25; - int yPos = 7 + (i*12); - int yRender = 0; - - if(upgrade == selectedType) - { - yRender = 166 + 24; - } - else if(xAxis >= xPos && xAxis <= xPos+58 && yAxis >= yPos && yAxis <= yPos+12) - { - yRender = 166; - } - else { - yRender = 166 + 12; - } - - MekanismRenderer.color(upgrade.getColor(), 1.0F, 2.5F); - drawTexturedModalRect(guiWidth + xPos, guiHeight + yPos, 0, yRender, 58, 12); - MekanismRenderer.resetColor(); - } + public int supportedIndex; - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } - - private Set getCurrentUpgrades() - { - return tileEntity.getComponent().getInstalledTypes(); - } - - public int getScroll() - { - return Math.max(Math.min((int)(scroll*42), 42), 0); - } + public int delay; - public int getUpgradeIndex() - { - if(getCurrentUpgrades().size() <= 4) - { - return 0; - } + public float scroll; - return (int)((getCurrentUpgrades().size()*scroll) - ((4F/(float)getCurrentUpgrades().size()))*scroll); - } - - @Override - protected void mouseClickMove(int mouseX, int mouseY, int button, long ticks) - { - super.mouseClickMove(mouseX, mouseY, button, ticks); + public GuiUpgradeManagement(InventoryPlayer inventory, IUpgradeTile tile) { + super(new ContainerUpgradeManagement(inventory, tile)); + tileEntity = tile; + } - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + @Override + public void updateScreen() { + super.updateScreen(); - if(isDragging) - { - scroll = Math.min(Math.max((float)(yAxis-8-dragOffset)/42F, 0), 1); - } - } + if (delay < 40) { + delay++; + } else { + delay = 0; + supportedIndex + = ++supportedIndex % tileEntity.getComponent().getSupportedTypes().size(); + } + } - @Override - protected void mouseMovedOrUp(int mouseX, int mouseY, int type) - { - super.mouseMovedOrUp(mouseX, mouseY, type); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - if(type == 0 && isDragging) - { - dragOffset = 0; - isDragging = false; - } - } - - @Override - protected void mouseClicked(int mouseX, int mouseY, int button) - { - super.mouseClicked(mouseX, mouseY, button); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiUpgradeManagement.png") + ); + GL11.glColor4f(1, 1, 1, 1); + drawTexturedModalRect(84, 8 + getScroll(), 202, 0, 4, 4); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); - - TileEntity tile = (TileEntity)tileEntity; - - if(button == 0) - { - if(xAxis >= 84 && xAxis <= 88 && yAxis >= getScroll()+8 && yAxis <= getScroll()+8+4) - { - if(getCurrentUpgrades().size()>4) - { - dragOffset = yAxis - (getScroll()+8); - isDragging = true; - } - else { - scroll = 0; - } - } - - if(xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) - { - int guiId = MachineType.get(tile.getBlockType(), tile.getBlockMetadata()).guiId; + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.upgrades.supported") + ":", 26, 59, 0x404040 + ); + + if (selectedType == null) { + renderText( + LangUtils.localize("gui.upgrades.noSelection") + ".", 92, 8, 0.8F, true + ); + } else { + int amount = tileEntity.getComponent().getUpgrades(selectedType); + + renderText( + selectedType.getName() + " " + LangUtils.localize("gui.upgrade"), + 92, + 8, + 0.6F, + true + ); + renderText( + LangUtils.localize("gui.upgrades.amount") + ": " + amount + "/" + + selectedType.getMax(), + 92, + 16, + 0.6F, + true + ); + + int text = 0; + + for (String s : selectedType.getInfo((TileEntity) tileEntity)) { + renderText(s, 92, 22 + (6 * text++), 0.6F, true); + } + } + + if (!tileEntity.getComponent().getSupportedTypes().isEmpty()) { + Upgrade[] supported = tileEntity.getComponent().getSupportedTypes().toArray( + new Upgrade[tileEntity.getComponent().getSupportedTypes().size()] + ); + + if (supported.length > supportedIndex) { + renderUpgrade(supported[supportedIndex], 80, 57, 0.8F, true); + fontRendererObj.drawString( + supported[supportedIndex].getName(), 96, 59, 0x404040 + ); + } + } + + Upgrade[] upgrades + = getCurrentUpgrades().toArray(new Upgrade[getCurrentUpgrades().size()]); + + for (int i = 0; i < 4; i++) { + int index = getUpgradeIndex() + i; + + if (index > upgrades.length - 1) { + break; + } + + Upgrade upgrade = upgrades[index]; + + int xPos = 25; + int yPos = 7 + (i * 12); + int yRender = 0; + + fontRendererObj.drawString(upgrade.getName(), xPos + 12, yPos + 2, 0x404040); + + renderUpgrade(upgrade, xPos + 2, yPos + 2, 0.5F, true); + + if (xAxis >= xPos && xAxis <= xPos + 58 && yAxis >= yPos + && yAxis <= yPos + 12) { + func_146283_a( + MekanismUtils.splitTooltip( + upgrade.getDescription(), upgrade.getStack() + ), + xAxis, + yAxis + ); + } + } + + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + private void renderText(String text, int x, int y, float size, boolean scale) { + GL11.glPushMatrix(); + GL11.glScalef(size, size, size); + fontRendererObj.drawString( + text, + scale ? (int) ((1F / size) * x) : x, + scale ? (int) ((1F / size) * y) : y, + 0x00CD00 + ); + GL11.glPopMatrix(); + } + + private void renderUpgrade(Upgrade type, int x, int y, float size, boolean scale) { + GL11.glPushMatrix(); + GL11.glScalef(size, size, size); + GL11.glEnable(GL11.GL_LIGHTING); + itemRender.renderItemAndEffectIntoGUI( + fontRendererObj, + mc.getTextureManager(), + type.getStack(), + scale ? (int) ((1F / size) * x) : x, + scale ? (int) ((1F / size) * y) : y + ); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiUpgradeManagement.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + if (xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) { + drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176, 0, 14, 14); + } else { + drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176, 14, 14, 14); + } + + if (selectedType == null) { + drawTexturedModalRect(guiWidth + 136, guiHeight + 57, 176 + 14, 24, 12, 12); + } else if (xAxis >= 136 && xAxis <= 148 && yAxis >= 57 && yAxis <= 69) { + drawTexturedModalRect(guiWidth + 136, guiHeight + 57, 176 + 14, 0, 12, 12); + } else { + drawTexturedModalRect(guiWidth + 136, guiHeight + 57, 176 + 14, 12, 12, 12); + } + + int displayInt = tileEntity.getComponent().getScaledUpgradeProgress(14); + drawTexturedModalRect(guiWidth + 154, guiHeight + 26, 176, 28, 10, displayInt); + + if (selectedType != null + && tileEntity.getComponent().getUpgrades(selectedType) == 0) { + selectedType = null; + } + + Upgrade[] upgrades + = getCurrentUpgrades().toArray(new Upgrade[getCurrentUpgrades().size()]); + + for (int i = 0; i < 4; i++) { + int index = getUpgradeIndex() + i; + + if (index > upgrades.length - 1) { + break; + } + + Upgrade upgrade = upgrades[index]; + + int xPos = 25; + int yPos = 7 + (i * 12); + int yRender = 0; + + if (upgrade == selectedType) { + yRender = 166 + 24; + } else if (xAxis >= xPos && xAxis <= xPos + 58 && yAxis >= yPos && yAxis <= yPos + 12) { + yRender = 166; + } else { + yRender = 166 + 12; + } + + MekanismRenderer.color(upgrade.getColor(), 1.0F, 2.5F); + drawTexturedModalRect(guiWidth + xPos, guiHeight + yPos, 0, yRender, 58, 12); + MekanismRenderer.resetColor(); + } + + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } + + private Set getCurrentUpgrades() { + return tileEntity.getComponent().getInstalledTypes(); + } + + public int getScroll() { + return Math.max(Math.min((int) (scroll * 42), 42), 0); + } + + public int getUpgradeIndex() { + if (getCurrentUpgrades().size() <= 4) { + return 0; + } + + return (int + ) ((getCurrentUpgrades().size() * scroll) + - ((4F / (float) getCurrentUpgrades().size())) * scroll); + } + + @Override + protected void mouseClickMove(int mouseX, int mouseY, int button, long ticks) { + super.mouseClickMove(mouseX, mouseY, button, ticks); + + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + if (isDragging) { + scroll = Math.min(Math.max((float) (yAxis - 8 - dragOffset) / 42F, 0), 1); + } + } + + @Override + protected void mouseMovedOrUp(int mouseX, int mouseY, int type) { + super.mouseMovedOrUp(mouseX, mouseY, type); + + if (type == 0 && isDragging) { + dragOffset = 0; + isDragging = false; + } + } + + @Override + protected void mouseClicked(int mouseX, int mouseY, int button) { + super.mouseClicked(mouseX, mouseY, button); + + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + TileEntity tile = (TileEntity) tileEntity; + + if (button == 0) { + if (xAxis >= 84 && xAxis <= 88 && yAxis >= getScroll() + 8 + && yAxis <= getScroll() + 8 + 4) { + if (getCurrentUpgrades().size() > 4) { + dragOffset = yAxis - (getScroll() + 8); + isDragging = true; + } else { + scroll = 0; + } + } + + if (xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) { + int guiId + = MachineType.get(tile.getBlockType(), tile.getBlockMetadata()).guiId; SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new SimpleGuiMessage(Coord4D.get(tile), 0, guiId)); - } - - if(selectedType != null && xAxis >= 136 && xAxis <= 148 && yAxis >= 57 && yAxis <= 69) - { - SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new RemoveUpgradeMessage(Coord4D.get(tile), selectedType.ordinal())); - } - - int counter = 0; - - for(Upgrade upgrade : getCurrentUpgrades()) - { - int xPos = 25; - int yPos = 7 + (counter++*12); - int yRender = 0; - - if(xAxis >= xPos && xAxis <= xPos+58 && yAxis >= yPos && yAxis <= yPos+12) - { - selectedType = upgrade; - break; - } - } - } - } + Mekanism.packetHandler.sendToServer( + new SimpleGuiMessage(Coord4D.get(tile), 0, guiId) + ); + } + + if (selectedType != null && xAxis >= 136 && xAxis <= 148 && yAxis >= 57 + && yAxis <= 69) { + SoundHandler.playSound("gui.button.press"); + Mekanism.packetHandler.sendToServer( + new RemoveUpgradeMessage(Coord4D.get(tile), selectedType.ordinal()) + ); + } + + int counter = 0; + + for (Upgrade upgrade : getCurrentUpgrades()) { + int xPos = 25; + int yPos = 7 + (counter++ * 12); + int yRender = 0; + + if (xAxis >= xPos && xAxis <= xPos + 58 && yAxis >= yPos + && yAxis <= yPos + 12) { + selectedType = upgrade; + break; + } + } + } + } } diff --git a/src/main/java/mekanism/client/gui/GuiWeatherOrb.java b/src/main/java/mekanism/client/gui/GuiWeatherOrb.java index 3e4d856de..c2a71a72b 100644 --- a/src/main/java/mekanism/client/gui/GuiWeatherOrb.java +++ b/src/main/java/mekanism/client/gui/GuiWeatherOrb.java @@ -1,7 +1,5 @@ package mekanism.client.gui; -import org.lwjgl.opengl.GL11; - import mekanism.common.Mekanism; import mekanism.common.network.PacketChangeWeather.ChangeWeatherMessage; import mekanism.common.network.PacketChangeWeather.WeatherType; @@ -10,72 +8,95 @@ import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiScreen; import net.minecraft.entity.player.EntityPlayer; +import org.lwjgl.opengl.GL11; public class GuiWeatherOrb extends GuiScreen { private static EntityPlayer player; private int xSize; private int ySize; - + public GuiWeatherOrb(final EntityPlayer entityplayer) { this.xSize = 176; this.ySize = 166; GuiWeatherOrb.player = entityplayer; } - + @Override public void initGui() { this.buttonList.clear(); - this.buttonList.add(new GuiButton(0, this.width / 2 - 80, this.height / 2 - 65, 50, 20, "Clear")); - this.buttonList.add(new GuiButton(1, this.width / 2 - 80, this.height / 2 - 35, 50, 20, "Storm")); - this.buttonList.add(new GuiButton(2, this.width / 2 + 5, this.height / 2 - 65, 50, 20, "Haze")); - this.buttonList.add(new GuiButton(3, this.width / 2 + 5, this.height / 2 - 35, 50, 20, "Rain")); + this.buttonList.add( + new GuiButton(0, this.width / 2 - 80, this.height / 2 - 65, 50, 20, "Clear") + ); + this.buttonList.add( + new GuiButton(1, this.width / 2 - 80, this.height / 2 - 35, 50, 20, "Storm") + ); + this.buttonList.add( + new GuiButton(2, this.width / 2 + 5, this.height / 2 - 65, 50, 20, "Haze") + ); + this.buttonList.add( + new GuiButton(3, this.width / 2 + 5, this.height / 2 - 35, 50, 20, "Rain") + ); } - + @Override public void drawScreen(final int i, final int j, final float f) { GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - this.mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiWeatherOrb.png")); - this.drawTexturedModalRect(this.width / 2 - 100, this.height / 2 - 100, 0, 0, xSize, ySize); - this.drawString(this.fontRendererObj, "Weather Orb", this.width / 2 - 45, this.height / 2 - 95, 16777215); + this.mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiWeatherOrb.png") + ); + this.drawTexturedModalRect( + this.width / 2 - 100, this.height / 2 - 100, 0, 0, xSize, ySize + ); + this.drawString( + this.fontRendererObj, + "Weather Orb", + this.width / 2 - 45, + this.height / 2 - 95, + 16777215 + ); super.drawScreen(i, j, f); GL11.glBlendFunc(770, 771); GL11.glEnable(2884); GL11.glEnable(3008); GL11.glEnable(2929); } - + @Override public void keyTyped(final char c, final int i) { if (i == 1) { this.mc.thePlayer.closeScreen(); } } - + @Override public boolean doesGuiPauseGame() { return false; } - + @Override public void actionPerformed(final GuiButton guibutton) { if (guibutton.id == 0) { MekanismUtils.doFakeEntityExplosion(GuiWeatherOrb.player); - Mekanism.packetHandler.sendToServer(new ChangeWeatherMessage(WeatherType.CLEAR)); + Mekanism.packetHandler.sendToServer(new ChangeWeatherMessage(WeatherType.CLEAR + )); this.mc.thePlayer.closeScreen(); } if (guibutton.id == 1) { MekanismUtils.doFakeEntityExplosion(GuiWeatherOrb.player); - Mekanism.packetHandler.sendToServer(new ChangeWeatherMessage(WeatherType.STORM)); + Mekanism.packetHandler.sendToServer(new ChangeWeatherMessage(WeatherType.STORM + )); this.mc.thePlayer.closeScreen(); } if (guibutton.id == 2) { MekanismUtils.doFakeEntityExplosion(GuiWeatherOrb.player); - Mekanism.packetHandler.sendToServer(new ChangeWeatherMessage(WeatherType.HAZE)); + Mekanism.packetHandler.sendToServer(new ChangeWeatherMessage(WeatherType.HAZE) + ); this.mc.thePlayer.closeScreen(); } if (guibutton.id == 3) { MekanismUtils.doFakeEntityExplosion(GuiWeatherOrb.player); - Mekanism.packetHandler.sendToServer(new ChangeWeatherMessage(WeatherType.RAIN)); + Mekanism.packetHandler.sendToServer(new ChangeWeatherMessage(WeatherType.RAIN) + ); this.mc.thePlayer.closeScreen(); } } diff --git a/src/main/java/mekanism/client/gui/IGuiWrapper.java b/src/main/java/mekanism/client/gui/IGuiWrapper.java index c22ccf2f9..f70baa8cb 100644 --- a/src/main/java/mekanism/client/gui/IGuiWrapper.java +++ b/src/main/java/mekanism/client/gui/IGuiWrapper.java @@ -5,15 +5,14 @@ import java.util.List; import net.minecraft.client.gui.FontRenderer; import net.minecraft.util.IIcon; -public interface IGuiWrapper -{ - public void drawTexturedRect(int x, int y, int u, int v, int w, int h); +public interface IGuiWrapper { + public void drawTexturedRect(int x, int y, int u, int v, int w, int h); - public void drawTexturedRectFromIcon(int x, int y, IIcon icon, int w, int h); + public void drawTexturedRectFromIcon(int x, int y, IIcon icon, int w, int h); - public void displayTooltip(String s, int xAxis, int yAxis); + public void displayTooltip(String s, int xAxis, int yAxis); - public void displayTooltips(List list, int xAxis, int yAxis); + public void displayTooltips(List list, int xAxis, int yAxis); - public FontRenderer getFont(); + public FontRenderer getFont(); } diff --git a/src/main/java/mekanism/client/gui/element/GuiAmplifierTab.java b/src/main/java/mekanism/client/gui/element/GuiAmplifierTab.java index b2eaa1b58..8133fe24d 100644 --- a/src/main/java/mekanism/client/gui/element/GuiAmplifierTab.java +++ b/src/main/java/mekanism/client/gui/element/GuiAmplifierTab.java @@ -2,6 +2,9 @@ package mekanism.client.gui.element; import java.util.ArrayList; +import codechicken.lib.vec.Rectangle4i; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.client.gui.IGuiWrapper; import mekanism.client.sound.SoundHandler; @@ -13,77 +16,77 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; -import codechicken.lib.vec.Rectangle4i; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiAmplifierTab extends GuiElement -{ - public TileEntity tileEntity; +public class GuiAmplifierTab extends GuiElement { + public TileEntity tileEntity; - public GuiAmplifierTab(IGuiWrapper gui, TileEntity tile, ResourceLocation def) - { - super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiAmplifierTab.png"), gui, def); + public GuiAmplifierTab(IGuiWrapper gui, TileEntity tile, ResourceLocation def) { + super( + MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiAmplifierTab.png"), + gui, + def + ); - tileEntity = tile; - } - - @Override - public Rectangle4i getBounds(int guiWidth, int guiHeight) - { - return new Rectangle4i(guiWidth - 26, guiHeight + 138, 26, 26); - } + tileEntity = tile; + } - @Override - public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) - { - mc.renderEngine.bindTexture(RESOURCE); + @Override + public Rectangle4i getBounds(int guiWidth, int guiHeight) { + return new Rectangle4i(guiWidth - 26, guiHeight + 138, 26, 26); + } - guiObj.drawTexturedRect(guiWidth - 26, guiHeight + 138, 0, 0, 26, 26); - int outputOrdinal = ((TileEntityLaserAmplifier)tileEntity).outputMode.ordinal(); + @Override + public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) { + mc.renderEngine.bindTexture(RESOURCE); - if(xAxis >= -21 && xAxis <= -3 && yAxis >= 142 && yAxis <= 160) - { - guiObj.drawTexturedRect(guiWidth - 21, guiHeight + 142, 26 + 18*outputOrdinal, 0, 18, 18); - } - else { - guiObj.drawTexturedRect(guiWidth - 21, guiHeight + 142, 26 + 18*outputOrdinal, 18, 18, 18); - } + guiObj.drawTexturedRect(guiWidth - 26, guiHeight + 138, 0, 0, 26, 26); + int outputOrdinal = ((TileEntityLaserAmplifier) tileEntity).outputMode.ordinal(); - mc.renderEngine.bindTexture(defaultLocation); - } + if (xAxis >= -21 && xAxis <= -3 && yAxis >= 142 && yAxis <= 160) { + guiObj.drawTexturedRect( + guiWidth - 21, guiHeight + 142, 26 + 18 * outputOrdinal, 0, 18, 18 + ); + } else { + guiObj.drawTexturedRect( + guiWidth - 21, guiHeight + 142, 26 + 18 * outputOrdinal, 18, 18, 18 + ); + } - @Override - public void renderForeground(int xAxis, int yAxis) - { - mc.renderEngine.bindTexture(RESOURCE); + mc.renderEngine.bindTexture(defaultLocation); + } - if(xAxis >= -21 && xAxis <= -3 && yAxis >= 142 && yAxis <= 160) - { - String text = LangUtils.localize("gui.redstoneOutput") + ": "; - displayTooltip(text + ((TileEntityLaserAmplifier)tileEntity).outputMode.getName(), xAxis, yAxis); - } + @Override + public void renderForeground(int xAxis, int yAxis) { + mc.renderEngine.bindTexture(RESOURCE); - mc.renderEngine.bindTexture(defaultLocation); - } + if (xAxis >= -21 && xAxis <= -3 && yAxis >= 142 && yAxis <= 160) { + String text = LangUtils.localize("gui.redstoneOutput") + ": "; + displayTooltip( + text + ((TileEntityLaserAmplifier) tileEntity).outputMode.getName(), + xAxis, + yAxis + ); + } - @Override - public void preMouseClicked(int xAxis, int yAxis, int button) {} + mc.renderEngine.bindTexture(defaultLocation); + } - @Override - public void mouseClicked(int xAxis, int yAxis, int button) - { - if(button == 0) - { - if(xAxis >= -21 && xAxis <= -3 && yAxis >= 142 && yAxis <= 160) - { - ArrayList data = new ArrayList(); - data.add(3); - - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); + @Override + public void preMouseClicked(int xAxis, int yAxis, int button) {} + + @Override + public void mouseClicked(int xAxis, int yAxis, int button) { + if (button == 0) { + if (xAxis >= -21 && xAxis <= -3 && yAxis >= 142 && yAxis <= 160) { + ArrayList data = new ArrayList(); + data.add(3); + + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); SoundHandler.playSound("gui.button.press"); - } - } - } + } + } + } } diff --git a/src/main/java/mekanism/client/gui/element/GuiBoilerTab.java b/src/main/java/mekanism/client/gui/element/GuiBoilerTab.java index 24d2b24b8..5adcb0fb4 100644 --- a/src/main/java/mekanism/client/gui/element/GuiBoilerTab.java +++ b/src/main/java/mekanism/client/gui/element/GuiBoilerTab.java @@ -1,5 +1,8 @@ package mekanism.client.gui.element; +import codechicken.lib.vec.Rectangle4i; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.client.gui.IGuiWrapper; import mekanism.client.sound.SoundHandler; @@ -10,108 +13,93 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; -import codechicken.lib.vec.Rectangle4i; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiBoilerTab extends GuiElement -{ - private TileEntity tileEntity; - private BoilerTab tabType; - private int yPos; +public class GuiBoilerTab extends GuiElement { + private TileEntity tileEntity; + private BoilerTab tabType; + private int yPos; - public GuiBoilerTab(IGuiWrapper gui, TileEntity tile, BoilerTab type, int y, ResourceLocation def) - { - super(type.getResource(), gui, def); + public GuiBoilerTab( + IGuiWrapper gui, TileEntity tile, BoilerTab type, int y, ResourceLocation def + ) { + super(type.getResource(), gui, def); - tileEntity = tile; - tabType = type; - yPos = y; - } + tileEntity = tile; + tabType = type; + yPos = y; + } - @Override - public Rectangle4i getBounds(int guiWidth, int guiHeight) - { - return new Rectangle4i(guiWidth - 26, guiHeight + yPos, 26, 26); - } + @Override + public Rectangle4i getBounds(int guiWidth, int guiHeight) { + return new Rectangle4i(guiWidth - 26, guiHeight + yPos, 26, 26); + } - @Override - public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) - { - mc.renderEngine.bindTexture(RESOURCE); + @Override + public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) { + mc.renderEngine.bindTexture(RESOURCE); - guiObj.drawTexturedRect(guiWidth - 26, guiHeight + yPos, 0, 0, 26, 26); + guiObj.drawTexturedRect(guiWidth - 26, guiHeight + yPos, 0, 0, 26, 26); - if(xAxis >= -21 && xAxis <= -3 && yAxis >= yPos+4 && yAxis <= yPos+22) - { - guiObj.drawTexturedRect(guiWidth - 21, guiHeight + yPos+4, 26, 0, 18, 18); - } - else { - guiObj.drawTexturedRect(guiWidth - 21, guiHeight + yPos+4, 26, 18, 18, 18); - } + if (xAxis >= -21 && xAxis <= -3 && yAxis >= yPos + 4 && yAxis <= yPos + 22) { + guiObj.drawTexturedRect(guiWidth - 21, guiHeight + yPos + 4, 26, 0, 18, 18); + } else { + guiObj.drawTexturedRect(guiWidth - 21, guiHeight + yPos + 4, 26, 18, 18, 18); + } - mc.renderEngine.bindTexture(defaultLocation); - } + mc.renderEngine.bindTexture(defaultLocation); + } - @Override - public void renderForeground(int xAxis, int yAxis) - { - mc.renderEngine.bindTexture(RESOURCE); + @Override + public void renderForeground(int xAxis, int yAxis) { + mc.renderEngine.bindTexture(RESOURCE); - if(xAxis >= -21 && xAxis <= -3 && yAxis >= yPos+4 && yAxis <= yPos+22) - { - displayTooltip(tabType.getDesc(), xAxis, yAxis); - } + if (xAxis >= -21 && xAxis <= -3 && yAxis >= yPos + 4 && yAxis <= yPos + 22) { + displayTooltip(tabType.getDesc(), xAxis, yAxis); + } - mc.renderEngine.bindTexture(defaultLocation); - } + mc.renderEngine.bindTexture(defaultLocation); + } - @Override - public void preMouseClicked(int xAxis, int yAxis, int button) {} + @Override + public void preMouseClicked(int xAxis, int yAxis, int button) {} - @Override - public void mouseClicked(int xAxis, int yAxis, int button) - { - if(button == 0) - { - if(xAxis >= -21 && xAxis <= -3 && yAxis >= yPos+4 && yAxis <= yPos+22) - { - tabType.openGui(tileEntity); - SoundHandler.playSound("gui.button.press"); - } - } - } - - public static enum BoilerTab - { - MAIN("GuiGasesTab.png", 54, "gui.main"), - STAT("GuiStatsTab.png", 55, "gui.stats"); - - private String path; - private int guiId; - private String desc; - - private BoilerTab(String s, int id, String s1) - { - path = s; - guiId = id; - desc = s1; - } - - public ResourceLocation getResource() - { - return MekanismUtils.getResource(ResourceType.GUI_ELEMENT, path); - } - - public void openGui(TileEntity tile) - { - Mekanism.packetHandler.sendToServer(new SimpleGuiMessage(Coord4D.get(tile), 0, guiId)); - } - - public String getDesc() - { - return LangUtils.localize(desc); - } - } + @Override + public void mouseClicked(int xAxis, int yAxis, int button) { + if (button == 0) { + if (xAxis >= -21 && xAxis <= -3 && yAxis >= yPos + 4 && yAxis <= yPos + 22) { + tabType.openGui(tileEntity); + SoundHandler.playSound("gui.button.press"); + } + } + } + + public static enum BoilerTab { + MAIN("GuiGasesTab.png", 54, "gui.main"), + STAT("GuiStatsTab.png", 55, "gui.stats"); + + private String path; + private int guiId; + private String desc; + + private BoilerTab(String s, int id, String s1) { + path = s; + guiId = id; + desc = s1; + } + + public ResourceLocation getResource() { + return MekanismUtils.getResource(ResourceType.GUI_ELEMENT, path); + } + + public void openGui(TileEntity tile) { + Mekanism.packetHandler.sendToServer( + new SimpleGuiMessage(Coord4D.get(tile), 0, guiId) + ); + } + + public String getDesc() { + return LangUtils.localize(desc); + } + } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/gui/element/GuiBucketIO.java b/src/main/java/mekanism/client/gui/element/GuiBucketIO.java index 944479a79..6497dd784 100644 --- a/src/main/java/mekanism/client/gui/element/GuiBucketIO.java +++ b/src/main/java/mekanism/client/gui/element/GuiBucketIO.java @@ -1,60 +1,55 @@ package mekanism.client.gui.element; +import codechicken.lib.vec.Rectangle4i; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.gui.IGuiWrapper; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.util.ResourceLocation; -import codechicken.lib.vec.Rectangle4i; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiBucketIO extends GuiElement -{ - public GuiBucketIO(IGuiWrapper gui, ResourceLocation def) - { - super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiBucket.png"), gui, def); - } - - @Override - public Rectangle4i getBounds(int guiWidth, int guiHeight) - { - return new Rectangle4i(guiWidth + 176, guiHeight + 66, 26, 57); - } +public class GuiBucketIO extends GuiElement { + public GuiBucketIO(IGuiWrapper gui, ResourceLocation def) { + super( + MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiBucket.png"), gui, def + ); + } - @Override - public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) - { - mc.renderEngine.bindTexture(RESOURCE); + @Override + public Rectangle4i getBounds(int guiWidth, int guiHeight) { + return new Rectangle4i(guiWidth + 176, guiHeight + 66, 26, 57); + } - guiObj.drawTexturedRect(guiWidth + 176, guiHeight + 66, 0, 0, 26, 57); + @Override + public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) { + mc.renderEngine.bindTexture(RESOURCE); - mc.renderEngine.bindTexture(defaultLocation); - } + guiObj.drawTexturedRect(guiWidth + 176, guiHeight + 66, 0, 0, 26, 57); - @Override - public void renderForeground(int xAxis, int yAxis) - { - mc.renderEngine.bindTexture(RESOURCE); + mc.renderEngine.bindTexture(defaultLocation); + } - mc.renderEngine.bindTexture(defaultLocation); - } + @Override + public void renderForeground(int xAxis, int yAxis) { + mc.renderEngine.bindTexture(RESOURCE); - @Override - public void preMouseClicked(int xAxis, int yAxis, int button) - { - if((xAxis >= 180 && xAxis <= 196 && yAxis >= 71 && yAxis <= 87) || (xAxis >= 180 && xAxis <= 196 && yAxis >= 102 && yAxis <= 118)) - { - offsetX(26); - } - } + mc.renderEngine.bindTexture(defaultLocation); + } - @Override - public void mouseClicked(int xAxis, int yAxis, int button) - { - if((xAxis >= 180 && xAxis <= 196 && yAxis >= 71 && yAxis <= 87) || (xAxis >= 180 && xAxis <= 196 && yAxis >= 102 && yAxis <= 118)) - { - offsetX(-26); - } - } + @Override + public void preMouseClicked(int xAxis, int yAxis, int button) { + if ((xAxis >= 180 && xAxis <= 196 && yAxis >= 71 && yAxis <= 87) + || (xAxis >= 180 && xAxis <= 196 && yAxis >= 102 && yAxis <= 118)) { + offsetX(26); + } + } + + @Override + public void mouseClicked(int xAxis, int yAxis, int button) { + if ((xAxis >= 180 && xAxis <= 196 && yAxis >= 71 && yAxis <= 87) + || (xAxis >= 180 && xAxis <= 196 && yAxis >= 102 && yAxis <= 118)) { + offsetX(-26); + } + } } diff --git a/src/main/java/mekanism/client/gui/element/GuiConfigTypeTab.java b/src/main/java/mekanism/client/gui/element/GuiConfigTypeTab.java index 69aa43e87..c13f67929 100644 --- a/src/main/java/mekanism/client/gui/element/GuiConfigTypeTab.java +++ b/src/main/java/mekanism/client/gui/element/GuiConfigTypeTab.java @@ -1,5 +1,8 @@ package mekanism.client.gui.element; +import codechicken.lib.vec.Rectangle4i; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.transmitters.TransmissionType; import mekanism.client.gui.GuiSideConfiguration; import mekanism.client.gui.IGuiWrapper; @@ -8,115 +11,109 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; -import codechicken.lib.vec.Rectangle4i; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiConfigTypeTab extends GuiElement -{ - private TileEntity tileEntity; - public TransmissionType transmission; - - private int yPos; - - public boolean visible; - public boolean left; +public class GuiConfigTypeTab extends GuiElement { + private TileEntity tileEntity; + public TransmissionType transmission; - public GuiConfigTypeTab(IGuiWrapper gui, TileEntity tile, TransmissionType type, ResourceLocation def) - { - super(getResource(type), gui, def); + private int yPos; - tileEntity = tile; - transmission = type; - } - - private static ResourceLocation getResource(TransmissionType t) - { - return MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "Gui" + t.getTransmission() + "Tab.png"); - } - - public void setY(int y) - { - yPos = y; - } + public boolean visible; + public boolean left; - @Override - public Rectangle4i getBounds(int guiWidth, int guiHeight) - { - return new Rectangle4i(guiWidth + getLeftBound(false)-4, guiHeight + yPos, 26, 26); - } + public GuiConfigTypeTab( + IGuiWrapper gui, TileEntity tile, TransmissionType type, ResourceLocation def + ) { + super(getResource(type), gui, def); - @Override - public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) - { - if(!visible) - { - return; - } - - mc.renderEngine.bindTexture(RESOURCE); + tileEntity = tile; + transmission = type; + } - guiObj.drawTexturedRect(guiWidth + getLeftBound(false)-4, guiHeight + yPos, 0, left ? 0 : 26, 26, 26); + private static ResourceLocation getResource(TransmissionType t) { + return MekanismUtils.getResource( + ResourceType.GUI_ELEMENT, "Gui" + t.getTransmission() + "Tab.png" + ); + } - if(xAxis >= getLeftBound(true) && xAxis <= getRightBound(true) && yAxis >= yPos+4 && yAxis <= yPos+22) - { - guiObj.drawTexturedRect(guiWidth + getLeftBound(true), guiHeight + yPos+4, 26, 0, 18, 18); - } - else { - guiObj.drawTexturedRect(guiWidth + getLeftBound(true), guiHeight + yPos+4, 26, 18, 18, 18); - } + public void setY(int y) { + yPos = y; + } - mc.renderEngine.bindTexture(defaultLocation); - } + @Override + public Rectangle4i getBounds(int guiWidth, int guiHeight) { + return new Rectangle4i( + guiWidth + getLeftBound(false) - 4, guiHeight + yPos, 26, 26 + ); + } - @Override - public void renderForeground(int xAxis, int yAxis) - { - if(!visible) - { - return; - } - - mc.renderEngine.bindTexture(RESOURCE); + @Override + public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) { + if (!visible) { + return; + } - if(xAxis >= getLeftBound(true) && xAxis <= getRightBound(true) && yAxis >= yPos+4 && yAxis <= yPos+22) - { - displayTooltip(transmission.localize(), xAxis, yAxis); - } + mc.renderEngine.bindTexture(RESOURCE); - mc.renderEngine.bindTexture(defaultLocation); - } - - public int getLeftBound(boolean adjust) - { - return left ? -21+(adjust ? 1 : 0) : 179-(adjust ? 1 : 0); - } - - public int getRightBound(boolean adjust) - { - return left ? -3+(adjust ? 1 : 0) : 197-(adjust ? 1 : 0); - } + guiObj.drawTexturedRect( + guiWidth + getLeftBound(false) - 4, guiHeight + yPos, 0, left ? 0 : 26, 26, 26 + ); - @Override - public void preMouseClicked(int xAxis, int yAxis, int button) {} + if (xAxis >= getLeftBound(true) && xAxis <= getRightBound(true) + && yAxis >= yPos + 4 && yAxis <= yPos + 22) { + guiObj.drawTexturedRect( + guiWidth + getLeftBound(true), guiHeight + yPos + 4, 26, 0, 18, 18 + ); + } else { + guiObj.drawTexturedRect( + guiWidth + getLeftBound(true), guiHeight + yPos + 4, 26, 18, 18, 18 + ); + } - @Override - public void mouseClicked(int xAxis, int yAxis, int button) - { - if(!visible) - { - return; - } - - if(button == 0) - { - if(xAxis >= getLeftBound(true) && xAxis <= getRightBound(true) && yAxis >= yPos+4 && yAxis <= yPos+22) - { - ((GuiSideConfiguration)guiObj).currentType = transmission; - ((GuiSideConfiguration)guiObj).updateTabs(); - SoundHandler.playSound("gui.button.press"); - } - } - } + mc.renderEngine.bindTexture(defaultLocation); + } + + @Override + public void renderForeground(int xAxis, int yAxis) { + if (!visible) { + return; + } + + mc.renderEngine.bindTexture(RESOURCE); + + if (xAxis >= getLeftBound(true) && xAxis <= getRightBound(true) + && yAxis >= yPos + 4 && yAxis <= yPos + 22) { + displayTooltip(transmission.localize(), xAxis, yAxis); + } + + mc.renderEngine.bindTexture(defaultLocation); + } + + public int getLeftBound(boolean adjust) { + return left ? -21 + (adjust ? 1 : 0) : 179 - (adjust ? 1 : 0); + } + + public int getRightBound(boolean adjust) { + return left ? -3 + (adjust ? 1 : 0) : 197 - (adjust ? 1 : 0); + } + + @Override + public void preMouseClicked(int xAxis, int yAxis, int button) {} + + @Override + public void mouseClicked(int xAxis, int yAxis, int button) { + if (!visible) { + return; + } + + if (button == 0) { + if (xAxis >= getLeftBound(true) && xAxis <= getRightBound(true) + && yAxis >= yPos + 4 && yAxis <= yPos + 22) { + ((GuiSideConfiguration) guiObj).currentType = transmission; + ((GuiSideConfiguration) guiObj).updateTabs(); + SoundHandler.playSound("gui.button.press"); + } + } + } } diff --git a/src/main/java/mekanism/client/gui/element/GuiContainerEditMode.java b/src/main/java/mekanism/client/gui/element/GuiContainerEditMode.java index b265d4c7a..66419d108 100644 --- a/src/main/java/mekanism/client/gui/element/GuiContainerEditMode.java +++ b/src/main/java/mekanism/client/gui/element/GuiContainerEditMode.java @@ -1,5 +1,8 @@ package mekanism.client.gui.element; +import codechicken.lib.vec.Rectangle4i; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.client.gui.IGuiWrapper; import mekanism.client.sound.SoundHandler; @@ -11,82 +14,79 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; -import codechicken.lib.vec.Rectangle4i; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiContainerEditMode extends GuiElement -{ - public TileEntity tileEntity; +public class GuiContainerEditMode extends GuiElement { + public TileEntity tileEntity; - public GuiContainerEditMode(IGuiWrapper gui, TileEntity tile, ResourceLocation def) - { - super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiContainerEditMode.png"), gui, def); + public GuiContainerEditMode(IGuiWrapper gui, TileEntity tile, ResourceLocation def) { + super( + MekanismUtils.getResource( + ResourceType.GUI_ELEMENT, "GuiContainerEditMode.png" + ), + gui, + def + ); - tileEntity = tile; - } - - @Override - public Rectangle4i getBounds(int guiWidth, int guiHeight) - { - return new Rectangle4i(guiWidth + 176, guiHeight + 138, 26, 26); - } + tileEntity = tile; + } - @Override - public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) - { - mc.renderEngine.bindTexture(RESOURCE); + @Override + public Rectangle4i getBounds(int guiWidth, int guiHeight) { + return new Rectangle4i(guiWidth + 176, guiHeight + 138, 26, 26); + } - guiObj.drawTexturedRect(guiWidth + 176, guiHeight + 138, 0, 0, 26, 26); + @Override + public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) { + mc.renderEngine.bindTexture(RESOURCE); - IFluidContainerManager control = (IFluidContainerManager)tileEntity; - int renderX = 26 + (18*control.getContainerEditMode().ordinal()); + guiObj.drawTexturedRect(guiWidth + 176, guiHeight + 138, 0, 0, 26, 26); - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 142 && yAxis <= 160) - { - guiObj.drawTexturedRect(guiWidth + 179, guiHeight + 142, renderX, 0, 18, 18); - } - else { - guiObj.drawTexturedRect(guiWidth + 179, guiHeight + 142, renderX, 18, 18, 18); - } + IFluidContainerManager control = (IFluidContainerManager) tileEntity; + int renderX = 26 + (18 * control.getContainerEditMode().ordinal()); - mc.renderEngine.bindTexture(defaultLocation); - } + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 142 && yAxis <= 160) { + guiObj.drawTexturedRect(guiWidth + 179, guiHeight + 142, renderX, 0, 18, 18); + } else { + guiObj.drawTexturedRect(guiWidth + 179, guiHeight + 142, renderX, 18, 18, 18); + } - @Override - public void renderForeground(int xAxis, int yAxis) - { - mc.renderEngine.bindTexture(RESOURCE); + mc.renderEngine.bindTexture(defaultLocation); + } - IFluidContainerManager manager = (IFluidContainerManager)tileEntity; + @Override + public void renderForeground(int xAxis, int yAxis) { + mc.renderEngine.bindTexture(RESOURCE); - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 142 && yAxis <= 160) - { - displayTooltip(manager.getContainerEditMode().getDisplay(), xAxis, yAxis); - } + IFluidContainerManager manager = (IFluidContainerManager) tileEntity; - mc.renderEngine.bindTexture(defaultLocation); - } + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 142 && yAxis <= 160) { + displayTooltip(manager.getContainerEditMode().getDisplay(), xAxis, yAxis); + } - @Override - public void preMouseClicked(int xAxis, int yAxis, int button) {} + mc.renderEngine.bindTexture(defaultLocation); + } - @Override - public void mouseClicked(int xAxis, int yAxis, int button) - { - IFluidContainerManager manager = (IFluidContainerManager)tileEntity; + @Override + public void preMouseClicked(int xAxis, int yAxis, int button) {} - if(button == 0) - { - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 142 && yAxis <= 160) - { - ContainerEditMode current = manager.getContainerEditMode(); - int ordinalToSet = current.ordinal() < (ContainerEditMode.values().length-1) ? current.ordinal()+1 : 0; + @Override + public void mouseClicked(int xAxis, int yAxis, int button) { + IFluidContainerManager manager = (IFluidContainerManager) tileEntity; - SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new ContainerEditModeMessage(Coord4D.get(tileEntity), ContainerEditMode.values()[ordinalToSet])); - } - } - } + if (button == 0) { + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 142 && yAxis <= 160) { + ContainerEditMode current = manager.getContainerEditMode(); + int ordinalToSet + = current.ordinal() < (ContainerEditMode.values().length - 1) + ? current.ordinal() + 1 + : 0; + + SoundHandler.playSound("gui.button.press"); + Mekanism.packetHandler.sendToServer(new ContainerEditModeMessage( + Coord4D.get(tileEntity), ContainerEditMode.values()[ordinalToSet] + )); + } + } + } } diff --git a/src/main/java/mekanism/client/gui/element/GuiElement.java b/src/main/java/mekanism/client/gui/element/GuiElement.java index af0c0d74a..244d814a6 100644 --- a/src/main/java/mekanism/client/gui/element/GuiElement.java +++ b/src/main/java/mekanism/client/gui/element/GuiElement.java @@ -2,6 +2,9 @@ package mekanism.client.gui.element; import java.util.List; +import codechicken.lib.vec.Rectangle4i; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.gui.IGuiWrapper; import mekanism.common.ObfuscatedNames; import mekanism.common.util.MekanismUtils; @@ -9,137 +12,146 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; -import codechicken.lib.vec.Rectangle4i; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public abstract class GuiElement -{ - public static Minecraft mc = Minecraft.getMinecraft(); +public abstract class GuiElement { + public static Minecraft mc = Minecraft.getMinecraft(); - public ResourceLocation RESOURCE; + public ResourceLocation RESOURCE; - public IGuiWrapper guiObj; + public IGuiWrapper guiObj; - public ResourceLocation defaultLocation; + public ResourceLocation defaultLocation; - public GuiElement(ResourceLocation resource, IGuiWrapper gui, ResourceLocation def) - { - RESOURCE = resource; - guiObj = gui; - defaultLocation = def; - } + public GuiElement(ResourceLocation resource, IGuiWrapper gui, ResourceLocation def) { + RESOURCE = resource; + guiObj = gui; + defaultLocation = def; + } - public void displayTooltip(String s, int xAxis, int yAxis) - { - guiObj.displayTooltip(s, xAxis, yAxis); - } + public void displayTooltip(String s, int xAxis, int yAxis) { + guiObj.displayTooltip(s, xAxis, yAxis); + } - public void displayTooltips(List list, int xAxis, int yAxis) - { - guiObj.displayTooltips(list, xAxis, yAxis); - } + public void displayTooltips(List list, int xAxis, int yAxis) { + guiObj.displayTooltips(list, xAxis, yAxis); + } - public void offsetX(int xSize) - { - if(guiObj instanceof GuiContainer) - { - try { - int size = (Integer)MekanismUtils.getPrivateValue(guiObj, GuiContainer.class, ObfuscatedNames.GuiContainer_xSize); - MekanismUtils.setPrivateValue(guiObj, size + xSize, GuiContainer.class, ObfuscatedNames.GuiContainer_xSize); - } catch(Exception e) { - e.printStackTrace(); - } - } - } + public void offsetX(int xSize) { + if (guiObj instanceof GuiContainer) { + try { + int size = (Integer) MekanismUtils.getPrivateValue( + guiObj, GuiContainer.class, ObfuscatedNames.GuiContainer_xSize + ); + MekanismUtils.setPrivateValue( + guiObj, + size + xSize, + GuiContainer.class, + ObfuscatedNames.GuiContainer_xSize + ); + } catch (Exception e) { + e.printStackTrace(); + } + } + } - public void offsetY(int ySize) - { - if(guiObj instanceof GuiContainer) - { - try { - int size = (Integer)MekanismUtils.getPrivateValue(guiObj, GuiContainer.class, ObfuscatedNames.GuiContainer_ySize); - MekanismUtils.setPrivateValue(guiObj, size + ySize, GuiContainer.class, ObfuscatedNames.GuiContainer_ySize); - } catch(Exception e) { - e.printStackTrace(); - } - } - } - - public void offsetLeft(int guiLeft) - { - if(guiObj instanceof GuiContainer) - { - try { - int left = (Integer)MekanismUtils.getPrivateValue(guiObj, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); - System.out.println(left + " " + guiLeft); - MekanismUtils.setPrivateValue(guiObj, left + guiLeft, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); - } catch(Exception e) { - e.printStackTrace(); - } - } - } - - public void offsetTop(int guiTop) - { - if(guiObj instanceof GuiContainer) - { - try { - int top = (Integer)MekanismUtils.getPrivateValue(guiObj, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); - MekanismUtils.setPrivateValue(guiObj, top + guiTop, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); - } catch(Exception e) { - e.printStackTrace(); - } - } - } - - public void renderScaledText(String text, int x, int y, int color, int maxX) - { - int length = getFontRenderer().getStringWidth(text); - - if(length <= maxX) - { - getFontRenderer().drawString(text, x, y, color); - } - else { - float scale = (float)maxX/length; - float reverse = 1/scale; - float yAdd = 4-(scale*8)/2F; - - GL11.glPushMatrix(); - - GL11.glScalef(scale, scale, scale); - getFontRenderer().drawString(text, (int)(x*reverse), (int)((y*reverse)+yAdd), color); - - GL11.glPopMatrix(); - } - } + public void offsetY(int ySize) { + if (guiObj instanceof GuiContainer) { + try { + int size = (Integer) MekanismUtils.getPrivateValue( + guiObj, GuiContainer.class, ObfuscatedNames.GuiContainer_ySize + ); + MekanismUtils.setPrivateValue( + guiObj, + size + ySize, + GuiContainer.class, + ObfuscatedNames.GuiContainer_ySize + ); + } catch (Exception e) { + e.printStackTrace(); + } + } + } - public FontRenderer getFontRenderer() - { - return guiObj.getFont(); - } - - public void mouseClickMove(int mouseX, int mouseY, int button, long ticks) {} + public void offsetLeft(int guiLeft) { + if (guiObj instanceof GuiContainer) { + try { + int left = (Integer) MekanismUtils.getPrivateValue( + guiObj, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft + ); + System.out.println(left + " " + guiLeft); + MekanismUtils.setPrivateValue( + guiObj, + left + guiLeft, + GuiContainer.class, + ObfuscatedNames.GuiContainer_guiLeft + ); + } catch (Exception e) { + e.printStackTrace(); + } + } + } - public void mouseMovedOrUp(int x, int y, int type) {} - - public abstract Rectangle4i getBounds(int guiWidth, int guiHeight); + public void offsetTop(int guiTop) { + if (guiObj instanceof GuiContainer) { + try { + int top = (Integer) MekanismUtils.getPrivateValue( + guiObj, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop + ); + MekanismUtils.setPrivateValue( + guiObj, + top + guiTop, + GuiContainer.class, + ObfuscatedNames.GuiContainer_guiTop + ); + } catch (Exception e) { + e.printStackTrace(); + } + } + } - public abstract void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight); + public void renderScaledText(String text, int x, int y, int color, int maxX) { + int length = getFontRenderer().getStringWidth(text); - public abstract void renderForeground(int xAxis, int yAxis); + if (length <= maxX) { + getFontRenderer().drawString(text, x, y, color); + } else { + float scale = (float) maxX / length; + float reverse = 1 / scale; + float yAdd = 4 - (scale * 8) / 2F; - public abstract void preMouseClicked(int xAxis, int yAxis, int button); + GL11.glPushMatrix(); - public abstract void mouseClicked(int xAxis, int yAxis, int button); - - public static interface IInfoHandler - { - public List getInfo(); - } + GL11.glScalef(scale, scale, scale); + getFontRenderer().drawString( + text, (int) (x * reverse), (int) ((y * reverse) + yAdd), color + ); + + GL11.glPopMatrix(); + } + } + + public FontRenderer getFontRenderer() { + return guiObj.getFont(); + } + + public void mouseClickMove(int mouseX, int mouseY, int button, long ticks) {} + + public void mouseMovedOrUp(int x, int y, int type) {} + + public abstract Rectangle4i getBounds(int guiWidth, int guiHeight); + + public abstract void + renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight); + + public abstract void renderForeground(int xAxis, int yAxis); + + public abstract void preMouseClicked(int xAxis, int yAxis, int button); + + public abstract void mouseClicked(int xAxis, int yAxis, int button); + + public static interface IInfoHandler { + public List getInfo(); + } } diff --git a/src/main/java/mekanism/client/gui/element/GuiEnergyGauge.java b/src/main/java/mekanism/client/gui/element/GuiEnergyGauge.java index 53a388f3d..9022cf602 100644 --- a/src/main/java/mekanism/client/gui/element/GuiEnergyGauge.java +++ b/src/main/java/mekanism/client/gui/element/GuiEnergyGauge.java @@ -1,5 +1,6 @@ package mekanism.client.gui.element; +import codechicken.lib.vec.Rectangle4i; import mekanism.api.energy.IStrictEnergyStorage; import mekanism.api.transmitters.TransmissionType; import mekanism.client.gui.IGuiWrapper; @@ -8,56 +9,57 @@ import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; -import codechicken.lib.vec.Rectangle4i; -public class GuiEnergyGauge extends GuiGauge -{ - IEnergyInfoHandler infoHandler; +public class GuiEnergyGauge extends GuiGauge { + IEnergyInfoHandler infoHandler; - public GuiEnergyGauge(IEnergyInfoHandler handler, Type type, IGuiWrapper gui, ResourceLocation def, int x, int y) - { - super(type, gui, def, x, y); + public GuiEnergyGauge( + IEnergyInfoHandler handler, + Type type, + IGuiWrapper gui, + ResourceLocation def, + int x, + int y + ) { + super(type, gui, def, x, y); - infoHandler = handler; - } - - @Override - public Rectangle4i getBounds(int guiWidth, int guiHeight) - { - return new Rectangle4i(guiWidth - 26, guiHeight + 6, 26, 26); - } - - @Override - public TransmissionType getTransmission() - { - return TransmissionType.ENERGY; - } + infoHandler = handler; + } - @Override - public int getScaledLevel() - { - if(infoHandler.getEnergyStorage().getEnergy() == Double.MAX_VALUE) - { - return height-2; - } - - return (int)(infoHandler.getEnergyStorage().getEnergy()*(height-2) / infoHandler.getEnergyStorage().getMaxEnergy()); - } + @Override + public Rectangle4i getBounds(int guiWidth, int guiHeight) { + return new Rectangle4i(guiWidth - 26, guiHeight + 6, 26, 26); + } - @Override - public IIcon getIcon() - { - return MekanismRenderer.energyIcon; - } + @Override + public TransmissionType getTransmission() { + return TransmissionType.ENERGY; + } - @Override - public String getTooltipText() - { - return infoHandler.getEnergyStorage().getEnergy() > 0 ? MekanismUtils.getEnergyDisplay(infoHandler.getEnergyStorage().getEnergy()) : LangUtils.localize("gui.empty"); - } + @Override + public int getScaledLevel() { + if (infoHandler.getEnergyStorage().getEnergy() == Double.MAX_VALUE) { + return height - 2; + } - public static interface IEnergyInfoHandler - { - public IStrictEnergyStorage getEnergyStorage(); - } + return (int + ) (infoHandler.getEnergyStorage().getEnergy() * (height - 2) + / infoHandler.getEnergyStorage().getMaxEnergy()); + } + + @Override + public IIcon getIcon() { + return MekanismRenderer.energyIcon; + } + + @Override + public String getTooltipText() { + return infoHandler.getEnergyStorage().getEnergy() > 0 + ? MekanismUtils.getEnergyDisplay(infoHandler.getEnergyStorage().getEnergy()) + : LangUtils.localize("gui.empty"); + } + + public static interface IEnergyInfoHandler { + public IStrictEnergyStorage getEnergyStorage(); + } } diff --git a/src/main/java/mekanism/client/gui/element/GuiEnergyInfo.java b/src/main/java/mekanism/client/gui/element/GuiEnergyInfo.java index c734f0e2a..45ad4d449 100644 --- a/src/main/java/mekanism/client/gui/element/GuiEnergyInfo.java +++ b/src/main/java/mekanism/client/gui/element/GuiEnergyInfo.java @@ -3,6 +3,9 @@ package mekanism.client.gui.element; import java.util.ArrayList; import java.util.List; +import codechicken.lib.vec.Rectangle4i; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.MekanismConfig.general; import mekanism.api.util.UnitDisplayUtils.EnergyType; import mekanism.client.gui.IGuiWrapper; @@ -10,67 +13,59 @@ import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.util.ResourceLocation; -import codechicken.lib.vec.Rectangle4i; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiEnergyInfo extends GuiElement -{ - public IInfoHandler infoHandler; +public class GuiEnergyInfo extends GuiElement { + public IInfoHandler infoHandler; - public GuiEnergyInfo(IInfoHandler handler, IGuiWrapper gui, ResourceLocation def) - { - super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiEnergyInfo.png"), gui, def); + public GuiEnergyInfo(IInfoHandler handler, IGuiWrapper gui, ResourceLocation def) { + super( + MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiEnergyInfo.png"), + gui, + def + ); - infoHandler = handler; - } - - @Override - public Rectangle4i getBounds(int guiWidth, int guiHeight) - { - return new Rectangle4i(guiWidth - 26, guiHeight + 138, 26, 26); - } + infoHandler = handler; + } - @Override - public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) - { - mc.renderEngine.bindTexture(RESOURCE); + @Override + public Rectangle4i getBounds(int guiWidth, int guiHeight) { + return new Rectangle4i(guiWidth - 26, guiHeight + 138, 26, 26); + } - guiObj.drawTexturedRect(guiWidth - 26, guiHeight + 138, 0, 0, 26, 26); + @Override + public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) { + mc.renderEngine.bindTexture(RESOURCE); - mc.renderEngine.bindTexture(defaultLocation); - } + guiObj.drawTexturedRect(guiWidth - 26, guiHeight + 138, 0, 0, 26, 26); - @Override - public void renderForeground(int xAxis, int yAxis) - { - if(xAxis >= -21 && xAxis <= -3 && yAxis >= 142 && yAxis <= 160) - { - List info = new ArrayList(); - - for(String s : infoHandler.getInfo()) - { - info.add(s); - } - - info.add(LangUtils.localize("gui.unit") + ": " + general.energyUnit); - displayTooltips(info, xAxis, yAxis); - } - } + mc.renderEngine.bindTexture(defaultLocation); + } - @Override - public void preMouseClicked(int xAxis, int yAxis, int button) {} + @Override + public void renderForeground(int xAxis, int yAxis) { + if (xAxis >= -21 && xAxis <= -3 && yAxis >= 142 && yAxis <= 160) { + List info = new ArrayList(); - @Override - public void mouseClicked(int xAxis, int yAxis, int button) - { - if(button == 0) - { - if(xAxis >= -21 && xAxis <= -3 && yAxis >= 142 && yAxis <= 160) - { - general.energyUnit = EnergyType.values()[(general.energyUnit.ordinal()+1)%EnergyType.values().length]; - } - } - } + for (String s : infoHandler.getInfo()) { + info.add(s); + } + + info.add(LangUtils.localize("gui.unit") + ": " + general.energyUnit); + displayTooltips(info, xAxis, yAxis); + } + } + + @Override + public void preMouseClicked(int xAxis, int yAxis, int button) {} + + @Override + public void mouseClicked(int xAxis, int yAxis, int button) { + if (button == 0) { + if (xAxis >= -21 && xAxis <= -3 && yAxis >= 142 && yAxis <= 160) { + general.energyUnit = EnergyType.values( + )[(general.energyUnit.ordinal() + 1) % EnergyType.values().length]; + } + } + } } diff --git a/src/main/java/mekanism/client/gui/element/GuiFluidGauge.java b/src/main/java/mekanism/client/gui/element/GuiFluidGauge.java index 51ef948eb..133982048 100644 --- a/src/main/java/mekanism/client/gui/element/GuiFluidGauge.java +++ b/src/main/java/mekanism/client/gui/element/GuiFluidGauge.java @@ -17,103 +17,103 @@ import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidTank; - import org.lwjgl.input.Keyboard; -public class GuiFluidGauge extends GuiGauge -{ - IFluidInfoHandler infoHandler; +public class GuiFluidGauge extends GuiGauge { + IFluidInfoHandler infoHandler; - public GuiFluidGauge(IFluidInfoHandler handler, Type type, IGuiWrapper gui, ResourceLocation def, int x, int y) - { - super(type, gui, def, x, y); + public GuiFluidGauge( + IFluidInfoHandler handler, + Type type, + IGuiWrapper gui, + ResourceLocation def, + int x, + int y + ) { + super(type, gui, def, x, y); - infoHandler = handler; - } - - public static GuiFluidGauge getDummy(Type type, IGuiWrapper gui, ResourceLocation def, int x, int y) - { - GuiFluidGauge gauge = new GuiFluidGauge(null, type, gui, def, x, y); - gauge.dummy = true; - - return gauge; - } - - @Override - public TransmissionType getTransmission() - { - return TransmissionType.FLUID; - } - - @Override - public void mouseClicked(int xAxis, int yAxis, int button) - { - if(xAxis >= xLocation + 1 && xAxis <= xLocation + width - 1 && yAxis >= yLocation + 1 && yAxis <= yLocation + height - 1) - { - ItemStack stack = mc.thePlayer.inventory.getItemStack(); - - if(guiObj instanceof GuiMekanism && stack != null && stack.getItem() instanceof ItemGaugeDropper) - { - TileEntity tile = ((GuiMekanism)guiObj).getTileEntity(); - - if(tile instanceof ITankManager && ((ITankManager)tile).getTanks() != null) - { - int index = Arrays.asList(((ITankManager)tile).getTanks()).indexOf(infoHandler.getTank()); - - if(index != -1) - { - if(button == 0 && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) - { - button = 2; - } - - Mekanism.packetHandler.sendToServer(new DropperUseMessage(Coord4D.get(tile), button, index)); - } - } - } - } - } + infoHandler = handler; + } - @Override - public int getScaledLevel() - { - if(dummy) - { - return height-2; - } + public static GuiFluidGauge + getDummy(Type type, IGuiWrapper gui, ResourceLocation def, int x, int y) { + GuiFluidGauge gauge = new GuiFluidGauge(null, type, gui, def, x, y); + gauge.dummy = true; - if(infoHandler.getTank().getFluid() == null || infoHandler.getTank().getCapacity() == 0) - { + return gauge; + } + + @Override + public TransmissionType getTransmission() { + return TransmissionType.FLUID; + } + + @Override + public void mouseClicked(int xAxis, int yAxis, int button) { + if (xAxis >= xLocation + 1 && xAxis <= xLocation + width - 1 + && yAxis >= yLocation + 1 && yAxis <= yLocation + height - 1) { + ItemStack stack = mc.thePlayer.inventory.getItemStack(); + + if (guiObj instanceof GuiMekanism && stack != null + && stack.getItem() instanceof ItemGaugeDropper) { + TileEntity tile = ((GuiMekanism) guiObj).getTileEntity(); + + if (tile instanceof ITankManager + && ((ITankManager) tile).getTanks() != null) { + int index = Arrays.asList(((ITankManager) tile).getTanks()) + .indexOf(infoHandler.getTank()); + + if (index != -1) { + if (button == 0 && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + button = 2; + } + + Mekanism.packetHandler.sendToServer( + new DropperUseMessage(Coord4D.get(tile), button, index) + ); + } + } + } + } + } + + @Override + public int getScaledLevel() { + if (dummy) { + return height - 2; + } + + if (infoHandler.getTank().getFluid() == null + || infoHandler.getTank().getCapacity() == 0) { return 0; } - - return infoHandler.getTank().getFluidAmount()*(height-2) / infoHandler.getTank().getCapacity(); - } - @Override - public IIcon getIcon() - { - if(dummy) - { - return dummyType.getIcon(); - } - - return infoHandler.getTank().getFluid().getFluid().getIcon(); - } + return infoHandler.getTank().getFluidAmount() * (height - 2) + / infoHandler.getTank().getCapacity(); + } - @Override - public String getTooltipText() - { - if(dummy) - { - return dummyType.getLocalizedName(null); - } - - return infoHandler.getTank().getFluid() != null ? LangUtils.localizeFluidStack(infoHandler.getTank().getFluid()) + ": " + infoHandler.getTank().getFluidAmount() + "mB" : LangUtils.localize("gui.empty"); - } + @Override + public IIcon getIcon() { + if (dummy) { + return dummyType.getIcon(); + } - public static interface IFluidInfoHandler - { - public FluidTank getTank(); - } + return infoHandler.getTank().getFluid().getFluid().getIcon(); + } + + @Override + public String getTooltipText() { + if (dummy) { + return dummyType.getLocalizedName(null); + } + + return infoHandler.getTank().getFluid() != null + ? LangUtils.localizeFluidStack(infoHandler.getTank().getFluid()) + ": " + + infoHandler.getTank().getFluidAmount() + "mB" + : LangUtils.localize("gui.empty"); + } + + public static interface IFluidInfoHandler { + public FluidTank getTank(); + } } diff --git a/src/main/java/mekanism/client/gui/element/GuiGasGauge.java b/src/main/java/mekanism/client/gui/element/GuiGasGauge.java index 939edaaa1..ac680d9d9 100644 --- a/src/main/java/mekanism/client/gui/element/GuiGasGauge.java +++ b/src/main/java/mekanism/client/gui/element/GuiGasGauge.java @@ -17,103 +17,106 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; - import org.lwjgl.input.Keyboard; -public class GuiGasGauge extends GuiGauge -{ - IGasInfoHandler infoHandler; +public class GuiGasGauge extends GuiGauge { + IGasInfoHandler infoHandler; - public GuiGasGauge(IGasInfoHandler handler, Type type, IGuiWrapper gui, ResourceLocation def, int x, int y) - { - super(type, gui, def, x, y); + public GuiGasGauge( + IGasInfoHandler handler, + Type type, + IGuiWrapper gui, + ResourceLocation def, + int x, + int y + ) { + super(type, gui, def, x, y); - infoHandler = handler; - } - - public static GuiGasGauge getDummy(Type type, IGuiWrapper gui, ResourceLocation def, int x, int y) - { - GuiGasGauge gauge = new GuiGasGauge(null, type, gui, def, x, y); - gauge.dummy = true; - - return gauge; - } - - @Override - public TransmissionType getTransmission() - { - return TransmissionType.GAS; - } - - @Override - public void mouseClicked(int xAxis, int yAxis, int button) - { - if(xAxis >= xLocation + 1 && xAxis <= xLocation + width - 1 && yAxis >= yLocation + 1 && yAxis <= yLocation + height - 1) - { - ItemStack stack = mc.thePlayer.inventory.getItemStack(); - - if(guiObj instanceof GuiMekanism && stack != null && stack.getItem() instanceof ItemGaugeDropper) - { - TileEntity tile = ((GuiMekanism)guiObj).getTileEntity(); - - if(tile instanceof ITankManager && ((ITankManager)tile).getTanks() != null) - { - int index = Arrays.asList(((ITankManager)tile).getTanks()).indexOf(infoHandler.getTank()); - - if(index != -1) - { - if(button == 0 && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) - { - button = 2; - } - - Mekanism.packetHandler.sendToServer(new DropperUseMessage(Coord4D.get(tile), button, index)); - } - } - } - } - } + infoHandler = handler; + } - @Override - public int getScaledLevel() - { - if(dummy) - { - return height-2; - } + public static GuiGasGauge + getDummy(Type type, IGuiWrapper gui, ResourceLocation def, int x, int y) { + GuiGasGauge gauge = new GuiGasGauge(null, type, gui, def, x, y); + gauge.dummy = true; - if(infoHandler.getTank().getGas() == null || infoHandler.getTank().getMaxGas() == 0) - { + return gauge; + } + + @Override + public TransmissionType getTransmission() { + return TransmissionType.GAS; + } + + @Override + public void mouseClicked(int xAxis, int yAxis, int button) { + if (xAxis >= xLocation + 1 && xAxis <= xLocation + width - 1 + && yAxis >= yLocation + 1 && yAxis <= yLocation + height - 1) { + ItemStack stack = mc.thePlayer.inventory.getItemStack(); + + if (guiObj instanceof GuiMekanism && stack != null + && stack.getItem() instanceof ItemGaugeDropper) { + TileEntity tile = ((GuiMekanism) guiObj).getTileEntity(); + + if (tile instanceof ITankManager + && ((ITankManager) tile).getTanks() != null) { + int index = Arrays.asList(((ITankManager) tile).getTanks()) + .indexOf(infoHandler.getTank()); + + if (index != -1) { + if (button == 0 && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + button = 2; + } + + Mekanism.packetHandler.sendToServer( + new DropperUseMessage(Coord4D.get(tile), button, index) + ); + } + } + } + } + } + + @Override + public int getScaledLevel() { + if (dummy) { + return height - 2; + } + + if (infoHandler.getTank().getGas() == null + || infoHandler.getTank().getMaxGas() == 0) { return 0; } - - return infoHandler.getTank().getStored()*(height-2) / infoHandler.getTank().getMaxGas(); - } - @Override - public IIcon getIcon() - { - if(dummy) - { - return dummyType.getIcon(); - } - - return (infoHandler.getTank() != null && infoHandler.getTank().getGas() != null && infoHandler.getTank().getGas().getGas() != null) ? infoHandler.getTank().getGas().getGas().getIcon() : null; - } + return infoHandler.getTank().getStored() * (height - 2) + / infoHandler.getTank().getMaxGas(); + } - @Override - public String getTooltipText() - { - if(dummy) - { - return dummyType.getLocalizedName(); - } - - return (infoHandler.getTank().getGas() != null) ? infoHandler.getTank().getGas().getGas().getLocalizedName() + ": " + infoHandler.getTank().getStored() : LangUtils.localize("gui.empty"); - } + @Override + public IIcon getIcon() { + if (dummy) { + return dummyType.getIcon(); + } - public static interface IGasInfoHandler - { - public GasTank getTank(); - } + return (infoHandler.getTank() != null && infoHandler.getTank().getGas() != null + && infoHandler.getTank().getGas().getGas() != null) + ? infoHandler.getTank().getGas().getGas().getIcon() + : null; + } + + @Override + public String getTooltipText() { + if (dummy) { + return dummyType.getLocalizedName(); + } + + return (infoHandler.getTank().getGas() != null) + ? infoHandler.getTank().getGas().getGas().getLocalizedName() + ": " + + infoHandler.getTank().getStored() + : LangUtils.localize("gui.empty"); + } + + public static interface IGasInfoHandler { + public GasTank getTank(); + } } diff --git a/src/main/java/mekanism/client/gui/element/GuiGauge.java b/src/main/java/mekanism/client/gui/element/GuiGauge.java index 7d43268ae..387aa2f74 100644 --- a/src/main/java/mekanism/client/gui/element/GuiGauge.java +++ b/src/main/java/mekanism/client/gui/element/GuiGauge.java @@ -1,5 +1,6 @@ package mekanism.client.gui.element; +import codechicken.lib.vec.Rectangle4i; import mekanism.api.EnumColor; import mekanism.api.transmitters.TransmissionType; import mekanism.client.gui.GuiMekanism; @@ -14,203 +15,200 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; -import codechicken.lib.vec.Rectangle4i; -public abstract class GuiGauge extends GuiElement -{ - protected int xLocation; - protected int yLocation; - - protected int texX; - protected int texY; +public abstract class GuiGauge extends GuiElement { + protected int xLocation; + protected int yLocation; - protected int width; - protected int height; + protected int texX; + protected int texY; - public EnumColor color; - protected int number; - protected boolean dummy; - - protected T dummyType; - - public GuiGauge(Type type, IGuiWrapper gui, ResourceLocation def, int x, int y) - { - super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, type.textureLocation), gui, def); + protected int width; + protected int height; - xLocation = x; - yLocation = y; + public EnumColor color; + protected int number; + protected boolean dummy; - width = type.width; - height = type.height; - - texX = type.texX; - texY = type.texY; - - color = type.color; - number = type.number; - } + protected T dummyType; - public abstract int getScaledLevel(); + public GuiGauge(Type type, IGuiWrapper gui, ResourceLocation def, int x, int y) { + super( + MekanismUtils.getResource(ResourceType.GUI_ELEMENT, type.textureLocation), + gui, + def + ); - public abstract IIcon getIcon(); + xLocation = x; + yLocation = y; - public abstract String getTooltipText(); + width = type.width; + height = type.height; - @Override - public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) - { - mc.renderEngine.bindTexture(RESOURCE); + texX = type.texX; + texY = type.texY; - guiObj.drawTexturedRect(guiWidth + xLocation, guiHeight + yLocation, texX, texY, width, height); - - if(!dummy) - { - renderScale(xAxis, yAxis, guiWidth, guiHeight); - } + color = type.color; + number = type.number; + } - mc.renderEngine.bindTexture(defaultLocation); - } - - public void renderScale(int xAxis, int yAxis, int guiWidth, int guiHeight) - { - if(getScaledLevel() == 0 || getIcon() == null) - { - guiObj.drawTexturedRect(guiWidth + xLocation, guiHeight + yLocation, width, 0, width, height); - return; - } - - int scale = getScaledLevel(); - int start = 0; - - while(scale > 0) - { - int renderRemaining = 0; + public abstract int getScaledLevel(); - if(scale > 16) - { - renderRemaining = 16; - scale -= 16; - } - else { - renderRemaining = scale; - scale = 0; - } + public abstract IIcon getIcon(); - mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture()); + public abstract String getTooltipText(); - for(int i = 0; i < number; i++) - { - guiObj.drawTexturedRectFromIcon(guiWidth + xLocation + 16*i + 1, guiHeight + yLocation + height - renderRemaining - start - 1, getIcon(), 16, renderRemaining); - } + @Override + public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) { + mc.renderEngine.bindTexture(RESOURCE); - start+=16; + guiObj.drawTexturedRect( + guiWidth + xLocation, guiHeight + yLocation, texX, texY, width, height + ); - if(renderRemaining == 0 || scale == 0) - { - break; - } - } + if (!dummy) { + renderScale(xAxis, yAxis, guiWidth, guiHeight); + } - mc.renderEngine.bindTexture(RESOURCE); - guiObj.drawTexturedRect(guiWidth + xLocation, guiHeight + yLocation, width, 0, width, height); - } + mc.renderEngine.bindTexture(defaultLocation); + } - @Override - public void renderForeground(int xAxis, int yAxis) - { - if(xAxis >= xLocation + 1 && xAxis <= xLocation + width - 1 && yAxis >= yLocation + 1 && yAxis <= yLocation + height - 1) - { - ItemStack stack = mc.thePlayer.inventory.getItemStack(); + public void renderScale(int xAxis, int yAxis, int guiWidth, int guiHeight) { + if (getScaledLevel() == 0 || getIcon() == null) { + guiObj.drawTexturedRect( + guiWidth + xLocation, guiHeight + yLocation, width, 0, width, height + ); + return; + } - if(stack != null && stack.getItem() instanceof ItemConfigurator && color != null) - { - if(guiObj instanceof GuiMekanism && ((GuiMekanism)guiObj).getTileEntity() != null) - { - TileEntity tile = ((GuiMekanism)guiObj).getTileEntity(); - - if(tile instanceof ISideConfiguration && getTransmission() != null) - { - SideData data = null; - - for(SideData iterData : ((ISideConfiguration)tile).getConfig().getOutputs(getTransmission())) - { - if(iterData.color == color) - { - data = iterData; - break; - } - } - - guiObj.displayTooltip(color + data.localize() + " (" + color.getName() + ")", xAxis, yAxis); - } - } - } - else { - guiObj.displayTooltip(getTooltipText(), xAxis, yAxis); - } - } - } + int scale = getScaledLevel(); + int start = 0; - @Override - public void preMouseClicked(int xAxis, int yAxis, int button) - { + while (scale > 0) { + int renderRemaining = 0; - } + if (scale > 16) { + renderRemaining = 16; + scale -= 16; + } else { + renderRemaining = scale; + scale = 0; + } - @Override - public void mouseClicked(int xAxis, int yAxis, int button) - { - - } - - public abstract TransmissionType getTransmission(); + mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture()); - public void setDummyType(T type) - { - dummyType = type; - } - - @Override - public Rectangle4i getBounds(int guiWidth, int guiHeight) - { - return new Rectangle4i(guiWidth + xLocation, guiHeight + yLocation, width, height); - } - - public static enum Type - { - STANDARD(null, 18, 60, 0, 0, 1, "GuiGaugeStandard.png"), - STANDARD_YELLOW(EnumColor.YELLOW, 18, 60, 0, 60, 1, "GuiGaugeStandard.png"), - STANDARD_RED(EnumColor.DARK_RED, 18, 60, 0, 120, 1, "GuiGaugeStandard.png"), - STANDARD_ORANGE(EnumColor.ORANGE, 18, 60, 0, 180, 1, "GuiGaugeStandard.png"), - STANDARD_BLUE(EnumColor.DARK_BLUE, 18, 60, 0, 240, 1, "GuiGaugeStandard.png"), - WIDE(null, 66, 50, 0, 0, 4, "GuiGaugeWide.png"), - WIDE_YELLOW(EnumColor.YELLOW, 66, 50, 0, 50, 4, "GuiGaugeWide.png"), - WIDE_RED(EnumColor.DARK_RED, 66, 50, 0, 100, 4, "GuiGaugeWide.png"), - WIDE_ORANGE(EnumColor.ORANGE, 66, 50, 0, 150, 4, "GuiGaugeWide.png"), - WIDE_BLUE(EnumColor.DARK_BLUE, 66, 50, 0, 200, 4, "GuiGaugeWide.png"), - SMALL(null, 18, 30, 0, 0, 1, "GuiGaugeSmall.png"), - SMALL_YELLOW(EnumColor.YELLOW, 18, 30, 0, 30, 1, "GuiGaugeSmall.png"), - SMALL_RED(EnumColor.DARK_RED, 18, 30, 0, 60, 1, "GuiGaugeSmall.png"), - SMALL_ORANGE(EnumColor.ORANGE, 18, 30, 0, 90, 1, "GuiGaugeSmall.png"), - SMALL_BLUE(EnumColor.DARK_BLUE, 18, 30, 0, 120, 1, "GuiGaugeSmall.png"); + for (int i = 0; i < number; i++) { + guiObj.drawTexturedRectFromIcon( + guiWidth + xLocation + 16 * i + 1, + guiHeight + yLocation + height - renderRemaining - start - 1, + getIcon(), + 16, + renderRemaining + ); + } - public EnumColor color; - public int width; - public int height; - public int texX; - public int texY; - public int number; - public String textureLocation; + start += 16; - private Type(EnumColor c, int w, int h, int tx, int ty, int n, String t) - { - color = c; - width = w; - height = h; - texX = tx; - texY = ty; - number = n; - textureLocation = t; - } - } + if (renderRemaining == 0 || scale == 0) { + break; + } + } + + mc.renderEngine.bindTexture(RESOURCE); + guiObj.drawTexturedRect( + guiWidth + xLocation, guiHeight + yLocation, width, 0, width, height + ); + } + + @Override + public void renderForeground(int xAxis, int yAxis) { + if (xAxis >= xLocation + 1 && xAxis <= xLocation + width - 1 + && yAxis >= yLocation + 1 && yAxis <= yLocation + height - 1) { + ItemStack stack = mc.thePlayer.inventory.getItemStack(); + + if (stack != null && stack.getItem() instanceof ItemConfigurator + && color != null) { + if (guiObj instanceof GuiMekanism + && ((GuiMekanism) guiObj).getTileEntity() != null) { + TileEntity tile = ((GuiMekanism) guiObj).getTileEntity(); + + if (tile instanceof ISideConfiguration && getTransmission() != null) { + SideData data = null; + + for (SideData iterData : ((ISideConfiguration) tile) + .getConfig() + .getOutputs(getTransmission())) { + if (iterData.color == color) { + data = iterData; + break; + } + } + + guiObj.displayTooltip( + color + data.localize() + " (" + color.getName() + ")", + xAxis, + yAxis + ); + } + } + } else { + guiObj.displayTooltip(getTooltipText(), xAxis, yAxis); + } + } + } + + @Override + public void preMouseClicked(int xAxis, int yAxis, int button) {} + + @Override + public void mouseClicked(int xAxis, int yAxis, int button) {} + + public abstract TransmissionType getTransmission(); + + public void setDummyType(T type) { + dummyType = type; + } + + @Override + public Rectangle4i getBounds(int guiWidth, int guiHeight) { + return new Rectangle4i( + guiWidth + xLocation, guiHeight + yLocation, width, height + ); + } + + public static enum Type { + STANDARD(null, 18, 60, 0, 0, 1, "GuiGaugeStandard.png"), + STANDARD_YELLOW(EnumColor.YELLOW, 18, 60, 0, 60, 1, "GuiGaugeStandard.png"), + STANDARD_RED(EnumColor.DARK_RED, 18, 60, 0, 120, 1, "GuiGaugeStandard.png"), + STANDARD_ORANGE(EnumColor.ORANGE, 18, 60, 0, 180, 1, "GuiGaugeStandard.png"), + STANDARD_BLUE(EnumColor.DARK_BLUE, 18, 60, 0, 240, 1, "GuiGaugeStandard.png"), + WIDE(null, 66, 50, 0, 0, 4, "GuiGaugeWide.png"), + WIDE_YELLOW(EnumColor.YELLOW, 66, 50, 0, 50, 4, "GuiGaugeWide.png"), + WIDE_RED(EnumColor.DARK_RED, 66, 50, 0, 100, 4, "GuiGaugeWide.png"), + WIDE_ORANGE(EnumColor.ORANGE, 66, 50, 0, 150, 4, "GuiGaugeWide.png"), + WIDE_BLUE(EnumColor.DARK_BLUE, 66, 50, 0, 200, 4, "GuiGaugeWide.png"), + SMALL(null, 18, 30, 0, 0, 1, "GuiGaugeSmall.png"), + SMALL_YELLOW(EnumColor.YELLOW, 18, 30, 0, 30, 1, "GuiGaugeSmall.png"), + SMALL_RED(EnumColor.DARK_RED, 18, 30, 0, 60, 1, "GuiGaugeSmall.png"), + SMALL_ORANGE(EnumColor.ORANGE, 18, 30, 0, 90, 1, "GuiGaugeSmall.png"), + SMALL_BLUE(EnumColor.DARK_BLUE, 18, 30, 0, 120, 1, "GuiGaugeSmall.png"); + + public EnumColor color; + public int width; + public int height; + public int texX; + public int texY; + public int number; + public String textureLocation; + + private Type(EnumColor c, int w, int h, int tx, int ty, int n, String t) { + color = c; + width = w; + height = h; + texX = tx; + texY = ty; + number = n; + textureLocation = t; + } + } } diff --git a/src/main/java/mekanism/client/gui/element/GuiGraph.java b/src/main/java/mekanism/client/gui/element/GuiGraph.java index 4fbd0f4b2..45a10c090 100644 --- a/src/main/java/mekanism/client/gui/element/GuiGraph.java +++ b/src/main/java/mekanism/client/gui/element/GuiGraph.java @@ -3,150 +3,170 @@ package mekanism.client.gui.element; import java.util.ArrayList; import java.util.List; +import codechicken.lib.vec.Rectangle4i; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.gui.IGuiWrapper; import mekanism.client.render.MekanismRenderer; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; -import codechicken.lib.vec.Rectangle4i; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiGraph extends GuiElement -{ - public int xPosition; - public int yPosition; - - public int xSize; - public int ySize; - - public int currentScale = 10; - public boolean fixedScale = false; - - public List graphData = new ArrayList(); - - public GraphDataHandler dataHandler; - - public GuiGraph(IGuiWrapper gui, ResourceLocation def, int x, int y, int sizeX, int sizeY, GraphDataHandler handler) - { - super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiGraph.png"), gui, def); - - xPosition = x; - yPosition = y; - - xSize = sizeX; - ySize = sizeY; - - dataHandler = handler; - } - - public void enableFixedScale(int scale) - { - fixedScale = true; - currentScale = scale; - } - - public void addData(int data) - { - if(graphData.size() == xSize) - { - graphData.remove(0); - } - - graphData.add(data); - - if(!fixedScale) - { - for(int i : graphData) - { - if(i > currentScale) - { - currentScale = i; - } - } - } - } - - @Override - public Rectangle4i getBounds(int guiWidth, int guiHeight) - { - return new Rectangle4i(guiWidth + xPosition, guiHeight + yPosition, xSize, ySize); - } - - @Override - public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) - { - mc.renderEngine.bindTexture(RESOURCE); - - drawBlack(guiWidth, guiHeight); - drawGraph(guiWidth, guiHeight); +public class GuiGraph extends GuiElement { + public int xPosition; + public int yPosition; - mc.renderEngine.bindTexture(defaultLocation); - } - - @Override - public void renderForeground(int xAxis, int yAxis) - { - if(xAxis >= xPosition && xAxis <= xPosition+xSize && yAxis >= yPosition && yAxis <= yPosition+ySize) - { - int height = ySize-(yAxis-yPosition); - int scaled = (int)(((double)height/(double)ySize)*currentScale); - - displayTooltip(dataHandler.getDataDisplay(scaled), xAxis, yAxis); - } - } - - @Override - public void preMouseClicked(int xAxis, int yAxis, int button) {} + public int xSize; + public int ySize; - @Override - public void mouseClicked(int xAxis, int yAxis, int button) {} - - public void drawBlack(int guiWidth, int guiHeight) - { - int xDisplays = xSize/10 + (xSize%10 > 0 ? 1 : 0); - int yDisplays = ySize/10 + (ySize%10 > 0 ? 1 : 0); - - for(int yIter = 0; yIter < yDisplays; yIter++) - { - for(int xIter = 0; xIter < xDisplays; xIter++) - { - int width = (xSize%10 > 0 && xIter == xDisplays-1 ? xSize%10 : 10); - int height = (ySize%10 > 0 && yIter == yDisplays-1 ? ySize%10 : 10); - - guiObj.drawTexturedRect(guiWidth + xPosition + (xIter*10), guiHeight + yPosition + (yIter*10), 0, 0, width, height); - } - } - } - - public void drawGraph(int guiWidth, int guiHeight) - { - for(int i = 0; i < graphData.size(); i++) - { - int data = Math.min(currentScale, graphData.get(i)); - int relativeHeight = (int)(((double)data/(double)currentScale)*ySize); - - guiObj.drawTexturedRect(guiWidth + xPosition + i, guiHeight + yPosition + (ySize-relativeHeight), 10, 0, 1, 1); - - int displays = (relativeHeight-1)/10 + ((relativeHeight-1)%10 > 0 ? 1 : 0); - - for(int iter = 0; iter < displays; iter++) - { - MekanismRenderer.blendOn(); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.2F + (0.8F*((float)i/(float)graphData.size()))); - int height = ((relativeHeight-1)%10 > 0 && iter == displays-1 ? (relativeHeight-1)%10 : 10); - guiObj.drawTexturedRect(guiWidth + xPosition + i, guiHeight + yPosition + (ySize-(iter*10)) - 10 + (10-height), 11, 0, 1, height); - MekanismRenderer.blendOff(); - } - } - } - - public static interface GraphDataHandler - { - public String getDataDisplay(int data); - } + public int currentScale = 10; + public boolean fixedScale = false; + + public List graphData = new ArrayList(); + + public GraphDataHandler dataHandler; + + public GuiGraph( + IGuiWrapper gui, + ResourceLocation def, + int x, + int y, + int sizeX, + int sizeY, + GraphDataHandler handler + ) { + super( + MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiGraph.png"), gui, def + ); + + xPosition = x; + yPosition = y; + + xSize = sizeX; + ySize = sizeY; + + dataHandler = handler; + } + + public void enableFixedScale(int scale) { + fixedScale = true; + currentScale = scale; + } + + public void addData(int data) { + if (graphData.size() == xSize) { + graphData.remove(0); + } + + graphData.add(data); + + if (!fixedScale) { + for (int i : graphData) { + if (i > currentScale) { + currentScale = i; + } + } + } + } + + @Override + public Rectangle4i getBounds(int guiWidth, int guiHeight) { + return new Rectangle4i(guiWidth + xPosition, guiHeight + yPosition, xSize, ySize); + } + + @Override + public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) { + mc.renderEngine.bindTexture(RESOURCE); + + drawBlack(guiWidth, guiHeight); + drawGraph(guiWidth, guiHeight); + + mc.renderEngine.bindTexture(defaultLocation); + } + + @Override + public void renderForeground(int xAxis, int yAxis) { + if (xAxis >= xPosition && xAxis <= xPosition + xSize && yAxis >= yPosition + && yAxis <= yPosition + ySize) { + int height = ySize - (yAxis - yPosition); + int scaled = (int) (((double) height / (double) ySize) * currentScale); + + displayTooltip(dataHandler.getDataDisplay(scaled), xAxis, yAxis); + } + } + + @Override + public void preMouseClicked(int xAxis, int yAxis, int button) {} + + @Override + public void mouseClicked(int xAxis, int yAxis, int button) {} + + public void drawBlack(int guiWidth, int guiHeight) { + int xDisplays = xSize / 10 + (xSize % 10 > 0 ? 1 : 0); + int yDisplays = ySize / 10 + (ySize % 10 > 0 ? 1 : 0); + + for (int yIter = 0; yIter < yDisplays; yIter++) { + for (int xIter = 0; xIter < xDisplays; xIter++) { + int width = (xSize % 10 > 0 && xIter == xDisplays - 1 ? xSize % 10 : 10); + int height = (ySize % 10 > 0 && yIter == yDisplays - 1 ? ySize % 10 : 10); + + guiObj.drawTexturedRect( + guiWidth + xPosition + (xIter * 10), + guiHeight + yPosition + (yIter * 10), + 0, + 0, + width, + height + ); + } + } + } + + public void drawGraph(int guiWidth, int guiHeight) { + for (int i = 0; i < graphData.size(); i++) { + int data = Math.min(currentScale, graphData.get(i)); + int relativeHeight = (int) (((double) data / (double) currentScale) * ySize); + + guiObj.drawTexturedRect( + guiWidth + xPosition + i, + guiHeight + yPosition + (ySize - relativeHeight), + 10, + 0, + 1, + 1 + ); + + int displays + = (relativeHeight - 1) / 10 + ((relativeHeight - 1) % 10 > 0 ? 1 : 0); + + for (int iter = 0; iter < displays; iter++) { + MekanismRenderer.blendOn(); + GL11.glColor4f( + 1.0F, + 1.0F, + 1.0F, + 0.2F + (0.8F * ((float) i / (float) graphData.size())) + ); + int height + = ((relativeHeight - 1) % 10 > 0 && iter == displays - 1 + ? (relativeHeight - 1) % 10 + : 10); + guiObj.drawTexturedRect( + guiWidth + xPosition + i, + guiHeight + yPosition + (ySize - (iter * 10)) - 10 + (10 - height), + 11, + 0, + 1, + height + ); + MekanismRenderer.blendOff(); + } + } + } + + public static interface GraphDataHandler { + public String getDataDisplay(int data); + } } diff --git a/src/main/java/mekanism/client/gui/element/GuiHeatInfo.java b/src/main/java/mekanism/client/gui/element/GuiHeatInfo.java index 41d335736..4b06d7f1e 100644 --- a/src/main/java/mekanism/client/gui/element/GuiHeatInfo.java +++ b/src/main/java/mekanism/client/gui/element/GuiHeatInfo.java @@ -3,6 +3,9 @@ package mekanism.client.gui.element; import java.util.ArrayList; import java.util.List; +import codechicken.lib.vec.Rectangle4i; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.MekanismConfig.general; import mekanism.api.util.UnitDisplayUtils.TempType; import mekanism.client.gui.IGuiWrapper; @@ -10,67 +13,59 @@ import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.util.ResourceLocation; -import codechicken.lib.vec.Rectangle4i; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiHeatInfo extends GuiElement -{ - public IInfoHandler infoHandler; +public class GuiHeatInfo extends GuiElement { + public IInfoHandler infoHandler; - public GuiHeatInfo(IInfoHandler handler, IGuiWrapper gui, ResourceLocation def) - { - super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiHeatInfo.png"), gui, def); + public GuiHeatInfo(IInfoHandler handler, IGuiWrapper gui, ResourceLocation def) { + super( + MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiHeatInfo.png"), + gui, + def + ); - infoHandler = handler; - } - - @Override - public Rectangle4i getBounds(int guiWidth, int guiHeight) - { - return new Rectangle4i(guiWidth - 26, guiHeight + 138, 26, 26); - } + infoHandler = handler; + } - @Override - public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) - { - mc.renderEngine.bindTexture(RESOURCE); + @Override + public Rectangle4i getBounds(int guiWidth, int guiHeight) { + return new Rectangle4i(guiWidth - 26, guiHeight + 138, 26, 26); + } - guiObj.drawTexturedRect(guiWidth - 26, guiHeight + 112, 0, 0, 26, 26); + @Override + public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) { + mc.renderEngine.bindTexture(RESOURCE); - mc.renderEngine.bindTexture(defaultLocation); - } + guiObj.drawTexturedRect(guiWidth - 26, guiHeight + 112, 0, 0, 26, 26); - @Override - public void renderForeground(int xAxis, int yAxis) - { - if(xAxis >= -21 && xAxis <= -3 && yAxis >= 116 && yAxis <= 134) - { - List info = new ArrayList(); - - for(String s : infoHandler.getInfo()) - { - info.add(s); - } - - info.add(LangUtils.localize("gui.unit") + ": " + general.tempUnit); - displayTooltips(info, xAxis, yAxis); - } - } + mc.renderEngine.bindTexture(defaultLocation); + } - @Override - public void preMouseClicked(int xAxis, int yAxis, int button) {} + @Override + public void renderForeground(int xAxis, int yAxis) { + if (xAxis >= -21 && xAxis <= -3 && yAxis >= 116 && yAxis <= 134) { + List info = new ArrayList(); - @Override - public void mouseClicked(int xAxis, int yAxis, int button) - { - if(button == 0) - { - if(xAxis >= -21 && xAxis <= -3 && yAxis >= 116 && yAxis <= 134) - { - general.tempUnit = TempType.values()[(general.tempUnit.ordinal()+1)%TempType.values().length]; - } - } - } + for (String s : infoHandler.getInfo()) { + info.add(s); + } + + info.add(LangUtils.localize("gui.unit") + ": " + general.tempUnit); + displayTooltips(info, xAxis, yAxis); + } + } + + @Override + public void preMouseClicked(int xAxis, int yAxis, int button) {} + + @Override + public void mouseClicked(int xAxis, int yAxis, int button) { + if (button == 0) { + if (xAxis >= -21 && xAxis <= -3 && yAxis >= 116 && yAxis <= 134) { + general.tempUnit = TempType.values( + )[(general.tempUnit.ordinal() + 1) % TempType.values().length]; + } + } + } } diff --git a/src/main/java/mekanism/client/gui/element/GuiMatrixTab.java b/src/main/java/mekanism/client/gui/element/GuiMatrixTab.java index db464f2f6..566fd83de 100644 --- a/src/main/java/mekanism/client/gui/element/GuiMatrixTab.java +++ b/src/main/java/mekanism/client/gui/element/GuiMatrixTab.java @@ -1,5 +1,8 @@ package mekanism.client.gui.element; +import codechicken.lib.vec.Rectangle4i; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.client.gui.IGuiWrapper; import mekanism.client.sound.SoundHandler; @@ -10,108 +13,93 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; -import codechicken.lib.vec.Rectangle4i; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiMatrixTab extends GuiElement -{ - private TileEntity tileEntity; - private MatrixTab tabType; - private int yPos; +public class GuiMatrixTab extends GuiElement { + private TileEntity tileEntity; + private MatrixTab tabType; + private int yPos; - public GuiMatrixTab(IGuiWrapper gui, TileEntity tile, MatrixTab type, int y, ResourceLocation def) - { - super(type.getResource(), gui, def); + public GuiMatrixTab( + IGuiWrapper gui, TileEntity tile, MatrixTab type, int y, ResourceLocation def + ) { + super(type.getResource(), gui, def); - tileEntity = tile; - tabType = type; - yPos = y; - } + tileEntity = tile; + tabType = type; + yPos = y; + } - @Override - public Rectangle4i getBounds(int guiWidth, int guiHeight) - { - return new Rectangle4i(guiWidth - 26, guiHeight + yPos, 26, 26); - } + @Override + public Rectangle4i getBounds(int guiWidth, int guiHeight) { + return new Rectangle4i(guiWidth - 26, guiHeight + yPos, 26, 26); + } - @Override - public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) - { - mc.renderEngine.bindTexture(RESOURCE); + @Override + public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) { + mc.renderEngine.bindTexture(RESOURCE); - guiObj.drawTexturedRect(guiWidth - 26, guiHeight + yPos, 0, 0, 26, 26); + guiObj.drawTexturedRect(guiWidth - 26, guiHeight + yPos, 0, 0, 26, 26); - if(xAxis >= -21 && xAxis <= -3 && yAxis >= yPos+4 && yAxis <= yPos+22) - { - guiObj.drawTexturedRect(guiWidth - 21, guiHeight + yPos+4, 26, 0, 18, 18); - } - else { - guiObj.drawTexturedRect(guiWidth - 21, guiHeight + yPos+4, 26, 18, 18, 18); - } + if (xAxis >= -21 && xAxis <= -3 && yAxis >= yPos + 4 && yAxis <= yPos + 22) { + guiObj.drawTexturedRect(guiWidth - 21, guiHeight + yPos + 4, 26, 0, 18, 18); + } else { + guiObj.drawTexturedRect(guiWidth - 21, guiHeight + yPos + 4, 26, 18, 18, 18); + } - mc.renderEngine.bindTexture(defaultLocation); - } + mc.renderEngine.bindTexture(defaultLocation); + } - @Override - public void renderForeground(int xAxis, int yAxis) - { - mc.renderEngine.bindTexture(RESOURCE); + @Override + public void renderForeground(int xAxis, int yAxis) { + mc.renderEngine.bindTexture(RESOURCE); - if(xAxis >= -21 && xAxis <= -3 && yAxis >= yPos+4 && yAxis <= yPos+22) - { - displayTooltip(tabType.getDesc(), xAxis, yAxis); - } + if (xAxis >= -21 && xAxis <= -3 && yAxis >= yPos + 4 && yAxis <= yPos + 22) { + displayTooltip(tabType.getDesc(), xAxis, yAxis); + } - mc.renderEngine.bindTexture(defaultLocation); - } + mc.renderEngine.bindTexture(defaultLocation); + } - @Override - public void preMouseClicked(int xAxis, int yAxis, int button) {} + @Override + public void preMouseClicked(int xAxis, int yAxis, int button) {} - @Override - public void mouseClicked(int xAxis, int yAxis, int button) - { - if(button == 0) - { - if(xAxis >= -21 && xAxis <= -3 && yAxis >= yPos+4 && yAxis <= yPos+22) - { - tabType.openGui(tileEntity); - SoundHandler.playSound("gui.button.press"); - } - } - } - - public static enum MatrixTab - { - MAIN("GuiEnergyTab.png", 49, "gui.main"), - STAT("GuiStatsTab.png", 50, "gui.stats"); - - private String path; - private int guiId; - private String desc; - - private MatrixTab(String s, int id, String s1) - { - path = s; - guiId = id; - desc = s1; - } - - public ResourceLocation getResource() - { - return MekanismUtils.getResource(ResourceType.GUI_ELEMENT, path); - } - - public void openGui(TileEntity tile) - { - Mekanism.packetHandler.sendToServer(new SimpleGuiMessage(Coord4D.get(tile), 0, guiId)); - } - - public String getDesc() - { - return LangUtils.localize(desc); - } - } + @Override + public void mouseClicked(int xAxis, int yAxis, int button) { + if (button == 0) { + if (xAxis >= -21 && xAxis <= -3 && yAxis >= yPos + 4 && yAxis <= yPos + 22) { + tabType.openGui(tileEntity); + SoundHandler.playSound("gui.button.press"); + } + } + } + + public static enum MatrixTab { + MAIN("GuiEnergyTab.png", 49, "gui.main"), + STAT("GuiStatsTab.png", 50, "gui.stats"); + + private String path; + private int guiId; + private String desc; + + private MatrixTab(String s, int id, String s1) { + path = s; + guiId = id; + desc = s1; + } + + public ResourceLocation getResource() { + return MekanismUtils.getResource(ResourceType.GUI_ELEMENT, path); + } + + public void openGui(TileEntity tile) { + Mekanism.packetHandler.sendToServer( + new SimpleGuiMessage(Coord4D.get(tile), 0, guiId) + ); + } + + public String getDesc() { + return LangUtils.localize(desc); + } + } } diff --git a/src/main/java/mekanism/client/gui/element/GuiNumberGauge.java b/src/main/java/mekanism/client/gui/element/GuiNumberGauge.java index 8143e7bee..e04b5d1f1 100644 --- a/src/main/java/mekanism/client/gui/element/GuiNumberGauge.java +++ b/src/main/java/mekanism/client/gui/element/GuiNumberGauge.java @@ -1,55 +1,56 @@ package mekanism.client.gui.element; import static java.lang.Math.min; + import mekanism.api.transmitters.TransmissionType; import mekanism.client.gui.IGuiWrapper; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; -public class GuiNumberGauge extends GuiGauge -{ - INumberInfoHandler infoHandler; +public class GuiNumberGauge extends GuiGauge { + INumberInfoHandler infoHandler; - public GuiNumberGauge(INumberInfoHandler handler, Type type, IGuiWrapper gui, ResourceLocation def, int x, int y) - { - super(type, gui, def, x, y); + public GuiNumberGauge( + INumberInfoHandler handler, + Type type, + IGuiWrapper gui, + ResourceLocation def, + int x, + int y + ) { + super(type, gui, def, x, y); - infoHandler = handler; - } - - @Override - public TransmissionType getTransmission() - { - return null; - } + infoHandler = handler; + } - @Override - public int getScaledLevel() - { - return (int)((height-2) * min(infoHandler.getLevel() / infoHandler.getMaxLevel(), 1)); - } + @Override + public TransmissionType getTransmission() { + return null; + } - @Override - public IIcon getIcon() - { - return infoHandler.getIcon(); - } + @Override + public int getScaledLevel() { + return (int + ) ((height - 2) * min(infoHandler.getLevel() / infoHandler.getMaxLevel(), 1)); + } - @Override - public String getTooltipText() - { - return infoHandler.getText(infoHandler.getLevel()); - } + @Override + public IIcon getIcon() { + return infoHandler.getIcon(); + } + @Override + public String getTooltipText() { + return infoHandler.getText(infoHandler.getLevel()); + } - public static interface INumberInfoHandler - { - public IIcon getIcon(); + public static interface INumberInfoHandler { + public IIcon getIcon(); - public double getLevel(); + public double getLevel(); - public double getMaxLevel(); + public double getMaxLevel(); - public String getText(double level); - } + public String getText(double level); + } } diff --git a/src/main/java/mekanism/client/gui/element/GuiPowerBar.java b/src/main/java/mekanism/client/gui/element/GuiPowerBar.java index 16d3d2826..94c11100b 100644 --- a/src/main/java/mekanism/client/gui/element/GuiPowerBar.java +++ b/src/main/java/mekanism/client/gui/element/GuiPowerBar.java @@ -1,109 +1,122 @@ package mekanism.client.gui.element; +import codechicken.lib.vec.Rectangle4i; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.energy.IStrictEnergyStorage; import mekanism.client.gui.IGuiWrapper; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.util.ResourceLocation; -import codechicken.lib.vec.Rectangle4i; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiPowerBar extends GuiElement -{ - private int xLocation; - private int yLocation; +public class GuiPowerBar extends GuiElement { + private int xLocation; + private int yLocation; - private int width = 6; - private int height = 56; - private int innerOffsetY = 2; + private int width = 6; + private int height = 56; + private int innerOffsetY = 2; - private IStrictEnergyStorage tileEntity; - private IPowerInfoHandler handler; + private IStrictEnergyStorage tileEntity; + private IPowerInfoHandler handler; - public GuiPowerBar(IGuiWrapper gui, IStrictEnergyStorage tile, ResourceLocation def, int x, int y) - { - super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiPowerBar.png"), gui, def); - - tileEntity = tile; - - handler = new IPowerInfoHandler() { - @Override - public String getTooltip() - { - return MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()); - } - - @Override - public double getLevel() - { - return tileEntity.getEnergy()/tileEntity.getMaxEnergy(); - } - }; - - xLocation = x; - yLocation = y; - } - - public GuiPowerBar(IGuiWrapper gui, IPowerInfoHandler h, ResourceLocation def, int x, int y) - { - super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiPowerBar.png"), gui, def); - - handler = h; - - xLocation = x; - yLocation = y; - } - - @Override - public Rectangle4i getBounds(int guiWidth, int guiHeight) - { - return new Rectangle4i(guiWidth + xLocation, guiHeight + yLocation, width, height); - } - - public static abstract class IPowerInfoHandler - { - public String getTooltip() - { - return null; - } - - public abstract double getLevel(); - } + public GuiPowerBar( + IGuiWrapper gui, IStrictEnergyStorage tile, ResourceLocation def, int x, int y + ) { + super( + MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiPowerBar.png"), + gui, + def + ); - @Override - public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) - { - mc.renderEngine.bindTexture(RESOURCE); + tileEntity = tile; - guiObj.drawTexturedRect(guiWidth + xLocation, guiHeight + yLocation, 0, 0, width, height); - - if(handler.getLevel() > 0) - { - int displayInt = (int)(handler.getLevel()*52) + innerOffsetY; - guiObj.drawTexturedRect(guiWidth + xLocation, guiHeight + yLocation + height - displayInt, 6, height - displayInt, width, displayInt); - } + handler = new IPowerInfoHandler() { + @Override + public String getTooltip() { + return MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()); + } - mc.renderEngine.bindTexture(defaultLocation); - } + @Override + public double getLevel() { + return tileEntity.getEnergy() / tileEntity.getMaxEnergy(); + } + }; - @Override - public void renderForeground(int xAxis, int yAxis) - { - mc.renderEngine.bindTexture(RESOURCE); + xLocation = x; + yLocation = y; + } - if(handler.getTooltip() != null && xAxis >= xLocation && xAxis <= xLocation + width && yAxis >= yLocation && yAxis <= yLocation + height) - { - displayTooltip(handler.getTooltip(), xAxis, yAxis); - } + public GuiPowerBar( + IGuiWrapper gui, IPowerInfoHandler h, ResourceLocation def, int x, int y + ) { + super( + MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiPowerBar.png"), + gui, + def + ); - mc.renderEngine.bindTexture(defaultLocation); - } + handler = h; - @Override - public void preMouseClicked(int xAxis, int yAxis, int button) {} + xLocation = x; + yLocation = y; + } - @Override - public void mouseClicked(int xAxis, int yAxis, int button) {} + @Override + public Rectangle4i getBounds(int guiWidth, int guiHeight) { + return new Rectangle4i( + guiWidth + xLocation, guiHeight + yLocation, width, height + ); + } + + public static abstract class IPowerInfoHandler { + public String getTooltip() { + return null; + } + + public abstract double getLevel(); + } + + @Override + public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) { + mc.renderEngine.bindTexture(RESOURCE); + + guiObj.drawTexturedRect( + guiWidth + xLocation, guiHeight + yLocation, 0, 0, width, height + ); + + if (handler.getLevel() > 0) { + int displayInt = (int) (handler.getLevel() * 52) + innerOffsetY; + guiObj.drawTexturedRect( + guiWidth + xLocation, + guiHeight + yLocation + height - displayInt, + 6, + height - displayInt, + width, + displayInt + ); + } + + mc.renderEngine.bindTexture(defaultLocation); + } + + @Override + public void renderForeground(int xAxis, int yAxis) { + mc.renderEngine.bindTexture(RESOURCE); + + if (handler.getTooltip() != null && xAxis >= xLocation + && xAxis <= xLocation + width && yAxis >= yLocation + && yAxis <= yLocation + height) { + displayTooltip(handler.getTooltip(), xAxis, yAxis); + } + + mc.renderEngine.bindTexture(defaultLocation); + } + + @Override + public void preMouseClicked(int xAxis, int yAxis, int button) {} + + @Override + public void mouseClicked(int xAxis, int yAxis, int button) {} } diff --git a/src/main/java/mekanism/client/gui/element/GuiProgress.java b/src/main/java/mekanism/client/gui/element/GuiProgress.java index 97c716cca..65c73f395 100644 --- a/src/main/java/mekanism/client/gui/element/GuiProgress.java +++ b/src/main/java/mekanism/client/gui/element/GuiProgress.java @@ -1,103 +1,122 @@ package mekanism.client.gui.element; +import codechicken.lib.vec.Rectangle4i; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.gui.IGuiWrapper; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.util.ResourceLocation; -import codechicken.lib.vec.Rectangle4i; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiProgress extends GuiElement -{ - private int xLocation; - private int yLocation; +public class GuiProgress extends GuiElement { + private int xLocation; + private int yLocation; - private int innerOffsetX = 2; + private int innerOffsetX = 2; - private ProgressBar type; - private IProgressInfoHandler handler; + private ProgressBar type; + private IProgressInfoHandler handler; - public GuiProgress(IProgressInfoHandler handler, ProgressBar type, IGuiWrapper gui, ResourceLocation def, int x, int y) - { - super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiProgress.png"), gui, def); - xLocation = x; - yLocation = y; + public GuiProgress( + IProgressInfoHandler handler, + ProgressBar type, + IGuiWrapper gui, + ResourceLocation def, + int x, + int y + ) { + super( + MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiProgress.png"), + gui, + def + ); + xLocation = x; + yLocation = y; - this.type = type; - this.handler = handler; - } - - @Override - public Rectangle4i getBounds(int guiWidth, int guiHeight) - { - return new Rectangle4i(guiWidth + xLocation, guiHeight + yLocation, type.width, type.height); - } + this.type = type; + this.handler = handler; + } - @Override - public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) - { - mc.renderEngine.bindTexture(RESOURCE); - - if(handler.isActive()) - { - guiObj.drawTexturedRect(guiWidth + xLocation, guiHeight + yLocation, type.textureX, type.textureY, type.width, type.height); - int displayInt = (int)(handler.getProgress() * (type.width-2*innerOffsetX)); - guiObj.drawTexturedRect(guiWidth + xLocation + innerOffsetX, guiHeight + yLocation, type.textureX + type.width + innerOffsetX, type.textureY, displayInt, type.height); - } - - mc.renderEngine.bindTexture(defaultLocation); - } + @Override + public Rectangle4i getBounds(int guiWidth, int guiHeight) { + return new Rectangle4i( + guiWidth + xLocation, guiHeight + yLocation, type.width, type.height + ); + } - @Override - public void renderForeground(int xAxis, int yAxis) {} + @Override + public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) { + mc.renderEngine.bindTexture(RESOURCE); - @Override - public void preMouseClicked(int xAxis, int yAxis, int button) {} + if (handler.isActive()) { + guiObj.drawTexturedRect( + guiWidth + xLocation, + guiHeight + yLocation, + type.textureX, + type.textureY, + type.width, + type.height + ); + int displayInt + = (int) (handler.getProgress() * (type.width - 2 * innerOffsetX)); + guiObj.drawTexturedRect( + guiWidth + xLocation + innerOffsetX, + guiHeight + yLocation, + type.textureX + type.width + innerOffsetX, + type.textureY, + displayInt, + type.height + ); + } - @Override - public void mouseClicked(int xAxis, int yAxis, int button) {} + mc.renderEngine.bindTexture(defaultLocation); + } - public static abstract class IProgressInfoHandler - { - public abstract double getProgress(); + @Override + public void renderForeground(int xAxis, int yAxis) {} - public boolean isActive() - { - return true; - } - } + @Override + public void preMouseClicked(int xAxis, int yAxis, int button) {} - public enum ProgressBar - { - BLUE(28, 11, 0, 0), - YELLOW(28, 11, 0, 11), - RED(28, 11, 0, 22), - GREEN(28, 11, 0, 33), - PURPLE(28, 11, 0, 44), - STONE(28, 11, 0, 55), - CRUSH(28, 11, 0, 66), + @Override + public void mouseClicked(int xAxis, int yAxis, int button) {} - LARGE_RIGHT(52, 10, 128, 0), - LARGE_LEFT(52, 10, 128, 10), - MEDIUM(36, 10, 128, 20), - SMALL_RIGHT(32, 10, 128, 30), - SMALL_LEFT(32, 10, 128, 40), - BI(20, 8, 128, 50); + public static abstract class IProgressInfoHandler { + public abstract double getProgress(); - public int width; - public int height; + public boolean isActive() { + return true; + } + } - public int textureX; - public int textureY; + public enum ProgressBar { + BLUE(28, 11, 0, 0), + YELLOW(28, 11, 0, 11), + RED(28, 11, 0, 22), + GREEN(28, 11, 0, 33), + PURPLE(28, 11, 0, 44), + STONE(28, 11, 0, 55), + CRUSH(28, 11, 0, 66), - private ProgressBar(int w, int h, int u, int v) - { - width = w; - height = h; - textureX = u; - textureY = v; - } - } + LARGE_RIGHT(52, 10, 128, 0), + LARGE_LEFT(52, 10, 128, 10), + MEDIUM(36, 10, 128, 20), + SMALL_RIGHT(32, 10, 128, 30), + SMALL_LEFT(32, 10, 128, 40), + BI(20, 8, 128, 50); + + public int width; + public int height; + + public int textureX; + public int textureY; + + private ProgressBar(int w, int h, int u, int v) { + width = w; + height = h; + textureX = u; + textureY = v; + } + } } diff --git a/src/main/java/mekanism/client/gui/element/GuiRateBar.java b/src/main/java/mekanism/client/gui/element/GuiRateBar.java index e6c1d450b..9511117e2 100644 --- a/src/main/java/mekanism/client/gui/element/GuiRateBar.java +++ b/src/main/java/mekanism/client/gui/element/GuiRateBar.java @@ -1,82 +1,92 @@ package mekanism.client.gui.element; +import codechicken.lib.vec.Rectangle4i; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.gui.IGuiWrapper; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.util.ResourceLocation; -import codechicken.lib.vec.Rectangle4i; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiRateBar extends GuiElement -{ - private int xLocation; - private int yLocation; +public class GuiRateBar extends GuiElement { + private int xLocation; + private int yLocation; - private int width = 8; - private int height = 60; + private int width = 8; + private int height = 60; - private IRateInfoHandler handler; + private IRateInfoHandler handler; - public GuiRateBar(IGuiWrapper gui, IRateInfoHandler h, ResourceLocation def, int x, int y) - { - super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiRateBar.png"), gui, def); - - handler = h; - - xLocation = x; - yLocation = y; - } - - @Override - public Rectangle4i getBounds(int guiWidth, int guiHeight) - { - return new Rectangle4i(guiWidth + xLocation, guiHeight + yLocation, width, height); - } - - public static abstract class IRateInfoHandler - { - public String getTooltip() - { - return null; - } - - public abstract double getLevel(); - } + public GuiRateBar( + IGuiWrapper gui, IRateInfoHandler h, ResourceLocation def, int x, int y + ) { + super( + MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiRateBar.png"), + gui, + def + ); - @Override - public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) - { - mc.renderEngine.bindTexture(RESOURCE); + handler = h; - guiObj.drawTexturedRect(guiWidth + xLocation, guiHeight + yLocation, 0, 0, width, height); - - if(handler.getLevel() > 0) - { - int displayInt = (int)(handler.getLevel()*58); - guiObj.drawTexturedRect(guiWidth + xLocation+1, guiHeight + yLocation + height-1 - displayInt, 8, height-2 - displayInt, width-2, displayInt); - } + xLocation = x; + yLocation = y; + } - mc.renderEngine.bindTexture(defaultLocation); - } + @Override + public Rectangle4i getBounds(int guiWidth, int guiHeight) { + return new Rectangle4i( + guiWidth + xLocation, guiHeight + yLocation, width, height + ); + } - @Override - public void renderForeground(int xAxis, int yAxis) - { - mc.renderEngine.bindTexture(RESOURCE); + public static abstract class IRateInfoHandler { + public String getTooltip() { + return null; + } - if(handler.getTooltip() != null && xAxis >= xLocation+1 && xAxis <= xLocation + width-1 && yAxis >= yLocation+1 && yAxis <= yLocation + height-1) - { - displayTooltip(handler.getTooltip(), xAxis, yAxis); - } + public abstract double getLevel(); + } - mc.renderEngine.bindTexture(defaultLocation); - } + @Override + public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) { + mc.renderEngine.bindTexture(RESOURCE); - @Override - public void preMouseClicked(int xAxis, int yAxis, int button) {} + guiObj.drawTexturedRect( + guiWidth + xLocation, guiHeight + yLocation, 0, 0, width, height + ); - @Override - public void mouseClicked(int xAxis, int yAxis, int button) {} + if (handler.getLevel() > 0) { + int displayInt = (int) (handler.getLevel() * 58); + guiObj.drawTexturedRect( + guiWidth + xLocation + 1, + guiHeight + yLocation + height - 1 - displayInt, + 8, + height - 2 - displayInt, + width - 2, + displayInt + ); + } + + mc.renderEngine.bindTexture(defaultLocation); + } + + @Override + public void renderForeground(int xAxis, int yAxis) { + mc.renderEngine.bindTexture(RESOURCE); + + if (handler.getTooltip() != null && xAxis >= xLocation + 1 + && xAxis <= xLocation + width - 1 && yAxis >= yLocation + 1 + && yAxis <= yLocation + height - 1) { + displayTooltip(handler.getTooltip(), xAxis, yAxis); + } + + mc.renderEngine.bindTexture(defaultLocation); + } + + @Override + public void preMouseClicked(int xAxis, int yAxis, int button) {} + + @Override + public void mouseClicked(int xAxis, int yAxis, int button) {} } diff --git a/src/main/java/mekanism/client/gui/element/GuiRecipeType.java b/src/main/java/mekanism/client/gui/element/GuiRecipeType.java index cba684451..4e8b5ed3f 100644 --- a/src/main/java/mekanism/client/gui/element/GuiRecipeType.java +++ b/src/main/java/mekanism/client/gui/element/GuiRecipeType.java @@ -1,76 +1,66 @@ package mekanism.client.gui.element; +import codechicken.lib.vec.Rectangle4i; import mekanism.client.gui.IGuiWrapper; import mekanism.common.tile.TileEntityFactory; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.util.ResourceLocation; -import codechicken.lib.vec.Rectangle4i; -public class GuiRecipeType extends GuiElement -{ - public TileEntityFactory tileEntity; +public class GuiRecipeType extends GuiElement { + public TileEntityFactory tileEntity; - public GuiRecipeType(IGuiWrapper gui, TileEntityFactory tile, ResourceLocation def) - { - super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiRecipeType.png"), gui, def); + public GuiRecipeType(IGuiWrapper gui, TileEntityFactory tile, ResourceLocation def) { + super( + MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiRecipeType.png"), + gui, + def + ); - tileEntity = tile; - } - - @Override - public Rectangle4i getBounds(int guiWidth, int guiHeight) - { - return new Rectangle4i(guiWidth + 176, guiHeight + 70, 26, 63); - } + tileEntity = tile; + } - @Override - public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) - { - mc.renderEngine.bindTexture(RESOURCE); + @Override + public Rectangle4i getBounds(int guiWidth, int guiHeight) { + return new Rectangle4i(guiWidth + 176, guiHeight + 70, 26, 63); + } - guiObj.drawTexturedRect(guiWidth + 176, guiHeight + 70, 0, 0, 26, 63); + @Override + public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) { + mc.renderEngine.bindTexture(RESOURCE); - TileEntityFactory factory = tileEntity; - int displayInt = factory.getScaledRecipeProgress(15); + guiObj.drawTexturedRect(guiWidth + 176, guiHeight + 70, 0, 0, 26, 63); - guiObj.drawTexturedRect(guiWidth + 181, guiHeight + 94, 26, 0, 10, displayInt); + TileEntityFactory factory = tileEntity; + int displayInt = factory.getScaledRecipeProgress(15); - mc.renderEngine.bindTexture(defaultLocation); - } + guiObj.drawTexturedRect(guiWidth + 181, guiHeight + 94, 26, 0, 10, displayInt); - @Override - public void renderForeground(int xAxis, int yAxis) {} + mc.renderEngine.bindTexture(defaultLocation); + } - @Override - public void preMouseClicked(int xAxis, int yAxis, int button) - { - if(button == 0) - { - if(xAxis >= 180 && xAxis <= 196 && yAxis >= 75 && yAxis <= 91) - { - offsetX(26); - } - else if(xAxis >= 180 && xAxis <= 196 && yAxis >= 112 && yAxis <= 128) - { - offsetX(26); - } - } - } + @Override + public void renderForeground(int xAxis, int yAxis) {} - @Override - public void mouseClicked(int xAxis, int yAxis, int button) - { - if(button == 0) - { - if(xAxis >= 180 && xAxis <= 196 && yAxis >= 75 && yAxis <= 91) - { - offsetX(-26); - } - else if(xAxis >= 180 && xAxis <= 196 && yAxis >= 112 && yAxis <= 128) - { - offsetX(-26); - } - } - } + @Override + public void preMouseClicked(int xAxis, int yAxis, int button) { + if (button == 0) { + if (xAxis >= 180 && xAxis <= 196 && yAxis >= 75 && yAxis <= 91) { + offsetX(26); + } else if (xAxis >= 180 && xAxis <= 196 && yAxis >= 112 && yAxis <= 128) { + offsetX(26); + } + } + } + + @Override + public void mouseClicked(int xAxis, int yAxis, int button) { + if (button == 0) { + if (xAxis >= 180 && xAxis <= 196 && yAxis >= 75 && yAxis <= 91) { + offsetX(-26); + } else if (xAxis >= 180 && xAxis <= 196 && yAxis >= 112 && yAxis <= 128) { + offsetX(-26); + } + } + } } diff --git a/src/main/java/mekanism/client/gui/element/GuiRedstoneControl.java b/src/main/java/mekanism/client/gui/element/GuiRedstoneControl.java index 02ae61822..897649e58 100644 --- a/src/main/java/mekanism/client/gui/element/GuiRedstoneControl.java +++ b/src/main/java/mekanism/client/gui/element/GuiRedstoneControl.java @@ -1,5 +1,8 @@ package mekanism.client.gui.element; +import codechicken.lib.vec.Rectangle4i; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.client.gui.IGuiWrapper; import mekanism.client.sound.SoundHandler; @@ -11,83 +14,80 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; -import codechicken.lib.vec.Rectangle4i; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiRedstoneControl extends GuiElement -{ - TileEntity tileEntity; +public class GuiRedstoneControl extends GuiElement { + TileEntity tileEntity; - public GuiRedstoneControl(IGuiWrapper gui, TileEntity tile, ResourceLocation def) - { - super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiRedstoneControl.png"), gui, def); + public GuiRedstoneControl(IGuiWrapper gui, TileEntity tile, ResourceLocation def) { + super( + MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiRedstoneControl.png"), + gui, + def + ); - tileEntity = tile; - } - - @Override - public Rectangle4i getBounds(int guiWidth, int guiHeight) - { - return new Rectangle4i(guiWidth + 176, guiHeight + 138, 26, 26); - } + tileEntity = tile; + } - @Override - public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) - { - mc.renderEngine.bindTexture(RESOURCE); + @Override + public Rectangle4i getBounds(int guiWidth, int guiHeight) { + return new Rectangle4i(guiWidth + 176, guiHeight + 138, 26, 26); + } - guiObj.drawTexturedRect(guiWidth + 176, guiHeight + 138, 0, 0, 26, 26); + @Override + public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) { + mc.renderEngine.bindTexture(RESOURCE); - IRedstoneControl control = (IRedstoneControl)tileEntity; - int renderX = 26 + (18*control.getControlType().ordinal()); + guiObj.drawTexturedRect(guiWidth + 176, guiHeight + 138, 0, 0, 26, 26); - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 142 && yAxis <= 160) - { - guiObj.drawTexturedRect(guiWidth + 179, guiHeight + 142, renderX, 0, 18, 18); - } - else { - guiObj.drawTexturedRect(guiWidth + 179, guiHeight + 142, renderX, 18, 18, 18); - } + IRedstoneControl control = (IRedstoneControl) tileEntity; + int renderX = 26 + (18 * control.getControlType().ordinal()); - mc.renderEngine.bindTexture(defaultLocation); - } + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 142 && yAxis <= 160) { + guiObj.drawTexturedRect(guiWidth + 179, guiHeight + 142, renderX, 0, 18, 18); + } else { + guiObj.drawTexturedRect(guiWidth + 179, guiHeight + 142, renderX, 18, 18, 18); + } - @Override - public void renderForeground(int xAxis, int yAxis) - { - mc.renderEngine.bindTexture(RESOURCE); + mc.renderEngine.bindTexture(defaultLocation); + } - IRedstoneControl control = (IRedstoneControl)tileEntity; + @Override + public void renderForeground(int xAxis, int yAxis) { + mc.renderEngine.bindTexture(RESOURCE); - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 142 && yAxis <= 160) - { - displayTooltip(control.getControlType().getDisplay(), xAxis, yAxis); - } + IRedstoneControl control = (IRedstoneControl) tileEntity; - mc.renderEngine.bindTexture(defaultLocation); - } + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 142 && yAxis <= 160) { + displayTooltip(control.getControlType().getDisplay(), xAxis, yAxis); + } - @Override - public void preMouseClicked(int xAxis, int yAxis, int button) {} + mc.renderEngine.bindTexture(defaultLocation); + } - @Override - public void mouseClicked(int xAxis, int yAxis, int button) - { - IRedstoneControl control = (IRedstoneControl)tileEntity; + @Override + public void preMouseClicked(int xAxis, int yAxis, int button) {} - if(button == 0) - { - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 142 && yAxis <= 160) - { - RedstoneControl current = control.getControlType(); - int ordinalToSet = current.ordinal() < (RedstoneControl.values().length-1) ? current.ordinal()+1 : 0; - if(ordinalToSet == RedstoneControl.PULSE.ordinal() && !control.canPulse()) ordinalToSet = 0; + @Override + public void mouseClicked(int xAxis, int yAxis, int button) { + IRedstoneControl control = (IRedstoneControl) tileEntity; - SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new RedstoneControlMessage(Coord4D.get(tileEntity), RedstoneControl.values()[ordinalToSet])); - } - } - } + if (button == 0) { + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 142 && yAxis <= 160) { + RedstoneControl current = control.getControlType(); + int ordinalToSet + = current.ordinal() < (RedstoneControl.values().length - 1) + ? current.ordinal() + 1 + : 0; + if (ordinalToSet == RedstoneControl.PULSE.ordinal() + && !control.canPulse()) + ordinalToSet = 0; + + SoundHandler.playSound("gui.button.press"); + Mekanism.packetHandler.sendToServer(new RedstoneControlMessage( + Coord4D.get(tileEntity), RedstoneControl.values()[ordinalToSet] + )); + } + } + } } diff --git a/src/main/java/mekanism/client/gui/element/GuiScrollList.java b/src/main/java/mekanism/client/gui/element/GuiScrollList.java index 5c9f0a421..1fd1dfecc 100644 --- a/src/main/java/mekanism/client/gui/element/GuiScrollList.java +++ b/src/main/java/mekanism/client/gui/element/GuiScrollList.java @@ -3,247 +3,247 @@ package mekanism.client.gui.element; import java.util.ArrayList; import java.util.List; +import codechicken.lib.vec.Rectangle4i; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.gui.IGuiWrapper; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; -import codechicken.lib.vec.Rectangle4i; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiScrollList extends GuiElement -{ - public int xSize; - public int size; - - public int xPosition; - public int yPosition; - - public List textEntries = new ArrayList(); - - public int dragOffset = 0; - - public int selected = -1; - - public float scroll; - - public boolean isDragging; - - public GuiScrollList(IGuiWrapper gui, ResourceLocation def, int x, int y, int sizeX, int sizeY) - { - super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiScrollList.png"), gui, def); - - xPosition = x; - yPosition = y; - - xSize = sizeX; - size = sizeY; - } - - public boolean hasSelection() - { - return selected != -1; - } - - public int getSelection() - { - return selected; - } - - public void setText(List text) - { - if(text == null) - { - textEntries.clear(); - return; - } - - if(selected > text.size()-1) - { - selected = -1; - } - - textEntries = text; - - if(textEntries.size()<=size) - { - scroll = 0; - } - } - - @Override - public Rectangle4i getBounds(int guiWidth, int guiHeight) - { - return new Rectangle4i(guiWidth + xPosition, guiHeight + yPosition, xSize, size*10); - } +public class GuiScrollList extends GuiElement { + public int xSize; + public int size; - @Override - public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) - { - mc.renderEngine.bindTexture(RESOURCE); - - drawBlack(guiWidth, guiHeight); - drawSelected(guiWidth, guiHeight, selected); + public int xPosition; + public int yPosition; - mc.renderEngine.bindTexture(defaultLocation); - } - - public void drawBlack(int guiWidth, int guiHeight) - { - int xDisplays = xSize/10 + (xSize%10 > 0 ? 1 : 0); - - for(int yIter = 0; yIter < size; yIter++) - { - for(int xIter = 0; xIter < xDisplays; xIter++) - { - int width = (xSize%10 > 0 && xIter == xDisplays-1 ? xSize%10 : 10); - guiObj.drawTexturedRect(guiWidth + xPosition + (xIter*10), guiHeight + yPosition + (yIter*10), 0, 0, width, 10); - } - } - } - - public void drawSelected(int guiWidth, int guiHeight, int index) - { - int scroll = getScrollIndex(); - - if(selected != -1 && index >= scroll && index <= scroll+size-1) - { - int xDisplays = xSize/10 + (xSize%10 > 0 ? 1 : 0); - - for(int xIter = 0; xIter < xDisplays; xIter++) - { - int width = (xSize%10 > 0 && xIter == xDisplays-1 ? xSize%10 : 10); - guiObj.drawTexturedRect(guiWidth + xPosition + (xIter*10), guiHeight + yPosition + (index-scroll)*10, 0, 10, width, 10); - } - } - } - - public void drawScroll() - { - GL11.glColor4f(1, 1, 1, 1); - - int xStart = xPosition + xSize - 6; - int yStart = yPosition; - - for(int i = 0; i < size; i++) - { - guiObj.drawTexturedRect(xStart, yStart+(i*10), 10, 1, 6, 10); - } - - guiObj.drawTexturedRect(xStart, yStart, 10, 0, 6, 1); - guiObj.drawTexturedRect(xStart, yStart+(size*10)-1, 10, 0, 6, 1); - - guiObj.drawTexturedRect(xStart+1, yStart+1+getScroll(), 16, 0, 4, 4); - } - - public int getMaxScroll() - { - return (size*10)-2; - } - - public int getScroll() - { - return Math.max(Math.min((int)(scroll*(getMaxScroll()-4)), (getMaxScroll()-4)), 0); - } - - public int getScrollIndex() - { - if(textEntries.size() <= size) - { - return 0; - } + public List textEntries = new ArrayList(); - return (int)((textEntries.size()*scroll) - (((float)size/(float)textEntries.size()))*scroll); - } + public int dragOffset = 0; - @Override - public void renderForeground(int xAxis, int yAxis) - { - if(!textEntries.isEmpty()) - { - for(int i = 0; i < size; i++) - { - int index = getScrollIndex() + i; - - if(index <= textEntries.size()-1) - { - renderScaledText(textEntries.get(index), xPosition + 1, yPosition + 1 + (10*i), 0x00CD00, xSize-6); - } - } - } - - mc.renderEngine.bindTexture(RESOURCE); - - drawScroll(); + public int selected = -1; - mc.renderEngine.bindTexture(defaultLocation); - } + public float scroll; - @Override - public void preMouseClicked(int xAxis, int yAxis, int button) {} + public boolean isDragging; - @Override - public void mouseClicked(int xAxis, int yAxis, int button) - { - if(button == 0) - { - int xStart = xPosition + xSize - 5; - - if(xAxis >= xStart && xAxis <= xStart+4 && yAxis >= getScroll()+yPosition+1 && yAxis <= getScroll()+4+yPosition+1) - { - if(textEntries.size()>size) - { - dragOffset = yAxis - (getScroll()+yPosition+1); - isDragging = true; - } - } - else if(xAxis >= xPosition && xAxis <= xPosition + xSize-6 && yAxis >= yPosition && yAxis <= yPosition+size*10) - { - int index = getScrollIndex(); - selected = -1; - - for(int i = 0; i < size; i++) - { - if(index+i <= textEntries.size()-1) - { - if(yAxis >= (yPosition + i*10) && yAxis <= (yPosition + i*10 + 10)) - { - selected = index+i; - break; - } - } - } - } - } - } - - @Override - public void mouseClickMove(int xAxis, int yAxis, int button, long ticks) - { - super.mouseClickMove(xAxis, yAxis, button, ticks); + public GuiScrollList( + IGuiWrapper gui, ResourceLocation def, int x, int y, int sizeX, int sizeY + ) { + super( + MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiScrollList.png"), + gui, + def + ); - if(isDragging) - { - scroll = Math.min(Math.max((float)(yAxis-(yPosition+1)-dragOffset)/(float)(getMaxScroll()-4), 0), 1); - } - } + xPosition = x; + yPosition = y; - @Override - public void mouseMovedOrUp(int xAxis, int yAxis, int type) - { - super.mouseMovedOrUp(xAxis, yAxis, type); + xSize = sizeX; + size = sizeY; + } - if(type == 0) - { - if(isDragging) - { - dragOffset = 0; - isDragging = false; - } - } - } + public boolean hasSelection() { + return selected != -1; + } + + public int getSelection() { + return selected; + } + + public void setText(List text) { + if (text == null) { + textEntries.clear(); + return; + } + + if (selected > text.size() - 1) { + selected = -1; + } + + textEntries = text; + + if (textEntries.size() <= size) { + scroll = 0; + } + } + + @Override + public Rectangle4i getBounds(int guiWidth, int guiHeight) { + return new Rectangle4i( + guiWidth + xPosition, guiHeight + yPosition, xSize, size * 10 + ); + } + + @Override + public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) { + mc.renderEngine.bindTexture(RESOURCE); + + drawBlack(guiWidth, guiHeight); + drawSelected(guiWidth, guiHeight, selected); + + mc.renderEngine.bindTexture(defaultLocation); + } + + public void drawBlack(int guiWidth, int guiHeight) { + int xDisplays = xSize / 10 + (xSize % 10 > 0 ? 1 : 0); + + for (int yIter = 0; yIter < size; yIter++) { + for (int xIter = 0; xIter < xDisplays; xIter++) { + int width = (xSize % 10 > 0 && xIter == xDisplays - 1 ? xSize % 10 : 10); + guiObj.drawTexturedRect( + guiWidth + xPosition + (xIter * 10), + guiHeight + yPosition + (yIter * 10), + 0, + 0, + width, + 10 + ); + } + } + } + + public void drawSelected(int guiWidth, int guiHeight, int index) { + int scroll = getScrollIndex(); + + if (selected != -1 && index >= scroll && index <= scroll + size - 1) { + int xDisplays = xSize / 10 + (xSize % 10 > 0 ? 1 : 0); + + for (int xIter = 0; xIter < xDisplays; xIter++) { + int width = (xSize % 10 > 0 && xIter == xDisplays - 1 ? xSize % 10 : 10); + guiObj.drawTexturedRect( + guiWidth + xPosition + (xIter * 10), + guiHeight + yPosition + (index - scroll) * 10, + 0, + 10, + width, + 10 + ); + } + } + } + + public void drawScroll() { + GL11.glColor4f(1, 1, 1, 1); + + int xStart = xPosition + xSize - 6; + int yStart = yPosition; + + for (int i = 0; i < size; i++) { + guiObj.drawTexturedRect(xStart, yStart + (i * 10), 10, 1, 6, 10); + } + + guiObj.drawTexturedRect(xStart, yStart, 10, 0, 6, 1); + guiObj.drawTexturedRect(xStart, yStart + (size * 10) - 1, 10, 0, 6, 1); + + guiObj.drawTexturedRect(xStart + 1, yStart + 1 + getScroll(), 16, 0, 4, 4); + } + + public int getMaxScroll() { + return (size * 10) - 2; + } + + public int getScroll() { + return Math.max( + Math.min((int) (scroll * (getMaxScroll() - 4)), (getMaxScroll() - 4)), 0 + ); + } + + public int getScrollIndex() { + if (textEntries.size() <= size) { + return 0; + } + + return (int + ) ((textEntries.size() * scroll) + - (((float) size / (float) textEntries.size())) * scroll); + } + + @Override + public void renderForeground(int xAxis, int yAxis) { + if (!textEntries.isEmpty()) { + for (int i = 0; i < size; i++) { + int index = getScrollIndex() + i; + + if (index <= textEntries.size() - 1) { + renderScaledText( + textEntries.get(index), + xPosition + 1, + yPosition + 1 + (10 * i), + 0x00CD00, + xSize - 6 + ); + } + } + } + + mc.renderEngine.bindTexture(RESOURCE); + + drawScroll(); + + mc.renderEngine.bindTexture(defaultLocation); + } + + @Override + public void preMouseClicked(int xAxis, int yAxis, int button) {} + + @Override + public void mouseClicked(int xAxis, int yAxis, int button) { + if (button == 0) { + int xStart = xPosition + xSize - 5; + + if (xAxis >= xStart && xAxis <= xStart + 4 + && yAxis >= getScroll() + yPosition + 1 + && yAxis <= getScroll() + 4 + yPosition + 1) { + if (textEntries.size() > size) { + dragOffset = yAxis - (getScroll() + yPosition + 1); + isDragging = true; + } + } else if (xAxis >= xPosition && xAxis <= xPosition + xSize - 6 && yAxis >= yPosition && yAxis <= yPosition + size * 10) { + int index = getScrollIndex(); + selected = -1; + + for (int i = 0; i < size; i++) { + if (index + i <= textEntries.size() - 1) { + if (yAxis >= (yPosition + i * 10) + && yAxis <= (yPosition + i * 10 + 10)) { + selected = index + i; + break; + } + } + } + } + } + } + + @Override + public void mouseClickMove(int xAxis, int yAxis, int button, long ticks) { + super.mouseClickMove(xAxis, yAxis, button, ticks); + + if (isDragging) { + scroll = Math.min( + Math.max( + (float) (yAxis - (yPosition + 1) - dragOffset) + / (float) (getMaxScroll() - 4), + 0 + ), + 1 + ); + } + } + + @Override + public void mouseMovedOrUp(int xAxis, int yAxis, int type) { + super.mouseMovedOrUp(xAxis, yAxis, type); + + if (type == 0) { + if (isDragging) { + dragOffset = 0; + isDragging = false; + } + } + } } diff --git a/src/main/java/mekanism/client/gui/element/GuiSecurityTab.java b/src/main/java/mekanism/client/gui/element/GuiSecurityTab.java index ece37160e..8928420a0 100644 --- a/src/main/java/mekanism/client/gui/element/GuiSecurityTab.java +++ b/src/main/java/mekanism/client/gui/element/GuiSecurityTab.java @@ -1,5 +1,8 @@ package mekanism.client.gui.element; +import codechicken.lib.vec.Rectangle4i; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.MekanismConfig.general; @@ -21,181 +24,174 @@ import mekanism.common.util.SecurityUtils; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; -import codechicken.lib.vec.Rectangle4i; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiSecurityTab extends GuiElement -{ - public boolean isItem; - - public TileEntity tileEntity; +public class GuiSecurityTab extends GuiElement { + public boolean isItem; - public GuiSecurityTab(IGuiWrapper gui, TileEntity tile, ResourceLocation def) - { - super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiSecurityTab.png"), gui, def); + public TileEntity tileEntity; - tileEntity = tile; - } - - public GuiSecurityTab(IGuiWrapper gui, ResourceLocation def) - { - super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiSecurityTab.png"), gui, def); - - isItem = true; - } - - @Override - public Rectangle4i getBounds(int guiWidth, int guiHeight) - { - return new Rectangle4i(guiWidth + 176, guiHeight + 32, 26, 26); - } + public GuiSecurityTab(IGuiWrapper gui, TileEntity tile, ResourceLocation def) { + super( + MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiSecurityTab.png"), + gui, + def + ); - @Override - public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) - { - mc.renderEngine.bindTexture(RESOURCE); + tileEntity = tile; + } - guiObj.drawTexturedRect(guiWidth + 176, guiHeight + 32, 0, 0, 26, 26); + public GuiSecurityTab(IGuiWrapper gui, ResourceLocation def) { + super( + MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiSecurityTab.png"), + gui, + def + ); - SecurityMode mode = getSecurity(); - SecurityData data = MekanismClient.clientSecurityMap.get(getOwner()); - - if(data != null && data.override) - { - mode = data.mode; - } - - int renderX = 26 + (18*mode.ordinal()); + isItem = true; + } - if(getOwner() != null && getOwner().equals(mc.thePlayer.getCommandSenderName()) && - (data == null || !data.override)) - { - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 36 && yAxis <= 54) - { - guiObj.drawTexturedRect(guiWidth + 179, guiHeight + 36, renderX, 0, 18, 18); - } - else { - guiObj.drawTexturedRect(guiWidth + 179, guiHeight + 36, renderX, 18, 18, 18); - } - } - else { - guiObj.drawTexturedRect(guiWidth + 179, guiHeight + 36, renderX, 36, 18, 18); - } + @Override + public Rectangle4i getBounds(int guiWidth, int guiHeight) { + return new Rectangle4i(guiWidth + 176, guiHeight + 32, 26, 26); + } - mc.renderEngine.bindTexture(defaultLocation); - } + @Override + public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) { + mc.renderEngine.bindTexture(RESOURCE); - @Override - public void renderForeground(int xAxis, int yAxis) - { - mc.renderEngine.bindTexture(RESOURCE); + guiObj.drawTexturedRect(guiWidth + 176, guiHeight + 32, 0, 0, 26, 26); - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 36 && yAxis <= 54) - { - String securityDisplay = isItem ? SecurityUtils.getSecurityDisplay(getItem(), Side.CLIENT) : SecurityUtils.getSecurityDisplay(tileEntity, Side.CLIENT); - String securityText = EnumColor.GREY + LangUtils.localize("gui.security") + ": " + securityDisplay; - String ownerText = SecurityUtils.getOwnerDisplay(mc.thePlayer.getCommandSenderName(), getOwner()); - String overrideText = EnumColor.RED + "(" + LangUtils.localize("gui.overridden") + ")"; - - if(isItem ? SecurityUtils.isOverridden(getItem(), Side.CLIENT) : SecurityUtils.isOverridden(tileEntity, Side.CLIENT)) - { - displayTooltips(ListUtils.asList(securityText, ownerText, overrideText), xAxis, yAxis); - } - else { - displayTooltips(ListUtils.asList(securityText, ownerText), xAxis, yAxis); - } - } + SecurityMode mode = getSecurity(); + SecurityData data = MekanismClient.clientSecurityMap.get(getOwner()); - mc.renderEngine.bindTexture(defaultLocation); - } - - private SecurityFrequency getFrequency() - { - if(isItem) - { - if(getItem() == null || !(getItem().getItem() instanceof ISecurityItem)) - { - mc.thePlayer.closeScreen(); - return null; - } - - return SecurityUtils.getFrequency(getOwner()); - } - else { - return ((ISecurityTile)tileEntity).getSecurity().getFrequency(); - } - } - - private SecurityMode getSecurity() - { - if(!general.allowProtection) { - return SecurityMode.PUBLIC; - } - if(isItem) - { - if(getItem() == null || !(getItem().getItem() instanceof ISecurityItem)) - { - mc.thePlayer.closeScreen(); - return SecurityMode.PUBLIC; - } - - return ((ISecurityItem)getItem().getItem()).getSecurity(getItem()); - } - else { - return ((ISecurityTile)tileEntity).getSecurity().getMode(); - } - } - - private String getOwner() - { - if(isItem) - { - if(getItem() == null || !(getItem().getItem() instanceof ISecurityItem)) - { - mc.thePlayer.closeScreen(); - return null; - } - - return ((ISecurityItem)getItem().getItem()).getOwner(getItem()); - } - else { - return ((ISecurityTile)tileEntity).getSecurity().getOwner(); - } - } - - private ItemStack getItem() - { - return mc.thePlayer.getCurrentEquippedItem(); - } + if (data != null && data.override) { + mode = data.mode; + } - @Override - public void preMouseClicked(int xAxis, int yAxis, int button) {} + int renderX = 26 + (18 * mode.ordinal()); - @Override - public void mouseClicked(int xAxis, int yAxis, int button) - { - if(button == 0 && general.allowProtection) - { - if(getOwner() != null && mc.thePlayer.getCommandSenderName().equals(getOwner())) - { - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 36 && yAxis <= 54) - { - SecurityMode current = getSecurity(); - int ordinalToSet = current.ordinal() < (SecurityMode.values().length-1) ? current.ordinal()+1 : 0; - - SoundHandler.playSound("gui.button.press"); - - if(isItem) - { - Mekanism.packetHandler.sendToServer(new SecurityModeMessage(SecurityMode.values()[ordinalToSet])); - } - else { - Mekanism.packetHandler.sendToServer(new SecurityModeMessage(Coord4D.get(tileEntity), SecurityMode.values()[ordinalToSet])); - } - } - } - } - } + if (getOwner() != null && getOwner().equals(mc.thePlayer.getCommandSenderName()) + && (data == null || !data.override)) { + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 36 && yAxis <= 54) { + guiObj.drawTexturedRect( + guiWidth + 179, guiHeight + 36, renderX, 0, 18, 18 + ); + } else { + guiObj.drawTexturedRect( + guiWidth + 179, guiHeight + 36, renderX, 18, 18, 18 + ); + } + } else { + guiObj.drawTexturedRect(guiWidth + 179, guiHeight + 36, renderX, 36, 18, 18); + } + + mc.renderEngine.bindTexture(defaultLocation); + } + + @Override + public void renderForeground(int xAxis, int yAxis) { + mc.renderEngine.bindTexture(RESOURCE); + + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 36 && yAxis <= 54) { + String securityDisplay = isItem + ? SecurityUtils.getSecurityDisplay(getItem(), Side.CLIENT) + : SecurityUtils.getSecurityDisplay(tileEntity, Side.CLIENT); + String securityText = EnumColor.GREY + LangUtils.localize("gui.security") + + ": " + securityDisplay; + String ownerText = SecurityUtils.getOwnerDisplay( + mc.thePlayer.getCommandSenderName(), getOwner() + ); + String overrideText + = EnumColor.RED + "(" + LangUtils.localize("gui.overridden") + ")"; + + if (isItem ? SecurityUtils.isOverridden(getItem(), Side.CLIENT) + : SecurityUtils.isOverridden(tileEntity, Side.CLIENT)) { + displayTooltips( + ListUtils.asList(securityText, ownerText, overrideText), xAxis, yAxis + ); + } else { + displayTooltips(ListUtils.asList(securityText, ownerText), xAxis, yAxis); + } + } + + mc.renderEngine.bindTexture(defaultLocation); + } + + private SecurityFrequency getFrequency() { + if (isItem) { + if (getItem() == null || !(getItem().getItem() instanceof ISecurityItem)) { + mc.thePlayer.closeScreen(); + return null; + } + + return SecurityUtils.getFrequency(getOwner()); + } else { + return ((ISecurityTile) tileEntity).getSecurity().getFrequency(); + } + } + + private SecurityMode getSecurity() { + if (!general.allowProtection) { + return SecurityMode.PUBLIC; + } + if (isItem) { + if (getItem() == null || !(getItem().getItem() instanceof ISecurityItem)) { + mc.thePlayer.closeScreen(); + return SecurityMode.PUBLIC; + } + + return ((ISecurityItem) getItem().getItem()).getSecurity(getItem()); + } else { + return ((ISecurityTile) tileEntity).getSecurity().getMode(); + } + } + + private String getOwner() { + if (isItem) { + if (getItem() == null || !(getItem().getItem() instanceof ISecurityItem)) { + mc.thePlayer.closeScreen(); + return null; + } + + return ((ISecurityItem) getItem().getItem()).getOwner(getItem()); + } else { + return ((ISecurityTile) tileEntity).getSecurity().getOwner(); + } + } + + private ItemStack getItem() { + return mc.thePlayer.getCurrentEquippedItem(); + } + + @Override + public void preMouseClicked(int xAxis, int yAxis, int button) {} + + @Override + public void mouseClicked(int xAxis, int yAxis, int button) { + if (button == 0 && general.allowProtection) { + if (getOwner() != null + && mc.thePlayer.getCommandSenderName().equals(getOwner())) { + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 36 && yAxis <= 54) { + SecurityMode current = getSecurity(); + int ordinalToSet + = current.ordinal() < (SecurityMode.values().length - 1) + ? current.ordinal() + 1 + : 0; + + SoundHandler.playSound("gui.button.press"); + + if (isItem) { + Mekanism.packetHandler.sendToServer( + new SecurityModeMessage(SecurityMode.values()[ordinalToSet]) + ); + } else { + Mekanism.packetHandler.sendToServer(new SecurityModeMessage( + Coord4D.get(tileEntity), SecurityMode.values()[ordinalToSet] + )); + } + } + } + } + } } diff --git a/src/main/java/mekanism/client/gui/element/GuiSideConfigurationTab.java b/src/main/java/mekanism/client/gui/element/GuiSideConfigurationTab.java index 21d09df96..cb721f59a 100644 --- a/src/main/java/mekanism/client/gui/element/GuiSideConfigurationTab.java +++ b/src/main/java/mekanism/client/gui/element/GuiSideConfigurationTab.java @@ -1,5 +1,8 @@ package mekanism.client.gui.element; +import codechicken.lib.vec.Rectangle4i; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.client.gui.IGuiWrapper; import mekanism.client.sound.SoundHandler; @@ -10,72 +13,68 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; -import codechicken.lib.vec.Rectangle4i; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiSideConfigurationTab extends GuiElement -{ - public TileEntity tileEntity; +public class GuiSideConfigurationTab extends GuiElement { + public TileEntity tileEntity; - public GuiSideConfigurationTab(IGuiWrapper gui, TileEntity tile, ResourceLocation def) - { - super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiConfigurationTab.png"), gui, def); + public GuiSideConfigurationTab( + IGuiWrapper gui, TileEntity tile, ResourceLocation def + ) { + super( + MekanismUtils.getResource( + ResourceType.GUI_ELEMENT, "GuiConfigurationTab.png" + ), + gui, + def + ); - tileEntity = tile; - } - - @Override - public Rectangle4i getBounds(int guiWidth, int guiHeight) - { - return new Rectangle4i(guiWidth - 26, guiHeight + 6, 26, 26); - } + tileEntity = tile; + } - @Override - public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) - { - mc.renderEngine.bindTexture(RESOURCE); + @Override + public Rectangle4i getBounds(int guiWidth, int guiHeight) { + return new Rectangle4i(guiWidth - 26, guiHeight + 6, 26, 26); + } - guiObj.drawTexturedRect(guiWidth - 26, guiHeight + 6, 0, 0, 26, 26); + @Override + public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) { + mc.renderEngine.bindTexture(RESOURCE); - if(xAxis >= -21 && xAxis <= -3 && yAxis >= 10 && yAxis <= 28) - { - guiObj.drawTexturedRect(guiWidth - 21, guiHeight + 10, 26, 0, 18, 18); - } - else { - guiObj.drawTexturedRect(guiWidth - 21, guiHeight + 10, 26, 18, 18, 18); - } + guiObj.drawTexturedRect(guiWidth - 26, guiHeight + 6, 0, 0, 26, 26); - mc.renderEngine.bindTexture(defaultLocation); - } + if (xAxis >= -21 && xAxis <= -3 && yAxis >= 10 && yAxis <= 28) { + guiObj.drawTexturedRect(guiWidth - 21, guiHeight + 10, 26, 0, 18, 18); + } else { + guiObj.drawTexturedRect(guiWidth - 21, guiHeight + 10, 26, 18, 18, 18); + } - @Override - public void renderForeground(int xAxis, int yAxis) - { - mc.renderEngine.bindTexture(RESOURCE); + mc.renderEngine.bindTexture(defaultLocation); + } - if(xAxis >= -21 && xAxis <= -3 && yAxis >= 10 && yAxis <= 28) - { - displayTooltip(LangUtils.localize("gui.configuration.side"), xAxis, yAxis); - } + @Override + public void renderForeground(int xAxis, int yAxis) { + mc.renderEngine.bindTexture(RESOURCE); - mc.renderEngine.bindTexture(defaultLocation); - } + if (xAxis >= -21 && xAxis <= -3 && yAxis >= 10 && yAxis <= 28) { + displayTooltip(LangUtils.localize("gui.configuration.side"), xAxis, yAxis); + } - @Override - public void preMouseClicked(int xAxis, int yAxis, int button) {} + mc.renderEngine.bindTexture(defaultLocation); + } - @Override - public void mouseClicked(int xAxis, int yAxis, int button) - { - if(button == 0) - { - if(xAxis >= -21 && xAxis <= -3 && yAxis >= 10 && yAxis <= 28) - { - Mekanism.packetHandler.sendToServer(new SimpleGuiMessage(Coord4D.get(tileEntity), 0, 9)); + @Override + public void preMouseClicked(int xAxis, int yAxis, int button) {} + + @Override + public void mouseClicked(int xAxis, int yAxis, int button) { + if (button == 0) { + if (xAxis >= -21 && xAxis <= -3 && yAxis >= 10 && yAxis <= 28) { + Mekanism.packetHandler.sendToServer( + new SimpleGuiMessage(Coord4D.get(tileEntity), 0, 9) + ); SoundHandler.playSound("gui.button.press"); - } - } - } + } + } + } } diff --git a/src/main/java/mekanism/client/gui/element/GuiSlot.java b/src/main/java/mekanism/client/gui/element/GuiSlot.java index c3c8af31d..c11adc30a 100644 --- a/src/main/java/mekanism/client/gui/element/GuiSlot.java +++ b/src/main/java/mekanism/client/gui/element/GuiSlot.java @@ -1,127 +1,130 @@ package mekanism.client.gui.element; +import codechicken.lib.vec.Rectangle4i; import mekanism.client.gui.IGuiWrapper; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.util.ResourceLocation; -import codechicken.lib.vec.Rectangle4i; -public class GuiSlot extends GuiElement -{ - protected int xLocation; - protected int yLocation; +public class GuiSlot extends GuiElement { + protected int xLocation; + protected int yLocation; - protected int textureX; - protected int textureY; + protected int textureX; + protected int textureY; - protected int width; - protected int height; + protected int width; + protected int height; - protected SlotOverlay overlay = null; + protected SlotOverlay overlay = null; - public GuiSlot(SlotType type, IGuiWrapper gui, ResourceLocation def, int x, int y) - { - super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiSlot.png"), gui, def); + public GuiSlot(SlotType type, IGuiWrapper gui, ResourceLocation def, int x, int y) { + super( + MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiSlot.png"), gui, def + ); - xLocation = x; - yLocation = y; + xLocation = x; + yLocation = y; - width = type.width; - height = type.height; + width = type.width; + height = type.height; - textureX = type.textureX; - textureY = type.textureY; - } + textureX = type.textureX; + textureY = type.textureY; + } - public GuiSlot with(SlotOverlay overlay) - { - this.overlay = overlay; - return this; - } - - @Override - public Rectangle4i getBounds(int guiWidth, int guiHeight) - { - return new Rectangle4i(guiWidth + xLocation, guiHeight + yLocation, width, height); - } + public GuiSlot with(SlotOverlay overlay) { + this.overlay = overlay; + return this; + } - @Override - public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) - { - mc.renderEngine.bindTexture(RESOURCE); + @Override + public Rectangle4i getBounds(int guiWidth, int guiHeight) { + return new Rectangle4i( + guiWidth + xLocation, guiHeight + yLocation, width, height + ); + } - guiObj.drawTexturedRect(guiWidth + xLocation, guiHeight + yLocation, textureX, textureY, width, height); + @Override + public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) { + mc.renderEngine.bindTexture(RESOURCE); - if(overlay != null) - { - int w = overlay.width; - int h = overlay.height; - int xLocationOverlay = xLocation + (width-w)/2; - int yLocationOverlay = yLocation + (height-h)/2; + guiObj.drawTexturedRect( + guiWidth + xLocation, guiHeight + yLocation, textureX, textureY, width, height + ); - guiObj.drawTexturedRect(guiWidth + xLocationOverlay, guiHeight + yLocationOverlay, overlay.textureX, overlay.textureY, w, h); - } + if (overlay != null) { + int w = overlay.width; + int h = overlay.height; + int xLocationOverlay = xLocation + (width - w) / 2; + int yLocationOverlay = yLocation + (height - h) / 2; - mc.renderEngine.bindTexture(defaultLocation); - } + guiObj.drawTexturedRect( + guiWidth + xLocationOverlay, + guiHeight + yLocationOverlay, + overlay.textureX, + overlay.textureY, + w, + h + ); + } - @Override - public void renderForeground(int xAxis, int yAxis) {} + mc.renderEngine.bindTexture(defaultLocation); + } - @Override - public void preMouseClicked(int xAxis, int yAxis, int button) {} + @Override + public void renderForeground(int xAxis, int yAxis) {} - @Override - public void mouseClicked(int xAxis, int yAxis, int button) {} + @Override + public void preMouseClicked(int xAxis, int yAxis, int button) {} - public enum SlotType - { - NORMAL(18, 18, 0, 0), - POWER(18, 18, 18, 0), - INPUT(18, 18, 36, 0), - EXTRA(18, 18, 54, 0), - OUTPUT(18, 18, 72, 0), - OUTPUT_LARGE(26, 26, 90, 0), - OUTPUT_WIDE(42, 26, 116, 0); + @Override + public void mouseClicked(int xAxis, int yAxis, int button) {} - public int width; - public int height; + public enum SlotType { + NORMAL(18, 18, 0, 0), + POWER(18, 18, 18, 0), + INPUT(18, 18, 36, 0), + EXTRA(18, 18, 54, 0), + OUTPUT(18, 18, 72, 0), + OUTPUT_LARGE(26, 26, 90, 0), + OUTPUT_WIDE(42, 26, 116, 0); - public int textureX; - public int textureY; + public int width; + public int height; - private SlotType(int w, int h, int x, int y) - { - width = w; - height = h; + public int textureX; + public int textureY; - textureX = x; - textureY = y; - } - } + private SlotType(int w, int h, int x, int y) { + width = w; + height = h; - public enum SlotOverlay - { - MINUS(18, 18, 0, 18), - PLUS(18, 18, 18, 18), - POWER(18, 18, 36, 18), - INPUT(18, 18, 54, 18), - OUTPUT(18, 18, 72, 18), - CHECK(18, 18, 0, 36); + textureX = x; + textureY = y; + } + } - public int width; - public int height; + public enum SlotOverlay { + MINUS(18, 18, 0, 18), + PLUS(18, 18, 18, 18), + POWER(18, 18, 36, 18), + INPUT(18, 18, 54, 18), + OUTPUT(18, 18, 72, 18), + CHECK(18, 18, 0, 36); - public int textureX; - public int textureY; + public int width; + public int height; - private SlotOverlay(int w, int h, int x, int y) - { - width = w; - height = h; + public int textureX; + public int textureY; - textureX = x; - textureY = y; - } - } + private SlotOverlay(int w, int h, int x, int y) { + width = w; + height = h; + + textureX = x; + textureY = y; + } + } } diff --git a/src/main/java/mekanism/client/gui/element/GuiSortingTab.java b/src/main/java/mekanism/client/gui/element/GuiSortingTab.java index 69400f688..7ea842069 100644 --- a/src/main/java/mekanism/client/gui/element/GuiSortingTab.java +++ b/src/main/java/mekanism/client/gui/element/GuiSortingTab.java @@ -2,6 +2,9 @@ package mekanism.client.gui.element; import java.util.ArrayList; +import codechicken.lib.vec.Rectangle4i; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.client.gui.IGuiWrapper; import mekanism.client.sound.SoundHandler; @@ -12,76 +15,73 @@ import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.util.ResourceLocation; -import codechicken.lib.vec.Rectangle4i; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiSortingTab extends GuiElement -{ - public TileEntityFactory tileEntity; +public class GuiSortingTab extends GuiElement { + public TileEntityFactory tileEntity; - public GuiSortingTab(IGuiWrapper gui, TileEntityFactory tile, ResourceLocation def) - { - super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiSortingTab.png"), gui, def); + public GuiSortingTab(IGuiWrapper gui, TileEntityFactory tile, ResourceLocation def) { + super( + MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiSortingTab.png"), + gui, + def + ); - tileEntity = tile; - } - - @Override - public Rectangle4i getBounds(int guiWidth, int guiHeight) - { - return new Rectangle4i(guiWidth - 26, guiHeight + 62, 26, 35); - } + tileEntity = tile; + } - @Override - public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) - { - mc.renderEngine.bindTexture(RESOURCE); + @Override + public Rectangle4i getBounds(int guiWidth, int guiHeight) { + return new Rectangle4i(guiWidth - 26, guiHeight + 62, 26, 35); + } - guiObj.drawTexturedRect(guiWidth - 26, guiHeight + 62, 0, 0, 26, 35); + @Override + public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) { + mc.renderEngine.bindTexture(RESOURCE); - if(xAxis >= -21 && xAxis <= -3 && yAxis >= 66 && yAxis <= 84) - { - guiObj.drawTexturedRect(guiWidth - 21, guiHeight + 66, 26, 0, 18, 18); - } - else { - guiObj.drawTexturedRect(guiWidth - 21, guiHeight + 66, 26, 18, 18, 18); - } + guiObj.drawTexturedRect(guiWidth - 26, guiHeight + 62, 0, 0, 26, 35); - mc.renderEngine.bindTexture(defaultLocation); - } + if (xAxis >= -21 && xAxis <= -3 && yAxis >= 66 && yAxis <= 84) { + guiObj.drawTexturedRect(guiWidth - 21, guiHeight + 66, 26, 0, 18, 18); + } else { + guiObj.drawTexturedRect(guiWidth - 21, guiHeight + 66, 26, 18, 18, 18); + } - @Override - public void renderForeground(int xAxis, int yAxis) - { - mc.renderEngine.bindTexture(RESOURCE); + mc.renderEngine.bindTexture(defaultLocation); + } - getFontRenderer().drawString(LangUtils.transOnOff(((TileEntityFactory)tileEntity).sorting), -21, 86, 0x0404040); + @Override + public void renderForeground(int xAxis, int yAxis) { + mc.renderEngine.bindTexture(RESOURCE); - if(xAxis >= -21 && xAxis <= -3 && yAxis >= 66 && yAxis <= 84) - { - displayTooltip(LangUtils.localize("gui.factory.autoSort"), xAxis, yAxis); - } + getFontRenderer().drawString( + LangUtils.transOnOff(((TileEntityFactory) tileEntity).sorting), + -21, + 86, + 0x0404040 + ); - mc.renderEngine.bindTexture(defaultLocation); - } + if (xAxis >= -21 && xAxis <= -3 && yAxis >= 66 && yAxis <= 84) { + displayTooltip(LangUtils.localize("gui.factory.autoSort"), xAxis, yAxis); + } - @Override - public void preMouseClicked(int xAxis, int yAxis, int button) {} + mc.renderEngine.bindTexture(defaultLocation); + } - @Override - public void mouseClicked(int xAxis, int yAxis, int button) - { - if(button == 0) - { - if(xAxis >= -21 && xAxis <= -3 && yAxis >= 66 && yAxis <= 84) - { - ArrayList data = new ArrayList(); - data.add(0); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); + @Override + public void preMouseClicked(int xAxis, int yAxis, int button) {} + + @Override + public void mouseClicked(int xAxis, int yAxis, int button) { + if (button == 0) { + if (xAxis >= -21 && xAxis <= -3 && yAxis >= 66 && yAxis <= 84) { + ArrayList data = new ArrayList(); + data.add(0); + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); SoundHandler.playSound("gui.button.press"); - } - } - } + } + } + } } diff --git a/src/main/java/mekanism/client/gui/element/GuiTransporterConfigTab.java b/src/main/java/mekanism/client/gui/element/GuiTransporterConfigTab.java index 35457b507..bb8f0aca5 100644 --- a/src/main/java/mekanism/client/gui/element/GuiTransporterConfigTab.java +++ b/src/main/java/mekanism/client/gui/element/GuiTransporterConfigTab.java @@ -1,5 +1,8 @@ package mekanism.client.gui.element; +import codechicken.lib.vec.Rectangle4i; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.client.gui.IGuiWrapper; import mekanism.client.sound.SoundHandler; @@ -10,74 +13,72 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; -import codechicken.lib.vec.Rectangle4i; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiTransporterConfigTab extends GuiElement -{ - public TileEntity tileEntity; - public int yPos; +public class GuiTransporterConfigTab extends GuiElement { + public TileEntity tileEntity; + public int yPos; - public GuiTransporterConfigTab(IGuiWrapper gui, int y, TileEntity tile, ResourceLocation def) - { - super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiTransporterConfigTab.png"), gui, def); + public GuiTransporterConfigTab( + IGuiWrapper gui, int y, TileEntity tile, ResourceLocation def + ) { + super( + MekanismUtils.getResource( + ResourceType.GUI_ELEMENT, "GuiTransporterConfigTab.png" + ), + gui, + def + ); - yPos = y; - tileEntity = tile; - } - - @Override - public Rectangle4i getBounds(int guiWidth, int guiHeight) - { - return new Rectangle4i(guiWidth - 26, guiHeight + yPos, 26, 26); - } + yPos = y; + tileEntity = tile; + } - @Override - public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) - { - mc.renderEngine.bindTexture(RESOURCE); + @Override + public Rectangle4i getBounds(int guiWidth, int guiHeight) { + return new Rectangle4i(guiWidth - 26, guiHeight + yPos, 26, 26); + } - guiObj.drawTexturedRect(guiWidth - 26, guiHeight + yPos, 0, 0, 26, 26); + @Override + public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) { + mc.renderEngine.bindTexture(RESOURCE); - if(xAxis >= -21 && xAxis <= -3 && yAxis >= yPos+4 && yAxis <= yPos+22) - { - guiObj.drawTexturedRect(guiWidth - 21, guiHeight + yPos+4, 26, 0, 18, 18); - } - else { - guiObj.drawTexturedRect(guiWidth - 21, guiHeight + yPos+4, 26, 18, 18, 18); - } + guiObj.drawTexturedRect(guiWidth - 26, guiHeight + yPos, 0, 0, 26, 26); - mc.renderEngine.bindTexture(defaultLocation); - } + if (xAxis >= -21 && xAxis <= -3 && yAxis >= yPos + 4 && yAxis <= yPos + 22) { + guiObj.drawTexturedRect(guiWidth - 21, guiHeight + yPos + 4, 26, 0, 18, 18); + } else { + guiObj.drawTexturedRect(guiWidth - 21, guiHeight + yPos + 4, 26, 18, 18, 18); + } - @Override - public void renderForeground(int xAxis, int yAxis) - { - mc.renderEngine.bindTexture(RESOURCE); + mc.renderEngine.bindTexture(defaultLocation); + } - if(xAxis >= -21 && xAxis <= -3 && yAxis >= yPos+4 && yAxis <= yPos+22) - { - displayTooltip(LangUtils.localize("gui.configuration.transporter"), xAxis, yAxis); - } + @Override + public void renderForeground(int xAxis, int yAxis) { + mc.renderEngine.bindTexture(RESOURCE); - mc.renderEngine.bindTexture(defaultLocation); - } + if (xAxis >= -21 && xAxis <= -3 && yAxis >= yPos + 4 && yAxis <= yPos + 22) { + displayTooltip( + LangUtils.localize("gui.configuration.transporter"), xAxis, yAxis + ); + } - @Override - public void preMouseClicked(int xAxis, int yAxis, int button) {} + mc.renderEngine.bindTexture(defaultLocation); + } - @Override - public void mouseClicked(int xAxis, int yAxis, int button) - { - if(button == 0) - { - if(xAxis >= -21 && xAxis <= -3 && yAxis >= yPos+4 && yAxis <= yPos+22) - { - Mekanism.packetHandler.sendToServer(new SimpleGuiMessage(Coord4D.get(tileEntity), 0, 51)); + @Override + public void preMouseClicked(int xAxis, int yAxis, int button) {} + + @Override + public void mouseClicked(int xAxis, int yAxis, int button) { + if (button == 0) { + if (xAxis >= -21 && xAxis <= -3 && yAxis >= yPos + 4 && yAxis <= yPos + 22) { + Mekanism.packetHandler.sendToServer( + new SimpleGuiMessage(Coord4D.get(tileEntity), 0, 51) + ); SoundHandler.playSound("gui.button.press"); - } - } - } + } + } + } } diff --git a/src/main/java/mekanism/client/gui/element/GuiUpgradeTab.java b/src/main/java/mekanism/client/gui/element/GuiUpgradeTab.java index 051a8eb8a..04bb8837d 100644 --- a/src/main/java/mekanism/client/gui/element/GuiUpgradeTab.java +++ b/src/main/java/mekanism/client/gui/element/GuiUpgradeTab.java @@ -1,5 +1,6 @@ package mekanism.client.gui.element; +import codechicken.lib.vec.Rectangle4i; import mekanism.api.Coord4D; import mekanism.client.gui.IGuiWrapper; import mekanism.client.sound.SoundHandler; @@ -10,69 +11,63 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; -import codechicken.lib.vec.Rectangle4i; -public class GuiUpgradeTab extends GuiElement -{ - TileEntity tileEntity; +public class GuiUpgradeTab extends GuiElement { + TileEntity tileEntity; - public GuiUpgradeTab(IGuiWrapper gui, TileEntity tile, ResourceLocation def) - { - super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiUpgradeTab.png"), gui, def); + public GuiUpgradeTab(IGuiWrapper gui, TileEntity tile, ResourceLocation def) { + super( + MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiUpgradeTab.png"), + gui, + def + ); - tileEntity = tile; - } - - @Override - public Rectangle4i getBounds(int guiWidth, int guiHeight) - { - return new Rectangle4i(guiWidth + 176, guiHeight + 6, 26, 26); - } + tileEntity = tile; + } - @Override - public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) - { - mc.renderEngine.bindTexture(RESOURCE); + @Override + public Rectangle4i getBounds(int guiWidth, int guiHeight) { + return new Rectangle4i(guiWidth + 176, guiHeight + 6, 26, 26); + } - guiObj.drawTexturedRect(guiWidth + 176, guiHeight + 6, 0, 0, 26, 26); - - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) - { - guiObj.drawTexturedRect(guiWidth + 179, guiHeight + 10, 26, 0, 18, 18); - } - else { - guiObj.drawTexturedRect(guiWidth + 179, guiHeight + 10, 26, 18, 18, 18); - } + @Override + public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) { + mc.renderEngine.bindTexture(RESOURCE); - mc.renderEngine.bindTexture(defaultLocation); - } + guiObj.drawTexturedRect(guiWidth + 176, guiHeight + 6, 0, 0, 26, 26); - @Override - public void renderForeground(int xAxis, int yAxis) - { - mc.renderEngine.bindTexture(RESOURCE); + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) { + guiObj.drawTexturedRect(guiWidth + 179, guiHeight + 10, 26, 0, 18, 18); + } else { + guiObj.drawTexturedRect(guiWidth + 179, guiHeight + 10, 26, 18, 18, 18); + } - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) - { - displayTooltip(LangUtils.localize("gui.upgrades"), xAxis, yAxis); - } + mc.renderEngine.bindTexture(defaultLocation); + } - mc.renderEngine.bindTexture(defaultLocation); - } + @Override + public void renderForeground(int xAxis, int yAxis) { + mc.renderEngine.bindTexture(RESOURCE); - @Override - public void preMouseClicked(int xAxis, int yAxis, int button) {} + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) { + displayTooltip(LangUtils.localize("gui.upgrades"), xAxis, yAxis); + } - @Override - public void mouseClicked(int xAxis, int yAxis, int button) - { - if(button == 0) - { - if(xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) - { - Mekanism.packetHandler.sendToServer(new SimpleGuiMessage(Coord4D.get(tileEntity), 0, 43)); - SoundHandler.playSound("gui.button.press"); - } - } - } + mc.renderEngine.bindTexture(defaultLocation); + } + + @Override + public void preMouseClicked(int xAxis, int yAxis, int button) {} + + @Override + public void mouseClicked(int xAxis, int yAxis, int button) { + if (button == 0) { + if (xAxis >= 179 && xAxis <= 197 && yAxis >= 10 && yAxis <= 28) { + Mekanism.packetHandler.sendToServer( + new SimpleGuiMessage(Coord4D.get(tileEntity), 0, 43) + ); + SoundHandler.playSound("gui.button.press"); + } + } + } } diff --git a/src/main/java/mekanism/client/gui/element/GuiVisualsTab.java b/src/main/java/mekanism/client/gui/element/GuiVisualsTab.java index a638548b3..d46a57d18 100644 --- a/src/main/java/mekanism/client/gui/element/GuiVisualsTab.java +++ b/src/main/java/mekanism/client/gui/element/GuiVisualsTab.java @@ -1,5 +1,6 @@ package mekanism.client.gui.element; +import codechicken.lib.vec.Rectangle4i; import mekanism.client.gui.IGuiWrapper; import mekanism.client.sound.SoundHandler; import mekanism.common.tile.TileEntityDigitalMiner; @@ -7,69 +8,68 @@ import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.util.ResourceLocation; -import codechicken.lib.vec.Rectangle4i; -public class GuiVisualsTab extends GuiElement -{ - private TileEntityDigitalMiner tileEntity; +public class GuiVisualsTab extends GuiElement { + private TileEntityDigitalMiner tileEntity; - public GuiVisualsTab(IGuiWrapper gui, TileEntityDigitalMiner tile, ResourceLocation def) - { - super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiVisualsTab.png"), gui, def); + public GuiVisualsTab( + IGuiWrapper gui, TileEntityDigitalMiner tile, ResourceLocation def + ) { + super( + MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiVisualsTab.png"), + gui, + def + ); - tileEntity = tile; - } - - @Override - public Rectangle4i getBounds(int guiWidth, int guiHeight) - { - return new Rectangle4i(guiWidth - 26, guiHeight + 6, 26, 26); - } + tileEntity = tile; + } - @Override - public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) - { - mc.renderEngine.bindTexture(RESOURCE); + @Override + public Rectangle4i getBounds(int guiWidth, int guiHeight) { + return new Rectangle4i(guiWidth - 26, guiHeight + 6, 26, 26); + } - guiObj.drawTexturedRect(guiWidth - 26, guiHeight + 6, 0, 0, 26, 26); - - if(xAxis >= -21 && xAxis <= -3 && yAxis >= 10 && yAxis <= 28) - { - guiObj.drawTexturedRect(guiWidth - 21, guiHeight + 10, 26, 0, 18, 18); - } - else { - guiObj.drawTexturedRect(guiWidth - 21, guiHeight + 10, 26, 18, 18, 18); - } + @Override + public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) { + mc.renderEngine.bindTexture(RESOURCE); - mc.renderEngine.bindTexture(defaultLocation); - } + guiObj.drawTexturedRect(guiWidth - 26, guiHeight + 6, 0, 0, 26, 26); - @Override - public void renderForeground(int xAxis, int yAxis) - { - mc.renderEngine.bindTexture(RESOURCE); + if (xAxis >= -21 && xAxis <= -3 && yAxis >= 10 && yAxis <= 28) { + guiObj.drawTexturedRect(guiWidth - 21, guiHeight + 10, 26, 0, 18, 18); + } else { + guiObj.drawTexturedRect(guiWidth - 21, guiHeight + 10, 26, 18, 18, 18); + } - if(xAxis >= -21 && xAxis <= -3 && yAxis >= 10 && yAxis <= 28) - { - displayTooltip(LangUtils.localize("gui.visuals") + ": " + LangUtils.transOnOff(tileEntity.clientRendering), xAxis, yAxis); - } + mc.renderEngine.bindTexture(defaultLocation); + } - mc.renderEngine.bindTexture(defaultLocation); - } + @Override + public void renderForeground(int xAxis, int yAxis) { + mc.renderEngine.bindTexture(RESOURCE); - @Override - public void preMouseClicked(int xAxis, int yAxis, int button) {} + if (xAxis >= -21 && xAxis <= -3 && yAxis >= 10 && yAxis <= 28) { + displayTooltip( + LangUtils.localize("gui.visuals") + ": " + + LangUtils.transOnOff(tileEntity.clientRendering), + xAxis, + yAxis + ); + } - @Override - public void mouseClicked(int xAxis, int yAxis, int button) - { - if(button == 0) - { - if(xAxis >= -21 && xAxis <= -3 && yAxis >= 10 && yAxis <= 28) - { - tileEntity.clientRendering = !tileEntity.clientRendering; - SoundHandler.playSound("gui.button.press"); - } - } - } + mc.renderEngine.bindTexture(defaultLocation); + } + + @Override + public void preMouseClicked(int xAxis, int yAxis, int button) {} + + @Override + public void mouseClicked(int xAxis, int yAxis, int button) { + if (button == 0) { + if (xAxis >= -21 && xAxis <= -3 && yAxis >= 10 && yAxis <= 28) { + tileEntity.clientRendering = !tileEntity.clientRendering; + SoundHandler.playSound("gui.button.press"); + } + } + } } diff --git a/src/main/java/mekanism/client/model/ModelArmoredJetpack.java b/src/main/java/mekanism/client/model/ModelArmoredJetpack.java index 55083bec4..18ab6a020 100644 --- a/src/main/java/mekanism/client/model/ModelArmoredJetpack.java +++ b/src/main/java/mekanism/client/model/ModelArmoredJetpack.java @@ -3,285 +3,280 @@ package mekanism.client.model; import mekanism.client.render.MekanismRenderer; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; - import org.lwjgl.opengl.GL11; -public class ModelArmoredJetpack extends ModelBase -{ - ModelRenderer Packtop; - ModelRenderer Packbottom; - ModelRenderer Thrusterleft; - ModelRenderer Thrusterright; - ModelRenderer Fueltuberight; - ModelRenderer Fueltubeleft; - ModelRenderer Packmid; - ModelRenderer Packcore; - ModelRenderer WingsupportL; - ModelRenderer WingsupportR; - ModelRenderer Packtoprear; - ModelRenderer ExtendosupportL; - ModelRenderer ExtendosupportR; - ModelRenderer WingbladeL; - ModelRenderer WingbladeR; - ModelRenderer Packdoodad2; - ModelRenderer Packdoodad3; - ModelRenderer Bottomthruster; - ModelRenderer light1; - ModelRenderer light2; - ModelRenderer light3; - ModelRenderer Chestplate; - ModelRenderer Leftguardtop; - ModelRenderer Rightguardtop; - ModelRenderer middleplate; - ModelRenderer Rightguardbot; - ModelRenderer Leftguardbot; - ModelRenderer Rightlight; - ModelRenderer Leftlight; +public class ModelArmoredJetpack extends ModelBase { + ModelRenderer Packtop; + ModelRenderer Packbottom; + ModelRenderer Thrusterleft; + ModelRenderer Thrusterright; + ModelRenderer Fueltuberight; + ModelRenderer Fueltubeleft; + ModelRenderer Packmid; + ModelRenderer Packcore; + ModelRenderer WingsupportL; + ModelRenderer WingsupportR; + ModelRenderer Packtoprear; + ModelRenderer ExtendosupportL; + ModelRenderer ExtendosupportR; + ModelRenderer WingbladeL; + ModelRenderer WingbladeR; + ModelRenderer Packdoodad2; + ModelRenderer Packdoodad3; + ModelRenderer Bottomthruster; + ModelRenderer light1; + ModelRenderer light2; + ModelRenderer light3; + ModelRenderer Chestplate; + ModelRenderer Leftguardtop; + ModelRenderer Rightguardtop; + ModelRenderer middleplate; + ModelRenderer Rightguardbot; + ModelRenderer Leftguardbot; + ModelRenderer Rightlight; + ModelRenderer Leftlight; - public ModelArmoredJetpack() - { - textureWidth = 128; - textureHeight = 64; + public ModelArmoredJetpack() { + textureWidth = 128; + textureHeight = 64; - Packtop = new ModelRenderer(this, 92, 28); - Packtop.addBox(-4F, 0F, 4F, 8, 4, 1); - Packtop.setRotationPoint(0F, 0F, 0F); - Packtop.setTextureSize(128, 64); - Packtop.mirror = true; - setRotation(Packtop, 0.2094395F, 0F, 0F); - Packbottom = new ModelRenderer(this, 92, 42); - Packbottom.addBox(-4F, 4.1F, 1.5F, 8, 4, 4); - Packbottom.setRotationPoint(0F, 0F, 0F); - Packbottom.setTextureSize(128, 64); - Packbottom.mirror = true; - setRotation(Packbottom, -0.0872665F, 0F, 0F); - Thrusterleft = new ModelRenderer(this, 69, 30); - Thrusterleft.addBox(7.8F, 1.5F, -2.4F, 3, 3, 3); - Thrusterleft.setRotationPoint(0F, 0F, 0F); - Thrusterleft.setTextureSize(128, 64); - Thrusterleft.mirror = true; - setRotation(Thrusterleft, 0.7853982F, -0.715585F, 0.3490659F); - Thrusterright = new ModelRenderer(this, 69, 30); - Thrusterright.addBox(-10.8F, 1.5F, -2.4F, 3, 3, 3); - Thrusterright.setRotationPoint(0F, 0F, 0F); - Thrusterright.setTextureSize(128, 64); - Thrusterright.mirror = true; - setRotation(Thrusterright, 0.7853982F, 0.715585F, -0.3490659F); - Fueltuberight = new ModelRenderer(this, 92, 23); - Fueltuberight.addBox(-11.2F, 2F, -1.9F, 8, 2, 2); - Fueltuberight.setRotationPoint(0F, 0F, 0F); - Fueltuberight.setTextureSize(128, 64); - Fueltuberight.mirror = true; - setRotation(Fueltuberight, 0.7853982F, 0.715585F, -0.3490659F); - Fueltubeleft = new ModelRenderer(this, 92, 23); - Fueltubeleft.addBox(3.2F, 2F, -1.9F, 8, 2, 2); - Fueltubeleft.setRotationPoint(0F, 0F, 0F); - Fueltubeleft.setTextureSize(128, 64); - Fueltubeleft.mirror = true; - setRotation(Fueltubeleft, 0.7853982F, -0.715585F, 0.3490659F); - Packmid = new ModelRenderer(this, 92, 34); - Packmid.addBox(-4F, 3.3F, 1.5F, 8, 1, 4); - Packmid.setRotationPoint(0F, 0F, 0F); - Packmid.setTextureSize(128, 64); - Packmid.mirror = true; - setRotation(Packmid, 0F, 0F, 0F); - Packcore = new ModelRenderer(this, 69, 2); - Packcore.addBox(-3.5F, 3F, 2F, 7, 1, 3); - Packcore.setRotationPoint(0F, 0F, 0F); - Packcore.setTextureSize(128, 64); - Packcore.mirror = true; - setRotation(Packcore, 0F, 0F, 0F); - WingsupportL = new ModelRenderer(this, 71, 55); - WingsupportL.addBox(3F, -1F, 2.2F, 7, 2, 2); - WingsupportL.setRotationPoint(0F, 0F, 0F); - WingsupportL.setTextureSize(128, 64); - WingsupportL.mirror = true; - setRotation(WingsupportL, 0F, 0F, 0.2792527F); - WingsupportR = new ModelRenderer(this, 71, 55); - WingsupportR.addBox(-10F, -1F, 2.2F, 7, 2, 2); - WingsupportR.setRotationPoint(0F, 0F, 0F); - WingsupportR.setTextureSize(128, 64); - WingsupportR.mirror = true; - setRotation(WingsupportR, 0F, 0F, -0.2792527F); - Packtoprear = new ModelRenderer(this, 106, 28); - Packtoprear.addBox(-4F, 1F, 1F, 8, 3, 3); - Packtoprear.setRotationPoint(0F, 0F, 0F); - Packtoprear.setTextureSize(128, 64); - Packtoprear.mirror = true; - setRotation(Packtoprear, 0.2094395F, 0F, 0F); - ExtendosupportL = new ModelRenderer(this, 94, 16); - ExtendosupportL.addBox(8F, -0.2F, 2.5F, 9, 1, 1); - ExtendosupportL.setRotationPoint(0F, 0F, 0F); - ExtendosupportL.setTextureSize(128, 64); - ExtendosupportL.mirror = true; - setRotation(ExtendosupportL, 0F, 0F, 0.2792527F); - ExtendosupportR = new ModelRenderer(this, 94, 16); - ExtendosupportR.addBox(-17F, -0.2F, 2.5F, 9, 1, 1); - ExtendosupportR.setRotationPoint(0F, 0F, 0F); - ExtendosupportR.setTextureSize(128, 64); - ExtendosupportR.mirror = true; - setRotation(ExtendosupportR, 0F, 0F, -0.2792527F); - WingbladeL = new ModelRenderer(this, 62, 5); - WingbladeL.addBox(3.3F, 1.1F, 3F, 14, 2, 0); - WingbladeL.setRotationPoint(0F, 0F, 0F); - WingbladeL.setTextureSize(128, 64); - WingbladeL.mirror = true; - setRotation(WingbladeL, 0F, 0F, 0.2094395F); - WingbladeR = new ModelRenderer(this, 62, 5); - WingbladeR.addBox(-17.3F, 1.1F, 3F, 14, 2, 0); - WingbladeR.setRotationPoint(0F, 0F, 0F); - WingbladeR.setTextureSize(128, 64); - WingbladeR.mirror = true; - setRotation(WingbladeR, 0F, 0F, -0.2094395F); - Packdoodad2 = new ModelRenderer(this, 116, 0); - Packdoodad2.addBox(1F, 0.5F, 4.2F, 2, 1, 1); - Packdoodad2.setRotationPoint(0F, 0F, 0F); - Packdoodad2.setTextureSize(128, 64); - Packdoodad2.mirror = true; - setRotation(Packdoodad2, 0.2094395F, 0F, 0F); - Packdoodad3 = new ModelRenderer(this, 116, 0); - Packdoodad3.addBox(1F, 2F, 4.2F, 2, 1, 1); - Packdoodad3.setRotationPoint(0F, 0F, 0F); - Packdoodad3.setTextureSize(128, 64); - Packdoodad3.mirror = true; - setRotation(Packdoodad3, 0.2094395F, 0F, 0F); - Bottomthruster = new ModelRenderer(this, 68, 26); - Bottomthruster.addBox(-3F, 8F, 2.333333F, 6, 1, 2); - Bottomthruster.setRotationPoint(0F, 0F, 0F); - Bottomthruster.setTextureSize(128, 64); - Bottomthruster.mirror = true; - setRotation(Bottomthruster, 0F, 0F, 0F); - light1 = new ModelRenderer(this, 55, 2); - light1.addBox(2F, 6.55F, 4F, 1, 1, 1); - light1.setRotationPoint(0F, 0F, 0F); - light1.setTextureSize(128, 64); - light1.mirror = true; - setRotation(light1, 0F, 0F, 0F); - light2 = new ModelRenderer(this, 55, 2); - light2.addBox(0F, 6.55F, 4F, 1, 1, 1); - light2.setRotationPoint(0F, 0F, 0F); - light2.setTextureSize(128, 64); - light2.mirror = true; - setRotation(light2, 0F, 0F, 0F); - light3 = new ModelRenderer(this, 55, 2); - light3.addBox(-3F, 6.55F, 4F, 1, 1, 1); - light3.setRotationPoint(0F, 0F, 0F); - light3.setTextureSize(128, 64); - light3.mirror = true; - setRotation(light3, 0F, 0F, 0F); - Chestplate = new ModelRenderer(this, 104, 22); - Chestplate.addBox(-4F, 1.333333F, -3F, 8, 4, 3); - Chestplate.setRotationPoint(0F, 0F, 0F); - Chestplate.setTextureSize(128, 64); - Chestplate.mirror = true; - setRotation(Chestplate, -0.3665191F, 0F, 0F); - Leftguardtop = new ModelRenderer(this, 87, 31); - Leftguardtop.addBox(0.95F, 3F, -5F, 3, 4, 2); - Leftguardtop.setRotationPoint(0F, 0F, 0F); - Leftguardtop.setTextureSize(128, 64); - Leftguardtop.mirror = true; - setRotation(Leftguardtop, 0.2094395F, 0F, 0F); - Leftguardtop.mirror = false; - Rightguardtop = new ModelRenderer(this, 87, 31); - Rightguardtop.addBox(-3.95F, 3F, -5F, 3, 4, 2); - Rightguardtop.setRotationPoint(0F, 0F, 0F); - Rightguardtop.setTextureSize(128, 64); - Rightguardtop.mirror = true; - setRotation(Rightguardtop, 0.2094395F, 0F, 0F); - middleplate = new ModelRenderer(this, 93, 20); - middleplate.addBox(-1.5F, 3F, -6.2F, 3, 5, 3); - middleplate.setRotationPoint(0F, 0F, 0F); - middleplate.setTextureSize(128, 64); - middleplate.mirror = true; - setRotation(middleplate, 0.2094395F, 0F, 0F); - middleplate.mirror = false; - Rightguardbot = new ModelRenderer(this, 84, 30); - Rightguardbot.addBox(-3.5F, 5.5F, -6.5F, 2, 2, 2); - Rightguardbot.setRotationPoint(0F, 0F, 0F); - Rightguardbot.setTextureSize(128, 64); - Rightguardbot.mirror = true; - setRotation(Rightguardbot, 0.4712389F, 0F, 0F); - Rightguardbot.mirror = false; - Leftguardbot = new ModelRenderer(this, 84, 30); - Leftguardbot.addBox(1.5F, 5.5F, -6.5F, 2, 2, 2); - Leftguardbot.setRotationPoint(0F, 0F, 0F); - Leftguardbot.setTextureSize(128, 64); - Leftguardbot.mirror = true; - setRotation(Leftguardbot, 0.4712389F, 0F, 0F); - Rightlight = new ModelRenderer(this, 81, 0); - Rightlight.addBox(-3F, 4F, -4.5F, 1, 3, 1); - Rightlight.setRotationPoint(0F, 0F, 0F); - Rightlight.setTextureSize(128, 64); - Rightlight.mirror = true; - setRotation(Rightlight, 0F, 0F, 0F); - Leftlight = new ModelRenderer(this, 81, 0); - Leftlight.addBox(2F, 4F, -4.5F, 1, 3, 1); - Leftlight.setRotationPoint(0F, 0F, 0F); - Leftlight.setTextureSize(128, 64); - Leftlight.mirror = true; - setRotation(Leftlight, 0F, 0F, 0F); - } + Packtop = new ModelRenderer(this, 92, 28); + Packtop.addBox(-4F, 0F, 4F, 8, 4, 1); + Packtop.setRotationPoint(0F, 0F, 0F); + Packtop.setTextureSize(128, 64); + Packtop.mirror = true; + setRotation(Packtop, 0.2094395F, 0F, 0F); + Packbottom = new ModelRenderer(this, 92, 42); + Packbottom.addBox(-4F, 4.1F, 1.5F, 8, 4, 4); + Packbottom.setRotationPoint(0F, 0F, 0F); + Packbottom.setTextureSize(128, 64); + Packbottom.mirror = true; + setRotation(Packbottom, -0.0872665F, 0F, 0F); + Thrusterleft = new ModelRenderer(this, 69, 30); + Thrusterleft.addBox(7.8F, 1.5F, -2.4F, 3, 3, 3); + Thrusterleft.setRotationPoint(0F, 0F, 0F); + Thrusterleft.setTextureSize(128, 64); + Thrusterleft.mirror = true; + setRotation(Thrusterleft, 0.7853982F, -0.715585F, 0.3490659F); + Thrusterright = new ModelRenderer(this, 69, 30); + Thrusterright.addBox(-10.8F, 1.5F, -2.4F, 3, 3, 3); + Thrusterright.setRotationPoint(0F, 0F, 0F); + Thrusterright.setTextureSize(128, 64); + Thrusterright.mirror = true; + setRotation(Thrusterright, 0.7853982F, 0.715585F, -0.3490659F); + Fueltuberight = new ModelRenderer(this, 92, 23); + Fueltuberight.addBox(-11.2F, 2F, -1.9F, 8, 2, 2); + Fueltuberight.setRotationPoint(0F, 0F, 0F); + Fueltuberight.setTextureSize(128, 64); + Fueltuberight.mirror = true; + setRotation(Fueltuberight, 0.7853982F, 0.715585F, -0.3490659F); + Fueltubeleft = new ModelRenderer(this, 92, 23); + Fueltubeleft.addBox(3.2F, 2F, -1.9F, 8, 2, 2); + Fueltubeleft.setRotationPoint(0F, 0F, 0F); + Fueltubeleft.setTextureSize(128, 64); + Fueltubeleft.mirror = true; + setRotation(Fueltubeleft, 0.7853982F, -0.715585F, 0.3490659F); + Packmid = new ModelRenderer(this, 92, 34); + Packmid.addBox(-4F, 3.3F, 1.5F, 8, 1, 4); + Packmid.setRotationPoint(0F, 0F, 0F); + Packmid.setTextureSize(128, 64); + Packmid.mirror = true; + setRotation(Packmid, 0F, 0F, 0F); + Packcore = new ModelRenderer(this, 69, 2); + Packcore.addBox(-3.5F, 3F, 2F, 7, 1, 3); + Packcore.setRotationPoint(0F, 0F, 0F); + Packcore.setTextureSize(128, 64); + Packcore.mirror = true; + setRotation(Packcore, 0F, 0F, 0F); + WingsupportL = new ModelRenderer(this, 71, 55); + WingsupportL.addBox(3F, -1F, 2.2F, 7, 2, 2); + WingsupportL.setRotationPoint(0F, 0F, 0F); + WingsupportL.setTextureSize(128, 64); + WingsupportL.mirror = true; + setRotation(WingsupportL, 0F, 0F, 0.2792527F); + WingsupportR = new ModelRenderer(this, 71, 55); + WingsupportR.addBox(-10F, -1F, 2.2F, 7, 2, 2); + WingsupportR.setRotationPoint(0F, 0F, 0F); + WingsupportR.setTextureSize(128, 64); + WingsupportR.mirror = true; + setRotation(WingsupportR, 0F, 0F, -0.2792527F); + Packtoprear = new ModelRenderer(this, 106, 28); + Packtoprear.addBox(-4F, 1F, 1F, 8, 3, 3); + Packtoprear.setRotationPoint(0F, 0F, 0F); + Packtoprear.setTextureSize(128, 64); + Packtoprear.mirror = true; + setRotation(Packtoprear, 0.2094395F, 0F, 0F); + ExtendosupportL = new ModelRenderer(this, 94, 16); + ExtendosupportL.addBox(8F, -0.2F, 2.5F, 9, 1, 1); + ExtendosupportL.setRotationPoint(0F, 0F, 0F); + ExtendosupportL.setTextureSize(128, 64); + ExtendosupportL.mirror = true; + setRotation(ExtendosupportL, 0F, 0F, 0.2792527F); + ExtendosupportR = new ModelRenderer(this, 94, 16); + ExtendosupportR.addBox(-17F, -0.2F, 2.5F, 9, 1, 1); + ExtendosupportR.setRotationPoint(0F, 0F, 0F); + ExtendosupportR.setTextureSize(128, 64); + ExtendosupportR.mirror = true; + setRotation(ExtendosupportR, 0F, 0F, -0.2792527F); + WingbladeL = new ModelRenderer(this, 62, 5); + WingbladeL.addBox(3.3F, 1.1F, 3F, 14, 2, 0); + WingbladeL.setRotationPoint(0F, 0F, 0F); + WingbladeL.setTextureSize(128, 64); + WingbladeL.mirror = true; + setRotation(WingbladeL, 0F, 0F, 0.2094395F); + WingbladeR = new ModelRenderer(this, 62, 5); + WingbladeR.addBox(-17.3F, 1.1F, 3F, 14, 2, 0); + WingbladeR.setRotationPoint(0F, 0F, 0F); + WingbladeR.setTextureSize(128, 64); + WingbladeR.mirror = true; + setRotation(WingbladeR, 0F, 0F, -0.2094395F); + Packdoodad2 = new ModelRenderer(this, 116, 0); + Packdoodad2.addBox(1F, 0.5F, 4.2F, 2, 1, 1); + Packdoodad2.setRotationPoint(0F, 0F, 0F); + Packdoodad2.setTextureSize(128, 64); + Packdoodad2.mirror = true; + setRotation(Packdoodad2, 0.2094395F, 0F, 0F); + Packdoodad3 = new ModelRenderer(this, 116, 0); + Packdoodad3.addBox(1F, 2F, 4.2F, 2, 1, 1); + Packdoodad3.setRotationPoint(0F, 0F, 0F); + Packdoodad3.setTextureSize(128, 64); + Packdoodad3.mirror = true; + setRotation(Packdoodad3, 0.2094395F, 0F, 0F); + Bottomthruster = new ModelRenderer(this, 68, 26); + Bottomthruster.addBox(-3F, 8F, 2.333333F, 6, 1, 2); + Bottomthruster.setRotationPoint(0F, 0F, 0F); + Bottomthruster.setTextureSize(128, 64); + Bottomthruster.mirror = true; + setRotation(Bottomthruster, 0F, 0F, 0F); + light1 = new ModelRenderer(this, 55, 2); + light1.addBox(2F, 6.55F, 4F, 1, 1, 1); + light1.setRotationPoint(0F, 0F, 0F); + light1.setTextureSize(128, 64); + light1.mirror = true; + setRotation(light1, 0F, 0F, 0F); + light2 = new ModelRenderer(this, 55, 2); + light2.addBox(0F, 6.55F, 4F, 1, 1, 1); + light2.setRotationPoint(0F, 0F, 0F); + light2.setTextureSize(128, 64); + light2.mirror = true; + setRotation(light2, 0F, 0F, 0F); + light3 = new ModelRenderer(this, 55, 2); + light3.addBox(-3F, 6.55F, 4F, 1, 1, 1); + light3.setRotationPoint(0F, 0F, 0F); + light3.setTextureSize(128, 64); + light3.mirror = true; + setRotation(light3, 0F, 0F, 0F); + Chestplate = new ModelRenderer(this, 104, 22); + Chestplate.addBox(-4F, 1.333333F, -3F, 8, 4, 3); + Chestplate.setRotationPoint(0F, 0F, 0F); + Chestplate.setTextureSize(128, 64); + Chestplate.mirror = true; + setRotation(Chestplate, -0.3665191F, 0F, 0F); + Leftguardtop = new ModelRenderer(this, 87, 31); + Leftguardtop.addBox(0.95F, 3F, -5F, 3, 4, 2); + Leftguardtop.setRotationPoint(0F, 0F, 0F); + Leftguardtop.setTextureSize(128, 64); + Leftguardtop.mirror = true; + setRotation(Leftguardtop, 0.2094395F, 0F, 0F); + Leftguardtop.mirror = false; + Rightguardtop = new ModelRenderer(this, 87, 31); + Rightguardtop.addBox(-3.95F, 3F, -5F, 3, 4, 2); + Rightguardtop.setRotationPoint(0F, 0F, 0F); + Rightguardtop.setTextureSize(128, 64); + Rightguardtop.mirror = true; + setRotation(Rightguardtop, 0.2094395F, 0F, 0F); + middleplate = new ModelRenderer(this, 93, 20); + middleplate.addBox(-1.5F, 3F, -6.2F, 3, 5, 3); + middleplate.setRotationPoint(0F, 0F, 0F); + middleplate.setTextureSize(128, 64); + middleplate.mirror = true; + setRotation(middleplate, 0.2094395F, 0F, 0F); + middleplate.mirror = false; + Rightguardbot = new ModelRenderer(this, 84, 30); + Rightguardbot.addBox(-3.5F, 5.5F, -6.5F, 2, 2, 2); + Rightguardbot.setRotationPoint(0F, 0F, 0F); + Rightguardbot.setTextureSize(128, 64); + Rightguardbot.mirror = true; + setRotation(Rightguardbot, 0.4712389F, 0F, 0F); + Rightguardbot.mirror = false; + Leftguardbot = new ModelRenderer(this, 84, 30); + Leftguardbot.addBox(1.5F, 5.5F, -6.5F, 2, 2, 2); + Leftguardbot.setRotationPoint(0F, 0F, 0F); + Leftguardbot.setTextureSize(128, 64); + Leftguardbot.mirror = true; + setRotation(Leftguardbot, 0.4712389F, 0F, 0F); + Rightlight = new ModelRenderer(this, 81, 0); + Rightlight.addBox(-3F, 4F, -4.5F, 1, 3, 1); + Rightlight.setRotationPoint(0F, 0F, 0F); + Rightlight.setTextureSize(128, 64); + Rightlight.mirror = true; + setRotation(Rightlight, 0F, 0F, 0F); + Leftlight = new ModelRenderer(this, 81, 0); + Leftlight.addBox(2F, 4F, -4.5F, 1, 3, 1); + Leftlight.setRotationPoint(0F, 0F, 0F); + Leftlight.setTextureSize(128, 64); + Leftlight.mirror = true; + setRotation(Leftlight, 0F, 0F, 0F); + } - public void render(float size) - { - Packtop.render(size); - Packbottom.render(size); - Thrusterleft.render(size); - Thrusterright.render(size); - Fueltuberight.render(size); - Fueltubeleft.render(size); - Packmid.render(size); - WingsupportL.render(size); - WingsupportR.render(size); - Packtoprear.render(size); - ExtendosupportL.render(size); - ExtendosupportR.render(size); - Packdoodad2.render(size); - Packdoodad3.render(size); - Bottomthruster.render(size); + public void render(float size) { + Packtop.render(size); + Packbottom.render(size); + Thrusterleft.render(size); + Thrusterright.render(size); + Fueltuberight.render(size); + Fueltubeleft.render(size); + Packmid.render(size); + WingsupportL.render(size); + WingsupportR.render(size); + Packtoprear.render(size); + ExtendosupportL.render(size); + ExtendosupportR.render(size); + Packdoodad2.render(size); + Packdoodad3.render(size); + Bottomthruster.render(size); - GL11.glPushMatrix(); - MekanismRenderer.blendOn(); - MekanismRenderer.glowOn(); - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glColor4f(1, 1, 1, 0.2F); + GL11.glPushMatrix(); + MekanismRenderer.blendOn(); + MekanismRenderer.glowOn(); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glColor4f(1, 1, 1, 0.2F); - WingbladeL.render(size); - WingbladeR.render(size); + WingbladeL.render(size); + WingbladeR.render(size); - GL11.glColor4f(1, 1, 1, 1); - GL11.glDisable(GL11.GL_CULL_FACE); - MekanismRenderer.glowOff(); - MekanismRenderer.blendOff(); - GL11.glPopMatrix(); + GL11.glColor4f(1, 1, 1, 1); + GL11.glDisable(GL11.GL_CULL_FACE); + MekanismRenderer.glowOff(); + MekanismRenderer.blendOff(); + GL11.glPopMatrix(); - MekanismRenderer.glowOn(); - light1.render(size); - light2.render(size); - light3.render(size); - Packcore.render(size); + MekanismRenderer.glowOn(); + light1.render(size); + light2.render(size); + light3.render(size); + Packcore.render(size); - GL11.glPushMatrix(); - GL11.glTranslatef(0.0F, 0.0F, -0.0625F); + GL11.glPushMatrix(); + GL11.glTranslatef(0.0F, 0.0F, -0.0625F); - Rightlight.render(size); - Leftlight.render(size); - MekanismRenderer.glowOff(); + Rightlight.render(size); + Leftlight.render(size); + MekanismRenderer.glowOff(); - Chestplate.render(size); - Leftguardtop.render(size); - Rightguardtop.render(size); - middleplate.render(size); - Rightguardbot.render(size); - Leftguardbot.render(size); + Chestplate.render(size); + Leftguardtop.render(size); + Rightguardtop.render(size); + middleplate.render(size); + Rightguardbot.render(size); + Leftguardbot.render(size); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/mekanism/client/model/ModelAtomicDisassembler.java b/src/main/java/mekanism/client/model/ModelAtomicDisassembler.java index c312595f5..585ebc0ac 100644 --- a/src/main/java/mekanism/client/model/ModelAtomicDisassembler.java +++ b/src/main/java/mekanism/client/model/ModelAtomicDisassembler.java @@ -3,162 +3,157 @@ package mekanism.client.model; import mekanism.client.render.MekanismRenderer; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; - import org.lwjgl.opengl.GL11; -public class ModelAtomicDisassembler extends ModelBase -{ - ModelRenderer Shape1; - ModelRenderer Shape2; - ModelRenderer Shape5; - ModelRenderer Shape6; - ModelRenderer Shape7; - ModelRenderer Shape9; - ModelRenderer Shape16; - ModelRenderer Shape10; - ModelRenderer Shape3; - ModelRenderer Shape11; - ModelRenderer Shape4; - ModelRenderer Shape12; - ModelRenderer Shape13; - ModelRenderer Shape14; - ModelRenderer Shape15; - ModelRenderer Shape8; +public class ModelAtomicDisassembler extends ModelBase { + ModelRenderer Shape1; + ModelRenderer Shape2; + ModelRenderer Shape5; + ModelRenderer Shape6; + ModelRenderer Shape7; + ModelRenderer Shape9; + ModelRenderer Shape16; + ModelRenderer Shape10; + ModelRenderer Shape3; + ModelRenderer Shape11; + ModelRenderer Shape4; + ModelRenderer Shape12; + ModelRenderer Shape13; + ModelRenderer Shape14; + ModelRenderer Shape15; + ModelRenderer Shape8; - public ModelAtomicDisassembler() - { - textureWidth = 64; - textureHeight = 32; + public ModelAtomicDisassembler() { + textureWidth = 64; + textureHeight = 32; - Shape1 = new ModelRenderer(this, 0, 10); - Shape1.addBox(0F, -1F, -3F, 1, 16, 1); - Shape1.setRotationPoint(0F, 0F, 0F); - Shape1.setTextureSize(64, 32); - Shape1.mirror = true; - setRotation(Shape1, 0F, 0F, 0F); - Shape2 = new ModelRenderer(this, 34, 9); - Shape2.addBox(-0.5F, -3.5F, -3.5F, 2, 5, 2); - Shape2.setRotationPoint(0F, 0F, 0F); - Shape2.setTextureSize(64, 32); - Shape2.mirror = true; - setRotation(Shape2, 0F, 0F, 0F); - Shape5 = new ModelRenderer(this, 42, 0); - Shape5.addBox(0F, -4F, -4F, 1, 2, 10); - Shape5.setRotationPoint(0F, 0F, 0F); - Shape5.setTextureSize(64, 32); - Shape5.mirror = true; - setRotation(Shape5, 0F, 0F, 0F); - Shape6 = new ModelRenderer(this, 24, 0); - Shape6.addBox(-5F, -5.7F, -5.5F, 3, 3, 6); - Shape6.setRotationPoint(0F, 0F, 0F); - Shape6.setTextureSize(64, 32); - Shape6.mirror = true; - setRotation(Shape6, 0F, 0F, 0.7853982F); - Shape7 = new ModelRenderer(this, 0, 0); - Shape7.addBox(-0.5F, -6F, -7F, 2, 2, 8); - Shape7.setRotationPoint(0F, 0F, 0F); - Shape7.setTextureSize(64, 32); - Shape7.mirror = true; - setRotation(Shape7, 0F, 0F, 0F); - Shape9 = new ModelRenderer(this, 60, 0); - Shape9.addBox(0F, -0.5333334F, -9.6F, 1, 3, 1); - Shape9.setRotationPoint(0F, 0F, 0F); - Shape9.setTextureSize(64, 32); - Shape9.mirror = true; - setRotation(Shape9, -0.7853982F, 0F, 0F); - Shape16 = new ModelRenderer(this, 58, 0); - Shape16.addBox(0F, -9.58F, -4F, 1, 5, 2); - Shape16.setRotationPoint(0F, 0F, 0F); - Shape16.setTextureSize(64, 32); - Shape16.mirror = true; - setRotation(Shape16, 0.7853982F, 0F, 0F); - Shape10 = new ModelRenderer(this, 12, 0); - Shape10.addBox(-0.5F, -8.2F, -2.5F, 2, 1, 1); - Shape10.setRotationPoint(0F, 0F, 0F); - Shape10.setTextureSize(64, 32); - Shape10.mirror = true; - setRotation(Shape10, 0.7853982F, 0F, 0F); - Shape3 = new ModelRenderer(this, 56, 0); - Shape3.addBox(0F, -2.44F, -6.07F, 1, 2, 3); - Shape3.setRotationPoint(0F, 0F, 0F); - Shape3.setTextureSize(64, 32); - Shape3.mirror = true; - setRotation(Shape3, 0F, 0F, 0F); - Shape11 = new ModelRenderer(this, 42, 14); - Shape11.addBox(-0.5F, -0.5F, 3.5F, 2, 1, 1); - Shape11.setRotationPoint(0F, -4F, 0F); - Shape11.setTextureSize(64, 32); - Shape11.mirror = true; - setRotation(Shape11, 0F, 0F, 0F); - Shape4 = new ModelRenderer(this, 30, 16); - Shape4.addBox(-0.5F, -3.5F, -1.5F, 2, 1, 4); - Shape4.setRotationPoint(0F, 0F, 0F); - Shape4.setTextureSize(64, 32); - Shape4.mirror = true; - setRotation(Shape4, 0F, 0F, 0F); - Shape12 = new ModelRenderer(this, 42, 12); - Shape12.addBox(-0.5F, -4.5F, 1.5F, 2, 1, 1); - Shape12.setRotationPoint(0F, 0F, 0F); - Shape12.setTextureSize(64, 32); - Shape12.mirror = true; - setRotation(Shape12, 0F, 0F, 0F); - Shape13 = new ModelRenderer(this, 4, 10); - Shape13.addBox(0F, -5.3F, 0F, 1, 1, 7); - Shape13.setRotationPoint(0F, 0F, 0F); - Shape13.setTextureSize(64, 32); - Shape13.mirror = true; - setRotation(Shape13, 0F, 0F, 0F); - Shape14 = new ModelRenderer(this, 60, 0); - Shape14.addBox(0F, -4F, 6F, 1, 1, 1); - Shape14.setRotationPoint(0F, 0F, 0F); - Shape14.setTextureSize(64, 32); - Shape14.mirror = true; - setRotation(Shape14, 0F, 0F, 0F); - Shape15 = new ModelRenderer(this, 26, 9); - Shape15.addBox(-0.5F, 15F, -3.5F, 2, 4, 2); - Shape15.setRotationPoint(0F, 0F, 0F); - Shape15.setTextureSize(64, 32); - Shape15.mirror = true; - setRotation(Shape15, 0F, 0F, 0F); - Shape8 = new ModelRenderer(this, 37, 0); - Shape8.addBox(0F, -2F, -2F, 1, 4, 1); - Shape8.setRotationPoint(0F, 0F, 0F); - Shape8.setTextureSize(64, 32); - Shape8.mirror = true; - setRotation(Shape8, 0F, 0F, 0F); - } + Shape1 = new ModelRenderer(this, 0, 10); + Shape1.addBox(0F, -1F, -3F, 1, 16, 1); + Shape1.setRotationPoint(0F, 0F, 0F); + Shape1.setTextureSize(64, 32); + Shape1.mirror = true; + setRotation(Shape1, 0F, 0F, 0F); + Shape2 = new ModelRenderer(this, 34, 9); + Shape2.addBox(-0.5F, -3.5F, -3.5F, 2, 5, 2); + Shape2.setRotationPoint(0F, 0F, 0F); + Shape2.setTextureSize(64, 32); + Shape2.mirror = true; + setRotation(Shape2, 0F, 0F, 0F); + Shape5 = new ModelRenderer(this, 42, 0); + Shape5.addBox(0F, -4F, -4F, 1, 2, 10); + Shape5.setRotationPoint(0F, 0F, 0F); + Shape5.setTextureSize(64, 32); + Shape5.mirror = true; + setRotation(Shape5, 0F, 0F, 0F); + Shape6 = new ModelRenderer(this, 24, 0); + Shape6.addBox(-5F, -5.7F, -5.5F, 3, 3, 6); + Shape6.setRotationPoint(0F, 0F, 0F); + Shape6.setTextureSize(64, 32); + Shape6.mirror = true; + setRotation(Shape6, 0F, 0F, 0.7853982F); + Shape7 = new ModelRenderer(this, 0, 0); + Shape7.addBox(-0.5F, -6F, -7F, 2, 2, 8); + Shape7.setRotationPoint(0F, 0F, 0F); + Shape7.setTextureSize(64, 32); + Shape7.mirror = true; + setRotation(Shape7, 0F, 0F, 0F); + Shape9 = new ModelRenderer(this, 60, 0); + Shape9.addBox(0F, -0.5333334F, -9.6F, 1, 3, 1); + Shape9.setRotationPoint(0F, 0F, 0F); + Shape9.setTextureSize(64, 32); + Shape9.mirror = true; + setRotation(Shape9, -0.7853982F, 0F, 0F); + Shape16 = new ModelRenderer(this, 58, 0); + Shape16.addBox(0F, -9.58F, -4F, 1, 5, 2); + Shape16.setRotationPoint(0F, 0F, 0F); + Shape16.setTextureSize(64, 32); + Shape16.mirror = true; + setRotation(Shape16, 0.7853982F, 0F, 0F); + Shape10 = new ModelRenderer(this, 12, 0); + Shape10.addBox(-0.5F, -8.2F, -2.5F, 2, 1, 1); + Shape10.setRotationPoint(0F, 0F, 0F); + Shape10.setTextureSize(64, 32); + Shape10.mirror = true; + setRotation(Shape10, 0.7853982F, 0F, 0F); + Shape3 = new ModelRenderer(this, 56, 0); + Shape3.addBox(0F, -2.44F, -6.07F, 1, 2, 3); + Shape3.setRotationPoint(0F, 0F, 0F); + Shape3.setTextureSize(64, 32); + Shape3.mirror = true; + setRotation(Shape3, 0F, 0F, 0F); + Shape11 = new ModelRenderer(this, 42, 14); + Shape11.addBox(-0.5F, -0.5F, 3.5F, 2, 1, 1); + Shape11.setRotationPoint(0F, -4F, 0F); + Shape11.setTextureSize(64, 32); + Shape11.mirror = true; + setRotation(Shape11, 0F, 0F, 0F); + Shape4 = new ModelRenderer(this, 30, 16); + Shape4.addBox(-0.5F, -3.5F, -1.5F, 2, 1, 4); + Shape4.setRotationPoint(0F, 0F, 0F); + Shape4.setTextureSize(64, 32); + Shape4.mirror = true; + setRotation(Shape4, 0F, 0F, 0F); + Shape12 = new ModelRenderer(this, 42, 12); + Shape12.addBox(-0.5F, -4.5F, 1.5F, 2, 1, 1); + Shape12.setRotationPoint(0F, 0F, 0F); + Shape12.setTextureSize(64, 32); + Shape12.mirror = true; + setRotation(Shape12, 0F, 0F, 0F); + Shape13 = new ModelRenderer(this, 4, 10); + Shape13.addBox(0F, -5.3F, 0F, 1, 1, 7); + Shape13.setRotationPoint(0F, 0F, 0F); + Shape13.setTextureSize(64, 32); + Shape13.mirror = true; + setRotation(Shape13, 0F, 0F, 0F); + Shape14 = new ModelRenderer(this, 60, 0); + Shape14.addBox(0F, -4F, 6F, 1, 1, 1); + Shape14.setRotationPoint(0F, 0F, 0F); + Shape14.setTextureSize(64, 32); + Shape14.mirror = true; + setRotation(Shape14, 0F, 0F, 0F); + Shape15 = new ModelRenderer(this, 26, 9); + Shape15.addBox(-0.5F, 15F, -3.5F, 2, 4, 2); + Shape15.setRotationPoint(0F, 0F, 0F); + Shape15.setTextureSize(64, 32); + Shape15.mirror = true; + setRotation(Shape15, 0F, 0F, 0F); + Shape8 = new ModelRenderer(this, 37, 0); + Shape8.addBox(0F, -2F, -2F, 1, 4, 1); + Shape8.setRotationPoint(0F, 0F, 0F); + Shape8.setTextureSize(64, 32); + Shape8.mirror = true; + setRotation(Shape8, 0F, 0F, 0F); + } - public void render(float size) - { - GL11.glPushMatrix(); - MekanismRenderer.glowOn(); + public void render(float size) { + GL11.glPushMatrix(); + MekanismRenderer.glowOn(); - Shape3.render(size); - Shape5.render(size); - Shape9.render(size); - Shape16.render(size); - Shape14.render(size); + Shape3.render(size); + Shape5.render(size); + Shape9.render(size); + Shape16.render(size); + Shape14.render(size); - MekanismRenderer.glowOff(); - GL11.glPopMatrix(); + MekanismRenderer.glowOff(); + GL11.glPopMatrix(); - Shape1.render(size); - Shape2.render(size); - Shape6.render(size); - Shape7.render(size); - Shape13.render(size); - Shape10.render(size); - Shape11.render(size); - Shape4.render(size); - Shape12.render(size); - Shape15.render(size); - Shape8.render(size); - } + Shape1.render(size); + Shape2.render(size); + Shape6.render(size); + Shape7.render(size); + Shape13.render(size); + Shape10.render(size); + Shape11.render(size); + Shape4.render(size); + Shape12.render(size); + Shape15.render(size); + Shape8.render(size); + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/mekanism/client/model/ModelBalloon.java b/src/main/java/mekanism/client/model/ModelBalloon.java index dab4fb017..f9f198f84 100644 --- a/src/main/java/mekanism/client/model/ModelBalloon.java +++ b/src/main/java/mekanism/client/model/ModelBalloon.java @@ -1,85 +1,79 @@ package mekanism.client.model; -import mekanism.api.EnumColor; -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; - -import org.lwjgl.opengl.GL11; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import mekanism.api.EnumColor; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) -public class ModelBalloon extends ModelBase -{ - ModelRenderer Balloon2; - ModelRenderer Balloon1; - ModelRenderer Balloon3; - ModelRenderer Balloonnub; - ModelRenderer String; +public class ModelBalloon extends ModelBase { + ModelRenderer Balloon2; + ModelRenderer Balloon1; + ModelRenderer Balloon3; + ModelRenderer Balloonnub; + ModelRenderer String; - public ModelBalloon() - { - textureWidth = 64; - textureHeight = 32; + public ModelBalloon() { + textureWidth = 64; + textureHeight = 32; - Balloon2 = new ModelRenderer(this, 0, 0); - Balloon2.addBox(-2.5F, -2F, -2F, 5, 4, 4); - Balloon2.setRotationPoint(0F, 0F, 0F); - Balloon2.setTextureSize(64, 32); - Balloon2.mirror = true; - setRotation(Balloon2, 0F, 0F, 0F); - Balloon1 = new ModelRenderer(this, 0, 8); - Balloon1.addBox(-2F, -2F, -2.5F, 4, 4, 5); - Balloon1.setRotationPoint(0F, 0F, 0F); - Balloon1.setTextureSize(64, 32); - Balloon1.mirror = true; - setRotation(Balloon1, 0F, 0F, 0F); - Balloon3 = new ModelRenderer(this, 18, 0); - Balloon3.addBox(-2F, -2.5F, -2F, 4, 5, 4); - Balloon3.setRotationPoint(0F, 0F, 0F); - Balloon3.setTextureSize(64, 32); - Balloon3.mirror = true; - setRotation(Balloon3, 0F, 0F, 0F); - Balloonnub = new ModelRenderer(this, 18, 9); - Balloonnub.addBox(-0.5F, 2.5F, -0.5F, 1, 1, 1); - Balloonnub.setRotationPoint(0F, 0F, 0F); - Balloonnub.setTextureSize(64, 32); - Balloonnub.mirror = true; - setRotation(Balloonnub, 0F, 0F, 0F); - String = new ModelRenderer(this, 34, 0); - String.addBox(-0.5F, 3.5F, -0.5F, 1, 11, 1); - String.setRotationPoint(0F, 0F, 0F); - String.setTextureSize(64, 32); - String.mirror = true; - setRotation(String, 0F, 0F, 0F); - } + Balloon2 = new ModelRenderer(this, 0, 0); + Balloon2.addBox(-2.5F, -2F, -2F, 5, 4, 4); + Balloon2.setRotationPoint(0F, 0F, 0F); + Balloon2.setTextureSize(64, 32); + Balloon2.mirror = true; + setRotation(Balloon2, 0F, 0F, 0F); + Balloon1 = new ModelRenderer(this, 0, 8); + Balloon1.addBox(-2F, -2F, -2.5F, 4, 4, 5); + Balloon1.setRotationPoint(0F, 0F, 0F); + Balloon1.setTextureSize(64, 32); + Balloon1.mirror = true; + setRotation(Balloon1, 0F, 0F, 0F); + Balloon3 = new ModelRenderer(this, 18, 0); + Balloon3.addBox(-2F, -2.5F, -2F, 4, 5, 4); + Balloon3.setRotationPoint(0F, 0F, 0F); + Balloon3.setTextureSize(64, 32); + Balloon3.mirror = true; + setRotation(Balloon3, 0F, 0F, 0F); + Balloonnub = new ModelRenderer(this, 18, 9); + Balloonnub.addBox(-0.5F, 2.5F, -0.5F, 1, 1, 1); + Balloonnub.setRotationPoint(0F, 0F, 0F); + Balloonnub.setTextureSize(64, 32); + Balloonnub.mirror = true; + setRotation(Balloonnub, 0F, 0F, 0F); + String = new ModelRenderer(this, 34, 0); + String.addBox(-0.5F, 3.5F, -0.5F, 1, 11, 1); + String.setRotationPoint(0F, 0F, 0F); + String.setTextureSize(64, 32); + String.mirror = true; + setRotation(String, 0F, 0F, 0F); + } - public void render(float size, EnumColor color) - { - GL11.glPushMatrix(); - GL11.glColor3f(color.getColor(0), color.getColor(1), color.getColor(2)); - GL11.glScalef(1.5F, 1.5F, 1.5F); - GL11.glTranslatef(0, -0.07F, 0); + public void render(float size, EnumColor color) { + GL11.glPushMatrix(); + GL11.glColor3f(color.getColor(0), color.getColor(1), color.getColor(2)); + GL11.glScalef(1.5F, 1.5F, 1.5F); + GL11.glTranslatef(0, -0.07F, 0); - Balloon2.render(size); - Balloon1.render(size); - Balloon3.render(size); - Balloonnub.render(size); + Balloon2.render(size); + Balloon1.render(size); + Balloon3.render(size); + Balloonnub.render(size); - GL11.glColor3f(1, 1, 1); - GL11.glPopMatrix(); + GL11.glColor3f(1, 1, 1); + GL11.glPopMatrix(); - GL11.glPushMatrix(); - GL11.glScalef(0.2F, 1, 0.2F); - String.render(size); - GL11.glPopMatrix(); - } + GL11.glPushMatrix(); + GL11.glScalef(0.2F, 1, 0.2F); + String.render(size); + GL11.glPopMatrix(); + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/model/ModelChargepad.java b/src/main/java/mekanism/client/model/ModelChargepad.java index d6b0cd015..e078fb5cd 100644 --- a/src/main/java/mekanism/client/model/ModelChargepad.java +++ b/src/main/java/mekanism/client/model/ModelChargepad.java @@ -1,5 +1,7 @@ package mekanism.client.model; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.render.MekanismRenderer; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; @@ -7,17 +9,13 @@ import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class ModelChargepad extends ModelBase -{ - public static ResourceLocation OVERLAY = MekanismUtils.getResource(ResourceType.RENDER, "Chargepad_Overlay.png"); - +public class ModelChargepad extends ModelBase { + public static ResourceLocation OVERLAY + = MekanismUtils.getResource(ResourceType.RENDER, "Chargepad_Overlay.png"); + ModelRenderer base; ModelRenderer port; ModelRenderer plug; @@ -26,89 +24,85 @@ public class ModelChargepad extends ModelBase ModelRenderer pillar2; ModelRenderer pillar1; - public ModelChargepad() - { - textureWidth = 64; - textureHeight = 64; + public ModelChargepad() { + textureWidth = 64; + textureHeight = 64; - base = new ModelRenderer(this, 0, 0); - base.addBox(0F, 0F, 0F, 16, 1, 16); - base.setRotationPoint(-8F, 23F, -8F); - base.setTextureSize(64, 64); - base.mirror = true; - setRotation(base, 0F, 0F, 0F); - port = new ModelRenderer(this, 0, 17); - port.addBox(0F, 0F, 0F, 8, 8, 1); - port.setRotationPoint(-4F, 12F, 7F); - port.setTextureSize(64, 64); - port.mirror = true; - setRotation(port, 0F, 0F, 0F); - plug = new ModelRenderer(this, 0, 11); - plug.addBox(0F, 0F, 0F, 2, 1, 2); - plug.setRotationPoint(-1F, 19F, 3F); - plug.setTextureSize(64, 64); - plug.mirror = true; - setRotation(plug, 0F, 0F, 0F); - connector = new ModelRenderer(this, 18, 17); - connector.addBox(0F, 0F, 0F, 6, 6, 1); - connector.setRotationPoint(-3F, 13F, 6F); - connector.setTextureSize(64, 64); - connector.mirror = true; - setRotation(connector, 0F, 0F, 0F); - stand = new ModelRenderer(this, 0, 0); - stand.addBox(0F, 0F, 0F, 6, 10, 1); - stand.setRotationPoint(-3F, 13F, 5F); - stand.setTextureSize(64, 64); - stand.mirror = true; - setRotation(stand, 0F, 0F, 0F); - pillar2 = new ModelRenderer(this, 48, 0); - pillar2.mirror = true; - pillar2.addBox(0F, 0F, 0F, 2, 7, 2); - pillar2.setRotationPoint(2F, 16F, 3.99F); - pillar2.setTextureSize(64, 64); - setRotation(pillar2, 0F, 0F, 0F); - pillar1 = new ModelRenderer(this, 48, 0); - pillar1.addBox(0F, 0F, 0F, 2, 7, 2); - pillar1.setRotationPoint(-4F, 16F, 3.99F); - pillar1.setTextureSize(64, 64); - pillar1.mirror = true; - setRotation(pillar1, 0F, 0F, 0F); - } - - public void render(float size, TextureManager manager) - { - GL11.glPushMatrix(); - MekanismRenderer.blendOn(); - - doRender(size); - - manager.bindTexture(OVERLAY); - GL11.glScalef(1.001F, 1.001F, 1.001F); - GL11.glTranslatef(0, -0.0011F, 0); - MekanismRenderer.glowOn(); - - doRender(size); - - MekanismRenderer.glowOff(); - MekanismRenderer.blendOff(); - GL11.glPopMatrix(); - } + base = new ModelRenderer(this, 0, 0); + base.addBox(0F, 0F, 0F, 16, 1, 16); + base.setRotationPoint(-8F, 23F, -8F); + base.setTextureSize(64, 64); + base.mirror = true; + setRotation(base, 0F, 0F, 0F); + port = new ModelRenderer(this, 0, 17); + port.addBox(0F, 0F, 0F, 8, 8, 1); + port.setRotationPoint(-4F, 12F, 7F); + port.setTextureSize(64, 64); + port.mirror = true; + setRotation(port, 0F, 0F, 0F); + plug = new ModelRenderer(this, 0, 11); + plug.addBox(0F, 0F, 0F, 2, 1, 2); + plug.setRotationPoint(-1F, 19F, 3F); + plug.setTextureSize(64, 64); + plug.mirror = true; + setRotation(plug, 0F, 0F, 0F); + connector = new ModelRenderer(this, 18, 17); + connector.addBox(0F, 0F, 0F, 6, 6, 1); + connector.setRotationPoint(-3F, 13F, 6F); + connector.setTextureSize(64, 64); + connector.mirror = true; + setRotation(connector, 0F, 0F, 0F); + stand = new ModelRenderer(this, 0, 0); + stand.addBox(0F, 0F, 0F, 6, 10, 1); + stand.setRotationPoint(-3F, 13F, 5F); + stand.setTextureSize(64, 64); + stand.mirror = true; + setRotation(stand, 0F, 0F, 0F); + pillar2 = new ModelRenderer(this, 48, 0); + pillar2.mirror = true; + pillar2.addBox(0F, 0F, 0F, 2, 7, 2); + pillar2.setRotationPoint(2F, 16F, 3.99F); + pillar2.setTextureSize(64, 64); + setRotation(pillar2, 0F, 0F, 0F); + pillar1 = new ModelRenderer(this, 48, 0); + pillar1.addBox(0F, 0F, 0F, 2, 7, 2); + pillar1.setRotationPoint(-4F, 16F, 3.99F); + pillar1.setTextureSize(64, 64); + pillar1.mirror = true; + setRotation(pillar1, 0F, 0F, 0F); + } - private void doRender(float size) - { - base.render(size); - port.render(size); - plug.render(size); - connector.render(size); - stand.render(size); - pillar2.render(size); - pillar1.render(size); - } + public void render(float size, TextureManager manager) { + GL11.glPushMatrix(); + MekanismRenderer.blendOn(); - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + doRender(size); + + manager.bindTexture(OVERLAY); + GL11.glScalef(1.001F, 1.001F, 1.001F); + GL11.glTranslatef(0, -0.0011F, 0); + MekanismRenderer.glowOn(); + + doRender(size); + + MekanismRenderer.glowOff(); + MekanismRenderer.blendOff(); + GL11.glPopMatrix(); + } + + private void doRender(float size) { + base.render(size); + port.render(size); + plug.render(size); + connector.render(size); + stand.render(size); + pillar2.render(size); + pillar1.render(size); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/mekanism/client/model/ModelChemicalCrystallizer.java b/src/main/java/mekanism/client/model/ModelChemicalCrystallizer.java index ac0441e12..f57e82f56 100644 --- a/src/main/java/mekanism/client/model/ModelChemicalCrystallizer.java +++ b/src/main/java/mekanism/client/model/ModelChemicalCrystallizer.java @@ -1,170 +1,166 @@ package mekanism.client.model; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.render.MekanismRenderer; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class ModelChemicalCrystallizer extends ModelBase -{ - ModelRenderer tray; - ModelRenderer support4; - ModelRenderer rimBack; - ModelRenderer portRight; - ModelRenderer rimRight; - ModelRenderer rimLeft; - ModelRenderer rimFront; - ModelRenderer portLeft; - ModelRenderer support3; - ModelRenderer support2; - ModelRenderer support1; - ModelRenderer tank; - ModelRenderer rod1; - ModelRenderer rod2; - ModelRenderer rod3; - ModelRenderer base; - ModelRenderer Shape1; +public class ModelChemicalCrystallizer extends ModelBase { + ModelRenderer tray; + ModelRenderer support4; + ModelRenderer rimBack; + ModelRenderer portRight; + ModelRenderer rimRight; + ModelRenderer rimLeft; + ModelRenderer rimFront; + ModelRenderer portLeft; + ModelRenderer support3; + ModelRenderer support2; + ModelRenderer support1; + ModelRenderer tank; + ModelRenderer rod1; + ModelRenderer rod2; + ModelRenderer rod3; + ModelRenderer base; + ModelRenderer Shape1; - public ModelChemicalCrystallizer() - { - textureWidth = 128; - textureHeight = 64; + public ModelChemicalCrystallizer() { + textureWidth = 128; + textureHeight = 64; - tray = new ModelRenderer(this, 48, 0); - tray.addBox(0F, 0F, 0F, 10, 1, 10); - tray.setRotationPoint(-5F, 18.5F, -5F); - tray.setTextureSize(128, 64); - tray.mirror = true; - setRotation(tray, 0F, 0F, 0F); - support4 = new ModelRenderer(this, 0, 0); - support4.addBox(0F, 0F, 0F, 1, 5, 1); - support4.setRotationPoint(6.5F, 13F, 6.5F); - support4.setTextureSize(128, 64); - support4.mirror = true; - setRotation(support4, 0F, 0F, 0F); - rimBack = new ModelRenderer(this, 0, 46); - rimBack.addBox(0F, 0F, 0F, 16, 2, 2); - rimBack.setRotationPoint(-8F, 17F, 6F); - rimBack.setTextureSize(128, 64); - rimBack.mirror = true; - setRotation(rimBack, 0F, 0F, 0F); - portRight = new ModelRenderer(this, 54, 42); - portRight.mirror = true; - portRight.addBox(0F, 0F, 0F, 1, 10, 10); - portRight.setRotationPoint(7.01F, 11F, -5F); - portRight.setTextureSize(128, 64); - setRotation(portRight, 0F, 0F, 0F); - rimRight = new ModelRenderer(this, 0, 50); - rimRight.mirror = true; - rimRight.addBox(0F, 0F, 0F, 2, 2, 12); - rimRight.setRotationPoint(6F, 17F, -6F); - rimRight.setTextureSize(128, 64); - setRotation(rimRight, 0F, 0F, 0F); - rimLeft = new ModelRenderer(this, 0, 50); - rimLeft.addBox(0F, 0F, 0F, 2, 2, 12); - rimLeft.setRotationPoint(-8F, 17F, -6F); - rimLeft.setTextureSize(128, 64); - rimLeft.mirror = true; - setRotation(rimLeft, 0F, 0F, 0F); - rimFront = new ModelRenderer(this, 0, 42); - rimFront.addBox(0F, 0F, 0F, 16, 2, 2); - rimFront.setRotationPoint(-8F, 17F, -8F); - rimFront.setTextureSize(128, 64); - rimFront.mirror = true; - setRotation(rimFront, 0F, 0F, 0F); - portLeft = new ModelRenderer(this, 36, 42); - portLeft.addBox(0F, 0F, 0F, 1, 8, 8); - portLeft.setRotationPoint(-8.01F, 12F, -4F); - portLeft.setTextureSize(128, 64); - portLeft.mirror = true; - setRotation(portLeft, 0F, 0F, 0F); - support3 = new ModelRenderer(this, 0, 0); - support3.addBox(0F, 0F, 0F, 1, 5, 1); - support3.setRotationPoint(-7.5F, 13F, 6.5F); - support3.setTextureSize(128, 64); - support3.mirror = true; - setRotation(support3, 0F, 0F, 0F); - support2 = new ModelRenderer(this, 0, 0); - support2.addBox(0F, 0F, 0F, 1, 5, 1); - support2.setRotationPoint(6.5F, 13F, -7.5F); - support2.setTextureSize(128, 64); - support2.mirror = true; - setRotation(support2, 0F, 0F, 0F); - support1 = new ModelRenderer(this, 0, 0); - support1.addBox(0F, 0F, 0F, 1, 5, 1); - support1.setRotationPoint(-7.5F, 13F, -7.5F); - support1.setTextureSize(128, 64); - support1.mirror = true; - setRotation(support1, 0F, 0F, 0F); - tank = new ModelRenderer(this, 0, 0); - tank.addBox(0F, 0F, 0F, 16, 5, 16); - tank.setRotationPoint(-8F, 8F, -8F); - tank.setTextureSize(128, 64); - tank.mirror = true; - setRotation(tank, 0F, 0F, 0F); - rod1 = new ModelRenderer(this, 8, 0); - rod1.addBox(0F, 0F, 0F, 1, 2, 1); - rod1.setRotationPoint(-2F, 13F, 0F); - rod1.setTextureSize(128, 64); - rod1.mirror = true; - setRotation(rod1, 0F, 0F, 0F); - rod2 = new ModelRenderer(this, 8, 3); - rod2.addBox(0F, 0F, 0F, 1, 3, 1); - rod2.setRotationPoint(1F, 13F, 1F); - rod2.setTextureSize(128, 64); - rod2.mirror = true; - setRotation(rod2, 0F, 0F, 0F); - rod3 = new ModelRenderer(this, 4, 0); - rod3.addBox(0F, 0F, 0F, 1, 4, 1); - rod3.setRotationPoint(-0.5F, 13F, -2F); - rod3.setTextureSize(128, 64); - rod3.mirror = true; - setRotation(rod3, 0F, 0F, 0F); - base = new ModelRenderer(this, 0, 21); - base.addBox(0F, 0F, 0F, 16, 5, 16); - base.setRotationPoint(-8F, 19F, -8F); - base.setTextureSize(128, 64); - base.mirror = true; - setRotation(base, 0F, 0F, 0F); - Shape1 = new ModelRenderer(this, 64, 11); - Shape1.addBox(0F, 0F, 0F, 14, 4, 14); - Shape1.setRotationPoint(-7F, 13F, -7F); - Shape1.setTextureSize(128, 64); - Shape1.mirror = true; - setRotation(Shape1, 0F, 0F, 0F); - } + tray = new ModelRenderer(this, 48, 0); + tray.addBox(0F, 0F, 0F, 10, 1, 10); + tray.setRotationPoint(-5F, 18.5F, -5F); + tray.setTextureSize(128, 64); + tray.mirror = true; + setRotation(tray, 0F, 0F, 0F); + support4 = new ModelRenderer(this, 0, 0); + support4.addBox(0F, 0F, 0F, 1, 5, 1); + support4.setRotationPoint(6.5F, 13F, 6.5F); + support4.setTextureSize(128, 64); + support4.mirror = true; + setRotation(support4, 0F, 0F, 0F); + rimBack = new ModelRenderer(this, 0, 46); + rimBack.addBox(0F, 0F, 0F, 16, 2, 2); + rimBack.setRotationPoint(-8F, 17F, 6F); + rimBack.setTextureSize(128, 64); + rimBack.mirror = true; + setRotation(rimBack, 0F, 0F, 0F); + portRight = new ModelRenderer(this, 54, 42); + portRight.mirror = true; + portRight.addBox(0F, 0F, 0F, 1, 10, 10); + portRight.setRotationPoint(7.01F, 11F, -5F); + portRight.setTextureSize(128, 64); + setRotation(portRight, 0F, 0F, 0F); + rimRight = new ModelRenderer(this, 0, 50); + rimRight.mirror = true; + rimRight.addBox(0F, 0F, 0F, 2, 2, 12); + rimRight.setRotationPoint(6F, 17F, -6F); + rimRight.setTextureSize(128, 64); + setRotation(rimRight, 0F, 0F, 0F); + rimLeft = new ModelRenderer(this, 0, 50); + rimLeft.addBox(0F, 0F, 0F, 2, 2, 12); + rimLeft.setRotationPoint(-8F, 17F, -6F); + rimLeft.setTextureSize(128, 64); + rimLeft.mirror = true; + setRotation(rimLeft, 0F, 0F, 0F); + rimFront = new ModelRenderer(this, 0, 42); + rimFront.addBox(0F, 0F, 0F, 16, 2, 2); + rimFront.setRotationPoint(-8F, 17F, -8F); + rimFront.setTextureSize(128, 64); + rimFront.mirror = true; + setRotation(rimFront, 0F, 0F, 0F); + portLeft = new ModelRenderer(this, 36, 42); + portLeft.addBox(0F, 0F, 0F, 1, 8, 8); + portLeft.setRotationPoint(-8.01F, 12F, -4F); + portLeft.setTextureSize(128, 64); + portLeft.mirror = true; + setRotation(portLeft, 0F, 0F, 0F); + support3 = new ModelRenderer(this, 0, 0); + support3.addBox(0F, 0F, 0F, 1, 5, 1); + support3.setRotationPoint(-7.5F, 13F, 6.5F); + support3.setTextureSize(128, 64); + support3.mirror = true; + setRotation(support3, 0F, 0F, 0F); + support2 = new ModelRenderer(this, 0, 0); + support2.addBox(0F, 0F, 0F, 1, 5, 1); + support2.setRotationPoint(6.5F, 13F, -7.5F); + support2.setTextureSize(128, 64); + support2.mirror = true; + setRotation(support2, 0F, 0F, 0F); + support1 = new ModelRenderer(this, 0, 0); + support1.addBox(0F, 0F, 0F, 1, 5, 1); + support1.setRotationPoint(-7.5F, 13F, -7.5F); + support1.setTextureSize(128, 64); + support1.mirror = true; + setRotation(support1, 0F, 0F, 0F); + tank = new ModelRenderer(this, 0, 0); + tank.addBox(0F, 0F, 0F, 16, 5, 16); + tank.setRotationPoint(-8F, 8F, -8F); + tank.setTextureSize(128, 64); + tank.mirror = true; + setRotation(tank, 0F, 0F, 0F); + rod1 = new ModelRenderer(this, 8, 0); + rod1.addBox(0F, 0F, 0F, 1, 2, 1); + rod1.setRotationPoint(-2F, 13F, 0F); + rod1.setTextureSize(128, 64); + rod1.mirror = true; + setRotation(rod1, 0F, 0F, 0F); + rod2 = new ModelRenderer(this, 8, 3); + rod2.addBox(0F, 0F, 0F, 1, 3, 1); + rod2.setRotationPoint(1F, 13F, 1F); + rod2.setTextureSize(128, 64); + rod2.mirror = true; + setRotation(rod2, 0F, 0F, 0F); + rod3 = new ModelRenderer(this, 4, 0); + rod3.addBox(0F, 0F, 0F, 1, 4, 1); + rod3.setRotationPoint(-0.5F, 13F, -2F); + rod3.setTextureSize(128, 64); + rod3.mirror = true; + setRotation(rod3, 0F, 0F, 0F); + base = new ModelRenderer(this, 0, 21); + base.addBox(0F, 0F, 0F, 16, 5, 16); + base.setRotationPoint(-8F, 19F, -8F); + base.setTextureSize(128, 64); + base.mirror = true; + setRotation(base, 0F, 0F, 0F); + Shape1 = new ModelRenderer(this, 64, 11); + Shape1.addBox(0F, 0F, 0F, 14, 4, 14); + Shape1.setRotationPoint(-7F, 13F, -7F); + Shape1.setTextureSize(128, 64); + Shape1.mirror = true; + setRotation(Shape1, 0F, 0F, 0F); + } - public void render(float size) - { - MekanismRenderer.blendOn(); - - tray.render(size); - support4.render(size); - rimBack.render(size); - portRight.render(size); - rimRight.render(size); - rimLeft.render(size); - rimFront.render(size); - portLeft.render(size); - support3.render(size); - support2.render(size); - support1.render(size); - tank.render(size); - rod1.render(size); - rod2.render(size); - rod3.render(size); - base.render(size); - Shape1.render(size); - - MekanismRenderer.blendOff(); - } + public void render(float size) { + MekanismRenderer.blendOn(); - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + tray.render(size); + support4.render(size); + rimBack.render(size); + portRight.render(size); + rimRight.render(size); + rimLeft.render(size); + rimFront.render(size); + portLeft.render(size); + support3.render(size); + support2.render(size); + support1.render(size); + tank.render(size); + rod1.render(size); + rod2.render(size); + rod3.render(size); + base.render(size); + Shape1.render(size); + + MekanismRenderer.blendOff(); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/mekanism/client/model/ModelChemicalDissolutionChamber.java b/src/main/java/mekanism/client/model/ModelChemicalDissolutionChamber.java index 9787060be..64a19ca49 100644 --- a/src/main/java/mekanism/client/model/ModelChemicalDissolutionChamber.java +++ b/src/main/java/mekanism/client/model/ModelChemicalDissolutionChamber.java @@ -1,274 +1,270 @@ package mekanism.client.model; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.render.MekanismRenderer; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class ModelChemicalDissolutionChamber extends ModelBase -{ - ModelRenderer support2; - ModelRenderer vat5; - ModelRenderer top2; - ModelRenderer top; - ModelRenderer base; - ModelRenderer vat2; - ModelRenderer vat3; - ModelRenderer vat6; - ModelRenderer vat9; - ModelRenderer vat8; - ModelRenderer vat7; - ModelRenderer vat4; - ModelRenderer backEdge2; - ModelRenderer back; - ModelRenderer backEdge1; - ModelRenderer vents; - ModelRenderer support1; - ModelRenderer vat1; - ModelRenderer nozzle8; - ModelRenderer nozzle5; - ModelRenderer nozzle7; - ModelRenderer nozzle4; - ModelRenderer nozzle9; - ModelRenderer nozzle6; - ModelRenderer nozzle3; - ModelRenderer nozzle2; - ModelRenderer nozzle1; - ModelRenderer glass; - ModelRenderer portToggle1; - ModelRenderer portToggle2; +public class ModelChemicalDissolutionChamber extends ModelBase { + ModelRenderer support2; + ModelRenderer vat5; + ModelRenderer top2; + ModelRenderer top; + ModelRenderer base; + ModelRenderer vat2; + ModelRenderer vat3; + ModelRenderer vat6; + ModelRenderer vat9; + ModelRenderer vat8; + ModelRenderer vat7; + ModelRenderer vat4; + ModelRenderer backEdge2; + ModelRenderer back; + ModelRenderer backEdge1; + ModelRenderer vents; + ModelRenderer support1; + ModelRenderer vat1; + ModelRenderer nozzle8; + ModelRenderer nozzle5; + ModelRenderer nozzle7; + ModelRenderer nozzle4; + ModelRenderer nozzle9; + ModelRenderer nozzle6; + ModelRenderer nozzle3; + ModelRenderer nozzle2; + ModelRenderer nozzle1; + ModelRenderer glass; + ModelRenderer portToggle1; + ModelRenderer portToggle2; - public ModelChemicalDissolutionChamber() - { - textureWidth = 128; - textureHeight = 64; + public ModelChemicalDissolutionChamber() { + textureWidth = 128; + textureHeight = 64; - support2 = new ModelRenderer(this, 4, 0); - support2.addBox(0F, 0F, 0F, 1, 2, 1); - support2.setRotationPoint(6F, 9F, -7F); - support2.setTextureSize(128, 64); - support2.mirror = true; - setRotation(support2, 0F, 0F, 0F); - vat5 = new ModelRenderer(this, 0, 23); - vat5.addBox(0F, 0F, 0F, 3, 4, 3); - vat5.setRotationPoint(-1.5F, 13F, -1.5F); - vat5.setTextureSize(128, 64); - vat5.mirror = true; - setRotation(vat5, 0F, 0F, 0F); - top2 = new ModelRenderer(this, 0, 40); - top2.addBox(0F, 0F, 0F, 16, 1, 15); - top2.setRotationPoint(-8F, 11F, -8F); - top2.setTextureSize(128, 64); - top2.mirror = true; - setRotation(top2, 0F, 0F, 0F); - top = new ModelRenderer(this, 0, 23); - top.addBox(0F, 0F, 0F, 16, 1, 16); - top.setRotationPoint(-8F, 8F, -8F); - top.setTextureSize(128, 64); - top.mirror = true; - setRotation(top, 0F, 0F, 0F); - base = new ModelRenderer(this, 0, 0); - base.addBox(0F, 0F, 0F, 16, 7, 16); - base.setRotationPoint(-8F, 17F, -8F); - base.setTextureSize(128, 64); - base.mirror = true; - setRotation(base, 0F, 0F, 0F); - vat2 = new ModelRenderer(this, 0, 23); - vat2.addBox(0F, 0F, 0F, 3, 4, 3); - vat2.setRotationPoint(-5F, 13F, -1.5F); - vat2.setTextureSize(128, 64); - vat2.mirror = true; - setRotation(vat2, 0F, 0F, 0F); - vat3 = new ModelRenderer(this, 0, 23); - vat3.addBox(0F, 0F, 0F, 3, 4, 3); - vat3.setRotationPoint(-5F, 13F, 2F); - vat3.setTextureSize(128, 64); - vat3.mirror = true; - setRotation(vat3, 0F, 0F, 0F); - vat6 = new ModelRenderer(this, 0, 23); - vat6.addBox(0F, 0F, 0F, 3, 4, 3); - vat6.setRotationPoint(-1.5F, 13F, 2F); - vat6.setTextureSize(128, 64); - vat6.mirror = true; - setRotation(vat6, 0F, 0F, 0F); - vat9 = new ModelRenderer(this, 0, 23); - vat9.addBox(0F, 0F, 0F, 3, 4, 3); - vat9.setRotationPoint(2F, 13F, 2F); - vat9.setTextureSize(128, 64); - vat9.mirror = true; - setRotation(vat9, 0F, 0F, 0F); - vat8 = new ModelRenderer(this, 0, 23); - vat8.addBox(0F, 0F, 0F, 3, 4, 3); - vat8.setRotationPoint(2F, 13F, -1.5F); - vat8.setTextureSize(128, 64); - vat8.mirror = true; - setRotation(vat8, 0F, 0F, 0F); - vat7 = new ModelRenderer(this, 0, 23); - vat7.addBox(0F, 0F, 0F, 3, 4, 3); - vat7.setRotationPoint(2F, 13F, -5F); - vat7.setTextureSize(128, 64); - vat7.mirror = true; - setRotation(vat7, 0F, 0F, 0F); - vat4 = new ModelRenderer(this, 0, 23); - vat4.addBox(0F, 0F, 0F, 3, 4, 3); - vat4.setRotationPoint(-1.5F, 13F, -5F); - vat4.setTextureSize(128, 64); - vat4.mirror = true; - setRotation(vat4, 0F, 0F, 0F); - backEdge2 = new ModelRenderer(this, 8, 0); - backEdge2.addBox(0F, 0F, 0F, 1, 8, 1); - backEdge2.setRotationPoint(7F, 9F, 7F); - backEdge2.setTextureSize(128, 64); - backEdge2.mirror = true; - setRotation(backEdge2, 0F, 0F, 0F); - back = new ModelRenderer(this, 48, 0); - back.addBox(0F, 0F, 0F, 14, 8, 2); - back.setRotationPoint(-7F, 9F, 6F); - back.setTextureSize(128, 64); - back.mirror = true; - setRotation(back, 0F, 0F, 0F); - backEdge1 = new ModelRenderer(this, 8, 0); - backEdge1.addBox(0F, 0F, 0F, 1, 8, 1); - backEdge1.setRotationPoint(-8F, 9F, 7F); - backEdge1.setTextureSize(128, 64); - backEdge1.mirror = true; - setRotation(backEdge1, 0F, 0F, 0F); - vents = new ModelRenderer(this, 70, 0); - vents.addBox(0F, 0F, 0F, 8, 2, 10); - vents.setRotationPoint(-4F, 9F, -4F); - vents.setTextureSize(128, 64); - vents.mirror = true; - setRotation(vents, 0F, 0F, 0F); - support1 = new ModelRenderer(this, 4, 0); - support1.addBox(0F, 0F, 0F, 1, 2, 1); - support1.setRotationPoint(-7F, 9F, -7F); - support1.setTextureSize(128, 64); - support1.mirror = true; - setRotation(support1, 0F, 0F, 0F); - vat1 = new ModelRenderer(this, 0, 23); - vat1.addBox(0F, 0F, 0F, 3, 4, 3); - vat1.setRotationPoint(-5F, 13F, -5F); - vat1.setTextureSize(128, 64); - vat1.mirror = true; - setRotation(vat1, 0F, 0F, 0F); - nozzle8 = new ModelRenderer(this, 0, 0); - nozzle8.addBox(0F, 0F, 0F, 1, 1, 1); - nozzle8.setRotationPoint(3F, 11.5F, -0.5F); - nozzle8.setTextureSize(128, 64); - nozzle8.mirror = true; - setRotation(nozzle8, 0F, 0F, 0F); - nozzle5 = new ModelRenderer(this, 0, 0); - nozzle5.addBox(0F, 0F, 0F, 1, 1, 1); - nozzle5.setRotationPoint(-0.5F, 11.5F, -0.5F); - nozzle5.setTextureSize(128, 64); - nozzle5.mirror = true; - setRotation(nozzle5, 0F, 0F, 0F); - nozzle7 = new ModelRenderer(this, 0, 0); - nozzle7.addBox(0F, 0F, 0F, 1, 1, 1); - nozzle7.setRotationPoint(3F, 11.5F, -4F); - nozzle7.setTextureSize(128, 64); - nozzle7.mirror = true; - setRotation(nozzle7, 0F, 0F, 0F); - nozzle4 = new ModelRenderer(this, 0, 0); - nozzle4.addBox(0F, 0F, 0F, 1, 1, 1); - nozzle4.setRotationPoint(-0.5F, 11.5F, -4F); - nozzle4.setTextureSize(128, 64); - nozzle4.mirror = true; - setRotation(nozzle4, 0F, 0F, 0F); - nozzle9 = new ModelRenderer(this, 0, 0); - nozzle9.addBox(0F, 0F, 0F, 1, 1, 1); - nozzle9.setRotationPoint(3F, 11.5F, 3F); - nozzle9.setTextureSize(128, 64); - nozzle9.mirror = true; - setRotation(nozzle9, 0F, 0F, 0F); - nozzle6 = new ModelRenderer(this, 0, 0); - nozzle6.addBox(0F, 0F, 0F, 1, 1, 1); - nozzle6.setRotationPoint(-0.5F, 11.5F, 3F); - nozzle6.setTextureSize(128, 64); - nozzle6.mirror = true; - setRotation(nozzle6, 0F, 0F, 0F); - nozzle3 = new ModelRenderer(this, 0, 0); - nozzle3.addBox(0F, 0F, 0F, 1, 1, 1); - nozzle3.setRotationPoint(-4F, 11.5F, 3F); - nozzle3.setTextureSize(128, 64); - nozzle3.mirror = true; - setRotation(nozzle3, 0F, 0F, 0F); - nozzle2 = new ModelRenderer(this, 0, 0); - nozzle2.addBox(0F, 0F, 0F, 1, 1, 1); - nozzle2.setRotationPoint(-4F, 11.5F, -0.5F); - nozzle2.setTextureSize(128, 64); - nozzle2.mirror = true; - setRotation(nozzle2, 0F, 0F, 0F); - nozzle1 = new ModelRenderer(this, 0, 0); - nozzle1.addBox(0F, 0F, 0F, 1, 1, 1); - nozzle1.setRotationPoint(-4F, 11.5F, -4F); - nozzle1.setTextureSize(128, 64); - nozzle1.mirror = true; - setRotation(nozzle1, 0F, 0F, 0F); - glass = new ModelRenderer(this, 64, 14); - glass.addBox(0F, 0F, 0F, 14, 5, 13); - glass.setRotationPoint(-7F, 12F, -7F); - glass.setTextureSize(128, 64); - glass.mirror = true; - setRotation(glass, 0F, 0F, 0F); - portToggle1 = new ModelRenderer(this, 106, 0); - portToggle1.addBox(0F, 0F, 0F, 1, 10, 10); - portToggle1.setRotationPoint(-8.01F, 10.99F, -5F); - portToggle1.setTextureSize(128, 64); - portToggle1.mirror = true; - setRotation(portToggle1, 0F, 0F, 0F); - portToggle2 = new ModelRenderer(this, 64, 32); - portToggle2.addBox(0F, 0F, 0F, 1, 8, 8); - portToggle2.setRotationPoint(7.01F, 12F, -4F); - portToggle2.setTextureSize(128, 64); - portToggle2.mirror = true; - setRotation(portToggle2, 0F, 0F, 0F); - } + support2 = new ModelRenderer(this, 4, 0); + support2.addBox(0F, 0F, 0F, 1, 2, 1); + support2.setRotationPoint(6F, 9F, -7F); + support2.setTextureSize(128, 64); + support2.mirror = true; + setRotation(support2, 0F, 0F, 0F); + vat5 = new ModelRenderer(this, 0, 23); + vat5.addBox(0F, 0F, 0F, 3, 4, 3); + vat5.setRotationPoint(-1.5F, 13F, -1.5F); + vat5.setTextureSize(128, 64); + vat5.mirror = true; + setRotation(vat5, 0F, 0F, 0F); + top2 = new ModelRenderer(this, 0, 40); + top2.addBox(0F, 0F, 0F, 16, 1, 15); + top2.setRotationPoint(-8F, 11F, -8F); + top2.setTextureSize(128, 64); + top2.mirror = true; + setRotation(top2, 0F, 0F, 0F); + top = new ModelRenderer(this, 0, 23); + top.addBox(0F, 0F, 0F, 16, 1, 16); + top.setRotationPoint(-8F, 8F, -8F); + top.setTextureSize(128, 64); + top.mirror = true; + setRotation(top, 0F, 0F, 0F); + base = new ModelRenderer(this, 0, 0); + base.addBox(0F, 0F, 0F, 16, 7, 16); + base.setRotationPoint(-8F, 17F, -8F); + base.setTextureSize(128, 64); + base.mirror = true; + setRotation(base, 0F, 0F, 0F); + vat2 = new ModelRenderer(this, 0, 23); + vat2.addBox(0F, 0F, 0F, 3, 4, 3); + vat2.setRotationPoint(-5F, 13F, -1.5F); + vat2.setTextureSize(128, 64); + vat2.mirror = true; + setRotation(vat2, 0F, 0F, 0F); + vat3 = new ModelRenderer(this, 0, 23); + vat3.addBox(0F, 0F, 0F, 3, 4, 3); + vat3.setRotationPoint(-5F, 13F, 2F); + vat3.setTextureSize(128, 64); + vat3.mirror = true; + setRotation(vat3, 0F, 0F, 0F); + vat6 = new ModelRenderer(this, 0, 23); + vat6.addBox(0F, 0F, 0F, 3, 4, 3); + vat6.setRotationPoint(-1.5F, 13F, 2F); + vat6.setTextureSize(128, 64); + vat6.mirror = true; + setRotation(vat6, 0F, 0F, 0F); + vat9 = new ModelRenderer(this, 0, 23); + vat9.addBox(0F, 0F, 0F, 3, 4, 3); + vat9.setRotationPoint(2F, 13F, 2F); + vat9.setTextureSize(128, 64); + vat9.mirror = true; + setRotation(vat9, 0F, 0F, 0F); + vat8 = new ModelRenderer(this, 0, 23); + vat8.addBox(0F, 0F, 0F, 3, 4, 3); + vat8.setRotationPoint(2F, 13F, -1.5F); + vat8.setTextureSize(128, 64); + vat8.mirror = true; + setRotation(vat8, 0F, 0F, 0F); + vat7 = new ModelRenderer(this, 0, 23); + vat7.addBox(0F, 0F, 0F, 3, 4, 3); + vat7.setRotationPoint(2F, 13F, -5F); + vat7.setTextureSize(128, 64); + vat7.mirror = true; + setRotation(vat7, 0F, 0F, 0F); + vat4 = new ModelRenderer(this, 0, 23); + vat4.addBox(0F, 0F, 0F, 3, 4, 3); + vat4.setRotationPoint(-1.5F, 13F, -5F); + vat4.setTextureSize(128, 64); + vat4.mirror = true; + setRotation(vat4, 0F, 0F, 0F); + backEdge2 = new ModelRenderer(this, 8, 0); + backEdge2.addBox(0F, 0F, 0F, 1, 8, 1); + backEdge2.setRotationPoint(7F, 9F, 7F); + backEdge2.setTextureSize(128, 64); + backEdge2.mirror = true; + setRotation(backEdge2, 0F, 0F, 0F); + back = new ModelRenderer(this, 48, 0); + back.addBox(0F, 0F, 0F, 14, 8, 2); + back.setRotationPoint(-7F, 9F, 6F); + back.setTextureSize(128, 64); + back.mirror = true; + setRotation(back, 0F, 0F, 0F); + backEdge1 = new ModelRenderer(this, 8, 0); + backEdge1.addBox(0F, 0F, 0F, 1, 8, 1); + backEdge1.setRotationPoint(-8F, 9F, 7F); + backEdge1.setTextureSize(128, 64); + backEdge1.mirror = true; + setRotation(backEdge1, 0F, 0F, 0F); + vents = new ModelRenderer(this, 70, 0); + vents.addBox(0F, 0F, 0F, 8, 2, 10); + vents.setRotationPoint(-4F, 9F, -4F); + vents.setTextureSize(128, 64); + vents.mirror = true; + setRotation(vents, 0F, 0F, 0F); + support1 = new ModelRenderer(this, 4, 0); + support1.addBox(0F, 0F, 0F, 1, 2, 1); + support1.setRotationPoint(-7F, 9F, -7F); + support1.setTextureSize(128, 64); + support1.mirror = true; + setRotation(support1, 0F, 0F, 0F); + vat1 = new ModelRenderer(this, 0, 23); + vat1.addBox(0F, 0F, 0F, 3, 4, 3); + vat1.setRotationPoint(-5F, 13F, -5F); + vat1.setTextureSize(128, 64); + vat1.mirror = true; + setRotation(vat1, 0F, 0F, 0F); + nozzle8 = new ModelRenderer(this, 0, 0); + nozzle8.addBox(0F, 0F, 0F, 1, 1, 1); + nozzle8.setRotationPoint(3F, 11.5F, -0.5F); + nozzle8.setTextureSize(128, 64); + nozzle8.mirror = true; + setRotation(nozzle8, 0F, 0F, 0F); + nozzle5 = new ModelRenderer(this, 0, 0); + nozzle5.addBox(0F, 0F, 0F, 1, 1, 1); + nozzle5.setRotationPoint(-0.5F, 11.5F, -0.5F); + nozzle5.setTextureSize(128, 64); + nozzle5.mirror = true; + setRotation(nozzle5, 0F, 0F, 0F); + nozzle7 = new ModelRenderer(this, 0, 0); + nozzle7.addBox(0F, 0F, 0F, 1, 1, 1); + nozzle7.setRotationPoint(3F, 11.5F, -4F); + nozzle7.setTextureSize(128, 64); + nozzle7.mirror = true; + setRotation(nozzle7, 0F, 0F, 0F); + nozzle4 = new ModelRenderer(this, 0, 0); + nozzle4.addBox(0F, 0F, 0F, 1, 1, 1); + nozzle4.setRotationPoint(-0.5F, 11.5F, -4F); + nozzle4.setTextureSize(128, 64); + nozzle4.mirror = true; + setRotation(nozzle4, 0F, 0F, 0F); + nozzle9 = new ModelRenderer(this, 0, 0); + nozzle9.addBox(0F, 0F, 0F, 1, 1, 1); + nozzle9.setRotationPoint(3F, 11.5F, 3F); + nozzle9.setTextureSize(128, 64); + nozzle9.mirror = true; + setRotation(nozzle9, 0F, 0F, 0F); + nozzle6 = new ModelRenderer(this, 0, 0); + nozzle6.addBox(0F, 0F, 0F, 1, 1, 1); + nozzle6.setRotationPoint(-0.5F, 11.5F, 3F); + nozzle6.setTextureSize(128, 64); + nozzle6.mirror = true; + setRotation(nozzle6, 0F, 0F, 0F); + nozzle3 = new ModelRenderer(this, 0, 0); + nozzle3.addBox(0F, 0F, 0F, 1, 1, 1); + nozzle3.setRotationPoint(-4F, 11.5F, 3F); + nozzle3.setTextureSize(128, 64); + nozzle3.mirror = true; + setRotation(nozzle3, 0F, 0F, 0F); + nozzle2 = new ModelRenderer(this, 0, 0); + nozzle2.addBox(0F, 0F, 0F, 1, 1, 1); + nozzle2.setRotationPoint(-4F, 11.5F, -0.5F); + nozzle2.setTextureSize(128, 64); + nozzle2.mirror = true; + setRotation(nozzle2, 0F, 0F, 0F); + nozzle1 = new ModelRenderer(this, 0, 0); + nozzle1.addBox(0F, 0F, 0F, 1, 1, 1); + nozzle1.setRotationPoint(-4F, 11.5F, -4F); + nozzle1.setTextureSize(128, 64); + nozzle1.mirror = true; + setRotation(nozzle1, 0F, 0F, 0F); + glass = new ModelRenderer(this, 64, 14); + glass.addBox(0F, 0F, 0F, 14, 5, 13); + glass.setRotationPoint(-7F, 12F, -7F); + glass.setTextureSize(128, 64); + glass.mirror = true; + setRotation(glass, 0F, 0F, 0F); + portToggle1 = new ModelRenderer(this, 106, 0); + portToggle1.addBox(0F, 0F, 0F, 1, 10, 10); + portToggle1.setRotationPoint(-8.01F, 10.99F, -5F); + portToggle1.setTextureSize(128, 64); + portToggle1.mirror = true; + setRotation(portToggle1, 0F, 0F, 0F); + portToggle2 = new ModelRenderer(this, 64, 32); + portToggle2.addBox(0F, 0F, 0F, 1, 8, 8); + portToggle2.setRotationPoint(7.01F, 12F, -4F); + portToggle2.setTextureSize(128, 64); + portToggle2.mirror = true; + setRotation(portToggle2, 0F, 0F, 0F); + } - public void render(float size) - { - MekanismRenderer.blendOn(); - - support2.render(size); - vat5.render(size); - top2.render(size); - top.render(size); - base.render(size); - vat2.render(size); - vat3.render(size); - vat6.render(size); - vat9.render(size); - vat8.render(size); - vat7.render(size); - vat4.render(size); - backEdge2.render(size); - back.render(size); - backEdge1.render(size); - vents.render(size); - support1.render(size); - vat1.render(size); - nozzle8.render(size); - nozzle5.render(size); - nozzle7.render(size); - nozzle4.render(size); - nozzle9.render(size); - nozzle6.render(size); - nozzle3.render(size); - nozzle2.render(size); - nozzle1.render(size); - glass.render(size); - portToggle1.render(size); - portToggle2.render(size); - - MekanismRenderer.blendOff(); - } + public void render(float size) { + MekanismRenderer.blendOn(); - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + support2.render(size); + vat5.render(size); + top2.render(size); + top.render(size); + base.render(size); + vat2.render(size); + vat3.render(size); + vat6.render(size); + vat9.render(size); + vat8.render(size); + vat7.render(size); + vat4.render(size); + backEdge2.render(size); + back.render(size); + backEdge1.render(size); + vents.render(size); + support1.render(size); + vat1.render(size); + nozzle8.render(size); + nozzle5.render(size); + nozzle7.render(size); + nozzle4.render(size); + nozzle9.render(size); + nozzle6.render(size); + nozzle3.render(size); + nozzle2.render(size); + nozzle1.render(size); + glass.render(size); + portToggle1.render(size); + portToggle2.render(size); + + MekanismRenderer.blendOff(); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/mekanism/client/model/ModelChemicalInfuser.java b/src/main/java/mekanism/client/model/ModelChemicalInfuser.java index 24413cb7c..8f4c048e6 100644 --- a/src/main/java/mekanism/client/model/ModelChemicalInfuser.java +++ b/src/main/java/mekanism/client/model/ModelChemicalInfuser.java @@ -1,261 +1,257 @@ package mekanism.client.model; -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; @SideOnly(Side.CLIENT) -public class ModelChemicalInfuser extends ModelBase -{ - ModelRenderer base; - ModelRenderer tank2; - ModelRenderer portRight; - ModelRenderer portBack; - ModelRenderer portLeft; - ModelRenderer tank1; - ModelRenderer portFront; - ModelRenderer tank3; - ModelRenderer pipeAngle2; - ModelRenderer connectorAngle; - ModelRenderer pipe2; - ModelRenderer connector; - ModelRenderer compressor; - ModelRenderer tube10; - ModelRenderer tube8; - ModelRenderer tube9; - ModelRenderer tube7; - ModelRenderer tube6; - ModelRenderer tube5; - ModelRenderer tube4; - ModelRenderer tube3; - ModelRenderer tube2; - ModelRenderer tube1; - ModelRenderer pipe1; - ModelRenderer pipeAngle1; - ModelRenderer exhaust4; - ModelRenderer exhaust3; - ModelRenderer exhaust2; - ModelRenderer exhaust1; +public class ModelChemicalInfuser extends ModelBase { + ModelRenderer base; + ModelRenderer tank2; + ModelRenderer portRight; + ModelRenderer portBack; + ModelRenderer portLeft; + ModelRenderer tank1; + ModelRenderer portFront; + ModelRenderer tank3; + ModelRenderer pipeAngle2; + ModelRenderer connectorAngle; + ModelRenderer pipe2; + ModelRenderer connector; + ModelRenderer compressor; + ModelRenderer tube10; + ModelRenderer tube8; + ModelRenderer tube9; + ModelRenderer tube7; + ModelRenderer tube6; + ModelRenderer tube5; + ModelRenderer tube4; + ModelRenderer tube3; + ModelRenderer tube2; + ModelRenderer tube1; + ModelRenderer pipe1; + ModelRenderer pipeAngle1; + ModelRenderer exhaust4; + ModelRenderer exhaust3; + ModelRenderer exhaust2; + ModelRenderer exhaust1; - public ModelChemicalInfuser() - { - textureWidth = 128; - textureHeight = 64; + public ModelChemicalInfuser() { + textureWidth = 128; + textureHeight = 64; - base = new ModelRenderer(this, 0, 0); - base.addBox(0F, 0F, 0F, 16, 5, 16); - base.setRotationPoint(-8F, 19F, -8F); - base.setTextureSize(128, 64); - base.mirror = true; - setRotation(base, 0F, 0F, 0F); - tank2 = new ModelRenderer(this, 0, 21); - tank2.mirror = true; - tank2.addBox(0F, 0F, 0F, 6, 11, 6); - tank2.setRotationPoint(1F, 8F, 1F); - tank2.setTextureSize(128, 64); - setRotation(tank2, 0F, 0F, 0F); - portRight = new ModelRenderer(this, 0, 38); - portRight.addBox(0F, 0F, 0F, 1, 8, 8); - portRight.setRotationPoint(7.01F, 12F, -4F); - portRight.setTextureSize(128, 64); - portRight.mirror = true; - setRotation(portRight, 0F, 0F, 0F); - portBack = new ModelRenderer(this, 0, 54); - portBack.addBox(0F, 0F, 0F, 8, 8, 1); - portBack.setRotationPoint(-4F, 12F, 7.01F); - portBack.setTextureSize(128, 64); - portBack.mirror = true; - setRotation(portBack, 0F, 0F, 0F); - portLeft = new ModelRenderer(this, 0, 38); - portLeft.addBox(0F, 0F, 0F, 1, 8, 8); - portLeft.setRotationPoint(-8.01F, 12F, -4F); - portLeft.setTextureSize(128, 64); - portLeft.mirror = true; - setRotation(portLeft, 0F, 0F, 0F); - tank1 = new ModelRenderer(this, 0, 21); - tank1.addBox(0F, 0F, 0F, 6, 11, 6); - tank1.setRotationPoint(-7F, 8F, 1F); - tank1.setTextureSize(128, 64); - tank1.mirror = true; - setRotation(tank1, 0F, 0F, 0F); - portFront = new ModelRenderer(this, 18, 38); - portFront.addBox(0F, 0F, 0F, 8, 8, 1); - portFront.setRotationPoint(-4F, 12F, -8.01F); - portFront.setTextureSize(128, 64); - portFront.mirror = true; - setRotation(portFront, 0F, 0F, 0F); - tank3 = new ModelRenderer(this, 24, 21); - tank3.addBox(0F, 0F, 0F, 12, 7, 7); - tank3.setRotationPoint(-6F, 12F, -7F); - tank3.setTextureSize(128, 64); - tank3.mirror = true; - setRotation(tank3, 0F, 0F, 0F); - pipeAngle2 = new ModelRenderer(this, 18, 55); - pipeAngle2.addBox(-5F, 0F, 0F, 5, 6, 3); - pipeAngle2.setRotationPoint(5F, 13.01F, -2F); - pipeAngle2.setTextureSize(128, 64); - pipeAngle2.mirror = true; - setRotation(pipeAngle2, 0F, 0.7853982F, 0F); - connectorAngle = new ModelRenderer(this, 40, 45); - connectorAngle.addBox(0F, 0F, 0F, 2, 8, 2); - connectorAngle.setRotationPoint(-1F, 13F, 5F); - connectorAngle.setTextureSize(128, 64); - connectorAngle.mirror = true; - setRotation(connectorAngle, -0.4886922F, 0F, 0F); - pipe2 = new ModelRenderer(this, 40, 35); - pipe2.addBox(0F, 0F, 0F, 1, 6, 4); - pipe2.setRotationPoint(6F, 13F, -3F); - pipe2.setTextureSize(128, 64); - pipe2.mirror = true; - setRotation(pipe2, 0F, 0F, 0F); - connector = new ModelRenderer(this, 50, 35); - connector.addBox(0F, 0F, 0F, 2, 6, 2); - connector.setRotationPoint(-1F, 13F, 5F); - connector.setTextureSize(128, 64); - connector.mirror = true; - setRotation(connector, 0F, 0F, 0F); - compressor = new ModelRenderer(this, 18, 49); - compressor.addBox(0F, 0F, 0F, 6, 3, 3); - compressor.setRotationPoint(-3F, 8.5F, -2.5F); - compressor.setTextureSize(128, 64); - compressor.mirror = true; - setRotation(compressor, 0F, 0F, 0F); - tube10 = new ModelRenderer(this, 0, 14); - tube10.addBox(0F, 0F, 0F, 2, 1, 1); - tube10.setRotationPoint(-1F, 9F, 5F); - tube10.setTextureSize(128, 64); - tube10.mirror = true; - setRotation(tube10, 0F, 0F, 0F); - tube8 = new ModelRenderer(this, 0, 2); - tube8.addBox(0F, 0F, 0F, 1, 1, 2); - tube8.setRotationPoint(4F, 9.5F, -0.5F); - tube8.setTextureSize(128, 64); - tube8.mirror = true; - setRotation(tube8, 0F, 0F, 0F); - tube9 = new ModelRenderer(this, 0, 14); - tube9.addBox(0F, 0F, 0F, 2, 1, 1); - tube9.setRotationPoint(-1F, 9F, 2F); - tube9.setTextureSize(128, 64); - tube9.mirror = true; - setRotation(tube9, 0F, 0F, 0F); - tube7 = new ModelRenderer(this, 0, 0); - tube7.addBox(0F, 0F, 0F, 2, 1, 1); - tube7.setRotationPoint(3F, 9.5F, -1.5F); - tube7.setTextureSize(128, 64); - tube7.mirror = true; - setRotation(tube7, 0F, 0F, 0F); - tube6 = new ModelRenderer(this, 12, 13); - tube6.addBox(0F, 0F, 0F, 1, 2, 1); - tube6.setRotationPoint(1F, 10.5F, -4F); - tube6.setTextureSize(128, 64); - tube6.mirror = true; - setRotation(tube6, 0F, 0F, 0F); - tube5 = new ModelRenderer(this, 0, 2); - tube5.addBox(0F, 0F, 0F, 1, 1, 2); - tube5.setRotationPoint(1F, 9.5F, -4F); - tube5.setTextureSize(128, 64); - tube5.mirror = true; - setRotation(tube5, 0F, 0F, 0F); - tube4 = new ModelRenderer(this, 0, 2); - tube4.addBox(0F, 0F, 0F, 1, 1, 2); - tube4.setRotationPoint(-2F, 9.5F, -4F); - tube4.setTextureSize(128, 64); - tube4.mirror = true; - setRotation(tube4, 0F, 0F, 0F); - tube3 = new ModelRenderer(this, 12, 13); - tube3.addBox(0F, 0F, 0F, 1, 2, 1); - tube3.setRotationPoint(-2F, 10.5F, -4F); - tube3.setTextureSize(128, 64); - tube3.mirror = true; - setRotation(tube3, 0F, 0F, 0F); - tube2 = new ModelRenderer(this, 0, 0); - tube2.addBox(0F, 0F, 0F, 2, 1, 1); - tube2.setRotationPoint(-5F, 9.5F, -1.5F); - tube2.setTextureSize(128, 64); - tube2.mirror = true; - setRotation(tube2, 0F, 0F, 0F); - tube1 = new ModelRenderer(this, 0, 2); - tube1.addBox(0F, 0F, 0F, 1, 1, 2); - tube1.setRotationPoint(-5F, 9.5F, -0.5F); - tube1.setTextureSize(128, 64); - tube1.mirror = true; - setRotation(tube1, 0F, 0F, 0F); - pipe1 = new ModelRenderer(this, 40, 35); - pipe1.addBox(0F, 0F, 0F, 1, 6, 4); - pipe1.setRotationPoint(-7F, 13F, -3F); - pipe1.setTextureSize(128, 64); - pipe1.mirror = true; - setRotation(pipe1, 0F, 0F, 0F); - pipeAngle1 = new ModelRenderer(this, 18, 55); - pipeAngle1.addBox(0F, 0F, 0F, 5, 6, 3); - pipeAngle1.setRotationPoint(-5F, 13.01F, -2F); - pipeAngle1.setTextureSize(128, 64); - pipeAngle1.mirror = true; - setRotation(pipeAngle1, 0F, -0.7853982F, 0F); - exhaust4 = new ModelRenderer(this, 0, 9); - exhaust4.addBox(0F, 0F, 0F, 1, 1, 1); - exhaust4.setRotationPoint(-1.33F, 11.5F, -6.2F); - exhaust4.setTextureSize(128, 64); - exhaust4.mirror = true; - setRotation(exhaust4, 0.3490659F, 0F, 0F); - exhaust3 = new ModelRenderer(this, 0, 9); - exhaust3.addBox(0F, 0F, 0F, 1, 1, 1); - exhaust3.setRotationPoint(-3F, 11.5F, -6.2F); - exhaust3.setTextureSize(128, 64); - exhaust3.mirror = true; - setRotation(exhaust3, 0.3490659F, 0F, 0F); - exhaust2 = new ModelRenderer(this, 0, 9); - exhaust2.addBox(0F, 0F, 0F, 1, 1, 1); - exhaust2.setRotationPoint(2F, 11.5F, -6.2F); - exhaust2.setTextureSize(128, 64); - exhaust2.mirror = true; - setRotation(exhaust2, 0.3490659F, 0F, 0F); - exhaust1 = new ModelRenderer(this, 0, 9); - exhaust1.addBox(0F, 0F, 0F, 1, 1, 1); - exhaust1.setRotationPoint(0.33F, 11.5F, -6.2F); - exhaust1.setTextureSize(128, 64); - exhaust1.mirror = true; - setRotation(exhaust1, 0.3490659F, 0F, 0F); - } + base = new ModelRenderer(this, 0, 0); + base.addBox(0F, 0F, 0F, 16, 5, 16); + base.setRotationPoint(-8F, 19F, -8F); + base.setTextureSize(128, 64); + base.mirror = true; + setRotation(base, 0F, 0F, 0F); + tank2 = new ModelRenderer(this, 0, 21); + tank2.mirror = true; + tank2.addBox(0F, 0F, 0F, 6, 11, 6); + tank2.setRotationPoint(1F, 8F, 1F); + tank2.setTextureSize(128, 64); + setRotation(tank2, 0F, 0F, 0F); + portRight = new ModelRenderer(this, 0, 38); + portRight.addBox(0F, 0F, 0F, 1, 8, 8); + portRight.setRotationPoint(7.01F, 12F, -4F); + portRight.setTextureSize(128, 64); + portRight.mirror = true; + setRotation(portRight, 0F, 0F, 0F); + portBack = new ModelRenderer(this, 0, 54); + portBack.addBox(0F, 0F, 0F, 8, 8, 1); + portBack.setRotationPoint(-4F, 12F, 7.01F); + portBack.setTextureSize(128, 64); + portBack.mirror = true; + setRotation(portBack, 0F, 0F, 0F); + portLeft = new ModelRenderer(this, 0, 38); + portLeft.addBox(0F, 0F, 0F, 1, 8, 8); + portLeft.setRotationPoint(-8.01F, 12F, -4F); + portLeft.setTextureSize(128, 64); + portLeft.mirror = true; + setRotation(portLeft, 0F, 0F, 0F); + tank1 = new ModelRenderer(this, 0, 21); + tank1.addBox(0F, 0F, 0F, 6, 11, 6); + tank1.setRotationPoint(-7F, 8F, 1F); + tank1.setTextureSize(128, 64); + tank1.mirror = true; + setRotation(tank1, 0F, 0F, 0F); + portFront = new ModelRenderer(this, 18, 38); + portFront.addBox(0F, 0F, 0F, 8, 8, 1); + portFront.setRotationPoint(-4F, 12F, -8.01F); + portFront.setTextureSize(128, 64); + portFront.mirror = true; + setRotation(portFront, 0F, 0F, 0F); + tank3 = new ModelRenderer(this, 24, 21); + tank3.addBox(0F, 0F, 0F, 12, 7, 7); + tank3.setRotationPoint(-6F, 12F, -7F); + tank3.setTextureSize(128, 64); + tank3.mirror = true; + setRotation(tank3, 0F, 0F, 0F); + pipeAngle2 = new ModelRenderer(this, 18, 55); + pipeAngle2.addBox(-5F, 0F, 0F, 5, 6, 3); + pipeAngle2.setRotationPoint(5F, 13.01F, -2F); + pipeAngle2.setTextureSize(128, 64); + pipeAngle2.mirror = true; + setRotation(pipeAngle2, 0F, 0.7853982F, 0F); + connectorAngle = new ModelRenderer(this, 40, 45); + connectorAngle.addBox(0F, 0F, 0F, 2, 8, 2); + connectorAngle.setRotationPoint(-1F, 13F, 5F); + connectorAngle.setTextureSize(128, 64); + connectorAngle.mirror = true; + setRotation(connectorAngle, -0.4886922F, 0F, 0F); + pipe2 = new ModelRenderer(this, 40, 35); + pipe2.addBox(0F, 0F, 0F, 1, 6, 4); + pipe2.setRotationPoint(6F, 13F, -3F); + pipe2.setTextureSize(128, 64); + pipe2.mirror = true; + setRotation(pipe2, 0F, 0F, 0F); + connector = new ModelRenderer(this, 50, 35); + connector.addBox(0F, 0F, 0F, 2, 6, 2); + connector.setRotationPoint(-1F, 13F, 5F); + connector.setTextureSize(128, 64); + connector.mirror = true; + setRotation(connector, 0F, 0F, 0F); + compressor = new ModelRenderer(this, 18, 49); + compressor.addBox(0F, 0F, 0F, 6, 3, 3); + compressor.setRotationPoint(-3F, 8.5F, -2.5F); + compressor.setTextureSize(128, 64); + compressor.mirror = true; + setRotation(compressor, 0F, 0F, 0F); + tube10 = new ModelRenderer(this, 0, 14); + tube10.addBox(0F, 0F, 0F, 2, 1, 1); + tube10.setRotationPoint(-1F, 9F, 5F); + tube10.setTextureSize(128, 64); + tube10.mirror = true; + setRotation(tube10, 0F, 0F, 0F); + tube8 = new ModelRenderer(this, 0, 2); + tube8.addBox(0F, 0F, 0F, 1, 1, 2); + tube8.setRotationPoint(4F, 9.5F, -0.5F); + tube8.setTextureSize(128, 64); + tube8.mirror = true; + setRotation(tube8, 0F, 0F, 0F); + tube9 = new ModelRenderer(this, 0, 14); + tube9.addBox(0F, 0F, 0F, 2, 1, 1); + tube9.setRotationPoint(-1F, 9F, 2F); + tube9.setTextureSize(128, 64); + tube9.mirror = true; + setRotation(tube9, 0F, 0F, 0F); + tube7 = new ModelRenderer(this, 0, 0); + tube7.addBox(0F, 0F, 0F, 2, 1, 1); + tube7.setRotationPoint(3F, 9.5F, -1.5F); + tube7.setTextureSize(128, 64); + tube7.mirror = true; + setRotation(tube7, 0F, 0F, 0F); + tube6 = new ModelRenderer(this, 12, 13); + tube6.addBox(0F, 0F, 0F, 1, 2, 1); + tube6.setRotationPoint(1F, 10.5F, -4F); + tube6.setTextureSize(128, 64); + tube6.mirror = true; + setRotation(tube6, 0F, 0F, 0F); + tube5 = new ModelRenderer(this, 0, 2); + tube5.addBox(0F, 0F, 0F, 1, 1, 2); + tube5.setRotationPoint(1F, 9.5F, -4F); + tube5.setTextureSize(128, 64); + tube5.mirror = true; + setRotation(tube5, 0F, 0F, 0F); + tube4 = new ModelRenderer(this, 0, 2); + tube4.addBox(0F, 0F, 0F, 1, 1, 2); + tube4.setRotationPoint(-2F, 9.5F, -4F); + tube4.setTextureSize(128, 64); + tube4.mirror = true; + setRotation(tube4, 0F, 0F, 0F); + tube3 = new ModelRenderer(this, 12, 13); + tube3.addBox(0F, 0F, 0F, 1, 2, 1); + tube3.setRotationPoint(-2F, 10.5F, -4F); + tube3.setTextureSize(128, 64); + tube3.mirror = true; + setRotation(tube3, 0F, 0F, 0F); + tube2 = new ModelRenderer(this, 0, 0); + tube2.addBox(0F, 0F, 0F, 2, 1, 1); + tube2.setRotationPoint(-5F, 9.5F, -1.5F); + tube2.setTextureSize(128, 64); + tube2.mirror = true; + setRotation(tube2, 0F, 0F, 0F); + tube1 = new ModelRenderer(this, 0, 2); + tube1.addBox(0F, 0F, 0F, 1, 1, 2); + tube1.setRotationPoint(-5F, 9.5F, -0.5F); + tube1.setTextureSize(128, 64); + tube1.mirror = true; + setRotation(tube1, 0F, 0F, 0F); + pipe1 = new ModelRenderer(this, 40, 35); + pipe1.addBox(0F, 0F, 0F, 1, 6, 4); + pipe1.setRotationPoint(-7F, 13F, -3F); + pipe1.setTextureSize(128, 64); + pipe1.mirror = true; + setRotation(pipe1, 0F, 0F, 0F); + pipeAngle1 = new ModelRenderer(this, 18, 55); + pipeAngle1.addBox(0F, 0F, 0F, 5, 6, 3); + pipeAngle1.setRotationPoint(-5F, 13.01F, -2F); + pipeAngle1.setTextureSize(128, 64); + pipeAngle1.mirror = true; + setRotation(pipeAngle1, 0F, -0.7853982F, 0F); + exhaust4 = new ModelRenderer(this, 0, 9); + exhaust4.addBox(0F, 0F, 0F, 1, 1, 1); + exhaust4.setRotationPoint(-1.33F, 11.5F, -6.2F); + exhaust4.setTextureSize(128, 64); + exhaust4.mirror = true; + setRotation(exhaust4, 0.3490659F, 0F, 0F); + exhaust3 = new ModelRenderer(this, 0, 9); + exhaust3.addBox(0F, 0F, 0F, 1, 1, 1); + exhaust3.setRotationPoint(-3F, 11.5F, -6.2F); + exhaust3.setTextureSize(128, 64); + exhaust3.mirror = true; + setRotation(exhaust3, 0.3490659F, 0F, 0F); + exhaust2 = new ModelRenderer(this, 0, 9); + exhaust2.addBox(0F, 0F, 0F, 1, 1, 1); + exhaust2.setRotationPoint(2F, 11.5F, -6.2F); + exhaust2.setTextureSize(128, 64); + exhaust2.mirror = true; + setRotation(exhaust2, 0.3490659F, 0F, 0F); + exhaust1 = new ModelRenderer(this, 0, 9); + exhaust1.addBox(0F, 0F, 0F, 1, 1, 1); + exhaust1.setRotationPoint(0.33F, 11.5F, -6.2F); + exhaust1.setTextureSize(128, 64); + exhaust1.mirror = true; + setRotation(exhaust1, 0.3490659F, 0F, 0F); + } - public void render(float size) - { - base.render(size); - tank2.render(size); - portRight.render(size); - portBack.render(size); - portLeft.render(size); - tank1.render(size); - portFront.render(size); - tank3.render(size); - pipeAngle2.render(size); - connectorAngle.render(size); - pipe2.render(size); - connector.render(size); - compressor.render(size); - tube10.render(size); - tube8.render(size); - tube9.render(size); - tube7.render(size); - tube6.render(size); - tube5.render(size); - tube4.render(size); - tube3.render(size); - tube2.render(size); - tube1.render(size); - pipe1.render(size); - pipeAngle1.render(size); - exhaust4.render(size); - exhaust3.render(size); - exhaust2.render(size); - exhaust1.render(size); - } + public void render(float size) { + base.render(size); + tank2.render(size); + portRight.render(size); + portBack.render(size); + portLeft.render(size); + tank1.render(size); + portFront.render(size); + tank3.render(size); + pipeAngle2.render(size); + connectorAngle.render(size); + pipe2.render(size); + connector.render(size); + compressor.render(size); + tube10.render(size); + tube8.render(size); + tube9.render(size); + tube7.render(size); + tube6.render(size); + tube5.render(size); + tube4.render(size); + tube3.render(size); + tube2.render(size); + tube1.render(size); + pipe1.render(size); + pipeAngle1.render(size); + exhaust4.render(size); + exhaust3.render(size); + exhaust2.render(size); + exhaust1.render(size); + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/mekanism/client/model/ModelChemicalOxidizer.java b/src/main/java/mekanism/client/model/ModelChemicalOxidizer.java index b2cd1a122..a36f496da 100644 --- a/src/main/java/mekanism/client/model/ModelChemicalOxidizer.java +++ b/src/main/java/mekanism/client/model/ModelChemicalOxidizer.java @@ -1,109 +1,105 @@ package mekanism.client.model; -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; @SideOnly(Side.CLIENT) -public class ModelChemicalOxidizer extends ModelBase -{ - ModelRenderer stand; - ModelRenderer tank; - ModelRenderer pipe2; - ModelRenderer bridge; - ModelRenderer pipe1; - ModelRenderer tower2; - ModelRenderer tower1; - ModelRenderer base; - ModelRenderer connector; - ModelRenderer connectorToggle; +public class ModelChemicalOxidizer extends ModelBase { + ModelRenderer stand; + ModelRenderer tank; + ModelRenderer pipe2; + ModelRenderer bridge; + ModelRenderer pipe1; + ModelRenderer tower2; + ModelRenderer tower1; + ModelRenderer base; + ModelRenderer connector; + ModelRenderer connectorToggle; - public ModelChemicalOxidizer() - { - textureWidth = 128; - textureHeight = 64; + public ModelChemicalOxidizer() { + textureWidth = 128; + textureHeight = 64; - stand = new ModelRenderer(this, 0, 20); - stand.addBox(0F, 0F, 0F, 5, 1, 13); - stand.setRotationPoint(-5.5F, 19F, -6.5F); - stand.setTextureSize(128, 64); - stand.mirror = true; - setRotation(stand, 0F, 0F, 0F); - tank = new ModelRenderer(this, 66, 0); - tank.addBox(0F, 0F, 0F, 7, 12, 16); - tank.setRotationPoint(1F, 8F, -8F); - tank.setTextureSize(128, 64); - tank.mirror = true; - setRotation(tank, 0F, 0F, 0F); - pipe2 = new ModelRenderer(this, 82, 28); - pipe2.addBox(0F, 0F, 0F, 2, 6, 6); - pipe2.setRotationPoint(-7F, 13F, -3F); - pipe2.setTextureSize(128, 64); - pipe2.mirror = true; - setRotation(pipe2, 0F, 0F, 0F); - bridge = new ModelRenderer(this, 70, 0); - bridge.addBox(0F, 0F, 0F, 5, 10, 1); - bridge.setRotationPoint(-5.5F, 8.5F, -2F); - bridge.setTextureSize(128, 64); - bridge.mirror = true; - setRotation(bridge, 0F, 0F, 0F); - pipe1 = new ModelRenderer(this, 0, 0); - pipe1.addBox(0F, 0F, 0F, 1, 3, 3); - pipe1.setRotationPoint(0F, 14F, 1F); - pipe1.setTextureSize(128, 64); - pipe1.mirror = true; - setRotation(pipe1, 0F, 0F, 0F); - tower2 = new ModelRenderer(this, 36, 20); - tower2.addBox(0F, 0F, 0F, 6, 11, 8); - tower2.setRotationPoint(-6F, 8F, -1F); - tower2.setTextureSize(128, 64); - tower2.mirror = true; - setRotation(tower2, 0F, 0F, 0F); - tower1 = new ModelRenderer(this, 48, 0); - tower1.addBox(0F, 0F, 0F, 6, 11, 5); - tower1.setRotationPoint(-6F, 8F, -7F); - tower1.setTextureSize(128, 64); - tower1.mirror = true; - setRotation(tower1, 0F, 0F, 0F); - base = new ModelRenderer(this, 0, 0); - base.addBox(0F, 0F, 0F, 16, 4, 16); - base.setRotationPoint(-8F, 20F, -8F); - base.setTextureSize(128, 64); - base.mirror = true; - setRotation(base, 0F, 0F, 0F); - connector = new ModelRenderer(this, 0, 34); - connector.addBox(0F, 0F, 0F, 1, 10, 10); - connector.setRotationPoint(-8F, 11F, -5F); - connector.setTextureSize(128, 64); - connector.mirror = true; - setRotation(connector, 0F, 0F, 0F); - connectorToggle = new ModelRenderer(this, 64, 28); - connectorToggle.addBox(0F, 0F, 0F, 1, 8, 8); - connectorToggle.setRotationPoint(7.01F, 12F, -4F); - connectorToggle.setTextureSize(128, 64); - connectorToggle.mirror = true; - setRotation(connectorToggle, 0F, 0F, 0F); - } + stand = new ModelRenderer(this, 0, 20); + stand.addBox(0F, 0F, 0F, 5, 1, 13); + stand.setRotationPoint(-5.5F, 19F, -6.5F); + stand.setTextureSize(128, 64); + stand.mirror = true; + setRotation(stand, 0F, 0F, 0F); + tank = new ModelRenderer(this, 66, 0); + tank.addBox(0F, 0F, 0F, 7, 12, 16); + tank.setRotationPoint(1F, 8F, -8F); + tank.setTextureSize(128, 64); + tank.mirror = true; + setRotation(tank, 0F, 0F, 0F); + pipe2 = new ModelRenderer(this, 82, 28); + pipe2.addBox(0F, 0F, 0F, 2, 6, 6); + pipe2.setRotationPoint(-7F, 13F, -3F); + pipe2.setTextureSize(128, 64); + pipe2.mirror = true; + setRotation(pipe2, 0F, 0F, 0F); + bridge = new ModelRenderer(this, 70, 0); + bridge.addBox(0F, 0F, 0F, 5, 10, 1); + bridge.setRotationPoint(-5.5F, 8.5F, -2F); + bridge.setTextureSize(128, 64); + bridge.mirror = true; + setRotation(bridge, 0F, 0F, 0F); + pipe1 = new ModelRenderer(this, 0, 0); + pipe1.addBox(0F, 0F, 0F, 1, 3, 3); + pipe1.setRotationPoint(0F, 14F, 1F); + pipe1.setTextureSize(128, 64); + pipe1.mirror = true; + setRotation(pipe1, 0F, 0F, 0F); + tower2 = new ModelRenderer(this, 36, 20); + tower2.addBox(0F, 0F, 0F, 6, 11, 8); + tower2.setRotationPoint(-6F, 8F, -1F); + tower2.setTextureSize(128, 64); + tower2.mirror = true; + setRotation(tower2, 0F, 0F, 0F); + tower1 = new ModelRenderer(this, 48, 0); + tower1.addBox(0F, 0F, 0F, 6, 11, 5); + tower1.setRotationPoint(-6F, 8F, -7F); + tower1.setTextureSize(128, 64); + tower1.mirror = true; + setRotation(tower1, 0F, 0F, 0F); + base = new ModelRenderer(this, 0, 0); + base.addBox(0F, 0F, 0F, 16, 4, 16); + base.setRotationPoint(-8F, 20F, -8F); + base.setTextureSize(128, 64); + base.mirror = true; + setRotation(base, 0F, 0F, 0F); + connector = new ModelRenderer(this, 0, 34); + connector.addBox(0F, 0F, 0F, 1, 10, 10); + connector.setRotationPoint(-8F, 11F, -5F); + connector.setTextureSize(128, 64); + connector.mirror = true; + setRotation(connector, 0F, 0F, 0F); + connectorToggle = new ModelRenderer(this, 64, 28); + connectorToggle.addBox(0F, 0F, 0F, 1, 8, 8); + connectorToggle.setRotationPoint(7.01F, 12F, -4F); + connectorToggle.setTextureSize(128, 64); + connectorToggle.mirror = true; + setRotation(connectorToggle, 0F, 0F, 0F); + } - public void render(float size) - { - stand.render(size); - tank.render(size); - pipe2.render(size); - bridge.render(size); - pipe1.render(size); - tower2.render(size); - tower1.render(size); - base.render(size); - connector.render(size); - connectorToggle.render(size); - } + public void render(float size) { + stand.render(size); + tank.render(size); + pipe2.render(size); + bridge.render(size); + pipe1.render(size); + tower2.render(size); + tower1.render(size); + base.render(size); + connector.render(size); + connectorToggle.render(size); + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/model/ModelChemicalWasher.java b/src/main/java/mekanism/client/model/ModelChemicalWasher.java index 3aa26bc5e..eb04de0e0 100644 --- a/src/main/java/mekanism/client/model/ModelChemicalWasher.java +++ b/src/main/java/mekanism/client/model/ModelChemicalWasher.java @@ -1,213 +1,209 @@ package mekanism.client.model; -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; @SideOnly(Side.CLIENT) -public class ModelChemicalWasher extends ModelBase -{ - ModelRenderer tankBack; - ModelRenderer base; - ModelRenderer portTop; - ModelRenderer pipe1; - ModelRenderer pipe2b; - ModelRenderer portRight; - ModelRenderer bridge1; - ModelRenderer bridge2; - ModelRenderer bridge3; - ModelRenderer conduit; - ModelRenderer bridge4; - ModelRenderer pipe2; - ModelRenderer tankLeft; - ModelRenderer connectorRight; - ModelRenderer portLeft; - ModelRenderer connectorLeft; - ModelRenderer tankRight; - ModelRenderer tubeLeft1; - ModelRenderer tubeLeft2; - ModelRenderer tubeRight3; - ModelRenderer tubeRight1; - ModelRenderer tubeRight2; - ModelRenderer tubeLeft3; +public class ModelChemicalWasher extends ModelBase { + ModelRenderer tankBack; + ModelRenderer base; + ModelRenderer portTop; + ModelRenderer pipe1; + ModelRenderer pipe2b; + ModelRenderer portRight; + ModelRenderer bridge1; + ModelRenderer bridge2; + ModelRenderer bridge3; + ModelRenderer conduit; + ModelRenderer bridge4; + ModelRenderer pipe2; + ModelRenderer tankLeft; + ModelRenderer connectorRight; + ModelRenderer portLeft; + ModelRenderer connectorLeft; + ModelRenderer tankRight; + ModelRenderer tubeLeft1; + ModelRenderer tubeLeft2; + ModelRenderer tubeRight3; + ModelRenderer tubeRight1; + ModelRenderer tubeRight2; + ModelRenderer tubeLeft3; - public ModelChemicalWasher() - { - textureWidth = 128; - textureHeight = 64; + public ModelChemicalWasher() { + textureWidth = 128; + textureHeight = 64; - tankBack = new ModelRenderer(this, 0, 20); - tankBack.addBox(0F, 0F, 0F, 16, 10, 6); - tankBack.setRotationPoint(-8F, 10F, 2F); - tankBack.setTextureSize(128, 64); - tankBack.mirror = true; - setRotation(tankBack, 0F, 0F, 0F); - base = new ModelRenderer(this, 0, 0); - base.addBox(0F, 0F, 0F, 16, 4, 16); - base.setRotationPoint(-8F, 20F, -8F); - base.setTextureSize(128, 64); - base.mirror = true; - setRotation(base, 0F, 0F, 0F); - portTop = new ModelRenderer(this, 53, 33); - portTop.addBox(0F, 0F, 0F, 10, 1, 10); - portTop.setRotationPoint(-5F, 8F, -5F); - portTop.setTextureSize(128, 64); - portTop.mirror = true; - setRotation(portTop, 0F, 0F, 0F); - pipe1 = new ModelRenderer(this, 66, 9); - pipe1.addBox(0F, 0F, 0F, 7, 5, 7); - pipe1.setRotationPoint(-3.5F, 9F, -3.5F); - pipe1.setTextureSize(128, 64); - pipe1.mirror = true; - setRotation(pipe1, 0F, 0F, 0F); - pipe2b = new ModelRenderer(this, 44, 21); - pipe2b.addBox(0F, 0F, 0F, 1, 8, 4); - pipe2b.setRotationPoint(-3.49F, 14F, -3.5F); - pipe2b.setTextureSize(128, 64); - pipe2b.mirror = true; - setRotation(pipe2b, 0.837758F, 0F, 0F); - portRight = new ModelRenderer(this, 48, 0); - portRight.addBox(0F, 0F, 0F, 1, 8, 8); - portRight.setRotationPoint(7.01F, 12F, -4F); - portRight.setTextureSize(128, 64); - portRight.mirror = true; - setRotation(portRight, 0F, 0F, 0F); - bridge1 = new ModelRenderer(this, 0, 0); - bridge1.addBox(0F, 0F, 0F, 2, 1, 1); - bridge1.setRotationPoint(-1F, 11F, -7F); - bridge1.setTextureSize(128, 64); - bridge1.mirror = true; - setRotation(bridge1, 0F, 0F, 0F); - bridge2 = new ModelRenderer(this, 0, 0); - bridge2.addBox(0F, 0F, 0F, 2, 1, 1); - bridge2.setRotationPoint(-1F, 13F, -7F); - bridge2.setTextureSize(128, 64); - bridge2.mirror = true; - setRotation(bridge2, 0F, 0F, 0F); - bridge3 = new ModelRenderer(this, 0, 0); - bridge3.addBox(0F, 0F, 0F, 2, 1, 1); - bridge3.setRotationPoint(-1F, 15F, -7F); - bridge3.setTextureSize(128, 64); - bridge3.mirror = true; - setRotation(bridge3, 0F, 0F, 0F); - conduit = new ModelRenderer(this, 0, 3); - conduit.addBox(0F, 0F, 0F, 2, 1, 2); - conduit.setRotationPoint(-1F, 19.5F, -5F); - conduit.setTextureSize(128, 64); - conduit.mirror = true; - setRotation(conduit, 0F, 0F, 0F); - bridge4 = new ModelRenderer(this, 0, 0); - bridge4.addBox(0F, 0F, 0F, 2, 1, 1); - bridge4.setRotationPoint(-1F, 17F, -7F); - bridge4.setTextureSize(128, 64); - bridge4.mirror = true; - setRotation(bridge4, 0F, 0F, 0F); - pipe2 = new ModelRenderer(this, 54, 21); - pipe2.addBox(0F, 0F, 0F, 6, 8, 4); - pipe2.setRotationPoint(-2.51F, 14F, -3.5F); - pipe2.setTextureSize(128, 64); - pipe2.mirror = true; - setRotation(pipe2, 0.837758F, 0F, 0F); - tankLeft = new ModelRenderer(this, 0, 36); - tankLeft.addBox(0F, 0F, 0F, 7, 10, 8); - tankLeft.setRotationPoint(-8F, 10F, -8F); - tankLeft.setTextureSize(128, 64); - tankLeft.mirror = true; - setRotation(tankLeft, 0F, 0F, 0F); - connectorRight = new ModelRenderer(this, 0, 7); - connectorRight.addBox(0F, 0F, 0F, 2, 6, 2); - connectorRight.setRotationPoint(5F, 13F, 0F); - connectorRight.setTextureSize(128, 64); - connectorRight.mirror = true; - setRotation(connectorRight, 0F, 0F, 0F); - portLeft = new ModelRenderer(this, 48, 0); - portLeft.addBox(0F, 0F, 0F, 1, 8, 8); - portLeft.setRotationPoint(-8.01F, 12F, -4F); - portLeft.setTextureSize(128, 64); - portLeft.mirror = true; - setRotation(portLeft, 0F, 0F, 0F); - connectorLeft = new ModelRenderer(this, 0, 7); - connectorLeft.addBox(0F, 0F, 0F, 2, 6, 2); - connectorLeft.setRotationPoint(-7F, 13F, 0F); - connectorLeft.setTextureSize(128, 64); - connectorLeft.mirror = true; - setRotation(connectorLeft, 0F, 0F, 0F); - tankRight = new ModelRenderer(this, 0, 36); - tankRight.mirror = true; - tankRight.addBox(0F, 0F, 0F, 7, 10, 8); - tankRight.setRotationPoint(1F, 10F, -8F); - tankRight.setTextureSize(128, 64); - setRotation(tankRight, 0F, 0F, 0F); - tubeLeft1 = new ModelRenderer(this, 30, 36); - tubeLeft1.addBox(0F, 0F, -1F, 1, 2, 1); - tubeLeft1.setRotationPoint(-6F, 8.5F, 4F); - tubeLeft1.setTextureSize(128, 64); - tubeLeft1.mirror = true; - setRotation(tubeLeft1, 0.6806784F, 0F, 0F); - tubeLeft2 = new ModelRenderer(this, 30, 36); - tubeLeft2.addBox(0F, 0F, 0F, 1, 1, 8); - tubeLeft2.setRotationPoint(-6F, 8.5F, -4F); - tubeLeft2.setTextureSize(128, 64); - tubeLeft2.mirror = true; - setRotation(tubeLeft2, 0F, 0F, 0F); - tubeRight3 = new ModelRenderer(this, 30, 39); - tubeRight3.addBox(0F, -1F, 0F, 1, 2, 1); - tubeRight3.setRotationPoint(6F, 10F, -2.5F); - tubeRight3.setTextureSize(128, 64); - tubeRight3.mirror = true; - setRotation(tubeRight3, 0F, 0F, 0.3141593F); - tubeRight1 = new ModelRenderer(this, 30, 39); - tubeRight1.addBox(0F, -1F, 0F, 1, 2, 1); - tubeRight1.setRotationPoint(6F, 10F, -6.5F); - tubeRight1.setTextureSize(128, 64); - tubeRight1.mirror = true; - setRotation(tubeRight1, 0F, 0F, 0.3141593F); - tubeRight2 = new ModelRenderer(this, 30, 39); - tubeRight2.addBox(0F, -1F, 0F, 1, 2, 1); - tubeRight2.setRotationPoint(6F, 10F, -4.5F); - tubeRight2.setTextureSize(128, 64); - tubeRight2.mirror = true; - setRotation(tubeRight2, 0F, 0F, 0.3141593F); - tubeLeft3 = new ModelRenderer(this, 30, 36); - tubeLeft3.addBox(0F, 0F, 0F, 1, 2, 1); - tubeLeft3.setRotationPoint(-6F, 9.5F, -4F); - tubeLeft3.setTextureSize(128, 64); - tubeLeft3.mirror = true; - setRotation(tubeLeft3, 0F, 0F, -0.8203047F); - } + tankBack = new ModelRenderer(this, 0, 20); + tankBack.addBox(0F, 0F, 0F, 16, 10, 6); + tankBack.setRotationPoint(-8F, 10F, 2F); + tankBack.setTextureSize(128, 64); + tankBack.mirror = true; + setRotation(tankBack, 0F, 0F, 0F); + base = new ModelRenderer(this, 0, 0); + base.addBox(0F, 0F, 0F, 16, 4, 16); + base.setRotationPoint(-8F, 20F, -8F); + base.setTextureSize(128, 64); + base.mirror = true; + setRotation(base, 0F, 0F, 0F); + portTop = new ModelRenderer(this, 53, 33); + portTop.addBox(0F, 0F, 0F, 10, 1, 10); + portTop.setRotationPoint(-5F, 8F, -5F); + portTop.setTextureSize(128, 64); + portTop.mirror = true; + setRotation(portTop, 0F, 0F, 0F); + pipe1 = new ModelRenderer(this, 66, 9); + pipe1.addBox(0F, 0F, 0F, 7, 5, 7); + pipe1.setRotationPoint(-3.5F, 9F, -3.5F); + pipe1.setTextureSize(128, 64); + pipe1.mirror = true; + setRotation(pipe1, 0F, 0F, 0F); + pipe2b = new ModelRenderer(this, 44, 21); + pipe2b.addBox(0F, 0F, 0F, 1, 8, 4); + pipe2b.setRotationPoint(-3.49F, 14F, -3.5F); + pipe2b.setTextureSize(128, 64); + pipe2b.mirror = true; + setRotation(pipe2b, 0.837758F, 0F, 0F); + portRight = new ModelRenderer(this, 48, 0); + portRight.addBox(0F, 0F, 0F, 1, 8, 8); + portRight.setRotationPoint(7.01F, 12F, -4F); + portRight.setTextureSize(128, 64); + portRight.mirror = true; + setRotation(portRight, 0F, 0F, 0F); + bridge1 = new ModelRenderer(this, 0, 0); + bridge1.addBox(0F, 0F, 0F, 2, 1, 1); + bridge1.setRotationPoint(-1F, 11F, -7F); + bridge1.setTextureSize(128, 64); + bridge1.mirror = true; + setRotation(bridge1, 0F, 0F, 0F); + bridge2 = new ModelRenderer(this, 0, 0); + bridge2.addBox(0F, 0F, 0F, 2, 1, 1); + bridge2.setRotationPoint(-1F, 13F, -7F); + bridge2.setTextureSize(128, 64); + bridge2.mirror = true; + setRotation(bridge2, 0F, 0F, 0F); + bridge3 = new ModelRenderer(this, 0, 0); + bridge3.addBox(0F, 0F, 0F, 2, 1, 1); + bridge3.setRotationPoint(-1F, 15F, -7F); + bridge3.setTextureSize(128, 64); + bridge3.mirror = true; + setRotation(bridge3, 0F, 0F, 0F); + conduit = new ModelRenderer(this, 0, 3); + conduit.addBox(0F, 0F, 0F, 2, 1, 2); + conduit.setRotationPoint(-1F, 19.5F, -5F); + conduit.setTextureSize(128, 64); + conduit.mirror = true; + setRotation(conduit, 0F, 0F, 0F); + bridge4 = new ModelRenderer(this, 0, 0); + bridge4.addBox(0F, 0F, 0F, 2, 1, 1); + bridge4.setRotationPoint(-1F, 17F, -7F); + bridge4.setTextureSize(128, 64); + bridge4.mirror = true; + setRotation(bridge4, 0F, 0F, 0F); + pipe2 = new ModelRenderer(this, 54, 21); + pipe2.addBox(0F, 0F, 0F, 6, 8, 4); + pipe2.setRotationPoint(-2.51F, 14F, -3.5F); + pipe2.setTextureSize(128, 64); + pipe2.mirror = true; + setRotation(pipe2, 0.837758F, 0F, 0F); + tankLeft = new ModelRenderer(this, 0, 36); + tankLeft.addBox(0F, 0F, 0F, 7, 10, 8); + tankLeft.setRotationPoint(-8F, 10F, -8F); + tankLeft.setTextureSize(128, 64); + tankLeft.mirror = true; + setRotation(tankLeft, 0F, 0F, 0F); + connectorRight = new ModelRenderer(this, 0, 7); + connectorRight.addBox(0F, 0F, 0F, 2, 6, 2); + connectorRight.setRotationPoint(5F, 13F, 0F); + connectorRight.setTextureSize(128, 64); + connectorRight.mirror = true; + setRotation(connectorRight, 0F, 0F, 0F); + portLeft = new ModelRenderer(this, 48, 0); + portLeft.addBox(0F, 0F, 0F, 1, 8, 8); + portLeft.setRotationPoint(-8.01F, 12F, -4F); + portLeft.setTextureSize(128, 64); + portLeft.mirror = true; + setRotation(portLeft, 0F, 0F, 0F); + connectorLeft = new ModelRenderer(this, 0, 7); + connectorLeft.addBox(0F, 0F, 0F, 2, 6, 2); + connectorLeft.setRotationPoint(-7F, 13F, 0F); + connectorLeft.setTextureSize(128, 64); + connectorLeft.mirror = true; + setRotation(connectorLeft, 0F, 0F, 0F); + tankRight = new ModelRenderer(this, 0, 36); + tankRight.mirror = true; + tankRight.addBox(0F, 0F, 0F, 7, 10, 8); + tankRight.setRotationPoint(1F, 10F, -8F); + tankRight.setTextureSize(128, 64); + setRotation(tankRight, 0F, 0F, 0F); + tubeLeft1 = new ModelRenderer(this, 30, 36); + tubeLeft1.addBox(0F, 0F, -1F, 1, 2, 1); + tubeLeft1.setRotationPoint(-6F, 8.5F, 4F); + tubeLeft1.setTextureSize(128, 64); + tubeLeft1.mirror = true; + setRotation(tubeLeft1, 0.6806784F, 0F, 0F); + tubeLeft2 = new ModelRenderer(this, 30, 36); + tubeLeft2.addBox(0F, 0F, 0F, 1, 1, 8); + tubeLeft2.setRotationPoint(-6F, 8.5F, -4F); + tubeLeft2.setTextureSize(128, 64); + tubeLeft2.mirror = true; + setRotation(tubeLeft2, 0F, 0F, 0F); + tubeRight3 = new ModelRenderer(this, 30, 39); + tubeRight3.addBox(0F, -1F, 0F, 1, 2, 1); + tubeRight3.setRotationPoint(6F, 10F, -2.5F); + tubeRight3.setTextureSize(128, 64); + tubeRight3.mirror = true; + setRotation(tubeRight3, 0F, 0F, 0.3141593F); + tubeRight1 = new ModelRenderer(this, 30, 39); + tubeRight1.addBox(0F, -1F, 0F, 1, 2, 1); + tubeRight1.setRotationPoint(6F, 10F, -6.5F); + tubeRight1.setTextureSize(128, 64); + tubeRight1.mirror = true; + setRotation(tubeRight1, 0F, 0F, 0.3141593F); + tubeRight2 = new ModelRenderer(this, 30, 39); + tubeRight2.addBox(0F, -1F, 0F, 1, 2, 1); + tubeRight2.setRotationPoint(6F, 10F, -4.5F); + tubeRight2.setTextureSize(128, 64); + tubeRight2.mirror = true; + setRotation(tubeRight2, 0F, 0F, 0.3141593F); + tubeLeft3 = new ModelRenderer(this, 30, 36); + tubeLeft3.addBox(0F, 0F, 0F, 1, 2, 1); + tubeLeft3.setRotationPoint(-6F, 9.5F, -4F); + tubeLeft3.setTextureSize(128, 64); + tubeLeft3.mirror = true; + setRotation(tubeLeft3, 0F, 0F, -0.8203047F); + } - public void render(float size) - { - tankBack.render(size); - base.render(size); - portTop.render(size); - pipe1.render(size); - pipe2b.render(size); - portRight.render(size); - bridge1.render(size); - bridge2.render(size); - bridge3.render(size); - conduit.render(size); - bridge4.render(size); - pipe2.render(size); - tankLeft.render(size); - connectorRight.render(size); - portLeft.render(size); - connectorLeft.render(size); - tankRight.render(size); - tubeLeft1.render(size); - tubeLeft2.render(size); - tubeRight3.render(size); - tubeRight1.render(size); - tubeRight2.render(size); - tubeLeft3.render(size); - } + public void render(float size) { + tankBack.render(size); + base.render(size); + portTop.render(size); + pipe1.render(size); + pipe2b.render(size); + portRight.render(size); + bridge1.render(size); + bridge2.render(size); + bridge3.render(size); + conduit.render(size); + bridge4.render(size); + pipe2.render(size); + tankLeft.render(size); + connectorRight.render(size); + portLeft.render(size); + connectorLeft.render(size); + tankRight.render(size); + tubeLeft1.render(size); + tubeLeft2.render(size); + tubeRight3.render(size); + tubeRight1.render(size); + tubeRight2.render(size); + tubeLeft3.render(size); + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/mekanism/client/model/ModelDigitalMiner.java b/src/main/java/mekanism/client/model/ModelDigitalMiner.java index 00e36202c..55e795784 100644 --- a/src/main/java/mekanism/client/model/ModelDigitalMiner.java +++ b/src/main/java/mekanism/client/model/ModelDigitalMiner.java @@ -1,5 +1,7 @@ package mekanism.client.model; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.render.MekanismRenderer; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; @@ -7,504 +9,497 @@ import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class ModelDigitalMiner extends ModelBase -{ - public static ResourceLocation OVERLAY_ON = MekanismUtils.getResource(ResourceType.RENDER, "DigitalMiner_OverlayOn.png"); - public static ResourceLocation OVERLAY_OFF = MekanismUtils.getResource(ResourceType.RENDER, "DigitalMiner_OverlayOff.png"); - - ModelRenderer keyboard; - ModelRenderer keyboardBottom; - ModelRenderer keyboardSupportExt1; - ModelRenderer keyboardSupportExt2; - ModelRenderer keyboardSupport1; - ModelRenderer keyboardSupport2; - ModelRenderer monitor1back; - ModelRenderer monitor2back; - ModelRenderer monitor3back; - ModelRenderer monitorBar1; - ModelRenderer monitorBar2; - ModelRenderer led1; - ModelRenderer led2; - ModelRenderer led3; - ModelRenderer monitorMount1; - ModelRenderer monitorMount2; - ModelRenderer frame1; - ModelRenderer frame3; - ModelRenderer plate5; - ModelRenderer bracket1; - ModelRenderer bracket2; - ModelRenderer bracket3; - ModelRenderer bracket4; - ModelRenderer bracket5; - ModelRenderer bracket6; - ModelRenderer bracket7; - ModelRenderer bracket8; - ModelRenderer bracketPlate1; - ModelRenderer bracketPlate2; - ModelRenderer bracketPlate3; - ModelRenderer bracketPlate4; - ModelRenderer supportBeam1; - ModelRenderer supportBeam2; - ModelRenderer supportBeam3; - ModelRenderer supportBeam4; - ModelRenderer foot1; - ModelRenderer foot2; - ModelRenderer foot3; - ModelRenderer foot4; - ModelRenderer core; - ModelRenderer powerCable1a; - ModelRenderer powerCable1b; - ModelRenderer powerCable2; - ModelRenderer powerCable3; - ModelRenderer powerConnector1; - ModelRenderer powerConnector2a; - ModelRenderer powerConnector2b; - ModelRenderer powerCpnnector3a; - ModelRenderer powerConnector3b; - ModelRenderer frame2a; - ModelRenderer frame2b; - ModelRenderer frame2c; - ModelRenderer frame2d; - ModelRenderer monitor1; - ModelRenderer monitor2; - ModelRenderer monitor3; +public class ModelDigitalMiner extends ModelBase { + public static ResourceLocation OVERLAY_ON + = MekanismUtils.getResource(ResourceType.RENDER, "DigitalMiner_OverlayOn.png"); + public static ResourceLocation OVERLAY_OFF + = MekanismUtils.getResource(ResourceType.RENDER, "DigitalMiner_OverlayOff.png"); - public ModelDigitalMiner() - { - textureWidth = 256; - textureHeight = 128; + ModelRenderer keyboard; + ModelRenderer keyboardBottom; + ModelRenderer keyboardSupportExt1; + ModelRenderer keyboardSupportExt2; + ModelRenderer keyboardSupport1; + ModelRenderer keyboardSupport2; + ModelRenderer monitor1back; + ModelRenderer monitor2back; + ModelRenderer monitor3back; + ModelRenderer monitorBar1; + ModelRenderer monitorBar2; + ModelRenderer led1; + ModelRenderer led2; + ModelRenderer led3; + ModelRenderer monitorMount1; + ModelRenderer monitorMount2; + ModelRenderer frame1; + ModelRenderer frame3; + ModelRenderer plate5; + ModelRenderer bracket1; + ModelRenderer bracket2; + ModelRenderer bracket3; + ModelRenderer bracket4; + ModelRenderer bracket5; + ModelRenderer bracket6; + ModelRenderer bracket7; + ModelRenderer bracket8; + ModelRenderer bracketPlate1; + ModelRenderer bracketPlate2; + ModelRenderer bracketPlate3; + ModelRenderer bracketPlate4; + ModelRenderer supportBeam1; + ModelRenderer supportBeam2; + ModelRenderer supportBeam3; + ModelRenderer supportBeam4; + ModelRenderer foot1; + ModelRenderer foot2; + ModelRenderer foot3; + ModelRenderer foot4; + ModelRenderer core; + ModelRenderer powerCable1a; + ModelRenderer powerCable1b; + ModelRenderer powerCable2; + ModelRenderer powerCable3; + ModelRenderer powerConnector1; + ModelRenderer powerConnector2a; + ModelRenderer powerConnector2b; + ModelRenderer powerCpnnector3a; + ModelRenderer powerConnector3b; + ModelRenderer frame2a; + ModelRenderer frame2b; + ModelRenderer frame2c; + ModelRenderer frame2d; + ModelRenderer monitor1; + ModelRenderer monitor2; + ModelRenderer monitor3; - keyboard = new ModelRenderer(this, 120, 20); - keyboard.addBox(0F, -3F, -1F, 10, 5, 1); - keyboard.setRotationPoint(-5F, 14F, -5F); - keyboard.setTextureSize(256, 128); - keyboard.mirror = true; - setRotation(keyboard, -1.082104F, 0.0174533F, 0F); - keyboardBottom = new ModelRenderer(this, 120, 26); - keyboardBottom.addBox(0F, -2.5F, -0.5F, 8, 4, 1); - keyboardBottom.setRotationPoint(-4F, 14F, -5F); - keyboardBottom.setTextureSize(256, 128); - keyboardBottom.mirror = true; - setRotation(keyboardBottom, -0.9075712F, 0F, 0F); - keyboardSupportExt1 = new ModelRenderer(this, 138, 26); - keyboardSupportExt1.addBox(0F, 0F, -1F, 1, 1, 1); - keyboardSupportExt1.setRotationPoint(2F, 14F, -5F); - keyboardSupportExt1.setTextureSize(256, 128); - keyboardSupportExt1.mirror = true; - setRotation(keyboardSupportExt1, 0F, 0F, 0F); - keyboardSupportExt2 = new ModelRenderer(this, 138, 26); - keyboardSupportExt2.addBox(0F, 0F, -1F, 1, 1, 1); - keyboardSupportExt2.setRotationPoint(-3F, 14F, -5F); - keyboardSupportExt2.setTextureSize(256, 128); - keyboardSupportExt2.mirror = true; - setRotation(keyboardSupportExt2, 0F, 0F, 0F); - keyboardSupport1 = new ModelRenderer(this, 142, 20); - keyboardSupport1.addBox(0F, -1F, 0F, 1, 2, 4); - keyboardSupport1.setRotationPoint(-3F, 14F, -5F); - keyboardSupport1.setTextureSize(256, 128); - keyboardSupport1.mirror = true; - setRotation(keyboardSupport1, 0F, 0F, 0F); - keyboardSupport2 = new ModelRenderer(this, 142, 20); - keyboardSupport2.addBox(0F, -1F, 0F, 1, 2, 4); - keyboardSupport2.setRotationPoint(2F, 14F, -5F); - keyboardSupport2.setTextureSize(256, 128); - keyboardSupport2.mirror = true; - setRotation(keyboardSupport2, 0F, 0F, 0F); - monitor1back = new ModelRenderer(this, 88, 32); - monitor1back.addBox(-13F, -3F, 0F, 12, 6, 1); - monitor1back.setRotationPoint(-8F, 3F, -3F); - monitor1back.setTextureSize(256, 128); - monitor1back.mirror = true; - setRotation(monitor1back, 0.0872665F, -0.2094395F, 0F); - monitor2back = new ModelRenderer(this, 88, 32); - monitor2back.addBox(0F, -4F, 0F, 12, 6, 1); - monitor2back.setRotationPoint(-6F, 4F, -3F); - monitor2back.setTextureSize(256, 128); - monitor2back.mirror = true; - setRotation(monitor2back, 0.0872665F, 0F, 0F); - monitor3back = new ModelRenderer(this, 88, 32); - monitor3back.addBox(1F, -3F, 0F, 12, 6, 1); - monitor3back.setRotationPoint(8F, 3F, -3F); - monitor3back.setTextureSize(256, 128); - monitor3back.mirror = true; - setRotation(monitor3back, 0.0872665F, 0.2094395F, 0F); - monitorBar1 = new ModelRenderer(this, 114, 36); - monitorBar1.addBox(-3.5F, -2F, -0.2F, 4, 2, 1); - monitorBar1.setRotationPoint(-6F, 4F, -3F); - monitorBar1.setTextureSize(256, 128); - monitorBar1.mirror = true; - setRotation(monitorBar1, 0.0872665F, -0.0523599F, 0F); - monitorBar2 = new ModelRenderer(this, 114, 36); - monitorBar2.addBox(0.5F, -2F, -0.2F, 4, 2, 1); - monitorBar2.setRotationPoint(5F, 4F, -3F); - monitorBar2.setTextureSize(256, 128); - monitorBar2.mirror = true; - setRotation(monitorBar2, 0.0872665F, 0.0523599F, 0F); - led1 = new ModelRenderer(this, 0, 0); - led1.addBox(-2F, 4.5F, -1.9F, 1, 1, 1); - led1.setRotationPoint(-8F, 3F, -3F); - led1.setTextureSize(256, 128); - led1.mirror = true; - setRotation(led1, 0.0872665F, -0.2094395F, 0F); - led2 = new ModelRenderer(this, 0, 0); - led2.addBox(12F, 4.466667F, -1.9F, 1, 1, 1); - led2.setRotationPoint(-7F, 3F, -3F); - led2.setTextureSize(256, 128); - led2.mirror = true; - setRotation(led2, 0.0872665F, 0F, 0F); - led3 = new ModelRenderer(this, 0, 0); - led3.addBox(12F, 4.5F, -1.9F, 1, 1, 1); - led3.setRotationPoint(8F, 3F, -3F); - led3.setTextureSize(256, 128); - led3.mirror = true; - setRotation(led3, 0.0872665F, 0.2094395F, 0F); - monitorMount1 = new ModelRenderer(this, 114, 32); - monitorMount1.addBox(0F, -1F, 0F, 2, 2, 2); - monitorMount1.setRotationPoint(-4F, 3F, -3F); - monitorMount1.setTextureSize(256, 128); - monitorMount1.mirror = true; - setRotation(monitorMount1, 0F, 0F, 0F); - monitorMount2 = new ModelRenderer(this, 114, 32); - monitorMount2.addBox(0F, -1F, 0F, 2, 2, 2); - monitorMount2.setRotationPoint(2F, 3F, -3F); - monitorMount2.setTextureSize(256, 128); - monitorMount2.mirror = true; - setRotation(monitorMount2, 0F, 0F, 0F); - frame1 = new ModelRenderer(this, 0, 0); - frame1.addBox(0F, 0F, 0F, 32, 29, 12); - frame1.setRotationPoint(-16F, -8F, -1F); - frame1.setTextureSize(256, 128); - frame1.mirror = true; - setRotation(frame1, 0F, 0F, 0F); - frame3 = new ModelRenderer(this, 0, 0); - frame3.addBox(0F, 0F, 0F, 32, 29, 12); - frame3.setRotationPoint(-16F, -8F, 28F); - frame3.setTextureSize(256, 128); - frame3.mirror = true; - setRotation(frame3, 0F, 0F, 0F); - plate5 = new ModelRenderer(this, 88, 90); - plate5.addBox(0F, 0F, 0F, 32, 5, 15); - plate5.setRotationPoint(-16F, 16F, 12F); - plate5.setTextureSize(256, 128); - plate5.mirror = true; - setRotation(plate5, 0F, 0F, 0F); - bracket1 = new ModelRenderer(this, 16, 85); - bracket1.addBox(0F, 0F, 0F, 5, 5, 2); - bracket1.setRotationPoint(-21F, -5F, 0F); - bracket1.setTextureSize(256, 128); - bracket1.mirror = true; - setRotation(bracket1, 0F, 0F, 0F); - bracket2 = new ModelRenderer(this, 16, 85); - bracket2.addBox(0F, 0F, 0F, 5, 5, 2); - bracket2.setRotationPoint(-21F, -5F, 8F); - bracket2.setTextureSize(256, 128); - bracket2.mirror = true; - setRotation(bracket2, 0F, 0F, 0F); - bracket3 = new ModelRenderer(this, 16, 85); - bracket3.addBox(0F, 0F, 0F, 5, 5, 2); - bracket3.setRotationPoint(-21F, -5F, 29F); - bracket3.setTextureSize(256, 128); - bracket3.mirror = true; - setRotation(bracket3, 0F, 0F, 0F); - bracket4 = new ModelRenderer(this, 16, 85); - bracket4.addBox(0F, 0F, 0F, 5, 5, 2); - bracket4.setRotationPoint(-21F, -5F, 37F); - bracket4.setTextureSize(256, 128); - bracket4.mirror = true; - setRotation(bracket4, 0F, 0F, 0F); - bracket5 = new ModelRenderer(this, 16, 85); - bracket5.addBox(0F, 0F, 0F, 5, 5, 2); - bracket5.setRotationPoint(16F, -5F, 0F); - bracket5.setTextureSize(256, 128); - bracket5.mirror = true; - setRotation(bracket5, 0F, 0F, 0F); - bracket5.mirror = false; - bracket6 = new ModelRenderer(this, 16, 85); - bracket6.addBox(0F, 0F, 0F, 5, 5, 2); - bracket6.setRotationPoint(16F, -5F, 8F); - bracket6.setTextureSize(256, 128); - bracket6.mirror = true; - setRotation(bracket6, 0F, 0F, 0F); - bracket7 = new ModelRenderer(this, 16, 85); - bracket7.addBox(0F, 0F, 0F, 5, 5, 2); - bracket7.setRotationPoint(16F, -5F, 29F); - bracket7.setTextureSize(256, 128); - bracket7.mirror = true; - setRotation(bracket7, 0F, 0F, 0F); - bracket8 = new ModelRenderer(this, 16, 85); - bracket8.addBox(0F, 0F, 0F, 5, 5, 2); - bracket8.setRotationPoint(16F, -5F, 37F); - bracket8.setTextureSize(256, 128); - bracket8.mirror = true; - setRotation(bracket8, 0F, 0F, 0F); - bracket8.mirror = false; - bracketPlate1 = new ModelRenderer(this, 30, 85); - bracketPlate1.addBox(0F, 0F, 0F, 1, 5, 6); - bracketPlate1.setRotationPoint(-17F, -5F, 2F); - bracketPlate1.setTextureSize(256, 128); - bracketPlate1.mirror = true; - setRotation(bracketPlate1, 0F, 0F, 0F); - bracketPlate2 = new ModelRenderer(this, 30, 85); - bracketPlate2.addBox(0F, 0F, 0F, 1, 5, 6); - bracketPlate2.setRotationPoint(-17F, -5F, 31F); - bracketPlate2.setTextureSize(256, 128); - bracketPlate2.mirror = true; - setRotation(bracketPlate2, 0F, 0F, 0F); - bracketPlate3 = new ModelRenderer(this, 30, 85); - bracketPlate3.addBox(0F, 0F, 0F, 1, 5, 6); - bracketPlate3.setRotationPoint(16F, -5F, 2F); - bracketPlate3.setTextureSize(256, 128); - bracketPlate3.mirror = true; - setRotation(bracketPlate3, 0F, 0F, 0F); - bracketPlate4 = new ModelRenderer(this, 30, 85); - bracketPlate4.addBox(0F, 0F, 0F, 1, 5, 6); - bracketPlate4.setRotationPoint(16F, -5F, 31F); - bracketPlate4.setTextureSize(256, 128); - bracketPlate4.mirror = true; - setRotation(bracketPlate4, 0F, 0F, 0F); - supportBeam1 = new ModelRenderer(this, 0, 85); - supportBeam1.addBox(0F, 0F, 0F, 4, 28, 8); - supportBeam1.setRotationPoint(-22F, -6F, 1F); - supportBeam1.setTextureSize(256, 128); - supportBeam1.mirror = true; - setRotation(supportBeam1, 0F, 0F, 0F); - supportBeam2 = new ModelRenderer(this, 0, 85); - supportBeam2.addBox(0F, 0F, 0F, 4, 28, 8); - supportBeam2.setRotationPoint(-22F, -6F, 30F); - supportBeam2.setTextureSize(256, 128); - supportBeam2.mirror = true; - setRotation(supportBeam2, 0F, 0F, 0F); - supportBeam3 = new ModelRenderer(this, 0, 85); - supportBeam3.addBox(0F, 0F, 0F, 4, 28, 8); - supportBeam3.setRotationPoint(18F, -6F, 1F); - supportBeam3.setTextureSize(256, 128); - supportBeam3.mirror = true; - setRotation(supportBeam3, 0F, 0F, 0F); - supportBeam4 = new ModelRenderer(this, 0, 85); - supportBeam4.addBox(0F, 0F, 0F, 4, 28, 8); - supportBeam4.setRotationPoint(18F, -6F, 30F); - supportBeam4.setTextureSize(256, 128); - supportBeam4.mirror = true; - setRotation(supportBeam4, 0F, 0F, 0F); - supportBeam4.mirror = false; - foot1 = new ModelRenderer(this, 44, 85); - foot1.addBox(0F, 0F, 0F, 7, 2, 10); - foot1.setRotationPoint(-23F, 22F, 0F); - foot1.setTextureSize(256, 128); - foot1.mirror = true; - setRotation(foot1, 0F, 0F, 0F); - foot2 = new ModelRenderer(this, 44, 85); - foot2.addBox(0F, 0F, 0F, 7, 2, 10); - foot2.setRotationPoint(-23F, 22F, 29F); - foot2.setTextureSize(256, 128); - foot2.mirror = true; - setRotation(foot2, 0F, 0F, 0F); - foot3 = new ModelRenderer(this, 44, 85); - foot3.addBox(0F, 0F, 0F, 7, 2, 10); - foot3.setRotationPoint(16F, 22F, 29F); - foot3.setTextureSize(256, 128); - foot3.mirror = true; - setRotation(foot3, 0F, 0F, 0F); - foot4 = new ModelRenderer(this, 44, 85); - foot4.addBox(0F, 0F, 0F, 7, 2, 10); - foot4.setRotationPoint(16F, 22F, 0F); - foot4.setTextureSize(256, 128); - foot4.mirror = true; - setRotation(foot4, 0F, 0F, 0F); - core = new ModelRenderer(this, 0, 41); - core.addBox(0F, 0F, 0F, 30, 27, 17); - core.setRotationPoint(-15F, -7F, 11F); - core.setTextureSize(256, 128); - core.mirror = true; - setRotation(core, 0F, 0F, 0F); - powerCable1a = new ModelRenderer(this, 88, 39); - powerCable1a.addBox(0F, 0F, 0F, 6, 2, 11); - powerCable1a.setRotationPoint(-3F, 20F, 2F); - powerCable1a.setTextureSize(256, 128); - powerCable1a.mirror = true; - setRotation(powerCable1a, 0F, 0F, 0F); - powerCable1b = new ModelRenderer(this, 94, 52); - powerCable1b.addBox(0F, 0F, 0F, 6, 3, 6); - powerCable1b.setRotationPoint(-3F, 20F, 13F); - powerCable1b.setTextureSize(256, 128); - powerCable1b.mirror = true; - setRotation(powerCable1b, 0F, 0F, 0F); - powerCable2 = new ModelRenderer(this, 42, 109); - powerCable2.addBox(0F, 0F, 0F, 9, 6, 6); - powerCable2.setRotationPoint(14F, 13F, 13F); - powerCable2.setTextureSize(256, 128); - powerCable2.mirror = true; - setRotation(powerCable2, 0F, 0F, 0F); - powerCable3 = new ModelRenderer(this, 42, 109); - powerCable3.addBox(0F, 0F, 0F, 9, 6, 6); - powerCable3.setRotationPoint(-23F, 13F, 13F); - powerCable3.setTextureSize(256, 128); - powerCable3.mirror = true; - setRotation(powerCable3, 0F, 0F, 0F); - powerConnector1 = new ModelRenderer(this, 94, 61); - powerConnector1.addBox(0F, 0F, 0F, 8, 1, 8); - powerConnector1.setRotationPoint(-4F, 23F, 12F); - powerConnector1.setTextureSize(256, 128); - powerConnector1.mirror = true; - setRotation(powerConnector1, 0F, 0F, 0F); - powerConnector2a = new ModelRenderer(this, 24, 105); - powerConnector2a.addBox(0F, 0F, 0F, 1, 8, 8); - powerConnector2a.setRotationPoint(23F, 12F, 12F); - powerConnector2a.setTextureSize(256, 128); - powerConnector2a.mirror = true; - setRotation(powerConnector2a, 0F, 0F, 0F); - powerConnector2b = new ModelRenderer(this, 24, 105); - powerConnector2b.addBox(0F, 0F, 0F, 1, 8, 8); - powerConnector2b.setRotationPoint(16F, 12F, 12F); - powerConnector2b.setTextureSize(256, 128); - powerConnector2b.mirror = true; - setRotation(powerConnector2b, 0F, 0F, 0F); - powerCpnnector3a = new ModelRenderer(this, 24, 105); - powerCpnnector3a.addBox(0F, 0F, 0F, 1, 8, 8); - powerCpnnector3a.setRotationPoint(-24F, 12F, 12F); - powerCpnnector3a.setTextureSize(256, 128); - powerCpnnector3a.mirror = true; - setRotation(powerCpnnector3a, 0F, 0F, 0F); - powerConnector3b = new ModelRenderer(this, 24, 105); - powerConnector3b.addBox(0F, 0F, 0F, 1, 8, 8); - powerConnector3b.setRotationPoint(-17F, 12F, 12F); - powerConnector3b.setTextureSize(256, 128); - powerConnector3b.mirror = true; - setRotation(powerConnector3b, 0F, 0F, 0F); - frame2a = new ModelRenderer(this, 88, 0); - frame2a.addBox(0F, 0F, 0F, 32, 5, 15); - frame2a.setRotationPoint(-16F, -8F, 12F); - frame2a.setTextureSize(256, 128); - frame2a.mirror = true; - setRotation(frame2a, 0F, 0F, 0F); - frame2b = new ModelRenderer(this, 126, 50); - frame2b.addBox(0F, 0F, 0F, 32, 5, 15); - frame2b.setRotationPoint(-16F, -2F, 12F); - frame2b.setTextureSize(256, 128); - frame2b.mirror = true; - setRotation(frame2b, 0F, 0F, 0F); - frame2c = new ModelRenderer(this, 126, 50); - frame2c.addBox(0F, 0F, 0F, 32, 5, 15); - frame2c.setRotationPoint(-16F, 4F, 12F); - frame2c.setTextureSize(256, 128); - frame2c.mirror = true; - setRotation(frame2c, 0F, 0F, 0F); - frame2d = new ModelRenderer(this, 88, 70); - frame2d.addBox(0F, 0F, 0F, 32, 5, 15); - frame2d.setRotationPoint(-16F, 10F, 12F); - frame2d.setTextureSize(256, 128); - frame2d.mirror = true; - setRotation(frame2d, 0F, 0F, 0F); - monitor1 = new ModelRenderer(this, 88, 20); - monitor1.addBox(-14F, -5F, -2F, 14, 10, 2); - monitor1.setRotationPoint(-8F, 3F, -3F); - monitor1.setTextureSize(256, 128); - monitor1.mirror = true; - setRotation(monitor1, 0.0872665F, -0.2094395F, 0F); - monitor2 = new ModelRenderer(this, 88, 20); - monitor2.addBox(0F, -5F, -2F, 14, 10, 2); - monitor2.setRotationPoint(-7F, 3F, -3F); - monitor2.setTextureSize(256, 128); - monitor2.mirror = true; - setRotation(monitor2, 0.0872665F, 0F, 0F); - monitor3 = new ModelRenderer(this, 88, 20); - monitor3.addBox(0F, -5F, -2F, 14, 10, 2); - monitor3.setRotationPoint(8F, 3F, -3F); - monitor3.setTextureSize(256, 128); - monitor3.mirror = true; - setRotation(monitor3, 0.0872665F, 0.2094395F, 0F); - } - - public void render(float size, boolean on, TextureManager manager) - { - GL11.glPushMatrix(); - MekanismRenderer.blendOn(); - - doRender(size); - - manager.bindTexture(on ? OVERLAY_ON : OVERLAY_OFF); - GL11.glScalef(1.001F, 1.001F, 1.001F); - GL11.glTranslatef(0, -0.0011F, 0); - MekanismRenderer.glowOn(); - - doRender(size); - - MekanismRenderer.glowOff(); - MekanismRenderer.blendOff(); - GL11.glPopMatrix(); - } + public ModelDigitalMiner() { + textureWidth = 256; + textureHeight = 128; - private void doRender(float size) - { - keyboard.render(size); - keyboardBottom.render(size); - keyboardSupportExt1.render(size); - keyboardSupportExt2.render(size); - keyboardSupport1.render(size); - keyboardSupport2.render(size); - monitor1back.render(size); - monitor2back.render(size); - monitor3back.render(size); - monitorBar1.render(size); - monitorBar2.render(size); - led1.render(size); - led2.render(size); - led3.render(size); - monitor1.render(size); - monitor2.render(size); - monitor3.render(size); - monitorMount1.render(size); - monitorMount2.render(size); - frame1.render(size); - frame3.render(size); - plate5.render(size); - bracket1.render(size); - bracket2.render(size); - bracket3.render(size); - bracket4.render(size); - bracket5.render(size); - bracket6.render(size); - bracket7.render(size); - bracket8.render(size); - bracketPlate1.render(size); - bracketPlate2.render(size); - bracketPlate3.render(size); - bracketPlate4.render(size); - supportBeam1.render(size); - supportBeam2.render(size); - supportBeam3.render(size); - supportBeam4.render(size); - foot1.render(size); - foot2.render(size); - foot3.render(size); - foot4.render(size); - core.render(size); - powerCable1a.render(size); - powerCable1b.render(size); - powerCable2.render(size); - powerCable3.render(size); - powerConnector1.render(size); - powerConnector2a.render(size); - powerConnector2b.render(size); - powerCpnnector3a.render(size); - powerConnector3b.render(size); - frame2a.render(size); - frame2b.render(size); - frame2c.render(size); - frame2d.render(size); - } + keyboard = new ModelRenderer(this, 120, 20); + keyboard.addBox(0F, -3F, -1F, 10, 5, 1); + keyboard.setRotationPoint(-5F, 14F, -5F); + keyboard.setTextureSize(256, 128); + keyboard.mirror = true; + setRotation(keyboard, -1.082104F, 0.0174533F, 0F); + keyboardBottom = new ModelRenderer(this, 120, 26); + keyboardBottom.addBox(0F, -2.5F, -0.5F, 8, 4, 1); + keyboardBottom.setRotationPoint(-4F, 14F, -5F); + keyboardBottom.setTextureSize(256, 128); + keyboardBottom.mirror = true; + setRotation(keyboardBottom, -0.9075712F, 0F, 0F); + keyboardSupportExt1 = new ModelRenderer(this, 138, 26); + keyboardSupportExt1.addBox(0F, 0F, -1F, 1, 1, 1); + keyboardSupportExt1.setRotationPoint(2F, 14F, -5F); + keyboardSupportExt1.setTextureSize(256, 128); + keyboardSupportExt1.mirror = true; + setRotation(keyboardSupportExt1, 0F, 0F, 0F); + keyboardSupportExt2 = new ModelRenderer(this, 138, 26); + keyboardSupportExt2.addBox(0F, 0F, -1F, 1, 1, 1); + keyboardSupportExt2.setRotationPoint(-3F, 14F, -5F); + keyboardSupportExt2.setTextureSize(256, 128); + keyboardSupportExt2.mirror = true; + setRotation(keyboardSupportExt2, 0F, 0F, 0F); + keyboardSupport1 = new ModelRenderer(this, 142, 20); + keyboardSupport1.addBox(0F, -1F, 0F, 1, 2, 4); + keyboardSupport1.setRotationPoint(-3F, 14F, -5F); + keyboardSupport1.setTextureSize(256, 128); + keyboardSupport1.mirror = true; + setRotation(keyboardSupport1, 0F, 0F, 0F); + keyboardSupport2 = new ModelRenderer(this, 142, 20); + keyboardSupport2.addBox(0F, -1F, 0F, 1, 2, 4); + keyboardSupport2.setRotationPoint(2F, 14F, -5F); + keyboardSupport2.setTextureSize(256, 128); + keyboardSupport2.mirror = true; + setRotation(keyboardSupport2, 0F, 0F, 0F); + monitor1back = new ModelRenderer(this, 88, 32); + monitor1back.addBox(-13F, -3F, 0F, 12, 6, 1); + monitor1back.setRotationPoint(-8F, 3F, -3F); + monitor1back.setTextureSize(256, 128); + monitor1back.mirror = true; + setRotation(monitor1back, 0.0872665F, -0.2094395F, 0F); + monitor2back = new ModelRenderer(this, 88, 32); + monitor2back.addBox(0F, -4F, 0F, 12, 6, 1); + monitor2back.setRotationPoint(-6F, 4F, -3F); + monitor2back.setTextureSize(256, 128); + monitor2back.mirror = true; + setRotation(monitor2back, 0.0872665F, 0F, 0F); + monitor3back = new ModelRenderer(this, 88, 32); + monitor3back.addBox(1F, -3F, 0F, 12, 6, 1); + monitor3back.setRotationPoint(8F, 3F, -3F); + monitor3back.setTextureSize(256, 128); + monitor3back.mirror = true; + setRotation(monitor3back, 0.0872665F, 0.2094395F, 0F); + monitorBar1 = new ModelRenderer(this, 114, 36); + monitorBar1.addBox(-3.5F, -2F, -0.2F, 4, 2, 1); + monitorBar1.setRotationPoint(-6F, 4F, -3F); + monitorBar1.setTextureSize(256, 128); + monitorBar1.mirror = true; + setRotation(monitorBar1, 0.0872665F, -0.0523599F, 0F); + monitorBar2 = new ModelRenderer(this, 114, 36); + monitorBar2.addBox(0.5F, -2F, -0.2F, 4, 2, 1); + monitorBar2.setRotationPoint(5F, 4F, -3F); + monitorBar2.setTextureSize(256, 128); + monitorBar2.mirror = true; + setRotation(monitorBar2, 0.0872665F, 0.0523599F, 0F); + led1 = new ModelRenderer(this, 0, 0); + led1.addBox(-2F, 4.5F, -1.9F, 1, 1, 1); + led1.setRotationPoint(-8F, 3F, -3F); + led1.setTextureSize(256, 128); + led1.mirror = true; + setRotation(led1, 0.0872665F, -0.2094395F, 0F); + led2 = new ModelRenderer(this, 0, 0); + led2.addBox(12F, 4.466667F, -1.9F, 1, 1, 1); + led2.setRotationPoint(-7F, 3F, -3F); + led2.setTextureSize(256, 128); + led2.mirror = true; + setRotation(led2, 0.0872665F, 0F, 0F); + led3 = new ModelRenderer(this, 0, 0); + led3.addBox(12F, 4.5F, -1.9F, 1, 1, 1); + led3.setRotationPoint(8F, 3F, -3F); + led3.setTextureSize(256, 128); + led3.mirror = true; + setRotation(led3, 0.0872665F, 0.2094395F, 0F); + monitorMount1 = new ModelRenderer(this, 114, 32); + monitorMount1.addBox(0F, -1F, 0F, 2, 2, 2); + monitorMount1.setRotationPoint(-4F, 3F, -3F); + monitorMount1.setTextureSize(256, 128); + monitorMount1.mirror = true; + setRotation(monitorMount1, 0F, 0F, 0F); + monitorMount2 = new ModelRenderer(this, 114, 32); + monitorMount2.addBox(0F, -1F, 0F, 2, 2, 2); + monitorMount2.setRotationPoint(2F, 3F, -3F); + monitorMount2.setTextureSize(256, 128); + monitorMount2.mirror = true; + setRotation(monitorMount2, 0F, 0F, 0F); + frame1 = new ModelRenderer(this, 0, 0); + frame1.addBox(0F, 0F, 0F, 32, 29, 12); + frame1.setRotationPoint(-16F, -8F, -1F); + frame1.setTextureSize(256, 128); + frame1.mirror = true; + setRotation(frame1, 0F, 0F, 0F); + frame3 = new ModelRenderer(this, 0, 0); + frame3.addBox(0F, 0F, 0F, 32, 29, 12); + frame3.setRotationPoint(-16F, -8F, 28F); + frame3.setTextureSize(256, 128); + frame3.mirror = true; + setRotation(frame3, 0F, 0F, 0F); + plate5 = new ModelRenderer(this, 88, 90); + plate5.addBox(0F, 0F, 0F, 32, 5, 15); + plate5.setRotationPoint(-16F, 16F, 12F); + plate5.setTextureSize(256, 128); + plate5.mirror = true; + setRotation(plate5, 0F, 0F, 0F); + bracket1 = new ModelRenderer(this, 16, 85); + bracket1.addBox(0F, 0F, 0F, 5, 5, 2); + bracket1.setRotationPoint(-21F, -5F, 0F); + bracket1.setTextureSize(256, 128); + bracket1.mirror = true; + setRotation(bracket1, 0F, 0F, 0F); + bracket2 = new ModelRenderer(this, 16, 85); + bracket2.addBox(0F, 0F, 0F, 5, 5, 2); + bracket2.setRotationPoint(-21F, -5F, 8F); + bracket2.setTextureSize(256, 128); + bracket2.mirror = true; + setRotation(bracket2, 0F, 0F, 0F); + bracket3 = new ModelRenderer(this, 16, 85); + bracket3.addBox(0F, 0F, 0F, 5, 5, 2); + bracket3.setRotationPoint(-21F, -5F, 29F); + bracket3.setTextureSize(256, 128); + bracket3.mirror = true; + setRotation(bracket3, 0F, 0F, 0F); + bracket4 = new ModelRenderer(this, 16, 85); + bracket4.addBox(0F, 0F, 0F, 5, 5, 2); + bracket4.setRotationPoint(-21F, -5F, 37F); + bracket4.setTextureSize(256, 128); + bracket4.mirror = true; + setRotation(bracket4, 0F, 0F, 0F); + bracket5 = new ModelRenderer(this, 16, 85); + bracket5.addBox(0F, 0F, 0F, 5, 5, 2); + bracket5.setRotationPoint(16F, -5F, 0F); + bracket5.setTextureSize(256, 128); + bracket5.mirror = true; + setRotation(bracket5, 0F, 0F, 0F); + bracket5.mirror = false; + bracket6 = new ModelRenderer(this, 16, 85); + bracket6.addBox(0F, 0F, 0F, 5, 5, 2); + bracket6.setRotationPoint(16F, -5F, 8F); + bracket6.setTextureSize(256, 128); + bracket6.mirror = true; + setRotation(bracket6, 0F, 0F, 0F); + bracket7 = new ModelRenderer(this, 16, 85); + bracket7.addBox(0F, 0F, 0F, 5, 5, 2); + bracket7.setRotationPoint(16F, -5F, 29F); + bracket7.setTextureSize(256, 128); + bracket7.mirror = true; + setRotation(bracket7, 0F, 0F, 0F); + bracket8 = new ModelRenderer(this, 16, 85); + bracket8.addBox(0F, 0F, 0F, 5, 5, 2); + bracket8.setRotationPoint(16F, -5F, 37F); + bracket8.setTextureSize(256, 128); + bracket8.mirror = true; + setRotation(bracket8, 0F, 0F, 0F); + bracket8.mirror = false; + bracketPlate1 = new ModelRenderer(this, 30, 85); + bracketPlate1.addBox(0F, 0F, 0F, 1, 5, 6); + bracketPlate1.setRotationPoint(-17F, -5F, 2F); + bracketPlate1.setTextureSize(256, 128); + bracketPlate1.mirror = true; + setRotation(bracketPlate1, 0F, 0F, 0F); + bracketPlate2 = new ModelRenderer(this, 30, 85); + bracketPlate2.addBox(0F, 0F, 0F, 1, 5, 6); + bracketPlate2.setRotationPoint(-17F, -5F, 31F); + bracketPlate2.setTextureSize(256, 128); + bracketPlate2.mirror = true; + setRotation(bracketPlate2, 0F, 0F, 0F); + bracketPlate3 = new ModelRenderer(this, 30, 85); + bracketPlate3.addBox(0F, 0F, 0F, 1, 5, 6); + bracketPlate3.setRotationPoint(16F, -5F, 2F); + bracketPlate3.setTextureSize(256, 128); + bracketPlate3.mirror = true; + setRotation(bracketPlate3, 0F, 0F, 0F); + bracketPlate4 = new ModelRenderer(this, 30, 85); + bracketPlate4.addBox(0F, 0F, 0F, 1, 5, 6); + bracketPlate4.setRotationPoint(16F, -5F, 31F); + bracketPlate4.setTextureSize(256, 128); + bracketPlate4.mirror = true; + setRotation(bracketPlate4, 0F, 0F, 0F); + supportBeam1 = new ModelRenderer(this, 0, 85); + supportBeam1.addBox(0F, 0F, 0F, 4, 28, 8); + supportBeam1.setRotationPoint(-22F, -6F, 1F); + supportBeam1.setTextureSize(256, 128); + supportBeam1.mirror = true; + setRotation(supportBeam1, 0F, 0F, 0F); + supportBeam2 = new ModelRenderer(this, 0, 85); + supportBeam2.addBox(0F, 0F, 0F, 4, 28, 8); + supportBeam2.setRotationPoint(-22F, -6F, 30F); + supportBeam2.setTextureSize(256, 128); + supportBeam2.mirror = true; + setRotation(supportBeam2, 0F, 0F, 0F); + supportBeam3 = new ModelRenderer(this, 0, 85); + supportBeam3.addBox(0F, 0F, 0F, 4, 28, 8); + supportBeam3.setRotationPoint(18F, -6F, 1F); + supportBeam3.setTextureSize(256, 128); + supportBeam3.mirror = true; + setRotation(supportBeam3, 0F, 0F, 0F); + supportBeam4 = new ModelRenderer(this, 0, 85); + supportBeam4.addBox(0F, 0F, 0F, 4, 28, 8); + supportBeam4.setRotationPoint(18F, -6F, 30F); + supportBeam4.setTextureSize(256, 128); + supportBeam4.mirror = true; + setRotation(supportBeam4, 0F, 0F, 0F); + supportBeam4.mirror = false; + foot1 = new ModelRenderer(this, 44, 85); + foot1.addBox(0F, 0F, 0F, 7, 2, 10); + foot1.setRotationPoint(-23F, 22F, 0F); + foot1.setTextureSize(256, 128); + foot1.mirror = true; + setRotation(foot1, 0F, 0F, 0F); + foot2 = new ModelRenderer(this, 44, 85); + foot2.addBox(0F, 0F, 0F, 7, 2, 10); + foot2.setRotationPoint(-23F, 22F, 29F); + foot2.setTextureSize(256, 128); + foot2.mirror = true; + setRotation(foot2, 0F, 0F, 0F); + foot3 = new ModelRenderer(this, 44, 85); + foot3.addBox(0F, 0F, 0F, 7, 2, 10); + foot3.setRotationPoint(16F, 22F, 29F); + foot3.setTextureSize(256, 128); + foot3.mirror = true; + setRotation(foot3, 0F, 0F, 0F); + foot4 = new ModelRenderer(this, 44, 85); + foot4.addBox(0F, 0F, 0F, 7, 2, 10); + foot4.setRotationPoint(16F, 22F, 0F); + foot4.setTextureSize(256, 128); + foot4.mirror = true; + setRotation(foot4, 0F, 0F, 0F); + core = new ModelRenderer(this, 0, 41); + core.addBox(0F, 0F, 0F, 30, 27, 17); + core.setRotationPoint(-15F, -7F, 11F); + core.setTextureSize(256, 128); + core.mirror = true; + setRotation(core, 0F, 0F, 0F); + powerCable1a = new ModelRenderer(this, 88, 39); + powerCable1a.addBox(0F, 0F, 0F, 6, 2, 11); + powerCable1a.setRotationPoint(-3F, 20F, 2F); + powerCable1a.setTextureSize(256, 128); + powerCable1a.mirror = true; + setRotation(powerCable1a, 0F, 0F, 0F); + powerCable1b = new ModelRenderer(this, 94, 52); + powerCable1b.addBox(0F, 0F, 0F, 6, 3, 6); + powerCable1b.setRotationPoint(-3F, 20F, 13F); + powerCable1b.setTextureSize(256, 128); + powerCable1b.mirror = true; + setRotation(powerCable1b, 0F, 0F, 0F); + powerCable2 = new ModelRenderer(this, 42, 109); + powerCable2.addBox(0F, 0F, 0F, 9, 6, 6); + powerCable2.setRotationPoint(14F, 13F, 13F); + powerCable2.setTextureSize(256, 128); + powerCable2.mirror = true; + setRotation(powerCable2, 0F, 0F, 0F); + powerCable3 = new ModelRenderer(this, 42, 109); + powerCable3.addBox(0F, 0F, 0F, 9, 6, 6); + powerCable3.setRotationPoint(-23F, 13F, 13F); + powerCable3.setTextureSize(256, 128); + powerCable3.mirror = true; + setRotation(powerCable3, 0F, 0F, 0F); + powerConnector1 = new ModelRenderer(this, 94, 61); + powerConnector1.addBox(0F, 0F, 0F, 8, 1, 8); + powerConnector1.setRotationPoint(-4F, 23F, 12F); + powerConnector1.setTextureSize(256, 128); + powerConnector1.mirror = true; + setRotation(powerConnector1, 0F, 0F, 0F); + powerConnector2a = new ModelRenderer(this, 24, 105); + powerConnector2a.addBox(0F, 0F, 0F, 1, 8, 8); + powerConnector2a.setRotationPoint(23F, 12F, 12F); + powerConnector2a.setTextureSize(256, 128); + powerConnector2a.mirror = true; + setRotation(powerConnector2a, 0F, 0F, 0F); + powerConnector2b = new ModelRenderer(this, 24, 105); + powerConnector2b.addBox(0F, 0F, 0F, 1, 8, 8); + powerConnector2b.setRotationPoint(16F, 12F, 12F); + powerConnector2b.setTextureSize(256, 128); + powerConnector2b.mirror = true; + setRotation(powerConnector2b, 0F, 0F, 0F); + powerCpnnector3a = new ModelRenderer(this, 24, 105); + powerCpnnector3a.addBox(0F, 0F, 0F, 1, 8, 8); + powerCpnnector3a.setRotationPoint(-24F, 12F, 12F); + powerCpnnector3a.setTextureSize(256, 128); + powerCpnnector3a.mirror = true; + setRotation(powerCpnnector3a, 0F, 0F, 0F); + powerConnector3b = new ModelRenderer(this, 24, 105); + powerConnector3b.addBox(0F, 0F, 0F, 1, 8, 8); + powerConnector3b.setRotationPoint(-17F, 12F, 12F); + powerConnector3b.setTextureSize(256, 128); + powerConnector3b.mirror = true; + setRotation(powerConnector3b, 0F, 0F, 0F); + frame2a = new ModelRenderer(this, 88, 0); + frame2a.addBox(0F, 0F, 0F, 32, 5, 15); + frame2a.setRotationPoint(-16F, -8F, 12F); + frame2a.setTextureSize(256, 128); + frame2a.mirror = true; + setRotation(frame2a, 0F, 0F, 0F); + frame2b = new ModelRenderer(this, 126, 50); + frame2b.addBox(0F, 0F, 0F, 32, 5, 15); + frame2b.setRotationPoint(-16F, -2F, 12F); + frame2b.setTextureSize(256, 128); + frame2b.mirror = true; + setRotation(frame2b, 0F, 0F, 0F); + frame2c = new ModelRenderer(this, 126, 50); + frame2c.addBox(0F, 0F, 0F, 32, 5, 15); + frame2c.setRotationPoint(-16F, 4F, 12F); + frame2c.setTextureSize(256, 128); + frame2c.mirror = true; + setRotation(frame2c, 0F, 0F, 0F); + frame2d = new ModelRenderer(this, 88, 70); + frame2d.addBox(0F, 0F, 0F, 32, 5, 15); + frame2d.setRotationPoint(-16F, 10F, 12F); + frame2d.setTextureSize(256, 128); + frame2d.mirror = true; + setRotation(frame2d, 0F, 0F, 0F); + monitor1 = new ModelRenderer(this, 88, 20); + monitor1.addBox(-14F, -5F, -2F, 14, 10, 2); + monitor1.setRotationPoint(-8F, 3F, -3F); + monitor1.setTextureSize(256, 128); + monitor1.mirror = true; + setRotation(monitor1, 0.0872665F, -0.2094395F, 0F); + monitor2 = new ModelRenderer(this, 88, 20); + monitor2.addBox(0F, -5F, -2F, 14, 10, 2); + monitor2.setRotationPoint(-7F, 3F, -3F); + monitor2.setTextureSize(256, 128); + monitor2.mirror = true; + setRotation(monitor2, 0.0872665F, 0F, 0F); + monitor3 = new ModelRenderer(this, 88, 20); + monitor3.addBox(0F, -5F, -2F, 14, 10, 2); + monitor3.setRotationPoint(8F, 3F, -3F); + monitor3.setTextureSize(256, 128); + monitor3.mirror = true; + setRotation(monitor3, 0.0872665F, 0.2094395F, 0F); + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + public void render(float size, boolean on, TextureManager manager) { + GL11.glPushMatrix(); + MekanismRenderer.blendOn(); + + doRender(size); + + manager.bindTexture(on ? OVERLAY_ON : OVERLAY_OFF); + GL11.glScalef(1.001F, 1.001F, 1.001F); + GL11.glTranslatef(0, -0.0011F, 0); + MekanismRenderer.glowOn(); + + doRender(size); + + MekanismRenderer.glowOff(); + MekanismRenderer.blendOff(); + GL11.glPopMatrix(); + } + + private void doRender(float size) { + keyboard.render(size); + keyboardBottom.render(size); + keyboardSupportExt1.render(size); + keyboardSupportExt2.render(size); + keyboardSupport1.render(size); + keyboardSupport2.render(size); + monitor1back.render(size); + monitor2back.render(size); + monitor3back.render(size); + monitorBar1.render(size); + monitorBar2.render(size); + led1.render(size); + led2.render(size); + led3.render(size); + monitor1.render(size); + monitor2.render(size); + monitor3.render(size); + monitorMount1.render(size); + monitorMount2.render(size); + frame1.render(size); + frame3.render(size); + plate5.render(size); + bracket1.render(size); + bracket2.render(size); + bracket3.render(size); + bracket4.render(size); + bracket5.render(size); + bracket6.render(size); + bracket7.render(size); + bracket8.render(size); + bracketPlate1.render(size); + bracketPlate2.render(size); + bracketPlate3.render(size); + bracketPlate4.render(size); + supportBeam1.render(size); + supportBeam2.render(size); + supportBeam3.render(size); + supportBeam4.render(size); + foot1.render(size); + foot2.render(size); + foot3.render(size); + foot4.render(size); + core.render(size); + powerCable1a.render(size); + powerCable1b.render(size); + powerCable2.render(size); + powerCable3.render(size); + powerConnector1.render(size); + powerConnector2a.render(size); + powerConnector2b.render(size); + powerCpnnector3a.render(size); + powerConnector3b.render(size); + frame2a.render(size); + frame2b.render(size); + frame2c.render(size); + frame2d.render(size); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/mekanism/client/model/ModelElectricPump.java b/src/main/java/mekanism/client/model/ModelElectricPump.java index dad1e41bc..7fb4312f9 100644 --- a/src/main/java/mekanism/client/model/ModelElectricPump.java +++ b/src/main/java/mekanism/client/model/ModelElectricPump.java @@ -1,189 +1,185 @@ package mekanism.client.model; -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; @SideOnly(Side.CLIENT) -public class ModelElectricPump extends ModelBase -{ - ModelRenderer pumpRingTop; - ModelRenderer pumpPortTop; - ModelRenderer pumpCasing; - ModelRenderer pumpBase; - ModelRenderer powerPort; - ModelRenderer powerConnector; - ModelRenderer powerConnectorFrame4; - ModelRenderer powerConnectorFrame3; - ModelRenderer powerConnectorFrame2; - ModelRenderer powerConnectorFrame1; - ModelRenderer pipeToggleBack; - ModelRenderer pipeToggleRingBack; - ModelRenderer pipeTogglePortBack; - ModelRenderer pipeToggleLeft; - ModelRenderer pipeToggleRingLeft; - ModelRenderer pipeTogglePortLeft; - ModelRenderer pipeToggleRight; - ModelRenderer pipeToggleRingRight; - ModelRenderer pipeTogglePortRight; - ModelRenderer pumpPipe; +public class ModelElectricPump extends ModelBase { + ModelRenderer pumpRingTop; + ModelRenderer pumpPortTop; + ModelRenderer pumpCasing; + ModelRenderer pumpBase; + ModelRenderer powerPort; + ModelRenderer powerConnector; + ModelRenderer powerConnectorFrame4; + ModelRenderer powerConnectorFrame3; + ModelRenderer powerConnectorFrame2; + ModelRenderer powerConnectorFrame1; + ModelRenderer pipeToggleBack; + ModelRenderer pipeToggleRingBack; + ModelRenderer pipeTogglePortBack; + ModelRenderer pipeToggleLeft; + ModelRenderer pipeToggleRingLeft; + ModelRenderer pipeTogglePortLeft; + ModelRenderer pipeToggleRight; + ModelRenderer pipeToggleRingRight; + ModelRenderer pipeTogglePortRight; + ModelRenderer pumpPipe; - public ModelElectricPump() - { - textureWidth = 128; - textureHeight = 64; + public ModelElectricPump() { + textureWidth = 128; + textureHeight = 64; - pumpRingTop = new ModelRenderer(this, 68, 9); - pumpRingTop.addBox(0F, 0F, 0F, 8, 1, 8); - pumpRingTop.setRotationPoint(-4F, 10F, -4F); - pumpRingTop.setTextureSize(128, 64); - pumpRingTop.mirror = true; - setRotation(pumpRingTop, 0F, 0F, 0F); - pumpPortTop = new ModelRenderer(this, 68, 0); - pumpPortTop.addBox(0F, 0F, 0F, 8, 1, 8); - pumpPortTop.setRotationPoint(-4F, 8F, -4F); - pumpPortTop.setTextureSize(128, 64); - pumpPortTop.mirror = true; - setRotation(pumpPortTop, 0F, 0F, 0F); - pumpCasing = new ModelRenderer(this, 0, 0); - pumpCasing.addBox(0F, 0F, 0F, 7, 12, 7); - pumpCasing.setRotationPoint(-3.5F, 11F, -3.5F); - pumpCasing.setTextureSize(128, 64); - pumpCasing.mirror = true; - setRotation(pumpCasing, 0F, 0F, 0F); - pumpBase = new ModelRenderer(this, 28, 0); - pumpBase.addBox(0F, 0F, 0F, 6, 15, 6); - pumpBase.setRotationPoint(-3F, 9F, -3F); - pumpBase.setTextureSize(128, 64); - pumpBase.mirror = true; - setRotation(pumpBase, 0F, 0F, 0F); - powerPort = new ModelRenderer(this, 38, 29); - powerPort.addBox(0F, 0F, 0F, 8, 8, 1); - powerPort.setRotationPoint(-4F, 12F, -8F); - powerPort.setTextureSize(128, 64); - powerPort.mirror = true; - setRotation(powerPort, 0F, 0F, 0F); - powerConnector = new ModelRenderer(this, 0, 29); - powerConnector.addBox(0F, 0F, 0F, 5, 5, 4); - powerConnector.setRotationPoint(-2.5F, 13.5F, -7F); - powerConnector.setTextureSize(128, 64); - powerConnector.mirror = true; - setRotation(powerConnector, 0F, 0F, 0F); - powerConnectorFrame4 = new ModelRenderer(this, 38, 21); - powerConnectorFrame4.addBox(0F, 0F, 0F, 1, 1, 4); - powerConnectorFrame4.setRotationPoint(2F, 18F, -7F); - powerConnectorFrame4.setTextureSize(128, 64); - powerConnectorFrame4.mirror = true; - setRotation(powerConnectorFrame4, 0F, 0F, 0F); - powerConnectorFrame3 = new ModelRenderer(this, 38, 21); - powerConnectorFrame3.addBox(0F, 0F, 0F, 1, 1, 4); - powerConnectorFrame3.setRotationPoint(-3F, 18F, -7F); - powerConnectorFrame3.setTextureSize(128, 64); - powerConnectorFrame3.mirror = true; - setRotation(powerConnectorFrame3, 0F, 0F, 0F); - powerConnectorFrame2 = new ModelRenderer(this, 38, 21); - powerConnectorFrame2.addBox(0F, 0F, 0F, 1, 1, 4); - powerConnectorFrame2.setRotationPoint(2F, 13F, -7F); - powerConnectorFrame2.setTextureSize(128, 64); - powerConnectorFrame2.mirror = true; - setRotation(powerConnectorFrame2, 0F, 0F, 0F); - powerConnectorFrame1 = new ModelRenderer(this, 38, 21); - powerConnectorFrame1.addBox(0F, 0F, 0F, 1, 1, 4); - powerConnectorFrame1.setRotationPoint(-3F, 13F, -7F); - powerConnectorFrame1.setTextureSize(128, 64); - powerConnectorFrame1.mirror = true; - setRotation(powerConnectorFrame1, 0F, 0F, 0F); - pipeToggleBack = new ModelRenderer(this, 0, 19); - pipeToggleBack.addBox(0F, 0F, 0F, 6, 6, 4); - pipeToggleBack.setRotationPoint(-3F, 13F, 3F); - pipeToggleBack.setTextureSize(128, 64); - pipeToggleBack.mirror = true; - setRotation(pipeToggleBack, 0F, 0F, 0F); - pipeToggleRingBack = new ModelRenderer(this, 18, 30); - pipeToggleRingBack.addBox(0F, 0F, 0F, 7, 7, 1); - pipeToggleRingBack.setRotationPoint(-3.5F, 12.5F, 5F); - pipeToggleRingBack.setTextureSize(128, 64); - pipeToggleRingBack.mirror = true; - setRotation(pipeToggleRingBack, 0F, 0F, 0F); - pipeTogglePortBack = new ModelRenderer(this, 20, 21); - pipeTogglePortBack.addBox(0F, 0F, 0F, 8, 8, 1); - pipeTogglePortBack.setRotationPoint(-4F, 12F, 7F); - pipeTogglePortBack.setTextureSize(128, 64); - pipeTogglePortBack.mirror = true; - setRotation(pipeTogglePortBack, 0F, 0F, 0F); - pipeToggleLeft = new ModelRenderer(this, 34, 38); - pipeToggleLeft.addBox(0F, 0F, 0F, 4, 6, 6); - pipeToggleLeft.setRotationPoint(3F, 13F, -3F); - pipeToggleLeft.setTextureSize(128, 64); - pipeToggleLeft.mirror = true; - setRotation(pipeToggleLeft, 0F, 0F, 0F); - pipeToggleRingLeft = new ModelRenderer(this, 18, 38); - pipeToggleRingLeft.addBox(0F, 0F, 0F, 1, 7, 7); - pipeToggleRingLeft.setRotationPoint(5F, 12.5F, -3.5F); - pipeToggleRingLeft.setTextureSize(128, 64); - pipeToggleRingLeft.mirror = true; - setRotation(pipeToggleRingLeft, 0F, 0F, 0F); - pipeTogglePortLeft = new ModelRenderer(this, 0, 38); - pipeTogglePortLeft.addBox(0F, 0F, 0F, 1, 8, 8); - pipeTogglePortLeft.setRotationPoint(7F, 12F, -4F); - pipeTogglePortLeft.setTextureSize(128, 64); - pipeTogglePortLeft.mirror = true; - setRotation(pipeTogglePortLeft, 0F, 0F, 0F); - pipeToggleRight = new ModelRenderer(this, 34, 38); - pipeToggleRight.mirror = true; - pipeToggleRight.addBox(0F, 0F, 0F, 4, 6, 6); - pipeToggleRight.setRotationPoint(-7F, 13F, -3F); - pipeToggleRight.setTextureSize(128, 64); - setRotation(pipeToggleRight, 0F, 0F, 0F); - pipeToggleRingRight = new ModelRenderer(this, 18, 38); - pipeToggleRingRight.addBox(0F, 0F, 0F, 1, 7, 7); - pipeToggleRingRight.setRotationPoint(-6F, 12.5F, -3.5F); - pipeToggleRingRight.setTextureSize(128, 64); - pipeToggleRingRight.mirror = true; - setRotation(pipeToggleRingRight, 0F, 0F, 0F); - pipeTogglePortRight = new ModelRenderer(this, 0, 38); - pipeTogglePortRight.addBox(0F, 0F, 0F, 1, 8, 8); - pipeTogglePortRight.setRotationPoint(-8F, 12F, -4F); - pipeTogglePortRight.setTextureSize(128, 64); - pipeTogglePortRight.mirror = true; - setRotation(pipeTogglePortRight, 0F, 0F, 0F); - pumpPipe = new ModelRenderer(this, 52, 0); - pumpPipe.addBox(0F, 0F, 0F, 4, 8, 4); - pumpPipe.setRotationPoint(-2F, 24F, -2F); - pumpPipe.setTextureSize(128, 64); - pumpPipe.mirror = true; - setRotation(pumpPipe, 0F, 0F, 0F); - } + pumpRingTop = new ModelRenderer(this, 68, 9); + pumpRingTop.addBox(0F, 0F, 0F, 8, 1, 8); + pumpRingTop.setRotationPoint(-4F, 10F, -4F); + pumpRingTop.setTextureSize(128, 64); + pumpRingTop.mirror = true; + setRotation(pumpRingTop, 0F, 0F, 0F); + pumpPortTop = new ModelRenderer(this, 68, 0); + pumpPortTop.addBox(0F, 0F, 0F, 8, 1, 8); + pumpPortTop.setRotationPoint(-4F, 8F, -4F); + pumpPortTop.setTextureSize(128, 64); + pumpPortTop.mirror = true; + setRotation(pumpPortTop, 0F, 0F, 0F); + pumpCasing = new ModelRenderer(this, 0, 0); + pumpCasing.addBox(0F, 0F, 0F, 7, 12, 7); + pumpCasing.setRotationPoint(-3.5F, 11F, -3.5F); + pumpCasing.setTextureSize(128, 64); + pumpCasing.mirror = true; + setRotation(pumpCasing, 0F, 0F, 0F); + pumpBase = new ModelRenderer(this, 28, 0); + pumpBase.addBox(0F, 0F, 0F, 6, 15, 6); + pumpBase.setRotationPoint(-3F, 9F, -3F); + pumpBase.setTextureSize(128, 64); + pumpBase.mirror = true; + setRotation(pumpBase, 0F, 0F, 0F); + powerPort = new ModelRenderer(this, 38, 29); + powerPort.addBox(0F, 0F, 0F, 8, 8, 1); + powerPort.setRotationPoint(-4F, 12F, -8F); + powerPort.setTextureSize(128, 64); + powerPort.mirror = true; + setRotation(powerPort, 0F, 0F, 0F); + powerConnector = new ModelRenderer(this, 0, 29); + powerConnector.addBox(0F, 0F, 0F, 5, 5, 4); + powerConnector.setRotationPoint(-2.5F, 13.5F, -7F); + powerConnector.setTextureSize(128, 64); + powerConnector.mirror = true; + setRotation(powerConnector, 0F, 0F, 0F); + powerConnectorFrame4 = new ModelRenderer(this, 38, 21); + powerConnectorFrame4.addBox(0F, 0F, 0F, 1, 1, 4); + powerConnectorFrame4.setRotationPoint(2F, 18F, -7F); + powerConnectorFrame4.setTextureSize(128, 64); + powerConnectorFrame4.mirror = true; + setRotation(powerConnectorFrame4, 0F, 0F, 0F); + powerConnectorFrame3 = new ModelRenderer(this, 38, 21); + powerConnectorFrame3.addBox(0F, 0F, 0F, 1, 1, 4); + powerConnectorFrame3.setRotationPoint(-3F, 18F, -7F); + powerConnectorFrame3.setTextureSize(128, 64); + powerConnectorFrame3.mirror = true; + setRotation(powerConnectorFrame3, 0F, 0F, 0F); + powerConnectorFrame2 = new ModelRenderer(this, 38, 21); + powerConnectorFrame2.addBox(0F, 0F, 0F, 1, 1, 4); + powerConnectorFrame2.setRotationPoint(2F, 13F, -7F); + powerConnectorFrame2.setTextureSize(128, 64); + powerConnectorFrame2.mirror = true; + setRotation(powerConnectorFrame2, 0F, 0F, 0F); + powerConnectorFrame1 = new ModelRenderer(this, 38, 21); + powerConnectorFrame1.addBox(0F, 0F, 0F, 1, 1, 4); + powerConnectorFrame1.setRotationPoint(-3F, 13F, -7F); + powerConnectorFrame1.setTextureSize(128, 64); + powerConnectorFrame1.mirror = true; + setRotation(powerConnectorFrame1, 0F, 0F, 0F); + pipeToggleBack = new ModelRenderer(this, 0, 19); + pipeToggleBack.addBox(0F, 0F, 0F, 6, 6, 4); + pipeToggleBack.setRotationPoint(-3F, 13F, 3F); + pipeToggleBack.setTextureSize(128, 64); + pipeToggleBack.mirror = true; + setRotation(pipeToggleBack, 0F, 0F, 0F); + pipeToggleRingBack = new ModelRenderer(this, 18, 30); + pipeToggleRingBack.addBox(0F, 0F, 0F, 7, 7, 1); + pipeToggleRingBack.setRotationPoint(-3.5F, 12.5F, 5F); + pipeToggleRingBack.setTextureSize(128, 64); + pipeToggleRingBack.mirror = true; + setRotation(pipeToggleRingBack, 0F, 0F, 0F); + pipeTogglePortBack = new ModelRenderer(this, 20, 21); + pipeTogglePortBack.addBox(0F, 0F, 0F, 8, 8, 1); + pipeTogglePortBack.setRotationPoint(-4F, 12F, 7F); + pipeTogglePortBack.setTextureSize(128, 64); + pipeTogglePortBack.mirror = true; + setRotation(pipeTogglePortBack, 0F, 0F, 0F); + pipeToggleLeft = new ModelRenderer(this, 34, 38); + pipeToggleLeft.addBox(0F, 0F, 0F, 4, 6, 6); + pipeToggleLeft.setRotationPoint(3F, 13F, -3F); + pipeToggleLeft.setTextureSize(128, 64); + pipeToggleLeft.mirror = true; + setRotation(pipeToggleLeft, 0F, 0F, 0F); + pipeToggleRingLeft = new ModelRenderer(this, 18, 38); + pipeToggleRingLeft.addBox(0F, 0F, 0F, 1, 7, 7); + pipeToggleRingLeft.setRotationPoint(5F, 12.5F, -3.5F); + pipeToggleRingLeft.setTextureSize(128, 64); + pipeToggleRingLeft.mirror = true; + setRotation(pipeToggleRingLeft, 0F, 0F, 0F); + pipeTogglePortLeft = new ModelRenderer(this, 0, 38); + pipeTogglePortLeft.addBox(0F, 0F, 0F, 1, 8, 8); + pipeTogglePortLeft.setRotationPoint(7F, 12F, -4F); + pipeTogglePortLeft.setTextureSize(128, 64); + pipeTogglePortLeft.mirror = true; + setRotation(pipeTogglePortLeft, 0F, 0F, 0F); + pipeToggleRight = new ModelRenderer(this, 34, 38); + pipeToggleRight.mirror = true; + pipeToggleRight.addBox(0F, 0F, 0F, 4, 6, 6); + pipeToggleRight.setRotationPoint(-7F, 13F, -3F); + pipeToggleRight.setTextureSize(128, 64); + setRotation(pipeToggleRight, 0F, 0F, 0F); + pipeToggleRingRight = new ModelRenderer(this, 18, 38); + pipeToggleRingRight.addBox(0F, 0F, 0F, 1, 7, 7); + pipeToggleRingRight.setRotationPoint(-6F, 12.5F, -3.5F); + pipeToggleRingRight.setTextureSize(128, 64); + pipeToggleRingRight.mirror = true; + setRotation(pipeToggleRingRight, 0F, 0F, 0F); + pipeTogglePortRight = new ModelRenderer(this, 0, 38); + pipeTogglePortRight.addBox(0F, 0F, 0F, 1, 8, 8); + pipeTogglePortRight.setRotationPoint(-8F, 12F, -4F); + pipeTogglePortRight.setTextureSize(128, 64); + pipeTogglePortRight.mirror = true; + setRotation(pipeTogglePortRight, 0F, 0F, 0F); + pumpPipe = new ModelRenderer(this, 52, 0); + pumpPipe.addBox(0F, 0F, 0F, 4, 8, 4); + pumpPipe.setRotationPoint(-2F, 24F, -2F); + pumpPipe.setTextureSize(128, 64); + pumpPipe.mirror = true; + setRotation(pumpPipe, 0F, 0F, 0F); + } - public void render(float size) - { - pumpRingTop.render(size); - pumpPortTop.render(size); - pumpCasing.render(size); - pumpBase.render(size); - powerPort.render(size); - powerConnector.render(size); - powerConnectorFrame4.render(size); - powerConnectorFrame3.render(size); - powerConnectorFrame2.render(size); - powerConnectorFrame1.render(size); - /*pipeToggleBack.render(size); - pipeToggleRingBack.render(size); - pipeTogglePortBack.render(size); - pipeToggleLeft.render(size); - pipeToggleRingLeft.render(size); - pipeTogglePortLeft.render(size); - pipeToggleRight.render(size); - pipeToggleRingRight.render(size); - pipeTogglePortRight.render(size); - pumpPipe.render(size);*/ - } + public void render(float size) { + pumpRingTop.render(size); + pumpPortTop.render(size); + pumpCasing.render(size); + pumpBase.render(size); + powerPort.render(size); + powerConnector.render(size); + powerConnectorFrame4.render(size); + powerConnectorFrame3.render(size); + powerConnectorFrame2.render(size); + powerConnectorFrame1.render(size); + /*pipeToggleBack.render(size); + pipeToggleRingBack.render(size); + pipeTogglePortBack.render(size); + pipeToggleLeft.render(size); + pipeToggleRingLeft.render(size); + pipeTogglePortLeft.render(size); + pipeToggleRight.render(size); + pipeToggleRingRight.render(size); + pipeTogglePortRight.render(size); + pumpPipe.render(size);*/ + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/mekanism/client/model/ModelElectrolyticSeparator.java b/src/main/java/mekanism/client/model/ModelElectrolyticSeparator.java index f424ca347..19caeca17 100644 --- a/src/main/java/mekanism/client/model/ModelElectrolyticSeparator.java +++ b/src/main/java/mekanism/client/model/ModelElectrolyticSeparator.java @@ -1,165 +1,161 @@ package mekanism.client.model; -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; @SideOnly(Side.CLIENT) -public class ModelElectrolyticSeparator extends ModelBase -{ - ModelRenderer tank2; - ModelRenderer tank1; - ModelRenderer tank3; - ModelRenderer tube6; - ModelRenderer tube5; - ModelRenderer tube4; - ModelRenderer tube3; - ModelRenderer tube2; - ModelRenderer tube1; - ModelRenderer base; - ModelRenderer portToggle1; - ModelRenderer portToggle2a; - ModelRenderer portToggle2b; - ModelRenderer portToggle3a; - ModelRenderer portToggle3b; - ModelRenderer portToggle4a; - ModelRenderer portToggle4b; +public class ModelElectrolyticSeparator extends ModelBase { + ModelRenderer tank2; + ModelRenderer tank1; + ModelRenderer tank3; + ModelRenderer tube6; + ModelRenderer tube5; + ModelRenderer tube4; + ModelRenderer tube3; + ModelRenderer tube2; + ModelRenderer tube1; + ModelRenderer base; + ModelRenderer portToggle1; + ModelRenderer portToggle2a; + ModelRenderer portToggle2b; + ModelRenderer portToggle3a; + ModelRenderer portToggle3b; + ModelRenderer portToggle4a; + ModelRenderer portToggle4b; - public ModelElectrolyticSeparator() - { - textureWidth = 128; - textureHeight = 64; + public ModelElectrolyticSeparator() { + textureWidth = 128; + textureHeight = 64; - tank2 = new ModelRenderer(this, 64, 0); - tank2.addBox(0F, 0F, 0F, 7, 10, 7); - tank2.setRotationPoint(1F, 10F, 1F); - tank2.setTextureSize(128, 64); - tank2.mirror = true; - setRotation(tank2, 0F, 0F, 0F); - tank1 = new ModelRenderer(this, 0, 20); - tank1.addBox(0F, 0F, 0F, 8, 12, 16); - tank1.setRotationPoint(-8F, 8F, -8F); - tank1.setTextureSize(128, 64); - tank1.mirror = true; - setRotation(tank1, 0F, 0F, 0F); - tank3 = new ModelRenderer(this, 64, 0); - tank3.addBox(0F, 0F, 0F, 7, 10, 7); - tank3.setRotationPoint(1F, 10F, -8F); - tank3.setTextureSize(128, 64); - tank3.mirror = true; - setRotation(tank3, 0F, 0F, 0F); - tube6 = new ModelRenderer(this, 0, 0); - tube6.addBox(0F, 0F, 0F, 1, 1, 1); - tube6.setRotationPoint(4F, 9F, 4F); - tube6.setTextureSize(128, 64); - tube6.mirror = true; - setRotation(tube6, 0F, 0F, 0F); - tube5 = new ModelRenderer(this, 0, 0); - tube5.addBox(0F, 0F, 0F, 1, 1, 1); - tube5.setRotationPoint(4F, 9F, -5F); - tube5.setTextureSize(128, 64); - tube5.mirror = true; - setRotation(tube5, 0F, 0F, 0F); - tube4 = new ModelRenderer(this, 0, 48); - tube4.addBox(0F, 0F, 0F, 1, 1, 10); - tube4.setRotationPoint(4F, 8F, -5F); - tube4.setTextureSize(128, 64); - tube4.mirror = true; - setRotation(tube4, 0F, 0F, 0F); - tube3 = new ModelRenderer(this, 0, 0); - tube3.addBox(0F, 0F, 0F, 1, 3, 1); - tube3.setRotationPoint(4F, 9F, -0.5F); - tube3.setTextureSize(128, 64); - tube3.mirror = true; - setRotation(tube3, 0F, 0F, 0F); - tube2 = new ModelRenderer(this, 0, 0); - tube2.addBox(-4F, -1F, 0F, 4, 1, 1); - tube2.setRotationPoint(5F, 12F, -0.5F); - tube2.setTextureSize(128, 64); - tube2.mirror = true; - setRotation(tube2, 0F, 0F, -0.5235988F); - tube1 = new ModelRenderer(this, 0, 0); - tube1.addBox(-3F, -1F, 0F, 3, 1, 1); - tube1.setRotationPoint(1.5F, 14F, -0.5F); - tube1.setTextureSize(128, 64); - tube1.mirror = true; - setRotation(tube1, 0F, 0F, 0F); - base = new ModelRenderer(this, 0, 0); - base.addBox(0F, 0F, 0F, 16, 4, 16); - base.setRotationPoint(-8F, 20F, -8F); - base.setTextureSize(128, 64); - base.mirror = true; - setRotation(base, 0F, 0F, 0F); - portToggle1 = new ModelRenderer(this, 48, 36); - portToggle1.addBox(0F, 0F, 0F, 1, 10, 10); - portToggle1.setRotationPoint(-8.01F, 11F, -5F); - portToggle1.setTextureSize(128, 64); - portToggle1.mirror = true; - setRotation(portToggle1, 0F, 0F, 0F); - portToggle2a = new ModelRenderer(this, 48, 20); - portToggle2a.addBox(0F, 0F, 0F, 1, 8, 8); - portToggle2a.setRotationPoint(7.01F, 12F, -4F); - portToggle2a.setTextureSize(128, 64); - portToggle2a.mirror = true; - setRotation(portToggle2a, 0F, 0F, 0F); - portToggle2b = new ModelRenderer(this, 0, 4); - portToggle2b.addBox(0F, 0F, 0F, 2, 7, 2); - portToggle2b.setRotationPoint(5F, 13F, -1F); - portToggle2b.setTextureSize(128, 64); - portToggle2b.mirror = true; - setRotation(portToggle2b, 0F, 0F, 0F); - portToggle3a = new ModelRenderer(this, 66, 20); - portToggle3a.addBox(0F, 0F, 0F, 8, 8, 1); - portToggle3a.setRotationPoint(-4F, 12F, -8.01F); - portToggle3a.setTextureSize(128, 64); - portToggle3a.mirror = true; - setRotation(portToggle3a, 0F, 0F, 0F); - portToggle3b = new ModelRenderer(this, 0, 4); - portToggle3b.addBox(0F, 0F, 0F, 1, 7, 2); - portToggle3b.setRotationPoint(0F, 13F, -7F); - portToggle3b.setTextureSize(128, 64); - portToggle3b.mirror = true; - setRotation(portToggle3b, 0F, 0F, 0F); - portToggle4a = new ModelRenderer(this, 66, 20); - portToggle4a.addBox(0F, 0F, 0F, 8, 8, 1); - portToggle4a.setRotationPoint(-4F, 12F, 7.01F); - portToggle4a.setTextureSize(128, 64); - portToggle4a.mirror = true; - setRotation(portToggle4a, 0F, 0F, 0F); - portToggle4b = new ModelRenderer(this, 0, 4); - portToggle4b.addBox(0F, 0F, 0F, 1, 7, 2); - portToggle4b.setRotationPoint(0F, 13F, 5F); - portToggle4b.setTextureSize(128, 64); - portToggle4b.mirror = true; - setRotation(portToggle4b, 0F, 0F, 0F); - } + tank2 = new ModelRenderer(this, 64, 0); + tank2.addBox(0F, 0F, 0F, 7, 10, 7); + tank2.setRotationPoint(1F, 10F, 1F); + tank2.setTextureSize(128, 64); + tank2.mirror = true; + setRotation(tank2, 0F, 0F, 0F); + tank1 = new ModelRenderer(this, 0, 20); + tank1.addBox(0F, 0F, 0F, 8, 12, 16); + tank1.setRotationPoint(-8F, 8F, -8F); + tank1.setTextureSize(128, 64); + tank1.mirror = true; + setRotation(tank1, 0F, 0F, 0F); + tank3 = new ModelRenderer(this, 64, 0); + tank3.addBox(0F, 0F, 0F, 7, 10, 7); + tank3.setRotationPoint(1F, 10F, -8F); + tank3.setTextureSize(128, 64); + tank3.mirror = true; + setRotation(tank3, 0F, 0F, 0F); + tube6 = new ModelRenderer(this, 0, 0); + tube6.addBox(0F, 0F, 0F, 1, 1, 1); + tube6.setRotationPoint(4F, 9F, 4F); + tube6.setTextureSize(128, 64); + tube6.mirror = true; + setRotation(tube6, 0F, 0F, 0F); + tube5 = new ModelRenderer(this, 0, 0); + tube5.addBox(0F, 0F, 0F, 1, 1, 1); + tube5.setRotationPoint(4F, 9F, -5F); + tube5.setTextureSize(128, 64); + tube5.mirror = true; + setRotation(tube5, 0F, 0F, 0F); + tube4 = new ModelRenderer(this, 0, 48); + tube4.addBox(0F, 0F, 0F, 1, 1, 10); + tube4.setRotationPoint(4F, 8F, -5F); + tube4.setTextureSize(128, 64); + tube4.mirror = true; + setRotation(tube4, 0F, 0F, 0F); + tube3 = new ModelRenderer(this, 0, 0); + tube3.addBox(0F, 0F, 0F, 1, 3, 1); + tube3.setRotationPoint(4F, 9F, -0.5F); + tube3.setTextureSize(128, 64); + tube3.mirror = true; + setRotation(tube3, 0F, 0F, 0F); + tube2 = new ModelRenderer(this, 0, 0); + tube2.addBox(-4F, -1F, 0F, 4, 1, 1); + tube2.setRotationPoint(5F, 12F, -0.5F); + tube2.setTextureSize(128, 64); + tube2.mirror = true; + setRotation(tube2, 0F, 0F, -0.5235988F); + tube1 = new ModelRenderer(this, 0, 0); + tube1.addBox(-3F, -1F, 0F, 3, 1, 1); + tube1.setRotationPoint(1.5F, 14F, -0.5F); + tube1.setTextureSize(128, 64); + tube1.mirror = true; + setRotation(tube1, 0F, 0F, 0F); + base = new ModelRenderer(this, 0, 0); + base.addBox(0F, 0F, 0F, 16, 4, 16); + base.setRotationPoint(-8F, 20F, -8F); + base.setTextureSize(128, 64); + base.mirror = true; + setRotation(base, 0F, 0F, 0F); + portToggle1 = new ModelRenderer(this, 48, 36); + portToggle1.addBox(0F, 0F, 0F, 1, 10, 10); + portToggle1.setRotationPoint(-8.01F, 11F, -5F); + portToggle1.setTextureSize(128, 64); + portToggle1.mirror = true; + setRotation(portToggle1, 0F, 0F, 0F); + portToggle2a = new ModelRenderer(this, 48, 20); + portToggle2a.addBox(0F, 0F, 0F, 1, 8, 8); + portToggle2a.setRotationPoint(7.01F, 12F, -4F); + portToggle2a.setTextureSize(128, 64); + portToggle2a.mirror = true; + setRotation(portToggle2a, 0F, 0F, 0F); + portToggle2b = new ModelRenderer(this, 0, 4); + portToggle2b.addBox(0F, 0F, 0F, 2, 7, 2); + portToggle2b.setRotationPoint(5F, 13F, -1F); + portToggle2b.setTextureSize(128, 64); + portToggle2b.mirror = true; + setRotation(portToggle2b, 0F, 0F, 0F); + portToggle3a = new ModelRenderer(this, 66, 20); + portToggle3a.addBox(0F, 0F, 0F, 8, 8, 1); + portToggle3a.setRotationPoint(-4F, 12F, -8.01F); + portToggle3a.setTextureSize(128, 64); + portToggle3a.mirror = true; + setRotation(portToggle3a, 0F, 0F, 0F); + portToggle3b = new ModelRenderer(this, 0, 4); + portToggle3b.addBox(0F, 0F, 0F, 1, 7, 2); + portToggle3b.setRotationPoint(0F, 13F, -7F); + portToggle3b.setTextureSize(128, 64); + portToggle3b.mirror = true; + setRotation(portToggle3b, 0F, 0F, 0F); + portToggle4a = new ModelRenderer(this, 66, 20); + portToggle4a.addBox(0F, 0F, 0F, 8, 8, 1); + portToggle4a.setRotationPoint(-4F, 12F, 7.01F); + portToggle4a.setTextureSize(128, 64); + portToggle4a.mirror = true; + setRotation(portToggle4a, 0F, 0F, 0F); + portToggle4b = new ModelRenderer(this, 0, 4); + portToggle4b.addBox(0F, 0F, 0F, 1, 7, 2); + portToggle4b.setRotationPoint(0F, 13F, 5F); + portToggle4b.setTextureSize(128, 64); + portToggle4b.mirror = true; + setRotation(portToggle4b, 0F, 0F, 0F); + } - public void render(float size) - { - tank2.render(size); - tank1.render(size); - tank3.render(size); - tube6.render(size); - tube5.render(size); - tube4.render(size); - tube3.render(size); - tube2.render(size); - tube1.render(size); - base.render(size); - portToggle1.render(size); - portToggle2a.render(size); - portToggle2b.render(size); - portToggle3a.render(size); - portToggle3b.render(size); - portToggle4a.render(size); - portToggle4b.render(size); - } + public void render(float size) { + tank2.render(size); + tank1.render(size); + tank3.render(size); + tube6.render(size); + tube5.render(size); + tube4.render(size); + tube3.render(size); + tube2.render(size); + tube1.render(size); + base.render(size); + portToggle1.render(size); + portToggle2a.render(size); + portToggle2b.render(size); + portToggle3a.render(size); + portToggle3b.render(size); + portToggle4a.render(size); + portToggle4b.render(size); + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/mekanism/client/model/ModelEnergyCube.java b/src/main/java/mekanism/client/model/ModelEnergyCube.java index 334846a76..8d71712c5 100644 --- a/src/main/java/mekanism/client/model/ModelEnergyCube.java +++ b/src/main/java/mekanism/client/model/ModelEnergyCube.java @@ -1,5 +1,7 @@ package mekanism.client.model; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.render.MekanismRenderer; import mekanism.client.render.tileentity.RenderEnergyCube; import mekanism.common.SideData.IOState; @@ -11,448 +13,445 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.util.ForgeDirection; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class ModelEnergyCube extends ModelBase -{ - public static ResourceLocation OVERLAY_ON = MekanismUtils.getResource(ResourceType.RENDER, "EnergyCube_OverlayOn.png"); - public static ResourceLocation OVERLAY_OFF = MekanismUtils.getResource(ResourceType.RENDER, "EnergyCube_OverlayOff.png"); - - ModelRenderer frame12; - ModelRenderer frame11; - ModelRenderer frame10; - ModelRenderer frame9; - ModelRenderer frame8; - ModelRenderer frame7; - ModelRenderer frame6; - ModelRenderer frame5; - ModelRenderer frame4; - ModelRenderer frame3; - ModelRenderer frame2; - ModelRenderer frame1; - ModelRenderer corner8; - ModelRenderer corner7; - ModelRenderer corner6; - ModelRenderer corner5; - ModelRenderer corner4; - ModelRenderer corner3; - ModelRenderer corner2; - ModelRenderer corner1; - ModelRenderer connectorBackToggle; - ModelRenderer connectorRightToggle; - ModelRenderer connectorBottomToggle; - ModelRenderer connectorLeftToggle; - ModelRenderer connectorFrontToggle; - ModelRenderer connectorTopToggle; - ModelRenderer portBackToggle; - ModelRenderer portBottomToggle; - ModelRenderer portFrontToggle; - ModelRenderer portLeftToggle; - ModelRenderer portRightToggle; - ModelRenderer portTopToggle; - ModelRenderer ledTop1; - ModelRenderer ledTop2; - ModelRenderer ledBack1; - ModelRenderer ledBack2; - ModelRenderer ledBottom2; - ModelRenderer ledBottom1; - ModelRenderer ledFront1; - ModelRenderer ledFront2; - ModelRenderer ledRight2; - ModelRenderer ledRight1; - ModelRenderer ledLeft1; - ModelRenderer ledLeft2; - - public ModelRenderer[] leds1; - public ModelRenderer[] leds2; - - public ModelRenderer[] ports; - public ModelRenderer[] connectors; +public class ModelEnergyCube extends ModelBase { + public static ResourceLocation OVERLAY_ON + = MekanismUtils.getResource(ResourceType.RENDER, "EnergyCube_OverlayOn.png"); + public static ResourceLocation OVERLAY_OFF + = MekanismUtils.getResource(ResourceType.RENDER, "EnergyCube_OverlayOff.png"); - public ModelEnergyCube() - { - textureWidth = 64; - textureHeight = 64; + ModelRenderer frame12; + ModelRenderer frame11; + ModelRenderer frame10; + ModelRenderer frame9; + ModelRenderer frame8; + ModelRenderer frame7; + ModelRenderer frame6; + ModelRenderer frame5; + ModelRenderer frame4; + ModelRenderer frame3; + ModelRenderer frame2; + ModelRenderer frame1; + ModelRenderer corner8; + ModelRenderer corner7; + ModelRenderer corner6; + ModelRenderer corner5; + ModelRenderer corner4; + ModelRenderer corner3; + ModelRenderer corner2; + ModelRenderer corner1; + ModelRenderer connectorBackToggle; + ModelRenderer connectorRightToggle; + ModelRenderer connectorBottomToggle; + ModelRenderer connectorLeftToggle; + ModelRenderer connectorFrontToggle; + ModelRenderer connectorTopToggle; + ModelRenderer portBackToggle; + ModelRenderer portBottomToggle; + ModelRenderer portFrontToggle; + ModelRenderer portLeftToggle; + ModelRenderer portRightToggle; + ModelRenderer portTopToggle; + ModelRenderer ledTop1; + ModelRenderer ledTop2; + ModelRenderer ledBack1; + ModelRenderer ledBack2; + ModelRenderer ledBottom2; + ModelRenderer ledBottom1; + ModelRenderer ledFront1; + ModelRenderer ledFront2; + ModelRenderer ledRight2; + ModelRenderer ledRight1; + ModelRenderer ledLeft1; + ModelRenderer ledLeft2; - frame12 = new ModelRenderer(this, 0, 0); - frame12.addBox(0F, 0F, 0F, 3, 10, 3); - frame12.setRotationPoint(-8F, 11F, 5F); - frame12.setTextureSize(64, 64); - frame12.mirror = true; - setRotation(frame12, 0F, 0F, 0F); - frame11 = new ModelRenderer(this, 0, 0); - frame11.addBox(0F, 0F, 0F, 3, 10, 3); - frame11.setRotationPoint(5F, 11F, -8F); - frame11.setTextureSize(64, 64); - frame11.mirror = true; - setRotation(frame11, 0F, 0F, 0F); - frame10 = new ModelRenderer(this, 0, 13); - frame10.addBox(0F, 0F, 0F, 10, 3, 3); - frame10.setRotationPoint(-5F, 21F, 5F); - frame10.setTextureSize(64, 64); - frame10.mirror = true; - setRotation(frame10, 0F, 0F, 0F); - frame9 = new ModelRenderer(this, 12, 0); - frame9.addBox(0F, 0F, 0F, 3, 3, 10); - frame9.setRotationPoint(5F, 21F, -5F); - frame9.setTextureSize(64, 64); - frame9.mirror = true; - setRotation(frame9, 0F, 0F, 0F); - frame8 = new ModelRenderer(this, 0, 13); - frame8.addBox(0F, 0F, 0F, 10, 3, 3); - frame8.setRotationPoint(-5F, 8F, 5F); - frame8.setTextureSize(64, 64); - frame8.mirror = true; - setRotation(frame8, 0F, 0F, 0F); - frame7 = new ModelRenderer(this, 0, 13); - frame7.addBox(0F, 0F, 0F, 10, 3, 3); - frame7.setRotationPoint(-5F, 21F, -8F); - frame7.setTextureSize(64, 64); - frame7.mirror = true; - setRotation(frame7, 0F, 0F, 0F); - frame6 = new ModelRenderer(this, 0, 0); - frame6.addBox(0F, 0F, 0F, 3, 10, 3); - frame6.setRotationPoint(5F, 11F, 5F); - frame6.setTextureSize(64, 64); - frame6.mirror = true; - setRotation(frame6, 0F, 0F, 0F); - frame5 = new ModelRenderer(this, 0, 0); - frame5.addBox(0F, 0F, 0F, 3, 10, 3); - frame5.setRotationPoint(-8F, 11F, -8F); - frame5.setTextureSize(64, 64); - frame5.mirror = true; - setRotation(frame5, 0F, 0F, 0F); - frame4 = new ModelRenderer(this, 12, 0); - frame4.addBox(0F, 0F, 0F, 3, 3, 10); - frame4.setRotationPoint(5F, 8F, -5F); - frame4.setTextureSize(64, 64); - frame4.mirror = true; - setRotation(frame4, 0F, 0F, 0F); - frame3 = new ModelRenderer(this, 12, 0); - frame3.addBox(0F, 0F, 0F, 3, 3, 10); - frame3.setRotationPoint(-8F, 21F, -5F); - frame3.setTextureSize(64, 64); - frame3.mirror = true; - setRotation(frame3, 0F, 0F, 0F); - frame2 = new ModelRenderer(this, 12, 0); - frame2.addBox(0F, 0F, 0F, 3, 3, 10); - frame2.setRotationPoint(-8F, 8F, -5F); - frame2.setTextureSize(64, 64); - frame2.mirror = true; - setRotation(frame2, 0F, 0F, 0F); - frame1 = new ModelRenderer(this, 0, 13); - frame1.addBox(0F, 0F, 0F, 10, 3, 3); - frame1.setRotationPoint(-5F, 8F, -8F); - frame1.setTextureSize(64, 64); - frame1.mirror = true; - setRotation(frame1, 0F, 0F, 0F); - corner8 = new ModelRenderer(this, 26, 13); - corner8.addBox(0F, 0F, 0F, 3, 3, 3); - corner8.setRotationPoint(5F, 21F, 5F); - corner8.setTextureSize(64, 64); - corner8.mirror = true; - setRotation(corner8, 0F, 0F, 0F); - corner7 = new ModelRenderer(this, 26, 13); - corner7.addBox(0F, 0F, 0F, 3, 3, 3); - corner7.setRotationPoint(5F, 21F, -8F); - corner7.setTextureSize(64, 64); - corner7.mirror = true; - setRotation(corner7, 0F, 0F, 0F); - corner6 = new ModelRenderer(this, 26, 13); - corner6.addBox(0F, 0F, 0F, 3, 3, 3); - corner6.setRotationPoint(-8F, 21F, 5F); - corner6.setTextureSize(64, 64); - corner6.mirror = true; - setRotation(corner6, 0F, 0F, 0F); - corner5 = new ModelRenderer(this, 26, 13); - corner5.addBox(0F, 0F, 0F, 3, 3, 3); - corner5.setRotationPoint(-8F, 21F, -8F); - corner5.setTextureSize(64, 64); - corner5.mirror = true; - setRotation(corner5, 0F, 0F, 0F); - corner4 = new ModelRenderer(this, 26, 13); - corner4.addBox(0F, 0F, 0F, 3, 3, 3); - corner4.setRotationPoint(5F, 8F, 5F); - corner4.setTextureSize(64, 64); - corner4.mirror = true; - setRotation(corner4, 0F, 0F, 0F); - corner3 = new ModelRenderer(this, 26, 13); - corner3.addBox(0F, 0F, 0F, 3, 3, 3); - corner3.setRotationPoint(5F, 8F, -8F); - corner3.setTextureSize(64, 64); - corner3.mirror = true; - setRotation(corner3, 0F, 0F, 0F); - corner2 = new ModelRenderer(this, 26, 13); - corner2.addBox(0F, 0F, 0F, 3, 3, 3); - corner2.setRotationPoint(-8F, 8F, 5F); - corner2.setTextureSize(64, 64); - corner2.mirror = true; - setRotation(corner2, 0F, 0F, 0F); - corner1 = new ModelRenderer(this, 26, 13); - corner1.addBox(0F, 0F, 0F, 3, 3, 3); - corner1.setRotationPoint(-8F, 8F, -8F); - corner1.setTextureSize(64, 64); - corner1.mirror = true; - setRotation(corner1, 0F, 0F, 0F); - connectorBackToggle = new ModelRenderer(this, 38, 16); - connectorBackToggle.addBox(0F, 0F, 0F, 10, 6, 1); - connectorBackToggle.setRotationPoint(-5F, 13F, 6F); - connectorBackToggle.setTextureSize(64, 64); - connectorBackToggle.mirror = true; - setRotation(connectorBackToggle, 0F, 0F, 0F); - connectorRightToggle = new ModelRenderer(this, 38, 0); - connectorRightToggle.addBox(0F, 0F, 0F, 1, 6, 10); - connectorRightToggle.setRotationPoint(6F, 13F, -5F); - connectorRightToggle.setTextureSize(64, 64); - connectorRightToggle.mirror = true; - setRotation(connectorRightToggle, 0F, 0F, 0F); - connectorBottomToggle = new ModelRenderer(this, 0, 19); - connectorBottomToggle.addBox(0F, 0F, 0F, 10, 1, 6); - connectorBottomToggle.setRotationPoint(-5F, 22F, -3F); - connectorBottomToggle.setTextureSize(64, 64); - connectorBottomToggle.mirror = true; - setRotation(connectorBottomToggle, 0F, 0F, 0F); - connectorLeftToggle = new ModelRenderer(this, 38, 0); - connectorLeftToggle.addBox(0F, 0F, 0F, 1, 6, 10); - connectorLeftToggle.setRotationPoint(-7F, 13F, -5F); - connectorLeftToggle.setTextureSize(64, 64); - connectorLeftToggle.mirror = true; - setRotation(connectorLeftToggle, 0F, 0F, 0F); - connectorFrontToggle = new ModelRenderer(this, 38, 16); - connectorFrontToggle.addBox(0F, 0F, 0F, 10, 6, 1); - connectorFrontToggle.setRotationPoint(-5F, 13F, -7F); - connectorFrontToggle.setTextureSize(64, 64); - connectorFrontToggle.mirror = true; - setRotation(connectorFrontToggle, 0F, 0F, 0F); - connectorTopToggle = new ModelRenderer(this, 0, 19); - connectorTopToggle.addBox(0F, 0F, 0F, 10, 1, 6); - connectorTopToggle.setRotationPoint(-5F, 9F, -3F); - connectorTopToggle.setTextureSize(64, 64); - connectorTopToggle.mirror = true; - setRotation(connectorTopToggle, 0F, 0F, 0F); - portBackToggle = new ModelRenderer(this, 18, 35); - portBackToggle.addBox(0F, 0F, 0F, 8, 8, 1); - portBackToggle.setRotationPoint(-4F, 12F, 7F); - portBackToggle.setTextureSize(64, 64); - portBackToggle.mirror = true; - setRotation(portBackToggle, 0F, 0F, 0F); - portBottomToggle = new ModelRenderer(this, 0, 26); - portBottomToggle.addBox(0F, 0F, 0F, 8, 1, 8); - portBottomToggle.setRotationPoint(-4F, 23F, -4F); - portBottomToggle.setTextureSize(64, 64); - portBottomToggle.mirror = true; - setRotation(portBottomToggle, 0F, 0F, 0F); - portFrontToggle = new ModelRenderer(this, 18, 35); - portFrontToggle.addBox(0F, 0F, 0F, 8, 8, 1); - portFrontToggle.setRotationPoint(-4F, 12F, -8F); - portFrontToggle.setTextureSize(64, 64); - portFrontToggle.mirror = true; - setRotation(portFrontToggle, 0F, 0F, 0F); - portLeftToggle = new ModelRenderer(this, 0, 35); - portLeftToggle.addBox(0F, 0F, 0F, 1, 8, 8); - portLeftToggle.setRotationPoint(-8F, 12F, -4F); - portLeftToggle.setTextureSize(64, 64); - portLeftToggle.mirror = true; - setRotation(portLeftToggle, 0F, 0F, 0F); - portRightToggle = new ModelRenderer(this, 0, 35); - portRightToggle.addBox(0F, 0F, 0F, 1, 8, 8); - portRightToggle.setRotationPoint(7F, 12F, -4F); - portRightToggle.setTextureSize(64, 64); - portRightToggle.mirror = true; - setRotation(portRightToggle, 0F, 0F, 0F); - portTopToggle = new ModelRenderer(this, 0, 26); - portTopToggle.addBox(0F, 0F, 0F, 8, 1, 8); - portTopToggle.setRotationPoint(-4F, 8F, -4F); - portTopToggle.setTextureSize(64, 64); - portTopToggle.mirror = true; - setRotation(portTopToggle, 0F, 0F, 0F); - ledTop1 = new ModelRenderer(this, 0, 51); - ledTop1.addBox(0F, 0F, 0F, 1, 1, 1); - ledTop1.setRotationPoint(-5.5F, 8.1F, -0.5F); - ledTop1.setTextureSize(64, 64); - ledTop1.mirror = true; - setRotation(ledTop1, 0F, 0F, 0F); - ledTop2 = new ModelRenderer(this, 0, 51); - ledTop2.addBox(0F, 0F, 0F, 1, 1, 1); - ledTop2.setRotationPoint(4.5F, 8.1F, -0.5F); - ledTop2.setTextureSize(64, 64); - ledTop2.mirror = true; - setRotation(ledTop2, 0F, 0F, 0F); - ledBack1 = new ModelRenderer(this, 0, 51); - ledBack1.addBox(0F, 0F, 0F, 1, 1, 1); - ledBack1.setRotationPoint(-5.5F, 15.5F, 6.9F); - ledBack1.setTextureSize(64, 64); - ledBack1.mirror = true; - setRotation(ledBack1, 0F, 0F, 0F); - ledBack2 = new ModelRenderer(this, 0, 51); - ledBack2.addBox(0F, 0F, 0F, 1, 1, 1); - ledBack2.setRotationPoint(4.5F, 15.5F, 6.9F); - ledBack2.setTextureSize(64, 64); - ledBack2.mirror = true; - setRotation(ledBack2, 0F, 0F, 0F); - ledBottom2 = new ModelRenderer(this, 0, 51); - ledBottom2.addBox(0F, 0F, 0F, 1, 1, 1); - ledBottom2.setRotationPoint(4.5F, 22.9F, -0.5F); - ledBottom2.setTextureSize(64, 64); - ledBottom2.mirror = true; - setRotation(ledBottom2, 0F, 0F, 0F); - ledBottom1 = new ModelRenderer(this, 0, 51); - ledBottom1.addBox(0F, 0F, 0F, 1, 1, 1); - ledBottom1.setRotationPoint(-5.5F, 22.9F, -0.5F); - ledBottom1.setTextureSize(64, 64); - ledBottom1.mirror = true; - setRotation(ledBottom1, 0F, 0F, 0F); - ledFront1 = new ModelRenderer(this, 0, 51); - ledFront1.addBox(0F, 0F, 0F, 1, 1, 1); - ledFront1.setRotationPoint(-5.5F, 15.5F, -7.9F); - ledFront1.setTextureSize(64, 64); - ledFront1.mirror = true; - setRotation(ledFront1, 0F, 0F, 0F); - ledFront2 = new ModelRenderer(this, 0, 51); - ledFront2.addBox(0F, 0F, 0F, 1, 1, 1); - ledFront2.setRotationPoint(4.5F, 15.5F, -7.9F); - ledFront2.setTextureSize(64, 64); - ledFront2.mirror = true; - setRotation(ledFront2, 0F, 0F, 0F); - ledRight2 = new ModelRenderer(this, 0, 51); - ledRight2.addBox(0F, 0F, 0F, 1, 1, 1); - ledRight2.setRotationPoint(6.9F, 15.5F, 4.5F); - ledRight2.setTextureSize(64, 64); - ledRight2.mirror = true; - setRotation(ledRight2, 0F, 0F, 0F); - ledRight1 = new ModelRenderer(this, 0, 51); - ledRight1.addBox(0F, 0F, 0F, 1, 1, 1); - ledRight1.setRotationPoint(6.9F, 15.5F, -5.5F); - ledRight1.setTextureSize(64, 64); - ledRight1.mirror = true; - setRotation(ledRight1, 0F, 0F, 0F); - ledLeft1 = new ModelRenderer(this, 0, 51); - ledLeft1.addBox(0F, 0F, 0F, 1, 1, 1); - ledLeft1.setRotationPoint(-7.9F, 15.5F, 4.5F); - ledLeft1.setTextureSize(64, 64); - ledLeft1.mirror = true; - setRotation(ledLeft1, 0F, 0F, 0F); - ledLeft2 = new ModelRenderer(this, 0, 51); - ledLeft2.addBox(0F, 0F, 0F, 1, 1, 1); - ledLeft2.setRotationPoint(-7.9F, 15.5F, -5.5F); - ledLeft2.setTextureSize(64, 64); - ledLeft2.mirror = true; - setRotation(ledLeft2, 0F, 0F, 0F); - - leds1 = new ModelRenderer[] {ledBottom1, ledTop1, ledFront1, ledBack1, ledLeft1, ledRight1}; - leds2 = new ModelRenderer[] {ledBottom2, ledTop2, ledFront2, ledBack2, ledLeft2, ledRight2}; - - ports = new ModelRenderer[] {portBottomToggle, portTopToggle, portFrontToggle, portBackToggle, portLeftToggle, portRightToggle}; - connectors = new ModelRenderer[] {connectorBottomToggle, connectorTopToggle, connectorFrontToggle, connectorBackToggle, connectorLeftToggle, connectorRightToggle}; - } + public ModelRenderer[] leds1; + public ModelRenderer[] leds2; - public void render(float size, EnergyCubeTier tier, TextureManager manager) - { - frame12.render(size); - frame11.render(size); - frame10.render(size); - frame9.render(size); - frame8.render(size); - frame7.render(size); - frame6.render(size); - frame5.render(size); - frame4.render(size); - frame3.render(size); - frame2.render(size); - frame1.render(size); - - corner8.render(size); - corner7.render(size); - corner6.render(size); - corner5.render(size); - corner4.render(size); - corner3.render(size); - corner2.render(size); - corner1.render(size); - - GL11.glPushMatrix(); - GL11.glScalef(1.0001F, 1.0001F, 1.0001F); - GL11.glTranslatef(0, -0.00011F, 0); - manager.bindTexture(RenderEnergyCube.resources.get(tier)); - MekanismRenderer.glowOn(); - - corner8.render(size); - corner7.render(size); - corner6.render(size); - corner5.render(size); - corner4.render(size); - corner3.render(size); - corner2.render(size); - corner1.render(size); - - MekanismRenderer.glowOff(); - GL11.glPopMatrix(); - } - - public void renderSide(float size, ForgeDirection side, IOState state, EnergyCubeTier tier, TextureManager renderer) - { - if(state != IOState.OFF) - { - connectors[side.ordinal()].render(size); - ports[side.ordinal()].render(size); - - if(state == IOState.OUTPUT) - { - MekanismRenderer.glowOn(); - renderer.bindTexture(RenderEnergyCube.resources.get(tier)); - - ports[side.ordinal()].render(size); - - MekanismRenderer.glowOff(); - } - } - - renderer.bindTexture(state == IOState.OUTPUT ? OVERLAY_ON : OVERLAY_OFF); - - if(state == IOState.OUTPUT) - { - MekanismRenderer.glowOn(); - } - - leds1[side.ordinal()].render(size); - leds2[side.ordinal()].render(size); - - if(state == IOState.OUTPUT) - { - MekanismRenderer.glowOff(); - } - } + public ModelRenderer[] ports; + public ModelRenderer[] connectors; - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + public ModelEnergyCube() { + textureWidth = 64; + textureHeight = 64; - public static class ModelEnergyCore extends ModelBase - { - private ModelRenderer cube; + frame12 = new ModelRenderer(this, 0, 0); + frame12.addBox(0F, 0F, 0F, 3, 10, 3); + frame12.setRotationPoint(-8F, 11F, 5F); + frame12.setTextureSize(64, 64); + frame12.mirror = true; + setRotation(frame12, 0F, 0F, 0F); + frame11 = new ModelRenderer(this, 0, 0); + frame11.addBox(0F, 0F, 0F, 3, 10, 3); + frame11.setRotationPoint(5F, 11F, -8F); + frame11.setTextureSize(64, 64); + frame11.mirror = true; + setRotation(frame11, 0F, 0F, 0F); + frame10 = new ModelRenderer(this, 0, 13); + frame10.addBox(0F, 0F, 0F, 10, 3, 3); + frame10.setRotationPoint(-5F, 21F, 5F); + frame10.setTextureSize(64, 64); + frame10.mirror = true; + setRotation(frame10, 0F, 0F, 0F); + frame9 = new ModelRenderer(this, 12, 0); + frame9.addBox(0F, 0F, 0F, 3, 3, 10); + frame9.setRotationPoint(5F, 21F, -5F); + frame9.setTextureSize(64, 64); + frame9.mirror = true; + setRotation(frame9, 0F, 0F, 0F); + frame8 = new ModelRenderer(this, 0, 13); + frame8.addBox(0F, 0F, 0F, 10, 3, 3); + frame8.setRotationPoint(-5F, 8F, 5F); + frame8.setTextureSize(64, 64); + frame8.mirror = true; + setRotation(frame8, 0F, 0F, 0F); + frame7 = new ModelRenderer(this, 0, 13); + frame7.addBox(0F, 0F, 0F, 10, 3, 3); + frame7.setRotationPoint(-5F, 21F, -8F); + frame7.setTextureSize(64, 64); + frame7.mirror = true; + setRotation(frame7, 0F, 0F, 0F); + frame6 = new ModelRenderer(this, 0, 0); + frame6.addBox(0F, 0F, 0F, 3, 10, 3); + frame6.setRotationPoint(5F, 11F, 5F); + frame6.setTextureSize(64, 64); + frame6.mirror = true; + setRotation(frame6, 0F, 0F, 0F); + frame5 = new ModelRenderer(this, 0, 0); + frame5.addBox(0F, 0F, 0F, 3, 10, 3); + frame5.setRotationPoint(-8F, 11F, -8F); + frame5.setTextureSize(64, 64); + frame5.mirror = true; + setRotation(frame5, 0F, 0F, 0F); + frame4 = new ModelRenderer(this, 12, 0); + frame4.addBox(0F, 0F, 0F, 3, 3, 10); + frame4.setRotationPoint(5F, 8F, -5F); + frame4.setTextureSize(64, 64); + frame4.mirror = true; + setRotation(frame4, 0F, 0F, 0F); + frame3 = new ModelRenderer(this, 12, 0); + frame3.addBox(0F, 0F, 0F, 3, 3, 10); + frame3.setRotationPoint(-8F, 21F, -5F); + frame3.setTextureSize(64, 64); + frame3.mirror = true; + setRotation(frame3, 0F, 0F, 0F); + frame2 = new ModelRenderer(this, 12, 0); + frame2.addBox(0F, 0F, 0F, 3, 3, 10); + frame2.setRotationPoint(-8F, 8F, -5F); + frame2.setTextureSize(64, 64); + frame2.mirror = true; + setRotation(frame2, 0F, 0F, 0F); + frame1 = new ModelRenderer(this, 0, 13); + frame1.addBox(0F, 0F, 0F, 10, 3, 3); + frame1.setRotationPoint(-5F, 8F, -8F); + frame1.setTextureSize(64, 64); + frame1.mirror = true; + setRotation(frame1, 0F, 0F, 0F); + corner8 = new ModelRenderer(this, 26, 13); + corner8.addBox(0F, 0F, 0F, 3, 3, 3); + corner8.setRotationPoint(5F, 21F, 5F); + corner8.setTextureSize(64, 64); + corner8.mirror = true; + setRotation(corner8, 0F, 0F, 0F); + corner7 = new ModelRenderer(this, 26, 13); + corner7.addBox(0F, 0F, 0F, 3, 3, 3); + corner7.setRotationPoint(5F, 21F, -8F); + corner7.setTextureSize(64, 64); + corner7.mirror = true; + setRotation(corner7, 0F, 0F, 0F); + corner6 = new ModelRenderer(this, 26, 13); + corner6.addBox(0F, 0F, 0F, 3, 3, 3); + corner6.setRotationPoint(-8F, 21F, 5F); + corner6.setTextureSize(64, 64); + corner6.mirror = true; + setRotation(corner6, 0F, 0F, 0F); + corner5 = new ModelRenderer(this, 26, 13); + corner5.addBox(0F, 0F, 0F, 3, 3, 3); + corner5.setRotationPoint(-8F, 21F, -8F); + corner5.setTextureSize(64, 64); + corner5.mirror = true; + setRotation(corner5, 0F, 0F, 0F); + corner4 = new ModelRenderer(this, 26, 13); + corner4.addBox(0F, 0F, 0F, 3, 3, 3); + corner4.setRotationPoint(5F, 8F, 5F); + corner4.setTextureSize(64, 64); + corner4.mirror = true; + setRotation(corner4, 0F, 0F, 0F); + corner3 = new ModelRenderer(this, 26, 13); + corner3.addBox(0F, 0F, 0F, 3, 3, 3); + corner3.setRotationPoint(5F, 8F, -8F); + corner3.setTextureSize(64, 64); + corner3.mirror = true; + setRotation(corner3, 0F, 0F, 0F); + corner2 = new ModelRenderer(this, 26, 13); + corner2.addBox(0F, 0F, 0F, 3, 3, 3); + corner2.setRotationPoint(-8F, 8F, 5F); + corner2.setTextureSize(64, 64); + corner2.mirror = true; + setRotation(corner2, 0F, 0F, 0F); + corner1 = new ModelRenderer(this, 26, 13); + corner1.addBox(0F, 0F, 0F, 3, 3, 3); + corner1.setRotationPoint(-8F, 8F, -8F); + corner1.setTextureSize(64, 64); + corner1.mirror = true; + setRotation(corner1, 0F, 0F, 0F); + connectorBackToggle = new ModelRenderer(this, 38, 16); + connectorBackToggle.addBox(0F, 0F, 0F, 10, 6, 1); + connectorBackToggle.setRotationPoint(-5F, 13F, 6F); + connectorBackToggle.setTextureSize(64, 64); + connectorBackToggle.mirror = true; + setRotation(connectorBackToggle, 0F, 0F, 0F); + connectorRightToggle = new ModelRenderer(this, 38, 0); + connectorRightToggle.addBox(0F, 0F, 0F, 1, 6, 10); + connectorRightToggle.setRotationPoint(6F, 13F, -5F); + connectorRightToggle.setTextureSize(64, 64); + connectorRightToggle.mirror = true; + setRotation(connectorRightToggle, 0F, 0F, 0F); + connectorBottomToggle = new ModelRenderer(this, 0, 19); + connectorBottomToggle.addBox(0F, 0F, 0F, 10, 1, 6); + connectorBottomToggle.setRotationPoint(-5F, 22F, -3F); + connectorBottomToggle.setTextureSize(64, 64); + connectorBottomToggle.mirror = true; + setRotation(connectorBottomToggle, 0F, 0F, 0F); + connectorLeftToggle = new ModelRenderer(this, 38, 0); + connectorLeftToggle.addBox(0F, 0F, 0F, 1, 6, 10); + connectorLeftToggle.setRotationPoint(-7F, 13F, -5F); + connectorLeftToggle.setTextureSize(64, 64); + connectorLeftToggle.mirror = true; + setRotation(connectorLeftToggle, 0F, 0F, 0F); + connectorFrontToggle = new ModelRenderer(this, 38, 16); + connectorFrontToggle.addBox(0F, 0F, 0F, 10, 6, 1); + connectorFrontToggle.setRotationPoint(-5F, 13F, -7F); + connectorFrontToggle.setTextureSize(64, 64); + connectorFrontToggle.mirror = true; + setRotation(connectorFrontToggle, 0F, 0F, 0F); + connectorTopToggle = new ModelRenderer(this, 0, 19); + connectorTopToggle.addBox(0F, 0F, 0F, 10, 1, 6); + connectorTopToggle.setRotationPoint(-5F, 9F, -3F); + connectorTopToggle.setTextureSize(64, 64); + connectorTopToggle.mirror = true; + setRotation(connectorTopToggle, 0F, 0F, 0F); + portBackToggle = new ModelRenderer(this, 18, 35); + portBackToggle.addBox(0F, 0F, 0F, 8, 8, 1); + portBackToggle.setRotationPoint(-4F, 12F, 7F); + portBackToggle.setTextureSize(64, 64); + portBackToggle.mirror = true; + setRotation(portBackToggle, 0F, 0F, 0F); + portBottomToggle = new ModelRenderer(this, 0, 26); + portBottomToggle.addBox(0F, 0F, 0F, 8, 1, 8); + portBottomToggle.setRotationPoint(-4F, 23F, -4F); + portBottomToggle.setTextureSize(64, 64); + portBottomToggle.mirror = true; + setRotation(portBottomToggle, 0F, 0F, 0F); + portFrontToggle = new ModelRenderer(this, 18, 35); + portFrontToggle.addBox(0F, 0F, 0F, 8, 8, 1); + portFrontToggle.setRotationPoint(-4F, 12F, -8F); + portFrontToggle.setTextureSize(64, 64); + portFrontToggle.mirror = true; + setRotation(portFrontToggle, 0F, 0F, 0F); + portLeftToggle = new ModelRenderer(this, 0, 35); + portLeftToggle.addBox(0F, 0F, 0F, 1, 8, 8); + portLeftToggle.setRotationPoint(-8F, 12F, -4F); + portLeftToggle.setTextureSize(64, 64); + portLeftToggle.mirror = true; + setRotation(portLeftToggle, 0F, 0F, 0F); + portRightToggle = new ModelRenderer(this, 0, 35); + portRightToggle.addBox(0F, 0F, 0F, 1, 8, 8); + portRightToggle.setRotationPoint(7F, 12F, -4F); + portRightToggle.setTextureSize(64, 64); + portRightToggle.mirror = true; + setRotation(portRightToggle, 0F, 0F, 0F); + portTopToggle = new ModelRenderer(this, 0, 26); + portTopToggle.addBox(0F, 0F, 0F, 8, 1, 8); + portTopToggle.setRotationPoint(-4F, 8F, -4F); + portTopToggle.setTextureSize(64, 64); + portTopToggle.mirror = true; + setRotation(portTopToggle, 0F, 0F, 0F); + ledTop1 = new ModelRenderer(this, 0, 51); + ledTop1.addBox(0F, 0F, 0F, 1, 1, 1); + ledTop1.setRotationPoint(-5.5F, 8.1F, -0.5F); + ledTop1.setTextureSize(64, 64); + ledTop1.mirror = true; + setRotation(ledTop1, 0F, 0F, 0F); + ledTop2 = new ModelRenderer(this, 0, 51); + ledTop2.addBox(0F, 0F, 0F, 1, 1, 1); + ledTop2.setRotationPoint(4.5F, 8.1F, -0.5F); + ledTop2.setTextureSize(64, 64); + ledTop2.mirror = true; + setRotation(ledTop2, 0F, 0F, 0F); + ledBack1 = new ModelRenderer(this, 0, 51); + ledBack1.addBox(0F, 0F, 0F, 1, 1, 1); + ledBack1.setRotationPoint(-5.5F, 15.5F, 6.9F); + ledBack1.setTextureSize(64, 64); + ledBack1.mirror = true; + setRotation(ledBack1, 0F, 0F, 0F); + ledBack2 = new ModelRenderer(this, 0, 51); + ledBack2.addBox(0F, 0F, 0F, 1, 1, 1); + ledBack2.setRotationPoint(4.5F, 15.5F, 6.9F); + ledBack2.setTextureSize(64, 64); + ledBack2.mirror = true; + setRotation(ledBack2, 0F, 0F, 0F); + ledBottom2 = new ModelRenderer(this, 0, 51); + ledBottom2.addBox(0F, 0F, 0F, 1, 1, 1); + ledBottom2.setRotationPoint(4.5F, 22.9F, -0.5F); + ledBottom2.setTextureSize(64, 64); + ledBottom2.mirror = true; + setRotation(ledBottom2, 0F, 0F, 0F); + ledBottom1 = new ModelRenderer(this, 0, 51); + ledBottom1.addBox(0F, 0F, 0F, 1, 1, 1); + ledBottom1.setRotationPoint(-5.5F, 22.9F, -0.5F); + ledBottom1.setTextureSize(64, 64); + ledBottom1.mirror = true; + setRotation(ledBottom1, 0F, 0F, 0F); + ledFront1 = new ModelRenderer(this, 0, 51); + ledFront1.addBox(0F, 0F, 0F, 1, 1, 1); + ledFront1.setRotationPoint(-5.5F, 15.5F, -7.9F); + ledFront1.setTextureSize(64, 64); + ledFront1.mirror = true; + setRotation(ledFront1, 0F, 0F, 0F); + ledFront2 = new ModelRenderer(this, 0, 51); + ledFront2.addBox(0F, 0F, 0F, 1, 1, 1); + ledFront2.setRotationPoint(4.5F, 15.5F, -7.9F); + ledFront2.setTextureSize(64, 64); + ledFront2.mirror = true; + setRotation(ledFront2, 0F, 0F, 0F); + ledRight2 = new ModelRenderer(this, 0, 51); + ledRight2.addBox(0F, 0F, 0F, 1, 1, 1); + ledRight2.setRotationPoint(6.9F, 15.5F, 4.5F); + ledRight2.setTextureSize(64, 64); + ledRight2.mirror = true; + setRotation(ledRight2, 0F, 0F, 0F); + ledRight1 = new ModelRenderer(this, 0, 51); + ledRight1.addBox(0F, 0F, 0F, 1, 1, 1); + ledRight1.setRotationPoint(6.9F, 15.5F, -5.5F); + ledRight1.setTextureSize(64, 64); + ledRight1.mirror = true; + setRotation(ledRight1, 0F, 0F, 0F); + ledLeft1 = new ModelRenderer(this, 0, 51); + ledLeft1.addBox(0F, 0F, 0F, 1, 1, 1); + ledLeft1.setRotationPoint(-7.9F, 15.5F, 4.5F); + ledLeft1.setTextureSize(64, 64); + ledLeft1.mirror = true; + setRotation(ledLeft1, 0F, 0F, 0F); + ledLeft2 = new ModelRenderer(this, 0, 51); + ledLeft2.addBox(0F, 0F, 0F, 1, 1, 1); + ledLeft2.setRotationPoint(-7.9F, 15.5F, -5.5F); + ledLeft2.setTextureSize(64, 64); + ledLeft2.mirror = true; + setRotation(ledLeft2, 0F, 0F, 0F); - public ModelEnergyCore() - { - textureWidth = 32; - textureHeight = 32; + leds1 = new ModelRenderer[] { ledBottom1, ledTop1, ledFront1, + ledBack1, ledLeft1, ledRight1 }; + leds2 = new ModelRenderer[] { ledBottom2, ledTop2, ledFront2, + ledBack2, ledLeft2, ledRight2 }; - cube = new ModelRenderer(this, 0, 0); - cube.addBox(-8, -8, -8, 16, 16, 16); - cube.setTextureSize(32, 32); - cube.mirror = true; - } + ports = new ModelRenderer[] { portBottomToggle, portTopToggle, portFrontToggle, + portBackToggle, portLeftToggle, portRightToggle }; + connectors = new ModelRenderer[] { connectorBottomToggle, connectorTopToggle, + connectorFrontToggle, connectorBackToggle, + connectorLeftToggle, connectorRightToggle }; + } - public void render(float size) - { - cube.render(0.0625F); - } - } + public void render(float size, EnergyCubeTier tier, TextureManager manager) { + frame12.render(size); + frame11.render(size); + frame10.render(size); + frame9.render(size); + frame8.render(size); + frame7.render(size); + frame6.render(size); + frame5.render(size); + frame4.render(size); + frame3.render(size); + frame2.render(size); + frame1.render(size); + + corner8.render(size); + corner7.render(size); + corner6.render(size); + corner5.render(size); + corner4.render(size); + corner3.render(size); + corner2.render(size); + corner1.render(size); + + GL11.glPushMatrix(); + GL11.glScalef(1.0001F, 1.0001F, 1.0001F); + GL11.glTranslatef(0, -0.00011F, 0); + manager.bindTexture(RenderEnergyCube.resources.get(tier)); + MekanismRenderer.glowOn(); + + corner8.render(size); + corner7.render(size); + corner6.render(size); + corner5.render(size); + corner4.render(size); + corner3.render(size); + corner2.render(size); + corner1.render(size); + + MekanismRenderer.glowOff(); + GL11.glPopMatrix(); + } + + public void renderSide( + float size, + ForgeDirection side, + IOState state, + EnergyCubeTier tier, + TextureManager renderer + ) { + if (state != IOState.OFF) { + connectors[side.ordinal()].render(size); + ports[side.ordinal()].render(size); + + if (state == IOState.OUTPUT) { + MekanismRenderer.glowOn(); + renderer.bindTexture(RenderEnergyCube.resources.get(tier)); + + ports[side.ordinal()].render(size); + + MekanismRenderer.glowOff(); + } + } + + renderer.bindTexture(state == IOState.OUTPUT ? OVERLAY_ON : OVERLAY_OFF); + + if (state == IOState.OUTPUT) { + MekanismRenderer.glowOn(); + } + + leds1[side.ordinal()].render(size); + leds2[side.ordinal()].render(size); + + if (state == IOState.OUTPUT) { + MekanismRenderer.glowOff(); + } + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } + + public static class ModelEnergyCore extends ModelBase { + private ModelRenderer cube; + + public ModelEnergyCore() { + textureWidth = 32; + textureHeight = 32; + + cube = new ModelRenderer(this, 0, 0); + cube.addBox(-8, -8, -8, 16, 16, 16); + cube.setTextureSize(32, 32); + cube.mirror = true; + } + + public void render(float size) { + cube.render(0.0625F); + } + } } diff --git a/src/main/java/mekanism/client/model/ModelFlamethrower.java b/src/main/java/mekanism/client/model/ModelFlamethrower.java index c6e72f986..8e982f1ea 100644 --- a/src/main/java/mekanism/client/model/ModelFlamethrower.java +++ b/src/main/java/mekanism/client/model/ModelFlamethrower.java @@ -1,214 +1,210 @@ package mekanism.client.model; -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; @SideOnly(Side.CLIENT) -public class ModelFlamethrower extends ModelBase -{ - ModelRenderer RingButtom; - ModelRenderer RingTop; - ModelRenderer Ring; - ModelRenderer Axle; - ModelRenderer AxleBLeft; - ModelRenderer AxleBRight; - ModelRenderer AxleTRight; - ModelRenderer AxleTLeft; - ModelRenderer Grasp; - ModelRenderer GraspRod; - ModelRenderer SupportCentre; - ModelRenderer SupportFront; - ModelRenderer SupportRear; - ModelRenderer LargeBarrel; - ModelRenderer LargeBarrelDecor; - ModelRenderer LargeBarrelDecor2; - ModelRenderer Barrel; - ModelRenderer BarrelRing; - ModelRenderer BarrelRing2; - ModelRenderer Flame; - ModelRenderer FlameStrut; - ModelRenderer HydrogenDecor; - ModelRenderer Hydrogen; +public class ModelFlamethrower extends ModelBase { + ModelRenderer RingButtom; + ModelRenderer RingTop; + ModelRenderer Ring; + ModelRenderer Axle; + ModelRenderer AxleBLeft; + ModelRenderer AxleBRight; + ModelRenderer AxleTRight; + ModelRenderer AxleTLeft; + ModelRenderer Grasp; + ModelRenderer GraspRod; + ModelRenderer SupportCentre; + ModelRenderer SupportFront; + ModelRenderer SupportRear; + ModelRenderer LargeBarrel; + ModelRenderer LargeBarrelDecor; + ModelRenderer LargeBarrelDecor2; + ModelRenderer Barrel; + ModelRenderer BarrelRing; + ModelRenderer BarrelRing2; + ModelRenderer Flame; + ModelRenderer FlameStrut; + ModelRenderer HydrogenDecor; + ModelRenderer Hydrogen; - public ModelFlamethrower() - { - textureWidth = 64; - textureHeight = 64; + public ModelFlamethrower() { + textureWidth = 64; + textureHeight = 64; - RingButtom = new ModelRenderer(this, 19, 14); - RingButtom.addBox(0F, 0F, 0F, 3, 1, 3); - RingButtom.setRotationPoint(-2F, 19.5F, 1.5F); - RingButtom.setTextureSize(64, 64); - RingButtom.mirror = true; - setRotation(RingButtom, 0F, 0F, 0F); - RingTop = new ModelRenderer(this, 19, 14); - RingTop.addBox(0F, 0F, 0F, 3, 1, 3); - RingTop.setRotationPoint(-2F, 13.5F, 1.466667F); - RingTop.setTextureSize(64, 64); - RingTop.mirror = true; - setRotation(RingTop, 0F, 0F, 0F); - Ring = new ModelRenderer(this, 0, 14); - Ring.addBox(0F, 0F, 0F, 5, 6, 4); - Ring.setRotationPoint(-3F, 14F, 1F); - Ring.setTextureSize(64, 64); - Ring.mirror = true; - setRotation(Ring, 0F, 0F, 0F); - Axle = new ModelRenderer(this, 32, 12); - Axle.addBox(0F, 0F, 0F, 4, 4, 7); - Axle.setRotationPoint(-2.5F, 15F, -6.5F); - Axle.setTextureSize(64, 64); - Axle.mirror = true; - setRotation(Axle, 0F, 0F, 0F); - AxleBLeft = new ModelRenderer(this, 0, 25); - AxleBLeft.addBox(-0.5F, -0.5F, 0F, 1, 1, 8); - AxleBLeft.setRotationPoint(-2F, 19F, -7F); - AxleBLeft.setTextureSize(64, 64); - AxleBLeft.mirror = true; - setRotation(AxleBLeft, 0F, 0F, 0.2094395F); - AxleBRight = new ModelRenderer(this, 0, 25); - AxleBRight.addBox(-0.5F, -0.5F, 0F, 1, 1, 8); - AxleBRight.setRotationPoint(1F, 19F, -7F); - AxleBRight.setTextureSize(64, 64); - AxleBRight.mirror = true; - setRotation(AxleBRight, 0.0174533F, 0F, -0.2094395F); - AxleTRight = new ModelRenderer(this, 0, 25); - AxleTRight.addBox(-0.5F, -0.5F, 0F, 1, 1, 8); - AxleTRight.setRotationPoint(1F, 15F, -7F); - AxleTRight.setTextureSize(64, 64); - AxleTRight.mirror = true; - setRotation(AxleTRight, 0F, 0F, 0.2094395F); - AxleTLeft = new ModelRenderer(this, 0, 25); - AxleTLeft.addBox(-0.5F, -0.5F, 0F, 1, 1, 8); - AxleTLeft.setRotationPoint(-2F, 15F, -7F); - AxleTLeft.setTextureSize(64, 64); - AxleTLeft.mirror = true; - setRotation(AxleTLeft, 0F, 0F, -0.2094395F); - Grasp = new ModelRenderer(this, 24, 19); - Grasp.addBox(0F, 0F, 0F, 2, 1, 1); - Grasp.setRotationPoint(-1.5F, 13F, -1.1F); - Grasp.setTextureSize(64, 64); - Grasp.mirror = true; - setRotation(Grasp, 0.7807508F, 0F, 0F); - Grasp.mirror = false; - GraspRod = new ModelRenderer(this, 19, 19); - GraspRod.addBox(0F, 0F, 0F, 1, 3, 1); - GraspRod.setRotationPoint(-1F, 13F, -1F); - GraspRod.setTextureSize(64, 64); - GraspRod.mirror = true; - setRotation(GraspRod, 0.2230717F, 0F, 0F); - SupportCentre = new ModelRenderer(this, 0, 40); - SupportCentre.addBox(0F, 0F, 0F, 2, 1, 6); - SupportCentre.setRotationPoint(-1.5F, 12.4F, 6.6F); - SupportCentre.setTextureSize(64, 64); - SupportCentre.mirror = true; - setRotation(SupportCentre, -0.1115358F, 0F, 0F); - SupportFront = new ModelRenderer(this, 19, 24); - SupportFront.addBox(0F, 0F, 0F, 1, 1, 4); - SupportFront.setRotationPoint(-1F, 13.1F, 12.5F); - SupportFront.setTextureSize(64, 64); - SupportFront.mirror = true; - setRotation(SupportFront, -1.226894F, 0F, 0F); - SupportRear = new ModelRenderer(this, 0, 35); - SupportRear.addBox(0F, 0F, 0F, 3, 1, 3); - SupportRear.setRotationPoint(-2F, 14F, 4F); - SupportRear.setTextureSize(64, 64); - SupportRear.mirror = true; - setRotation(SupportRear, 0.5424979F, 0F, 0F); - LargeBarrel = new ModelRenderer(this, 19, 48); - LargeBarrel.addBox(0F, 0F, 0F, 2, 3, 7); - LargeBarrel.setRotationPoint(-1.5F, 16F, 4F); - LargeBarrel.setTextureSize(64, 64); - LargeBarrel.mirror = true; - setRotation(LargeBarrel, 0F, 0F, 0F); - LargeBarrelDecor = new ModelRenderer(this, 0, 48); - LargeBarrelDecor.addBox(0F, 0F, 0F, 3, 3, 6); - LargeBarrelDecor.setRotationPoint(-2F, 15F, 4F); - LargeBarrelDecor.setTextureSize(64, 64); - LargeBarrelDecor.mirror = true; - setRotation(LargeBarrelDecor, -0.1115358F, 0F, 0F); - LargeBarrelDecor2 = new ModelRenderer(this, 17, 41); - LargeBarrelDecor2.addBox(0F, 0F, 0F, 4, 2, 4); - LargeBarrelDecor2.setRotationPoint(-2.5F, 16F, 4F); - LargeBarrelDecor2.setTextureSize(64, 64); - LargeBarrelDecor2.mirror = true; - setRotation(LargeBarrelDecor2, 0F, 0F, 0F); - Barrel = new ModelRenderer(this, 19, 30); - Barrel.addBox(0F, 0F, 0F, 2, 2, 8); - Barrel.setRotationPoint(-1.5F, 16.5F, 11F); - Barrel.setTextureSize(64, 64); - Barrel.mirror = true; - setRotation(Barrel, 0F, 0F, 0F); - BarrelRing = new ModelRenderer(this, 30, 25); - BarrelRing.addBox(0F, 0F, 0F, 3, 3, 1); - BarrelRing.setRotationPoint(-2F, 16F, 13F); - BarrelRing.setTextureSize(64, 64); - BarrelRing.mirror = true; - setRotation(BarrelRing, 0F, 0F, 0F); - BarrelRing2 = new ModelRenderer(this, 30, 25); - BarrelRing2.addBox(0F, 0F, 0F, 3, 3, 1); - BarrelRing2.setRotationPoint(-2F, 16F, 17F); - BarrelRing2.setTextureSize(64, 64); - BarrelRing2.mirror = true; - setRotation(BarrelRing2, 0F, 0F, 0F); - Flame = new ModelRenderer(this, 38, 0); - Flame.addBox(0F, 0F, 0F, 1, 1, 2); - Flame.setRotationPoint(-1F, 19.5F, 19F); - Flame.setTextureSize(64, 64); - Flame.mirror = true; - setRotation(Flame, 0.7063936F, 0F, 0F); - FlameStrut = new ModelRenderer(this, 27, 0); - FlameStrut.addBox(0F, 0F, 0F, 2, 1, 3); - FlameStrut.setRotationPoint(-1.466667F, 18.5F, 17F); - FlameStrut.setTextureSize(64, 64); - FlameStrut.mirror = true; - setRotation(FlameStrut, -0.2602503F, 0F, 0F); - HydrogenDecor = new ModelRenderer(this, 27, 5); - HydrogenDecor.addBox(0F, 0F, 0F, 3, 1, 5); - HydrogenDecor.setRotationPoint(1.5F, 15.66667F, -4.933333F); - HydrogenDecor.setTextureSize(64, 64); - HydrogenDecor.mirror = true; - setRotation(HydrogenDecor, 0F, 0F, 0.4438713F); - Hydrogen = new ModelRenderer(this, 0, 0); - Hydrogen.addBox(0F, 0F, 0F, 3, 3, 10); - Hydrogen.setRotationPoint(1.5F, 16F, -5.5F); - Hydrogen.setTextureSize(64, 64); - Hydrogen.mirror = true; - setRotation(Hydrogen, 0F, 0F, 0.4438713F); - } + RingButtom = new ModelRenderer(this, 19, 14); + RingButtom.addBox(0F, 0F, 0F, 3, 1, 3); + RingButtom.setRotationPoint(-2F, 19.5F, 1.5F); + RingButtom.setTextureSize(64, 64); + RingButtom.mirror = true; + setRotation(RingButtom, 0F, 0F, 0F); + RingTop = new ModelRenderer(this, 19, 14); + RingTop.addBox(0F, 0F, 0F, 3, 1, 3); + RingTop.setRotationPoint(-2F, 13.5F, 1.466667F); + RingTop.setTextureSize(64, 64); + RingTop.mirror = true; + setRotation(RingTop, 0F, 0F, 0F); + Ring = new ModelRenderer(this, 0, 14); + Ring.addBox(0F, 0F, 0F, 5, 6, 4); + Ring.setRotationPoint(-3F, 14F, 1F); + Ring.setTextureSize(64, 64); + Ring.mirror = true; + setRotation(Ring, 0F, 0F, 0F); + Axle = new ModelRenderer(this, 32, 12); + Axle.addBox(0F, 0F, 0F, 4, 4, 7); + Axle.setRotationPoint(-2.5F, 15F, -6.5F); + Axle.setTextureSize(64, 64); + Axle.mirror = true; + setRotation(Axle, 0F, 0F, 0F); + AxleBLeft = new ModelRenderer(this, 0, 25); + AxleBLeft.addBox(-0.5F, -0.5F, 0F, 1, 1, 8); + AxleBLeft.setRotationPoint(-2F, 19F, -7F); + AxleBLeft.setTextureSize(64, 64); + AxleBLeft.mirror = true; + setRotation(AxleBLeft, 0F, 0F, 0.2094395F); + AxleBRight = new ModelRenderer(this, 0, 25); + AxleBRight.addBox(-0.5F, -0.5F, 0F, 1, 1, 8); + AxleBRight.setRotationPoint(1F, 19F, -7F); + AxleBRight.setTextureSize(64, 64); + AxleBRight.mirror = true; + setRotation(AxleBRight, 0.0174533F, 0F, -0.2094395F); + AxleTRight = new ModelRenderer(this, 0, 25); + AxleTRight.addBox(-0.5F, -0.5F, 0F, 1, 1, 8); + AxleTRight.setRotationPoint(1F, 15F, -7F); + AxleTRight.setTextureSize(64, 64); + AxleTRight.mirror = true; + setRotation(AxleTRight, 0F, 0F, 0.2094395F); + AxleTLeft = new ModelRenderer(this, 0, 25); + AxleTLeft.addBox(-0.5F, -0.5F, 0F, 1, 1, 8); + AxleTLeft.setRotationPoint(-2F, 15F, -7F); + AxleTLeft.setTextureSize(64, 64); + AxleTLeft.mirror = true; + setRotation(AxleTLeft, 0F, 0F, -0.2094395F); + Grasp = new ModelRenderer(this, 24, 19); + Grasp.addBox(0F, 0F, 0F, 2, 1, 1); + Grasp.setRotationPoint(-1.5F, 13F, -1.1F); + Grasp.setTextureSize(64, 64); + Grasp.mirror = true; + setRotation(Grasp, 0.7807508F, 0F, 0F); + Grasp.mirror = false; + GraspRod = new ModelRenderer(this, 19, 19); + GraspRod.addBox(0F, 0F, 0F, 1, 3, 1); + GraspRod.setRotationPoint(-1F, 13F, -1F); + GraspRod.setTextureSize(64, 64); + GraspRod.mirror = true; + setRotation(GraspRod, 0.2230717F, 0F, 0F); + SupportCentre = new ModelRenderer(this, 0, 40); + SupportCentre.addBox(0F, 0F, 0F, 2, 1, 6); + SupportCentre.setRotationPoint(-1.5F, 12.4F, 6.6F); + SupportCentre.setTextureSize(64, 64); + SupportCentre.mirror = true; + setRotation(SupportCentre, -0.1115358F, 0F, 0F); + SupportFront = new ModelRenderer(this, 19, 24); + SupportFront.addBox(0F, 0F, 0F, 1, 1, 4); + SupportFront.setRotationPoint(-1F, 13.1F, 12.5F); + SupportFront.setTextureSize(64, 64); + SupportFront.mirror = true; + setRotation(SupportFront, -1.226894F, 0F, 0F); + SupportRear = new ModelRenderer(this, 0, 35); + SupportRear.addBox(0F, 0F, 0F, 3, 1, 3); + SupportRear.setRotationPoint(-2F, 14F, 4F); + SupportRear.setTextureSize(64, 64); + SupportRear.mirror = true; + setRotation(SupportRear, 0.5424979F, 0F, 0F); + LargeBarrel = new ModelRenderer(this, 19, 48); + LargeBarrel.addBox(0F, 0F, 0F, 2, 3, 7); + LargeBarrel.setRotationPoint(-1.5F, 16F, 4F); + LargeBarrel.setTextureSize(64, 64); + LargeBarrel.mirror = true; + setRotation(LargeBarrel, 0F, 0F, 0F); + LargeBarrelDecor = new ModelRenderer(this, 0, 48); + LargeBarrelDecor.addBox(0F, 0F, 0F, 3, 3, 6); + LargeBarrelDecor.setRotationPoint(-2F, 15F, 4F); + LargeBarrelDecor.setTextureSize(64, 64); + LargeBarrelDecor.mirror = true; + setRotation(LargeBarrelDecor, -0.1115358F, 0F, 0F); + LargeBarrelDecor2 = new ModelRenderer(this, 17, 41); + LargeBarrelDecor2.addBox(0F, 0F, 0F, 4, 2, 4); + LargeBarrelDecor2.setRotationPoint(-2.5F, 16F, 4F); + LargeBarrelDecor2.setTextureSize(64, 64); + LargeBarrelDecor2.mirror = true; + setRotation(LargeBarrelDecor2, 0F, 0F, 0F); + Barrel = new ModelRenderer(this, 19, 30); + Barrel.addBox(0F, 0F, 0F, 2, 2, 8); + Barrel.setRotationPoint(-1.5F, 16.5F, 11F); + Barrel.setTextureSize(64, 64); + Barrel.mirror = true; + setRotation(Barrel, 0F, 0F, 0F); + BarrelRing = new ModelRenderer(this, 30, 25); + BarrelRing.addBox(0F, 0F, 0F, 3, 3, 1); + BarrelRing.setRotationPoint(-2F, 16F, 13F); + BarrelRing.setTextureSize(64, 64); + BarrelRing.mirror = true; + setRotation(BarrelRing, 0F, 0F, 0F); + BarrelRing2 = new ModelRenderer(this, 30, 25); + BarrelRing2.addBox(0F, 0F, 0F, 3, 3, 1); + BarrelRing2.setRotationPoint(-2F, 16F, 17F); + BarrelRing2.setTextureSize(64, 64); + BarrelRing2.mirror = true; + setRotation(BarrelRing2, 0F, 0F, 0F); + Flame = new ModelRenderer(this, 38, 0); + Flame.addBox(0F, 0F, 0F, 1, 1, 2); + Flame.setRotationPoint(-1F, 19.5F, 19F); + Flame.setTextureSize(64, 64); + Flame.mirror = true; + setRotation(Flame, 0.7063936F, 0F, 0F); + FlameStrut = new ModelRenderer(this, 27, 0); + FlameStrut.addBox(0F, 0F, 0F, 2, 1, 3); + FlameStrut.setRotationPoint(-1.466667F, 18.5F, 17F); + FlameStrut.setTextureSize(64, 64); + FlameStrut.mirror = true; + setRotation(FlameStrut, -0.2602503F, 0F, 0F); + HydrogenDecor = new ModelRenderer(this, 27, 5); + HydrogenDecor.addBox(0F, 0F, 0F, 3, 1, 5); + HydrogenDecor.setRotationPoint(1.5F, 15.66667F, -4.933333F); + HydrogenDecor.setTextureSize(64, 64); + HydrogenDecor.mirror = true; + setRotation(HydrogenDecor, 0F, 0F, 0.4438713F); + Hydrogen = new ModelRenderer(this, 0, 0); + Hydrogen.addBox(0F, 0F, 0F, 3, 3, 10); + Hydrogen.setRotationPoint(1.5F, 16F, -5.5F); + Hydrogen.setTextureSize(64, 64); + Hydrogen.mirror = true; + setRotation(Hydrogen, 0F, 0F, 0.4438713F); + } - public void render(float size) - { - RingButtom.render(size); - RingTop.render(size); - Ring.render(size); - Axle.render(size); - AxleBLeft.render(size); - AxleBRight.render(size); - AxleTRight.render(size); - AxleTLeft.render(size); - Grasp.render(size); - GraspRod.render(size); - SupportCentre.render(size); - SupportFront.render(size); - SupportRear.render(size); - LargeBarrel.render(size); - LargeBarrelDecor.render(size); - LargeBarrelDecor2.render(size); - Barrel.render(size); - BarrelRing.render(size); - BarrelRing2.render(size); - Flame.render(size); - FlameStrut.render(size); - HydrogenDecor.render(size); - Hydrogen.render(size); - } + public void render(float size) { + RingButtom.render(size); + RingTop.render(size); + Ring.render(size); + Axle.render(size); + AxleBLeft.render(size); + AxleBRight.render(size); + AxleTRight.render(size); + AxleTLeft.render(size); + Grasp.render(size); + GraspRod.render(size); + SupportCentre.render(size); + SupportFront.render(size); + SupportRear.render(size); + LargeBarrel.render(size); + LargeBarrelDecor.render(size); + LargeBarrelDecor2.render(size); + Barrel.render(size); + BarrelRing.render(size); + BarrelRing2.render(size); + Flame.render(size); + FlameStrut.render(size); + HydrogenDecor.render(size); + Hydrogen.render(size); + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/mekanism/client/model/ModelFluidTank.java b/src/main/java/mekanism/client/model/ModelFluidTank.java index ffc7d375d..6fe1ca23b 100644 --- a/src/main/java/mekanism/client/model/ModelFluidTank.java +++ b/src/main/java/mekanism/client/model/ModelFluidTank.java @@ -1,115 +1,111 @@ package mekanism.client.model; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.render.MekanismRenderer; import mekanism.common.Tier.FluidTankTier; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class ModelFluidTank extends ModelBase -{ - ModelRenderer Base; - ModelRenderer PoleFL; - ModelRenderer PoleLB; - ModelRenderer PoleBR; - ModelRenderer PoleRF; - ModelRenderer Top; - ModelRenderer FrontGlass; - ModelRenderer BackGlass; - ModelRenderer RightGlass; - ModelRenderer LeftGlass; +public class ModelFluidTank extends ModelBase { + ModelRenderer Base; + ModelRenderer PoleFL; + ModelRenderer PoleLB; + ModelRenderer PoleBR; + ModelRenderer PoleRF; + ModelRenderer Top; + ModelRenderer FrontGlass; + ModelRenderer BackGlass; + ModelRenderer RightGlass; + ModelRenderer LeftGlass; - public ModelFluidTank() - { - textureWidth = 128; - textureHeight = 128; + public ModelFluidTank() { + textureWidth = 128; + textureHeight = 128; - Base = new ModelRenderer(this, 0, 0); - Base.addBox(0F, 0F, 0F, 12, 1, 12); - Base.setRotationPoint(-6F, 23F, -6F); - Base.setTextureSize(128, 128); - Base.mirror = true; - setRotation(Base, 0F, 0F, 0F); - PoleFL = new ModelRenderer(this, 48, 0); - PoleFL.addBox(0F, 0F, 0F, 1, 14, 1); - PoleFL.setRotationPoint(5F, 9F, -6F); - PoleFL.setTextureSize(128, 128); - PoleFL.mirror = true; - setRotation(PoleFL, 0F, 0F, 0F); - PoleLB = new ModelRenderer(this, 48, 0); - PoleLB.addBox(0F, 0F, 0F, 1, 14, 1); - PoleLB.setRotationPoint(5F, 9F, 5F); - PoleLB.setTextureSize(128, 128); - PoleLB.mirror = true; - setRotation(PoleLB, 0F, 0F, 0F); - PoleBR = new ModelRenderer(this, 48, 0); - PoleBR.addBox(0F, 0F, 0F, 1, 14, 1); - PoleBR.setRotationPoint(-6F, 9F, 5F); - PoleBR.setTextureSize(128, 128); - PoleBR.mirror = true; - setRotation(PoleBR, 0F, 0F, 0F); - PoleRF = new ModelRenderer(this, 48, 0); - PoleRF.addBox(0F, 0F, 0F, 1, 14, 1); - PoleRF.setRotationPoint(-6F, 9F, -6F); - PoleRF.setTextureSize(128, 128); - PoleRF.mirror = true; - setRotation(PoleRF, 0F, 0F, 0F); - Top = new ModelRenderer(this, 0, 0); - Top.addBox(0F, 0F, 0F, 12, 1, 12); - Top.setRotationPoint(-6F, 8F, -6F); - Top.setTextureSize(128, 128); - Top.mirror = true; - setRotation(Top, 0F, 0F, 0F); - FrontGlass = new ModelRenderer(this, 0, 13); - FrontGlass.addBox(0F, 0F, 0F, 10, 14, 1); - FrontGlass.setRotationPoint(-5F, 9F, -6F); - FrontGlass.setTextureSize(128, 128); - FrontGlass.mirror = true; - setRotation(FrontGlass, 0F, 0F, 0F); - BackGlass = new ModelRenderer(this, 0, 28); - BackGlass.addBox(0F, 0F, 3F, 10, 14, 1); - BackGlass.setRotationPoint(-5F, 9F, 2F); - BackGlass.setTextureSize(128, 128); - BackGlass.mirror = true; - setRotation(BackGlass, 0F, 0F, 0F); - RightGlass = new ModelRenderer(this, 22, 13); - RightGlass.addBox(0F, 0F, 0F, 1, 14, 10); - RightGlass.setRotationPoint(-6F, 9F, -5F); - RightGlass.setTextureSize(128, 128); - RightGlass.mirror = true; - setRotation(RightGlass, 0F, 0F, 0F); - LeftGlass = new ModelRenderer(this, 22, 37); - LeftGlass.addBox(0F, 0F, 0F, 1, 14, 10); - LeftGlass.setRotationPoint(5F, 9F, -5F); - LeftGlass.setTextureSize(128, 128); - LeftGlass.mirror = true; - setRotation(LeftGlass, 0F, 0F, 0F); - } + Base = new ModelRenderer(this, 0, 0); + Base.addBox(0F, 0F, 0F, 12, 1, 12); + Base.setRotationPoint(-6F, 23F, -6F); + Base.setTextureSize(128, 128); + Base.mirror = true; + setRotation(Base, 0F, 0F, 0F); + PoleFL = new ModelRenderer(this, 48, 0); + PoleFL.addBox(0F, 0F, 0F, 1, 14, 1); + PoleFL.setRotationPoint(5F, 9F, -6F); + PoleFL.setTextureSize(128, 128); + PoleFL.mirror = true; + setRotation(PoleFL, 0F, 0F, 0F); + PoleLB = new ModelRenderer(this, 48, 0); + PoleLB.addBox(0F, 0F, 0F, 1, 14, 1); + PoleLB.setRotationPoint(5F, 9F, 5F); + PoleLB.setTextureSize(128, 128); + PoleLB.mirror = true; + setRotation(PoleLB, 0F, 0F, 0F); + PoleBR = new ModelRenderer(this, 48, 0); + PoleBR.addBox(0F, 0F, 0F, 1, 14, 1); + PoleBR.setRotationPoint(-6F, 9F, 5F); + PoleBR.setTextureSize(128, 128); + PoleBR.mirror = true; + setRotation(PoleBR, 0F, 0F, 0F); + PoleRF = new ModelRenderer(this, 48, 0); + PoleRF.addBox(0F, 0F, 0F, 1, 14, 1); + PoleRF.setRotationPoint(-6F, 9F, -6F); + PoleRF.setTextureSize(128, 128); + PoleRF.mirror = true; + setRotation(PoleRF, 0F, 0F, 0F); + Top = new ModelRenderer(this, 0, 0); + Top.addBox(0F, 0F, 0F, 12, 1, 12); + Top.setRotationPoint(-6F, 8F, -6F); + Top.setTextureSize(128, 128); + Top.mirror = true; + setRotation(Top, 0F, 0F, 0F); + FrontGlass = new ModelRenderer(this, 0, 13); + FrontGlass.addBox(0F, 0F, 0F, 10, 14, 1); + FrontGlass.setRotationPoint(-5F, 9F, -6F); + FrontGlass.setTextureSize(128, 128); + FrontGlass.mirror = true; + setRotation(FrontGlass, 0F, 0F, 0F); + BackGlass = new ModelRenderer(this, 0, 28); + BackGlass.addBox(0F, 0F, 3F, 10, 14, 1); + BackGlass.setRotationPoint(-5F, 9F, 2F); + BackGlass.setTextureSize(128, 128); + BackGlass.mirror = true; + setRotation(BackGlass, 0F, 0F, 0F); + RightGlass = new ModelRenderer(this, 22, 13); + RightGlass.addBox(0F, 0F, 0F, 1, 14, 10); + RightGlass.setRotationPoint(-6F, 9F, -5F); + RightGlass.setTextureSize(128, 128); + RightGlass.mirror = true; + setRotation(RightGlass, 0F, 0F, 0F); + LeftGlass = new ModelRenderer(this, 22, 37); + LeftGlass.addBox(0F, 0F, 0F, 1, 14, 10); + LeftGlass.setRotationPoint(5F, 9F, -5F); + LeftGlass.setTextureSize(128, 128); + LeftGlass.mirror = true; + setRotation(LeftGlass, 0F, 0F, 0F); + } - public void render(float size, FluidTankTier tier) - { - Base.render(size); - PoleFL.render(size); - PoleLB.render(size); - PoleBR.render(size); - PoleRF.render(size); - Top.render(size); - - MekanismRenderer.blendOn(); - MekanismRenderer.color(tier.getBaseTier().getColor()); - FrontGlass.render(size); - BackGlass.render(size); - RightGlass.render(size); - LeftGlass.render(size); - MekanismRenderer.blendOff(); - } + public void render(float size, FluidTankTier tier) { + Base.render(size); + PoleFL.render(size); + PoleLB.render(size); + PoleBR.render(size); + PoleRF.render(size); + Top.render(size); - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + MekanismRenderer.blendOn(); + MekanismRenderer.color(tier.getBaseTier().getColor()); + FrontGlass.render(size); + BackGlass.render(size); + RightGlass.render(size); + LeftGlass.render(size); + MekanismRenderer.blendOff(); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/mekanism/client/model/ModelFluidicPlenisher.java b/src/main/java/mekanism/client/model/ModelFluidicPlenisher.java index 23912acbe..644b9411a 100644 --- a/src/main/java/mekanism/client/model/ModelFluidicPlenisher.java +++ b/src/main/java/mekanism/client/model/ModelFluidicPlenisher.java @@ -1,149 +1,145 @@ package mekanism.client.model; -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; @SideOnly(Side.CLIENT) -public class ModelFluidicPlenisher extends ModelBase -{ - ModelRenderer bearingRight; - ModelRenderer ringTank; - ModelRenderer portTop; - ModelRenderer portBack; - ModelRenderer Connector; - ModelRenderer pipeToggle; - ModelRenderer ringTop; - ModelRenderer ringBottom; - ModelRenderer tank; - ModelRenderer bearingLeft; - ModelRenderer connectorRing; - ModelRenderer rod4; - ModelRenderer rod3; - ModelRenderer rod2; - ModelRenderer rod1; +public class ModelFluidicPlenisher extends ModelBase { + ModelRenderer bearingRight; + ModelRenderer ringTank; + ModelRenderer portTop; + ModelRenderer portBack; + ModelRenderer Connector; + ModelRenderer pipeToggle; + ModelRenderer ringTop; + ModelRenderer ringBottom; + ModelRenderer tank; + ModelRenderer bearingLeft; + ModelRenderer connectorRing; + ModelRenderer rod4; + ModelRenderer rod3; + ModelRenderer rod2; + ModelRenderer rod1; - public ModelFluidicPlenisher() - { - textureWidth = 64; - textureHeight = 64; + public ModelFluidicPlenisher() { + textureWidth = 64; + textureHeight = 64; - bearingRight = new ModelRenderer(this, 44, 26); - bearingRight.mirror = true; - bearingRight.addBox(0F, 0F, 0F, 1, 4, 4); - bearingRight.setRotationPoint(4F, 14F, -2F); - bearingRight.setTextureSize(64, 64); - setRotation(bearingRight, 0F, 0F, 0F); - ringTank = new ModelRenderer(this, 0, 32); - ringTank.addBox(0F, 0F, 0F, 11, 1, 11); - ringTank.setRotationPoint(-5.5F, 10F, -5.5F); - ringTank.setTextureSize(64, 64); - ringTank.mirror = true; - setRotation(ringTank, 0F, 0F, 0F); - portTop = new ModelRenderer(this, 0, 21); - portTop.addBox(0F, 0F, 0F, 10, 1, 10); - portTop.setRotationPoint(-5F, 8F, -5F); - portTop.setTextureSize(64, 64); - portTop.mirror = true; - setRotation(portTop, 0F, 0F, 0F); - portBack = new ModelRenderer(this, 36, 0); - portBack.addBox(0F, 0F, 0F, 8, 8, 1); - portBack.setRotationPoint(-4F, 12F, 7F); - portBack.setTextureSize(64, 64); - portBack.mirror = true; - setRotation(portBack, 0F, 0F, 0F); - Connector = new ModelRenderer(this, 36, 9); - Connector.addBox(0F, 0F, 0F, 5, 5, 4); - Connector.setRotationPoint(-2.5F, 13.5F, 3F); - Connector.setTextureSize(64, 64); - Connector.mirror = true; - setRotation(Connector, 0F, 0F, 0F); - pipeToggle = new ModelRenderer(this, 32, 44); - pipeToggle.addBox(0F, 0F, 0F, 6, 8, 6); - pipeToggle.setRotationPoint(-3F, 24F, -3F); - pipeToggle.setTextureSize(64, 64); - pipeToggle.mirror = true; - setRotation(pipeToggle, 0F, 0F, 0F); - ringTop = new ModelRenderer(this, 0, 44); - ringTop.addBox(0F, 0F, 0F, 8, 1, 8); - ringTop.setRotationPoint(-4F, 9F, -4F); - ringTop.setTextureSize(64, 64); - ringTop.mirror = true; - setRotation(ringTop, 0F, 0F, 0F); - ringBottom = new ModelRenderer(this, 0, 53); - ringBottom.addBox(0F, 0F, 0F, 8, 1, 8); - ringBottom.setRotationPoint(-4F, 23F, -4F); - ringBottom.setTextureSize(64, 64); - ringBottom.mirror = true; - setRotation(ringBottom, 0F, 0F, 0F); - tank = new ModelRenderer(this, 0, 0); - tank.addBox(0F, 0F, 0F, 9, 12, 9); - tank.setRotationPoint(-4.5F, 11F, -4.5F); - tank.setTextureSize(64, 64); - tank.mirror = true; - setRotation(tank, 0F, 0F, 0F); - bearingLeft = new ModelRenderer(this, 44, 26); - bearingLeft.addBox(0F, 0F, 0F, 1, 4, 4); - bearingLeft.setRotationPoint(-5F, 14F, -2F); - bearingLeft.setTextureSize(64, 64); - bearingLeft.mirror = true; - setRotation(bearingLeft, 0F, 0F, 0F); - connectorRing = new ModelRenderer(this, 40, 18); - connectorRing.addBox(0F, 0F, 0F, 7, 7, 1); - connectorRing.setRotationPoint(-3.5F, 12.5F, 5F); - connectorRing.setTextureSize(64, 64); - connectorRing.mirror = true; - setRotation(connectorRing, 0F, 0F, 0F); - rod4 = new ModelRenderer(this, 0, 0); - rod4.addBox(0F, 0F, 0F, 1, 1, 3); - rod4.setRotationPoint(2F, 18F, 4F); - rod4.setTextureSize(64, 64); - rod4.mirror = true; - setRotation(rod4, 0F, 0F, 0F); - rod3 = new ModelRenderer(this, 0, 0); - rod3.addBox(0F, 0F, 0F, 1, 1, 3); - rod3.setRotationPoint(-3F, 18F, 4F); - rod3.setTextureSize(64, 64); - rod3.mirror = true; - setRotation(rod3, 0F, 0F, 0F); - rod2 = new ModelRenderer(this, 0, 0); - rod2.addBox(0F, 0F, 0F, 1, 1, 3); - rod2.setRotationPoint(2F, 13F, 4F); - rod2.setTextureSize(64, 64); - rod2.mirror = true; - setRotation(rod2, 0F, 0F, 0F); - rod1 = new ModelRenderer(this, 0, 0); - rod1.addBox(0F, 0F, 0F, 1, 1, 3); - rod1.setRotationPoint(-3F, 13F, 4F); - rod1.setTextureSize(64, 64); - rod1.mirror = true; - setRotation(rod1, 0F, 0F, 0F); - } + bearingRight = new ModelRenderer(this, 44, 26); + bearingRight.mirror = true; + bearingRight.addBox(0F, 0F, 0F, 1, 4, 4); + bearingRight.setRotationPoint(4F, 14F, -2F); + bearingRight.setTextureSize(64, 64); + setRotation(bearingRight, 0F, 0F, 0F); + ringTank = new ModelRenderer(this, 0, 32); + ringTank.addBox(0F, 0F, 0F, 11, 1, 11); + ringTank.setRotationPoint(-5.5F, 10F, -5.5F); + ringTank.setTextureSize(64, 64); + ringTank.mirror = true; + setRotation(ringTank, 0F, 0F, 0F); + portTop = new ModelRenderer(this, 0, 21); + portTop.addBox(0F, 0F, 0F, 10, 1, 10); + portTop.setRotationPoint(-5F, 8F, -5F); + portTop.setTextureSize(64, 64); + portTop.mirror = true; + setRotation(portTop, 0F, 0F, 0F); + portBack = new ModelRenderer(this, 36, 0); + portBack.addBox(0F, 0F, 0F, 8, 8, 1); + portBack.setRotationPoint(-4F, 12F, 7F); + portBack.setTextureSize(64, 64); + portBack.mirror = true; + setRotation(portBack, 0F, 0F, 0F); + Connector = new ModelRenderer(this, 36, 9); + Connector.addBox(0F, 0F, 0F, 5, 5, 4); + Connector.setRotationPoint(-2.5F, 13.5F, 3F); + Connector.setTextureSize(64, 64); + Connector.mirror = true; + setRotation(Connector, 0F, 0F, 0F); + pipeToggle = new ModelRenderer(this, 32, 44); + pipeToggle.addBox(0F, 0F, 0F, 6, 8, 6); + pipeToggle.setRotationPoint(-3F, 24F, -3F); + pipeToggle.setTextureSize(64, 64); + pipeToggle.mirror = true; + setRotation(pipeToggle, 0F, 0F, 0F); + ringTop = new ModelRenderer(this, 0, 44); + ringTop.addBox(0F, 0F, 0F, 8, 1, 8); + ringTop.setRotationPoint(-4F, 9F, -4F); + ringTop.setTextureSize(64, 64); + ringTop.mirror = true; + setRotation(ringTop, 0F, 0F, 0F); + ringBottom = new ModelRenderer(this, 0, 53); + ringBottom.addBox(0F, 0F, 0F, 8, 1, 8); + ringBottom.setRotationPoint(-4F, 23F, -4F); + ringBottom.setTextureSize(64, 64); + ringBottom.mirror = true; + setRotation(ringBottom, 0F, 0F, 0F); + tank = new ModelRenderer(this, 0, 0); + tank.addBox(0F, 0F, 0F, 9, 12, 9); + tank.setRotationPoint(-4.5F, 11F, -4.5F); + tank.setTextureSize(64, 64); + tank.mirror = true; + setRotation(tank, 0F, 0F, 0F); + bearingLeft = new ModelRenderer(this, 44, 26); + bearingLeft.addBox(0F, 0F, 0F, 1, 4, 4); + bearingLeft.setRotationPoint(-5F, 14F, -2F); + bearingLeft.setTextureSize(64, 64); + bearingLeft.mirror = true; + setRotation(bearingLeft, 0F, 0F, 0F); + connectorRing = new ModelRenderer(this, 40, 18); + connectorRing.addBox(0F, 0F, 0F, 7, 7, 1); + connectorRing.setRotationPoint(-3.5F, 12.5F, 5F); + connectorRing.setTextureSize(64, 64); + connectorRing.mirror = true; + setRotation(connectorRing, 0F, 0F, 0F); + rod4 = new ModelRenderer(this, 0, 0); + rod4.addBox(0F, 0F, 0F, 1, 1, 3); + rod4.setRotationPoint(2F, 18F, 4F); + rod4.setTextureSize(64, 64); + rod4.mirror = true; + setRotation(rod4, 0F, 0F, 0F); + rod3 = new ModelRenderer(this, 0, 0); + rod3.addBox(0F, 0F, 0F, 1, 1, 3); + rod3.setRotationPoint(-3F, 18F, 4F); + rod3.setTextureSize(64, 64); + rod3.mirror = true; + setRotation(rod3, 0F, 0F, 0F); + rod2 = new ModelRenderer(this, 0, 0); + rod2.addBox(0F, 0F, 0F, 1, 1, 3); + rod2.setRotationPoint(2F, 13F, 4F); + rod2.setTextureSize(64, 64); + rod2.mirror = true; + setRotation(rod2, 0F, 0F, 0F); + rod1 = new ModelRenderer(this, 0, 0); + rod1.addBox(0F, 0F, 0F, 1, 1, 3); + rod1.setRotationPoint(-3F, 13F, 4F); + rod1.setTextureSize(64, 64); + rod1.mirror = true; + setRotation(rod1, 0F, 0F, 0F); + } - public void render(float size) - { - bearingRight.render(size); - ringTank.render(size); - portTop.render(size); - portBack.render(size); - Connector.render(size); - //pipeToggle.render(size); - ringTop.render(size); - ringBottom.render(size); - tank.render(size); - bearingLeft.render(size); - connectorRing.render(size); - rod4.render(size); - rod3.render(size); - rod2.render(size); - rod1.render(size); - } + public void render(float size) { + bearingRight.render(size); + ringTank.render(size); + portTop.render(size); + portBack.render(size); + Connector.render(size); + //pipeToggle.render(size); + ringTop.render(size); + ringBottom.render(size); + tank.render(size); + bearingLeft.render(size); + connectorRing.render(size); + rod4.render(size); + rod3.render(size); + rod2.render(size); + rod1.render(size); + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/mekanism/client/model/ModelFreeRunners.java b/src/main/java/mekanism/client/model/ModelFreeRunners.java index ad59b4883..1e40cb6e6 100644 --- a/src/main/java/mekanism/client/model/ModelFreeRunners.java +++ b/src/main/java/mekanism/client/model/ModelFreeRunners.java @@ -3,88 +3,82 @@ package mekanism.client.model; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; -public class ModelFreeRunners extends ModelBase -{ - ModelRenderer SpringL; - ModelRenderer SpringR; - ModelRenderer BraceL; - ModelRenderer BraceR; - ModelRenderer SupportL; - ModelRenderer SupportR; +public class ModelFreeRunners extends ModelBase { + ModelRenderer SpringL; + ModelRenderer SpringR; + ModelRenderer BraceL; + ModelRenderer BraceR; + ModelRenderer SupportL; + ModelRenderer SupportR; - public ModelFreeRunners() - { - textureWidth = 64; - textureHeight = 32; + public ModelFreeRunners() { + textureWidth = 64; + textureHeight = 32; - SpringL = new ModelRenderer(this, 8, 0); - SpringL.addBox(1.5F, 18F, 0F, 1, 6, 1); - SpringL.setRotationPoint(0F, 0F, 0F); - SpringL.setTextureSize(64, 32); - SpringL.mirror = true; - setRotation(SpringL, 0.1047198F, 0F, 0F); - SpringR = new ModelRenderer(this, 8, 0); - SpringR.addBox(-2.5F, 18F, 0F, 1, 6, 1); - SpringR.setRotationPoint(0F, 0F, 0F); - SpringR.setTextureSize(64, 32); - SpringR.mirror = true; - setRotation(SpringR, 0.1047198F, 0F, 0F); - SpringR.mirror = false; - BraceL = new ModelRenderer(this, 12, 0); - BraceL.addBox(0.2F, 18F, -0.8F, 4, 2, 3); - BraceL.setRotationPoint(0F, 0F, 0F); - BraceL.setTextureSize(64, 32); - BraceL.mirror = true; - setRotation(BraceL, 0F, 0F, 0F); - BraceR = new ModelRenderer(this, 12, 0); - BraceR.addBox(-4.2F, 18F, -0.8F, 4, 2, 3); - BraceR.setRotationPoint(0F, 0F, 0F); - BraceR.setTextureSize(64, 32); - BraceR.mirror = true; - setRotation(BraceR, 0F, 0F, 0F); - SupportL = new ModelRenderer(this, 0, 0); - SupportL.addBox(1F, 16.5F, -4.2F, 2, 4, 2); - SupportL.setRotationPoint(0F, 0F, 0F); - SupportL.setTextureSize(64, 32); - SupportL.mirror = true; - setRotation(SupportL, 0.296706F, 0F, 0F); - SupportR = new ModelRenderer(this, 0, 0); - SupportR.addBox(-3F, 16.5F, -4.2F, 2, 4, 2); - SupportR.setRotationPoint(0F, 0F, 0F); - SupportR.setTextureSize(64, 32); - SupportR.mirror = true; - setRotation(SupportR, 0.296706F, 0F, 0F); - SupportR.mirror = false; - } + SpringL = new ModelRenderer(this, 8, 0); + SpringL.addBox(1.5F, 18F, 0F, 1, 6, 1); + SpringL.setRotationPoint(0F, 0F, 0F); + SpringL.setTextureSize(64, 32); + SpringL.mirror = true; + setRotation(SpringL, 0.1047198F, 0F, 0F); + SpringR = new ModelRenderer(this, 8, 0); + SpringR.addBox(-2.5F, 18F, 0F, 1, 6, 1); + SpringR.setRotationPoint(0F, 0F, 0F); + SpringR.setTextureSize(64, 32); + SpringR.mirror = true; + setRotation(SpringR, 0.1047198F, 0F, 0F); + SpringR.mirror = false; + BraceL = new ModelRenderer(this, 12, 0); + BraceL.addBox(0.2F, 18F, -0.8F, 4, 2, 3); + BraceL.setRotationPoint(0F, 0F, 0F); + BraceL.setTextureSize(64, 32); + BraceL.mirror = true; + setRotation(BraceL, 0F, 0F, 0F); + BraceR = new ModelRenderer(this, 12, 0); + BraceR.addBox(-4.2F, 18F, -0.8F, 4, 2, 3); + BraceR.setRotationPoint(0F, 0F, 0F); + BraceR.setTextureSize(64, 32); + BraceR.mirror = true; + setRotation(BraceR, 0F, 0F, 0F); + SupportL = new ModelRenderer(this, 0, 0); + SupportL.addBox(1F, 16.5F, -4.2F, 2, 4, 2); + SupportL.setRotationPoint(0F, 0F, 0F); + SupportL.setTextureSize(64, 32); + SupportL.mirror = true; + setRotation(SupportL, 0.296706F, 0F, 0F); + SupportR = new ModelRenderer(this, 0, 0); + SupportR.addBox(-3F, 16.5F, -4.2F, 2, 4, 2); + SupportR.setRotationPoint(0F, 0F, 0F); + SupportR.setTextureSize(64, 32); + SupportR.mirror = true; + setRotation(SupportR, 0.296706F, 0F, 0F); + SupportR.mirror = false; + } - public void render(float size) - { - SpringL.render(size); - SpringR.render(size); - BraceL.render(size); - BraceR.render(size); - SupportL.render(size); - SupportR.render(size); - } + public void render(float size) { + SpringL.render(size); + SpringR.render(size); + BraceL.render(size); + BraceR.render(size); + SupportL.render(size); + SupportR.render(size); + } - public void renderLeft(float size) - { - SpringL.render(size); - BraceL.render(size); - SupportL.render(size); - } + public void renderLeft(float size) { + SpringL.render(size); + BraceL.render(size); + SupportL.render(size); + } - public void renderRight(float size) - { - SpringR.render(size); - BraceR.render(size); - SupportR.render(size); - } + public void renderRight(float size) { + SpringR.render(size); + BraceR.render(size); + SupportR.render(size); + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/mekanism/client/model/ModelGasMask.java b/src/main/java/mekanism/client/model/ModelGasMask.java index 469a43070..e6f353674 100644 --- a/src/main/java/mekanism/client/model/ModelGasMask.java +++ b/src/main/java/mekanism/client/model/ModelGasMask.java @@ -1,275 +1,269 @@ package mekanism.client.model; -import mekanism.client.render.MekanismRenderer; -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; - -import org.lwjgl.opengl.GL11; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import mekanism.client.render.MekanismRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) -public class ModelGasMask extends ModelBase -{ - ModelRenderer helmetfeed; - ModelRenderer tubeback; - ModelRenderer tubeL; - ModelRenderer tubeR; - ModelRenderer tubefront; - ModelRenderer mouthintake; - ModelRenderer finupperR; - ModelRenderer finupperL; - ModelRenderer finmidR; - ModelRenderer finmidL; - ModelRenderer finback; - ModelRenderer topplate; - ModelRenderer filterL; - ModelRenderer filterR; - ModelRenderer filterpipelower; - ModelRenderer filterpipeupper; - ModelRenderer glasstop; - ModelRenderer glassfront; - ModelRenderer glassR; - ModelRenderer glassL; - ModelRenderer glassbackR; - ModelRenderer glassbackL; - ModelRenderer pipecornerFL; - ModelRenderer pipecornerFR; - ModelRenderer pipecornerBR; - ModelRenderer pipecornerBL; - ModelRenderer lightL; - ModelRenderer lightR; +public class ModelGasMask extends ModelBase { + ModelRenderer helmetfeed; + ModelRenderer tubeback; + ModelRenderer tubeL; + ModelRenderer tubeR; + ModelRenderer tubefront; + ModelRenderer mouthintake; + ModelRenderer finupperR; + ModelRenderer finupperL; + ModelRenderer finmidR; + ModelRenderer finmidL; + ModelRenderer finback; + ModelRenderer topplate; + ModelRenderer filterL; + ModelRenderer filterR; + ModelRenderer filterpipelower; + ModelRenderer filterpipeupper; + ModelRenderer glasstop; + ModelRenderer glassfront; + ModelRenderer glassR; + ModelRenderer glassL; + ModelRenderer glassbackR; + ModelRenderer glassbackL; + ModelRenderer pipecornerFL; + ModelRenderer pipecornerFR; + ModelRenderer pipecornerBR; + ModelRenderer pipecornerBL; + ModelRenderer lightL; + ModelRenderer lightR; - public ModelGasMask() - { - textureWidth = 128; - textureHeight = 64; + public ModelGasMask() { + textureWidth = 128; + textureHeight = 64; - helmetfeed = new ModelRenderer(this, 88, 43); - helmetfeed.addBox(-2F, -2F, 2F, 4, 3, 4); - helmetfeed.setRotationPoint(0F, 0F, 0F); - helmetfeed.setTextureSize(128, 64); - helmetfeed.mirror = true; - setRotation(helmetfeed, 0F, 0F, 0F); - tubeback = new ModelRenderer(this, 106, 50); - tubeback.addBox(-4.5F, -1F, 4.5F, 9, 1, 1); - tubeback.setRotationPoint(0F, 0F, 0F); - tubeback.setTextureSize(128, 64); - tubeback.mirror = true; - setRotation(tubeback, 0F, 0F, 0F); - tubeL = new ModelRenderer(this, 106, 54); - tubeL.addBox(4.5F, -1F, -4.5F, 1, 1, 9); - tubeL.setRotationPoint(0F, 0F, 0F); - tubeL.setTextureSize(128, 64); - tubeL.mirror = true; - setRotation(tubeL, 0F, 0F, 0F); - tubeR = new ModelRenderer(this, 106, 54); - tubeR.addBox(-5.5F, -1F, -4.5F, 1, 1, 9); - tubeR.setRotationPoint(0F, 0F, 0F); - tubeR.setTextureSize(128, 64); - tubeR.mirror = true; - setRotation(tubeR, 0F, 0F, 0F); - tubefront = new ModelRenderer(this, 106, 50); - tubefront.addBox(-4.5F, -1F, -5.5F, 9, 1, 1); - tubefront.setRotationPoint(0F, 0F, 0F); - tubefront.setTextureSize(128, 64); - tubefront.mirror = true; - setRotation(tubefront, 0F, 0F, 0F); - mouthintake = new ModelRenderer(this, 118, 42); - mouthintake.addBox(-1.5F, -0.7F, -6F, 3, 2, 3); - mouthintake.setRotationPoint(0F, -2F, 0F); - mouthintake.setTextureSize(128, 64); - mouthintake.mirror = true; - setRotation(mouthintake, 0.2094395F, 0F, 0F); - finupperR = new ModelRenderer(this, 78, 50); - finupperR.addBox(-6F, -7.5F, -3.3F, 1, 2, 12); - finupperR.setRotationPoint(0F, 0F, 0F); - finupperR.setTextureSize(128, 64); - finupperR.mirror = true; - setRotation(finupperR, 0.0698132F, 0F, 0F); - finupperL = new ModelRenderer(this, 78, 50); - finupperL.addBox(5F, -7.5F, -3.3F, 1, 2, 12); - finupperL.setRotationPoint(0F, 0F, 0F); - finupperL.setTextureSize(128, 64); - finupperL.mirror = true; - setRotation(finupperL, 0.0698132F, 0F, 0F); - finupperL.mirror = false; - finmidR = new ModelRenderer(this, 72, 34); - finmidR.addBox(-7.5F, -6F, -1F, 2, 2, 5); - finmidR.setRotationPoint(0F, 0F, 0F); - finmidR.setTextureSize(128, 64); - finmidR.mirror = true; - setRotation(finmidR, 0F, 0F, 0F); - finmidL = new ModelRenderer(this, 72, 34); - finmidL.addBox(5.5F, -6F, -1F, 2, 2, 5); - finmidL.setRotationPoint(0F, 0F, 0F); - finmidL.setTextureSize(128, 64); - finmidL.mirror = true; - setRotation(finmidL, 0F, 0F, 0F); - finmidL.mirror = false; - finback = new ModelRenderer(this, 80, 0); - finback.addBox(-1F, -9.6F, 2.5F, 2, 10, 3); - finback.setRotationPoint(0F, 0F, 0F); - finback.setTextureSize(128, 64); - finback.mirror = true; - setRotation(finback, 0F, 0F, 0F); - topplate = new ModelRenderer(this, 104, 34); - topplate.addBox(-3F, -10F, -2F, 6, 2, 6); - topplate.setRotationPoint(0F, 0F, 0F); - topplate.setTextureSize(128, 64); - topplate.mirror = true; - setRotation(topplate, 0.1396263F, 0F, 0F); - filterL = new ModelRenderer(this, 108, 42); - filterL.addBox(3.4F, -1.8F, -5F, 2, 3, 3); - filterL.setRotationPoint(0F, 0F, 0F); - filterL.setTextureSize(128, 64); - filterL.mirror = true; - setRotation(filterL, 0F, 0.3839724F, 0.5061455F); - filterL.mirror = false; - filterR = new ModelRenderer(this, 108, 42); - filterR.addBox(-5.4F, -1.8F, -5F, 2, 3, 3); - filterR.setRotationPoint(0F, 0F, 0F); - filterR.setTextureSize(128, 64); - filterR.mirror = true; - setRotation(filterR, 0F, -0.3839724F, -0.5061455F); - filterpipelower = new ModelRenderer(this, 92, 41); - filterpipelower.addBox(-3F, 1F, -5F, 5, 1, 1); - filterpipelower.setRotationPoint(0F, 0F, 0F); - filterpipelower.setTextureSize(128, 64); - filterpipelower.mirror = true; - setRotation(filterpipelower, 0F, 0F, 0F); - filterpipeupper = new ModelRenderer(this, 104, 42); - filterpipeupper.addBox(-0.5F, 0F, -5F, 1, 1, 1); - filterpipeupper.setRotationPoint(0F, 0F, 0F); - filterpipeupper.setTextureSize(128, 64); - filterpipeupper.mirror = true; - setRotation(filterpipeupper, 0F, 0F, 0F); - glasstop = new ModelRenderer(this, 0, 0); - glasstop.addBox(-4F, -9F, -4F, 8, 1, 8); - glasstop.setRotationPoint(0F, 0F, 0F); - glasstop.setTextureSize(128, 64); - glasstop.mirror = true; - setRotation(glasstop, 0F, 0F, 0F); - glassfront = new ModelRenderer(this, 0, 0); - glassfront.addBox(-4F, -8F, -5F, 8, 7, 1); - glassfront.setRotationPoint(0F, 0F, 0F); - glassfront.setTextureSize(128, 64); - glassfront.mirror = true; - setRotation(glassfront, 0F, 0F, 0F); - glassR = new ModelRenderer(this, 0, 0); - glassR.addBox(-5F, -8F, -4F, 1, 7, 8); - glassR.setRotationPoint(0F, 0F, 0F); - glassR.setTextureSize(128, 64); - glassR.mirror = true; - setRotation(glassR, 0F, 0F, 0F); - glassL = new ModelRenderer(this, 0, 0); - glassL.addBox(4F, -8F, -4F, 1, 7, 8); - glassL.setRotationPoint(0F, 0F, 0F); - glassL.setTextureSize(128, 64); - glassL.mirror = true; - setRotation(glassL, 0F, 0F, 0F); - glassbackR = new ModelRenderer(this, 0, 0); - glassbackR.addBox(-4F, -8F, 4F, 3, 7, 1); - glassbackR.setRotationPoint(0F, 0F, 0F); - glassbackR.setTextureSize(128, 64); - glassbackR.mirror = true; - setRotation(glassbackR, 0F, 0F, 0F); - glassbackL = new ModelRenderer(this, 0, 0); - glassbackL.addBox(1F, -8F, 4F, 3, 7, 1); - glassbackL.setRotationPoint(0F, 0F, 0F); - glassbackL.setTextureSize(128, 64); - glassbackL.mirror = true; - setRotation(glassbackL, 0F, 0F, 0F); - pipecornerFL = new ModelRenderer(this, 109, 50); - pipecornerFL.addBox(3.5F, -1F, -4.5F, 1, 1, 1); - pipecornerFL.setRotationPoint(0F, 0F, 0F); - pipecornerFL.setTextureSize(128, 64); - pipecornerFL.mirror = true; - setRotation(pipecornerFL, 0F, 0F, 0F); - pipecornerFR = new ModelRenderer(this, 109, 50); - pipecornerFR.addBox(-4.5F, -1F, -4.5F, 1, 1, 1); - pipecornerFR.setRotationPoint(0F, 0F, 0F); - pipecornerFR.setTextureSize(128, 64); - pipecornerFR.mirror = true; - setRotation(pipecornerFR, 0F, 0F, 0F); - pipecornerBR = new ModelRenderer(this, 109, 50); - pipecornerBR.addBox(-4.5F, -1F, 3.5F, 1, 1, 1); - pipecornerBR.setRotationPoint(0F, 0F, 0F); - pipecornerBR.setTextureSize(128, 64); - pipecornerBR.mirror = true; - setRotation(pipecornerBR, 0F, 0F, 0F); - pipecornerBL = new ModelRenderer(this, 109, 50); - pipecornerBL.addBox(3.5F, -1F, 4.5F, 1, 1, 1); - pipecornerBL.setRotationPoint(0F, 0F, -1F); - pipecornerBL.setTextureSize(128, 64); - pipecornerBL.mirror = true; - setRotation(pipecornerBL, 0F, 0F, 0F); - lightL = new ModelRenderer(this, 89, 37); - lightL.addBox(5.5F, -6F, -2F, 2, 2, 1); - lightL.setRotationPoint(0F, 0F, 0F); - lightL.setTextureSize(128, 64); - lightL.mirror = true; - setRotation(lightL, 0F, 0F, 0F); - lightR = new ModelRenderer(this, 89, 37); - lightR.addBox(-7.5F, -6F, -2F, 2, 2, 1); - lightR.setRotationPoint(0F, 0F, 0F); - lightR.setTextureSize(128, 64); - lightR.mirror = true; - setRotation(lightR, 0F, 0F, 0F); - } + helmetfeed = new ModelRenderer(this, 88, 43); + helmetfeed.addBox(-2F, -2F, 2F, 4, 3, 4); + helmetfeed.setRotationPoint(0F, 0F, 0F); + helmetfeed.setTextureSize(128, 64); + helmetfeed.mirror = true; + setRotation(helmetfeed, 0F, 0F, 0F); + tubeback = new ModelRenderer(this, 106, 50); + tubeback.addBox(-4.5F, -1F, 4.5F, 9, 1, 1); + tubeback.setRotationPoint(0F, 0F, 0F); + tubeback.setTextureSize(128, 64); + tubeback.mirror = true; + setRotation(tubeback, 0F, 0F, 0F); + tubeL = new ModelRenderer(this, 106, 54); + tubeL.addBox(4.5F, -1F, -4.5F, 1, 1, 9); + tubeL.setRotationPoint(0F, 0F, 0F); + tubeL.setTextureSize(128, 64); + tubeL.mirror = true; + setRotation(tubeL, 0F, 0F, 0F); + tubeR = new ModelRenderer(this, 106, 54); + tubeR.addBox(-5.5F, -1F, -4.5F, 1, 1, 9); + tubeR.setRotationPoint(0F, 0F, 0F); + tubeR.setTextureSize(128, 64); + tubeR.mirror = true; + setRotation(tubeR, 0F, 0F, 0F); + tubefront = new ModelRenderer(this, 106, 50); + tubefront.addBox(-4.5F, -1F, -5.5F, 9, 1, 1); + tubefront.setRotationPoint(0F, 0F, 0F); + tubefront.setTextureSize(128, 64); + tubefront.mirror = true; + setRotation(tubefront, 0F, 0F, 0F); + mouthintake = new ModelRenderer(this, 118, 42); + mouthintake.addBox(-1.5F, -0.7F, -6F, 3, 2, 3); + mouthintake.setRotationPoint(0F, -2F, 0F); + mouthintake.setTextureSize(128, 64); + mouthintake.mirror = true; + setRotation(mouthintake, 0.2094395F, 0F, 0F); + finupperR = new ModelRenderer(this, 78, 50); + finupperR.addBox(-6F, -7.5F, -3.3F, 1, 2, 12); + finupperR.setRotationPoint(0F, 0F, 0F); + finupperR.setTextureSize(128, 64); + finupperR.mirror = true; + setRotation(finupperR, 0.0698132F, 0F, 0F); + finupperL = new ModelRenderer(this, 78, 50); + finupperL.addBox(5F, -7.5F, -3.3F, 1, 2, 12); + finupperL.setRotationPoint(0F, 0F, 0F); + finupperL.setTextureSize(128, 64); + finupperL.mirror = true; + setRotation(finupperL, 0.0698132F, 0F, 0F); + finupperL.mirror = false; + finmidR = new ModelRenderer(this, 72, 34); + finmidR.addBox(-7.5F, -6F, -1F, 2, 2, 5); + finmidR.setRotationPoint(0F, 0F, 0F); + finmidR.setTextureSize(128, 64); + finmidR.mirror = true; + setRotation(finmidR, 0F, 0F, 0F); + finmidL = new ModelRenderer(this, 72, 34); + finmidL.addBox(5.5F, -6F, -1F, 2, 2, 5); + finmidL.setRotationPoint(0F, 0F, 0F); + finmidL.setTextureSize(128, 64); + finmidL.mirror = true; + setRotation(finmidL, 0F, 0F, 0F); + finmidL.mirror = false; + finback = new ModelRenderer(this, 80, 0); + finback.addBox(-1F, -9.6F, 2.5F, 2, 10, 3); + finback.setRotationPoint(0F, 0F, 0F); + finback.setTextureSize(128, 64); + finback.mirror = true; + setRotation(finback, 0F, 0F, 0F); + topplate = new ModelRenderer(this, 104, 34); + topplate.addBox(-3F, -10F, -2F, 6, 2, 6); + topplate.setRotationPoint(0F, 0F, 0F); + topplate.setTextureSize(128, 64); + topplate.mirror = true; + setRotation(topplate, 0.1396263F, 0F, 0F); + filterL = new ModelRenderer(this, 108, 42); + filterL.addBox(3.4F, -1.8F, -5F, 2, 3, 3); + filterL.setRotationPoint(0F, 0F, 0F); + filterL.setTextureSize(128, 64); + filterL.mirror = true; + setRotation(filterL, 0F, 0.3839724F, 0.5061455F); + filterL.mirror = false; + filterR = new ModelRenderer(this, 108, 42); + filterR.addBox(-5.4F, -1.8F, -5F, 2, 3, 3); + filterR.setRotationPoint(0F, 0F, 0F); + filterR.setTextureSize(128, 64); + filterR.mirror = true; + setRotation(filterR, 0F, -0.3839724F, -0.5061455F); + filterpipelower = new ModelRenderer(this, 92, 41); + filterpipelower.addBox(-3F, 1F, -5F, 5, 1, 1); + filterpipelower.setRotationPoint(0F, 0F, 0F); + filterpipelower.setTextureSize(128, 64); + filterpipelower.mirror = true; + setRotation(filterpipelower, 0F, 0F, 0F); + filterpipeupper = new ModelRenderer(this, 104, 42); + filterpipeupper.addBox(-0.5F, 0F, -5F, 1, 1, 1); + filterpipeupper.setRotationPoint(0F, 0F, 0F); + filterpipeupper.setTextureSize(128, 64); + filterpipeupper.mirror = true; + setRotation(filterpipeupper, 0F, 0F, 0F); + glasstop = new ModelRenderer(this, 0, 0); + glasstop.addBox(-4F, -9F, -4F, 8, 1, 8); + glasstop.setRotationPoint(0F, 0F, 0F); + glasstop.setTextureSize(128, 64); + glasstop.mirror = true; + setRotation(glasstop, 0F, 0F, 0F); + glassfront = new ModelRenderer(this, 0, 0); + glassfront.addBox(-4F, -8F, -5F, 8, 7, 1); + glassfront.setRotationPoint(0F, 0F, 0F); + glassfront.setTextureSize(128, 64); + glassfront.mirror = true; + setRotation(glassfront, 0F, 0F, 0F); + glassR = new ModelRenderer(this, 0, 0); + glassR.addBox(-5F, -8F, -4F, 1, 7, 8); + glassR.setRotationPoint(0F, 0F, 0F); + glassR.setTextureSize(128, 64); + glassR.mirror = true; + setRotation(glassR, 0F, 0F, 0F); + glassL = new ModelRenderer(this, 0, 0); + glassL.addBox(4F, -8F, -4F, 1, 7, 8); + glassL.setRotationPoint(0F, 0F, 0F); + glassL.setTextureSize(128, 64); + glassL.mirror = true; + setRotation(glassL, 0F, 0F, 0F); + glassbackR = new ModelRenderer(this, 0, 0); + glassbackR.addBox(-4F, -8F, 4F, 3, 7, 1); + glassbackR.setRotationPoint(0F, 0F, 0F); + glassbackR.setTextureSize(128, 64); + glassbackR.mirror = true; + setRotation(glassbackR, 0F, 0F, 0F); + glassbackL = new ModelRenderer(this, 0, 0); + glassbackL.addBox(1F, -8F, 4F, 3, 7, 1); + glassbackL.setRotationPoint(0F, 0F, 0F); + glassbackL.setTextureSize(128, 64); + glassbackL.mirror = true; + setRotation(glassbackL, 0F, 0F, 0F); + pipecornerFL = new ModelRenderer(this, 109, 50); + pipecornerFL.addBox(3.5F, -1F, -4.5F, 1, 1, 1); + pipecornerFL.setRotationPoint(0F, 0F, 0F); + pipecornerFL.setTextureSize(128, 64); + pipecornerFL.mirror = true; + setRotation(pipecornerFL, 0F, 0F, 0F); + pipecornerFR = new ModelRenderer(this, 109, 50); + pipecornerFR.addBox(-4.5F, -1F, -4.5F, 1, 1, 1); + pipecornerFR.setRotationPoint(0F, 0F, 0F); + pipecornerFR.setTextureSize(128, 64); + pipecornerFR.mirror = true; + setRotation(pipecornerFR, 0F, 0F, 0F); + pipecornerBR = new ModelRenderer(this, 109, 50); + pipecornerBR.addBox(-4.5F, -1F, 3.5F, 1, 1, 1); + pipecornerBR.setRotationPoint(0F, 0F, 0F); + pipecornerBR.setTextureSize(128, 64); + pipecornerBR.mirror = true; + setRotation(pipecornerBR, 0F, 0F, 0F); + pipecornerBL = new ModelRenderer(this, 109, 50); + pipecornerBL.addBox(3.5F, -1F, 4.5F, 1, 1, 1); + pipecornerBL.setRotationPoint(0F, 0F, -1F); + pipecornerBL.setTextureSize(128, 64); + pipecornerBL.mirror = true; + setRotation(pipecornerBL, 0F, 0F, 0F); + lightL = new ModelRenderer(this, 89, 37); + lightL.addBox(5.5F, -6F, -2F, 2, 2, 1); + lightL.setRotationPoint(0F, 0F, 0F); + lightL.setTextureSize(128, 64); + lightL.mirror = true; + setRotation(lightL, 0F, 0F, 0F); + lightR = new ModelRenderer(this, 89, 37); + lightR.addBox(-7.5F, -6F, -2F, 2, 2, 1); + lightR.setRotationPoint(0F, 0F, 0F); + lightR.setTextureSize(128, 64); + lightR.mirror = true; + setRotation(lightR, 0F, 0F, 0F); + } - public void render(float size) - { - helmetfeed.render(size); - tubeback.render(size); - tubeL.render(size); - tubeR.render(size); - tubefront.render(size); - mouthintake.render(size); - finupperR.render(size); - finupperL.render(size); - finmidR.render(size); - finmidL.render(size); - finback.render(size); - topplate.render(size); - filterL.render(size); - filterR.render(size); - filterpipelower.render(size); - filterpipeupper.render(size); + public void render(float size) { + helmetfeed.render(size); + tubeback.render(size); + tubeL.render(size); + tubeR.render(size); + tubefront.render(size); + mouthintake.render(size); + finupperR.render(size); + finupperL.render(size); + finmidR.render(size); + finmidL.render(size); + finback.render(size); + topplate.render(size); + filterL.render(size); + filterR.render(size); + filterpipelower.render(size); + filterpipeupper.render(size); - MekanismRenderer.blendOn(); - MekanismRenderer.glowOn(); - GL11.glColor4f(1, 1, 1, 0.3F); - GL11.glEnable(GL11.GL_CULL_FACE); + MekanismRenderer.blendOn(); + MekanismRenderer.glowOn(); + GL11.glColor4f(1, 1, 1, 0.3F); + GL11.glEnable(GL11.GL_CULL_FACE); - glasstop.render(size); - glassfront.render(size); - glassR.render(size); - glassL.render(size); - glassbackR.render(size); - glassbackL.render(size); + glasstop.render(size); + glassfront.render(size); + glassR.render(size); + glassL.render(size); + glassbackR.render(size); + glassbackL.render(size); - GL11.glDisable(GL11.GL_CULL_FACE); - GL11.glColor4f(1, 1, 1, 1); - MekanismRenderer.glowOff(); - MekanismRenderer.blendOff(); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glColor4f(1, 1, 1, 1); + MekanismRenderer.glowOff(); + MekanismRenderer.blendOff(); - pipecornerFL.render(size); - pipecornerFR.render(size); - pipecornerBR.render(size); - pipecornerBL.render(size); + pipecornerFL.render(size); + pipecornerFR.render(size); + pipecornerBR.render(size); + pipecornerBL.render(size); - MekanismRenderer.glowOn(); - lightL.render(size); - lightR.render(size); - MekanismRenderer.glowOff(); - } + MekanismRenderer.glowOn(); + lightL.render(size); + lightR.render(size); + MekanismRenderer.glowOff(); + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/model/ModelGasTank.java b/src/main/java/mekanism/client/model/ModelGasTank.java index 083381ab0..9d2d6f5ed 100644 --- a/src/main/java/mekanism/client/model/ModelGasTank.java +++ b/src/main/java/mekanism/client/model/ModelGasTank.java @@ -1,110 +1,106 @@ package mekanism.client.model; -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; @SideOnly(Side.CLIENT) -public class ModelGasTank extends ModelBase -{ - ModelRenderer rim4; - ModelRenderer rim5; - ModelRenderer rim2; - ModelRenderer tankBase; - ModelRenderer valve; - ModelRenderer rim3; - ModelRenderer tank; - ModelRenderer rim0; - ModelRenderer valveBase; - ModelRenderer rim1; +public class ModelGasTank extends ModelBase { + ModelRenderer rim4; + ModelRenderer rim5; + ModelRenderer rim2; + ModelRenderer tankBase; + ModelRenderer valve; + ModelRenderer rim3; + ModelRenderer tank; + ModelRenderer rim0; + ModelRenderer valveBase; + ModelRenderer rim1; - public ModelGasTank() - { - textureWidth = 64; - textureHeight = 32; + public ModelGasTank() { + textureWidth = 64; + textureHeight = 32; - rim4 = new ModelRenderer(this, 30, 0); - rim4.addBox(0F, 0F, 0F, 1, 3, 6); - rim4.setRotationPoint(3F, 8F, -3F); - rim4.setTextureSize(64, 32); - rim4.mirror = true; - setRotation(rim4, 0F, 0F, 0F); - rim4.mirror = false; - rim5 = new ModelRenderer(this, 0, 4); - rim5.addBox(0F, 0F, 0F, 2, 3, 1); - rim5.setRotationPoint(2F, 8F, -4F); - rim5.setTextureSize(64, 32); - rim5.mirror = true; - setRotation(rim5, 0F, 0F, 0F); - rim2 = new ModelRenderer(this, 30, 0); - rim2.addBox(0F, 0F, 0F, 1, 3, 6); - rim2.setRotationPoint(-4F, 8F, -3F); - rim2.setTextureSize(64, 32); - rim2.mirror = true; - setRotation(rim2, 0F, 0F, 0F); - tankBase = new ModelRenderer(this, 0, 22); - tankBase.addBox(0F, 0F, 0F, 9, 1, 9); - tankBase.setRotationPoint(-4.5F, 22.5F, -4.5F); - tankBase.setTextureSize(64, 32); - tankBase.mirror = true; - setRotation(tankBase, 0F, 0F, 0F); - valve = new ModelRenderer(this, 46, 0); - valve.addBox(0F, 0F, 0F, 3, 1, 3); - valve.setRotationPoint(-1.5F, 8.5F, -1.5F); - valve.setTextureSize(64, 32); - valve.mirror = true; - setRotation(valve, 0F, 0F, 0F); - rim3 = new ModelRenderer(this, 44, 5); - rim3.addBox(0F, 0F, 0F, 8, 3, 1); - rim3.setRotationPoint(-4F, 8F, 3F); - rim3.setTextureSize(64, 32); - rim3.mirror = true; - setRotation(rim3, 0F, 0F, 0F); - tank = new ModelRenderer(this, 0, 0); - tank.addBox(0F, 0F, 0F, 10, 12, 10); - tank.setRotationPoint(-5F, 10.5F, -5F); - tank.setTextureSize(64, 32); - tank.mirror = true; - setRotation(tank, 0F, 0F, 0F); - rim0 = new ModelRenderer(this, 0, 8); - rim0.addBox(0F, 0F, 0F, 4, 1, 1); - rim0.setRotationPoint(-2F, 10F, -4F); - rim0.setTextureSize(64, 32); - rim0.mirror = true; - setRotation(rim0, 0F, 0F, 0F); - valveBase = new ModelRenderer(this, 38, 0); - valveBase.addBox(0F, 0F, 0F, 2, 1, 2); - valveBase.setRotationPoint(-1F, 9.5F, -1F); - valveBase.setTextureSize(64, 32); - valveBase.mirror = true; - setRotation(valveBase, 0F, 0F, 0F); - rim1 = new ModelRenderer(this, 0, 0); - rim1.addBox(0F, 0F, 0F, 2, 3, 1); - rim1.setRotationPoint(-4F, 8F, -4F); - rim1.setTextureSize(64, 32); - rim1.mirror = true; - setRotation(rim1, 0F, 0F, 0F); - } + rim4 = new ModelRenderer(this, 30, 0); + rim4.addBox(0F, 0F, 0F, 1, 3, 6); + rim4.setRotationPoint(3F, 8F, -3F); + rim4.setTextureSize(64, 32); + rim4.mirror = true; + setRotation(rim4, 0F, 0F, 0F); + rim4.mirror = false; + rim5 = new ModelRenderer(this, 0, 4); + rim5.addBox(0F, 0F, 0F, 2, 3, 1); + rim5.setRotationPoint(2F, 8F, -4F); + rim5.setTextureSize(64, 32); + rim5.mirror = true; + setRotation(rim5, 0F, 0F, 0F); + rim2 = new ModelRenderer(this, 30, 0); + rim2.addBox(0F, 0F, 0F, 1, 3, 6); + rim2.setRotationPoint(-4F, 8F, -3F); + rim2.setTextureSize(64, 32); + rim2.mirror = true; + setRotation(rim2, 0F, 0F, 0F); + tankBase = new ModelRenderer(this, 0, 22); + tankBase.addBox(0F, 0F, 0F, 9, 1, 9); + tankBase.setRotationPoint(-4.5F, 22.5F, -4.5F); + tankBase.setTextureSize(64, 32); + tankBase.mirror = true; + setRotation(tankBase, 0F, 0F, 0F); + valve = new ModelRenderer(this, 46, 0); + valve.addBox(0F, 0F, 0F, 3, 1, 3); + valve.setRotationPoint(-1.5F, 8.5F, -1.5F); + valve.setTextureSize(64, 32); + valve.mirror = true; + setRotation(valve, 0F, 0F, 0F); + rim3 = new ModelRenderer(this, 44, 5); + rim3.addBox(0F, 0F, 0F, 8, 3, 1); + rim3.setRotationPoint(-4F, 8F, 3F); + rim3.setTextureSize(64, 32); + rim3.mirror = true; + setRotation(rim3, 0F, 0F, 0F); + tank = new ModelRenderer(this, 0, 0); + tank.addBox(0F, 0F, 0F, 10, 12, 10); + tank.setRotationPoint(-5F, 10.5F, -5F); + tank.setTextureSize(64, 32); + tank.mirror = true; + setRotation(tank, 0F, 0F, 0F); + rim0 = new ModelRenderer(this, 0, 8); + rim0.addBox(0F, 0F, 0F, 4, 1, 1); + rim0.setRotationPoint(-2F, 10F, -4F); + rim0.setTextureSize(64, 32); + rim0.mirror = true; + setRotation(rim0, 0F, 0F, 0F); + valveBase = new ModelRenderer(this, 38, 0); + valveBase.addBox(0F, 0F, 0F, 2, 1, 2); + valveBase.setRotationPoint(-1F, 9.5F, -1F); + valveBase.setTextureSize(64, 32); + valveBase.mirror = true; + setRotation(valveBase, 0F, 0F, 0F); + rim1 = new ModelRenderer(this, 0, 0); + rim1.addBox(0F, 0F, 0F, 2, 3, 1); + rim1.setRotationPoint(-4F, 8F, -4F); + rim1.setTextureSize(64, 32); + rim1.mirror = true; + setRotation(rim1, 0F, 0F, 0F); + } - public void render(float size) - { - rim4.render(size); - rim5.render(size); - rim2.render(size); - tankBase.render(size); - valve.render(size); - rim3.render(size); - tank.render(size); - rim0.render(size); - valveBase.render(size); - rim1.render(size); - } + public void render(float size) { + rim4.render(size); + rim5.render(size); + rim2.render(size); + tankBase.render(size); + valve.render(size); + rim3.render(size); + tank.render(size); + rim0.render(size); + valveBase.render(size); + rim1.render(size); + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/mekanism/client/model/ModelJetpack.java b/src/main/java/mekanism/client/model/ModelJetpack.java index 19d31a719..5a7aaf3d1 100644 --- a/src/main/java/mekanism/client/model/ModelJetpack.java +++ b/src/main/java/mekanism/client/model/ModelJetpack.java @@ -1,223 +1,217 @@ package mekanism.client.model; -import mekanism.client.render.MekanismRenderer; -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; - -import org.lwjgl.opengl.GL11; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import mekanism.client.render.MekanismRenderer; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; +import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) -public class ModelJetpack extends ModelBase -{ - ModelRenderer Packtop; - ModelRenderer Packbottom; - ModelRenderer Thrusterleft; - ModelRenderer Thrusterright; - ModelRenderer Fueltuberight; - ModelRenderer Fueltubeleft; - ModelRenderer Packmid; - ModelRenderer Packcore; - ModelRenderer WingsupportL; - ModelRenderer WingsupportR; - ModelRenderer Packtoprear; - ModelRenderer ExtendosupportL; - ModelRenderer ExtendosupportR; - ModelRenderer WingbladeL; - ModelRenderer WingbladeR; - ModelRenderer Packdoodad2; - ModelRenderer Packdoodad3; - ModelRenderer Bottomthruster; - ModelRenderer light1; - ModelRenderer light2; - ModelRenderer light3; +public class ModelJetpack extends ModelBase { + ModelRenderer Packtop; + ModelRenderer Packbottom; + ModelRenderer Thrusterleft; + ModelRenderer Thrusterright; + ModelRenderer Fueltuberight; + ModelRenderer Fueltubeleft; + ModelRenderer Packmid; + ModelRenderer Packcore; + ModelRenderer WingsupportL; + ModelRenderer WingsupportR; + ModelRenderer Packtoprear; + ModelRenderer ExtendosupportL; + ModelRenderer ExtendosupportR; + ModelRenderer WingbladeL; + ModelRenderer WingbladeR; + ModelRenderer Packdoodad2; + ModelRenderer Packdoodad3; + ModelRenderer Bottomthruster; + ModelRenderer light1; + ModelRenderer light2; + ModelRenderer light3; - public ModelJetpack() - { - textureWidth = 128; - textureHeight = 64; + public ModelJetpack() { + textureWidth = 128; + textureHeight = 64; - Packtop = new ModelRenderer(this, 92, 28); - Packtop.addBox(-4F, 0F, 4F, 8, 4, 1); - Packtop.setRotationPoint(0F, 0F, 0F); - Packtop.setTextureSize(128, 64); - Packtop.mirror = true; - setRotation(Packtop, 0.2094395F, 0F, 0F); - Packbottom = new ModelRenderer(this, 92, 42); - Packbottom.addBox(-4F, 4.1F, 1.5F, 8, 4, 4); - Packbottom.setRotationPoint(0F, 0F, 0F); - Packbottom.setTextureSize(128, 64); - Packbottom.mirror = true; - setRotation(Packbottom, -0.0872665F, 0F, 0F); - Thrusterleft = new ModelRenderer(this, 69, 30); - Thrusterleft.addBox(7.8F, 1.5F, -3.5F, 3, 3, 3); - Thrusterleft.setRotationPoint(0F, 0F, 0F); - Thrusterleft.setTextureSize(128, 64); - Thrusterleft.mirror = true; - setRotation(Thrusterleft, 0.7853982F, -0.715585F, 0.3490659F); - Thrusterright = new ModelRenderer(this, 69, 30); - Thrusterright.addBox(-10.8F, 1.5F, -3.5F, 3, 3, 3); - Thrusterright.setRotationPoint(0F, 0F, 0F); - Thrusterright.setTextureSize(128, 64); - Thrusterright.mirror = true; - setRotation(Thrusterright, 0.7853982F, 0.715585F, -0.3490659F); - Fueltuberight = new ModelRenderer(this, 92, 23); - Fueltuberight.addBox(-11.2F, 2F, -3F, 8, 2, 2); - Fueltuberight.setRotationPoint(0F, 0F, 0F); - Fueltuberight.setTextureSize(128, 64); - Fueltuberight.mirror = true; - setRotation(Fueltuberight, 0.7853982F, 0.715585F, -0.3490659F); - Fueltubeleft = new ModelRenderer(this, 92, 23); - Fueltubeleft.addBox(3.2F, 2F, -3F, 8, 2, 2); - Fueltubeleft.setRotationPoint(0F, 0F, 0F); - Fueltubeleft.setTextureSize(128, 64); - Fueltubeleft.mirror = true; - setRotation(Fueltubeleft, 0.7853982F, -0.715585F, 0.3490659F); - Packmid = new ModelRenderer(this, 92, 34); - Packmid.addBox(-4F, 3.3F, 1.5F, 8, 1, 4); - Packmid.setRotationPoint(0F, 0F, 0F); - Packmid.setTextureSize(128, 64); - Packmid.mirror = true; - setRotation(Packmid, 0F, 0F, 0F); - Packcore = new ModelRenderer(this, 69, 2); - Packcore.addBox(-3.5F, 3F, 2F, 7, 1, 3); - Packcore.setRotationPoint(0F, 0F, 0F); - Packcore.setTextureSize(128, 64); - Packcore.mirror = true; - setRotation(Packcore, 0F, 0F, 0F); - WingsupportL = new ModelRenderer(this, 71, 55); - WingsupportL.addBox(3F, -1F, 2.2F, 7, 2, 2); - WingsupportL.setRotationPoint(0F, 0F, 0F); - WingsupportL.setTextureSize(128, 64); - WingsupportL.mirror = true; - setRotation(WingsupportL, 0F, 0F, 0.2792527F); - WingsupportR = new ModelRenderer(this, 71, 55); - WingsupportR.addBox(-10F, -1F, 2.2F, 7, 2, 2); - WingsupportR.setRotationPoint(0F, 0F, 0F); - WingsupportR.setTextureSize(128, 64); - WingsupportR.mirror = true; - setRotation(WingsupportR, 0F, 0F, -0.2792527F); - Packtoprear = new ModelRenderer(this, 106, 28); - Packtoprear.addBox(-4F, 1F, 1F, 8, 3, 3); - Packtoprear.setRotationPoint(0F, 0F, 0F); - Packtoprear.setTextureSize(128, 64); - Packtoprear.mirror = true; - setRotation(Packtoprear, 0.2094395F, 0F, 0F); - ExtendosupportL = new ModelRenderer(this, 94, 16); - ExtendosupportL.addBox(8F, -0.2F, 2.5F, 9, 1, 1); - ExtendosupportL.setRotationPoint(0F, 0F, 0F); - ExtendosupportL.setTextureSize(128, 64); - ExtendosupportL.mirror = true; - setRotation(ExtendosupportL, 0F, 0F, 0.2792527F); - ExtendosupportR = new ModelRenderer(this, 94, 16); - ExtendosupportR.addBox(-17F, -0.2F, 2.5F, 9, 1, 1); - ExtendosupportR.setRotationPoint(0F, 0F, 0F); - ExtendosupportR.setTextureSize(128, 64); - ExtendosupportR.mirror = true; - setRotation(ExtendosupportR, 0F, 0F, -0.2792527F); - WingbladeL = new ModelRenderer(this, 62, 5); - WingbladeL.addBox(3.3F, 1.1F, 3F, 14, 2, 0); - WingbladeL.setRotationPoint(0F, 0F, 0F); - WingbladeL.setTextureSize(128, 64); - WingbladeL.mirror = true; - setRotation(WingbladeL, 0F, 0F, 0.2094395F); - WingbladeR = new ModelRenderer(this, 62, 5); - WingbladeR.addBox(-17.3F, 1.1F, 3F, 14, 2, 0); - WingbladeR.setRotationPoint(0F, 0F, 0F); - WingbladeR.setTextureSize(128, 64); - WingbladeR.mirror = true; - setRotation(WingbladeR, 0F, 0F, -0.2094395F); - Packdoodad2 = new ModelRenderer(this, 116, 0); - Packdoodad2.addBox(1F, 0.5F, 4.2F, 2, 1, 1); - Packdoodad2.setRotationPoint(0F, 0F, 0F); - Packdoodad2.setTextureSize(128, 64); - Packdoodad2.mirror = true; - setRotation(Packdoodad2, 0.2094395F, 0F, 0F); - Packdoodad3 = new ModelRenderer(this, 116, 0); - Packdoodad3.addBox(1F, 2F, 4.2F, 2, 1, 1); - Packdoodad3.setRotationPoint(0F, 0F, 0F); - Packdoodad3.setTextureSize(128, 64); - Packdoodad3.mirror = true; - setRotation(Packdoodad3, 0.2094395F, 0F, 0F); - Bottomthruster = new ModelRenderer(this, 68, 26); - Bottomthruster.addBox(-3F, 8F, 2.333333F, 6, 1, 2); - Bottomthruster.setRotationPoint(0F, 0F, 0F); - Bottomthruster.setTextureSize(128, 64); - Bottomthruster.mirror = true; - setRotation(Bottomthruster, 0F, 0F, 0F); - light1 = new ModelRenderer(this, 55, 2); - light1.addBox(2F, 6.55F, 4F, 1, 1, 1); - light1.setRotationPoint(0F, 0F, 0F); - light1.setTextureSize(128, 64); - light1.mirror = true; - setRotation(light1, 0F, 0F, 0F); - light2 = new ModelRenderer(this, 55, 2); - light2.addBox(0F, 6.55F, 4F, 1, 1, 1); - light2.setRotationPoint(0F, 0F, 0F); - light2.setTextureSize(128, 64); - light2.mirror = true; - setRotation(light2, 0F, 0F, 0F); - light3 = new ModelRenderer(this, 55, 2); - light3.addBox(-3F, 6.55F, 4F, 1, 1, 1); - light3.setRotationPoint(0F, 0F, 0F); - light3.setTextureSize(128, 64); - light3.mirror = true; - setRotation(light3, 0F, 0F, 0F); - } + Packtop = new ModelRenderer(this, 92, 28); + Packtop.addBox(-4F, 0F, 4F, 8, 4, 1); + Packtop.setRotationPoint(0F, 0F, 0F); + Packtop.setTextureSize(128, 64); + Packtop.mirror = true; + setRotation(Packtop, 0.2094395F, 0F, 0F); + Packbottom = new ModelRenderer(this, 92, 42); + Packbottom.addBox(-4F, 4.1F, 1.5F, 8, 4, 4); + Packbottom.setRotationPoint(0F, 0F, 0F); + Packbottom.setTextureSize(128, 64); + Packbottom.mirror = true; + setRotation(Packbottom, -0.0872665F, 0F, 0F); + Thrusterleft = new ModelRenderer(this, 69, 30); + Thrusterleft.addBox(7.8F, 1.5F, -3.5F, 3, 3, 3); + Thrusterleft.setRotationPoint(0F, 0F, 0F); + Thrusterleft.setTextureSize(128, 64); + Thrusterleft.mirror = true; + setRotation(Thrusterleft, 0.7853982F, -0.715585F, 0.3490659F); + Thrusterright = new ModelRenderer(this, 69, 30); + Thrusterright.addBox(-10.8F, 1.5F, -3.5F, 3, 3, 3); + Thrusterright.setRotationPoint(0F, 0F, 0F); + Thrusterright.setTextureSize(128, 64); + Thrusterright.mirror = true; + setRotation(Thrusterright, 0.7853982F, 0.715585F, -0.3490659F); + Fueltuberight = new ModelRenderer(this, 92, 23); + Fueltuberight.addBox(-11.2F, 2F, -3F, 8, 2, 2); + Fueltuberight.setRotationPoint(0F, 0F, 0F); + Fueltuberight.setTextureSize(128, 64); + Fueltuberight.mirror = true; + setRotation(Fueltuberight, 0.7853982F, 0.715585F, -0.3490659F); + Fueltubeleft = new ModelRenderer(this, 92, 23); + Fueltubeleft.addBox(3.2F, 2F, -3F, 8, 2, 2); + Fueltubeleft.setRotationPoint(0F, 0F, 0F); + Fueltubeleft.setTextureSize(128, 64); + Fueltubeleft.mirror = true; + setRotation(Fueltubeleft, 0.7853982F, -0.715585F, 0.3490659F); + Packmid = new ModelRenderer(this, 92, 34); + Packmid.addBox(-4F, 3.3F, 1.5F, 8, 1, 4); + Packmid.setRotationPoint(0F, 0F, 0F); + Packmid.setTextureSize(128, 64); + Packmid.mirror = true; + setRotation(Packmid, 0F, 0F, 0F); + Packcore = new ModelRenderer(this, 69, 2); + Packcore.addBox(-3.5F, 3F, 2F, 7, 1, 3); + Packcore.setRotationPoint(0F, 0F, 0F); + Packcore.setTextureSize(128, 64); + Packcore.mirror = true; + setRotation(Packcore, 0F, 0F, 0F); + WingsupportL = new ModelRenderer(this, 71, 55); + WingsupportL.addBox(3F, -1F, 2.2F, 7, 2, 2); + WingsupportL.setRotationPoint(0F, 0F, 0F); + WingsupportL.setTextureSize(128, 64); + WingsupportL.mirror = true; + setRotation(WingsupportL, 0F, 0F, 0.2792527F); + WingsupportR = new ModelRenderer(this, 71, 55); + WingsupportR.addBox(-10F, -1F, 2.2F, 7, 2, 2); + WingsupportR.setRotationPoint(0F, 0F, 0F); + WingsupportR.setTextureSize(128, 64); + WingsupportR.mirror = true; + setRotation(WingsupportR, 0F, 0F, -0.2792527F); + Packtoprear = new ModelRenderer(this, 106, 28); + Packtoprear.addBox(-4F, 1F, 1F, 8, 3, 3); + Packtoprear.setRotationPoint(0F, 0F, 0F); + Packtoprear.setTextureSize(128, 64); + Packtoprear.mirror = true; + setRotation(Packtoprear, 0.2094395F, 0F, 0F); + ExtendosupportL = new ModelRenderer(this, 94, 16); + ExtendosupportL.addBox(8F, -0.2F, 2.5F, 9, 1, 1); + ExtendosupportL.setRotationPoint(0F, 0F, 0F); + ExtendosupportL.setTextureSize(128, 64); + ExtendosupportL.mirror = true; + setRotation(ExtendosupportL, 0F, 0F, 0.2792527F); + ExtendosupportR = new ModelRenderer(this, 94, 16); + ExtendosupportR.addBox(-17F, -0.2F, 2.5F, 9, 1, 1); + ExtendosupportR.setRotationPoint(0F, 0F, 0F); + ExtendosupportR.setTextureSize(128, 64); + ExtendosupportR.mirror = true; + setRotation(ExtendosupportR, 0F, 0F, -0.2792527F); + WingbladeL = new ModelRenderer(this, 62, 5); + WingbladeL.addBox(3.3F, 1.1F, 3F, 14, 2, 0); + WingbladeL.setRotationPoint(0F, 0F, 0F); + WingbladeL.setTextureSize(128, 64); + WingbladeL.mirror = true; + setRotation(WingbladeL, 0F, 0F, 0.2094395F); + WingbladeR = new ModelRenderer(this, 62, 5); + WingbladeR.addBox(-17.3F, 1.1F, 3F, 14, 2, 0); + WingbladeR.setRotationPoint(0F, 0F, 0F); + WingbladeR.setTextureSize(128, 64); + WingbladeR.mirror = true; + setRotation(WingbladeR, 0F, 0F, -0.2094395F); + Packdoodad2 = new ModelRenderer(this, 116, 0); + Packdoodad2.addBox(1F, 0.5F, 4.2F, 2, 1, 1); + Packdoodad2.setRotationPoint(0F, 0F, 0F); + Packdoodad2.setTextureSize(128, 64); + Packdoodad2.mirror = true; + setRotation(Packdoodad2, 0.2094395F, 0F, 0F); + Packdoodad3 = new ModelRenderer(this, 116, 0); + Packdoodad3.addBox(1F, 2F, 4.2F, 2, 1, 1); + Packdoodad3.setRotationPoint(0F, 0F, 0F); + Packdoodad3.setTextureSize(128, 64); + Packdoodad3.mirror = true; + setRotation(Packdoodad3, 0.2094395F, 0F, 0F); + Bottomthruster = new ModelRenderer(this, 68, 26); + Bottomthruster.addBox(-3F, 8F, 2.333333F, 6, 1, 2); + Bottomthruster.setRotationPoint(0F, 0F, 0F); + Bottomthruster.setTextureSize(128, 64); + Bottomthruster.mirror = true; + setRotation(Bottomthruster, 0F, 0F, 0F); + light1 = new ModelRenderer(this, 55, 2); + light1.addBox(2F, 6.55F, 4F, 1, 1, 1); + light1.setRotationPoint(0F, 0F, 0F); + light1.setTextureSize(128, 64); + light1.mirror = true; + setRotation(light1, 0F, 0F, 0F); + light2 = new ModelRenderer(this, 55, 2); + light2.addBox(0F, 6.55F, 4F, 1, 1, 1); + light2.setRotationPoint(0F, 0F, 0F); + light2.setTextureSize(128, 64); + light2.mirror = true; + setRotation(light2, 0F, 0F, 0F); + light3 = new ModelRenderer(this, 55, 2); + light3.addBox(-3F, 6.55F, 4F, 1, 1, 1); + light3.setRotationPoint(0F, 0F, 0F); + light3.setTextureSize(128, 64); + light3.mirror = true; + setRotation(light3, 0F, 0F, 0F); + } - public void render(float size) - { - Packtop.render(size); - Packbottom.render(size); - Thrusterleft.render(size); - Thrusterright.render(size); - Fueltuberight.render(size); - Fueltubeleft.render(size); - Packmid.render(size); + public void render(float size) { + Packtop.render(size); + Packbottom.render(size); + Thrusterleft.render(size); + Thrusterright.render(size); + Fueltuberight.render(size); + Fueltubeleft.render(size); + Packmid.render(size); - MekanismRenderer.glowOn(); - Packcore.render(size); - MekanismRenderer.glowOff(); + MekanismRenderer.glowOn(); + Packcore.render(size); + MekanismRenderer.glowOff(); - WingsupportL.render(size); - WingsupportR.render(size); - Packtoprear.render(size); - ExtendosupportL.render(size); - ExtendosupportR.render(size); + WingsupportL.render(size); + WingsupportR.render(size); + Packtoprear.render(size); + ExtendosupportL.render(size); + ExtendosupportR.render(size); - GL11.glPushMatrix(); - MekanismRenderer.blendOn(); - MekanismRenderer.glowOn(); - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glColor4f(1, 1, 1, 0.2F); + GL11.glPushMatrix(); + MekanismRenderer.blendOn(); + MekanismRenderer.glowOn(); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glColor4f(1, 1, 1, 0.2F); - WingbladeL.render(size); - WingbladeR.render(size); + WingbladeL.render(size); + WingbladeR.render(size); - GL11.glColor4f(1, 1, 1, 1); - GL11.glDisable(GL11.GL_CULL_FACE); - MekanismRenderer.glowOff(); - MekanismRenderer.blendOff(); - GL11.glPopMatrix(); + GL11.glColor4f(1, 1, 1, 1); + GL11.glDisable(GL11.GL_CULL_FACE); + MekanismRenderer.glowOff(); + MekanismRenderer.blendOff(); + GL11.glPopMatrix(); - Packdoodad2.render(size); - Packdoodad3.render(size); - Bottomthruster.render(size); + Packdoodad2.render(size); + Packdoodad3.render(size); + Bottomthruster.render(size); - MekanismRenderer.glowOn(); - light1.render(size); - light2.render(size); - light3.render(size); - Packcore.render(size); - MekanismRenderer.glowOff(); - } + MekanismRenderer.glowOn(); + light1.render(size); + light2.render(size); + light3.render(size); + Packcore.render(size); + MekanismRenderer.glowOff(); + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/model/ModelLaser.java b/src/main/java/mekanism/client/model/ModelLaser.java index dfe696903..ef576f993 100644 --- a/src/main/java/mekanism/client/model/ModelLaser.java +++ b/src/main/java/mekanism/client/model/ModelLaser.java @@ -3,184 +3,180 @@ package mekanism.client.model; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; -public class ModelLaser extends ModelBase -{ - ModelRenderer connector; - ModelRenderer center; - ModelRenderer shaft; - ModelRenderer ring1; - ModelRenderer port; - ModelRenderer rod1; - ModelRenderer fin1; - ModelRenderer fin2; - ModelRenderer fin3; - ModelRenderer fin4; - ModelRenderer ring2; - ModelRenderer body; - ModelRenderer rod2; - ModelRenderer wire; - ModelRenderer rod3; - ModelRenderer fin5; - ModelRenderer fin6; - ModelRenderer fin7; - ModelRenderer fin8; - ModelRenderer rod4; +public class ModelLaser extends ModelBase { + ModelRenderer connector; + ModelRenderer center; + ModelRenderer shaft; + ModelRenderer ring1; + ModelRenderer port; + ModelRenderer rod1; + ModelRenderer fin1; + ModelRenderer fin2; + ModelRenderer fin3; + ModelRenderer fin4; + ModelRenderer ring2; + ModelRenderer body; + ModelRenderer rod2; + ModelRenderer wire; + ModelRenderer rod3; + ModelRenderer fin5; + ModelRenderer fin6; + ModelRenderer fin7; + ModelRenderer fin8; + ModelRenderer rod4; - public ModelLaser() - { - textureWidth = 64; - textureHeight = 32; + public ModelLaser() { + textureWidth = 64; + textureHeight = 32; - connector = new ModelRenderer(this, 32, 15); - connector.addBox(0F, 0F, 0F, 6, 1, 6); - connector.setRotationPoint(-3F, 22F, -3F); - connector.setTextureSize(64, 32); - connector.mirror = true; - setRotation(connector, 0F, 0F, 0F); - center = new ModelRenderer(this, 18, 9); - center.addBox(0F, 0F, 0F, 2, 15, 2); - center.setRotationPoint(-1F, 8F, -1F); - center.setTextureSize(64, 32); - center.mirror = true; - setRotation(center, 0F, 0F, 0F); - shaft = new ModelRenderer(this, 0, 18); - shaft.addBox(0F, 0F, 0F, 3, 2, 3); - shaft.setRotationPoint(-1.5F, 13F, -1.5F); - shaft.setTextureSize(64, 32); - shaft.mirror = true; - setRotation(shaft, 0F, 0F, 0F); - ring1 = new ModelRenderer(this, 0, 23); - ring1.addBox(0F, 0F, 0F, 4, 1, 4); - ring1.setRotationPoint(-2F, 10F, -2F); - ring1.setTextureSize(64, 32); - ring1.mirror = true; - setRotation(ring1, 0F, 0F, 0F); - port = new ModelRenderer(this, 0, 0); - port.addBox(0F, 0F, 0F, 8, 1, 8); - port.setRotationPoint(-4F, 23F, -4F); - port.setTextureSize(64, 32); - port.mirror = true; - setRotation(port, 0F, 0F, 0F); - rod1 = new ModelRenderer(this, 0, 9); - rod1.addBox(0F, 0F, 0F, 1, 5, 1); - rod1.setRotationPoint(2.8F, 16F, 1F); - rod1.setTextureSize(64, 32); - rod1.mirror = true; - setRotation(rod1, 0F, 0F, 0F); - fin1 = new ModelRenderer(this, 0, 9); - fin1.addBox(0F, 0F, 0F, 1, 1, 8); - fin1.setRotationPoint(3F, 21F, -4F); - fin1.setTextureSize(64, 32); - fin1.mirror = true; - setRotation(fin1, 0F, 0F, 0F); - fin2 = new ModelRenderer(this, 0, 9); - fin2.addBox(0F, 0F, 0F, 1, 1, 8); - fin2.setRotationPoint(3F, 19F, -4F); - fin2.setTextureSize(64, 32); - fin2.mirror = true; - setRotation(fin2, 0F, 0F, 0F); - fin3 = new ModelRenderer(this, 0, 9); - fin3.addBox(0F, 0F, 0F, 1, 1, 8); - fin3.setRotationPoint(3F, 17F, -4F); - fin3.setTextureSize(64, 32); - fin3.mirror = true; - setRotation(fin3, 0F, 0F, 0F); - fin4 = new ModelRenderer(this, 0, 9); - fin4.addBox(0F, 0F, 0F, 1, 1, 8); - fin4.setRotationPoint(3F, 15F, -4F); - fin4.setTextureSize(64, 32); - fin4.mirror = true; - setRotation(fin4, 0F, 0F, 0F); - ring2 = new ModelRenderer(this, 0, 23); - ring2.addBox(0F, 0F, 0F, 4, 1, 4); - ring2.setRotationPoint(-2F, 12F, -2F); - ring2.setTextureSize(64, 32); - ring2.mirror = true; - setRotation(ring2, 0F, 0F, 0F); - body = new ModelRenderer(this, 32, 0); - body.addBox(0F, 0F, 0F, 6, 7, 8); - body.setRotationPoint(-3F, 15F, -4F); - body.setTextureSize(64, 32); - body.mirror = true; - setRotation(body, 0F, 0F, 0F); - rod2 = new ModelRenderer(this, 0, 9); - rod2.addBox(0F, 0F, 0F, 1, 5, 1); - rod2.setRotationPoint(2.8F, 16F, -2F); - rod2.setTextureSize(64, 32); - rod2.mirror = true; - setRotation(rod2, 0F, 0F, 0F); - wire = new ModelRenderer(this, 10, 9); - wire.addBox(0F, -1F, 0F, 1, 6, 1); - wire.setRotationPoint(-1.5F, 11F, -0.5F); - wire.setTextureSize(64, 32); - wire.mirror = true; - setRotation(wire, 0F, 0F, 0.1919862F); - rod3 = new ModelRenderer(this, 0, 9); - rod3.addBox(0F, 0F, 0F, 1, 5, 1); - rod3.setRotationPoint(-3.8F, 16F, 1F); - rod3.setTextureSize(64, 32); - rod3.mirror = true; - setRotation(rod3, 0F, 0F, 0F); - fin5 = new ModelRenderer(this, 0, 9); - fin5.addBox(0F, 0F, 0F, 1, 1, 8); - fin5.setRotationPoint(-4F, 15F, -4F); - fin5.setTextureSize(64, 32); - fin5.mirror = true; - setRotation(fin5, 0F, 0F, 0F); - fin6 = new ModelRenderer(this, 0, 9); - fin6.addBox(0F, 0F, 0F, 1, 1, 8); - fin6.setRotationPoint(-4F, 17F, -4F); - fin6.setTextureSize(64, 32); - fin6.mirror = true; - setRotation(fin6, 0F, 0F, 0F); - fin7 = new ModelRenderer(this, 0, 9); - fin7.addBox(0F, 0F, 0F, 1, 1, 8); - fin7.setRotationPoint(-4F, 19F, -4F); - fin7.setTextureSize(64, 32); - fin7.mirror = true; - setRotation(fin7, 0F, 0F, 0F); - fin8 = new ModelRenderer(this, 0, 9); - fin8.addBox(0F, 0F, 0F, 1, 1, 8); - fin8.setRotationPoint(-4F, 21F, -4F); - fin8.setTextureSize(64, 32); - fin8.mirror = true; - setRotation(fin8, 0F, 0F, 0F); - rod4 = new ModelRenderer(this, 0, 9); - rod4.addBox(0F, 0F, 0F, 1, 5, 1); - rod4.setRotationPoint(-3.8F, 16F, -2F); - rod4.setTextureSize(64, 32); - rod4.mirror = true; - setRotation(rod4, 0F, 0F, 0F); - } + connector = new ModelRenderer(this, 32, 15); + connector.addBox(0F, 0F, 0F, 6, 1, 6); + connector.setRotationPoint(-3F, 22F, -3F); + connector.setTextureSize(64, 32); + connector.mirror = true; + setRotation(connector, 0F, 0F, 0F); + center = new ModelRenderer(this, 18, 9); + center.addBox(0F, 0F, 0F, 2, 15, 2); + center.setRotationPoint(-1F, 8F, -1F); + center.setTextureSize(64, 32); + center.mirror = true; + setRotation(center, 0F, 0F, 0F); + shaft = new ModelRenderer(this, 0, 18); + shaft.addBox(0F, 0F, 0F, 3, 2, 3); + shaft.setRotationPoint(-1.5F, 13F, -1.5F); + shaft.setTextureSize(64, 32); + shaft.mirror = true; + setRotation(shaft, 0F, 0F, 0F); + ring1 = new ModelRenderer(this, 0, 23); + ring1.addBox(0F, 0F, 0F, 4, 1, 4); + ring1.setRotationPoint(-2F, 10F, -2F); + ring1.setTextureSize(64, 32); + ring1.mirror = true; + setRotation(ring1, 0F, 0F, 0F); + port = new ModelRenderer(this, 0, 0); + port.addBox(0F, 0F, 0F, 8, 1, 8); + port.setRotationPoint(-4F, 23F, -4F); + port.setTextureSize(64, 32); + port.mirror = true; + setRotation(port, 0F, 0F, 0F); + rod1 = new ModelRenderer(this, 0, 9); + rod1.addBox(0F, 0F, 0F, 1, 5, 1); + rod1.setRotationPoint(2.8F, 16F, 1F); + rod1.setTextureSize(64, 32); + rod1.mirror = true; + setRotation(rod1, 0F, 0F, 0F); + fin1 = new ModelRenderer(this, 0, 9); + fin1.addBox(0F, 0F, 0F, 1, 1, 8); + fin1.setRotationPoint(3F, 21F, -4F); + fin1.setTextureSize(64, 32); + fin1.mirror = true; + setRotation(fin1, 0F, 0F, 0F); + fin2 = new ModelRenderer(this, 0, 9); + fin2.addBox(0F, 0F, 0F, 1, 1, 8); + fin2.setRotationPoint(3F, 19F, -4F); + fin2.setTextureSize(64, 32); + fin2.mirror = true; + setRotation(fin2, 0F, 0F, 0F); + fin3 = new ModelRenderer(this, 0, 9); + fin3.addBox(0F, 0F, 0F, 1, 1, 8); + fin3.setRotationPoint(3F, 17F, -4F); + fin3.setTextureSize(64, 32); + fin3.mirror = true; + setRotation(fin3, 0F, 0F, 0F); + fin4 = new ModelRenderer(this, 0, 9); + fin4.addBox(0F, 0F, 0F, 1, 1, 8); + fin4.setRotationPoint(3F, 15F, -4F); + fin4.setTextureSize(64, 32); + fin4.mirror = true; + setRotation(fin4, 0F, 0F, 0F); + ring2 = new ModelRenderer(this, 0, 23); + ring2.addBox(0F, 0F, 0F, 4, 1, 4); + ring2.setRotationPoint(-2F, 12F, -2F); + ring2.setTextureSize(64, 32); + ring2.mirror = true; + setRotation(ring2, 0F, 0F, 0F); + body = new ModelRenderer(this, 32, 0); + body.addBox(0F, 0F, 0F, 6, 7, 8); + body.setRotationPoint(-3F, 15F, -4F); + body.setTextureSize(64, 32); + body.mirror = true; + setRotation(body, 0F, 0F, 0F); + rod2 = new ModelRenderer(this, 0, 9); + rod2.addBox(0F, 0F, 0F, 1, 5, 1); + rod2.setRotationPoint(2.8F, 16F, -2F); + rod2.setTextureSize(64, 32); + rod2.mirror = true; + setRotation(rod2, 0F, 0F, 0F); + wire = new ModelRenderer(this, 10, 9); + wire.addBox(0F, -1F, 0F, 1, 6, 1); + wire.setRotationPoint(-1.5F, 11F, -0.5F); + wire.setTextureSize(64, 32); + wire.mirror = true; + setRotation(wire, 0F, 0F, 0.1919862F); + rod3 = new ModelRenderer(this, 0, 9); + rod3.addBox(0F, 0F, 0F, 1, 5, 1); + rod3.setRotationPoint(-3.8F, 16F, 1F); + rod3.setTextureSize(64, 32); + rod3.mirror = true; + setRotation(rod3, 0F, 0F, 0F); + fin5 = new ModelRenderer(this, 0, 9); + fin5.addBox(0F, 0F, 0F, 1, 1, 8); + fin5.setRotationPoint(-4F, 15F, -4F); + fin5.setTextureSize(64, 32); + fin5.mirror = true; + setRotation(fin5, 0F, 0F, 0F); + fin6 = new ModelRenderer(this, 0, 9); + fin6.addBox(0F, 0F, 0F, 1, 1, 8); + fin6.setRotationPoint(-4F, 17F, -4F); + fin6.setTextureSize(64, 32); + fin6.mirror = true; + setRotation(fin6, 0F, 0F, 0F); + fin7 = new ModelRenderer(this, 0, 9); + fin7.addBox(0F, 0F, 0F, 1, 1, 8); + fin7.setRotationPoint(-4F, 19F, -4F); + fin7.setTextureSize(64, 32); + fin7.mirror = true; + setRotation(fin7, 0F, 0F, 0F); + fin8 = new ModelRenderer(this, 0, 9); + fin8.addBox(0F, 0F, 0F, 1, 1, 8); + fin8.setRotationPoint(-4F, 21F, -4F); + fin8.setTextureSize(64, 32); + fin8.mirror = true; + setRotation(fin8, 0F, 0F, 0F); + rod4 = new ModelRenderer(this, 0, 9); + rod4.addBox(0F, 0F, 0F, 1, 5, 1); + rod4.setRotationPoint(-3.8F, 16F, -2F); + rod4.setTextureSize(64, 32); + rod4.mirror = true; + setRotation(rod4, 0F, 0F, 0F); + } - public void render(float size) - { - connector.render(size); - center.render(size); - shaft.render(size); - ring1.render(size); - port.render(size); - rod1.render(size); - fin1.render(size); - fin2.render(size); - fin3.render(size); - fin4.render(size); - ring2.render(size); - body.render(size); - rod2.render(size); - wire.render(size); - rod3.render(size); - fin5.render(size); - fin6.render(size); - fin7.render(size); - fin8.render(size); - rod4.render(size); - } + public void render(float size) { + connector.render(size); + center.render(size); + shaft.render(size); + ring1.render(size); + port.render(size); + rod1.render(size); + fin1.render(size); + fin2.render(size); + fin3.render(size); + fin4.render(size); + ring2.render(size); + body.render(size); + rod2.render(size); + wire.render(size); + rod3.render(size); + fin5.render(size); + fin6.render(size); + fin7.render(size); + fin8.render(size); + rod4.render(size); + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/mekanism/client/model/ModelLaserAmplifier.java b/src/main/java/mekanism/client/model/ModelLaserAmplifier.java index 344391899..04a469184 100644 --- a/src/main/java/mekanism/client/model/ModelLaserAmplifier.java +++ b/src/main/java/mekanism/client/model/ModelLaserAmplifier.java @@ -1,85 +1,81 @@ package mekanism.client.model; -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; @SideOnly(Side.CLIENT) -public class ModelLaserAmplifier extends ModelBase -{ - ModelRenderer S1; - ModelRenderer S2; - ModelRenderer S3; - ModelRenderer S4; - ModelRenderer S5; - ModelRenderer Base; - ModelRenderer S6; +public class ModelLaserAmplifier extends ModelBase { + ModelRenderer S1; + ModelRenderer S2; + ModelRenderer S3; + ModelRenderer S4; + ModelRenderer S5; + ModelRenderer Base; + ModelRenderer S6; - public ModelLaserAmplifier() - { - textureWidth = 64; - textureHeight = 64; + public ModelLaserAmplifier() { + textureWidth = 64; + textureHeight = 64; - S1 = new ModelRenderer(this, 0, 39); - S1.addBox(0F, 0F, 0F, 1, 10, 10); - S1.setRotationPoint(7F, 11F, -5F); - S1.setTextureSize(64, 64); - S1.mirror = true; - setRotation(S1, 0F, 0F, 0F); - S2 = new ModelRenderer(this, 22, 39); - S2.addBox(0F, 0F, 0F, 10, 10, 1); - S2.setRotationPoint(-5F, 11F, 7F); - S2.setTextureSize(64, 64); - S2.mirror = true; - setRotation(S2, 0F, 0F, 0F); - S3 = new ModelRenderer(this, 0, 39); - S3.addBox(0F, 0F, 0F, 1, 10, 10); - S3.setRotationPoint(-8F, 11F, -5F); - S3.setTextureSize(64, 64); - S3.mirror = true; - setRotation(S3, 0F, 0F, 0F); - S4 = new ModelRenderer(this, 0, 28); - S4.addBox(0F, 0F, 0F, 10, 1, 10); - S4.setRotationPoint(-5F, 23F, -5F); - S4.setTextureSize(64, 64); - S4.mirror = true; - setRotation(S4, 0F, 0F, 0F); - S5 = new ModelRenderer(this, 22, 39); - S5.addBox(0F, 0F, 0F, 10, 10, 1); - S5.setRotationPoint(-5F, 11F, -8F); - S5.setTextureSize(64, 64); - S5.mirror = true; - setRotation(S5, 0F, 0F, 0F); - Base = new ModelRenderer(this, 0, 0); - Base.addBox(0F, 0F, 0F, 14, 14, 14); - Base.setRotationPoint(-7F, 9F, -7F); - Base.setTextureSize(64, 64); - Base.mirror = true; - setRotation(Base, 0F, 0F, 0F); - S6 = new ModelRenderer(this, 0, 28); - S6.addBox(0F, 0F, 0F, 10, 1, 10); - S6.setRotationPoint(-5F, 8F, -5F); - S6.setTextureSize(64, 64); - S6.mirror = true; - setRotation(S6, 0F, 0F, 0F); - } + S1 = new ModelRenderer(this, 0, 39); + S1.addBox(0F, 0F, 0F, 1, 10, 10); + S1.setRotationPoint(7F, 11F, -5F); + S1.setTextureSize(64, 64); + S1.mirror = true; + setRotation(S1, 0F, 0F, 0F); + S2 = new ModelRenderer(this, 22, 39); + S2.addBox(0F, 0F, 0F, 10, 10, 1); + S2.setRotationPoint(-5F, 11F, 7F); + S2.setTextureSize(64, 64); + S2.mirror = true; + setRotation(S2, 0F, 0F, 0F); + S3 = new ModelRenderer(this, 0, 39); + S3.addBox(0F, 0F, 0F, 1, 10, 10); + S3.setRotationPoint(-8F, 11F, -5F); + S3.setTextureSize(64, 64); + S3.mirror = true; + setRotation(S3, 0F, 0F, 0F); + S4 = new ModelRenderer(this, 0, 28); + S4.addBox(0F, 0F, 0F, 10, 1, 10); + S4.setRotationPoint(-5F, 23F, -5F); + S4.setTextureSize(64, 64); + S4.mirror = true; + setRotation(S4, 0F, 0F, 0F); + S5 = new ModelRenderer(this, 22, 39); + S5.addBox(0F, 0F, 0F, 10, 10, 1); + S5.setRotationPoint(-5F, 11F, -8F); + S5.setTextureSize(64, 64); + S5.mirror = true; + setRotation(S5, 0F, 0F, 0F); + Base = new ModelRenderer(this, 0, 0); + Base.addBox(0F, 0F, 0F, 14, 14, 14); + Base.setRotationPoint(-7F, 9F, -7F); + Base.setTextureSize(64, 64); + Base.mirror = true; + setRotation(Base, 0F, 0F, 0F); + S6 = new ModelRenderer(this, 0, 28); + S6.addBox(0F, 0F, 0F, 10, 1, 10); + S6.setRotationPoint(-5F, 8F, -5F); + S6.setTextureSize(64, 64); + S6.mirror = true; + setRotation(S6, 0F, 0F, 0F); + } - public void render(float size) - { - S1.render(size); - S2.render(size); - S3.render(size); - S4.render(size); - S5.render(size); - Base.render(size); - S6.render(size); - } + public void render(float size) { + S1.render(size); + S2.render(size); + S3.render(size); + S4.render(size); + S5.render(size); + Base.render(size); + S6.render(size); + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/mekanism/client/model/ModelLogisticalSorter.java b/src/main/java/mekanism/client/model/ModelLogisticalSorter.java index 8fec0d967..2b4305f4f 100644 --- a/src/main/java/mekanism/client/model/ModelLogisticalSorter.java +++ b/src/main/java/mekanism/client/model/ModelLogisticalSorter.java @@ -1,250 +1,244 @@ package mekanism.client.model; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.render.MekanismRenderer; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class ModelLogisticalSorter extends ModelBase -{ - ModelRenderer portBack; - ModelRenderer portBackLarge; - ModelRenderer connectorBack; - ModelRenderer portFront; - ModelRenderer ring1; - ModelRenderer ring2; - ModelRenderer ring3; - ModelRenderer ring4; - ModelRenderer ring5; - ModelRenderer ring6; - ModelRenderer ring7; - ModelRenderer pistonBar1; - ModelRenderer pipe; - ModelRenderer pistonBase1; - ModelRenderer pistonBrace1; - ModelRenderer pistonConnector1; - ModelRenderer pistonBrace2; - ModelRenderer pistonConnector2; - ModelRenderer pistonBar2; - ModelRenderer pistonBase2; - ModelRenderer panel2; - ModelRenderer led4; - ModelRenderer led3; - ModelRenderer led2; - ModelRenderer led1; - ModelRenderer panel1; +public class ModelLogisticalSorter extends ModelBase { + ModelRenderer portBack; + ModelRenderer portBackLarge; + ModelRenderer connectorBack; + ModelRenderer portFront; + ModelRenderer ring1; + ModelRenderer ring2; + ModelRenderer ring3; + ModelRenderer ring4; + ModelRenderer ring5; + ModelRenderer ring6; + ModelRenderer ring7; + ModelRenderer pistonBar1; + ModelRenderer pipe; + ModelRenderer pistonBase1; + ModelRenderer pistonBrace1; + ModelRenderer pistonConnector1; + ModelRenderer pistonBrace2; + ModelRenderer pistonConnector2; + ModelRenderer pistonBar2; + ModelRenderer pistonBase2; + ModelRenderer panel2; + ModelRenderer led4; + ModelRenderer led3; + ModelRenderer led2; + ModelRenderer led1; + ModelRenderer panel1; - public ModelLogisticalSorter() - { - textureWidth = 128; - textureHeight = 64; + public ModelLogisticalSorter() { + textureWidth = 128; + textureHeight = 64; - portBack = new ModelRenderer(this, 26, 11); - portBack.addBox(0F, 0F, 0F, 8, 8, 1); - portBack.setRotationPoint(-4F, 12F, 8F); - portBack.setTextureSize(128, 64); - portBack.mirror = true; - setRotation(portBack, 0F, 0F, 0F); - portBackLarge = new ModelRenderer(this, 0, 0); - portBackLarge.addBox(0F, 0F, 0F, 12, 12, 1); - portBackLarge.setRotationPoint(-6F, 10F, 7F); - portBackLarge.setTextureSize(128, 64); - portBackLarge.mirror = true; - setRotation(portBackLarge, 0F, 0F, 0F); - connectorBack = new ModelRenderer(this, 26, 0); - connectorBack.addBox(0F, 0F, 0F, 10, 10, 1); - connectorBack.setRotationPoint(-5F, 11F, 6F); - connectorBack.setTextureSize(128, 64); - connectorBack.mirror = true; - setRotation(connectorBack, 0F, 0F, 0F); - portFront = new ModelRenderer(this, 48, 0); - portFront.addBox(0F, 0F, 0F, 10, 10, 1); - portFront.setRotationPoint(-5F, 11F, -8F); - portFront.setTextureSize(128, 64); - portFront.mirror = true; - setRotation(portFront, 0F, 0F, 0F); - ring1 = new ModelRenderer(this, 44, 11); - ring1.addBox(0F, 0F, 0F, 7, 7, 1); - ring1.setRotationPoint(-3.5F, 12.5F, -7F); - ring1.setTextureSize(128, 64); - ring1.mirror = true; - setRotation(ring1, 0F, 0F, 0F); - ring2 = new ModelRenderer(this, 44, 11); - ring2.addBox(0F, 0F, 0F, 7, 7, 1); - ring2.setRotationPoint(-3.5F, 12.5F, -5F); - ring2.setTextureSize(128, 64); - ring2.mirror = true; - setRotation(ring2, 0F, 0F, 0F); - ring3 = new ModelRenderer(this, 44, 11); - ring3.addBox(0F, 0F, 0F, 7, 7, 1); - ring3.setRotationPoint(-3.5F, 12.5F, -3F); - ring3.setTextureSize(128, 64); - ring3.mirror = true; - setRotation(ring3, 0F, 0F, 0F); - ring4 = new ModelRenderer(this, 44, 11); - ring4.addBox(0F, 0F, 0F, 7, 7, 1); - ring4.setRotationPoint(-3.5F, 12.5F, -1F); - ring4.setTextureSize(128, 64); - ring4.mirror = true; - setRotation(ring4, 0F, 0F, 0F); - ring5 = new ModelRenderer(this, 44, 11); - ring5.addBox(0F, 0F, 0F, 7, 7, 1); - ring5.setRotationPoint(-3.5F, 12.5F, 1F); - ring5.setTextureSize(128, 64); - ring5.mirror = true; - setRotation(ring5, 0F, 0F, 0F); - ring6 = new ModelRenderer(this, 44, 11); - ring6.addBox(0F, 0F, 0F, 7, 7, 1); - ring6.setRotationPoint(-3.5F, 12.5F, 3F); - ring6.setTextureSize(128, 64); - ring6.mirror = true; - setRotation(ring6, 0F, 0F, 0F); - ring7 = new ModelRenderer(this, 44, 11); - ring7.addBox(0F, 0F, 0F, 7, 7, 1); - ring7.setRotationPoint(-3.5F, 12.5F, 5F); - ring7.setTextureSize(128, 64); - ring7.mirror = true; - setRotation(ring7, 0F, 0F, 0F); - pistonBar1 = new ModelRenderer(this, 0, 20); - pistonBar1.addBox(0F, 0F, 0F, 1, 1, 5); - pistonBar1.setRotationPoint(-0.5F, 19.5F, -2.99F); - pistonBar1.setTextureSize(128, 64); - pistonBar1.mirror = true; - setRotation(pistonBar1, 0F, 0F, 0F); - pipe = new ModelRenderer(this, 0, 13); - pipe.addBox(0F, 0F, 0F, 6, 6, 14); - pipe.setRotationPoint(-3F, 13F, -7F); - pipe.setTextureSize(128, 64); - pipe.mirror = true; - setRotation(pipe, 0F, 0F, 0F); - pistonBase1 = new ModelRenderer(this, 0, 13); - pistonBase1.addBox(0F, 0F, 0F, 2, 2, 5); - pistonBase1.setRotationPoint(-1F, 19F, 1.01F); - pistonBase1.setTextureSize(128, 64); - pistonBase1.mirror = true; - setRotation(pistonBase1, 0F, 0F, 0F); - pistonBrace1 = new ModelRenderer(this, 0, 33); - pistonBrace1.addBox(0F, 0F, 0F, 2, 2, 3); - pistonBrace1.setRotationPoint(-1F, 18.5F, -7F); - pistonBrace1.setTextureSize(128, 64); - pistonBrace1.mirror = true; - setRotation(pistonBrace1, 0F, 0F, 0F); - pistonConnector1 = new ModelRenderer(this, 10, 33); - pistonConnector1.addBox(0F, 0F, 0F, 2, 2, 1); - pistonConnector1.setRotationPoint(-1F, 19F, -4F); - pistonConnector1.setTextureSize(128, 64); - pistonConnector1.mirror = true; - setRotation(pistonConnector1, 0F, 0F, 0F); - pistonBrace2 = new ModelRenderer(this, 0, 33); - pistonBrace2.addBox(0F, 0F, 0F, 2, 2, 3); - pistonBrace2.setRotationPoint(-1F, 11.5F, -7F); - pistonBrace2.setTextureSize(128, 64); - pistonBrace2.mirror = true; - setRotation(pistonBrace2, 0F, 0F, 0F); - pistonConnector2 = new ModelRenderer(this, 10, 33); - pistonConnector2.addBox(0F, 0F, 0F, 2, 2, 1); - pistonConnector2.setRotationPoint(-1F, 11F, -4F); - pistonConnector2.setTextureSize(128, 64); - pistonConnector2.mirror = true; - setRotation(pistonConnector2, 0F, 0F, 0F); - pistonBar2 = new ModelRenderer(this, 0, 20); - pistonBar2.addBox(0F, 0F, 0F, 1, 1, 5); - pistonBar2.setRotationPoint(-0.5F, 11.5F, -2.99F); - pistonBar2.setTextureSize(128, 64); - pistonBar2.mirror = true; - setRotation(pistonBar2, 0F, 0F, 0F); - pistonBase2 = new ModelRenderer(this, 0, 13); - pistonBase2.addBox(0F, 0F, 0F, 2, 2, 5); - pistonBase2.setRotationPoint(-1F, 11F, 1.01F); - pistonBase2.setTextureSize(128, 64); - pistonBase2.mirror = true; - setRotation(pistonBase2, 0F, 0F, 0F); - panel2 = new ModelRenderer(this, 40, 22); - panel2.addBox(0F, 0F, 0F, 1, 3, 8); - panel2.setRotationPoint(3F, 14.5F, -4.5F); - panel2.setTextureSize(128, 64); - panel2.mirror = true; - setRotation(panel2, 0F, 0F, 0F); - led4 = new ModelRenderer(this, 40, 22); - led4.addBox(0F, 0F, 0F, 1, 1, 1); - led4.setRotationPoint(3.5F, 15.5F, -1.5F); - led4.setTextureSize(128, 64); - led4.mirror = true; - setRotation(led4, 0F, 0F, 0F); - led3 = new ModelRenderer(this, 40, 22); - led3.addBox(0F, 0F, 0F, 1, 1, 1); - led3.setRotationPoint(3.5F, 15.5F, -3.5F); - led3.setTextureSize(128, 64); - led3.mirror = true; - setRotation(led3, 0F, 0F, 0F); - led2 = new ModelRenderer(this, 40, 22); - led2.addBox(0F, 0F, 0F, 1, 1, 1); - led2.setRotationPoint(-4.5F, 15.5F, -3.5F); - led2.setTextureSize(128, 64); - led2.mirror = true; - setRotation(led2, 0F, 0F, 0F); - led1 = new ModelRenderer(this, 40, 22); - led1.addBox(0F, 0F, 0F, 1, 1, 1); - led1.setRotationPoint(-4.5F, 15.5F, -1.5F); - led1.setTextureSize(128, 64); - led1.mirror = true; - setRotation(led1, 0F, 0F, 0F); - panel1 = new ModelRenderer(this, 40, 22); - panel1.addBox(0F, 0F, 0F, 1, 3, 8); - panel1.setRotationPoint(-4F, 14.5F, -4.5F); - panel1.setTextureSize(128, 64); - panel1.mirror = true; - setRotation(panel1, 0F, 0F, 0F); - } + portBack = new ModelRenderer(this, 26, 11); + portBack.addBox(0F, 0F, 0F, 8, 8, 1); + portBack.setRotationPoint(-4F, 12F, 8F); + portBack.setTextureSize(128, 64); + portBack.mirror = true; + setRotation(portBack, 0F, 0F, 0F); + portBackLarge = new ModelRenderer(this, 0, 0); + portBackLarge.addBox(0F, 0F, 0F, 12, 12, 1); + portBackLarge.setRotationPoint(-6F, 10F, 7F); + portBackLarge.setTextureSize(128, 64); + portBackLarge.mirror = true; + setRotation(portBackLarge, 0F, 0F, 0F); + connectorBack = new ModelRenderer(this, 26, 0); + connectorBack.addBox(0F, 0F, 0F, 10, 10, 1); + connectorBack.setRotationPoint(-5F, 11F, 6F); + connectorBack.setTextureSize(128, 64); + connectorBack.mirror = true; + setRotation(connectorBack, 0F, 0F, 0F); + portFront = new ModelRenderer(this, 48, 0); + portFront.addBox(0F, 0F, 0F, 10, 10, 1); + portFront.setRotationPoint(-5F, 11F, -8F); + portFront.setTextureSize(128, 64); + portFront.mirror = true; + setRotation(portFront, 0F, 0F, 0F); + ring1 = new ModelRenderer(this, 44, 11); + ring1.addBox(0F, 0F, 0F, 7, 7, 1); + ring1.setRotationPoint(-3.5F, 12.5F, -7F); + ring1.setTextureSize(128, 64); + ring1.mirror = true; + setRotation(ring1, 0F, 0F, 0F); + ring2 = new ModelRenderer(this, 44, 11); + ring2.addBox(0F, 0F, 0F, 7, 7, 1); + ring2.setRotationPoint(-3.5F, 12.5F, -5F); + ring2.setTextureSize(128, 64); + ring2.mirror = true; + setRotation(ring2, 0F, 0F, 0F); + ring3 = new ModelRenderer(this, 44, 11); + ring3.addBox(0F, 0F, 0F, 7, 7, 1); + ring3.setRotationPoint(-3.5F, 12.5F, -3F); + ring3.setTextureSize(128, 64); + ring3.mirror = true; + setRotation(ring3, 0F, 0F, 0F); + ring4 = new ModelRenderer(this, 44, 11); + ring4.addBox(0F, 0F, 0F, 7, 7, 1); + ring4.setRotationPoint(-3.5F, 12.5F, -1F); + ring4.setTextureSize(128, 64); + ring4.mirror = true; + setRotation(ring4, 0F, 0F, 0F); + ring5 = new ModelRenderer(this, 44, 11); + ring5.addBox(0F, 0F, 0F, 7, 7, 1); + ring5.setRotationPoint(-3.5F, 12.5F, 1F); + ring5.setTextureSize(128, 64); + ring5.mirror = true; + setRotation(ring5, 0F, 0F, 0F); + ring6 = new ModelRenderer(this, 44, 11); + ring6.addBox(0F, 0F, 0F, 7, 7, 1); + ring6.setRotationPoint(-3.5F, 12.5F, 3F); + ring6.setTextureSize(128, 64); + ring6.mirror = true; + setRotation(ring6, 0F, 0F, 0F); + ring7 = new ModelRenderer(this, 44, 11); + ring7.addBox(0F, 0F, 0F, 7, 7, 1); + ring7.setRotationPoint(-3.5F, 12.5F, 5F); + ring7.setTextureSize(128, 64); + ring7.mirror = true; + setRotation(ring7, 0F, 0F, 0F); + pistonBar1 = new ModelRenderer(this, 0, 20); + pistonBar1.addBox(0F, 0F, 0F, 1, 1, 5); + pistonBar1.setRotationPoint(-0.5F, 19.5F, -2.99F); + pistonBar1.setTextureSize(128, 64); + pistonBar1.mirror = true; + setRotation(pistonBar1, 0F, 0F, 0F); + pipe = new ModelRenderer(this, 0, 13); + pipe.addBox(0F, 0F, 0F, 6, 6, 14); + pipe.setRotationPoint(-3F, 13F, -7F); + pipe.setTextureSize(128, 64); + pipe.mirror = true; + setRotation(pipe, 0F, 0F, 0F); + pistonBase1 = new ModelRenderer(this, 0, 13); + pistonBase1.addBox(0F, 0F, 0F, 2, 2, 5); + pistonBase1.setRotationPoint(-1F, 19F, 1.01F); + pistonBase1.setTextureSize(128, 64); + pistonBase1.mirror = true; + setRotation(pistonBase1, 0F, 0F, 0F); + pistonBrace1 = new ModelRenderer(this, 0, 33); + pistonBrace1.addBox(0F, 0F, 0F, 2, 2, 3); + pistonBrace1.setRotationPoint(-1F, 18.5F, -7F); + pistonBrace1.setTextureSize(128, 64); + pistonBrace1.mirror = true; + setRotation(pistonBrace1, 0F, 0F, 0F); + pistonConnector1 = new ModelRenderer(this, 10, 33); + pistonConnector1.addBox(0F, 0F, 0F, 2, 2, 1); + pistonConnector1.setRotationPoint(-1F, 19F, -4F); + pistonConnector1.setTextureSize(128, 64); + pistonConnector1.mirror = true; + setRotation(pistonConnector1, 0F, 0F, 0F); + pistonBrace2 = new ModelRenderer(this, 0, 33); + pistonBrace2.addBox(0F, 0F, 0F, 2, 2, 3); + pistonBrace2.setRotationPoint(-1F, 11.5F, -7F); + pistonBrace2.setTextureSize(128, 64); + pistonBrace2.mirror = true; + setRotation(pistonBrace2, 0F, 0F, 0F); + pistonConnector2 = new ModelRenderer(this, 10, 33); + pistonConnector2.addBox(0F, 0F, 0F, 2, 2, 1); + pistonConnector2.setRotationPoint(-1F, 11F, -4F); + pistonConnector2.setTextureSize(128, 64); + pistonConnector2.mirror = true; + setRotation(pistonConnector2, 0F, 0F, 0F); + pistonBar2 = new ModelRenderer(this, 0, 20); + pistonBar2.addBox(0F, 0F, 0F, 1, 1, 5); + pistonBar2.setRotationPoint(-0.5F, 11.5F, -2.99F); + pistonBar2.setTextureSize(128, 64); + pistonBar2.mirror = true; + setRotation(pistonBar2, 0F, 0F, 0F); + pistonBase2 = new ModelRenderer(this, 0, 13); + pistonBase2.addBox(0F, 0F, 0F, 2, 2, 5); + pistonBase2.setRotationPoint(-1F, 11F, 1.01F); + pistonBase2.setTextureSize(128, 64); + pistonBase2.mirror = true; + setRotation(pistonBase2, 0F, 0F, 0F); + panel2 = new ModelRenderer(this, 40, 22); + panel2.addBox(0F, 0F, 0F, 1, 3, 8); + panel2.setRotationPoint(3F, 14.5F, -4.5F); + panel2.setTextureSize(128, 64); + panel2.mirror = true; + setRotation(panel2, 0F, 0F, 0F); + led4 = new ModelRenderer(this, 40, 22); + led4.addBox(0F, 0F, 0F, 1, 1, 1); + led4.setRotationPoint(3.5F, 15.5F, -1.5F); + led4.setTextureSize(128, 64); + led4.mirror = true; + setRotation(led4, 0F, 0F, 0F); + led3 = new ModelRenderer(this, 40, 22); + led3.addBox(0F, 0F, 0F, 1, 1, 1); + led3.setRotationPoint(3.5F, 15.5F, -3.5F); + led3.setTextureSize(128, 64); + led3.mirror = true; + setRotation(led3, 0F, 0F, 0F); + led2 = new ModelRenderer(this, 40, 22); + led2.addBox(0F, 0F, 0F, 1, 1, 1); + led2.setRotationPoint(-4.5F, 15.5F, -3.5F); + led2.setTextureSize(128, 64); + led2.mirror = true; + setRotation(led2, 0F, 0F, 0F); + led1 = new ModelRenderer(this, 40, 22); + led1.addBox(0F, 0F, 0F, 1, 1, 1); + led1.setRotationPoint(-4.5F, 15.5F, -1.5F); + led1.setTextureSize(128, 64); + led1.mirror = true; + setRotation(led1, 0F, 0F, 0F); + panel1 = new ModelRenderer(this, 40, 22); + panel1.addBox(0F, 0F, 0F, 1, 3, 8); + panel1.setRotationPoint(-4F, 14.5F, -4.5F); + panel1.setTextureSize(128, 64); + panel1.mirror = true; + setRotation(panel1, 0F, 0F, 0F); + } - public void render(float size, boolean active) - { - portBack.render(size); - portBackLarge.render(size); - connectorBack.render(size); - portFront.render(size); - ring1.render(size); - ring2.render(size); - ring3.render(size); - ring4.render(size); - ring5.render(size); - ring6.render(size); - ring7.render(size); - pistonBar1.render(size); - pipe.render(size); - pistonBase1.render(size); - pistonBrace1.render(size); - pistonConnector1.render(size); - pistonBrace2.render(size); - pistonConnector2.render(size); - pistonBar2.render(size); - pistonBase2.render(size); - panel2.render(size); - - if(active) - { - MekanismRenderer.glowOn(); - } - - led4.render(size); - led3.render(size); - led2.render(size); - led1.render(size); - - if(active) - { - MekanismRenderer.glowOff(); - } - - panel1.render(size); - } + public void render(float size, boolean active) { + portBack.render(size); + portBackLarge.render(size); + connectorBack.render(size); + portFront.render(size); + ring1.render(size); + ring2.render(size); + ring3.render(size); + ring4.render(size); + ring5.render(size); + ring6.render(size); + ring7.render(size); + pistonBar1.render(size); + pipe.render(size); + pistonBase1.render(size); + pistonBrace1.render(size); + pistonConnector1.render(size); + pistonBrace2.render(size); + pistonConnector2.render(size); + pistonBar2.render(size); + pistonBase2.render(size); + panel2.render(size); - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + if (active) { + MekanismRenderer.glowOn(); + } + + led4.render(size); + led3.render(size); + led2.render(size); + led1.render(size); + + if (active) { + MekanismRenderer.glowOff(); + } + + panel1.render(size); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/mekanism/client/model/ModelMetallurgicInfuser.java b/src/main/java/mekanism/client/model/ModelMetallurgicInfuser.java index b12adbee3..74dec577c 100644 --- a/src/main/java/mekanism/client/model/ModelMetallurgicInfuser.java +++ b/src/main/java/mekanism/client/model/ModelMetallurgicInfuser.java @@ -1,14 +1,13 @@ package mekanism.client.model; -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; @SideOnly(Side.CLIENT) -public class ModelMetallurgicInfuser extends ModelBase -{ - ModelRenderer base; +public class ModelMetallurgicInfuser extends ModelBase { + ModelRenderer base; ModelRenderer back; ModelRenderer connector1; ModelRenderer connector2; @@ -26,140 +25,137 @@ public class ModelMetallurgicInfuser extends ModelBase ModelRenderer bar1; ModelRenderer bar2; - public ModelMetallurgicInfuser() - { - textureWidth = 128; - textureHeight = 64; + public ModelMetallurgicInfuser() { + textureWidth = 128; + textureHeight = 64; - base = new ModelRenderer(this, 0, 0); - base.addBox(0F, 0F, 0F, 16, 4, 16); - base.setRotationPoint(-8F, 20F, -8F); - base.setTextureSize(128, 64); - base.mirror = true; - setRotation(base, 0F, 0F, 0F); - back = new ModelRenderer(this, 42, 20); - back.addBox(0F, 0F, 0F, 16, 12, 1); - back.setRotationPoint(-8F, 8F, 7F); - back.setTextureSize(128, 64); - back.mirror = true; - setRotation(back, 0F, 0F, 0F); - connector1 = new ModelRenderer(this, 0, 8); - connector1.addBox(0F, 0F, 0F, 1, 5, 3); - connector1.setRotationPoint(-4F, 8.5F, -3F); - connector1.setTextureSize(128, 64); - connector1.mirror = true; - setRotation(connector1, 0F, 0F, 0F); - connector2 = new ModelRenderer(this, 0, 8); - connector2.addBox(0F, 0F, 0F, 1, 5, 3); - connector2.setRotationPoint(3F, 8.5F, -3F); - connector2.setTextureSize(128, 64); - connector2.mirror = true; - setRotation(connector2, 0F, 0F, 0F); - sideRight = new ModelRenderer(this, 64, 0); - sideRight.mirror = true; - sideRight.addBox(0F, 0F, 0F, 1, 11, 7); - sideRight.setRotationPoint(7F, 9F, 0F); - sideRight.setTextureSize(128, 64); - setRotation(sideRight, 0F, 0F, 0F); - top = new ModelRenderer(this, 80, 0); - top.addBox(0F, 0F, 0F, 16, 1, 7); - top.setRotationPoint(-8F, 8F, 0F); - top.setTextureSize(128, 64); - top.mirror = true; - setRotation(top, 0F, 0F, 0F); - sideLeft = new ModelRenderer(this, 64, 0); - sideLeft.addBox(0F, 0F, 0F, 1, 11, 7); - sideLeft.setRotationPoint(-8F, 9F, 0F); - sideLeft.setTextureSize(128, 64); - sideLeft.mirror = true; - setRotation(sideLeft, 0F, 0F, 0F); - tap1 = new ModelRenderer(this, 80, 8); - tap1.addBox(0F, 0F, 0F, 2, 1, 11); - tap1.setRotationPoint(-4.5F, 11.5F, -4F); - tap1.setTextureSize(128, 64); - tap1.mirror = true; - setRotation(tap1, 0F, 0F, 0F); - tap2 = new ModelRenderer(this, 80, 8); - tap2.addBox(0F, 0F, 0F, 2, 1, 11); - tap2.setRotationPoint(2.5F, 11.5F, -4F); - tap2.setTextureSize(128, 64); - tap2.mirror = true; - setRotation(tap2, 0F, 0F, 0F); - tapBase1 = new ModelRenderer(this, 4, 0); - tapBase1.addBox(0F, 0F, 0F, 2, 1, 2); - tapBase1.setRotationPoint(-4.5F, 12.5F, 5F); - tapBase1.setTextureSize(128, 64); - tapBase1.mirror = true; - setRotation(tapBase1, 0F, 0F, 0F); - tapBase2 = new ModelRenderer(this, 4, 0); - tapBase2.addBox(0F, 0F, 0F, 2, 1, 2); - tapBase2.setRotationPoint(2.5F, 12.5F, 5F); - tapBase2.setTextureSize(128, 64); - tapBase2.mirror = true; - setRotation(tapBase2, 0F, 0F, 0F); - divider = new ModelRenderer(this, 66, 20); - divider.addBox(0F, 0F, 0F, 13, 1, 14); - divider.setRotationPoint(-6.5F, 16F, -6.5F); - divider.setTextureSize(128, 64); - divider.mirror = true; - setRotation(divider, 0F, 0F, 0F); - plate1 = new ModelRenderer(this, 0, 20); - plate1.addBox(0F, 0F, 0F, 14, 3, 14); - plate1.setRotationPoint(-7F, 9F, -7F); - plate1.setTextureSize(128, 64); - plate1.mirror = true; - setRotation(plate1, 0F, 0F, 0F); - plate2 = new ModelRenderer(this, 0, 37); - plate2.addBox(0F, 0F, 0F, 14, 3, 14); - plate2.setRotationPoint(-7F, 13F, -7F); - plate2.setTextureSize(128, 64); - plate2.mirror = true; - setRotation(plate2, 0F, 0F, 0F); - plate3 = new ModelRenderer(this, 0, 37); - plate3.addBox(0F, 0F, 0F, 14, 3, 14); - plate3.setRotationPoint(-7F, 17F, -7F); - plate3.setTextureSize(128, 64); - plate3.mirror = true; - setRotation(plate3, 0F, 0F, 0F); - bar1 = new ModelRenderer(this, 0, 0); - bar1.addBox(0F, 0F, 0F, 1, 1, 1); - bar1.setRotationPoint(-6.5F, 12F, -6.5F); - bar1.setTextureSize(128, 64); - bar1.mirror = true; - setRotation(bar1, 0F, 0F, 0F); - bar2 = new ModelRenderer(this, 0, 0); - bar2.addBox(0F, 0F, 0F, 1, 1, 1); - bar2.setRotationPoint(5.5F, 12F, -6.5F); - bar2.setTextureSize(128, 64); - bar2.mirror = true; - setRotation(bar2, 0F, 0F, 0F); - } + base = new ModelRenderer(this, 0, 0); + base.addBox(0F, 0F, 0F, 16, 4, 16); + base.setRotationPoint(-8F, 20F, -8F); + base.setTextureSize(128, 64); + base.mirror = true; + setRotation(base, 0F, 0F, 0F); + back = new ModelRenderer(this, 42, 20); + back.addBox(0F, 0F, 0F, 16, 12, 1); + back.setRotationPoint(-8F, 8F, 7F); + back.setTextureSize(128, 64); + back.mirror = true; + setRotation(back, 0F, 0F, 0F); + connector1 = new ModelRenderer(this, 0, 8); + connector1.addBox(0F, 0F, 0F, 1, 5, 3); + connector1.setRotationPoint(-4F, 8.5F, -3F); + connector1.setTextureSize(128, 64); + connector1.mirror = true; + setRotation(connector1, 0F, 0F, 0F); + connector2 = new ModelRenderer(this, 0, 8); + connector2.addBox(0F, 0F, 0F, 1, 5, 3); + connector2.setRotationPoint(3F, 8.5F, -3F); + connector2.setTextureSize(128, 64); + connector2.mirror = true; + setRotation(connector2, 0F, 0F, 0F); + sideRight = new ModelRenderer(this, 64, 0); + sideRight.mirror = true; + sideRight.addBox(0F, 0F, 0F, 1, 11, 7); + sideRight.setRotationPoint(7F, 9F, 0F); + sideRight.setTextureSize(128, 64); + setRotation(sideRight, 0F, 0F, 0F); + top = new ModelRenderer(this, 80, 0); + top.addBox(0F, 0F, 0F, 16, 1, 7); + top.setRotationPoint(-8F, 8F, 0F); + top.setTextureSize(128, 64); + top.mirror = true; + setRotation(top, 0F, 0F, 0F); + sideLeft = new ModelRenderer(this, 64, 0); + sideLeft.addBox(0F, 0F, 0F, 1, 11, 7); + sideLeft.setRotationPoint(-8F, 9F, 0F); + sideLeft.setTextureSize(128, 64); + sideLeft.mirror = true; + setRotation(sideLeft, 0F, 0F, 0F); + tap1 = new ModelRenderer(this, 80, 8); + tap1.addBox(0F, 0F, 0F, 2, 1, 11); + tap1.setRotationPoint(-4.5F, 11.5F, -4F); + tap1.setTextureSize(128, 64); + tap1.mirror = true; + setRotation(tap1, 0F, 0F, 0F); + tap2 = new ModelRenderer(this, 80, 8); + tap2.addBox(0F, 0F, 0F, 2, 1, 11); + tap2.setRotationPoint(2.5F, 11.5F, -4F); + tap2.setTextureSize(128, 64); + tap2.mirror = true; + setRotation(tap2, 0F, 0F, 0F); + tapBase1 = new ModelRenderer(this, 4, 0); + tapBase1.addBox(0F, 0F, 0F, 2, 1, 2); + tapBase1.setRotationPoint(-4.5F, 12.5F, 5F); + tapBase1.setTextureSize(128, 64); + tapBase1.mirror = true; + setRotation(tapBase1, 0F, 0F, 0F); + tapBase2 = new ModelRenderer(this, 4, 0); + tapBase2.addBox(0F, 0F, 0F, 2, 1, 2); + tapBase2.setRotationPoint(2.5F, 12.5F, 5F); + tapBase2.setTextureSize(128, 64); + tapBase2.mirror = true; + setRotation(tapBase2, 0F, 0F, 0F); + divider = new ModelRenderer(this, 66, 20); + divider.addBox(0F, 0F, 0F, 13, 1, 14); + divider.setRotationPoint(-6.5F, 16F, -6.5F); + divider.setTextureSize(128, 64); + divider.mirror = true; + setRotation(divider, 0F, 0F, 0F); + plate1 = new ModelRenderer(this, 0, 20); + plate1.addBox(0F, 0F, 0F, 14, 3, 14); + plate1.setRotationPoint(-7F, 9F, -7F); + plate1.setTextureSize(128, 64); + plate1.mirror = true; + setRotation(plate1, 0F, 0F, 0F); + plate2 = new ModelRenderer(this, 0, 37); + plate2.addBox(0F, 0F, 0F, 14, 3, 14); + plate2.setRotationPoint(-7F, 13F, -7F); + plate2.setTextureSize(128, 64); + plate2.mirror = true; + setRotation(plate2, 0F, 0F, 0F); + plate3 = new ModelRenderer(this, 0, 37); + plate3.addBox(0F, 0F, 0F, 14, 3, 14); + plate3.setRotationPoint(-7F, 17F, -7F); + plate3.setTextureSize(128, 64); + plate3.mirror = true; + setRotation(plate3, 0F, 0F, 0F); + bar1 = new ModelRenderer(this, 0, 0); + bar1.addBox(0F, 0F, 0F, 1, 1, 1); + bar1.setRotationPoint(-6.5F, 12F, -6.5F); + bar1.setTextureSize(128, 64); + bar1.mirror = true; + setRotation(bar1, 0F, 0F, 0F); + bar2 = new ModelRenderer(this, 0, 0); + bar2.addBox(0F, 0F, 0F, 1, 1, 1); + bar2.setRotationPoint(5.5F, 12F, -6.5F); + bar2.setTextureSize(128, 64); + bar2.mirror = true; + setRotation(bar2, 0F, 0F, 0F); + } - public void render(float size) - { - base.render(size); - back.render(size); - connector1.render(size); - connector2.render(size); - sideRight.render(size); - top.render(size); - sideLeft.render(size); - tap1.render(size); - tap2.render(size); - tapBase1.render(size); - tapBase2.render(size); - divider.render(size); - plate1.render(size); - plate2.render(size); - plate3.render(size); - bar1.render(size); - bar2.render(size); - } + public void render(float size) { + base.render(size); + back.render(size); + connector1.render(size); + connector2.render(size); + sideRight.render(size); + top.render(size); + sideLeft.render(size); + tap1.render(size); + tap2.render(size); + tapBase1.render(size); + tapBase2.render(size); + divider.render(size); + plate1.render(size); + plate2.render(size); + plate3.render(size); + bar1.render(size); + bar2.render(size); + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/mekanism/client/model/ModelObsidianTNT.java b/src/main/java/mekanism/client/model/ModelObsidianTNT.java index 574c63811..82135497d 100644 --- a/src/main/java/mekanism/client/model/ModelObsidianTNT.java +++ b/src/main/java/mekanism/client/model/ModelObsidianTNT.java @@ -1,189 +1,185 @@ package mekanism.client.model; -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; @SideOnly(Side.CLIENT) -public class ModelObsidianTNT extends ModelBase -{ - ModelRenderer Wick9; - ModelRenderer Wick8; - ModelRenderer Wick7; - ModelRenderer Wick6; - ModelRenderer Wick5; - ModelRenderer Wick4; - ModelRenderer Wick3; - ModelRenderer Wick2; - ModelRenderer Wick1; - ModelRenderer Wooden2; - ModelRenderer Wooden1; - ModelRenderer Rod1; - ModelRenderer Rod2; - ModelRenderer Rod3; - ModelRenderer Rod4; - ModelRenderer Rod5; - ModelRenderer Rod6; - ModelRenderer Rod7; - ModelRenderer Rod8; - ModelRenderer Rod9; +public class ModelObsidianTNT extends ModelBase { + ModelRenderer Wick9; + ModelRenderer Wick8; + ModelRenderer Wick7; + ModelRenderer Wick6; + ModelRenderer Wick5; + ModelRenderer Wick4; + ModelRenderer Wick3; + ModelRenderer Wick2; + ModelRenderer Wick1; + ModelRenderer Wooden2; + ModelRenderer Wooden1; + ModelRenderer Rod1; + ModelRenderer Rod2; + ModelRenderer Rod3; + ModelRenderer Rod4; + ModelRenderer Rod5; + ModelRenderer Rod6; + ModelRenderer Rod7; + ModelRenderer Rod8; + ModelRenderer Rod9; - public ModelObsidianTNT() - { - textureWidth = 64; - textureHeight = 64; + public ModelObsidianTNT() { + textureWidth = 64; + textureHeight = 64; - Wick9 = new ModelRenderer(this, 0, 0); - Wick9.addBox(0F, 0F, 0F, 1, 2, 1); - Wick9.setRotationPoint(-0.5F, 9.2F, -0.5F); - Wick9.setTextureSize(64, 64); - Wick9.mirror = true; - setRotation(Wick9, 0F, 0F, 0.2268928F); - Wick8 = new ModelRenderer(this, 0, 0); - Wick8.addBox(0F, 0F, 0F, 1, 2, 1); - Wick8.setRotationPoint(-0.5F, 9.5F, -5.5F); - Wick8.setTextureSize(64, 64); - Wick8.mirror = true; - setRotation(Wick8, 0F, 0F, -0.2379431F); - Wick7 = new ModelRenderer(this, 0, 0); - Wick7.addBox(0F, 0F, 0F, 1, 2, 1); - Wick7.setRotationPoint(-0.5F, 9.5F, 4.5F); - Wick7.setTextureSize(64, 64); - Wick7.mirror = true; - setRotation(Wick7, 0F, 0F, -0.2379431F); - Wick6 = new ModelRenderer(this, 0, 0); - Wick6.addBox(0F, 0F, 0F, 1, 2, 1); - Wick6.setRotationPoint(-5.5F, 9.2F, -5.5F); - Wick6.setTextureSize(64, 64); - Wick6.mirror = true; - setRotation(Wick6, 0F, 0F, 0.2268928F); - Wick5 = new ModelRenderer(this, 0, 0); - Wick5.addBox(0F, 0F, 0F, 1, 2, 1); - Wick5.setRotationPoint(-5.5F, 9.5F, -0.5F); - Wick5.setTextureSize(64, 64); - Wick5.mirror = true; - setRotation(Wick5, 0F, 0F, -0.2379431F); - Wick4 = new ModelRenderer(this, 0, 0); - Wick4.addBox(0F, 0F, 0F, 1, 2, 1); - Wick4.setRotationPoint(-5.5F, 9.2F, 4.5F); - Wick4.setTextureSize(64, 64); - Wick4.mirror = true; - setRotation(Wick4, 0F, 0F, 0.2268928F); - Wick3 = new ModelRenderer(this, 0, 0); - Wick3.addBox(0F, 0F, 0F, 1, 2, 1); - Wick3.setRotationPoint(4.5F, 9.2F, -5.5F); - Wick3.setTextureSize(64, 64); - Wick3.mirror = true; - setRotation(Wick3, 0F, 0F, 0.2268928F); - Wick2 = new ModelRenderer(this, 0, 0); - Wick2.addBox(0F, 0F, 0F, 1, 2, 1); - Wick2.setRotationPoint(4.5F, 9.5F, -0.5F); - Wick2.setTextureSize(64, 64); - Wick2.mirror = true; - setRotation(Wick2, 0F, 0F, -0.2379431F); - Wick1 = new ModelRenderer(this, 0, 0); - Wick1.addBox(0F, 0F, 0F, 1, 2, 1); - Wick1.setRotationPoint(4.5F, 9.2F, 4.5F); - Wick1.setTextureSize(64, 64); - Wick1.mirror = true; - setRotation(Wick1, 0F, 0F, 0.2268928F); - Wooden2 = new ModelRenderer(this, 0, 0); - Wooden2.addBox(0F, 0F, 0F, 16, 3, 16); - Wooden2.setRotationPoint(-8F, 12F, -8F); - Wooden2.setTextureSize(64, 64); - Wooden2.mirror = true; - setRotation(Wooden2, 0F, 0F, 0F); - Wooden1 = new ModelRenderer(this, 0, 0); - Wooden1.addBox(0F, 0F, 0F, 16, 3, 16); - Wooden1.setRotationPoint(-8F, 20F, -8F); - Wooden1.setTextureSize(64, 64); - Wooden1.mirror = true; - setRotation(Wooden1, 0F, 0F, 0F); - Rod1 = new ModelRenderer(this, 0, 20); - Rod1.addBox(0F, 0F, 0F, 4, 13, 4); - Rod1.setRotationPoint(3F, 11F, 3F); - Rod1.setTextureSize(64, 64); - Rod1.mirror = true; - setRotation(Rod1, 0F, 0F, 0F); - Rod2 = new ModelRenderer(this, 0, 20); - Rod2.addBox(0F, 0F, 0F, 4, 13, 4); - Rod2.setRotationPoint(3F, 11F, -2F); - Rod2.setTextureSize(64, 64); - Rod2.mirror = true; - setRotation(Rod2, 0F, 0F, 0F); - Rod3 = new ModelRenderer(this, 0, 20); - Rod3.addBox(0F, 0F, 0F, 4, 13, 4); - Rod3.setRotationPoint(3F, 11F, -7F); - Rod3.setTextureSize(64, 64); - Rod3.mirror = true; - setRotation(Rod3, 0F, 0F, 0F); - Rod4 = new ModelRenderer(this, 0, 20); - Rod4.addBox(0F, 0F, 0F, 4, 13, 4); - Rod4.setRotationPoint(-2F, 11F, -7F); - Rod4.setTextureSize(64, 64); - Rod4.mirror = true; - setRotation(Rod4, 0F, 0F, 0F); - Rod5 = new ModelRenderer(this, 0, 20); - Rod5.addBox(0F, 0F, 0F, 4, 13, 4); - Rod5.setRotationPoint(-2F, 11F, -2F); - Rod5.setTextureSize(64, 64); - Rod5.mirror = true; - setRotation(Rod5, 0F, 0F, 0F); - Rod6 = new ModelRenderer(this, 0, 20); - Rod6.addBox(0F, 0F, 0F, 4, 13, 4); - Rod6.setRotationPoint(-2F, 11F, 3F); - Rod6.setTextureSize(64, 64); - Rod6.mirror = true; - setRotation(Rod6, 0F, 0F, 0F); - Rod7 = new ModelRenderer(this, 0, 20); - Rod7.addBox(0F, 0F, 0F, 4, 13, 4); - Rod7.setRotationPoint(-7F, 11F, -2F); - Rod7.setTextureSize(64, 64); - Rod7.mirror = true; - setRotation(Rod7, 0F, 0F, 0F); - Rod8 = new ModelRenderer(this, 0, 20); - Rod8.addBox(0F, 0F, 0F, 4, 13, 4); - Rod8.setRotationPoint(-7F, 11F, 3F); - Rod8.setTextureSize(64, 64); - Rod8.mirror = true; - setRotation(Rod8, 0F, 0F, 0F); - Rod9 = new ModelRenderer(this, 0, 20); - Rod9.addBox(0F, 0F, 0F, 4, 13, 4); - Rod9.setRotationPoint(-7F, 11F, -7F); - Rod9.setTextureSize(64, 64); - Rod9.mirror = true; - setRotation(Rod9, 0F, 0F, 0F); - } + Wick9 = new ModelRenderer(this, 0, 0); + Wick9.addBox(0F, 0F, 0F, 1, 2, 1); + Wick9.setRotationPoint(-0.5F, 9.2F, -0.5F); + Wick9.setTextureSize(64, 64); + Wick9.mirror = true; + setRotation(Wick9, 0F, 0F, 0.2268928F); + Wick8 = new ModelRenderer(this, 0, 0); + Wick8.addBox(0F, 0F, 0F, 1, 2, 1); + Wick8.setRotationPoint(-0.5F, 9.5F, -5.5F); + Wick8.setTextureSize(64, 64); + Wick8.mirror = true; + setRotation(Wick8, 0F, 0F, -0.2379431F); + Wick7 = new ModelRenderer(this, 0, 0); + Wick7.addBox(0F, 0F, 0F, 1, 2, 1); + Wick7.setRotationPoint(-0.5F, 9.5F, 4.5F); + Wick7.setTextureSize(64, 64); + Wick7.mirror = true; + setRotation(Wick7, 0F, 0F, -0.2379431F); + Wick6 = new ModelRenderer(this, 0, 0); + Wick6.addBox(0F, 0F, 0F, 1, 2, 1); + Wick6.setRotationPoint(-5.5F, 9.2F, -5.5F); + Wick6.setTextureSize(64, 64); + Wick6.mirror = true; + setRotation(Wick6, 0F, 0F, 0.2268928F); + Wick5 = new ModelRenderer(this, 0, 0); + Wick5.addBox(0F, 0F, 0F, 1, 2, 1); + Wick5.setRotationPoint(-5.5F, 9.5F, -0.5F); + Wick5.setTextureSize(64, 64); + Wick5.mirror = true; + setRotation(Wick5, 0F, 0F, -0.2379431F); + Wick4 = new ModelRenderer(this, 0, 0); + Wick4.addBox(0F, 0F, 0F, 1, 2, 1); + Wick4.setRotationPoint(-5.5F, 9.2F, 4.5F); + Wick4.setTextureSize(64, 64); + Wick4.mirror = true; + setRotation(Wick4, 0F, 0F, 0.2268928F); + Wick3 = new ModelRenderer(this, 0, 0); + Wick3.addBox(0F, 0F, 0F, 1, 2, 1); + Wick3.setRotationPoint(4.5F, 9.2F, -5.5F); + Wick3.setTextureSize(64, 64); + Wick3.mirror = true; + setRotation(Wick3, 0F, 0F, 0.2268928F); + Wick2 = new ModelRenderer(this, 0, 0); + Wick2.addBox(0F, 0F, 0F, 1, 2, 1); + Wick2.setRotationPoint(4.5F, 9.5F, -0.5F); + Wick2.setTextureSize(64, 64); + Wick2.mirror = true; + setRotation(Wick2, 0F, 0F, -0.2379431F); + Wick1 = new ModelRenderer(this, 0, 0); + Wick1.addBox(0F, 0F, 0F, 1, 2, 1); + Wick1.setRotationPoint(4.5F, 9.2F, 4.5F); + Wick1.setTextureSize(64, 64); + Wick1.mirror = true; + setRotation(Wick1, 0F, 0F, 0.2268928F); + Wooden2 = new ModelRenderer(this, 0, 0); + Wooden2.addBox(0F, 0F, 0F, 16, 3, 16); + Wooden2.setRotationPoint(-8F, 12F, -8F); + Wooden2.setTextureSize(64, 64); + Wooden2.mirror = true; + setRotation(Wooden2, 0F, 0F, 0F); + Wooden1 = new ModelRenderer(this, 0, 0); + Wooden1.addBox(0F, 0F, 0F, 16, 3, 16); + Wooden1.setRotationPoint(-8F, 20F, -8F); + Wooden1.setTextureSize(64, 64); + Wooden1.mirror = true; + setRotation(Wooden1, 0F, 0F, 0F); + Rod1 = new ModelRenderer(this, 0, 20); + Rod1.addBox(0F, 0F, 0F, 4, 13, 4); + Rod1.setRotationPoint(3F, 11F, 3F); + Rod1.setTextureSize(64, 64); + Rod1.mirror = true; + setRotation(Rod1, 0F, 0F, 0F); + Rod2 = new ModelRenderer(this, 0, 20); + Rod2.addBox(0F, 0F, 0F, 4, 13, 4); + Rod2.setRotationPoint(3F, 11F, -2F); + Rod2.setTextureSize(64, 64); + Rod2.mirror = true; + setRotation(Rod2, 0F, 0F, 0F); + Rod3 = new ModelRenderer(this, 0, 20); + Rod3.addBox(0F, 0F, 0F, 4, 13, 4); + Rod3.setRotationPoint(3F, 11F, -7F); + Rod3.setTextureSize(64, 64); + Rod3.mirror = true; + setRotation(Rod3, 0F, 0F, 0F); + Rod4 = new ModelRenderer(this, 0, 20); + Rod4.addBox(0F, 0F, 0F, 4, 13, 4); + Rod4.setRotationPoint(-2F, 11F, -7F); + Rod4.setTextureSize(64, 64); + Rod4.mirror = true; + setRotation(Rod4, 0F, 0F, 0F); + Rod5 = new ModelRenderer(this, 0, 20); + Rod5.addBox(0F, 0F, 0F, 4, 13, 4); + Rod5.setRotationPoint(-2F, 11F, -2F); + Rod5.setTextureSize(64, 64); + Rod5.mirror = true; + setRotation(Rod5, 0F, 0F, 0F); + Rod6 = new ModelRenderer(this, 0, 20); + Rod6.addBox(0F, 0F, 0F, 4, 13, 4); + Rod6.setRotationPoint(-2F, 11F, 3F); + Rod6.setTextureSize(64, 64); + Rod6.mirror = true; + setRotation(Rod6, 0F, 0F, 0F); + Rod7 = new ModelRenderer(this, 0, 20); + Rod7.addBox(0F, 0F, 0F, 4, 13, 4); + Rod7.setRotationPoint(-7F, 11F, -2F); + Rod7.setTextureSize(64, 64); + Rod7.mirror = true; + setRotation(Rod7, 0F, 0F, 0F); + Rod8 = new ModelRenderer(this, 0, 20); + Rod8.addBox(0F, 0F, 0F, 4, 13, 4); + Rod8.setRotationPoint(-7F, 11F, 3F); + Rod8.setTextureSize(64, 64); + Rod8.mirror = true; + setRotation(Rod8, 0F, 0F, 0F); + Rod9 = new ModelRenderer(this, 0, 20); + Rod9.addBox(0F, 0F, 0F, 4, 13, 4); + Rod9.setRotationPoint(-7F, 11F, -7F); + Rod9.setTextureSize(64, 64); + Rod9.mirror = true; + setRotation(Rod9, 0F, 0F, 0F); + } - public void render(float size) - { - Wick9.render(size); - Wick8.render(size); - Wick7.render(size); - Wick6.render(size); - Wick5.render(size); - Wick4.render(size); - Wick3.render(size); - Wick2.render(size); - Wick1.render(size); - Wooden2.render(size); - Wooden1.render(size); - Rod1.render(size); - Rod2.render(size); - Rod3.render(size); - Rod4.render(size); - Rod5.render(size); - Rod6.render(size); - Rod7.render(size); - Rod8.render(size); - Rod9.render(size); - } + public void render(float size) { + Wick9.render(size); + Wick8.render(size); + Wick7.render(size); + Wick6.render(size); + Wick5.render(size); + Wick4.render(size); + Wick3.render(size); + Wick2.render(size); + Wick1.render(size); + Wooden2.render(size); + Wooden1.render(size); + Rod1.render(size); + Rod2.render(size); + Rod3.render(size); + Rod4.render(size); + Rod5.render(size); + Rod6.render(size); + Rod7.render(size); + Rod8.render(size); + Rod9.render(size); + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/mekanism/client/model/ModelPressurizedReactionChamber.java b/src/main/java/mekanism/client/model/ModelPressurizedReactionChamber.java index 4e0ae34a3..c64f8f209 100644 --- a/src/main/java/mekanism/client/model/ModelPressurizedReactionChamber.java +++ b/src/main/java/mekanism/client/model/ModelPressurizedReactionChamber.java @@ -1,109 +1,105 @@ package mekanism.client.model; -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; @SideOnly(Side.CLIENT) -public class ModelPressurizedReactionChamber extends ModelBase -{ - ModelRenderer frontDivider1; - ModelRenderer base; - ModelRenderer front; - ModelRenderer bar1; - ModelRenderer body; - ModelRenderer bar5; - ModelRenderer bar4; - ModelRenderer bar3; - ModelRenderer bar2; - ModelRenderer frontDivider2; +public class ModelPressurizedReactionChamber extends ModelBase { + ModelRenderer frontDivider1; + ModelRenderer base; + ModelRenderer front; + ModelRenderer bar1; + ModelRenderer body; + ModelRenderer bar5; + ModelRenderer bar4; + ModelRenderer bar3; + ModelRenderer bar2; + ModelRenderer frontDivider2; - public ModelPressurizedReactionChamber() - { - textureWidth = 128; - textureHeight = 64; + public ModelPressurizedReactionChamber() { + textureWidth = 128; + textureHeight = 64; - frontDivider1 = new ModelRenderer(this, 52, 20); - frontDivider1.addBox(0F, 0F, 0F, 2, 12, 6); - frontDivider1.setRotationPoint(-7F, 8.5F, -7.5F); - frontDivider1.setTextureSize(128, 64); - frontDivider1.mirror = true; - setRotation(frontDivider1, 0F, 0F, 0F); - base = new ModelRenderer(this, 0, 0); - base.addBox(0F, 0F, 0F, 16, 4, 16); - base.setRotationPoint(-8F, 20F, -8F); - base.setTextureSize(128, 64); - base.mirror = true; - setRotation(base, 0F, 0F, 0F); - front = new ModelRenderer(this, 48, 0); - front.addBox(0F, 0F, 0F, 9, 11, 5); - front.setRotationPoint(-2F, 9F, -7F); - front.setTextureSize(128, 64); - front.mirror = true; - setRotation(front, 0F, 0F, 0F); - bar1 = new ModelRenderer(this, 0, 0); - bar1.addBox(0F, 0F, 0F, 1, 1, 5); - bar1.setRotationPoint(-5F, 18F, -7F); - bar1.setTextureSize(128, 64); - bar1.mirror = true; - setRotation(bar1, 0F, 0F, 0F); - body = new ModelRenderer(this, 0, 20); - body.addBox(0F, 0F, 0F, 16, 12, 10); - body.setRotationPoint(-8F, 8F, -2F); - body.setTextureSize(128, 64); - body.mirror = true; - setRotation(body, 0F, 0F, 0F); - bar5 = new ModelRenderer(this, 0, 0); - bar5.addBox(0F, 0F, 0F, 1, 1, 5); - bar5.setRotationPoint(-5F, 10F, -7F); - bar5.setTextureSize(128, 64); - bar5.mirror = true; - setRotation(bar5, 0F, 0F, 0F); - bar4 = new ModelRenderer(this, 0, 0); - bar4.addBox(0F, 0F, 0F, 1, 1, 5); - bar4.setRotationPoint(-5F, 12F, -7F); - bar4.setTextureSize(128, 64); - bar4.mirror = true; - setRotation(bar4, 0F, 0F, 0F); - bar3 = new ModelRenderer(this, 0, 0); - bar3.addBox(0F, 0F, 0F, 1, 1, 5); - bar3.setRotationPoint(-5F, 14F, -7F); - bar3.setTextureSize(128, 64); - bar3.mirror = true; - setRotation(bar3, 0F, 0F, 0F); - bar2 = new ModelRenderer(this, 0, 0); - bar2.addBox(0F, 0F, 0F, 1, 1, 5); - bar2.setRotationPoint(-5F, 16F, -7F); - bar2.setTextureSize(128, 64); - bar2.mirror = true; - setRotation(bar2, 0F, 0F, 0F); - frontDivider2 = new ModelRenderer(this, 52, 20); - frontDivider2.mirror = true; - frontDivider2.addBox(0F, 0F, 0F, 2, 12, 6); - frontDivider2.setRotationPoint(-4F, 8.5F, -7.5F); - frontDivider2.setTextureSize(128, 64); - setRotation(frontDivider2, 0F, 0F, 0F); - } + frontDivider1 = new ModelRenderer(this, 52, 20); + frontDivider1.addBox(0F, 0F, 0F, 2, 12, 6); + frontDivider1.setRotationPoint(-7F, 8.5F, -7.5F); + frontDivider1.setTextureSize(128, 64); + frontDivider1.mirror = true; + setRotation(frontDivider1, 0F, 0F, 0F); + base = new ModelRenderer(this, 0, 0); + base.addBox(0F, 0F, 0F, 16, 4, 16); + base.setRotationPoint(-8F, 20F, -8F); + base.setTextureSize(128, 64); + base.mirror = true; + setRotation(base, 0F, 0F, 0F); + front = new ModelRenderer(this, 48, 0); + front.addBox(0F, 0F, 0F, 9, 11, 5); + front.setRotationPoint(-2F, 9F, -7F); + front.setTextureSize(128, 64); + front.mirror = true; + setRotation(front, 0F, 0F, 0F); + bar1 = new ModelRenderer(this, 0, 0); + bar1.addBox(0F, 0F, 0F, 1, 1, 5); + bar1.setRotationPoint(-5F, 18F, -7F); + bar1.setTextureSize(128, 64); + bar1.mirror = true; + setRotation(bar1, 0F, 0F, 0F); + body = new ModelRenderer(this, 0, 20); + body.addBox(0F, 0F, 0F, 16, 12, 10); + body.setRotationPoint(-8F, 8F, -2F); + body.setTextureSize(128, 64); + body.mirror = true; + setRotation(body, 0F, 0F, 0F); + bar5 = new ModelRenderer(this, 0, 0); + bar5.addBox(0F, 0F, 0F, 1, 1, 5); + bar5.setRotationPoint(-5F, 10F, -7F); + bar5.setTextureSize(128, 64); + bar5.mirror = true; + setRotation(bar5, 0F, 0F, 0F); + bar4 = new ModelRenderer(this, 0, 0); + bar4.addBox(0F, 0F, 0F, 1, 1, 5); + bar4.setRotationPoint(-5F, 12F, -7F); + bar4.setTextureSize(128, 64); + bar4.mirror = true; + setRotation(bar4, 0F, 0F, 0F); + bar3 = new ModelRenderer(this, 0, 0); + bar3.addBox(0F, 0F, 0F, 1, 1, 5); + bar3.setRotationPoint(-5F, 14F, -7F); + bar3.setTextureSize(128, 64); + bar3.mirror = true; + setRotation(bar3, 0F, 0F, 0F); + bar2 = new ModelRenderer(this, 0, 0); + bar2.addBox(0F, 0F, 0F, 1, 1, 5); + bar2.setRotationPoint(-5F, 16F, -7F); + bar2.setTextureSize(128, 64); + bar2.mirror = true; + setRotation(bar2, 0F, 0F, 0F); + frontDivider2 = new ModelRenderer(this, 52, 20); + frontDivider2.mirror = true; + frontDivider2.addBox(0F, 0F, 0F, 2, 12, 6); + frontDivider2.setRotationPoint(-4F, 8.5F, -7.5F); + frontDivider2.setTextureSize(128, 64); + setRotation(frontDivider2, 0F, 0F, 0F); + } - public void render(float size) - { - frontDivider1.render(size); - base.render(size); - front.render(size); - bar1.render(size); - body.render(size); - bar5.render(size); - bar4.render(size); - bar3.render(size); - bar2.render(size); - frontDivider2.render(size); - } + public void render(float size) { + frontDivider1.render(size); + base.render(size); + front.render(size); + bar1.render(size); + body.render(size); + bar5.render(size); + bar4.render(size); + bar3.render(size); + bar2.render(size); + frontDivider2.render(size); + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/mekanism/client/model/ModelQuantumEntangloporter.java b/src/main/java/mekanism/client/model/ModelQuantumEntangloporter.java index ce935ceba..5f623aaa7 100644 --- a/src/main/java/mekanism/client/model/ModelQuantumEntangloporter.java +++ b/src/main/java/mekanism/client/model/ModelQuantumEntangloporter.java @@ -1,5 +1,7 @@ package mekanism.client.model; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.render.MekanismRenderer; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; @@ -7,380 +9,373 @@ import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class ModelQuantumEntangloporter extends ModelBase -{ - public static ResourceLocation OVERLAY = MekanismUtils.getResource(ResourceType.RENDER, "QuantumEntangloporter_Overlay.png"); - - ModelRenderer portTop; - ModelRenderer portBottom; - ModelRenderer portLeft; - ModelRenderer portRight; - ModelRenderer portBack; - ModelRenderer portFront; - ModelRenderer energyCubeCore; - ModelRenderer frameEdge1; - ModelRenderer frameEdge2; - ModelRenderer frameEdge3; - ModelRenderer frameEdge4; - ModelRenderer frameEdge5; - ModelRenderer frameEdge6; - ModelRenderer frameEdge7; - ModelRenderer frameEdge8; - ModelRenderer frameEdge9; - ModelRenderer frameEdge10; - ModelRenderer frameEdge11; - ModelRenderer frameEdge12; - ModelRenderer frame1; - ModelRenderer frame2; - ModelRenderer frame3; - ModelRenderer frame4; - ModelRenderer frame5; - ModelRenderer frame6; - ModelRenderer frame7; - ModelRenderer frame8; - ModelRenderer frame9; - ModelRenderer frame10; - ModelRenderer frame11; - ModelRenderer frame12; - ModelRenderer corner1; - ModelRenderer corner2; - ModelRenderer corner3; - ModelRenderer corner4; - ModelRenderer corner5; - ModelRenderer corner6; - ModelRenderer corner7; - ModelRenderer corner8; - ModelRenderer portRightLarge; - ModelRenderer portLeftLarge; +public class ModelQuantumEntangloporter extends ModelBase { + public static ResourceLocation OVERLAY = MekanismUtils.getResource( + ResourceType.RENDER, "QuantumEntangloporter_Overlay.png" + ); - public ModelQuantumEntangloporter() - { - textureWidth = 128; - textureHeight = 64; + ModelRenderer portTop; + ModelRenderer portBottom; + ModelRenderer portLeft; + ModelRenderer portRight; + ModelRenderer portBack; + ModelRenderer portFront; + ModelRenderer energyCubeCore; + ModelRenderer frameEdge1; + ModelRenderer frameEdge2; + ModelRenderer frameEdge3; + ModelRenderer frameEdge4; + ModelRenderer frameEdge5; + ModelRenderer frameEdge6; + ModelRenderer frameEdge7; + ModelRenderer frameEdge8; + ModelRenderer frameEdge9; + ModelRenderer frameEdge10; + ModelRenderer frameEdge11; + ModelRenderer frameEdge12; + ModelRenderer frame1; + ModelRenderer frame2; + ModelRenderer frame3; + ModelRenderer frame4; + ModelRenderer frame5; + ModelRenderer frame6; + ModelRenderer frame7; + ModelRenderer frame8; + ModelRenderer frame9; + ModelRenderer frame10; + ModelRenderer frame11; + ModelRenderer frame12; + ModelRenderer corner1; + ModelRenderer corner2; + ModelRenderer corner3; + ModelRenderer corner4; + ModelRenderer corner5; + ModelRenderer corner6; + ModelRenderer corner7; + ModelRenderer corner8; + ModelRenderer portRightLarge; + ModelRenderer portLeftLarge; - portTop = new ModelRenderer(this, 36, 0); - portTop.addBox(0F, 0F, 0F, 8, 1, 8); - portTop.setRotationPoint(-4F, 8F, -4F); - portTop.setTextureSize(128, 64); - portTop.mirror = true; - setRotation(portTop, 0F, 0F, 0F); - portBottom = new ModelRenderer(this, 36, 9); - portBottom.addBox(0F, 0F, 0F, 8, 1, 8); - portBottom.setRotationPoint(-4F, 23F, -4F); - portBottom.setTextureSize(128, 64); - portBottom.mirror = true; - setRotation(portBottom, 0F, 0F, 0F); - portLeft = new ModelRenderer(this, 0, 0); - portLeft.addBox(0F, 0F, 0F, 1, 8, 8); - portLeft.setRotationPoint(-8F, 12F, -4F); - portLeft.setTextureSize(128, 64); - portLeft.mirror = true; - setRotation(portLeft, 0F, 0F, 0F); - portRight = new ModelRenderer(this, 0, 0); - portRight.mirror = true; - portRight.addBox(0F, 0F, 0F, 1, 8, 8); - portRight.setRotationPoint(7F, 12F, -4F); - portRight.setTextureSize(128, 64); - setRotation(portRight, 0F, 0F, 0F); - portBack = new ModelRenderer(this, 18, 9); - portBack.addBox(0F, 0F, 0F, 8, 8, 1); - portBack.setRotationPoint(-4F, 12F, 7F); - portBack.setTextureSize(128, 64); - portBack.mirror = true; - setRotation(portBack, 0F, 0F, 0F); - portFront = new ModelRenderer(this, 18, 0); - portFront.addBox(0F, 0F, 0F, 8, 8, 1); - portFront.setRotationPoint(-4F, 12F, -8F); - portFront.setTextureSize(128, 64); - portFront.mirror = true; - setRotation(portFront, 0F, 0F, 0F); - energyCubeCore = new ModelRenderer(this, 0, 41); - energyCubeCore.addBox(-2F, -2F, -2F, 4, 4, 4); - energyCubeCore.setRotationPoint(0F, 16F, 0F); - energyCubeCore.setTextureSize(128, 64); - energyCubeCore.mirror = true; - setRotation(energyCubeCore, 0.7132579F, 0.403365F, 0.645384F); - frameEdge1 = new ModelRenderer(this, 0, 16); - frameEdge1.addBox(0F, 0F, 0F, 1, 10, 1); - frameEdge1.setRotationPoint(-7.5F, 11F, -7.5F); - frameEdge1.setTextureSize(128, 64); - frameEdge1.mirror = true; - setRotation(frameEdge1, 0F, 0F, 0F); - frameEdge2 = new ModelRenderer(this, 0, 16); - frameEdge2.addBox(0F, 0F, 0F, 1, 10, 1); - frameEdge2.setRotationPoint(6.5F, 11F, -7.5F); - frameEdge2.setTextureSize(128, 64); - frameEdge2.mirror = true; - setRotation(frameEdge2, 0F, 0F, 0F); - frameEdge3 = new ModelRenderer(this, 0, 16); - frameEdge3.addBox(0F, 0F, 0F, 1, 10, 1); - frameEdge3.setRotationPoint(-7.5F, 11F, 6.5F); - frameEdge3.setTextureSize(128, 64); - frameEdge3.mirror = true; - setRotation(frameEdge3, 0F, 0F, 0F); - frameEdge4 = new ModelRenderer(this, 0, 16); - frameEdge4.addBox(0F, 0F, 0F, 1, 10, 1); - frameEdge4.setRotationPoint(6.5F, 11F, 6.5F); - frameEdge4.setTextureSize(128, 64); - frameEdge4.mirror = true; - setRotation(frameEdge4, 0F, 0F, 0F); - frameEdge5 = new ModelRenderer(this, 4, 27); - frameEdge5.addBox(0F, 0F, 0F, 10, 1, 1); - frameEdge5.setRotationPoint(-5F, 22.5F, -7.5F); - frameEdge5.setTextureSize(128, 64); - frameEdge5.mirror = true; - setRotation(frameEdge5, 0F, 0F, 0F); - frameEdge6 = new ModelRenderer(this, 4, 16); - frameEdge6.addBox(0F, 0F, 0F, 1, 1, 10); - frameEdge6.setRotationPoint(-7.5F, 22.5F, -5F); - frameEdge6.setTextureSize(128, 64); - frameEdge6.mirror = true; - setRotation(frameEdge6, 0F, 0F, 0F); - frameEdge7 = new ModelRenderer(this, 4, 16); - frameEdge7.addBox(0F, 0F, 0F, 1, 1, 10); - frameEdge7.setRotationPoint(6.5F, 22.5F, -5F); - frameEdge7.setTextureSize(128, 64); - frameEdge7.mirror = true; - setRotation(frameEdge7, 0F, 0F, 0F); - frameEdge8 = new ModelRenderer(this, 4, 27); - frameEdge8.addBox(0F, 0F, 0F, 10, 1, 1); - frameEdge8.setRotationPoint(-5F, 22.5F, 6.5F); - frameEdge8.setTextureSize(128, 64); - frameEdge8.mirror = true; - setRotation(frameEdge8, 0F, 0F, 0F); - frameEdge9 = new ModelRenderer(this, 4, 27); - frameEdge9.addBox(0F, 0F, 0F, 10, 1, 1); - frameEdge9.setRotationPoint(-5F, 8.5F, -7.5F); - frameEdge9.setTextureSize(128, 64); - frameEdge9.mirror = true; - setRotation(frameEdge9, 0F, 0F, 0F); - frameEdge10 = new ModelRenderer(this, 4, 16); - frameEdge10.addBox(0F, 0F, 0F, 1, 1, 10); - frameEdge10.setRotationPoint(-7.5F, 8.5F, -5F); - frameEdge10.setTextureSize(128, 64); - frameEdge10.mirror = true; - setRotation(frameEdge10, 0F, 0F, 0F); - frameEdge11 = new ModelRenderer(this, 4, 16); - frameEdge11.addBox(0F, 0F, 0F, 1, 1, 10); - frameEdge11.setRotationPoint(6.5F, 8.5F, -5F); - frameEdge11.setTextureSize(128, 64); - frameEdge11.mirror = true; - setRotation(frameEdge11, 0F, 0F, 0F); - frameEdge12 = new ModelRenderer(this, 4, 27); - frameEdge12.addBox(0F, 0F, 0F, 10, 1, 1); - frameEdge12.setRotationPoint(-5F, 8.5F, 6.5F); - frameEdge12.setTextureSize(128, 64); - frameEdge12.mirror = true; - setRotation(frameEdge12, 0F, 0F, 0F); - frame1 = new ModelRenderer(this, 0, 29); - frame1.addBox(0F, 0F, 0F, 2, 10, 2); - frame1.setRotationPoint(-7F, 11F, -7F); - frame1.setTextureSize(128, 64); - frame1.mirror = true; - setRotation(frame1, 0F, 0F, 0F); - frame2 = new ModelRenderer(this, 0, 29); - frame2.mirror = true; - frame2.addBox(0F, 0F, 0F, 2, 10, 2); - frame2.setRotationPoint(5F, 11F, -7F); - frame2.setTextureSize(128, 64); - setRotation(frame2, 0F, 0F, 0F); - frame3 = new ModelRenderer(this, 8, 29); - frame3.addBox(0F, 0F, 0F, 2, 10, 2); - frame3.setRotationPoint(-7F, 11F, 5F); - frame3.setTextureSize(128, 64); - frame3.mirror = true; - setRotation(frame3, 0F, 0F, 0F); - frame4 = new ModelRenderer(this, 8, 29); - frame4.mirror = true; - frame4.addBox(0F, 0F, 0F, 2, 10, 2); - frame4.setRotationPoint(5F, 11F, 5F); - frame4.setTextureSize(128, 64); - setRotation(frame4, 0F, 0F, 0F); - frame5 = new ModelRenderer(this, 16, 45); - frame5.addBox(0F, 0F, 0F, 10, 2, 2); - frame5.setRotationPoint(-5F, 21F, -7F); - frame5.setTextureSize(128, 64); - frame5.mirror = true; - setRotation(frame5, 0F, 0F, 0F); - frame6 = new ModelRenderer(this, 40, 29); - frame6.addBox(0F, 0F, 0F, 2, 2, 10); - frame6.setRotationPoint(-7F, 21F, -5F); - frame6.setTextureSize(128, 64); - frame6.mirror = true; - setRotation(frame6, 0F, 0F, 0F); - frame7 = new ModelRenderer(this, 40, 29); - frame7.mirror = true; - frame7.addBox(0F, 0F, 0F, 2, 2, 10); - frame7.setRotationPoint(5F, 21F, -5F); - frame7.setTextureSize(128, 64); - setRotation(frame7, 0F, 0F, 0F); - frame8 = new ModelRenderer(this, 16, 49); - frame8.addBox(0F, 0F, 0F, 10, 2, 2); - frame8.setRotationPoint(-5F, 21F, 5F); - frame8.setTextureSize(128, 64); - frame8.mirror = true; - setRotation(frame8, 0F, 0F, 0F); - frame9 = new ModelRenderer(this, 16, 41); - frame9.addBox(0F, 0F, 0F, 10, 2, 2); - frame9.setRotationPoint(-5F, 9F, -7F); - frame9.setTextureSize(128, 64); - frame9.mirror = true; - setRotation(frame9, 0F, 0F, 0F); - frame10 = new ModelRenderer(this, 16, 29); - frame10.addBox(0F, 0F, 0F, 2, 2, 10); - frame10.setRotationPoint(-7F, 9F, -5F); - frame10.setTextureSize(128, 64); - frame10.mirror = true; - setRotation(frame10, 0F, 0F, 0F); - frame11 = new ModelRenderer(this, 16, 29); - frame11.mirror = true; - frame11.addBox(0F, 0F, 0F, 2, 2, 10); - frame11.setRotationPoint(5F, 9F, -5F); - frame11.setTextureSize(128, 64); - setRotation(frame11, 0F, 0F, 0F); - frame12 = new ModelRenderer(this, 16, 53); - frame12.addBox(0F, 0F, 0F, 10, 2, 2); - frame12.setRotationPoint(-5F, 9F, 5F); - frame12.setTextureSize(128, 64); - frame12.mirror = true; - setRotation(frame12, 0F, 0F, 0F); - corner1 = new ModelRenderer(this, 0, 49); - corner1.addBox(0F, 0F, 0F, 3, 3, 3); - corner1.setRotationPoint(-8F, 8F, -8F); - corner1.setTextureSize(128, 64); - corner1.mirror = true; - setRotation(corner1, 0F, 0F, 0F); - corner2 = new ModelRenderer(this, 0, 49); - corner2.addBox(0F, 0F, 0F, 3, 3, 3); - corner2.setRotationPoint(5F, 8F, -8F); - corner2.setTextureSize(128, 64); - corner2.mirror = true; - setRotation(corner2, 0F, 0F, 0F); - corner3 = new ModelRenderer(this, 0, 49); - corner3.addBox(0F, 0F, 0F, 3, 3, 3); - corner3.setRotationPoint(-8F, 8F, 5F); - corner3.setTextureSize(128, 64); - corner3.mirror = true; - setRotation(corner3, 0F, 0F, 0F); - corner4 = new ModelRenderer(this, 0, 49); - corner4.addBox(0F, 0F, 0F, 3, 3, 3); - corner4.setRotationPoint(5F, 8F, 5F); - corner4.setTextureSize(128, 64); - corner4.mirror = true; - setRotation(corner4, 0F, 0F, 0F); - corner5 = new ModelRenderer(this, 0, 49); - corner5.addBox(0F, 0F, 0F, 3, 3, 3); - corner5.setRotationPoint(-8F, 21F, -8F); - corner5.setTextureSize(128, 64); - corner5.mirror = true; - setRotation(corner5, 0F, 0F, 0F); - corner6 = new ModelRenderer(this, 0, 49); - corner6.addBox(0F, 0F, 0F, 3, 3, 3); - corner6.setRotationPoint(5F, 21F, -8F); - corner6.setTextureSize(128, 64); - corner6.mirror = true; - setRotation(corner6, 0F, 0F, 0F); - corner7 = new ModelRenderer(this, 0, 49); - corner7.addBox(0F, 0F, 0F, 3, 3, 3); - corner7.setRotationPoint(-8F, 21F, 5F); - corner7.setTextureSize(128, 64); - corner7.mirror = true; - setRotation(corner7, 0F, 0F, 0F); - corner8 = new ModelRenderer(this, 0, 49); - corner8.addBox(0F, 0F, 0F, 3, 3, 3); - corner8.setRotationPoint(5F, 21F, 5F); - corner8.setTextureSize(128, 64); - corner8.mirror = true; - setRotation(corner8, 0F, 0F, 0F); - portRightLarge = new ModelRenderer(this, 68, 0); - portRightLarge.mirror = true; - portRightLarge.addBox(0F, 0F, 0F, 1, 10, 10); - portRightLarge.setRotationPoint(7F, 11F, -5F); - portRightLarge.setTextureSize(128, 64); - setRotation(portRightLarge, 0F, 0F, 0F); - portLeftLarge = new ModelRenderer(this, 68, 0); - portLeftLarge.addBox(0F, 0F, 0F, 1, 10, 10); - portLeftLarge.setRotationPoint(-8F, 11F, -5F); - portLeftLarge.setTextureSize(128, 64); - portLeftLarge.mirror = true; - setRotation(portLeftLarge, 0F, 0F, 0F); - } - - public void render(float size, TextureManager manager) - { - GL11.glPushMatrix(); - MekanismRenderer.blendOn(); - - doRender(size); - - manager.bindTexture(OVERLAY); - GL11.glScalef(1.001F, 1.001F, 1.001F); - GL11.glTranslatef(0, -0.0011F, 0); - MekanismRenderer.glowOn(); - - doRender(size); - - MekanismRenderer.glowOff(); - MekanismRenderer.blendOff(); - GL11.glPopMatrix(); - } + public ModelQuantumEntangloporter() { + textureWidth = 128; + textureHeight = 64; - public void doRender(float size) - { - portTop.render(size); - portBottom.render(size); - portLeft.render(size); - portRight.render(size); - portBack.render(size); - portFront.render(size); - energyCubeCore.render(size); - frameEdge1.render(size); - frameEdge2.render(size); - frameEdge3.render(size); - frameEdge4.render(size); - frameEdge5.render(size); - frameEdge6.render(size); - frameEdge7.render(size); - frameEdge8.render(size); - frameEdge9.render(size); - frameEdge10.render(size); - frameEdge11.render(size); - frameEdge12.render(size); - frame1.render(size); - frame2.render(size); - frame3.render(size); - frame4.render(size); - frame5.render(size); - frame6.render(size); - frame7.render(size); - frame8.render(size); - frame9.render(size); - frame10.render(size); - frame11.render(size); - frame12.render(size); - corner1.render(size); - corner2.render(size); - corner3.render(size); - corner4.render(size); - corner5.render(size); - corner6.render(size); - corner7.render(size); - corner8.render(size); - //portRightLarge.render(size); - //portLeftLarge.render(size); - } - - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + portTop = new ModelRenderer(this, 36, 0); + portTop.addBox(0F, 0F, 0F, 8, 1, 8); + portTop.setRotationPoint(-4F, 8F, -4F); + portTop.setTextureSize(128, 64); + portTop.mirror = true; + setRotation(portTop, 0F, 0F, 0F); + portBottom = new ModelRenderer(this, 36, 9); + portBottom.addBox(0F, 0F, 0F, 8, 1, 8); + portBottom.setRotationPoint(-4F, 23F, -4F); + portBottom.setTextureSize(128, 64); + portBottom.mirror = true; + setRotation(portBottom, 0F, 0F, 0F); + portLeft = new ModelRenderer(this, 0, 0); + portLeft.addBox(0F, 0F, 0F, 1, 8, 8); + portLeft.setRotationPoint(-8F, 12F, -4F); + portLeft.setTextureSize(128, 64); + portLeft.mirror = true; + setRotation(portLeft, 0F, 0F, 0F); + portRight = new ModelRenderer(this, 0, 0); + portRight.mirror = true; + portRight.addBox(0F, 0F, 0F, 1, 8, 8); + portRight.setRotationPoint(7F, 12F, -4F); + portRight.setTextureSize(128, 64); + setRotation(portRight, 0F, 0F, 0F); + portBack = new ModelRenderer(this, 18, 9); + portBack.addBox(0F, 0F, 0F, 8, 8, 1); + portBack.setRotationPoint(-4F, 12F, 7F); + portBack.setTextureSize(128, 64); + portBack.mirror = true; + setRotation(portBack, 0F, 0F, 0F); + portFront = new ModelRenderer(this, 18, 0); + portFront.addBox(0F, 0F, 0F, 8, 8, 1); + portFront.setRotationPoint(-4F, 12F, -8F); + portFront.setTextureSize(128, 64); + portFront.mirror = true; + setRotation(portFront, 0F, 0F, 0F); + energyCubeCore = new ModelRenderer(this, 0, 41); + energyCubeCore.addBox(-2F, -2F, -2F, 4, 4, 4); + energyCubeCore.setRotationPoint(0F, 16F, 0F); + energyCubeCore.setTextureSize(128, 64); + energyCubeCore.mirror = true; + setRotation(energyCubeCore, 0.7132579F, 0.403365F, 0.645384F); + frameEdge1 = new ModelRenderer(this, 0, 16); + frameEdge1.addBox(0F, 0F, 0F, 1, 10, 1); + frameEdge1.setRotationPoint(-7.5F, 11F, -7.5F); + frameEdge1.setTextureSize(128, 64); + frameEdge1.mirror = true; + setRotation(frameEdge1, 0F, 0F, 0F); + frameEdge2 = new ModelRenderer(this, 0, 16); + frameEdge2.addBox(0F, 0F, 0F, 1, 10, 1); + frameEdge2.setRotationPoint(6.5F, 11F, -7.5F); + frameEdge2.setTextureSize(128, 64); + frameEdge2.mirror = true; + setRotation(frameEdge2, 0F, 0F, 0F); + frameEdge3 = new ModelRenderer(this, 0, 16); + frameEdge3.addBox(0F, 0F, 0F, 1, 10, 1); + frameEdge3.setRotationPoint(-7.5F, 11F, 6.5F); + frameEdge3.setTextureSize(128, 64); + frameEdge3.mirror = true; + setRotation(frameEdge3, 0F, 0F, 0F); + frameEdge4 = new ModelRenderer(this, 0, 16); + frameEdge4.addBox(0F, 0F, 0F, 1, 10, 1); + frameEdge4.setRotationPoint(6.5F, 11F, 6.5F); + frameEdge4.setTextureSize(128, 64); + frameEdge4.mirror = true; + setRotation(frameEdge4, 0F, 0F, 0F); + frameEdge5 = new ModelRenderer(this, 4, 27); + frameEdge5.addBox(0F, 0F, 0F, 10, 1, 1); + frameEdge5.setRotationPoint(-5F, 22.5F, -7.5F); + frameEdge5.setTextureSize(128, 64); + frameEdge5.mirror = true; + setRotation(frameEdge5, 0F, 0F, 0F); + frameEdge6 = new ModelRenderer(this, 4, 16); + frameEdge6.addBox(0F, 0F, 0F, 1, 1, 10); + frameEdge6.setRotationPoint(-7.5F, 22.5F, -5F); + frameEdge6.setTextureSize(128, 64); + frameEdge6.mirror = true; + setRotation(frameEdge6, 0F, 0F, 0F); + frameEdge7 = new ModelRenderer(this, 4, 16); + frameEdge7.addBox(0F, 0F, 0F, 1, 1, 10); + frameEdge7.setRotationPoint(6.5F, 22.5F, -5F); + frameEdge7.setTextureSize(128, 64); + frameEdge7.mirror = true; + setRotation(frameEdge7, 0F, 0F, 0F); + frameEdge8 = new ModelRenderer(this, 4, 27); + frameEdge8.addBox(0F, 0F, 0F, 10, 1, 1); + frameEdge8.setRotationPoint(-5F, 22.5F, 6.5F); + frameEdge8.setTextureSize(128, 64); + frameEdge8.mirror = true; + setRotation(frameEdge8, 0F, 0F, 0F); + frameEdge9 = new ModelRenderer(this, 4, 27); + frameEdge9.addBox(0F, 0F, 0F, 10, 1, 1); + frameEdge9.setRotationPoint(-5F, 8.5F, -7.5F); + frameEdge9.setTextureSize(128, 64); + frameEdge9.mirror = true; + setRotation(frameEdge9, 0F, 0F, 0F); + frameEdge10 = new ModelRenderer(this, 4, 16); + frameEdge10.addBox(0F, 0F, 0F, 1, 1, 10); + frameEdge10.setRotationPoint(-7.5F, 8.5F, -5F); + frameEdge10.setTextureSize(128, 64); + frameEdge10.mirror = true; + setRotation(frameEdge10, 0F, 0F, 0F); + frameEdge11 = new ModelRenderer(this, 4, 16); + frameEdge11.addBox(0F, 0F, 0F, 1, 1, 10); + frameEdge11.setRotationPoint(6.5F, 8.5F, -5F); + frameEdge11.setTextureSize(128, 64); + frameEdge11.mirror = true; + setRotation(frameEdge11, 0F, 0F, 0F); + frameEdge12 = new ModelRenderer(this, 4, 27); + frameEdge12.addBox(0F, 0F, 0F, 10, 1, 1); + frameEdge12.setRotationPoint(-5F, 8.5F, 6.5F); + frameEdge12.setTextureSize(128, 64); + frameEdge12.mirror = true; + setRotation(frameEdge12, 0F, 0F, 0F); + frame1 = new ModelRenderer(this, 0, 29); + frame1.addBox(0F, 0F, 0F, 2, 10, 2); + frame1.setRotationPoint(-7F, 11F, -7F); + frame1.setTextureSize(128, 64); + frame1.mirror = true; + setRotation(frame1, 0F, 0F, 0F); + frame2 = new ModelRenderer(this, 0, 29); + frame2.mirror = true; + frame2.addBox(0F, 0F, 0F, 2, 10, 2); + frame2.setRotationPoint(5F, 11F, -7F); + frame2.setTextureSize(128, 64); + setRotation(frame2, 0F, 0F, 0F); + frame3 = new ModelRenderer(this, 8, 29); + frame3.addBox(0F, 0F, 0F, 2, 10, 2); + frame3.setRotationPoint(-7F, 11F, 5F); + frame3.setTextureSize(128, 64); + frame3.mirror = true; + setRotation(frame3, 0F, 0F, 0F); + frame4 = new ModelRenderer(this, 8, 29); + frame4.mirror = true; + frame4.addBox(0F, 0F, 0F, 2, 10, 2); + frame4.setRotationPoint(5F, 11F, 5F); + frame4.setTextureSize(128, 64); + setRotation(frame4, 0F, 0F, 0F); + frame5 = new ModelRenderer(this, 16, 45); + frame5.addBox(0F, 0F, 0F, 10, 2, 2); + frame5.setRotationPoint(-5F, 21F, -7F); + frame5.setTextureSize(128, 64); + frame5.mirror = true; + setRotation(frame5, 0F, 0F, 0F); + frame6 = new ModelRenderer(this, 40, 29); + frame6.addBox(0F, 0F, 0F, 2, 2, 10); + frame6.setRotationPoint(-7F, 21F, -5F); + frame6.setTextureSize(128, 64); + frame6.mirror = true; + setRotation(frame6, 0F, 0F, 0F); + frame7 = new ModelRenderer(this, 40, 29); + frame7.mirror = true; + frame7.addBox(0F, 0F, 0F, 2, 2, 10); + frame7.setRotationPoint(5F, 21F, -5F); + frame7.setTextureSize(128, 64); + setRotation(frame7, 0F, 0F, 0F); + frame8 = new ModelRenderer(this, 16, 49); + frame8.addBox(0F, 0F, 0F, 10, 2, 2); + frame8.setRotationPoint(-5F, 21F, 5F); + frame8.setTextureSize(128, 64); + frame8.mirror = true; + setRotation(frame8, 0F, 0F, 0F); + frame9 = new ModelRenderer(this, 16, 41); + frame9.addBox(0F, 0F, 0F, 10, 2, 2); + frame9.setRotationPoint(-5F, 9F, -7F); + frame9.setTextureSize(128, 64); + frame9.mirror = true; + setRotation(frame9, 0F, 0F, 0F); + frame10 = new ModelRenderer(this, 16, 29); + frame10.addBox(0F, 0F, 0F, 2, 2, 10); + frame10.setRotationPoint(-7F, 9F, -5F); + frame10.setTextureSize(128, 64); + frame10.mirror = true; + setRotation(frame10, 0F, 0F, 0F); + frame11 = new ModelRenderer(this, 16, 29); + frame11.mirror = true; + frame11.addBox(0F, 0F, 0F, 2, 2, 10); + frame11.setRotationPoint(5F, 9F, -5F); + frame11.setTextureSize(128, 64); + setRotation(frame11, 0F, 0F, 0F); + frame12 = new ModelRenderer(this, 16, 53); + frame12.addBox(0F, 0F, 0F, 10, 2, 2); + frame12.setRotationPoint(-5F, 9F, 5F); + frame12.setTextureSize(128, 64); + frame12.mirror = true; + setRotation(frame12, 0F, 0F, 0F); + corner1 = new ModelRenderer(this, 0, 49); + corner1.addBox(0F, 0F, 0F, 3, 3, 3); + corner1.setRotationPoint(-8F, 8F, -8F); + corner1.setTextureSize(128, 64); + corner1.mirror = true; + setRotation(corner1, 0F, 0F, 0F); + corner2 = new ModelRenderer(this, 0, 49); + corner2.addBox(0F, 0F, 0F, 3, 3, 3); + corner2.setRotationPoint(5F, 8F, -8F); + corner2.setTextureSize(128, 64); + corner2.mirror = true; + setRotation(corner2, 0F, 0F, 0F); + corner3 = new ModelRenderer(this, 0, 49); + corner3.addBox(0F, 0F, 0F, 3, 3, 3); + corner3.setRotationPoint(-8F, 8F, 5F); + corner3.setTextureSize(128, 64); + corner3.mirror = true; + setRotation(corner3, 0F, 0F, 0F); + corner4 = new ModelRenderer(this, 0, 49); + corner4.addBox(0F, 0F, 0F, 3, 3, 3); + corner4.setRotationPoint(5F, 8F, 5F); + corner4.setTextureSize(128, 64); + corner4.mirror = true; + setRotation(corner4, 0F, 0F, 0F); + corner5 = new ModelRenderer(this, 0, 49); + corner5.addBox(0F, 0F, 0F, 3, 3, 3); + corner5.setRotationPoint(-8F, 21F, -8F); + corner5.setTextureSize(128, 64); + corner5.mirror = true; + setRotation(corner5, 0F, 0F, 0F); + corner6 = new ModelRenderer(this, 0, 49); + corner6.addBox(0F, 0F, 0F, 3, 3, 3); + corner6.setRotationPoint(5F, 21F, -8F); + corner6.setTextureSize(128, 64); + corner6.mirror = true; + setRotation(corner6, 0F, 0F, 0F); + corner7 = new ModelRenderer(this, 0, 49); + corner7.addBox(0F, 0F, 0F, 3, 3, 3); + corner7.setRotationPoint(-8F, 21F, 5F); + corner7.setTextureSize(128, 64); + corner7.mirror = true; + setRotation(corner7, 0F, 0F, 0F); + corner8 = new ModelRenderer(this, 0, 49); + corner8.addBox(0F, 0F, 0F, 3, 3, 3); + corner8.setRotationPoint(5F, 21F, 5F); + corner8.setTextureSize(128, 64); + corner8.mirror = true; + setRotation(corner8, 0F, 0F, 0F); + portRightLarge = new ModelRenderer(this, 68, 0); + portRightLarge.mirror = true; + portRightLarge.addBox(0F, 0F, 0F, 1, 10, 10); + portRightLarge.setRotationPoint(7F, 11F, -5F); + portRightLarge.setTextureSize(128, 64); + setRotation(portRightLarge, 0F, 0F, 0F); + portLeftLarge = new ModelRenderer(this, 68, 0); + portLeftLarge.addBox(0F, 0F, 0F, 1, 10, 10); + portLeftLarge.setRotationPoint(-8F, 11F, -5F); + portLeftLarge.setTextureSize(128, 64); + portLeftLarge.mirror = true; + setRotation(portLeftLarge, 0F, 0F, 0F); + } + + public void render(float size, TextureManager manager) { + GL11.glPushMatrix(); + MekanismRenderer.blendOn(); + + doRender(size); + + manager.bindTexture(OVERLAY); + GL11.glScalef(1.001F, 1.001F, 1.001F); + GL11.glTranslatef(0, -0.0011F, 0); + MekanismRenderer.glowOn(); + + doRender(size); + + MekanismRenderer.glowOff(); + MekanismRenderer.blendOff(); + GL11.glPopMatrix(); + } + + public void doRender(float size) { + portTop.render(size); + portBottom.render(size); + portLeft.render(size); + portRight.render(size); + portBack.render(size); + portFront.render(size); + energyCubeCore.render(size); + frameEdge1.render(size); + frameEdge2.render(size); + frameEdge3.render(size); + frameEdge4.render(size); + frameEdge5.render(size); + frameEdge6.render(size); + frameEdge7.render(size); + frameEdge8.render(size); + frameEdge9.render(size); + frameEdge10.render(size); + frameEdge11.render(size); + frameEdge12.render(size); + frame1.render(size); + frame2.render(size); + frame3.render(size); + frame4.render(size); + frame5.render(size); + frame6.render(size); + frame7.render(size); + frame8.render(size); + frame9.render(size); + frame10.render(size); + frame11.render(size); + frame12.render(size); + corner1.render(size); + corner2.render(size); + corner3.render(size); + corner4.render(size); + corner5.render(size); + corner6.render(size); + corner7.render(size); + corner8.render(size); + //portRightLarge.render(size); + //portLeftLarge.render(size); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/mekanism/client/model/ModelResistiveHeater.java b/src/main/java/mekanism/client/model/ModelResistiveHeater.java index c6ad45b68..65ad7b952 100644 --- a/src/main/java/mekanism/client/model/ModelResistiveHeater.java +++ b/src/main/java/mekanism/client/model/ModelResistiveHeater.java @@ -1,5 +1,7 @@ package mekanism.client.model; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.render.MekanismRenderer; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; @@ -7,213 +9,207 @@ import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class ModelResistiveHeater extends ModelBase -{ - public static ResourceLocation OVERLAY_ON = MekanismUtils.getResource(ResourceType.RENDER, "ResistiveHeater_OverlayOn.png"); - public static ResourceLocation OVERLAY_OFF = MekanismUtils.getResource(ResourceType.RENDER, "ResistiveHeater_OverlayOff.png"); - - ModelRenderer wallLeft; - ModelRenderer base; - ModelRenderer fin10; - ModelRenderer portRight; - ModelRenderer fin9; - ModelRenderer fin2; - ModelRenderer bar2; - ModelRenderer fin4; - ModelRenderer fin3; - ModelRenderer fin6; - ModelRenderer center; - ModelRenderer fin8; - ModelRenderer fin7; - ModelRenderer fin5; - ModelRenderer fin1; - ModelRenderer bar1; - ModelRenderer bar4; - ModelRenderer bar3; - ModelRenderer wallRight; - ModelRenderer portLeft; +public class ModelResistiveHeater extends ModelBase { + public static ResourceLocation OVERLAY_ON + = MekanismUtils.getResource(ResourceType.RENDER, "ResistiveHeater_OverlayOn.png"); + public static ResourceLocation OVERLAY_OFF = MekanismUtils.getResource( + ResourceType.RENDER, "ResistiveHeater_OverlayOff.png" + ); - public ModelResistiveHeater() - { - textureWidth = 128; - textureHeight = 64; + ModelRenderer wallLeft; + ModelRenderer base; + ModelRenderer fin10; + ModelRenderer portRight; + ModelRenderer fin9; + ModelRenderer fin2; + ModelRenderer bar2; + ModelRenderer fin4; + ModelRenderer fin3; + ModelRenderer fin6; + ModelRenderer center; + ModelRenderer fin8; + ModelRenderer fin7; + ModelRenderer fin5; + ModelRenderer fin1; + ModelRenderer bar1; + ModelRenderer bar4; + ModelRenderer bar3; + ModelRenderer wallRight; + ModelRenderer portLeft; - wallLeft = new ModelRenderer(this, 0, 23); - wallLeft.mirror = true; - wallLeft.addBox(0F, 0F, 0F, 3, 9, 16); - wallLeft.setRotationPoint(5F, 8F, -8F); - wallLeft.setTextureSize(128, 64); - setRotation(wallLeft, 0F, 0F, 0F); - base = new ModelRenderer(this, 0, 0); - base.addBox(0F, 0F, 0F, 16, 7, 16); - base.setRotationPoint(-8F, 17F, -8F); - base.setTextureSize(128, 64); - base.mirror = true; - setRotation(base, 0F, 0F, 0F); - fin10 = new ModelRenderer(this, 38, 38); - fin10.mirror = true; - fin10.addBox(0F, 0F, 0F, 10, 9, 1); - fin10.setRotationPoint(-5F, 8.5F, 6.5F); - fin10.setTextureSize(128, 64); - setRotation(fin10, 0F, 0F, 0F); - portRight = new ModelRenderer(this, 48, 0); - portRight.addBox(0F, 0F, 0F, 1, 8, 8); - portRight.setRotationPoint(-8.01F, 12F, -4F); - portRight.setTextureSize(128, 64); - portRight.mirror = true; - setRotation(portRight, 0F, 0F, 0F); - fin9 = new ModelRenderer(this, 0, 48); - fin9.mirror = true; - fin9.addBox(0F, 0F, 0F, 10, 9, 1); - fin9.setRotationPoint(-5F, 8.5F, 5F); - fin9.setTextureSize(128, 64); - setRotation(fin9, 0F, 0F, 0F); - fin2 = new ModelRenderer(this, 0, 48); - fin2.addBox(0F, 0F, 0F, 10, 9, 1); - fin2.setRotationPoint(-5F, 8.5F, -6F); - fin2.setTextureSize(128, 64); - fin2.mirror = true; - setRotation(fin2, 0F, 0F, 0F); - bar2 = new ModelRenderer(this, 36, 23); - bar2.addBox(0F, 0F, 0F, 1, 1, 13); - bar2.setRotationPoint(-2F, 9.5F, -6.5F); - bar2.setTextureSize(128, 64); - bar2.mirror = true; - setRotation(bar2, 0F, 0F, 0F); - fin4 = new ModelRenderer(this, 0, 48); - fin4.addBox(0F, 0F, 0F, 10, 9, 1); - fin4.setRotationPoint(-5F, 8.5F, -3F); - fin4.setTextureSize(128, 64); - fin4.mirror = true; - setRotation(fin4, 0F, 0F, 0F); - fin3 = new ModelRenderer(this, 0, 48); - fin3.mirror = true; - fin3.addBox(0F, 0F, 0F, 10, 9, 1); - fin3.setRotationPoint(-5F, 8.5F, -4.5F); - fin3.setTextureSize(128, 64); - setRotation(fin3, 0F, 0F, 0F); - fin6 = new ModelRenderer(this, 0, 48); - fin6.addBox(0F, 0F, 0F, 10, 9, 1); - fin6.setRotationPoint(-5F, 8.5F, 0.5F); - fin6.setTextureSize(128, 64); - fin6.mirror = true; - setRotation(fin6, 0F, 0F, 0F); - center = new ModelRenderer(this, 0, 0); - center.addBox(0F, 0F, 0F, 6, 6, 1); - center.setRotationPoint(-3F, 11.5F, -0.5F); - center.setTextureSize(128, 64); - center.mirror = true; - setRotation(center, 0F, 0F, 0F); - fin8 = new ModelRenderer(this, 0, 48); - fin8.addBox(0F, 0F, 0F, 10, 9, 1); - fin8.setRotationPoint(-5F, 8.5F, 3.5F); - fin8.setTextureSize(128, 64); - fin8.mirror = true; - setRotation(fin8, 0F, 0F, 0F); - fin7 = new ModelRenderer(this, 0, 48); - fin7.mirror = true; - fin7.addBox(0F, 0F, 0F, 10, 9, 1); - fin7.setRotationPoint(-5F, 8.5F, 2F); - fin7.setTextureSize(128, 64); - setRotation(fin7, 0F, 0F, 0F); - fin5 = new ModelRenderer(this, 0, 48); - fin5.mirror = true; - fin5.addBox(0F, 0F, 0F, 10, 9, 1); - fin5.setRotationPoint(-5F, 8.5F, -1.5F); - fin5.setTextureSize(128, 64); - setRotation(fin5, 0F, 0F, 0F); - fin1 = new ModelRenderer(this, 22, 48); - fin1.addBox(0F, 0F, 0F, 10, 9, 1); - fin1.setRotationPoint(-5F, 8.5F, -7.5F); - fin1.setTextureSize(128, 64); - fin1.mirror = true; - setRotation(fin1, 0F, 0F, 0F); - bar1 = new ModelRenderer(this, 36, 23); - bar1.addBox(0F, 0F, 0F, 1, 1, 13); - bar1.setRotationPoint(-4F, 9.5F, -6.5F); - bar1.setTextureSize(128, 64); - bar1.mirror = true; - setRotation(bar1, 0F, 0F, 0F); - bar4 = new ModelRenderer(this, 36, 23); - bar4.addBox(0F, 0F, 0F, 1, 1, 13); - bar4.setRotationPoint(3F, 9.5F, -6.5F); - bar4.setTextureSize(128, 64); - bar4.mirror = true; - setRotation(bar4, 0F, 0F, 0F); - bar3 = new ModelRenderer(this, 36, 23); - bar3.addBox(0F, 0F, 0F, 1, 1, 13); - bar3.setRotationPoint(1F, 9.5F, -6.5F); - bar3.setTextureSize(128, 64); - bar3.mirror = true; - setRotation(bar3, 0F, 0F, 0F); - wallRight = new ModelRenderer(this, 0, 23); - wallRight.addBox(0F, 0F, 0F, 3, 9, 16); - wallRight.setRotationPoint(-8F, 8F, -8F); - wallRight.setTextureSize(128, 64); - wallRight.mirror = true; - setRotation(wallRight, 0F, 0F, 0F); - portLeft = new ModelRenderer(this, 48, 0); - portLeft.addBox(0F, 0F, 0F, 1, 8, 8); - portLeft.setRotationPoint(7.01F, 12F, -4F); - portLeft.setTextureSize(128, 64); - portLeft.mirror = true; - setRotation(portLeft, 0F, 0F, 0F); - } - - public void render(float size, boolean on, TextureManager manager) - { - GL11.glPushMatrix(); - MekanismRenderer.blendOn(); - - doRender(size); - - manager.bindTexture(on ? OVERLAY_ON : OVERLAY_OFF); - GL11.glScalef(1.001F, 1.001F, 1.001F); - GL11.glTranslatef(0, -0.0011F, 0); - MekanismRenderer.glowOn(); - - doRender(size); - - MekanismRenderer.glowOff(); - MekanismRenderer.blendOff(); - GL11.glPopMatrix(); - } + public ModelResistiveHeater() { + textureWidth = 128; + textureHeight = 64; - private void doRender(float size) - { - wallLeft.render(size); - base.render(size); - fin10.render(size); - portRight.render(size); - fin9.render(size); - fin2.render(size); - bar2.render(size); - fin4.render(size); - fin3.render(size); - fin6.render(size); - center.render(size); - fin8.render(size); - fin7.render(size); - fin5.render(size); - fin1.render(size); - bar1.render(size); - bar4.render(size); - bar3.render(size); - wallRight.render(size); - portLeft.render(size); - } + wallLeft = new ModelRenderer(this, 0, 23); + wallLeft.mirror = true; + wallLeft.addBox(0F, 0F, 0F, 3, 9, 16); + wallLeft.setRotationPoint(5F, 8F, -8F); + wallLeft.setTextureSize(128, 64); + setRotation(wallLeft, 0F, 0F, 0F); + base = new ModelRenderer(this, 0, 0); + base.addBox(0F, 0F, 0F, 16, 7, 16); + base.setRotationPoint(-8F, 17F, -8F); + base.setTextureSize(128, 64); + base.mirror = true; + setRotation(base, 0F, 0F, 0F); + fin10 = new ModelRenderer(this, 38, 38); + fin10.mirror = true; + fin10.addBox(0F, 0F, 0F, 10, 9, 1); + fin10.setRotationPoint(-5F, 8.5F, 6.5F); + fin10.setTextureSize(128, 64); + setRotation(fin10, 0F, 0F, 0F); + portRight = new ModelRenderer(this, 48, 0); + portRight.addBox(0F, 0F, 0F, 1, 8, 8); + portRight.setRotationPoint(-8.01F, 12F, -4F); + portRight.setTextureSize(128, 64); + portRight.mirror = true; + setRotation(portRight, 0F, 0F, 0F); + fin9 = new ModelRenderer(this, 0, 48); + fin9.mirror = true; + fin9.addBox(0F, 0F, 0F, 10, 9, 1); + fin9.setRotationPoint(-5F, 8.5F, 5F); + fin9.setTextureSize(128, 64); + setRotation(fin9, 0F, 0F, 0F); + fin2 = new ModelRenderer(this, 0, 48); + fin2.addBox(0F, 0F, 0F, 10, 9, 1); + fin2.setRotationPoint(-5F, 8.5F, -6F); + fin2.setTextureSize(128, 64); + fin2.mirror = true; + setRotation(fin2, 0F, 0F, 0F); + bar2 = new ModelRenderer(this, 36, 23); + bar2.addBox(0F, 0F, 0F, 1, 1, 13); + bar2.setRotationPoint(-2F, 9.5F, -6.5F); + bar2.setTextureSize(128, 64); + bar2.mirror = true; + setRotation(bar2, 0F, 0F, 0F); + fin4 = new ModelRenderer(this, 0, 48); + fin4.addBox(0F, 0F, 0F, 10, 9, 1); + fin4.setRotationPoint(-5F, 8.5F, -3F); + fin4.setTextureSize(128, 64); + fin4.mirror = true; + setRotation(fin4, 0F, 0F, 0F); + fin3 = new ModelRenderer(this, 0, 48); + fin3.mirror = true; + fin3.addBox(0F, 0F, 0F, 10, 9, 1); + fin3.setRotationPoint(-5F, 8.5F, -4.5F); + fin3.setTextureSize(128, 64); + setRotation(fin3, 0F, 0F, 0F); + fin6 = new ModelRenderer(this, 0, 48); + fin6.addBox(0F, 0F, 0F, 10, 9, 1); + fin6.setRotationPoint(-5F, 8.5F, 0.5F); + fin6.setTextureSize(128, 64); + fin6.mirror = true; + setRotation(fin6, 0F, 0F, 0F); + center = new ModelRenderer(this, 0, 0); + center.addBox(0F, 0F, 0F, 6, 6, 1); + center.setRotationPoint(-3F, 11.5F, -0.5F); + center.setTextureSize(128, 64); + center.mirror = true; + setRotation(center, 0F, 0F, 0F); + fin8 = new ModelRenderer(this, 0, 48); + fin8.addBox(0F, 0F, 0F, 10, 9, 1); + fin8.setRotationPoint(-5F, 8.5F, 3.5F); + fin8.setTextureSize(128, 64); + fin8.mirror = true; + setRotation(fin8, 0F, 0F, 0F); + fin7 = new ModelRenderer(this, 0, 48); + fin7.mirror = true; + fin7.addBox(0F, 0F, 0F, 10, 9, 1); + fin7.setRotationPoint(-5F, 8.5F, 2F); + fin7.setTextureSize(128, 64); + setRotation(fin7, 0F, 0F, 0F); + fin5 = new ModelRenderer(this, 0, 48); + fin5.mirror = true; + fin5.addBox(0F, 0F, 0F, 10, 9, 1); + fin5.setRotationPoint(-5F, 8.5F, -1.5F); + fin5.setTextureSize(128, 64); + setRotation(fin5, 0F, 0F, 0F); + fin1 = new ModelRenderer(this, 22, 48); + fin1.addBox(0F, 0F, 0F, 10, 9, 1); + fin1.setRotationPoint(-5F, 8.5F, -7.5F); + fin1.setTextureSize(128, 64); + fin1.mirror = true; + setRotation(fin1, 0F, 0F, 0F); + bar1 = new ModelRenderer(this, 36, 23); + bar1.addBox(0F, 0F, 0F, 1, 1, 13); + bar1.setRotationPoint(-4F, 9.5F, -6.5F); + bar1.setTextureSize(128, 64); + bar1.mirror = true; + setRotation(bar1, 0F, 0F, 0F); + bar4 = new ModelRenderer(this, 36, 23); + bar4.addBox(0F, 0F, 0F, 1, 1, 13); + bar4.setRotationPoint(3F, 9.5F, -6.5F); + bar4.setTextureSize(128, 64); + bar4.mirror = true; + setRotation(bar4, 0F, 0F, 0F); + bar3 = new ModelRenderer(this, 36, 23); + bar3.addBox(0F, 0F, 0F, 1, 1, 13); + bar3.setRotationPoint(1F, 9.5F, -6.5F); + bar3.setTextureSize(128, 64); + bar3.mirror = true; + setRotation(bar3, 0F, 0F, 0F); + wallRight = new ModelRenderer(this, 0, 23); + wallRight.addBox(0F, 0F, 0F, 3, 9, 16); + wallRight.setRotationPoint(-8F, 8F, -8F); + wallRight.setTextureSize(128, 64); + wallRight.mirror = true; + setRotation(wallRight, 0F, 0F, 0F); + portLeft = new ModelRenderer(this, 48, 0); + portLeft.addBox(0F, 0F, 0F, 1, 8, 8); + portLeft.setRotationPoint(7.01F, 12F, -4F); + portLeft.setTextureSize(128, 64); + portLeft.mirror = true; + setRotation(portLeft, 0F, 0F, 0F); + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + public void render(float size, boolean on, TextureManager manager) { + GL11.glPushMatrix(); + MekanismRenderer.blendOn(); + + doRender(size); + + manager.bindTexture(on ? OVERLAY_ON : OVERLAY_OFF); + GL11.glScalef(1.001F, 1.001F, 1.001F); + GL11.glTranslatef(0, -0.0011F, 0); + MekanismRenderer.glowOn(); + + doRender(size); + + MekanismRenderer.glowOff(); + MekanismRenderer.blendOff(); + GL11.glPopMatrix(); + } + + private void doRender(float size) { + wallLeft.render(size); + base.render(size); + fin10.render(size); + portRight.render(size); + fin9.render(size); + fin2.render(size); + bar2.render(size); + fin4.render(size); + fin3.render(size); + fin6.render(size); + center.render(size); + fin8.render(size); + fin7.render(size); + fin5.render(size); + fin1.render(size); + bar1.render(size); + bar4.render(size); + bar3.render(size); + wallRight.render(size); + portLeft.render(size); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/mekanism/client/model/ModelRobit.java b/src/main/java/mekanism/client/model/ModelRobit.java index 6796e0798..122517045 100644 --- a/src/main/java/mekanism/client/model/ModelRobit.java +++ b/src/main/java/mekanism/client/model/ModelRobit.java @@ -1,185 +1,179 @@ package mekanism.client.model; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.render.MekanismRenderer; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class ModelRobit extends ModelBase -{ - public ModelRenderer Body; - public ModelRenderer Bottom; - public ModelRenderer RightTrack; - public ModelRenderer LeftTrack; - public ModelRenderer Neck; - public ModelRenderer Head; - public ModelRenderer Backpack; - public ModelRenderer headback; - public ModelRenderer rightarn; - public ModelRenderer leftarm; - public ModelRenderer righthand; - public ModelRenderer lefthand; - public ModelRenderer backLight; - public ModelRenderer eyeRight; - public ModelRenderer eyeLeft; +public class ModelRobit extends ModelBase { + public ModelRenderer Body; + public ModelRenderer Bottom; + public ModelRenderer RightTrack; + public ModelRenderer LeftTrack; + public ModelRenderer Neck; + public ModelRenderer Head; + public ModelRenderer Backpack; + public ModelRenderer headback; + public ModelRenderer rightarn; + public ModelRenderer leftarm; + public ModelRenderer righthand; + public ModelRenderer lefthand; + public ModelRenderer backLight; + public ModelRenderer eyeRight; + public ModelRenderer eyeLeft; - public ModelRobit() - { - textureWidth = 64; - textureHeight = 64; + public ModelRobit() { + textureWidth = 64; + textureHeight = 64; - Body = new ModelRenderer(this, 0, 0); - Body.addBox(0F, 0F, 1F, 6, 4, 5); - Body.setRotationPoint(-3F, 17F, -3F); - Body.setTextureSize(64, 64); - Body.mirror = true; - setRotation(Body, 0F, 0F, 0F); - Bottom = new ModelRenderer(this, 22, 0); - Bottom.addBox(0F, 0F, 0F, 6, 2, 7); - Bottom.setRotationPoint(-3F, 21F, -2.5F); - Bottom.setTextureSize(64, 64); - Bottom.mirror = true; - setRotation(Bottom, 0F, 0F, 0F); - RightTrack = new ModelRenderer(this, 26, 9); - RightTrack.addBox(0F, 0F, 0F, 2, 3, 9); - RightTrack.setRotationPoint(3F, 21F, -4F); - RightTrack.setTextureSize(64, 64); - RightTrack.mirror = true; - setRotation(RightTrack, 0F, 0F, 0F); - LeftTrack = new ModelRenderer(this, 0, 9); - LeftTrack.addBox(0F, 0F, 0F, 2, 3, 9); - LeftTrack.setRotationPoint(-5F, 21F, -4F); - LeftTrack.setTextureSize(64, 64); - LeftTrack.mirror = true; - setRotation(LeftTrack, 0F, 0F, 0F); - Neck = new ModelRenderer(this, 0, 26); - Neck.addBox(0F, 0F, 0F, 3, 1, 2); - Neck.setRotationPoint(-1.5F, 16F, -0.5F); - Neck.setTextureSize(64, 64); - Neck.mirror = true; - setRotation(Neck, 0F, 0F, 0F); - Head = new ModelRenderer(this, 26, 21); - Head.addBox(0F, 0F, 0F, 7, 3, 4); - Head.setRotationPoint(-3.5F, 13.5F, -1.533333F); - Head.setTextureSize(64, 64); - Head.mirror = true; - setRotation(Head, 0F, 0F, 0F); - Backpack = new ModelRenderer(this, 14, 9); - Backpack.addBox(0F, 0F, 0F, 4, 3, 6); - Backpack.setRotationPoint(-2F, 16.8F, -4F); - Backpack.setTextureSize(64, 64); - Backpack.mirror = true; - setRotation(Backpack, 0F, 0F, 0F); - headback = new ModelRenderer(this, 17, 1); - headback.addBox(0F, 0F, 0F, 5, 2, 1); - headback.setRotationPoint(-2.5F, 14F, -2F); - headback.setTextureSize(64, 64); - headback.mirror = true; - setRotation(headback, 0F, 0F, 0F); - rightarn = new ModelRenderer(this, 0, 21); - rightarn.addBox(0F, 0F, 0F, 1, 1, 4); - rightarn.setRotationPoint(3F, 17.5F, 0F); - rightarn.setTextureSize(64, 64); - rightarn.mirror = true; - setRotation(rightarn, 0F, 0F, 0F); - leftarm = new ModelRenderer(this, 12, 21); - leftarm.addBox(0F, 0F, 0F, 1, 1, 4); - leftarm.setRotationPoint(-4F, 17.5F, 0F); - leftarm.setTextureSize(64, 64); - leftarm.mirror = true; - setRotation(leftarm, 0F, 0F, 0F); - righthand = new ModelRenderer(this, 15, 28); - righthand.addBox(0F, 0F, 0F, 1, 1, 0); - righthand.setRotationPoint(2.5F, 17.5F, 4F); - righthand.setTextureSize(64, 64); - righthand.mirror = true; - setRotation(righthand, 0F, 0F, 0F); - lefthand = new ModelRenderer(this, 15, 28); - lefthand.addBox(0F, 0F, 0F, 1, 1, 0); - lefthand.setRotationPoint(-3.5F, 17.5F, 4F); - lefthand.setTextureSize(64, 64); - lefthand.mirror = true; - setRotation(lefthand, 0F, 0F, 0F); - backLight = new ModelRenderer(this, 20, 15); - backLight.addBox(0F, 0F, 0F, 2, 1, 1); - backLight.setRotationPoint(-1F, 17.8F, -4.001F); - backLight.setTextureSize(64, 64); - backLight.mirror = true; - setRotation(backLight, 0F, 0F, 0F); - eyeRight = new ModelRenderer(this, 43, 25); - eyeRight.addBox(0F, 0F, 0F, 1, 1, 1); - eyeRight.setRotationPoint(1.5F, 14.5F, 1.50001F); - eyeRight.setTextureSize(64, 64); - eyeRight.mirror = true; - setRotation(eyeRight, 0F, 0F, 0F); - eyeLeft = new ModelRenderer(this, 43, 25); - eyeLeft.addBox(0F, 0F, 0F, 1, 1, 1); - eyeLeft.setRotationPoint(-2.5F, 14.5F, 1.50001F); - eyeLeft.setTextureSize(64, 64); - eyeLeft.mirror = true; - setRotation(eyeLeft, 0F, 0F, 0F); - } + Body = new ModelRenderer(this, 0, 0); + Body.addBox(0F, 0F, 1F, 6, 4, 5); + Body.setRotationPoint(-3F, 17F, -3F); + Body.setTextureSize(64, 64); + Body.mirror = true; + setRotation(Body, 0F, 0F, 0F); + Bottom = new ModelRenderer(this, 22, 0); + Bottom.addBox(0F, 0F, 0F, 6, 2, 7); + Bottom.setRotationPoint(-3F, 21F, -2.5F); + Bottom.setTextureSize(64, 64); + Bottom.mirror = true; + setRotation(Bottom, 0F, 0F, 0F); + RightTrack = new ModelRenderer(this, 26, 9); + RightTrack.addBox(0F, 0F, 0F, 2, 3, 9); + RightTrack.setRotationPoint(3F, 21F, -4F); + RightTrack.setTextureSize(64, 64); + RightTrack.mirror = true; + setRotation(RightTrack, 0F, 0F, 0F); + LeftTrack = new ModelRenderer(this, 0, 9); + LeftTrack.addBox(0F, 0F, 0F, 2, 3, 9); + LeftTrack.setRotationPoint(-5F, 21F, -4F); + LeftTrack.setTextureSize(64, 64); + LeftTrack.mirror = true; + setRotation(LeftTrack, 0F, 0F, 0F); + Neck = new ModelRenderer(this, 0, 26); + Neck.addBox(0F, 0F, 0F, 3, 1, 2); + Neck.setRotationPoint(-1.5F, 16F, -0.5F); + Neck.setTextureSize(64, 64); + Neck.mirror = true; + setRotation(Neck, 0F, 0F, 0F); + Head = new ModelRenderer(this, 26, 21); + Head.addBox(0F, 0F, 0F, 7, 3, 4); + Head.setRotationPoint(-3.5F, 13.5F, -1.533333F); + Head.setTextureSize(64, 64); + Head.mirror = true; + setRotation(Head, 0F, 0F, 0F); + Backpack = new ModelRenderer(this, 14, 9); + Backpack.addBox(0F, 0F, 0F, 4, 3, 6); + Backpack.setRotationPoint(-2F, 16.8F, -4F); + Backpack.setTextureSize(64, 64); + Backpack.mirror = true; + setRotation(Backpack, 0F, 0F, 0F); + headback = new ModelRenderer(this, 17, 1); + headback.addBox(0F, 0F, 0F, 5, 2, 1); + headback.setRotationPoint(-2.5F, 14F, -2F); + headback.setTextureSize(64, 64); + headback.mirror = true; + setRotation(headback, 0F, 0F, 0F); + rightarn = new ModelRenderer(this, 0, 21); + rightarn.addBox(0F, 0F, 0F, 1, 1, 4); + rightarn.setRotationPoint(3F, 17.5F, 0F); + rightarn.setTextureSize(64, 64); + rightarn.mirror = true; + setRotation(rightarn, 0F, 0F, 0F); + leftarm = new ModelRenderer(this, 12, 21); + leftarm.addBox(0F, 0F, 0F, 1, 1, 4); + leftarm.setRotationPoint(-4F, 17.5F, 0F); + leftarm.setTextureSize(64, 64); + leftarm.mirror = true; + setRotation(leftarm, 0F, 0F, 0F); + righthand = new ModelRenderer(this, 15, 28); + righthand.addBox(0F, 0F, 0F, 1, 1, 0); + righthand.setRotationPoint(2.5F, 17.5F, 4F); + righthand.setTextureSize(64, 64); + righthand.mirror = true; + setRotation(righthand, 0F, 0F, 0F); + lefthand = new ModelRenderer(this, 15, 28); + lefthand.addBox(0F, 0F, 0F, 1, 1, 0); + lefthand.setRotationPoint(-3.5F, 17.5F, 4F); + lefthand.setTextureSize(64, 64); + lefthand.mirror = true; + setRotation(lefthand, 0F, 0F, 0F); + backLight = new ModelRenderer(this, 20, 15); + backLight.addBox(0F, 0F, 0F, 2, 1, 1); + backLight.setRotationPoint(-1F, 17.8F, -4.001F); + backLight.setTextureSize(64, 64); + backLight.mirror = true; + setRotation(backLight, 0F, 0F, 0F); + eyeRight = new ModelRenderer(this, 43, 25); + eyeRight.addBox(0F, 0F, 0F, 1, 1, 1); + eyeRight.setRotationPoint(1.5F, 14.5F, 1.50001F); + eyeRight.setTextureSize(64, 64); + eyeRight.mirror = true; + setRotation(eyeRight, 0F, 0F, 0F); + eyeLeft = new ModelRenderer(this, 43, 25); + eyeLeft.addBox(0F, 0F, 0F, 1, 1, 1); + eyeLeft.setRotationPoint(-2.5F, 14.5F, 1.50001F); + eyeLeft.setTextureSize(64, 64); + eyeLeft.mirror = true; + setRotation(eyeLeft, 0F, 0F, 0F); + } - @Override - public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) - { - super.render(entity, f, f1, f2, f3, f4, f5); - setRotationAngles(f, f1, f2, f3, f4, f5, entity); + @Override + public void + render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { + super.render(entity, f, f1, f2, f3, f4, f5); + setRotationAngles(f, f1, f2, f3, f4, f5, entity); - GL11.glPushMatrix(); - GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); + GL11.glPushMatrix(); + GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); - Body.render(f5); - Bottom.render(f5); - RightTrack.render(f5); - LeftTrack.render(f5); - Neck.render(f5); - Head.render(f5); - Backpack.render(f5); - headback.render(f5); - rightarn.render(f5); - leftarm.render(f5); - righthand.render(f5); - lefthand.render(f5); + Body.render(f5); + Bottom.render(f5); + RightTrack.render(f5); + LeftTrack.render(f5); + Neck.render(f5); + Head.render(f5); + Backpack.render(f5); + headback.render(f5); + rightarn.render(f5); + leftarm.render(f5); + righthand.render(f5); + lefthand.render(f5); - MekanismRenderer.glowOn(); - backLight.render(f5); - eyeRight.render(f5); - eyeLeft.render(f5); - MekanismRenderer.glowOff(); + MekanismRenderer.glowOn(); + backLight.render(f5); + eyeRight.render(f5); + eyeLeft.render(f5); + MekanismRenderer.glowOff(); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - public void render(float size) - { - Body.render(size); - Bottom.render(size); - RightTrack.render(size); - LeftTrack.render(size); - Neck.render(size); - Head.render(size); - Backpack.render(size); - headback.render(size); - rightarn.render(size); - leftarm.render(size); - righthand.render(size); - lefthand.render(size); - backLight.render(size); - eyeRight.render(size); - eyeLeft.render(size); - } + public void render(float size) { + Body.render(size); + Bottom.render(size); + RightTrack.render(size); + LeftTrack.render(size); + Neck.render(size); + Head.render(size); + Backpack.render(size); + headback.render(size); + rightarn.render(size); + leftarm.render(size); + righthand.render(size); + lefthand.render(size); + backLight.render(size); + eyeRight.render(size); + eyeLeft.render(size); + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/mekanism/client/model/ModelRotaryCondensentrator.java b/src/main/java/mekanism/client/model/ModelRotaryCondensentrator.java index 5b252f01d..3d059a794 100644 --- a/src/main/java/mekanism/client/model/ModelRotaryCondensentrator.java +++ b/src/main/java/mekanism/client/model/ModelRotaryCondensentrator.java @@ -1,205 +1,201 @@ package mekanism.client.model; -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; @SideOnly(Side.CLIENT) -public class ModelRotaryCondensentrator extends ModelBase -{ - ModelRenderer portRight; - ModelRenderer tankRight; - ModelRenderer base; - ModelRenderer pipe; - ModelRenderer middle; - ModelRenderer shaft; - ModelRenderer portLeft; - ModelRenderer tankLeft; - ModelRenderer support4; - ModelRenderer bridge; - ModelRenderer tube8; - ModelRenderer tube7; - ModelRenderer tube6; - ModelRenderer tube5; - ModelRenderer tube4; - ModelRenderer tube3; - ModelRenderer tube2; - ModelRenderer tube1; - ModelRenderer top; - ModelRenderer support3; - ModelRenderer support2; - ModelRenderer support1; +public class ModelRotaryCondensentrator extends ModelBase { + ModelRenderer portRight; + ModelRenderer tankRight; + ModelRenderer base; + ModelRenderer pipe; + ModelRenderer middle; + ModelRenderer shaft; + ModelRenderer portLeft; + ModelRenderer tankLeft; + ModelRenderer support4; + ModelRenderer bridge; + ModelRenderer tube8; + ModelRenderer tube7; + ModelRenderer tube6; + ModelRenderer tube5; + ModelRenderer tube4; + ModelRenderer tube3; + ModelRenderer tube2; + ModelRenderer tube1; + ModelRenderer top; + ModelRenderer support3; + ModelRenderer support2; + ModelRenderer support1; - public ModelRotaryCondensentrator() - { - textureWidth = 128; - textureHeight = 64; + public ModelRotaryCondensentrator() { + textureWidth = 128; + textureHeight = 64; - portRight = new ModelRenderer(this, 82, 31); - portRight.addBox(0F, 0F, 0F, 1, 10, 10); - portRight.setRotationPoint(7.01F, 11F, -5F); - portRight.setTextureSize(128, 64); - portRight.mirror = true; - setRotation(portRight, 0F, 0F, 0F); - tankRight = new ModelRenderer(this, 64, 9); - tankRight.mirror = true; - tankRight.addBox(0F, 0F, 0F, 6, 8, 14); - tankRight.setRotationPoint(1F, 11F, -7F); - tankRight.setTextureSize(128, 64); - setRotation(tankRight, 0F, 0F, 0F); - base = new ModelRenderer(this, 0, 34); - base.addBox(0F, 0F, 0F, 16, 5, 16); - base.setRotationPoint(-8F, 19F, -8F); - base.setTextureSize(128, 64); - base.mirror = true; - setRotation(base, 0F, 0F, 0F); - pipe = new ModelRenderer(this, 0, 4); - pipe.addBox(0F, 0F, 0F, 2, 6, 6); - pipe.setRotationPoint(-1.01F, 13F, -3F); - pipe.setTextureSize(128, 64); - pipe.mirror = true; - setRotation(pipe, 0F, 0F, 0F); - middle = new ModelRenderer(this, 0, 17); - middle.addBox(0F, 0F, 0F, 16, 1, 16); - middle.setRotationPoint(-8F, 10F, -8F); - middle.setTextureSize(128, 64); - middle.mirror = true; - setRotation(middle, 0F, 0F, 0F); - shaft = new ModelRenderer(this, 12, 0); - shaft.addBox(0F, 0F, 0F, 1, 2, 1); - shaft.setRotationPoint(-0.5F, 11F, -0.5F); - shaft.setTextureSize(128, 64); - shaft.mirror = true; - setRotation(shaft, 0F, 0F, 0F); - portLeft = new ModelRenderer(this, 64, 31); - portLeft.addBox(0F, 0F, 0F, 1, 8, 8); - portLeft.setRotationPoint(-8.01F, 12F, -4F); - portLeft.setTextureSize(128, 64); - portLeft.mirror = true; - setRotation(portLeft, 0F, 0F, 0F); - tankLeft = new ModelRenderer(this, 64, 9); - tankLeft.addBox(0F, 0F, 0F, 6, 8, 14); - tankLeft.setRotationPoint(-7F, 11F, -7F); - tankLeft.setTextureSize(128, 64); - tankLeft.mirror = true; - setRotation(tankLeft, 0F, 0F, 0F); - support4 = new ModelRenderer(this, 7, 0); - support4.addBox(0F, 0F, 0F, 1, 1, 1); - support4.setRotationPoint(6F, 9F, 6F); - support4.setTextureSize(128, 64); - support4.mirror = true; - setRotation(support4, 0F, 0F, 0F); - bridge = new ModelRenderer(this, 64, 0); - bridge.addBox(0F, 0F, 0F, 8, 1, 8); - bridge.setRotationPoint(-4F, 9F, -4F); - bridge.setTextureSize(128, 64); - bridge.mirror = true; - setRotation(bridge, 0F, 0F, 0F); - tube8 = new ModelRenderer(this, 0, 0); - tube8.addBox(0F, 0F, 0F, 2, 1, 1); - tube8.setRotationPoint(-1F, 18F, 5F); - tube8.setTextureSize(128, 64); - tube8.mirror = true; - setRotation(tube8, 0F, 0F, 0F); - tube7 = new ModelRenderer(this, 0, 0); - tube7.addBox(0F, 0F, 0F, 2, 1, 1); - tube7.setRotationPoint(-1F, 12F, 5F); - tube7.setTextureSize(128, 64); - tube7.mirror = true; - setRotation(tube7, 0F, 0F, 0F); - tube6 = new ModelRenderer(this, 0, 0); - tube6.addBox(0F, 0F, 0F, 2, 1, 1); - tube6.setRotationPoint(-1F, 14F, 5F); - tube6.setTextureSize(128, 64); - tube6.mirror = true; - setRotation(tube6, 0F, 0F, 0F); - tube5 = new ModelRenderer(this, 0, 0); - tube5.addBox(0F, 0F, 0F, 2, 1, 1); - tube5.setRotationPoint(-1F, 16F, 5F); - tube5.setTextureSize(128, 64); - tube5.mirror = true; - setRotation(tube5, 0F, 0F, 0F); - tube4 = new ModelRenderer(this, 0, 0); - tube4.addBox(0F, 0F, 0F, 2, 1, 1); - tube4.setRotationPoint(-1F, 18F, -6F); - tube4.setTextureSize(128, 64); - tube4.mirror = true; - setRotation(tube4, 0F, 0F, 0F); - tube3 = new ModelRenderer(this, 0, 0); - tube3.addBox(0F, 0F, 0F, 2, 1, 1); - tube3.setRotationPoint(-1F, 16F, -6F); - tube3.setTextureSize(128, 64); - tube3.mirror = true; - setRotation(tube3, 0F, 0F, 0F); - tube2 = new ModelRenderer(this, 0, 0); - tube2.addBox(0F, 0F, 0F, 2, 1, 1); - tube2.setRotationPoint(-1F, 14F, -6F); - tube2.setTextureSize(128, 64); - tube2.mirror = true; - setRotation(tube2, 0F, 0F, 0F); - tube1 = new ModelRenderer(this, 0, 0); - tube1.addBox(0F, 0F, 0F, 2, 1, 1); - tube1.setRotationPoint(-1F, 12F, -6F); - tube1.setTextureSize(128, 64); - tube1.mirror = true; - setRotation(tube1, 0F, 0F, 0F); - top = new ModelRenderer(this, 0, 0); - top.addBox(0F, 0F, 0F, 16, 1, 16); - top.setRotationPoint(-8F, 8F, -8F); - top.setTextureSize(128, 64); - top.mirror = true; - setRotation(top, 0F, 0F, 0F); - support3 = new ModelRenderer(this, 7, 0); - support3.addBox(0F, 0F, 0F, 1, 1, 1); - support3.setRotationPoint(6F, 9F, -7F); - support3.setTextureSize(128, 64); - support3.mirror = true; - setRotation(support3, 0F, 0F, 0F); - support2 = new ModelRenderer(this, 7, 0); - support2.addBox(0F, 0F, 0F, 1, 1, 1); - support2.setRotationPoint(-7F, 9F, -7F); - support2.setTextureSize(128, 64); - support2.mirror = true; - setRotation(support2, 0F, 0F, 0F); - support1 = new ModelRenderer(this, 7, 0); - support1.addBox(0F, 0F, 0F, 1, 1, 1); - support1.setRotationPoint(-7F, 9F, 6F); - support1.setTextureSize(128, 64); - support1.mirror = true; - setRotation(support1, 0F, 0F, 0F); - } + portRight = new ModelRenderer(this, 82, 31); + portRight.addBox(0F, 0F, 0F, 1, 10, 10); + portRight.setRotationPoint(7.01F, 11F, -5F); + portRight.setTextureSize(128, 64); + portRight.mirror = true; + setRotation(portRight, 0F, 0F, 0F); + tankRight = new ModelRenderer(this, 64, 9); + tankRight.mirror = true; + tankRight.addBox(0F, 0F, 0F, 6, 8, 14); + tankRight.setRotationPoint(1F, 11F, -7F); + tankRight.setTextureSize(128, 64); + setRotation(tankRight, 0F, 0F, 0F); + base = new ModelRenderer(this, 0, 34); + base.addBox(0F, 0F, 0F, 16, 5, 16); + base.setRotationPoint(-8F, 19F, -8F); + base.setTextureSize(128, 64); + base.mirror = true; + setRotation(base, 0F, 0F, 0F); + pipe = new ModelRenderer(this, 0, 4); + pipe.addBox(0F, 0F, 0F, 2, 6, 6); + pipe.setRotationPoint(-1.01F, 13F, -3F); + pipe.setTextureSize(128, 64); + pipe.mirror = true; + setRotation(pipe, 0F, 0F, 0F); + middle = new ModelRenderer(this, 0, 17); + middle.addBox(0F, 0F, 0F, 16, 1, 16); + middle.setRotationPoint(-8F, 10F, -8F); + middle.setTextureSize(128, 64); + middle.mirror = true; + setRotation(middle, 0F, 0F, 0F); + shaft = new ModelRenderer(this, 12, 0); + shaft.addBox(0F, 0F, 0F, 1, 2, 1); + shaft.setRotationPoint(-0.5F, 11F, -0.5F); + shaft.setTextureSize(128, 64); + shaft.mirror = true; + setRotation(shaft, 0F, 0F, 0F); + portLeft = new ModelRenderer(this, 64, 31); + portLeft.addBox(0F, 0F, 0F, 1, 8, 8); + portLeft.setRotationPoint(-8.01F, 12F, -4F); + portLeft.setTextureSize(128, 64); + portLeft.mirror = true; + setRotation(portLeft, 0F, 0F, 0F); + tankLeft = new ModelRenderer(this, 64, 9); + tankLeft.addBox(0F, 0F, 0F, 6, 8, 14); + tankLeft.setRotationPoint(-7F, 11F, -7F); + tankLeft.setTextureSize(128, 64); + tankLeft.mirror = true; + setRotation(tankLeft, 0F, 0F, 0F); + support4 = new ModelRenderer(this, 7, 0); + support4.addBox(0F, 0F, 0F, 1, 1, 1); + support4.setRotationPoint(6F, 9F, 6F); + support4.setTextureSize(128, 64); + support4.mirror = true; + setRotation(support4, 0F, 0F, 0F); + bridge = new ModelRenderer(this, 64, 0); + bridge.addBox(0F, 0F, 0F, 8, 1, 8); + bridge.setRotationPoint(-4F, 9F, -4F); + bridge.setTextureSize(128, 64); + bridge.mirror = true; + setRotation(bridge, 0F, 0F, 0F); + tube8 = new ModelRenderer(this, 0, 0); + tube8.addBox(0F, 0F, 0F, 2, 1, 1); + tube8.setRotationPoint(-1F, 18F, 5F); + tube8.setTextureSize(128, 64); + tube8.mirror = true; + setRotation(tube8, 0F, 0F, 0F); + tube7 = new ModelRenderer(this, 0, 0); + tube7.addBox(0F, 0F, 0F, 2, 1, 1); + tube7.setRotationPoint(-1F, 12F, 5F); + tube7.setTextureSize(128, 64); + tube7.mirror = true; + setRotation(tube7, 0F, 0F, 0F); + tube6 = new ModelRenderer(this, 0, 0); + tube6.addBox(0F, 0F, 0F, 2, 1, 1); + tube6.setRotationPoint(-1F, 14F, 5F); + tube6.setTextureSize(128, 64); + tube6.mirror = true; + setRotation(tube6, 0F, 0F, 0F); + tube5 = new ModelRenderer(this, 0, 0); + tube5.addBox(0F, 0F, 0F, 2, 1, 1); + tube5.setRotationPoint(-1F, 16F, 5F); + tube5.setTextureSize(128, 64); + tube5.mirror = true; + setRotation(tube5, 0F, 0F, 0F); + tube4 = new ModelRenderer(this, 0, 0); + tube4.addBox(0F, 0F, 0F, 2, 1, 1); + tube4.setRotationPoint(-1F, 18F, -6F); + tube4.setTextureSize(128, 64); + tube4.mirror = true; + setRotation(tube4, 0F, 0F, 0F); + tube3 = new ModelRenderer(this, 0, 0); + tube3.addBox(0F, 0F, 0F, 2, 1, 1); + tube3.setRotationPoint(-1F, 16F, -6F); + tube3.setTextureSize(128, 64); + tube3.mirror = true; + setRotation(tube3, 0F, 0F, 0F); + tube2 = new ModelRenderer(this, 0, 0); + tube2.addBox(0F, 0F, 0F, 2, 1, 1); + tube2.setRotationPoint(-1F, 14F, -6F); + tube2.setTextureSize(128, 64); + tube2.mirror = true; + setRotation(tube2, 0F, 0F, 0F); + tube1 = new ModelRenderer(this, 0, 0); + tube1.addBox(0F, 0F, 0F, 2, 1, 1); + tube1.setRotationPoint(-1F, 12F, -6F); + tube1.setTextureSize(128, 64); + tube1.mirror = true; + setRotation(tube1, 0F, 0F, 0F); + top = new ModelRenderer(this, 0, 0); + top.addBox(0F, 0F, 0F, 16, 1, 16); + top.setRotationPoint(-8F, 8F, -8F); + top.setTextureSize(128, 64); + top.mirror = true; + setRotation(top, 0F, 0F, 0F); + support3 = new ModelRenderer(this, 7, 0); + support3.addBox(0F, 0F, 0F, 1, 1, 1); + support3.setRotationPoint(6F, 9F, -7F); + support3.setTextureSize(128, 64); + support3.mirror = true; + setRotation(support3, 0F, 0F, 0F); + support2 = new ModelRenderer(this, 7, 0); + support2.addBox(0F, 0F, 0F, 1, 1, 1); + support2.setRotationPoint(-7F, 9F, -7F); + support2.setTextureSize(128, 64); + support2.mirror = true; + setRotation(support2, 0F, 0F, 0F); + support1 = new ModelRenderer(this, 7, 0); + support1.addBox(0F, 0F, 0F, 1, 1, 1); + support1.setRotationPoint(-7F, 9F, 6F); + support1.setTextureSize(128, 64); + support1.mirror = true; + setRotation(support1, 0F, 0F, 0F); + } - public void render(float size) - { - portRight.render(size); - tankRight.render(size); - base.render(size); - pipe.render(size); - middle.render(size); - shaft.render(size); - portLeft.render(size); - tankLeft.render(size); - support4.render(size); - bridge.render(size); - tube8.render(size); - tube7.render(size); - tube6.render(size); - tube5.render(size); - tube4.render(size); - tube3.render(size); - tube2.render(size); - tube1.render(size); - top.render(size); - support3.render(size); - support2.render(size); - support1.render(size); - } + public void render(float size) { + portRight.render(size); + tankRight.render(size); + base.render(size); + pipe.render(size); + middle.render(size); + shaft.render(size); + portLeft.render(size); + tankLeft.render(size); + support4.render(size); + bridge.render(size); + tube8.render(size); + tube7.render(size); + tube6.render(size); + tube5.render(size); + tube4.render(size); + tube3.render(size); + tube2.render(size); + tube1.render(size); + top.render(size); + support3.render(size); + support2.render(size); + support1.render(size); + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/mekanism/client/model/ModelScubaTank.java b/src/main/java/mekanism/client/model/ModelScubaTank.java index 963eb82b1..6a4b56015 100644 --- a/src/main/java/mekanism/client/model/ModelScubaTank.java +++ b/src/main/java/mekanism/client/model/ModelScubaTank.java @@ -1,102 +1,98 @@ package mekanism.client.model; -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; @SideOnly(Side.CLIENT) -public class ModelScubaTank extends ModelBase -{ - ModelRenderer tankL; - ModelRenderer tankR; - ModelRenderer tankdock; - ModelRenderer capL; - ModelRenderer capR; - ModelRenderer tankbridge; - ModelRenderer tankpipelower; - ModelRenderer tankpipeupper; - ModelRenderer tankbackbrace; +public class ModelScubaTank extends ModelBase { + ModelRenderer tankL; + ModelRenderer tankR; + ModelRenderer tankdock; + ModelRenderer capL; + ModelRenderer capR; + ModelRenderer tankbridge; + ModelRenderer tankpipelower; + ModelRenderer tankpipeupper; + ModelRenderer tankbackbrace; - public ModelScubaTank() - { - textureWidth = 128; - textureHeight = 64; + public ModelScubaTank() { + textureWidth = 128; + textureHeight = 64; - tankL = new ModelRenderer(this, 23, 54); - tankL.addBox(-1F, 2F, 4F, 3, 7, 3); - tankL.setRotationPoint(0F, 0F, 0F); - tankL.setTextureSize(128, 64); - tankL.mirror = true; - setRotation(tankL, -0.2443461F, 0.5235988F, 0F); - tankR = new ModelRenderer(this, 23, 54); - tankR.addBox(-2F, 2F, 4F, 3, 7, 3); - tankR.setRotationPoint(0F, 0F, 0F); - tankR.setTextureSize(128, 64); - tankR.mirror = true; - setRotation(tankR, -0.2443461F, -0.5235988F, 0F); - tankR.mirror = false; - tankdock = new ModelRenderer(this, 0, 55); - tankdock.addBox(-2F, 5F, 1F, 4, 4, 5); - tankdock.setRotationPoint(0F, 0F, 0F); - tankdock.setTextureSize(128, 64); - tankdock.mirror = true; - setRotation(tankdock, 0F, 0F, 0F); - capL = new ModelRenderer(this, 23, 51); - capL.addBox(-0.5F, 1F, 4.5F, 2, 1, 2); - capL.setRotationPoint(0F, 0F, 0F); - capL.setTextureSize(128, 64); - capL.mirror = true; - setRotation(capL, -0.2443461F, 0.5235988F, 0F); - capR = new ModelRenderer(this, 23, 51); - capR.addBox(-1.5F, 1F, 4.5F, 2, 1, 2); - capR.setRotationPoint(0F, 0F, 0F); - capR.setTextureSize(128, 64); - capR.mirror = true; - setRotation(capR, -0.2443461F, -0.5235988F, 0F); - tankbridge = new ModelRenderer(this, 0, 47); - tankbridge.addBox(-1F, 3F, -1.5F, 2, 5, 3); - tankbridge.setRotationPoint(0F, 0F, 0F); - tankbridge.setTextureSize(128, 64); - tankbridge.mirror = true; - setRotation(tankbridge, 0.5934119F, 0F, 0F); - tankpipelower = new ModelRenderer(this, 0, 37); - tankpipelower.addBox(-0.5F, 2F, 3F, 1, 4, 1); - tankpipelower.setRotationPoint(0F, 0F, 0F); - tankpipelower.setTextureSize(128, 64); - tankpipelower.mirror = true; - setRotation(tankpipelower, 0.2094395F, 0F, 0F); - tankpipeupper = new ModelRenderer(this, 4, 38); - tankpipeupper.addBox(-0.5F, 1F, 1.5F, 1, 1, 3); - tankpipeupper.setRotationPoint(0F, 0F, 0F); - tankpipeupper.setTextureSize(128, 64); - tankpipeupper.mirror = true; - setRotation(tankpipeupper, 0F, 0F, 0F); - tankbackbrace = new ModelRenderer(this, 0, 42); - tankbackbrace.addBox(-3F, 2F, 0.5F, 6, 3, 2); - tankbackbrace.setRotationPoint(0F, 0F, 0F); - tankbackbrace.setTextureSize(128, 64); - tankbackbrace.mirror = true; - setRotation(tankbackbrace, 0.2443461F, 0F, 0F); - } + tankL = new ModelRenderer(this, 23, 54); + tankL.addBox(-1F, 2F, 4F, 3, 7, 3); + tankL.setRotationPoint(0F, 0F, 0F); + tankL.setTextureSize(128, 64); + tankL.mirror = true; + setRotation(tankL, -0.2443461F, 0.5235988F, 0F); + tankR = new ModelRenderer(this, 23, 54); + tankR.addBox(-2F, 2F, 4F, 3, 7, 3); + tankR.setRotationPoint(0F, 0F, 0F); + tankR.setTextureSize(128, 64); + tankR.mirror = true; + setRotation(tankR, -0.2443461F, -0.5235988F, 0F); + tankR.mirror = false; + tankdock = new ModelRenderer(this, 0, 55); + tankdock.addBox(-2F, 5F, 1F, 4, 4, 5); + tankdock.setRotationPoint(0F, 0F, 0F); + tankdock.setTextureSize(128, 64); + tankdock.mirror = true; + setRotation(tankdock, 0F, 0F, 0F); + capL = new ModelRenderer(this, 23, 51); + capL.addBox(-0.5F, 1F, 4.5F, 2, 1, 2); + capL.setRotationPoint(0F, 0F, 0F); + capL.setTextureSize(128, 64); + capL.mirror = true; + setRotation(capL, -0.2443461F, 0.5235988F, 0F); + capR = new ModelRenderer(this, 23, 51); + capR.addBox(-1.5F, 1F, 4.5F, 2, 1, 2); + capR.setRotationPoint(0F, 0F, 0F); + capR.setTextureSize(128, 64); + capR.mirror = true; + setRotation(capR, -0.2443461F, -0.5235988F, 0F); + tankbridge = new ModelRenderer(this, 0, 47); + tankbridge.addBox(-1F, 3F, -1.5F, 2, 5, 3); + tankbridge.setRotationPoint(0F, 0F, 0F); + tankbridge.setTextureSize(128, 64); + tankbridge.mirror = true; + setRotation(tankbridge, 0.5934119F, 0F, 0F); + tankpipelower = new ModelRenderer(this, 0, 37); + tankpipelower.addBox(-0.5F, 2F, 3F, 1, 4, 1); + tankpipelower.setRotationPoint(0F, 0F, 0F); + tankpipelower.setTextureSize(128, 64); + tankpipelower.mirror = true; + setRotation(tankpipelower, 0.2094395F, 0F, 0F); + tankpipeupper = new ModelRenderer(this, 4, 38); + tankpipeupper.addBox(-0.5F, 1F, 1.5F, 1, 1, 3); + tankpipeupper.setRotationPoint(0F, 0F, 0F); + tankpipeupper.setTextureSize(128, 64); + tankpipeupper.mirror = true; + setRotation(tankpipeupper, 0F, 0F, 0F); + tankbackbrace = new ModelRenderer(this, 0, 42); + tankbackbrace.addBox(-3F, 2F, 0.5F, 6, 3, 2); + tankbackbrace.setRotationPoint(0F, 0F, 0F); + tankbackbrace.setTextureSize(128, 64); + tankbackbrace.mirror = true; + setRotation(tankbackbrace, 0.2443461F, 0F, 0F); + } - public void render(float size) - { - tankL.render(size); - tankR.render(size); - tankdock.render(size); - capL.render(size); - capR.render(size); - tankbridge.render(size); - tankpipelower.render(size); - tankpipeupper.render(size); - tankbackbrace.render(size); - } + public void render(float size) { + tankL.render(size); + tankR.render(size); + tankdock.render(size); + capL.render(size); + capR.render(size); + tankbridge.render(size); + tankpipelower.render(size); + tankpipeupper.render(size); + tankbackbrace.render(size); + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/model/ModelSecurityDesk.java b/src/main/java/mekanism/client/model/ModelSecurityDesk.java index 0bde64d7c..0a1df4df8 100644 --- a/src/main/java/mekanism/client/model/ModelSecurityDesk.java +++ b/src/main/java/mekanism/client/model/ModelSecurityDesk.java @@ -1,5 +1,7 @@ package mekanism.client.model; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.render.MekanismRenderer; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; @@ -7,132 +9,124 @@ import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class ModelSecurityDesk extends ModelBase -{ - public static ResourceLocation OVERLAY = MekanismUtils.getResource(ResourceType.RENDER, "SecurityDesk_Overlay.png"); - - ModelRenderer deskTop; - ModelRenderer deskBase; - ModelRenderer led; - ModelRenderer monitorBack; - ModelRenderer keyboard; - ModelRenderer monitor; - ModelRenderer standNeck; - ModelRenderer standBase; - ModelRenderer deskMiddle; - ModelRenderer monitorScreen; +public class ModelSecurityDesk extends ModelBase { + public static ResourceLocation OVERLAY + = MekanismUtils.getResource(ResourceType.RENDER, "SecurityDesk_Overlay.png"); - public ModelSecurityDesk() - { - textureWidth = 128; - textureHeight = 64; + ModelRenderer deskTop; + ModelRenderer deskBase; + ModelRenderer led; + ModelRenderer monitorBack; + ModelRenderer keyboard; + ModelRenderer monitor; + ModelRenderer standNeck; + ModelRenderer standBase; + ModelRenderer deskMiddle; + ModelRenderer monitorScreen; - deskTop = new ModelRenderer(this, 0, 0); - deskTop.addBox(0F, 0F, 0F, 16, 7, 16); - deskTop.setRotationPoint(-8F, 11F, -8F); - deskTop.setTextureSize(128, 64); - deskTop.mirror = true; - setRotation(deskTop, 0F, 0F, 0F); - deskBase = new ModelRenderer(this, 0, 38); - deskBase.addBox(0F, 0F, 0F, 16, 5, 16); - deskBase.setRotationPoint(-8F, 19F, -8F); - deskBase.setTextureSize(128, 64); - deskBase.mirror = true; - setRotation(deskBase, 0F, 0F, 0F); - led = new ModelRenderer(this, 0, 0); - led.addBox(12F, 4.5F, -1.5F, 1, 1, 1); - led.setRotationPoint(-7F, 5F, 4F); - led.setTextureSize(128, 64); - led.mirror = true; - setRotation(led, -0.4712389F, 0F, 0F); - monitorBack = new ModelRenderer(this, 82, 0); - monitorBack.addBox(1F, -3F, 0F, 12, 6, 1); - monitorBack.setRotationPoint(-7F, 5F, 4F); - monitorBack.setTextureSize(128, 64); - monitorBack.mirror = true; - setRotation(monitorBack, -0.4712389F, 0F, 0F); - keyboard = new ModelRenderer(this, 64, 27); - keyboard.addBox(0F, 0F, 0F, 10, 1, 5); - keyboard.setRotationPoint(-5F, 10.5F, -6F); - keyboard.setTextureSize(128, 64); - keyboard.mirror = true; - setRotation(keyboard, 0.0872665F, 0F, 0F); - monitor = new ModelRenderer(this, 64, 10); - monitor.addBox(0F, -5F, -2F, 14, 10, 2); - monitor.setRotationPoint(-7F, 5F, 4F); - monitor.setTextureSize(128, 64); - monitor.mirror = true; - setRotation(monitor, -0.4712389F, 0F, 0F); - standNeck = new ModelRenderer(this, 96, 7); - standNeck.addBox(0F, -7F, -1F, 2, 7, 1); - standNeck.setRotationPoint(-1F, 10F, 6F); - standNeck.setTextureSize(128, 64); - standNeck.mirror = true; - setRotation(standNeck, 0.0698132F, 0F, 0F); - standBase = new ModelRenderer(this, 64, 22); - standBase.addBox(0F, 0F, -4F, 8, 1, 4); - standBase.setRotationPoint(-4F, 10F, 6F); - standBase.setTextureSize(128, 64); - standBase.mirror = true; - setRotation(standBase, 0.1047198F, 0F, 0F); - deskMiddle = new ModelRenderer(this, 0, 23); - deskMiddle.addBox(0F, 0F, 0F, 14, 1, 14); - deskMiddle.setRotationPoint(-7F, 18F, -7F); - deskMiddle.setTextureSize(128, 64); - deskMiddle.mirror = true; - setRotation(deskMiddle, 0F, 0F, 0F); - monitorScreen = new ModelRenderer(this, 64, 33); - monitorScreen.addBox(0.5F, -4.5F, -2.01F, 13, 9, 2); - monitorScreen.setRotationPoint(-7F, 5F, 4F); - monitorScreen.setTextureSize(128, 64); - monitorScreen.mirror = true; - setRotation(monitorScreen, -0.4712389F, 0F, 0F); - } + public ModelSecurityDesk() { + textureWidth = 128; + textureHeight = 64; - public void render(float size, TextureManager manager) - { - GL11.glPushMatrix(); - MekanismRenderer.blendOn(); - - doRender(size); - - manager.bindTexture(OVERLAY); - GL11.glScalef(1.001F, 1.001F, 1.001F); - GL11.glTranslatef(0, -0.0011F, 0); - MekanismRenderer.glowOn(); - - doRender(size); - - MekanismRenderer.glowOff(); - MekanismRenderer.blendOff(); - GL11.glPopMatrix(); - } - - private void doRender(float size) - { - deskTop.render(size); - deskBase.render(size); - led.render(size); - monitorBack.render(size); - keyboard.render(size); - monitor.render(size); - standNeck.render(size); - standBase.render(size); - deskMiddle.render(size); - monitorScreen.render(size); - } + deskTop = new ModelRenderer(this, 0, 0); + deskTop.addBox(0F, 0F, 0F, 16, 7, 16); + deskTop.setRotationPoint(-8F, 11F, -8F); + deskTop.setTextureSize(128, 64); + deskTop.mirror = true; + setRotation(deskTop, 0F, 0F, 0F); + deskBase = new ModelRenderer(this, 0, 38); + deskBase.addBox(0F, 0F, 0F, 16, 5, 16); + deskBase.setRotationPoint(-8F, 19F, -8F); + deskBase.setTextureSize(128, 64); + deskBase.mirror = true; + setRotation(deskBase, 0F, 0F, 0F); + led = new ModelRenderer(this, 0, 0); + led.addBox(12F, 4.5F, -1.5F, 1, 1, 1); + led.setRotationPoint(-7F, 5F, 4F); + led.setTextureSize(128, 64); + led.mirror = true; + setRotation(led, -0.4712389F, 0F, 0F); + monitorBack = new ModelRenderer(this, 82, 0); + monitorBack.addBox(1F, -3F, 0F, 12, 6, 1); + monitorBack.setRotationPoint(-7F, 5F, 4F); + monitorBack.setTextureSize(128, 64); + monitorBack.mirror = true; + setRotation(monitorBack, -0.4712389F, 0F, 0F); + keyboard = new ModelRenderer(this, 64, 27); + keyboard.addBox(0F, 0F, 0F, 10, 1, 5); + keyboard.setRotationPoint(-5F, 10.5F, -6F); + keyboard.setTextureSize(128, 64); + keyboard.mirror = true; + setRotation(keyboard, 0.0872665F, 0F, 0F); + monitor = new ModelRenderer(this, 64, 10); + monitor.addBox(0F, -5F, -2F, 14, 10, 2); + monitor.setRotationPoint(-7F, 5F, 4F); + monitor.setTextureSize(128, 64); + monitor.mirror = true; + setRotation(monitor, -0.4712389F, 0F, 0F); + standNeck = new ModelRenderer(this, 96, 7); + standNeck.addBox(0F, -7F, -1F, 2, 7, 1); + standNeck.setRotationPoint(-1F, 10F, 6F); + standNeck.setTextureSize(128, 64); + standNeck.mirror = true; + setRotation(standNeck, 0.0698132F, 0F, 0F); + standBase = new ModelRenderer(this, 64, 22); + standBase.addBox(0F, 0F, -4F, 8, 1, 4); + standBase.setRotationPoint(-4F, 10F, 6F); + standBase.setTextureSize(128, 64); + standBase.mirror = true; + setRotation(standBase, 0.1047198F, 0F, 0F); + deskMiddle = new ModelRenderer(this, 0, 23); + deskMiddle.addBox(0F, 0F, 0F, 14, 1, 14); + deskMiddle.setRotationPoint(-7F, 18F, -7F); + deskMiddle.setTextureSize(128, 64); + deskMiddle.mirror = true; + setRotation(deskMiddle, 0F, 0F, 0F); + monitorScreen = new ModelRenderer(this, 64, 33); + monitorScreen.addBox(0.5F, -4.5F, -2.01F, 13, 9, 2); + monitorScreen.setRotationPoint(-7F, 5F, 4F); + monitorScreen.setTextureSize(128, 64); + monitorScreen.mirror = true; + setRotation(monitorScreen, -0.4712389F, 0F, 0F); + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + public void render(float size, TextureManager manager) { + GL11.glPushMatrix(); + MekanismRenderer.blendOn(); + + doRender(size); + + manager.bindTexture(OVERLAY); + GL11.glScalef(1.001F, 1.001F, 1.001F); + GL11.glTranslatef(0, -0.0011F, 0); + MekanismRenderer.glowOn(); + + doRender(size); + + MekanismRenderer.glowOff(); + MekanismRenderer.blendOff(); + GL11.glPopMatrix(); + } + + private void doRender(float size) { + deskTop.render(size); + deskBase.render(size); + led.render(size); + monitorBack.render(size); + keyboard.render(size); + monitor.render(size); + standNeck.render(size); + standBase.render(size); + deskMiddle.render(size); + monitorScreen.render(size); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/mekanism/client/model/ModelSeismicVibrator.java b/src/main/java/mekanism/client/model/ModelSeismicVibrator.java index c304a8c71..4af25b37d 100644 --- a/src/main/java/mekanism/client/model/ModelSeismicVibrator.java +++ b/src/main/java/mekanism/client/model/ModelSeismicVibrator.java @@ -1,398 +1,393 @@ package mekanism.client.model; -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; @SideOnly(Side.CLIENT) -public class ModelSeismicVibrator extends ModelBase -{ - ModelRenderer plate3; - ModelRenderer baseBack; - ModelRenderer motor; - ModelRenderer port; - ModelRenderer pole4; - ModelRenderer shaft2; - ModelRenderer shaft1; - ModelRenderer arm3; - ModelRenderer plate2; - ModelRenderer arm2; - ModelRenderer arm1; - ModelRenderer top; - ModelRenderer frameBack5; - ModelRenderer pole3; - ModelRenderer frameRight5; - ModelRenderer baseRight; - ModelRenderer baseFront; - ModelRenderer baseLeft; - ModelRenderer frameRight3; - ModelRenderer pole1; - ModelRenderer frameRight4; - ModelRenderer frameRight1; - ModelRenderer frameRight2; - ModelRenderer frameLeft5; - ModelRenderer frameLeft4; - ModelRenderer frameBack3; - ModelRenderer frameLeft2; - ModelRenderer frameLeft1; - ModelRenderer pole2; - ModelRenderer frameBack1; - ModelRenderer frameBack2; - ModelRenderer frameBack4; - ModelRenderer frameLeft3; - ModelRenderer conduit; - ModelRenderer plate1; - ModelRenderer rivet10; - ModelRenderer rivet5; - ModelRenderer rivet1; - ModelRenderer rivet6; - ModelRenderer rivet2; - ModelRenderer rivet7; - ModelRenderer rivet3; - ModelRenderer rivet8; - ModelRenderer rivet4; - ModelRenderer rivet9; +public class ModelSeismicVibrator extends ModelBase { + ModelRenderer plate3; + ModelRenderer baseBack; + ModelRenderer motor; + ModelRenderer port; + ModelRenderer pole4; + ModelRenderer shaft2; + ModelRenderer shaft1; + ModelRenderer arm3; + ModelRenderer plate2; + ModelRenderer arm2; + ModelRenderer arm1; + ModelRenderer top; + ModelRenderer frameBack5; + ModelRenderer pole3; + ModelRenderer frameRight5; + ModelRenderer baseRight; + ModelRenderer baseFront; + ModelRenderer baseLeft; + ModelRenderer frameRight3; + ModelRenderer pole1; + ModelRenderer frameRight4; + ModelRenderer frameRight1; + ModelRenderer frameRight2; + ModelRenderer frameLeft5; + ModelRenderer frameLeft4; + ModelRenderer frameBack3; + ModelRenderer frameLeft2; + ModelRenderer frameLeft1; + ModelRenderer pole2; + ModelRenderer frameBack1; + ModelRenderer frameBack2; + ModelRenderer frameBack4; + ModelRenderer frameLeft3; + ModelRenderer conduit; + ModelRenderer plate1; + ModelRenderer rivet10; + ModelRenderer rivet5; + ModelRenderer rivet1; + ModelRenderer rivet6; + ModelRenderer rivet2; + ModelRenderer rivet7; + ModelRenderer rivet3; + ModelRenderer rivet8; + ModelRenderer rivet4; + ModelRenderer rivet9; - public ModelSeismicVibrator() - { - textureWidth = 128; - textureHeight = 64; + public ModelSeismicVibrator() { + textureWidth = 128; + textureHeight = 64; - plate3 = new ModelRenderer(this, 36, 42); - plate3.addBox(0F, 0F, 0F, 8, 2, 8); - plate3.setRotationPoint(-4F, 22F, -4F); - plate3.setTextureSize(128, 64); - plate3.mirror = true; - setRotation(plate3, 0F, 0F, 0F); - baseBack = new ModelRenderer(this, 0, 26); - baseBack.addBox(0F, 0F, 0F, 16, 5, 3); - baseBack.setRotationPoint(-8F, 19F, 5F); - baseBack.setTextureSize(128, 64); - baseBack.mirror = true; - setRotation(baseBack, 0F, 0F, 0F); - motor = new ModelRenderer(this, 76, 13); - motor.addBox(0F, 0F, 0F, 6, 4, 10); - motor.setRotationPoint(-3F, -5F, -3F); - motor.setTextureSize(128, 64); - motor.mirror = true; - setRotation(motor, 0F, 0F, 0F); - port = new ModelRenderer(this, 38, 33); - port.addBox(0F, 0F, 0F, 8, 8, 1); - port.setRotationPoint(-4F, 12F, 7.01F); - port.setTextureSize(128, 64); - port.mirror = true; - setRotation(port, 0F, 0F, 0F); - pole4 = new ModelRenderer(this, 0, 34); - pole4.addBox(0F, 0F, 0F, 1, 25, 1); - pole4.setRotationPoint(6.5F, -6F, 6.5F); - pole4.setTextureSize(128, 64); - pole4.mirror = true; - setRotation(pole4, 0F, 0F, 0F); - shaft2 = new ModelRenderer(this, 16, 34); - shaft2.addBox(0F, 0F, 0F, 3, 11, 3); - shaft2.setRotationPoint(-1.5F, -5F, -1.5F); - shaft2.setTextureSize(128, 64); - shaft2.mirror = true; - setRotation(shaft2, 0F, 0F, 0F); - shaft1 = new ModelRenderer(this, 8, 34); - shaft1.addBox(0F, 0F, 0F, 2, 15, 2); - shaft1.setRotationPoint(-1F, 6F, -1F); - shaft1.setTextureSize(128, 64); - shaft1.mirror = true; - setRotation(shaft1, 0F, 0F, 0F); - arm3 = new ModelRenderer(this, 0, 6); - arm3.addBox(0F, 0F, 0F, 2, 2, 4); - arm3.setRotationPoint(-1F, 7F, 3F); - arm3.setTextureSize(128, 64); - arm3.mirror = true; - setRotation(arm3, -0.3665191F, 0F, 0F); - plate2 = new ModelRenderer(this, 48, 0); - plate2.addBox(0F, 0F, 0F, 4, 2, 4); - plate2.setRotationPoint(-2F, 21F, -2F); - plate2.setTextureSize(128, 64); - plate2.mirror = true; - setRotation(plate2, 0F, 0F, 0F); - arm2 = new ModelRenderer(this, 48, 6); - arm2.addBox(0F, 0F, 0F, 4, 2, 4); - arm2.setRotationPoint(-2F, 7F, -2F); - arm2.setTextureSize(128, 64); - arm2.mirror = true; - setRotation(arm2, 0F, 0F, 0F); - arm1 = new ModelRenderer(this, 56, 33); - arm1.addBox(0F, 0F, 0F, 3, 2, 4); - arm1.setRotationPoint(-1.5F, 7F, 2F); - arm1.setTextureSize(128, 64); - arm1.mirror = true; - setRotation(arm1, 0F, 0F, 0F); - top = new ModelRenderer(this, 0, 0); - top.addBox(0F, 0F, 0F, 16, 2, 16); - top.setRotationPoint(-8F, -8F, -8F); - top.setTextureSize(128, 64); - top.mirror = true; - setRotation(top, 0F, 0F, 0F); - frameBack5 = new ModelRenderer(this, 4, 34); - frameBack5.addBox(-1F, 0F, 0F, 1, 19, 1); - frameBack5.setRotationPoint(7.5F, 7F, 6.49F); - frameBack5.setTextureSize(128, 64); - frameBack5.mirror = true; - setRotation(frameBack5, 0F, 0F, 0.837758F); - pole3 = new ModelRenderer(this, 0, 34); - pole3.addBox(0F, 0F, 0F, 1, 25, 1); - pole3.setRotationPoint(6.5F, -6F, -7.5F); - pole3.setTextureSize(128, 64); - pole3.mirror = true; - setRotation(pole3, 0F, 0F, 0F); - frameRight5 = new ModelRenderer(this, 4, 34); - frameRight5.addBox(0F, 0F, 0F, 1, 19, 1); - frameRight5.setRotationPoint(6.485F, 7F, -7.5F); - frameRight5.setTextureSize(128, 64); - frameRight5.mirror = true; - setRotation(frameRight5, 0.837758F, 0F, 0F); - baseRight = new ModelRenderer(this, 38, 18); - baseRight.mirror = true; - baseRight.addBox(0F, 0F, 0F, 3, 5, 10); - baseRight.setRotationPoint(5F, 19F, -5F); - baseRight.setTextureSize(128, 64); - setRotation(baseRight, 0F, 0F, 0F); - baseFront = new ModelRenderer(this, 0, 18); - baseFront.addBox(0F, 0F, 0F, 16, 5, 3); - baseFront.setRotationPoint(-8F, 19F, -8F); - baseFront.setTextureSize(128, 64); - baseFront.mirror = true; - setRotation(baseFront, 0F, 0F, 0F); - baseLeft = new ModelRenderer(this, 38, 18); - baseLeft.addBox(0F, 0F, 0F, 3, 5, 10); - baseLeft.setRotationPoint(-8F, 19F, -5F); - baseLeft.setTextureSize(128, 64); - baseLeft.mirror = true; - setRotation(baseLeft, 0F, 0F, 0F); - frameRight3 = new ModelRenderer(this, 64, 27); - frameRight3.addBox(0F, 0F, 0F, 1, 1, 13); - frameRight3.setRotationPoint(6.5F, 6F, -6.5F); - frameRight3.setTextureSize(128, 64); - frameRight3.mirror = true; - setRotation(frameRight3, 0F, 0F, 0F); - pole1 = new ModelRenderer(this, 0, 34); - pole1.addBox(0F, 0F, 0F, 1, 25, 1); - pole1.setRotationPoint(-7.5F, -6F, -7.5F); - pole1.setTextureSize(128, 64); - pole1.mirror = true; - setRotation(pole1, 0F, 0F, 0F); - frameRight4 = new ModelRenderer(this, 4, 34); - frameRight4.addBox(0F, 0F, -1F, 1, 19, 1); - frameRight4.setRotationPoint(6.49F, 7F, 7.5F); - frameRight4.setTextureSize(128, 64); - frameRight4.mirror = true; - setRotation(frameRight4, -0.837758F, 0F, 0F); - frameRight1 = new ModelRenderer(this, 4, 34); - frameRight1.addBox(0F, 0F, 0F, 1, 19, 1); - frameRight1.setRotationPoint(6.485F, -6F, -7.5F); - frameRight1.setTextureSize(128, 64); - frameRight1.mirror = true; - setRotation(frameRight1, 0.837758F, 0F, 0F); - frameRight2 = new ModelRenderer(this, 4, 34); - frameRight2.addBox(0F, 0F, -1F, 1, 19, 1); - frameRight2.setRotationPoint(6.49F, -6F, 7.5F); - frameRight2.setTextureSize(128, 64); - frameRight2.mirror = true; - setRotation(frameRight2, -0.837758F, 0F, 0F); - frameLeft5 = new ModelRenderer(this, 4, 34); - frameLeft5.addBox(0F, 0F, 0F, 1, 19, 1); - frameLeft5.setRotationPoint(-7.485F, 7F, -7.5F); - frameLeft5.setTextureSize(128, 64); - frameLeft5.mirror = true; - setRotation(frameLeft5, 0.837758F, 0F, 0F); - frameLeft4 = new ModelRenderer(this, 4, 34); - frameLeft4.addBox(0F, 0F, -1F, 1, 19, 1); - frameLeft4.setRotationPoint(-7.49F, 7F, 7.5F); - frameLeft4.setTextureSize(128, 64); - frameLeft4.mirror = true; - setRotation(frameLeft4, -0.837758F, 0F, 0F); - frameBack3 = new ModelRenderer(this, 36, 52); - frameBack3.addBox(0F, 0F, 0F, 13, 1, 1); - frameBack3.setRotationPoint(-6.5F, 6F, 6.5F); - frameBack3.setTextureSize(128, 64); - frameBack3.mirror = true; - setRotation(frameBack3, 0F, 0F, 0F); - frameLeft2 = new ModelRenderer(this, 4, 34); - frameLeft2.addBox(0F, 0F, 0F, 1, 19, 1); - frameLeft2.setRotationPoint(-7.485F, -6F, -7.5F); - frameLeft2.setTextureSize(128, 64); - frameLeft2.mirror = true; - setRotation(frameLeft2, 0.837758F, 0F, 0F); - frameLeft1 = new ModelRenderer(this, 4, 34); - frameLeft1.addBox(0F, 0F, -1F, 1, 19, 1); - frameLeft1.setRotationPoint(-7.49F, -6F, 7.5F); - frameLeft1.setTextureSize(128, 64); - frameLeft1.mirror = true; - setRotation(frameLeft1, -0.837758F, 0F, 0F); - pole2 = new ModelRenderer(this, 0, 34); - pole2.addBox(0F, 0F, 0F, 1, 25, 1); - pole2.setRotationPoint(-7.5F, -6F, 6.5F); - pole2.setTextureSize(128, 64); - pole2.mirror = true; - setRotation(pole2, 0F, 0F, 0F); - frameBack1 = new ModelRenderer(this, 4, 34); - frameBack1.addBox(-1F, 0F, 0F, 1, 19, 1); - frameBack1.setRotationPoint(7.5F, -6F, 6.49F); - frameBack1.setTextureSize(128, 64); - frameBack1.mirror = true; - setRotation(frameBack1, 0F, 0F, 0.837758F); - frameBack2 = new ModelRenderer(this, 4, 34); - frameBack2.addBox(0F, 0F, 0F, 1, 19, 1); - frameBack2.setRotationPoint(-7.5F, -6F, 6.49F); - frameBack2.setTextureSize(128, 64); - frameBack2.mirror = true; - setRotation(frameBack2, 0F, 0F, -0.837758F); - frameBack4 = new ModelRenderer(this, 4, 34); - frameBack4.addBox(0F, 0F, 0F, 1, 19, 1); - frameBack4.setRotationPoint(-7.5F, 7F, 6.49F); - frameBack4.setTextureSize(128, 64); - frameBack4.mirror = true; - setRotation(frameBack4, 0F, 0F, -0.837758F); - frameLeft3 = new ModelRenderer(this, 64, 27); - frameLeft3.addBox(0F, 0F, 0F, 1, 1, 13); - frameLeft3.setRotationPoint(-7.5F, 6F, -6.5F); - frameLeft3.setTextureSize(128, 64); - frameLeft3.mirror = true; - setRotation(frameLeft3, 0F, 0F, 0F); - conduit = new ModelRenderer(this, 64, 0); - conduit.addBox(0F, 0F, 0F, 4, 25, 2); - conduit.setRotationPoint(-2F, -6F, 6F); - conduit.setTextureSize(128, 64); - conduit.mirror = true; - setRotation(conduit, 0F, 0F, 0F); - plate1 = new ModelRenderer(this, 76, 0); - plate1.addBox(0F, 0F, 0F, 10, 1, 12); - plate1.setRotationPoint(-5F, -6F, -5F); - plate1.setTextureSize(128, 64); - plate1.mirror = true; - setRotation(plate1, 0F, 0F, 0F); - rivet10 = new ModelRenderer(this, 0, 0); - rivet10.addBox(0F, 0F, 0F, 1, 1, 1); - rivet10.setRotationPoint(3.5F, -5.5F, 3.5F); - rivet10.setTextureSize(128, 64); - rivet10.mirror = true; - setRotation(rivet10, 0F, 0F, 0F); - rivet5 = new ModelRenderer(this, 0, 0); - rivet5.addBox(0F, 0F, 0F, 1, 1, 1); - rivet5.setRotationPoint(-4.5F, -5.5F, 3.5F); - rivet5.setTextureSize(128, 64); - rivet5.mirror = true; - setRotation(rivet5, 0F, 0F, 0F); - rivet1 = new ModelRenderer(this, 0, 0); - rivet1.addBox(0F, 0F, 0F, 1, 1, 1); - rivet1.setRotationPoint(-4.5F, -5.5F, -4.5F); - rivet1.setTextureSize(128, 64); - rivet1.mirror = true; - setRotation(rivet1, 0F, 0F, 0F); - rivet6 = new ModelRenderer(this, 0, 0); - rivet6.addBox(0F, 0F, 0F, 1, 1, 1); - rivet6.setRotationPoint(3.5F, -5.5F, -4.5F); - rivet6.setTextureSize(128, 64); - rivet6.mirror = true; - setRotation(rivet6, 0F, 0F, 0F); - rivet2 = new ModelRenderer(this, 0, 0); - rivet2.addBox(0F, 0F, 0F, 1, 1, 1); - rivet2.setRotationPoint(-4.5F, -5.5F, -2.5F); - rivet2.setTextureSize(128, 64); - rivet2.mirror = true; - setRotation(rivet2, 0F, 0F, 0F); - rivet7 = new ModelRenderer(this, 0, 0); - rivet7.addBox(0F, 0F, 0F, 1, 1, 1); - rivet7.setRotationPoint(3.5F, -5.5F, -2.5F); - rivet7.setTextureSize(128, 64); - rivet7.mirror = true; - setRotation(rivet7, 0F, 0F, 0F); - rivet3 = new ModelRenderer(this, 0, 0); - rivet3.addBox(0F, 0F, 0F, 1, 1, 1); - rivet3.setRotationPoint(-4.5F, -5.5F, -0.5F); - rivet3.setTextureSize(128, 64); - rivet3.mirror = true; - setRotation(rivet3, 0F, 0F, 0F); - rivet8 = new ModelRenderer(this, 0, 0); - rivet8.addBox(0F, 0F, 0F, 1, 1, 1); - rivet8.setRotationPoint(3.5F, -5.5F, -0.5F); - rivet8.setTextureSize(128, 64); - rivet8.mirror = true; - setRotation(rivet8, 0F, 0F, 0F); - rivet4 = new ModelRenderer(this, 0, 0); - rivet4.addBox(0F, 0F, 0F, 1, 1, 1); - rivet4.setRotationPoint(-4.5F, -5.5F, 1.5F); - rivet4.setTextureSize(128, 64); - rivet4.mirror = true; - setRotation(rivet4, 0F, 0F, 0F); - rivet9 = new ModelRenderer(this, 0, 0); - rivet9.addBox(0F, 0F, 0F, 1, 1, 1); - rivet9.setRotationPoint(3.5F, -5.5F, 1.5F); - rivet9.setTextureSize(128, 64); - rivet9.mirror = true; - setRotation(rivet9, 0F, 0F, 0F); - } + plate3 = new ModelRenderer(this, 36, 42); + plate3.addBox(0F, 0F, 0F, 8, 2, 8); + plate3.setRotationPoint(-4F, 22F, -4F); + plate3.setTextureSize(128, 64); + plate3.mirror = true; + setRotation(plate3, 0F, 0F, 0F); + baseBack = new ModelRenderer(this, 0, 26); + baseBack.addBox(0F, 0F, 0F, 16, 5, 3); + baseBack.setRotationPoint(-8F, 19F, 5F); + baseBack.setTextureSize(128, 64); + baseBack.mirror = true; + setRotation(baseBack, 0F, 0F, 0F); + motor = new ModelRenderer(this, 76, 13); + motor.addBox(0F, 0F, 0F, 6, 4, 10); + motor.setRotationPoint(-3F, -5F, -3F); + motor.setTextureSize(128, 64); + motor.mirror = true; + setRotation(motor, 0F, 0F, 0F); + port = new ModelRenderer(this, 38, 33); + port.addBox(0F, 0F, 0F, 8, 8, 1); + port.setRotationPoint(-4F, 12F, 7.01F); + port.setTextureSize(128, 64); + port.mirror = true; + setRotation(port, 0F, 0F, 0F); + pole4 = new ModelRenderer(this, 0, 34); + pole4.addBox(0F, 0F, 0F, 1, 25, 1); + pole4.setRotationPoint(6.5F, -6F, 6.5F); + pole4.setTextureSize(128, 64); + pole4.mirror = true; + setRotation(pole4, 0F, 0F, 0F); + shaft2 = new ModelRenderer(this, 16, 34); + shaft2.addBox(0F, 0F, 0F, 3, 11, 3); + shaft2.setRotationPoint(-1.5F, -5F, -1.5F); + shaft2.setTextureSize(128, 64); + shaft2.mirror = true; + setRotation(shaft2, 0F, 0F, 0F); + shaft1 = new ModelRenderer(this, 8, 34); + shaft1.addBox(0F, 0F, 0F, 2, 15, 2); + shaft1.setRotationPoint(-1F, 6F, -1F); + shaft1.setTextureSize(128, 64); + shaft1.mirror = true; + setRotation(shaft1, 0F, 0F, 0F); + arm3 = new ModelRenderer(this, 0, 6); + arm3.addBox(0F, 0F, 0F, 2, 2, 4); + arm3.setRotationPoint(-1F, 7F, 3F); + arm3.setTextureSize(128, 64); + arm3.mirror = true; + setRotation(arm3, -0.3665191F, 0F, 0F); + plate2 = new ModelRenderer(this, 48, 0); + plate2.addBox(0F, 0F, 0F, 4, 2, 4); + plate2.setRotationPoint(-2F, 21F, -2F); + plate2.setTextureSize(128, 64); + plate2.mirror = true; + setRotation(plate2, 0F, 0F, 0F); + arm2 = new ModelRenderer(this, 48, 6); + arm2.addBox(0F, 0F, 0F, 4, 2, 4); + arm2.setRotationPoint(-2F, 7F, -2F); + arm2.setTextureSize(128, 64); + arm2.mirror = true; + setRotation(arm2, 0F, 0F, 0F); + arm1 = new ModelRenderer(this, 56, 33); + arm1.addBox(0F, 0F, 0F, 3, 2, 4); + arm1.setRotationPoint(-1.5F, 7F, 2F); + arm1.setTextureSize(128, 64); + arm1.mirror = true; + setRotation(arm1, 0F, 0F, 0F); + top = new ModelRenderer(this, 0, 0); + top.addBox(0F, 0F, 0F, 16, 2, 16); + top.setRotationPoint(-8F, -8F, -8F); + top.setTextureSize(128, 64); + top.mirror = true; + setRotation(top, 0F, 0F, 0F); + frameBack5 = new ModelRenderer(this, 4, 34); + frameBack5.addBox(-1F, 0F, 0F, 1, 19, 1); + frameBack5.setRotationPoint(7.5F, 7F, 6.49F); + frameBack5.setTextureSize(128, 64); + frameBack5.mirror = true; + setRotation(frameBack5, 0F, 0F, 0.837758F); + pole3 = new ModelRenderer(this, 0, 34); + pole3.addBox(0F, 0F, 0F, 1, 25, 1); + pole3.setRotationPoint(6.5F, -6F, -7.5F); + pole3.setTextureSize(128, 64); + pole3.mirror = true; + setRotation(pole3, 0F, 0F, 0F); + frameRight5 = new ModelRenderer(this, 4, 34); + frameRight5.addBox(0F, 0F, 0F, 1, 19, 1); + frameRight5.setRotationPoint(6.485F, 7F, -7.5F); + frameRight5.setTextureSize(128, 64); + frameRight5.mirror = true; + setRotation(frameRight5, 0.837758F, 0F, 0F); + baseRight = new ModelRenderer(this, 38, 18); + baseRight.mirror = true; + baseRight.addBox(0F, 0F, 0F, 3, 5, 10); + baseRight.setRotationPoint(5F, 19F, -5F); + baseRight.setTextureSize(128, 64); + setRotation(baseRight, 0F, 0F, 0F); + baseFront = new ModelRenderer(this, 0, 18); + baseFront.addBox(0F, 0F, 0F, 16, 5, 3); + baseFront.setRotationPoint(-8F, 19F, -8F); + baseFront.setTextureSize(128, 64); + baseFront.mirror = true; + setRotation(baseFront, 0F, 0F, 0F); + baseLeft = new ModelRenderer(this, 38, 18); + baseLeft.addBox(0F, 0F, 0F, 3, 5, 10); + baseLeft.setRotationPoint(-8F, 19F, -5F); + baseLeft.setTextureSize(128, 64); + baseLeft.mirror = true; + setRotation(baseLeft, 0F, 0F, 0F); + frameRight3 = new ModelRenderer(this, 64, 27); + frameRight3.addBox(0F, 0F, 0F, 1, 1, 13); + frameRight3.setRotationPoint(6.5F, 6F, -6.5F); + frameRight3.setTextureSize(128, 64); + frameRight3.mirror = true; + setRotation(frameRight3, 0F, 0F, 0F); + pole1 = new ModelRenderer(this, 0, 34); + pole1.addBox(0F, 0F, 0F, 1, 25, 1); + pole1.setRotationPoint(-7.5F, -6F, -7.5F); + pole1.setTextureSize(128, 64); + pole1.mirror = true; + setRotation(pole1, 0F, 0F, 0F); + frameRight4 = new ModelRenderer(this, 4, 34); + frameRight4.addBox(0F, 0F, -1F, 1, 19, 1); + frameRight4.setRotationPoint(6.49F, 7F, 7.5F); + frameRight4.setTextureSize(128, 64); + frameRight4.mirror = true; + setRotation(frameRight4, -0.837758F, 0F, 0F); + frameRight1 = new ModelRenderer(this, 4, 34); + frameRight1.addBox(0F, 0F, 0F, 1, 19, 1); + frameRight1.setRotationPoint(6.485F, -6F, -7.5F); + frameRight1.setTextureSize(128, 64); + frameRight1.mirror = true; + setRotation(frameRight1, 0.837758F, 0F, 0F); + frameRight2 = new ModelRenderer(this, 4, 34); + frameRight2.addBox(0F, 0F, -1F, 1, 19, 1); + frameRight2.setRotationPoint(6.49F, -6F, 7.5F); + frameRight2.setTextureSize(128, 64); + frameRight2.mirror = true; + setRotation(frameRight2, -0.837758F, 0F, 0F); + frameLeft5 = new ModelRenderer(this, 4, 34); + frameLeft5.addBox(0F, 0F, 0F, 1, 19, 1); + frameLeft5.setRotationPoint(-7.485F, 7F, -7.5F); + frameLeft5.setTextureSize(128, 64); + frameLeft5.mirror = true; + setRotation(frameLeft5, 0.837758F, 0F, 0F); + frameLeft4 = new ModelRenderer(this, 4, 34); + frameLeft4.addBox(0F, 0F, -1F, 1, 19, 1); + frameLeft4.setRotationPoint(-7.49F, 7F, 7.5F); + frameLeft4.setTextureSize(128, 64); + frameLeft4.mirror = true; + setRotation(frameLeft4, -0.837758F, 0F, 0F); + frameBack3 = new ModelRenderer(this, 36, 52); + frameBack3.addBox(0F, 0F, 0F, 13, 1, 1); + frameBack3.setRotationPoint(-6.5F, 6F, 6.5F); + frameBack3.setTextureSize(128, 64); + frameBack3.mirror = true; + setRotation(frameBack3, 0F, 0F, 0F); + frameLeft2 = new ModelRenderer(this, 4, 34); + frameLeft2.addBox(0F, 0F, 0F, 1, 19, 1); + frameLeft2.setRotationPoint(-7.485F, -6F, -7.5F); + frameLeft2.setTextureSize(128, 64); + frameLeft2.mirror = true; + setRotation(frameLeft2, 0.837758F, 0F, 0F); + frameLeft1 = new ModelRenderer(this, 4, 34); + frameLeft1.addBox(0F, 0F, -1F, 1, 19, 1); + frameLeft1.setRotationPoint(-7.49F, -6F, 7.5F); + frameLeft1.setTextureSize(128, 64); + frameLeft1.mirror = true; + setRotation(frameLeft1, -0.837758F, 0F, 0F); + pole2 = new ModelRenderer(this, 0, 34); + pole2.addBox(0F, 0F, 0F, 1, 25, 1); + pole2.setRotationPoint(-7.5F, -6F, 6.5F); + pole2.setTextureSize(128, 64); + pole2.mirror = true; + setRotation(pole2, 0F, 0F, 0F); + frameBack1 = new ModelRenderer(this, 4, 34); + frameBack1.addBox(-1F, 0F, 0F, 1, 19, 1); + frameBack1.setRotationPoint(7.5F, -6F, 6.49F); + frameBack1.setTextureSize(128, 64); + frameBack1.mirror = true; + setRotation(frameBack1, 0F, 0F, 0.837758F); + frameBack2 = new ModelRenderer(this, 4, 34); + frameBack2.addBox(0F, 0F, 0F, 1, 19, 1); + frameBack2.setRotationPoint(-7.5F, -6F, 6.49F); + frameBack2.setTextureSize(128, 64); + frameBack2.mirror = true; + setRotation(frameBack2, 0F, 0F, -0.837758F); + frameBack4 = new ModelRenderer(this, 4, 34); + frameBack4.addBox(0F, 0F, 0F, 1, 19, 1); + frameBack4.setRotationPoint(-7.5F, 7F, 6.49F); + frameBack4.setTextureSize(128, 64); + frameBack4.mirror = true; + setRotation(frameBack4, 0F, 0F, -0.837758F); + frameLeft3 = new ModelRenderer(this, 64, 27); + frameLeft3.addBox(0F, 0F, 0F, 1, 1, 13); + frameLeft3.setRotationPoint(-7.5F, 6F, -6.5F); + frameLeft3.setTextureSize(128, 64); + frameLeft3.mirror = true; + setRotation(frameLeft3, 0F, 0F, 0F); + conduit = new ModelRenderer(this, 64, 0); + conduit.addBox(0F, 0F, 0F, 4, 25, 2); + conduit.setRotationPoint(-2F, -6F, 6F); + conduit.setTextureSize(128, 64); + conduit.mirror = true; + setRotation(conduit, 0F, 0F, 0F); + plate1 = new ModelRenderer(this, 76, 0); + plate1.addBox(0F, 0F, 0F, 10, 1, 12); + plate1.setRotationPoint(-5F, -6F, -5F); + plate1.setTextureSize(128, 64); + plate1.mirror = true; + setRotation(plate1, 0F, 0F, 0F); + rivet10 = new ModelRenderer(this, 0, 0); + rivet10.addBox(0F, 0F, 0F, 1, 1, 1); + rivet10.setRotationPoint(3.5F, -5.5F, 3.5F); + rivet10.setTextureSize(128, 64); + rivet10.mirror = true; + setRotation(rivet10, 0F, 0F, 0F); + rivet5 = new ModelRenderer(this, 0, 0); + rivet5.addBox(0F, 0F, 0F, 1, 1, 1); + rivet5.setRotationPoint(-4.5F, -5.5F, 3.5F); + rivet5.setTextureSize(128, 64); + rivet5.mirror = true; + setRotation(rivet5, 0F, 0F, 0F); + rivet1 = new ModelRenderer(this, 0, 0); + rivet1.addBox(0F, 0F, 0F, 1, 1, 1); + rivet1.setRotationPoint(-4.5F, -5.5F, -4.5F); + rivet1.setTextureSize(128, 64); + rivet1.mirror = true; + setRotation(rivet1, 0F, 0F, 0F); + rivet6 = new ModelRenderer(this, 0, 0); + rivet6.addBox(0F, 0F, 0F, 1, 1, 1); + rivet6.setRotationPoint(3.5F, -5.5F, -4.5F); + rivet6.setTextureSize(128, 64); + rivet6.mirror = true; + setRotation(rivet6, 0F, 0F, 0F); + rivet2 = new ModelRenderer(this, 0, 0); + rivet2.addBox(0F, 0F, 0F, 1, 1, 1); + rivet2.setRotationPoint(-4.5F, -5.5F, -2.5F); + rivet2.setTextureSize(128, 64); + rivet2.mirror = true; + setRotation(rivet2, 0F, 0F, 0F); + rivet7 = new ModelRenderer(this, 0, 0); + rivet7.addBox(0F, 0F, 0F, 1, 1, 1); + rivet7.setRotationPoint(3.5F, -5.5F, -2.5F); + rivet7.setTextureSize(128, 64); + rivet7.mirror = true; + setRotation(rivet7, 0F, 0F, 0F); + rivet3 = new ModelRenderer(this, 0, 0); + rivet3.addBox(0F, 0F, 0F, 1, 1, 1); + rivet3.setRotationPoint(-4.5F, -5.5F, -0.5F); + rivet3.setTextureSize(128, 64); + rivet3.mirror = true; + setRotation(rivet3, 0F, 0F, 0F); + rivet8 = new ModelRenderer(this, 0, 0); + rivet8.addBox(0F, 0F, 0F, 1, 1, 1); + rivet8.setRotationPoint(3.5F, -5.5F, -0.5F); + rivet8.setTextureSize(128, 64); + rivet8.mirror = true; + setRotation(rivet8, 0F, 0F, 0F); + rivet4 = new ModelRenderer(this, 0, 0); + rivet4.addBox(0F, 0F, 0F, 1, 1, 1); + rivet4.setRotationPoint(-4.5F, -5.5F, 1.5F); + rivet4.setTextureSize(128, 64); + rivet4.mirror = true; + setRotation(rivet4, 0F, 0F, 0F); + rivet9 = new ModelRenderer(this, 0, 0); + rivet9.addBox(0F, 0F, 0F, 1, 1, 1); + rivet9.setRotationPoint(3.5F, -5.5F, 1.5F); + rivet9.setTextureSize(128, 64); + rivet9.mirror = true; + setRotation(rivet9, 0F, 0F, 0F); + } - public void render(float size) - { - plate3.render(size); - baseBack.render(size); - motor.render(size); - port.render(size); - pole4.render(size); - shaft2.render(size); - shaft1.render(size); - arm3.render(size); - plate2.render(size); - arm2.render(size); - arm1.render(size); - top.render(size); - frameBack5.render(size); - pole3.render(size); - frameRight5.render(size); - baseRight.render(size); - baseFront.render(size); - baseLeft.render(size); - frameRight3.render(size); - pole1.render(size); - frameRight4.render(size); - frameRight1.render(size); - frameRight2.render(size); - frameLeft5.render(size); - frameLeft4.render(size); - frameBack3.render(size); - frameLeft2.render(size); - frameLeft1.render(size); - pole2.render(size); - frameBack1.render(size); - frameBack2.render(size); - frameBack4.render(size); - frameLeft3.render(size); - conduit.render(size); - plate1.render(size); - rivet10.render(size); - rivet5.render(size); - rivet1.render(size); - rivet6.render(size); - rivet2.render(size); - rivet7.render(size); - rivet3.render(size); - rivet8.render(size); - rivet4.render(size); - rivet9.render(size); - } + public void render(float size) { + plate3.render(size); + baseBack.render(size); + motor.render(size); + port.render(size); + pole4.render(size); + shaft2.render(size); + shaft1.render(size); + arm3.render(size); + plate2.render(size); + arm2.render(size); + arm1.render(size); + top.render(size); + frameBack5.render(size); + pole3.render(size); + frameRight5.render(size); + baseRight.render(size); + baseFront.render(size); + baseLeft.render(size); + frameRight3.render(size); + pole1.render(size); + frameRight4.render(size); + frameRight1.render(size); + frameRight2.render(size); + frameLeft5.render(size); + frameLeft4.render(size); + frameBack3.render(size); + frameLeft2.render(size); + frameLeft1.render(size); + pole2.render(size); + frameBack1.render(size); + frameBack2.render(size); + frameBack4.render(size); + frameLeft3.render(size); + conduit.render(size); + plate1.render(size); + rivet10.render(size); + rivet5.render(size); + rivet1.render(size); + rivet6.render(size); + rivet2.render(size); + rivet7.render(size); + rivet3.render(size); + rivet8.render(size); + rivet4.render(size); + rivet9.render(size); + } - public void renderWithPiston(float piston, float size) - { - shaft1.rotationPointY = 6 - (piston*12); - plate2.rotationPointY = 21 - (piston*12); - plate3.rotationPointY = 22 - (piston*12); - - render(size); - } + public void renderWithPiston(float piston, float size) { + shaft1.rotationPointY = 6 - (piston * 12); + plate2.rotationPointY = 21 - (piston * 12); + plate3.rotationPointY = 22 - (piston * 12); - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + render(size); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/mekanism/client/model/ModelSolarNeutronActivator.java b/src/main/java/mekanism/client/model/ModelSolarNeutronActivator.java index 7159c810d..46433c5c2 100644 --- a/src/main/java/mekanism/client/model/ModelSolarNeutronActivator.java +++ b/src/main/java/mekanism/client/model/ModelSolarNeutronActivator.java @@ -1,405 +1,401 @@ package mekanism.client.model; -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; @SideOnly(Side.CLIENT) -public class ModelSolarNeutronActivator extends ModelBase -{ - ModelRenderer pole; - ModelRenderer panel3; - ModelRenderer port; - ModelRenderer panel1; - ModelRenderer panel2; - ModelRenderer panelBase; - ModelRenderer panelBraceLeft2; - ModelRenderer panelBraceRight2; - ModelRenderer panelBraceLeft1; - ModelRenderer panelBraceRight1; - ModelRenderer panelBrace; - ModelRenderer bridge; - ModelRenderer platform; - ModelRenderer hole2; - ModelRenderer hole4; - ModelRenderer hole1; - ModelRenderer hole3; - ModelRenderer brace2; - ModelRenderer tube2c; - ModelRenderer tube1b; - ModelRenderer tube1c; - ModelRenderer tube2b; - ModelRenderer tube2a; - ModelRenderer tube1a; - ModelRenderer conduit; - ModelRenderer brace1; - ModelRenderer tank; - ModelRenderer laser; - ModelRenderer base; - ModelRenderer support1; - ModelRenderer support2; - ModelRenderer support3; - ModelRenderer support4; - ModelRenderer support5; - ModelRenderer support6; - ModelRenderer support7; - ModelRenderer support8; - ModelRenderer support9; - ModelRenderer support10; - ModelRenderer support11; - ModelRenderer support12; - ModelRenderer support13; - ModelRenderer support14; - ModelRenderer support15; - ModelRenderer support16; - ModelRenderer portConnector; - ModelRenderer laserBeamToggle; +public class ModelSolarNeutronActivator extends ModelBase { + ModelRenderer pole; + ModelRenderer panel3; + ModelRenderer port; + ModelRenderer panel1; + ModelRenderer panel2; + ModelRenderer panelBase; + ModelRenderer panelBraceLeft2; + ModelRenderer panelBraceRight2; + ModelRenderer panelBraceLeft1; + ModelRenderer panelBraceRight1; + ModelRenderer panelBrace; + ModelRenderer bridge; + ModelRenderer platform; + ModelRenderer hole2; + ModelRenderer hole4; + ModelRenderer hole1; + ModelRenderer hole3; + ModelRenderer brace2; + ModelRenderer tube2c; + ModelRenderer tube1b; + ModelRenderer tube1c; + ModelRenderer tube2b; + ModelRenderer tube2a; + ModelRenderer tube1a; + ModelRenderer conduit; + ModelRenderer brace1; + ModelRenderer tank; + ModelRenderer laser; + ModelRenderer base; + ModelRenderer support1; + ModelRenderer support2; + ModelRenderer support3; + ModelRenderer support4; + ModelRenderer support5; + ModelRenderer support6; + ModelRenderer support7; + ModelRenderer support8; + ModelRenderer support9; + ModelRenderer support10; + ModelRenderer support11; + ModelRenderer support12; + ModelRenderer support13; + ModelRenderer support14; + ModelRenderer support15; + ModelRenderer support16; + ModelRenderer portConnector; + ModelRenderer laserBeamToggle; - public ModelSolarNeutronActivator() - { - textureWidth = 128; - textureHeight = 64; + public ModelSolarNeutronActivator() { + textureWidth = 128; + textureHeight = 64; - pole = new ModelRenderer(this, 116, 0); - pole.addBox(0F, 0F, 0F, 4, 15, 2); - pole.setRotationPoint(-2F, -5F, 6F); - pole.setTextureSize(128, 64); - pole.mirror = true; - setRotation(pole, 0F, 0F, 0F); - panel3 = new ModelRenderer(this, 84, 32); - panel3.addBox(-6F, 0F, -16F, 6, 1, 16); - panel3.setRotationPoint(-2.75F, -4.95F, 8F); - panel3.setTextureSize(128, 64); - panel3.mirror = true; - setRotation(panel3, -0.1082104F, 0.0279253F, 0.2617994F); - port = new ModelRenderer(this, 0, 45); - port.addBox(0F, 0F, 0F, 8, 8, 1); - port.setRotationPoint(-4F, 12F, -8.01F); - port.setTextureSize(128, 64); - port.mirror = true; - setRotation(port, 0F, 0F, 0F); - panel1 = new ModelRenderer(this, 84, 32); - panel1.mirror = true; - panel1.addBox(0F, 0F, -16F, 6, 1, 16); - panel1.setRotationPoint(2.75F, -4.95F, 8F); - panel1.setTextureSize(128, 64); - setRotation(panel1, -0.1082104F, -0.0279253F, -0.2617994F); - panel2 = new ModelRenderer(this, 84, 15); - panel2.addBox(0F, 0F, -16F, 6, 1, 16); - panel2.setRotationPoint(-3F, -5F, 8F); - panel2.setTextureSize(128, 64); - panel2.mirror = true; - setRotation(panel2, -0.1047198F, 0F, 0F); - panelBase = new ModelRenderer(this, 28, 45); - panelBase.addBox(0F, 1F, -16F, 6, 1, 14); - panelBase.setRotationPoint(-3F, -5F, 9F); - panelBase.setTextureSize(128, 64); - panelBase.mirror = true; - setRotation(panelBase, -0.1047198F, 0F, 0F); - panelBraceLeft2 = new ModelRenderer(this, 64, 15); - panelBraceLeft2.addBox(-4F, 0.5F, -5F, 5, 1, 2); - panelBraceLeft2.setRotationPoint(-3F, -5F, 9F); - panelBraceLeft2.setTextureSize(128, 64); - panelBraceLeft2.mirror = true; - setRotation(panelBraceLeft2, -0.1047198F, 0F, 0.2505517F); - panelBraceRight2 = new ModelRenderer(this, 64, 15); - panelBraceRight2.addBox(-1F, 0.5F, -5F, 5, 1, 2); - panelBraceRight2.setRotationPoint(3F, -5F, 9F); - panelBraceRight2.setTextureSize(128, 64); - panelBraceRight2.mirror = true; - setRotation(panelBraceRight2, -0.1047198F, 0F, -0.2555938F); - panelBraceLeft1 = new ModelRenderer(this, 64, 15); - panelBraceLeft1.addBox(-4F, 0.5F, -15F, 5, 1, 2); - panelBraceLeft1.setRotationPoint(-3F, -5F, 9F); - panelBraceLeft1.setTextureSize(128, 64); - panelBraceLeft1.mirror = true; - setRotation(panelBraceLeft1, -0.1047198F, 0F, 0.2505517F); - panelBraceRight1 = new ModelRenderer(this, 64, 15); - panelBraceRight1.addBox(-1F, 0.5F, -15F, 5, 1, 2); - panelBraceRight1.setRotationPoint(3F, -5F, 9F); - panelBraceRight1.setTextureSize(128, 64); - panelBraceRight1.mirror = true; - setRotation(panelBraceRight1, -0.1047198F, 0F, -0.2555938F); - panelBrace = new ModelRenderer(this, 56, 18); - panelBrace.addBox(0F, 1.2F, -10F, 2, 2, 9); - panelBrace.setRotationPoint(-1F, -5F, 8F); - panelBrace.setTextureSize(128, 64); - panelBrace.mirror = true; - setRotation(panelBrace, -0.1047198F, 0F, 0F); - bridge = new ModelRenderer(this, 65, 1); - bridge.addBox(0F, 0F, 0F, 12, 1, 13); - bridge.setRotationPoint(-6F, 19F, -6F); - bridge.setTextureSize(128, 64); - bridge.mirror = true; - setRotation(bridge, 0F, 0F, 0F); - platform = new ModelRenderer(this, 18, 45); - platform.addBox(-2.5F, 1F, -2.5F, 6, 3, 6); - platform.setRotationPoint(-0.5F, 8F, -2.5F); - platform.setTextureSize(128, 64); - platform.mirror = true; - setRotation(platform, -0.1047198F, 0F, 0F); - hole2 = new ModelRenderer(this, 0, 6); - hole2.addBox(1F, 0F, 0F, 1, 2, 1); - hole2.setRotationPoint(-0.5F, 8F, -2.5F); - hole2.setTextureSize(128, 64); - hole2.mirror = true; - setRotation(hole2, -0.1047198F, 0F, 0F); - hole4 = new ModelRenderer(this, 0, 3); - hole4.addBox(-1F, 0F, 1F, 3, 2, 1); - hole4.setRotationPoint(-0.5F, 8F, -2.5F); - hole4.setTextureSize(128, 64); - hole4.mirror = true; - setRotation(hole4, -0.1047198F, 0F, 0F); - hole1 = new ModelRenderer(this, 0, 3); - hole1.addBox(-1F, 0F, -1F, 3, 2, 1); - hole1.setRotationPoint(-0.5F, 8F, -2.5F); - hole1.setTextureSize(128, 64); - hole1.mirror = true; - setRotation(hole1, -0.1047198F, 0F, 0F); - hole3 = new ModelRenderer(this, 0, 6); - hole3.addBox(-1F, 0F, 0F, 1, 2, 1); - hole3.setRotationPoint(-0.5F, 8F, -2.5F); - hole3.setTextureSize(128, 64); - hole3.mirror = true; - setRotation(hole3, -0.1047198F, 0F, 0F); - brace2 = new ModelRenderer(this, 0, 11); - brace2.addBox(0F, 0F, 0F, 1, 1, 2); - brace2.setRotationPoint(1F, 9.5F, -7.1F); - brace2.setTextureSize(128, 64); - brace2.mirror = true; - setRotation(brace2, 0.1745329F, 0F, 0F); - tube2c = new ModelRenderer(this, 0, 9); - tube2c.addBox(0F, 0F, 0F, 1, 1, 1); - tube2c.setRotationPoint(2F, 9F, 4F); - tube2c.setTextureSize(128, 64); - tube2c.mirror = true; - setRotation(tube2c, 0F, 0F, 0F); - tube1b = new ModelRenderer(this, 0, 14); - tube1b.addBox(0F, 0F, 0F, 6, 1, 1); - tube1b.setRotationPoint(-3F, 8F, 2F); - tube1b.setTextureSize(128, 64); - tube1b.mirror = true; - setRotation(tube1b, 0F, 0F, 0F); - tube1c = new ModelRenderer(this, 0, 9); - tube1c.addBox(0F, 0F, 0F, 1, 1, 1); - tube1c.setRotationPoint(2F, 9F, 2F); - tube1c.setTextureSize(128, 64); - tube1c.mirror = true; - setRotation(tube1c, 0F, 0F, 0F); - tube2b = new ModelRenderer(this, 0, 14); - tube2b.addBox(0F, 0F, 0F, 6, 1, 1); - tube2b.setRotationPoint(-3F, 8F, 4F); - tube2b.setTextureSize(128, 64); - tube2b.mirror = true; - setRotation(tube2b, 0F, 0F, 0F); - tube2a = new ModelRenderer(this, 0, 9); - tube2a.addBox(0F, 0F, 0F, 1, 1, 1); - tube2a.setRotationPoint(-3F, 9F, 4F); - tube2a.setTextureSize(128, 64); - tube2a.mirror = true; - setRotation(tube2a, 0F, 0F, 0F); - tube1a = new ModelRenderer(this, 0, 9); - tube1a.addBox(0F, 0F, 0F, 1, 1, 1); - tube1a.setRotationPoint(-3F, 9F, 2F); - tube1a.setTextureSize(128, 64); - tube1a.mirror = true; - setRotation(tube1a, 0F, 0F, 0F); - conduit = new ModelRenderer(this, 48, 0); - conduit.addBox(0F, 0F, 0F, 2, 1, 7); - conduit.setRotationPoint(-1F, 9.5F, -1F); - conduit.setTextureSize(128, 64); - conduit.mirror = true; - setRotation(conduit, 0F, 0F, 0F); - brace1 = new ModelRenderer(this, 0, 11); - brace1.addBox(0F, 0F, 0F, 1, 1, 2); - brace1.setRotationPoint(-2F, 9.5F, -7.1F); - brace1.setTextureSize(128, 64); - brace1.mirror = true; - setRotation(brace1, 0.1745329F, 0F, 0F); - tank = new ModelRenderer(this, 0, 0); - tank.addBox(0F, 0F, 0F, 16, 9, 16); - tank.setRotationPoint(-8F, 10F, -8F); - tank.setTextureSize(128, 64); - tank.mirror = true; - setRotation(tank, 0F, 0F, 0F); - laser = new ModelRenderer(this, 4, 0); - laser.addBox(0.5F, 2.1F, -9F, 1, 2, 1); - laser.setRotationPoint(-1F, -5F, 8F); - laser.setTextureSize(128, 64); - laser.mirror = true; - setRotation(laser, -0.1117011F, 0F, 0F); - base = new ModelRenderer(this, 0, 25); - base.addBox(0F, 0F, 0F, 16, 4, 16); - base.setRotationPoint(-8F, 20F, -8F); - base.setTextureSize(128, 64); - base.mirror = true; - setRotation(base, 0F, 0F, 0F); - support1 = new ModelRenderer(this, 0, 0); - support1.addBox(0F, 0F, 0F, 1, 1, 1); - support1.setRotationPoint(6.5F, 19F, -7.5F); - support1.setTextureSize(128, 64); - support1.mirror = true; - setRotation(support1, 0F, 0F, 0F); - support2 = new ModelRenderer(this, 0, 0); - support2.addBox(0F, 0F, 0F, 1, 1, 1); - support2.setRotationPoint(6.5F, 19F, 6.5F); - support2.setTextureSize(128, 64); - support2.mirror = true; - setRotation(support2, 0F, 0F, 0F); - support3 = new ModelRenderer(this, 0, 0); - support3.addBox(0F, 0F, 0F, 1, 1, 1); - support3.setRotationPoint(6.5F, 19F, -5.5F); - support3.setTextureSize(128, 64); - support3.mirror = true; - setRotation(support3, 0F, 0F, 0F); - support4 = new ModelRenderer(this, 0, 0); - support4.addBox(0F, 0F, 0F, 1, 1, 1); - support4.setRotationPoint(6.5F, 19F, -3.5F); - support4.setTextureSize(128, 64); - support4.mirror = true; - setRotation(support4, 0F, 0F, 0F); - support5 = new ModelRenderer(this, 0, 0); - support5.addBox(0F, 0F, 0F, 1, 1, 1); - support5.setRotationPoint(6.5F, 19F, -1.5F); - support5.setTextureSize(128, 64); - support5.mirror = true; - setRotation(support5, 0F, 0F, 0F); - support6 = new ModelRenderer(this, 0, 0); - support6.addBox(0F, 0F, 0F, 1, 1, 1); - support6.setRotationPoint(6.5F, 19F, 0.5F); - support6.setTextureSize(128, 64); - support6.mirror = true; - setRotation(support6, 0F, 0F, 0F); - support7 = new ModelRenderer(this, 0, 0); - support7.addBox(0F, 0F, 0F, 1, 1, 1); - support7.setRotationPoint(6.5F, 19F, 2.5F); - support7.setTextureSize(128, 64); - support7.mirror = true; - setRotation(support7, 0F, 0F, 0F); - support8 = new ModelRenderer(this, 0, 0); - support8.addBox(0F, 0F, 0F, 1, 1, 1); - support8.setRotationPoint(6.5F, 19F, 4.5F); - support8.setTextureSize(128, 64); - support8.mirror = true; - setRotation(support8, 0F, 0F, 0F); - support9 = new ModelRenderer(this, 0, 0); - support9.addBox(0F, 0F, 0F, 1, 1, 1); - support9.setRotationPoint(-7.5F, 19F, 6.5F); - support9.setTextureSize(128, 64); - support9.mirror = true; - setRotation(support9, 0F, 0F, 0F); - support10 = new ModelRenderer(this, 0, 0); - support10.addBox(0F, 0F, 0F, 1, 1, 1); - support10.setRotationPoint(-7.5F, 19F, 4.5F); - support10.setTextureSize(128, 64); - support10.mirror = true; - setRotation(support10, 0F, 0F, 0F); - support11 = new ModelRenderer(this, 0, 0); - support11.addBox(0F, 0F, 0F, 1, 1, 1); - support11.setRotationPoint(-7.5F, 19F, 2.5F); - support11.setTextureSize(128, 64); - support11.mirror = true; - setRotation(support11, 0F, 0F, 0F); - support12 = new ModelRenderer(this, 0, 0); - support12.addBox(0F, 0F, 0F, 1, 1, 1); - support12.setRotationPoint(-7.5F, 19F, 0.5F); - support12.setTextureSize(128, 64); - support12.mirror = true; - setRotation(support12, 0F, 0F, 0F); - support13 = new ModelRenderer(this, 0, 0); - support13.addBox(0F, 0F, 0F, 1, 1, 1); - support13.setRotationPoint(-7.5F, 19F, -1.5F); - support13.setTextureSize(128, 64); - support13.mirror = true; - setRotation(support13, 0F, 0F, 0F); - support14 = new ModelRenderer(this, 0, 0); - support14.addBox(0F, 0F, 0F, 1, 1, 1); - support14.setRotationPoint(-7.5F, 19F, -3.5F); - support14.setTextureSize(128, 64); - support14.mirror = true; - setRotation(support14, 0F, 0F, 0F); - support15 = new ModelRenderer(this, 0, 0); - support15.addBox(0F, 0F, 0F, 1, 1, 1); - support15.setRotationPoint(-7.5F, 19F, -5.5F); - support15.setTextureSize(128, 64); - support15.mirror = true; - setRotation(support15, 0F, 0F, 0F); - support16 = new ModelRenderer(this, 0, 0); - support16.addBox(0F, 0F, 0F, 1, 1, 1); - support16.setRotationPoint(-7.5F, 19F, -7.5F); - support16.setTextureSize(128, 64); - support16.mirror = true; - setRotation(support16, 0F, 0F, 0F); - portConnector = new ModelRenderer(this, 0, 14); - portConnector.addBox(0F, 0F, 0F, 6, 1, 1); - portConnector.setRotationPoint(-3F, 19F, -7.01F); - portConnector.setTextureSize(128, 64); - portConnector.mirror = true; - setRotation(portConnector, 0F, 0F, 0F); - laserBeamToggle = new ModelRenderer(this, 12, 0); - laserBeamToggle.addBox(0.5F, 4.1F, -9F, 1, 11, 1); - laserBeamToggle.setRotationPoint(-1F, -5F, 8F); - laserBeamToggle.setTextureSize(128, 64); - laserBeamToggle.mirror = true; - setRotation(laserBeamToggle, -0.1117011F, 0F, 0F); - } + pole = new ModelRenderer(this, 116, 0); + pole.addBox(0F, 0F, 0F, 4, 15, 2); + pole.setRotationPoint(-2F, -5F, 6F); + pole.setTextureSize(128, 64); + pole.mirror = true; + setRotation(pole, 0F, 0F, 0F); + panel3 = new ModelRenderer(this, 84, 32); + panel3.addBox(-6F, 0F, -16F, 6, 1, 16); + panel3.setRotationPoint(-2.75F, -4.95F, 8F); + panel3.setTextureSize(128, 64); + panel3.mirror = true; + setRotation(panel3, -0.1082104F, 0.0279253F, 0.2617994F); + port = new ModelRenderer(this, 0, 45); + port.addBox(0F, 0F, 0F, 8, 8, 1); + port.setRotationPoint(-4F, 12F, -8.01F); + port.setTextureSize(128, 64); + port.mirror = true; + setRotation(port, 0F, 0F, 0F); + panel1 = new ModelRenderer(this, 84, 32); + panel1.mirror = true; + panel1.addBox(0F, 0F, -16F, 6, 1, 16); + panel1.setRotationPoint(2.75F, -4.95F, 8F); + panel1.setTextureSize(128, 64); + setRotation(panel1, -0.1082104F, -0.0279253F, -0.2617994F); + panel2 = new ModelRenderer(this, 84, 15); + panel2.addBox(0F, 0F, -16F, 6, 1, 16); + panel2.setRotationPoint(-3F, -5F, 8F); + panel2.setTextureSize(128, 64); + panel2.mirror = true; + setRotation(panel2, -0.1047198F, 0F, 0F); + panelBase = new ModelRenderer(this, 28, 45); + panelBase.addBox(0F, 1F, -16F, 6, 1, 14); + panelBase.setRotationPoint(-3F, -5F, 9F); + panelBase.setTextureSize(128, 64); + panelBase.mirror = true; + setRotation(panelBase, -0.1047198F, 0F, 0F); + panelBraceLeft2 = new ModelRenderer(this, 64, 15); + panelBraceLeft2.addBox(-4F, 0.5F, -5F, 5, 1, 2); + panelBraceLeft2.setRotationPoint(-3F, -5F, 9F); + panelBraceLeft2.setTextureSize(128, 64); + panelBraceLeft2.mirror = true; + setRotation(panelBraceLeft2, -0.1047198F, 0F, 0.2505517F); + panelBraceRight2 = new ModelRenderer(this, 64, 15); + panelBraceRight2.addBox(-1F, 0.5F, -5F, 5, 1, 2); + panelBraceRight2.setRotationPoint(3F, -5F, 9F); + panelBraceRight2.setTextureSize(128, 64); + panelBraceRight2.mirror = true; + setRotation(panelBraceRight2, -0.1047198F, 0F, -0.2555938F); + panelBraceLeft1 = new ModelRenderer(this, 64, 15); + panelBraceLeft1.addBox(-4F, 0.5F, -15F, 5, 1, 2); + panelBraceLeft1.setRotationPoint(-3F, -5F, 9F); + panelBraceLeft1.setTextureSize(128, 64); + panelBraceLeft1.mirror = true; + setRotation(panelBraceLeft1, -0.1047198F, 0F, 0.2505517F); + panelBraceRight1 = new ModelRenderer(this, 64, 15); + panelBraceRight1.addBox(-1F, 0.5F, -15F, 5, 1, 2); + panelBraceRight1.setRotationPoint(3F, -5F, 9F); + panelBraceRight1.setTextureSize(128, 64); + panelBraceRight1.mirror = true; + setRotation(panelBraceRight1, -0.1047198F, 0F, -0.2555938F); + panelBrace = new ModelRenderer(this, 56, 18); + panelBrace.addBox(0F, 1.2F, -10F, 2, 2, 9); + panelBrace.setRotationPoint(-1F, -5F, 8F); + panelBrace.setTextureSize(128, 64); + panelBrace.mirror = true; + setRotation(panelBrace, -0.1047198F, 0F, 0F); + bridge = new ModelRenderer(this, 65, 1); + bridge.addBox(0F, 0F, 0F, 12, 1, 13); + bridge.setRotationPoint(-6F, 19F, -6F); + bridge.setTextureSize(128, 64); + bridge.mirror = true; + setRotation(bridge, 0F, 0F, 0F); + platform = new ModelRenderer(this, 18, 45); + platform.addBox(-2.5F, 1F, -2.5F, 6, 3, 6); + platform.setRotationPoint(-0.5F, 8F, -2.5F); + platform.setTextureSize(128, 64); + platform.mirror = true; + setRotation(platform, -0.1047198F, 0F, 0F); + hole2 = new ModelRenderer(this, 0, 6); + hole2.addBox(1F, 0F, 0F, 1, 2, 1); + hole2.setRotationPoint(-0.5F, 8F, -2.5F); + hole2.setTextureSize(128, 64); + hole2.mirror = true; + setRotation(hole2, -0.1047198F, 0F, 0F); + hole4 = new ModelRenderer(this, 0, 3); + hole4.addBox(-1F, 0F, 1F, 3, 2, 1); + hole4.setRotationPoint(-0.5F, 8F, -2.5F); + hole4.setTextureSize(128, 64); + hole4.mirror = true; + setRotation(hole4, -0.1047198F, 0F, 0F); + hole1 = new ModelRenderer(this, 0, 3); + hole1.addBox(-1F, 0F, -1F, 3, 2, 1); + hole1.setRotationPoint(-0.5F, 8F, -2.5F); + hole1.setTextureSize(128, 64); + hole1.mirror = true; + setRotation(hole1, -0.1047198F, 0F, 0F); + hole3 = new ModelRenderer(this, 0, 6); + hole3.addBox(-1F, 0F, 0F, 1, 2, 1); + hole3.setRotationPoint(-0.5F, 8F, -2.5F); + hole3.setTextureSize(128, 64); + hole3.mirror = true; + setRotation(hole3, -0.1047198F, 0F, 0F); + brace2 = new ModelRenderer(this, 0, 11); + brace2.addBox(0F, 0F, 0F, 1, 1, 2); + brace2.setRotationPoint(1F, 9.5F, -7.1F); + brace2.setTextureSize(128, 64); + brace2.mirror = true; + setRotation(brace2, 0.1745329F, 0F, 0F); + tube2c = new ModelRenderer(this, 0, 9); + tube2c.addBox(0F, 0F, 0F, 1, 1, 1); + tube2c.setRotationPoint(2F, 9F, 4F); + tube2c.setTextureSize(128, 64); + tube2c.mirror = true; + setRotation(tube2c, 0F, 0F, 0F); + tube1b = new ModelRenderer(this, 0, 14); + tube1b.addBox(0F, 0F, 0F, 6, 1, 1); + tube1b.setRotationPoint(-3F, 8F, 2F); + tube1b.setTextureSize(128, 64); + tube1b.mirror = true; + setRotation(tube1b, 0F, 0F, 0F); + tube1c = new ModelRenderer(this, 0, 9); + tube1c.addBox(0F, 0F, 0F, 1, 1, 1); + tube1c.setRotationPoint(2F, 9F, 2F); + tube1c.setTextureSize(128, 64); + tube1c.mirror = true; + setRotation(tube1c, 0F, 0F, 0F); + tube2b = new ModelRenderer(this, 0, 14); + tube2b.addBox(0F, 0F, 0F, 6, 1, 1); + tube2b.setRotationPoint(-3F, 8F, 4F); + tube2b.setTextureSize(128, 64); + tube2b.mirror = true; + setRotation(tube2b, 0F, 0F, 0F); + tube2a = new ModelRenderer(this, 0, 9); + tube2a.addBox(0F, 0F, 0F, 1, 1, 1); + tube2a.setRotationPoint(-3F, 9F, 4F); + tube2a.setTextureSize(128, 64); + tube2a.mirror = true; + setRotation(tube2a, 0F, 0F, 0F); + tube1a = new ModelRenderer(this, 0, 9); + tube1a.addBox(0F, 0F, 0F, 1, 1, 1); + tube1a.setRotationPoint(-3F, 9F, 2F); + tube1a.setTextureSize(128, 64); + tube1a.mirror = true; + setRotation(tube1a, 0F, 0F, 0F); + conduit = new ModelRenderer(this, 48, 0); + conduit.addBox(0F, 0F, 0F, 2, 1, 7); + conduit.setRotationPoint(-1F, 9.5F, -1F); + conduit.setTextureSize(128, 64); + conduit.mirror = true; + setRotation(conduit, 0F, 0F, 0F); + brace1 = new ModelRenderer(this, 0, 11); + brace1.addBox(0F, 0F, 0F, 1, 1, 2); + brace1.setRotationPoint(-2F, 9.5F, -7.1F); + brace1.setTextureSize(128, 64); + brace1.mirror = true; + setRotation(brace1, 0.1745329F, 0F, 0F); + tank = new ModelRenderer(this, 0, 0); + tank.addBox(0F, 0F, 0F, 16, 9, 16); + tank.setRotationPoint(-8F, 10F, -8F); + tank.setTextureSize(128, 64); + tank.mirror = true; + setRotation(tank, 0F, 0F, 0F); + laser = new ModelRenderer(this, 4, 0); + laser.addBox(0.5F, 2.1F, -9F, 1, 2, 1); + laser.setRotationPoint(-1F, -5F, 8F); + laser.setTextureSize(128, 64); + laser.mirror = true; + setRotation(laser, -0.1117011F, 0F, 0F); + base = new ModelRenderer(this, 0, 25); + base.addBox(0F, 0F, 0F, 16, 4, 16); + base.setRotationPoint(-8F, 20F, -8F); + base.setTextureSize(128, 64); + base.mirror = true; + setRotation(base, 0F, 0F, 0F); + support1 = new ModelRenderer(this, 0, 0); + support1.addBox(0F, 0F, 0F, 1, 1, 1); + support1.setRotationPoint(6.5F, 19F, -7.5F); + support1.setTextureSize(128, 64); + support1.mirror = true; + setRotation(support1, 0F, 0F, 0F); + support2 = new ModelRenderer(this, 0, 0); + support2.addBox(0F, 0F, 0F, 1, 1, 1); + support2.setRotationPoint(6.5F, 19F, 6.5F); + support2.setTextureSize(128, 64); + support2.mirror = true; + setRotation(support2, 0F, 0F, 0F); + support3 = new ModelRenderer(this, 0, 0); + support3.addBox(0F, 0F, 0F, 1, 1, 1); + support3.setRotationPoint(6.5F, 19F, -5.5F); + support3.setTextureSize(128, 64); + support3.mirror = true; + setRotation(support3, 0F, 0F, 0F); + support4 = new ModelRenderer(this, 0, 0); + support4.addBox(0F, 0F, 0F, 1, 1, 1); + support4.setRotationPoint(6.5F, 19F, -3.5F); + support4.setTextureSize(128, 64); + support4.mirror = true; + setRotation(support4, 0F, 0F, 0F); + support5 = new ModelRenderer(this, 0, 0); + support5.addBox(0F, 0F, 0F, 1, 1, 1); + support5.setRotationPoint(6.5F, 19F, -1.5F); + support5.setTextureSize(128, 64); + support5.mirror = true; + setRotation(support5, 0F, 0F, 0F); + support6 = new ModelRenderer(this, 0, 0); + support6.addBox(0F, 0F, 0F, 1, 1, 1); + support6.setRotationPoint(6.5F, 19F, 0.5F); + support6.setTextureSize(128, 64); + support6.mirror = true; + setRotation(support6, 0F, 0F, 0F); + support7 = new ModelRenderer(this, 0, 0); + support7.addBox(0F, 0F, 0F, 1, 1, 1); + support7.setRotationPoint(6.5F, 19F, 2.5F); + support7.setTextureSize(128, 64); + support7.mirror = true; + setRotation(support7, 0F, 0F, 0F); + support8 = new ModelRenderer(this, 0, 0); + support8.addBox(0F, 0F, 0F, 1, 1, 1); + support8.setRotationPoint(6.5F, 19F, 4.5F); + support8.setTextureSize(128, 64); + support8.mirror = true; + setRotation(support8, 0F, 0F, 0F); + support9 = new ModelRenderer(this, 0, 0); + support9.addBox(0F, 0F, 0F, 1, 1, 1); + support9.setRotationPoint(-7.5F, 19F, 6.5F); + support9.setTextureSize(128, 64); + support9.mirror = true; + setRotation(support9, 0F, 0F, 0F); + support10 = new ModelRenderer(this, 0, 0); + support10.addBox(0F, 0F, 0F, 1, 1, 1); + support10.setRotationPoint(-7.5F, 19F, 4.5F); + support10.setTextureSize(128, 64); + support10.mirror = true; + setRotation(support10, 0F, 0F, 0F); + support11 = new ModelRenderer(this, 0, 0); + support11.addBox(0F, 0F, 0F, 1, 1, 1); + support11.setRotationPoint(-7.5F, 19F, 2.5F); + support11.setTextureSize(128, 64); + support11.mirror = true; + setRotation(support11, 0F, 0F, 0F); + support12 = new ModelRenderer(this, 0, 0); + support12.addBox(0F, 0F, 0F, 1, 1, 1); + support12.setRotationPoint(-7.5F, 19F, 0.5F); + support12.setTextureSize(128, 64); + support12.mirror = true; + setRotation(support12, 0F, 0F, 0F); + support13 = new ModelRenderer(this, 0, 0); + support13.addBox(0F, 0F, 0F, 1, 1, 1); + support13.setRotationPoint(-7.5F, 19F, -1.5F); + support13.setTextureSize(128, 64); + support13.mirror = true; + setRotation(support13, 0F, 0F, 0F); + support14 = new ModelRenderer(this, 0, 0); + support14.addBox(0F, 0F, 0F, 1, 1, 1); + support14.setRotationPoint(-7.5F, 19F, -3.5F); + support14.setTextureSize(128, 64); + support14.mirror = true; + setRotation(support14, 0F, 0F, 0F); + support15 = new ModelRenderer(this, 0, 0); + support15.addBox(0F, 0F, 0F, 1, 1, 1); + support15.setRotationPoint(-7.5F, 19F, -5.5F); + support15.setTextureSize(128, 64); + support15.mirror = true; + setRotation(support15, 0F, 0F, 0F); + support16 = new ModelRenderer(this, 0, 0); + support16.addBox(0F, 0F, 0F, 1, 1, 1); + support16.setRotationPoint(-7.5F, 19F, -7.5F); + support16.setTextureSize(128, 64); + support16.mirror = true; + setRotation(support16, 0F, 0F, 0F); + portConnector = new ModelRenderer(this, 0, 14); + portConnector.addBox(0F, 0F, 0F, 6, 1, 1); + portConnector.setRotationPoint(-3F, 19F, -7.01F); + portConnector.setTextureSize(128, 64); + portConnector.mirror = true; + setRotation(portConnector, 0F, 0F, 0F); + laserBeamToggle = new ModelRenderer(this, 12, 0); + laserBeamToggle.addBox(0.5F, 4.1F, -9F, 1, 11, 1); + laserBeamToggle.setRotationPoint(-1F, -5F, 8F); + laserBeamToggle.setTextureSize(128, 64); + laserBeamToggle.mirror = true; + setRotation(laserBeamToggle, -0.1117011F, 0F, 0F); + } - public void render(float size) - { - pole.render(size); - panel3.render(size); - port.render(size); - panel1.render(size); - panel2.render(size); - panelBase.render(size); - panelBraceLeft2.render(size); - panelBraceRight2.render(size); - panelBraceLeft1.render(size); - panelBraceRight1.render(size); - panelBrace.render(size); - bridge.render(size); - platform.render(size); - hole2.render(size); - hole4.render(size); - hole1.render(size); - hole3.render(size); - brace2.render(size); - tube2c.render(size); - tube1b.render(size); - tube1c.render(size); - tube2b.render(size); - tube2a.render(size); - tube1a.render(size); - conduit.render(size); - brace1.render(size); - tank.render(size); - laser.render(size); - base.render(size); - support1.render(size); - support2.render(size); - support3.render(size); - support4.render(size); - support5.render(size); - support6.render(size); - support7.render(size); - support8.render(size); - support9.render(size); - support10.render(size); - support11.render(size); - support12.render(size); - support13.render(size); - support14.render(size); - support15.render(size); - support16.render(size); - portConnector.render(size); - laserBeamToggle.render(size); - } - - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + public void render(float size) { + pole.render(size); + panel3.render(size); + port.render(size); + panel1.render(size); + panel2.render(size); + panelBase.render(size); + panelBraceLeft2.render(size); + panelBraceRight2.render(size); + panelBraceLeft1.render(size); + panelBraceRight1.render(size); + panelBrace.render(size); + bridge.render(size); + platform.render(size); + hole2.render(size); + hole4.render(size); + hole1.render(size); + hole3.render(size); + brace2.render(size); + tube2c.render(size); + tube1b.render(size); + tube1c.render(size); + tube2b.render(size); + tube2a.render(size); + tube1a.render(size); + conduit.render(size); + brace1.render(size); + tank.render(size); + laser.render(size); + base.render(size); + support1.render(size); + support2.render(size); + support3.render(size); + support4.render(size); + support5.render(size); + support6.render(size); + support7.render(size); + support8.render(size); + support9.render(size); + support10.render(size); + support11.render(size); + support12.render(size); + support13.render(size); + support14.render(size); + support15.render(size); + support16.render(size); + portConnector.render(size); + laserBeamToggle.render(size); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/mekanism/client/model/ModelTheoreticalElementizer.java b/src/main/java/mekanism/client/model/ModelTheoreticalElementizer.java index 36063b330..843b01b6f 100644 --- a/src/main/java/mekanism/client/model/ModelTheoreticalElementizer.java +++ b/src/main/java/mekanism/client/model/ModelTheoreticalElementizer.java @@ -7,8 +7,7 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; @SideOnly(Side.CLIENT) -public class ModelTheoreticalElementizer extends ModelBase -{ +public class ModelTheoreticalElementizer extends ModelBase { ModelRenderer A; ModelRenderer B; ModelRenderer C; @@ -27,102 +26,120 @@ public class ModelTheoreticalElementizer extends ModelBase ModelRenderer P; ModelRenderer Q; ModelRenderer R; - + public ModelTheoreticalElementizer() { super.textureWidth = 128; super.textureHeight = 128; - (this.A = new ModelRenderer((ModelBase)this, 0, 0)).addBox(-8.0f, 0.0f, -8.0f, 16, 1, 16); + (this.A = new ModelRenderer((ModelBase) this, 0, 0)) + .addBox(-8.0f, 0.0f, -8.0f, 16, 1, 16); this.A.setRotationPoint(0.0f, 23.0f, 0.0f); this.A.setTextureSize(64, 32); this.A.mirror = true; this.setRotation(this.A, 0.0f, 0.0f, 0.0f); - (this.B = new ModelRenderer((ModelBase)this, 0, 40)).addBox(-5.0f, 0.0f, -4.0f, 10, 10, 8); + (this.B = new ModelRenderer((ModelBase) this, 0, 40)) + .addBox(-5.0f, 0.0f, -4.0f, 10, 10, 8); this.B.setRotationPoint(0.0f, 13.0f, 0.0f); this.B.setTextureSize(64, 32); this.B.mirror = true; this.setRotation(this.B, 0.0f, 0.0f, 0.0f); - (this.C = new ModelRenderer((ModelBase)this, 0, 19)).addBox(-3.0f, 0.0f, -3.0f, 6, 14, 6); + (this.C = new ModelRenderer((ModelBase) this, 0, 19)) + .addBox(-3.0f, 0.0f, -3.0f, 6, 14, 6); this.C.setRotationPoint(0.0f, 8.0f, 0.0f); this.C.setTextureSize(64, 32); this.C.mirror = true; this.setRotation(this.C, 0.0f, 0.0f, 0.0f); - (this.DROT = new ModelRenderer((ModelBase)this, 5, 0)).addBox(-1.0f, -1.0f, -1.0f, 2, 2, 2); + (this.DROT = new ModelRenderer((ModelBase) this, 5, 0)) + .addBox(-1.0f, -1.0f, -1.0f, 2, 2, 2); this.DROT.setRotationPoint(0.0f, 5.0f, 0.0f); this.DROT.setTextureSize(64, 32); this.DROT.mirror = true; this.setRotation(this.DROT, 0.7853982f, 0.7853982f, 0.7853982f); - (this.E = new ModelRenderer((ModelBase)this, 65, 0)).addBox(-2.0f, 0.0f, 2.0f, 4, 8, 7); + (this.E = new ModelRenderer((ModelBase) this, 65, 0)) + .addBox(-2.0f, 0.0f, 2.0f, 4, 8, 7); this.E.setRotationPoint(0.0f, 15.0f, 0.0f); this.E.setTextureSize(64, 32); this.E.mirror = true; this.setRotation(this.E, 0.0f, 0.7853982f, 0.0f); - (this.F = new ModelRenderer((ModelBase)this, 65, 0)).addBox(-2.0f, 0.0f, 2.0f, 4, 8, 7); + (this.F = new ModelRenderer((ModelBase) this, 65, 0)) + .addBox(-2.0f, 0.0f, 2.0f, 4, 8, 7); this.F.setRotationPoint(0.0f, 15.0f, 0.0f); this.F.setTextureSize(64, 32); this.F.mirror = true; this.setRotation(this.F, 0.0f, -0.7853982f, 0.0f); - (this.G = new ModelRenderer((ModelBase)this, 0, 0)).addBox(6.0f, 0.0f, 0.0f, 1, 4, 1); + (this.G = new ModelRenderer((ModelBase) this, 0, 0)) + .addBox(6.0f, 0.0f, 0.0f, 1, 4, 1); this.G.setRotationPoint(0.0f, 19.0f, -2.0f); this.G.setTextureSize(64, 32); this.G.mirror = true; this.setRotation(this.G, 0.0f, 0.0f, 0.0f); - (this.H = new ModelRenderer((ModelBase)this, 0, 6)).addBox(5.0f, 0.0f, 0.0f, 1, 1, 1); + (this.H = new ModelRenderer((ModelBase) this, 0, 6)) + .addBox(5.0f, 0.0f, 0.0f, 1, 1, 1); this.H.setRotationPoint(0.0f, 19.0f, -2.0f); this.H.setTextureSize(64, 32); this.H.mirror = true; this.setRotation(this.H, 0.0f, 0.0f, 0.0f); - (this.I = new ModelRenderer((ModelBase)this, 0, 6)).addBox(5.0f, 0.0f, 0.0f, 1, 1, 1); + (this.I = new ModelRenderer((ModelBase) this, 0, 6)) + .addBox(5.0f, 0.0f, 0.0f, 1, 1, 1); this.I.setRotationPoint(0.0f, 19.0f, 0.0f); this.I.setTextureSize(64, 32); this.I.mirror = true; this.setRotation(this.I, 0.0f, 0.0f, 0.0f); - (this.J = new ModelRenderer((ModelBase)this, 0, 0)).addBox(6.0f, 0.0f, 0.0f, 1, 4, 1); + (this.J = new ModelRenderer((ModelBase) this, 0, 0)) + .addBox(6.0f, 0.0f, 0.0f, 1, 4, 1); this.J.setRotationPoint(0.0f, 19.0f, 0.0f); this.J.setTextureSize(64, 32); this.J.mirror = true; this.setRotation(this.J, 0.0f, 0.0f, 0.0f); - (this.K = new ModelRenderer((ModelBase)this, 21, 61)).addBox(0.0f, -1.0f, -4.0f, 2, 9, 5); + (this.K = new ModelRenderer((ModelBase) this, 21, 61)) + .addBox(0.0f, -1.0f, -4.0f, 2, 9, 5); this.K.setRotationPoint(-7.0f, 15.0f, 1.0f); this.K.setTextureSize(64, 32); this.K.mirror = true; this.setRotation(this.K, 0.0f, 0.0f, 0.0f); - (this.L = new ModelRenderer((ModelBase)this, 21, 77)).addBox(0.0f, -1.0f, -1.0f, 1, 2, 2); + (this.L = new ModelRenderer((ModelBase) this, 21, 77)) + .addBox(0.0f, -1.0f, -1.0f, 1, 2, 2); this.L.setRotationPoint(-8.0f, 16.0f, 0.0f); this.L.setTextureSize(64, 32); this.L.mirror = true; this.setRotation(this.L, 0.0f, 0.0f, 0.0f); - (this.M = new ModelRenderer((ModelBase)this, 0, 61)).addBox(-4.0f, 0.0f, 0.0f, 8, 10, 0); + (this.M = new ModelRenderer((ModelBase) this, 0, 61)) + .addBox(-4.0f, 0.0f, 0.0f, 8, 10, 0); this.M.setRotationPoint(0.0f, 3.0f, 0.0f); this.M.setTextureSize(64, 32); this.M.mirror = true; this.setRotation(this.M, 0.0f, 0.7853982f, 0.0f); - (this.N = new ModelRenderer((ModelBase)this, 0, 73)).addBox(-4.0f, 0.0f, 0.0f, 8, 10, 0); + (this.N = new ModelRenderer((ModelBase) this, 0, 73)) + .addBox(-4.0f, 0.0f, 0.0f, 8, 10, 0); this.N.setRotationPoint(0.0f, 3.0f, 0.0f); this.N.setTextureSize(64, 32); this.N.mirror = true; this.setRotation(this.N, 0.0f, -0.7853982f, 0.0f); - (this.O = new ModelRenderer((ModelBase)this, 0, 93)).addBox(-5.0f, -5.0f, 0.0f, 6, 6, 0); + (this.O = new ModelRenderer((ModelBase) this, 0, 93)) + .addBox(-5.0f, -5.0f, 0.0f, 6, 6, 0); this.O.setRotationPoint(0.0f, 6.0f, 0.0f); this.O.setTextureSize(64, 32); this.O.mirror = true; this.setRotation(this.O, 0.0f, -0.7853982f, 0.7853982f); - (this.P = new ModelRenderer((ModelBase)this, 0, 85)).addBox(-5.0f, -5.0f, 0.0f, 6, 6, 0); + (this.P = new ModelRenderer((ModelBase) this, 0, 85)) + .addBox(-5.0f, -5.0f, 0.0f, 6, 6, 0); this.P.setRotationPoint(0.0f, 6.0f, 0.0f); this.P.setTextureSize(64, 32); this.P.mirror = true; this.setRotation(this.P, 0.0f, 0.7853982f, 0.7853982f); - (this.Q = new ModelRenderer((ModelBase)this, 65, 17)).addBox(-4.0f, 0.0f, 0.0f, 8, 6, 4); + (this.Q = new ModelRenderer((ModelBase) this, 65, 17)) + .addBox(-4.0f, 0.0f, 0.0f, 8, 6, 4); this.Q.setRotationPoint(0.0f, 17.0f, -8.0f); this.Q.setTextureSize(64, 32); this.Q.mirror = true; this.setRotation(this.Q, 0.0f, 0.0f, 0.0f); - (this.R = new ModelRenderer((ModelBase)this, 65, 28)).addBox(-4.0f, 0.0f, 0.0f, 8, 3, 5); + (this.R = new ModelRenderer((ModelBase) this, 65, 28)) + .addBox(-4.0f, 0.0f, 0.0f, 8, 3, 5); this.R.setRotationPoint(0.0f, 17.0f, -8.0f); this.R.setTextureSize(64, 32); this.R.mirror = true; this.setRotation(this.R, 0.5934119f, 0.0f, 0.0f); } - + public void render(final float size) { this.A.render(size); this.B.render(size); @@ -143,8 +160,16 @@ public class ModelTheoreticalElementizer extends ModelBase this.Q.render(size); this.R.render(size); } - - public void render(final Entity entity, final float f, final float f1, final float f2, final float f3, final float f4, final float f5) { + + public void render( + final Entity entity, + final float f, + final float f1, + final float f2, + final float f3, + final float f4, + final float f5 + ) { super.render(entity, f, f1, f2, f3, f4, f5); this.setRotationAngles(f, f1, f2, f3, f4, f5, entity); this.A.render(f5); @@ -166,8 +191,9 @@ public class ModelTheoreticalElementizer extends ModelBase this.Q.render(f5); this.R.render(f5); } - - private void setRotation(final ModelRenderer model, final float x, final float y, final float z) { + + private void + setRotation(final ModelRenderer model, final float x, final float y, final float z) { model.rotateAngleX = x; model.rotateAngleY = y; model.rotateAngleZ = z; diff --git a/src/main/java/mekanism/client/model/ModelTransporterBox.java b/src/main/java/mekanism/client/model/ModelTransporterBox.java index 9d756e558..d20a54477 100644 --- a/src/main/java/mekanism/client/model/ModelTransporterBox.java +++ b/src/main/java/mekanism/client/model/ModelTransporterBox.java @@ -1,37 +1,33 @@ package mekanism.client.model; -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; @SideOnly(Side.CLIENT) -public class ModelTransporterBox extends ModelBase -{ - ModelRenderer box; +public class ModelTransporterBox extends ModelBase { + ModelRenderer box; - public ModelTransporterBox() - { - textureWidth = 64; - textureHeight = 64; + public ModelTransporterBox() { + textureWidth = 64; + textureHeight = 64; - box = new ModelRenderer(this, 0, 0); - box.addBox(0F, 0F, 0F, 7, 7, 7); - box.setRotationPoint(-3.5F, 0, -3.5F); - box.setTextureSize(64, 64); - box.mirror = true; - setRotation(box, 0F, 0F, 0F); - } + box = new ModelRenderer(this, 0, 0); + box.addBox(0F, 0F, 0F, 7, 7, 7); + box.setRotationPoint(-3.5F, 0, -3.5F); + box.setTextureSize(64, 64); + box.mirror = true; + setRotation(box, 0F, 0F, 0F); + } - public void render(float size) - { - box.render(size); - } + public void render(float size) { + box.render(size); + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/mekanism/client/nei/AdvancedMachineRecipeHandler.java b/src/main/java/mekanism/client/nei/AdvancedMachineRecipeHandler.java index 536a86cfc..94dc05faf 100644 --- a/src/main/java/mekanism/client/nei/AdvancedMachineRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/AdvancedMachineRecipeHandler.java @@ -8,6 +8,12 @@ import java.awt.Rectangle; import java.util.Collection; import java.util.List; +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.NEIClientConfig; +import codechicken.nei.NEIServerUtils; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.GuiRecipe; +import codechicken.nei.recipe.TemplateRecipeHandler; import mekanism.api.gas.Gas; import mekanism.api.gas.GasStack; import mekanism.client.gui.element.GuiElement; @@ -26,281 +32,308 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.item.ItemStack; - import org.lwjgl.opengl.GL11; -import codechicken.lib.gui.GuiDraw; -import codechicken.nei.NEIClientConfig; -import codechicken.nei.NEIServerUtils; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.GuiRecipe; -import codechicken.nei.recipe.TemplateRecipeHandler; +public abstract class AdvancedMachineRecipeHandler extends BaseRecipeHandler { + private int ticksPassed; -public abstract class AdvancedMachineRecipeHandler extends BaseRecipeHandler -{ - private int ticksPassed; + public abstract String getRecipeId(); - public abstract String getRecipeId(); + public abstract Collection getRecipes(); - public abstract Collection getRecipes(); + public abstract List getFuelStacks(Gas gasType); - public abstract List getFuelStacks(Gas gasType); - - public abstract ProgressBar getProgressType(); - - @Override - public void addGuiElements() - { - guiElements.add(new GuiSlot(SlotType.INPUT, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 55, 16)); - guiElements.add(new GuiSlot(SlotType.POWER, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 30, 34).with(SlotOverlay.POWER)); - guiElements.add(new GuiSlot(SlotType.EXTRA, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 55, 52)); - guiElements.add(new GuiSlot(SlotType.OUTPUT_LARGE, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 111, 30)); - - guiElements.add(new GuiPowerBar(this, new IPowerInfoHandler() { - @Override - public double getLevel() - { - return ticksPassed <= 20 ? ticksPassed / 20.0F : 1.0F; - } - }, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 164, 15)); - guiElements.add(new GuiProgress(new IProgressInfoHandler() - { - @Override - public double getProgress() - { - return ticksPassed >= 40 ? (ticksPassed - 40) % 20 / 20.0F : 0.0F; - } - }, getProgressType(), this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 77, 37)); - } + public abstract ProgressBar getProgressType(); - @Override - public void drawBackground(int i) - { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - changeTexture(getGuiTexture()); - drawTexturedModalRect(12, 0, 28, 5, 144, 68); - - for(GuiElement e : guiElements) - { - e.renderBackground(0, 0, -16, -5); - } - } + @Override + public void addGuiElements() { + guiElements.add(new GuiSlot( + SlotType.INPUT, + this, + MekanismUtils.getResource(ResourceType.GUI, stripTexture()), + 55, + 16 + )); + guiElements.add(new GuiSlot( + SlotType.POWER, + this, + MekanismUtils.getResource(ResourceType.GUI, stripTexture()), + 30, + 34 + ) + .with(SlotOverlay.POWER)); + guiElements.add(new GuiSlot( + SlotType.EXTRA, + this, + MekanismUtils.getResource(ResourceType.GUI, stripTexture()), + 55, + 52 + )); + guiElements.add(new GuiSlot( + SlotType.OUTPUT_LARGE, + this, + MekanismUtils.getResource(ResourceType.GUI, stripTexture()), + 111, + 30 + )); - @Override - public void drawExtras(int i) - { - CachedIORecipe recipe = (CachedIORecipe)arecipes.get(i); + guiElements.add(new GuiPowerBar(this, new IPowerInfoHandler() { + @Override + public double getLevel() { + return ticksPassed <= 20 ? ticksPassed / 20.0F : 1.0F; + } + }, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 164, 15)); + guiElements.add(new GuiProgress( + new IProgressInfoHandler() { + @Override + public double getProgress() { + return ticksPassed >= 40 ? (ticksPassed - 40) % 20 / 20.0F : 0.0F; + } + }, + getProgressType(), + this, + MekanismUtils.getResource(ResourceType.GUI, stripTexture()), + 77, + 37 + )); + } - if(recipe.input.gasType != null && ticksPassed >= 20) - { - int displayInt = ticksPassed < 40 ? (ticksPassed-20)*12 / 20 : 12; - displayGauge(45, 32 + 12 - displayInt, 6, displayInt, new GasStack(recipe.input.gasType, 1)); - } - } + @Override + public void drawBackground(int i) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + changeTexture(getGuiTexture()); + drawTexturedModalRect(12, 0, 28, 5, 144, 68); - @Override - public void onUpdate() - { - super.onUpdate(); - ticksPassed++; - } + for (GuiElement e : guiElements) { + e.renderBackground(0, 0, -16, -5); + } + } - @Override - public void loadTransferRects() - { - transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(63, 34, 24, 7), getRecipeId(), new Object[0])); - } + @Override + public void drawExtras(int i) { + CachedIORecipe recipe = (CachedIORecipe) arecipes.get(i); - @Override - public void loadCraftingRecipes(String outputId, Object... results) - { - if(outputId.equals(getRecipeId())) - { - for(AdvancedMachineRecipe irecipe : getRecipes()) - { - arecipes.add(new CachedIORecipe(irecipe, getFuelStacks(irecipe.getInput().gasType))); - } - } - else { - super.loadCraftingRecipes(outputId, results); - } - } + if (recipe.input.gasType != null && ticksPassed >= 20) { + int displayInt = ticksPassed < 40 ? (ticksPassed - 20) * 12 / 20 : 12; + displayGauge( + 45, + 32 + 12 - displayInt, + 6, + displayInt, + new GasStack(recipe.input.gasType, 1) + ); + } + } - @Override - public void loadCraftingRecipes(ItemStack result) - { - for(AdvancedMachineRecipe irecipe : getRecipes()) - { - if(NEIServerUtils.areStacksSameTypeCrafting(irecipe.getOutput().output, result)) - { - arecipes.add(new CachedIORecipe(irecipe, getFuelStacks(irecipe.getInput().gasType))); - } - } - } - - @Override - public String getGuiTexture() - { - return "mekanism:gui/GuiAdvancedMachine.png"; - } + @Override + public void onUpdate() { + super.onUpdate(); + ticksPassed++; + } - @Override - public void loadUsageRecipes(String inputId, Object... ingredients) - { - if(inputId.equals("gas") && ingredients.length == 1 && ingredients[0] instanceof GasStack) - { - for(AdvancedMachineRecipe irecipe : getRecipes()) - { - if(irecipe.getInput().gasType == ((GasStack)ingredients[0]).getGas()) - { - arecipes.add(new CachedIORecipe(irecipe, getFuelStacks(irecipe.getInput().gasType))); - } - } - } - else { - super.loadUsageRecipes(inputId, ingredients); - } - } + @Override + public void loadTransferRects() { + transferRects.add(new TemplateRecipeHandler.RecipeTransferRect( + new Rectangle(63, 34, 24, 7), getRecipeId(), new Object[0] + )); + } - @Override - public void loadUsageRecipes(ItemStack ingredient) - { - for(AdvancedMachineRecipe irecipe : getRecipes()) - { - if(NEIServerUtils.areStacksSameTypeCrafting(irecipe.getInput().itemStack, ingredient)) - { - arecipes.add(new CachedIORecipe(irecipe, getFuelStacks(irecipe.getInput().gasType))); - } - } - } + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals(getRecipeId())) { + for (AdvancedMachineRecipe irecipe : getRecipes()) { + arecipes.add( + new CachedIORecipe(irecipe, getFuelStacks(irecipe.getInput().gasType)) + ); + } + } else { + super.loadCraftingRecipes(outputId, results); + } + } - @Override - public List handleTooltip(GuiRecipe gui, List currenttip, int recipe) - { - Point point = GuiDraw.getMousePosition(); - Point offset = gui.getRecipePosition(recipe); + @Override + public void loadCraftingRecipes(ItemStack result) { + for (AdvancedMachineRecipe irecipe : getRecipes()) { + if (NEIServerUtils.areStacksSameTypeCrafting( + irecipe.getOutput().output, result + )) { + arecipes.add( + new CachedIORecipe(irecipe, getFuelStacks(irecipe.getInput().gasType)) + ); + } + } + } - int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft)-offset.x; - int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop)-offset.y; + @Override + public String getGuiTexture() { + return "mekanism:gui/GuiAdvancedMachine.png"; + } - if(xAxis >= 45 && xAxis <= 51 && yAxis >= 33 && yAxis <= 45) - { - currenttip.add(((CachedIORecipe)arecipes.get(recipe)).input.gasType.getLocalizedName()); - } + @Override + public void loadUsageRecipes(String inputId, Object... ingredients) { + if (inputId.equals("gas") && ingredients.length == 1 + && ingredients[0] instanceof GasStack) { + for (AdvancedMachineRecipe irecipe : getRecipes()) { + if (irecipe.getInput().gasType == ((GasStack) ingredients[0]).getGas()) { + arecipes.add(new CachedIORecipe( + irecipe, getFuelStacks(irecipe.getInput().gasType) + )); + } + } + } else { + super.loadUsageRecipes(inputId, ingredients); + } + } - return super.handleTooltip(gui, currenttip, recipe); - } + @Override + public void loadUsageRecipes(ItemStack ingredient) { + for (AdvancedMachineRecipe irecipe : getRecipes()) { + if (NEIServerUtils.areStacksSameTypeCrafting( + irecipe.getInput().itemStack, ingredient + )) { + arecipes.add( + new CachedIORecipe(irecipe, getFuelStacks(irecipe.getInput().gasType)) + ); + } + } + } - @Override - public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) - { - Point point = GuiDraw.getMousePosition(); - Point offset = gui.getRecipePosition(recipe); + @Override + public List + handleTooltip(GuiRecipe gui, List currenttip, int recipe) { + Point point = GuiDraw.getMousePosition(); + Point offset = gui.getRecipePosition(recipe); - int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft)-offset.x; - int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop)-offset.y; + int xAxis = point.x + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft + ) + - offset.x; + int yAxis = point.y + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop + ) + - offset.y; - GasStack stack = null; + if (xAxis >= 45 && xAxis <= 51 && yAxis >= 33 && yAxis <= 45) { + currenttip.add( + ((CachedIORecipe) arecipes.get(recipe)).input.gasType.getLocalizedName() + ); + } - if(xAxis >= 45 && xAxis <= 51 && yAxis >= 33 && yAxis <= 45) - { - stack = new GasStack(((CachedIORecipe)arecipes.get(recipe)).input.gasType, 1); - } + return super.handleTooltip(gui, currenttip, recipe); + } - if(stack != null) - { - if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) - { - if(doGasLookup(stack, false)) - { - return true; - } - } - else if(keyCode == NEIClientConfig.getKeyBinding("gui.usage")) - { - if(doGasLookup(stack, true)) - { - return true; - } - } - } + @Override + public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) { + Point point = GuiDraw.getMousePosition(); + Point offset = gui.getRecipePosition(recipe); - return super.keyTyped(gui, keyChar, keyCode, recipe); - } + int xAxis = point.x + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft + ) + - offset.x; + int yAxis = point.y + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop + ) + - offset.y; - @Override - public boolean mouseClicked(GuiRecipe gui, int button, int recipe) - { - Point point = GuiDraw.getMousePosition(); - Point offset = gui.getRecipePosition(recipe); + GasStack stack = null; - int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft)-offset.x; - int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop)-offset.y; + if (xAxis >= 45 && xAxis <= 51 && yAxis >= 33 && yAxis <= 45) { + stack + = new GasStack(((CachedIORecipe) arecipes.get(recipe)).input.gasType, 1); + } - GasStack stack = null; + if (stack != null) { + if (keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) { + if (doGasLookup(stack, false)) { + return true; + } + } else if (keyCode == NEIClientConfig.getKeyBinding("gui.usage")) { + if (doGasLookup(stack, true)) { + return true; + } + } + } - if(xAxis >= 45 && xAxis <= 51 && yAxis >= 33 && yAxis <= 45) - { - stack = new GasStack(((CachedIORecipe)arecipes.get(recipe)).input.gasType, 1); - } + return super.keyTyped(gui, keyChar, keyCode, recipe); + } - if(stack != null) - { - if(button == 0) - { - if(doGasLookup(stack, false)) - { - return true; - } - } - else if(button == 1) - { - if(doGasLookup(stack, true)) - { - return true; - } - } - } + @Override + public boolean mouseClicked(GuiRecipe gui, int button, int recipe) { + Point point = GuiDraw.getMousePosition(); + Point offset = gui.getRecipePosition(recipe); - return super.mouseClicked(gui, button, recipe); - } + int xAxis = point.x + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft + ) + - offset.x; + int yAxis = point.y + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop + ) + - offset.y; - public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe - { - public List fuelStacks; + GasStack stack = null; - public AdvancedMachineInput input; + if (xAxis >= 45 && xAxis <= 51 && yAxis >= 33 && yAxis <= 45) { + stack + = new GasStack(((CachedIORecipe) arecipes.get(recipe)).input.gasType, 1); + } - public PositionedStack outputStack; + if (stack != null) { + if (button == 0) { + if (doGasLookup(stack, false)) { + return true; + } + } else if (button == 1) { + if (doGasLookup(stack, true)) { + return true; + } + } + } - @Override - public PositionedStack getIngredient() - { - return new PositionedStack(input.itemStack, 40, 12); - } + return super.mouseClicked(gui, button, recipe); + } - @Override - public PositionedStack getResult() - { - return outputStack; - } + public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe { + public List fuelStacks; - @Override - public PositionedStack getOtherStack() - { - return new PositionedStack(fuelStacks.get(cycleticks/40 % fuelStacks.size()), 40, 48); - } + public AdvancedMachineInput input; - public CachedIORecipe(AdvancedMachineInput adv, ItemStack output, List fuels) - { - input = adv; - outputStack = new PositionedStack(output, 100, 30); - fuelStacks = fuels; - } + public PositionedStack outputStack; - public CachedIORecipe(AdvancedMachineRecipe recipe, List fuels) - { - this(recipe.getInput(), recipe.getOutput().output, fuels); - } - } + @Override + public PositionedStack getIngredient() { + return new PositionedStack(input.itemStack, 40, 12); + } + + @Override + public PositionedStack getResult() { + return outputStack; + } + + @Override + public PositionedStack getOtherStack() { + return new PositionedStack( + fuelStacks.get(cycleticks / 40 % fuelStacks.size()), 40, 48 + ); + } + + public CachedIORecipe( + AdvancedMachineInput adv, ItemStack output, List fuels + ) { + input = adv; + outputStack = new PositionedStack(output, 100, 30); + fuelStacks = fuels; + } + + public CachedIORecipe(AdvancedMachineRecipe recipe, List fuels) { + this(recipe.getInput(), recipe.getOutput().output, fuels); + } + } } diff --git a/src/main/java/mekanism/client/nei/BaseRecipeHandler.java b/src/main/java/mekanism/client/nei/BaseRecipeHandler.java index 5fe5f3879..b52dcfea2 100644 --- a/src/main/java/mekanism/client/nei/BaseRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/BaseRecipeHandler.java @@ -8,6 +8,9 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import codechicken.nei.recipe.GuiCraftingRecipe; +import codechicken.nei.recipe.GuiUsageRecipe; +import codechicken.nei.recipe.TemplateRecipeHandler; import mekanism.api.gas.GasStack; import mekanism.client.gui.IGuiWrapper; import mekanism.client.gui.element.GuiElement; @@ -15,158 +18,150 @@ import mekanism.client.render.MekanismRenderer; import net.minecraft.client.gui.FontRenderer; import net.minecraft.util.IIcon; import net.minecraftforge.fluids.FluidStack; -import codechicken.nei.recipe.GuiCraftingRecipe; -import codechicken.nei.recipe.GuiUsageRecipe; -import codechicken.nei.recipe.TemplateRecipeHandler; -public abstract class BaseRecipeHandler extends TemplateRecipeHandler implements IGuiWrapper -{ - public BaseRecipeHandler() - { - addGuiElements(); - } +public abstract class BaseRecipeHandler + extends TemplateRecipeHandler implements IGuiWrapper { + public BaseRecipeHandler() { + addGuiElements(); + } - public Set guiElements = new HashSet(); + public Set guiElements = new HashSet(); - public abstract void addGuiElements(); + public abstract void addGuiElements(); - public void displayGauge(int length, int xPos, int yPos, int overlayX, int overlayY, int scale, FluidStack fluid, GasStack gas) - { - if(fluid == null && gas == null) - { - return; - } + public void displayGauge( + int length, + int xPos, + int yPos, + int overlayX, + int overlayY, + int scale, + FluidStack fluid, + GasStack gas + ) { + if (fluid == null && gas == null) { + return; + } - int start = 0; + int start = 0; - while(true) - { - int renderRemaining = 0; + while (true) { + int renderRemaining = 0; - if(scale > 16) - { - renderRemaining = 16; - scale -= 16; - } - else { - renderRemaining = scale; - scale = 0; - } + if (scale > 16) { + renderRemaining = 16; + scale -= 16; + } else { + renderRemaining = scale; + scale = 0; + } - changeTexture(MekanismRenderer.getBlocksTexture()); + changeTexture(MekanismRenderer.getBlocksTexture()); - if(fluid != null) - { - gui.drawTexturedModelRectFromIcon(xPos, yPos + length - renderRemaining - start, fluid.getFluid().getIcon(), 16, 16 - (16 - renderRemaining)); - } - else if(gas != null) - { - gui.drawTexturedModelRectFromIcon(xPos, yPos + length - renderRemaining - start, gas.getGas().getIcon(), 16, 16 - (16 - renderRemaining)); - } + if (fluid != null) { + gui.drawTexturedModelRectFromIcon( + xPos, + yPos + length - renderRemaining - start, + fluid.getFluid().getIcon(), + 16, + 16 - (16 - renderRemaining) + ); + } else if (gas != null) { + gui.drawTexturedModelRectFromIcon( + xPos, + yPos + length - renderRemaining - start, + gas.getGas().getIcon(), + 16, + 16 - (16 - renderRemaining) + ); + } - start+=16; + start += 16; - if(renderRemaining == 0 || scale == 0) - { - break; - } - } + if (renderRemaining == 0 || scale == 0) { + break; + } + } - changeTexture(getGuiTexture()); - drawTexturedModalRect(xPos, yPos, overlayX, overlayY, 16, length+1); - } + changeTexture(getGuiTexture()); + drawTexturedModalRect(xPos, yPos, overlayX, overlayY, 16, length + 1); + } - /* - * true = usage, false = recipe - */ - public boolean doGasLookup(GasStack stack, boolean type) - { - if(stack != null && stack.amount > 0) - { - if(type) - { - if(!GuiUsageRecipe.openRecipeGui("gas", new Object[] {stack})) - { - return false; - } - } - else { - if(!GuiCraftingRecipe.openRecipeGui("gas", new Object[] {stack})) - { - return false; - } - } + /* + * true = usage, false = recipe + */ + public boolean doGasLookup(GasStack stack, boolean type) { + if (stack != null && stack.amount > 0) { + if (type) { + if (!GuiUsageRecipe.openRecipeGui("gas", new Object[] { stack })) { + return false; + } + } else { + if (!GuiCraftingRecipe.openRecipeGui("gas", new Object[] { stack })) { + return false; + } + } - return true; - } + return true; + } - return false; - } + return false; + } - public void displayGauge(int xPos, int yPos, int sizeX, int sizeY, GasStack gas) - { - if(gas == null) - { - return; - } + public void displayGauge(int xPos, int yPos, int sizeX, int sizeY, GasStack gas) { + if (gas == null) { + return; + } - changeTexture(MekanismRenderer.getBlocksTexture()); - gui.drawTexturedModelRectFromIcon(xPos, yPos, gas.getGas().getIcon(), sizeX, sizeY); - } - - public String stripTexture() - { - return getGuiTexture().replace("mekanism:gui/", ""); - } + changeTexture(MekanismRenderer.getBlocksTexture()); + gui.drawTexturedModelRectFromIcon( + xPos, yPos, gas.getGas().getIcon(), sizeX, sizeY + ); + } - /* - * true = usage, false = recipe - */ - public boolean doFluidLookup(FluidStack stack, boolean type) - { - if(stack != null && stack.amount > 0) - { - if(type) - { - if(!GuiUsageRecipe.openRecipeGui("fluid", new Object[] {stack})) - { - return false; - } - } - else { - if(!GuiCraftingRecipe.openRecipeGui("fluid", new Object[] {stack})) - { - return false; - } - } + public String stripTexture() { + return getGuiTexture().replace("mekanism:gui/", ""); + } - return true; - } + /* + * true = usage, false = recipe + */ + public boolean doFluidLookup(FluidStack stack, boolean type) { + if (stack != null && stack.amount > 0) { + if (type) { + if (!GuiUsageRecipe.openRecipeGui("fluid", new Object[] { stack })) { + return false; + } + } else { + if (!GuiCraftingRecipe.openRecipeGui("fluid", new Object[] { stack })) { + return false; + } + } - return false; - } + return true; + } - @Override - public void drawTexturedRect(int x, int y, int u, int v, int w, int h) - { - drawTexturedModalRect(x, y, u, v, w, h); - } + return false; + } - @Override - public void drawTexturedRectFromIcon(int x, int y, IIcon icon, int w, int h) - { - gui.drawTexturedModelRectFromIcon(x, y, icon, w, h); - } + @Override + public void drawTexturedRect(int x, int y, int u, int v, int w, int h) { + drawTexturedModalRect(x, y, u, v, w, h); + } - @Override - public void displayTooltip(String s, int xAxis, int yAxis) {} + @Override + public void drawTexturedRectFromIcon(int x, int y, IIcon icon, int w, int h) { + gui.drawTexturedModelRectFromIcon(x, y, icon, w, h); + } - @Override - public void displayTooltips(List list, int xAxis, int yAxis) {} + @Override + public void displayTooltip(String s, int xAxis, int yAxis) {} - @Override - public FontRenderer getFont() - { - return null; - } + @Override + public void displayTooltips(List list, int xAxis, int yAxis) {} + + @Override + public FontRenderer getFont() { + return null; + } } diff --git a/src/main/java/mekanism/client/nei/ChanceMachineRecipeHandler.java b/src/main/java/mekanism/client/nei/ChanceMachineRecipeHandler.java index e9e56e0ac..efb6a2979 100644 --- a/src/main/java/mekanism/client/nei/ChanceMachineRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/ChanceMachineRecipeHandler.java @@ -7,6 +7,9 @@ import static codechicken.lib.gui.GuiDraw.drawTexturedModalRect; import java.awt.Rectangle; import java.util.Collection; +import codechicken.nei.NEIServerUtils; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.TemplateRecipeHandler; import mekanism.client.gui.element.GuiElement; import mekanism.client.gui.element.GuiPowerBar; import mekanism.client.gui.element.GuiPowerBar.IPowerInfoHandler; @@ -21,175 +24,179 @@ import mekanism.common.recipe.outputs.ChanceOutput; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.item.ItemStack; - import org.lwjgl.opengl.GL11; -import codechicken.nei.NEIServerUtils; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.TemplateRecipeHandler; +public abstract class ChanceMachineRecipeHandler extends BaseRecipeHandler { + private int ticksPassed; -public abstract class ChanceMachineRecipeHandler extends BaseRecipeHandler -{ - private int ticksPassed; + public abstract String getRecipeId(); - public abstract String getRecipeId(); + public abstract Collection getRecipes(); - public abstract Collection getRecipes(); - - public abstract ProgressBar getProgressType(); - - @Override - public void addGuiElements() - { - guiElements.add(new GuiSlot(SlotType.INPUT, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 55, 16)); - guiElements.add(new GuiSlot(SlotType.POWER, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 55, 52).with(SlotOverlay.POWER)); - guiElements.add(new GuiSlot(SlotType.OUTPUT_WIDE, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 111, 30)); - - guiElements.add(new GuiPowerBar(this, new IPowerInfoHandler() { - @Override - public double getLevel() - { - return ticksPassed <= 20 ? ticksPassed / 20.0F : 1.0F; - } - }, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 164, 15)); - guiElements.add(new GuiProgress(new IProgressInfoHandler() - { - @Override - public double getProgress() - { - return ticksPassed >= 20 ? (ticksPassed - 20) % 20 / 20.0F : 0.0F; - } - }, getProgressType(), this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 77, 37)); - } + public abstract ProgressBar getProgressType(); - @Override - public void drawBackground(int i) - { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - changeTexture(getGuiTexture()); - drawTexturedModalRect(12, 0, 28, 5, 144, 68); - - for(GuiElement e : guiElements) - { - e.renderBackground(0, 0, -16, -5); - } - } + @Override + public void addGuiElements() { + guiElements.add(new GuiSlot( + SlotType.INPUT, + this, + MekanismUtils.getResource(ResourceType.GUI, stripTexture()), + 55, + 16 + )); + guiElements.add(new GuiSlot( + SlotType.POWER, + this, + MekanismUtils.getResource(ResourceType.GUI, stripTexture()), + 55, + 52 + ) + .with(SlotOverlay.POWER)); + guiElements.add(new GuiSlot( + SlotType.OUTPUT_WIDE, + this, + MekanismUtils.getResource(ResourceType.GUI, stripTexture()), + 111, + 30 + )); - @Override - public void drawExtras(int i) - { - CachedIORecipe recipe = (CachedIORecipe)arecipes.get(i); + guiElements.add(new GuiPowerBar(this, new IPowerInfoHandler() { + @Override + public double getLevel() { + return ticksPassed <= 20 ? ticksPassed / 20.0F : 1.0F; + } + }, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 164, 15)); + guiElements.add(new GuiProgress( + new IProgressInfoHandler() { + @Override + public double getProgress() { + return ticksPassed >= 20 ? (ticksPassed - 20) % 20 / 20.0F : 0.0F; + } + }, + getProgressType(), + this, + MekanismUtils.getResource(ResourceType.GUI, stripTexture()), + 77, + 37 + )); + } - if(recipe.output.hasSecondary()) - { - drawString(Math.round(recipe.output.secondaryChance*100) + "%", 116, 52, 0x404040, false); - } - } + @Override + public void drawBackground(int i) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + changeTexture(getGuiTexture()); + drawTexturedModalRect(12, 0, 28, 5, 144, 68); - @Override - public void onUpdate() - { - super.onUpdate(); - ticksPassed++; - } + for (GuiElement e : guiElements) { + e.renderBackground(0, 0, -16, -5); + } + } - @Override - public void loadTransferRects() - { - transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(63, 34, 24, 7), getRecipeId(), new Object[0])); - } + @Override + public void drawExtras(int i) { + CachedIORecipe recipe = (CachedIORecipe) arecipes.get(i); - @Override - public void loadCraftingRecipes(String outputId, Object... results) - { - if(outputId.equals(getRecipeId())) - { - for(ChanceMachineRecipe irecipe : getRecipes()) - { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - else { - super.loadCraftingRecipes(outputId, results); - } - } + if (recipe.output.hasSecondary()) { + drawString( + Math.round(recipe.output.secondaryChance * 100) + "%", + 116, + 52, + 0x404040, + false + ); + } + } - @Override - public void loadCraftingRecipes(ItemStack result) - { - for(ChanceMachineRecipe irecipe : getRecipes()) - { - if(irecipe.getOutput().hasPrimary() && NEIServerUtils.areStacksSameTypeCrafting(irecipe.getOutput().primaryOutput, result)) - { - arecipes.add(new CachedIORecipe(irecipe)); - } + @Override + public void onUpdate() { + super.onUpdate(); + ticksPassed++; + } + + @Override + public void loadTransferRects() { + transferRects.add(new TemplateRecipeHandler.RecipeTransferRect( + new Rectangle(63, 34, 24, 7), getRecipeId(), new Object[0] + )); + } + + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals(getRecipeId())) { + for (ChanceMachineRecipe irecipe : getRecipes()) { + arecipes.add(new CachedIORecipe(irecipe)); + } + } else { + super.loadCraftingRecipes(outputId, results); + } + } + + @Override + public void loadCraftingRecipes(ItemStack result) { + for (ChanceMachineRecipe irecipe : getRecipes()) { + if (irecipe.getOutput().hasPrimary() + && NEIServerUtils.areStacksSameTypeCrafting( + irecipe.getOutput().primaryOutput, result + )) { + arecipes.add(new CachedIORecipe(irecipe)); + } else if(irecipe.getOutput().hasSecondary() && NEIServerUtils.areStacksSameTypeCrafting(irecipe.getOutput().secondaryOutput, result)) { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - } - - @Override - public String getGuiTexture() - { - return "mekanism:gui/GuiBasicMachine.png"; - } + arecipes.add(new CachedIORecipe(irecipe)); + } + } + } - @Override - public void loadUsageRecipes(ItemStack ingredient) - { - for(ChanceMachineRecipe irecipe : getRecipes()) - { - if(NEIServerUtils.areStacksSameTypeCrafting((ItemStack)irecipe.getInput().ingredient, ingredient)) - { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - } + @Override + public String getGuiTexture() { + return "mekanism:gui/GuiBasicMachine.png"; + } - public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe - { - public PositionedStack input; - public ChanceOutput output; + @Override + public void loadUsageRecipes(ItemStack ingredient) { + for (ChanceMachineRecipe irecipe : getRecipes()) { + if (NEIServerUtils.areStacksSameTypeCrafting( + (ItemStack) irecipe.getInput().ingredient, ingredient + )) { + arecipes.add(new CachedIORecipe(irecipe)); + } + } + } - @Override - public PositionedStack getIngredient() - { - return input; - } + public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe { + public PositionedStack input; + public ChanceOutput output; - @Override - public PositionedStack getResult() - { - if(output.hasPrimary()) - { - return new PositionedStack(output.primaryOutput, 100, 30); - } + @Override + public PositionedStack getIngredient() { + return input; + } - return null; - } + @Override + public PositionedStack getResult() { + if (output.hasPrimary()) { + return new PositionedStack(output.primaryOutput, 100, 30); + } - @Override - public PositionedStack getOtherStack() - { - if(output.hasSecondary()) - { - return new PositionedStack(output.secondaryOutput, 116, 30); - } + return null; + } - return null; - } + @Override + public PositionedStack getOtherStack() { + if (output.hasSecondary()) { + return new PositionedStack(output.secondaryOutput, 116, 30); + } - public CachedIORecipe(ItemStack itemstack, ChanceOutput chance) - { - input = new PositionedStack(itemstack, 40, 12); - output = chance; - } + return null; + } - public CachedIORecipe(ChanceMachineRecipe recipe) - { - this(recipe.getInput().ingredient, recipe.getOutput()); - } - } + public CachedIORecipe(ItemStack itemstack, ChanceOutput chance) { + input = new PositionedStack(itemstack, 40, 12); + output = chance; + } + + public CachedIORecipe(ChanceMachineRecipe recipe) { + this(recipe.getInput().ingredient, recipe.getOutput()); + } + } } diff --git a/src/main/java/mekanism/client/nei/ChemicalCrystallizerRecipeHandler.java b/src/main/java/mekanism/client/nei/ChemicalCrystallizerRecipeHandler.java index 72821cc56..df68d65d9 100644 --- a/src/main/java/mekanism/client/nei/ChemicalCrystallizerRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/ChemicalCrystallizerRecipeHandler.java @@ -8,6 +8,12 @@ import java.awt.Rectangle; import java.util.Collection; import java.util.List; +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.NEIClientConfig; +import codechicken.nei.NEIServerUtils; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.GuiRecipe; +import codechicken.nei.recipe.TemplateRecipeHandler; import mekanism.api.gas.GasStack; import mekanism.client.gui.GuiChemicalCrystallizer; import mekanism.common.ObfuscatedNames; @@ -17,258 +23,226 @@ import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.item.ItemStack; - import org.lwjgl.opengl.GL11; -import codechicken.lib.gui.GuiDraw; -import codechicken.nei.NEIClientConfig; -import codechicken.nei.NEIServerUtils; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.GuiRecipe; -import codechicken.nei.recipe.TemplateRecipeHandler; +public class ChemicalCrystallizerRecipeHandler extends BaseRecipeHandler { + private int ticksPassed; -public class ChemicalCrystallizerRecipeHandler extends BaseRecipeHandler -{ - private int ticksPassed; + public static int xOffset = 5; + public static int yOffset = 3; - public static int xOffset = 5; - public static int yOffset = 3; + @Override + public String getRecipeName() { + return LangUtils.localize("tile.MachineBlock2.ChemicalCrystallizer.name"); + } - @Override - public String getRecipeName() - { - return LangUtils.localize("tile.MachineBlock2.ChemicalCrystallizer.name"); - } + @Override + public String getOverlayIdentifier() { + return "chemicalcrystallizer"; + } - @Override - public String getOverlayIdentifier() - { - return "chemicalcrystallizer"; - } + @Override + public String getGuiTexture() { + return "mekanism:gui/nei/GuiChemicalCrystallizer.png"; + } - @Override - public String getGuiTexture() - { - return "mekanism:gui/nei/GuiChemicalCrystallizer.png"; - } + @Override + public Class getGuiClass() { + return GuiChemicalCrystallizer.class; + } - @Override - public Class getGuiClass() - { - return GuiChemicalCrystallizer.class; - } + public String getRecipeId() { + return "mekanism.chemicalcrystallizer"; + } - public String getRecipeId() - { - return "mekanism.chemicalcrystallizer"; - } + public Collection getRecipes() { + return Recipe.CHEMICAL_CRYSTALLIZER.get().values(); + } - public Collection getRecipes() - { - return Recipe.CHEMICAL_CRYSTALLIZER.get().values(); - } + @Override + public void drawBackground(int i) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + changeTexture(getGuiTexture()); + drawTexturedModalRect(-2, 0, 3, yOffset, 147, 79); + } - @Override - public void drawBackground(int i) - { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - changeTexture(getGuiTexture()); - drawTexturedModalRect(-2, 0, 3, yOffset, 147, 79); - } + @Override + public void drawExtras(int i) { + GasStack gas = ((CachedIORecipe) arecipes.get(i)).inputStack; - @Override - public void drawExtras(int i) - { - GasStack gas = ((CachedIORecipe)arecipes.get(i)).inputStack; + float f = ticksPassed % 20 / 20.0F; + drawProgressBar(53 - xOffset, 61 - yOffset, 176, 63, 48, 8, f, 0); - float f = ticksPassed % 20 / 20.0F; - drawProgressBar(53-xOffset, 61-yOffset, 176, 63, 48, 8, f, 0); + if (gas != null) { + displayGauge(58, 6 - xOffset, 5 - yOffset, 176, 4, 58, null, gas); + } + } - if(gas != null) - { - displayGauge(58, 6-xOffset, 5-yOffset, 176, 4, 58, null, gas); - } - } + @Override + public void onUpdate() { + super.onUpdate(); - @Override - public void onUpdate() - { - super.onUpdate(); + ticksPassed++; + } - ticksPassed++; - } + @Override + public void loadTransferRects() { + transferRects.add(new TemplateRecipeHandler.RecipeTransferRect( + new Rectangle(53 - xOffset, 61 - yOffset, 48, 8), getRecipeId(), new Object[0] + )); + } - @Override - public void loadTransferRects() - { - transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(53-xOffset, 61-yOffset, 48, 8), getRecipeId(), new Object[0])); - } + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals(getRecipeId())) { + for (CrystallizerRecipe irecipe : getRecipes()) { + arecipes.add(new CachedIORecipe(irecipe)); + } + } else { + super.loadCraftingRecipes(outputId, results); + } + } - @Override - public void loadCraftingRecipes(String outputId, Object... results) - { - if(outputId.equals(getRecipeId())) - { - for(CrystallizerRecipe irecipe : getRecipes()) - { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - else { - super.loadCraftingRecipes(outputId, results); - } - } + @Override + public void loadCraftingRecipes(ItemStack result) { + for (CrystallizerRecipe irecipe : getRecipes()) { + if (NEIServerUtils.areStacksSameTypeCrafting( + irecipe.getOutput().output, result + )) { + arecipes.add(new CachedIORecipe(irecipe)); + } + } + } - @Override - public void loadCraftingRecipes(ItemStack result) - { - for(CrystallizerRecipe irecipe : getRecipes()) - { - if(NEIServerUtils.areStacksSameTypeCrafting(irecipe.getOutput().output, result)) - { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - } + @Override + public List + handleTooltip(GuiRecipe gui, List currenttip, int recipe) { + Point point = GuiDraw.getMousePosition(); - @Override - public List handleTooltip(GuiRecipe gui, List currenttip, int recipe) - { - Point point = GuiDraw.getMousePosition(); + int xAxis = point.x + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft + ); + int yAxis = point.y + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop + ); - int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); - int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); + if (xAxis >= 6 && xAxis <= 22 && yAxis >= 5 + 13 && yAxis <= 63 + 13) { + currenttip.add(LangUtils.localizeGasStack( + ((CachedIORecipe) arecipes.get(recipe)).inputStack + )); + } - if(xAxis >= 6 && xAxis <= 22 && yAxis >= 5+13 && yAxis <= 63+13) - { - currenttip.add(LangUtils.localizeGasStack(((CachedIORecipe)arecipes.get(recipe)).inputStack)); - } + return super.handleTooltip(gui, currenttip, recipe); + } - return super.handleTooltip(gui, currenttip, recipe); - } + @Override + public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) { + Point point = GuiDraw.getMousePosition(); - @Override - public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) - { - Point point = GuiDraw.getMousePosition(); + int xAxis = point.x + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft + ); + int yAxis = point.y + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop + ); - int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); - int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); + GasStack stack = null; - GasStack stack = null; + if (xAxis >= 6 && xAxis <= 22 && yAxis >= 5 + 13 && yAxis <= 63 + 13) { + stack = ((CachedIORecipe) arecipes.get(recipe)).inputStack; + } - if(xAxis >= 6 && xAxis <= 22 && yAxis >= 5+13 && yAxis <= 63+13) - { - stack = ((CachedIORecipe)arecipes.get(recipe)).inputStack; - } + if (stack != null) { + if (keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) { + if (doGasLookup(stack, false)) { + return true; + } + } else if (keyCode == NEIClientConfig.getKeyBinding("gui.usage")) { + if (doGasLookup(stack, true)) { + return true; + } + } + } - if(stack != null) - { - if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) - { - if(doGasLookup(stack, false)) - { - return true; - } - } - else if(keyCode == NEIClientConfig.getKeyBinding("gui.usage")) - { - if(doGasLookup(stack, true)) - { - return true; - } - } - } + return super.keyTyped(gui, keyChar, keyCode, recipe); + } - return super.keyTyped(gui, keyChar, keyCode, recipe); - } + @Override + public boolean mouseClicked(GuiRecipe gui, int button, int recipe) { + Point point = GuiDraw.getMousePosition(); - @Override - public boolean mouseClicked(GuiRecipe gui, int button, int recipe) - { - Point point = GuiDraw.getMousePosition(); + int xAxis = point.x + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft + ); + int yAxis = point.y + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop + ); - int xAxis = point.x - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); - int yAxis = point.y - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); + GasStack stack = null; - GasStack stack = null; + if (xAxis >= 6 && xAxis <= 22 && yAxis >= 5 + 13 && yAxis <= 63 + 13) { + stack = ((CachedIORecipe) arecipes.get(recipe)).inputStack; + } - if(xAxis >= 6 && xAxis <= 22 && yAxis >= 5+13 && yAxis <= 63+13) - { - stack = ((CachedIORecipe)arecipes.get(recipe)).inputStack; - } + if (stack != null) { + if (button == 0) { + if (doGasLookup(stack, false)) { + return true; + } + } else if (button == 1) { + if (doGasLookup(stack, true)) { + return true; + } + } + } - if(stack != null) - { - if(button == 0) - { - if(doGasLookup(stack, false)) - { - return true; - } - } - else if(button == 1) - { - if(doGasLookup(stack, true)) - { - return true; - } - } - } + return super.mouseClicked(gui, button, recipe); + } - return super.mouseClicked(gui, button, recipe); - } + @Override + public int recipiesPerPage() { + return 1; + } - @Override - public int recipiesPerPage() - { - return 1; - } + @Override + public void loadUsageRecipes(String inputId, Object... ingredients) { + if (inputId.equals("gas") && ingredients.length == 1 + && ingredients[0] instanceof GasStack) { + for (CrystallizerRecipe irecipe : getRecipes()) { + if (irecipe.getInput().ingredient.isGasEqual((GasStack) ingredients[0])) { + arecipes.add(new CachedIORecipe(irecipe)); + } + } + } else { + super.loadUsageRecipes(inputId, ingredients); + } + } - @Override - public void loadUsageRecipes(String inputId, Object... ingredients) - { - if(inputId.equals("gas") && ingredients.length == 1 && ingredients[0] instanceof GasStack) - { - for(CrystallizerRecipe irecipe : getRecipes()) - { - if(irecipe.getInput().ingredient.isGasEqual((GasStack)ingredients[0])) - { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - } - else { - super.loadUsageRecipes(inputId, ingredients); - } - } + @Override + public void addGuiElements() {} - @Override - public void addGuiElements() - { + public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe { + public GasStack inputStack; + public PositionedStack outputStack; - } + @Override + public PositionedStack getResult() { + return outputStack; + } - public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe - { - public GasStack inputStack; - public PositionedStack outputStack; + public CachedIORecipe(GasStack input, ItemStack output) { + inputStack = input; + outputStack = new PositionedStack(output, 131 - xOffset, 57 - yOffset); + } - @Override - public PositionedStack getResult() - { - return outputStack; - } - - public CachedIORecipe(GasStack input, ItemStack output) - { - inputStack = input; - outputStack = new PositionedStack(output, 131-xOffset, 57-yOffset); - } - - public CachedIORecipe(CrystallizerRecipe recipe) - { - this(recipe.getInput().ingredient, recipe.getOutput().output); - } - } + public CachedIORecipe(CrystallizerRecipe recipe) { + this(recipe.getInput().ingredient, recipe.getOutput().output); + } + } } diff --git a/src/main/java/mekanism/client/nei/ChemicalDissolutionChamberRecipeHandler.java b/src/main/java/mekanism/client/nei/ChemicalDissolutionChamberRecipeHandler.java index 2dc3b302f..ee0440471 100644 --- a/src/main/java/mekanism/client/nei/ChemicalDissolutionChamberRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/ChemicalDissolutionChamberRecipeHandler.java @@ -8,6 +8,12 @@ import java.awt.Rectangle; import java.util.Collection; import java.util.List; +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.NEIClientConfig; +import codechicken.nei.NEIServerUtils; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.GuiRecipe; +import codechicken.nei.recipe.TemplateRecipeHandler; import mekanism.api.gas.GasRegistry; import mekanism.api.gas.GasStack; import mekanism.client.gui.GuiChemicalDissolutionChamber; @@ -18,270 +24,240 @@ import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.item.ItemStack; - import org.lwjgl.opengl.GL11; -import codechicken.lib.gui.GuiDraw; -import codechicken.nei.NEIClientConfig; -import codechicken.nei.NEIServerUtils; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.GuiRecipe; -import codechicken.nei.recipe.TemplateRecipeHandler; +public class ChemicalDissolutionChamberRecipeHandler extends BaseRecipeHandler { + private int ticksPassed; -public class ChemicalDissolutionChamberRecipeHandler extends BaseRecipeHandler -{ - private int ticksPassed; + public static int xOffset = 5; + public static int yOffset = 3; - public static int xOffset = 5; - public static int yOffset = 3; + @Override + public String getRecipeName() { + return LangUtils.localize("gui.chemicalDissolutionChamber.short"); + } - @Override - public String getRecipeName() - { - return LangUtils.localize("gui.chemicalDissolutionChamber.short"); - } + @Override + public String getOverlayIdentifier() { + return "chemicaldissolutionchamber"; + } - @Override - public String getOverlayIdentifier() - { - return "chemicaldissolutionchamber"; - } + @Override + public String getGuiTexture() { + return "mekanism:gui/nei/GuiChemicalDissolutionChamber.png"; + } - @Override - public String getGuiTexture() - { - return "mekanism:gui/nei/GuiChemicalDissolutionChamber.png"; - } + @Override + public Class getGuiClass() { + return GuiChemicalDissolutionChamber.class; + } - @Override - public Class getGuiClass() - { - return GuiChemicalDissolutionChamber.class; - } + public String getRecipeId() { + return "mekanism.chemicaldissolutionchamber"; + } - public String getRecipeId() - { - return "mekanism.chemicaldissolutionchamber"; - } + public Collection getRecipes() { + return Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get().values(); + } - public Collection getRecipes() - { - return Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get().values(); - } + @Override + public void drawBackground(int i) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + changeTexture(getGuiTexture()); + drawTexturedModalRect(-2, 0, 3, yOffset, 170, 79); + } - @Override - public void drawBackground(int i) - { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - changeTexture(getGuiTexture()); - drawTexturedModalRect(-2, 0, 3, yOffset, 170, 79); - } + @Override + public void drawExtras(int i) { + GasStack gas = ((CachedIORecipe) arecipes.get(i)).outputStack; - @Override - public void drawExtras(int i) - { - GasStack gas = ((CachedIORecipe)arecipes.get(i)).outputStack; + float f = ticksPassed % 20 / 20.0F; + drawProgressBar(64 - xOffset, 40 - yOffset, 176, 63, 48, 8, f, 0); - float f = ticksPassed % 20 / 20.0F; - drawProgressBar(64-xOffset, 40-yOffset, 176, 63, 48, 8, f, 0); + displayGauge( + 58, + 6 - xOffset, + 5 - yOffset, + 176, + 4, + 58, + null, + new GasStack(GasRegistry.getGas("sulfuricAcid"), 1) + ); - displayGauge(58, 6-xOffset, 5-yOffset, 176, 4, 58, null, new GasStack(GasRegistry.getGas("sulfuricAcid"), 1)); + if (gas != null) { + displayGauge(58, 134 - xOffset, 14 - yOffset, 176, 4, 58, null, gas); + } + } - if(gas != null) - { - displayGauge(58, 134-xOffset, 14-yOffset, 176, 4, 58, null, gas); - } - } + @Override + public void onUpdate() { + super.onUpdate(); - @Override - public void onUpdate() - { - super.onUpdate(); + ticksPassed++; + } - ticksPassed++; - } + @Override + public void loadTransferRects() { + transferRects.add(new TemplateRecipeHandler.RecipeTransferRect( + new Rectangle(64 - xOffset, 40 - yOffset, 48, 8), getRecipeId(), new Object[0] + )); + } - @Override - public void loadTransferRects() - { - transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(64-xOffset, 40-yOffset, 48, 8), getRecipeId(), new Object[0])); - } + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals(getRecipeId())) { + for (DissolutionRecipe irecipe : getRecipes()) { + arecipes.add(new CachedIORecipe(irecipe)); + } + } else if (outputId.equals("gas") && results.length == 1 && results[0] instanceof GasStack) { + for (DissolutionRecipe irecipe : getRecipes()) { + if (((GasStack) results[0]).isGasEqual(irecipe.getOutput().output)) { + arecipes.add(new CachedIORecipe(irecipe)); + } + } + } else { + super.loadCraftingRecipes(outputId, results); + } + } - @Override - public void loadCraftingRecipes(String outputId, Object... results) - { - if(outputId.equals(getRecipeId())) - { - for(DissolutionRecipe irecipe : getRecipes()) - { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - else if(outputId.equals("gas") && results.length == 1 && results[0] instanceof GasStack) - { - for(DissolutionRecipe irecipe : getRecipes()) - { - if(((GasStack)results[0]).isGasEqual(irecipe.getOutput().output)) - { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - } - else { - super.loadCraftingRecipes(outputId, results); - } - } + @Override + public List + handleTooltip(GuiRecipe gui, List currenttip, int recipe) { + Point point = GuiDraw.getMousePosition(); - @Override - public List handleTooltip(GuiRecipe gui, List currenttip, int recipe) - { - Point point = GuiDraw.getMousePosition(); + int xAxis = point.x + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft + ); + int yAxis = point.y + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop + ); - int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); - int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); + if (xAxis >= 6 && xAxis <= 22 && yAxis >= 5 + 13 && yAxis <= 63 + 13) { + currenttip.add(GasRegistry.getGas("sulfuricAcid").getLocalizedName()); + } else if (xAxis >= 134 && xAxis <= 150 && yAxis >= 14 + 4 && yAxis <= 72 + 4) { + currenttip.add(LangUtils.localizeGasStack( + ((CachedIORecipe) arecipes.get(recipe)).outputStack + )); + } - if(xAxis >= 6 && xAxis <= 22 && yAxis >= 5+13 && yAxis <= 63+13) - { - currenttip.add(GasRegistry.getGas("sulfuricAcid").getLocalizedName()); - } - else if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14+4 && yAxis <= 72+4) - { - currenttip.add(LangUtils.localizeGasStack(((CachedIORecipe)arecipes.get(recipe)).outputStack)); - } + return super.handleTooltip(gui, currenttip, recipe); + } - return super.handleTooltip(gui, currenttip, recipe); - } + @Override + public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) { + Point point = GuiDraw.getMousePosition(); - @Override - public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) - { - Point point = GuiDraw.getMousePosition(); + int xAxis = point.x + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft + ); + int yAxis = point.y + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop + ); - int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); - int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); + GasStack stack = null; - GasStack stack = null; + if (xAxis >= 6 && xAxis <= 22 && yAxis >= 5 + 13 && yAxis <= 63 + 13) { + stack = new GasStack(GasRegistry.getGas("sulfuricAcid"), 1); + } else if (xAxis >= 134 && xAxis <= 150 && yAxis >= 14 + 4 && yAxis <= 72 + 4) { + stack = ((CachedIORecipe) arecipes.get(recipe)).outputStack; + } - if(xAxis >= 6 && xAxis <= 22 && yAxis >= 5+13 && yAxis <= 63+13) - { - stack = new GasStack(GasRegistry.getGas("sulfuricAcid"), 1); - } - else if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14+4 && yAxis <= 72+4) - { - stack = ((CachedIORecipe)arecipes.get(recipe)).outputStack; - } + if (stack != null) { + if (keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) { + if (doGasLookup(stack, false)) { + return true; + } + } else if (keyCode == NEIClientConfig.getKeyBinding("gui.usage")) { + if (doGasLookup(stack, true)) { + return true; + } + } + } - if(stack != null) - { - if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) - { - if(doGasLookup(stack, false)) - { - return true; - } - } - else if(keyCode == NEIClientConfig.getKeyBinding("gui.usage")) - { - if(doGasLookup(stack, true)) - { - return true; - } - } - } + return super.keyTyped(gui, keyChar, keyCode, recipe); + } - return super.keyTyped(gui, keyChar, keyCode, recipe); - } + @Override + public boolean mouseClicked(GuiRecipe gui, int button, int recipe) { + Point point = GuiDraw.getMousePosition(); - @Override - public boolean mouseClicked(GuiRecipe gui, int button, int recipe) - { - Point point = GuiDraw.getMousePosition(); + int xAxis = point.x + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft + ); + int yAxis = point.y + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop + ); - int xAxis = point.x - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); - int yAxis = point.y - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); + GasStack stack = null; - GasStack stack = null; + if (xAxis >= 6 && xAxis <= 22 && yAxis >= 5 + 13 && yAxis <= 63 + 13) { + stack = new GasStack(GasRegistry.getGas("sulfuricAcid"), 1); + } else if (xAxis >= 134 && xAxis <= 150 && yAxis >= 14 + 4 && yAxis <= 72 + 4) { + stack = ((CachedIORecipe) arecipes.get(recipe)).outputStack; + } - if(xAxis >= 6 && xAxis <= 22 && yAxis >= 5+13 && yAxis <= 63+13) - { - stack = new GasStack(GasRegistry.getGas("sulfuricAcid"), 1); - } - else if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14+4 && yAxis <= 72+4) - { - stack = ((CachedIORecipe)arecipes.get(recipe)).outputStack; - } + if (stack != null) { + if (button == 0) { + if (doGasLookup(stack, false)) { + return true; + } + } else if (button == 1) { + if (doGasLookup(stack, true)) { + return true; + } + } + } - if(stack != null) - { - if(button == 0) - { - if(doGasLookup(stack, false)) - { - return true; - } - } - else if(button == 1) - { - if(doGasLookup(stack, true)) - { - return true; - } - } - } + return super.mouseClicked(gui, button, recipe); + } - return super.mouseClicked(gui, button, recipe); - } + @Override + public int recipiesPerPage() { + return 1; + } - @Override - public int recipiesPerPage() - { - return 1; - } + @Override + public void loadUsageRecipes(ItemStack ingredient) { + for (DissolutionRecipe irecipe : getRecipes()) { + if (NEIServerUtils.areStacksSameTypeCrafting( + (ItemStack) irecipe.getInput().ingredient, ingredient + )) { + arecipes.add(new CachedIORecipe(irecipe)); + } + } + } - @Override - public void loadUsageRecipes(ItemStack ingredient) - { - for(DissolutionRecipe irecipe : getRecipes()) - { - if(NEIServerUtils.areStacksSameTypeCrafting((ItemStack)irecipe.getInput().ingredient, ingredient)) - { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - } + @Override + public void addGuiElements() {} - @Override - public void addGuiElements() - { + public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe { + public PositionedStack inputStack; + public GasStack outputStack; - } + @Override + public PositionedStack getIngredient() { + return inputStack; + } - public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe - { - public PositionedStack inputStack; - public GasStack outputStack; + @Override + public PositionedStack getResult() { + return null; + } - @Override - public PositionedStack getIngredient() - { - return inputStack; - } + public CachedIORecipe(ItemStack input, GasStack output) { + inputStack = new PositionedStack(input, 26 - xOffset, 36 - yOffset); + outputStack = output; + } - @Override - public PositionedStack getResult() - { - return null; - } - - public CachedIORecipe(ItemStack input, GasStack output) - { - inputStack = new PositionedStack(input, 26-xOffset, 36-yOffset); - outputStack = output; - } - - public CachedIORecipe(DissolutionRecipe recipe) - { - this(recipe.getInput().ingredient, recipe.getOutput().output); - } - } + public CachedIORecipe(DissolutionRecipe recipe) { + this(recipe.getInput().ingredient, recipe.getOutput().output); + } + } } diff --git a/src/main/java/mekanism/client/nei/ChemicalInfuserRecipeHandler.java b/src/main/java/mekanism/client/nei/ChemicalInfuserRecipeHandler.java index f0040b32a..27df55ebe 100644 --- a/src/main/java/mekanism/client/nei/ChemicalInfuserRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/ChemicalInfuserRecipeHandler.java @@ -8,6 +8,11 @@ import java.awt.Rectangle; import java.util.Collection; import java.util.List; +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.NEIClientConfig; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.GuiRecipe; +import codechicken.nei.recipe.TemplateRecipeHandler; import mekanism.api.gas.GasStack; import mekanism.client.gui.GuiChemicalInfuser; import mekanism.common.ObfuscatedNames; @@ -17,290 +22,270 @@ import mekanism.common.recipe.machines.ChemicalInfuserRecipe; import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import net.minecraft.client.gui.inventory.GuiContainer; - import org.lwjgl.opengl.GL11; -import codechicken.lib.gui.GuiDraw; -import codechicken.nei.NEIClientConfig; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.GuiRecipe; -import codechicken.nei.recipe.TemplateRecipeHandler; +public class ChemicalInfuserRecipeHandler extends BaseRecipeHandler { + private int ticksPassed; -public class ChemicalInfuserRecipeHandler extends BaseRecipeHandler -{ - private int ticksPassed; + public static int xOffset = 5; + public static int yOffset = 3; - public static int xOffset = 5; - public static int yOffset = 3; + @Override + public String getRecipeName() { + return LangUtils.localize("tile.MachineBlock2.ChemicalInfuser.name"); + } - @Override - public String getRecipeName() - { - return LangUtils.localize("tile.MachineBlock2.ChemicalInfuser.name"); - } + @Override + public String getOverlayIdentifier() { + return "chemicalinfuser"; + } - @Override - public String getOverlayIdentifier() - { - return "chemicalinfuser"; - } + @Override + public String getGuiTexture() { + return "mekanism:gui/nei/GuiChemicalInfuser.png"; + } - @Override - public String getGuiTexture() - { - return "mekanism:gui/nei/GuiChemicalInfuser.png"; - } + @Override + public Class getGuiClass() { + return GuiChemicalInfuser.class; + } - @Override - public Class getGuiClass() - { - return GuiChemicalInfuser.class; - } + public String getRecipeId() { + return "mekanism.chemicalinfuser"; + } - public String getRecipeId() - { - return "mekanism.chemicalinfuser"; - } + public Collection getRecipes() { + return Recipe.CHEMICAL_INFUSER.get().values(); + } - public Collection getRecipes() - { - return Recipe.CHEMICAL_INFUSER.get().values(); - } + @Override + public void drawBackground(int i) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + changeTexture(getGuiTexture()); + drawTexturedModalRect(-2, 0, 3, yOffset, 170, 80); + } - @Override - public void drawBackground(int i) - { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - changeTexture(getGuiTexture()); - drawTexturedModalRect(-2, 0, 3, yOffset, 170, 80); - } + @Override + public void drawExtras(int i) { + CachedIORecipe recipe = (CachedIORecipe) arecipes.get(i); - @Override - public void drawExtras(int i) - { - CachedIORecipe recipe = (CachedIORecipe)arecipes.get(i); + drawTexturedModalRect(47 - xOffset, 39 - yOffset, 176, 71, 28, 8); + drawTexturedModalRect(101 - xOffset, 39 - yOffset, 176, 63, 28, 8); - drawTexturedModalRect(47-xOffset, 39-yOffset, 176, 71, 28, 8); - drawTexturedModalRect(101-xOffset, 39-yOffset, 176, 63, 28, 8); + if (recipe.chemicalInput.leftGas != null) { + displayGauge( + 58, + 26 - xOffset, + 14 - yOffset, + 176, + 4, + 58, + null, + recipe.chemicalInput.leftGas + ); + } - if(recipe.chemicalInput.leftGas != null) - { - displayGauge(58, 26-xOffset, 14-yOffset, 176, 4, 58, null, recipe.chemicalInput.leftGas); - } + if (recipe.outputStack != null) { + displayGauge( + 58, 80 - xOffset, 5 - yOffset, 176, 4, 58, null, recipe.outputStack + ); + } - if(recipe.outputStack != null) - { - displayGauge(58, 80-xOffset, 5-yOffset, 176, 4, 58, null, recipe.outputStack); - } + if (recipe.chemicalInput.rightGas != null) { + displayGauge( + 58, + 134 - xOffset, + 14 - yOffset, + 176, + 4, + 58, + null, + recipe.chemicalInput.rightGas + ); + } + } - if(recipe.chemicalInput.rightGas != null) - { - displayGauge(58, 134-xOffset, 14-yOffset, 176, 4, 58, null, recipe.chemicalInput.rightGas); - } - } + @Override + public void onUpdate() { + super.onUpdate(); - @Override - public void onUpdate() - { - super.onUpdate(); + ticksPassed++; + } - ticksPassed++; - } + @Override + public void loadTransferRects() { + transferRects.add(new TemplateRecipeHandler.RecipeTransferRect( + new Rectangle(47 - xOffset, 39 - yOffset, 28, 8), getRecipeId(), new Object[0] + )); + transferRects.add(new TemplateRecipeHandler.RecipeTransferRect( + new Rectangle(101 - xOffset, 39 - yOffset, 28, 8), + getRecipeId(), + new Object[0] + )); + } - @Override - public void loadTransferRects() - { - transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(47-xOffset, 39-yOffset, 28, 8), getRecipeId(), new Object[0])); - transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(101-xOffset, 39-yOffset, 28, 8), getRecipeId(), new Object[0])); - } + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals(getRecipeId())) { + for (ChemicalInfuserRecipe irecipe : getRecipes()) { + arecipes.add(new CachedIORecipe(irecipe)); + } + } else if (outputId.equals("gas") && results.length == 1 && results[0] instanceof GasStack) { + for (ChemicalInfuserRecipe irecipe : getRecipes()) { + if (((GasStack) results[0]).isGasEqual(irecipe.getOutput().output)) { + arecipes.add(new CachedIORecipe(irecipe)); + } + } + } else { + super.loadCraftingRecipes(outputId, results); + } + } - @Override - public void loadCraftingRecipes(String outputId, Object... results) - { - if(outputId.equals(getRecipeId())) - { - for(ChemicalInfuserRecipe irecipe : getRecipes()) - { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - else if(outputId.equals("gas") && results.length == 1 && results[0] instanceof GasStack) - { - for(ChemicalInfuserRecipe irecipe : getRecipes()) - { - if(((GasStack)results[0]).isGasEqual(irecipe.getOutput().output)) - { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - } - else { - super.loadCraftingRecipes(outputId, results); - } - } + @Override + public void loadUsageRecipes(String inputId, Object... ingredients) { + if (inputId.equals("gas") && ingredients.length == 1 + && ingredients[0] instanceof GasStack) { + for (ChemicalInfuserRecipe irecipe : getRecipes()) { + if (irecipe.getInput().containsType((GasStack) ingredients[0])) { + arecipes.add(new CachedIORecipe(irecipe)); + } + } + } else { + super.loadUsageRecipes(inputId, ingredients); + } + } - @Override - public void loadUsageRecipes(String inputId, Object... ingredients) - { - if(inputId.equals("gas") && ingredients.length == 1 && ingredients[0] instanceof GasStack) - { - for(ChemicalInfuserRecipe irecipe : getRecipes()) - { - if(irecipe.getInput().containsType((GasStack)ingredients[0])) - { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - } - else { - super.loadUsageRecipes(inputId, ingredients); - } - } + @Override + public List + handleTooltip(GuiRecipe gui, List currenttip, int recipe) { + Point point = GuiDraw.getMousePosition(); - @Override - public List handleTooltip(GuiRecipe gui, List currenttip, int recipe) - { - Point point = GuiDraw.getMousePosition(); + int xAxis = point.x + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft + ); + int yAxis = point.y + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop + ); - int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); - int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); + if (xAxis >= 26 && xAxis <= 42 && yAxis >= 14 + 13 && yAxis <= 72 + 13) { + currenttip.add(LangUtils.localizeGasStack( + ((CachedIORecipe) arecipes.get(recipe)).chemicalInput.leftGas + )); + } else if (xAxis >= 80 && xAxis <= 96 && yAxis >= 5 + 13 && yAxis <= 63 + 13) { + currenttip.add(LangUtils.localizeGasStack( + ((CachedIORecipe) arecipes.get(recipe)).outputStack + )); + } else if (xAxis >= 134 && xAxis <= 150 && yAxis >= 14 + 13 && yAxis <= 72 + 13) { + currenttip.add(LangUtils.localizeGasStack( + ((CachedIORecipe) arecipes.get(recipe)).chemicalInput.rightGas + )); + } - if(xAxis >= 26 && xAxis <= 42 && yAxis >= 14+13 && yAxis <= 72+13) - { - currenttip.add(LangUtils.localizeGasStack(((CachedIORecipe)arecipes.get(recipe)).chemicalInput.leftGas)); - } - else if(xAxis >= 80 && xAxis <= 96 && yAxis >= 5+13 && yAxis <= 63+13) - { - currenttip.add(LangUtils.localizeGasStack(((CachedIORecipe)arecipes.get(recipe)).outputStack)); - } - else if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14+13 && yAxis <= 72+13) - { - currenttip.add(LangUtils.localizeGasStack(((CachedIORecipe)arecipes.get(recipe)).chemicalInput.rightGas)); - } + return super.handleTooltip(gui, currenttip, recipe); + } - return super.handleTooltip(gui, currenttip, recipe); - } + @Override + public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) { + Point point = GuiDraw.getMousePosition(); - @Override - public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) - { - Point point = GuiDraw.getMousePosition(); + int xAxis = point.x + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft + ); + int yAxis = point.y + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop + ); - int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); - int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); + GasStack stack = null; - GasStack stack = null; + if (xAxis >= 26 && xAxis <= 42 && yAxis >= 14 + 13 && yAxis <= 72 + 13) { + stack = ((CachedIORecipe) arecipes.get(recipe)).chemicalInput.leftGas; + } else if (xAxis >= 80 && xAxis <= 96 && yAxis >= 5 + 13 && yAxis <= 63 + 13) { + stack = ((CachedIORecipe) arecipes.get(recipe)).outputStack; + } else if (xAxis >= 134 && xAxis <= 150 && yAxis >= 14 + 13 && yAxis <= 72 + 13) { + stack = ((CachedIORecipe) arecipes.get(recipe)).chemicalInput.rightGas; + } - if(xAxis >= 26 && xAxis <= 42 && yAxis >= 14+13 && yAxis <= 72+13) - { - stack = ((CachedIORecipe)arecipes.get(recipe)).chemicalInput.leftGas; - } - else if(xAxis >= 80 && xAxis <= 96 && yAxis >= 5+13 && yAxis <= 63+13) - { - stack = ((CachedIORecipe)arecipes.get(recipe)).outputStack; - } - else if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14+13 && yAxis <= 72+13) - { - stack = ((CachedIORecipe)arecipes.get(recipe)).chemicalInput.rightGas; - } + if (stack != null) { + if (keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) { + if (doGasLookup(stack, false)) { + return true; + } + } else if (keyCode == NEIClientConfig.getKeyBinding("gui.usage")) { + if (doGasLookup(stack, true)) { + return true; + } + } + } - if(stack != null) - { - if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) - { - if(doGasLookup(stack, false)) - { - return true; - } - } - else if(keyCode == NEIClientConfig.getKeyBinding("gui.usage")) - { - if(doGasLookup(stack, true)) - { - return true; - } - } - } + return super.keyTyped(gui, keyChar, keyCode, recipe); + } - return super.keyTyped(gui, keyChar, keyCode, recipe); - } + @Override + public boolean mouseClicked(GuiRecipe gui, int button, int recipe) { + Point point = GuiDraw.getMousePosition(); - @Override - public boolean mouseClicked(GuiRecipe gui, int button, int recipe) - { - Point point = GuiDraw.getMousePosition(); + int xAxis = point.x + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft + ); + int yAxis = point.y + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop + ); - int xAxis = point.x - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); - int yAxis = point.y - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); + GasStack stack = null; - GasStack stack = null; + if (xAxis >= 26 && xAxis <= 42 && yAxis >= 14 + 13 && yAxis <= 72 + 13) { + stack = ((CachedIORecipe) arecipes.get(recipe)).chemicalInput.leftGas; + } else if (xAxis >= 80 && xAxis <= 96 && yAxis >= 5 + 13 && yAxis <= 63 + 13) { + stack = ((CachedIORecipe) arecipes.get(recipe)).outputStack; + } else if (xAxis >= 134 && xAxis <= 150 && yAxis >= 14 + 13 && yAxis <= 72 + 13) { + stack = ((CachedIORecipe) arecipes.get(recipe)).chemicalInput.rightGas; + } - if(xAxis >= 26 && xAxis <= 42 && yAxis >= 14+13 && yAxis <= 72+13) - { - stack = ((CachedIORecipe)arecipes.get(recipe)).chemicalInput.leftGas; - } - else if(xAxis >= 80 && xAxis <= 96 && yAxis >= 5+13 && yAxis <= 63+13) - { - stack = ((CachedIORecipe)arecipes.get(recipe)).outputStack; - } - else if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14+13 && yAxis <= 72+13) - { - stack = ((CachedIORecipe)arecipes.get(recipe)).chemicalInput.rightGas; - } + if (stack != null) { + if (button == 0) { + if (doGasLookup(stack, false)) { + return true; + } + } else if (button == 1) { + if (doGasLookup(stack, true)) { + return true; + } + } + } - if(stack != null) - { - if(button == 0) - { - if(doGasLookup(stack, false)) - { - return true; - } - } - else if(button == 1) - { - if(doGasLookup(stack, true)) - { - return true; - } - } - } + return super.mouseClicked(gui, button, recipe); + } - return super.mouseClicked(gui, button, recipe); - } + @Override + public int recipiesPerPage() { + return 1; + } - @Override - public int recipiesPerPage() - { - return 1; - } + @Override + public void addGuiElements() {} - @Override - public void addGuiElements() - { + public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe { + public ChemicalPairInput chemicalInput; + public GasStack outputStack; - } + @Override + public PositionedStack getResult() { + return null; + } - public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe - { - public ChemicalPairInput chemicalInput; - public GasStack outputStack; + public CachedIORecipe(ChemicalPairInput input, GasStack output) { + chemicalInput = input; + outputStack = output; + } - @Override - public PositionedStack getResult() - { - return null; - } - - public CachedIORecipe(ChemicalPairInput input, GasStack output) - { - chemicalInput = input; - outputStack = output; - } - - public CachedIORecipe(ChemicalInfuserRecipe recipe) - { - this(recipe.getInput(), recipe.getOutput().output); - } - } + public CachedIORecipe(ChemicalInfuserRecipe recipe) { + this(recipe.getInput(), recipe.getOutput().output); + } + } } diff --git a/src/main/java/mekanism/client/nei/ChemicalInjectionChamberRecipeHandler.java b/src/main/java/mekanism/client/nei/ChemicalInjectionChamberRecipeHandler.java index e94cb15cf..4047efe5c 100644 --- a/src/main/java/mekanism/client/nei/ChemicalInjectionChamberRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/ChemicalInjectionChamberRecipeHandler.java @@ -17,79 +17,69 @@ import mekanism.common.util.MekanismUtils; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; -public class ChemicalInjectionChamberRecipeHandler extends AdvancedMachineRecipeHandler -{ - @Override - public String getRecipeName() - { - return LangUtils.localize("nei.chemicalInjectionChamber"); - } +public class ChemicalInjectionChamberRecipeHandler extends AdvancedMachineRecipeHandler { + @Override + public String getRecipeName() { + return LangUtils.localize("nei.chemicalInjectionChamber"); + } - @Override - public String getRecipeId() - { - return "mekanism.chemicalinjectionchamber"; - } + @Override + public String getRecipeId() { + return "mekanism.chemicalinjectionchamber"; + } - @Override - public String getOverlayIdentifier() - { - return "chemicalinjectionchamber"; - } + @Override + public String getOverlayIdentifier() { + return "chemicalinjectionchamber"; + } - @Override - public Collection getRecipes() - { - return Recipe.CHEMICAL_INJECTION_CHAMBER.get().values(); - } + @Override + public Collection getRecipes() { + return Recipe.CHEMICAL_INJECTION_CHAMBER.get().values(); + } - @Override - public List getFuelStacks(Gas gasType) - { - if(gasType == GasRegistry.getGas("sulfuricAcid")) - { - List fuels = new ArrayList(); - fuels.addAll(OreDictionary.getOres("dustSulfur")); + @Override + public List getFuelStacks(Gas gasType) { + if (gasType == GasRegistry.getGas("sulfuricAcid")) { + List fuels = new ArrayList(); + fuels.addAll(OreDictionary.getOres("dustSulfur")); - for(GasTankTier tier : GasTankTier.values()) - { - fuels.add(MekanismUtils.getFullGasTank(tier, GasRegistry.getGas("sulfuricAcid"))); - } - - return fuels; - } - else if(gasType == GasRegistry.getGas("water")) - { - for(GasTankTier tier : GasTankTier.values()) - { - return ListUtils.asList(MekanismUtils.getFullGasTank(tier, GasRegistry.getGas("water"))); - } - } - else if(gasType == GasRegistry.getGas("hydrogenChloride")) - { - List fuels = new ArrayList(); - fuels.addAll(OreDictionary.getOres("dustSalt")); - - for(GasTankTier tier : GasTankTier.values()) - { - fuels.add(MekanismUtils.getFullGasTank(tier, GasRegistry.getGas("hydrogenChloride"))); - } - - return fuels; - } + for (GasTankTier tier : GasTankTier.values()) { + fuels.add( + MekanismUtils.getFullGasTank(tier, GasRegistry.getGas("sulfuricAcid")) + ); + } - return new ArrayList(); - } - - @Override - public ProgressBar getProgressType() - { - return ProgressBar.YELLOW; - } + return fuels; + } else if (gasType == GasRegistry.getGas("water")) { + for (GasTankTier tier : GasTankTier.values()) { + return ListUtils.asList( + MekanismUtils.getFullGasTank(tier, GasRegistry.getGas("water")) + ); + } + } else if (gasType == GasRegistry.getGas("hydrogenChloride")) { + List fuels = new ArrayList(); + fuels.addAll(OreDictionary.getOres("dustSalt")); - @Override - public Class getGuiClass() - { - return GuiChemicalInjectionChamber.class; - } + for (GasTankTier tier : GasTankTier.values()) { + fuels.add(MekanismUtils.getFullGasTank( + tier, GasRegistry.getGas("hydrogenChloride") + )); + } + + return fuels; + } + + return new ArrayList(); + } + + @Override + public ProgressBar getProgressType() { + return ProgressBar.YELLOW; + } + + @Override + public Class getGuiClass() { + return GuiChemicalInjectionChamber.class; + } } diff --git a/src/main/java/mekanism/client/nei/ChemicalOxidizerRecipeHandler.java b/src/main/java/mekanism/client/nei/ChemicalOxidizerRecipeHandler.java index 6f5b877c5..0ef9aeab9 100644 --- a/src/main/java/mekanism/client/nei/ChemicalOxidizerRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/ChemicalOxidizerRecipeHandler.java @@ -8,6 +8,12 @@ import java.awt.Rectangle; import java.util.Collection; import java.util.List; +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.NEIClientConfig; +import codechicken.nei.NEIServerUtils; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.GuiRecipe; +import codechicken.nei.recipe.TemplateRecipeHandler; import mekanism.api.gas.GasStack; import mekanism.client.gui.GuiChemicalOxidizer; import mekanism.client.gui.element.GuiElement; @@ -27,267 +33,283 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.item.ItemStack; - import org.lwjgl.opengl.GL11; -import codechicken.lib.gui.GuiDraw; -import codechicken.nei.NEIClientConfig; -import codechicken.nei.NEIServerUtils; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.GuiRecipe; -import codechicken.nei.recipe.TemplateRecipeHandler; +public class ChemicalOxidizerRecipeHandler extends BaseRecipeHandler { + private int ticksPassed; -public class ChemicalOxidizerRecipeHandler extends BaseRecipeHandler -{ - private int ticksPassed; - - public GuiGasGauge gasOutput; + public GuiGasGauge gasOutput; - public static int xOffset = 5; - public static int yOffset = 12; - - @Override - public void addGuiElements() - { - guiElements.add(gasOutput = GuiGasGauge.getDummy(GuiGauge.Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png"), 133, 13)); + public static int xOffset = 5; + public static int yOffset = 12; - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png"), 154, 4).with(SlotOverlay.POWER)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png"), 25, 35)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png"), 154, 24).with(SlotOverlay.PLUS)); + @Override + public void addGuiElements() { + guiElements.add( + gasOutput = GuiGasGauge.getDummy( + GuiGauge.Type.STANDARD, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png"), + 133, + 13 + ) + ); - guiElements.add(new GuiProgress(new IProgressInfoHandler() - { - @Override - public double getProgress() - { - return ticksPassed >= 20 ? (ticksPassed - 20) % 20 / 20.0F : 0.0F; - } - }, ProgressBar.LARGE_RIGHT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png"), 62, 39)); - } + guiElements.add( + new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png"), + 154, + 4 + ) + .with(SlotOverlay.POWER) + ); + guiElements.add(new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png"), + 25, + 35 + )); + guiElements.add( + new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png"), + 154, + 24 + ) + .with(SlotOverlay.PLUS) + ); - @Override - public String getRecipeName() - { - return LangUtils.localize("tile.MachineBlock2.ChemicalOxidizer.name"); - } + guiElements.add(new GuiProgress( + new IProgressInfoHandler() { + @Override + public double getProgress() { + return ticksPassed >= 20 ? (ticksPassed - 20) % 20 / 20.0F : 0.0F; + } + }, + ProgressBar.LARGE_RIGHT, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalOxidizer.png"), + 62, + 39 + )); + } - @Override - public String getOverlayIdentifier() - { - return "chemicaloxidizer"; - } + @Override + public String getRecipeName() { + return LangUtils.localize("tile.MachineBlock2.ChemicalOxidizer.name"); + } - @Override - public String getGuiTexture() - { - return "mekanism:gui/GuiChemicalOxidizer.png"; - } + @Override + public String getOverlayIdentifier() { + return "chemicaloxidizer"; + } - @Override - public Class getGuiClass() - { - return GuiChemicalOxidizer.class; - } + @Override + public String getGuiTexture() { + return "mekanism:gui/GuiChemicalOxidizer.png"; + } - public String getRecipeId() - { - return "mekanism.chemicaloxidizer"; - } + @Override + public Class getGuiClass() { + return GuiChemicalOxidizer.class; + } - public Collection getRecipes() - { - return Recipe.CHEMICAL_OXIDIZER.get().values(); - } + public String getRecipeId() { + return "mekanism.chemicaloxidizer"; + } - @Override - public void drawBackground(int i) - { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - changeTexture(getGuiTexture()); - drawTexturedModalRect(0, 0, xOffset, yOffset, 147, 62); - - for(GuiElement e : guiElements) - { - e.renderBackground(0, 0, -xOffset, -yOffset); - } - } + public Collection getRecipes() { + return Recipe.CHEMICAL_OXIDIZER.get().values(); + } - @Override - public void drawExtras(int i) - { - CachedIORecipe recipe = (CachedIORecipe)arecipes.get(i); + @Override + public void drawBackground(int i) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + changeTexture(getGuiTexture()); + drawTexturedModalRect(0, 0, xOffset, yOffset, 147, 62); - if(recipe.outputStack != null) - { - gasOutput.setDummyType(recipe.outputStack.getGas()); - gasOutput.renderScale(0, 0, -xOffset, -yOffset); - } - } + for (GuiElement e : guiElements) { + e.renderBackground(0, 0, -xOffset, -yOffset); + } + } - @Override - public void onUpdate() - { - super.onUpdate(); + @Override + public void drawExtras(int i) { + CachedIORecipe recipe = (CachedIORecipe) arecipes.get(i); - ticksPassed++; - } + if (recipe.outputStack != null) { + gasOutput.setDummyType(recipe.outputStack.getGas()); + gasOutput.renderScale(0, 0, -xOffset, -yOffset); + } + } - @Override - public void loadTransferRects() - { - transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(64-xOffset, 40-yOffset, 48, 8), getRecipeId(), new Object[0])); - } + @Override + public void onUpdate() { + super.onUpdate(); - @Override - public void loadCraftingRecipes(String outputId, Object... results) - { - if(outputId.equals(getRecipeId())) - { - for(OxidationRecipe irecipe : getRecipes()) - { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - else if(outputId.equals("gas") && results.length == 1 && results[0] instanceof GasStack) - { - for(OxidationRecipe irecipe : getRecipes()) - { - if(((GasStack)results[0]).isGasEqual(irecipe.getOutput().output)) - { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - } - else { - super.loadCraftingRecipes(outputId, results); - } - } + ticksPassed++; + } - @Override - public List handleTooltip(GuiRecipe gui, List currenttip, int recipe) - { - Point point = GuiDraw.getMousePosition(); - Point offset = gui.getRecipePosition(recipe); + @Override + public void loadTransferRects() { + transferRects.add(new TemplateRecipeHandler.RecipeTransferRect( + new Rectangle(64 - xOffset, 40 - yOffset, 48, 8), getRecipeId(), new Object[0] + )); + } - int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft)-offset.x; - int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop)-offset.y; + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals(getRecipeId())) { + for (OxidationRecipe irecipe : getRecipes()) { + arecipes.add(new CachedIORecipe(irecipe)); + } + } else if (outputId.equals("gas") && results.length == 1 && results[0] instanceof GasStack) { + for (OxidationRecipe irecipe : getRecipes()) { + if (((GasStack) results[0]).isGasEqual(irecipe.getOutput().output)) { + arecipes.add(new CachedIORecipe(irecipe)); + } + } + } else { + super.loadCraftingRecipes(outputId, results); + } + } - if(xAxis >= 134-5 && xAxis <= 150-5 && yAxis >= 14-11 && yAxis <= 72-11) - { - currenttip.add(LangUtils.localizeGasStack(((CachedIORecipe)arecipes.get(recipe)).outputStack)); - } + @Override + public List + handleTooltip(GuiRecipe gui, List currenttip, int recipe) { + Point point = GuiDraw.getMousePosition(); + Point offset = gui.getRecipePosition(recipe); - return super.handleTooltip(gui, currenttip, recipe); - } + int xAxis = point.x + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft + ) + - offset.x; + int yAxis = point.y + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop + ) + - offset.y; - @Override - public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) - { - Point point = GuiDraw.getMousePosition(); - Point offset = gui.getRecipePosition(recipe); + if (xAxis >= 134 - 5 && xAxis <= 150 - 5 && yAxis >= 14 - 11 + && yAxis <= 72 - 11) { + currenttip.add(LangUtils.localizeGasStack( + ((CachedIORecipe) arecipes.get(recipe)).outputStack + )); + } - int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft)-offset.x; - int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop)-offset.y; + return super.handleTooltip(gui, currenttip, recipe); + } - if(xAxis >= 134-5 && xAxis <= 150-5 && yAxis >= 14-11 && yAxis <= 72-11) - { - GasStack stack = ((CachedIORecipe)arecipes.get(recipe)).outputStack; + @Override + public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) { + Point point = GuiDraw.getMousePosition(); + Point offset = gui.getRecipePosition(recipe); - if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) - { - if(doGasLookup(stack, false)) - { - return true; - } - } - else if(keyCode == NEIClientConfig.getKeyBinding("gui.usage")) - { - if(doGasLookup(stack, true)) - { - return true; - } - } - } + int xAxis = point.x + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft + ) + - offset.x; + int yAxis = point.y + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop + ) + - offset.y; - return super.keyTyped(gui, keyChar, keyCode, recipe); - } + if (xAxis >= 134 - 5 && xAxis <= 150 - 5 && yAxis >= 14 - 11 + && yAxis <= 72 - 11) { + GasStack stack = ((CachedIORecipe) arecipes.get(recipe)).outputStack; - @Override - public boolean mouseClicked(GuiRecipe gui, int button, int recipe) - { - Point point = GuiDraw.getMousePosition(); - Point offset = gui.getRecipePosition(recipe); + if (keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) { + if (doGasLookup(stack, false)) { + return true; + } + } else if (keyCode == NEIClientConfig.getKeyBinding("gui.usage")) { + if (doGasLookup(stack, true)) { + return true; + } + } + } - int xAxis = point.x - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft)-offset.x; - int yAxis = point.y - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop)-offset.y; + return super.keyTyped(gui, keyChar, keyCode, recipe); + } - if(xAxis >= 134-5 && xAxis <= 150-5 && yAxis >= 14-11 && yAxis <= 72-11) - { - GasStack stack = ((CachedIORecipe)arecipes.get(recipe)).outputStack; + @Override + public boolean mouseClicked(GuiRecipe gui, int button, int recipe) { + Point point = GuiDraw.getMousePosition(); + Point offset = gui.getRecipePosition(recipe); - if(button == 0) - { - if(doGasLookup(stack, false)) - { - return true; - } - } - else if(button == 1) - { - if(doGasLookup(stack, true)) - { - return true; - } - } - } + int xAxis = point.x + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft + ) + - offset.x; + int yAxis = point.y + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop + ) + - offset.y; - return super.mouseClicked(gui, button, recipe); - } + if (xAxis >= 134 - 5 && xAxis <= 150 - 5 && yAxis >= 14 - 11 + && yAxis <= 72 - 11) { + GasStack stack = ((CachedIORecipe) arecipes.get(recipe)).outputStack; - @Override - public int recipiesPerPage() - { - return 2; - } + if (button == 0) { + if (doGasLookup(stack, false)) { + return true; + } + } else if (button == 1) { + if (doGasLookup(stack, true)) { + return true; + } + } + } - @Override - public void loadUsageRecipes(ItemStack ingredient) - { - for(OxidationRecipe irecipe : getRecipes()) - { - if(NEIServerUtils.areStacksSameTypeCrafting(irecipe.getInput().ingredient, ingredient)) - { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - } + return super.mouseClicked(gui, button, recipe); + } - public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe - { - public PositionedStack inputStack; - public GasStack outputStack; + @Override + public int recipiesPerPage() { + return 2; + } - @Override - public PositionedStack getIngredient() - { - return inputStack; - } + @Override + public void loadUsageRecipes(ItemStack ingredient) { + for (OxidationRecipe irecipe : getRecipes()) { + if (NEIServerUtils.areStacksSameTypeCrafting( + irecipe.getInput().ingredient, ingredient + )) { + arecipes.add(new CachedIORecipe(irecipe)); + } + } + } - @Override - public PositionedStack getResult() - { - return null; - } + public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe { + public PositionedStack inputStack; + public GasStack outputStack; - public CachedIORecipe(ItemStack input, GasStack output) - { - inputStack = new PositionedStack(input, 26-xOffset, 36-yOffset); - outputStack = output; - } + @Override + public PositionedStack getIngredient() { + return inputStack; + } - public CachedIORecipe(OxidationRecipe recipe) - { - this(recipe.getInput().ingredient, recipe.getOutput().output); - } - } + @Override + public PositionedStack getResult() { + return null; + } + + public CachedIORecipe(ItemStack input, GasStack output) { + inputStack = new PositionedStack(input, 26 - xOffset, 36 - yOffset); + outputStack = output; + } + + public CachedIORecipe(OxidationRecipe recipe) { + this(recipe.getInput().ingredient, recipe.getOutput().output); + } + } } diff --git a/src/main/java/mekanism/client/nei/ChemicalWasherRecipeHandler.java b/src/main/java/mekanism/client/nei/ChemicalWasherRecipeHandler.java index 808029516..9deff04da 100644 --- a/src/main/java/mekanism/client/nei/ChemicalWasherRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/ChemicalWasherRecipeHandler.java @@ -8,6 +8,11 @@ import java.awt.Rectangle; import java.util.Collection; import java.util.List; +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.NEIClientConfig; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.GuiRecipe; +import codechicken.nei.recipe.TemplateRecipeHandler; import mekanism.api.gas.GasStack; import mekanism.client.gui.GuiChemicalWasher; import mekanism.common.ObfuscatedNames; @@ -18,331 +23,281 @@ import mekanism.common.util.MekanismUtils; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; - import org.lwjgl.opengl.GL11; -import codechicken.lib.gui.GuiDraw; -import codechicken.nei.NEIClientConfig; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.GuiRecipe; -import codechicken.nei.recipe.TemplateRecipeHandler; +public class ChemicalWasherRecipeHandler extends BaseRecipeHandler { + private int ticksPassed; -public class ChemicalWasherRecipeHandler extends BaseRecipeHandler -{ - private int ticksPassed; + public static int xOffset = 5; + public static int yOffset = 3; - public static int xOffset = 5; - public static int yOffset = 3; + @Override + public String getRecipeName() { + return LangUtils.localize("tile.MachineBlock2.ChemicalWasher.name"); + } - @Override - public String getRecipeName() - { - return LangUtils.localize("tile.MachineBlock2.ChemicalWasher.name"); - } + @Override + public String getOverlayIdentifier() { + return "chemicalwasher"; + } - @Override - public String getOverlayIdentifier() - { - return "chemicalwasher"; - } + @Override + public String getGuiTexture() { + return "mekanism:gui/nei/GuiChemicalWasher.png"; + } - @Override - public String getGuiTexture() - { - return "mekanism:gui/nei/GuiChemicalWasher.png"; - } + @Override + public Class getGuiClass() { + return GuiChemicalWasher.class; + } - @Override - public Class getGuiClass() - { - return GuiChemicalWasher.class; - } + public String getRecipeId() { + return "mekanism.chemicalwasher"; + } - public String getRecipeId() - { - return "mekanism.chemicalwasher"; - } + public Collection getRecipes() { + return Recipe.CHEMICAL_WASHER.get().values(); + } - public Collection getRecipes() - { - return Recipe.CHEMICAL_WASHER.get().values(); - } + @Override + public void drawBackground(int i) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + changeTexture(getGuiTexture()); + drawTexturedModalRect(-2, 0, 3, yOffset, 170, 70); + } - @Override - public void drawBackground(int i) - { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - changeTexture(getGuiTexture()); - drawTexturedModalRect(-2, 0, 3, yOffset, 170, 70); - } + @Override + public void drawExtras(int i) { + CachedIORecipe recipe = (CachedIORecipe) arecipes.get(i); - @Override - public void drawExtras(int i) - { - CachedIORecipe recipe = (CachedIORecipe)arecipes.get(i); + drawTexturedModalRect(61 - xOffset, 39 - yOffset, 176, 63, 55, 8); - drawTexturedModalRect(61-xOffset, 39-yOffset, 176, 63, 55, 8); + displayGauge( + 58, + 6 - xOffset, + 5 - yOffset, + 176, + 4, + 58, + new FluidStack(FluidRegistry.WATER, 1), + null + ); - displayGauge(58, 6-xOffset, 5-yOffset, 176, 4, 58, new FluidStack(FluidRegistry.WATER, 1), null); + if (recipe.outputStack != null) { + displayGauge( + 58, 27 - xOffset, 14 - yOffset, 176, 4, 58, null, recipe.inputStack + ); + } - if(recipe.outputStack != null) - { - displayGauge(58, 27-xOffset, 14-yOffset, 176, 4, 58, null, recipe.inputStack); - } + if (recipe.inputStack != null) { + displayGauge( + 58, 134 - xOffset, 14 - yOffset, 176, 4, 58, null, recipe.outputStack + ); + } + } - if(recipe.inputStack != null) - { - displayGauge(58, 134-xOffset, 14-yOffset, 176, 4, 58, null, recipe.outputStack); - } - } + @Override + public void onUpdate() { + super.onUpdate(); - @Override - public void onUpdate() - { - super.onUpdate(); + ticksPassed++; + } - ticksPassed++; - } + @Override + public void loadTransferRects() { + transferRects.add(new TemplateRecipeHandler.RecipeTransferRect( + new Rectangle(61 - xOffset, 39 - yOffset, 55, 8), getRecipeId(), new Object[0] + )); + } - @Override - public void loadTransferRects() - { - transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(61-xOffset, 39-yOffset, 55, 8), getRecipeId(), new Object[0])); - } + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals(getRecipeId())) { + for (WasherRecipe irecipe : getRecipes()) { + arecipes.add(new CachedIORecipe(irecipe)); + } + } else if (outputId.equals("gas") && results.length == 1 && results[0] instanceof GasStack) { + for (WasherRecipe irecipe : getRecipes()) { + if (((GasStack) results[0]).isGasEqual(irecipe.getOutput().output)) { + arecipes.add(new CachedIORecipe(irecipe)); + } + } + } else { + super.loadCraftingRecipes(outputId, results); + } + } - @Override - public void loadCraftingRecipes(String outputId, Object... results) - { - if(outputId.equals(getRecipeId())) - { - for(WasherRecipe irecipe : getRecipes()) - { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - else if(outputId.equals("gas") && results.length == 1 && results[0] instanceof GasStack) - { - for(WasherRecipe irecipe : getRecipes()) - { - if(((GasStack)results[0]).isGasEqual(irecipe.getOutput().output)) - { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - } - else { - super.loadCraftingRecipes(outputId, results); - } - } + @Override + public void loadUsageRecipes(String inputId, Object... ingredients) { + if (inputId.equals("fluid") && ingredients.length == 1 + && ingredients[0] instanceof FluidStack) { + if (((FluidStack) ingredients[0]).getFluid() == FluidRegistry.WATER) { + for (WasherRecipe irecipe : getRecipes()) { + arecipes.add(new CachedIORecipe(irecipe)); + } + } + } else if (inputId.equals("gas") && ingredients.length == 1 && ingredients[0] instanceof GasStack) { + for (WasherRecipe irecipe : getRecipes()) { + if (irecipe.getInput().ingredient.isGasEqual((GasStack) ingredients[0])) { + arecipes.add(new CachedIORecipe(irecipe)); + } + } + } else { + super.loadUsageRecipes(inputId, ingredients); + } + } - @Override - public void loadUsageRecipes(String inputId, Object... ingredients) - { - if(inputId.equals("fluid") && ingredients.length == 1 && ingredients[0] instanceof FluidStack) - { - if(((FluidStack)ingredients[0]).getFluid() == FluidRegistry.WATER) - { - for(WasherRecipe irecipe : getRecipes()) - { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - } - else if(inputId.equals("gas") && ingredients.length == 1 && ingredients[0] instanceof GasStack) - { - for(WasherRecipe irecipe : getRecipes()) - { - if(irecipe.getInput().ingredient.isGasEqual((GasStack)ingredients[0])) - { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - } - else { - super.loadUsageRecipes(inputId, ingredients); - } - } + @Override + public List + handleTooltip(GuiRecipe gui, List currenttip, int recipe) { + Point point = GuiDraw.getMousePosition(); - @Override - public List handleTooltip(GuiRecipe gui, List currenttip, int recipe) - { - Point point = GuiDraw.getMousePosition(); + int xAxis = point.x + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft + ); + int yAxis = point.y + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop + ); - int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); - int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); + if (xAxis >= 6 && xAxis <= 22 && yAxis >= 5 + 13 && yAxis <= 63 + 13) { + currenttip.add(FluidRegistry.WATER.getLocalizedName(null)); + } else if (xAxis >= 27 && xAxis <= 43 && yAxis >= 14 + 13 && yAxis <= 72 + 13) { + currenttip.add(LangUtils.localizeGasStack( + ((CachedIORecipe) arecipes.get(recipe)).inputStack + )); + } else if (xAxis >= 134 && xAxis <= 150 && yAxis >= 14 + 13 && yAxis <= 72 + 13) { + currenttip.add(LangUtils.localizeGasStack( + ((CachedIORecipe) arecipes.get(recipe)).outputStack + )); + } - if(xAxis >= 6 && xAxis <= 22 && yAxis >= 5+13 && yAxis <= 63+13) - { - currenttip.add(FluidRegistry.WATER.getLocalizedName(null)); - } - else if(xAxis >= 27 && xAxis <= 43 && yAxis >= 14+13 && yAxis <= 72+13) - { - currenttip.add(LangUtils.localizeGasStack(((CachedIORecipe)arecipes.get(recipe)).inputStack)); - } - else if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14+13 && yAxis <= 72+13) - { - currenttip.add(LangUtils.localizeGasStack(((CachedIORecipe)arecipes.get(recipe)).outputStack)); - } + return super.handleTooltip(gui, currenttip, recipe); + } - return super.handleTooltip(gui, currenttip, recipe); - } + @Override + public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) { + Point point = GuiDraw.getMousePosition(); - @Override - public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) - { - Point point = GuiDraw.getMousePosition(); + int xAxis = point.x + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft + ); + int yAxis = point.y + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop + ); - int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); - int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); + GasStack gas = null; + FluidStack fluid = null; - GasStack gas = null; - FluidStack fluid = null; + if (xAxis >= 6 && xAxis <= 22 && yAxis >= 5 + 13 && yAxis <= 63 + 13) { + fluid = new FluidStack(FluidRegistry.WATER, 1); + } else if (xAxis >= 27 && xAxis <= 43 && yAxis >= 14 + 13 && yAxis <= 72 + 13) { + gas = ((CachedIORecipe) arecipes.get(recipe)).inputStack; + } else if (xAxis >= 134 && xAxis <= 150 && yAxis >= 14 + 13 && yAxis <= 72 + 13) { + gas = ((CachedIORecipe) arecipes.get(recipe)).outputStack; + } - if(xAxis >= 6 && xAxis <= 22 && yAxis >= 5+13 && yAxis <= 63+13) - { - fluid = new FluidStack(FluidRegistry.WATER, 1); - } - else if(xAxis >= 27 && xAxis <= 43 && yAxis >= 14+13 && yAxis <= 72+13) - { - gas = ((CachedIORecipe)arecipes.get(recipe)).inputStack; - } - else if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14+13 && yAxis <= 72+13) - { - gas = ((CachedIORecipe)arecipes.get(recipe)).outputStack; - } + if (gas != null) { + if (keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) { + if (doGasLookup(gas, false)) { + return true; + } + } else if (keyCode == NEIClientConfig.getKeyBinding("gui.usage")) { + if (doGasLookup(gas, true)) { + return true; + } + } + } else if (fluid != null) { + if (keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) { + if (doFluidLookup(fluid, false)) { + return true; + } + } else if (keyCode == NEIClientConfig.getKeyBinding("gui.usage")) { + if (doFluidLookup(fluid, true)) { + return true; + } + } + } - if(gas != null) - { - if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) - { - if(doGasLookup(gas, false)) - { - return true; - } - } - else if(keyCode == NEIClientConfig.getKeyBinding("gui.usage")) - { - if(doGasLookup(gas, true)) - { - return true; - } - } - } - else if(fluid != null) - { - if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) - { - if(doFluidLookup(fluid, false)) - { - return true; - } - } - else if(keyCode == NEIClientConfig.getKeyBinding("gui.usage")) - { - if(doFluidLookup(fluid, true)) - { - return true; - } - } - } + return super.keyTyped(gui, keyChar, keyCode, recipe); + } - return super.keyTyped(gui, keyChar, keyCode, recipe); - } + @Override + public boolean mouseClicked(GuiRecipe gui, int button, int recipe) { + Point point = GuiDraw.getMousePosition(); - @Override - public boolean mouseClicked(GuiRecipe gui, int button, int recipe) - { - Point point = GuiDraw.getMousePosition(); + int xAxis = point.x + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft + ); + int yAxis = point.y + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop + ); - int xAxis = point.x - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); - int yAxis = point.y - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); + GasStack gas = null; + FluidStack fluid = null; - GasStack gas = null; - FluidStack fluid = null; + if (xAxis >= 6 && xAxis <= 22 && yAxis >= 5 + 13 && yAxis <= 63 + 13) { + fluid = new FluidStack(FluidRegistry.WATER, 1); + } else if (xAxis >= 27 && xAxis <= 43 && yAxis >= 14 + 13 && yAxis <= 72 + 13) { + gas = ((CachedIORecipe) arecipes.get(recipe)).inputStack; + } else if (xAxis >= 134 && xAxis <= 150 && yAxis >= 14 + 13 && yAxis <= 72 + 13) { + gas = ((CachedIORecipe) arecipes.get(recipe)).outputStack; + } - if(xAxis >= 6 && xAxis <= 22 && yAxis >= 5+13 && yAxis <= 63+13) - { - fluid = new FluidStack(FluidRegistry.WATER, 1); - } - else if(xAxis >= 27 && xAxis <= 43 && yAxis >= 14+13 && yAxis <= 72+13) - { - gas = ((CachedIORecipe)arecipes.get(recipe)).inputStack; - } - else if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14+13 && yAxis <= 72+13) - { - gas = ((CachedIORecipe)arecipes.get(recipe)).outputStack; - } + if (gas != null) { + if (button == 0) { + if (doGasLookup(gas, false)) { + return true; + } + } else if (button == 1) { + if (doGasLookup(gas, true)) { + return true; + } + } + } else if (fluid != null) { + if (button == 0) { + if (doFluidLookup(fluid, false)) { + return true; + } + } else if (button == 1) { + if (doFluidLookup(fluid, true)) { + return true; + } + } + } - if(gas != null) - { - if(button == 0) - { - if(doGasLookup(gas, false)) - { - return true; - } - } - else if(button == 1) - { - if(doGasLookup(gas, true)) - { - return true; - } - } - } - else if(fluid != null) - { - if(button == 0) - { - if(doFluidLookup(fluid, false)) - { - return true; - } - } - else if(button == 1) - { - if(doFluidLookup(fluid, true)) - { - return true; - } - } - } + return super.mouseClicked(gui, button, recipe); + } - return super.mouseClicked(gui, button, recipe); - } + @Override + public int recipiesPerPage() { + return 1; + } - @Override - public int recipiesPerPage() - { - return 1; - } + @Override + public void addGuiElements() {} - @Override - public void addGuiElements() - { + public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe { + public GasStack inputStack; + public GasStack outputStack; - } + @Override + public PositionedStack getResult() { + return null; + } - public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe - { - public GasStack inputStack; - public GasStack outputStack; + public CachedIORecipe(GasStack input, GasStack output) { + inputStack = input; + outputStack = output; + } - @Override - public PositionedStack getResult() - { - return null; - } - - public CachedIORecipe(GasStack input, GasStack output) - { - inputStack = input; - outputStack = output; - } - - public CachedIORecipe(WasherRecipe recipe) - { - this(recipe.getInput().ingredient, recipe.getOutput().output); - } - } + public CachedIORecipe(WasherRecipe recipe) { + this(recipe.getInput().ingredient, recipe.getOutput().output); + } + } } diff --git a/src/main/java/mekanism/client/nei/CombinerRecipeHandler.java b/src/main/java/mekanism/client/nei/CombinerRecipeHandler.java index c6e052620..404662cd4 100644 --- a/src/main/java/mekanism/client/nei/CombinerRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/CombinerRecipeHandler.java @@ -13,47 +13,39 @@ import mekanism.common.util.LangUtils; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; -public class CombinerRecipeHandler extends AdvancedMachineRecipeHandler -{ - @Override - public String getRecipeName() - { - return LangUtils.localize("tile.MachineBlock.Combiner.name"); - } +public class CombinerRecipeHandler extends AdvancedMachineRecipeHandler { + @Override + public String getRecipeName() { + return LangUtils.localize("tile.MachineBlock.Combiner.name"); + } - @Override - public String getRecipeId() - { - return "mekanism.combiner"; - } + @Override + public String getRecipeId() { + return "mekanism.combiner"; + } - @Override - public String getOverlayIdentifier() - { - return "combiner"; - } + @Override + public String getOverlayIdentifier() { + return "combiner"; + } - @Override - public Collection getRecipes() - { - return Recipe.COMBINER.get().values(); - } - - @Override - public ProgressBar getProgressType() - { - return ProgressBar.STONE; - } + @Override + public Collection getRecipes() { + return Recipe.COMBINER.get().values(); + } - @Override - public List getFuelStacks(Gas gasType) - { - return ListUtils.asList(new ItemStack(Blocks.cobblestone)); - } + @Override + public ProgressBar getProgressType() { + return ProgressBar.STONE; + } - @Override - public Class getGuiClass() - { - return GuiCombiner.class; - } + @Override + public List getFuelStacks(Gas gasType) { + return ListUtils.asList(new ItemStack(Blocks.cobblestone)); + } + + @Override + public Class getGuiClass() { + return GuiCombiner.class; + } } diff --git a/src/main/java/mekanism/client/nei/CrusherRecipeHandler.java b/src/main/java/mekanism/client/nei/CrusherRecipeHandler.java index 0b695e98a..a22d49385 100644 --- a/src/main/java/mekanism/client/nei/CrusherRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/CrusherRecipeHandler.java @@ -8,41 +8,34 @@ import mekanism.common.recipe.RecipeHandler.Recipe; import mekanism.common.recipe.machines.CrusherRecipe; import mekanism.common.util.LangUtils; -public class CrusherRecipeHandler extends MachineRecipeHandler -{ - @Override - public String getRecipeName() - { - return LangUtils.localize("tile.MachineBlock.Crusher.name"); - } +public class CrusherRecipeHandler extends MachineRecipeHandler { + @Override + public String getRecipeName() { + return LangUtils.localize("tile.MachineBlock.Crusher.name"); + } - @Override - public String getRecipeId() - { - return "mekanism.crusher"; - } + @Override + public String getRecipeId() { + return "mekanism.crusher"; + } - @Override - public String getOverlayIdentifier() - { - return "crusher"; - } - - @Override - public ProgressBar getProgressType() - { - return ProgressBar.CRUSH; - } + @Override + public String getOverlayIdentifier() { + return "crusher"; + } - @Override - public Collection getRecipes() - { - return Recipe.CRUSHER.get().values(); - } + @Override + public ProgressBar getProgressType() { + return ProgressBar.CRUSH; + } - @Override - public Class getGuiClass() - { - return GuiCrusher.class; - } + @Override + public Collection getRecipes() { + return Recipe.CRUSHER.get().values(); + } + + @Override + public Class getGuiClass() { + return GuiCrusher.class; + } } diff --git a/src/main/java/mekanism/client/nei/ElectrolyticSeparatorRecipeHandler.java b/src/main/java/mekanism/client/nei/ElectrolyticSeparatorRecipeHandler.java index cb5a27450..89f79c933 100644 --- a/src/main/java/mekanism/client/nei/ElectrolyticSeparatorRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/ElectrolyticSeparatorRecipeHandler.java @@ -8,6 +8,11 @@ import java.awt.Rectangle; import java.util.Collection; import java.util.List; +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.NEIClientConfig; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.GuiRecipe; +import codechicken.nei.recipe.TemplateRecipeHandler; import mekanism.api.gas.GasStack; import mekanism.client.gui.GuiElectrolyticSeparator; import mekanism.client.gui.element.GuiElement; @@ -32,359 +37,382 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraftforge.fluids.FluidStack; - import org.lwjgl.opengl.GL11; -import codechicken.lib.gui.GuiDraw; -import codechicken.nei.NEIClientConfig; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.GuiRecipe; -import codechicken.nei.recipe.TemplateRecipeHandler; +public class ElectrolyticSeparatorRecipeHandler extends BaseRecipeHandler { + private int ticksPassed; -public class ElectrolyticSeparatorRecipeHandler extends BaseRecipeHandler -{ - private int ticksPassed; - - public GuiFluidGauge fluidInput; - public GuiGasGauge leftGas; - public GuiGasGauge rightGas; + public GuiFluidGauge fluidInput; + public GuiGasGauge leftGas; + public GuiGasGauge rightGas; - public static int xOffset = 5; - public static int yOffset = 9; - - @Override - public void addGuiElements() - { - guiElements.add(fluidInput = GuiFluidGauge.getDummy(GuiGauge.Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), 5, 10)); - guiElements.add(leftGas = GuiGasGauge.getDummy(GuiGauge.Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), 58, 18)); - guiElements.add(rightGas = GuiGasGauge.getDummy(GuiGauge.Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), 100, 18)); - guiElements.add(new GuiPowerBar(this, new IPowerInfoHandler() { - @Override - public double getLevel() - { - return ticksPassed <= 20 ? ticksPassed / 20.0F : 1.0F; - } - }, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 164, 15)); - - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), 25, 34)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), 58, 51)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), 100, 51)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), 142, 34).with(SlotOverlay.POWER)); + public static int xOffset = 5; + public static int yOffset = 9; - guiElements.add(new GuiProgress(new IProgressInfoHandler() - { - @Override - public double getProgress() - { - return 1; - } - }, ProgressBar.BI, this, MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), 78, 29)); - } + @Override + public void addGuiElements() { + guiElements.add( + fluidInput = GuiFluidGauge.getDummy( + GuiGauge.Type.STANDARD, + this, + MekanismUtils.getResource( + ResourceType.GUI, "GuiElectrolyticSeparator.png" + ), + 5, + 10 + ) + ); + guiElements.add( + leftGas = GuiGasGauge.getDummy( + GuiGauge.Type.SMALL, + this, + MekanismUtils.getResource( + ResourceType.GUI, "GuiElectrolyticSeparator.png" + ), + 58, + 18 + ) + ); + guiElements.add( + rightGas = GuiGasGauge.getDummy( + GuiGauge.Type.SMALL, + this, + MekanismUtils.getResource( + ResourceType.GUI, "GuiElectrolyticSeparator.png" + ), + 100, + 18 + ) + ); + guiElements.add(new GuiPowerBar(this, new IPowerInfoHandler() { + @Override + public double getLevel() { + return ticksPassed <= 20 ? ticksPassed / 20.0F : 1.0F; + } + }, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 164, 15)); - @Override - public String getRecipeName() - { - return LangUtils.localize("tile.MachineBlock2.ElectrolyticSeparator.name"); - } + guiElements.add(new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), + 25, + 34 + )); + guiElements.add(new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), + 58, + 51 + )); + guiElements.add(new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), + 100, + 51 + )); + guiElements.add(new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource( + ResourceType.GUI, "GuiElectrolyticSeparator.png" + ), + 142, + 34 + ) + .with(SlotOverlay.POWER)); - @Override - public String getOverlayIdentifier() - { - return "electrolyticseparator"; - } + guiElements.add(new GuiProgress( + new IProgressInfoHandler() { + @Override + public double getProgress() { + return 1; + } + }, + ProgressBar.BI, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), + 78, + 29 + )); + } - @Override - public String getGuiTexture() - { - return "mekanism:gui/GuiElectrolyticSeparator.png"; - } + @Override + public String getRecipeName() { + return LangUtils.localize("tile.MachineBlock2.ElectrolyticSeparator.name"); + } - @Override - public Class getGuiClass() - { - return GuiElectrolyticSeparator.class; - } + @Override + public String getOverlayIdentifier() { + return "electrolyticseparator"; + } - public String getRecipeId() - { - return "mekanism.electrolyticseparator"; - } + @Override + public String getGuiTexture() { + return "mekanism:gui/GuiElectrolyticSeparator.png"; + } - public Collection getRecipes() - { - return Recipe.ELECTROLYTIC_SEPARATOR.get().values(); - } + @Override + public Class getGuiClass() { + return GuiElectrolyticSeparator.class; + } - @Override - public void drawBackground(int i) - { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - changeTexture(getGuiTexture()); - drawTexturedModalRect(-1, 0, 4, yOffset, 167, 62); - - for(GuiElement e : guiElements) - { - e.renderBackground(0, 0, -xOffset, -yOffset); - } - } + public String getRecipeId() { + return "mekanism.electrolyticseparator"; + } - @Override - public void drawExtras(int i) - { - CachedIORecipe recipe = (CachedIORecipe)arecipes.get(i); + public Collection getRecipes() { + return Recipe.ELECTROLYTIC_SEPARATOR.get().values(); + } - if(recipe.fluidInput != null) - { - fluidInput.setDummyType(recipe.fluidInput.ingredient.getFluid()); - fluidInput.renderScale(0, 0, -xOffset, -yOffset); - } + @Override + public void drawBackground(int i) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + changeTexture(getGuiTexture()); + drawTexturedModalRect(-1, 0, 4, yOffset, 167, 62); - if(recipe.outputPair.leftGas != null) - { - displayGauge(28, 59-xOffset, 19-yOffset, 176, 68, 28, null, recipe.outputPair.leftGas); - leftGas.setDummyType(recipe.outputPair.leftGas.getGas()); - leftGas.renderScale(0, 0, -xOffset, -yOffset); - } + for (GuiElement e : guiElements) { + e.renderBackground(0, 0, -xOffset, -yOffset); + } + } - if(recipe.outputPair.rightGas != null) - { - displayGauge(28, 101-xOffset, 19-yOffset, 176, 68, 28, null, recipe.outputPair.rightGas); - rightGas.setDummyType(recipe.outputPair.rightGas.getGas()); - rightGas.renderScale(0, 0, -xOffset, -yOffset); - } - } + @Override + public void drawExtras(int i) { + CachedIORecipe recipe = (CachedIORecipe) arecipes.get(i); - @Override - public void onUpdate() - { - super.onUpdate(); + if (recipe.fluidInput != null) { + fluidInput.setDummyType(recipe.fluidInput.ingredient.getFluid()); + fluidInput.renderScale(0, 0, -xOffset, -yOffset); + } - ticksPassed++; - } + if (recipe.outputPair.leftGas != null) { + displayGauge( + 28, + 59 - xOffset, + 19 - yOffset, + 176, + 68, + 28, + null, + recipe.outputPair.leftGas + ); + leftGas.setDummyType(recipe.outputPair.leftGas.getGas()); + leftGas.renderScale(0, 0, -xOffset, -yOffset); + } - @Override - public void loadTransferRects() - { - transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(80-xOffset, 30-yOffset, 16, 6), getRecipeId(), new Object[0])); - } + if (recipe.outputPair.rightGas != null) { + displayGauge( + 28, + 101 - xOffset, + 19 - yOffset, + 176, + 68, + 28, + null, + recipe.outputPair.rightGas + ); + rightGas.setDummyType(recipe.outputPair.rightGas.getGas()); + rightGas.renderScale(0, 0, -xOffset, -yOffset); + } + } - @Override - public void loadCraftingRecipes(String outputId, Object... results) - { - if(outputId.equals(getRecipeId())) - { - for(SeparatorRecipe irecipe : getRecipes()) - { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - else if(outputId.equals("gas") && results.length == 1 && results[0] instanceof GasStack) - { - for(SeparatorRecipe irecipe : getRecipes()) - { - if(irecipe.recipeOutput.containsType((GasStack)results[0])) - { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - } - else { - super.loadCraftingRecipes(outputId, results); - } - } + @Override + public void onUpdate() { + super.onUpdate(); - @Override - public void loadUsageRecipes(String inputId, Object... ingredients) - { - if(inputId.equals("fluid") && ingredients.length == 1 && ingredients[0] instanceof FluidStack) - { - for(SeparatorRecipe irecipe : getRecipes()) - { - if(irecipe.recipeInput.ingredient.isFluidEqual((FluidStack)ingredients[0])) - { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - } - else { - super.loadUsageRecipes(inputId, ingredients); - } - } + ticksPassed++; + } - @Override - public List handleTooltip(GuiRecipe gui, List currenttip, int recipe) - { - Point point = GuiDraw.getMousePosition(); + @Override + public void loadTransferRects() { + transferRects.add(new TemplateRecipeHandler.RecipeTransferRect( + new Rectangle(80 - xOffset, 30 - yOffset, 16, 6), getRecipeId(), new Object[0] + )); + } - int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); - int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals(getRecipeId())) { + for (SeparatorRecipe irecipe : getRecipes()) { + arecipes.add(new CachedIORecipe(irecipe)); + } + } else if (outputId.equals("gas") && results.length == 1 && results[0] instanceof GasStack) { + for (SeparatorRecipe irecipe : getRecipes()) { + if (irecipe.recipeOutput.containsType((GasStack) results[0])) { + arecipes.add(new CachedIORecipe(irecipe)); + } + } + } else { + super.loadCraftingRecipes(outputId, results); + } + } - if(xAxis >= 6 && xAxis <= 22 && yAxis >= 11+7 && yAxis <= 69+7) - { - currenttip.add(LangUtils.localizeFluidStack(((CachedIORecipe)arecipes.get(recipe)).fluidInput.ingredient)); - } - else if(xAxis >= 59 && xAxis <= 75 && yAxis >= 19+7 && yAxis <= 47+7) - { - currenttip.add(((CachedIORecipe)arecipes.get(recipe)).outputPair.leftGas.getGas().getLocalizedName()); - } - else if(xAxis >= 101 && xAxis <= 117 && yAxis >= 19+7 && yAxis <= 47+7) - { - currenttip.add(((CachedIORecipe)arecipes.get(recipe)).outputPair.rightGas.getGas().getLocalizedName()); - } + @Override + public void loadUsageRecipes(String inputId, Object... ingredients) { + if (inputId.equals("fluid") && ingredients.length == 1 + && ingredients[0] instanceof FluidStack) { + for (SeparatorRecipe irecipe : getRecipes()) { + if (irecipe.recipeInput.ingredient.isFluidEqual((FluidStack + ) ingredients[0])) { + arecipes.add(new CachedIORecipe(irecipe)); + } + } + } else { + super.loadUsageRecipes(inputId, ingredients); + } + } - return super.handleTooltip(gui, currenttip, recipe); - } + @Override + public List + handleTooltip(GuiRecipe gui, List currenttip, int recipe) { + Point point = GuiDraw.getMousePosition(); - @Override - public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) - { - Point point = GuiDraw.getMousePosition(); + int xAxis = point.x + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft + ); + int yAxis = point.y + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop + ); - int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); - int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); + if (xAxis >= 6 && xAxis <= 22 && yAxis >= 11 + 7 && yAxis <= 69 + 7) { + currenttip.add(LangUtils.localizeFluidStack( + ((CachedIORecipe) arecipes.get(recipe)).fluidInput.ingredient + )); + } else if (xAxis >= 59 && xAxis <= 75 && yAxis >= 19 + 7 && yAxis <= 47 + 7) { + currenttip.add(((CachedIORecipe) arecipes.get(recipe)) + .outputPair.leftGas.getGas() + .getLocalizedName()); + } else if (xAxis >= 101 && xAxis <= 117 && yAxis >= 19 + 7 && yAxis <= 47 + 7) { + currenttip.add(((CachedIORecipe) arecipes.get(recipe)) + .outputPair.rightGas.getGas() + .getLocalizedName()); + } - GasStack gas = null; - FluidStack fluid = null; + return super.handleTooltip(gui, currenttip, recipe); + } - if(xAxis >= 6 && xAxis <= 22 && yAxis >= 11+7 && yAxis <= 69+7) - { - fluid = ((CachedIORecipe)arecipes.get(recipe)).fluidInput.ingredient; - } - else if(xAxis >= 59 && xAxis <= 75 && yAxis >= 19+7 && yAxis <= 47+7) - { - gas = ((CachedIORecipe)arecipes.get(recipe)).outputPair.leftGas; - } - else if(xAxis >= 101 && xAxis <= 117 && yAxis >= 19+7 && yAxis <= 47+7) - { - gas = ((CachedIORecipe)arecipes.get(recipe)).outputPair.rightGas; - } + @Override + public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) { + Point point = GuiDraw.getMousePosition(); - if(gas != null) - { - if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) - { - if(doGasLookup(gas, false)) - { - return true; - } - } - else if(keyCode == NEIClientConfig.getKeyBinding("gui.usage")) - { - if(doGasLookup(gas, true)) - { - return true; - } - } - } - else if(fluid != null) - { - if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) - { - if(doFluidLookup(fluid, false)) - { - return true; - } - } - else if(keyCode == NEIClientConfig.getKeyBinding("gui.usage")) - { - if(doFluidLookup(fluid, true)) - { - return true; - } - } - } + int xAxis = point.x + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft + ); + int yAxis = point.y + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop + ); - return super.keyTyped(gui, keyChar, keyCode, recipe); - } + GasStack gas = null; + FluidStack fluid = null; - @Override - public boolean mouseClicked(GuiRecipe gui, int button, int recipe) - { - Point point = GuiDraw.getMousePosition(); + if (xAxis >= 6 && xAxis <= 22 && yAxis >= 11 + 7 && yAxis <= 69 + 7) { + fluid = ((CachedIORecipe) arecipes.get(recipe)).fluidInput.ingredient; + } else if (xAxis >= 59 && xAxis <= 75 && yAxis >= 19 + 7 && yAxis <= 47 + 7) { + gas = ((CachedIORecipe) arecipes.get(recipe)).outputPair.leftGas; + } else if (xAxis >= 101 && xAxis <= 117 && yAxis >= 19 + 7 && yAxis <= 47 + 7) { + gas = ((CachedIORecipe) arecipes.get(recipe)).outputPair.rightGas; + } - int xAxis = point.x - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); - int yAxis = point.y - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); + if (gas != null) { + if (keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) { + if (doGasLookup(gas, false)) { + return true; + } + } else if (keyCode == NEIClientConfig.getKeyBinding("gui.usage")) { + if (doGasLookup(gas, true)) { + return true; + } + } + } else if (fluid != null) { + if (keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) { + if (doFluidLookup(fluid, false)) { + return true; + } + } else if (keyCode == NEIClientConfig.getKeyBinding("gui.usage")) { + if (doFluidLookup(fluid, true)) { + return true; + } + } + } - GasStack gas = null; - FluidStack fluid = null; + return super.keyTyped(gui, keyChar, keyCode, recipe); + } - if(xAxis >= 6 && xAxis <= 22 && yAxis >= 11+7 && yAxis <= 69+7) - { - fluid = ((CachedIORecipe)arecipes.get(recipe)).fluidInput.ingredient; - } - else if(xAxis >= 59 && xAxis <= 75 && yAxis >= 19+7 && yAxis <= 47+7) - { - gas = ((CachedIORecipe)arecipes.get(recipe)).outputPair.leftGas; - } - else if(xAxis >= 101 && xAxis <= 117 && yAxis >= 19+7 && yAxis <= 47+7) - { - gas = ((CachedIORecipe)arecipes.get(recipe)).outputPair.rightGas; - } + @Override + public boolean mouseClicked(GuiRecipe gui, int button, int recipe) { + Point point = GuiDraw.getMousePosition(); - if(gas != null) - { - if(button == 0) - { - if(doGasLookup(gas, false)) - { - return true; - } - } - else if(button == 1) - { - if(doGasLookup(gas, true)) - { - return true; - } - } - } - else if(fluid != null) - { - if(button == 0) - { - if(doFluidLookup(fluid, false)) - { - return true; - } - } - else if(button == 1) - { - if(doFluidLookup(fluid, true)) - { - return true; - } - } - } + int xAxis = point.x + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft + ); + int yAxis = point.y + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop + ); - return super.mouseClicked(gui, button, recipe); - } + GasStack gas = null; + FluidStack fluid = null; - @Override - public int recipiesPerPage() - { - return 1; - } + if (xAxis >= 6 && xAxis <= 22 && yAxis >= 11 + 7 && yAxis <= 69 + 7) { + fluid = ((CachedIORecipe) arecipes.get(recipe)).fluidInput.ingredient; + } else if (xAxis >= 59 && xAxis <= 75 && yAxis >= 19 + 7 && yAxis <= 47 + 7) { + gas = ((CachedIORecipe) arecipes.get(recipe)).outputPair.leftGas; + } else if (xAxis >= 101 && xAxis <= 117 && yAxis >= 19 + 7 && yAxis <= 47 + 7) { + gas = ((CachedIORecipe) arecipes.get(recipe)).outputPair.rightGas; + } - public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe - { - public FluidInput fluidInput; - public ChemicalPairOutput outputPair; + if (gas != null) { + if (button == 0) { + if (doGasLookup(gas, false)) { + return true; + } + } else if (button == 1) { + if (doGasLookup(gas, true)) { + return true; + } + } + } else if (fluid != null) { + if (button == 0) { + if (doFluidLookup(fluid, false)) { + return true; + } + } else if (button == 1) { + if (doFluidLookup(fluid, true)) { + return true; + } + } + } - @Override - public PositionedStack getResult() - { - return null; - } + return super.mouseClicked(gui, button, recipe); + } - public CachedIORecipe(FluidInput input, ChemicalPairOutput pair) - { - fluidInput = input; - outputPair = pair; - } + @Override + public int recipiesPerPage() { + return 1; + } - public CachedIORecipe(SeparatorRecipe recipe) - { - this(recipe.recipeInput, recipe.recipeOutput); - } - } + public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe { + public FluidInput fluidInput; + public ChemicalPairOutput outputPair; + + @Override + public PositionedStack getResult() { + return null; + } + + public CachedIORecipe(FluidInput input, ChemicalPairOutput pair) { + fluidInput = input; + outputPair = pair; + } + + public CachedIORecipe(SeparatorRecipe recipe) { + this(recipe.recipeInput, recipe.recipeOutput); + } + } } diff --git a/src/main/java/mekanism/client/nei/ElementBoundHandler.java b/src/main/java/mekanism/client/nei/ElementBoundHandler.java index e0b455704..0d49b4da3 100644 --- a/src/main/java/mekanism/client/nei/ElementBoundHandler.java +++ b/src/main/java/mekanism/client/nei/ElementBoundHandler.java @@ -1,31 +1,28 @@ package mekanism.client.nei; +import codechicken.lib.vec.Rectangle4i; +import codechicken.nei.api.INEIGuiAdapter; import mekanism.client.gui.GuiMekanism; import mekanism.client.gui.element.GuiElement; import net.minecraft.client.gui.inventory.GuiContainer; -import codechicken.lib.vec.Rectangle4i; -import codechicken.nei.api.INEIGuiAdapter; -public class ElementBoundHandler extends INEIGuiAdapter -{ - @Override - public boolean hideItemPanelSlot(GuiContainer gui, int x, int y, int width, int height) - { - if(gui instanceof GuiMekanism) - { - GuiMekanism guiMek = (GuiMekanism)gui; - - Rectangle4i rect = new Rectangle4i(x, y, width, height); - - for(GuiElement element : guiMek.guiElements) - { - if(element.getBounds(guiMek.getXPos(), guiMek.getYPos()).intersects(rect)) - { - return true; - } - } - } - - return false; - } +public class ElementBoundHandler extends INEIGuiAdapter { + @Override + public boolean + hideItemPanelSlot(GuiContainer gui, int x, int y, int width, int height) { + if (gui instanceof GuiMekanism) { + GuiMekanism guiMek = (GuiMekanism) gui; + + Rectangle4i rect = new Rectangle4i(x, y, width, height); + + for (GuiElement element : guiMek.guiElements) { + if (element.getBounds(guiMek.getXPos(), guiMek.getYPos()) + .intersects(rect)) { + return true; + } + } + } + + return false; + } } diff --git a/src/main/java/mekanism/client/nei/EnrichmentChamberRecipeHandler.java b/src/main/java/mekanism/client/nei/EnrichmentChamberRecipeHandler.java index f32986f6b..5e1539c9b 100644 --- a/src/main/java/mekanism/client/nei/EnrichmentChamberRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/EnrichmentChamberRecipeHandler.java @@ -8,41 +8,34 @@ import mekanism.common.recipe.RecipeHandler.Recipe; import mekanism.common.recipe.machines.EnrichmentRecipe; import mekanism.common.util.LangUtils; -public class EnrichmentChamberRecipeHandler extends MachineRecipeHandler -{ - @Override - public String getRecipeName() - { - return LangUtils.localize("tile.MachineBlock.EnrichmentChamber.name"); - } +public class EnrichmentChamberRecipeHandler extends MachineRecipeHandler { + @Override + public String getRecipeName() { + return LangUtils.localize("tile.MachineBlock.EnrichmentChamber.name"); + } - @Override - public String getRecipeId() - { - return "mekanism.chamber"; - } + @Override + public String getRecipeId() { + return "mekanism.chamber"; + } - @Override - public String getOverlayIdentifier() - { - return "chamber"; - } - - @Override - public ProgressBar getProgressType() - { - return ProgressBar.BLUE; - } + @Override + public String getOverlayIdentifier() { + return "chamber"; + } - @Override - public Collection getRecipes() - { - return Recipe.ENRICHMENT_CHAMBER.get().values(); - } + @Override + public ProgressBar getProgressType() { + return ProgressBar.BLUE; + } - @Override - public Class getGuiClass() - { - return GuiEnrichmentChamber.class; - } + @Override + public Collection getRecipes() { + return Recipe.ENRICHMENT_CHAMBER.get().values(); + } + + @Override + public Class getGuiClass() { + return GuiEnrichmentChamber.class; + } } diff --git a/src/main/java/mekanism/client/nei/MachineRecipeHandler.java b/src/main/java/mekanism/client/nei/MachineRecipeHandler.java index d9551fae2..420f092c1 100644 --- a/src/main/java/mekanism/client/nei/MachineRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/MachineRecipeHandler.java @@ -6,6 +6,9 @@ import static codechicken.lib.gui.GuiDraw.drawTexturedModalRect; import java.awt.Rectangle; import java.util.Collection; +import codechicken.nei.NEIServerUtils; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.TemplateRecipeHandler; import mekanism.client.gui.element.GuiElement; import mekanism.client.gui.element.GuiPowerBar; import mekanism.client.gui.element.GuiPowerBar.IPowerInfoHandler; @@ -19,146 +22,148 @@ import mekanism.common.recipe.machines.BasicMachineRecipe; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.item.ItemStack; - import org.lwjgl.opengl.GL11; -import codechicken.nei.NEIServerUtils; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.TemplateRecipeHandler; +public abstract class MachineRecipeHandler extends BaseRecipeHandler { + private int ticksPassed; -public abstract class MachineRecipeHandler extends BaseRecipeHandler -{ - private int ticksPassed; + public abstract String getRecipeId(); - public abstract String getRecipeId(); + public abstract Collection getRecipes(); - public abstract Collection getRecipes(); + public abstract ProgressBar getProgressType(); - public abstract ProgressBar getProgressType(); + @Override + public void addGuiElements() { + guiElements.add(new GuiSlot( + SlotType.INPUT, + this, + MekanismUtils.getResource(ResourceType.GUI, stripTexture()), + 55, + 16 + )); + guiElements.add(new GuiSlot( + SlotType.POWER, + this, + MekanismUtils.getResource(ResourceType.GUI, stripTexture()), + 55, + 52 + ) + .with(SlotOverlay.POWER)); + guiElements.add(new GuiSlot( + SlotType.OUTPUT_LARGE, + this, + MekanismUtils.getResource(ResourceType.GUI, stripTexture()), + 111, + 30 + )); - @Override - public void addGuiElements() - { - guiElements.add(new GuiSlot(SlotType.INPUT, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 55, 16)); - guiElements.add(new GuiSlot(SlotType.POWER, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 55, 52).with(SlotOverlay.POWER)); - guiElements.add(new GuiSlot(SlotType.OUTPUT_LARGE, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 111, 30)); + guiElements.add(new GuiPowerBar(this, new IPowerInfoHandler() { + @Override + public double getLevel() { + return ticksPassed <= 20 ? ticksPassed / 20.0F : 1.0F; + } + }, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 164, 15)); + guiElements.add(new GuiProgress( + new IProgressInfoHandler() { + @Override + public double getProgress() { + return ticksPassed >= 20 ? (ticksPassed - 20) % 20 / 20.0F : 0.0F; + } + }, + getProgressType(), + this, + MekanismUtils.getResource(ResourceType.GUI, stripTexture()), + 77, + 37 + )); + } - guiElements.add(new GuiPowerBar(this, new IPowerInfoHandler() { - @Override - public double getLevel() - { - return ticksPassed <= 20 ? ticksPassed / 20.0F : 1.0F; - } - }, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 164, 15)); - guiElements.add(new GuiProgress(new IProgressInfoHandler() - { - @Override - public double getProgress() - { - return ticksPassed >= 20 ? (ticksPassed - 20) % 20 / 20.0F : 0.0F; - } - }, getProgressType(), this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 77, 37)); - } + @Override + public void drawBackground(int i) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + changeTexture(getGuiTexture()); + drawTexturedModalRect(12, 0, 28, 5, 144, 68); - @Override - public void drawBackground(int i) - { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - changeTexture(getGuiTexture()); - drawTexturedModalRect(12, 0, 28, 5, 144, 68); - - for(GuiElement e : guiElements) - { - e.renderBackground(0, 0, -16, -5); - } - } + for (GuiElement e : guiElements) { + e.renderBackground(0, 0, -16, -5); + } + } - @Override - public void onUpdate() - { - super.onUpdate(); - ticksPassed++; - } + @Override + public void onUpdate() { + super.onUpdate(); + ticksPassed++; + } - @Override - public void loadTransferRects() - { - transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(63, 34, 24, 7), getRecipeId(), new Object[0])); - } + @Override + public void loadTransferRects() { + transferRects.add(new TemplateRecipeHandler.RecipeTransferRect( + new Rectangle(63, 34, 24, 7), getRecipeId(), new Object[0] + )); + } - @Override - public void loadCraftingRecipes(String outputId, Object... results) - { - if(outputId.equals(getRecipeId())) - { - for(BasicMachineRecipe irecipe : getRecipes()) - { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - else { - super.loadCraftingRecipes(outputId, results); - } - } + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals(getRecipeId())) { + for (BasicMachineRecipe irecipe : getRecipes()) { + arecipes.add(new CachedIORecipe(irecipe)); + } + } else { + super.loadCraftingRecipes(outputId, results); + } + } - @Override - public void loadCraftingRecipes(ItemStack result) - { - for(BasicMachineRecipe irecipe : getRecipes()) - { - if(NEIServerUtils.areStacksSameTypeCrafting(irecipe.getOutput().output, result)) - { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - } + @Override + public void loadCraftingRecipes(ItemStack result) { + for (BasicMachineRecipe irecipe : getRecipes()) { + if (NEIServerUtils.areStacksSameTypeCrafting( + irecipe.getOutput().output, result + )) { + arecipes.add(new CachedIORecipe(irecipe)); + } + } + } - @Override - public String getGuiTexture() - { - return "mekanism:gui/GuiBasicMachine.png"; - } + @Override + public String getGuiTexture() { + return "mekanism:gui/GuiBasicMachine.png"; + } - @Override - public void loadUsageRecipes(ItemStack ingredient) - { - for(BasicMachineRecipe irecipe : getRecipes()) - { - if(NEIServerUtils.areStacksSameTypeCrafting(irecipe.getInput().ingredient, ingredient)) - { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - } + @Override + public void loadUsageRecipes(ItemStack ingredient) { + for (BasicMachineRecipe irecipe : getRecipes()) { + if (NEIServerUtils.areStacksSameTypeCrafting( + irecipe.getInput().ingredient, ingredient + )) { + arecipes.add(new CachedIORecipe(irecipe)); + } + } + } - public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe - { - public PositionedStack input; - public PositionedStack output; + public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe { + public PositionedStack input; + public PositionedStack output; - @Override - public PositionedStack getIngredient() - { - return input; - } + @Override + public PositionedStack getIngredient() { + return input; + } - @Override - public PositionedStack getResult() - { - return output; - } + @Override + public PositionedStack getResult() { + return output; + } - public CachedIORecipe(ItemStack itemstack, ItemStack itemstack1) - { - super(); - - input = new PositionedStack(itemstack, 40, 12); - output = new PositionedStack(itemstack1, 100, 30); - } + public CachedIORecipe(ItemStack itemstack, ItemStack itemstack1) { + super(); - public CachedIORecipe(BasicMachineRecipe recipe) - { - this(recipe.getInput().ingredient, recipe.getOutput().output); - } - } + input = new PositionedStack(itemstack, 40, 12); + output = new PositionedStack(itemstack1, 100, 30); + } + + public CachedIORecipe(BasicMachineRecipe recipe) { + this(recipe.getInput().ingredient, recipe.getOutput().output); + } + } } diff --git a/src/main/java/mekanism/client/nei/MekanismSlotClickHandler.java b/src/main/java/mekanism/client/nei/MekanismSlotClickHandler.java index 229831a5b..121e74974 100644 --- a/src/main/java/mekanism/client/nei/MekanismSlotClickHandler.java +++ b/src/main/java/mekanism/client/nei/MekanismSlotClickHandler.java @@ -1,33 +1,36 @@ package mekanism.client.nei; +import codechicken.nei.guihook.IContainerSlotClickHandler; import mekanism.client.gui.GuiMekanism; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.inventory.Slot; -import codechicken.nei.guihook.IContainerSlotClickHandler; -public class MekanismSlotClickHandler implements IContainerSlotClickHandler -{ - @Override - public void beforeSlotClick(GuiContainer gui, int slotIndex, int button, Slot slot, int modifier) - { - - } +public class MekanismSlotClickHandler implements IContainerSlotClickHandler { + @Override + public void beforeSlotClick( + GuiContainer gui, int slotIndex, int button, Slot slot, int modifier + ) {} - @Override - public boolean handleSlotClick(GuiContainer gui, int slotIndex, int button, Slot slot, int modifier, boolean eventconsumed) - { - if(gui instanceof GuiMekanism) - { - ((GuiMekanism)gui).handleMouse(slot, slotIndex, button, modifier); - return true; - } - - return false; - } + @Override + public boolean handleSlotClick( + GuiContainer gui, + int slotIndex, + int button, + Slot slot, + int modifier, + boolean eventconsumed + ) { + if (gui instanceof GuiMekanism) { + ((GuiMekanism) gui).handleMouse(slot, slotIndex, button, modifier); + return true; + } - @Override - public void afterSlotClick(GuiContainer gui, int slotIndex, int button, Slot slot, int modifier) - { - - } + return false; + } + + @Override + public void + afterSlotClick(GuiContainer gui, int slotIndex, int button, Slot slot, int modifier) { + + } } diff --git a/src/main/java/mekanism/client/nei/MetallurgicInfuserRecipeHandler.java b/src/main/java/mekanism/client/nei/MetallurgicInfuserRecipeHandler.java index f8053382e..52f510f42 100644 --- a/src/main/java/mekanism/client/nei/MetallurgicInfuserRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/MetallurgicInfuserRecipeHandler.java @@ -9,6 +9,9 @@ import java.util.Collection; import java.util.List; import java.util.Map; +import codechicken.nei.NEIServerUtils; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.TemplateRecipeHandler; import mekanism.api.infuse.InfuseObject; import mekanism.api.infuse.InfuseRegistry; import mekanism.api.infuse.InfuseType; @@ -29,229 +32,248 @@ import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.item.ItemStack; - import org.lwjgl.opengl.GL11; -import codechicken.nei.NEIServerUtils; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.TemplateRecipeHandler; +public class MetallurgicInfuserRecipeHandler extends BaseRecipeHandler { + private int ticksPassed; -public class MetallurgicInfuserRecipeHandler extends BaseRecipeHandler -{ - private int ticksPassed; - - @Override - public void addGuiElements() - { - guiElements.add(new GuiSlot(SlotType.EXTRA, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 16, 34)); - guiElements.add(new GuiSlot(SlotType.INPUT, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 50, 42)); - guiElements.add(new GuiSlot(SlotType.POWER, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 142, 34).with(SlotOverlay.POWER)); - guiElements.add(new GuiSlot(SlotType.OUTPUT, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 108, 42)); + @Override + public void addGuiElements() { + guiElements.add(new GuiSlot( + SlotType.EXTRA, + this, + MekanismUtils.getResource(ResourceType.GUI, stripTexture()), + 16, + 34 + )); + guiElements.add(new GuiSlot( + SlotType.INPUT, + this, + MekanismUtils.getResource(ResourceType.GUI, stripTexture()), + 50, + 42 + )); + guiElements.add(new GuiSlot( + SlotType.POWER, + this, + MekanismUtils.getResource(ResourceType.GUI, stripTexture()), + 142, + 34 + ) + .with(SlotOverlay.POWER)); + guiElements.add(new GuiSlot( + SlotType.OUTPUT, + this, + MekanismUtils.getResource(ResourceType.GUI, stripTexture()), + 108, + 42 + )); - guiElements.add(new GuiPowerBar(this, new IPowerInfoHandler() { - @Override - public double getLevel() - { - return ticksPassed <= 20 ? ticksPassed / 20.0F : 1.0F; - } - }, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 164, 15)); - guiElements.add(new GuiProgress(new IProgressInfoHandler() { - @Override - public double getProgress() - { - return ticksPassed >= 40 ? (ticksPassed - 40) % 20 / 20.0F : 0.0F; - } - }, ProgressBar.MEDIUM, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 70, 46)); - } + guiElements.add(new GuiPowerBar(this, new IPowerInfoHandler() { + @Override + public double getLevel() { + return ticksPassed <= 20 ? ticksPassed / 20.0F : 1.0F; + } + }, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 164, 15)); + guiElements.add(new GuiProgress( + new IProgressInfoHandler() { + @Override + public double getProgress() { + return ticksPassed >= 40 ? (ticksPassed - 40) % 20 / 20.0F : 0.0F; + } + }, + ProgressBar.MEDIUM, + this, + MekanismUtils.getResource(ResourceType.GUI, stripTexture()), + 70, + 46 + )); + } - @Override - public String getRecipeName() - { - return LangUtils.localize("tile.MachineBlock.MetallurgicInfuser.name"); - } + @Override + public String getRecipeName() { + return LangUtils.localize("tile.MachineBlock.MetallurgicInfuser.name"); + } - @Override - public String getOverlayIdentifier() - { - return "infuser"; - } + @Override + public String getOverlayIdentifier() { + return "infuser"; + } - @Override - public String getGuiTexture() - { - return "mekanism:gui/GuiMetallurgicInfuser.png"; - } + @Override + public String getGuiTexture() { + return "mekanism:gui/GuiMetallurgicInfuser.png"; + } - @Override - public Class getGuiClass() - { - return GuiMetallurgicInfuser.class; - } + @Override + public Class getGuiClass() { + return GuiMetallurgicInfuser.class; + } - public String getRecipeId() - { - return "mekanism.infuser"; - } + public String getRecipeId() { + return "mekanism.infuser"; + } - public List getInfuseStacks(InfuseType type) - { - List ret = new ArrayList(); + public List getInfuseStacks(InfuseType type) { + List ret = new ArrayList(); - for(Map.Entry obj : InfuseRegistry.getObjectMap().entrySet()) - { - if(obj.getValue().type == type) - { - ret.add(obj.getKey()); - } - } + for (Map.Entry obj : + InfuseRegistry.getObjectMap().entrySet()) { + if (obj.getValue().type == type) { + ret.add(obj.getKey()); + } + } - return ret; - } + return ret; + } - public Collection getRecipes() - { - return Recipe.METALLURGIC_INFUSER.get().values(); - } + public Collection getRecipes() { + return Recipe.METALLURGIC_INFUSER.get().values(); + } - @Override - public void drawBackground(int i) - { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - changeTexture(getGuiTexture()); - drawTexturedModalRect(0, 0, 5, 15, 166, 56); - - for(GuiElement e : guiElements) - { - e.renderBackground(0, 0, -5, -15); - } - } + @Override + public void drawBackground(int i) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + changeTexture(getGuiTexture()); + drawTexturedModalRect(0, 0, 5, 15, 166, 56); - @Override - public void drawExtras(int i) - { - InfuseType type = ((CachedIORecipe)arecipes.get(i)).infusionType; + for (GuiElement e : guiElements) { + e.renderBackground(0, 0, -5, -15); + } + } - float f = ticksPassed >= 20 && ticksPassed < 40 ? (ticksPassed - 20) % 20 / 20.0F : 1.0F; - if(ticksPassed < 20) f = 0.0F; + @Override + public void drawExtras(int i) { + InfuseType type = ((CachedIORecipe) arecipes.get(i)).infusionType; - int display = (int)(52F*f); - changeTexture(MekanismRenderer.getBlocksTexture()); - drawTexturedRectFromIcon(2, 2+52-display, type.icon, 4, display); - } + float f = ticksPassed >= 20 && ticksPassed < 40 ? (ticksPassed - 20) % 20 / 20.0F + : 1.0F; + if (ticksPassed < 20) + f = 0.0F; - @Override - public void onUpdate() - { - super.onUpdate(); + int display = (int) (52F * f); + changeTexture(MekanismRenderer.getBlocksTexture()); + drawTexturedRectFromIcon(2, 2 + 52 - display, type.icon, 4, display); + } - ticksPassed++; - } + @Override + public void onUpdate() { + super.onUpdate(); - @Override - public void loadTransferRects() - { - transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(67, 32, 32, 8), getRecipeId(), new Object[0])); - } + ticksPassed++; + } - @Override - public void loadCraftingRecipes(String outputId, Object... results) - { - if(outputId.equals(getRecipeId())) - { - for(MetallurgicInfuserRecipe irecipe : getRecipes()) - { - arecipes.add(new CachedIORecipe(irecipe, getInfuseStacks(irecipe.getInput().infuse.type), irecipe.getInput().infuse.type)); - } - } - else { - super.loadCraftingRecipes(outputId, results); - } - } + @Override + public void loadTransferRects() { + transferRects.add(new TemplateRecipeHandler.RecipeTransferRect( + new Rectangle(67, 32, 32, 8), getRecipeId(), new Object[0] + )); + } - @Override - public int recipiesPerPage() - { - return 2; - } + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals(getRecipeId())) { + for (MetallurgicInfuserRecipe irecipe : getRecipes()) { + arecipes.add(new CachedIORecipe( + irecipe, + getInfuseStacks(irecipe.getInput().infuse.type), + irecipe.getInput().infuse.type + )); + } + } else { + super.loadCraftingRecipes(outputId, results); + } + } - @Override - public void loadCraftingRecipes(ItemStack result) - { - for(MetallurgicInfuserRecipe irecipe : getRecipes()) - { - if(NEIServerUtils.areStacksSameTypeCrafting(irecipe.getOutput().output, result)) - { - arecipes.add(new CachedIORecipe(irecipe, getInfuseStacks(irecipe.getInput().infuse.type), irecipe.getInput().infuse.type)); - } - } - } + @Override + public int recipiesPerPage() { + return 2; + } - @Override - public void loadUsageRecipes(ItemStack ingredient) - { - for(MetallurgicInfuserRecipe irecipe : getRecipes()) - { - if(NEIServerUtils.areStacksSameTypeCrafting(irecipe.getInput().inputStack, ingredient)) - { - arecipes.add(new CachedIORecipe(irecipe, getInfuseStacks(irecipe.getInput().infuse.type), irecipe.getInput().infuse.type)); - } - - List infuses; - - for(ItemStack stack : getInfuseStacks(irecipe.getInput().infuse.type)) - { - if(NEIServerUtils.areStacksSameTypeCrafting(stack, ingredient)) - { - infuses = new ArrayList(); - infuses.add(stack); - arecipes.add(new CachedIORecipe(irecipe, infuses, irecipe.getInput().infuse.type)); - } - } - } - } + @Override + public void loadCraftingRecipes(ItemStack result) { + for (MetallurgicInfuserRecipe irecipe : getRecipes()) { + if (NEIServerUtils.areStacksSameTypeCrafting( + irecipe.getOutput().output, result + )) { + arecipes.add(new CachedIORecipe( + irecipe, + getInfuseStacks(irecipe.getInput().infuse.type), + irecipe.getInput().infuse.type + )); + } + } + } - public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe - { - public List infuseStacks; + @Override + public void loadUsageRecipes(ItemStack ingredient) { + for (MetallurgicInfuserRecipe irecipe : getRecipes()) { + if (NEIServerUtils.areStacksSameTypeCrafting( + irecipe.getInput().inputStack, ingredient + )) { + arecipes.add(new CachedIORecipe( + irecipe, + getInfuseStacks(irecipe.getInput().infuse.type), + irecipe.getInput().infuse.type + )); + } - public PositionedStack inputStack; - public PositionedStack outputStack; + List infuses; - public InfuseType infusionType; + for (ItemStack stack : getInfuseStacks(irecipe.getInput().infuse.type)) { + if (NEIServerUtils.areStacksSameTypeCrafting(stack, ingredient)) { + infuses = new ArrayList(); + infuses.add(stack); + arecipes.add(new CachedIORecipe( + irecipe, infuses, irecipe.getInput().infuse.type + )); + } + } + } + } - @Override - public PositionedStack getIngredient() - { - return inputStack; - } + public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe { + public List infuseStacks; - @Override - public PositionedStack getResult() - { - return outputStack; - } + public PositionedStack inputStack; + public PositionedStack outputStack; - @Override - public PositionedStack getOtherStack() - { - return new PositionedStack(infuseStacks.get(cycleticks/40 % infuseStacks.size()), 12, 20); - } + public InfuseType infusionType; - public CachedIORecipe(ItemStack input, ItemStack output, List infuses, InfuseType type) - { - super(); + @Override + public PositionedStack getIngredient() { + return inputStack; + } - inputStack = new PositionedStack(input, 46, 28); - outputStack = new PositionedStack(output, 104, 28); + @Override + public PositionedStack getResult() { + return outputStack; + } - infuseStacks = infuses; + @Override + public PositionedStack getOtherStack() { + return new PositionedStack( + infuseStacks.get(cycleticks / 40 % infuseStacks.size()), 12, 20 + ); + } - infusionType = type; - } + public CachedIORecipe( + ItemStack input, ItemStack output, List infuses, InfuseType type + ) { + super(); - public CachedIORecipe(MetallurgicInfuserRecipe recipe, List infuses, InfuseType type) - { - this(recipe.getInput().inputStack, recipe.getOutput().output, infuses, type); - } - } + inputStack = new PositionedStack(input, 46, 28); + outputStack = new PositionedStack(output, 104, 28); + + infuseStacks = infuses; + + infusionType = type; + } + + public CachedIORecipe( + MetallurgicInfuserRecipe recipe, List infuses, InfuseType type + ) { + this(recipe.getInput().inputStack, recipe.getOutput().output, infuses, type); + } + } } diff --git a/src/main/java/mekanism/client/nei/NEIMekanismConfig.java b/src/main/java/mekanism/client/nei/NEIMekanismConfig.java index ba13363e2..6fa54e094 100644 --- a/src/main/java/mekanism/client/nei/NEIMekanismConfig.java +++ b/src/main/java/mekanism/client/nei/NEIMekanismConfig.java @@ -1,5 +1,8 @@ package mekanism.client.nei; +import codechicken.nei.api.API; +import codechicken.nei.api.IConfigureNEI; +import codechicken.nei.guihook.GuiContainerManager; import mekanism.client.gui.GuiChemicalCrystallizer; import mekanism.client.gui.GuiChemicalDissolutionChamber; import mekanism.client.gui.GuiChemicalInfuser; @@ -21,115 +24,150 @@ import mekanism.client.gui.GuiThermalEvaporationController; import mekanism.common.MekanismBlocks; import mekanism.common.MekanismItems; import net.minecraft.item.ItemStack; -import codechicken.nei.api.API; -import codechicken.nei.api.IConfigureNEI; -import codechicken.nei.guihook.GuiContainerManager; -public class NEIMekanismConfig implements IConfigureNEI -{ - @Override - public void loadConfig() - { - API.registerRecipeHandler(new EnrichmentChamberRecipeHandler()); - API.registerUsageHandler(new EnrichmentChamberRecipeHandler()); +public class NEIMekanismConfig implements IConfigureNEI { + @Override + public void loadConfig() { + API.registerRecipeHandler(new EnrichmentChamberRecipeHandler()); + API.registerUsageHandler(new EnrichmentChamberRecipeHandler()); - API.registerRecipeHandler(new OsmiumCompressorRecipeHandler()); - API.registerUsageHandler(new OsmiumCompressorRecipeHandler()); + API.registerRecipeHandler(new OsmiumCompressorRecipeHandler()); + API.registerUsageHandler(new OsmiumCompressorRecipeHandler()); - API.registerRecipeHandler(new CrusherRecipeHandler()); - API.registerUsageHandler(new CrusherRecipeHandler()); + API.registerRecipeHandler(new CrusherRecipeHandler()); + API.registerUsageHandler(new CrusherRecipeHandler()); - API.registerRecipeHandler(new CombinerRecipeHandler()); - API.registerUsageHandler(new CombinerRecipeHandler()); + API.registerRecipeHandler(new CombinerRecipeHandler()); + API.registerUsageHandler(new CombinerRecipeHandler()); - API.registerRecipeHandler(new MetallurgicInfuserRecipeHandler()); - API.registerUsageHandler(new MetallurgicInfuserRecipeHandler()); + API.registerRecipeHandler(new MetallurgicInfuserRecipeHandler()); + API.registerUsageHandler(new MetallurgicInfuserRecipeHandler()); - API.registerRecipeHandler(new PurificationChamberRecipeHandler()); - API.registerUsageHandler(new PurificationChamberRecipeHandler()); + API.registerRecipeHandler(new PurificationChamberRecipeHandler()); + API.registerUsageHandler(new PurificationChamberRecipeHandler()); - API.registerRecipeHandler(new ChemicalInjectionChamberRecipeHandler()); - API.registerUsageHandler(new ChemicalInjectionChamberRecipeHandler()); + API.registerRecipeHandler(new ChemicalInjectionChamberRecipeHandler()); + API.registerUsageHandler(new ChemicalInjectionChamberRecipeHandler()); - API.registerRecipeHandler(new ChemicalOxidizerRecipeHandler()); - API.registerUsageHandler(new ChemicalOxidizerRecipeHandler()); + API.registerRecipeHandler(new ChemicalOxidizerRecipeHandler()); + API.registerUsageHandler(new ChemicalOxidizerRecipeHandler()); - API.registerRecipeHandler(new ChemicalInfuserRecipeHandler()); - API.registerUsageHandler(new ChemicalInfuserRecipeHandler()); + API.registerRecipeHandler(new ChemicalInfuserRecipeHandler()); + API.registerUsageHandler(new ChemicalInfuserRecipeHandler()); - API.registerRecipeHandler(new RotaryCondensentratorRecipeHandler()); - API.registerUsageHandler(new RotaryCondensentratorRecipeHandler()); + API.registerRecipeHandler(new RotaryCondensentratorRecipeHandler()); + API.registerUsageHandler(new RotaryCondensentratorRecipeHandler()); - API.registerRecipeHandler(new ElectrolyticSeparatorRecipeHandler()); - API.registerUsageHandler(new ElectrolyticSeparatorRecipeHandler()); + API.registerRecipeHandler(new ElectrolyticSeparatorRecipeHandler()); + API.registerUsageHandler(new ElectrolyticSeparatorRecipeHandler()); - API.registerRecipeHandler(new PrecisionSawmillRecipeHandler()); - API.registerUsageHandler(new PrecisionSawmillRecipeHandler()); + API.registerRecipeHandler(new PrecisionSawmillRecipeHandler()); + API.registerUsageHandler(new PrecisionSawmillRecipeHandler()); - API.registerRecipeHandler(new ThermalEvaporationRecipeHandler()); - API.registerUsageHandler(new ThermalEvaporationRecipeHandler()); + API.registerRecipeHandler(new ThermalEvaporationRecipeHandler()); + API.registerUsageHandler(new ThermalEvaporationRecipeHandler()); - API.registerRecipeHandler(new ChemicalDissolutionChamberRecipeHandler()); - API.registerUsageHandler(new ChemicalDissolutionChamberRecipeHandler()); + API.registerRecipeHandler(new ChemicalDissolutionChamberRecipeHandler()); + API.registerUsageHandler(new ChemicalDissolutionChamberRecipeHandler()); - API.registerRecipeHandler(new ChemicalWasherRecipeHandler()); - API.registerUsageHandler(new ChemicalWasherRecipeHandler()); + API.registerRecipeHandler(new ChemicalWasherRecipeHandler()); + API.registerUsageHandler(new ChemicalWasherRecipeHandler()); - API.registerRecipeHandler(new ChemicalCrystallizerRecipeHandler()); - API.registerUsageHandler(new ChemicalCrystallizerRecipeHandler()); - - API.registerRecipeHandler(new PRCRecipeHandler()); - API.registerUsageHandler(new PRCRecipeHandler()); - - API.registerRecipeHandler(new SolarNeutronRecipeHandler()); - API.registerUsageHandler(new SolarNeutronRecipeHandler()); - - API.registerRecipeHandler(new TheoreticalElementizerRecipeHandler()); - API.registerUsageHandler(new TheoreticalElementizerRecipeHandler()); + API.registerRecipeHandler(new ChemicalCrystallizerRecipeHandler()); + API.registerUsageHandler(new ChemicalCrystallizerRecipeHandler()); - API.registerRecipeHandler(new ShapedMekanismRecipeHandler()); - API.registerUsageHandler(new ShapedMekanismRecipeHandler()); - - API.registerRecipeHandler(new ShapelessMekanismRecipeHandler()); - API.registerUsageHandler(new ShapelessMekanismRecipeHandler()); + API.registerRecipeHandler(new PRCRecipeHandler()); + API.registerUsageHandler(new PRCRecipeHandler()); - API.setGuiOffset(GuiEnrichmentChamber.class, 16, 6); - API.setGuiOffset(GuiOsmiumCompressor.class, 16, 6); - API.setGuiOffset(GuiCrusher.class, 16, 6); - API.setGuiOffset(GuiCombiner.class, 16, 6); - API.setGuiOffset(GuiPurificationChamber.class, 16, 6); - API.setGuiOffset(GuiChemicalInjectionChamber.class, 16, 6); - API.setGuiOffset(GuiMetallurgicInfuser.class, 5, 15); - API.setGuiOffset(GuiChemicalOxidizer.class, ChemicalOxidizerRecipeHandler.xOffset, ChemicalOxidizerRecipeHandler.yOffset); - API.setGuiOffset(GuiChemicalInfuser.class, ChemicalInfuserRecipeHandler.xOffset, ChemicalInfuserRecipeHandler.yOffset); - API.setGuiOffset(GuiRotaryCondensentrator.class, RotaryCondensentratorRecipeHandler.xOffset, RotaryCondensentratorRecipeHandler.yOffset); - API.setGuiOffset(GuiElectrolyticSeparator.class, ElectrolyticSeparatorRecipeHandler.xOffset, ElectrolyticSeparatorRecipeHandler.yOffset); - API.setGuiOffset(GuiPrecisionSawmill.class, 16, 6); - API.setGuiOffset(GuiThermalEvaporationController.class, ThermalEvaporationRecipeHandler.xOffset, ThermalEvaporationRecipeHandler.yOffset); - API.setGuiOffset(GuiChemicalDissolutionChamber.class, ChemicalDissolutionChamberRecipeHandler.xOffset, ChemicalDissolutionChamberRecipeHandler.yOffset); - API.setGuiOffset(GuiChemicalWasher.class, ChemicalWasherRecipeHandler.xOffset, ChemicalWasherRecipeHandler.yOffset); - API.setGuiOffset(GuiChemicalCrystallizer.class, ChemicalCrystallizerRecipeHandler.xOffset, ChemicalCrystallizerRecipeHandler.yOffset); - API.setGuiOffset(GuiPRC.class, PRCRecipeHandler.xOffset, PRCRecipeHandler.yOffset); - API.setGuiOffset(GuiThermalEvaporationController.class, ThermalEvaporationRecipeHandler.xOffset, ThermalEvaporationRecipeHandler.yOffset); - API.setGuiOffset(GuiSolarNeutronActivator.class, SolarNeutronRecipeHandler.xOffset, SolarNeutronRecipeHandler.yOffset); - - GuiContainerManager.addSlotClickHandler(new MekanismSlotClickHandler()); - - API.registerNEIGuiHandler(new ElementBoundHandler()); + API.registerRecipeHandler(new SolarNeutronRecipeHandler()); + API.registerUsageHandler(new SolarNeutronRecipeHandler()); - API.hideItem(new ItemStack(MekanismBlocks.BoundingBlock)); - API.hideItem(new ItemStack(MekanismItems.ItemProxy)); - } + API.registerRecipeHandler(new TheoreticalElementizerRecipeHandler()); + API.registerUsageHandler(new TheoreticalElementizerRecipeHandler()); - @Override - public String getName() - { - return "Mekanism NEI Plugin"; - } + API.registerRecipeHandler(new ShapedMekanismRecipeHandler()); + API.registerUsageHandler(new ShapedMekanismRecipeHandler()); - @Override - public String getVersion() - { - return "8.0.0"; - } + API.registerRecipeHandler(new ShapelessMekanismRecipeHandler()); + API.registerUsageHandler(new ShapelessMekanismRecipeHandler()); + + API.setGuiOffset(GuiEnrichmentChamber.class, 16, 6); + API.setGuiOffset(GuiOsmiumCompressor.class, 16, 6); + API.setGuiOffset(GuiCrusher.class, 16, 6); + API.setGuiOffset(GuiCombiner.class, 16, 6); + API.setGuiOffset(GuiPurificationChamber.class, 16, 6); + API.setGuiOffset(GuiChemicalInjectionChamber.class, 16, 6); + API.setGuiOffset(GuiMetallurgicInfuser.class, 5, 15); + API.setGuiOffset( + GuiChemicalOxidizer.class, + ChemicalOxidizerRecipeHandler.xOffset, + ChemicalOxidizerRecipeHandler.yOffset + ); + API.setGuiOffset( + GuiChemicalInfuser.class, + ChemicalInfuserRecipeHandler.xOffset, + ChemicalInfuserRecipeHandler.yOffset + ); + API.setGuiOffset( + GuiRotaryCondensentrator.class, + RotaryCondensentratorRecipeHandler.xOffset, + RotaryCondensentratorRecipeHandler.yOffset + ); + API.setGuiOffset( + GuiElectrolyticSeparator.class, + ElectrolyticSeparatorRecipeHandler.xOffset, + ElectrolyticSeparatorRecipeHandler.yOffset + ); + API.setGuiOffset(GuiPrecisionSawmill.class, 16, 6); + API.setGuiOffset( + GuiThermalEvaporationController.class, + ThermalEvaporationRecipeHandler.xOffset, + ThermalEvaporationRecipeHandler.yOffset + ); + API.setGuiOffset( + GuiChemicalDissolutionChamber.class, + ChemicalDissolutionChamberRecipeHandler.xOffset, + ChemicalDissolutionChamberRecipeHandler.yOffset + ); + API.setGuiOffset( + GuiChemicalWasher.class, + ChemicalWasherRecipeHandler.xOffset, + ChemicalWasherRecipeHandler.yOffset + ); + API.setGuiOffset( + GuiChemicalCrystallizer.class, + ChemicalCrystallizerRecipeHandler.xOffset, + ChemicalCrystallizerRecipeHandler.yOffset + ); + API.setGuiOffset( + GuiPRC.class, PRCRecipeHandler.xOffset, PRCRecipeHandler.yOffset + ); + API.setGuiOffset( + GuiThermalEvaporationController.class, + ThermalEvaporationRecipeHandler.xOffset, + ThermalEvaporationRecipeHandler.yOffset + ); + API.setGuiOffset( + GuiSolarNeutronActivator.class, + SolarNeutronRecipeHandler.xOffset, + SolarNeutronRecipeHandler.yOffset + ); + + GuiContainerManager.addSlotClickHandler(new MekanismSlotClickHandler()); + + API.registerNEIGuiHandler(new ElementBoundHandler()); + + API.hideItem(new ItemStack(MekanismBlocks.BoundingBlock)); + API.hideItem(new ItemStack(MekanismItems.ItemProxy)); + } + + @Override + public String getName() { + return "Mekanism NEI Plugin"; + } + + @Override + public String getVersion() { + return "8.0.0"; + } } diff --git a/src/main/java/mekanism/client/nei/OsmiumCompressorRecipeHandler.java b/src/main/java/mekanism/client/nei/OsmiumCompressorRecipeHandler.java index 2b6fb30a6..69f317868 100644 --- a/src/main/java/mekanism/client/nei/OsmiumCompressorRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/OsmiumCompressorRecipeHandler.java @@ -13,47 +13,39 @@ import mekanism.common.recipe.machines.OsmiumCompressorRecipe; import mekanism.common.util.LangUtils; import net.minecraft.item.ItemStack; -public class OsmiumCompressorRecipeHandler extends AdvancedMachineRecipeHandler -{ - @Override - public String getRecipeName() - { - return LangUtils.localize("tile.MachineBlock.OsmiumCompressor.name"); - } +public class OsmiumCompressorRecipeHandler extends AdvancedMachineRecipeHandler { + @Override + public String getRecipeName() { + return LangUtils.localize("tile.MachineBlock.OsmiumCompressor.name"); + } - @Override - public String getRecipeId() - { - return "mekanism.compressor"; - } + @Override + public String getRecipeId() { + return "mekanism.compressor"; + } - @Override - public String getOverlayIdentifier() - { - return "compressor"; - } + @Override + public String getOverlayIdentifier() { + return "compressor"; + } - @Override - public Collection getRecipes() - { - return Recipe.OSMIUM_COMPRESSOR.get().values(); - } - - @Override - public ProgressBar getProgressType() - { - return ProgressBar.RED; - } + @Override + public Collection getRecipes() { + return Recipe.OSMIUM_COMPRESSOR.get().values(); + } - @Override - public List getFuelStacks(Gas gasType) - { - return ListUtils.asList(new ItemStack(MekanismItems.Ingot, 1, 1)); - } + @Override + public ProgressBar getProgressType() { + return ProgressBar.RED; + } - @Override - public Class getGuiClass() - { - return GuiOsmiumCompressor.class; - } + @Override + public List getFuelStacks(Gas gasType) { + return ListUtils.asList(new ItemStack(MekanismItems.Ingot, 1, 1)); + } + + @Override + public Class getGuiClass() { + return GuiOsmiumCompressor.class; + } } diff --git a/src/main/java/mekanism/client/nei/PRCRecipeHandler.java b/src/main/java/mekanism/client/nei/PRCRecipeHandler.java index 4dbb1484b..3898eb3ed 100644 --- a/src/main/java/mekanism/client/nei/PRCRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/PRCRecipeHandler.java @@ -10,6 +10,12 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.NEIClientConfig; +import codechicken.nei.NEIServerUtils; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.GuiRecipe; +import codechicken.nei.recipe.TemplateRecipeHandler; import mekanism.api.gas.GasStack; import mekanism.client.gui.GuiPRC; import mekanism.client.gui.element.GuiElement; @@ -34,410 +40,428 @@ import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; - import org.lwjgl.opengl.GL11; -import codechicken.lib.gui.GuiDraw; -import codechicken.nei.NEIClientConfig; -import codechicken.nei.NEIServerUtils; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.GuiRecipe; -import codechicken.nei.recipe.TemplateRecipeHandler; +public class PRCRecipeHandler extends BaseRecipeHandler { + private int ticksPassed; -public class PRCRecipeHandler extends BaseRecipeHandler -{ - private int ticksPassed; - - public GuiFluidGauge fluidInput; - public GuiGasGauge gasInput; - public GuiGasGauge gasOutput; - - public static int xOffset = 5; - public static int yOffset = 11; - - @Override - public void addGuiElements() - { - guiElements.add(new GuiSlot(SlotType.INPUT, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 53, 34)); - guiElements.add(new GuiSlot(SlotType.POWER, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 140, 18).with(SlotOverlay.POWER)); - guiElements.add(new GuiSlot(SlotType.OUTPUT, this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 115, 34)); - - guiElements.add(fluidInput = GuiFluidGauge.getDummy(GuiGauge.Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiPRC.png"), 5, 10)); - guiElements.add(gasInput = GuiGasGauge.getDummy(GuiGauge.Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiPRC.png"), 28, 10)); - guiElements.add(gasOutput = GuiGasGauge.getDummy(GuiGauge.Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiPRC.png"), 140, 40)); + public GuiFluidGauge fluidInput; + public GuiGasGauge gasInput; + public GuiGasGauge gasOutput; - guiElements.add(new GuiPowerBar(this, new IPowerInfoHandler() { - @Override - public double getLevel() - { - return ticksPassed <= 20 ? ticksPassed / 20.0F : 1.0F; - } - }, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 164, 15)); - guiElements.add(new GuiProgress(new IProgressInfoHandler() - { - @Override - public double getProgress() - { - return ticksPassed >= 20 ? (ticksPassed - 20) % 20 / 20.0F : 0.0F; - } - }, getProgressType(), this, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 75, 37)); - } - - public ProgressBar getProgressType() - { - return ProgressBar.MEDIUM; - } - - public Set> getRecipes() - { - return Recipe.PRESSURIZED_REACTION_CHAMBER.get().entrySet(); - } - - @Override - public void drawBackground(int i) - { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - changeTexture(getGuiTexture()); - drawTexturedModalRect(-2, 0, 3, yOffset, 170, 68); - - for(GuiElement e : guiElements) - { - e.renderBackground(0, 0, -xOffset, -yOffset); - } - } - - @Override - public void loadTransferRects() - { - transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(75-xOffset, 37-yOffset, 36, 10), getRecipeId(), new Object[0])); - } - - @Override - public void onUpdate() - { - super.onUpdate(); - ticksPassed++; - } - - @Override - public String getRecipeName() - { - return LangUtils.localize("tile.MachineBlock2.PressurizedReactionChamber.short.name"); - } - - @Override - public Class getGuiClass() - { - return GuiPRC.class; - } - - @Override - public String getOverlayIdentifier() - { - return "prc"; - } - - @Override - public int recipiesPerPage() - { - return 2; - } - - public String getRecipeId() - { - return "mekanism.prc"; - } - - @Override - public String getGuiTexture() - { - return "mekanism:gui/nei/GuiPRC.png"; - } - - @Override - public void drawExtras(int i) - { - CachedIORecipe recipe = (CachedIORecipe)arecipes.get(i); - - if(recipe.pressurizedRecipe.getInput().getFluid() != null) - { - fluidInput.setDummyType(recipe.pressurizedRecipe.getInput().getFluid().getFluid()); - fluidInput.renderScale(0, 0, -xOffset, -yOffset); - } + public static int xOffset = 5; + public static int yOffset = 11; - if(recipe.pressurizedRecipe.getInput().getGas() != null) - { - gasInput.setDummyType(recipe.pressurizedRecipe.getInput().getGas().getGas()); - gasInput.renderScale(0, 0, -xOffset, -yOffset); - } + @Override + public void addGuiElements() { + guiElements.add(new GuiSlot( + SlotType.INPUT, + this, + MekanismUtils.getResource(ResourceType.GUI, stripTexture()), + 53, + 34 + )); + guiElements.add(new GuiSlot( + SlotType.POWER, + this, + MekanismUtils.getResource(ResourceType.GUI, stripTexture()), + 140, + 18 + ) + .with(SlotOverlay.POWER)); + guiElements.add(new GuiSlot( + SlotType.OUTPUT, + this, + MekanismUtils.getResource(ResourceType.GUI, stripTexture()), + 115, + 34 + )); - if(recipe.pressurizedRecipe.getOutput().getGasOutput() != null) - { - gasOutput.setDummyType(recipe.pressurizedRecipe.getOutput().getGasOutput().getGas()); - gasOutput.renderScale(0, 0, -xOffset, -yOffset); - } - } - - @Override - public void loadCraftingRecipes(String outputId, Object... results) - { - if(outputId.equals(getRecipeId())) - { - for(Map.Entry irecipe : getRecipes()) - { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - else if(outputId.equals("gas") && results.length == 1 && results[0] instanceof GasStack) - { - for(Map.Entry irecipe : getRecipes()) - { - if(irecipe.getValue().getOutput().getGasOutput().isGasEqual((GasStack)results[0])) - { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - } - else { - super.loadCraftingRecipes(outputId, results); - } - } - - @Override - public void loadCraftingRecipes(ItemStack result) - { - for(Map.Entry irecipe : getRecipes()) - { - if(NEIServerUtils.areStacksSameTypeCrafting(irecipe.getValue().getOutput().getItemOutput(), result)) - { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - } + guiElements.add( + fluidInput = GuiFluidGauge.getDummy( + GuiGauge.Type.STANDARD, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiPRC.png"), + 5, + 10 + ) + ); + guiElements.add( + gasInput = GuiGasGauge.getDummy( + GuiGauge.Type.STANDARD, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiPRC.png"), + 28, + 10 + ) + ); + guiElements.add( + gasOutput = GuiGasGauge.getDummy( + GuiGauge.Type.SMALL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiPRC.png"), + 140, + 40 + ) + ); - @Override - public void loadUsageRecipes(String inputId, Object... ingredients) - { - if(inputId.equals("gas") && ingredients.length == 1 && ingredients[0] instanceof GasStack) - { - for(Map.Entry irecipe : getRecipes()) - { - if(irecipe.getKey().containsType((GasStack)ingredients[0])) - { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - } - else if(inputId.equals("fluid") && ingredients.length == 1 && ingredients[0] instanceof FluidStack) - { - for(Map.Entry irecipe : getRecipes()) - { - if(irecipe.getKey().containsType((FluidStack)ingredients[0])) - { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - } - else { - super.loadUsageRecipes(inputId, ingredients); - } - } - - @Override - public void loadUsageRecipes(ItemStack ingredient) - { - for(Map.Entry irecipe : getRecipes()) - { - if(NEIServerUtils.areStacksSameTypeCrafting(irecipe.getKey().getSolid(), ingredient)) - { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - } + guiElements.add(new GuiPowerBar(this, new IPowerInfoHandler() { + @Override + public double getLevel() { + return ticksPassed <= 20 ? ticksPassed / 20.0F : 1.0F; + } + }, MekanismUtils.getResource(ResourceType.GUI, stripTexture()), 164, 15)); + guiElements.add(new GuiProgress( + new IProgressInfoHandler() { + @Override + public double getProgress() { + return ticksPassed >= 20 ? (ticksPassed - 20) % 20 / 20.0F : 0.0F; + } + }, + getProgressType(), + this, + MekanismUtils.getResource(ResourceType.GUI, stripTexture()), + 75, + 37 + )); + } - @Override - public List handleTooltip(GuiRecipe gui, List currenttip, int recipe) - { - Point point = GuiDraw.getMousePosition(); - Point offset = gui.getRecipePosition(recipe); + public ProgressBar getProgressType() { + return ProgressBar.MEDIUM; + } - int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft)-offset.x; - int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop)-offset.y; + public Set> getRecipes() { + return Recipe.PRESSURIZED_REACTION_CHAMBER.get().entrySet(); + } - if(xAxis >= 6-5 && xAxis <= 22-5 && yAxis >= 11-10 && yAxis <= 69-10) - { - currenttip.add(LangUtils.localizeFluidStack(((CachedIORecipe)arecipes.get(recipe)).pressurizedRecipe.getInput().getFluid())); - } - else if(xAxis >= 29-5 && xAxis <= 45-5 && yAxis >= 11-10 && yAxis <= 69-10) - { - currenttip.add(LangUtils.localizeGasStack(((CachedIORecipe)arecipes.get(recipe)).pressurizedRecipe.getInput().getGas())); - } - else if(xAxis >= 141-5 && xAxis <= 157-5 && yAxis >= 41-10 && yAxis <= 69-10) - { - currenttip.add(LangUtils.localizeGasStack(((CachedIORecipe)arecipes.get(recipe)).pressurizedRecipe.getOutput().getGasOutput())); - } + @Override + public void drawBackground(int i) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + changeTexture(getGuiTexture()); + drawTexturedModalRect(-2, 0, 3, yOffset, 170, 68); - return super.handleTooltip(gui, currenttip, recipe); - } - - @Override - public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) - { - Point point = GuiDraw.getMousePosition(); - Point offset = gui.getRecipePosition(recipe); + for (GuiElement e : guiElements) { + e.renderBackground(0, 0, -xOffset, -yOffset); + } + } - int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft)-offset.x; - int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop)-offset.y; + @Override + public void loadTransferRects() { + transferRects.add(new TemplateRecipeHandler.RecipeTransferRect( + new Rectangle(75 - xOffset, 37 - yOffset, 36, 10), + getRecipeId(), + new Object[0] + )); + } - GasStack gas = null; - FluidStack fluid = null; + @Override + public void onUpdate() { + super.onUpdate(); + ticksPassed++; + } - if(xAxis >= 6-5 && xAxis <= 22-5 && yAxis >= 11-10 && yAxis <= 69-10) - { - fluid = ((CachedIORecipe)arecipes.get(recipe)).pressurizedRecipe.getInput().getFluid(); - } - else if(xAxis >= 29-5 && xAxis <= 45-5 && yAxis >= 11-10 && yAxis <= 69-10) - { - gas = ((CachedIORecipe)arecipes.get(recipe)).pressurizedRecipe.getInput().getGas(); - } - else if(xAxis >= 141-5 && xAxis <= 157-5 && yAxis >= 41-10 && yAxis <= 69-10) - { - gas = ((CachedIORecipe)arecipes.get(recipe)).pressurizedRecipe.getOutput().getGasOutput(); - } + @Override + public String getRecipeName() { + return LangUtils.localize( + "tile.MachineBlock2.PressurizedReactionChamber.short.name" + ); + } - if(gas != null) - { - if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) - { - if(doGasLookup(gas, false)) - { - return true; - } - } - else if(keyCode == NEIClientConfig.getKeyBinding("gui.usage")) - { - if(doGasLookup(gas, true)) - { - return true; - } - } - } - else if(fluid != null) - { - if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) - { - if(doFluidLookup(fluid, false)) - { - return true; - } - } - else if(keyCode == NEIClientConfig.getKeyBinding("gui.usage")) - { - if(doFluidLookup(fluid, true)) - { - return true; - } - } - } + @Override + public Class getGuiClass() { + return GuiPRC.class; + } - return super.keyTyped(gui, keyChar, keyCode, recipe); - } - - @Override - public boolean mouseClicked(GuiRecipe gui, int button, int recipe) - { - Point point = GuiDraw.getMousePosition(); - Point offset = gui.getRecipePosition(recipe); + @Override + public String getOverlayIdentifier() { + return "prc"; + } - int xAxis = point.x - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft)-offset.x; - int yAxis = point.y - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop)-offset.y; + @Override + public int recipiesPerPage() { + return 2; + } - GasStack gas = null; - FluidStack fluid = null; + public String getRecipeId() { + return "mekanism.prc"; + } - if(xAxis >= 6-5 && xAxis <= 22-5 && yAxis >= 11-10 && yAxis <= 69-10) - { - fluid = ((CachedIORecipe)arecipes.get(recipe)).pressurizedRecipe.getInput().getFluid(); - } - else if(xAxis >= 29-5 && xAxis <= 45-5 && yAxis >= 11-10 && yAxis <= 69-10) - { - gas = ((CachedIORecipe)arecipes.get(recipe)).pressurizedRecipe.getInput().getGas(); - } - else if(xAxis >= 141-5 && xAxis <= 157-5 && yAxis >= 41-10 && yAxis <= 69-10) - { - gas = ((CachedIORecipe)arecipes.get(recipe)).pressurizedRecipe.getOutput().getGasOutput(); - } + @Override + public String getGuiTexture() { + return "mekanism:gui/nei/GuiPRC.png"; + } - if(gas != null) - { - if(button == 0) - { - if(doGasLookup(gas, false)) - { - return true; - } - } - else if(button == 1) - { - if(doGasLookup(gas, true)) - { - return true; - } - } - } - else if(fluid != null) - { - if(button == 0) - { - if(doFluidLookup(fluid, false)) - { - return true; - } - } - else if(button == 1) - { - if(doFluidLookup(fluid, true)) - { - return true; - } - } - } + @Override + public void drawExtras(int i) { + CachedIORecipe recipe = (CachedIORecipe) arecipes.get(i); - return super.mouseClicked(gui, button, recipe); - } - - public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe - { - public PressurizedRecipe pressurizedRecipe; - - public PositionedStack input; - public PositionedStack output; + if (recipe.pressurizedRecipe.getInput().getFluid() != null) { + fluidInput.setDummyType( + recipe.pressurizedRecipe.getInput().getFluid().getFluid() + ); + fluidInput.renderScale(0, 0, -xOffset, -yOffset); + } - @Override - public PositionedStack getIngredient() - { - return input; - } + if (recipe.pressurizedRecipe.getInput().getGas() != null) { + gasInput.setDummyType(recipe.pressurizedRecipe.getInput().getGas().getGas()); + gasInput.renderScale(0, 0, -xOffset, -yOffset); + } - @Override - public PositionedStack getResult() - { - return output; - } + if (recipe.pressurizedRecipe.getOutput().getGasOutput() != null) { + gasOutput.setDummyType( + recipe.pressurizedRecipe.getOutput().getGasOutput().getGas() + ); + gasOutput.renderScale(0, 0, -xOffset, -yOffset); + } + } - public CachedIORecipe(PressurizedRecipe recipe) - { - super(); - - pressurizedRecipe = recipe; - - input = new PositionedStack(recipe.getInput().getSolid(), 54-xOffset, 35-yOffset); - output = new PositionedStack(recipe.getOutput().getItemOutput(), 116-xOffset, 35-yOffset); - } + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals(getRecipeId())) { + for (Map.Entry irecipe : getRecipes()) { + arecipes.add(new CachedIORecipe(irecipe)); + } + } else if (outputId.equals("gas") && results.length == 1 && results[0] instanceof GasStack) { + for (Map.Entry irecipe : getRecipes()) { + if (irecipe.getValue().getOutput().getGasOutput().isGasEqual((GasStack + ) results[0])) { + arecipes.add(new CachedIORecipe(irecipe)); + } + } + } else { + super.loadCraftingRecipes(outputId, results); + } + } - public CachedIORecipe(Map.Entry recipe) - { - this((PressurizedRecipe)recipe.getValue()); - } - } + @Override + public void loadCraftingRecipes(ItemStack result) { + for (Map.Entry irecipe : getRecipes()) { + if (NEIServerUtils.areStacksSameTypeCrafting( + irecipe.getValue().getOutput().getItemOutput(), result + )) { + arecipes.add(new CachedIORecipe(irecipe)); + } + } + } + + @Override + public void loadUsageRecipes(String inputId, Object... ingredients) { + if (inputId.equals("gas") && ingredients.length == 1 + && ingredients[0] instanceof GasStack) { + for (Map.Entry irecipe : getRecipes()) { + if (irecipe.getKey().containsType((GasStack) ingredients[0])) { + arecipes.add(new CachedIORecipe(irecipe)); + } + } + } else if (inputId.equals("fluid") && ingredients.length == 1 && ingredients[0] instanceof FluidStack) { + for (Map.Entry irecipe : getRecipes()) { + if (irecipe.getKey().containsType((FluidStack) ingredients[0])) { + arecipes.add(new CachedIORecipe(irecipe)); + } + } + } else { + super.loadUsageRecipes(inputId, ingredients); + } + } + + @Override + public void loadUsageRecipes(ItemStack ingredient) { + for (Map.Entry irecipe : getRecipes()) { + if (NEIServerUtils.areStacksSameTypeCrafting( + irecipe.getKey().getSolid(), ingredient + )) { + arecipes.add(new CachedIORecipe(irecipe)); + } + } + } + + @Override + public List + handleTooltip(GuiRecipe gui, List currenttip, int recipe) { + Point point = GuiDraw.getMousePosition(); + Point offset = gui.getRecipePosition(recipe); + + int xAxis = point.x + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft + ) + - offset.x; + int yAxis = point.y + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop + ) + - offset.y; + + if (xAxis >= 6 - 5 && xAxis <= 22 - 5 && yAxis >= 11 - 10 && yAxis <= 69 - 10) { + currenttip.add( + LangUtils.localizeFluidStack(((CachedIORecipe) arecipes.get(recipe)) + .pressurizedRecipe.getInput() + .getFluid()) + ); + } else if (xAxis >= 29 - 5 && xAxis <= 45 - 5 && yAxis >= 11 - 10 && yAxis <= 69 - 10) { + currenttip.add( + LangUtils.localizeGasStack(((CachedIORecipe) arecipes.get(recipe)) + .pressurizedRecipe.getInput() + .getGas()) + ); + } else if (xAxis >= 141 - 5 && xAxis <= 157 - 5 && yAxis >= 41 - 10 && yAxis <= 69 - 10) { + currenttip.add( + LangUtils.localizeGasStack(((CachedIORecipe) arecipes.get(recipe)) + .pressurizedRecipe.getOutput() + .getGasOutput()) + ); + } + + return super.handleTooltip(gui, currenttip, recipe); + } + + @Override + public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) { + Point point = GuiDraw.getMousePosition(); + Point offset = gui.getRecipePosition(recipe); + + int xAxis = point.x + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft + ) + - offset.x; + int yAxis = point.y + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop + ) + - offset.y; + + GasStack gas = null; + FluidStack fluid = null; + + if (xAxis >= 6 - 5 && xAxis <= 22 - 5 && yAxis >= 11 - 10 && yAxis <= 69 - 10) { + fluid = ((CachedIORecipe) arecipes.get(recipe)) + .pressurizedRecipe.getInput() + .getFluid(); + } else if (xAxis >= 29 - 5 && xAxis <= 45 - 5 && yAxis >= 11 - 10 && yAxis <= 69 - 10) { + gas = ((CachedIORecipe) arecipes.get(recipe)) + .pressurizedRecipe.getInput() + .getGas(); + } else if (xAxis >= 141 - 5 && xAxis <= 157 - 5 && yAxis >= 41 - 10 && yAxis <= 69 - 10) { + gas = ((CachedIORecipe) arecipes.get(recipe)) + .pressurizedRecipe.getOutput() + .getGasOutput(); + } + + if (gas != null) { + if (keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) { + if (doGasLookup(gas, false)) { + return true; + } + } else if (keyCode == NEIClientConfig.getKeyBinding("gui.usage")) { + if (doGasLookup(gas, true)) { + return true; + } + } + } else if (fluid != null) { + if (keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) { + if (doFluidLookup(fluid, false)) { + return true; + } + } else if (keyCode == NEIClientConfig.getKeyBinding("gui.usage")) { + if (doFluidLookup(fluid, true)) { + return true; + } + } + } + + return super.keyTyped(gui, keyChar, keyCode, recipe); + } + + @Override + public boolean mouseClicked(GuiRecipe gui, int button, int recipe) { + Point point = GuiDraw.getMousePosition(); + Point offset = gui.getRecipePosition(recipe); + + int xAxis = point.x + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft + ) + - offset.x; + int yAxis = point.y + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop + ) + - offset.y; + + GasStack gas = null; + FluidStack fluid = null; + + if (xAxis >= 6 - 5 && xAxis <= 22 - 5 && yAxis >= 11 - 10 && yAxis <= 69 - 10) { + fluid = ((CachedIORecipe) arecipes.get(recipe)) + .pressurizedRecipe.getInput() + .getFluid(); + } else if (xAxis >= 29 - 5 && xAxis <= 45 - 5 && yAxis >= 11 - 10 && yAxis <= 69 - 10) { + gas = ((CachedIORecipe) arecipes.get(recipe)) + .pressurizedRecipe.getInput() + .getGas(); + } else if (xAxis >= 141 - 5 && xAxis <= 157 - 5 && yAxis >= 41 - 10 && yAxis <= 69 - 10) { + gas = ((CachedIORecipe) arecipes.get(recipe)) + .pressurizedRecipe.getOutput() + .getGasOutput(); + } + + if (gas != null) { + if (button == 0) { + if (doGasLookup(gas, false)) { + return true; + } + } else if (button == 1) { + if (doGasLookup(gas, true)) { + return true; + } + } + } else if (fluid != null) { + if (button == 0) { + if (doFluidLookup(fluid, false)) { + return true; + } + } else if (button == 1) { + if (doFluidLookup(fluid, true)) { + return true; + } + } + } + + return super.mouseClicked(gui, button, recipe); + } + + public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe { + public PressurizedRecipe pressurizedRecipe; + + public PositionedStack input; + public PositionedStack output; + + @Override + public PositionedStack getIngredient() { + return input; + } + + @Override + public PositionedStack getResult() { + return output; + } + + public CachedIORecipe(PressurizedRecipe recipe) { + super(); + + pressurizedRecipe = recipe; + + input = new PositionedStack( + recipe.getInput().getSolid(), 54 - xOffset, 35 - yOffset + ); + output = new PositionedStack( + recipe.getOutput().getItemOutput(), 116 - xOffset, 35 - yOffset + ); + } + + public CachedIORecipe(Map.Entry recipe) { + this((PressurizedRecipe) recipe.getValue()); + } + } } diff --git a/src/main/java/mekanism/client/nei/PrecisionSawmillRecipeHandler.java b/src/main/java/mekanism/client/nei/PrecisionSawmillRecipeHandler.java index 9d3442119..dcf749c35 100644 --- a/src/main/java/mekanism/client/nei/PrecisionSawmillRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/PrecisionSawmillRecipeHandler.java @@ -8,41 +8,34 @@ import mekanism.common.recipe.RecipeHandler.Recipe; import mekanism.common.recipe.machines.SawmillRecipe; import mekanism.common.util.LangUtils; -public class PrecisionSawmillRecipeHandler extends ChanceMachineRecipeHandler -{ - @Override - public String getRecipeName() - { - return LangUtils.localize("tile.MachineBlock2.PrecisionSawmill.name"); - } +public class PrecisionSawmillRecipeHandler extends ChanceMachineRecipeHandler { + @Override + public String getRecipeName() { + return LangUtils.localize("tile.MachineBlock2.PrecisionSawmill.name"); + } - @Override - public String getRecipeId() - { - return "mekanism.precisionsawmill"; - } + @Override + public String getRecipeId() { + return "mekanism.precisionsawmill"; + } - @Override - public String getOverlayIdentifier() - { - return "precisionsawmill"; - } + @Override + public String getOverlayIdentifier() { + return "precisionsawmill"; + } - @Override - public Collection getRecipes() - { - return Recipe.PRECISION_SAWMILL.get().values(); - } - - @Override - public ProgressBar getProgressType() - { - return ProgressBar.PURPLE; - } + @Override + public Collection getRecipes() { + return Recipe.PRECISION_SAWMILL.get().values(); + } - @Override - public Class getGuiClass() - { - return GuiPrecisionSawmill.class; - } + @Override + public ProgressBar getProgressType() { + return ProgressBar.PURPLE; + } + + @Override + public Class getGuiClass() { + return GuiPrecisionSawmill.class; + } } diff --git a/src/main/java/mekanism/client/nei/PurificationChamberRecipeHandler.java b/src/main/java/mekanism/client/nei/PurificationChamberRecipeHandler.java index db1e61bca..f18512a5f 100644 --- a/src/main/java/mekanism/client/nei/PurificationChamberRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/PurificationChamberRecipeHandler.java @@ -17,55 +17,48 @@ import mekanism.common.util.MekanismUtils; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; -public class PurificationChamberRecipeHandler extends AdvancedMachineRecipeHandler -{ - @Override - public String getRecipeName() - { - return LangUtils.localize("tile.MachineBlock.PurificationChamber.name"); - } +public class PurificationChamberRecipeHandler extends AdvancedMachineRecipeHandler { + @Override + public String getRecipeName() { + return LangUtils.localize("tile.MachineBlock.PurificationChamber.name"); + } - @Override - public String getRecipeId() - { - return "mekanism.purificationchamber"; - } + @Override + public String getRecipeId() { + return "mekanism.purificationchamber"; + } - @Override - public String getOverlayIdentifier() - { - return "purificationchamber"; - } + @Override + public String getOverlayIdentifier() { + return "purificationchamber"; + } - @Override - public Collection getRecipes() - { - return Recipe.PURIFICATION_CHAMBER.get().values(); - } - - @Override - public ProgressBar getProgressType() - { - return ProgressBar.RED; - } + @Override + public Collection getRecipes() { + return Recipe.PURIFICATION_CHAMBER.get().values(); + } - @Override - public List getFuelStacks(Gas gasType) - { - if(gasType == GasRegistry.getGas("oxygen")) - { - for(GasTankTier tier : GasTankTier.values()) - { - return ListUtils.asList(new ItemStack(Items.flint), MekanismUtils.getFullGasTank(tier, GasRegistry.getGas("oxygen"))); - } - } + @Override + public ProgressBar getProgressType() { + return ProgressBar.RED; + } - return new ArrayList(); - } + @Override + public List getFuelStacks(Gas gasType) { + if (gasType == GasRegistry.getGas("oxygen")) { + for (GasTankTier tier : GasTankTier.values()) { + return ListUtils.asList( + new ItemStack(Items.flint), + MekanismUtils.getFullGasTank(tier, GasRegistry.getGas("oxygen")) + ); + } + } - @Override - public Class getGuiClass() - { - return GuiPurificationChamber.class; - } + return new ArrayList(); + } + + @Override + public Class getGuiClass() { + return GuiPurificationChamber.class; + } } diff --git a/src/main/java/mekanism/client/nei/RotaryCondensentratorRecipeHandler.java b/src/main/java/mekanism/client/nei/RotaryCondensentratorRecipeHandler.java index 03afb2ae3..02125b8e7 100644 --- a/src/main/java/mekanism/client/nei/RotaryCondensentratorRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/RotaryCondensentratorRecipeHandler.java @@ -8,6 +8,11 @@ import java.awt.Point; import java.awt.Rectangle; import java.util.List; +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.NEIClientConfig; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.GuiRecipe; +import codechicken.nei.recipe.TemplateRecipeHandler; import mekanism.api.gas.Gas; import mekanism.api.gas.GasRegistry; import mekanism.api.gas.GasStack; @@ -17,331 +22,300 @@ import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraftforge.fluids.FluidStack; - import org.lwjgl.opengl.GL11; -import codechicken.lib.gui.GuiDraw; -import codechicken.nei.NEIClientConfig; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.GuiRecipe; -import codechicken.nei.recipe.TemplateRecipeHandler; +public class RotaryCondensentratorRecipeHandler extends BaseRecipeHandler { + private int ticksPassed; -public class RotaryCondensentratorRecipeHandler extends BaseRecipeHandler -{ - private int ticksPassed; + public static int xOffset = 5; + public static int yOffset = 12; - public static int xOffset = 5; - public static int yOffset = 12; + @Override + public String getRecipeName() { + return LangUtils.localize("nei.rotaryCondensentrator"); + } - @Override - public String getRecipeName() - { - return LangUtils.localize("nei.rotaryCondensentrator"); - } + @Override + public String getOverlayIdentifier() { + return "rotarycondensentrator"; + } - @Override - public String getOverlayIdentifier() - { - return "rotarycondensentrator"; - } + @Override + public String getGuiTexture() { + return "mekanism:gui/nei/GuiRotaryCondensentrator.png"; + } - @Override - public String getGuiTexture() - { - return "mekanism:gui/nei/GuiRotaryCondensentrator.png"; - } + @Override + public Class getGuiClass() { + return GuiRotaryCondensentrator.class; + } - @Override - public Class getGuiClass() - { - return GuiRotaryCondensentrator.class; - } + public String getRecipeId() { + return "mekanism.rotarycondensentrator"; + } - public String getRecipeId() - { - return "mekanism.rotarycondensentrator"; - } + @Override + public void drawBackground(int i) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + changeTexture(getGuiTexture()); + drawTexturedModalRect(-2, 0, 3, yOffset, 170, 71); + } - @Override - public void drawBackground(int i) - { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - changeTexture(getGuiTexture()); - drawTexturedModalRect(-2, 0, 3, yOffset, 170, 71); - } + @Override + public void drawExtras(int i) { + CachedIORecipe recipe = (CachedIORecipe) arecipes.get(i); - @Override - public void drawExtras(int i) - { - CachedIORecipe recipe = (CachedIORecipe)arecipes.get(i); + if (recipe.type) { + drawTexturedModalRect(64 - xOffset, 39 - yOffset, 176, 123, 48, 8); + } else { + drawTexturedModalRect(64 - xOffset, 39 - yOffset, 176, 115, 48, 8); + } - if(recipe.type) - { - drawTexturedModalRect(64-xOffset, 39-yOffset, 176, 123, 48, 8); - } - else { - drawTexturedModalRect(64-xOffset, 39-yOffset, 176, 115, 48, 8); - } + if (recipe.gasStack != null) { + displayGauge( + 58, 26 - xOffset, 14 - yOffset, 176, 40, 58, null, recipe.gasStack + ); + } - if(recipe.gasStack != null) - { - displayGauge(58, 26-xOffset, 14-yOffset, 176, 40, 58, null, recipe.gasStack); - } + if (recipe.fluidStack != null) { + displayGauge( + 58, 134 - xOffset, 14 - yOffset, 176, 40, 58, recipe.fluidStack, null + ); + } - if(recipe.fluidStack != null) - { - displayGauge(58, 134-xOffset, 14-yOffset, 176, 40, 58, recipe.fluidStack, null); - } + drawString( + recipe.type ? LangUtils.localize("gui.condensentrating") + : LangUtils.localize("gui.decondensentrating"), + 6 - xOffset, + 74 - yOffset, + 0x404040, + false + ); + } - drawString(recipe.type ? LangUtils.localize("gui.condensentrating") : LangUtils.localize("gui.decondensentrating"), 6-xOffset, 74-yOffset, 0x404040, false); - } + @Override + public void onUpdate() { + super.onUpdate(); - @Override - public void onUpdate() - { - super.onUpdate(); + ticksPassed++; + } - ticksPassed++; - } + @Override + public void loadTransferRects() { + transferRects.add(new TemplateRecipeHandler.RecipeTransferRect( + new Rectangle(64 - xOffset, 39 - yOffset, 48, 8), getRecipeId(), new Object[0] + )); + } - @Override - public void loadTransferRects() - { - transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(64-xOffset, 39-yOffset, 48, 8), getRecipeId(), new Object[0])); - } + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals(getRecipeId())) { + for (Gas gas : GasRegistry.getRegisteredGasses()) { + if (gas.hasFluid()) { + arecipes.add(new CachedIORecipe( + new GasStack(gas, 1), new FluidStack(gas.getFluid(), 1), true + )); + arecipes.add(new CachedIORecipe( + new GasStack(gas, 1), new FluidStack(gas.getFluid(), 1), false + )); + } + } + } else if (outputId.equals("gas") && results.length == 1 && results[0] instanceof GasStack) { + GasStack gas = (GasStack) results[0]; - @Override - public void loadCraftingRecipes(String outputId, Object... results) - { - if(outputId.equals(getRecipeId())) - { - for(Gas gas : GasRegistry.getRegisteredGasses()) - { - if(gas.hasFluid()) - { - arecipes.add(new CachedIORecipe(new GasStack(gas, 1), new FluidStack(gas.getFluid(), 1), true)); - arecipes.add(new CachedIORecipe(new GasStack(gas, 1), new FluidStack(gas.getFluid(), 1), false)); - } - } - } - else if(outputId.equals("gas") && results.length == 1 && results[0] instanceof GasStack) - { - GasStack gas = (GasStack)results[0]; + if (gas.getGas().hasFluid()) { + arecipes.add(new CachedIORecipe( + new GasStack(gas.getGas(), 1), + new FluidStack(gas.getGas().getFluid(), 1), + false + )); + } + } else if (outputId.equals("fluid") && results.length == 1 && results[0] instanceof FluidStack) { + FluidStack fluid = (FluidStack) results[0]; + Gas gas = GasRegistry.getGas(fluid.getFluid()); - if(gas.getGas().hasFluid()) - { - arecipes.add(new CachedIORecipe(new GasStack(gas.getGas(), 1), new FluidStack(gas.getGas().getFluid(), 1), false)); - } - } - else if(outputId.equals("fluid") && results.length == 1 && results[0] instanceof FluidStack) - { - FluidStack fluid = (FluidStack)results[0]; - Gas gas = GasRegistry.getGas(fluid.getFluid()); + if (gas != null) { + arecipes.add(new CachedIORecipe( + new GasStack(gas, 1), new FluidStack(fluid.getFluid(), 1), true + )); + } + } else { + super.loadCraftingRecipes(outputId, results); + } + } - if(gas != null) - { - arecipes.add(new CachedIORecipe(new GasStack(gas, 1), new FluidStack(fluid.getFluid(), 1), true)); - } - } - else { - super.loadCraftingRecipes(outputId, results); - } - } + @Override + public void loadUsageRecipes(String inputId, Object... ingredients) { + if (inputId.equals("gas") && ingredients.length == 1 + && ingredients[0] instanceof GasStack) { + GasStack gas = (GasStack) ingredients[0]; - @Override - public void loadUsageRecipes(String inputId, Object... ingredients) - { - if(inputId.equals("gas") && ingredients.length == 1 && ingredients[0] instanceof GasStack) - { - GasStack gas = (GasStack)ingredients[0]; + if (gas.getGas().hasFluid()) { + arecipes.add(new CachedIORecipe( + new GasStack(gas.getGas(), 1), + new FluidStack(gas.getGas().getFluid(), 1), + true + )); + } + } else if (inputId.equals("fluid") && ingredients.length == 1 && ingredients[0] instanceof FluidStack) { + FluidStack fluid = (FluidStack) ingredients[0]; + Gas gas = GasRegistry.getGas(fluid.getFluid()); - if(gas.getGas().hasFluid()) - { - arecipes.add(new CachedIORecipe(new GasStack(gas.getGas(), 1), new FluidStack(gas.getGas().getFluid(), 1), true)); - } - } - else if(inputId.equals("fluid") && ingredients.length == 1 && ingredients[0] instanceof FluidStack) - { - FluidStack fluid = (FluidStack)ingredients[0]; - Gas gas = GasRegistry.getGas(fluid.getFluid()); + if (gas != null) { + arecipes.add(new CachedIORecipe( + new GasStack(gas, 1), new FluidStack(fluid.getFluid(), 1), false + )); + } + } else { + super.loadUsageRecipes(inputId, ingredients); + } + } - if(gas != null) - { - arecipes.add(new CachedIORecipe(new GasStack(gas, 1), new FluidStack(fluid.getFluid(), 1), false)); - } - } - else { - super.loadUsageRecipes(inputId, ingredients); - } - } + @Override + public List + handleTooltip(GuiRecipe gui, List currenttip, int recipe) { + Point point = GuiDraw.getMousePosition(); - @Override - public List handleTooltip(GuiRecipe gui, List currenttip, int recipe) - { - Point point = GuiDraw.getMousePosition(); + int xAxis = point.x + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft + ); + int yAxis = point.y + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop + ); - int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); - int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); + if (xAxis >= 26 && xAxis <= 42 && yAxis >= 14 + 4 && yAxis <= 72 + 4) { + currenttip.add(LangUtils.localizeGasStack( + ((CachedIORecipe) arecipes.get(recipe)).gasStack + )); + } else if (xAxis >= 134 && xAxis <= 150 && yAxis >= 14 + 4 && yAxis <= 72 + 4) { + currenttip.add(LangUtils.localizeFluidStack( + ((CachedIORecipe) arecipes.get(recipe)).fluidStack + )); + } - if(xAxis >= 26 && xAxis <= 42 && yAxis >= 14+4 && yAxis <= 72+4) - { - currenttip.add(LangUtils.localizeGasStack(((CachedIORecipe)arecipes.get(recipe)).gasStack)); - } - else if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14+4 && yAxis <= 72+4) - { - currenttip.add(LangUtils.localizeFluidStack(((CachedIORecipe)arecipes.get(recipe)).fluidStack)); - } + return super.handleTooltip(gui, currenttip, recipe); + } - return super.handleTooltip(gui, currenttip, recipe); - } + @Override + public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) { + Point point = GuiDraw.getMousePosition(); - @Override - public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) - { - Point point = GuiDraw.getMousePosition(); + int xAxis = point.x + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft + ); + int yAxis = point.y + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop + ); - int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); - int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); + GasStack gas = null; + FluidStack fluid = null; - GasStack gas = null; - FluidStack fluid = null; + if (xAxis >= 26 && xAxis <= 42 && yAxis >= 14 + 4 && yAxis <= 72 + 4) { + gas = ((CachedIORecipe) arecipes.get(recipe)).gasStack; + } else if (xAxis >= 134 && xAxis <= 150 && yAxis >= 14 + 4 && yAxis <= 72 + 4) { + fluid = ((CachedIORecipe) arecipes.get(recipe)).fluidStack; + } - if(xAxis >= 26 && xAxis <= 42 && yAxis >= 14+4 && yAxis <= 72+4) - { - gas = ((CachedIORecipe)arecipes.get(recipe)).gasStack; - } - else if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14+4 && yAxis <= 72+4) - { - fluid = ((CachedIORecipe)arecipes.get(recipe)).fluidStack; - } + if (gas != null) { + if (keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) { + if (doGasLookup(gas, false)) { + return true; + } + } else if (keyCode == NEIClientConfig.getKeyBinding("gui.usage")) { + if (doGasLookup(gas, true)) { + return true; + } + } + } else if (fluid != null) { + if (keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) { + if (doFluidLookup(fluid, false)) { + return true; + } + } else if (keyCode == NEIClientConfig.getKeyBinding("gui.usage")) { + if (doFluidLookup(fluid, true)) { + return true; + } + } + } - if(gas != null) - { - if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) - { - if(doGasLookup(gas, false)) - { - return true; - } - } - else if(keyCode == NEIClientConfig.getKeyBinding("gui.usage")) - { - if(doGasLookup(gas, true)) - { - return true; - } - } - } - else if(fluid != null) - { - if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) - { - if(doFluidLookup(fluid, false)) - { - return true; - } - } - else if(keyCode == NEIClientConfig.getKeyBinding("gui.usage")) - { - if(doFluidLookup(fluid, true)) - { - return true; - } - } - } + return super.keyTyped(gui, keyChar, keyCode, recipe); + } - return super.keyTyped(gui, keyChar, keyCode, recipe); - } + @Override + public boolean mouseClicked(GuiRecipe gui, int button, int recipe) { + Point point = GuiDraw.getMousePosition(); - @Override - public boolean mouseClicked(GuiRecipe gui, int button, int recipe) - { - Point point = GuiDraw.getMousePosition(); + int xAxis = point.x + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft + ); + int yAxis = point.y + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop + ); - int xAxis = point.x - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); - int yAxis = point.y - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); + GasStack gas = null; + FluidStack fluid = null; - GasStack gas = null; - FluidStack fluid = null; + if (xAxis >= 26 && xAxis <= 42 && yAxis >= 14 + 18 && yAxis <= 72 + 18) { + gas = ((CachedIORecipe) arecipes.get(recipe)).gasStack; + } else if (xAxis >= 134 && xAxis <= 150 && yAxis >= 14 + 18 && yAxis <= 72 + 18) { + fluid = ((CachedIORecipe) arecipes.get(recipe)).fluidStack; + } - if(xAxis >= 26 && xAxis <= 42 && yAxis >= 14+18 && yAxis <= 72+18) - { - gas = ((CachedIORecipe)arecipes.get(recipe)).gasStack; - } - else if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14+18 && yAxis <= 72+18) - { - fluid = ((CachedIORecipe)arecipes.get(recipe)).fluidStack; - } + if (gas != null) { + if (button == 0) { + if (doGasLookup(gas, false)) { + return true; + } + } else if (button == 1) { + if (doGasLookup(gas, true)) { + return true; + } + } + } else if (fluid != null) { + if (button == 0) { + if (doFluidLookup(fluid, false)) { + return true; + } + } else if (button == 1) { + if (doFluidLookup(fluid, true)) { + return true; + } + } + } - if(gas != null) - { - if(button == 0) - { - if(doGasLookup(gas, false)) - { - return true; - } - } - else if(button == 1) - { - if(doGasLookup(gas, true)) - { - return true; - } - } - } - else if(fluid != null) - { - if(button == 0) - { - if(doFluidLookup(fluid, false)) - { - return true; - } - } - else if(button == 1) - { - if(doFluidLookup(fluid, true)) - { - return true; - } - } - } + return super.mouseClicked(gui, button, recipe); + } - return super.mouseClicked(gui, button, recipe); - } + @Override + public int recipiesPerPage() { + return 1; + } - @Override - public int recipiesPerPage() - { - return 1; - } + @Override + public void addGuiElements() {} - @Override - public void addGuiElements() - { + public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe { + public GasStack gasStack; + public FluidStack fluidStack; - } + /* true = condensentrating, false = decondensentrating */ + public boolean type; - public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe - { - public GasStack gasStack; - public FluidStack fluidStack; + @Override + public PositionedStack getResult() { + return null; + } - /* true = condensentrating, false = decondensentrating */ - public boolean type; - - @Override - public PositionedStack getResult() - { - return null; - } - - public CachedIORecipe(GasStack gas, FluidStack fluid, boolean b) - { - gasStack = gas; - fluidStack = fluid; - type = b; - } - } + public CachedIORecipe(GasStack gas, FluidStack fluid, boolean b) { + gasStack = gas; + fluidStack = fluid; + type = b; + } + } } diff --git a/src/main/java/mekanism/client/nei/ShapedMekanismRecipeHandler.java b/src/main/java/mekanism/client/nei/ShapedMekanismRecipeHandler.java index 0c87a628a..433c4d8c7 100644 --- a/src/main/java/mekanism/client/nei/ShapedMekanismRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/ShapedMekanismRecipeHandler.java @@ -4,153 +4,135 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.ShapedRecipeHandler; import mekanism.common.recipe.ShapedMekanismRecipe; import mekanism.common.util.LangUtils; import mekanism.common.util.RecipeUtils; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.item.crafting.IRecipe; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.ShapedRecipeHandler; -public class ShapedMekanismRecipeHandler extends ShapedRecipeHandler -{ - @Override - public String getRecipeName() - { - return "Mekanism " + LangUtils.localize("recipe.mekanismShaped"); - } +public class ShapedMekanismRecipeHandler extends ShapedRecipeHandler { + @Override + public String getRecipeName() { + return "Mekanism " + LangUtils.localize("recipe.mekanismShaped"); + } - @Override - public void loadCraftingRecipes(String outputId, Object... results) - { - if(outputId.equals("crafting") && getClass() == ShapedMekanismRecipeHandler.class) - { - List allrecipes = CraftingManager.getInstance().getRecipeList(); + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals("crafting") + && getClass() == ShapedMekanismRecipeHandler.class) { + List allrecipes = CraftingManager.getInstance().getRecipeList(); - for(IRecipe irecipe : allrecipes) - { - if(irecipe instanceof ShapedMekanismRecipe) - { - ShapedMekanismRecipe mekanismRecipe = (ShapedMekanismRecipe)irecipe; - CachedShapedMekanismRecipe recipe = new CachedShapedMekanismRecipe(mekanismRecipe); - - recipe.computeVisuals(); - arecipes.add(recipe); - } - } - } - else { - super.loadCraftingRecipes(outputId, results); - } - } + for (IRecipe irecipe : allrecipes) { + if (irecipe instanceof ShapedMekanismRecipe) { + ShapedMekanismRecipe mekanismRecipe = (ShapedMekanismRecipe) irecipe; + CachedShapedMekanismRecipe recipe + = new CachedShapedMekanismRecipe(mekanismRecipe); - @Override - public void loadCraftingRecipes(ItemStack result) - { - List allrecipes = CraftingManager.getInstance().getRecipeList(); + recipe.computeVisuals(); + arecipes.add(recipe); + } + } + } else { + super.loadCraftingRecipes(outputId, results); + } + } - for(IRecipe irecipe : allrecipes) - { - if(irecipe instanceof ShapedMekanismRecipe && RecipeUtils.areItemsEqualForCrafting(irecipe.getRecipeOutput(), result)) - { - ShapedMekanismRecipe mekanismRecipe = (ShapedMekanismRecipe)irecipe; - CachedShapedMekanismRecipe recipe = new CachedShapedMekanismRecipe(mekanismRecipe); - - recipe.computeVisuals(); - arecipes.add(recipe); - } - } - } + @Override + public void loadCraftingRecipes(ItemStack result) { + List allrecipes = CraftingManager.getInstance().getRecipeList(); - @Override - public void loadUsageRecipes(ItemStack ingredient) - { - List allrecipes = CraftingManager.getInstance().getRecipeList(); + for (IRecipe irecipe : allrecipes) { + if (irecipe instanceof ShapedMekanismRecipe + && RecipeUtils.areItemsEqualForCrafting( + irecipe.getRecipeOutput(), result + )) { + ShapedMekanismRecipe mekanismRecipe = (ShapedMekanismRecipe) irecipe; + CachedShapedMekanismRecipe recipe + = new CachedShapedMekanismRecipe(mekanismRecipe); - for(IRecipe irecipe : allrecipes) - { - if(irecipe instanceof ShapedMekanismRecipe) - { - ShapedMekanismRecipe mekanismRecipe = (ShapedMekanismRecipe)irecipe; - CachedShapedMekanismRecipe recipe = new CachedShapedMekanismRecipe(mekanismRecipe); + recipe.computeVisuals(); + arecipes.add(recipe); + } + } + } - recipe.computeVisuals(); - - if(recipe.contains(recipe.ingredients, ingredient)) - { - recipe.setIngredientPermutation(recipe.ingredients, ingredient); - arecipes.add(recipe); - } - } - } - } + @Override + public void loadUsageRecipes(ItemStack ingredient) { + List allrecipes = CraftingManager.getInstance().getRecipeList(); - public class CachedShapedMekanismRecipe extends CachedRecipe - { - public ArrayList ingredients; - public PositionedStack result; + for (IRecipe irecipe : allrecipes) { + if (irecipe instanceof ShapedMekanismRecipe) { + ShapedMekanismRecipe mekanismRecipe = (ShapedMekanismRecipe) irecipe; + CachedShapedMekanismRecipe recipe + = new CachedShapedMekanismRecipe(mekanismRecipe); - public CachedShapedMekanismRecipe(ShapedMekanismRecipe recipe) - { - result = new PositionedStack(recipe.getRecipeOutput(), 119, 24); - ingredients = new ArrayList(); - setIngredients(recipe.width, recipe.height, recipe.getInput()); - } + recipe.computeVisuals(); - public void setIngredients(int width, int height, Object[] items) - { - for(int x = 0; x < width; x++) - { - for(int y = 0; y < height; y++) - { - if(items[y*width+x] == null) - { - continue; - } + if (recipe.contains(recipe.ingredients, ingredient)) { + recipe.setIngredientPermutation(recipe.ingredients, ingredient); + arecipes.add(recipe); + } + } + } + } - PositionedStack stack = new PositionedStack(items[y*width+x], 25+x*18, 6+y*18); - stack.setMaxSize(1); - ingredients.add(stack); - } - } - } + public class CachedShapedMekanismRecipe extends CachedRecipe { + public ArrayList ingredients; + public PositionedStack result; - @Override - public List getIngredients() - { - return getCycledIngredients(cycleticks / 20, ingredients); - } + public CachedShapedMekanismRecipe(ShapedMekanismRecipe recipe) { + result = new PositionedStack(recipe.getRecipeOutput(), 119, 24); + ingredients = new ArrayList(); + setIngredients(recipe.width, recipe.height, recipe.getInput()); + } - @Override - public PositionedStack getResult() - { - return result; - } - - public void computeVisuals() - { - for(PositionedStack p : ingredients) - { + public void setIngredients(int width, int height, Object[] items) { + for (int x = 0; x < width; x++) { + for (int y = 0; y < height; y++) { + if (items[y * width + x] == null) { + continue; + } + + PositionedStack stack = new PositionedStack( + items[y * width + x], 25 + x * 18, 6 + y * 18 + ); + stack.setMaxSize(1); + ingredients.add(stack); + } + } + } + + @Override + public List getIngredients() { + return getCycledIngredients(cycleticks / 20, ingredients); + } + + @Override + public PositionedStack getResult() { + return result; + } + + public void computeVisuals() { + for (PositionedStack p : ingredients) { p.generatePermutations(); } } - @Override - public boolean contains(Collection ingredients, ItemStack ingredient) - { - for(PositionedStack stack : ingredients) - { - for(ItemStack item : stack.items) - { - if(RecipeUtils.areItemsEqualForCrafting(item, ingredient)) - { - return true; - } - } - } + @Override + public boolean + contains(Collection ingredients, ItemStack ingredient) { + for (PositionedStack stack : ingredients) { + for (ItemStack item : stack.items) { + if (RecipeUtils.areItemsEqualForCrafting(item, ingredient)) { + return true; + } + } + } - return false; - } - } + return false; + } + } } diff --git a/src/main/java/mekanism/client/nei/ShapelessMekanismRecipeHandler.java b/src/main/java/mekanism/client/nei/ShapelessMekanismRecipeHandler.java index f3cecc9a5..fd600a7e9 100644 --- a/src/main/java/mekanism/client/nei/ShapelessMekanismRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/ShapelessMekanismRecipeHandler.java @@ -3,122 +3,113 @@ package mekanism.client.nei; import java.util.ArrayList; import java.util.List; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.ShapelessRecipeHandler; import mekanism.common.recipe.ShapelessMekanismRecipe; import mekanism.common.util.LangUtils; import mekanism.common.util.RecipeUtils; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.item.crafting.IRecipe; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.ShapelessRecipeHandler; -public class ShapelessMekanismRecipeHandler extends ShapelessRecipeHandler -{ - @Override - public String getRecipeName() - { - return "Mekanism " + LangUtils.localize("recipe.mekanismShapeless"); - } - - @Override - public void loadCraftingRecipes(String outputId, Object... results) - { - if(outputId.equals("crafting") && getClass() == ShapelessMekanismRecipeHandler.class) - { - List allrecipes = CraftingManager.getInstance().getRecipeList(); +public class ShapelessMekanismRecipeHandler extends ShapelessRecipeHandler { + @Override + public String getRecipeName() { + return "Mekanism " + LangUtils.localize("recipe.mekanismShapeless"); + } - for(IRecipe irecipe : allrecipes) - { - if(irecipe instanceof ShapelessMekanismRecipe) - { - ShapelessMekanismRecipe mekanismRecipe = (ShapelessMekanismRecipe)irecipe; - CachedShapelessMekanismRecipe recipe = new CachedShapelessMekanismRecipe(mekanismRecipe); + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals("crafting") + && getClass() == ShapelessMekanismRecipeHandler.class) { + List allrecipes = CraftingManager.getInstance().getRecipeList(); - arecipes.add(recipe); - } - } - } - else { - super.loadCraftingRecipes(outputId, results); - } - } + for (IRecipe irecipe : allrecipes) { + if (irecipe instanceof ShapelessMekanismRecipe) { + ShapelessMekanismRecipe mekanismRecipe + = (ShapelessMekanismRecipe) irecipe; + CachedShapelessMekanismRecipe recipe + = new CachedShapelessMekanismRecipe(mekanismRecipe); - @Override - public void loadCraftingRecipes(ItemStack result) - { - List allrecipes = CraftingManager.getInstance().getRecipeList(); + arecipes.add(recipe); + } + } + } else { + super.loadCraftingRecipes(outputId, results); + } + } - for(IRecipe irecipe : allrecipes) - { - if(irecipe instanceof ShapelessMekanismRecipe && RecipeUtils.areItemsEqualForCrafting(irecipe.getRecipeOutput(), result)) - { - ShapelessMekanismRecipe mekanismRecipe = (ShapelessMekanismRecipe)irecipe; - CachedShapelessMekanismRecipe recipe = new CachedShapelessMekanismRecipe(mekanismRecipe); + @Override + public void loadCraftingRecipes(ItemStack result) { + List allrecipes = CraftingManager.getInstance().getRecipeList(); - arecipes.add(recipe); - } - } - } + for (IRecipe irecipe : allrecipes) { + if (irecipe instanceof ShapelessMekanismRecipe + && RecipeUtils.areItemsEqualForCrafting( + irecipe.getRecipeOutput(), result + )) { + ShapelessMekanismRecipe mekanismRecipe + = (ShapelessMekanismRecipe) irecipe; + CachedShapelessMekanismRecipe recipe + = new CachedShapelessMekanismRecipe(mekanismRecipe); - @Override - public void loadUsageRecipes(ItemStack ingredient) - { - List allrecipes = CraftingManager.getInstance().getRecipeList(); + arecipes.add(recipe); + } + } + } - for(IRecipe irecipe : allrecipes) - { - if(irecipe instanceof ShapelessMekanismRecipe) - { - ShapelessMekanismRecipe mekanismRecipe = (ShapelessMekanismRecipe)irecipe; - CachedShapelessMekanismRecipe recipe = new CachedShapelessMekanismRecipe(mekanismRecipe); - - if(recipe.contains(recipe.ingredients, ingredient)) - { - recipe.setIngredientPermutation(recipe.ingredients, ingredient); - arecipes.add(recipe); - } - } - } - } - - public class CachedShapelessMekanismRecipe extends CachedRecipe - { + @Override + public void loadUsageRecipes(ItemStack ingredient) { + List allrecipes = CraftingManager.getInstance().getRecipeList(); + + for (IRecipe irecipe : allrecipes) { + if (irecipe instanceof ShapelessMekanismRecipe) { + ShapelessMekanismRecipe mekanismRecipe + = (ShapelessMekanismRecipe) irecipe; + CachedShapelessMekanismRecipe recipe + = new CachedShapelessMekanismRecipe(mekanismRecipe); + + if (recipe.contains(recipe.ingredients, ingredient)) { + recipe.setIngredientPermutation(recipe.ingredients, ingredient); + arecipes.add(recipe); + } + } + } + } + + public class CachedShapelessMekanismRecipe extends CachedRecipe { public ArrayList ingredients; public PositionedStack result; - - public CachedShapelessMekanismRecipe(ShapelessMekanismRecipe recipe) - { - result = new PositionedStack(recipe.getRecipeOutput(), 119, 24); + + public CachedShapelessMekanismRecipe(ShapelessMekanismRecipe recipe) { + result = new PositionedStack(recipe.getRecipeOutput(), 119, 24); ingredients = new ArrayList(); setIngredients(recipe.getInput()); } - public void setIngredients(List items) - { + public void setIngredients(List items) { ingredients.clear(); - - for(int x = 0; x < items.size(); x++) - { - PositionedStack stack = new PositionedStack(items.get(x), 25 + stackorder[x][0] * 18, 6 + stackorder[x][1] * 18); + + for (int x = 0; x < items.size(); x++) { + PositionedStack stack = new PositionedStack( + items.get(x), 25 + stackorder[x][0] * 18, 6 + stackorder[x][1] * 18 + ); stack.setMaxSize(1); ingredients.add(stack); } } - public void setResult(ItemStack output) - { + public void setResult(ItemStack output) { result = new PositionedStack(output, 119, 24); } @Override - public List getIngredients() - { + public List getIngredients() { return getCycledIngredients(cycleticks / 20, ingredients); } @Override - public PositionedStack getResult() - { + public PositionedStack getResult() { return result; } } diff --git a/src/main/java/mekanism/client/nei/SolarNeutronRecipeHandler.java b/src/main/java/mekanism/client/nei/SolarNeutronRecipeHandler.java index f7d2b88c2..df34b0424 100644 --- a/src/main/java/mekanism/client/nei/SolarNeutronRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/SolarNeutronRecipeHandler.java @@ -8,6 +8,11 @@ import java.awt.Rectangle; import java.util.Collection; import java.util.List; +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.NEIClientConfig; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.GuiRecipe; +import codechicken.nei.recipe.TemplateRecipeHandler; import mekanism.api.gas.GasStack; import mekanism.client.gui.GuiSolarNeutronActivator; import mekanism.common.ObfuscatedNames; @@ -16,271 +21,236 @@ import mekanism.common.recipe.machines.SolarNeutronRecipe; import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import net.minecraft.client.gui.inventory.GuiContainer; - import org.lwjgl.opengl.GL11; -import codechicken.lib.gui.GuiDraw; -import codechicken.nei.NEIClientConfig; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.GuiRecipe; -import codechicken.nei.recipe.TemplateRecipeHandler; +public class SolarNeutronRecipeHandler extends BaseRecipeHandler { + private int ticksPassed; -public class SolarNeutronRecipeHandler extends BaseRecipeHandler -{ - private int ticksPassed; + public static int xOffset = 5; + public static int yOffset = 12; - public static int xOffset = 5; - public static int yOffset = 12; + @Override + public String getRecipeName() { + return LangUtils.localize("tile.MachineBlock3.SolarNeutronActivator.name"); + } - @Override - public String getRecipeName() - { - return LangUtils.localize("tile.MachineBlock3.SolarNeutronActivator.name"); - } + @Override + public String getOverlayIdentifier() { + return "solarneutron"; + } - @Override - public String getOverlayIdentifier() - { - return "solarneutron"; - } + @Override + public String getGuiTexture() { + return "mekanism:gui/nei/GuiSolarNeutronActivator.png"; + } - @Override - public String getGuiTexture() - { - return "mekanism:gui/nei/GuiSolarNeutronActivator.png"; - } + @Override + public Class getGuiClass() { + return GuiSolarNeutronActivator.class; + } - @Override - public Class getGuiClass() - { - return GuiSolarNeutronActivator.class; - } + public String getRecipeId() { + return "mekanism.solarneutron"; + } - public String getRecipeId() - { - return "mekanism.solarneutron"; - } + public Collection getRecipes() { + return Recipe.SOLAR_NEUTRON_ACTIVATOR.get().values(); + } - public Collection getRecipes() - { - return Recipe.SOLAR_NEUTRON_ACTIVATOR.get().values(); - } + @Override + public void drawBackground(int i) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + changeTexture(getGuiTexture()); + drawTexturedModalRect(-2, 0, 3, yOffset, 170, 70); + } - @Override - public void drawBackground(int i) - { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - changeTexture(getGuiTexture()); - drawTexturedModalRect(-2, 0, 3, yOffset, 170, 70); - } + @Override + public void drawExtras(int i) { + CachedIORecipe recipe = (CachedIORecipe) arecipes.get(i); - @Override - public void drawExtras(int i) - { - CachedIORecipe recipe = (CachedIORecipe)arecipes.get(i); + drawTexturedModalRect(64 - xOffset, 39 - yOffset, 176, 58, 55, 8); - drawTexturedModalRect(64-xOffset, 39-yOffset, 176, 58, 55, 8); + if (recipe.inputStack != null) { + displayGauge( + 58, 26 - xOffset, 14 - yOffset, 176, 0, 58, null, recipe.inputStack + ); + } - if(recipe.inputStack != null) - { - displayGauge(58, 26-xOffset, 14-yOffset, 176, 0, 58, null, recipe.inputStack); - } + if (recipe.inputStack != null) { + displayGauge( + 58, 134 - xOffset, 14 - yOffset, 176, 0, 58, null, recipe.outputStack + ); + } + } - if(recipe.inputStack != null) - { - displayGauge(58, 134-xOffset, 14-yOffset, 176, 0, 58, null, recipe.outputStack); - } - } + @Override + public void onUpdate() { + super.onUpdate(); - @Override - public void onUpdate() - { - super.onUpdate(); + ticksPassed++; + } - ticksPassed++; - } + @Override + public void loadTransferRects() { + transferRects.add(new TemplateRecipeHandler.RecipeTransferRect( + new Rectangle(64 - xOffset, 39 - yOffset, 48, 8), getRecipeId(), new Object[0] + )); + } - @Override - public void loadTransferRects() - { - transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(64-xOffset, 39-yOffset, 48, 8), getRecipeId(), new Object[0])); - } + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals(getRecipeId())) { + for (SolarNeutronRecipe irecipe : getRecipes()) { + arecipes.add(new CachedIORecipe(irecipe)); + } + } else if (outputId.equals("gas") && results.length == 1 && results[0] instanceof GasStack) { + for (SolarNeutronRecipe irecipe : getRecipes()) { + if (((GasStack) results[0]).isGasEqual(irecipe.getOutput().output)) { + arecipes.add(new CachedIORecipe(irecipe)); + } + } + } else { + super.loadCraftingRecipes(outputId, results); + } + } - @Override - public void loadCraftingRecipes(String outputId, Object... results) - { - if(outputId.equals(getRecipeId())) - { - for(SolarNeutronRecipe irecipe : getRecipes()) - { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - else if(outputId.equals("gas") && results.length == 1 && results[0] instanceof GasStack) - { - for(SolarNeutronRecipe irecipe : getRecipes()) - { - if(((GasStack)results[0]).isGasEqual(irecipe.getOutput().output)) - { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - } - else { - super.loadCraftingRecipes(outputId, results); - } - } + @Override + public void loadUsageRecipes(String inputId, Object... ingredients) { + if (inputId.equals("gas") && ingredients.length == 1 + && ingredients[0] instanceof GasStack) { + for (SolarNeutronRecipe irecipe : getRecipes()) { + if (irecipe.getInput().ingredient.isGasEqual((GasStack) ingredients[0])) { + arecipes.add(new CachedIORecipe(irecipe)); + } + } + } else { + super.loadUsageRecipes(inputId, ingredients); + } + } - @Override - public void loadUsageRecipes(String inputId, Object... ingredients) - { - if(inputId.equals("gas") && ingredients.length == 1 && ingredients[0] instanceof GasStack) - { - for(SolarNeutronRecipe irecipe : getRecipes()) - { - if(irecipe.getInput().ingredient.isGasEqual((GasStack)ingredients[0])) - { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - } - else { - super.loadUsageRecipes(inputId, ingredients); - } - } + @Override + public List + handleTooltip(GuiRecipe gui, List currenttip, int recipe) { + Point point = GuiDraw.getMousePosition(); - @Override - public List handleTooltip(GuiRecipe gui, List currenttip, int recipe) - { - Point point = GuiDraw.getMousePosition(); + int xAxis = point.x + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft + ); + int yAxis = point.y + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop + ); - int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); - int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); + if (xAxis >= 26 && xAxis <= 42 && yAxis >= 14 + 4 && yAxis <= 72 + 4) { + currenttip.add(LangUtils.localizeGasStack( + ((CachedIORecipe) arecipes.get(recipe)).inputStack + )); + } else if (xAxis >= 134 && xAxis <= 150 && yAxis >= 14 + 4 && yAxis <= 72 + 4) { + currenttip.add(LangUtils.localizeGasStack( + ((CachedIORecipe) arecipes.get(recipe)).outputStack + )); + } - if(xAxis >= 26 && xAxis <= 42 && yAxis >= 14+4 && yAxis <= 72+4) - { - currenttip.add(LangUtils.localizeGasStack(((CachedIORecipe)arecipes.get(recipe)).inputStack)); - } - else if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14+4 && yAxis <= 72+4) - { - currenttip.add(LangUtils.localizeGasStack(((CachedIORecipe)arecipes.get(recipe)).outputStack)); - } + return super.handleTooltip(gui, currenttip, recipe); + } - return super.handleTooltip(gui, currenttip, recipe); - } + @Override + public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) { + Point point = GuiDraw.getMousePosition(); - @Override - public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) - { - Point point = GuiDraw.getMousePosition(); + int xAxis = point.x + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft + ); + int yAxis = point.y + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop + ); - int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); - int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); + GasStack gas = null; - GasStack gas = null; + if (xAxis >= 26 && xAxis <= 42 && yAxis >= 14 + 4 && yAxis <= 72 + 4) { + gas = ((CachedIORecipe) arecipes.get(recipe)).inputStack; + } else if (xAxis >= 134 && xAxis <= 150 && yAxis >= 14 + 4 && yAxis <= 72 + 4) { + gas = ((CachedIORecipe) arecipes.get(recipe)).outputStack; + } - if(xAxis >= 26 && xAxis <= 42 && yAxis >= 14+4 && yAxis <= 72+4) - { - gas = ((CachedIORecipe)arecipes.get(recipe)).inputStack; - } - else if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14+4 && yAxis <= 72+4) - { - gas = ((CachedIORecipe)arecipes.get(recipe)).outputStack; - } + if (gas != null) { + if (keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) { + if (doGasLookup(gas, false)) { + return true; + } + } else if (keyCode == NEIClientConfig.getKeyBinding("gui.usage")) { + if (doGasLookup(gas, true)) { + return true; + } + } + } - if(gas != null) - { - if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) - { - if(doGasLookup(gas, false)) - { - return true; - } - } - else if(keyCode == NEIClientConfig.getKeyBinding("gui.usage")) - { - if(doGasLookup(gas, true)) - { - return true; - } - } - } + return super.keyTyped(gui, keyChar, keyCode, recipe); + } - return super.keyTyped(gui, keyChar, keyCode, recipe); - } + @Override + public boolean mouseClicked(GuiRecipe gui, int button, int recipe) { + Point point = GuiDraw.getMousePosition(); - @Override - public boolean mouseClicked(GuiRecipe gui, int button, int recipe) - { - Point point = GuiDraw.getMousePosition(); + int xAxis = point.x + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft + ); + int yAxis = point.y + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop + ); - int xAxis = point.x - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); - int yAxis = point.y - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); + GasStack gas = null; - GasStack gas = null; + if (xAxis >= 26 && xAxis <= 42 && yAxis >= 14 + 18 && yAxis <= 72 + 18) { + gas = ((CachedIORecipe) arecipes.get(recipe)).inputStack; + } else if (xAxis >= 134 && xAxis <= 150 && yAxis >= 14 + 18 && yAxis <= 72 + 18) { + gas = ((CachedIORecipe) arecipes.get(recipe)).outputStack; + } - if(xAxis >= 26 && xAxis <= 42 && yAxis >= 14+18 && yAxis <= 72+18) - { - gas = ((CachedIORecipe)arecipes.get(recipe)).inputStack; - } - else if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14+18 && yAxis <= 72+18) - { - gas = ((CachedIORecipe)arecipes.get(recipe)).outputStack; - } + if (gas != null) { + if (button == 0) { + if (doGasLookup(gas, false)) { + return true; + } + } else if (button == 1) { + if (doGasLookup(gas, true)) { + return true; + } + } + } - if(gas != null) - { - if(button == 0) - { - if(doGasLookup(gas, false)) - { - return true; - } - } - else if(button == 1) - { - if(doGasLookup(gas, true)) - { - return true; - } - } - } + return super.mouseClicked(gui, button, recipe); + } - return super.mouseClicked(gui, button, recipe); - } + @Override + public int recipiesPerPage() { + return 1; + } - @Override - public int recipiesPerPage() - { - return 1; - } + @Override + public void addGuiElements() {} - @Override - public void addGuiElements() - { + public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe { + public GasStack inputStack; + public GasStack outputStack; - } + @Override + public PositionedStack getResult() { + return null; + } - public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe - { - public GasStack inputStack; - public GasStack outputStack; + public CachedIORecipe(GasStack input, GasStack output) { + inputStack = input; + outputStack = output; + } - @Override - public PositionedStack getResult() - { - return null; - } - - public CachedIORecipe(GasStack input, GasStack output) - { - inputStack = input; - outputStack = output; - } - - public CachedIORecipe(SolarNeutronRecipe recipe) - { - this(recipe.getInput().ingredient, recipe.getOutput().output); - } - } + public CachedIORecipe(SolarNeutronRecipe recipe) { + this(recipe.getInput().ingredient, recipe.getOutput().output); + } + } } diff --git a/src/main/java/mekanism/client/nei/TheoreticalElementizerRecipeHandler.java b/src/main/java/mekanism/client/nei/TheoreticalElementizerRecipeHandler.java index fb4b68313..6ca590025 100644 --- a/src/main/java/mekanism/client/nei/TheoreticalElementizerRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/TheoreticalElementizerRecipeHandler.java @@ -12,7 +12,6 @@ import mekanism.common.util.LangUtils; import net.minecraft.item.ItemStack; public class TheoreticalElementizerRecipeHandler extends AdvancedMachineRecipeHandler { - @Override public String getRecipeName() { return LangUtils.localize("tile.MachineBlock3.TheoreticalElementizer.name"); @@ -37,11 +36,9 @@ public class TheoreticalElementizerRecipeHandler extends AdvancedMachineRecipeHa public ProgressBar getProgressType() { return ProgressBar.BLUE; } - - @Override - public Class getGuiClass() - { - return GuiTheoreticalElementizer.class; - } + @Override + public Class getGuiClass() { + return GuiTheoreticalElementizer.class; + } } diff --git a/src/main/java/mekanism/client/nei/ThermalEvaporationRecipeHandler.java b/src/main/java/mekanism/client/nei/ThermalEvaporationRecipeHandler.java index bf924aae7..64fa62dd8 100644 --- a/src/main/java/mekanism/client/nei/ThermalEvaporationRecipeHandler.java +++ b/src/main/java/mekanism/client/nei/ThermalEvaporationRecipeHandler.java @@ -8,6 +8,11 @@ import java.awt.Rectangle; import java.util.Collection; import java.util.List; +import codechicken.lib.gui.GuiDraw; +import codechicken.nei.NEIClientConfig; +import codechicken.nei.PositionedStack; +import codechicken.nei.recipe.GuiRecipe; +import codechicken.nei.recipe.TemplateRecipeHandler; import mekanism.client.gui.GuiThermalEvaporationController; import mekanism.common.ObfuscatedNames; import mekanism.common.recipe.RecipeHandler.Recipe; @@ -16,271 +21,251 @@ import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraftforge.fluids.FluidStack; - import org.lwjgl.opengl.GL11; -import codechicken.lib.gui.GuiDraw; -import codechicken.nei.NEIClientConfig; -import codechicken.nei.PositionedStack; -import codechicken.nei.recipe.GuiRecipe; -import codechicken.nei.recipe.TemplateRecipeHandler; +public class ThermalEvaporationRecipeHandler extends BaseRecipeHandler { + private int ticksPassed; -public class ThermalEvaporationRecipeHandler extends BaseRecipeHandler -{ - private int ticksPassed; + public static int xOffset = 5; + public static int yOffset = 12; - public static int xOffset = 5; - public static int yOffset = 12; + @Override + public String getRecipeName() { + return LangUtils.localize("gui.thermalEvaporationController.short"); + } - @Override - public String getRecipeName() - { - return LangUtils.localize("gui.thermalEvaporationController.short"); - } + @Override + public String getOverlayIdentifier() { + return "thermalevaporation"; + } - @Override - public String getOverlayIdentifier() - { - return "thermalevaporation"; - } + @Override + public String getGuiTexture() { + return "mekanism:gui/nei/GuiThermalEvaporationController.png"; + } - @Override - public String getGuiTexture() - { - return "mekanism:gui/nei/GuiThermalEvaporationController.png"; - } + @Override + public Class getGuiClass() { + return GuiThermalEvaporationController.class; + } - @Override - public Class getGuiClass() - { - return GuiThermalEvaporationController.class; - } + public String getRecipeId() { + return "mekanism.thermalevaporation"; + } - public String getRecipeId() - { - return "mekanism.thermalevaporation"; - } + public Collection getRecipes() { + return Recipe.THERMAL_EVAPORATION_PLANT.get().values(); + } - public Collection getRecipes() - { - return Recipe.THERMAL_EVAPORATION_PLANT.get().values(); - } - - @Override - public void loadTransferRects() - { - transferRects.add(new TemplateRecipeHandler.RecipeTransferRect(new Rectangle(49-xOffset, 20-yOffset, 78, 38), getRecipeId(), new Object[0])); - } + @Override + public void loadTransferRects() { + transferRects.add(new TemplateRecipeHandler.RecipeTransferRect( + new Rectangle(49 - xOffset, 20 - yOffset, 78, 38), + getRecipeId(), + new Object[0] + )); + } - @Override - public void drawBackground(int i) - { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - changeTexture(getGuiTexture()); - drawTexturedModalRect(-2, 0, 3, yOffset, 170, 62); - } + @Override + public void drawBackground(int i) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + changeTexture(getGuiTexture()); + drawTexturedModalRect(-2, 0, 3, yOffset, 170, 62); + } - @Override - public void drawExtras(int i) - { - CachedIORecipe recipe = (CachedIORecipe)arecipes.get(i); + @Override + public void drawExtras(int i) { + CachedIORecipe recipe = (CachedIORecipe) arecipes.get(i); - drawProgressBar(49-xOffset, 64-yOffset, 176, 59, 78, 8, ticksPassed < 20 ? ticksPassed % 20 / 20.0F : 1.0F, 0); + drawProgressBar( + 49 - xOffset, + 64 - yOffset, + 176, + 59, + 78, + 8, + ticksPassed < 20 ? ticksPassed % 20 / 20.0F : 1.0F, + 0 + ); - if(recipe.fluidInput != null) - { - displayGauge(58, 7-xOffset, 14-yOffset, 176, 0, 58, recipe.fluidInput, null); - } + if (recipe.fluidInput != null) { + displayGauge( + 58, 7 - xOffset, 14 - yOffset, 176, 0, 58, recipe.fluidInput, null + ); + } - if(recipe.fluidOutput != null) - { - displayGauge(58, 153-xOffset, 14-yOffset, 176, 0, 58, recipe.fluidOutput, null); - } - } + if (recipe.fluidOutput != null) { + displayGauge( + 58, 153 - xOffset, 14 - yOffset, 176, 0, 58, recipe.fluidOutput, null + ); + } + } - @Override - public void onUpdate() - { - super.onUpdate(); + @Override + public void onUpdate() { + super.onUpdate(); - ticksPassed++; - } + ticksPassed++; + } - @Override - public void loadCraftingRecipes(String outputId, Object... results) - { - if(outputId.equals(getRecipeId())) - { - for(ThermalEvaporationRecipe irecipe : getRecipes()) - { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - else if(outputId.equals("fluid") && results.length == 1 && results[0] instanceof FluidStack) - { - for(ThermalEvaporationRecipe irecipe : getRecipes()) - { - if(((FluidStack)results[0]).isFluidEqual(irecipe.recipeOutput.output)) - { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - } - else { - super.loadCraftingRecipes(outputId, results); - } - } + @Override + public void loadCraftingRecipes(String outputId, Object... results) { + if (outputId.equals(getRecipeId())) { + for (ThermalEvaporationRecipe irecipe : getRecipes()) { + arecipes.add(new CachedIORecipe(irecipe)); + } + } else if (outputId.equals("fluid") && results.length == 1 && results[0] instanceof FluidStack) { + for (ThermalEvaporationRecipe irecipe : getRecipes()) { + if (((FluidStack) results[0]).isFluidEqual(irecipe.recipeOutput.output)) { + arecipes.add(new CachedIORecipe(irecipe)); + } + } + } else { + super.loadCraftingRecipes(outputId, results); + } + } - @Override - public void loadUsageRecipes(String inputId, Object... ingredients) - { - if(inputId.equals("fluid") && ingredients.length == 1 && ingredients[0] instanceof FluidStack) - { - for(ThermalEvaporationRecipe irecipe : getRecipes()) - { - if(irecipe.recipeInput.ingredient.isFluidEqual((FluidStack)ingredients[0])) - { - arecipes.add(new CachedIORecipe(irecipe)); - } - } - } - else { - super.loadUsageRecipes(inputId, ingredients); - } - } + @Override + public void loadUsageRecipes(String inputId, Object... ingredients) { + if (inputId.equals("fluid") && ingredients.length == 1 + && ingredients[0] instanceof FluidStack) { + for (ThermalEvaporationRecipe irecipe : getRecipes()) { + if (irecipe.recipeInput.ingredient.isFluidEqual((FluidStack + ) ingredients[0])) { + arecipes.add(new CachedIORecipe(irecipe)); + } + } + } else { + super.loadUsageRecipes(inputId, ingredients); + } + } - @Override - public List handleTooltip(GuiRecipe gui, List currenttip, int recipe) - { - Point point = GuiDraw.getMousePosition(); + @Override + public List + handleTooltip(GuiRecipe gui, List currenttip, int recipe) { + Point point = GuiDraw.getMousePosition(); - int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); - int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); + int xAxis = point.x + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft + ); + int yAxis = point.y + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop + ); - if(xAxis >= 7 && xAxis <= 23 && yAxis >= 14+4 && yAxis <= 72+4) - { - currenttip.add(LangUtils.localizeFluidStack(((CachedIORecipe) arecipes.get(recipe)).fluidInput)); - } - else if(xAxis >= 153 && xAxis <= 169 && yAxis >= 14+4 && yAxis <= 72+4) - { - currenttip.add(LangUtils.localizeFluidStack(((CachedIORecipe) arecipes.get(recipe)).fluidOutput)); - } + if (xAxis >= 7 && xAxis <= 23 && yAxis >= 14 + 4 && yAxis <= 72 + 4) { + currenttip.add(LangUtils.localizeFluidStack( + ((CachedIORecipe) arecipes.get(recipe)).fluidInput + )); + } else if (xAxis >= 153 && xAxis <= 169 && yAxis >= 14 + 4 && yAxis <= 72 + 4) { + currenttip.add(LangUtils.localizeFluidStack( + ((CachedIORecipe) arecipes.get(recipe)).fluidOutput + )); + } - return super.handleTooltip(gui, currenttip, recipe); - } + return super.handleTooltip(gui, currenttip, recipe); + } - @Override - public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) - { - Point point = GuiDraw.getMousePosition(); + @Override + public boolean keyTyped(GuiRecipe gui, char keyChar, int keyCode, int recipe) { + Point point = GuiDraw.getMousePosition(); - int xAxis = point.x-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); - int yAxis = point.y-(Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); + int xAxis = point.x + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft + ); + int yAxis = point.y + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop + ); - FluidStack stack = null; + FluidStack stack = null; - if(xAxis >= 7 && xAxis <= 23 && yAxis >= 14+4 && yAxis <= 72+4) - { - stack = ((CachedIORecipe)arecipes.get(recipe)).fluidInput; - } - else if(xAxis >= 153 && xAxis <= 169 && yAxis >= 14+4 && yAxis <= 72+4) - { - stack = ((CachedIORecipe)arecipes.get(recipe)).fluidOutput; - } + if (xAxis >= 7 && xAxis <= 23 && yAxis >= 14 + 4 && yAxis <= 72 + 4) { + stack = ((CachedIORecipe) arecipes.get(recipe)).fluidInput; + } else if (xAxis >= 153 && xAxis <= 169 && yAxis >= 14 + 4 && yAxis <= 72 + 4) { + stack = ((CachedIORecipe) arecipes.get(recipe)).fluidOutput; + } - if(stack != null) - { - if(keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) - { - if(doFluidLookup(stack, false)) - { - return true; - } - } - else if(keyCode == NEIClientConfig.getKeyBinding("gui.usage")) - { - if(doFluidLookup(stack, true)) - { - return true; - } - } - } + if (stack != null) { + if (keyCode == NEIClientConfig.getKeyBinding("gui.recipe")) { + if (doFluidLookup(stack, false)) { + return true; + } + } else if (keyCode == NEIClientConfig.getKeyBinding("gui.usage")) { + if (doFluidLookup(stack, true)) { + return true; + } + } + } - return super.keyTyped(gui, keyChar, keyCode, recipe); - } + return super.keyTyped(gui, keyChar, keyCode, recipe); + } - @Override - public boolean mouseClicked(GuiRecipe gui, int button, int recipe) - { - Point point = GuiDraw.getMousePosition(); + @Override + public boolean mouseClicked(GuiRecipe gui, int button, int recipe) { + Point point = GuiDraw.getMousePosition(); - int xAxis = point.x - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft); - int yAxis = point.y - (Integer)MekanismUtils.getPrivateValue(gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop); + int xAxis = point.x + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiLeft + ); + int yAxis = point.y + - (Integer) MekanismUtils.getPrivateValue( + gui, GuiContainer.class, ObfuscatedNames.GuiContainer_guiTop + ); - FluidStack stack = null; + FluidStack stack = null; - if(xAxis >= 7 && xAxis <= 23 && yAxis >= 14+4 && yAxis <= 72+4) - { - stack = ((CachedIORecipe)arecipes.get(recipe)).fluidInput; - } - else if(xAxis >= 153 && xAxis <= 169 && yAxis >= 14+4 && yAxis <= 72+4) - { - stack = ((CachedIORecipe)arecipes.get(recipe)).fluidOutput; - } + if (xAxis >= 7 && xAxis <= 23 && yAxis >= 14 + 4 && yAxis <= 72 + 4) { + stack = ((CachedIORecipe) arecipes.get(recipe)).fluidInput; + } else if (xAxis >= 153 && xAxis <= 169 && yAxis >= 14 + 4 && yAxis <= 72 + 4) { + stack = ((CachedIORecipe) arecipes.get(recipe)).fluidOutput; + } - if(stack != null) - { - if(button == 0) - { - if(doFluidLookup(stack, false)) - { - return true; - } - } - else if(button == 1) - { - if(doFluidLookup(stack, true)) - { - return true; - } - } - } + if (stack != null) { + if (button == 0) { + if (doFluidLookup(stack, false)) { + return true; + } + } else if (button == 1) { + if (doFluidLookup(stack, true)) { + return true; + } + } + } - return super.mouseClicked(gui, button, recipe); - } + return super.mouseClicked(gui, button, recipe); + } - @Override - public int recipiesPerPage() - { - return 1; - } + @Override + public int recipiesPerPage() { + return 1; + } - @Override - public void addGuiElements() - { + @Override + public void addGuiElements() {} - } + public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe { + public FluidStack fluidInput; + public FluidStack fluidOutput; - public class CachedIORecipe extends TemplateRecipeHandler.CachedRecipe - { - public FluidStack fluidInput; - public FluidStack fluidOutput; + @Override + public PositionedStack getResult() { + return null; + } - @Override - public PositionedStack getResult() - { - return null; - } + public CachedIORecipe(FluidStack input, FluidStack output) { + fluidInput = input; + fluidOutput = output; + } - public CachedIORecipe(FluidStack input, FluidStack output) - { - fluidInput = input; - fluidOutput = output; - } - - public CachedIORecipe(ThermalEvaporationRecipe recipe) - { - this((FluidStack)recipe.recipeInput.ingredient, (FluidStack)recipe.recipeOutput.output); - } - } + public CachedIORecipe(ThermalEvaporationRecipe recipe) { + this( + (FluidStack) recipe.recipeInput.ingredient, + (FluidStack) recipe.recipeOutput.output + ); + } + } } diff --git a/src/main/java/mekanism/client/render/CTM.java b/src/main/java/mekanism/client/render/CTM.java index ee2a1e6f3..a7091f834 100644 --- a/src/main/java/mekanism/client/render/CTM.java +++ b/src/main/java/mekanism/client/render/CTM.java @@ -9,370 +9,411 @@ import net.minecraft.world.IBlockAccess; /** * CTM Logic adapted from Chisel. Code licensed under GPLv2 - * + * * @author AUTOMATIC_MAIDEN, asie, pokefenn, unpairedbracket */ -public class CTM -{ - static int submaps[][] = { {16, 17, 18, 19}, {16, 9, 18, 13}, {8, 9, 12, 13}, {8, 17, 12, 19}, {16, 9, 6, 15}, {8, 17, 14, 7}, {2, 11, 6, 15}, - {8, 9, 14, 15}, {10, 1, 14, 15}, {10, 11, 14, 5}, {0, 11, 4, 15}, {0, 1, 14, 15}, {}, {}, {}, {}, {16, 17, 6, 7}, {16, 9, 6, 5}, {8, 9, 4, 5}, - {8, 17, 4, 7}, {2, 11, 18, 13}, {10, 3, 12, 19}, {10, 11, 12, 13}, {10, 3, 14, 7}, {0, 11, 14, 15}, {10, 11, 4, 15}, {10, 11, 4, 5}, - {10, 1, 14, 5}, {}, {}, {}, {}, {2, 3, 6, 7}, {2, 1, 6, 5}, {0, 1, 4, 5}, {0, 3, 4, 7}, {2, 11, 6, 5}, {8, 9, 4, 15}, {2, 1, 6, 15}, {8, 9, 14, 5}, - {0, 1, 4, 15}, {0, 1, 14, 5}, {10, 1, 4, 15}, {0, 11, 14, 5}, {}, {}, {}, {}, {2, 3, 18, 19}, {2, 1, 18, 13}, {0, 1, 12, 13}, {0, 3, 12, 19}, - {10, 1, 12, 13}, {0, 3, 14, 7}, {0, 11, 12, 13}, {10, 3, 4, 7}, {0, 11, 4, 5}, {10, 1, 4, 5}, {10, 11, 14, 15}, {0, 1, 4, 5}, {}, {}, {}, {},}; +public class CTM { + static int submaps[][] = { + { 16, 17, 18, 19 }, + { 16, 9, 18, 13 }, + { 8, 9, 12, 13 }, + { 8, 17, 12, 19 }, + { 16, 9, 6, 15 }, + { 8, 17, 14, 7 }, + { 2, 11, 6, 15 }, + { 8, 9, 14, 15 }, + { 10, 1, 14, 15 }, + { 10, 11, 14, 5 }, + { 0, 11, 4, 15 }, + { 0, 1, 14, 15 }, + {}, + {}, + {}, + {}, + { 16, 17, 6, 7 }, + { 16, 9, 6, 5 }, + { 8, 9, 4, 5 }, + { 8, 17, 4, 7 }, + { 2, 11, 18, 13 }, + { 10, 3, 12, 19 }, + { 10, 11, 12, 13 }, + { 10, 3, 14, 7 }, + { 0, 11, 14, 15 }, + { 10, 11, 4, 15 }, + { 10, 11, 4, 5 }, + { 10, 1, 14, 5 }, + {}, + {}, + {}, + {}, + { 2, 3, 6, 7 }, + { 2, 1, 6, 5 }, + { 0, 1, 4, 5 }, + { 0, 3, 4, 7 }, + { 2, 11, 6, 5 }, + { 8, 9, 4, 15 }, + { 2, 1, 6, 15 }, + { 8, 9, 14, 5 }, + { 0, 1, 4, 15 }, + { 0, 1, 14, 5 }, + { 10, 1, 4, 15 }, + { 0, 11, 14, 5 }, + {}, + {}, + {}, + {}, + { 2, 3, 18, 19 }, + { 2, 1, 18, 13 }, + { 0, 1, 12, 13 }, + { 0, 3, 12, 19 }, + { 10, 1, 12, 13 }, + { 0, 3, 14, 7 }, + { 0, 11, 12, 13 }, + { 10, 3, 4, 7 }, + { 0, 11, 4, 5 }, + { 10, 1, 4, 5 }, + { 10, 11, 14, 15 }, + { 0, 1, 4, 5 }, + {}, + {}, + {}, + {}, + }; - public static int[] getSubmapIndices(IBlockAccess world, int x, int y, int z, int side, HashMap> blockMetas, boolean convexConnections) - { - int index = getTexture(world, x, y, z, side, blockMetas, convexConnections); + public static int[] getSubmapIndices( + IBlockAccess world, + int x, + int y, + int z, + int side, + HashMap> blockMetas, + boolean convexConnections + ) { + int index = getTexture(world, x, y, z, side, blockMetas, convexConnections); - return submaps[index]; - } + return submaps[index]; + } - public static int getTexture(IBlockAccess world, int x, int y, int z, int side, HashMap> blockMetas, boolean convexConnections) - { - if(world == null) - { - return 0; - } + public static int getTexture( + IBlockAccess world, + int x, + int y, + int z, + int side, + HashMap> blockMetas, + boolean convexConnections + ) { + if (world == null) { + return 0; + } - int texture = 0; + int texture = 0; - boolean b[] = new boolean[6]; + boolean b[] = new boolean[6]; - if(side <= 1) - { - b[0] = isConnected(world, x - 1, y, z, side, blockMetas, convexConnections); - b[1] = isConnected(world, x + 1, y, z, side, blockMetas, convexConnections); - b[2] = isConnected(world, x, y, z + 1, side, blockMetas, convexConnections); - b[3] = isConnected(world, x, y, z - 1, side, blockMetas, convexConnections); - } - else if(side == 2) - { - b[0] = isConnected(world, x + 1, y, z, side, blockMetas, convexConnections); - b[1] = isConnected(world, x - 1, y, z, side, blockMetas, convexConnections); - b[2] = isConnected(world, x, y - 1, z, side, blockMetas, convexConnections); - b[3] = isConnected(world, x, y + 1, z, side, blockMetas, convexConnections); - } - else if(side == 3) - { - b[0] = isConnected(world, x - 1, y, z, side, blockMetas, convexConnections); - b[1] = isConnected(world, x + 1, y, z, side, blockMetas, convexConnections); - b[2] = isConnected(world, x, y - 1, z, side, blockMetas, convexConnections); - b[3] = isConnected(world, x, y + 1, z, side, blockMetas, convexConnections); - } - else if(side == 4) - { - b[0] = isConnected(world, x, y, z - 1, side, blockMetas, convexConnections); - b[1] = isConnected(world, x, y, z + 1, side, blockMetas, convexConnections); - b[2] = isConnected(world, x, y - 1, z, side, blockMetas, convexConnections); - b[3] = isConnected(world, x, y + 1, z, side, blockMetas, convexConnections); - } - else if(side == 5) - { - b[0] = isConnected(world, x, y, z + 1, side, blockMetas, convexConnections); - b[1] = isConnected(world, x, y, z - 1, side, blockMetas, convexConnections); - b[2] = isConnected(world, x, y - 1, z, side, blockMetas, convexConnections); - b[3] = isConnected(world, x, y + 1, z, side, blockMetas, convexConnections); - } + if (side <= 1) { + b[0] = isConnected(world, x - 1, y, z, side, blockMetas, convexConnections); + b[1] = isConnected(world, x + 1, y, z, side, blockMetas, convexConnections); + b[2] = isConnected(world, x, y, z + 1, side, blockMetas, convexConnections); + b[3] = isConnected(world, x, y, z - 1, side, blockMetas, convexConnections); + } else if (side == 2) { + b[0] = isConnected(world, x + 1, y, z, side, blockMetas, convexConnections); + b[1] = isConnected(world, x - 1, y, z, side, blockMetas, convexConnections); + b[2] = isConnected(world, x, y - 1, z, side, blockMetas, convexConnections); + b[3] = isConnected(world, x, y + 1, z, side, blockMetas, convexConnections); + } else if (side == 3) { + b[0] = isConnected(world, x - 1, y, z, side, blockMetas, convexConnections); + b[1] = isConnected(world, x + 1, y, z, side, blockMetas, convexConnections); + b[2] = isConnected(world, x, y - 1, z, side, blockMetas, convexConnections); + b[3] = isConnected(world, x, y + 1, z, side, blockMetas, convexConnections); + } else if (side == 4) { + b[0] = isConnected(world, x, y, z - 1, side, blockMetas, convexConnections); + b[1] = isConnected(world, x, y, z + 1, side, blockMetas, convexConnections); + b[2] = isConnected(world, x, y - 1, z, side, blockMetas, convexConnections); + b[3] = isConnected(world, x, y + 1, z, side, blockMetas, convexConnections); + } else if (side == 5) { + b[0] = isConnected(world, x, y, z + 1, side, blockMetas, convexConnections); + b[1] = isConnected(world, x, y, z - 1, side, blockMetas, convexConnections); + b[2] = isConnected(world, x, y - 1, z, side, blockMetas, convexConnections); + b[3] = isConnected(world, x, y + 1, z, side, blockMetas, convexConnections); + } - if(b[0] & !b[1] & !b[2] & !b[3]) - { - texture = 3; - } - else if(!b[0] & b[1] & !b[2] & !b[3]) - { - texture = 1; - } - else if(!b[0] & !b[1] & b[2] & !b[3]) - { - texture = 16; - } - else if(!b[0] & !b[1] & !b[2] & b[3]) - { - texture = 48; - } - else if(b[0] & b[1] & !b[2] & !b[3]) - { - texture = 2; - } - else if(!b[0] & !b[1] & b[2] & b[3]) - { - texture = 32; - } - else if(b[0] & !b[1] & b[2] & !b[3]) - { - texture = 19; - } - else if(b[0] & !b[1] & !b[2] & b[3]) - { - texture = 51; - } - else if(!b[0] & b[1] & b[2] & !b[3]) - { - texture = 17; - } - else if(!b[0] & b[1] & !b[2] & b[3]) - { - texture = 49; - } - else if(!b[0] & b[1] & b[2] & b[3]) - { - texture = 33; - } - else if(b[0] & !b[1] & b[2] & b[3]) - { - texture = 35; - } - else if(b[0] & b[1] & !b[2] & b[3]) - { - texture = 50; - } - else if(b[0] & b[1] & b[2] & !b[3]) - { - texture = 18; - } - else if(b[0] & b[1] & b[2] & b[3]) - { - texture = 34; - } + if (b[0] & !b[1] & !b[2] & !b[3]) { + texture = 3; + } else if (!b[0] & b[1] & !b[2] & !b[3]) { + texture = 1; + } else if (!b[0] & !b[1] & b[2] & !b[3]) { + texture = 16; + } else if (!b[0] & !b[1] & !b[2] & b[3]) { + texture = 48; + } else if (b[0] & b[1] & !b[2] & !b[3]) { + texture = 2; + } else if (!b[0] & !b[1] & b[2] & b[3]) { + texture = 32; + } else if (b[0] & !b[1] & b[2] & !b[3]) { + texture = 19; + } else if (b[0] & !b[1] & !b[2] & b[3]) { + texture = 51; + } else if (!b[0] & b[1] & b[2] & !b[3]) { + texture = 17; + } else if (!b[0] & b[1] & !b[2] & b[3]) { + texture = 49; + } else if (!b[0] & b[1] & b[2] & b[3]) { + texture = 33; + } else if (b[0] & !b[1] & b[2] & b[3]) { + texture = 35; + } else if (b[0] & b[1] & !b[2] & b[3]) { + texture = 50; + } else if (b[0] & b[1] & b[2] & !b[3]) { + texture = 18; + } else if (b[0] & b[1] & b[2] & b[3]) { + texture = 34; + } - boolean b2[] = new boolean[6]; + boolean b2[] = new boolean[6]; - if(side <= 1) - { - b2[0] = !isConnected(world, x + 1, y, z + 1, side, blockMetas, convexConnections); - b2[1] = !isConnected(world, x - 1, y, z + 1, side, blockMetas, convexConnections); - b2[2] = !isConnected(world, x + 1, y, z - 1, side, blockMetas, convexConnections); - b2[3] = !isConnected(world, x - 1, y, z - 1, side, blockMetas, convexConnections); - } - else if(side == 2) - { - b2[0] = !isConnected(world, x - 1, y - 1, z, side, blockMetas, convexConnections); - b2[1] = !isConnected(world, x + 1, y - 1, z, side, blockMetas, convexConnections); - b2[2] = !isConnected(world, x - 1, y + 1, z, side, blockMetas, convexConnections); - b2[3] = !isConnected(world, x + 1, y + 1, z, side, blockMetas, convexConnections); - } - else if(side == 3) - { - b2[0] = !isConnected(world, x + 1, y - 1, z, side, blockMetas, convexConnections); - b2[1] = !isConnected(world, x - 1, y - 1, z, side, blockMetas, convexConnections); - b2[2] = !isConnected(world, x + 1, y + 1, z, side, blockMetas, convexConnections); - b2[3] = !isConnected(world, x - 1, y + 1, z, side, blockMetas, convexConnections); - } - else if(side == 4) - { - b2[0] = !isConnected(world, x, y - 1, z + 1, side, blockMetas, convexConnections); - b2[1] = !isConnected(world, x, y - 1, z - 1, side, blockMetas, convexConnections); - b2[2] = !isConnected(world, x, y + 1, z + 1, side, blockMetas, convexConnections); - b2[3] = !isConnected(world, x, y + 1, z - 1, side, blockMetas, convexConnections); - } - else if(side == 5) - { - b2[0] = !isConnected(world, x, y - 1, z - 1, side, blockMetas, convexConnections); - b2[1] = !isConnected(world, x, y - 1, z + 1, side, blockMetas, convexConnections); - b2[2] = !isConnected(world, x, y + 1, z - 1, side, blockMetas, convexConnections); - b2[3] = !isConnected(world, x, y + 1, z + 1, side, blockMetas, convexConnections); - } + if (side <= 1) { + b2[0] = !isConnected( + world, x + 1, y, z + 1, side, blockMetas, convexConnections + ); + b2[1] = !isConnected( + world, x - 1, y, z + 1, side, blockMetas, convexConnections + ); + b2[2] = !isConnected( + world, x + 1, y, z - 1, side, blockMetas, convexConnections + ); + b2[3] = !isConnected( + world, x - 1, y, z - 1, side, blockMetas, convexConnections + ); + } else if (side == 2) { + b2[0] = !isConnected( + world, x - 1, y - 1, z, side, blockMetas, convexConnections + ); + b2[1] = !isConnected( + world, x + 1, y - 1, z, side, blockMetas, convexConnections + ); + b2[2] = !isConnected( + world, x - 1, y + 1, z, side, blockMetas, convexConnections + ); + b2[3] = !isConnected( + world, x + 1, y + 1, z, side, blockMetas, convexConnections + ); + } else if (side == 3) { + b2[0] = !isConnected( + world, x + 1, y - 1, z, side, blockMetas, convexConnections + ); + b2[1] = !isConnected( + world, x - 1, y - 1, z, side, blockMetas, convexConnections + ); + b2[2] = !isConnected( + world, x + 1, y + 1, z, side, blockMetas, convexConnections + ); + b2[3] = !isConnected( + world, x - 1, y + 1, z, side, blockMetas, convexConnections + ); + } else if (side == 4) { + b2[0] = !isConnected( + world, x, y - 1, z + 1, side, blockMetas, convexConnections + ); + b2[1] = !isConnected( + world, x, y - 1, z - 1, side, blockMetas, convexConnections + ); + b2[2] = !isConnected( + world, x, y + 1, z + 1, side, blockMetas, convexConnections + ); + b2[3] = !isConnected( + world, x, y + 1, z - 1, side, blockMetas, convexConnections + ); + } else if (side == 5) { + b2[0] = !isConnected( + world, x, y - 1, z - 1, side, blockMetas, convexConnections + ); + b2[1] = !isConnected( + world, x, y - 1, z + 1, side, blockMetas, convexConnections + ); + b2[2] = !isConnected( + world, x, y + 1, z - 1, side, blockMetas, convexConnections + ); + b2[3] = !isConnected( + world, x, y + 1, z + 1, side, blockMetas, convexConnections + ); + } - if(texture == 17 && b2[0]) - { - texture = 4; - } + if (texture == 17 && b2[0]) { + texture = 4; + } - if(texture == 19 && b2[1]) - { - texture = 5; - } + if (texture == 19 && b2[1]) { + texture = 5; + } - if(texture == 49 && b2[2]) - { - texture = 20; - } + if (texture == 49 && b2[2]) { + texture = 20; + } - if(texture == 51 && b2[3]) - { - texture = 21; - } + if (texture == 51 && b2[3]) { + texture = 21; + } - if(texture == 18 && b2[0] && b2[1]) - { - texture = 7; - } + if (texture == 18 && b2[0] && b2[1]) { + texture = 7; + } - if(texture == 33 && b2[0] && b2[2]) - { - texture = 6; - } + if (texture == 33 && b2[0] && b2[2]) { + texture = 6; + } - if(texture == 35 && b2[3] && b2[1]) - { - texture = 23; - } + if (texture == 35 && b2[3] && b2[1]) { + texture = 23; + } - if(texture == 50 && b2[3] && b2[2]) - { - texture = 22; - } + if (texture == 50 && b2[3] && b2[2]) { + texture = 22; + } - if(texture == 18 && !b2[0] && b2[1]) - { - texture = 39; - } + if (texture == 18 && !b2[0] && b2[1]) { + texture = 39; + } - if(texture == 33 && b2[0] && !b2[2]) - { - texture = 38; - } + if (texture == 33 && b2[0] && !b2[2]) { + texture = 38; + } - if(texture == 35 && !b2[3] && b2[1]) - { - texture = 53; - } + if (texture == 35 && !b2[3] && b2[1]) { + texture = 53; + } - if(texture == 50 && b2[3] && !b2[2]) - { - texture = 52; - } + if (texture == 50 && b2[3] && !b2[2]) { + texture = 52; + } - if(texture == 18 && b2[0] && !b2[1]) - { - texture = 37; - } + if (texture == 18 && b2[0] && !b2[1]) { + texture = 37; + } - if(texture == 33 && !b2[0] && b2[2]) - { - texture = 36; - } + if (texture == 33 && !b2[0] && b2[2]) { + texture = 36; + } - if(texture == 35 && b2[3] && !b2[1]) - { - texture = 55; - } + if (texture == 35 && b2[3] && !b2[1]) { + texture = 55; + } - if(texture == 50 && !b2[3] && b2[2]) - { - texture = 54; - } + if (texture == 50 && !b2[3] && b2[2]) { + texture = 54; + } - if(texture == 34 && b2[0] && b2[1] && b2[2] && b2[3]) - { - texture = 58; - } + if (texture == 34 && b2[0] && b2[1] && b2[2] && b2[3]) { + texture = 58; + } - if(texture == 34 && !b2[0] && b2[1] && b2[2] && b2[3]) - { - texture = 9; - } + if (texture == 34 && !b2[0] && b2[1] && b2[2] && b2[3]) { + texture = 9; + } - if(texture == 34 && b2[0] && !b2[1] && b2[2] && b2[3]) - { - texture = 25; - } + if (texture == 34 && b2[0] && !b2[1] && b2[2] && b2[3]) { + texture = 25; + } - if(texture == 34 && b2[0] && b2[1] && !b2[2] && b2[3]) - { - texture = 8; - } + if (texture == 34 && b2[0] && b2[1] && !b2[2] && b2[3]) { + texture = 8; + } - if(texture == 34 && b2[0] && b2[1] && b2[2] && !b2[3]) - { - texture = 24; - } + if (texture == 34 && b2[0] && b2[1] && b2[2] && !b2[3]) { + texture = 24; + } - if(texture == 34 && b2[0] && b2[1] && !b2[2] && !b2[3]) - { - texture = 11; - } + if (texture == 34 && b2[0] && b2[1] && !b2[2] && !b2[3]) { + texture = 11; + } - if(texture == 34 && !b2[0] && !b2[1] && b2[2] && b2[3]) - { - texture = 26; - } + if (texture == 34 && !b2[0] && !b2[1] && b2[2] && b2[3]) { + texture = 26; + } - if(texture == 34 && !b2[0] && b2[1] && !b2[2] && b2[3]) - { - texture = 27; - } + if (texture == 34 && !b2[0] && b2[1] && !b2[2] && b2[3]) { + texture = 27; + } - if(texture == 34 && b2[0] && !b2[1] && b2[2] && !b2[3]) - { - texture = 10; - } + if (texture == 34 && b2[0] && !b2[1] && b2[2] && !b2[3]) { + texture = 10; + } - if(texture == 34 && b2[0] && !b2[1] && !b2[2] && b2[3]) - { - texture = 42; - } - if(texture == 34 && !b2[0] && b2[1] && b2[2] && !b2[3]) - { - texture = 43; - } + if (texture == 34 && b2[0] && !b2[1] && !b2[2] && b2[3]) { + texture = 42; + } + if (texture == 34 && !b2[0] && b2[1] && b2[2] && !b2[3]) { + texture = 43; + } - if(texture == 34 && b2[0] && !b2[1] && !b2[2] && !b2[3]) - { - texture = 40; - } + if (texture == 34 && b2[0] && !b2[1] && !b2[2] && !b2[3]) { + texture = 40; + } - if(texture == 34 && !b2[0] && b2[1] && !b2[2] && !b2[3]) - { - texture = 41; - } + if (texture == 34 && !b2[0] && b2[1] && !b2[2] && !b2[3]) { + texture = 41; + } - if(texture == 34 && !b2[0] && !b2[1] && b2[2] && !b2[3]) - { - texture = 56; - } + if (texture == 34 && !b2[0] && !b2[1] && b2[2] && !b2[3]) { + texture = 56; + } - if(texture == 34 && !b2[0] && !b2[1] && !b2[2] && b2[3]) - { - texture = 57; - } + if (texture == 34 && !b2[0] && !b2[1] && !b2[2] && b2[3]) { + texture = 57; + } - return texture; - } + return texture; + } - public static boolean isConnected(IBlockAccess world, int x, int y, int z, int side, HashMap> blockMetas, boolean convexConnections) - { - int x2 = x, y2 = y, z2 = z; + public static boolean isConnected( + IBlockAccess world, + int x, + int y, + int z, + int side, + HashMap> blockMetas, + boolean convexConnections + ) { + int x2 = x, y2 = y, z2 = z; - switch(side) - { - case 0: - y2--; - break; - case 1: - y2++; - break; - case 2: - z2--; - break; - case 3: - z2++; - break; - case 4: - x2--; - break; - case 5: - x2++; - break; - } + switch (side) { + case 0: + y2--; + break; + case 1: + y2++; + break; + case 2: + z2--; + break; + case 3: + z2++; + break; + case 4: + x2--; + break; + case 5: + x2++; + break; + } - Block block1 = world.getBlock(x, y, z); - Block block2 = world.getBlock(x2, y2, z2); + Block block1 = world.getBlock(x, y, z); + Block block2 = world.getBlock(x2, y2, z2); - int meta1 = world.getBlockMetadata(x, y, z); - int meta2 = world.getBlockMetadata(x2, y2, z2); + int meta1 = world.getBlockMetadata(x, y, z); + int meta2 = world.getBlockMetadata(x2, y2, z2); - boolean validBlockMeta1 = false; - boolean invalidBlockMeta2 = true; + boolean validBlockMeta1 = false; + boolean invalidBlockMeta2 = true; - for(Entry> entry : blockMetas.entrySet()) - { - validBlockMeta1 |= block1.equals(entry.getKey()) && entry.getValue().contains(meta1); + for (Entry> entry : blockMetas.entrySet()) { + validBlockMeta1 + |= block1.equals(entry.getKey()) && entry.getValue().contains(meta1); - invalidBlockMeta2 &= convexConnections || !(block2.equals(entry.getKey()) && entry.getValue().contains(meta2)); - } + invalidBlockMeta2 &= convexConnections + || !(block2.equals(entry.getKey()) && entry.getValue().contains(meta2)); + } - return validBlockMeta1 && invalidBlockMeta2; - } + return validBlockMeta1 && invalidBlockMeta2; + } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/render/ColourTemperature.java b/src/main/java/mekanism/client/render/ColourTemperature.java index 18e62ccc2..b7500e812 100644 --- a/src/main/java/mekanism/client/render/ColourTemperature.java +++ b/src/main/java/mekanism/client/render/ColourTemperature.java @@ -2,120 +2,117 @@ package mekanism.client.render; import java.util.HashMap; -import mekanism.api.IHeatTransfer; import codechicken.lib.colour.ColourRGBA; +import mekanism.api.IHeatTransfer; -public class ColourTemperature extends ColourRGBA -{ - public static HashMap cache = new HashMap(); +public class ColourTemperature extends ColourRGBA { + public static HashMap cache + = new HashMap(); - public double temp; + public double temp; - public ColourTemperature(double r, double g, double b, double a, double t) - { - super(r, g, b, a); - temp = t; - } + public ColourTemperature(double r, double g, double b, double a, double t) { + super(r, g, b, a); + temp = t; + } - public static ColourTemperature fromTemperature(double temperature, ColourRGBA baseColour) - { - if(temperature < 0) - { - double alphaBlend = -temperature/IHeatTransfer.AMBIENT_TEMP; - if(alphaBlend < 0) - alphaBlend = 0; - if(alphaBlend > 1) - alphaBlend = 1; - return new ColourTemperature(1, 1, 1, alphaBlend, temperature).blendOnto(baseColour); - } - double absTemp = temperature + IHeatTransfer.AMBIENT_TEMP; - absTemp /= 100; + public static ColourTemperature + fromTemperature(double temperature, ColourRGBA baseColour) { + if (temperature < 0) { + double alphaBlend = -temperature / IHeatTransfer.AMBIENT_TEMP; + if (alphaBlend < 0) + alphaBlend = 0; + if (alphaBlend > 1) + alphaBlend = 1; + return new ColourTemperature(1, 1, 1, alphaBlend, temperature) + .blendOnto(baseColour); + } + double absTemp = temperature + IHeatTransfer.AMBIENT_TEMP; + absTemp /= 100; - if(cache.containsKey((int)absTemp)) - { - return cache.get((int)absTemp).blendOnto(baseColour); - } + if (cache.containsKey((int) absTemp)) { + return cache.get((int) absTemp).blendOnto(baseColour); + } - double tmpCalc; - double red, green, blue, alpha; - double effectiveTemp = absTemp; + double tmpCalc; + double red, green, blue, alpha; + double effectiveTemp = absTemp; - if(effectiveTemp < 10) - effectiveTemp = 10; - if(effectiveTemp > 400) - effectiveTemp = 400; + if (effectiveTemp < 10) + effectiveTemp = 10; + if (effectiveTemp > 400) + effectiveTemp = 400; - if(effectiveTemp <= 66) - { - red = 1; - } - else - { - tmpCalc = effectiveTemp - 60; - tmpCalc = 329.698727446 * Math.pow(tmpCalc,-0.1332047592); - red = tmpCalc/255D; - } + if (effectiveTemp <= 66) { + red = 1; + } else { + tmpCalc = effectiveTemp - 60; + tmpCalc = 329.698727446 * Math.pow(tmpCalc, -0.1332047592); + red = tmpCalc / 255D; + } - if(effectiveTemp <= 66) - { - tmpCalc = effectiveTemp; - tmpCalc = 99.4708025861 * Math.log(tmpCalc) - 161.1195681661; - green = tmpCalc/255D; - } - else - { - tmpCalc = effectiveTemp - 60; - tmpCalc = 288.1221695283 * Math.pow(tmpCalc, -0.0755148492); - green = tmpCalc/255D; - } + if (effectiveTemp <= 66) { + tmpCalc = effectiveTemp; + tmpCalc = 99.4708025861 * Math.log(tmpCalc) - 161.1195681661; + green = tmpCalc / 255D; + } else { + tmpCalc = effectiveTemp - 60; + tmpCalc = 288.1221695283 * Math.pow(tmpCalc, -0.0755148492); + green = tmpCalc / 255D; + } - if(effectiveTemp >= 66) - { - blue = 1; - } - else if(effectiveTemp <= 19) - { - blue = 0; - } - else - { - tmpCalc = effectiveTemp - 10; - tmpCalc = 138.5177312231 * Math.log(tmpCalc) - 305.0447927307; + if (effectiveTemp >= 66) { + blue = 1; + } else if (effectiveTemp <= 19) { + blue = 0; + } else { + tmpCalc = effectiveTemp - 10; + tmpCalc = 138.5177312231 * Math.log(tmpCalc) - 305.0447927307; - blue = tmpCalc / 255D; - } + blue = tmpCalc / 255D; + } - alpha = temperature/1000; + alpha = temperature / 1000; - if(red < 0) red = 0; - if(red > 1) red = 1; + if (red < 0) + red = 0; + if (red > 1) + red = 1; - if(green < 0) green = 0; - if(green > 1) green = 1; + if (green < 0) + green = 0; + if (green > 1) + green = 1; - if(blue < 0) blue = 0; - if(blue > 1) blue = 1; + if (blue < 0) + blue = 0; + if (blue > 1) + blue = 1; - if(alpha < 0) alpha = 0; - if(alpha > 1) alpha = 1; + if (alpha < 0) + alpha = 0; + if (alpha > 1) + alpha = 1; - ColourTemperature colourTemperature = new ColourTemperature(red, green, blue, alpha, temperature); + ColourTemperature colourTemperature + = new ColourTemperature(red, green, blue, alpha, temperature); - cache.put((int)(absTemp), colourTemperature); + cache.put((int) (absTemp), colourTemperature); - return colourTemperature.blendOnto(baseColour); - } + return colourTemperature.blendOnto(baseColour); + } - public ColourTemperature blendOnto(ColourRGBA baseColour) - { - double sR = (r & 0xFF)/255D, sG = (g & 0xFF)/255D, sB = (b & 0xFF)/255D, sA = (a & 0xFF)/255D; - double dR = (baseColour.r & 0xFF)/255D, dG = (baseColour.g & 0xFF)/255D, dB = (baseColour.b & 0xFF)/255D, dA = (baseColour.a & 0xFF)/255D; + public ColourTemperature blendOnto(ColourRGBA baseColour) { + double sR = (r & 0xFF) / 255D, sG = (g & 0xFF) / 255D, sB = (b & 0xFF) / 255D, + sA = (a & 0xFF) / 255D; + double dR = (baseColour.r & 0xFF) / 255D, dG = (baseColour.g & 0xFF) / 255D, + dB = (baseColour.b & 0xFF) / 255D, dA = (baseColour.a & 0xFF) / 255D; - double rR = sR * sA + dR * (1-sA); - double rG = sG * sA + dG * (1-sA); - double rB = sB * sA + dB * (1-sA); - double rA = dA * 1D + sA * (1-dA); + double rR = sR * sA + dR * (1 - sA); + double rG = sG * sA + dG * (1 - sA); + double rB = sB * sA + dB * (1 - sA); + double rA = dA * 1D + sA * (1 - dA); - return new ColourTemperature(rR, rG, rB, rA, temp); - } + return new ColourTemperature(rR, rG, rB, rA, temp); + } } diff --git a/src/main/java/mekanism/client/render/MekanismRenderer.java b/src/main/java/mekanism/client/render/MekanismRenderer.java index 922ba5431..03c1a7df8 100644 --- a/src/main/java/mekanism/client/render/MekanismRenderer.java +++ b/src/main/java/mekanism/client/render/MekanismRenderer.java @@ -6,6 +6,9 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.EnumColor; import mekanism.api.gas.Gas; import mekanism.api.gas.GasRegistry; @@ -42,480 +45,490 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; - import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class MekanismRenderer -{ - private static RenderBlocks renderBlocks = new RenderBlocks(); - - public static IIcon[] colors = new IIcon[256]; - - public static IIcon energyIcon; - public static IIcon heatIcon; - - public static float GAS_RENDER_BASE = 0.2F; - - public static Map overlays = new HashMap(); - - private static float lightmapLastX; +public class MekanismRenderer { + private static RenderBlocks renderBlocks = new RenderBlocks(); + + public static IIcon[] colors = new IIcon[256]; + + public static IIcon energyIcon; + public static IIcon heatIcon; + + public static float GAS_RENDER_BASE = 0.2F; + + public static Map overlays + = new HashMap(); + + private static float lightmapLastX; private static float lightmapLastY; - private static boolean optifineBreak = false; - - public static int[] directionMap = new int[] {3, 0, 1, 2}; - - public static RenderConfigurableMachine machineRenderer = new RenderConfigurableMachine(); - - private static String[] simpleSides = new String[] {"Bottom", "Top", "Front", "Back", "Left", "Right"}; - - public static void init() - { - MinecraftForge.EVENT_BUS.register(new MekanismRenderer()); - } - - @SubscribeEvent - public void onStitch(TextureStitchEvent.Pre event) - { - if(event.map.getTextureType() == 0) - { - for(EnumColor color : EnumColor.values()) - { - colors[color.ordinal()] = event.map.registerIcon("mekanism:overlay/overlay_" + color.unlocalizedName); - } - - for(TransmissionType type : TransmissionType.values()) - { - overlays.put(type, event.map.registerIcon("mekanism:overlay/" + type.getTransmission() + "Overlay")); - } - - energyIcon = event.map.registerIcon("mekanism:liquid/LiquidEnergy"); - heatIcon = event.map.registerIcon("mekanism:liquid/LiquidHeat"); - - GasRegistry.getGas("hydrogen").setIcon(event.map.registerIcon("mekanism:liquid/LiquidHydrogen")); - GasRegistry.getGas("oxygen").setIcon(event.map.registerIcon("mekanism:liquid/LiquidOxygen")); - GasRegistry.getGas("water").setIcon(event.map.registerIcon("mekanism:liquid/LiquidSteam")); - GasRegistry.getGas("chlorine").setIcon(event.map.registerIcon("mekanism:liquid/LiquidChlorine")); - GasRegistry.getGas("sulfurDioxideGas").setIcon(event.map.registerIcon("mekanism:liquid/LiquidSulfurDioxide")); - GasRegistry.getGas("sulfurTrioxideGas").setIcon(event.map.registerIcon("mekanism:liquid/LiquidSulfurTrioxide")); - GasRegistry.getGas("sulfuricAcid").setIcon(event.map.registerIcon("mekanism:liquid/LiquidSulfuricAcid")); - GasRegistry.getGas("hydrogenChloride").setIcon(event.map.registerIcon("mekanism:liquid/LiquidHydrogenChloride")); - GasRegistry.getGas("liquidOsmium").setIcon(event.map.registerIcon("mekanism:liquid/LiquidOsmium")); - GasRegistry.getGas("elementizerFuel").setIcon(event.map.registerIcon("mekanism:liquid/LiquidOsmium")); //TODO specific Icon - GasRegistry.getGas("liquidStone").setIcon(event.map.registerIcon("mekanism:liquid/LiquidStone")); - GasRegistry.getGas("ethene").setIcon(event.map.registerIcon("mekanism:liquid/LiquidEthene")); - GasRegistry.getGas("brine").setIcon(event.map.registerIcon("mekanism:liquid/LiquidBrine")); - GasRegistry.getGas("sodium").setIcon(event.map.registerIcon("mekanism:liquid/LiquidSodium")); - GasRegistry.getGas("deuterium").setIcon(event.map.registerIcon("mekanism:liquid/LiquidDeuterium")); - GasRegistry.getGas("tritium").setIcon(event.map.registerIcon("mekanism:liquid/LiquidTritium")); - GasRegistry.getGas("fusionFuelDT").setIcon(event.map.registerIcon("mekanism:liquid/LiquidDT")); - GasRegistry.getGas("lithium").setIcon(event.map.registerIcon("mekanism:liquid/LiquidLithium")); - GasRegistry.getGas("methane").setIcon(event.map.registerIcon("mekanism:liquid/LiquidMethane")); + private static boolean optifineBreak = false; - for(Gas gas : GasRegistry.getRegisteredGasses()) - { - if(gas instanceof OreGas) - { - if(gas.getUnlocalizedName().contains("clean")) - { - gas.setIcon(event.map.registerIcon("mekanism:liquid/LiquidCleanOre")); - } - else { - gas.setIcon(event.map.registerIcon("mekanism:liquid/LiquidOre")); - } - } - } + public static int[] directionMap = new int[] { 3, 0, 1, 2 }; - FluidRegistry.getFluid("brine").setIcons(event.map.registerIcon("mekanism:liquid/LiquidBrine")); - FluidRegistry.getFluid("heavywater").setIcons(event.map.registerIcon("mekanism:liquid/LiquidHeavyWater")); - FluidRegistry.getFluid("steam").setIcons(event.map.registerIcon("mekanism:liquid/LiquidSteam")); - - for(InfuseType type : InfuseRegistry.getInfuseMap().values()) - { - type.setIcon(event.map.registerIcon(type.textureLocation)); - } + public static RenderConfigurableMachine machineRenderer + = new RenderConfigurableMachine(); - if(RenderPartTransmitter.getInstance() != null) - { - RenderPartTransmitter.getInstance().resetDisplayInts(); - } - - RenderDynamicTank.resetDisplayInts(); - RenderThermalEvaporationController.resetDisplayInts(); - RenderFluidTank.resetDisplayInts(); - RenderThermoelectricBoiler.resetDisplayInts(); - } - } - - public static boolean blockIconExists(String texture) //Credit to CoFHCore - { - String[] split = texture.split(":"); - texture = split[0] + ":textures/blocks/" + split[1] + ".png"; - - try { - Minecraft.getMinecraft().getResourceManager().getAllResources(new ResourceLocation(texture)); - return true; - } catch(Throwable t) { - return false; - } - } - - public static void loadDynamicTextures(IIconRegister register, String name, IIcon[] textures, DefIcon... defaults) - { - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - String tex = "mekanism:" + name + simpleSides[side.ordinal()]; - String texOn = tex + "On"; - - if(blockIconExists(tex)) - { - textures[side.ordinal()] = register.registerIcon(tex); - - if(blockIconExists(texOn)) - { - textures[side.ordinal()+6] = register.registerIcon(texOn); - } - else { - boolean found = false; - - for(DefIcon def : defaults) - { - if(def.icons.contains(side.ordinal()+6) && def.overridesInactive) - { - textures[side.ordinal()+6] = def.defIcon; - found = true; - } - } - - if(!found) - { - textures[side.ordinal()+6] = register.registerIcon(tex); - } - } - } - else { - for(DefIcon def : defaults) - { - if(def.icons.contains(side.ordinal())) - { - textures[side.ordinal()] = def.defIcon; - } - - if(def.icons.contains(side.ordinal()+6)) - { - textures[side.ordinal()+6] = def.defIcon; - } - } - } - } - } - - public static class DefIcon - { - public IIcon defIcon; - - public List icons = new ArrayList(); - - /** If this DefIcon should be prioritized over a machine's side-specific off texture - * if no on texture is present. */ - public boolean overridesInactive = true; - - public DefIcon(IIcon icon, int... is) - { - defIcon = icon; - - for(int i : is) - { - icons.add(i); - } - } - - public DefIcon setOverrides(boolean b) - { - overridesInactive = b; - - return this; - } - - public static DefIcon getAll(IIcon icon) - { - return new DefIcon(icon, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); - } - - public static DefIcon getActivePair(IIcon icon, int... is) - { - DefIcon ret = new DefIcon(icon, is); - - for(int i : is) - { - ret.icons.add(i+6); - } - - return ret; - } - } - - public static class Model3D - { - public double minX; - public double minY; - public double minZ; - public double maxX; - public double maxY; - public double maxZ; - - public IIcon[] textures = new IIcon[6]; - - public boolean[] renderSides = new boolean[] {true, true, true, true, true, true, false}; + private static String[] simpleSides + = new String[] { "Bottom", "Top", "Front", "Back", "Left", "Right" }; - public Block baseBlock = Blocks.sand; - - public final void setBlockBounds(double xNeg, double yNeg, double zNeg, double xPos, double yPos, double zPos) - { - minX = xNeg; - minY = yNeg; - minZ = zNeg; - maxX = xPos; - maxY = yPos; - maxZ = zPos; - } - - public void setSideRender(ForgeDirection side, boolean value) - { - renderSides[side.ordinal()] = value; - } - - public boolean shouldSideRender(ForgeDirection side) - { - return renderSides[side.ordinal()]; - } + public static void init() { + MinecraftForge.EVENT_BUS.register(new MekanismRenderer()); + } + + @SubscribeEvent + public void onStitch(TextureStitchEvent.Pre event) { + if (event.map.getTextureType() == 0) { + for (EnumColor color : EnumColor.values()) { + colors[color.ordinal()] = event.map.registerIcon( + "mekanism:overlay/overlay_" + color.unlocalizedName + ); + } + + for (TransmissionType type : TransmissionType.values()) { + overlays.put( + type, + event.map.registerIcon( + "mekanism:overlay/" + type.getTransmission() + "Overlay" + ) + ); + } + + energyIcon = event.map.registerIcon("mekanism:liquid/LiquidEnergy"); + heatIcon = event.map.registerIcon("mekanism:liquid/LiquidHeat"); + + GasRegistry.getGas("hydrogen") + .setIcon(event.map.registerIcon("mekanism:liquid/LiquidHydrogen")); + GasRegistry.getGas("oxygen").setIcon( + event.map.registerIcon("mekanism:liquid/LiquidOxygen") + ); + GasRegistry.getGas("water").setIcon( + event.map.registerIcon("mekanism:liquid/LiquidSteam") + ); + GasRegistry.getGas("chlorine") + .setIcon(event.map.registerIcon("mekanism:liquid/LiquidChlorine")); + GasRegistry.getGas("sulfurDioxideGas") + .setIcon(event.map.registerIcon("mekanism:liquid/LiquidSulfurDioxide")); + GasRegistry.getGas("sulfurTrioxideGas") + .setIcon(event.map.registerIcon("mekanism:liquid/LiquidSulfurTrioxide")); + GasRegistry.getGas("sulfuricAcid") + .setIcon(event.map.registerIcon("mekanism:liquid/LiquidSulfuricAcid")); + GasRegistry.getGas("hydrogenChloride") + .setIcon(event.map.registerIcon("mekanism:liquid/LiquidHydrogenChloride") + ); + GasRegistry.getGas("liquidOsmium") + .setIcon(event.map.registerIcon("mekanism:liquid/LiquidOsmium")); + GasRegistry.getGas("elementizerFuel") + .setIcon(event.map.registerIcon("mekanism:liquid/LiquidOsmium") + ); //TODO specific Icon + GasRegistry.getGas("liquidStone") + .setIcon(event.map.registerIcon("mekanism:liquid/LiquidStone")); + GasRegistry.getGas("ethene").setIcon( + event.map.registerIcon("mekanism:liquid/LiquidEthene") + ); + GasRegistry.getGas("brine").setIcon( + event.map.registerIcon("mekanism:liquid/LiquidBrine") + ); + GasRegistry.getGas("sodium").setIcon( + event.map.registerIcon("mekanism:liquid/LiquidSodium") + ); + GasRegistry.getGas("deuterium") + .setIcon(event.map.registerIcon("mekanism:liquid/LiquidDeuterium")); + GasRegistry.getGas("tritium").setIcon( + event.map.registerIcon("mekanism:liquid/LiquidTritium") + ); + GasRegistry.getGas("fusionFuelDT") + .setIcon(event.map.registerIcon("mekanism:liquid/LiquidDT")); + GasRegistry.getGas("lithium").setIcon( + event.map.registerIcon("mekanism:liquid/LiquidLithium") + ); + GasRegistry.getGas("methane").setIcon( + event.map.registerIcon("mekanism:liquid/LiquidMethane") + ); + + for (Gas gas : GasRegistry.getRegisteredGasses()) { + if (gas instanceof OreGas) { + if (gas.getUnlocalizedName().contains("clean")) { + gas.setIcon( + event.map.registerIcon("mekanism:liquid/LiquidCleanOre") + ); + } else { + gas.setIcon(event.map.registerIcon("mekanism:liquid/LiquidOre")); + } + } + } + + FluidRegistry.getFluid("brine").setIcons( + event.map.registerIcon("mekanism:liquid/LiquidBrine") + ); + FluidRegistry.getFluid("heavywater") + .setIcons(event.map.registerIcon("mekanism:liquid/LiquidHeavyWater")); + FluidRegistry.getFluid("steam").setIcons( + event.map.registerIcon("mekanism:liquid/LiquidSteam") + ); + + for (InfuseType type : InfuseRegistry.getInfuseMap().values()) { + type.setIcon(event.map.registerIcon(type.textureLocation)); + } + + if (RenderPartTransmitter.getInstance() != null) { + RenderPartTransmitter.getInstance().resetDisplayInts(); + } + + RenderDynamicTank.resetDisplayInts(); + RenderThermalEvaporationController.resetDisplayInts(); + RenderFluidTank.resetDisplayInts(); + RenderThermoelectricBoiler.resetDisplayInts(); + } + } + + public static boolean blockIconExists(String texture) //Credit to CoFHCore + { + String[] split = texture.split(":"); + texture = split[0] + ":textures/blocks/" + split[1] + ".png"; + + try { + Minecraft.getMinecraft().getResourceManager().getAllResources( + new ResourceLocation(texture) + ); + return true; + } catch (Throwable t) { + return false; + } + } + + public static void loadDynamicTextures( + IIconRegister register, String name, IIcon[] textures, DefIcon... defaults + ) { + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + String tex = "mekanism:" + name + simpleSides[side.ordinal()]; + String texOn = tex + "On"; + + if (blockIconExists(tex)) { + textures[side.ordinal()] = register.registerIcon(tex); + + if (blockIconExists(texOn)) { + textures[side.ordinal() + 6] = register.registerIcon(texOn); + } else { + boolean found = false; + + for (DefIcon def : defaults) { + if (def.icons.contains(side.ordinal() + 6) + && def.overridesInactive) { + textures[side.ordinal() + 6] = def.defIcon; + found = true; + } + } + + if (!found) { + textures[side.ordinal() + 6] = register.registerIcon(tex); + } + } + } else { + for (DefIcon def : defaults) { + if (def.icons.contains(side.ordinal())) { + textures[side.ordinal()] = def.defIcon; + } + + if (def.icons.contains(side.ordinal() + 6)) { + textures[side.ordinal() + 6] = def.defIcon; + } + } + } + } + } + + public static class DefIcon { + public IIcon defIcon; + + public List icons = new ArrayList(); + + /** + * If this DefIcon should be prioritized over a machine's side-specific off + * texture if no on texture is present. + */ + public boolean overridesInactive = true; + + public DefIcon(IIcon icon, int... is) { + defIcon = icon; + + for (int i : is) { + icons.add(i); + } + } + + public DefIcon setOverrides(boolean b) { + overridesInactive = b; + + return this; + } + + public static DefIcon getAll(IIcon icon) { + return new DefIcon(icon, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); + } + + public static DefIcon getActivePair(IIcon icon, int... is) { + DefIcon ret = new DefIcon(icon, is); + + for (int i : is) { + ret.icons.add(i + 6); + } + + return ret; + } + } + + public static class Model3D { + public double minX; + public double minY; + public double minZ; + public double maxX; + public double maxY; + public double maxZ; + + public IIcon[] textures = new IIcon[6]; + + public boolean[] renderSides + = new boolean[] { true, true, true, true, true, true, false }; + + public Block baseBlock = Blocks.sand; + + public final void setBlockBounds( + double xNeg, double yNeg, double zNeg, double xPos, double yPos, double zPos + ) { + minX = xNeg; + minY = yNeg; + minZ = zNeg; + maxX = xPos; + maxY = yPos; + maxZ = zPos; + } + + public void setSideRender(ForgeDirection side, boolean value) { + renderSides[side.ordinal()] = value; + } + + public boolean shouldSideRender(ForgeDirection side) { + return renderSides[side.ordinal()]; + } + + public IIcon getBlockTextureFromSide(int i) { + return textures[i]; + } + + public void setTexture(IIcon tex) { + Arrays.fill(textures, tex); + } + + public void setTextures( + IIcon down, IIcon up, IIcon north, IIcon south, IIcon west, IIcon east + ) { + textures[0] = down; + textures[1] = up; + textures[2] = north; + textures[3] = south; + textures[4] = west; + textures[5] = east; + } + } + + public static void renderObject(Model3D object) { + if (object == null) { + return; + } - public IIcon getBlockTextureFromSide(int i) - { - return textures[i]; - } - - public void setTexture(IIcon tex) - { - Arrays.fill(textures, tex); - } - - public void setTextures(IIcon down, IIcon up, IIcon north, IIcon south, IIcon west, IIcon east) - { - textures[0] = down; - textures[1] = up; - textures[2] = north; - textures[3] = south; - textures[4] = west; - textures[5] = east; - } - } - - public static void renderObject(Model3D object) - { - if(object == null) - { - return; - } - renderBlocks.renderMaxX = object.maxX; renderBlocks.renderMinX = object.minX; renderBlocks.renderMaxY = object.maxY; renderBlocks.renderMinY = object.minY; renderBlocks.renderMaxZ = object.maxZ; renderBlocks.renderMinZ = object.minZ; - + renderBlocks.enableAO = false; - Tessellator.instance.startDrawingQuads(); + Tessellator.instance.startDrawingQuads(); - if(object.shouldSideRender(ForgeDirection.DOWN)) - { - renderBlocks.renderFaceYNeg(null, 0, 0, 0, object.getBlockTextureFromSide(0)); - } + if (object.shouldSideRender(ForgeDirection.DOWN)) { + renderBlocks.renderFaceYNeg(null, 0, 0, 0, object.getBlockTextureFromSide(0)); + } - if(object.shouldSideRender(ForgeDirection.UP)) - { - renderBlocks.renderFaceYPos(null, 0, 0, 0, object.getBlockTextureFromSide(1)); - } + if (object.shouldSideRender(ForgeDirection.UP)) { + renderBlocks.renderFaceYPos(null, 0, 0, 0, object.getBlockTextureFromSide(1)); + } - if(object.shouldSideRender(ForgeDirection.NORTH)) - { - renderBlocks.renderFaceZNeg(null, 0, 0, 0, object.getBlockTextureFromSide(2)); - } + if (object.shouldSideRender(ForgeDirection.NORTH)) { + renderBlocks.renderFaceZNeg(null, 0, 0, 0, object.getBlockTextureFromSide(2)); + } - if(object.shouldSideRender(ForgeDirection.SOUTH)) - { - renderBlocks.renderFaceZPos(null, 0, 0, 0, object.getBlockTextureFromSide(3)); - } + if (object.shouldSideRender(ForgeDirection.SOUTH)) { + renderBlocks.renderFaceZPos(null, 0, 0, 0, object.getBlockTextureFromSide(3)); + } - if(object.shouldSideRender(ForgeDirection.WEST)) - { - renderBlocks.renderFaceXNeg(null, 0, 0, 0, object.getBlockTextureFromSide(4)); - } + if (object.shouldSideRender(ForgeDirection.WEST)) { + renderBlocks.renderFaceXNeg(null, 0, 0, 0, object.getBlockTextureFromSide(4)); + } - if(object.shouldSideRender(ForgeDirection.EAST)) - { - renderBlocks.renderFaceXPos(null, 0, 0, 0, object.getBlockTextureFromSide(5)); - } - - Tessellator.instance.draw(); - } - - public static void color(EnumColor color) - { - color(color, 1.0F); - } - - public static void color(EnumColor color, float alpha) - { - color(color, alpha, 1.0F); - } - - public static void color(EnumColor color, float alpha, float multiplier) - { - GL11.glColor4f(color.getColor(0)*multiplier, color.getColor(1)*multiplier, color.getColor(2)*multiplier, alpha); - } - - public static void resetColor() - { - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - } - - public static IIcon getColorIcon(EnumColor color) - { - return colors[color.ordinal()]; - } - - public static void glowOn() - { - glowOn(15); + if (object.shouldSideRender(ForgeDirection.EAST)) { + renderBlocks.renderFaceXPos(null, 0, 0, 0, object.getBlockTextureFromSide(5)); + } + + Tessellator.instance.draw(); } - - public static void glowOn(int glow) - { + + public static void color(EnumColor color) { + color(color, 1.0F); + } + + public static void color(EnumColor color, float alpha) { + color(color, alpha, 1.0F); + } + + public static void color(EnumColor color, float alpha, float multiplier) { + GL11.glColor4f( + color.getColor(0) * multiplier, + color.getColor(1) * multiplier, + color.getColor(2) * multiplier, + alpha + ); + } + + public static void resetColor() { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + } + + public static IIcon getColorIcon(EnumColor color) { + return colors[color.ordinal()]; + } + + public static void glowOn() { + glowOn(15); + } + + public static void glowOn(int glow) { GL11.glPushAttrib(GL11.GL_LIGHTING_BIT); - + try { - lightmapLastX = OpenGlHelper.lastBrightnessX; - lightmapLastY = OpenGlHelper.lastBrightnessY; - } catch(NoSuchFieldError e) { - optifineBreak = true; + lightmapLastX = OpenGlHelper.lastBrightnessX; + lightmapLastY = OpenGlHelper.lastBrightnessY; + } catch (NoSuchFieldError e) { + optifineBreak = true; } - + RenderHelper.disableStandardItemLighting(); - - float glowRatioX = Math.min((glow/15F)*240F + lightmapLastX, 240); - float glowRatioY = Math.min((glow/15F)*240F + lightmapLastY, 240); - - if(!optifineBreak) - { - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, glowRatioX, glowRatioY); + + float glowRatioX = Math.min((glow / 15F) * 240F + lightmapLastX, 240); + float glowRatioY = Math.min((glow / 15F) * 240F + lightmapLastY, 240); + + if (!optifineBreak) { + OpenGlHelper.setLightmapTextureCoords( + OpenGlHelper.lightmapTexUnit, glowRatioX, glowRatioY + ); } } - public static void glowOff() - { - if(!optifineBreak) - { - OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, lightmapLastX, lightmapLastY); - } - + public static void glowOff() { + if (!optifineBreak) { + OpenGlHelper.setLightmapTextureCoords( + OpenGlHelper.lightmapTexUnit, lightmapLastX, lightmapLastY + ); + } + GL11.glPopAttrib(); } - - public static void blendOn() - { - GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_LIGHTING_BIT); - GL11.glShadeModel(GL11.GL_SMOOTH); - GL11.glDisable(GL11.GL_ALPHA_TEST); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - } - - public static void blendOff() - { - GL11.glPopAttrib(); + + public static void blendOn() { + GL11.glPushAttrib(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_LIGHTING_BIT); + GL11.glShadeModel(GL11.GL_SMOOTH); + GL11.glDisable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); } - /** - * Blender .objs have a different handedness of coordinate system to MC, so faces are wound backwards. - */ - public static void cullFrontFace() - { - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glCullFace(GL11.GL_FRONT); - } + public static void blendOff() { + GL11.glPopAttrib(); + } - public static void disableCullFace() - { - GL11.glCullFace(GL11.GL_BACK); - GL11.glDisable(GL11.GL_CULL_FACE); - } - /** - * Cleaned-up snip of ItemRenderer.renderItem() -- meant to render 2D items as equipped. + * Blender .objs have a different handedness of coordinate system to MC, so faces are + * wound backwards. + */ + public static void cullFrontFace() { + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glCullFace(GL11.GL_FRONT); + } + + public static void disableCullFace() { + GL11.glCullFace(GL11.GL_BACK); + GL11.glDisable(GL11.GL_CULL_FACE); + } + + /** + * Cleaned-up snip of ItemRenderer.renderItem() -- meant to render 2D items as + * equipped. * @param item - ItemStack to render */ - public static void renderItem(ItemStack item) - { - IIcon icon = item.getItem().getIconIndex(item); - TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); + public static void renderItem(ItemStack item) { + IIcon icon = item.getItem().getIconIndex(item); + TextureManager texturemanager = Minecraft.getMinecraft().getTextureManager(); - if(icon == null) - { + if (icon == null) { GL11.glPopMatrix(); return; } - texturemanager.bindTexture(texturemanager.getResourceLocation(item.getItemSpriteNumber())); + texturemanager.bindTexture( + texturemanager.getResourceLocation(item.getItemSpriteNumber()) + ); Tessellator tessellator = Tessellator.instance; - + float minU = icon.getMinU(); float maxU = icon.getMaxU(); float minV = icon.getMinV(); float maxV = icon.getMaxV(); - + GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glTranslatef(0.0F, -0.3F, 0.0F); - + GL11.glScalef(1.5F, 1.5F, 1.5F); GL11.glRotatef(50.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(335.0F, 0.0F, 0.0F, 1.0F); GL11.glTranslatef(-0.9375F, -0.0625F, 0.0F); - - RenderManager.instance.itemRenderer.renderItemIn2D(tessellator, maxU, minV, minU, maxV, icon.getIconWidth(), icon.getIconHeight(), 0.0625F); + + RenderManager.instance.itemRenderer.renderItemIn2D( + tessellator, + maxU, + minV, + minU, + maxV, + icon.getIconWidth(), + icon.getIconHeight(), + 0.0625F + ); GL11.glDisable(GL12.GL_RESCALE_NORMAL); } - - public static void prepareItemRender(RenderBlocks renderer, int metadata, Block block) - { - if(!(block instanceof ISpecialBounds) || ((ISpecialBounds)block).doDefaultBoundSetting(metadata)) - { - block.setBlockBoundsForItemRender(); - } - - if(block instanceof ISpecialBounds) - { - ((ISpecialBounds)block).setRenderBounds(block, metadata); - } - - if(!(block instanceof ISpecialBounds) || ((ISpecialBounds)block).doDefaultBoundSetting(metadata)) - { - renderer.setRenderBoundsFromBlock(block); - } - else { - renderer.setRenderBounds(0, 0, 0, 1, 1, 1); - } - if(renderer.useInventoryTint) - { + public static void + prepareItemRender(RenderBlocks renderer, int metadata, Block block) { + if (!(block instanceof ISpecialBounds) + || ((ISpecialBounds) block).doDefaultBoundSetting(metadata)) { + block.setBlockBoundsForItemRender(); + } + + if (block instanceof ISpecialBounds) { + ((ISpecialBounds) block).setRenderBounds(block, metadata); + } + + if (!(block instanceof ISpecialBounds) + || ((ISpecialBounds) block).doDefaultBoundSetting(metadata)) { + renderer.setRenderBoundsFromBlock(block); + } else { + renderer.setRenderBounds(0, 0, 0, 1, 1, 1); + } + + if (renderer.useInventoryTint) { int renderColor = block.getRenderColor(metadata); float red = (renderColor >> 16 & 255) / 255.0F; float green = (renderColor >> 8 & 255) / 255.0F; @@ -526,194 +539,209 @@ public class MekanismRenderer GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); } - - public static void renderCustomItem(RenderBlocks renderer, ItemStack stack) - { - Block block = Block.getBlockFromItem(stack.getItem()); - - if(block instanceof ICustomBlockIcon) - { - ICustomBlockIcon custom = (ICustomBlockIcon)block; - prepareItemRender(renderer, stack.getItemDamage(), Block.getBlockFromItem(stack.getItem())); - + + public static void renderCustomItem(RenderBlocks renderer, ItemStack stack) { + Block block = Block.getBlockFromItem(stack.getItem()); + + if (block instanceof ICustomBlockIcon) { + ICustomBlockIcon custom = (ICustomBlockIcon) block; + prepareItemRender( + renderer, stack.getItemDamage(), Block.getBlockFromItem(stack.getItem()) + ); + try { - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); - tessellator.setNormal(0.0F, -1.0F, 0.0F); - renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, custom.getIcon(stack, 0)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(0.0F, 1.0F, 0.0F); - renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, custom.getIcon(stack, 1)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(0.0F, 0.0F, -1.0F); - renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, custom.getIcon(stack, 3)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(0.0F, 0.0F, 1.0F); - renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, custom.getIcon(stack, 2)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(-1.0F, 0.0F, 0.0F); - renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, custom.getIcon(stack, 4)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(1.0F, 0.0F, 0.0F); - renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, custom.getIcon(stack, 5)); - tessellator.draw(); - } catch(Exception e) {} - + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + renderer.renderFaceYNeg( + block, 0.0D, 0.0D, 0.0D, custom.getIcon(stack, 0) + ); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderer.renderFaceYPos( + block, 0.0D, 0.0D, 0.0D, custom.getIcon(stack, 1) + ); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + renderer.renderFaceZNeg( + block, 0.0D, 0.0D, 0.0D, custom.getIcon(stack, 3) + ); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + renderer.renderFaceZPos( + block, 0.0D, 0.0D, 0.0D, custom.getIcon(stack, 2) + ); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + renderer.renderFaceXNeg( + block, 0.0D, 0.0D, 0.0D, custom.getIcon(stack, 4) + ); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + renderer.renderFaceXPos( + block, 0.0D, 0.0D, 0.0D, custom.getIcon(stack, 5) + ); + tessellator.draw(); + } catch (Exception e) {} + GL11.glTranslatef(0.5F, 0.5F, 0.5F); - } + } } - - /** - * Cleaned-up snip of RenderBlocks.renderBlockAsItem() -- used for rendering an item as an entity, - * in a player's inventory, and in a player's hand. - * @param renderer - RenderBlocks renderer to render the item with - * @param metadata - block/item metadata - * @param block - block to render - */ - public static void renderItem(RenderBlocks renderer, int metadata, Block block) - { - prepareItemRender(renderer, metadata, block); - + + /** + * Cleaned-up snip of RenderBlocks.renderBlockAsItem() -- used for rendering an item + * as an entity, in a player's inventory, and in a player's hand. + * @param renderer - RenderBlocks renderer to render the item with + * @param metadata - block/item metadata + * @param block - block to render + */ + public static void renderItem(RenderBlocks renderer, int metadata, Block block) { + prepareItemRender(renderer, metadata, block); + try { - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); - tessellator.setNormal(0.0F, -1.0F, 0.0F); - renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, metadata)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(0.0F, 1.0F, 0.0F); - renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, metadata)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(0.0F, 0.0F, -1.0F); - renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, metadata)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(0.0F, 0.0F, 1.0F); - renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, metadata)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(-1.0F, 0.0F, 0.0F); - renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(4, metadata)); - tessellator.draw(); - tessellator.startDrawingQuads(); - tessellator.setNormal(1.0F, 0.0F, 0.0F); - renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, metadata)); - tessellator.draw(); - } catch(Exception e) {} - + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, -1.0F, 0.0F); + renderer.renderFaceYNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(0, metadata)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 1.0F, 0.0F); + renderer.renderFaceYPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(1, metadata)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, -1.0F); + renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(3, metadata)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(0.0F, 0.0F, 1.0F); + renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(2, metadata)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(-1.0F, 0.0F, 0.0F); + renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, block.getIcon(4, metadata)); + tessellator.draw(); + tessellator.startDrawingQuads(); + tessellator.setNormal(1.0F, 0.0F, 0.0F); + renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, block.getIcon(5, metadata)); + tessellator.draw(); + } catch (Exception e) {} + GL11.glTranslatef(0.5F, 0.5F, 0.5F); - } - - public static void colorFluid(Fluid fluid) - { - int color = fluid.getColor(); - - float cR = (color >> 16 & 0xFF) / 255.0F; - float cG = (color >> 8 & 0xFF) / 255.0F; - float cB = (color & 0xFF) / 255.0F; - - GL11.glColor3f(cR, cG, cB); - } - - public static class DisplayInteger - { - public int display; - - @Override - public int hashCode() - { - int code = 1; - code = 31 * code + display; - return code; - } - - @Override - public boolean equals(Object obj) - { - return obj instanceof DisplayInteger && ((DisplayInteger)obj).display == display; - } - - public static DisplayInteger createAndStart() - { - DisplayInteger newInteger = new DisplayInteger(); - newInteger.display = GLAllocation.generateDisplayLists(1); - GL11.glNewList(newInteger.display, GL11.GL_COMPILE); - return newInteger; - } - - public static void endList() - { - GL11.glEndList(); - } - - public void render() - { - GL11.glCallList(display); - } } - - public static TextureMap getTextureMap(int type) - { - try { - List l = (List)MekanismUtils.getPrivateValue(Minecraft.getMinecraft().renderEngine, TextureManager.class, ObfuscatedNames.TextureManager_listTickables); - - for(Object obj : l) - { - if(obj instanceof TextureMap) - { - if(((TextureMap)obj).getTextureType() == type) - { - return (TextureMap)obj; - } - } - } - } catch(Exception e) {} - - return null; + + public static void colorFluid(Fluid fluid) { + int color = fluid.getColor(); + + float cR = (color >> 16 & 0xFF) / 255.0F; + float cG = (color >> 8 & 0xFF) / 255.0F; + float cB = (color & 0xFF) / 255.0F; + + GL11.glColor3f(cR, cG, cB); } - - public static float getPartialTick() - { - try { - Timer t = (Timer)MekanismUtils.getPrivateValue(Minecraft.getMinecraft(), Minecraft.class, ObfuscatedNames.Minecraft_timer); - return t.renderPartialTicks; - } catch(Exception e) {} - - return 0; + + public static class DisplayInteger { + public int display; + + @Override + public int hashCode() { + int code = 1; + code = 31 * code + display; + return code; + } + + @Override + public boolean equals(Object obj) { + return obj instanceof DisplayInteger + && ((DisplayInteger) obj).display == display; + } + + public static DisplayInteger createAndStart() { + DisplayInteger newInteger = new DisplayInteger(); + newInteger.display = GLAllocation.generateDisplayLists(1); + GL11.glNewList(newInteger.display, GL11.GL_COMPILE); + return newInteger; + } + + public static void endList() { + GL11.glEndList(); + } + + public void render() { + GL11.glCallList(display); + } } - - public void drawTexturedModalRect(int par1, int par2, int par3, int par4, int par5, int par6) - { - int zLevel = 0; + + public static TextureMap getTextureMap(int type) { + try { + List l = (List) MekanismUtils.getPrivateValue( + Minecraft.getMinecraft().renderEngine, + TextureManager.class, + ObfuscatedNames.TextureManager_listTickables + ); + + for (Object obj : l) { + if (obj instanceof TextureMap) { + if (((TextureMap) obj).getTextureType() == type) { + return (TextureMap) obj; + } + } + } + } catch (Exception e) {} + + return null; + } + + public static float getPartialTick() { + try { + Timer t = (Timer) MekanismUtils.getPrivateValue( + Minecraft.getMinecraft(), Minecraft.class, ObfuscatedNames.Minecraft_timer + ); + return t.renderPartialTicks; + } catch (Exception e) {} + + return 0; + } + + public void + drawTexturedModalRect(int par1, int par2, int par3, int par4, int par5, int par6) { + int zLevel = 0; float f = 0.00390625F; float f1 = 0.00390625F; Tessellator tessellator = Tessellator.instance; tessellator.startDrawingQuads(); - tessellator.addVertexWithUV((par1 + 0), (par2 + par6), zLevel, ((par3 + 0) * f), ((par4 + par6) * f1)); - tessellator.addVertexWithUV((par1 + par5), (par2 + par6), zLevel, ((par3 + par5) * f), ((par4 + par6) * f1)); - tessellator.addVertexWithUV((par1 + par5), (par2 + 0), zLevel, ((par3 + par5) * f), ((par4 + 0) * f1)); - tessellator.addVertexWithUV((par1 + 0), (par2 + 0), zLevel, ((par3 + 0) * f), ((par4 + 0) * f1)); + tessellator.addVertexWithUV( + (par1 + 0), (par2 + par6), zLevel, ((par3 + 0) * f), ((par4 + par6) * f1) + ); + tessellator.addVertexWithUV( + (par1 + par5), + (par2 + par6), + zLevel, + ((par3 + par5) * f), + ((par4 + par6) * f1) + ); + tessellator.addVertexWithUV( + (par1 + par5), (par2 + 0), zLevel, ((par3 + par5) * f), ((par4 + 0) * f1) + ); + tessellator.addVertexWithUV( + (par1 + 0), (par2 + 0), zLevel, ((par3 + 0) * f), ((par4 + 0) * f1) + ); tessellator.draw(); } - - public static ResourceLocation getBlocksTexture() - { - return TextureMap.locationBlocksTexture; + + public static ResourceLocation getBlocksTexture() { + return TextureMap.locationBlocksTexture; } - - public static ResourceLocation getItemsTexture() - { - return TextureMap.locationItemsTexture; + + public static ResourceLocation getItemsTexture() { + return TextureMap.locationItemsTexture; } - - public static interface ICustomBlockIcon - { - public IIcon getIcon(ItemStack stack, int side); + + public static interface ICustomBlockIcon { + public IIcon getIcon(ItemStack stack, int side); } } diff --git a/src/main/java/mekanism/client/render/MinerVisualRenderer.java b/src/main/java/mekanism/client/render/MinerVisualRenderer.java index aeabc8a0a..5bc63ad42 100644 --- a/src/main/java/mekanism/client/render/MinerVisualRenderer.java +++ b/src/main/java/mekanism/client/render/MinerVisualRenderer.java @@ -13,131 +13,126 @@ import mekanism.common.tile.TileEntityDigitalMiner; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.init.Blocks; - import org.lwjgl.opengl.GL11; -public final class MinerVisualRenderer -{ - private static Minecraft mc = Minecraft.getMinecraft(); - - private static Map cachedVisuals = new HashMap(); - - private static final double offset = 0.01; - - public static void render(TileEntityDigitalMiner miner) - { - GL11.glPushMatrix(); - GL11.glTranslated(getX(miner.xCoord), getY(miner.yCoord), getZ(miner.zCoord)); - MekanismRenderer.blendOn(); - MekanismRenderer.glowOn(); - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.8F); - mc.getTextureManager().bindTexture(MekanismRenderer.getBlocksTexture()); - getList(new MinerRenderData(miner)).render(); - MekanismRenderer.glowOff(); - MekanismRenderer.blendOff(); - GL11.glPopMatrix(); - } - - private static DisplayInteger getList(MinerRenderData data) - { - if(cachedVisuals.containsKey(data)) - { - return cachedVisuals.get(data); - } - - DisplayInteger display = DisplayInteger.createAndStart(); - cachedVisuals.put(data, display); - - List models = new ArrayList(); - - for(int x = -data.radius; x <= data.radius; x++) - { - for(int y = data.minY-data.yCoord; y <= data.maxY-data.yCoord; y++) - { - for(int z = -data.radius; z <= data.radius; z++) - { - if(x == -data.radius || x == data.radius || y == data.minY-data.yCoord || y == data.maxY-data.yCoord || z == -data.radius || z == data.radius) - { - models.add(createModel(new Coord4D(x, y, z, mc.theWorld.provider.dimensionId))); - } - } - } - } - - for(Model3D model : models) - { - MekanismRenderer.renderObject(model); - } - - display.endList(); - - return display; - } - - private static Model3D createModel(Coord4D rel) - { - Model3D toReturn = new Model3D(); - - toReturn.setBlockBounds(rel.xCoord + 0.4, rel.yCoord + 0.4, rel.zCoord + 0.4, rel.xCoord + 0.6, rel.yCoord + 0.6, rel.zCoord + 0.6); - toReturn.baseBlock = Blocks.water; - toReturn.setTexture(MekanismRenderer.getColorIcon(EnumColor.WHITE)); - - return toReturn; - } - - private static double getX(int x) - { - return x - TileEntityRendererDispatcher.staticPlayerX; - } +public final class MinerVisualRenderer { + private static Minecraft mc = Minecraft.getMinecraft(); - private static double getY(int y) - { - return y - TileEntityRendererDispatcher.staticPlayerY; - } + private static Map cachedVisuals + = new HashMap(); - private static double getZ(int z) - { - return z - TileEntityRendererDispatcher.staticPlayerZ; - } - - public static class MinerRenderData - { - public int minY; - public int maxY; - public int radius; - public int yCoord; - - public MinerRenderData(int min, int max, int rad, int y) - { - minY = min; - maxY = max; - radius = rad; - yCoord = y; - } - - public MinerRenderData(TileEntityDigitalMiner miner) - { - this(miner.minY, miner.maxY, miner.radius, miner.yCoord); - } - - @Override - public boolean equals(Object data) - { - return data instanceof MinerRenderData && ((MinerRenderData)data).minY == minY && - ((MinerRenderData)data).maxY == maxY && ((MinerRenderData)data).radius == radius && - ((MinerRenderData)data).yCoord == yCoord; - } + private static final double offset = 0.01; - @Override - public int hashCode() - { - int code = 1; - code = 31 * code + minY; - code = 31 * code + maxY; - code = 31 * code + radius; - code = 31 * code + yCoord; - return code; - } - } + public static void render(TileEntityDigitalMiner miner) { + GL11.glPushMatrix(); + GL11.glTranslated(getX(miner.xCoord), getY(miner.yCoord), getZ(miner.zCoord)); + MekanismRenderer.blendOn(); + MekanismRenderer.glowOn(); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.8F); + mc.getTextureManager().bindTexture(MekanismRenderer.getBlocksTexture()); + getList(new MinerRenderData(miner)).render(); + MekanismRenderer.glowOff(); + MekanismRenderer.blendOff(); + GL11.glPopMatrix(); + } + + private static DisplayInteger getList(MinerRenderData data) { + if (cachedVisuals.containsKey(data)) { + return cachedVisuals.get(data); + } + + DisplayInteger display = DisplayInteger.createAndStart(); + cachedVisuals.put(data, display); + + List models = new ArrayList(); + + for (int x = -data.radius; x <= data.radius; x++) { + for (int y = data.minY - data.yCoord; y <= data.maxY - data.yCoord; y++) { + for (int z = -data.radius; z <= data.radius; z++) { + if (x == -data.radius || x == data.radius + || y == data.minY - data.yCoord || y == data.maxY - data.yCoord + || z == -data.radius || z == data.radius) { + models.add(createModel( + new Coord4D(x, y, z, mc.theWorld.provider.dimensionId) + )); + } + } + } + } + + for (Model3D model : models) { + MekanismRenderer.renderObject(model); + } + + display.endList(); + + return display; + } + + private static Model3D createModel(Coord4D rel) { + Model3D toReturn = new Model3D(); + + toReturn.setBlockBounds( + rel.xCoord + 0.4, + rel.yCoord + 0.4, + rel.zCoord + 0.4, + rel.xCoord + 0.6, + rel.yCoord + 0.6, + rel.zCoord + 0.6 + ); + toReturn.baseBlock = Blocks.water; + toReturn.setTexture(MekanismRenderer.getColorIcon(EnumColor.WHITE)); + + return toReturn; + } + + private static double getX(int x) { + return x - TileEntityRendererDispatcher.staticPlayerX; + } + + private static double getY(int y) { + return y - TileEntityRendererDispatcher.staticPlayerY; + } + + private static double getZ(int z) { + return z - TileEntityRendererDispatcher.staticPlayerZ; + } + + public static class MinerRenderData { + public int minY; + public int maxY; + public int radius; + public int yCoord; + + public MinerRenderData(int min, int max, int rad, int y) { + minY = min; + maxY = max; + radius = rad; + yCoord = y; + } + + public MinerRenderData(TileEntityDigitalMiner miner) { + this(miner.minY, miner.maxY, miner.radius, miner.yCoord); + } + + @Override + public boolean equals(Object data) { + return data instanceof MinerRenderData + && ((MinerRenderData) data).minY == minY + && ((MinerRenderData) data).maxY == maxY + && ((MinerRenderData) data).radius == radius + && ((MinerRenderData) data).yCoord == yCoord; + } + + @Override + public int hashCode() { + int code = 1; + code = 31 * code + minY; + code = 31 * code + maxY; + code = 31 * code + radius; + code = 31 * code + yCoord; + return code; + } + } } diff --git a/src/main/java/mekanism/client/render/ModelCustomArmor.java b/src/main/java/mekanism/client/render/ModelCustomArmor.java index 071937055..5ffc20daa 100644 --- a/src/main/java/mekanism/client/render/ModelCustomArmor.java +++ b/src/main/java/mekanism/client/render/ModelCustomArmor.java @@ -1,5 +1,7 @@ package mekanism.client.render; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.model.ModelArmoredJetpack; import mekanism.client.model.ModelFreeRunners; import mekanism.client.model.ModelGasMask; @@ -13,251 +15,222 @@ import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class ModelCustomArmor extends ModelBiped -{ - public static ModelCustomArmor INSTANCE = new ModelCustomArmor(); +public class ModelCustomArmor extends ModelBiped { + public static ModelCustomArmor INSTANCE = new ModelCustomArmor(); - public static GlowArmor GLOW_BIG = new GlowArmor(1.0F); - public static GlowArmor GLOW_SMALL = new GlowArmor(0.5F); + public static GlowArmor GLOW_BIG = new GlowArmor(1.0F); + public static GlowArmor GLOW_SMALL = new GlowArmor(0.5F); - public static Minecraft mc = Minecraft.getMinecraft(); + public static Minecraft mc = Minecraft.getMinecraft(); - public ArmorModel modelType; + public ArmorModel modelType; - public ModelCustomArmor() - { - resetPart(bipedHead, 0, 0, 0); - resetPart(bipedBody, 0, 0, 0); - resetPart(bipedRightArm, 5, 2, 0); - resetPart(bipedLeftArm, -5, 2, 0); - resetPart(bipedRightLeg, 0, 0, 0); - resetPart(bipedLeftLeg, 0, 0, 0); + public ModelCustomArmor() { + resetPart(bipedHead, 0, 0, 0); + resetPart(bipedBody, 0, 0, 0); + resetPart(bipedRightArm, 5, 2, 0); + resetPart(bipedLeftArm, -5, 2, 0); + resetPart(bipedRightLeg, 0, 0, 0); + resetPart(bipedLeftLeg, 0, 0, 0); - bipedHeadwear.cubeList.clear(); - bipedEars.cubeList.clear(); - bipedCloak.cubeList.clear(); - } + bipedHeadwear.cubeList.clear(); + bipedEars.cubeList.clear(); + bipedCloak.cubeList.clear(); + } - public void init(Entity entity, float f, float f1, float f2, float f3, float f4, float size) - { - reset(); + public void + init(Entity entity, float f, float f1, float f2, float f3, float f4, float size) { + reset(); - if(entity instanceof EntityLivingBase) - { - isSneak = ((EntityLivingBase)entity).isSneaking(); - isRiding = ((EntityLivingBase)entity).isRiding(); - isChild = ((EntityLivingBase)entity).isChild(); - } + if (entity instanceof EntityLivingBase) { + isSneak = ((EntityLivingBase) entity).isSneaking(); + isRiding = ((EntityLivingBase) entity).isRiding(); + isChild = ((EntityLivingBase) entity).isChild(); + } - if(modelType.armorSlot == 0) - { - bipedHead.isHidden = false; - bipedHead.showModel = true; - } - else if(modelType.armorSlot == 1) - { - bipedBody.isHidden = false; - bipedBody.showModel = true; - } - else if(modelType.armorSlot == 3) - { - bipedLeftLeg.isHidden = false; - bipedLeftLeg.showModel = true; - bipedRightLeg.isHidden = false; - bipedRightLeg.showModel = true; - } + if (modelType.armorSlot == 0) { + bipedHead.isHidden = false; + bipedHead.showModel = true; + } else if (modelType.armorSlot == 1) { + bipedBody.isHidden = false; + bipedBody.showModel = true; + } else if (modelType.armorSlot == 3) { + bipedLeftLeg.isHidden = false; + bipedLeftLeg.showModel = true; + bipedRightLeg.isHidden = false; + bipedRightLeg.showModel = true; + } - setRotationAngles(f, f1, f2, f3, f4, size, entity); - } + setRotationAngles(f, f1, f2, f3, f4, size, entity); + } - public void reset() - { - bipedHead.isHidden = true; - bipedBody.isHidden = true; - bipedRightArm.isHidden = true; - bipedLeftArm.isHidden = true; - bipedRightLeg.isHidden = true; - bipedLeftLeg.isHidden = true; + public void reset() { + bipedHead.isHidden = true; + bipedBody.isHidden = true; + bipedRightArm.isHidden = true; + bipedLeftArm.isHidden = true; + bipedRightLeg.isHidden = true; + bipedLeftLeg.isHidden = true; - bipedHead.showModel = false; - bipedBody.showModel = false; - bipedRightArm.showModel = false; - bipedLeftArm.showModel = false; - bipedRightLeg.showModel = false; - bipedLeftLeg.showModel = false; - } + bipedHead.showModel = false; + bipedBody.showModel = false; + bipedRightArm.showModel = false; + bipedLeftArm.showModel = false; + bipedRightLeg.showModel = false; + bipedLeftLeg.showModel = false; + } - public void resetPart(ModelRenderer renderer, float x, float y, float z) - { - renderer.cubeList.clear(); - ModelCustom model = new ModelCustom(this, renderer); - renderer.addChild(model); - setOffset(renderer, x, y, z); - } + public void resetPart(ModelRenderer renderer, float x, float y, float z) { + renderer.cubeList.clear(); + ModelCustom model = new ModelCustom(this, renderer); + renderer.addChild(model); + setOffset(renderer, x, y, z); + } - public void setOffset(ModelRenderer renderer, float x, float y, float z) - { - renderer.offsetX = x; - renderer.offsetY = y; - renderer.offsetZ = z; - } + public void setOffset(ModelRenderer renderer, float x, float y, float z) { + renderer.offsetX = x; + renderer.offsetY = y; + renderer.offsetZ = z; + } - public class ModelCustom extends ModelRenderer - { - public ModelCustomArmor biped; - public ModelRenderer partRender; + public class ModelCustom extends ModelRenderer { + public ModelCustomArmor biped; + public ModelRenderer partRender; - public ModelCustom(ModelCustomArmor base, ModelRenderer renderer) - { - super(base); - biped = base; - partRender = renderer; - } + public ModelCustom(ModelCustomArmor base, ModelRenderer renderer) { + super(base); + biped = base; + partRender = renderer; + } - @Override - public void render(float size) - { - if(ModelCustomArmor.this.modelType != null) - { - GL11.glPushMatrix(); - GL11.glTranslatef(0, 0, 0.06F); + @Override + public void render(float size) { + if (ModelCustomArmor.this.modelType != null) { + GL11.glPushMatrix(); + GL11.glTranslatef(0, 0, 0.06F); - mc.renderEngine.bindTexture(modelType.resource); + mc.renderEngine.bindTexture(modelType.resource); - if(useModel(biped.modelType, partRender, biped)) - { - if(biped.modelType == ArmorModel.JETPACK) - { - ArmorModel.jetpackModel.render(0.0625F); - } - else if(biped.modelType == ArmorModel.ARMOREDJETPACK) - { - ArmorModel.armoredJetpackModel.render(0.0625F); - } - else if(biped.modelType == ArmorModel.SCUBATANK) - { - ArmorModel.scubaTankModel.render(0.0625F); - } - else if(biped.modelType == ArmorModel.GASMASK) - { - GL11.glTranslatef(0, 0, -0.05F); - ArmorModel.gasMaskModel.render(0.0625F); - } - else if(biped.modelType == ArmorModel.FREERUNNERS) - { - GL11.glScalef(1.02F, 1.02F, 1.02F); + if (useModel(biped.modelType, partRender, biped)) { + if (biped.modelType == ArmorModel.JETPACK) { + ArmorModel.jetpackModel.render(0.0625F); + } else if (biped.modelType == ArmorModel.ARMOREDJETPACK) { + ArmorModel.armoredJetpackModel.render(0.0625F); + } else if (biped.modelType == ArmorModel.SCUBATANK) { + ArmorModel.scubaTankModel.render(0.0625F); + } else if (biped.modelType == ArmorModel.GASMASK) { + GL11.glTranslatef(0, 0, -0.05F); + ArmorModel.gasMaskModel.render(0.0625F); + } else if (biped.modelType == ArmorModel.FREERUNNERS) { + GL11.glScalef(1.02F, 1.02F, 1.02F); - if(partRender == biped.bipedLeftLeg) - { - GL11.glTranslatef(-0.1375F, -0.75F, -0.0625F); - ArmorModel.freeRunnersModel.renderLeft(0.0625F); - } - else if(partRender == biped.bipedRightLeg) - { - GL11.glTranslatef(0.1375F, -0.75F, -0.0625F); - ArmorModel.freeRunnersModel.renderRight(0.0625F); - } - } - } + if (partRender == biped.bipedLeftLeg) { + GL11.glTranslatef(-0.1375F, -0.75F, -0.0625F); + ArmorModel.freeRunnersModel.renderLeft(0.0625F); + } else if (partRender == biped.bipedRightLeg) { + GL11.glTranslatef(0.1375F, -0.75F, -0.0625F); + ArmorModel.freeRunnersModel.renderRight(0.0625F); + } + } + } - GL11.glPopMatrix(); - } - } - } + GL11.glPopMatrix(); + } + } + } - @Override - public void render(Entity entity, float par2, float par3, float par4, float par5, float par6, float par7) - { - init(entity, par2, par3, par4, par5, par6, par7); - super.render(entity, par2, par3, par4, par5, par6, par7); - } + @Override + public void render( + Entity entity, + float par2, + float par3, + float par4, + float par5, + float par6, + float par7 + ) { + init(entity, par2, par3, par4, par5, par6, par7); + super.render(entity, par2, par3, par4, par5, par6, par7); + } - public static boolean useModel(ArmorModel type, ModelRenderer partRender, ModelCustomArmor biped) - { - if(type.armorSlot == 0) - { - return partRender == biped.bipedHead; - } - else if(type.armorSlot == 1) - { - return partRender == biped.bipedBody; - } - else if(type.armorSlot == 3) - { - return partRender == biped.bipedLeftLeg || partRender == biped.bipedRightLeg; - } + public static boolean + useModel(ArmorModel type, ModelRenderer partRender, ModelCustomArmor biped) { + if (type.armorSlot == 0) { + return partRender == biped.bipedHead; + } else if (type.armorSlot == 1) { + return partRender == biped.bipedBody; + } else if (type.armorSlot == 3) { + return partRender == biped.bipedLeftLeg || partRender == biped.bipedRightLeg; + } - return false; - } + return false; + } - public static enum ArmorModel - { - JETPACK(1, MekanismUtils.getResource(ResourceType.RENDER, "Jetpack.png")), - ARMOREDJETPACK(1, MekanismUtils.getResource(ResourceType.RENDER, "Jetpack.png")), - SCUBATANK(1, MekanismUtils.getResource(ResourceType.RENDER, "ScubaSet.png")), - GASMASK(0, MekanismUtils.getResource(ResourceType.RENDER, "ScubaSet.png")), - FREERUNNERS(3, MekanismUtils.getResource(ResourceType.RENDER, "FreeRunners.png")); + public static enum ArmorModel { + JETPACK(1, MekanismUtils.getResource(ResourceType.RENDER, "Jetpack.png")), + ARMOREDJETPACK(1, MekanismUtils.getResource(ResourceType.RENDER, "Jetpack.png")), + SCUBATANK(1, MekanismUtils.getResource(ResourceType.RENDER, "ScubaSet.png")), + GASMASK(0, MekanismUtils.getResource(ResourceType.RENDER, "ScubaSet.png")), + FREERUNNERS(3, MekanismUtils.getResource(ResourceType.RENDER, "FreeRunners.png")); - public int armorSlot; - public ResourceLocation resource; + public int armorSlot; + public ResourceLocation resource; - public static ModelJetpack jetpackModel = new ModelJetpack(); - public static ModelArmoredJetpack armoredJetpackModel = new ModelArmoredJetpack(); - public static ModelGasMask gasMaskModel = new ModelGasMask(); - public static ModelScubaTank scubaTankModel = new ModelScubaTank(); - public static ModelFreeRunners freeRunnersModel = new ModelFreeRunners(); + public static ModelJetpack jetpackModel = new ModelJetpack(); + public static ModelArmoredJetpack armoredJetpackModel = new ModelArmoredJetpack(); + public static ModelGasMask gasMaskModel = new ModelGasMask(); + public static ModelScubaTank scubaTankModel = new ModelScubaTank(); + public static ModelFreeRunners freeRunnersModel = new ModelFreeRunners(); - private ArmorModel(int i, ResourceLocation r) - { - armorSlot = i; - resource = r; - } - } + private ArmorModel(int i, ResourceLocation r) { + armorSlot = i; + resource = r; + } + } - public static ModelBiped getGlow(int index) - { - ModelBiped biped = index != 2 ? GLOW_BIG : GLOW_SMALL; + public static ModelBiped getGlow(int index) { + ModelBiped biped = index != 2 ? GLOW_BIG : GLOW_SMALL; - biped.bipedHead.showModel = index == 0; - biped.bipedHeadwear.showModel = index == 0; - biped.bipedBody.showModel = index == 1 || index == 2; - biped.bipedRightArm.showModel = index == 1; - biped.bipedLeftArm.showModel = index == 1; - biped.bipedRightLeg.showModel = index == 2 || index == 3; - biped.bipedLeftLeg.showModel = index == 2 || index == 3; + biped.bipedHead.showModel = index == 0; + biped.bipedHeadwear.showModel = index == 0; + biped.bipedBody.showModel = index == 1 || index == 2; + biped.bipedRightArm.showModel = index == 1; + biped.bipedLeftArm.showModel = index == 1; + biped.bipedRightLeg.showModel = index == 2 || index == 3; + biped.bipedLeftLeg.showModel = index == 2 || index == 3; - return biped; - } + return biped; + } - public static class GlowArmor extends ModelBiped - { - public GlowArmor(float size) - { - super(size); - } + public static class GlowArmor extends ModelBiped { + public GlowArmor(float size) { + super(size); + } - @Override - public void render(Entity entity, float par2, float par3, float par4, float par5, float par6, float par7) - { - if(entity instanceof EntityLivingBase) - { - isSneak = ((EntityLivingBase)entity).isSneaking(); - isRiding = ((EntityLivingBase)entity).isRiding(); - isChild = ((EntityLivingBase)entity).isChild(); - } + @Override + public void render( + Entity entity, + float par2, + float par3, + float par4, + float par5, + float par6, + float par7 + ) { + if (entity instanceof EntityLivingBase) { + isSneak = ((EntityLivingBase) entity).isSneaking(); + isRiding = ((EntityLivingBase) entity).isRiding(); + isChild = ((EntityLivingBase) entity).isChild(); + } - setRotationAngles(par2, par3, par4, par5, par6, par7, entity); + setRotationAngles(par2, par3, par4, par5, par6, par7, entity); - MekanismRenderer.glowOn(); - super.render(entity, par2, par3, par4, par5, par6, par7); - MekanismRenderer.glowOff(); - } - } + MekanismRenderer.glowOn(); + super.render(entity, par2, par3, par4, par5, par6, par7); + MekanismRenderer.glowOff(); + } + } } diff --git a/src/main/java/mekanism/client/render/RenderGlowPanel.java b/src/main/java/mekanism/client/render/RenderGlowPanel.java index b88fc6f60..588c7c539 100644 --- a/src/main/java/mekanism/client/render/RenderGlowPanel.java +++ b/src/main/java/mekanism/client/render/RenderGlowPanel.java @@ -2,12 +2,6 @@ package mekanism.client.render; import java.util.Map; -import mekanism.api.EnumColor; -import mekanism.common.multipart.PartGlowPanel; -import mekanism.common.util.MekanismUtils; -import mekanism.common.util.MekanismUtils.ResourceType; -import net.minecraft.client.renderer.texture.IIconRegister; -import net.minecraft.util.IIcon; import codechicken.lib.colour.Colour; import codechicken.lib.colour.ColourRGBA; import codechicken.lib.lighting.LightModel; @@ -19,83 +13,103 @@ import codechicken.lib.render.TextureUtils.IIconSelfRegister; import codechicken.lib.render.uv.IconTransformation; import codechicken.lib.vec.Translation; import codechicken.lib.vec.Vector3; +import mekanism.api.EnumColor; +import mekanism.common.multipart.PartGlowPanel; +import mekanism.common.util.MekanismUtils; +import mekanism.common.util.MekanismUtils.ResourceType; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.util.IIcon; -public class RenderGlowPanel implements IIconSelfRegister -{ - public static RenderGlowPanel INSTANCE; +public class RenderGlowPanel implements IIconSelfRegister { + public static RenderGlowPanel INSTANCE; - public static CCModel[] frameModels; - public static CCModel[] lightModels; + public static CCModel[] frameModels; + public static CCModel[] lightModels; - public static IIcon icon; + public static IIcon icon; - public static RenderGlowPanel getInstance() - { - return INSTANCE; - } + public static RenderGlowPanel getInstance() { + return INSTANCE; + } - public static void init() - { - INSTANCE = new RenderGlowPanel(); - TextureUtils.addIconRegistrar(INSTANCE); + public static void init() { + INSTANCE = new RenderGlowPanel(); + TextureUtils.addIconRegistrar(INSTANCE); - Map models = CCModel.parseObjModels(MekanismUtils.getResource(ResourceType.MODEL, "glow_panel.obj"), 7, null); + Map models = CCModel.parseObjModels( + MekanismUtils.getResource(ResourceType.MODEL, "glow_panel.obj"), 7, null + ); - frameModels = new CCModel[6]; - frameModels[0] = models.get("frame").backfacedCopy().apply(Vector3.center.translation()).shrinkUVs(0.0005); - CCModel.generateSidedModels(frameModels, 0, Vector3.center); + frameModels = new CCModel[6]; + frameModels[0] = models.get("frame") + .backfacedCopy() + .apply(Vector3.center.translation()) + .shrinkUVs(0.0005); + CCModel.generateSidedModels(frameModels, 0, Vector3.center); - lightModels = new CCModel[6]; - lightModels[0] = models.get("light").backfacedCopy().apply(Vector3.center.translation()).shrinkUVs(0.0005); - CCModel.generateSidedModels(lightModels, 0, Vector3.center); + lightModels = new CCModel[6]; + lightModels[0] = models.get("light") + .backfacedCopy() + .apply(Vector3.center.translation()) + .shrinkUVs(0.0005); + CCModel.generateSidedModels(lightModels, 0, Vector3.center); - for(CCModel c : frameModels) - { - c.computeLighting(LightModel.standardLightModel); - } - } + for (CCModel c : frameModels) { + c.computeLighting(LightModel.standardLightModel); + } + } - public void renderStatic(PartGlowPanel panel) - { - CCRenderState.reset(); - CCRenderState.setBrightness(panel.world(), panel.x(), panel.y(), panel.z()); + public void renderStatic(PartGlowPanel panel) { + CCRenderState.reset(); + CCRenderState.setBrightness(panel.world(), panel.x(), panel.y(), panel.z()); - Colour colour = new ColourRGBA(panel.colour.getColor(0), panel.colour.getColor(1), panel.colour.getColor(2), 1); - int side = panel.side.ordinal(); - - frameModels[side].render(new Translation(panel.x(), panel.y(), panel.z()), new IconTransformation(icon)); - lightModels[side].render(new Translation(panel.x(), panel.y(), panel.z()), new IconTransformation(icon), new ColourMultiplier(colour.rgba())); - } + Colour colour = new ColourRGBA( + panel.colour.getColor(0), + panel.colour.getColor(1), + panel.colour.getColor(2), + 1 + ); + int side = panel.side.ordinal(); - public void renderItem(int metadata) - { - TextureUtils.bindAtlas(0); - CCRenderState.reset(); - CCRenderState.startDrawing(); - CCRenderState.hasColour = true; - EnumColor c = EnumColor.DYES[metadata]; + frameModels[side].render( + new Translation(panel.x(), panel.y(), panel.z()), new IconTransformation(icon) + ); + lightModels[side].render( + new Translation(panel.x(), panel.y(), panel.z()), + new IconTransformation(icon), + new ColourMultiplier(colour.rgba()) + ); + } - Colour colour = new ColourRGBA(c.getColor(0), c.getColor(1), c.getColor(2), 1); - Colour white = new ColourRGBA(1.0, 1.0, 1.0, 1.0); - - for(int i = 4; i < 5; i++) - { - frameModels[i].render(new IconTransformation(icon), new ColourMultiplier(white.rgba())); - lightModels[i].render(new IconTransformation(icon), new ColourMultiplier(colour.rgba())); - } - - CCRenderState.draw(); - } + public void renderItem(int metadata) { + TextureUtils.bindAtlas(0); + CCRenderState.reset(); + CCRenderState.startDrawing(); + CCRenderState.hasColour = true; + EnumColor c = EnumColor.DYES[metadata]; - @Override - public void registerIcons(IIconRegister register) - { - icon = register.registerIcon("mekanism:models/GlowPanel"); - } + Colour colour = new ColourRGBA(c.getColor(0), c.getColor(1), c.getColor(2), 1); + Colour white = new ColourRGBA(1.0, 1.0, 1.0, 1.0); - @Override - public int atlasIndex() - { - return 0; - } + for (int i = 4; i < 5; i++) { + frameModels[i].render( + new IconTransformation(icon), new ColourMultiplier(white.rgba()) + ); + lightModels[i].render( + new IconTransformation(icon), new ColourMultiplier(colour.rgba()) + ); + } + + CCRenderState.draw(); + } + + @Override + public void registerIcons(IIconRegister register) { + icon = register.registerIcon("mekanism:models/GlowPanel"); + } + + @Override + public int atlasIndex() { + return 0; + } } diff --git a/src/main/java/mekanism/client/render/RenderPartTransmitter.java b/src/main/java/mekanism/client/render/RenderPartTransmitter.java index b88ed0a98..059bb462e 100644 --- a/src/main/java/mekanism/client/render/RenderPartTransmitter.java +++ b/src/main/java/mekanism/client/render/RenderPartTransmitter.java @@ -3,6 +3,20 @@ package mekanism.client.render; import java.util.HashMap; import java.util.Map; +import codechicken.lib.colour.Colour; +import codechicken.lib.colour.ColourRGBA; +import codechicken.lib.lighting.LightModel; +import codechicken.lib.lighting.LightModel.Light; +import codechicken.lib.render.CCModel; +import codechicken.lib.render.CCRenderState; +import codechicken.lib.render.ColourMultiplier; +import codechicken.lib.render.TextureUtils; +import codechicken.lib.render.TextureUtils.IIconSelfRegister; +import codechicken.lib.render.uv.IconTransformation; +import codechicken.lib.vec.Translation; +import codechicken.lib.vec.Vector3; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.client.model.ModelTransporterBox; @@ -39,781 +53,772 @@ import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; - import org.lwjgl.opengl.GL11; -import codechicken.lib.colour.Colour; -import codechicken.lib.colour.ColourRGBA; -import codechicken.lib.lighting.LightModel; -import codechicken.lib.lighting.LightModel.Light; -import codechicken.lib.render.CCModel; -import codechicken.lib.render.CCRenderState; -import codechicken.lib.render.ColourMultiplier; -import codechicken.lib.render.TextureUtils; -import codechicken.lib.render.TextureUtils.IIconSelfRegister; -import codechicken.lib.render.uv.IconTransformation; -import codechicken.lib.vec.Translation; -import codechicken.lib.vec.Vector3; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class RenderPartTransmitter implements IIconSelfRegister -{ - public static RenderPartTransmitter INSTANCE; - - public static Map small_models; - public static Map large_models; - public static Map contents_models; - - private static final int stages = 100; - private static final double height = 0.45; - private static final double offset = 0.015; - - private ModelTransporterBox modelBox = new ModelTransporterBox(); - - private HashMap> cachedLiquids = new HashMap>(); - private HashMap> cachedOverlays = new HashMap>(); - - private Minecraft mc = Minecraft.getMinecraft(); - - private EntityItem entityItem = new EntityItem(null); - private RenderItem renderer = (RenderItem)RenderManager.instance.getEntityClassRenderObject(EntityItem.class); - - public static RenderPartTransmitter getInstance() - { - return INSTANCE; - } - - public static void init() - { - INSTANCE = new RenderPartTransmitter(); - TextureUtils.addIconRegistrar(INSTANCE); - - small_models = CCModel.parseObjModels(MekanismUtils.getResource(ResourceType.MODEL, "transmitter_small.obj"), 7, null); - - for(Map.Entry e : small_models.entrySet()) - { - e.setValue(e.getValue().computeLighting(LightModel.standardLightModel).twoFacedCopy().apply(new Translation(Vector3.center)).shrinkUVs(0.0005)); - } - - large_models = CCModel.parseObjModels(MekanismUtils.getResource(ResourceType.MODEL, "transmitter_large.obj"), 7, null); - - for(Map.Entry e : large_models.entrySet()) - { - e.setValue(e.getValue().computeLighting(LightModel.standardLightModel).twoFacedCopy().apply(new Translation(Vector3.center)).shrinkUVs(0.0005)); - } - - contents_models = CCModel.parseObjModels(MekanismUtils.getResource(ResourceType.MODEL, "transmitter_contents.obj"), 7, null); - LightModel interiorLightModel = new LightModel() - .setAmbient(new Vector3(0.6, 0.6, 0.6)) - .addLight(new Light(new Vector3(0.3, 1, -0.7)) - .setDiffuse(new Vector3(0.6, 0.6, 0.6))) - .addLight(new Light(new Vector3(-0.3, 1, 0.7)) - .setDiffuse(new Vector3(0.6, 0.6, 0.6))); - - for(CCModel c : contents_models.values()) - { - c.apply(new Translation(Vector3.center)); - c.computeLighting(interiorLightModel); - c.shrinkUVs(0.0005); - } - } - - private void push() - { - GL11.glPushMatrix(); - GL11.glPushAttrib(GL11.GL_ENABLE_BIT); - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glEnable(GL11.GL_BLEND); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - } - - private void pop() - { - GL11.glPopAttrib(); - GL11.glPopMatrix(); - } - - public void renderItem(TransmitterType type) - { - CCRenderState.reset(); - CCRenderState.startDrawing(); - - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - renderSide(side, type, false); - } - - CCRenderState.draw(); - - CCRenderState.reset(); - CCRenderState.startDrawing(); - - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - renderSide(side, type, true); - } - - CCRenderState.draw(); - } - - public void renderContents(PartLogisticalTransporter transporter, float partialTick, Vector3 vec) - { - GL11.glPushMatrix(); - - entityItem.age = 0; - entityItem.hoverStart = 0; - - entityItem.setPosition(transporter.x() + 0.5, transporter.y() + 0.5, transporter.z() + 0.5); - entityItem.worldObj = transporter.world(); - - for(TransporterStack stack : transporter.getTransmitter().transit) - { - if(stack != null) - { - GL11.glPushMatrix(); - entityItem.setEntityItemStack(stack.itemStack); - - float[] pos = TransporterUtils.getStackPosition(transporter.getTransmitter(), stack, partialTick*transporter.tier.speed); - - GL11.glTranslated(vec.x + pos[0], vec.y + pos[1] - entityItem.yOffset, vec.z + pos[2]); - GL11.glScalef(0.75F, 0.75F, 0.75F); - - renderer.doRender(entityItem, 0, 0, 0, 0, 0); - GL11.glPopMatrix(); - - if(stack.color != null) - { - CCRenderState.changeTexture(MekanismUtils.getResource(ResourceType.RENDER, "TransporterBox.png")); - GL11.glPushMatrix(); - MekanismRenderer.glowOn(); - GL11.glDisable(GL11.GL_CULL_FACE); - GL11.glColor4f(stack.color.getColor(0), stack.color.getColor(1), stack.color.getColor(2), 1.0F); - GL11.glTranslatef((float)(vec.x + pos[0]), (float)(vec.y + pos[1] - entityItem.yOffset - ((stack.itemStack.getItem() instanceof ItemBlock) ? 0.1 : 0)), (float)(vec.z + pos[2])); - modelBox.render(0.0625F); - MekanismRenderer.glowOff(); - GL11.glPopMatrix(); - } - } - } - - if(transporter instanceof PartDiversionTransporter) - { - EntityPlayer player = mc.thePlayer; - World world = mc.thePlayer.worldObj; - ItemStack itemStack = player.getCurrentEquippedItem(); - MovingObjectPosition pos = player.rayTrace(8.0D, 1.0F); - - if(pos != null && itemStack != null && itemStack.getItem() instanceof ItemConfigurator) - { - int xPos = MathHelper.floor_double(pos.blockX); - int yPos = MathHelper.floor_double(pos.blockY); - int zPos = MathHelper.floor_double(pos.blockZ); - - Coord4D obj = new Coord4D(xPos, yPos, zPos, transporter.world().provider.dimensionId); - - if(obj.equals(Coord4D.get(transporter.tile()))) - { - int mode = ((PartDiversionTransporter)transporter).modes[pos.sideHit]; - ForgeDirection side = ForgeDirection.getOrientation(pos.sideHit); - - pushTransporter(); - - GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.8F); - - CCRenderState.changeTexture(mode == 0 ? MekanismRenderer.getItemsTexture() : MekanismRenderer.getBlocksTexture()); - GL11.glTranslatef((float)vec.x, (float)vec.y, (float)vec.z); - GL11.glScalef(0.5F, 0.5F, 0.5F); - GL11.glTranslatef(0.5F, 0.5F, 0.5F); - - int display = getOverlayDisplay(world, side, mode).display; - GL11.glCallList(display); - - popTransporter(); - } - } - } - - GL11.glPopMatrix(); - } - - public void renderContents(PartUniversalCable cable, Vector3 pos) - { - if(cable.currentPower == 0) - { - return; - } - - push(); - CCRenderState.reset(); - CCRenderState.useNormals = true; - CCRenderState.startDrawing(); - GL11.glTranslated(pos.x, pos.y, pos.z); - - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - renderEnergySide(side, cable); - } - - MekanismRenderer.glowOn(); - MekanismRenderer.cullFrontFace(); - - CCRenderState.draw(); - - MekanismRenderer.disableCullFace(); - MekanismRenderer.glowOff(); - - pop(); - } - - public void renderContents(PartThermodynamicConductor transmitter, Vector3 pos) - { - push(); - CCRenderState.reset(); - CCRenderState.useNormals = true; - CCRenderState.startDrawing(); - GL11.glTranslated(pos.x, pos.y, pos.z); - - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - renderHeatSide(side, transmitter); - } - - MekanismRenderer.glowOn(); - MekanismRenderer.cullFrontFace(); - - CCRenderState.draw(); - - MekanismRenderer.disableCullFace(); - MekanismRenderer.glowOff(); - - pop(); - } - - public void renderContents(PartMechanicalPipe pipe, Vector3 pos) - { - float targetScale; - - if(pipe.getTransmitter().hasTransmitterNetwork()) - { - targetScale = pipe.getTransmitter().getTransmitterNetwork().fluidScale; - } - else { - targetScale = (float)pipe.buffer.getFluidAmount() / (float)pipe.buffer.getCapacity(); - } - - if(Math.abs(pipe.currentScale - targetScale) > 0.01) - { - pipe.currentScale = (12 * pipe.currentScale + targetScale) / 13; - } - else { - pipe.currentScale = targetScale; - } - - Fluid fluid; - - if(pipe.getTransmitter().hasTransmitterNetwork()) - { - fluid = pipe.getTransmitter().getTransmitterNetwork().refFluid; - } - else { - fluid = pipe.getBuffer() == null ? null : pipe.getBuffer().getFluid(); - } - - float scale = pipe.currentScale; - - if(scale > 0.01 && fluid != null) - { - push(); - - MekanismRenderer.glowOn(fluid.getLuminosity()); - MekanismRenderer.colorFluid(fluid); - - CCRenderState.changeTexture(MekanismRenderer.getBlocksTexture()); - GL11.glTranslated(pos.x, pos.y, pos.z); - - boolean gas = fluid.isGaseous(); - - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - if(pipe.getConnectionType(side) == ConnectionType.NORMAL) - { - DisplayInteger[] displayLists = getListAndRender(side, fluid); - - if(displayLists != null) - { - if(!gas) - { - displayLists[Math.max(3, (int)((float)scale*(stages-1)))].render(); - } - else { - GL11.glColor4f(1F, 1F, 1F, scale); - displayLists[stages-1].render(); - } - } - } - else if(pipe.getConnectionType(side) != ConnectionType.NONE) - { - GL11.glCullFace(GL11.GL_FRONT); - CCRenderState.startDrawing(); - renderFluidInOut(side, pipe); - CCRenderState.draw(); - GL11.glCullFace(GL11.GL_BACK); - } - } - - DisplayInteger[] displayLists = getListAndRender(ForgeDirection.UNKNOWN, fluid); - - if(displayLists != null) - { - if(!gas) - { - displayLists[Math.max(3, (int)((float)scale*(stages-1)))].render(); - } - else { - GL11.glColor4f(1F, 1F, 1F, scale); - displayLists[stages-1].render(); - } - } - - MekanismRenderer.glowOff(); - MekanismRenderer.resetColor(); - - pop(); - } - } - - private DisplayInteger[] getListAndRender(ForgeDirection side, Fluid fluid) - { - if(side == null || fluid == null || fluid.getIcon() == null) - { - return null; - } - - if(cachedLiquids.containsKey(side) && cachedLiquids.get(side).containsKey(fluid)) - { - return cachedLiquids.get(side).get(fluid); - } - - Model3D toReturn = new Model3D(); - toReturn.baseBlock = Blocks.water; - toReturn.setTexture(fluid.getIcon()); - - toReturn.setSideRender(side, false); - toReturn.setSideRender(side.getOpposite(), false); - - DisplayInteger[] displays = new DisplayInteger[stages]; - - if(cachedLiquids.containsKey(side)) - { - cachedLiquids.get(side).put(fluid, displays); - } - else { - HashMap map = new HashMap(); - map.put(fluid, displays); - cachedLiquids.put(side, map); - } - - for(int i = 0; i < stages; i++) - { - displays[i] = DisplayInteger.createAndStart(); - - switch(side) - { - case UNKNOWN: - { - toReturn.minX = 0.25 + offset; - toReturn.minY = 0.25 + offset; - toReturn.minZ = 0.25 + offset; - - toReturn.maxX = 0.75 - offset; - toReturn.maxY = 0.25 + offset + ((float)i / (float)stages)*height; - toReturn.maxZ = 0.75 - offset; - break; - } - case DOWN: - { - toReturn.minX = 0.5 - (((float)i / (float)stages)*height)/2; - toReturn.minY = 0.0; - toReturn.minZ = 0.5 - (((float)i / (float)stages)*height)/2; - - toReturn.maxX = 0.5 + (((float)i / (float)stages)*height)/2; - toReturn.maxY = 0.25 + offset; - toReturn.maxZ = 0.5 + (((float)i / (float)stages)*height)/2; - break; - } - case UP: - { - toReturn.minX = 0.5 - (((float)i / (float)stages)*height)/2; - toReturn.minY = 0.25 - offset + ((float)i / (float)stages)*height; - toReturn.minZ = 0.5 - (((float)i / (float)stages)*height)/2; - - toReturn.maxX = 0.5 + (((float)i / (float)stages)*height)/2; - toReturn.maxY = 1.0; - toReturn.maxZ = 0.5 + (((float)i / (float)stages)*height)/2; - break; - } - case NORTH: - { - toReturn.minX = 0.25 + offset; - toReturn.minY = 0.25 + offset; - toReturn.minZ = 0.0; - - toReturn.maxX = 0.75 - offset; - toReturn.maxY = 0.25 + offset + ((float)i / (float)stages)*height; - toReturn.maxZ = 0.25 + offset; - break; - } - case SOUTH: - { - toReturn.minX = 0.25 + offset; - toReturn.minY = 0.25 + offset; - toReturn.minZ = 0.75 - offset; - - toReturn.maxX = 0.75 - offset; - toReturn.maxY = 0.25 + offset + ((float)i / (float)stages)*height; - toReturn.maxZ = 1.0; - break; - } - case WEST: - { - toReturn.minX = 0.0; - toReturn.minY = 0.25 + offset; - toReturn.minZ = 0.25 + offset; - - toReturn.maxX = 0.25 + offset; - toReturn.maxY = 0.25 + offset + ((float)i / (float)stages)*height; - toReturn.maxZ = 0.75 - offset; - break; - } - case EAST: - { - toReturn.minX = 0.75 - offset; - toReturn.minY = 0.25 + offset; - toReturn.minZ = 0.25 + offset; - - toReturn.maxX = 1.0; - toReturn.maxY = 0.25 + offset + ((float)i / (float)stages)*height; - toReturn.maxZ = 0.75 - offset; - break; - } - } - - MekanismRenderer.renderObject(toReturn); - displays[i].endList(); - } - - return displays; - } - - public void renderContents(PartPressurizedTube tube, Vector3 pos) - { - if(!tube.getTransmitter().hasTransmitterNetwork() || tube.getTransmitter().getTransmitterNetwork().refGas == null || tube.getTransmitter().getTransmitterNetwork().gasScale == 0) - { - return; - } - - push(); - - CCRenderState.reset(); - CCRenderState.useNormals = true; - CCRenderState.startDrawing(); - GL11.glTranslated(pos.x, pos.y, pos.z); - - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - renderGasSide(side, tube); - } - - MekanismRenderer.glowOn(0); - MekanismRenderer.cullFrontFace(); - - CCRenderState.draw(); - - MekanismRenderer.disableCullFace(); - MekanismRenderer.glowOff(); - - pop(); - } - - public void renderStatic(PartSidedPipe transmitter, int pass) - { - CCRenderState.reset(); - CCRenderState.hasColour = true; - CCRenderState.setBrightness(transmitter.world(), transmitter.x(), transmitter.y(), transmitter.z()); - - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - renderSide(side, transmitter, pass); - } - } - - public void renderSide(ForgeDirection side, PartSidedPipe transmitter, int pass) - { - if(pass == 1) - { - if(transmitter.transparencyRender()) - { - IIcon renderIcon = transmitter.getIconForSide(side, false); - EnumColor color = transmitter.getRenderColor(false); - - Colour c = null; - - if(color != null) - { - c = new ColourRGBA(color.getColor(0), color.getColor(1), color.getColor(2), 1); - } - - renderPart(renderIcon, transmitter.getModelForSide(side, false), transmitter.x(), transmitter.y(), transmitter.z(), c); - } - } - else { - IIcon renderIcon = transmitter.getIconForSide(side, true); - EnumColor color = transmitter.getRenderColor(true); - - Colour c = null; - - if(color != null) - { - c = new ColourRGBA(color.getColor(0), color.getColor(1), color.getColor(2), 1); - } - - renderPart(renderIcon, transmitter.getModelForSide(side, false), transmitter.x(), transmitter.y(), transmitter.z(), c); - } - } - - public void renderSide(ForgeDirection side, TransmitterType type, boolean opaque) - { - boolean out = side == ForgeDirection.UP || side == ForgeDirection.DOWN; - - IIcon renderIcon = out ? type.getSideIcon(opaque) : type.getCenterIcon(opaque); - - renderPart(renderIcon, getItemModel(side, type), 0, 0, 0, null); - } - - public void renderEnergySide(ForgeDirection side, PartUniversalCable cable) - { - CCRenderState.changeTexture(MekanismRenderer.getBlocksTexture()); - renderTransparency(MekanismRenderer.energyIcon, cable.getModelForSide(side, true), new ColourRGBA(1.0, 1.0, 1.0, cable.currentPower)); - } - - public void renderHeatSide(ForgeDirection side, PartThermodynamicConductor cable) - { - CCRenderState.changeTexture(MekanismRenderer.getBlocksTexture()); - renderTransparency(MekanismRenderer.heatIcon, cable.getModelForSide(side, true), ColourTemperature.fromTemperature(cable.temperature, cable.getBaseColour())); - } - - public void renderFluidInOut(ForgeDirection side, PartMechanicalPipe pipe) - { - CCRenderState.changeTexture(MekanismRenderer.getBlocksTexture()); - renderTransparency(pipe.getTransmitter().getTransmitterNetwork().refFluid.getIcon(), pipe.getModelForSide(side, true), new ColourRGBA(1.0, 1.0, 1.0, pipe.currentScale)); - } - - public void renderGasSide(ForgeDirection side, PartPressurizedTube tube) - { - CCRenderState.changeTexture(MekanismRenderer.getBlocksTexture()); - renderTransparency(tube.getTransmitter().getTransmitterNetwork().refGas.getIcon(), tube.getModelForSide(side, true), new ColourRGBA(1.0, 1.0, 1.0, tube.currentScale)); - } - - public void renderPart(IIcon icon, CCModel cc, double x, double y, double z, Colour color) - { - if(color != null) - { - cc.render(new Translation(x, y, z), new IconTransformation(icon), new ColourMultiplier(color.rgba())); - } - else { - cc.render(new Translation(x, y, z), new IconTransformation(icon)); - } - } - - public void renderTransparency(IIcon icon, CCModel cc, Colour color) - { - if(icon == null) - { - return; - } - - if(color != null) - { - cc.render(new IconTransformation(icon), new ColourMultiplier(color.rgba())); - } - else { - cc.render(new IconTransformation(icon)); - } - } - - public CCModel getItemModel(ForgeDirection side, TransmitterType type) - { - String name = side.name().toLowerCase(); - boolean out = side == ForgeDirection.UP || side == ForgeDirection.DOWN; - name += out ? "NORMAL" : "NONE"; - - if(type.getSize() == Size.SMALL) - { - return small_models.get(name); - } - else { - return large_models.get(name); - } - } - - @Override - public void registerIcons(IIconRegister register) - { - PartUniversalCable.registerIcons(register); - PartMechanicalPipe.registerIcons(register); - PartPressurizedTube.registerIcons(register); - PartLogisticalTransporter.registerIcons(register); - PartThermodynamicConductor.registerIcons(register); - } - - @Override - public int atlasIndex() - { - return 0; - } - - private void popTransporter() - { - GL11.glPopAttrib(); - MekanismRenderer.glowOff(); - MekanismRenderer.blendOff(); - GL11.glPopMatrix(); - } - - private void pushTransporter() - { - GL11.glPushMatrix(); - GL11.glPushAttrib(GL11.GL_ENABLE_BIT); - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glDisable(GL11.GL_LIGHTING); - MekanismRenderer.glowOn(); - MekanismRenderer.blendOn(); - } - - private DisplayInteger getOverlayDisplay(World world, ForgeDirection side, int mode) - { - if(cachedOverlays.containsKey(side) && cachedOverlays.get(side).containsKey(mode)) - { - return cachedOverlays.get(side).get(mode); - } - - IIcon icon = null; - - switch(mode) - { - case 0: - icon = Items.gunpowder.getIcon(new ItemStack(Items.gunpowder), 0); - break; - case 1: - icon = Blocks.redstone_torch.getIcon(0, 0); - break; - case 2: - icon = Blocks.unlit_redstone_torch.getIcon(0, 0); - break; - } - - Model3D toReturn = new Model3D(); - toReturn.baseBlock = Blocks.stone; - toReturn.setTexture(icon); - - DisplayInteger display = DisplayInteger.createAndStart(); - - if(cachedOverlays.containsKey(side)) - { - cachedOverlays.get(side).put(mode, display); - } - else { - HashMap map = new HashMap(); - map.put(mode, display); - cachedOverlays.put(side, map); - } - - switch(side) - { - case DOWN: - { - toReturn.minY = -0.01; - toReturn.maxY = 0; - - toReturn.minX = 0; - toReturn.minZ = 0; - toReturn.maxX = 1; - toReturn.maxZ = 1; - break; - } - case UP: - { - toReturn.minY = 1; - toReturn.maxY = 1.01; - - toReturn.minX = 0; - toReturn.minZ = 0; - toReturn.maxX = 1; - toReturn.maxZ = 1; - break; - } - case NORTH: - { - toReturn.minZ = -0.01; - toReturn.maxZ = 0; - - toReturn.minX = 0; - toReturn.minY = 0; - toReturn.maxX = 1; - toReturn.maxY = 1; - break; - } - case SOUTH: - { - toReturn.minZ = 1; - toReturn.maxZ = 1.01; - - toReturn.minX = 0; - toReturn.minY = 0; - toReturn.maxX = 1; - toReturn.maxY = 1; - break; - } - case WEST: - { - toReturn.minX = -0.01; - toReturn.maxX = 0; - - toReturn.minY = 0; - toReturn.minZ = 0; - toReturn.maxY = 1; - toReturn.maxZ = 1; - break; - } - case EAST: - { - toReturn.minX = 1; - toReturn.maxX = 1.01; - - toReturn.minY = 0; - toReturn.minZ = 0; - toReturn.maxY = 1; - toReturn.maxZ = 1; - break; - } - default: - { - break; - } - } - - MekanismRenderer.renderObject(toReturn); - display.endList(); - - return display; - } - - public void resetDisplayInts() - { - cachedLiquids.clear(); - cachedOverlays.clear(); - } +public class RenderPartTransmitter implements IIconSelfRegister { + public static RenderPartTransmitter INSTANCE; + + public static Map small_models; + public static Map large_models; + public static Map contents_models; + + private static final int stages = 100; + private static final double height = 0.45; + private static final double offset = 0.015; + + private ModelTransporterBox modelBox = new ModelTransporterBox(); + + private HashMap> cachedLiquids + = new HashMap>(); + private HashMap> cachedOverlays + = new HashMap>(); + + private Minecraft mc = Minecraft.getMinecraft(); + + private EntityItem entityItem = new EntityItem(null); + private RenderItem renderer = (RenderItem + ) RenderManager.instance.getEntityClassRenderObject(EntityItem.class); + + public static RenderPartTransmitter getInstance() { + return INSTANCE; + } + + public static void init() { + INSTANCE = new RenderPartTransmitter(); + TextureUtils.addIconRegistrar(INSTANCE); + + small_models = CCModel.parseObjModels( + MekanismUtils.getResource(ResourceType.MODEL, "transmitter_small.obj"), + 7, + null + ); + + for (Map.Entry e : small_models.entrySet()) { + e.setValue(e.getValue() + .computeLighting(LightModel.standardLightModel) + .twoFacedCopy() + .apply(new Translation(Vector3.center)) + .shrinkUVs(0.0005)); + } + + large_models = CCModel.parseObjModels( + MekanismUtils.getResource(ResourceType.MODEL, "transmitter_large.obj"), + 7, + null + ); + + for (Map.Entry e : large_models.entrySet()) { + e.setValue(e.getValue() + .computeLighting(LightModel.standardLightModel) + .twoFacedCopy() + .apply(new Translation(Vector3.center)) + .shrinkUVs(0.0005)); + } + + contents_models = CCModel.parseObjModels( + MekanismUtils.getResource(ResourceType.MODEL, "transmitter_contents.obj"), + 7, + null + ); + LightModel interiorLightModel + = new LightModel() + .setAmbient(new Vector3(0.6, 0.6, 0.6)) + .addLight(new Light(new Vector3(0.3, 1, -0.7)) + .setDiffuse(new Vector3(0.6, 0.6, 0.6))) + .addLight(new Light(new Vector3(-0.3, 1, 0.7)) + .setDiffuse(new Vector3(0.6, 0.6, 0.6))); + + for (CCModel c : contents_models.values()) { + c.apply(new Translation(Vector3.center)); + c.computeLighting(interiorLightModel); + c.shrinkUVs(0.0005); + } + } + + private void push() { + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_ENABLE_BIT); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + } + + private void pop() { + GL11.glPopAttrib(); + GL11.glPopMatrix(); + } + + public void renderItem(TransmitterType type) { + CCRenderState.reset(); + CCRenderState.startDrawing(); + + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + renderSide(side, type, false); + } + + CCRenderState.draw(); + + CCRenderState.reset(); + CCRenderState.startDrawing(); + + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + renderSide(side, type, true); + } + + CCRenderState.draw(); + } + + public void renderContents( + PartLogisticalTransporter transporter, float partialTick, Vector3 vec + ) { + GL11.glPushMatrix(); + + entityItem.age = 0; + entityItem.hoverStart = 0; + + entityItem.setPosition( + transporter.x() + 0.5, transporter.y() + 0.5, transporter.z() + 0.5 + ); + entityItem.worldObj = transporter.world(); + + for (TransporterStack stack : transporter.getTransmitter().transit) { + if (stack != null) { + GL11.glPushMatrix(); + entityItem.setEntityItemStack(stack.itemStack); + + float[] pos = TransporterUtils.getStackPosition( + transporter.getTransmitter(), + stack, + partialTick * transporter.tier.speed + ); + + GL11.glTranslated( + vec.x + pos[0], vec.y + pos[1] - entityItem.yOffset, vec.z + pos[2] + ); + GL11.glScalef(0.75F, 0.75F, 0.75F); + + renderer.doRender(entityItem, 0, 0, 0, 0, 0); + GL11.glPopMatrix(); + + if (stack.color != null) { + CCRenderState.changeTexture(MekanismUtils.getResource( + ResourceType.RENDER, "TransporterBox.png" + )); + GL11.glPushMatrix(); + MekanismRenderer.glowOn(); + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glColor4f( + stack.color.getColor(0), + stack.color.getColor(1), + stack.color.getColor(2), + 1.0F + ); + GL11.glTranslatef( + (float) (vec.x + pos[0]), + (float + ) (vec.y + pos[1] - entityItem.yOffset + - ((stack.itemStack.getItem() instanceof ItemBlock) ? 0.1 : 0) + ), + (float) (vec.z + pos[2]) + ); + modelBox.render(0.0625F); + MekanismRenderer.glowOff(); + GL11.glPopMatrix(); + } + } + } + + if (transporter instanceof PartDiversionTransporter) { + EntityPlayer player = mc.thePlayer; + World world = mc.thePlayer.worldObj; + ItemStack itemStack = player.getCurrentEquippedItem(); + MovingObjectPosition pos = player.rayTrace(8.0D, 1.0F); + + if (pos != null && itemStack != null + && itemStack.getItem() instanceof ItemConfigurator) { + int xPos = MathHelper.floor_double(pos.blockX); + int yPos = MathHelper.floor_double(pos.blockY); + int zPos = MathHelper.floor_double(pos.blockZ); + + Coord4D obj = new Coord4D( + xPos, yPos, zPos, transporter.world().provider.dimensionId + ); + + if (obj.equals(Coord4D.get(transporter.tile()))) { + int mode + = ((PartDiversionTransporter) transporter).modes[pos.sideHit]; + ForgeDirection side = ForgeDirection.getOrientation(pos.sideHit); + + pushTransporter(); + + GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.8F); + + CCRenderState.changeTexture( + mode == 0 ? MekanismRenderer.getItemsTexture() + : MekanismRenderer.getBlocksTexture() + ); + GL11.glTranslatef((float) vec.x, (float) vec.y, (float) vec.z); + GL11.glScalef(0.5F, 0.5F, 0.5F); + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + + int display = getOverlayDisplay(world, side, mode).display; + GL11.glCallList(display); + + popTransporter(); + } + } + } + + GL11.glPopMatrix(); + } + + public void renderContents(PartUniversalCable cable, Vector3 pos) { + if (cable.currentPower == 0) { + return; + } + + push(); + CCRenderState.reset(); + CCRenderState.useNormals = true; + CCRenderState.startDrawing(); + GL11.glTranslated(pos.x, pos.y, pos.z); + + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + renderEnergySide(side, cable); + } + + MekanismRenderer.glowOn(); + MekanismRenderer.cullFrontFace(); + + CCRenderState.draw(); + + MekanismRenderer.disableCullFace(); + MekanismRenderer.glowOff(); + + pop(); + } + + public void renderContents(PartThermodynamicConductor transmitter, Vector3 pos) { + push(); + CCRenderState.reset(); + CCRenderState.useNormals = true; + CCRenderState.startDrawing(); + GL11.glTranslated(pos.x, pos.y, pos.z); + + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + renderHeatSide(side, transmitter); + } + + MekanismRenderer.glowOn(); + MekanismRenderer.cullFrontFace(); + + CCRenderState.draw(); + + MekanismRenderer.disableCullFace(); + MekanismRenderer.glowOff(); + + pop(); + } + + public void renderContents(PartMechanicalPipe pipe, Vector3 pos) { + float targetScale; + + if (pipe.getTransmitter().hasTransmitterNetwork()) { + targetScale = pipe.getTransmitter().getTransmitterNetwork().fluidScale; + } else { + targetScale = (float) pipe.buffer.getFluidAmount() + / (float) pipe.buffer.getCapacity(); + } + + if (Math.abs(pipe.currentScale - targetScale) > 0.01) { + pipe.currentScale = (12 * pipe.currentScale + targetScale) / 13; + } else { + pipe.currentScale = targetScale; + } + + Fluid fluid; + + if (pipe.getTransmitter().hasTransmitterNetwork()) { + fluid = pipe.getTransmitter().getTransmitterNetwork().refFluid; + } else { + fluid = pipe.getBuffer() == null ? null : pipe.getBuffer().getFluid(); + } + + float scale = pipe.currentScale; + + if (scale > 0.01 && fluid != null) { + push(); + + MekanismRenderer.glowOn(fluid.getLuminosity()); + MekanismRenderer.colorFluid(fluid); + + CCRenderState.changeTexture(MekanismRenderer.getBlocksTexture()); + GL11.glTranslated(pos.x, pos.y, pos.z); + + boolean gas = fluid.isGaseous(); + + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + if (pipe.getConnectionType(side) == ConnectionType.NORMAL) { + DisplayInteger[] displayLists = getListAndRender(side, fluid); + + if (displayLists != null) { + if (!gas) { + displayLists[Math.max( + 3, (int) ((float) scale * (stages - 1)) + )] + .render(); + } else { + GL11.glColor4f(1F, 1F, 1F, scale); + displayLists[stages - 1].render(); + } + } + } else if (pipe.getConnectionType(side) != ConnectionType.NONE) { + GL11.glCullFace(GL11.GL_FRONT); + CCRenderState.startDrawing(); + renderFluidInOut(side, pipe); + CCRenderState.draw(); + GL11.glCullFace(GL11.GL_BACK); + } + } + + DisplayInteger[] displayLists + = getListAndRender(ForgeDirection.UNKNOWN, fluid); + + if (displayLists != null) { + if (!gas) { + displayLists[Math.max(3, (int) ((float) scale * (stages - 1)))] + .render(); + } else { + GL11.glColor4f(1F, 1F, 1F, scale); + displayLists[stages - 1].render(); + } + } + + MekanismRenderer.glowOff(); + MekanismRenderer.resetColor(); + + pop(); + } + } + + private DisplayInteger[] getListAndRender(ForgeDirection side, Fluid fluid) { + if (side == null || fluid == null || fluid.getIcon() == null) { + return null; + } + + if (cachedLiquids.containsKey(side) + && cachedLiquids.get(side).containsKey(fluid)) { + return cachedLiquids.get(side).get(fluid); + } + + Model3D toReturn = new Model3D(); + toReturn.baseBlock = Blocks.water; + toReturn.setTexture(fluid.getIcon()); + + toReturn.setSideRender(side, false); + toReturn.setSideRender(side.getOpposite(), false); + + DisplayInteger[] displays = new DisplayInteger[stages]; + + if (cachedLiquids.containsKey(side)) { + cachedLiquids.get(side).put(fluid, displays); + } else { + HashMap map = new HashMap(); + map.put(fluid, displays); + cachedLiquids.put(side, map); + } + + for (int i = 0; i < stages; i++) { + displays[i] = DisplayInteger.createAndStart(); + + switch (side) { + case UNKNOWN: { + toReturn.minX = 0.25 + offset; + toReturn.minY = 0.25 + offset; + toReturn.minZ = 0.25 + offset; + + toReturn.maxX = 0.75 - offset; + toReturn.maxY = 0.25 + offset + ((float) i / (float) stages) * height; + toReturn.maxZ = 0.75 - offset; + break; + } + case DOWN: { + toReturn.minX = 0.5 - (((float) i / (float) stages) * height) / 2; + toReturn.minY = 0.0; + toReturn.minZ = 0.5 - (((float) i / (float) stages) * height) / 2; + + toReturn.maxX = 0.5 + (((float) i / (float) stages) * height) / 2; + toReturn.maxY = 0.25 + offset; + toReturn.maxZ = 0.5 + (((float) i / (float) stages) * height) / 2; + break; + } + case UP: { + toReturn.minX = 0.5 - (((float) i / (float) stages) * height) / 2; + toReturn.minY = 0.25 - offset + ((float) i / (float) stages) * height; + toReturn.minZ = 0.5 - (((float) i / (float) stages) * height) / 2; + + toReturn.maxX = 0.5 + (((float) i / (float) stages) * height) / 2; + toReturn.maxY = 1.0; + toReturn.maxZ = 0.5 + (((float) i / (float) stages) * height) / 2; + break; + } + case NORTH: { + toReturn.minX = 0.25 + offset; + toReturn.minY = 0.25 + offset; + toReturn.minZ = 0.0; + + toReturn.maxX = 0.75 - offset; + toReturn.maxY = 0.25 + offset + ((float) i / (float) stages) * height; + toReturn.maxZ = 0.25 + offset; + break; + } + case SOUTH: { + toReturn.minX = 0.25 + offset; + toReturn.minY = 0.25 + offset; + toReturn.minZ = 0.75 - offset; + + toReturn.maxX = 0.75 - offset; + toReturn.maxY = 0.25 + offset + ((float) i / (float) stages) * height; + toReturn.maxZ = 1.0; + break; + } + case WEST: { + toReturn.minX = 0.0; + toReturn.minY = 0.25 + offset; + toReturn.minZ = 0.25 + offset; + + toReturn.maxX = 0.25 + offset; + toReturn.maxY = 0.25 + offset + ((float) i / (float) stages) * height; + toReturn.maxZ = 0.75 - offset; + break; + } + case EAST: { + toReturn.minX = 0.75 - offset; + toReturn.minY = 0.25 + offset; + toReturn.minZ = 0.25 + offset; + + toReturn.maxX = 1.0; + toReturn.maxY = 0.25 + offset + ((float) i / (float) stages) * height; + toReturn.maxZ = 0.75 - offset; + break; + } + } + + MekanismRenderer.renderObject(toReturn); + displays[i].endList(); + } + + return displays; + } + + public void renderContents(PartPressurizedTube tube, Vector3 pos) { + if (!tube.getTransmitter().hasTransmitterNetwork() + || tube.getTransmitter().getTransmitterNetwork().refGas == null + || tube.getTransmitter().getTransmitterNetwork().gasScale == 0) { + return; + } + + push(); + + CCRenderState.reset(); + CCRenderState.useNormals = true; + CCRenderState.startDrawing(); + GL11.glTranslated(pos.x, pos.y, pos.z); + + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + renderGasSide(side, tube); + } + + MekanismRenderer.glowOn(0); + MekanismRenderer.cullFrontFace(); + + CCRenderState.draw(); + + MekanismRenderer.disableCullFace(); + MekanismRenderer.glowOff(); + + pop(); + } + + public void renderStatic(PartSidedPipe transmitter, int pass) { + CCRenderState.reset(); + CCRenderState.hasColour = true; + CCRenderState.setBrightness( + transmitter.world(), transmitter.x(), transmitter.y(), transmitter.z() + ); + + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + renderSide(side, transmitter, pass); + } + } + + public void renderSide(ForgeDirection side, PartSidedPipe transmitter, int pass) { + if (pass == 1) { + if (transmitter.transparencyRender()) { + IIcon renderIcon = transmitter.getIconForSide(side, false); + EnumColor color = transmitter.getRenderColor(false); + + Colour c = null; + + if (color != null) { + c = new ColourRGBA( + color.getColor(0), color.getColor(1), color.getColor(2), 1 + ); + } + + renderPart( + renderIcon, + transmitter.getModelForSide(side, false), + transmitter.x(), + transmitter.y(), + transmitter.z(), + c + ); + } + } else { + IIcon renderIcon = transmitter.getIconForSide(side, true); + EnumColor color = transmitter.getRenderColor(true); + + Colour c = null; + + if (color != null) { + c = new ColourRGBA( + color.getColor(0), color.getColor(1), color.getColor(2), 1 + ); + } + + renderPart( + renderIcon, + transmitter.getModelForSide(side, false), + transmitter.x(), + transmitter.y(), + transmitter.z(), + c + ); + } + } + + public void renderSide(ForgeDirection side, TransmitterType type, boolean opaque) { + boolean out = side == ForgeDirection.UP || side == ForgeDirection.DOWN; + + IIcon renderIcon = out ? type.getSideIcon(opaque) : type.getCenterIcon(opaque); + + renderPart(renderIcon, getItemModel(side, type), 0, 0, 0, null); + } + + public void renderEnergySide(ForgeDirection side, PartUniversalCable cable) { + CCRenderState.changeTexture(MekanismRenderer.getBlocksTexture()); + renderTransparency( + MekanismRenderer.energyIcon, + cable.getModelForSide(side, true), + new ColourRGBA(1.0, 1.0, 1.0, cable.currentPower) + ); + } + + public void renderHeatSide(ForgeDirection side, PartThermodynamicConductor cable) { + CCRenderState.changeTexture(MekanismRenderer.getBlocksTexture()); + renderTransparency( + MekanismRenderer.heatIcon, + cable.getModelForSide(side, true), + ColourTemperature.fromTemperature(cable.temperature, cable.getBaseColour()) + ); + } + + public void renderFluidInOut(ForgeDirection side, PartMechanicalPipe pipe) { + CCRenderState.changeTexture(MekanismRenderer.getBlocksTexture()); + renderTransparency( + pipe.getTransmitter().getTransmitterNetwork().refFluid.getIcon(), + pipe.getModelForSide(side, true), + new ColourRGBA(1.0, 1.0, 1.0, pipe.currentScale) + ); + } + + public void renderGasSide(ForgeDirection side, PartPressurizedTube tube) { + CCRenderState.changeTexture(MekanismRenderer.getBlocksTexture()); + renderTransparency( + tube.getTransmitter().getTransmitterNetwork().refGas.getIcon(), + tube.getModelForSide(side, true), + new ColourRGBA(1.0, 1.0, 1.0, tube.currentScale) + ); + } + + public void + renderPart(IIcon icon, CCModel cc, double x, double y, double z, Colour color) { + if (color != null) { + cc.render( + new Translation(x, y, z), + new IconTransformation(icon), + new ColourMultiplier(color.rgba()) + ); + } else { + cc.render(new Translation(x, y, z), new IconTransformation(icon)); + } + } + + public void renderTransparency(IIcon icon, CCModel cc, Colour color) { + if (icon == null) { + return; + } + + if (color != null) { + cc.render(new IconTransformation(icon), new ColourMultiplier(color.rgba())); + } else { + cc.render(new IconTransformation(icon)); + } + } + + public CCModel getItemModel(ForgeDirection side, TransmitterType type) { + String name = side.name().toLowerCase(); + boolean out = side == ForgeDirection.UP || side == ForgeDirection.DOWN; + name += out ? "NORMAL" : "NONE"; + + if (type.getSize() == Size.SMALL) { + return small_models.get(name); + } else { + return large_models.get(name); + } + } + + @Override + public void registerIcons(IIconRegister register) { + PartUniversalCable.registerIcons(register); + PartMechanicalPipe.registerIcons(register); + PartPressurizedTube.registerIcons(register); + PartLogisticalTransporter.registerIcons(register); + PartThermodynamicConductor.registerIcons(register); + } + + @Override + public int atlasIndex() { + return 0; + } + + private void popTransporter() { + GL11.glPopAttrib(); + MekanismRenderer.glowOff(); + MekanismRenderer.blendOff(); + GL11.glPopMatrix(); + } + + private void pushTransporter() { + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_ENABLE_BIT); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glDisable(GL11.GL_LIGHTING); + MekanismRenderer.glowOn(); + MekanismRenderer.blendOn(); + } + + private DisplayInteger getOverlayDisplay(World world, ForgeDirection side, int mode) { + if (cachedOverlays.containsKey(side) + && cachedOverlays.get(side).containsKey(mode)) { + return cachedOverlays.get(side).get(mode); + } + + IIcon icon = null; + + switch (mode) { + case 0: + icon = Items.gunpowder.getIcon(new ItemStack(Items.gunpowder), 0); + break; + case 1: + icon = Blocks.redstone_torch.getIcon(0, 0); + break; + case 2: + icon = Blocks.unlit_redstone_torch.getIcon(0, 0); + break; + } + + Model3D toReturn = new Model3D(); + toReturn.baseBlock = Blocks.stone; + toReturn.setTexture(icon); + + DisplayInteger display = DisplayInteger.createAndStart(); + + if (cachedOverlays.containsKey(side)) { + cachedOverlays.get(side).put(mode, display); + } else { + HashMap map = new HashMap(); + map.put(mode, display); + cachedOverlays.put(side, map); + } + + switch (side) { + case DOWN: { + toReturn.minY = -0.01; + toReturn.maxY = 0; + + toReturn.minX = 0; + toReturn.minZ = 0; + toReturn.maxX = 1; + toReturn.maxZ = 1; + break; + } + case UP: { + toReturn.minY = 1; + toReturn.maxY = 1.01; + + toReturn.minX = 0; + toReturn.minZ = 0; + toReturn.maxX = 1; + toReturn.maxZ = 1; + break; + } + case NORTH: { + toReturn.minZ = -0.01; + toReturn.maxZ = 0; + + toReturn.minX = 0; + toReturn.minY = 0; + toReturn.maxX = 1; + toReturn.maxY = 1; + break; + } + case SOUTH: { + toReturn.minZ = 1; + toReturn.maxZ = 1.01; + + toReturn.minX = 0; + toReturn.minY = 0; + toReturn.maxX = 1; + toReturn.maxY = 1; + break; + } + case WEST: { + toReturn.minX = -0.01; + toReturn.maxX = 0; + + toReturn.minY = 0; + toReturn.minZ = 0; + toReturn.maxY = 1; + toReturn.maxZ = 1; + break; + } + case EAST: { + toReturn.minX = 1; + toReturn.maxX = 1.01; + + toReturn.minY = 0; + toReturn.minZ = 0; + toReturn.maxY = 1; + toReturn.maxZ = 1; + break; + } + default: { + break; + } + } + + MekanismRenderer.renderObject(toReturn); + display.endList(); + + return display; + } + + public void resetDisplayInts() { + cachedLiquids.clear(); + cachedOverlays.clear(); + } } diff --git a/src/main/java/mekanism/client/render/RenderTickHandler.java b/src/main/java/mekanism/client/render/RenderTickHandler.java index 69d5c8ff8..f95d3faf8 100644 --- a/src/main/java/mekanism/client/render/RenderTickHandler.java +++ b/src/main/java/mekanism/client/render/RenderTickHandler.java @@ -3,6 +3,11 @@ package mekanism.client.render; import java.util.List; import java.util.Random; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent.Phase; +import cpw.mods.fml.common.gameevent.TickEvent.RenderTickEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.MekanismAPI; @@ -24,253 +29,342 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.MathHelper; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.TickEvent.Phase; -import cpw.mods.fml.common.gameevent.TickEvent.RenderTickEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class RenderTickHandler -{ - public Random rand = new Random(); - public Minecraft mc = Minecraft.getMinecraft(); +public class RenderTickHandler { + public Random rand = new Random(); + public Minecraft mc = Minecraft.getMinecraft(); - @SubscribeEvent - public void tickEnd(RenderTickEvent event) - { - if(event.phase == Phase.END) - { - if(mc.thePlayer != null && mc.theWorld != null && !mc.isGamePaused()) - { - EntityPlayer player = mc.thePlayer; - World world = mc.thePlayer.worldObj; - - FontRenderer font = mc.fontRenderer; - - MovingObjectPosition pos = player.rayTrace(40.0D, 1.0F); - - if(pos != null) - { - int x = MathHelper.floor_double(pos.blockX); - int y = MathHelper.floor_double(pos.blockY); - int z = MathHelper.floor_double(pos.blockZ); - - Coord4D obj = new Coord4D(x, y, z, world.provider.dimensionId); - - if(MekanismAPI.debug && mc.currentScreen == null && !mc.gameSettings.showDebugInfo) - { - String tileDisplay = ""; - - if(obj.getTileEntity(world) != null) - { - if(obj.getTileEntity(world).getClass() != null) - { - tileDisplay = obj.getTileEntity(world).getClass().getSimpleName(); - } - } - - font.drawStringWithShadow("Block: " + obj.getBlock(world).getUnlocalizedName(), 1, 1, 0x404040); - font.drawStringWithShadow("Metadata: " + obj.getMetadata(world), 1, 10, 0x404040); - font.drawStringWithShadow("Location: " + MekanismUtils.getCoordDisplay(obj), 1, 19, 0x404040); - font.drawStringWithShadow("TileEntity: " + tileDisplay, 1, 28, 0x404040); - font.drawStringWithShadow("Side: " + pos.sideHit, 1, 37, 0x404040); - } - } - - if(player != null && mc.currentScreen == null && player.getEquipmentInSlot(3) != null) - { - ItemStack stack = player.getEquipmentInSlot(3); - - ScaledResolution scaledresolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); - - int x = scaledresolution.getScaledWidth(); - int y = scaledresolution.getScaledHeight(); - - if(stack.getItem() instanceof ItemJetpack) - { - ItemJetpack jetpack = (ItemJetpack)stack.getItem(); - - font.drawStringWithShadow("Mode: " + jetpack.getMode(stack).getName(), 1, y - 20, 0x404040); - font.drawStringWithShadow("Hydrogen: " + jetpack.getStored(stack), 1, y - 11, 0x404040); - } - else if(stack.getItem() instanceof ItemScubaTank) - { - ItemScubaTank scubaTank = (ItemScubaTank)stack.getItem(); - String state = (scubaTank.getFlowing(stack) ? EnumColor.DARK_GREEN + "On" : EnumColor.DARK_RED + "Off"); - - font.drawStringWithShadow("Mode: " + state, 1, y - 20, 0x404040); - font.drawStringWithShadow("Oxygen: " + scubaTank.getStored(stack), 1, y - 11, 0x404040); - } - } + @SubscribeEvent + public void tickEnd(RenderTickEvent event) { + if (event.phase == Phase.END) { + if (mc.thePlayer != null && mc.theWorld != null && !mc.isGamePaused()) { + EntityPlayer player = mc.thePlayer; + World world = mc.thePlayer.worldObj; - synchronized(Mekanism.jetpackOn) - { - for(String s : Mekanism.jetpackOn) - { - EntityPlayer p = mc.theWorld.getPlayerEntityByName(s); + FontRenderer font = mc.fontRenderer; - if(p == null) - { - continue; - } + MovingObjectPosition pos = player.rayTrace(40.0D, 1.0F); - Pos3D playerPos = new Pos3D(p); + if (pos != null) { + int x = MathHelper.floor_double(pos.blockX); + int y = MathHelper.floor_double(pos.blockY); + int z = MathHelper.floor_double(pos.blockZ); - if(p != mc.thePlayer) - { - playerPos.translate(0, 1.7, 0); - } + Coord4D obj = new Coord4D(x, y, z, world.provider.dimensionId); - float random = (rand.nextFloat() - 0.5F) * 0.1F; + if (MekanismAPI.debug && mc.currentScreen == null + && !mc.gameSettings.showDebugInfo) { + String tileDisplay = ""; - Pos3D vLeft = new Pos3D(); - vLeft.xPos -= 0.43; - vLeft.yPos -= 0.55; - vLeft.zPos -= 0.54; - vLeft.rotatePitch(p.isSneaking() ? 25 : 0); - vLeft.rotateYaw(p.renderYawOffset); + if (obj.getTileEntity(world) != null) { + if (obj.getTileEntity(world).getClass() != null) { + tileDisplay + = obj.getTileEntity(world).getClass().getSimpleName(); + } + } - Pos3D vRight = new Pos3D(); - vRight.xPos += 0.43; - vRight.yPos -= 0.55; - vRight.zPos -= 0.54; - vRight.rotatePitch(p.isSneaking() ? 25 : 0); - vRight.rotateYaw(p.renderYawOffset); + font.drawStringWithShadow( + "Block: " + obj.getBlock(world).getUnlocalizedName(), + 1, + 1, + 0x404040 + ); + font.drawStringWithShadow( + "Metadata: " + obj.getMetadata(world), 1, 10, 0x404040 + ); + font.drawStringWithShadow( + "Location: " + MekanismUtils.getCoordDisplay(obj), + 1, + 19, + 0x404040 + ); + font.drawStringWithShadow( + "TileEntity: " + tileDisplay, 1, 28, 0x404040 + ); + font.drawStringWithShadow( + "Side: " + pos.sideHit, 1, 37, 0x404040 + ); + } + } - Pos3D vCenter = new Pos3D(); - vCenter.xPos = (rand.nextFloat() - 0.5F) * 0.4F; - vCenter.yPos -= 0.86; - vCenter.zPos -= 0.30; - vCenter.rotatePitch(p.isSneaking() ? 25 : 0); - vCenter.rotateYaw(p.renderYawOffset); + if (player != null && mc.currentScreen == null + && player.getEquipmentInSlot(3) != null) { + ItemStack stack = player.getEquipmentInSlot(3); - Pos3D rLeft = vLeft.clone().scale(random); - Pos3D rRight = vRight.clone().scale(random); + ScaledResolution scaledresolution + = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); - Pos3D mLeft = vLeft.clone().scale(0.2).translate(new Pos3D(p.motionX, p.motionY, p.motionZ)); - Pos3D mRight = vRight.clone().scale(0.2).translate(new Pos3D(p.motionX, p.motionY, p.motionZ)); - Pos3D mCenter = vCenter.clone().scale(0.2).translate(new Pos3D(p.motionX, p.motionY, p.motionZ)); + int x = scaledresolution.getScaledWidth(); + int y = scaledresolution.getScaledHeight(); - mLeft.translate(rLeft); - mRight.translate(rRight); + if (stack.getItem() instanceof ItemJetpack) { + ItemJetpack jetpack = (ItemJetpack) stack.getItem(); - Pos3D v = playerPos.clone().translate(vLeft); - spawnAndSetParticle("flame", world, v.xPos, v.yPos, v.zPos, mLeft.xPos, mLeft.yPos, mLeft.zPos); - spawnAndSetParticle("smoke", world, v.xPos, v.yPos, v.zPos, mLeft.xPos, mLeft.yPos, mLeft.zPos); + font.drawStringWithShadow( + "Mode: " + jetpack.getMode(stack).getName(), + 1, + y - 20, + 0x404040 + ); + font.drawStringWithShadow( + "Hydrogen: " + jetpack.getStored(stack), 1, y - 11, 0x404040 + ); + } else if (stack.getItem() instanceof ItemScubaTank) { + ItemScubaTank scubaTank = (ItemScubaTank) stack.getItem(); + String state + = (scubaTank.getFlowing(stack) ? EnumColor.DARK_GREEN + "On" + : EnumColor.DARK_RED + "Off"); - v = playerPos.clone().translate(vRight); - spawnAndSetParticle("flame", world, v.xPos, v.yPos, v.zPos, mRight.xPos, mRight.yPos, mRight.zPos); - spawnAndSetParticle("smoke", world, v.xPos, v.yPos, v.zPos, mRight.xPos, mRight.yPos, mRight.zPos); + font.drawStringWithShadow("Mode: " + state, 1, y - 20, 0x404040); + font.drawStringWithShadow( + "Oxygen: " + scubaTank.getStored(stack), 1, y - 11, 0x404040 + ); + } + } - v = playerPos.clone().translate(vCenter); - spawnAndSetParticle("flame", world, v.xPos, v.yPos, v.zPos, mCenter.xPos, mCenter.yPos, mCenter.zPos); - spawnAndSetParticle("smoke", world, v.xPos, v.yPos, v.zPos, mCenter.xPos, mCenter.yPos, mCenter.zPos); - } - } - - synchronized(Mekanism.gasmaskOn) - { - if(world.getWorldTime() % 4 == 0) - { - for(String s : Mekanism.gasmaskOn) - { - EntityPlayer p = mc.theWorld.getPlayerEntityByName(s); - - if(p == null || !p.isInWater()) - { - continue; - } - - Pos3D playerPos = new Pos3D(p); + synchronized (Mekanism.jetpackOn) { + for (String s : Mekanism.jetpackOn) { + EntityPlayer p = mc.theWorld.getPlayerEntityByName(s); - if(p != mc.thePlayer) - { - playerPos.translate(0, 1.7, 0); - } - - float xRand = (rand.nextFloat() - 0.5F) * 0.08F; - float yRand = (rand.nextFloat() - 0.5F) * 0.05F; - - Pos3D vec = new Pos3D(0.4, 0.4, 0.4).multiply(new Pos3D(p.getLook(90))).translate(0, -0.2, 0); - Pos3D motion = vec.clone().scale(0.2).translate(new Pos3D(p.motionX, p.motionY, p.motionZ)); - - Pos3D v = playerPos.clone().translate(vec); - spawnAndSetParticle("bubble", world, v.xPos, v.yPos, v.zPos, motion.xPos, motion.yPos + 0.2, motion.zPos); - } - } - } - - if(world.getWorldTime() % 4 == 0) - { - for(EntityPlayer p : (List)world.playerEntities) - { - if(!Mekanism.flamethrowerActive.contains(p.getCommandSenderName()) && !p.isSwingInProgress && p.getCurrentEquippedItem() != null && p.getCurrentEquippedItem().getItem() instanceof ItemFlamethrower) - { - if(((ItemFlamethrower)p.getCurrentEquippedItem().getItem()).getGas(p.getCurrentEquippedItem()) != null) - { - Pos3D playerPos = new Pos3D(p); - Pos3D flameVec = new Pos3D(); - - if(p.isSneaking()) - { - flameVec.yPos -= 0.35F; - flameVec.zPos -= 0.15F; - } - - Pos3D flameMotion = new Pos3D(p.motionX, p.onGround ? 0 : p.motionY, p.motionZ); - - if(player == p && mc.gameSettings.thirdPersonView == 0) - { - flameVec = new Pos3D(0.8, 0.8, 0.8); - - flameVec.multiply(new Pos3D(p.getLook(90))); - flameVec.rotateYaw(15); - } - else { - flameVec.xPos -= 0.45F; - - if(player == p) - { - flameVec.yPos -= 0.5F; - } - else { - flameVec.yPos += 1F; - } - - flameVec.zPos += 1.05F; - - flameVec.rotateYaw(p.renderYawOffset); - } - - Pos3D mergedVec = playerPos.clone().translate(flameVec); - - spawnAndSetParticle("flame", world, mergedVec.xPos, mergedVec.yPos, mergedVec.zPos, flameMotion.xPos, flameMotion.yPos, flameMotion.zPos); - } - } - } - } - } - } - } + if (p == null) { + continue; + } - public void spawnAndSetParticle(String s, World world, double x, double y, double z, double velX, double velY, double velZ) - { - EntityFX fx = null; + Pos3D playerPos = new Pos3D(p); - if(s.equals("flame")) - { - fx = new EntityJetpackFlameFX(world, x, y, z, velX, velY, velZ); - } - else if(s.equals("smoke")) - { - fx = new EntityJetpackSmokeFX(world, x, y, z, velX, velY, velZ); - } - else if(s.equals("bubble")) - { - fx = new EntityScubaBubbleFX(world, x, y, z, velX, velY, velZ); - } + if (p != mc.thePlayer) { + playerPos.translate(0, 1.7, 0); + } - mc.effectRenderer.addEffect(fx); - } + float random = (rand.nextFloat() - 0.5F) * 0.1F; + + Pos3D vLeft = new Pos3D(); + vLeft.xPos -= 0.43; + vLeft.yPos -= 0.55; + vLeft.zPos -= 0.54; + vLeft.rotatePitch(p.isSneaking() ? 25 : 0); + vLeft.rotateYaw(p.renderYawOffset); + + Pos3D vRight = new Pos3D(); + vRight.xPos += 0.43; + vRight.yPos -= 0.55; + vRight.zPos -= 0.54; + vRight.rotatePitch(p.isSneaking() ? 25 : 0); + vRight.rotateYaw(p.renderYawOffset); + + Pos3D vCenter = new Pos3D(); + vCenter.xPos = (rand.nextFloat() - 0.5F) * 0.4F; + vCenter.yPos -= 0.86; + vCenter.zPos -= 0.30; + vCenter.rotatePitch(p.isSneaking() ? 25 : 0); + vCenter.rotateYaw(p.renderYawOffset); + + Pos3D rLeft = vLeft.clone().scale(random); + Pos3D rRight = vRight.clone().scale(random); + + Pos3D mLeft = vLeft.clone().scale(0.2).translate( + new Pos3D(p.motionX, p.motionY, p.motionZ) + ); + Pos3D mRight = vRight.clone().scale(0.2).translate( + new Pos3D(p.motionX, p.motionY, p.motionZ) + ); + Pos3D mCenter = vCenter.clone().scale(0.2).translate( + new Pos3D(p.motionX, p.motionY, p.motionZ) + ); + + mLeft.translate(rLeft); + mRight.translate(rRight); + + Pos3D v = playerPos.clone().translate(vLeft); + spawnAndSetParticle( + "flame", + world, + v.xPos, + v.yPos, + v.zPos, + mLeft.xPos, + mLeft.yPos, + mLeft.zPos + ); + spawnAndSetParticle( + "smoke", + world, + v.xPos, + v.yPos, + v.zPos, + mLeft.xPos, + mLeft.yPos, + mLeft.zPos + ); + + v = playerPos.clone().translate(vRight); + spawnAndSetParticle( + "flame", + world, + v.xPos, + v.yPos, + v.zPos, + mRight.xPos, + mRight.yPos, + mRight.zPos + ); + spawnAndSetParticle( + "smoke", + world, + v.xPos, + v.yPos, + v.zPos, + mRight.xPos, + mRight.yPos, + mRight.zPos + ); + + v = playerPos.clone().translate(vCenter); + spawnAndSetParticle( + "flame", + world, + v.xPos, + v.yPos, + v.zPos, + mCenter.xPos, + mCenter.yPos, + mCenter.zPos + ); + spawnAndSetParticle( + "smoke", + world, + v.xPos, + v.yPos, + v.zPos, + mCenter.xPos, + mCenter.yPos, + mCenter.zPos + ); + } + } + + synchronized (Mekanism.gasmaskOn) { + if (world.getWorldTime() % 4 == 0) { + for (String s : Mekanism.gasmaskOn) { + EntityPlayer p = mc.theWorld.getPlayerEntityByName(s); + + if (p == null || !p.isInWater()) { + continue; + } + + Pos3D playerPos = new Pos3D(p); + + if (p != mc.thePlayer) { + playerPos.translate(0, 1.7, 0); + } + + float xRand = (rand.nextFloat() - 0.5F) * 0.08F; + float yRand = (rand.nextFloat() - 0.5F) * 0.05F; + + Pos3D vec = new Pos3D(0.4, 0.4, 0.4) + .multiply(new Pos3D(p.getLook(90))) + .translate(0, -0.2, 0); + Pos3D motion = vec.clone().scale(0.2).translate( + new Pos3D(p.motionX, p.motionY, p.motionZ) + ); + + Pos3D v = playerPos.clone().translate(vec); + spawnAndSetParticle( + "bubble", + world, + v.xPos, + v.yPos, + v.zPos, + motion.xPos, + motion.yPos + 0.2, + motion.zPos + ); + } + } + } + + if (world.getWorldTime() % 4 == 0) { + for (EntityPlayer p : (List) world.playerEntities) { + if (!Mekanism.flamethrowerActive.contains(p.getCommandSenderName() + ) + && !p.isSwingInProgress && p.getCurrentEquippedItem() != null + && p.getCurrentEquippedItem().getItem() + instanceof ItemFlamethrower) { + if (((ItemFlamethrower) p.getCurrentEquippedItem().getItem()) + .getGas(p.getCurrentEquippedItem()) + != null) { + Pos3D playerPos = new Pos3D(p); + Pos3D flameVec = new Pos3D(); + + if (p.isSneaking()) { + flameVec.yPos -= 0.35F; + flameVec.zPos -= 0.15F; + } + + Pos3D flameMotion = new Pos3D( + p.motionX, p.onGround ? 0 : p.motionY, p.motionZ + ); + + if (player == p && mc.gameSettings.thirdPersonView == 0) { + flameVec = new Pos3D(0.8, 0.8, 0.8); + + flameVec.multiply(new Pos3D(p.getLook(90))); + flameVec.rotateYaw(15); + } else { + flameVec.xPos -= 0.45F; + + if (player == p) { + flameVec.yPos -= 0.5F; + } else { + flameVec.yPos += 1F; + } + + flameVec.zPos += 1.05F; + + flameVec.rotateYaw(p.renderYawOffset); + } + + Pos3D mergedVec = playerPos.clone().translate(flameVec); + + spawnAndSetParticle( + "flame", + world, + mergedVec.xPos, + mergedVec.yPos, + mergedVec.zPos, + flameMotion.xPos, + flameMotion.yPos, + flameMotion.zPos + ); + } + } + } + } + } + } + } + + public void spawnAndSetParticle( + String s, + World world, + double x, + double y, + double z, + double velX, + double velY, + double velZ + ) { + EntityFX fx = null; + + if (s.equals("flame")) { + fx = new EntityJetpackFlameFX(world, x, y, z, velX, velY, velZ); + } else if (s.equals("smoke")) { + fx = new EntityJetpackSmokeFX(world, x, y, z, velX, velY, velZ); + } else if (s.equals("bubble")) { + fx = new EntityScubaBubbleFX(world, x, y, z, velX, velY, velZ); + } + + mc.effectRenderer.addEffect(fx); + } } diff --git a/src/main/java/mekanism/client/render/block/BasicRenderingHandler.java b/src/main/java/mekanism/client/render/block/BasicRenderingHandler.java index 7b59fbfab..7bba24725 100644 --- a/src/main/java/mekanism/client/render/block/BasicRenderingHandler.java +++ b/src/main/java/mekanism/client/render/block/BasicRenderingHandler.java @@ -1,5 +1,8 @@ package mekanism.client.render.block; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.ClientProxy; import mekanism.client.model.ModelSecurityDesk; import mekanism.client.render.MekanismRenderer; @@ -11,82 +14,77 @@ import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.world.IBlockAccess; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class BasicRenderingHandler implements ISimpleBlockRenderingHandler -{ - private Minecraft mc = Minecraft.getMinecraft(); - - public ModelSecurityDesk securityDesk = new ModelSecurityDesk(); - - @Override - public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) - { - GL11.glPushMatrix(); - GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); +public class BasicRenderingHandler implements ISimpleBlockRenderingHandler { + private Minecraft mc = Minecraft.getMinecraft(); - BasicType type = BasicType.get(block, metadata); - - if(type != null) - { - if(type == BasicType.STRUCTURAL_GLASS) - { - MekanismRenderer.blendOn(); - } - - if(type != BasicType.SECURITY_DESK) - { - GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); - MekanismRenderer.renderItem(renderer, metadata, block); - } - else { - GL11.glRotatef(180, 1.0F, 0.0F, 0.0F); - GL11.glScalef(0.8F, 0.8F, 0.8F); - GL11.glTranslatef(0.0F, -0.8F, 0.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "SecurityDesk.png")); - securityDesk.render(0.0625F, mc.renderEngine); - } - - if(type == BasicType.STRUCTURAL_GLASS) - { - MekanismRenderer.blendOff(); - } - } + public ModelSecurityDesk securityDesk = new ModelSecurityDesk(); - GL11.glPopMatrix(); - } + @Override + public void + renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); - @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) - { - if(block == MekanismBlocks.BasicBlock || block == MekanismBlocks.BasicBlock2) - { - int metadata = world.getBlockMetadata(x, y, z); + BasicType type = BasicType.get(block, metadata); - renderer.renderStandardBlock(block, x, y, z); - renderer.setRenderBoundsFromBlock(block); + if (type != null) { + if (type == BasicType.STRUCTURAL_GLASS) { + MekanismRenderer.blendOn(); + } - return true; - } + if (type != BasicType.SECURITY_DESK) { + GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); + MekanismRenderer.renderItem(renderer, metadata, block); + } else { + GL11.glRotatef(180, 1.0F, 0.0F, 0.0F); + GL11.glScalef(0.8F, 0.8F, 0.8F); + GL11.glTranslatef(0.0F, -0.8F, 0.0F); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "SecurityDesk.png") + ); + securityDesk.render(0.0625F, mc.renderEngine); + } - return false; - } + if (type == BasicType.STRUCTURAL_GLASS) { + MekanismRenderer.blendOff(); + } + } - @Override - public int getRenderId() - { - return ClientProxy.BASIC_RENDER_ID; - } + GL11.glPopMatrix(); + } - @Override - public boolean shouldRender3DInInventory(int modelId) - { - return true; - } + @Override + public boolean renderWorldBlock( + IBlockAccess world, + int x, + int y, + int z, + Block block, + int modelId, + RenderBlocks renderer + ) { + if (block == MekanismBlocks.BasicBlock || block == MekanismBlocks.BasicBlock2) { + int metadata = world.getBlockMetadata(x, y, z); + + renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBoundsFromBlock(block); + + return true; + } + + return false; + } + + @Override + public int getRenderId() { + return ClientProxy.BASIC_RENDER_ID; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } } diff --git a/src/main/java/mekanism/client/render/block/CTMRenderingHandler.java b/src/main/java/mekanism/client/render/block/CTMRenderingHandler.java index a2ff40b87..13a0ab259 100644 --- a/src/main/java/mekanism/client/render/block/CTMRenderingHandler.java +++ b/src/main/java/mekanism/client/render/block/CTMRenderingHandler.java @@ -1,5 +1,6 @@ package mekanism.client.render.block; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; import mekanism.api.MekanismConfig; import mekanism.client.ClientProxy; import mekanism.client.render.MekanismRenderer; @@ -11,92 +12,96 @@ import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; /** * CTM ISBRH adapted from Chisel * Code licensed under GPLv2 * @author AUTOMATIC_MAIDEN, asie, pokefenn, unpairedbracket */ -public class CTMRenderingHandler implements ISimpleBlockRenderingHandler -{ - RenderBlocksCTM rendererCTM = new RenderBlocksCTM(); +public class CTMRenderingHandler implements ISimpleBlockRenderingHandler { + RenderBlocksCTM rendererCTM = new RenderBlocksCTM(); - @Override - public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) - { - MekanismRenderer.renderItem(renderer, metadata, block); - } + @Override + public void + renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { + MekanismRenderer.renderItem(renderer, metadata, block); + } - @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks rendererOld) - { - int meta = world.getBlockMetadata(x, y, z); - - if(block instanceof IBlockCTM && !((IBlockCTM)block).shouldRenderBlock(world, x, y, z, meta)) - { - return false; - } + @Override + public boolean renderWorldBlock( + IBlockAccess world, + int x, + int y, + int z, + Block block, + int modelId, + RenderBlocks rendererOld + ) { + int meta = world.getBlockMetadata(x, y, z); - CTMData blockCTM = ((IBlockCTM)block).getCTMData(world, x, y, z, meta); + if (block instanceof IBlockCTM + && !((IBlockCTM) block).shouldRenderBlock(world, x, y, z, meta)) { + return false; + } - if(MekanismConfig.client.renderCTM && blockCTM != null) - { - if(blockCTM.hasFacingOverride() && world.getTileEntity(x, y, z) instanceof TileEntityBasicBlock) - { - TileEntityBasicBlock tile = (TileEntityBasicBlock)world.getTileEntity(x, y, z); - blockCTM.setFacing(tile.facing); - } - - rendererCTM.blockAccess = world; - rendererCTM.renderMaxX = 1.0; - rendererCTM.renderMaxY = 1.0; - rendererCTM.renderMaxZ = 1.0; + CTMData blockCTM = ((IBlockCTM) block).getCTMData(world, x, y, z, meta); - rendererCTM.dataCTM = blockCTM; + if (MekanismConfig.client.renderCTM && blockCTM != null) { + if (blockCTM.hasFacingOverride() + && world.getTileEntity(x, y, z) instanceof TileEntityBasicBlock) { + TileEntityBasicBlock tile + = (TileEntityBasicBlock) world.getTileEntity(x, y, z); + blockCTM.setFacing(tile.facing); + } - rendererCTM.rendererOld = rendererOld; + rendererCTM.blockAccess = world; + rendererCTM.renderMaxX = 1.0; + rendererCTM.renderMaxY = 1.0; + rendererCTM.renderMaxZ = 1.0; - return rendererCTM.renderStandardBlock(block, x, y, z); - } - - if(MachineType.get(block, meta) != null) - { - TileEntity tile = world.getTileEntity(x, y, z); - - int prevRotateTop = rendererOld.uvRotateTop; - int prevRotateBottom = rendererOld.uvRotateBottom; - - if(tile instanceof TileEntityBasicBlock) - { - if(((TileEntityBasicBlock)tile).facing >= 2) - { - rendererOld.uvRotateTop = MekanismRenderer.directionMap[((TileEntityBasicBlock)tile).facing-2]; - rendererOld.uvRotateBottom = MekanismRenderer.directionMap[((TileEntityBasicBlock)tile).facing-2]; - } - } - - rendererOld.renderStandardBlock(block, x, y, z); - rendererOld.setRenderBoundsFromBlock(block); - - rendererOld.uvRotateTop = prevRotateTop; - rendererOld.uvRotateBottom = prevRotateBottom; - - return true; - } - - return rendererOld.renderStandardBlock(block, x, y, z); - } + rendererCTM.dataCTM = blockCTM; - @Override - public boolean shouldRender3DInInventory(int renderId) - { - return true; - } + rendererCTM.rendererOld = rendererOld; - @Override - public int getRenderId() - { - return ClientProxy.CTM_RENDER_ID; - } + return rendererCTM.renderStandardBlock(block, x, y, z); + } + + if (MachineType.get(block, meta) != null) { + TileEntity tile = world.getTileEntity(x, y, z); + + int prevRotateTop = rendererOld.uvRotateTop; + int prevRotateBottom = rendererOld.uvRotateBottom; + + if (tile instanceof TileEntityBasicBlock) { + if (((TileEntityBasicBlock) tile).facing >= 2) { + rendererOld.uvRotateTop + = MekanismRenderer + .directionMap[((TileEntityBasicBlock) tile).facing - 2]; + rendererOld.uvRotateBottom + = MekanismRenderer + .directionMap[((TileEntityBasicBlock) tile).facing - 2]; + } + } + + rendererOld.renderStandardBlock(block, x, y, z); + rendererOld.setRenderBoundsFromBlock(block); + + rendererOld.uvRotateTop = prevRotateTop; + rendererOld.uvRotateBottom = prevRotateBottom; + + return true; + } + + return rendererOld.renderStandardBlock(block, x, y, z); + } + + @Override + public boolean shouldRender3DInInventory(int renderId) { + return true; + } + + @Override + public int getRenderId() { + return ClientProxy.CTM_RENDER_ID; + } } diff --git a/src/main/java/mekanism/client/render/block/MachineRenderingHandler.java b/src/main/java/mekanism/client/render/block/MachineRenderingHandler.java index 6218c7478..9495270c0 100644 --- a/src/main/java/mekanism/client/render/block/MachineRenderingHandler.java +++ b/src/main/java/mekanism/client/render/block/MachineRenderingHandler.java @@ -1,5 +1,8 @@ package mekanism.client.render.block; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.ClientProxy; import mekanism.client.model.ModelChargepad; import mekanism.client.model.ModelChemicalCrystallizer; @@ -30,252 +33,260 @@ import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.world.IBlockAccess; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class MachineRenderingHandler implements ISimpleBlockRenderingHandler -{ - private Minecraft mc = Minecraft.getMinecraft(); - - public ModelElectricPump electricPump = new ModelElectricPump(); - public ModelMetallurgicInfuser metallurgicInfuser = new ModelMetallurgicInfuser(); - public ModelChargepad chargepad = new ModelChargepad(); - public ModelLogisticalSorter logisticalSorter = new ModelLogisticalSorter(); - public ModelDigitalMiner digitalMiner = new ModelDigitalMiner(); - public ModelRotaryCondensentrator rotaryCondensentrator = new ModelRotaryCondensentrator(); - public ModelChemicalOxidizer chemicalOxidizer = new ModelChemicalOxidizer(); - public ModelChemicalInfuser chemicalInfuser = new ModelChemicalInfuser(); - public ModelElectrolyticSeparator electrolyticSeparator = new ModelElectrolyticSeparator(); - public ModelChemicalDissolutionChamber chemicalDissolutionChamber = new ModelChemicalDissolutionChamber(); - public ModelChemicalWasher chemicalWasher = new ModelChemicalWasher(); - public ModelChemicalCrystallizer chemicalCrystallizer = new ModelChemicalCrystallizer(); - public ModelSeismicVibrator seismicVibrator = new ModelSeismicVibrator(); - public ModelPressurizedReactionChamber pressurizedReactionChamber = new ModelPressurizedReactionChamber(); - public ModelFluidicPlenisher fluidicPlenisher = new ModelFluidicPlenisher(); - public ModelLaser laser = new ModelLaser(); - public ModelLaserAmplifier laserAmplifier = new ModelLaserAmplifier(); - public ModelSolarNeutronActivator solarNeutronActivator = new ModelSolarNeutronActivator(); - public ModelResistiveHeater resistiveHeater = new ModelResistiveHeater(); - public ModelQuantumEntangloporter quantumEntangloporter = new ModelQuantumEntangloporter(); - public ModelTheoreticalElementizer theoreticalElementizer = new ModelTheoreticalElementizer(); +public class MachineRenderingHandler implements ISimpleBlockRenderingHandler { + private Minecraft mc = Minecraft.getMinecraft(); - @Override - public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) - { - if(block == null || renderer == null || MachineType.get(block, metadata) == null) - { - return; - } + public ModelElectricPump electricPump = new ModelElectricPump(); + public ModelMetallurgicInfuser metallurgicInfuser = new ModelMetallurgicInfuser(); + public ModelChargepad chargepad = new ModelChargepad(); + public ModelLogisticalSorter logisticalSorter = new ModelLogisticalSorter(); + public ModelDigitalMiner digitalMiner = new ModelDigitalMiner(); + public ModelRotaryCondensentrator rotaryCondensentrator + = new ModelRotaryCondensentrator(); + public ModelChemicalOxidizer chemicalOxidizer = new ModelChemicalOxidizer(); + public ModelChemicalInfuser chemicalInfuser = new ModelChemicalInfuser(); + public ModelElectrolyticSeparator electrolyticSeparator + = new ModelElectrolyticSeparator(); + public ModelChemicalDissolutionChamber chemicalDissolutionChamber + = new ModelChemicalDissolutionChamber(); + public ModelChemicalWasher chemicalWasher = new ModelChemicalWasher(); + public ModelChemicalCrystallizer chemicalCrystallizer + = new ModelChemicalCrystallizer(); + public ModelSeismicVibrator seismicVibrator = new ModelSeismicVibrator(); + public ModelPressurizedReactionChamber pressurizedReactionChamber + = new ModelPressurizedReactionChamber(); + public ModelFluidicPlenisher fluidicPlenisher = new ModelFluidicPlenisher(); + public ModelLaser laser = new ModelLaser(); + public ModelLaserAmplifier laserAmplifier = new ModelLaserAmplifier(); + public ModelSolarNeutronActivator solarNeutronActivator + = new ModelSolarNeutronActivator(); + public ModelResistiveHeater resistiveHeater = new ModelResistiveHeater(); + public ModelQuantumEntangloporter quantumEntangloporter + = new ModelQuantumEntangloporter(); + public ModelTheoreticalElementizer theoreticalElementizer + = new ModelTheoreticalElementizer(); - GL11.glPushMatrix(); - GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); + @Override + public void + renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { + if (block == null || renderer == null + || MachineType.get(block, metadata) == null) { + return; + } - MachineType type = MachineType.get(block, metadata); + GL11.glPushMatrix(); + GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); - if(type == MachineType.ELECTRIC_PUMP) - { - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glTranslatef(0.0F, -0.85F, 0.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ElectricPump.png")); - electricPump.render(0.0560F); - } - else if(type == MachineType.METALLURGIC_INFUSER) - { - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(180F, 0.0F, -1.0F, 0.0F); - GL11.glTranslatef(0.0F, -1.0F, 0.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "MetallurgicInfuser.png")); - metallurgicInfuser.render(0.0625F); - } - else if(type == MachineType.CHARGEPAD) - { - GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F); - GL11.glTranslatef(0.0F, -1.1F, 0.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "Chargepad.png")); - chargepad.render(0.0625F, mc.renderEngine); - } - else if(type == MachineType.LOGISTICAL_SORTER) - { - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F); - GL11.glTranslatef(0.0F, -1.0F, 0.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "LogisticalSorter.png")); - logisticalSorter.render(0.0625F, false); - } - else if(type == MachineType.DIGITAL_MINER) - { - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(-180F, 0.0F, 1.0F, 0.0F); - GL11.glTranslatef(0.35F, 0.1F, 0.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "DigitalMiner.png")); - digitalMiner.render(0.022F, false, mc.renderEngine); - } - else if(type == MachineType.ROTARY_CONDENSENTRATOR) - { - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(180F, 0.0F, -1.0F, 0.0F); - GL11.glTranslatef(0.05F, -0.96F, 0.05F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "RotaryCondensentrator.png")); - rotaryCondensentrator.render(0.0625F); - } - else if(type == MachineType.CHEMICAL_OXIDIZER) - { - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F); - GL11.glTranslatef(0.0F, -1.00F, 0.05F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ChemicalOxidizer.png")); - chemicalOxidizer.render(0.0625F); - } - else if(type == MachineType.CHEMICAL_INFUSER) - { - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(180f, 0.0F, 1.0F, 0.0F); - GL11.glTranslatef(0.0F, -0.96F, 0.05F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ChemicalInfuser.png")); - chemicalInfuser.render(0.0625F); - } - else if(type == MachineType.ELECTROLYTIC_SEPARATOR) - { - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(-90F, 0.0F, 1.0F, 0.0F); - GL11.glTranslated(0.0F, -1.0F, 0.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ElectrolyticSeparator.png")); - electrolyticSeparator.render(0.0625F); - } - else if(type == MachineType.CHEMICAL_DISSOLUTION_CHAMBER) - { - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(180F, 0.0F, -1.0F, 0.0F); - GL11.glTranslatef(0.05F, -0.96F, 0.05F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ChemicalDissolutionChamber.png")); - chemicalDissolutionChamber.render(0.0625F); - } - else if(type == MachineType.CHEMICAL_WASHER) - { - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(180F, 0.0F, -1.0F, 0.0F); - GL11.glTranslatef(0.05F, -0.96F, 0.05F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ChemicalWasher.png")); - chemicalWasher.render(0.0625F); - } - else if(type == MachineType.CHEMICAL_CRYSTALLIZER) - { - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(180F, 0.0F, -1.0F, 0.0F); - GL11.glTranslatef(0.05F, -0.96F, 0.05F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ChemicalCrystallizer.png")); - chemicalCrystallizer.render(0.0625F); - } - else if(type == MachineType.SEISMIC_VIBRATOR) - { - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(180F, 0.0F, -1.0F, 0.0F); - GL11.glScalef(0.6F, 0.6F, 0.6F); - GL11.glTranslatef(0.0F, -0.55F, 0.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "SeismicVibrator.png")); - seismicVibrator.render(0.0625F); - } - else if(type == MachineType.PRESSURIZED_REACTION_CHAMBER) - { - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(180F, 0.0F, -1.0F, 0.0F); - GL11.glTranslatef(0.05F, -0.96F, 0.05F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "PressurizedReactionChamber.png")); - pressurizedReactionChamber.render(0.0625F); - } - else if(type == MachineType.FLUIDIC_PLENISHER) - { - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(180F, 0.0F, -1.0F, 0.0F); - GL11.glTranslatef(0.0F, -0.85F, 0.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "FluidicPlenisher.png")); - fluidicPlenisher.render(0.0560F); - } - else if(type == MachineType.LASER) - { - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(90F, 0.0F, -1.0F, 0.0F); - GL11.glTranslatef(0.0F, -0.85F, 0.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "Laser.png")); - laser.render(0.0560F); - } - else if(type == MachineType.LASER_AMPLIFIER) - { - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(90F, 0.0F, -1.0F, 0.0F); - GL11.glTranslatef(0.0F, -0.85F, 0.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "LaserAmplifier.png")); - laserAmplifier.render(0.0560F); - } - else if(type == MachineType.LASER_TRACTOR_BEAM) - { - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(90F, 0.0F, -1.0F, 0.0F); - GL11.glTranslatef(0.0F, -0.85F, 0.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "LaserTractorBeam.png")); - laserAmplifier.render(0.0560F); - } - else if(type == MachineType.RESISTIVE_HEATER) - { - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(180F, 0.0F, -1.0F, 0.0F); - GL11.glTranslatef(0.05F, -0.96F, 0.05F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ResistiveHeater.png")); - resistiveHeater.render(0.0625F, false, mc.renderEngine); - } - else if(type == MachineType.SOLAR_NEUTRON_ACTIVATOR) - { - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F); - GL11.glScalef(0.6F, 0.6F, 0.6F); - GL11.glTranslatef(0.0F, -0.55F, 0.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "SolarNeutronActivator.png")); - solarNeutronActivator.render(0.0625F); - } - else if(type == MachineType.QUANTUM_ENTANGLOPORTER) - { - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(180F, 0.0F, -1.0F, 0.0F); - GL11.glTranslatef(0.0F, -1.0F, 0.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "QuantumEntangloporter.png")); - quantumEntangloporter.render(0.0625F, mc.renderEngine); - } - else if (type == MachineType.THEORETICAL_ELEMENTIZER) { - GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); + MachineType type = MachineType.get(block, metadata); + + if (type == MachineType.ELECTRIC_PUMP) { + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glTranslatef(0.0F, -0.85F, 0.0F); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "ElectricPump.png") + ); + electricPump.render(0.0560F); + } else if (type == MachineType.METALLURGIC_INFUSER) { + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(180F, 0.0F, -1.0F, 0.0F); + GL11.glTranslatef(0.0F, -1.0F, 0.0F); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "MetallurgicInfuser.png") + ); + metallurgicInfuser.render(0.0625F); + } else if (type == MachineType.CHARGEPAD) { + GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F); + GL11.glTranslatef(0.0F, -1.1F, 0.0F); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "Chargepad.png") + ); + chargepad.render(0.0625F, mc.renderEngine); + } else if (type == MachineType.LOGISTICAL_SORTER) { + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(0.0F, -1.0F, 0.0F); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "LogisticalSorter.png") + ); + logisticalSorter.render(0.0625F, false); + } else if (type == MachineType.DIGITAL_MINER) { + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(-180F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(0.35F, 0.1F, 0.0F); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "DigitalMiner.png") + ); + digitalMiner.render(0.022F, false, mc.renderEngine); + } else if (type == MachineType.ROTARY_CONDENSENTRATOR) { + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(180F, 0.0F, -1.0F, 0.0F); + GL11.glTranslatef(0.05F, -0.96F, 0.05F); + mc.renderEngine.bindTexture(MekanismUtils.getResource( + ResourceType.RENDER, "RotaryCondensentrator.png" + )); + rotaryCondensentrator.render(0.0625F); + } else if (type == MachineType.CHEMICAL_OXIDIZER) { + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(0.0F, -1.00F, 0.05F); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "ChemicalOxidizer.png") + ); + chemicalOxidizer.render(0.0625F); + } else if (type == MachineType.CHEMICAL_INFUSER) { + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(180f, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(0.0F, -0.96F, 0.05F); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "ChemicalInfuser.png") + ); + chemicalInfuser.render(0.0625F); + } else if (type == MachineType.ELECTROLYTIC_SEPARATOR) { + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(-90F, 0.0F, 1.0F, 0.0F); + GL11.glTranslated(0.0F, -1.0F, 0.0F); + mc.renderEngine.bindTexture(MekanismUtils.getResource( + ResourceType.RENDER, "ElectrolyticSeparator.png" + )); + electrolyticSeparator.render(0.0625F); + } else if (type == MachineType.CHEMICAL_DISSOLUTION_CHAMBER) { + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(180F, 0.0F, -1.0F, 0.0F); + GL11.glTranslatef(0.05F, -0.96F, 0.05F); + mc.renderEngine.bindTexture(MekanismUtils.getResource( + ResourceType.RENDER, "ChemicalDissolutionChamber.png" + )); + chemicalDissolutionChamber.render(0.0625F); + } else if (type == MachineType.CHEMICAL_WASHER) { + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(180F, 0.0F, -1.0F, 0.0F); + GL11.glTranslatef(0.05F, -0.96F, 0.05F); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "ChemicalWasher.png") + ); + chemicalWasher.render(0.0625F); + } else if (type == MachineType.CHEMICAL_CRYSTALLIZER) { + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(180F, 0.0F, -1.0F, 0.0F); + GL11.glTranslatef(0.05F, -0.96F, 0.05F); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "ChemicalCrystallizer.png") + ); + chemicalCrystallizer.render(0.0625F); + } else if (type == MachineType.SEISMIC_VIBRATOR) { + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(180F, 0.0F, -1.0F, 0.0F); + GL11.glScalef(0.6F, 0.6F, 0.6F); + GL11.glTranslatef(0.0F, -0.55F, 0.0F); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "SeismicVibrator.png") + ); + seismicVibrator.render(0.0625F); + } else if (type == MachineType.PRESSURIZED_REACTION_CHAMBER) { + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(180F, 0.0F, -1.0F, 0.0F); + GL11.glTranslatef(0.05F, -0.96F, 0.05F); + mc.renderEngine.bindTexture(MekanismUtils.getResource( + ResourceType.RENDER, "PressurizedReactionChamber.png" + )); + pressurizedReactionChamber.render(0.0625F); + } else if (type == MachineType.FLUIDIC_PLENISHER) { + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(180F, 0.0F, -1.0F, 0.0F); + GL11.glTranslatef(0.0F, -0.85F, 0.0F); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "FluidicPlenisher.png") + ); + fluidicPlenisher.render(0.0560F); + } else if (type == MachineType.LASER) { + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(90F, 0.0F, -1.0F, 0.0F); + GL11.glTranslatef(0.0F, -0.85F, 0.0F); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "Laser.png") + ); + laser.render(0.0560F); + } else if (type == MachineType.LASER_AMPLIFIER) { + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(90F, 0.0F, -1.0F, 0.0F); + GL11.glTranslatef(0.0F, -0.85F, 0.0F); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "LaserAmplifier.png") + ); + laserAmplifier.render(0.0560F); + } else if (type == MachineType.LASER_TRACTOR_BEAM) { + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(90F, 0.0F, -1.0F, 0.0F); + GL11.glTranslatef(0.0F, -0.85F, 0.0F); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "LaserTractorBeam.png") + ); + laserAmplifier.render(0.0560F); + } else if (type == MachineType.RESISTIVE_HEATER) { + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(180F, 0.0F, -1.0F, 0.0F); + GL11.glTranslatef(0.05F, -0.96F, 0.05F); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "ResistiveHeater.png") + ); + resistiveHeater.render(0.0625F, false, mc.renderEngine); + } else if (type == MachineType.SOLAR_NEUTRON_ACTIVATOR) { + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F); + GL11.glScalef(0.6F, 0.6F, 0.6F); + GL11.glTranslatef(0.0F, -0.55F, 0.0F); + mc.renderEngine.bindTexture(MekanismUtils.getResource( + ResourceType.RENDER, "SolarNeutronActivator.png" + )); + solarNeutronActivator.render(0.0625F); + } else if (type == MachineType.QUANTUM_ENTANGLOPORTER) { + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(180F, 0.0F, -1.0F, 0.0F); + GL11.glTranslatef(0.0F, -1.0F, 0.0F); + mc.renderEngine.bindTexture(MekanismUtils.getResource( + ResourceType.RENDER, "QuantumEntangloporter.png" + )); + quantumEntangloporter.render(0.0625F, mc.renderEngine); + } else if (type == MachineType.THEORETICAL_ELEMENTIZER) { + GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); GL11.glRotatef(180.0F, 0.0F, -1.0F, 0.0F); GL11.glTranslatef(0.0F, -1.0F, 0.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "TheoreticalElementizer.png")); - theoreticalElementizer.render(0.0625F); - } - else { - GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F); - MekanismRenderer.renderItem(renderer, metadata, block); - } + mc.renderEngine.bindTexture(MekanismUtils.getResource( + ResourceType.RENDER, "TheoreticalElementizer.png" + )); + theoreticalElementizer.render(0.0625F); + } else { + GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F); + MekanismRenderer.renderItem(renderer, metadata, block); + } - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) - { - //Handled by CTMRenderingHandler - return false; - } + @Override + public boolean renderWorldBlock( + IBlockAccess world, + int x, + int y, + int z, + Block block, + int modelId, + RenderBlocks renderer + ) { + //Handled by CTMRenderingHandler + return false; + } - @Override - public boolean shouldRender3DInInventory(int modelId) - { - return true; - } + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } - @Override - public int getRenderId() - { - return ClientProxy.MACHINE_RENDER_ID; - } + @Override + public int getRenderId() { + return ClientProxy.MACHINE_RENDER_ID; + } } diff --git a/src/main/java/mekanism/client/render/block/PlasticRenderingHandler.java b/src/main/java/mekanism/client/render/block/PlasticRenderingHandler.java index 7a4131901..64286e974 100644 --- a/src/main/java/mekanism/client/render/block/PlasticRenderingHandler.java +++ b/src/main/java/mekanism/client/render/block/PlasticRenderingHandler.java @@ -1,5 +1,8 @@ package mekanism.client.render.block; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.ClientProxy; import mekanism.client.render.MekanismRenderer; import mekanism.common.MekanismBlocks; @@ -7,90 +10,125 @@ import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.world.IBlockAccess; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class PlasticRenderingHandler implements ISimpleBlockRenderingHandler -{ - @Override - public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) - { - MekanismRenderer.renderItem(renderer, metadata, block); - } +public class PlasticRenderingHandler implements ISimpleBlockRenderingHandler { + @Override + public void + renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { + MekanismRenderer.renderItem(renderer, metadata, block); + } - @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) - { - boolean flag = false; - - if(block == MekanismBlocks.GlowPlasticBlock) - { - Tessellator tessellator = Tessellator.instance; - tessellator.setBrightness(240); - int meta = world.getBlockMetadata(x, y, z); - int l = block.getRenderColor(meta); - int r = l >> 16 & 0xFF; - int g = l >> 8 & 0xFF; - int b = l & 0xFF; - tessellator.setColorOpaque(r, g, b); + @Override + public boolean renderWorldBlock( + IBlockAccess world, + int x, + int y, + int z, + Block block, + int modelId, + RenderBlocks renderer + ) { + boolean flag = false; - if((renderer.renderAllFaces) || (block.shouldSideBeRendered(renderer.blockAccess, x, y - 1, z, 0))) - { - renderer.renderFaceYNeg(block, x, y, z, renderer.getBlockIcon(block, renderer.blockAccess, x, y, z, 0)); - flag = true; - } + if (block == MekanismBlocks.GlowPlasticBlock) { + Tessellator tessellator = Tessellator.instance; + tessellator.setBrightness(240); + int meta = world.getBlockMetadata(x, y, z); + int l = block.getRenderColor(meta); + int r = l >> 16 & 0xFF; + int g = l >> 8 & 0xFF; + int b = l & 0xFF; + tessellator.setColorOpaque(r, g, b); - if((renderer.renderAllFaces) || (block.shouldSideBeRendered(renderer.blockAccess, x, y + 1, z, 1))) - { - renderer.renderFaceYPos(block, x, y, z, renderer.getBlockIcon(block, renderer.blockAccess, x, y, z, 1)); - flag = true; - } + if ((renderer.renderAllFaces) + || (block.shouldSideBeRendered(renderer.blockAccess, x, y - 1, z, 0))) { + renderer.renderFaceYNeg( + block, + x, + y, + z, + renderer.getBlockIcon(block, renderer.blockAccess, x, y, z, 0) + ); + flag = true; + } - if((renderer.renderAllFaces) || (block.shouldSideBeRendered(renderer.blockAccess, x, y, z - 1, 2))) - { - renderer.renderFaceZNeg(block, x, y, z, renderer.getBlockIcon(block, renderer.blockAccess, x, y, z, 2)); - flag = true; - } + if ((renderer.renderAllFaces) + || (block.shouldSideBeRendered(renderer.blockAccess, x, y + 1, z, 1))) { + renderer.renderFaceYPos( + block, + x, + y, + z, + renderer.getBlockIcon(block, renderer.blockAccess, x, y, z, 1) + ); + flag = true; + } - if((renderer.renderAllFaces) || (block.shouldSideBeRendered(renderer.blockAccess, x, y, z + 1, 3))) - { - renderer.renderFaceZPos(block, x, y, z, renderer.getBlockIcon(block, renderer.blockAccess, x, y, z, 3)); - flag = true; - } + if ((renderer.renderAllFaces) + || (block.shouldSideBeRendered(renderer.blockAccess, x, y, z - 1, 2))) { + renderer.renderFaceZNeg( + block, + x, + y, + z, + renderer.getBlockIcon(block, renderer.blockAccess, x, y, z, 2) + ); + flag = true; + } - if((renderer.renderAllFaces) || (block.shouldSideBeRendered(renderer.blockAccess, x - 1, y, z, 4))) - { - renderer.renderFaceXNeg(block, x, y, z, renderer.getBlockIcon(block, renderer.blockAccess, x, y, z, 4)); - flag = true; - } + if ((renderer.renderAllFaces) + || (block.shouldSideBeRendered(renderer.blockAccess, x, y, z + 1, 3))) { + renderer.renderFaceZPos( + block, + x, + y, + z, + renderer.getBlockIcon(block, renderer.blockAccess, x, y, z, 3) + ); + flag = true; + } - if((renderer.renderAllFaces) || (block.shouldSideBeRendered(renderer.blockAccess, x + 1, y, z, 5))) - { - renderer.renderFaceXPos(block, x, y, z, renderer.getBlockIcon(block, renderer.blockAccess, x, y, z, 5)); - flag = true; - } + if ((renderer.renderAllFaces) + || (block.shouldSideBeRendered(renderer.blockAccess, x - 1, y, z, 4))) { + renderer.renderFaceXNeg( + block, + x, + y, + z, + renderer.getBlockIcon(block, renderer.blockAccess, x, y, z, 4) + ); + flag = true; + } - return flag; - } - - flag = renderer.renderStandardBlock(block, x, y, z); - renderer.setRenderBoundsFromBlock(block); - - return flag; + if ((renderer.renderAllFaces) + || (block.shouldSideBeRendered(renderer.blockAccess, x + 1, y, z, 5))) { + renderer.renderFaceXPos( + block, + x, + y, + z, + renderer.getBlockIcon(block, renderer.blockAccess, x, y, z, 5) + ); + flag = true; + } - } + return flag; + } - @Override - public int getRenderId() - { - return ClientProxy.PLASTIC_RENDER_ID; - } + flag = renderer.renderStandardBlock(block, x, y, z); + renderer.setRenderBoundsFromBlock(block); - @Override - public boolean shouldRender3DInInventory(int modelId) - { - return true; - } + return flag; + } + + @Override + public int getRenderId() { + return ClientProxy.PLASTIC_RENDER_ID; + } + + @Override + public boolean shouldRender3DInInventory(int modelId) { + return true; + } } diff --git a/src/main/java/mekanism/client/render/block/RenderBlocksCTM.java b/src/main/java/mekanism/client/render/block/RenderBlocksCTM.java index 871ff161e..fc7d92e0a 100644 --- a/src/main/java/mekanism/client/render/block/RenderBlocksCTM.java +++ b/src/main/java/mekanism/client/render/block/RenderBlocksCTM.java @@ -12,371 +12,401 @@ import net.minecraft.util.IIcon; * Code licensed under GPLv2 * @author AUTOMATIC_MAIDEN, asie, pokefenn, unpairedbracket */ -public class RenderBlocksCTM extends RenderBlocks -{ - RenderBlocksCTM() - { - super(); - - resetVertices(); - } - - Tessellator tessellator; - double[] X = new double[26]; - double[] Y = new double[26]; - double[] Z = new double[26]; - double[] U = new double[26]; - double[] V = new double[26]; - int[] L = new int[26]; - float[] R = new float[26]; - float[] G = new float[26]; - float[] B = new float[26]; - CTMData dataCTM; - RenderBlocks rendererOld; - - int bx, by, bz; - - @Override - public boolean renderStandardBlock(Block block, int x, int y, int z) - { - bx = x; - by = y; - bz = z; - - tessellator = Tessellator.instance; - tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F); - - tessellator.addTranslation(x, y, z); - - boolean res = super.renderStandardBlock(block, x, y, z); - - tessellator.addTranslation(-x, -y, -z); - - return res; - } - - void setupSides(int a, int b, int c, int d, int xa, int xb, int xc, int xd, int e) - { - L[a] = brightnessBottomLeft; - L[b] = brightnessBottomRight; - L[c] = brightnessTopRight; - L[d] = brightnessTopLeft; - L[e] = (brightnessBottomLeft + brightnessTopLeft + brightnessTopRight + brightnessBottomRight) / 4; - L[xa] = (L[a] + L[b]) / 2; - L[xb] = (L[b] + L[c]) / 2; - L[xc] = (L[c] + L[d]) / 2; - L[xd] = (L[d] + L[a]) / 2; - - R[a] = colorRedBottomLeft; - R[b] = colorRedBottomRight; - R[c] = colorRedTopRight; - R[d] = colorRedTopLeft; - R[e] = (colorRedBottomLeft + colorRedTopLeft + colorRedTopRight + colorRedBottomRight) / 4; - R[xa] = (R[a] + R[b]) / 2; - R[xb] = (R[b] + R[c]) / 2; - R[xc] = (R[c] + R[d]) / 2; - R[xd] = (R[d] + R[a]) / 2; - - G[a] = colorGreenBottomLeft; - G[b] = colorGreenBottomRight; - G[c] = colorGreenTopRight; - G[d] = colorGreenTopLeft; - G[e] = (colorGreenBottomLeft + colorGreenTopLeft + colorGreenTopRight + colorGreenBottomRight) / 4; - G[xa] = (G[a] + G[b]) / 2; - G[xb] = (G[b] + G[c]) / 2; - G[xc] = (G[c] + G[d]) / 2; - G[xd] = (G[d] + G[a]) / 2; - - B[a] = colorBlueBottomLeft; - B[b] = colorBlueBottomRight; - B[c] = colorBlueTopRight; - B[d] = colorBlueTopLeft; - B[e] = (colorBlueBottomLeft + colorBlueTopLeft + colorBlueTopRight + colorBlueBottomRight) / 4; - B[xa] = (B[a] + B[b]) / 2; - B[xb] = (B[b] + B[c]) / 2; - B[xc] = (B[c] + B[d]) / 2; - B[xd] = (B[d] + B[a]) / 2; - } - - void side(int a, int b, int c, int d, int iconIndex, boolean flip, int side) - { - IIcon icon = iconIndex >= 16 ? dataCTM.getSmallSubmap(side).icons[iconIndex - 16] : dataCTM.getSubmap(side).icons[iconIndex]; - - double u0 = icon.getMaxU(); - double u1 = icon.getMinU(); - double v0 = icon.getMaxV(); - double v1 = icon.getMinV(); - - U[a] = flip ? u1 : u1; - U[b] = flip ? u0 : u1; - U[c] = flip ? u0 : u0; - U[d] = flip ? u1 : u0; - - V[a] = flip ? v1 : v1; - V[b] = flip ? v1 : v0; - V[c] = flip ? v0 : v0; - V[d] = flip ? v0 : v1; - - vert(a); - vert(b); - vert(c); - vert(d); - } - - void vert(int index) - { - if(enableAO) - { - tessellator.setColorOpaque_F(R[index], G[index], B[index]); - tessellator.setBrightness(L[index]); - } - - tessellator.addVertexWithUV(X[index], Y[index], Z[index], U[index], V[index]); - } - - @Override - public void renderFaceXNeg(Block block, double x, double y, double z, IIcon icon) - { - if(rendererOld != null && rendererOld.hasOverrideBlockTexture()) - { - IIcon i = rendererOld.overrideBlockTexture; - - tessellator.addVertexWithUV(0.0, 1.0, 0.0, i.getMinU(), i.getMinV()); - tessellator.addVertexWithUV(0.0, 0.0, 0.0, i.getMinU(), i.getMaxV()); - tessellator.addVertexWithUV(0.0, 0.0, 1.0, i.getMaxU(), i.getMaxV()); - tessellator.addVertexWithUV(0.0, 1.0, 1.0, i.getMaxU(), i.getMinV()); - } - else { - int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 4, dataCTM.acceptableBlockMetas, dataCTM.renderConvexConnections); - - setupSides(1, 0, 4, 5, 14, 19, 17, 23, 9); - side(1, 14, 9, 23, tex[0], false, 4); - side(23, 9, 17, 5, tex[1], false, 4); - side(9, 19, 4, 17, tex[3], false, 4); - side(14, 0, 19, 9, tex[2], false, 4); - } - } - - @Override - public void renderFaceXPos(Block block, double x, double y, double z, IIcon icon) - { - if(rendererOld != null && rendererOld.hasOverrideBlockTexture()) - { - IIcon i = rendererOld.overrideBlockTexture; - - tessellator.addVertexWithUV(1.0, 1.0, 1.0, i.getMaxU(), i.getMinV()); - tessellator.addVertexWithUV(1.0, 0.0, 1.0, i.getMaxU(), i.getMaxV()); - tessellator.addVertexWithUV(1.0, 0.0, 0.0, i.getMinU(), i.getMaxV()); - tessellator.addVertexWithUV(1.0, 1.0, 0.0, i.getMinU(), i.getMinV()); - } - else { - int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 5, dataCTM.acceptableBlockMetas, dataCTM.renderConvexConnections); - - setupSides(3, 2, 6, 7, 15, 25, 16, 21, 11); - side(11, 21, 3, 15, tex[3], false, 5); - side(16, 7, 21, 11, tex[2], false, 5); - side(25, 11, 15, 2, tex[1], false, 5); - side(6, 16, 11, 25, tex[0], false, 5); - } - } - - @Override - public void renderFaceZNeg(Block block, double x, double y, double z, IIcon icon) - { - if(rendererOld != null && rendererOld.hasOverrideBlockTexture()) - { - IIcon i = rendererOld.overrideBlockTexture; - - tessellator.addVertexWithUV(1.0, 1.0, 0.0, i.getMaxU(), i.getMinV()); - tessellator.addVertexWithUV(1.0, 0.0, 0.0, i.getMaxU(), i.getMaxV()); - tessellator.addVertexWithUV(0.0, 0.0, 0.0, i.getMinU(), i.getMaxV()); - tessellator.addVertexWithUV(0.0, 1.0, 0.0, i.getMinU(), i.getMinV()); - } - else { - int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 2, dataCTM.acceptableBlockMetas, dataCTM.renderConvexConnections); - - setupSides(2, 3, 0, 1, 15, 18, 14, 22, 8); - side(2, 15, 8, 22, tex[0], false, 2); - side(15, 3, 18, 8, tex[2], false, 2); - side(8, 18, 0, 14, tex[3], false, 2); - side(22, 8, 14, 1, tex[1], false, 2); - } - } - - - @Override - public void renderFaceZPos(Block block, double x, double y, double z, IIcon icon) - { - if(rendererOld != null && rendererOld.hasOverrideBlockTexture()) - { - IIcon i = rendererOld.overrideBlockTexture; - - tessellator.addVertexWithUV(0.0, 1.0, 1.0, i.getMinU(), i.getMinV()); - tessellator.addVertexWithUV(0.0, 0.0, 1.0, i.getMinU(), i.getMaxV()); - tessellator.addVertexWithUV(1.0, 0.0, 1.0, i.getMaxU(), i.getMaxV()); - tessellator.addVertexWithUV(1.0, 1.0, 1.0, i.getMaxU(), i.getMinV()); - } - else { - int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 3, dataCTM.acceptableBlockMetas, dataCTM.renderConvexConnections); - - setupSides(4, 7, 6, 5, 20, 16, 24, 17, 10); - side(17, 4, 20, 10, tex[2], false, 3); - side(5, 17, 10, 24, tex[0], false, 3); - side(24, 10, 16, 6, tex[1], false, 3); - side(10, 20, 7, 16, tex[3], false, 3); - } - } - - @Override - public void renderFaceYNeg(Block block, double x, double y, double z, IIcon icon) - { - if(rendererOld != null && rendererOld.hasOverrideBlockTexture()) - { - IIcon i = rendererOld.overrideBlockTexture; - - tessellator.addVertexWithUV(0.0, 0.0, 1.0, i.getMinU(), i.getMaxV()); - tessellator.addVertexWithUV(0.0, 0.0, 0.0, i.getMinU(), i.getMinV()); - tessellator.addVertexWithUV(1.0, 0.0, 0.0, i.getMaxU(), i.getMinV()); - tessellator.addVertexWithUV(1.0, 0.0, 1.0, i.getMaxU(), i.getMaxV()); - } - else { - int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 0, dataCTM.acceptableBlockMetas, dataCTM.renderConvexConnections); - - setupSides(0, 3, 7, 4, 18, 21, 20, 19, 13); - side(13, 21, 7, 20, tex[3], true, 0); - side(19, 13, 20, 4, tex[2], true, 0); - side(0, 18, 13, 19, tex[0], true, 0); - side(18, 3, 21, 13, tex[1], true, 0); - } - } - - @Override - public void renderFaceYPos(Block block, double x, double y, double z, IIcon icon) - { - if(rendererOld != null && rendererOld.hasOverrideBlockTexture()) - { - IIcon i = rendererOld.overrideBlockTexture; - - tessellator.addVertexWithUV(0.0, 1.0, 0.0, i.getMinU(), i.getMinV()); - tessellator.addVertexWithUV(0.0, 1.0, 1.0, i.getMinU(), i.getMaxV()); - tessellator.addVertexWithUV(1.0, 1.0, 1.0, i.getMaxU(), i.getMaxV()); - tessellator.addVertexWithUV(1.0, 1.0, 0.0, i.getMaxU(), i.getMinV()); - } - else { - int tex[] = CTM.getSubmapIndices(blockAccess, bx, by, bz, 1, dataCTM.acceptableBlockMetas, dataCTM.renderConvexConnections); - - setupSides(2, 1, 5, 6, 22, 23, 24, 25, 12); - side(12, 24, 6, 25, tex[3], false, 1); - side(22, 12, 25, 2, tex[1], false, 1); - side(1, 23, 12, 22, tex[0], false, 1); - side(23, 5, 24, 12, tex[2], false, 1); - } - } - - void resetVertices() - { - X[0] = 0; - Z[0] = 0; - Y[0] = 0; - - X[1] = 0; - Z[1] = 0; - Y[1] = 1; - - X[2] = 1; - Z[2] = 0; - Y[2] = 1; - - X[3] = 1; - Z[3] = 0; - Y[3] = 0; - - X[4] = 0; - Z[4] = 1; - Y[4] = 0; - - X[5] = 0; - Z[5] = 1; - Y[5] = 1; - - X[6] = 1; - Z[6] = 1; - Y[6] = 1; - - X[7] = 1; - Z[7] = 1; - Y[7] = 0; - - X[8] = 0.5; - Z[8] = 0; - Y[8] = 0.5; - - X[9] = 0; - Z[9] = 0.5; - Y[9] = 0.5; - - X[10] = 0.5; - Z[10] = 1; - Y[10] = 0.5; - - X[11] = 1; - Z[11] = 0.5; - Y[11] = 0.5; - - X[12] = 0.5; - Z[12] = 0.5; - Y[12] = 1; - - X[13] = 0.5; - Z[13] = 0.5; - Y[13] = 0; - - X[14] = 0; - Z[14] = 0; - Y[14] = 0.5; - - X[15] = 1; - Z[15] = 0; - Y[15] = 0.5; - - X[16] = 1; - Z[16] = 1; - Y[16] = 0.5; - - X[17] = 0; - Z[17] = 1; - Y[17] = 0.5; - - X[18] = 0.5; - Z[18] = 0; - Y[18] = 0; - - X[19] = 0; - Z[19] = 0.5; - Y[19] = 0; - - X[20] = 0.5; - Z[20] = 1; - Y[20] = 0; - - X[21] = 1; - Z[21] = 0.5; - Y[21] = 0; - - X[22] = 0.5; - Z[22] = 0; - Y[22] = 1; - - X[23] = 0; - Z[23] = 0.5; - Y[23] = 1; - - X[24] = 0.5; - Z[24] = 1; - Y[24] = 1; - - X[25] = 1; - Z[25] = 0.5; - Y[25] = 1; - } +public class RenderBlocksCTM extends RenderBlocks { + RenderBlocksCTM() { + super(); + + resetVertices(); + } + + Tessellator tessellator; + double[] X = new double[26]; + double[] Y = new double[26]; + double[] Z = new double[26]; + double[] U = new double[26]; + double[] V = new double[26]; + int[] L = new int[26]; + float[] R = new float[26]; + float[] G = new float[26]; + float[] B = new float[26]; + CTMData dataCTM; + RenderBlocks rendererOld; + + int bx, by, bz; + + @Override + public boolean renderStandardBlock(Block block, int x, int y, int z) { + bx = x; + by = y; + bz = z; + + tessellator = Tessellator.instance; + tessellator.setColorOpaque_F(1.0F, 1.0F, 1.0F); + + tessellator.addTranslation(x, y, z); + + boolean res = super.renderStandardBlock(block, x, y, z); + + tessellator.addTranslation(-x, -y, -z); + + return res; + } + + void setupSides(int a, int b, int c, int d, int xa, int xb, int xc, int xd, int e) { + L[a] = brightnessBottomLeft; + L[b] = brightnessBottomRight; + L[c] = brightnessTopRight; + L[d] = brightnessTopLeft; + L[e] = (brightnessBottomLeft + brightnessTopLeft + brightnessTopRight + + brightnessBottomRight) + / 4; + L[xa] = (L[a] + L[b]) / 2; + L[xb] = (L[b] + L[c]) / 2; + L[xc] = (L[c] + L[d]) / 2; + L[xd] = (L[d] + L[a]) / 2; + + R[a] = colorRedBottomLeft; + R[b] = colorRedBottomRight; + R[c] = colorRedTopRight; + R[d] = colorRedTopLeft; + R[e] = (colorRedBottomLeft + colorRedTopLeft + colorRedTopRight + + colorRedBottomRight) + / 4; + R[xa] = (R[a] + R[b]) / 2; + R[xb] = (R[b] + R[c]) / 2; + R[xc] = (R[c] + R[d]) / 2; + R[xd] = (R[d] + R[a]) / 2; + + G[a] = colorGreenBottomLeft; + G[b] = colorGreenBottomRight; + G[c] = colorGreenTopRight; + G[d] = colorGreenTopLeft; + G[e] = (colorGreenBottomLeft + colorGreenTopLeft + colorGreenTopRight + + colorGreenBottomRight) + / 4; + G[xa] = (G[a] + G[b]) / 2; + G[xb] = (G[b] + G[c]) / 2; + G[xc] = (G[c] + G[d]) / 2; + G[xd] = (G[d] + G[a]) / 2; + + B[a] = colorBlueBottomLeft; + B[b] = colorBlueBottomRight; + B[c] = colorBlueTopRight; + B[d] = colorBlueTopLeft; + B[e] = (colorBlueBottomLeft + colorBlueTopLeft + colorBlueTopRight + + colorBlueBottomRight) + / 4; + B[xa] = (B[a] + B[b]) / 2; + B[xb] = (B[b] + B[c]) / 2; + B[xc] = (B[c] + B[d]) / 2; + B[xd] = (B[d] + B[a]) / 2; + } + + void side(int a, int b, int c, int d, int iconIndex, boolean flip, int side) { + IIcon icon = iconIndex >= 16 ? dataCTM.getSmallSubmap(side).icons[iconIndex - 16] + : dataCTM.getSubmap(side).icons[iconIndex]; + + double u0 = icon.getMaxU(); + double u1 = icon.getMinU(); + double v0 = icon.getMaxV(); + double v1 = icon.getMinV(); + + U[a] = flip ? u1 : u1; + U[b] = flip ? u0 : u1; + U[c] = flip ? u0 : u0; + U[d] = flip ? u1 : u0; + + V[a] = flip ? v1 : v1; + V[b] = flip ? v1 : v0; + V[c] = flip ? v0 : v0; + V[d] = flip ? v0 : v1; + + vert(a); + vert(b); + vert(c); + vert(d); + } + + void vert(int index) { + if (enableAO) { + tessellator.setColorOpaque_F(R[index], G[index], B[index]); + tessellator.setBrightness(L[index]); + } + + tessellator.addVertexWithUV(X[index], Y[index], Z[index], U[index], V[index]); + } + + @Override + public void renderFaceXNeg(Block block, double x, double y, double z, IIcon icon) { + if (rendererOld != null && rendererOld.hasOverrideBlockTexture()) { + IIcon i = rendererOld.overrideBlockTexture; + + tessellator.addVertexWithUV(0.0, 1.0, 0.0, i.getMinU(), i.getMinV()); + tessellator.addVertexWithUV(0.0, 0.0, 0.0, i.getMinU(), i.getMaxV()); + tessellator.addVertexWithUV(0.0, 0.0, 1.0, i.getMaxU(), i.getMaxV()); + tessellator.addVertexWithUV(0.0, 1.0, 1.0, i.getMaxU(), i.getMinV()); + } else { + int tex[] = CTM.getSubmapIndices( + blockAccess, + bx, + by, + bz, + 4, + dataCTM.acceptableBlockMetas, + dataCTM.renderConvexConnections + ); + + setupSides(1, 0, 4, 5, 14, 19, 17, 23, 9); + side(1, 14, 9, 23, tex[0], false, 4); + side(23, 9, 17, 5, tex[1], false, 4); + side(9, 19, 4, 17, tex[3], false, 4); + side(14, 0, 19, 9, tex[2], false, 4); + } + } + + @Override + public void renderFaceXPos(Block block, double x, double y, double z, IIcon icon) { + if (rendererOld != null && rendererOld.hasOverrideBlockTexture()) { + IIcon i = rendererOld.overrideBlockTexture; + + tessellator.addVertexWithUV(1.0, 1.0, 1.0, i.getMaxU(), i.getMinV()); + tessellator.addVertexWithUV(1.0, 0.0, 1.0, i.getMaxU(), i.getMaxV()); + tessellator.addVertexWithUV(1.0, 0.0, 0.0, i.getMinU(), i.getMaxV()); + tessellator.addVertexWithUV(1.0, 1.0, 0.0, i.getMinU(), i.getMinV()); + } else { + int tex[] = CTM.getSubmapIndices( + blockAccess, + bx, + by, + bz, + 5, + dataCTM.acceptableBlockMetas, + dataCTM.renderConvexConnections + ); + + setupSides(3, 2, 6, 7, 15, 25, 16, 21, 11); + side(11, 21, 3, 15, tex[3], false, 5); + side(16, 7, 21, 11, tex[2], false, 5); + side(25, 11, 15, 2, tex[1], false, 5); + side(6, 16, 11, 25, tex[0], false, 5); + } + } + + @Override + public void renderFaceZNeg(Block block, double x, double y, double z, IIcon icon) { + if (rendererOld != null && rendererOld.hasOverrideBlockTexture()) { + IIcon i = rendererOld.overrideBlockTexture; + + tessellator.addVertexWithUV(1.0, 1.0, 0.0, i.getMaxU(), i.getMinV()); + tessellator.addVertexWithUV(1.0, 0.0, 0.0, i.getMaxU(), i.getMaxV()); + tessellator.addVertexWithUV(0.0, 0.0, 0.0, i.getMinU(), i.getMaxV()); + tessellator.addVertexWithUV(0.0, 1.0, 0.0, i.getMinU(), i.getMinV()); + } else { + int tex[] = CTM.getSubmapIndices( + blockAccess, + bx, + by, + bz, + 2, + dataCTM.acceptableBlockMetas, + dataCTM.renderConvexConnections + ); + + setupSides(2, 3, 0, 1, 15, 18, 14, 22, 8); + side(2, 15, 8, 22, tex[0], false, 2); + side(15, 3, 18, 8, tex[2], false, 2); + side(8, 18, 0, 14, tex[3], false, 2); + side(22, 8, 14, 1, tex[1], false, 2); + } + } + + @Override + public void renderFaceZPos(Block block, double x, double y, double z, IIcon icon) { + if (rendererOld != null && rendererOld.hasOverrideBlockTexture()) { + IIcon i = rendererOld.overrideBlockTexture; + + tessellator.addVertexWithUV(0.0, 1.0, 1.0, i.getMinU(), i.getMinV()); + tessellator.addVertexWithUV(0.0, 0.0, 1.0, i.getMinU(), i.getMaxV()); + tessellator.addVertexWithUV(1.0, 0.0, 1.0, i.getMaxU(), i.getMaxV()); + tessellator.addVertexWithUV(1.0, 1.0, 1.0, i.getMaxU(), i.getMinV()); + } else { + int tex[] = CTM.getSubmapIndices( + blockAccess, + bx, + by, + bz, + 3, + dataCTM.acceptableBlockMetas, + dataCTM.renderConvexConnections + ); + + setupSides(4, 7, 6, 5, 20, 16, 24, 17, 10); + side(17, 4, 20, 10, tex[2], false, 3); + side(5, 17, 10, 24, tex[0], false, 3); + side(24, 10, 16, 6, tex[1], false, 3); + side(10, 20, 7, 16, tex[3], false, 3); + } + } + + @Override + public void renderFaceYNeg(Block block, double x, double y, double z, IIcon icon) { + if (rendererOld != null && rendererOld.hasOverrideBlockTexture()) { + IIcon i = rendererOld.overrideBlockTexture; + + tessellator.addVertexWithUV(0.0, 0.0, 1.0, i.getMinU(), i.getMaxV()); + tessellator.addVertexWithUV(0.0, 0.0, 0.0, i.getMinU(), i.getMinV()); + tessellator.addVertexWithUV(1.0, 0.0, 0.0, i.getMaxU(), i.getMinV()); + tessellator.addVertexWithUV(1.0, 0.0, 1.0, i.getMaxU(), i.getMaxV()); + } else { + int tex[] = CTM.getSubmapIndices( + blockAccess, + bx, + by, + bz, + 0, + dataCTM.acceptableBlockMetas, + dataCTM.renderConvexConnections + ); + + setupSides(0, 3, 7, 4, 18, 21, 20, 19, 13); + side(13, 21, 7, 20, tex[3], true, 0); + side(19, 13, 20, 4, tex[2], true, 0); + side(0, 18, 13, 19, tex[0], true, 0); + side(18, 3, 21, 13, tex[1], true, 0); + } + } + + @Override + public void renderFaceYPos(Block block, double x, double y, double z, IIcon icon) { + if (rendererOld != null && rendererOld.hasOverrideBlockTexture()) { + IIcon i = rendererOld.overrideBlockTexture; + + tessellator.addVertexWithUV(0.0, 1.0, 0.0, i.getMinU(), i.getMinV()); + tessellator.addVertexWithUV(0.0, 1.0, 1.0, i.getMinU(), i.getMaxV()); + tessellator.addVertexWithUV(1.0, 1.0, 1.0, i.getMaxU(), i.getMaxV()); + tessellator.addVertexWithUV(1.0, 1.0, 0.0, i.getMaxU(), i.getMinV()); + } else { + int tex[] = CTM.getSubmapIndices( + blockAccess, + bx, + by, + bz, + 1, + dataCTM.acceptableBlockMetas, + dataCTM.renderConvexConnections + ); + + setupSides(2, 1, 5, 6, 22, 23, 24, 25, 12); + side(12, 24, 6, 25, tex[3], false, 1); + side(22, 12, 25, 2, tex[1], false, 1); + side(1, 23, 12, 22, tex[0], false, 1); + side(23, 5, 24, 12, tex[2], false, 1); + } + } + + void resetVertices() { + X[0] = 0; + Z[0] = 0; + Y[0] = 0; + + X[1] = 0; + Z[1] = 0; + Y[1] = 1; + + X[2] = 1; + Z[2] = 0; + Y[2] = 1; + + X[3] = 1; + Z[3] = 0; + Y[3] = 0; + + X[4] = 0; + Z[4] = 1; + Y[4] = 0; + + X[5] = 0; + Z[5] = 1; + Y[5] = 1; + + X[6] = 1; + Z[6] = 1; + Y[6] = 1; + + X[7] = 1; + Z[7] = 1; + Y[7] = 0; + + X[8] = 0.5; + Z[8] = 0; + Y[8] = 0.5; + + X[9] = 0; + Z[9] = 0.5; + Y[9] = 0.5; + + X[10] = 0.5; + Z[10] = 1; + Y[10] = 0.5; + + X[11] = 1; + Z[11] = 0.5; + Y[11] = 0.5; + + X[12] = 0.5; + Z[12] = 0.5; + Y[12] = 1; + + X[13] = 0.5; + Z[13] = 0.5; + Y[13] = 0; + + X[14] = 0; + Z[14] = 0; + Y[14] = 0.5; + + X[15] = 1; + Z[15] = 0; + Y[15] = 0.5; + + X[16] = 1; + Z[16] = 1; + Y[16] = 0.5; + + X[17] = 0; + Z[17] = 1; + Y[17] = 0.5; + + X[18] = 0.5; + Z[18] = 0; + Y[18] = 0; + + X[19] = 0; + Z[19] = 0.5; + Y[19] = 0; + + X[20] = 0.5; + Z[20] = 1; + Y[20] = 0; + + X[21] = 1; + Z[21] = 0.5; + Y[21] = 0; + + X[22] = 0.5; + Z[22] = 0; + Y[22] = 1; + + X[23] = 0; + Z[23] = 0.5; + Y[23] = 1; + + X[24] = 0.5; + Z[24] = 1; + Y[24] = 1; + + X[25] = 1; + Z[25] = 0.5; + Y[25] = 1; + } } diff --git a/src/main/java/mekanism/client/render/block/TextureSubmap.java b/src/main/java/mekanism/client/render/block/TextureSubmap.java index a103cdfa7..b5b3cb2b0 100644 --- a/src/main/java/mekanism/client/render/block/TextureSubmap.java +++ b/src/main/java/mekanism/client/render/block/TextureSubmap.java @@ -1,42 +1,37 @@ package mekanism.client.render.block; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.util.IIcon; import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.common.MinecraftForge; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; /** * Multi-texture class adapted from Chisel * Code licensed under GPLv2 * @author AUTOMATIC_MAIDEN, asie, pokefenn, unpairedbracket */ -public class TextureSubmap -{ - public int width, height; - - public IIcon icon; - - public IIcon icons[]; +public class TextureSubmap { + public int width, height; - public TextureSubmap(IIcon i, int w, int h) - { - icon = i; - width = w; - height = h; - icons = new IIcon[width * height]; + public IIcon icon; - MinecraftForge.EVENT_BUS.register(this); - } + public IIcon icons[]; - @SubscribeEvent - public void TexturesStitched(TextureStitchEvent.Post event) - { - for(int x = 0; x < width; x++) - { - for(int y = 0; y < height; y++) - { - icons[y * width + x] = new TextureVirtual(icon, width, height, x, y); - } - } - } + public TextureSubmap(IIcon i, int w, int h) { + icon = i; + width = w; + height = h; + icons = new IIcon[width * height]; + + MinecraftForge.EVENT_BUS.register(this); + } + + @SubscribeEvent + public void TexturesStitched(TextureStitchEvent.Post event) { + for (int x = 0; x < width; x++) { + for (int y = 0; y < height; y++) { + icons[y * width + x] = new TextureVirtual(icon, width, height, x, y); + } + } + } } diff --git a/src/main/java/mekanism/client/render/block/TextureVirtual.java b/src/main/java/mekanism/client/render/block/TextureVirtual.java index 2dfba26e1..14c8da3a3 100644 --- a/src/main/java/mekanism/client/render/block/TextureVirtual.java +++ b/src/main/java/mekanism/client/render/block/TextureVirtual.java @@ -1,96 +1,85 @@ package mekanism.client.render.block; -import net.minecraft.util.IIcon; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.util.IIcon; /** * Texture component class adapted from Chisel * Code licensed under GPLv2 * @author AUTOMATIC_MAIDEN, asie, pokefenn, unpairedbracket */ -public class TextureVirtual implements IIcon -{ - int ox, oy; - float u0, u1, v0, v1; - String name; - IIcon icon; +public class TextureVirtual implements IIcon { + int ox, oy; + float u0, u1, v0, v1; + String name; + IIcon icon; - TextureVirtual(IIcon parent, int w, int h, int x, int y) - { - icon = parent; + TextureVirtual(IIcon parent, int w, int h, int x, int y) { + icon = parent; - u0 = icon.getInterpolatedU(16.0 * (x) / w); - u1 = icon.getInterpolatedU(16.0 * (x + 1) / w); - v0 = icon.getInterpolatedV(16.0 * (y) / h); - v1 = icon.getInterpolatedV(16.0 * (y + 1) / h); + u0 = icon.getInterpolatedU(16.0 * (x) / w); + u1 = icon.getInterpolatedU(16.0 * (x + 1) / w); + v0 = icon.getInterpolatedV(16.0 * (y) / h); + v1 = icon.getInterpolatedV(16.0 * (y + 1) / h); - name = icon.getIconName() + "|" + x + "." + y; + name = icon.getIconName() + "|" + x + "." + y; - ox = icon.getIconWidth(); - oy = icon.getIconHeight(); - } + ox = icon.getIconWidth(); + oy = icon.getIconHeight(); + } - @Override - @SideOnly(Side.CLIENT) - public float getMinU() - { - return u0; - } + @Override + @SideOnly(Side.CLIENT) + public float getMinU() { + return u0; + } - @Override - @SideOnly(Side.CLIENT) - public float getMaxU() - { - return u1; - } + @Override + @SideOnly(Side.CLIENT) + public float getMaxU() { + return u1; + } - @Override - @SideOnly(Side.CLIENT) - public float getInterpolatedU(double d0) - { - return (float) (u0 + (u1 - u0) * d0 / 16.0); - } + @Override + @SideOnly(Side.CLIENT) + public float getInterpolatedU(double d0) { + return (float) (u0 + (u1 - u0) * d0 / 16.0); + } - @Override - @SideOnly(Side.CLIENT) - public float getMinV() - { - return v0; - } + @Override + @SideOnly(Side.CLIENT) + public float getMinV() { + return v0; + } - @Override - @SideOnly(Side.CLIENT) - public float getMaxV() - { - return v1; - } + @Override + @SideOnly(Side.CLIENT) + public float getMaxV() { + return v1; + } - @Override - @SideOnly(Side.CLIENT) - public float getInterpolatedV(double d0) - { - return (float) (v0 + (v1 - v0) * d0 / 16.0); - } + @Override + @SideOnly(Side.CLIENT) + public float getInterpolatedV(double d0) { + return (float) (v0 + (v1 - v0) * d0 / 16.0); + } - @Override - @SideOnly(Side.CLIENT) - public String getIconName() - { - return name; - } + @Override + @SideOnly(Side.CLIENT) + public String getIconName() { + return name; + } - @Override - @SideOnly(Side.CLIENT) - public int getIconWidth() - { - return ox; - } + @Override + @SideOnly(Side.CLIENT) + public int getIconWidth() { + return ox; + } - @Override - @SideOnly(Side.CLIENT) - public int getIconHeight() - { - return oy; - } + @Override + @SideOnly(Side.CLIENT) + public int getIconHeight() { + return oy; + } } diff --git a/src/main/java/mekanism/client/render/entity/RenderBalloon.java b/src/main/java/mekanism/client/render/entity/RenderBalloon.java index 4f0168de8..605e2e4e9 100644 --- a/src/main/java/mekanism/client/render/entity/RenderBalloon.java +++ b/src/main/java/mekanism/client/render/entity/RenderBalloon.java @@ -1,5 +1,7 @@ package mekanism.client.render.entity; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.EnumColor; import mekanism.client.model.ModelBalloon; import mekanism.common.entity.EntityBalloon; @@ -10,57 +12,60 @@ import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class RenderBalloon extends Render -{ - private Minecraft mc = Minecraft.getMinecraft(); +public class RenderBalloon extends Render { + private Minecraft mc = Minecraft.getMinecraft(); - public ModelBalloon model = new ModelBalloon(); + public ModelBalloon model = new ModelBalloon(); - @Override - protected ResourceLocation getEntityTexture(Entity entity) - { - return MekanismUtils.getResource(ResourceType.RENDER, "Balloon.png"); - } + @Override + protected ResourceLocation getEntityTexture(Entity entity) { + return MekanismUtils.getResource(ResourceType.RENDER, "Balloon.png"); + } - @Override - public void doRender(Entity entity, double x, double y, double z, float f, float partialTick) - { - EntityBalloon balloon = (EntityBalloon)entity; + @Override + public void + doRender(Entity entity, double x, double y, double z, float f, float partialTick) { + EntityBalloon balloon = (EntityBalloon) entity; - if(balloon.isLatchedToEntity()) - { - x = (balloon.latchedEntity.lastTickPosX + (balloon.latchedEntity.posX - balloon.latchedEntity.lastTickPosX)*partialTick); - y = (balloon.latchedEntity.lastTickPosY + (balloon.latchedEntity.posY - balloon.latchedEntity.lastTickPosY)*partialTick); - z = (balloon.latchedEntity.lastTickPosZ + (balloon.latchedEntity.posZ - balloon.latchedEntity.lastTickPosZ)*partialTick); + if (balloon.isLatchedToEntity()) { + x + = (balloon.latchedEntity.lastTickPosX + + (balloon.latchedEntity.posX - balloon.latchedEntity.lastTickPosX) + * partialTick); + y + = (balloon.latchedEntity.lastTickPosY + + (balloon.latchedEntity.posY - balloon.latchedEntity.lastTickPosY) + * partialTick); + z + = (balloon.latchedEntity.lastTickPosZ + + (balloon.latchedEntity.posZ - balloon.latchedEntity.lastTickPosZ) + * partialTick); - x -= RenderManager.renderPosX; - y -= RenderManager.renderPosY; - z -= RenderManager.renderPosZ; + x -= RenderManager.renderPosX; + y -= RenderManager.renderPosY; + z -= RenderManager.renderPosZ; - y += balloon.getAddedHeight(); - } + y += balloon.getAddedHeight(); + } - render(((EntityBalloon)entity).color, x, y, z); - } + render(((EntityBalloon) entity).color, x, y, z); + } - public void render(EnumColor color, double x, double y, double z) - { - GL11.glPushMatrix(); - GL11.glTranslated(x, y, z); - GL11.glRotatef(180, 1, 0, 0); - GL11.glTranslatef(0, 0.9F, 0); + public void render(EnumColor color, double x, double y, double z) { + GL11.glPushMatrix(); + GL11.glTranslated(x, y, z); + GL11.glRotatef(180, 1, 0, 0); + GL11.glTranslatef(0, 0.9F, 0); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "Balloon.png")); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "Balloon.png") + ); - model.render(0.0625F, color); + model.render(0.0625F, color); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } } diff --git a/src/main/java/mekanism/client/render/entity/RenderFlame.java b/src/main/java/mekanism/client/render/entity/RenderFlame.java index fd369b0f9..f2e0f2450 100644 --- a/src/main/java/mekanism/client/render/entity/RenderFlame.java +++ b/src/main/java/mekanism/client/render/entity/RenderFlame.java @@ -1,53 +1,64 @@ package mekanism.client.render.entity; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.render.MekanismRenderer; import mekanism.common.entity.EntityFlame; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.entity.Render; import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class RenderFlame extends Render -{ - public void doRender(EntityFlame entity, double x, double y, double z, float f, float partialTick) - { - float alpha = (float)(entity.ticksExisted+partialTick)/(float)EntityFlame.LIFESPAN; - float size = (float)Math.pow(2*alpha, 2); - +public class RenderFlame extends Render { + public void doRender( + EntityFlame entity, double x, double y, double z, float f, float partialTick + ) { + float alpha + = (float) (entity.ticksExisted + partialTick) / (float) EntityFlame.LIFESPAN; + float size = (float) Math.pow(2 * alpha, 2); + GL11.glPushMatrix(); MekanismRenderer.glowOn(); MekanismRenderer.blendOn(); - GL11.glColor4f(1, 1, 1, 1-alpha); - + GL11.glColor4f(1, 1, 1, 1 - alpha); + bindTexture(getEntityTexture(entity)); - - GL11.glTranslatef((float)x, (float)y, (float)z); - GL11.glRotatef((entity.prevRotationYaw + (entity.rotationYaw - entity.prevRotationYaw) * partialTick) - 90F, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(entity.prevRotationPitch + (entity.rotationPitch - entity.prevRotationPitch) * partialTick, 0.0F, 0.0F, 1.0F); - + + GL11.glTranslatef((float) x, (float) y, (float) z); + GL11.glRotatef( + (entity.prevRotationYaw + + (entity.rotationYaw - entity.prevRotationYaw) * partialTick) + - 90F, + 0.0F, + 1.0F, + 0.0F + ); + GL11.glRotatef( + entity.prevRotationPitch + + (entity.rotationPitch - entity.prevRotationPitch) * partialTick, + 0.0F, + 0.0F, + 1.0F + ); + Tessellator tessellator = Tessellator.instance; - + int i = 0; float f2 = 0.0F; float f3 = 0.5F; - float f4 = (float)(0 + i * 10) / 32F; - float f5 = (float)(5 + i * 10) / 32F; - float scale = 0.05625F*(0.8F+size); - + float f4 = (float) (0 + i * 10) / 32F; + float f5 = (float) (5 + i * 10) / 32F; + float scale = 0.05625F * (0.8F + size); + GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glRotatef(45F, 1.0F, 0.0F, 0.0F); GL11.glScalef(scale, scale, scale); GL11.glTranslatef(-4F, 0.0F, 0.0F); - for(int j = 0; j < 4; j++) - { + for (int j = 0; j < 4; j++) { GL11.glRotatef(90F, 1.0F, 0.0F, 0.0F); GL11.glNormal3f(0.0F, 0.0F, scale); tessellator.startDrawingQuads(); @@ -65,14 +76,13 @@ public class RenderFlame extends Render } @Override - public void doRender(Entity entity, double x, double y, double z, float f, float partialTick) - { - doRender((EntityFlame)entity, x, y, z, f, partialTick); + public void + doRender(Entity entity, double x, double y, double z, float f, float partialTick) { + doRender((EntityFlame) entity, x, y, z, f, partialTick); } - + @Override - protected ResourceLocation getEntityTexture(Entity entity) - { + protected ResourceLocation getEntityTexture(Entity entity) { return new ResourceLocation("mekanism:render/Flame.png"); } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/render/entity/RenderObsidianTNTPrimed.java b/src/main/java/mekanism/client/render/entity/RenderObsidianTNTPrimed.java index 51a4e5ce5..77432b77b 100644 --- a/src/main/java/mekanism/client/render/entity/RenderObsidianTNTPrimed.java +++ b/src/main/java/mekanism/client/render/entity/RenderObsidianTNTPrimed.java @@ -1,5 +1,7 @@ package mekanism.client.render.entity; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.model.ModelObsidianTNT; import mekanism.common.entity.EntityObsidianTNT; import mekanism.common.util.MekanismUtils; @@ -9,80 +11,74 @@ import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class RenderObsidianTNTPrimed extends Render -{ - private RenderBlocks blockRenderer = new RenderBlocks(); - private ModelObsidianTNT model = new ModelObsidianTNT(); +public class RenderObsidianTNTPrimed extends Render { + private RenderBlocks blockRenderer = new RenderBlocks(); + private ModelObsidianTNT model = new ModelObsidianTNT(); - public RenderObsidianTNTPrimed() - { - shadowSize = 0.5F; - } + public RenderObsidianTNTPrimed() { + shadowSize = 0.5F; + } - @Override - public void doRender(Entity entity, double x, double y, double z, float f, float f1) - { - renderObsidianTNT((EntityObsidianTNT)entity, x, y, z, f, f1); - } + @Override + public void doRender(Entity entity, double x, double y, double z, float f, float f1) { + renderObsidianTNT((EntityObsidianTNT) entity, x, y, z, f, f1); + } - public void renderObsidianTNT(EntityObsidianTNT entityobsidiantnt, double x, double y, double z, float f, float f1) - { - GL11.glPushMatrix(); - GL11.glTranslatef((float)x, (float)y+1.2F, (float)z); - GL11.glScalef(0.8F, 0.8F, 0.8F); - GL11.glRotatef(180, 1, 0, 0); + public void renderObsidianTNT( + EntityObsidianTNT entityobsidiantnt, + double x, + double y, + double z, + float f, + float f1 + ) { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x, (float) y + 1.2F, (float) z); + GL11.glScalef(0.8F, 0.8F, 0.8F); + GL11.glRotatef(180, 1, 0, 0); - if((entityobsidiantnt.fuse - f1) + 1.0F < 10F) - { - float scale = 1.0F - ((entityobsidiantnt.fuse - f1) + 1.0F) / 10F; + if ((entityobsidiantnt.fuse - f1) + 1.0F < 10F) { + float scale = 1.0F - ((entityobsidiantnt.fuse - f1) + 1.0F) / 10F; - if(scale < 0.0F) - { - scale = 0.0F; - } + if (scale < 0.0F) { + scale = 0.0F; + } - if(scale > 1.0F) - { - scale = 1.0F; - } + if (scale > 1.0F) { + scale = 1.0F; + } - scale *= scale; - scale *= scale; - float renderScale = 1.0F + scale * 0.3F; - GL11.glScalef(renderScale, renderScale, renderScale); - } + scale *= scale; + scale *= scale; + float renderScale = 1.0F + scale * 0.3F; + GL11.glScalef(renderScale, renderScale, renderScale); + } - float f3 = (1.0F - ((entityobsidiantnt.fuse - f1) + 1.0F) / 100F) * 0.8F; - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ObsidianTNT.png")); - model.render(0.0625F); + float f3 = (1.0F - ((entityobsidiantnt.fuse - f1) + 1.0F) / 100F) * 0.8F; + bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ObsidianTNT.png")); + model.render(0.0625F); - if(entityobsidiantnt.fuse / 5 % 2 == 0) - { - GL11.glDisable(GL11.GL_TEXTURE_2D); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_DST_ALPHA); - GL11.glColor4f(1.0F, 1.0F, 1.0F, f3); - model.render(0.0625F); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - GL11.glDisable(GL11.GL_BLEND); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_TEXTURE_2D); - } + if (entityobsidiantnt.fuse / 5 % 2 == 0) { + GL11.glDisable(GL11.GL_TEXTURE_2D); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_DST_ALPHA); + GL11.glColor4f(1.0F, 1.0F, 1.0F, f3); + model.render(0.0625F); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_BLEND); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_TEXTURE_2D); + } - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } - @Override - protected ResourceLocation getEntityTexture(Entity entity) - { - return TextureMap.locationBlocksTexture; - } + @Override + protected ResourceLocation getEntityTexture(Entity entity) { + return TextureMap.locationBlocksTexture; + } } diff --git a/src/main/java/mekanism/client/render/entity/RenderRobit.java b/src/main/java/mekanism/client/render/entity/RenderRobit.java index d585102a2..b24538213 100644 --- a/src/main/java/mekanism/client/render/entity/RenderRobit.java +++ b/src/main/java/mekanism/client/render/entity/RenderRobit.java @@ -1,5 +1,7 @@ package mekanism.client.render.entity; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.model.ModelRobit; import mekanism.common.entity.EntityRobit; import mekanism.common.util.MekanismUtils; @@ -7,30 +9,27 @@ import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.entity.Entity; import net.minecraft.util.ResourceLocation; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class RenderRobit extends RenderLiving -{ - public RenderRobit() - { - super(new ModelRobit(), 0.5F); - } +public class RenderRobit extends RenderLiving { + public RenderRobit() { + super(new ModelRobit(), 0.5F); + } - @Override - protected ResourceLocation getEntityTexture(Entity entity) - { - EntityRobit robit = (EntityRobit)entity; + @Override + protected ResourceLocation getEntityTexture(Entity entity) { + EntityRobit robit = (EntityRobit) entity; - if((Math.abs(entity.posX-entity.prevPosX) + Math.abs(entity.posX-entity.prevPosX)) > 0.001) - { - if(robit.ticksExisted % 3 == 0) - { - robit.texTick = !robit.texTick; - } - } + if ((Math.abs(entity.posX - entity.prevPosX) + + Math.abs(entity.posX - entity.prevPosX)) + > 0.001) { + if (robit.ticksExisted % 3 == 0) { + robit.texTick = !robit.texTick; + } + } - return MekanismUtils.getResource(ResourceType.RENDER, "Robit" + (robit.texTick ? "2" : "") + ".png"); - } + return MekanismUtils.getResource( + ResourceType.RENDER, "Robit" + (robit.texTick ? "2" : "") + ".png" + ); + } } diff --git a/src/main/java/mekanism/client/render/item/ItemRenderingHandler.java b/src/main/java/mekanism/client/render/item/ItemRenderingHandler.java index 591d02d8d..d79965ac8 100644 --- a/src/main/java/mekanism/client/render/item/ItemRenderingHandler.java +++ b/src/main/java/mekanism/client/render/item/ItemRenderingHandler.java @@ -1,5 +1,8 @@ package mekanism.client.render.item; +import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.EnumColor; import mekanism.api.energy.IEnergizedItem; import mekanism.client.ClientProxy; @@ -67,492 +70,523 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.client.IItemRenderer; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.client.registry.RenderingRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class ItemRenderingHandler implements IItemRenderer -{ - private Minecraft mc = Minecraft.getMinecraft(); - - public ModelRobit robit = new ModelRobit(); - public ModelChest personalChest = new ModelChest(); - public ModelEnergyCube energyCube = new ModelEnergyCube(); - public ModelEnergyCore energyCore = new ModelEnergyCore(); - public ModelGasTank gasTank = new ModelGasTank(); - public ModelObsidianTNT obsidianTNT = new ModelObsidianTNT(); - public ModelJetpack jetpack = new ModelJetpack(); - public ModelArmoredJetpack armoredJetpack = new ModelArmoredJetpack(); - public ModelGasMask gasMask = new ModelGasMask(); - public ModelScubaTank scubaTank = new ModelScubaTank(); - public ModelFreeRunners freeRunners = new ModelFreeRunners(); - public ModelAtomicDisassembler atomicDisassembler = new ModelAtomicDisassembler(); - public ModelFlamethrower flamethrower = new ModelFlamethrower(); +public class ItemRenderingHandler implements IItemRenderer { + private Minecraft mc = Minecraft.getMinecraft(); - private final RenderBalloon balloonRenderer = new RenderBalloon(); - private final RenderBin binRenderer = (RenderBin)TileEntityRendererDispatcher.instance.mapSpecialRenderers.get(TileEntityBin.class); - private final RenderFluidTank portableTankRenderer = (RenderFluidTank)TileEntityRendererDispatcher.instance.mapSpecialRenderers.get(TileEntityFluidTank.class); - private final RenderItem renderItem = (RenderItem)RenderManager.instance.getEntityClassRenderObject(EntityItem.class); + public ModelRobit robit = new ModelRobit(); + public ModelChest personalChest = new ModelChest(); + public ModelEnergyCube energyCube = new ModelEnergyCube(); + public ModelEnergyCore energyCore = new ModelEnergyCore(); + public ModelGasTank gasTank = new ModelGasTank(); + public ModelObsidianTNT obsidianTNT = new ModelObsidianTNT(); + public ModelJetpack jetpack = new ModelJetpack(); + public ModelArmoredJetpack armoredJetpack = new ModelArmoredJetpack(); + public ModelGasMask gasMask = new ModelGasMask(); + public ModelScubaTank scubaTank = new ModelScubaTank(); + public ModelFreeRunners freeRunners = new ModelFreeRunners(); + public ModelAtomicDisassembler atomicDisassembler = new ModelAtomicDisassembler(); + public ModelFlamethrower flamethrower = new ModelFlamethrower(); - @Override - public boolean handleRenderType(ItemStack item, ItemRenderType type) - { - if(item.getItem() == MekanismItems.WalkieTalkie) - { - return type != ItemRenderType.INVENTORY; - } + private final RenderBalloon balloonRenderer = new RenderBalloon(); + private final RenderBin binRenderer = (RenderBin + ) TileEntityRendererDispatcher.instance.mapSpecialRenderers.get(TileEntityBin.class); + private final RenderFluidTank portableTankRenderer + = (RenderFluidTank) TileEntityRendererDispatcher.instance.mapSpecialRenderers + .get(TileEntityFluidTank.class); + private final RenderItem renderItem = (RenderItem + ) RenderManager.instance.getEntityClassRenderObject(EntityItem.class); - return true; - } + @Override + public boolean handleRenderType(ItemStack item, ItemRenderType type) { + if (item.getItem() == MekanismItems.WalkieTalkie) { + return type != ItemRenderType.INVENTORY; + } - @Override - public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) - { - return true; - } + return true; + } - @Override - public void renderItem(ItemRenderType type, ItemStack item, Object... data) - { - RenderBlocks renderBlocks = (RenderBlocks)data[0]; + @Override + public boolean shouldUseRenderHelper( + ItemRenderType type, ItemStack item, ItemRendererHelper helper + ) { + return true; + } - if(type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) - { - GL11.glTranslatef(0.5F, 0.5F, 0.5F); - } + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + RenderBlocks renderBlocks = (RenderBlocks) data[0]; - if(item.getItem() instanceof IEnergyCube) - { - EnergyCubeTier tier = ((IEnergyCube)item.getItem()).getEnergyCubeTier(item); - IEnergizedItem energized = (IEnergizedItem)item.getItem(); - mc.renderEngine.bindTexture(RenderEnergyCube.baseTexture); + if (type == ItemRenderType.EQUIPPED + || type == ItemRenderType.EQUIPPED_FIRST_PERSON) { + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(270F, 0.0F, -1.0F, 0.0F); - GL11.glTranslatef(0.0F, -1.0F, 0.0F); + if (item.getItem() instanceof IEnergyCube) { + EnergyCubeTier tier = ((IEnergyCube) item.getItem()).getEnergyCubeTier(item); + IEnergizedItem energized = (IEnergizedItem) item.getItem(); + mc.renderEngine.bindTexture(RenderEnergyCube.baseTexture); - MekanismRenderer.blendOn(); - - energyCube.render(0.0625F, tier, mc.renderEngine); - - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - mc.renderEngine.bindTexture(RenderEnergyCube.baseTexture); - energyCube.renderSide(0.0625F, side, side == ForgeDirection.NORTH ? IOState.OUTPUT : IOState.INPUT, tier, mc.renderEngine); - } - - MekanismRenderer.blendOff(); + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(270F, 0.0F, -1.0F, 0.0F); + GL11.glTranslatef(0.0F, -1.0F, 0.0F); - GL11.glPushMatrix(); - GL11.glTranslated(0.0, 1.0, 0.0); - mc.renderEngine.bindTexture(RenderEnergyCube.coreTexture); + MekanismRenderer.blendOn(); - GL11.glShadeModel(GL11.GL_SMOOTH); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + energyCube.render(0.0625F, tier, mc.renderEngine); - MekanismRenderer.glowOn(); + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + mc.renderEngine.bindTexture(RenderEnergyCube.baseTexture); + energyCube.renderSide( + 0.0625F, + side, + side == ForgeDirection.NORTH ? IOState.OUTPUT : IOState.INPUT, + tier, + mc.renderEngine + ); + } - EnumColor c = tier.getBaseTier().getColor(); + MekanismRenderer.blendOff(); - GL11.glPushMatrix(); - GL11.glScalef(0.4F, 0.4F, 0.4F); - GL11.glColor4f(c.getColor(0), c.getColor(1), c.getColor(2), (float)(energized.getEnergy(item)/energized.getMaxEnergy(item))); - GL11.glTranslatef(0, (float)Math.sin(Math.toRadians((MekanismClient.ticksPassed + MekanismRenderer.getPartialTick()) * 3)) / 7, 0); - GL11.glRotatef((MekanismClient.ticksPassed + MekanismRenderer.getPartialTick()) * 4, 0, 1, 0); - GL11.glRotatef(36F + (MekanismClient.ticksPassed + MekanismRenderer.getPartialTick()) * 4, 0, 1, 1); - energyCore.render(0.0625F); - GL11.glPopMatrix(); + GL11.glPushMatrix(); + GL11.glTranslated(0.0, 1.0, 0.0); + mc.renderEngine.bindTexture(RenderEnergyCube.coreTexture); - MekanismRenderer.glowOff(); + GL11.glShadeModel(GL11.GL_SMOOTH); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - GL11.glShadeModel(GL11.GL_FLAT); - GL11.glDisable(GL11.GL_LINE_SMOOTH); - GL11.glDisable(GL11.GL_POLYGON_SMOOTH); - GL11.glDisable(GL11.GL_BLEND); + MekanismRenderer.glowOn(); - GL11.glPopMatrix(); - } + EnumColor c = tier.getBaseTier().getColor(); + + GL11.glPushMatrix(); + GL11.glScalef(0.4F, 0.4F, 0.4F); + GL11.glColor4f( + c.getColor(0), + c.getColor(1), + c.getColor(2), + (float) (energized.getEnergy(item) / energized.getMaxEnergy(item)) + ); + GL11.glTranslatef( + 0, + (float) Math.sin(Math.toRadians( + (MekanismClient.ticksPassed + MekanismRenderer.getPartialTick()) * 3 + )) / 7, + 0 + ); + GL11.glRotatef( + (MekanismClient.ticksPassed + MekanismRenderer.getPartialTick()) * 4, + 0, + 1, + 0 + ); + GL11.glRotatef( + 36F + + (MekanismClient.ticksPassed + MekanismRenderer.getPartialTick()) + * 4, + 0, + 1, + 1 + ); + energyCore.render(0.0625F); + GL11.glPopMatrix(); + + MekanismRenderer.glowOff(); + + GL11.glShadeModel(GL11.GL_FLAT); + GL11.glDisable(GL11.GL_LINE_SMOOTH); + GL11.glDisable(GL11.GL_POLYGON_SMOOTH); + GL11.glDisable(GL11.GL_BLEND); + + GL11.glPopMatrix(); + } else if(BasicType.get(item) == BasicType.INDUCTION_CELL || BasicType.get(item) == BasicType.INDUCTION_PROVIDER) { - MekanismRenderer.renderCustomItem((RenderBlocks)data[0], item); - } - else if(BasicType.get(item) == BasicType.BIN) - { - GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); - MekanismRenderer.renderCustomItem((RenderBlocks)data[0], item); - GL11.glRotatef(-270, 0.0F, 1.0F, 0.0F); - - if(binRenderer == null || binRenderer.func_147498_b()/*getFontRenderer()*/ == null) - { - return; - } + MekanismRenderer.renderCustomItem((RenderBlocks) data[0], item); + } else if (BasicType.get(item) == BasicType.BIN) { + GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); + MekanismRenderer.renderCustomItem((RenderBlocks) data[0], item); + GL11.glRotatef(-270, 0.0F, 1.0F, 0.0F); - InventoryBin inv = new InventoryBin(item); - ForgeDirection side = ForgeDirection.getOrientation(2); + if (binRenderer == null + || binRenderer.func_147498_b() /*getFontRenderer()*/ == null) { + return; + } - String amount = ""; - ItemStack itemStack = inv.getStack(); + InventoryBin inv = new InventoryBin(item); + ForgeDirection side = ForgeDirection.getOrientation(2); - if(itemStack != null) - { - amount = Integer.toString(inv.getItemCount()); - } + String amount = ""; + ItemStack itemStack = inv.getStack(); - MekanismRenderer.glowOn(); + if (itemStack != null) { + amount = Integer.toString(inv.getItemCount()); + } - if(itemStack != null) - { - GL11.glPushMatrix(); + MekanismRenderer.glowOn(); - if(!(itemStack.getItem() instanceof ItemBlock) || Block.getBlockFromItem(itemStack.getItem()).getRenderType() != 0) - { - GL11.glRotatef(180, 0, 0, 1); - GL11.glTranslatef(-1.02F, -0.2F, 0); + if (itemStack != null) { + GL11.glPushMatrix(); - if(type == ItemRenderType.INVENTORY) - { - GL11.glTranslatef(-0.45F, -0.4F, 0.0F); - } - } + if (!(itemStack.getItem() instanceof ItemBlock) + || Block.getBlockFromItem(itemStack.getItem()).getRenderType() != 0) { + GL11.glRotatef(180, 0, 0, 1); + GL11.glTranslatef(-1.02F, -0.2F, 0); - if(type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON || type == ItemRenderType.ENTITY) - { - GL11.glTranslatef(-0.22F, -0.2F, -0.22F); - } + if (type == ItemRenderType.INVENTORY) { + GL11.glTranslatef(-0.45F, -0.4F, 0.0F); + } + } - GL11.glTranslated(0.73, 0.08, 0.44); - GL11.glRotatef(90, 0, 1, 0); + if (type == ItemRenderType.EQUIPPED + || type == ItemRenderType.EQUIPPED_FIRST_PERSON + || type == ItemRenderType.ENTITY) { + GL11.glTranslatef(-0.22F, -0.2F, -0.22F); + } - float scale = 0.03125F; - float scaler = 0.9F; + GL11.glTranslated(0.73, 0.08, 0.44); + GL11.glRotatef(90, 0, 1, 0); - GL11.glScalef(scale*scaler, scale*scaler, 0); + float scale = 0.03125F; + float scaler = 0.9F; - TextureManager renderEngine = mc.renderEngine; + GL11.glScalef(scale * scaler, scale * scaler, 0); - GL11.glDisable(GL11.GL_LIGHTING); + TextureManager renderEngine = mc.renderEngine; - renderItem.renderItemAndEffectIntoGUI(binRenderer.func_147498_b()/*getFontRenderer()*/, renderEngine, itemStack, 0, 0); + GL11.glDisable(GL11.GL_LIGHTING); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - } - - MekanismRenderer.glowOff(); + renderItem.renderItemAndEffectIntoGUI( + binRenderer.func_147498_b() /*getFontRenderer()*/, + renderEngine, + itemStack, + 0, + 0 + ); - if(amount != "") - { - float maxScale = 0.02F; + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } - GL11.glPushMatrix(); + MekanismRenderer.glowOff(); - GL11.glPolygonOffset(-10, -10); - GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL); + if (amount != "") { + float maxScale = 0.02F; - float displayWidth = 1 - (2 / 16); - float displayHeight = 1 - (2 / 16); - GL11.glTranslatef(0, -0.31F, 0); + GL11.glPushMatrix(); - if(type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON || type == ItemRenderType.ENTITY) - { - GL11.glTranslated(-0.5, -0.4, -0.5); - } + GL11.glPolygonOffset(-10, -10); + GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL); - GL11.glTranslatef(0, 0.9F, 1); - GL11.glRotatef(90, 0, 1, 0); - GL11.glRotatef(90, 1, 0, 0); + float displayWidth = 1 - (2 / 16); + float displayHeight = 1 - (2 / 16); + GL11.glTranslatef(0, -0.31F, 0); - GL11.glTranslatef(displayWidth / 2, 1F, displayHeight / 2); - GL11.glRotatef(-90, 1, 0, 0); + if (type == ItemRenderType.EQUIPPED + || type == ItemRenderType.EQUIPPED_FIRST_PERSON + || type == ItemRenderType.ENTITY) { + GL11.glTranslated(-0.5, -0.4, -0.5); + } - FontRenderer fontRenderer = binRenderer.func_147498_b();//getFontRenderer(); + GL11.glTranslatef(0, 0.9F, 1); + GL11.glRotatef(90, 0, 1, 0); + GL11.glRotatef(90, 1, 0, 0); - int requiredWidth = Math.max(fontRenderer.getStringWidth(amount), 1); - int lineHeight = fontRenderer.FONT_HEIGHT + 2; - int requiredHeight = lineHeight * 1; - float scaler = 0.4F; - float scaleX = (displayWidth / requiredWidth); - float scale = scaleX * scaler; + GL11.glTranslatef(displayWidth / 2, 1F, displayHeight / 2); + GL11.glRotatef(-90, 1, 0, 0); - if(maxScale > 0) - { - scale = Math.min(scale, maxScale); - } + FontRenderer fontRenderer + = binRenderer.func_147498_b(); //getFontRenderer(); - GL11.glScalef(scale, -scale, scale); - GL11.glDepthMask(false); + int requiredWidth = Math.max(fontRenderer.getStringWidth(amount), 1); + int lineHeight = fontRenderer.FONT_HEIGHT + 2; + int requiredHeight = lineHeight * 1; + float scaler = 0.4F; + float scaleX = (displayWidth / requiredWidth); + float scale = scaleX * scaler; - int offsetX; - int offsetY; - int realHeight = (int)Math.floor(displayHeight / scale); - int realWidth = (int)Math.floor(displayWidth / scale); + if (maxScale > 0) { + scale = Math.min(scale, maxScale); + } - offsetX = (realWidth - requiredWidth) / 2; - offsetY = (realHeight - requiredHeight) / 2; + GL11.glScalef(scale, -scale, scale); + GL11.glDepthMask(false); - GL11.glDisable(GL11.GL_LIGHTING); - fontRenderer.drawString("\u00a7f" + amount, offsetX - (realWidth / 2), 1 + offsetY - (realHeight / 2), 1); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glDepthMask(true); - GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL); + int offsetX; + int offsetY; + int realHeight = (int) Math.floor(displayHeight / scale); + int realWidth = (int) Math.floor(displayWidth / scale); - GL11.glPopMatrix(); - } - } - else if(Block.getBlockFromItem(item.getItem()) == MekanismBlocks.GasTank) - { - GL11.glPushMatrix(); - - BaseTier tier = ((ItemBlockGasTank)item.getItem()).getBaseTier(item); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "GasTank" + tier.getName() + ".png")); - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); - GL11.glTranslatef(0.0F, -1.0F, 0.0F); - gasTank.render(0.0625F); - - GL11.glPopMatrix(); - } - else if(Block.getBlockFromItem(item.getItem()) == MekanismBlocks.ObsidianTNT) - { - GL11.glPushMatrix(); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ObsidianTNT.png")); - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(180F, 0.0F, -1.0F, 0.0F); - GL11.glTranslatef(0.0F, -1.0F, 0.0F); - obsidianTNT.render(0.0625F); - GL11.glPopMatrix(); - } - else if(item.getItem() instanceof ItemWalkieTalkie) - { - if(((ItemWalkieTalkie)item.getItem()).getOn(item)) - { - MekanismRenderer.glowOn(); - } + offsetX = (realWidth - requiredWidth) / 2; + offsetY = (realHeight - requiredHeight) / 2; - MekanismRenderer.renderItem(item); + GL11.glDisable(GL11.GL_LIGHTING); + fontRenderer.drawString( + "\u00a7f" + amount, + offsetX - (realWidth / 2), + 1 + offsetY - (realHeight / 2), + 1 + ); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDepthMask(true); + GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL); - if(((ItemWalkieTalkie)item.getItem()).getOn(item)) - { - MekanismRenderer.glowOff(); - } - } - else if(MachineType.get(item) == MachineType.PERSONAL_CHEST) - { - GL11.glPushMatrix(); - ItemBlockMachine chest = (ItemBlockMachine)item.getItem(); + GL11.glPopMatrix(); + } + } else if (Block.getBlockFromItem(item.getItem()) == MekanismBlocks.GasTank) { + GL11.glPushMatrix(); - GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); - GL11.glTranslatef(-0.5F, -0.5F, -0.5F); - GL11.glTranslatef(0, 1.0F, 1.0F); - GL11.glScalef(1.0F, -1F, -1F); + BaseTier tier = ((ItemBlockGasTank) item.getItem()).getBaseTier(item); + mc.renderEngine.bindTexture(MekanismUtils.getResource( + ResourceType.RENDER, "GasTank" + tier.getName() + ".png" + )); + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(0.0F, -1.0F, 0.0F); + gasTank.render(0.0625F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "PersonalChest.png")); + GL11.glPopMatrix(); + } else if (Block.getBlockFromItem(item.getItem()) == MekanismBlocks.ObsidianTNT) { + GL11.glPushMatrix(); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "ObsidianTNT.png") + ); + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(180F, 0.0F, -1.0F, 0.0F); + GL11.glTranslatef(0.0F, -1.0F, 0.0F); + obsidianTNT.render(0.0625F); + GL11.glPopMatrix(); + } else if (item.getItem() instanceof ItemWalkieTalkie) { + if (((ItemWalkieTalkie) item.getItem()).getOn(item)) { + MekanismRenderer.glowOn(); + } - personalChest.renderAll(); - GL11.glPopMatrix(); - } - else if(item.getItem() instanceof ItemRobit) - { - GL11.glPushMatrix(); - GL11.glRotatef(180, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(90, 0.0F, -1.0F, 0.0F); - GL11.glTranslatef(0.0F, -1.5F, 0.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "Robit.png")); - robit.render(0.08F); - GL11.glPopMatrix(); - } - else if(item.getItem() == MekanismItems.Jetpack) - { - GL11.glPushMatrix(); - GL11.glRotatef(180, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(90, 0.0F, -1.0F, 0.0F); - GL11.glTranslatef(0.2F, -0.35F, 0.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "Jetpack.png")); - jetpack.render(0.0625F); - GL11.glPopMatrix(); - } - else if(item.getItem() == MekanismItems.ArmoredJetpack) - { - GL11.glPushMatrix(); - GL11.glRotatef(180, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(90, 0.0F, -1.0F, 0.0F); - GL11.glTranslatef(0.2F, -0.35F, 0.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "Jetpack.png")); - armoredJetpack.render(0.0625F); - GL11.glPopMatrix(); - } - else if(item.getItem() instanceof ItemGasMask) - { - GL11.glPushMatrix(); - GL11.glRotatef(180, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(90, 0.0F, -1.0F, 0.0F); - GL11.glTranslatef(0.1F, 0.2F, 0.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ScubaSet.png")); - gasMask.render(0.0625F); - GL11.glPopMatrix(); - } - else if(item.getItem() instanceof ItemScubaTank) - { - GL11.glPushMatrix(); - GL11.glRotatef(180, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(90, 0.0F, -1.0F, 0.0F); - GL11.glScalef(1.6F, 1.6F, 1.6F); - GL11.glTranslatef(0.2F, -0.5F, 0.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ScubaSet.png")); - scubaTank.render(0.0625F); - GL11.glPopMatrix(); - } - else if(item.getItem() instanceof ItemFreeRunners) - { - GL11.glPushMatrix(); - GL11.glRotatef(180, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(90, 0.0F, -1.0F, 0.0F); - GL11.glScalef(2.0F, 2.0F, 2.0F); - GL11.glTranslatef(0.2F, -1.43F, 0.12F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "FreeRunners.png")); - freeRunners.render(0.0625F); - GL11.glPopMatrix(); - } - else if(item.getItem() instanceof ItemBalloon) - { - GL11.glPushMatrix(); - - if(type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) - { - GL11.glScalef(2.5F, 2.5F, 2.5F); - GL11.glTranslatef(0.2F, 0, 0.1F); - GL11.glRotatef(15, -1, 0, 1); - balloonRenderer.render(((ItemBalloon)item.getItem()).getColor(item), 0, 1.9F, 0); - } - else { - balloonRenderer.render(((ItemBalloon)item.getItem()).getColor(item), 0, 1, 0); - } - - GL11.glPopMatrix(); - } - else if(item.getItem() instanceof ItemAtomicDisassembler) - { - GL11.glPushMatrix(); - GL11.glScalef(1.4F, 1.4F, 1.4F); - GL11.glRotatef(180, 0.0F, 0.0F, 1.0F); + MekanismRenderer.renderItem(item); - if(type == ItemRenderType.EQUIPPED) - { - GL11.glRotatef(-45, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(50, 1.0F, 0.0F, 0.0F); - GL11.glScalef(2.0F, 2.0F, 2.0F); - GL11.glTranslatef(0.0F, -0.4F, 0.4F); - } - else if(type == ItemRenderType.INVENTORY) - { - GL11.glRotatef(225, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(45, -1.0F, 0.0F, -1.0F); - GL11.glScalef(0.6F, 0.6F, 0.6F); - GL11.glTranslatef(0.0F, -0.2F, 0.0F); - } - else { - GL11.glRotatef(45, 0.0F, 1.0F, 0.0F); - GL11.glTranslatef(0.0F, -0.7F, 0.0F); - } + if (((ItemWalkieTalkie) item.getItem()).getOn(item)) { + MekanismRenderer.glowOff(); + } + } else if (MachineType.get(item) == MachineType.PERSONAL_CHEST) { + GL11.glPushMatrix(); + ItemBlockMachine chest = (ItemBlockMachine) item.getItem(); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "AtomicDisassembler.png")); - atomicDisassembler.render(0.0625F); - GL11.glPopMatrix(); - } - else if(item.getItem() instanceof ItemPartTransmitter) - { - GL11.glPushMatrix(); - GL11.glTranslated(-0.5, -0.5, -0.5); - MekanismRenderer.blendOn(); - GL11.glDisable(GL11.GL_CULL_FACE); - RenderPartTransmitter.getInstance().renderItem(TransmitterType.values()[item.getItemDamage()]); - GL11.glEnable(GL11.GL_CULL_FACE); - MekanismRenderer.blendOff(); - GL11.glPopMatrix(); - } - else if(item.getItem() instanceof ItemGlowPanel) - { - GL11.glPushMatrix(); - GL11.glPushAttrib(GL11.GL_LIGHTING_BIT); - GL11.glTranslated(-0.5, -0.5, -0.5); - double d = 0.15; - GL11.glTranslated(d, d, d); - GL11.glScaled(2, 2, 2); - GL11.glTranslated(0.4-2*d, -2*d, -2*d); - GL11.glDisable(GL11.GL_CULL_FACE); - RenderHelper.disableStandardItemLighting(); - RenderGlowPanel.getInstance().renderItem(item.getItemDamage()); - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glPopAttrib(); - GL11.glPopMatrix(); - } - else if(item.getItem() instanceof ItemFlamethrower) - { - GL11.glPushMatrix(); - GL11.glRotatef(160, 0.0F, 0.0F, 1.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "Flamethrower.png")); - - GL11.glTranslatef(0.0F, -1.0F, 0.0F); - GL11.glRotatef(135, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(-20, 0.0F, 0.0F, 1.0F); - - if(type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) - { - if(type == ItemRenderType.EQUIPPED_FIRST_PERSON) - { - GL11.glRotatef(55, 0.0F, 1.0F, 0.0F); - } - else { - GL11.glTranslatef(0.0F, 0.5F, 0.0F); - } - - GL11.glScalef(2.5F, 2.5F, 2.5F); - GL11.glTranslatef(0.0F, -1.0F, -0.5F); - } - else if(type == ItemRenderType.INVENTORY) - { - GL11.glTranslatef(-0.6F, 0.0F, 0.0F); - GL11.glRotatef(45, 0.0F, 1.0F, 0.0F); - } - - flamethrower.render(0.0625F); - GL11.glPopMatrix(); - } - else if(MachineType.get(item) == MachineType.FLUID_TANK) - { - GL11.glPushMatrix(); - GL11.glRotatef(270F, 0.0F, -1.0F, 0.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "FluidTank.png")); - ItemBlockMachine itemMachine = (ItemBlockMachine)item.getItem(); - float targetScale = (float)(itemMachine.getFluidStack(item) != null ? itemMachine.getFluidStack(item).amount : 0)/itemMachine.getCapacity(item); - FluidTankTier tier = FluidTankTier.values()[itemMachine.getBaseTier(item).ordinal()]; - Fluid fluid = itemMachine.getFluidStack(item) != null ? itemMachine.getFluidStack(item).getFluid() : null; - portableTankRenderer.render(tier, fluid, targetScale, false, null, -0.5, -0.5, -0.5); - GL11.glPopMatrix(); - } - else { - if(item.getItem() instanceof ItemBlockMachine) - { - MachineType machine = MachineType.get(item); - - if(machine == MachineType.BASIC_FACTORY || machine == MachineType.ADVANCED_FACTORY || machine == MachineType.ELITE_FACTORY) - { - GL11.glRotatef(-90F, 0.0F, 1.0F, 0.0F); - MekanismRenderer.renderCustomItem(((RenderBlocks)data[0]), item); - } - else { - RenderingRegistry.instance().renderInventoryBlock((RenderBlocks)data[0], Block.getBlockFromItem(item.getItem()), item.getItemDamage(), ClientProxy.MACHINE_RENDER_ID); - } - } - else if(item.getItem() instanceof ItemBlockBasic) - { - RenderingRegistry.instance().renderInventoryBlock((RenderBlocks)data[0], Block.getBlockFromItem(item.getItem()), item.getItemDamage(), ClientProxy.BASIC_RENDER_ID); - } - } - } + GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(-0.5F, -0.5F, -0.5F); + GL11.glTranslatef(0, 1.0F, 1.0F); + GL11.glScalef(1.0F, -1F, -1F); + + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "PersonalChest.png") + ); + + personalChest.renderAll(); + GL11.glPopMatrix(); + } else if (item.getItem() instanceof ItemRobit) { + GL11.glPushMatrix(); + GL11.glRotatef(180, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(90, 0.0F, -1.0F, 0.0F); + GL11.glTranslatef(0.0F, -1.5F, 0.0F); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "Robit.png") + ); + robit.render(0.08F); + GL11.glPopMatrix(); + } else if (item.getItem() == MekanismItems.Jetpack) { + GL11.glPushMatrix(); + GL11.glRotatef(180, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(90, 0.0F, -1.0F, 0.0F); + GL11.glTranslatef(0.2F, -0.35F, 0.0F); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "Jetpack.png") + ); + jetpack.render(0.0625F); + GL11.glPopMatrix(); + } else if (item.getItem() == MekanismItems.ArmoredJetpack) { + GL11.glPushMatrix(); + GL11.glRotatef(180, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(90, 0.0F, -1.0F, 0.0F); + GL11.glTranslatef(0.2F, -0.35F, 0.0F); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "Jetpack.png") + ); + armoredJetpack.render(0.0625F); + GL11.glPopMatrix(); + } else if (item.getItem() instanceof ItemGasMask) { + GL11.glPushMatrix(); + GL11.glRotatef(180, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(90, 0.0F, -1.0F, 0.0F); + GL11.glTranslatef(0.1F, 0.2F, 0.0F); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "ScubaSet.png") + ); + gasMask.render(0.0625F); + GL11.glPopMatrix(); + } else if (item.getItem() instanceof ItemScubaTank) { + GL11.glPushMatrix(); + GL11.glRotatef(180, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(90, 0.0F, -1.0F, 0.0F); + GL11.glScalef(1.6F, 1.6F, 1.6F); + GL11.glTranslatef(0.2F, -0.5F, 0.0F); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "ScubaSet.png") + ); + scubaTank.render(0.0625F); + GL11.glPopMatrix(); + } else if (item.getItem() instanceof ItemFreeRunners) { + GL11.glPushMatrix(); + GL11.glRotatef(180, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(90, 0.0F, -1.0F, 0.0F); + GL11.glScalef(2.0F, 2.0F, 2.0F); + GL11.glTranslatef(0.2F, -1.43F, 0.12F); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "FreeRunners.png") + ); + freeRunners.render(0.0625F); + GL11.glPopMatrix(); + } else if (item.getItem() instanceof ItemBalloon) { + GL11.glPushMatrix(); + + if (type == ItemRenderType.EQUIPPED + || type == ItemRenderType.EQUIPPED_FIRST_PERSON) { + GL11.glScalef(2.5F, 2.5F, 2.5F); + GL11.glTranslatef(0.2F, 0, 0.1F); + GL11.glRotatef(15, -1, 0, 1); + balloonRenderer.render( + ((ItemBalloon) item.getItem()).getColor(item), 0, 1.9F, 0 + ); + } else { + balloonRenderer.render( + ((ItemBalloon) item.getItem()).getColor(item), 0, 1, 0 + ); + } + + GL11.glPopMatrix(); + } else if (item.getItem() instanceof ItemAtomicDisassembler) { + GL11.glPushMatrix(); + GL11.glScalef(1.4F, 1.4F, 1.4F); + GL11.glRotatef(180, 0.0F, 0.0F, 1.0F); + + if (type == ItemRenderType.EQUIPPED) { + GL11.glRotatef(-45, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(50, 1.0F, 0.0F, 0.0F); + GL11.glScalef(2.0F, 2.0F, 2.0F); + GL11.glTranslatef(0.0F, -0.4F, 0.4F); + } else if (type == ItemRenderType.INVENTORY) { + GL11.glRotatef(225, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(45, -1.0F, 0.0F, -1.0F); + GL11.glScalef(0.6F, 0.6F, 0.6F); + GL11.glTranslatef(0.0F, -0.2F, 0.0F); + } else { + GL11.glRotatef(45, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(0.0F, -0.7F, 0.0F); + } + + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "AtomicDisassembler.png") + ); + atomicDisassembler.render(0.0625F); + GL11.glPopMatrix(); + } else if (item.getItem() instanceof ItemPartTransmitter) { + GL11.glPushMatrix(); + GL11.glTranslated(-0.5, -0.5, -0.5); + MekanismRenderer.blendOn(); + GL11.glDisable(GL11.GL_CULL_FACE); + RenderPartTransmitter.getInstance().renderItem(TransmitterType.values( + )[item.getItemDamage()]); + GL11.glEnable(GL11.GL_CULL_FACE); + MekanismRenderer.blendOff(); + GL11.glPopMatrix(); + } else if (item.getItem() instanceof ItemGlowPanel) { + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_LIGHTING_BIT); + GL11.glTranslated(-0.5, -0.5, -0.5); + double d = 0.15; + GL11.glTranslated(d, d, d); + GL11.glScaled(2, 2, 2); + GL11.glTranslated(0.4 - 2 * d, -2 * d, -2 * d); + GL11.glDisable(GL11.GL_CULL_FACE); + RenderHelper.disableStandardItemLighting(); + RenderGlowPanel.getInstance().renderItem(item.getItemDamage()); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glPopAttrib(); + GL11.glPopMatrix(); + } else if (item.getItem() instanceof ItemFlamethrower) { + GL11.glPushMatrix(); + GL11.glRotatef(160, 0.0F, 0.0F, 1.0F); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "Flamethrower.png") + ); + + GL11.glTranslatef(0.0F, -1.0F, 0.0F); + GL11.glRotatef(135, 0.0F, 1.0F, 0.0F); + GL11.glRotatef(-20, 0.0F, 0.0F, 1.0F); + + if (type == ItemRenderType.EQUIPPED + || type == ItemRenderType.EQUIPPED_FIRST_PERSON) { + if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) { + GL11.glRotatef(55, 0.0F, 1.0F, 0.0F); + } else { + GL11.glTranslatef(0.0F, 0.5F, 0.0F); + } + + GL11.glScalef(2.5F, 2.5F, 2.5F); + GL11.glTranslatef(0.0F, -1.0F, -0.5F); + } else if (type == ItemRenderType.INVENTORY) { + GL11.glTranslatef(-0.6F, 0.0F, 0.0F); + GL11.glRotatef(45, 0.0F, 1.0F, 0.0F); + } + + flamethrower.render(0.0625F); + GL11.glPopMatrix(); + } else if (MachineType.get(item) == MachineType.FLUID_TANK) { + GL11.glPushMatrix(); + GL11.glRotatef(270F, 0.0F, -1.0F, 0.0F); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "FluidTank.png") + ); + ItemBlockMachine itemMachine = (ItemBlockMachine) item.getItem(); + float targetScale = (float + ) (itemMachine.getFluidStack(item) != null + ? itemMachine.getFluidStack(item).amount + : 0) + / itemMachine.getCapacity(item); + FluidTankTier tier + = FluidTankTier.values()[itemMachine.getBaseTier(item).ordinal()]; + Fluid fluid = itemMachine.getFluidStack(item) != null + ? itemMachine.getFluidStack(item).getFluid() + : null; + portableTankRenderer.render( + tier, fluid, targetScale, false, null, -0.5, -0.5, -0.5 + ); + GL11.glPopMatrix(); + } else { + if (item.getItem() instanceof ItemBlockMachine) { + MachineType machine = MachineType.get(item); + + if (machine == MachineType.BASIC_FACTORY + || machine == MachineType.ADVANCED_FACTORY + || machine == MachineType.ELITE_FACTORY) { + GL11.glRotatef(-90F, 0.0F, 1.0F, 0.0F); + MekanismRenderer.renderCustomItem(((RenderBlocks) data[0]), item); + } else { + RenderingRegistry.instance().renderInventoryBlock( + (RenderBlocks) data[0], + Block.getBlockFromItem(item.getItem()), + item.getItemDamage(), + ClientProxy.MACHINE_RENDER_ID + ); + } + } else if (item.getItem() instanceof ItemBlockBasic) { + RenderingRegistry.instance().renderInventoryBlock( + (RenderBlocks) data[0], + Block.getBlockFromItem(item.getItem()), + item.getItemDamage(), + ClientProxy.BASIC_RENDER_ID + ); + } + } + } } diff --git a/src/main/java/mekanism/client/render/particle/EntityJetpackFlameFX.java b/src/main/java/mekanism/client/render/particle/EntityJetpackFlameFX.java index cbfa5c1cd..b24b5a0a2 100644 --- a/src/main/java/mekanism/client/render/particle/EntityJetpackFlameFX.java +++ b/src/main/java/mekanism/client/render/particle/EntityJetpackFlameFX.java @@ -1,37 +1,56 @@ package mekanism.client.render.particle; +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.client.particle.EntityFlameFX; import net.minecraft.client.renderer.Tessellator; import net.minecraft.world.World; -import cpw.mods.fml.client.FMLClientHandler; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class EntityJetpackFlameFX extends EntityFlameFX -{ - private static Minecraft mc = FMLClientHandler.instance().getClient(); +public class EntityJetpackFlameFX extends EntityFlameFX { + private static Minecraft mc = FMLClientHandler.instance().getClient(); - public EntityJetpackFlameFX(World world, double posX, double posY, double posZ, double velX, double velY, double velZ) - { - super(world, posX, posY, posZ, velX, velY, velZ); - - noClip = false; - } + public EntityJetpackFlameFX( + World world, + double posX, + double posY, + double posZ, + double velX, + double velY, + double velZ + ) { + super(world, posX, posY, posZ, velX, velY, velZ); - @Override - public int getBrightnessForRender(float p_70013_1_) - { - return 190 + (int)(20F * (1.0F - mc.gameSettings.gammaSetting)); - } + noClip = false; + } - @Override - public void renderParticle(Tessellator p_70539_1_, float p_70539_2_, float p_70539_3_, float p_70539_4_, float p_70539_5_, float p_70539_6_, float p_70539_7_) - { - if(particleAge > 0) - { - super.renderParticle(p_70539_1_, p_70539_2_, p_70539_3_, p_70539_4_, p_70539_5_, p_70539_6_, p_70539_7_); - } - } + @Override + public int getBrightnessForRender(float p_70013_1_) { + return 190 + (int) (20F * (1.0F - mc.gameSettings.gammaSetting)); + } + + @Override + public void renderParticle( + Tessellator p_70539_1_, + float p_70539_2_, + float p_70539_3_, + float p_70539_4_, + float p_70539_5_, + float p_70539_6_, + float p_70539_7_ + ) { + if (particleAge > 0) { + super.renderParticle( + p_70539_1_, + p_70539_2_, + p_70539_3_, + p_70539_4_, + p_70539_5_, + p_70539_6_, + p_70539_7_ + ); + } + } } diff --git a/src/main/java/mekanism/client/render/particle/EntityJetpackSmokeFX.java b/src/main/java/mekanism/client/render/particle/EntityJetpackSmokeFX.java index b7609ecd6..bca25e5bf 100644 --- a/src/main/java/mekanism/client/render/particle/EntityJetpackSmokeFX.java +++ b/src/main/java/mekanism/client/render/particle/EntityJetpackSmokeFX.java @@ -1,37 +1,56 @@ package mekanism.client.render.particle; +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.client.particle.EntitySmokeFX; import net.minecraft.client.renderer.Tessellator; import net.minecraft.world.World; -import cpw.mods.fml.client.FMLClientHandler; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class EntityJetpackSmokeFX extends EntitySmokeFX -{ - private static Minecraft mc = FMLClientHandler.instance().getClient(); +public class EntityJetpackSmokeFX extends EntitySmokeFX { + private static Minecraft mc = FMLClientHandler.instance().getClient(); - public EntityJetpackSmokeFX(World world, double posX, double posY, double posZ, double velX, double velY, double velZ) - { - super(world, posX, posY, posZ, velX, velY, velZ); - - noClip = false; - } + public EntityJetpackSmokeFX( + World world, + double posX, + double posY, + double posZ, + double velX, + double velY, + double velZ + ) { + super(world, posX, posY, posZ, velX, velY, velZ); - @Override - public int getBrightnessForRender(float p_70013_1_) - { - return 190 + (int)(20F * (1.0F - mc.gameSettings.gammaSetting)); - } + noClip = false; + } - @Override - public void renderParticle(Tessellator p_70539_1_, float p_70539_2_, float p_70539_3_, float p_70539_4_, float p_70539_5_, float p_70539_6_, float p_70539_7_) - { - if(particleAge > 0) - { - super.renderParticle(p_70539_1_, p_70539_2_, p_70539_3_, p_70539_4_, p_70539_5_, p_70539_6_, p_70539_7_); - } - } + @Override + public int getBrightnessForRender(float p_70013_1_) { + return 190 + (int) (20F * (1.0F - mc.gameSettings.gammaSetting)); + } + + @Override + public void renderParticle( + Tessellator p_70539_1_, + float p_70539_2_, + float p_70539_3_, + float p_70539_4_, + float p_70539_5_, + float p_70539_6_, + float p_70539_7_ + ) { + if (particleAge > 0) { + super.renderParticle( + p_70539_1_, + p_70539_2_, + p_70539_3_, + p_70539_4_, + p_70539_5_, + p_70539_6_, + p_70539_7_ + ); + } + } } diff --git a/src/main/java/mekanism/client/render/particle/EntityScubaBubbleFX.java b/src/main/java/mekanism/client/render/particle/EntityScubaBubbleFX.java index 468f7bd1a..48ef1ed3e 100644 --- a/src/main/java/mekanism/client/render/particle/EntityScubaBubbleFX.java +++ b/src/main/java/mekanism/client/render/particle/EntityScubaBubbleFX.java @@ -1,41 +1,60 @@ package mekanism.client.render.particle; +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.Minecraft; import net.minecraft.client.particle.EntityBubbleFX; import net.minecraft.client.renderer.Tessellator; import net.minecraft.world.World; -import cpw.mods.fml.client.FMLClientHandler; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class EntityScubaBubbleFX extends EntityBubbleFX -{ - private static Minecraft mc = FMLClientHandler.instance().getClient(); - - public EntityScubaBubbleFX(World world, double posX, double posY, double posZ, double velX, double velY, double velZ) - { - super(world, posX, posY, posZ, velX, velY, velZ); - - particleScale = (rand.nextFloat()*0.2F)+0.5F; - particleMaxAge *= 2; - } - - @Override - public void onUpdate() - { - super.onUpdate(); - - particleAge++; +public class EntityScubaBubbleFX extends EntityBubbleFX { + private static Minecraft mc = FMLClientHandler.instance().getClient(); + + public EntityScubaBubbleFX( + World world, + double posX, + double posY, + double posZ, + double velX, + double velY, + double velZ + ) { + super(world, posX, posY, posZ, velX, velY, velZ); + + particleScale = (rand.nextFloat() * 0.2F) + 0.5F; + particleMaxAge *= 2; + } + + @Override + public void onUpdate() { + super.onUpdate(); + + particleAge++; + } + + @Override + public void renderParticle( + Tessellator p_70539_1_, + float p_70539_2_, + float p_70539_3_, + float p_70539_4_, + float p_70539_5_, + float p_70539_6_, + float p_70539_7_ + ) { + if (particleAge > 0) { + particleAlpha = Math.min(1, (particleAge + p_70539_2_) / 20F); + super.renderParticle( + p_70539_1_, + p_70539_2_, + p_70539_3_, + p_70539_4_, + p_70539_5_, + p_70539_6_, + p_70539_7_ + ); + } } - - @Override - public void renderParticle(Tessellator p_70539_1_, float p_70539_2_, float p_70539_3_, float p_70539_4_, float p_70539_5_, float p_70539_6_, float p_70539_7_) - { - if(particleAge > 0) - { - particleAlpha = Math.min(1, (particleAge+p_70539_2_)/20F); - super.renderParticle(p_70539_1_, p_70539_2_, p_70539_3_, p_70539_4_, p_70539_5_, p_70539_6_, p_70539_7_); - } - } } diff --git a/src/main/java/mekanism/client/render/tileentity/RenderBin.java b/src/main/java/mekanism/client/render/tileentity/RenderBin.java index 4b857bcfc..fbb483fad 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderBin.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderBin.java @@ -1,5 +1,7 @@ package mekanism.client.render.tileentity; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.client.render.MekanismRenderer; import mekanism.common.tile.TileEntityBin; @@ -12,159 +14,170 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class RenderBin extends TileEntitySpecialRenderer -{ - private final RenderBlocks renderBlocks = new RenderBlocks(); - private final RenderItem renderItem = new RenderItem(); +public class RenderBin extends TileEntitySpecialRenderer { + private final RenderBlocks renderBlocks = new RenderBlocks(); + private final RenderItem renderItem = new RenderItem(); - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntityBin)tileEntity, x, y, z, partialTick); - } + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt((TileEntityBin) tileEntity, x, y, z, partialTick); + } - @SuppressWarnings("incomplete-switch") - private void renderAModelAt(TileEntityBin tileEntity, double x, double y, double z, float partialTick) - { - if(tileEntity instanceof TileEntityBin) - { - String amount = ""; - ItemStack itemStack = tileEntity.itemType; + @SuppressWarnings("incomplete-switch") + private void renderAModelAt( + TileEntityBin tileEntity, double x, double y, double z, float partialTick + ) { + if (tileEntity instanceof TileEntityBin) { + String amount = ""; + ItemStack itemStack = tileEntity.itemType; - if(itemStack != null) - { - amount = Integer.toString(tileEntity.clientAmount); - } + if (itemStack != null) { + amount = Integer.toString(tileEntity.clientAmount); + } - Coord4D obj = Coord4D.get(tileEntity).getFromSide(ForgeDirection.getOrientation(tileEntity.facing)); + Coord4D obj + = Coord4D.get(tileEntity) + .getFromSide(ForgeDirection.getOrientation(tileEntity.facing)); - if(tileEntity.getWorldObj().getBlock(obj.xCoord, obj.yCoord, obj.zCoord).isSideSolid(tileEntity.getWorldObj(), obj.xCoord, obj.yCoord, obj.zCoord, ForgeDirection.getOrientation(tileEntity.facing).getOpposite())) - { - return; - } + if (tileEntity.getWorldObj() + .getBlock(obj.xCoord, obj.yCoord, obj.zCoord) + .isSideSolid( + tileEntity.getWorldObj(), + obj.xCoord, + obj.yCoord, + obj.zCoord, + ForgeDirection.getOrientation(tileEntity.facing).getOpposite() + )) { + return; + } - MekanismRenderer.glowOn(); - - if(itemStack != null) - { - GL11.glPushMatrix(); + MekanismRenderer.glowOn(); - switch(ForgeDirection.getOrientation(tileEntity.facing)) - { - case NORTH: - GL11.glTranslated(x + 0.73, y + 0.83, z - 0.01); - break; - case SOUTH: - GL11.glTranslated(x + 0.27, y + 0.83, z + 1.01); - GL11.glRotatef(180, 0, 1, 0); - break; - case WEST: - GL11.glTranslated(x - 0.01, y + 0.83, z + 0.27); - GL11.glRotatef(90, 0, 1, 0); - break; - case EAST: - GL11.glTranslated(x + 1.01, y + 0.83, z + 0.73); - GL11.glRotatef(-90, 0, 1, 0); - break; - } + if (itemStack != null) { + GL11.glPushMatrix(); - float scale = 0.03125F; - float scaler = 0.9F; + switch (ForgeDirection.getOrientation(tileEntity.facing)) { + case NORTH: + GL11.glTranslated(x + 0.73, y + 0.83, z - 0.01); + break; + case SOUTH: + GL11.glTranslated(x + 0.27, y + 0.83, z + 1.01); + GL11.glRotatef(180, 0, 1, 0); + break; + case WEST: + GL11.glTranslated(x - 0.01, y + 0.83, z + 0.27); + GL11.glRotatef(90, 0, 1, 0); + break; + case EAST: + GL11.glTranslated(x + 1.01, y + 0.83, z + 0.73); + GL11.glRotatef(-90, 0, 1, 0); + break; + } - GL11.glScalef(scale*scaler, scale*scaler, -0.0001F); - GL11.glRotatef(180, 0, 0, 1); + float scale = 0.03125F; + float scaler = 0.9F; - TextureManager renderEngine = Minecraft.getMinecraft().renderEngine; + GL11.glScalef(scale * scaler, scale * scaler, -0.0001F); + GL11.glRotatef(180, 0, 0, 1); - renderItem.renderItemAndEffectIntoGUI(func_147498_b()/*getFontRenderer()*/, renderEngine, itemStack, 0, 0); - - GL11.glPopMatrix(); - } + TextureManager renderEngine = Minecraft.getMinecraft().renderEngine; - if(amount != "") - { - renderText(amount, ForgeDirection.getOrientation(tileEntity.facing), 0.02F, x, y - 0.3725F, z); - } - - MekanismRenderer.glowOff(); - } - } + renderItem.renderItemAndEffectIntoGUI( + func_147498_b() /*getFontRenderer()*/, renderEngine, itemStack, 0, 0 + ); - @SuppressWarnings("incomplete-switch") - private void renderText(String text, ForgeDirection side, float maxScale, double x, double y, double z) - { - GL11.glPushMatrix(); + GL11.glPopMatrix(); + } - GL11.glPolygonOffset(-10, -10); - GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL); + if (amount != "") { + renderText( + amount, + ForgeDirection.getOrientation(tileEntity.facing), + 0.02F, + x, + y - 0.3725F, + z + ); + } - float displayWidth = 1 - (2 / 16); - float displayHeight = 1 - (2 / 16); - GL11.glTranslated(x, y, z); + MekanismRenderer.glowOff(); + } + } - switch(side) - { - case SOUTH: - GL11.glTranslatef(0, 1, 0); - GL11.glRotatef(0, 0, 1, 0); - GL11.glRotatef(90, 1, 0, 0); - break; - case NORTH: - GL11.glTranslatef(1, 1, 1); - GL11.glRotatef(180, 0, 1, 0); - GL11.glRotatef(90, 1, 0, 0); - break; - case EAST: - GL11.glTranslatef(0, 1, 1); - GL11.glRotatef(90, 0, 1, 0); - GL11.glRotatef(90, 1, 0, 0); - break; - case WEST: - GL11.glTranslatef(1, 1, 0); - GL11.glRotatef(-90, 0, 1, 0); - GL11.glRotatef(90, 1, 0, 0); - break; - } + @SuppressWarnings("incomplete-switch") + private void renderText( + String text, ForgeDirection side, float maxScale, double x, double y, double z + ) { + GL11.glPushMatrix(); - GL11.glTranslatef(displayWidth / 2, 1F, displayHeight / 2); - GL11.glRotatef(-90, 1, 0, 0); + GL11.glPolygonOffset(-10, -10); + GL11.glEnable(GL11.GL_POLYGON_OFFSET_FILL); - FontRenderer fontRenderer = func_147498_b();//getFontRenderer(); + float displayWidth = 1 - (2 / 16); + float displayHeight = 1 - (2 / 16); + GL11.glTranslated(x, y, z); - int requiredWidth = Math.max(fontRenderer.getStringWidth(text), 1); - int lineHeight = fontRenderer.FONT_HEIGHT + 2; - int requiredHeight = lineHeight * 1; - float scaler = 0.4F; - float scaleX = (displayWidth / requiredWidth); - float scale = scaleX * scaler; + switch (side) { + case SOUTH: + GL11.glTranslatef(0, 1, 0); + GL11.glRotatef(0, 0, 1, 0); + GL11.glRotatef(90, 1, 0, 0); + break; + case NORTH: + GL11.glTranslatef(1, 1, 1); + GL11.glRotatef(180, 0, 1, 0); + GL11.glRotatef(90, 1, 0, 0); + break; + case EAST: + GL11.glTranslatef(0, 1, 1); + GL11.glRotatef(90, 0, 1, 0); + GL11.glRotatef(90, 1, 0, 0); + break; + case WEST: + GL11.glTranslatef(1, 1, 0); + GL11.glRotatef(-90, 0, 1, 0); + GL11.glRotatef(90, 1, 0, 0); + break; + } - if(maxScale > 0) - { - scale = Math.min(scale, maxScale); - } + GL11.glTranslatef(displayWidth / 2, 1F, displayHeight / 2); + GL11.glRotatef(-90, 1, 0, 0); - GL11.glScalef(scale, -scale, scale); - GL11.glDepthMask(false); + FontRenderer fontRenderer = func_147498_b(); //getFontRenderer(); - int realHeight = (int)Math.floor(displayHeight / scale); - int realWidth = (int)Math.floor(displayWidth / scale); + int requiredWidth = Math.max(fontRenderer.getStringWidth(text), 1); + int lineHeight = fontRenderer.FONT_HEIGHT + 2; + int requiredHeight = lineHeight * 1; + float scaler = 0.4F; + float scaleX = (displayWidth / requiredWidth); + float scale = scaleX * scaler; - int offsetX = (realWidth - requiredWidth) / 2; - int offsetY = (realHeight - requiredHeight) / 2; + if (maxScale > 0) { + scale = Math.min(scale, maxScale); + } - GL11.glDisable(GL11.GL_LIGHTING); - fontRenderer.drawString("\u00a7f" + text, offsetX - (realWidth / 2), 1 + offsetY - (realHeight / 2), 1); - GL11.glEnable(GL11.GL_LIGHTING); - GL11.glDepthMask(true); - GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL); + GL11.glScalef(scale, -scale, scale); + GL11.glDepthMask(false); - GL11.glPopMatrix(); - } + int realHeight = (int) Math.floor(displayHeight / scale); + int realWidth = (int) Math.floor(displayWidth / scale); + + int offsetX = (realWidth - requiredWidth) / 2; + int offsetY = (realHeight - requiredHeight) / 2; + + GL11.glDisable(GL11.GL_LIGHTING); + fontRenderer.drawString( + "\u00a7f" + text, offsetX - (realWidth / 2), 1 + offsetY - (realHeight / 2), 1 + ); + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glDepthMask(true); + GL11.glDisable(GL11.GL_POLYGON_OFFSET_FILL); + + GL11.glPopMatrix(); + } } diff --git a/src/main/java/mekanism/client/render/tileentity/RenderChargepad.java b/src/main/java/mekanism/client/render/tileentity/RenderChargepad.java index f01e85ec0..2413bfb33 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderChargepad.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderChargepad.java @@ -1,44 +1,50 @@ package mekanism.client.render.tileentity; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.model.ModelChargepad; import mekanism.common.tile.TileEntityChargepad; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class RenderChargepad extends TileEntitySpecialRenderer -{ - private ModelChargepad model = new ModelChargepad(); +public class RenderChargepad extends TileEntitySpecialRenderer { + private ModelChargepad model = new ModelChargepad(); - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntityChargepad)tileEntity, x, y, z, partialTick); - } + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt((TileEntityChargepad) tileEntity, x, y, z, partialTick); + } - private void renderAModelAt(TileEntityChargepad tileEntity, double x, double y, double z, float partialTick) - { - GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "Chargepad.png")); + private void renderAModelAt( + TileEntityChargepad tileEntity, double x, double y, double z, float partialTick + ) { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); + bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "Chargepad.png")); - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; - case 3: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; - case 4: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; - case 5: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; - } + switch (tileEntity.facing) { + case 2: + GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); + break; + case 3: + GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); + break; + case 4: + GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); + break; + case 5: + GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); + break; + } - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - model.render(0.0625F, field_147501_a.field_147553_e); - GL11.glPopMatrix(); - } + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + model.render(0.0625F, field_147501_a.field_147553_e); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/mekanism/client/render/tileentity/RenderChemicalCrystallizer.java b/src/main/java/mekanism/client/render/tileentity/RenderChemicalCrystallizer.java index 847c9f532..4271461ba 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderChemicalCrystallizer.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderChemicalCrystallizer.java @@ -1,5 +1,7 @@ package mekanism.client.render.tileentity; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.model.ModelChemicalCrystallizer; import mekanism.client.render.MekanismRenderer; import mekanism.common.tile.TileEntityChemicalCrystallizer; @@ -7,51 +9,59 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class RenderChemicalCrystallizer extends TileEntitySpecialRenderer -{ - private ModelChemicalCrystallizer model = new ModelChemicalCrystallizer(); +public class RenderChemicalCrystallizer extends TileEntitySpecialRenderer { + private ModelChemicalCrystallizer model = new ModelChemicalCrystallizer(); - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntityChemicalCrystallizer)tileEntity, x, y, z, partialTick); - } + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt((TileEntityChemicalCrystallizer) tileEntity, x, y, z, partialTick); + } - private void renderAModelAt(TileEntityChemicalCrystallizer tileEntity, double x, double y, double z, float partialTick) - { - GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ChemicalCrystallizer.png")); + private void renderAModelAt( + TileEntityChemicalCrystallizer tileEntity, + double x, + double y, + double z, + float partialTick + ) { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); + bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "ChemicalCrystallizer.png") + ); - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; - case 3: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; - case 4: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; - case 5: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; - } + switch (tileEntity.facing) { + case 2: + GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); + break; + case 3: + GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); + break; + case 4: + GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); + break; + case 5: + GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); + break; + } - if(tileEntity.isActive) - { - tileEntity.spinSpeed = Math.min(1, tileEntity.spinSpeed+0.01F); - } - else { - tileEntity.spinSpeed = Math.max(0, tileEntity.spinSpeed-0.02F); - } + if (tileEntity.isActive) { + tileEntity.spinSpeed = Math.min(1, tileEntity.spinSpeed + 0.01F); + } else { + tileEntity.spinSpeed = Math.max(0, tileEntity.spinSpeed - 0.02F); + } - tileEntity.spin = (tileEntity.spin + (tileEntity.spinSpeed*0.1F)) % 1; + tileEntity.spin = (tileEntity.spin + (tileEntity.spinSpeed * 0.1F)) % 1; - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - model.render(0.0625F); - GL11.glPopMatrix(); + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + model.render(0.0625F); + GL11.glPopMatrix(); - MekanismRenderer.machineRenderer.renderAModelAt(tileEntity, x, y, z, partialTick); - } + MekanismRenderer.machineRenderer.renderAModelAt(tileEntity, x, y, z, partialTick); + } } diff --git a/src/main/java/mekanism/client/render/tileentity/RenderChemicalDissolutionChamber.java b/src/main/java/mekanism/client/render/tileentity/RenderChemicalDissolutionChamber.java index 2fee0e8d1..430c25bdf 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderChemicalDissolutionChamber.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderChemicalDissolutionChamber.java @@ -1,44 +1,58 @@ package mekanism.client.render.tileentity; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.model.ModelChemicalDissolutionChamber; import mekanism.common.tile.TileEntityChemicalDissolutionChamber; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class RenderChemicalDissolutionChamber extends TileEntitySpecialRenderer -{ - private ModelChemicalDissolutionChamber model = new ModelChemicalDissolutionChamber(); +public class RenderChemicalDissolutionChamber extends TileEntitySpecialRenderer { + private ModelChemicalDissolutionChamber model = new ModelChemicalDissolutionChamber(); - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntityChemicalDissolutionChamber)tileEntity, x, y, z, partialTick); - } + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt( + (TileEntityChemicalDissolutionChamber) tileEntity, x, y, z, partialTick + ); + } - private void renderAModelAt(TileEntityChemicalDissolutionChamber tileEntity, double x, double y, double z, float partialTick) - { - GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ChemicalDissolutionChamber.png")); + private void renderAModelAt( + TileEntityChemicalDissolutionChamber tileEntity, + double x, + double y, + double z, + float partialTick + ) { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); + bindTexture(MekanismUtils.getResource( + ResourceType.RENDER, "ChemicalDissolutionChamber.png" + )); - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; - case 3: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; - case 4: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; - case 5: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; - } + switch (tileEntity.facing) { + case 2: + GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); + break; + case 3: + GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); + break; + case 4: + GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); + break; + case 5: + GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); + break; + } - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - model.render(0.0625F); - GL11.glPopMatrix(); - } + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + model.render(0.0625F); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/mekanism/client/render/tileentity/RenderChemicalInfuser.java b/src/main/java/mekanism/client/render/tileentity/RenderChemicalInfuser.java index 9b3571c2c..9cbf53dc4 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderChemicalInfuser.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderChemicalInfuser.java @@ -6,37 +6,49 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; - import org.lwjgl.opengl.GL11; -public class RenderChemicalInfuser extends TileEntitySpecialRenderer -{ - private ModelChemicalInfuser model = new ModelChemicalInfuser(); +public class RenderChemicalInfuser extends TileEntitySpecialRenderer { + private ModelChemicalInfuser model = new ModelChemicalInfuser(); - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntityChemicalInfuser)tileEntity, x, y, z, partialTick); - } + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt((TileEntityChemicalInfuser) tileEntity, x, y, z, partialTick); + } - private void renderAModelAt(TileEntityChemicalInfuser tileEntity, double x, double y, double z, float partialTick) - { - GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); + private void renderAModelAt( + TileEntityChemicalInfuser tileEntity, + double x, + double y, + double z, + float partialTick + ) { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ChemicalInfuser.png")); + bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ChemicalInfuser.png") + ); - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; - case 3: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; - case 4: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; - case 5: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; - } + switch (tileEntity.facing) { + case 2: + GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); + break; + case 3: + GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); + break; + case 4: + GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); + break; + case 5: + GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); + break; + } - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - model.render(0.0625F); + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + model.render(0.0625F); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } } diff --git a/src/main/java/mekanism/client/render/tileentity/RenderChemicalOxidizer.java b/src/main/java/mekanism/client/render/tileentity/RenderChemicalOxidizer.java index 158ac18af..66ce22020 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderChemicalOxidizer.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderChemicalOxidizer.java @@ -12,42 +12,55 @@ import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; - import org.lwjgl.opengl.GL11; -public class RenderChemicalOxidizer extends TileEntitySpecialRenderer -{ - private ModelChemicalOxidizer model = new ModelChemicalOxidizer(); +public class RenderChemicalOxidizer extends TileEntitySpecialRenderer { + private ModelChemicalOxidizer model = new ModelChemicalOxidizer(); - private static final double offset = 0.001; + private static final double offset = 0.001; - private Map> cachedGasses = new HashMap>(); + private Map> cachedGasses + = new HashMap>(); - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntityChemicalOxidizer)tileEntity, x, y, z, partialTick); - } + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt((TileEntityChemicalOxidizer) tileEntity, x, y, z, partialTick); + } - private void renderAModelAt(TileEntityChemicalOxidizer tileEntity, double x, double y, double z, float partialTick) - { - GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); + private void renderAModelAt( + TileEntityChemicalOxidizer tileEntity, + double x, + double y, + double z, + float partialTick + ) { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ChemicalOxidizer.png")); + bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ChemicalOxidizer.png") + ); - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; - case 3: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; - case 4: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; - case 5: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; - } + switch (tileEntity.facing) { + case 2: + GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); + break; + case 3: + GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); + break; + case 4: + GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); + break; + case 5: + GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); + break; + } - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - model.render(0.0625F); + model.render(0.0625F); - GL11.glPopMatrix(); - } + GL11.glPopMatrix(); + } } diff --git a/src/main/java/mekanism/client/render/tileentity/RenderChemicalWasher.java b/src/main/java/mekanism/client/render/tileentity/RenderChemicalWasher.java index 04c8f889d..78ebd14e4 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderChemicalWasher.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderChemicalWasher.java @@ -6,35 +6,46 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; - import org.lwjgl.opengl.GL11; -public class RenderChemicalWasher extends TileEntitySpecialRenderer -{ - private ModelChemicalWasher model = new ModelChemicalWasher(); +public class RenderChemicalWasher extends TileEntitySpecialRenderer { + private ModelChemicalWasher model = new ModelChemicalWasher(); - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntityChemicalWasher)tileEntity, x, y, z, partialTick); - } + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt((TileEntityChemicalWasher) tileEntity, x, y, z, partialTick); + } - private void renderAModelAt(TileEntityChemicalWasher tileEntity, double x, double y, double z, float partialTick) - { - GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ChemicalWasher.png")); + private void renderAModelAt( + TileEntityChemicalWasher tileEntity, + double x, + double y, + double z, + float partialTick + ) { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); + bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ChemicalWasher.png")); - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; - case 3: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; - case 4: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; - case 5: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; - } + switch (tileEntity.facing) { + case 2: + GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); + break; + case 3: + GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); + break; + case 4: + GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); + break; + case 5: + GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); + break; + } - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - model.render(0.0625F); - GL11.glPopMatrix(); - } + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + model.render(0.0625F); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/mekanism/client/render/tileentity/RenderConfigurableMachine.java b/src/main/java/mekanism/client/render/tileentity/RenderConfigurableMachine.java index 6a62c2b1e..09ccd4235 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderConfigurableMachine.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderConfigurableMachine.java @@ -2,6 +2,10 @@ package mekanism.client.render.tileentity; import java.util.HashMap; +import codechicken.lib.math.MathHelper; +import cpw.mods.fml.client.FMLClientHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.transmitters.TransmissionType; import mekanism.client.render.MekanismRenderer; @@ -21,196 +25,192 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; - import org.lwjgl.opengl.GL11; -import codechicken.lib.math.MathHelper; -import cpw.mods.fml.client.FMLClientHandler; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class RenderConfigurableMachine extends TileEntitySpecialRenderer -{ - private Minecraft mc = FMLClientHandler.instance().getClient(); +public class RenderConfigurableMachine extends TileEntitySpecialRenderer { + private Minecraft mc = FMLClientHandler.instance().getClient(); - private HashMap> cachedOverlays = new HashMap>(); + private HashMap> + cachedOverlays + = new HashMap>(); - public RenderConfigurableMachine() - { - field_147501_a = TileEntityRendererDispatcher.instance; - } + public RenderConfigurableMachine() { + field_147501_a = TileEntityRendererDispatcher.instance; + } - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((ISideConfiguration)tileEntity, x, y, z, partialTick); - } + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt((ISideConfiguration) tileEntity, x, y, z, partialTick); + } - public void renderAModelAt(ISideConfiguration configurable, double x, double y, double z, float partialTick) - { - GL11.glPushMatrix(); + public void renderAModelAt( + ISideConfiguration configurable, double x, double y, double z, float partialTick + ) { + GL11.glPushMatrix(); - TileEntity tileEntity = (TileEntity)configurable; - EntityPlayer player = mc.thePlayer; - World world = mc.thePlayer.worldObj; - ItemStack itemStack = player.getCurrentEquippedItem(); - MovingObjectPosition pos = player.rayTrace(8.0D, 1.0F); + TileEntity tileEntity = (TileEntity) configurable; + EntityPlayer player = mc.thePlayer; + World world = mc.thePlayer.worldObj; + ItemStack itemStack = player.getCurrentEquippedItem(); + MovingObjectPosition pos = player.rayTrace(8.0D, 1.0F); - if(pos != null && itemStack != null && itemStack.getItem() instanceof ItemConfigurator && ((ItemConfigurator)itemStack.getItem()).getState(itemStack).isConfigurating()) - { - int xPos = MathHelper.floor_double(pos.blockX); - int yPos = MathHelper.floor_double(pos.blockY); - int zPos = MathHelper.floor_double(pos.blockZ); + if (pos != null && itemStack != null + && itemStack.getItem() instanceof ItemConfigurator + && ((ItemConfigurator) itemStack.getItem()) + .getState(itemStack) + .isConfigurating()) { + int xPos = MathHelper.floor_double(pos.blockX); + int yPos = MathHelper.floor_double(pos.blockY); + int zPos = MathHelper.floor_double(pos.blockZ); - Coord4D obj = new Coord4D(xPos, yPos, zPos, tileEntity.getWorldObj().provider.dimensionId); - TransmissionType type = ((ItemConfigurator)itemStack.getItem()).getState(itemStack).getTransmission(); + Coord4D obj = new Coord4D( + xPos, yPos, zPos, tileEntity.getWorldObj().provider.dimensionId + ); + TransmissionType type = ((ItemConfigurator) itemStack.getItem()) + .getState(itemStack) + .getTransmission(); - if(configurable.getConfig().supports(type)) - { - if(xPos == tileEntity.xCoord && yPos == tileEntity.yCoord && zPos == tileEntity.zCoord) - { - SideData data = configurable.getConfig().getOutput(type, pos.sideHit, configurable.getOrientation()); - - if(data != TileComponentConfig.EMPTY) - { - push(); - - MekanismRenderer.color(data.color, 0.6F); - - bindTexture(MekanismRenderer.getBlocksTexture()); - GL11.glTranslatef((float)x, (float)y, (float)z); - - int display = getOverlayDisplay(world, ForgeDirection.getOrientation(pos.sideHit), type).display; - GL11.glCallList(display); - - pop(); - } - } - } - } + if (configurable.getConfig().supports(type)) { + if (xPos == tileEntity.xCoord && yPos == tileEntity.yCoord + && zPos == tileEntity.zCoord) { + SideData data = configurable.getConfig().getOutput( + type, pos.sideHit, configurable.getOrientation() + ); - GL11.glPopMatrix(); - } + if (data != TileComponentConfig.EMPTY) { + push(); - private void pop() - { - GL11.glPopAttrib(); - MekanismRenderer.glowOff(); - MekanismRenderer.blendOff(); - GL11.glPopMatrix(); - } + MekanismRenderer.color(data.color, 0.6F); - private void push() - { - GL11.glPushMatrix(); - GL11.glPushAttrib(GL11.GL_ENABLE_BIT); - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glDisable(GL11.GL_LIGHTING); - MekanismRenderer.glowOn(); - MekanismRenderer.blendOn(); - } + bindTexture(MekanismRenderer.getBlocksTexture()); + GL11.glTranslatef((float) x, (float) y, (float) z); - private DisplayInteger getOverlayDisplay(World world, ForgeDirection side, TransmissionType type) - { - if(cachedOverlays.containsKey(side) && cachedOverlays.get(side).containsKey(type)) - { - return cachedOverlays.get(side).get(type); - } + int display + = getOverlayDisplay( + world, ForgeDirection.getOrientation(pos.sideHit), type + ) + .display; + GL11.glCallList(display); - Model3D toReturn = new Model3D(); - toReturn.baseBlock = Blocks.stone; - toReturn.setTexture(MekanismRenderer.overlays.get(type)); + pop(); + } + } + } + } - DisplayInteger display = DisplayInteger.createAndStart(); + GL11.glPopMatrix(); + } - if(cachedOverlays.containsKey(side)) - { - cachedOverlays.get(side).put(type, display); - } - else { - HashMap map = new HashMap(); - map.put(type, display); - cachedOverlays.put(side, map); - } + private void pop() { + GL11.glPopAttrib(); + MekanismRenderer.glowOff(); + MekanismRenderer.blendOff(); + GL11.glPopMatrix(); + } - switch(side) - { - case DOWN: - { - toReturn.minY = -.01; - toReturn.maxY = 0; + private void push() { + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_ENABLE_BIT); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glDisable(GL11.GL_LIGHTING); + MekanismRenderer.glowOn(); + MekanismRenderer.blendOn(); + } - toReturn.minX = 0; - toReturn.minZ = 0; - toReturn.maxX = 1; - toReturn.maxZ = 1; - break; - } - case UP: - { - toReturn.minY = 1; - toReturn.maxY = 1.01; + private DisplayInteger + getOverlayDisplay(World world, ForgeDirection side, TransmissionType type) { + if (cachedOverlays.containsKey(side) + && cachedOverlays.get(side).containsKey(type)) { + return cachedOverlays.get(side).get(type); + } - toReturn.minX = 0; - toReturn.minZ = 0; - toReturn.maxX = 1; - toReturn.maxZ = 1; - break; - } - case NORTH: - { - toReturn.minZ = -.01; - toReturn.maxZ = 0; + Model3D toReturn = new Model3D(); + toReturn.baseBlock = Blocks.stone; + toReturn.setTexture(MekanismRenderer.overlays.get(type)); - toReturn.minX = 0; - toReturn.minY = 0; - toReturn.maxX = 1; - toReturn.maxY = 1; - break; - } - case SOUTH: - { - toReturn.minZ = 1; - toReturn.maxZ = 1.01; + DisplayInteger display = DisplayInteger.createAndStart(); - toReturn.minX = 0; - toReturn.minY = 0; - toReturn.maxX = 1; - toReturn.maxY = 1; - break; - } - case WEST: - { - toReturn.minX = -.01; - toReturn.maxX = 0; + if (cachedOverlays.containsKey(side)) { + cachedOverlays.get(side).put(type, display); + } else { + HashMap map + = new HashMap(); + map.put(type, display); + cachedOverlays.put(side, map); + } - toReturn.minY = 0; - toReturn.minZ = 0; - toReturn.maxY = 1; - toReturn.maxZ = 1; - break; - } - case EAST: - { - toReturn.minX = 1; - toReturn.maxX = 1.01; + switch (side) { + case DOWN: { + toReturn.minY = -.01; + toReturn.maxY = 0; - toReturn.minY = 0; - toReturn.minZ = 0; - toReturn.maxY = 1; - toReturn.maxZ = 1; - break; - } - default: - { - break; - } - } + toReturn.minX = 0; + toReturn.minZ = 0; + toReturn.maxX = 1; + toReturn.maxZ = 1; + break; + } + case UP: { + toReturn.minY = 1; + toReturn.maxY = 1.01; - MekanismRenderer.renderObject(toReturn); - display.endList(); + toReturn.minX = 0; + toReturn.minZ = 0; + toReturn.maxX = 1; + toReturn.maxZ = 1; + break; + } + case NORTH: { + toReturn.minZ = -.01; + toReturn.maxZ = 0; - return display; - } + toReturn.minX = 0; + toReturn.minY = 0; + toReturn.maxX = 1; + toReturn.maxY = 1; + break; + } + case SOUTH: { + toReturn.minZ = 1; + toReturn.maxZ = 1.01; + + toReturn.minX = 0; + toReturn.minY = 0; + toReturn.maxX = 1; + toReturn.maxY = 1; + break; + } + case WEST: { + toReturn.minX = -.01; + toReturn.maxX = 0; + + toReturn.minY = 0; + toReturn.minZ = 0; + toReturn.maxY = 1; + toReturn.maxZ = 1; + break; + } + case EAST: { + toReturn.minX = 1; + toReturn.maxX = 1.01; + + toReturn.minY = 0; + toReturn.minZ = 0; + toReturn.maxY = 1; + toReturn.maxZ = 1; + break; + } + default: { + break; + } + } + + MekanismRenderer.renderObject(toReturn); + display.endList(); + + return display; + } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/render/tileentity/RenderDigitalMiner.java b/src/main/java/mekanism/client/render/tileentity/RenderDigitalMiner.java index a731187fa..148066213 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderDigitalMiner.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderDigitalMiner.java @@ -1,5 +1,7 @@ package mekanism.client.render.tileentity; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.model.ModelDigitalMiner; import mekanism.client.render.MinerVisualRenderer; import mekanism.common.tile.TileEntityDigitalMiner; @@ -7,57 +9,52 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class RenderDigitalMiner extends TileEntitySpecialRenderer -{ - private ModelDigitalMiner model = new ModelDigitalMiner(); +public class RenderDigitalMiner extends TileEntitySpecialRenderer { + private ModelDigitalMiner model = new ModelDigitalMiner(); - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntityDigitalMiner)tileEntity, x, y, z, partialTick); - } + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt((TileEntityDigitalMiner) tileEntity, x, y, z, partialTick); + } - private void renderAModelAt(TileEntityDigitalMiner tileEntity, double x, double y, double z, float partialTick) - { - GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); + private void renderAModelAt( + TileEntityDigitalMiner tileEntity, double x, double y, double z, float partialTick + ) { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "DigitalMiner.png")); + bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "DigitalMiner.png")); - switch(tileEntity.facing) - { - case 2: - GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); - GL11.glTranslatef(0.0F, 0.0F, -1.0F); - break; - case 3: - GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); - GL11.glTranslatef(0.0F, 0.0F, -1.0F); - break; - case 4: - GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); - GL11.glTranslatef(0.0F, 0.0F, -1.0F); - break; - case 5: - GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); - GL11.glTranslatef(0.0F, 0.0F, -1.0F); - break; - } + switch (tileEntity.facing) { + case 2: + GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(0.0F, 0.0F, -1.0F); + break; + case 3: + GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(0.0F, 0.0F, -1.0F); + break; + case 4: + GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(0.0F, 0.0F, -1.0F); + break; + case 5: + GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(0.0F, 0.0F, -1.0F); + break; + } - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - model.render(0.0625F, tileEntity.isActive, field_147501_a.field_147553_e); - GL11.glPopMatrix(); - - if(tileEntity.clientRendering) - { - MinerVisualRenderer.render(tileEntity); - } - } + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + model.render(0.0625F, tileEntity.isActive, field_147501_a.field_147553_e); + GL11.glPopMatrix(); + + if (tileEntity.clientRendering) { + MinerVisualRenderer.render(tileEntity); + } + } } diff --git a/src/main/java/mekanism/client/render/tileentity/RenderDynamicTank.java b/src/main/java/mekanism/client/render/tileentity/RenderDynamicTank.java index 6719019e6..d3bd82b7b 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderDynamicTank.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderDynamicTank.java @@ -3,6 +3,8 @@ package mekanism.client.render.tileentity; import java.util.HashMap; import java.util.Map; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.client.render.MekanismRenderer; import mekanism.client.render.MekanismRenderer.DisplayInteger; @@ -17,343 +19,350 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class RenderDynamicTank extends TileEntitySpecialRenderer -{ - private static Map> cachedCenterFluids = new HashMap>(); - private static Map> cachedValveFluids = new HashMap>(); +public class RenderDynamicTank extends TileEntitySpecialRenderer { + private static Map> cachedCenterFluids + = new HashMap>(); + private static Map> cachedValveFluids + = new HashMap>(); - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntityDynamicTank)tileEntity, x, y, z, partialTick); - } + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt((TileEntityDynamicTank) tileEntity, x, y, z, partialTick); + } - public void renderAModelAt(TileEntityDynamicTank tileEntity, double x, double y, double z, float partialTick) - { - if(tileEntity.clientHasStructure && tileEntity.isRendering && tileEntity.structure != null && tileEntity.structure.fluidStored != null && tileEntity.structure.fluidStored.amount != 0) - { - RenderData data = new RenderData(); + public void renderAModelAt( + TileEntityDynamicTank tileEntity, double x, double y, double z, float partialTick + ) { + if (tileEntity.clientHasStructure && tileEntity.isRendering + && tileEntity.structure != null && tileEntity.structure.fluidStored != null + && tileEntity.structure.fluidStored.amount != 0) { + RenderData data = new RenderData(); - data.location = tileEntity.structure.renderLocation; - data.height = tileEntity.structure.volHeight; - data.length = tileEntity.structure.volLength; - data.width = tileEntity.structure.volWidth; + data.location = tileEntity.structure.renderLocation; + data.height = tileEntity.structure.volHeight; + data.length = tileEntity.structure.volLength; + data.width = tileEntity.structure.volWidth; - bindTexture(MekanismRenderer.getBlocksTexture()); + bindTexture(MekanismRenderer.getBlocksTexture()); - if(data.location != null && data.height >= 3 && tileEntity.structure.fluidStored.getFluid() != null) - { - push(); + if (data.location != null && data.height >= 3 + && tileEntity.structure.fluidStored.getFluid() != null) { + push(); - GL11.glTranslated(getX(data.location.xCoord), getY(data.location.yCoord), getZ(data.location.zCoord)); + GL11.glTranslated( + getX(data.location.xCoord), + getY(data.location.yCoord), + getZ(data.location.zCoord) + ); - MekanismRenderer.glowOn(tileEntity.structure.fluidStored.getFluid().getLuminosity()); - MekanismRenderer.colorFluid(tileEntity.structure.fluidStored.getFluid()); + MekanismRenderer.glowOn( + tileEntity.structure.fluidStored.getFluid().getLuminosity() + ); + MekanismRenderer.colorFluid(tileEntity.structure.fluidStored.getFluid()); - DisplayInteger[] displayList = getListAndRender(data, tileEntity.structure.fluidStored.getFluid(), tileEntity.getWorldObj()); + DisplayInteger[] displayList = getListAndRender( + data, + tileEntity.structure.fluidStored.getFluid(), + tileEntity.getWorldObj() + ); - if(tileEntity.structure.fluidStored.getFluid().isGaseous()) - { - GL11.glColor4f(1F, 1F, 1F, Math.min(1, ((float)tileEntity.structure.fluidStored.amount / (float)tileEntity.clientCapacity)+MekanismRenderer.GAS_RENDER_BASE)); - displayList[getStages(data.height)-1].render(); - } - else { - displayList[Math.min(getStages(data.height)-1, (int)(tileEntity.prevScale*((float)getStages(data.height)-1)))].render(); - } + if (tileEntity.structure.fluidStored.getFluid().isGaseous()) { + GL11.glColor4f( + 1F, + 1F, + 1F, + Math.min( + 1, + ((float) tileEntity.structure.fluidStored.amount + / (float) tileEntity.clientCapacity) + + MekanismRenderer.GAS_RENDER_BASE + ) + ); + displayList[getStages(data.height) - 1].render(); + } else { + displayList[Math.min( + getStages(data.height) - 1, + (int + ) (tileEntity.prevScale + * ((float) getStages(data.height) - 1)) + )] + .render(); + } - MekanismRenderer.glowOff(); - MekanismRenderer.resetColor(); + MekanismRenderer.glowOff(); + MekanismRenderer.resetColor(); - pop(); + pop(); - for(ValveData valveData : tileEntity.valveViewing) - { - push(); + for (ValveData valveData : tileEntity.valveViewing) { + push(); - GL11.glTranslated(getX(valveData.location.xCoord), getY(valveData.location.yCoord), getZ(valveData.location.zCoord)); + GL11.glTranslated( + getX(valveData.location.xCoord), + getY(valveData.location.yCoord), + getZ(valveData.location.zCoord) + ); - MekanismRenderer.glowOn(tileEntity.structure.fluidStored.getFluid().getLuminosity()); + MekanismRenderer.glowOn( + tileEntity.structure.fluidStored.getFluid().getLuminosity() + ); - getValveDisplay(ValveRenderData.get(data, valveData), tileEntity.structure.fluidStored.getFluid(), tileEntity.getWorldObj()).render(); + getValveDisplay( + ValveRenderData.get(data, valveData), + tileEntity.structure.fluidStored.getFluid(), + tileEntity.getWorldObj() + ) + .render(); - MekanismRenderer.glowOff(); - MekanismRenderer.resetColor(); + MekanismRenderer.glowOff(); + MekanismRenderer.resetColor(); - pop(); - } - } - } - } + pop(); + } + } + } + } - private void pop() - { - GL11.glPopAttrib(); - GL11.glPopMatrix(); - } + private void pop() { + GL11.glPopAttrib(); + GL11.glPopMatrix(); + } - private void push() - { - GL11.glPushMatrix(); - GL11.glPushAttrib(GL11.GL_ENABLE_BIT); - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glEnable(GL11.GL_BLEND); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - } + private void push() { + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_ENABLE_BIT); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + } - private DisplayInteger[] getListAndRender(RenderData data, Fluid fluid, World world) - { - if(cachedCenterFluids.containsKey(data) && cachedCenterFluids.get(data).containsKey(fluid)) - { - return cachedCenterFluids.get(data).get(fluid); - } + private DisplayInteger[] getListAndRender(RenderData data, Fluid fluid, World world) { + if (cachedCenterFluids.containsKey(data) + && cachedCenterFluids.get(data).containsKey(fluid)) { + return cachedCenterFluids.get(data).get(fluid); + } - Model3D toReturn = new Model3D(); - toReturn.baseBlock = Blocks.water; - toReturn.setTexture(fluid.getIcon()); + Model3D toReturn = new Model3D(); + toReturn.baseBlock = Blocks.water; + toReturn.setTexture(fluid.getIcon()); - final int stages = getStages(data.height); - DisplayInteger[] displays = new DisplayInteger[stages]; + final int stages = getStages(data.height); + DisplayInteger[] displays = new DisplayInteger[stages]; - if(cachedCenterFluids.containsKey(data)) - { - cachedCenterFluids.get(data).put(fluid, displays); - } - else { - HashMap map = new HashMap(); - map.put(fluid, displays); - cachedCenterFluids.put(data, map); - } + if (cachedCenterFluids.containsKey(data)) { + cachedCenterFluids.get(data).put(fluid, displays); + } else { + HashMap map = new HashMap(); + map.put(fluid, displays); + cachedCenterFluids.put(data, map); + } - for(int i = 0; i < stages; i++) - { - displays[i] = DisplayInteger.createAndStart(); + for (int i = 0; i < stages; i++) { + displays[i] = DisplayInteger.createAndStart(); - if(fluid.getIcon() != null) - { - toReturn.minX = 0 + .01; - toReturn.minY = 0 + .01; - toReturn.minZ = 0 + .01; + if (fluid.getIcon() != null) { + toReturn.minX = 0 + .01; + toReturn.minY = 0 + .01; + toReturn.minZ = 0 + .01; - toReturn.maxX = data.length - .01; - toReturn.maxY = ((float)i/(float)stages)*(data.height-2) - .01; - toReturn.maxZ = data.width - .01; + toReturn.maxX = data.length - .01; + toReturn.maxY = ((float) i / (float) stages) * (data.height - 2) - .01; + toReturn.maxZ = data.width - .01; - MekanismRenderer.renderObject(toReturn); - } + MekanismRenderer.renderObject(toReturn); + } - GL11.glEndList(); - } + GL11.glEndList(); + } - return displays; - } + return displays; + } - private DisplayInteger getValveDisplay(ValveRenderData data, Fluid fluid, World world) - { - if(cachedValveFluids.containsKey(data) && cachedValveFluids.get(data).containsKey(fluid)) - { - return cachedValveFluids.get(data).get(fluid); - } + private DisplayInteger + getValveDisplay(ValveRenderData data, Fluid fluid, World world) { + if (cachedValveFluids.containsKey(data) + && cachedValveFluids.get(data).containsKey(fluid)) { + return cachedValveFluids.get(data).get(fluid); + } - Model3D toReturn = new Model3D(); - toReturn.baseBlock = Blocks.water; - toReturn.setTexture(fluid.getFlowingIcon()); + Model3D toReturn = new Model3D(); + toReturn.baseBlock = Blocks.water; + toReturn.setTexture(fluid.getFlowingIcon()); - DisplayInteger display = DisplayInteger.createAndStart(); + DisplayInteger display = DisplayInteger.createAndStart(); - if(cachedValveFluids.containsKey(data)) - { - cachedValveFluids.get(data).put(fluid, display); - } - else { - HashMap map = new HashMap(); - map.put(fluid, display); - cachedValveFluids.put(data, map); - } + if (cachedValveFluids.containsKey(data)) { + cachedValveFluids.get(data).put(fluid, display); + } else { + HashMap map = new HashMap(); + map.put(fluid, display); + cachedValveFluids.put(data, map); + } - switch(data.side) - { - case DOWN: - { - toReturn.minX = .3; - toReturn.minY = 1 + .01; - toReturn.minZ = .3; + switch (data.side) { + case DOWN: { + toReturn.minX = .3; + toReturn.minY = 1 + .01; + toReturn.minZ = .3; - toReturn.maxX = .7; - toReturn.maxY = 1.4 + .1; - toReturn.maxZ = .7; - break; - } - case UP: - { - toReturn.minX = .3; - toReturn.minY = -(data.height-2) - .01; - toReturn.minZ = .3; + toReturn.maxX = .7; + toReturn.maxY = 1.4 + .1; + toReturn.maxZ = .7; + break; + } + case UP: { + toReturn.minX = .3; + toReturn.minY = -(data.height - 2) - .01; + toReturn.minZ = .3; - toReturn.maxX = .7; - toReturn.maxY = -.01; - toReturn.maxZ = .7; - break; - } - case NORTH: - { - toReturn.minX = .3; - toReturn.minY = -(getValveFluidHeight(data)) + .01; - toReturn.minZ = 1 + .02; + toReturn.maxX = .7; + toReturn.maxY = -.01; + toReturn.maxZ = .7; + break; + } + case NORTH: { + toReturn.minX = .3; + toReturn.minY = -(getValveFluidHeight(data)) + .01; + toReturn.minZ = 1 + .02; - toReturn.maxX = .7; - toReturn.maxY = .7; - toReturn.maxZ = 1.4; - break; - } - case SOUTH: - { - toReturn.minX = .3; - toReturn.minY = -(getValveFluidHeight(data)) + .01; - toReturn.minZ = -.4; + toReturn.maxX = .7; + toReturn.maxY = .7; + toReturn.maxZ = 1.4; + break; + } + case SOUTH: { + toReturn.minX = .3; + toReturn.minY = -(getValveFluidHeight(data)) + .01; + toReturn.minZ = -.4; - toReturn.maxX = .7; - toReturn.maxY = .7; - toReturn.maxZ = -.02; - break; - } - case WEST: - { - toReturn.minX = 1 + .02; - toReturn.minY = -(getValveFluidHeight(data)) + .01; - toReturn.minZ = .3; + toReturn.maxX = .7; + toReturn.maxY = .7; + toReturn.maxZ = -.02; + break; + } + case WEST: { + toReturn.minX = 1 + .02; + toReturn.minY = -(getValveFluidHeight(data)) + .01; + toReturn.minZ = .3; - toReturn.maxX = 1.4; - toReturn.maxY = .7; - toReturn.maxZ = .7; - break; - } - case EAST: - { - toReturn.minX = -.4; - toReturn.minY = -(getValveFluidHeight(data)) + .01; - toReturn.minZ = .3; + toReturn.maxX = 1.4; + toReturn.maxY = .7; + toReturn.maxZ = .7; + break; + } + case EAST: { + toReturn.minX = -.4; + toReturn.minY = -(getValveFluidHeight(data)) + .01; + toReturn.minZ = .3; - toReturn.maxX = -.02; - toReturn.maxY = .7; - toReturn.maxZ = .7; - break; - } - default: - { - break; - } - } + toReturn.maxX = -.02; + toReturn.maxY = .7; + toReturn.maxZ = .7; + break; + } + default: { + break; + } + } - if(fluid.getFlowingIcon() != null) - { - MekanismRenderer.renderObject(toReturn); - } - - display.endList(); + if (fluid.getFlowingIcon() != null) { + MekanismRenderer.renderObject(toReturn); + } - return display; - } + display.endList(); - private int getValveFluidHeight(ValveRenderData data) - { - return data.valveLocation.yCoord - data.location.yCoord; - } + return display; + } - private int getStages(int height) - { - return (height-2)*(TankUpdateProtocol.FLUID_PER_TANK/10); - } + private int getValveFluidHeight(ValveRenderData data) { + return data.valveLocation.yCoord - data.location.yCoord; + } - private double getX(int x) - { - return x - TileEntityRendererDispatcher.staticPlayerX; - } + private int getStages(int height) { + return (height - 2) * (TankUpdateProtocol.FLUID_PER_TANK / 10); + } - private double getY(int y) - { - return y - TileEntityRendererDispatcher.staticPlayerY; - } + private double getX(int x) { + return x - TileEntityRendererDispatcher.staticPlayerX; + } - private double getZ(int z) - { - return z - TileEntityRendererDispatcher.staticPlayerZ; - } + private double getY(int y) { + return y - TileEntityRendererDispatcher.staticPlayerY; + } - public static class RenderData - { - public Coord4D location; + private double getZ(int z) { + return z - TileEntityRendererDispatcher.staticPlayerZ; + } - public int height; - public int length; - public int width; + public static class RenderData { + public Coord4D location; - @Override - public int hashCode() - { - int code = 1; - code = 31 * code + location.hashCode(); - code = 31 * code + height; - code = 31 * code + length; - code = 31 * code + width; - return code; - } + public int height; + public int length; + public int width; - @Override - public boolean equals(Object data) - { - return data instanceof RenderData && ((RenderData)data).location.equals(location) && ((RenderData)data).height == height && - ((RenderData)data).length == length && ((RenderData)data).width == width; - } - } + @Override + public int hashCode() { + int code = 1; + code = 31 * code + location.hashCode(); + code = 31 * code + height; + code = 31 * code + length; + code = 31 * code + width; + return code; + } - public static class ValveRenderData extends RenderData - { - public ForgeDirection side; - public Coord4D valveLocation; + @Override + public boolean equals(Object data) { + return data instanceof RenderData + && ((RenderData) data).location.equals(location) + && ((RenderData) data).height == height + && ((RenderData) data).length == length + && ((RenderData) data).width == width; + } + } - public static ValveRenderData get(RenderData renderData, ValveData valveData) - { - ValveRenderData data = new ValveRenderData(); + public static class ValveRenderData extends RenderData { + public ForgeDirection side; + public Coord4D valveLocation; - data.location = renderData.location; - data.height = renderData.height; - data.length = renderData.length; - data.width = renderData.width; + public static ValveRenderData get(RenderData renderData, ValveData valveData) { + ValveRenderData data = new ValveRenderData(); - data.side = valveData.side; - data.valveLocation = valveData.location; + data.location = renderData.location; + data.height = renderData.height; + data.length = renderData.length; + data.width = renderData.width; - return data; - } + data.side = valveData.side; + data.valveLocation = valveData.location; - @Override - public boolean equals(Object data) - { - return data instanceof ValveRenderData && super.equals(data) && ((ValveRenderData)data).side.equals(side); - } + return data; + } - @Override - public int hashCode() - { - int code = 1; - code = 31 * code + super.hashCode(); - code = 31 * code + side.ordinal(); - code = 31 * code + valveLocation.hashCode(); - return code; - } - } + @Override + public boolean equals(Object data) { + return data instanceof ValveRenderData && super.equals(data) + && ((ValveRenderData) data).side.equals(side); + } - public static void resetDisplayInts() - { - cachedCenterFluids.clear(); - cachedValveFluids.clear(); - } + @Override + public int hashCode() { + int code = 1; + code = 31 * code + super.hashCode(); + code = 31 * code + side.ordinal(); + code = 31 * code + valveLocation.hashCode(); + return code; + } + } + + public static void resetDisplayInts() { + cachedCenterFluids.clear(); + cachedValveFluids.clear(); + } } diff --git a/src/main/java/mekanism/client/render/tileentity/RenderElectricPump.java b/src/main/java/mekanism/client/render/tileentity/RenderElectricPump.java index 2524e3938..af971f8ab 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderElectricPump.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderElectricPump.java @@ -1,45 +1,51 @@ package mekanism.client.render.tileentity; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.model.ModelElectricPump; import mekanism.common.tile.TileEntityElectricPump; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class RenderElectricPump extends TileEntitySpecialRenderer -{ - private ModelElectricPump model = new ModelElectricPump(); +public class RenderElectricPump extends TileEntitySpecialRenderer { + private ModelElectricPump model = new ModelElectricPump(); - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntityElectricPump)tileEntity, x, y, z, partialTick); - } + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt((TileEntityElectricPump) tileEntity, x, y, z, partialTick); + } - private void renderAModelAt(TileEntityElectricPump tileEntity, double x, double y, double z, float partialTick) - { - GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); + private void renderAModelAt( + TileEntityElectricPump tileEntity, double x, double y, double z, float partialTick + ) { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ElectricPump.png")); + bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ElectricPump.png")); - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; - case 3: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; - case 4: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; - case 5: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; - } + switch (tileEntity.facing) { + case 2: + GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); + break; + case 3: + GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); + break; + case 4: + GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); + break; + case 5: + GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); + break; + } - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - model.render(0.0625F); - GL11.glPopMatrix(); - } + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + model.render(0.0625F); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/mekanism/client/render/tileentity/RenderElectrolyticSeparator.java b/src/main/java/mekanism/client/render/tileentity/RenderElectrolyticSeparator.java index 9f3aaee6f..fc8ef2d8c 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderElectrolyticSeparator.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderElectrolyticSeparator.java @@ -1,45 +1,59 @@ package mekanism.client.render.tileentity; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.model.ModelElectrolyticSeparator; import mekanism.common.tile.TileEntityElectrolyticSeparator; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class RenderElectrolyticSeparator extends TileEntitySpecialRenderer -{ - private ModelElectrolyticSeparator model = new ModelElectrolyticSeparator(); +public class RenderElectrolyticSeparator extends TileEntitySpecialRenderer { + private ModelElectrolyticSeparator model = new ModelElectrolyticSeparator(); - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntityElectrolyticSeparator)tileEntity, x, y, z, partialTick); - } + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt( + (TileEntityElectrolyticSeparator) tileEntity, x, y, z, partialTick + ); + } - private void renderAModelAt(TileEntityElectrolyticSeparator tileEntity, double x, double y, double z, float partialTick) - { - GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ElectrolyticSeparator.png")); + private void renderAModelAt( + TileEntityElectrolyticSeparator tileEntity, + double x, + double y, + double z, + float partialTick + ) { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); + bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "ElectrolyticSeparator.png") + ); - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; - case 3: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; - case 4: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; - case 5: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; - } + switch (tileEntity.facing) { + case 2: + GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); + break; + case 3: + GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); + break; + case 4: + GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); + break; + case 5: + GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); + break; + } - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); - model.render(0.0625F); - GL11.glPopMatrix(); - } + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); + model.render(0.0625F); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/mekanism/client/render/tileentity/RenderEnergyCube.java b/src/main/java/mekanism/client/render/tileentity/RenderEnergyCube.java index 47d718ca3..10e3b0d9c 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderEnergyCube.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderEnergyCube.java @@ -3,6 +3,8 @@ package mekanism.client.render.tileentity; import java.util.HashMap; import java.util.Map; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.transmitters.TransmissionType; import mekanism.client.MekanismClient; import mekanism.client.model.ModelEnergyCube; @@ -16,105 +18,134 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.util.ForgeDirection; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class RenderEnergyCube extends TileEntitySpecialRenderer -{ - public static int[][] COLORS = new int[][] {new int[] {100, 210, 125}, new int[] {215, 85, 70}, new int[] {80, 125, 230}, - new int[] {154, 120, 200}, new int[] {0, 0, 0}}; - - private ModelEnergyCube model = new ModelEnergyCube(); - private ModelEnergyCore core = new ModelEnergyCore(); - - public static Map resources = new HashMap(); - public static ResourceLocation baseTexture = MekanismUtils.getResource(ResourceType.RENDER, "EnergyCube.png"); - public static ResourceLocation coreTexture = MekanismUtils.getResource(ResourceType.RENDER, "EnergyCore.png"); +public class RenderEnergyCube extends TileEntitySpecialRenderer { + public static int[][] COLORS = new int[][] { new int[] { 100, 210, 125 }, + new int[] { 215, 85, 70 }, + new int[] { 80, 125, 230 }, + new int[] { 154, 120, 200 }, + new int[] { 0, 0, 0 } }; - static { - if(resources.isEmpty()) - { - for(EnergyCubeTier tier : EnergyCubeTier.values()) - { - resources.put(tier, MekanismUtils.getResource(ResourceType.RENDER, "EnergyCube" + tier.getBaseTier().getName() + ".png")); - } - } - } - - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntityEnergyCube)tileEntity, x, y, z, partialTick); - } + private ModelEnergyCube model = new ModelEnergyCube(); + private ModelEnergyCore core = new ModelEnergyCore(); - private void renderAModelAt(TileEntityEnergyCube tileEntity, double x, double y, double z, float partialTick) - { - GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); + public static Map resources + = new HashMap(); + public static ResourceLocation baseTexture + = MekanismUtils.getResource(ResourceType.RENDER, "EnergyCube.png"); + public static ResourceLocation coreTexture + = MekanismUtils.getResource(ResourceType.RENDER, "EnergyCore.png"); - bindTexture(baseTexture); + static { + if (resources.isEmpty()) { + for (EnergyCubeTier tier : EnergyCubeTier.values()) { + resources.put( + tier, + MekanismUtils.getResource( + ResourceType.RENDER, + "EnergyCube" + tier.getBaseTier().getName() + ".png" + ) + ); + } + } + } - switch(tileEntity.facing) - { - case 0: - { - GL11.glRotatef(90F, -1.0F, 0.0F, 0.0F); - GL11.glTranslatef(0.0F, 1.0F, -1.0F); - break; - } - case 1: - { - GL11.glRotatef(90F, 1.0F, 0.0F, 0.0F); - GL11.glTranslatef(0.0F, 1.0F, 1.0F); - break; - } - case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; - case 3: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; - case 4: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; - case 5: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; - } + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt((TileEntityEnergyCube) tileEntity, x, y, z, partialTick); + } - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - model.render(0.0625F, tileEntity.tier, field_147501_a.field_147553_e); - - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - bindTexture(baseTexture); - model.renderSide(0.0625F, side, tileEntity.configComponent.getOutput(TransmissionType.ENERGY, side.ordinal()).ioState, tileEntity.tier, field_147501_a.field_147553_e); - } - - GL11.glPopMatrix(); + private void renderAModelAt( + TileEntityEnergyCube tileEntity, double x, double y, double z, float partialTick + ) { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); - if(tileEntity.getEnergy()/tileEntity.getMaxEnergy() > 0.1) - { - GL11.glPushMatrix(); - GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); - bindTexture(coreTexture); + bindTexture(baseTexture); - MekanismRenderer.blendOn(); - MekanismRenderer.glowOn(); + switch (tileEntity.facing) { + case 0: { + GL11.glRotatef(90F, -1.0F, 0.0F, 0.0F); + GL11.glTranslatef(0.0F, 1.0F, -1.0F); + break; + } + case 1: { + GL11.glRotatef(90F, 1.0F, 0.0F, 0.0F); + GL11.glTranslatef(0.0F, 1.0F, 1.0F); + break; + } + case 2: + GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); + break; + case 3: + GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); + break; + case 4: + GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); + break; + case 5: + GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); + break; + } - int[] c = COLORS[tileEntity.tier.getBaseTier().ordinal()]; + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + model.render(0.0625F, tileEntity.tier, field_147501_a.field_147553_e); - GL11.glPushMatrix(); - GL11.glScalef(0.4F, 0.4F, 0.4F); - GL11.glColor4f((float)c[0]/255F, (float)c[1]/255F, (float)c[2]/255F, (float)(tileEntity.getEnergy() / tileEntity.getMaxEnergy())); - GL11.glTranslatef(0, (float)Math.sin(Math.toRadians((MekanismClient.ticksPassed + partialTick) * 3)) / 7, 0); - GL11.glRotatef((MekanismClient.ticksPassed + partialTick) * 4, 0, 1, 0); - GL11.glRotatef(36F + (MekanismClient.ticksPassed + partialTick) * 4, 0, 1, 1); - core.render(0.0625F); - GL11.glPopMatrix(); + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + bindTexture(baseTexture); + model.renderSide( + 0.0625F, + side, + tileEntity.configComponent + .getOutput(TransmissionType.ENERGY, side.ordinal()) + .ioState, + tileEntity.tier, + field_147501_a.field_147553_e + ); + } - MekanismRenderer.glowOff(); - MekanismRenderer.blendOff(); + GL11.glPopMatrix(); - GL11.glPopMatrix(); - } - - MekanismRenderer.machineRenderer.renderAModelAt(tileEntity, x, y, z, partialTick); - } + if (tileEntity.getEnergy() / tileEntity.getMaxEnergy() > 0.1) { + GL11.glPushMatrix(); + GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5); + bindTexture(coreTexture); + + MekanismRenderer.blendOn(); + MekanismRenderer.glowOn(); + + int[] c = COLORS[tileEntity.tier.getBaseTier().ordinal()]; + + GL11.glPushMatrix(); + GL11.glScalef(0.4F, 0.4F, 0.4F); + GL11.glColor4f( + (float) c[0] / 255F, + (float) c[1] / 255F, + (float) c[2] / 255F, + (float) (tileEntity.getEnergy() / tileEntity.getMaxEnergy()) + ); + GL11.glTranslatef( + 0, + (float + ) Math.sin(Math.toRadians((MekanismClient.ticksPassed + partialTick) * 3)) + / 7, + 0 + ); + GL11.glRotatef((MekanismClient.ticksPassed + partialTick) * 4, 0, 1, 0); + GL11.glRotatef(36F + (MekanismClient.ticksPassed + partialTick) * 4, 0, 1, 1); + core.render(0.0625F); + GL11.glPopMatrix(); + + MekanismRenderer.glowOff(); + MekanismRenderer.blendOff(); + + GL11.glPopMatrix(); + } + + MekanismRenderer.machineRenderer.renderAModelAt(tileEntity, x, y, z, partialTick); + } } diff --git a/src/main/java/mekanism/client/render/tileentity/RenderFluidTank.java b/src/main/java/mekanism/client/render/tileentity/RenderFluidTank.java index 91a182113..4a8f8b4fe 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderFluidTank.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderFluidTank.java @@ -3,6 +3,8 @@ package mekanism.client.render.tileentity; import java.util.HashMap; import java.util.Map; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.model.ModelFluidTank; import mekanism.client.render.MekanismRenderer; import mekanism.client.render.MekanismRenderer.DisplayInteger; @@ -15,185 +17,196 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.init.Blocks; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.fluids.Fluid; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class RenderFluidTank extends TileEntitySpecialRenderer -{ - private static Map cachedCenterFluids = new HashMap(); - private static Map cachedValveFluids = new HashMap(); - - private static int stages = 1400; - - private ModelFluidTank model = new ModelFluidTank(); +public class RenderFluidTank extends TileEntitySpecialRenderer { + private static Map cachedCenterFluids + = new HashMap(); + private static Map cachedValveFluids + = new HashMap(); - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntityFluidTank)tileEntity, x, y, z, partialTick); - } + private static int stages = 1400; - private void renderAModelAt(TileEntityFluidTank tileEntity, double x, double y, double z, float partialTick) - { - Fluid fluid = tileEntity.fluidTank.getFluid() != null ? tileEntity.fluidTank.getFluid().getFluid() : null; - render(tileEntity.tier, fluid, tileEntity.prevScale, tileEntity.isActive, tileEntity.valve > 0 ? tileEntity.valveFluid : null, x, y, z); - } - - public void render(FluidTankTier tier, Fluid fluid, float fluidScale, boolean active, Fluid valveFluid, double x, double y, double z) - { - if(fluid != null && fluidScale > 0) - { - push(); - - bindTexture(MekanismRenderer.getBlocksTexture()); - GL11.glTranslated(x, y, z); - - MekanismRenderer.glowOn(fluid.getLuminosity()); - MekanismRenderer.colorFluid(fluid); - - DisplayInteger[] displayList = getListAndRender(fluid); - - if(fluid.isGaseous()) - { - GL11.glColor4f(1F, 1F, 1F, Math.min(1, fluidScale+MekanismRenderer.GAS_RENDER_BASE)); - displayList[stages-1].render(); - } - else { - displayList[Math.min(stages-1, (int)(fluidScale*((float)stages-1)))].render(); - } - - MekanismRenderer.glowOff(); - MekanismRenderer.resetColor(); - - pop(); - } - - if(valveFluid != null && !valveFluid.isGaseous()) - { - push(); - - bindTexture(MekanismRenderer.getBlocksTexture()); - GL11.glTranslated(x, y, z); - - MekanismRenderer.glowOn(valveFluid.getLuminosity()); - MekanismRenderer.colorFluid(valveFluid); - - DisplayInteger[] valveList = getValveRender(valveFluid); - - valveList[Math.min(stages-1, (int)(fluidScale*((float)stages-1)))].render(); - - MekanismRenderer.glowOff(); - MekanismRenderer.resetColor(); - - pop(); - } - - GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "FluidTank" + (active ? "On" : "") + ".png")); + private ModelFluidTank model = new ModelFluidTank(); - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - model.render(0.0625F, tier); - GL11.glPopMatrix(); - } - - private void pop() - { - GL11.glPopAttrib(); - MekanismRenderer.blendOff(); - GL11.glPopMatrix(); - } + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt((TileEntityFluidTank) tileEntity, x, y, z, partialTick); + } - private void push() - { - GL11.glPushMatrix(); - GL11.glPushAttrib(GL11.GL_ENABLE_BIT); - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glDisable(GL11.GL_LIGHTING); - MekanismRenderer.blendOn(); - } - - private DisplayInteger[] getValveRender(Fluid fluid) - { - if(cachedValveFluids.containsKey(fluid)) - { - return cachedValveFluids.get(fluid); - } + private void renderAModelAt( + TileEntityFluidTank tileEntity, double x, double y, double z, float partialTick + ) { + Fluid fluid = tileEntity.fluidTank.getFluid() != null + ? tileEntity.fluidTank.getFluid().getFluid() + : null; + render( + tileEntity.tier, + fluid, + tileEntity.prevScale, + tileEntity.isActive, + tileEntity.valve > 0 ? tileEntity.valveFluid : null, + x, + y, + z + ); + } - Model3D toReturn = new Model3D(); - toReturn.baseBlock = Blocks.water; - toReturn.setTexture(fluid.getFlowingIcon()); - - DisplayInteger[] displays = new DisplayInteger[stages]; - cachedValveFluids.put(fluid, displays); + public void render( + FluidTankTier tier, + Fluid fluid, + float fluidScale, + boolean active, + Fluid valveFluid, + double x, + double y, + double z + ) { + if (fluid != null && fluidScale > 0) { + push(); - for(int i = 0; i < stages; i++) - { - displays[i] = DisplayInteger.createAndStart(); + bindTexture(MekanismRenderer.getBlocksTexture()); + GL11.glTranslated(x, y, z); - if(fluid.getIcon() != null) - { - toReturn.minX = 0.3125 + .01; - toReturn.minY = 0.0625 + ((float)i/(float)stages)*0.875; - toReturn.minZ = 0.3125 + .01; + MekanismRenderer.glowOn(fluid.getLuminosity()); + MekanismRenderer.colorFluid(fluid); - toReturn.maxX = 0.6875 - .01; - toReturn.maxY = 0.9375 - .01; - toReturn.maxZ = 0.6875 - .01; + DisplayInteger[] displayList = getListAndRender(fluid); - MekanismRenderer.renderObject(toReturn); - } + if (fluid.isGaseous()) { + GL11.glColor4f( + 1F, 1F, 1F, Math.min(1, fluidScale + MekanismRenderer.GAS_RENDER_BASE) + ); + displayList[stages - 1].render(); + } else { + displayList[Math.min( + stages - 1, (int) (fluidScale * ((float) stages - 1)) + )] + .render(); + } - GL11.glEndList(); - } + MekanismRenderer.glowOff(); + MekanismRenderer.resetColor(); - return displays; - } - - private DisplayInteger[] getListAndRender(Fluid fluid) - { - if(cachedCenterFluids.containsKey(fluid)) - { - return cachedCenterFluids.get(fluid); - } + pop(); + } - Model3D toReturn = new Model3D(); - toReturn.baseBlock = Blocks.water; - toReturn.setTexture(fluid.getIcon()); - - DisplayInteger[] displays = new DisplayInteger[stages]; - cachedCenterFluids.put(fluid, displays); + if (valveFluid != null && !valveFluid.isGaseous()) { + push(); - for(int i = 0; i < stages; i++) - { - displays[i] = DisplayInteger.createAndStart(); + bindTexture(MekanismRenderer.getBlocksTexture()); + GL11.glTranslated(x, y, z); - if(fluid.getIcon() != null) - { - toReturn.minX = 0.125 + .01; - toReturn.minY = 0.0625 + .01; - toReturn.minZ = 0.125 + .01; + MekanismRenderer.glowOn(valveFluid.getLuminosity()); + MekanismRenderer.colorFluid(valveFluid); - toReturn.maxX = 0.875 - .01; - toReturn.maxY = 0.0625 + ((float)i/(float)stages)*0.875 - .01; - toReturn.maxZ = 0.875 - .01; + DisplayInteger[] valveList = getValveRender(valveFluid); - MekanismRenderer.renderObject(toReturn); - } + valveList[Math.min(stages - 1, (int) (fluidScale * ((float) stages - 1)))] + .render(); - GL11.glEndList(); - } + MekanismRenderer.glowOff(); + MekanismRenderer.resetColor(); - return displays; - } + pop(); + } - public static void resetDisplayInts() - { - cachedCenterFluids.clear(); - cachedValveFluids.clear(); - } + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); + bindTexture(MekanismUtils.getResource( + ResourceType.RENDER, "FluidTank" + (active ? "On" : "") + ".png" + )); + + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + model.render(0.0625F, tier); + GL11.glPopMatrix(); + } + + private void pop() { + GL11.glPopAttrib(); + MekanismRenderer.blendOff(); + GL11.glPopMatrix(); + } + + private void push() { + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_ENABLE_BIT); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glDisable(GL11.GL_LIGHTING); + MekanismRenderer.blendOn(); + } + + private DisplayInteger[] getValveRender(Fluid fluid) { + if (cachedValveFluids.containsKey(fluid)) { + return cachedValveFluids.get(fluid); + } + + Model3D toReturn = new Model3D(); + toReturn.baseBlock = Blocks.water; + toReturn.setTexture(fluid.getFlowingIcon()); + + DisplayInteger[] displays = new DisplayInteger[stages]; + cachedValveFluids.put(fluid, displays); + + for (int i = 0; i < stages; i++) { + displays[i] = DisplayInteger.createAndStart(); + + if (fluid.getIcon() != null) { + toReturn.minX = 0.3125 + .01; + toReturn.minY = 0.0625 + ((float) i / (float) stages) * 0.875; + toReturn.minZ = 0.3125 + .01; + + toReturn.maxX = 0.6875 - .01; + toReturn.maxY = 0.9375 - .01; + toReturn.maxZ = 0.6875 - .01; + + MekanismRenderer.renderObject(toReturn); + } + + GL11.glEndList(); + } + + return displays; + } + + private DisplayInteger[] getListAndRender(Fluid fluid) { + if (cachedCenterFluids.containsKey(fluid)) { + return cachedCenterFluids.get(fluid); + } + + Model3D toReturn = new Model3D(); + toReturn.baseBlock = Blocks.water; + toReturn.setTexture(fluid.getIcon()); + + DisplayInteger[] displays = new DisplayInteger[stages]; + cachedCenterFluids.put(fluid, displays); + + for (int i = 0; i < stages; i++) { + displays[i] = DisplayInteger.createAndStart(); + + if (fluid.getIcon() != null) { + toReturn.minX = 0.125 + .01; + toReturn.minY = 0.0625 + .01; + toReturn.minZ = 0.125 + .01; + + toReturn.maxX = 0.875 - .01; + toReturn.maxY = 0.0625 + ((float) i / (float) stages) * 0.875 - .01; + toReturn.maxZ = 0.875 - .01; + + MekanismRenderer.renderObject(toReturn); + } + + GL11.glEndList(); + } + + return displays; + } + + public static void resetDisplayInts() { + cachedCenterFluids.clear(); + cachedValveFluids.clear(); + } } diff --git a/src/main/java/mekanism/client/render/tileentity/RenderFluidicPlenisher.java b/src/main/java/mekanism/client/render/tileentity/RenderFluidicPlenisher.java index 52c1375b0..55bd7ceac 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderFluidicPlenisher.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderFluidicPlenisher.java @@ -1,45 +1,56 @@ package mekanism.client.render.tileentity; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.model.ModelFluidicPlenisher; import mekanism.common.tile.TileEntityFluidicPlenisher; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class RenderFluidicPlenisher extends TileEntitySpecialRenderer -{ - private ModelFluidicPlenisher model = new ModelFluidicPlenisher(); +public class RenderFluidicPlenisher extends TileEntitySpecialRenderer { + private ModelFluidicPlenisher model = new ModelFluidicPlenisher(); - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntityFluidicPlenisher)tileEntity, x, y, z, partialTick); - } + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt((TileEntityFluidicPlenisher) tileEntity, x, y, z, partialTick); + } - private void renderAModelAt(TileEntityFluidicPlenisher tileEntity, double x, double y, double z, float partialTick) - { - GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); + private void renderAModelAt( + TileEntityFluidicPlenisher tileEntity, + double x, + double y, + double z, + float partialTick + ) { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "FluidicPlenisher.png")); + bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "FluidicPlenisher.png") + ); - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; - case 3: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; - case 4: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; - case 5: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; - } + switch (tileEntity.facing) { + case 2: + GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); + break; + case 3: + GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); + break; + case 4: + GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); + break; + case 5: + GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); + break; + } - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - model.render(0.0625F); - GL11.glPopMatrix(); - } + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + model.render(0.0625F); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/mekanism/client/render/tileentity/RenderGasTank.java b/src/main/java/mekanism/client/render/tileentity/RenderGasTank.java index af4af146d..bdf44ef91 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderGasTank.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderGasTank.java @@ -1,5 +1,7 @@ package mekanism.client.render.tileentity; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.model.ModelGasTank; import mekanism.client.render.MekanismRenderer; import mekanism.common.tile.TileEntityGasTank; @@ -7,41 +9,48 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class RenderGasTank extends TileEntitySpecialRenderer -{ - private ModelGasTank model = new ModelGasTank(); +public class RenderGasTank extends TileEntitySpecialRenderer { + private ModelGasTank model = new ModelGasTank(); - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntityGasTank)tileEntity, x, y, z, partialTick); - } + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt((TileEntityGasTank) tileEntity, x, y, z, partialTick); + } - private void renderAModelAt(TileEntityGasTank tileEntity, double x, double y, double z, float partialTick) - { - GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "GasTank" + tileEntity.tier.getBaseTier().getName() + ".png")); + private void renderAModelAt( + TileEntityGasTank tileEntity, double x, double y, double z, float partialTick + ) { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); + bindTexture(MekanismUtils.getResource( + ResourceType.RENDER, + "GasTank" + tileEntity.tier.getBaseTier().getName() + ".png" + )); - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; - case 3: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; - case 4: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; - case 5: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; - } + switch (tileEntity.facing) { + case 2: + GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); + break; + case 3: + GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); + break; + case 4: + GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); + break; + case 5: + GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); + break; + } - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - model.render(0.0625F); - GL11.glPopMatrix(); - - MekanismRenderer.machineRenderer.renderAModelAt(tileEntity, x, y, z, partialTick); - } + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + model.render(0.0625F); + GL11.glPopMatrix(); + + MekanismRenderer.machineRenderer.renderAModelAt(tileEntity, x, y, z, partialTick); + } } diff --git a/src/main/java/mekanism/client/render/tileentity/RenderLaser.java b/src/main/java/mekanism/client/render/tileentity/RenderLaser.java index 114fc4266..cc9ec6596 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderLaser.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderLaser.java @@ -1,68 +1,66 @@ package mekanism.client.render.tileentity; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.model.ModelLaser; import mekanism.common.tile.TileEntityLaser; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class RenderLaser extends TileEntitySpecialRenderer -{ - private ModelLaser model = new ModelLaser(); +public class RenderLaser extends TileEntitySpecialRenderer { + private ModelLaser model = new ModelLaser(); - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntityLaser)tileEntity, x, y, z, partialTick); - } + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt((TileEntityLaser) tileEntity, x, y, z, partialTick); + } - private void renderAModelAt(TileEntityLaser tileEntity, double x, double y, double z, float partialTick) - { - GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); + private void renderAModelAt( + TileEntityLaser tileEntity, double x, double y, double z, float partialTick + ) { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "Laser.png")); + bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "Laser.png")); - switch(tileEntity.facing) - { - case 0: - GL11.glTranslatef(0.0F, -2.0F, 0.0F); - GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F); - break; - case 5: - GL11.glTranslatef(0.0F, -1.0F, 0.0F); - GL11.glTranslatef(1.0F, 0.0F, 0.0F); - GL11.glRotatef(90F, 1.0F, 0.0F, 0.0F); - GL11.glRotatef(90, 0.0F, 0.0F, -1.0F); - break; - case 4: - GL11.glTranslatef(0.0F, -1.0F, 0.0F); - GL11.glTranslatef(-1.0F, 0.0F, 0.0F); - GL11.glRotatef(90F, 1.0F, 0.0F, 0.0F); - GL11.glRotatef(90, 0.0F, 0.0F, 1.0F); - break; - case 2: - GL11.glTranslatef(0.0F, -1.0F, 0.0F); - GL11.glTranslatef(0.0F, 0.0F, -1.0F); - GL11.glRotatef(90, -1.0F, 0.0F, 0.0F); - GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F); - break; - case 3: - GL11.glTranslatef(0.0F, -1.0F, 0.0F); - GL11.glTranslatef(0.0F, 0.0F, 1.0F); - GL11.glRotatef(90, 1.0F, 0.0F, 0.0F); - break; - } + switch (tileEntity.facing) { + case 0: + GL11.glTranslatef(0.0F, -2.0F, 0.0F); + GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F); + break; + case 5: + GL11.glTranslatef(0.0F, -1.0F, 0.0F); + GL11.glTranslatef(1.0F, 0.0F, 0.0F); + GL11.glRotatef(90F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(90, 0.0F, 0.0F, -1.0F); + break; + case 4: + GL11.glTranslatef(0.0F, -1.0F, 0.0F); + GL11.glTranslatef(-1.0F, 0.0F, 0.0F); + GL11.glRotatef(90F, 1.0F, 0.0F, 0.0F); + GL11.glRotatef(90, 0.0F, 0.0F, 1.0F); + break; + case 2: + GL11.glTranslatef(0.0F, -1.0F, 0.0F); + GL11.glTranslatef(0.0F, 0.0F, -1.0F); + GL11.glRotatef(90, -1.0F, 0.0F, 0.0F); + GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F); + break; + case 3: + GL11.glTranslatef(0.0F, -1.0F, 0.0F); + GL11.glTranslatef(0.0F, 0.0F, 1.0F); + GL11.glRotatef(90, 1.0F, 0.0F, 0.0F); + break; + } - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - model.render(0.0625F); - GL11.glPopMatrix(); - } + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + model.render(0.0625F); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/mekanism/client/render/tileentity/RenderLaserAmplifier.java b/src/main/java/mekanism/client/render/tileentity/RenderLaserAmplifier.java index 747e8f887..ed0fe1303 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderLaserAmplifier.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderLaserAmplifier.java @@ -1,5 +1,7 @@ package mekanism.client.render.tileentity; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.model.ModelLaserAmplifier; import mekanism.client.render.MekanismRenderer; import mekanism.common.tile.TileEntityLaserAmplifier; @@ -7,62 +9,62 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class RenderLaserAmplifier extends TileEntitySpecialRenderer -{ - private ModelLaserAmplifier model = new ModelLaserAmplifier(); +public class RenderLaserAmplifier extends TileEntitySpecialRenderer { + private ModelLaserAmplifier model = new ModelLaserAmplifier(); - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntityLaserAmplifier)tileEntity, x, y, z, partialTick); - } + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt((TileEntityLaserAmplifier) tileEntity, x, y, z, partialTick); + } - private void renderAModelAt(TileEntityLaserAmplifier tileEntity, double x, double y, double z, float partialTick) - { - GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); + private void renderAModelAt( + TileEntityLaserAmplifier tileEntity, + double x, + double y, + double z, + float partialTick + ) { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "LaserAmplifier.png")); + bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "LaserAmplifier.png")); - switch(tileEntity.facing) - { - case 0: - GL11.glTranslatef(0.0F, -2.0F, 0.0F); - GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F); - break; - case 5: - GL11.glTranslatef(0.0F, -1.0F, 0.0F); - GL11.glTranslatef(1.0F, 0.0F, 0.0F); - GL11.glRotatef(90, 0.0F, 0.0F, -1.0F); - break; - case 4: - GL11.glTranslatef(0.0F, -1.0F, 0.0F); - GL11.glTranslatef(-1.0F, 0.0F, 0.0F); - GL11.glRotatef(90, 0.0F, 0.0F, 1.0F); - break; - case 2: - GL11.glTranslatef(0.0F, -1.0F, 0.0F); - GL11.glTranslatef(0.0F, 0.0F, -1.0F); - GL11.glRotatef(90, -1.0F, 0.0F, 0.0F); - break; - case 3: - GL11.glTranslatef(0.0F, -1.0F, 0.0F); - GL11.glTranslatef(0.0F, 0.0F, 1.0F); - GL11.glRotatef(90, 1.0F, 0.0F, 0.0F); - break; - } + switch (tileEntity.facing) { + case 0: + GL11.glTranslatef(0.0F, -2.0F, 0.0F); + GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F); + break; + case 5: + GL11.glTranslatef(0.0F, -1.0F, 0.0F); + GL11.glTranslatef(1.0F, 0.0F, 0.0F); + GL11.glRotatef(90, 0.0F, 0.0F, -1.0F); + break; + case 4: + GL11.glTranslatef(0.0F, -1.0F, 0.0F); + GL11.glTranslatef(-1.0F, 0.0F, 0.0F); + GL11.glRotatef(90, 0.0F, 0.0F, 1.0F); + break; + case 2: + GL11.glTranslatef(0.0F, -1.0F, 0.0F); + GL11.glTranslatef(0.0F, 0.0F, -1.0F); + GL11.glRotatef(90, -1.0F, 0.0F, 0.0F); + break; + case 3: + GL11.glTranslatef(0.0F, -1.0F, 0.0F); + GL11.glTranslatef(0.0F, 0.0F, 1.0F); + GL11.glRotatef(90, 1.0F, 0.0F, 0.0F); + break; + } - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - MekanismRenderer.blendOn(); - model.render(0.0625F); - MekanismRenderer.blendOff(); - GL11.glPopMatrix(); - } + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + MekanismRenderer.blendOn(); + model.render(0.0625F); + MekanismRenderer.blendOff(); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/mekanism/client/render/tileentity/RenderLaserTractorBeam.java b/src/main/java/mekanism/client/render/tileentity/RenderLaserTractorBeam.java index 522cc8a49..69b795b2d 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderLaserTractorBeam.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderLaserTractorBeam.java @@ -7,58 +7,62 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; - import org.lwjgl.opengl.GL11; -public class RenderLaserTractorBeam extends TileEntitySpecialRenderer -{ - private ModelLaserAmplifier model = new ModelLaserAmplifier(); +public class RenderLaserTractorBeam extends TileEntitySpecialRenderer { + private ModelLaserAmplifier model = new ModelLaserAmplifier(); - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntityLaserTractorBeam)tileEntity, x, y, z, partialTick); - } + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt((TileEntityLaserTractorBeam) tileEntity, x, y, z, partialTick); + } - private void renderAModelAt(TileEntityLaserTractorBeam tileEntity, double x, double y, double z, float partialTick) - { - GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); + private void renderAModelAt( + TileEntityLaserTractorBeam tileEntity, + double x, + double y, + double z, + float partialTick + ) { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "LaserTractorBeam.png")); + bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "LaserTractorBeam.png") + ); - switch(tileEntity.facing) - { - case 0: - GL11.glTranslatef(0.0F, -2.0F, 0.0F); - GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F); - break; - case 5: - GL11.glTranslatef(0.0F, -1.0F, 0.0F); - GL11.glTranslatef(1.0F, 0.0F, 0.0F); - GL11.glRotatef(90, 0.0F, 0.0F, -1.0F); - break; - case 4: - GL11.glTranslatef(0.0F, -1.0F, 0.0F); - GL11.glTranslatef(-1.0F, 0.0F, 0.0F); - GL11.glRotatef(90, 0.0F, 0.0F, 1.0F); - break; - case 2: - GL11.glTranslatef(0.0F, -1.0F, 0.0F); - GL11.glTranslatef(0.0F, 0.0F, -1.0F); - GL11.glRotatef(90, -1.0F, 0.0F, 0.0F); - break; - case 3: - GL11.glTranslatef(0.0F, -1.0F, 0.0F); - GL11.glTranslatef(0.0F, 0.0F, 1.0F); - GL11.glRotatef(90, 1.0F, 0.0F, 0.0F); - break; - } + switch (tileEntity.facing) { + case 0: + GL11.glTranslatef(0.0F, -2.0F, 0.0F); + GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F); + break; + case 5: + GL11.glTranslatef(0.0F, -1.0F, 0.0F); + GL11.glTranslatef(1.0F, 0.0F, 0.0F); + GL11.glRotatef(90, 0.0F, 0.0F, -1.0F); + break; + case 4: + GL11.glTranslatef(0.0F, -1.0F, 0.0F); + GL11.glTranslatef(-1.0F, 0.0F, 0.0F); + GL11.glRotatef(90, 0.0F, 0.0F, 1.0F); + break; + case 2: + GL11.glTranslatef(0.0F, -1.0F, 0.0F); + GL11.glTranslatef(0.0F, 0.0F, -1.0F); + GL11.glRotatef(90, -1.0F, 0.0F, 0.0F); + break; + case 3: + GL11.glTranslatef(0.0F, -1.0F, 0.0F); + GL11.glTranslatef(0.0F, 0.0F, 1.0F); + GL11.glRotatef(90, 1.0F, 0.0F, 0.0F); + break; + } - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - MekanismRenderer.blendOn(); - model.render(0.0625F); - MekanismRenderer.blendOff(); - GL11.glPopMatrix(); - } + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + MekanismRenderer.blendOn(); + model.render(0.0625F); + MekanismRenderer.blendOff(); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/mekanism/client/render/tileentity/RenderLogisticalSorter.java b/src/main/java/mekanism/client/render/tileentity/RenderLogisticalSorter.java index 418586b68..c5a755b4b 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderLogisticalSorter.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderLogisticalSorter.java @@ -1,57 +1,68 @@ package mekanism.client.render.tileentity; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.model.ModelLogisticalSorter; import mekanism.common.tile.TileEntityLogisticalSorter; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class RenderLogisticalSorter extends TileEntitySpecialRenderer -{ - private ModelLogisticalSorter model = new ModelLogisticalSorter(); +public class RenderLogisticalSorter extends TileEntitySpecialRenderer { + private ModelLogisticalSorter model = new ModelLogisticalSorter(); - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntityLogisticalSorter)tileEntity, x, y, z, partialTick); - } + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt((TileEntityLogisticalSorter) tileEntity, x, y, z, partialTick); + } - private void renderAModelAt(TileEntityLogisticalSorter tileEntity, double x, double y, double z, float partialTick) - { - GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); + private void renderAModelAt( + TileEntityLogisticalSorter tileEntity, + double x, + double y, + double z, + float partialTick + ) { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "LogisticalSorter" + (tileEntity.isActive ? "On" : "") + ".png")); + bindTexture(MekanismUtils.getResource( + ResourceType.RENDER, + "LogisticalSorter" + (tileEntity.isActive ? "On" : "") + ".png" + )); - switch(tileEntity.facing) - { - case 0: - { - GL11.glRotatef(90F, -1.0F, 0.0F, 0.0F); - GL11.glTranslatef(0.0F, 1.0F, -1.0F); - break; - } - case 1: - { - GL11.glRotatef(90F, 1.0F, 0.0F, 0.0F); - GL11.glTranslatef(0.0F, 1.0F, 1.0F); - break; - } - case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; - case 3: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; - case 4: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; - case 5: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; - } + switch (tileEntity.facing) { + case 0: { + GL11.glRotatef(90F, -1.0F, 0.0F, 0.0F); + GL11.glTranslatef(0.0F, 1.0F, -1.0F); + break; + } + case 1: { + GL11.glRotatef(90F, 1.0F, 0.0F, 0.0F); + GL11.glTranslatef(0.0F, 1.0F, 1.0F); + break; + } + case 2: + GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); + break; + case 3: + GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); + break; + case 4: + GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); + break; + case 5: + GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); + break; + } - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - model.render(0.0625F, tileEntity.isActive); - GL11.glPopMatrix(); - } + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + model.render(0.0625F, tileEntity.isActive); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/mekanism/client/render/tileentity/RenderMetallurgicInfuser.java b/src/main/java/mekanism/client/render/tileentity/RenderMetallurgicInfuser.java index c0e8b3410..04aa5e996 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderMetallurgicInfuser.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderMetallurgicInfuser.java @@ -1,5 +1,7 @@ package mekanism.client.render.tileentity; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.model.ModelMetallurgicInfuser; import mekanism.client.render.MekanismRenderer; import mekanism.common.tile.TileEntityMetallurgicInfuser; @@ -7,42 +9,52 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class RenderMetallurgicInfuser extends TileEntitySpecialRenderer -{ - private ModelMetallurgicInfuser model = new ModelMetallurgicInfuser(); +public class RenderMetallurgicInfuser extends TileEntitySpecialRenderer { + private ModelMetallurgicInfuser model = new ModelMetallurgicInfuser(); - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntityMetallurgicInfuser)tileEntity, x, y, z, partialTick); - } + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt((TileEntityMetallurgicInfuser) tileEntity, x, y, z, partialTick); + } - private void renderAModelAt(TileEntityMetallurgicInfuser tileEntity, double x, double y, double z, float partialTick) - { - GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); + private void renderAModelAt( + TileEntityMetallurgicInfuser tileEntity, + double x, + double y, + double z, + float partialTick + ) { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "MetallurgicInfuser.png")); + bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "MetallurgicInfuser.png") + ); - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; - case 3: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; - case 4: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; - case 5: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; - } + switch (tileEntity.facing) { + case 2: + GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); + break; + case 3: + GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); + break; + case 4: + GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); + break; + case 5: + GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); + break; + } - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - model.render(0.0625F); - GL11.glPopMatrix(); + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + model.render(0.0625F); + GL11.glPopMatrix(); - MekanismRenderer.machineRenderer.renderAModelAt(tileEntity, x, y, z, partialTick); - } + MekanismRenderer.machineRenderer.renderAModelAt(tileEntity, x, y, z, partialTick); + } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/render/tileentity/RenderObsidianTNT.java b/src/main/java/mekanism/client/render/tileentity/RenderObsidianTNT.java index 0e0621cc4..40439aa31 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderObsidianTNT.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderObsidianTNT.java @@ -1,37 +1,36 @@ package mekanism.client.render.tileentity; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.model.ModelObsidianTNT; import mekanism.common.tile.TileEntityObsidianTNT; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class RenderObsidianTNT extends TileEntitySpecialRenderer -{ - private ModelObsidianTNT model = new ModelObsidianTNT(); +public class RenderObsidianTNT extends TileEntitySpecialRenderer { + private ModelObsidianTNT model = new ModelObsidianTNT(); - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntityObsidianTNT)tileEntity, x, y, z, partialTick); - } + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt((TileEntityObsidianTNT) tileEntity, x, y, z, partialTick); + } - private void renderAModelAt(TileEntityObsidianTNT tileEntity, double x, double y, double z, float partialTick) - { - GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); + private void renderAModelAt( + TileEntityObsidianTNT tileEntity, double x, double y, double z, float partialTick + ) { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ObsidianTNT.png")); + bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ObsidianTNT.png")); - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - model.render(0.0625F); - GL11.glPopMatrix(); - } + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + model.render(0.0625F); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/mekanism/client/render/tileentity/RenderPersonalChest.java b/src/main/java/mekanism/client/render/tileentity/RenderPersonalChest.java index 4da18412d..75a4747ee 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderPersonalChest.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderPersonalChest.java @@ -1,60 +1,63 @@ package mekanism.client.render.tileentity; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.common.tile.TileEntityPersonalChest; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.model.ModelChest; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class RenderPersonalChest extends TileEntitySpecialRenderer -{ - private ModelChest model = new ModelChest(); +public class RenderPersonalChest extends TileEntitySpecialRenderer { + private ModelChest model = new ModelChest(); - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntityPersonalChest)tileEntity, x, y, z, partialTick); - } + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt((TileEntityPersonalChest) tileEntity, x, y, z, partialTick); + } - private void renderAModelAt(TileEntityPersonalChest tileEntity, double x, double y, double z, float partialTick) - { - GL11.glPushMatrix(); - GL11.glTranslatef((float)x, (float)y + 1.0F, (float)z); - GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "PersonalChest.png")); + private void renderAModelAt( + TileEntityPersonalChest tileEntity, + double x, + double y, + double z, + float partialTick + ) { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x, (float) y + 1.0F, (float) z); + GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); + bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "PersonalChest.png")); - switch(tileEntity.facing) - { - case 2: - GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); - GL11.glTranslatef(1.0F, 0.0F, 0.0F); - break; - case 3: - GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); - GL11.glTranslatef(0.0F, 0.0F, -1.0F); - break; - case 4: - GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); - break; - case 5: - GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); - GL11.glTranslatef(1.0F, 0.0F, -1.0F); - break; - } + switch (tileEntity.facing) { + case 2: + GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(1.0F, 0.0F, 0.0F); + break; + case 3: + GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(0.0F, 0.0F, -1.0F); + break; + case 4: + GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); + break; + case 5: + GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(1.0F, 0.0F, -1.0F); + break; + } - float lidangle = tileEntity.prevLidAngle + (tileEntity.lidAngle - tileEntity.prevLidAngle) * partialTick; - lidangle = 1.0F - lidangle; - lidangle = 1.0F - lidangle * lidangle * lidangle; - model.chestLid.rotateAngleX = -((lidangle * 3.141593F) / 2.0F); - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - model.renderAll(); - GL11.glPopMatrix(); - } + float lidangle = tileEntity.prevLidAngle + + (tileEntity.lidAngle - tileEntity.prevLidAngle) * partialTick; + lidangle = 1.0F - lidangle; + lidangle = 1.0F - lidangle * lidangle * lidangle; + model.chestLid.rotateAngleX = -((lidangle * 3.141593F) / 2.0F); + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + model.renderAll(); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/mekanism/client/render/tileentity/RenderPressurizedReactionChamber.java b/src/main/java/mekanism/client/render/tileentity/RenderPressurizedReactionChamber.java index ba955e013..f32977b58 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderPressurizedReactionChamber.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderPressurizedReactionChamber.java @@ -1,5 +1,7 @@ package mekanism.client.render.tileentity; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.model.ModelPressurizedReactionChamber; import mekanism.client.render.MekanismRenderer; import mekanism.common.tile.TileEntityPRC; @@ -7,42 +9,48 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class RenderPressurizedReactionChamber extends TileEntitySpecialRenderer -{ - private ModelPressurizedReactionChamber model = new ModelPressurizedReactionChamber(); +public class RenderPressurizedReactionChamber extends TileEntitySpecialRenderer { + private ModelPressurizedReactionChamber model = new ModelPressurizedReactionChamber(); - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntityPRC)tileEntity, x, y, z, partialTick); - } + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt((TileEntityPRC) tileEntity, x, y, z, partialTick); + } - private void renderAModelAt(TileEntityPRC tileEntity, double x, double y, double z, float partialTick) - { - GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); + private void renderAModelAt( + TileEntityPRC tileEntity, double x, double y, double z, float partialTick + ) { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "PressurizedReactionChamber.png")); + bindTexture(MekanismUtils.getResource( + ResourceType.RENDER, "PressurizedReactionChamber.png" + )); - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; - case 3: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; - case 4: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; - case 5: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; - } + switch (tileEntity.facing) { + case 2: + GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); + break; + case 3: + GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); + break; + case 4: + GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); + break; + case 5: + GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); + break; + } - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - model.render(0.0625F); - GL11.glPopMatrix(); + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + model.render(0.0625F); + GL11.glPopMatrix(); - MekanismRenderer.machineRenderer.renderAModelAt(tileEntity, x, y, z, partialTick); - } + MekanismRenderer.machineRenderer.renderAModelAt(tileEntity, x, y, z, partialTick); + } } \ No newline at end of file diff --git a/src/main/java/mekanism/client/render/tileentity/RenderQuantumEntangloporter.java b/src/main/java/mekanism/client/render/tileentity/RenderQuantumEntangloporter.java index 1187767e5..63aad8c55 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderQuantumEntangloporter.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderQuantumEntangloporter.java @@ -1,5 +1,7 @@ package mekanism.client.render.tileentity; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.model.ModelQuantumEntangloporter; import mekanism.client.render.MekanismRenderer; import mekanism.common.tile.TileEntityQuantumEntangloporter; @@ -7,42 +9,54 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class RenderQuantumEntangloporter extends TileEntitySpecialRenderer -{ - private ModelQuantumEntangloporter model = new ModelQuantumEntangloporter(); +public class RenderQuantumEntangloporter extends TileEntitySpecialRenderer { + private ModelQuantumEntangloporter model = new ModelQuantumEntangloporter(); - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntityQuantumEntangloporter)tileEntity, x, y, z, partialTick); - } + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt( + (TileEntityQuantumEntangloporter) tileEntity, x, y, z, partialTick + ); + } - private void renderAModelAt(TileEntityQuantumEntangloporter tileEntity, double x, double y, double z, float partialTick) - { - GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); + private void renderAModelAt( + TileEntityQuantumEntangloporter tileEntity, + double x, + double y, + double z, + float partialTick + ) { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "QuantumEntangloporter.png")); + bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "QuantumEntangloporter.png") + ); - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; - case 3: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; - case 4: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; - case 5: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; - } + switch (tileEntity.facing) { + case 2: + GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); + break; + case 3: + GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); + break; + case 4: + GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); + break; + case 5: + GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); + break; + } - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - model.render(0.0625F, field_147501_a.field_147553_e); - GL11.glPopMatrix(); + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + model.render(0.0625F, field_147501_a.field_147553_e); + GL11.glPopMatrix(); - MekanismRenderer.machineRenderer.renderAModelAt(tileEntity, x, y, z, partialTick); - } + MekanismRenderer.machineRenderer.renderAModelAt(tileEntity, x, y, z, partialTick); + } } diff --git a/src/main/java/mekanism/client/render/tileentity/RenderResistiveHeater.java b/src/main/java/mekanism/client/render/tileentity/RenderResistiveHeater.java index df43ecd60..3479d54fd 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderResistiveHeater.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderResistiveHeater.java @@ -1,44 +1,55 @@ package mekanism.client.render.tileentity; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.model.ModelResistiveHeater; import mekanism.common.tile.TileEntityResistiveHeater; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class RenderResistiveHeater extends TileEntitySpecialRenderer -{ - private ModelResistiveHeater model = new ModelResistiveHeater(); +public class RenderResistiveHeater extends TileEntitySpecialRenderer { + private ModelResistiveHeater model = new ModelResistiveHeater(); - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntityResistiveHeater)tileEntity, x, y, z, partialTick); - } + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt((TileEntityResistiveHeater) tileEntity, x, y, z, partialTick); + } - private void renderAModelAt(TileEntityResistiveHeater tileEntity, double x, double y, double z, float partialTick) - { - GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ResistiveHeater.png")); + private void renderAModelAt( + TileEntityResistiveHeater tileEntity, + double x, + double y, + double z, + float partialTick + ) { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); + bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "ResistiveHeater.png") + ); - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; - case 3: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; - case 4: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; - case 5: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; - } + switch (tileEntity.facing) { + case 2: + GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); + break; + case 3: + GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); + break; + case 4: + GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); + break; + case 5: + GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); + break; + } - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - model.render(0.0625F, tileEntity.isActive, field_147501_a.field_147553_e); - GL11.glPopMatrix(); - } + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + model.render(0.0625F, tileEntity.isActive, field_147501_a.field_147553_e); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/mekanism/client/render/tileentity/RenderRotaryCondensentrator.java b/src/main/java/mekanism/client/render/tileentity/RenderRotaryCondensentrator.java index ac2892a04..77084bcd4 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderRotaryCondensentrator.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderRotaryCondensentrator.java @@ -1,45 +1,59 @@ package mekanism.client.render.tileentity; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.model.ModelRotaryCondensentrator; import mekanism.common.tile.TileEntityRotaryCondensentrator; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class RenderRotaryCondensentrator extends TileEntitySpecialRenderer -{ - private ModelRotaryCondensentrator model = new ModelRotaryCondensentrator(); +public class RenderRotaryCondensentrator extends TileEntitySpecialRenderer { + private ModelRotaryCondensentrator model = new ModelRotaryCondensentrator(); - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntityRotaryCondensentrator)tileEntity, x, y, z, partialTick); - } + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt( + (TileEntityRotaryCondensentrator) tileEntity, x, y, z, partialTick + ); + } - private void renderAModelAt(TileEntityRotaryCondensentrator tileEntity, double x, double y, double z, float partialTick) - { - GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); + private void renderAModelAt( + TileEntityRotaryCondensentrator tileEntity, + double x, + double y, + double z, + float partialTick + ) { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "RotaryCondensentrator.png")); + bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "RotaryCondensentrator.png") + ); - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; - case 3: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; - case 4: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; - case 5: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; - } + switch (tileEntity.facing) { + case 2: + GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); + break; + case 3: + GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); + break; + case 4: + GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); + break; + case 5: + GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); + break; + } - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - model.render(0.0625F); - GL11.glPopMatrix(); - } + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + model.render(0.0625F); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/mekanism/client/render/tileentity/RenderSecurityDesk.java b/src/main/java/mekanism/client/render/tileentity/RenderSecurityDesk.java index 1644afd11..1479bf29d 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderSecurityDesk.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderSecurityDesk.java @@ -1,45 +1,51 @@ package mekanism.client.render.tileentity; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.model.ModelSecurityDesk; import mekanism.common.tile.TileEntitySecurityDesk; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class RenderSecurityDesk extends TileEntitySpecialRenderer -{ - private ModelSecurityDesk model = new ModelSecurityDesk(); +public class RenderSecurityDesk extends TileEntitySpecialRenderer { + private ModelSecurityDesk model = new ModelSecurityDesk(); - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntitySecurityDesk)tileEntity, x, y, z, partialTick); - } + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt((TileEntitySecurityDesk) tileEntity, x, y, z, partialTick); + } - private void renderAModelAt(TileEntitySecurityDesk tileEntity, double x, double y, double z, float partialTick) - { - GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); + private void renderAModelAt( + TileEntitySecurityDesk tileEntity, double x, double y, double z, float partialTick + ) { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "SecurityDesk.png")); + bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "SecurityDesk.png")); - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; - case 3: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; - case 4: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; - case 5: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; - } + switch (tileEntity.facing) { + case 2: + GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); + break; + case 3: + GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); + break; + case 4: + GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); + break; + case 5: + GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); + break; + } - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - model.render(0.0625F, field_147501_a.field_147553_e); - GL11.glPopMatrix(); - } + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + model.render(0.0625F, field_147501_a.field_147553_e); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/mekanism/client/render/tileentity/RenderSeismicVibrator.java b/src/main/java/mekanism/client/render/tileentity/RenderSeismicVibrator.java index 797f44102..8586fb20e 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderSeismicVibrator.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderSeismicVibrator.java @@ -1,47 +1,62 @@ package mekanism.client.render.tileentity; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.model.ModelSeismicVibrator; import mekanism.common.tile.TileEntitySeismicVibrator; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class RenderSeismicVibrator extends TileEntitySpecialRenderer -{ - private ModelSeismicVibrator model = new ModelSeismicVibrator(); +public class RenderSeismicVibrator extends TileEntitySpecialRenderer { + private ModelSeismicVibrator model = new ModelSeismicVibrator(); - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntitySeismicVibrator)tileEntity, x, y, z, partialTick); - } + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt((TileEntitySeismicVibrator) tileEntity, x, y, z, partialTick); + } - private void renderAModelAt(TileEntitySeismicVibrator tileEntity, double x, double y, double z, float partialTick) - { - GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); + private void renderAModelAt( + TileEntitySeismicVibrator tileEntity, + double x, + double y, + double z, + float partialTick + ) { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "SeismicVibrator" /*+ (tileEntity.isActive ? "On" : "")*/ + ".png")); + bindTexture(MekanismUtils.getResource( + ResourceType.RENDER, + "SeismicVibrator" /*+ (tileEntity.isActive ? "On" : "")*/ + ".png" + )); - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; - case 3: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; - case 4: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; - case 5: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; - } - - float actualRate = (float)Math.sin((tileEntity.clientPiston + (tileEntity.isActive ? partialTick : 0))/5F); + switch (tileEntity.facing) { + case 2: + GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); + break; + case 3: + GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); + break; + case 4: + GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); + break; + case 5: + GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); + break; + } - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - model.renderWithPiston(Math.max(0, actualRate), 0.0625F); - GL11.glPopMatrix(); - } + float actualRate = (float) Math.sin( + (tileEntity.clientPiston + (tileEntity.isActive ? partialTick : 0)) / 5F + ); + + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + model.renderWithPiston(Math.max(0, actualRate), 0.0625F); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/mekanism/client/render/tileentity/RenderSolarNeutronActivator.java b/src/main/java/mekanism/client/render/tileentity/RenderSolarNeutronActivator.java index a02c3882a..98bb3ab64 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderSolarNeutronActivator.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderSolarNeutronActivator.java @@ -1,46 +1,60 @@ package mekanism.client.render.tileentity; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.model.ModelSolarNeutronActivator; import mekanism.common.tile.TileEntitySolarNeutronActivator; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class RenderSolarNeutronActivator extends TileEntitySpecialRenderer -{ - private ModelSolarNeutronActivator model = new ModelSolarNeutronActivator(); - - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntitySolarNeutronActivator)tileEntity, x, y, z, partialTick); - } - - private void renderAModelAt(TileEntitySolarNeutronActivator tileEntity, double x, double y, double z, float partialTick) - { - GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); - - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "SolarNeutronActivator.png")); - - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; - case 3: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; - case 4: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; - case 5: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; - } - - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - - model.render(0.0625F); - GL11.glPopMatrix(); - } +public class RenderSolarNeutronActivator extends TileEntitySpecialRenderer { + private ModelSolarNeutronActivator model = new ModelSolarNeutronActivator(); + + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt( + (TileEntitySolarNeutronActivator) tileEntity, x, y, z, partialTick + ); + } + + private void renderAModelAt( + TileEntitySolarNeutronActivator tileEntity, + double x, + double y, + double z, + float partialTick + ) { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); + + bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "SolarNeutronActivator.png") + ); + + switch (tileEntity.facing) { + case 2: + GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); + break; + case 3: + GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); + break; + case 4: + GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); + break; + case 5: + GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); + break; + } + + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + + model.render(0.0625F); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/mekanism/client/render/tileentity/RenderTeleporter.java b/src/main/java/mekanism/client/render/tileentity/RenderTeleporter.java index fcc05fecc..930f0d280 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderTeleporter.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderTeleporter.java @@ -14,113 +14,109 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.init.Blocks; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; - import org.lwjgl.opengl.GL11; -public class RenderTeleporter extends TileEntitySpecialRenderer -{ - private HashMap cachedOverlays = new HashMap(); +public class RenderTeleporter extends TileEntitySpecialRenderer { + private HashMap cachedOverlays + = new HashMap(); - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntityTeleporter)tileEntity, x, y, z, partialTick); - } + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt((TileEntityTeleporter) tileEntity, x, y, z, partialTick); + } - public void renderAModelAt(TileEntityTeleporter tileEntity, double x, double y, double z, float partialTick) - { - if(tileEntity.shouldRender) - { - push(); + public void renderAModelAt( + TileEntityTeleporter tileEntity, double x, double y, double z, float partialTick + ) { + if (tileEntity.shouldRender) { + push(); - GL11.glColor4f(EnumColor.PURPLE.getColor(0), EnumColor.PURPLE.getColor(1), EnumColor.PURPLE.getColor(2), 0.75F); + GL11.glColor4f( + EnumColor.PURPLE.getColor(0), + EnumColor.PURPLE.getColor(1), + EnumColor.PURPLE.getColor(2), + 0.75F + ); - bindTexture(MekanismRenderer.getBlocksTexture()); - GL11.glTranslatef((float)x, (float)y, (float)z); + bindTexture(MekanismRenderer.getBlocksTexture()); + GL11.glTranslatef((float) x, (float) y, (float) z); - Coord4D obj = Coord4D.get(tileEntity).getFromSide(ForgeDirection.WEST); - int type = 0; + Coord4D obj = Coord4D.get(tileEntity).getFromSide(ForgeDirection.WEST); + int type = 0; - if(obj.getBlock(tileEntity.getWorldObj()) == MekanismBlocks.BasicBlock && obj.getMetadata(tileEntity.getWorldObj()) == 7) - { - type = 1; - } + if (obj.getBlock(tileEntity.getWorldObj()) == MekanismBlocks.BasicBlock + && obj.getMetadata(tileEntity.getWorldObj()) == 7) { + type = 1; + } - int display = getOverlayDisplay(type).display; - GL11.glCallList(display); + int display = getOverlayDisplay(type).display; + GL11.glCallList(display); - pop(); - } - } + pop(); + } + } - private void pop() - { - GL11.glPopAttrib(); - MekanismRenderer.glowOff(); - MekanismRenderer.blendOff(); - GL11.glPopMatrix(); - } + private void pop() { + GL11.glPopAttrib(); + MekanismRenderer.glowOff(); + MekanismRenderer.blendOff(); + GL11.glPopMatrix(); + } - private void push() - { - GL11.glPushMatrix(); - GL11.glPushAttrib(GL11.GL_ENABLE_BIT); - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glDisable(GL11.GL_LIGHTING); - MekanismRenderer.glowOn(); - MekanismRenderer.blendOn(); - } + private void push() { + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_ENABLE_BIT); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glDisable(GL11.GL_LIGHTING); + MekanismRenderer.glowOn(); + MekanismRenderer.blendOn(); + } - private DisplayInteger getOverlayDisplay(Integer type) - { - if(cachedOverlays.containsKey(type)) - { - return cachedOverlays.get(type); - } + private DisplayInteger getOverlayDisplay(Integer type) { + if (cachedOverlays.containsKey(type)) { + return cachedOverlays.get(type); + } - Model3D toReturn = new Model3D(); - toReturn.baseBlock = Blocks.stone; - toReturn.setTexture(GasRegistry.getGas("oxygen").getIcon()); + Model3D toReturn = new Model3D(); + toReturn.baseBlock = Blocks.stone; + toReturn.setTexture(GasRegistry.getGas("oxygen").getIcon()); - DisplayInteger display = DisplayInteger.createAndStart(); + DisplayInteger display = DisplayInteger.createAndStart(); - if(cachedOverlays.containsKey(type)) - { - cachedOverlays.get(type); - } - else { - cachedOverlays.put(type, display); - } + if (cachedOverlays.containsKey(type)) { + cachedOverlays.get(type); + } else { + cachedOverlays.put(type, display); + } - switch(type) - { - case 0: - { - toReturn.minY = 1; - toReturn.maxY = 3; + switch (type) { + case 0: { + toReturn.minY = 1; + toReturn.maxY = 3; - toReturn.minX = 0.46; - toReturn.minZ = 0; - toReturn.maxX = 0.54; - toReturn.maxZ = 1; - break; - } - case 1: - { - toReturn.minY = 1; - toReturn.maxY = 3; + toReturn.minX = 0.46; + toReturn.minZ = 0; + toReturn.maxX = 0.54; + toReturn.maxZ = 1; + break; + } + case 1: { + toReturn.minY = 1; + toReturn.maxY = 3; - toReturn.minX = 0; - toReturn.minZ = 0.46; - toReturn.maxX = 1; - toReturn.maxZ = 0.54; - break; - } - } + toReturn.minX = 0; + toReturn.minZ = 0.46; + toReturn.maxX = 1; + toReturn.maxZ = 0.54; + break; + } + } - MekanismRenderer.renderObject(toReturn); - display.endList(); + MekanismRenderer.renderObject(toReturn); + display.endList(); - return display; - } + return display; + } } diff --git a/src/main/java/mekanism/client/render/tileentity/RenderTheoreticalElementizer.java b/src/main/java/mekanism/client/render/tileentity/RenderTheoreticalElementizer.java index 0805725e2..d08d4a790 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderTheoreticalElementizer.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderTheoreticalElementizer.java @@ -1,7 +1,5 @@ package mekanism.client.render.tileentity; -import org.lwjgl.opengl.GL11; - import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.model.ModelTheoreticalElementizer; @@ -10,25 +8,41 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; +import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) -public class RenderTheoreticalElementizer extends TileEntitySpecialRenderer -{ +public class RenderTheoreticalElementizer extends TileEntitySpecialRenderer { private ModelTheoreticalElementizer model; - + public RenderTheoreticalElementizer() { this.model = new ModelTheoreticalElementizer(); } - + @Override - public void renderTileEntityAt(final TileEntity tileEntity, final double x, final double y, final double z, final float partialTick) { - this.renderAModelAt((TileEntityTheoreticalElementizer)tileEntity, x, y, z, partialTick); + public void renderTileEntityAt( + final TileEntity tileEntity, + final double x, + final double y, + final double z, + final float partialTick + ) { + this.renderAModelAt( + (TileEntityTheoreticalElementizer) tileEntity, x, y, z, partialTick + ); } - - private void renderAModelAt(final TileEntityTheoreticalElementizer tileEntity, final double x, final double y, final double z, final float partialTick) { + + private void renderAModelAt( + final TileEntityTheoreticalElementizer tileEntity, + final double x, + final double y, + final double z, + final float partialTick + ) { GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5f, (float)y + 1.5f, (float)z + 0.5f); - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "TheoreticalElementizer.png")); + GL11.glTranslatef((float) x + 0.5f, (float) y + 1.5f, (float) z + 0.5f); + bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "TheoreticalElementizer.png") + ); switch (tileEntity.facing) { case 2: { GL11.glRotatef(270.0f, 0.0f, 1.0f, 0.0f); @@ -53,5 +67,4 @@ public class RenderTheoreticalElementizer extends TileEntitySpecialRenderer this.model.render(0.0625f); GL11.glPopMatrix(); } - } diff --git a/src/main/java/mekanism/client/render/tileentity/RenderThermalEvaporationController.java b/src/main/java/mekanism/client/render/tileentity/RenderThermalEvaporationController.java index 1d6cf6e5e..959ce9284 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderThermalEvaporationController.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderThermalEvaporationController.java @@ -3,6 +3,8 @@ package mekanism.client.render.tileentity; import java.util.HashMap; import java.util.Map; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.client.render.MekanismRenderer; import mekanism.client.render.MekanismRenderer.DisplayInteger; @@ -15,197 +17,194 @@ import net.minecraft.init.Blocks; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class RenderThermalEvaporationController extends TileEntitySpecialRenderer -{ - private static Map> cachedCenterFluids = new HashMap>(); +public class RenderThermalEvaporationController extends TileEntitySpecialRenderer { + private static Map> + cachedCenterFluids + = new HashMap>(); - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntityThermalEvaporationController)tileEntity, x, y, z, partialTick); - } + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt( + (TileEntityThermalEvaporationController) tileEntity, x, y, z, partialTick + ); + } - public void renderAModelAt(TileEntityThermalEvaporationController tileEntity, double x, double y, double z, float partialTick) - { - if(tileEntity.structured && tileEntity.inputTank.getFluid() != null) - { - SalinationRenderData data = new SalinationRenderData(); + public void renderAModelAt( + TileEntityThermalEvaporationController tileEntity, + double x, + double y, + double z, + float partialTick + ) { + if (tileEntity.structured && tileEntity.inputTank.getFluid() != null) { + SalinationRenderData data = new SalinationRenderData(); - data.height = tileEntity.height-2; - data.side = ForgeDirection.getOrientation(tileEntity.facing); + data.height = tileEntity.height - 2; + data.side = ForgeDirection.getOrientation(tileEntity.facing); - bindTexture(MekanismRenderer.getBlocksTexture()); - - if(data.height >= 1 && tileEntity.inputTank.getCapacity() > 0) - { - Coord4D renderLoc = tileEntity.getRenderLocation(); + bindTexture(MekanismRenderer.getBlocksTexture()); - push(); + if (data.height >= 1 && tileEntity.inputTank.getCapacity() > 0) { + Coord4D renderLoc = tileEntity.getRenderLocation(); - GL11.glTranslated(getX(renderLoc.xCoord), getY(renderLoc.yCoord), getZ(renderLoc.zCoord)); + push(); - MekanismRenderer.glowOn(tileEntity.inputTank.getFluid().getFluid().getLuminosity()); + GL11.glTranslated( + getX(renderLoc.xCoord), getY(renderLoc.yCoord), getZ(renderLoc.zCoord) + ); - DisplayInteger[] displayList = getListAndRender(data, tileEntity.inputTank.getFluid().getFluid()); - displayList[(int)(((float)tileEntity.inputTank.getFluidAmount()/tileEntity.inputTank.getCapacity())*((float)getStages(data.height)-1))].render(); + MekanismRenderer.glowOn( + tileEntity.inputTank.getFluid().getFluid().getLuminosity() + ); - MekanismRenderer.glowOff(); + DisplayInteger[] displayList + = getListAndRender(data, tileEntity.inputTank.getFluid().getFluid()); + displayList[(int + ) (((float) tileEntity.inputTank.getFluidAmount() + / tileEntity.inputTank.getCapacity()) + * ((float) getStages(data.height) - 1))] + .render(); - pop(); - } - } - } + MekanismRenderer.glowOff(); - private void pop() - { - GL11.glPopAttrib(); - GL11.glPopMatrix(); - } + pop(); + } + } + } - private void push() - { - GL11.glPushMatrix(); - GL11.glPushAttrib(GL11.GL_ENABLE_BIT); - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glEnable(GL11.GL_BLEND); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - } + private void pop() { + GL11.glPopAttrib(); + GL11.glPopMatrix(); + } - @SuppressWarnings("incomplete-switch") - private DisplayInteger[] getListAndRender(SalinationRenderData data, Fluid fluid) - { - if(cachedCenterFluids.containsKey(data) && cachedCenterFluids.get(data).containsKey(fluid)) - { - return cachedCenterFluids.get(data).get(fluid); - } + private void push() { + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_ENABLE_BIT); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + } - Model3D toReturn = new Model3D(); - toReturn.baseBlock = Blocks.water; - toReturn.setTexture(fluid.getIcon()); + @SuppressWarnings("incomplete-switch") + private DisplayInteger[] getListAndRender(SalinationRenderData data, Fluid fluid) { + if (cachedCenterFluids.containsKey(data) + && cachedCenterFluids.get(data).containsKey(fluid)) { + return cachedCenterFluids.get(data).get(fluid); + } - final int stages = getStages(data.height); - DisplayInteger[] displays = new DisplayInteger[stages]; + Model3D toReturn = new Model3D(); + toReturn.baseBlock = Blocks.water; + toReturn.setTexture(fluid.getIcon()); - if(cachedCenterFluids.containsKey(data)) - { - cachedCenterFluids.get(data).put(fluid, displays); - } - else { - HashMap map = new HashMap(); - map.put(fluid, displays); - cachedCenterFluids.put(data, map); - } + final int stages = getStages(data.height); + DisplayInteger[] displays = new DisplayInteger[stages]; - MekanismRenderer.colorFluid(fluid); + if (cachedCenterFluids.containsKey(data)) { + cachedCenterFluids.get(data).put(fluid, displays); + } else { + HashMap map = new HashMap(); + map.put(fluid, displays); + cachedCenterFluids.put(data, map); + } - for(int i = 0; i < stages; i++) - { - displays[i] = DisplayInteger.createAndStart(); + MekanismRenderer.colorFluid(fluid); - if(fluid.getIcon() != null) - { - switch(data.side) - { - case NORTH: - toReturn.minX = 0 + .01; - toReturn.minY = 0 + .01; - toReturn.minZ = 0 + .01; + for (int i = 0; i < stages; i++) { + displays[i] = DisplayInteger.createAndStart(); - toReturn.maxX = 2 - .01; - toReturn.maxY = ((float)i/(float)stages)*data.height - .01; - toReturn.maxZ = 2 - .01; - break; - case SOUTH: - toReturn.minX = -1 + .01; - toReturn.minY = 0 + .01; - toReturn.minZ = -1 + .01; + if (fluid.getIcon() != null) { + switch (data.side) { + case NORTH: + toReturn.minX = 0 + .01; + toReturn.minY = 0 + .01; + toReturn.minZ = 0 + .01; - toReturn.maxX = 1 - .01; - toReturn.maxY = ((float)i/(float)stages)*data.height - .01; - toReturn.maxZ = 1 - .01; - break; - case WEST: - toReturn.minX = 0 + .01; - toReturn.minY = 0 + .01; - toReturn.minZ = -1 + .01; + toReturn.maxX = 2 - .01; + toReturn.maxY = ((float) i / (float) stages) * data.height - .01; + toReturn.maxZ = 2 - .01; + break; + case SOUTH: + toReturn.minX = -1 + .01; + toReturn.minY = 0 + .01; + toReturn.minZ = -1 + .01; - toReturn.maxX = 2 - .01; - toReturn.maxY = ((float)i/(float)stages)*data.height - .01; - toReturn.maxZ = 1 - .01; - break; - case EAST: - toReturn.minX = -1 + .01; - toReturn.minY = 0 + .01; - toReturn.minZ = 0 + .01; + toReturn.maxX = 1 - .01; + toReturn.maxY = ((float) i / (float) stages) * data.height - .01; + toReturn.maxZ = 1 - .01; + break; + case WEST: + toReturn.minX = 0 + .01; + toReturn.minY = 0 + .01; + toReturn.minZ = -1 + .01; - toReturn.maxX = 1 - .01; - toReturn.maxY = ((float)i/(float)stages)*data.height - .01; - toReturn.maxZ = 2 - .01; - break; - } + toReturn.maxX = 2 - .01; + toReturn.maxY = ((float) i / (float) stages) * data.height - .01; + toReturn.maxZ = 1 - .01; + break; + case EAST: + toReturn.minX = -1 + .01; + toReturn.minY = 0 + .01; + toReturn.minZ = 0 + .01; - MekanismRenderer.renderObject(toReturn); - } + toReturn.maxX = 1 - .01; + toReturn.maxY = ((float) i / (float) stages) * data.height - .01; + toReturn.maxZ = 2 - .01; + break; + } - displays[i].endList(); - } + MekanismRenderer.renderObject(toReturn); + } - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + displays[i].endList(); + } - return displays; - } + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - private int getStages(int height) - { - return height*(TankUpdateProtocol.FLUID_PER_TANK/10); - } + return displays; + } - private double getX(int x) - { - return x - TileEntityRendererDispatcher.staticPlayerX; - } + private int getStages(int height) { + return height * (TankUpdateProtocol.FLUID_PER_TANK / 10); + } - private double getY(int y) - { - return y - TileEntityRendererDispatcher.staticPlayerY; - } + private double getX(int x) { + return x - TileEntityRendererDispatcher.staticPlayerX; + } - private double getZ(int z) - { - return z - TileEntityRendererDispatcher.staticPlayerZ; - } + private double getY(int y) { + return y - TileEntityRendererDispatcher.staticPlayerY; + } - public static class SalinationRenderData - { - public int height; - public ForgeDirection side; + private double getZ(int z) { + return z - TileEntityRendererDispatcher.staticPlayerZ; + } - @Override - public int hashCode() - { - int code = 1; - code = 31 * code + height; - return code; - } + public static class SalinationRenderData { + public int height; + public ForgeDirection side; - @Override - public boolean equals(Object data) - { - return data instanceof SalinationRenderData && ((SalinationRenderData)data).height == height && - ((SalinationRenderData)data).side == side; - } - } + @Override + public int hashCode() { + int code = 1; + code = 31 * code + height; + return code; + } - public static void resetDisplayInts() - { - cachedCenterFluids.clear(); - } + @Override + public boolean equals(Object data) { + return data instanceof SalinationRenderData + && ((SalinationRenderData) data).height == height + && ((SalinationRenderData) data).side == side; + } + } + + public static void resetDisplayInts() { + cachedCenterFluids.clear(); + } } diff --git a/src/main/java/mekanism/client/render/tileentity/RenderThermoelectricBoiler.java b/src/main/java/mekanism/client/render/tileentity/RenderThermoelectricBoiler.java index 106761c66..ec9066d82 100644 --- a/src/main/java/mekanism/client/render/tileentity/RenderThermoelectricBoiler.java +++ b/src/main/java/mekanism/client/render/tileentity/RenderThermoelectricBoiler.java @@ -3,6 +3,8 @@ package mekanism.client.render.tileentity; import java.util.HashMap; import java.util.Map; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.render.MekanismRenderer; import mekanism.client.render.MekanismRenderer.DisplayInteger; import mekanism.client.render.MekanismRenderer.Model3D; @@ -18,337 +20,372 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class RenderThermoelectricBoiler extends TileEntitySpecialRenderer -{ - private static Map cachedLowerFluids = new HashMap(); - private static Map cachedUpperFluids = new HashMap(); - private static Map cachedValveFluids = new HashMap(); - - private Fluid STEAM = FluidRegistry.getFluid("steam"); - private Fluid WATER = FluidRegistry.WATER; - - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntityBoilerCasing)tileEntity, x, y, z, partialTick); - } +public class RenderThermoelectricBoiler extends TileEntitySpecialRenderer { + private static Map cachedLowerFluids + = new HashMap(); + private static Map cachedUpperFluids + = new HashMap(); + private static Map cachedValveFluids + = new HashMap(); - public void renderAModelAt(TileEntityBoilerCasing tileEntity, double x, double y, double z, float partialTick) - { - if(tileEntity.clientHasStructure && tileEntity.isRendering && tileEntity.structure != null && tileEntity.structure.renderLocation != null && tileEntity.structure.upperRenderLocation != null) - { - if(tileEntity.structure.waterStored != null && tileEntity.structure.waterStored.amount != 0) - { - RenderData data = new RenderData(); + private Fluid STEAM = FluidRegistry.getFluid("steam"); + private Fluid WATER = FluidRegistry.WATER; - data.location = tileEntity.structure.renderLocation; - data.height = (tileEntity.structure.upperRenderLocation.yCoord-1)-tileEntity.structure.renderLocation.yCoord; - data.length = tileEntity.structure.volLength; - data.width = tileEntity.structure.volWidth; + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt((TileEntityBoilerCasing) tileEntity, x, y, z, partialTick); + } - bindTexture(MekanismRenderer.getBlocksTexture()); - - if(data.location != null && data.height >= 1 && tileEntity.structure.waterStored.getFluid() != null) - { - push(); + public void renderAModelAt( + TileEntityBoilerCasing tileEntity, double x, double y, double z, float partialTick + ) { + if (tileEntity.clientHasStructure && tileEntity.isRendering + && tileEntity.structure != null && tileEntity.structure.renderLocation != null + && tileEntity.structure.upperRenderLocation != null) { + if (tileEntity.structure.waterStored != null + && tileEntity.structure.waterStored.amount != 0) { + RenderData data = new RenderData(); - GL11.glTranslated(getX(data.location.xCoord), getY(data.location.yCoord), getZ(data.location.zCoord)); + data.location = tileEntity.structure.renderLocation; + data.height = (tileEntity.structure.upperRenderLocation.yCoord - 1) + - tileEntity.structure.renderLocation.yCoord; + data.length = tileEntity.structure.volLength; + data.width = tileEntity.structure.volWidth; - MekanismRenderer.glowOn(tileEntity.structure.waterStored.getFluid().getLuminosity()); - MekanismRenderer.colorFluid(tileEntity.structure.waterStored.getFluid()); + bindTexture(MekanismRenderer.getBlocksTexture()); - DisplayInteger[] displayList = getLowerDisplay(data, tileEntity.structure.waterStored.getFluid(), tileEntity.getWorldObj()); + if (data.location != null && data.height >= 1 + && tileEntity.structure.waterStored.getFluid() != null) { + push(); - if(tileEntity.structure.waterStored.getFluid().isGaseous()) - { - GL11.glColor4f(1F, 1F, 1F, Math.min(1, ((float)tileEntity.structure.waterStored.amount / (float)tileEntity.clientWaterCapacity)+MekanismRenderer.GAS_RENDER_BASE)); - displayList[getStages(data.height)-1].render(); - } - else { - displayList[Math.min(getStages(data.height)-1, (int)(tileEntity.prevWaterScale*((float)getStages(data.height)-1)))].render(); - } + GL11.glTranslated( + getX(data.location.xCoord), + getY(data.location.yCoord), + getZ(data.location.zCoord) + ); - MekanismRenderer.glowOff(); - MekanismRenderer.resetColor(); + MekanismRenderer.glowOn( + tileEntity.structure.waterStored.getFluid().getLuminosity() + ); + MekanismRenderer.colorFluid(tileEntity.structure.waterStored.getFluid( + )); - pop(); + DisplayInteger[] displayList = getLowerDisplay( + data, + tileEntity.structure.waterStored.getFluid(), + tileEntity.getWorldObj() + ); - for(ValveData valveData : tileEntity.valveViewing) - { - push(); + if (tileEntity.structure.waterStored.getFluid().isGaseous()) { + GL11.glColor4f( + 1F, + 1F, + 1F, + Math.min( + 1, + ((float) tileEntity.structure.waterStored.amount + / (float) tileEntity.clientWaterCapacity) + + MekanismRenderer.GAS_RENDER_BASE + ) + ); + displayList[getStages(data.height) - 1].render(); + } else { + displayList[Math.min( + getStages(data.height) - 1, + (int + ) (tileEntity.prevWaterScale + * ((float) getStages(data.height) - 1)) + )] + .render(); + } - GL11.glTranslated(getX(valveData.location.xCoord), getY(valveData.location.yCoord), getZ(valveData.location.zCoord)); + MekanismRenderer.glowOff(); + MekanismRenderer.resetColor(); - MekanismRenderer.glowOn(tileEntity.structure.waterStored.getFluid().getLuminosity()); + pop(); - getValveDisplay(ValveRenderData.get(data, valveData), tileEntity.structure.waterStored.getFluid(), tileEntity.getWorldObj()).render(); + for (ValveData valveData : tileEntity.valveViewing) { + push(); - MekanismRenderer.glowOff(); - MekanismRenderer.resetColor(); + GL11.glTranslated( + getX(valveData.location.xCoord), + getY(valveData.location.yCoord), + getZ(valveData.location.zCoord) + ); - pop(); - } - } - } - - if(tileEntity.structure.steamStored != null && tileEntity.structure.steamStored.amount != 0) - { - RenderData data = new RenderData(); + MekanismRenderer.glowOn( + tileEntity.structure.waterStored.getFluid().getLuminosity() + ); - data.location = tileEntity.structure.upperRenderLocation; - data.height = (tileEntity.structure.renderLocation.yCoord+tileEntity.structure.volHeight-2)-(tileEntity.structure.upperRenderLocation.yCoord); - data.length = tileEntity.structure.volLength; - data.width = tileEntity.structure.volWidth; + getValveDisplay( + ValveRenderData.get(data, valveData), + tileEntity.structure.waterStored.getFluid(), + tileEntity.getWorldObj() + ) + .render(); - bindTexture(MekanismRenderer.getBlocksTexture()); - - if(data.location != null && data.height >= 1 && tileEntity.structure.steamStored.getFluid() != null) - { - push(); - - GL11.glTranslated(getX(data.location.xCoord), getY(data.location.yCoord), getZ(data.location.zCoord)); - - MekanismRenderer.glowOn(tileEntity.structure.steamStored.getFluid().getLuminosity()); - MekanismRenderer.colorFluid(tileEntity.structure.steamStored.getFluid()); - - DisplayInteger display = getUpperDisplay(data, tileEntity.structure.steamStored.getFluid(), tileEntity.getWorldObj()); - - GL11.glColor4f(1F, 1F, 1F, Math.min(1, ((float)tileEntity.structure.steamStored.amount / (float)tileEntity.clientSteamCapacity)+MekanismRenderer.GAS_RENDER_BASE)); - display.render(); - - MekanismRenderer.glowOff(); - MekanismRenderer.resetColor(); - - pop(); - } - } - } - } - - private void pop() - { - GL11.glPopAttrib(); - GL11.glPopMatrix(); - } + MekanismRenderer.glowOff(); + MekanismRenderer.resetColor(); - private void push() - { - GL11.glPushMatrix(); - GL11.glPushAttrib(GL11.GL_ENABLE_BIT); - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glEnable(GL11.GL_BLEND); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - } - - private DisplayInteger[] getLowerDisplay(RenderData data, Fluid fluid, World world) - { - if(cachedLowerFluids.containsKey(data)) - { - return cachedLowerFluids.get(data); - } + pop(); + } + } + } - Model3D toReturn = new Model3D(); - toReturn.baseBlock = Blocks.water; - toReturn.setTexture(fluid.getIcon()); + if (tileEntity.structure.steamStored != null + && tileEntity.structure.steamStored.amount != 0) { + RenderData data = new RenderData(); - final int stages = getStages(data.height); - DisplayInteger[] displays = new DisplayInteger[stages]; + data.location = tileEntity.structure.upperRenderLocation; + data.height = (tileEntity.structure.renderLocation.yCoord + + tileEntity.structure.volHeight - 2) + - (tileEntity.structure.upperRenderLocation.yCoord); + data.length = tileEntity.structure.volLength; + data.width = tileEntity.structure.volWidth; - cachedLowerFluids.put(data, displays); + bindTexture(MekanismRenderer.getBlocksTexture()); - for(int i = 0; i < stages; i++) - { - displays[i] = DisplayInteger.createAndStart(); + if (data.location != null && data.height >= 1 + && tileEntity.structure.steamStored.getFluid() != null) { + push(); - if(fluid.getIcon() != null) - { - toReturn.minX = 0 + .01; - toReturn.minY = 0 + .01; - toReturn.minZ = 0 + .01; + GL11.glTranslated( + getX(data.location.xCoord), + getY(data.location.yCoord), + getZ(data.location.zCoord) + ); - toReturn.maxX = data.length - .01; - toReturn.maxY = ((float)i/(float)stages)*data.height - .01; - toReturn.maxZ = data.width - .01; + MekanismRenderer.glowOn( + tileEntity.structure.steamStored.getFluid().getLuminosity() + ); + MekanismRenderer.colorFluid(tileEntity.structure.steamStored.getFluid( + )); - MekanismRenderer.renderObject(toReturn); - } + DisplayInteger display = getUpperDisplay( + data, + tileEntity.structure.steamStored.getFluid(), + tileEntity.getWorldObj() + ); - GL11.glEndList(); - } + GL11.glColor4f( + 1F, + 1F, + 1F, + Math.min( + 1, + ((float) tileEntity.structure.steamStored.amount + / (float) tileEntity.clientSteamCapacity) + + MekanismRenderer.GAS_RENDER_BASE + ) + ); + display.render(); - return displays; - } - - private DisplayInteger getUpperDisplay(RenderData data, Fluid fluid, World world) - { - if(cachedUpperFluids.containsKey(data)) - { - return cachedUpperFluids.get(data); - } + MekanismRenderer.glowOff(); + MekanismRenderer.resetColor(); - Model3D toReturn = new Model3D(); - toReturn.baseBlock = Blocks.water; - toReturn.setTexture(fluid.getIcon()); + pop(); + } + } + } + } - final int stages = getStages(data.height); - DisplayInteger display = DisplayInteger.createAndStart(); + private void pop() { + GL11.glPopAttrib(); + GL11.glPopMatrix(); + } - cachedUpperFluids.put(data, display); - - if(STEAM.getIcon() != null) - { - toReturn.minX = 0 + .01; - toReturn.minY = 0 + .01; - toReturn.minZ = 0 + .01; + private void push() { + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_ENABLE_BIT); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + } - toReturn.maxX = data.length - .01; - toReturn.maxY = data.height - .01; - toReturn.maxZ = data.width - .01; + private DisplayInteger[] getLowerDisplay(RenderData data, Fluid fluid, World world) { + if (cachedLowerFluids.containsKey(data)) { + return cachedLowerFluids.get(data); + } - MekanismRenderer.renderObject(toReturn); - } + Model3D toReturn = new Model3D(); + toReturn.baseBlock = Blocks.water; + toReturn.setTexture(fluid.getIcon()); - GL11.glEndList(); + final int stages = getStages(data.height); + DisplayInteger[] displays = new DisplayInteger[stages]; - return display; - } + cachedLowerFluids.put(data, displays); - private DisplayInteger getValveDisplay(ValveRenderData data, Fluid fluid, World world) - { - if(cachedValveFluids.containsKey(data)) - { - return cachedValveFluids.get(data); - } + for (int i = 0; i < stages; i++) { + displays[i] = DisplayInteger.createAndStart(); - Model3D toReturn = new Model3D(); - toReturn.baseBlock = Blocks.water; - toReturn.setTexture(fluid.getFlowingIcon()); + if (fluid.getIcon() != null) { + toReturn.minX = 0 + .01; + toReturn.minY = 0 + .01; + toReturn.minZ = 0 + .01; - DisplayInteger display = DisplayInteger.createAndStart(); + toReturn.maxX = data.length - .01; + toReturn.maxY = ((float) i / (float) stages) * data.height - .01; + toReturn.maxZ = data.width - .01; - cachedValveFluids.put(data, display); + MekanismRenderer.renderObject(toReturn); + } - switch(data.side) - { - case DOWN: - { - toReturn.minX = .3; - toReturn.minY = 1 + .01; - toReturn.minZ = .3; + GL11.glEndList(); + } - toReturn.maxX = .7; - toReturn.maxY = 1.4 + .1; - toReturn.maxZ = .7; - break; - } - case UP: - { - toReturn.minX = .3; - toReturn.minY = -(data.height-2) - .01; - toReturn.minZ = .3; + return displays; + } - toReturn.maxX = .7; - toReturn.maxY = -.01; - toReturn.maxZ = .7; - break; - } - case NORTH: - { - toReturn.minX = .3; - toReturn.minY = -(getValveFluidHeight(data)) + .01; - toReturn.minZ = 1 + .02; + private DisplayInteger getUpperDisplay(RenderData data, Fluid fluid, World world) { + if (cachedUpperFluids.containsKey(data)) { + return cachedUpperFluids.get(data); + } - toReturn.maxX = .7; - toReturn.maxY = .7; - toReturn.maxZ = 1.4; - break; - } - case SOUTH: - { - toReturn.minX = .3; - toReturn.minY = -(getValveFluidHeight(data)) + .01; - toReturn.minZ = -.4; + Model3D toReturn = new Model3D(); + toReturn.baseBlock = Blocks.water; + toReturn.setTexture(fluid.getIcon()); - toReturn.maxX = .7; - toReturn.maxY = .7; - toReturn.maxZ = -.02; - break; - } - case WEST: - { - toReturn.minX = 1 + .02; - toReturn.minY = -(getValveFluidHeight(data)) + .01; - toReturn.minZ = .3; + final int stages = getStages(data.height); + DisplayInteger display = DisplayInteger.createAndStart(); - toReturn.maxX = 1.4; - toReturn.maxY = .7; - toReturn.maxZ = .7; - break; - } - case EAST: - { - toReturn.minX = -.4; - toReturn.minY = -(getValveFluidHeight(data)) + .01; - toReturn.minZ = .3; + cachedUpperFluids.put(data, display); - toReturn.maxX = -.02; - toReturn.maxY = .7; - toReturn.maxZ = .7; - break; - } - default: - { - break; - } - } + if (STEAM.getIcon() != null) { + toReturn.minX = 0 + .01; + toReturn.minY = 0 + .01; + toReturn.minZ = 0 + .01; - if(fluid.getFlowingIcon() != null) - { - MekanismRenderer.renderObject(toReturn); - } - - display.endList(); + toReturn.maxX = data.length - .01; + toReturn.maxY = data.height - .01; + toReturn.maxZ = data.width - .01; - return display; - } + MekanismRenderer.renderObject(toReturn); + } - private int getValveFluidHeight(ValveRenderData data) - { - return data.valveLocation.yCoord - data.location.yCoord; - } + GL11.glEndList(); - private int getStages(int height) - { - return height*(TankUpdateProtocol.FLUID_PER_TANK/10); - } + return display; + } - private double getX(int x) - { - return x - TileEntityRendererDispatcher.staticPlayerX; - } + private DisplayInteger + getValveDisplay(ValveRenderData data, Fluid fluid, World world) { + if (cachedValveFluids.containsKey(data)) { + return cachedValveFluids.get(data); + } - private double getY(int y) - { - return y - TileEntityRendererDispatcher.staticPlayerY; - } + Model3D toReturn = new Model3D(); + toReturn.baseBlock = Blocks.water; + toReturn.setTexture(fluid.getFlowingIcon()); - private double getZ(int z) - { - return z - TileEntityRendererDispatcher.staticPlayerZ; - } - - public static void resetDisplayInts() - { - cachedLowerFluids.clear(); - cachedUpperFluids.clear(); - cachedValveFluids.clear(); - } + DisplayInteger display = DisplayInteger.createAndStart(); + + cachedValveFluids.put(data, display); + + switch (data.side) { + case DOWN: { + toReturn.minX = .3; + toReturn.minY = 1 + .01; + toReturn.minZ = .3; + + toReturn.maxX = .7; + toReturn.maxY = 1.4 + .1; + toReturn.maxZ = .7; + break; + } + case UP: { + toReturn.minX = .3; + toReturn.minY = -(data.height - 2) - .01; + toReturn.minZ = .3; + + toReturn.maxX = .7; + toReturn.maxY = -.01; + toReturn.maxZ = .7; + break; + } + case NORTH: { + toReturn.minX = .3; + toReturn.minY = -(getValveFluidHeight(data)) + .01; + toReturn.minZ = 1 + .02; + + toReturn.maxX = .7; + toReturn.maxY = .7; + toReturn.maxZ = 1.4; + break; + } + case SOUTH: { + toReturn.minX = .3; + toReturn.minY = -(getValveFluidHeight(data)) + .01; + toReturn.minZ = -.4; + + toReturn.maxX = .7; + toReturn.maxY = .7; + toReturn.maxZ = -.02; + break; + } + case WEST: { + toReturn.minX = 1 + .02; + toReturn.minY = -(getValveFluidHeight(data)) + .01; + toReturn.minZ = .3; + + toReturn.maxX = 1.4; + toReturn.maxY = .7; + toReturn.maxZ = .7; + break; + } + case EAST: { + toReturn.minX = -.4; + toReturn.minY = -(getValveFluidHeight(data)) + .01; + toReturn.minZ = .3; + + toReturn.maxX = -.02; + toReturn.maxY = .7; + toReturn.maxZ = .7; + break; + } + default: { + break; + } + } + + if (fluid.getFlowingIcon() != null) { + MekanismRenderer.renderObject(toReturn); + } + + display.endList(); + + return display; + } + + private int getValveFluidHeight(ValveRenderData data) { + return data.valveLocation.yCoord - data.location.yCoord; + } + + private int getStages(int height) { + return height * (TankUpdateProtocol.FLUID_PER_TANK / 10); + } + + private double getX(int x) { + return x - TileEntityRendererDispatcher.staticPlayerX; + } + + private double getY(int y) { + return y - TileEntityRendererDispatcher.staticPlayerY; + } + + private double getZ(int z) { + return z - TileEntityRendererDispatcher.staticPlayerZ; + } + + public static void resetDisplayInts() { + cachedLowerFluids.clear(); + cachedUpperFluids.clear(); + cachedValveFluids.clear(); + } } diff --git a/src/main/java/mekanism/client/sound/FlamethrowerSound.java b/src/main/java/mekanism/client/sound/FlamethrowerSound.java index 982ba4394..e2cc488e6 100644 --- a/src/main/java/mekanism/client/sound/FlamethrowerSound.java +++ b/src/main/java/mekanism/client/sound/FlamethrowerSound.java @@ -1,64 +1,56 @@ package mekanism.client.sound; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.ClientTickHandler; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class FlamethrowerSound extends PlayerSound -{ - public boolean inUse; +public class FlamethrowerSound extends PlayerSound { + public boolean inUse; - public ResourceLocation onSound; - public ResourceLocation offSound; + public ResourceLocation onSound; + public ResourceLocation offSound; - public FlamethrowerSound(EntityPlayer player) - { - super(player, new ResourceLocation("mekanism", "item.flamethrower.idle")); - - onSound = new ResourceLocation("mekanism", "item.flamethrower.active"); - offSound = new ResourceLocation("mekanism", "item.flamethrower.idle"); - inUse = ClientTickHandler.isFlamethrowerOn(player); - sound = inUse ? onSound : offSound; - - setFadeIn(0); - setFadeOut(0); - } + public FlamethrowerSound(EntityPlayer player) { + super(player, new ResourceLocation("mekanism", "item.flamethrower.idle")); - @Override - public boolean isDonePlaying() - { - return donePlaying; - } + onSound = new ResourceLocation("mekanism", "item.flamethrower.active"); + offSound = new ResourceLocation("mekanism", "item.flamethrower.idle"); + inUse = ClientTickHandler.isFlamethrowerOn(player); + sound = inUse ? onSound : offSound; - @Override - public boolean shouldPlaySound() - { - return true; - } + setFadeIn(0); + setFadeOut(0); + } - @Override - public float getVolume() - { - return super.getVolume() * (inUse ? 2 : 1); - } + @Override + public boolean isDonePlaying() { + return donePlaying; + } - @Override - public void update() - { - if(!ClientTickHandler.hasFlamethrower(player)) - { - donePlaying = true; - return; - } - - if(inUse != ClientTickHandler.isFlamethrowerOn(player)) - { - inUse = ClientTickHandler.isFlamethrowerOn(player); - sound = inUse ? onSound : offSound; - donePlaying = true; - } - } + @Override + public boolean shouldPlaySound() { + return true; + } + + @Override + public float getVolume() { + return super.getVolume() * (inUse ? 2 : 1); + } + + @Override + public void update() { + if (!ClientTickHandler.hasFlamethrower(player)) { + donePlaying = true; + return; + } + + if (inUse != ClientTickHandler.isFlamethrowerOn(player)) { + inUse = ClientTickHandler.isFlamethrowerOn(player); + sound = inUse ? onSound : offSound; + donePlaying = true; + } + } } diff --git a/src/main/java/mekanism/client/sound/GasMaskSound.java b/src/main/java/mekanism/client/sound/GasMaskSound.java index b6e4d50cc..76edfe1ff 100644 --- a/src/main/java/mekanism/client/sound/GasMaskSound.java +++ b/src/main/java/mekanism/client/sound/GasMaskSound.java @@ -1,37 +1,33 @@ package mekanism.client.sound; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.ClientTickHandler; import mekanism.common.item.ItemGasMask; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GasMaskSound extends PlayerSound -{ - public GasMaskSound(EntityPlayer player) - { - super(player, new ResourceLocation("mekanism", "item.gasMask")); - - setFadeIn(10); - setFadeOut(5); - } +public class GasMaskSound extends PlayerSound { + public GasMaskSound(EntityPlayer player) { + super(player, new ResourceLocation("mekanism", "item.gasMask")); - @Override - public boolean isDonePlaying() - { - return donePlaying; - } + setFadeIn(10); + setFadeOut(5); + } - @Override - public boolean shouldPlaySound() - { - return hasGasMask(player) && ClientTickHandler.isGasMaskOn(player); - } + @Override + public boolean isDonePlaying() { + return donePlaying; + } - private boolean hasGasMask(EntityPlayer player) - { - return player.inventory.armorInventory[3] != null && player.inventory.armorInventory[3].getItem() instanceof ItemGasMask; - } + @Override + public boolean shouldPlaySound() { + return hasGasMask(player) && ClientTickHandler.isGasMaskOn(player); + } + + private boolean hasGasMask(EntityPlayer player) { + return player.inventory.armorInventory[3] != null + && player.inventory.armorInventory[3].getItem() instanceof ItemGasMask; + } } diff --git a/src/main/java/mekanism/client/sound/IResettableSound.java b/src/main/java/mekanism/client/sound/IResettableSound.java index 77acdb93d..4e25b085f 100644 --- a/src/main/java/mekanism/client/sound/IResettableSound.java +++ b/src/main/java/mekanism/client/sound/IResettableSound.java @@ -1,11 +1,10 @@ package mekanism.client.sound; -import net.minecraft.client.audio.ITickableSound; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.audio.ITickableSound; @SideOnly(Side.CLIENT) -public interface IResettableSound extends ITickableSound -{ - public void reset(); +public interface IResettableSound extends ITickableSound { + public void reset(); } diff --git a/src/main/java/mekanism/client/sound/ISoundSource.java b/src/main/java/mekanism/client/sound/ISoundSource.java index 894ef8aa5..5a6d4913f 100644 --- a/src/main/java/mekanism/client/sound/ISoundSource.java +++ b/src/main/java/mekanism/client/sound/ISoundSource.java @@ -1,31 +1,30 @@ package mekanism.client.sound; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Pos3D; import net.minecraft.client.audio.ISound.AttenuationType; import net.minecraft.util.ResourceLocation; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public interface ISoundSource -{ - @SideOnly(Side.CLIENT) - public ResourceLocation getSoundLocation(); +public interface ISoundSource { + @SideOnly(Side.CLIENT) + public ResourceLocation getSoundLocation(); - @SideOnly(Side.CLIENT) - public float getVolume(); + @SideOnly(Side.CLIENT) + public float getVolume(); - @SideOnly(Side.CLIENT) - public float getPitch(); + @SideOnly(Side.CLIENT) + public float getPitch(); - @SideOnly(Side.CLIENT) - public Pos3D getSoundPosition(); + @SideOnly(Side.CLIENT) + public Pos3D getSoundPosition(); - @SideOnly(Side.CLIENT) - public boolean shouldRepeat(); + @SideOnly(Side.CLIENT) + public boolean shouldRepeat(); - @SideOnly(Side.CLIENT) - public int getRepeatDelay(); + @SideOnly(Side.CLIENT) + public int getRepeatDelay(); - @SideOnly(Side.CLIENT) - public AttenuationType getAttenuation(); + @SideOnly(Side.CLIENT) + public AttenuationType getAttenuation(); } diff --git a/src/main/java/mekanism/client/sound/JetpackSound.java b/src/main/java/mekanism/client/sound/JetpackSound.java index dac03f285..1b3c13047 100644 --- a/src/main/java/mekanism/client/sound/JetpackSound.java +++ b/src/main/java/mekanism/client/sound/JetpackSound.java @@ -1,37 +1,33 @@ package mekanism.client.sound; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.ClientTickHandler; import mekanism.common.item.ItemJetpack; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class JetpackSound extends PlayerSound -{ - public JetpackSound(EntityPlayer player) - { - super(player, new ResourceLocation("mekanism", "item.jetpack")); - - setFadeIn(10); - setFadeOut(5); - } +public class JetpackSound extends PlayerSound { + public JetpackSound(EntityPlayer player) { + super(player, new ResourceLocation("mekanism", "item.jetpack")); - @Override - public boolean isDonePlaying() - { - return donePlaying; - } + setFadeIn(10); + setFadeOut(5); + } - @Override - public boolean shouldPlaySound() - { - return hasJetpack(player) && ClientTickHandler.isJetpackOn(player); - } + @Override + public boolean isDonePlaying() { + return donePlaying; + } - private boolean hasJetpack(EntityPlayer player) - { - return player.inventory.armorInventory[2] != null && player.inventory.armorInventory[2].getItem() instanceof ItemJetpack; - } + @Override + public boolean shouldPlaySound() { + return hasJetpack(player) && ClientTickHandler.isJetpackOn(player); + } + + private boolean hasJetpack(EntityPlayer player) { + return player.inventory.armorInventory[2] != null + && player.inventory.armorInventory[2].getItem() instanceof ItemJetpack; + } } diff --git a/src/main/java/mekanism/client/sound/PlayerSound.java b/src/main/java/mekanism/client/sound/PlayerSound.java index e2253aea3..9447d7a25 100644 --- a/src/main/java/mekanism/client/sound/PlayerSound.java +++ b/src/main/java/mekanism/client/sound/PlayerSound.java @@ -1,116 +1,109 @@ package mekanism.client.sound; -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.ResourceLocation; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.ResourceLocation; @SideOnly(Side.CLIENT) -public abstract class PlayerSound extends Sound implements IResettableSound -{ - public EntityPlayer player; +public abstract class PlayerSound extends Sound implements IResettableSound { + public EntityPlayer player; - boolean beginFadeOut; - - boolean donePlaying = true; - - int ticks = 0; - - int fadeIn; - - int fadeOut; - - float baseVolume = 0.3F; + boolean beginFadeOut; - public PlayerSound(EntityPlayer p, ResourceLocation location) - { - super(location, 0.3F, 1, true, 0, (float)p.posX, (float)p.posY, (float)p.posZ, AttenuationType.LINEAR); - player = p; - } + boolean donePlaying = true; - @Override - public float getXPosF() - { - return (float)player.posX; - } + int ticks = 0; - @Override - public float getYPosF() - { - return (float)player.posY; - } + int fadeIn; - @Override - public float getZPosF() - { - return (float)player.posZ; - } + int fadeOut; - public PlayerSound setFadeIn(int fade) - { - fadeIn = Math.max(0, fade); - return this; - } + float baseVolume = 0.3F; - public PlayerSound setFadeOut(int fade) - { - fadeOut = Math.max(0, fade); - return this; - } + public PlayerSound(EntityPlayer p, ResourceLocation location) { + super( + location, + 0.3F, + 1, + true, + 0, + (float) p.posX, + (float) p.posY, + (float) p.posZ, + AttenuationType.LINEAR + ); + player = p; + } - public float getFadeInMultiplier() - { - return ticks >= fadeIn ? 1 : (ticks / (float)fadeIn); - } + @Override + public float getXPosF() { + return (float) player.posX; + } - public float getFadeOutMultiplier() - { - return ticks >= fadeOut ? 0 : ((fadeOut - ticks) / (float)fadeOut); - } + @Override + public float getYPosF() { + return (float) player.posY; + } - @Override - public void update() - { - if(!beginFadeOut) - { - if(ticks < fadeIn) - { - ticks++; - } - - if(!shouldPlaySound()) - { - beginFadeOut = true; - ticks = 0; - } - } - else { - ticks++; - } - - float multiplier = beginFadeOut ? getFadeOutMultiplier() : getFadeInMultiplier(); - volume = baseVolume * multiplier; + @Override + public float getZPosF() { + return (float) player.posZ; + } - if(multiplier <= 0) - { - donePlaying = true; - } - } + public PlayerSound setFadeIn(int fade) { + fadeIn = Math.max(0, fade); + return this; + } - @Override - public boolean isDonePlaying() - { - return donePlaying; - } + public PlayerSound setFadeOut(int fade) { + fadeOut = Math.max(0, fade); + return this; + } - public abstract boolean shouldPlaySound(); + public float getFadeInMultiplier() { + return ticks >= fadeIn ? 1 : (ticks / (float) fadeIn); + } - @Override - public void reset() - { - donePlaying = false; - beginFadeOut = false; - volume = baseVolume; - ticks = 0; - } + public float getFadeOutMultiplier() { + return ticks >= fadeOut ? 0 : ((fadeOut - ticks) / (float) fadeOut); + } + + @Override + public void update() { + if (!beginFadeOut) { + if (ticks < fadeIn) { + ticks++; + } + + if (!shouldPlaySound()) { + beginFadeOut = true; + ticks = 0; + } + } else { + ticks++; + } + + float multiplier = beginFadeOut ? getFadeOutMultiplier() : getFadeInMultiplier(); + volume = baseVolume * multiplier; + + if (multiplier <= 0) { + donePlaying = true; + } + } + + @Override + public boolean isDonePlaying() { + return donePlaying; + } + + public abstract boolean shouldPlaySound(); + + @Override + public void reset() { + donePlaying = false; + beginFadeOut = false; + volume = baseVolume; + ticks = 0; + } } diff --git a/src/main/java/mekanism/client/sound/Sound.java b/src/main/java/mekanism/client/sound/Sound.java index bfad38fa7..af82906d4 100644 --- a/src/main/java/mekanism/client/sound/Sound.java +++ b/src/main/java/mekanism/client/sound/Sound.java @@ -1,10 +1,10 @@ package mekanism.client.sound; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.MekanismConfig.client; import net.minecraft.client.audio.ISound; import net.minecraft.util.ResourceLocation; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; /** * Generic ISound class with lots of constructor functionality. @@ -17,168 +17,197 @@ import cpw.mods.fml.relauncher.SideOnly; * */ @SideOnly(Side.CLIENT) -public class Sound implements ISound -{ - protected AttenuationType attenuation; - - protected ResourceLocation sound; - - protected float volume; - - protected float pitch; - - protected float x; - - protected float y; - - protected float z; - - protected boolean repeat; - - protected int repeatDelay; +public class Sound implements ISound { + protected AttenuationType attenuation; - public Sound(String sound) - { - this(sound, 0); - } + protected ResourceLocation sound; - public Sound(String sound, float volume) - { - this(sound, volume, 0); - } + protected float volume; - public Sound(String sound, float volume, float pitch) - { - this(sound, volume, pitch, false, 0); - } + protected float pitch; - public Sound(String sound, float volume, float pitch, boolean repeat, int repeatDelay) - { - this(sound, volume, pitch, repeat, repeatDelay, 0, 0, 0, AttenuationType.NONE); - } + protected float x; - public Sound(String sound, float volume, float pitch, double x, double y, double z) - { - this(sound, volume, pitch, false, 0, x, y, z); - } + protected float y; - public Sound(String sound, float volume, float pitch, boolean repeat, int repeatDelay, double x, double y, double z) - { - this(sound, volume, pitch, repeat, repeatDelay, x, y, z, AttenuationType.LINEAR); - } + protected float z; - public Sound(String sound, float volume, float pitch, boolean repeat, int repeatDelay, double x, double y, double z, AttenuationType attenuation) - { - this(new ResourceLocation(sound), volume, pitch, repeat, repeatDelay, x, y, z, attenuation); - } + protected boolean repeat; - public Sound(ResourceLocation sound) - { - this(sound, 0); - } + protected int repeatDelay; - public Sound(ResourceLocation sound, float volume) - { - this(sound, volume, 0); - } + public Sound(String sound) { + this(sound, 0); + } - public Sound(ResourceLocation sound, float volume, float pitch) - { - this(sound, volume, pitch, false, 0); - } + public Sound(String sound, float volume) { + this(sound, volume, 0); + } - public Sound(ResourceLocation sound, float volume, float pitch, boolean repeat, int repeatDelay) - { - this(sound, volume, pitch, repeat, repeatDelay, 0, 0, 0, AttenuationType.NONE); - } + public Sound(String sound, float volume, float pitch) { + this(sound, volume, pitch, false, 0); + } - public Sound(ResourceLocation sound, float volume, float pitch, double x, double y, double z) - { - this(sound, volume, pitch, false, 0, x, y, z); - } + public Sound( + String sound, float volume, float pitch, boolean repeat, int repeatDelay + ) { + this(sound, volume, pitch, repeat, repeatDelay, 0, 0, 0, AttenuationType.NONE); + } - public Sound(ResourceLocation sound, float volume, float pitch, boolean repeat, int repeatDelay, double x, double y, double z) - { - this(sound, volume, pitch, repeat, repeatDelay, x, y, z, AttenuationType.LINEAR); - } + public Sound(String sound, float volume, float pitch, double x, double y, double z) { + this(sound, volume, pitch, false, 0, x, y, z); + } - public Sound(ResourceLocation resource, float v, float p, boolean rep, int delay, double xPos, double yPos, double zPos, AttenuationType att) - { - attenuation = att; - sound = resource; - volume = v; - pitch = p; - x = (float)xPos; - y = (float)yPos; - z = (float)zPos; - repeat = rep; - repeatDelay = delay; - } + public Sound( + String sound, + float volume, + float pitch, + boolean repeat, + int repeatDelay, + double x, + double y, + double z + ) { + this(sound, volume, pitch, repeat, repeatDelay, x, y, z, AttenuationType.LINEAR); + } - public Sound(Sound other) - { - attenuation = other.attenuation; - sound = other.sound; - volume = other.volume; - pitch = other.pitch; - x = other.x; - y = other.y; - z = other.z; - repeat = other.repeat; - repeatDelay = other.repeatDelay; - } + public Sound( + String sound, + float volume, + float pitch, + boolean repeat, + int repeatDelay, + double x, + double y, + double z, + AttenuationType attenuation + ) { + this( + new ResourceLocation(sound), + volume, + pitch, + repeat, + repeatDelay, + x, + y, + z, + attenuation + ); + } - @Override - public AttenuationType getAttenuationType() - { - return attenuation; - } + public Sound(ResourceLocation sound) { + this(sound, 0); + } - @Override - public ResourceLocation getPositionedSoundLocation() - { - return sound; - } + public Sound(ResourceLocation sound, float volume) { + this(sound, volume, 0); + } - @Override - public float getVolume() - { - return volume * client.baseSoundVolume; - } + public Sound(ResourceLocation sound, float volume, float pitch) { + this(sound, volume, pitch, false, 0); + } - @Override - public float getPitch() - { - return pitch; - } + public Sound( + ResourceLocation sound, float volume, float pitch, boolean repeat, int repeatDelay + ) { + this(sound, volume, pitch, repeat, repeatDelay, 0, 0, 0, AttenuationType.NONE); + } - @Override - public float getXPosF() - { - return x; - } + public Sound( + ResourceLocation sound, float volume, float pitch, double x, double y, double z + ) { + this(sound, volume, pitch, false, 0, x, y, z); + } - @Override - public float getYPosF() - { - return y; - } + public Sound( + ResourceLocation sound, + float volume, + float pitch, + boolean repeat, + int repeatDelay, + double x, + double y, + double z + ) { + this(sound, volume, pitch, repeat, repeatDelay, x, y, z, AttenuationType.LINEAR); + } - @Override - public float getZPosF() - { - return z; - } + public Sound( + ResourceLocation resource, + float v, + float p, + boolean rep, + int delay, + double xPos, + double yPos, + double zPos, + AttenuationType att + ) { + attenuation = att; + sound = resource; + volume = v; + pitch = p; + x = (float) xPos; + y = (float) yPos; + z = (float) zPos; + repeat = rep; + repeatDelay = delay; + } - @Override - public boolean canRepeat() - { - return repeat; - } + public Sound(Sound other) { + attenuation = other.attenuation; + sound = other.sound; + volume = other.volume; + pitch = other.pitch; + x = other.x; + y = other.y; + z = other.z; + repeat = other.repeat; + repeatDelay = other.repeatDelay; + } - @Override - public int getRepeatDelay() - { - return repeatDelay; - } + @Override + public AttenuationType getAttenuationType() { + return attenuation; + } + + @Override + public ResourceLocation getPositionedSoundLocation() { + return sound; + } + + @Override + public float getVolume() { + return volume * client.baseSoundVolume; + } + + @Override + public float getPitch() { + return pitch; + } + + @Override + public float getXPosF() { + return x; + } + + @Override + public float getYPosF() { + return y; + } + + @Override + public float getZPosF() { + return z; + } + + @Override + public boolean canRepeat() { + return repeat; + } + + @Override + public int getRepeatDelay() { + return repeatDelay; + } } diff --git a/src/main/java/mekanism/client/sound/SoundHandler.java b/src/main/java/mekanism/client/sound/SoundHandler.java index 1f00b8c8c..3d23ddeba 100644 --- a/src/main/java/mekanism/client/sound/SoundHandler.java +++ b/src/main/java/mekanism/client/sound/SoundHandler.java @@ -3,6 +3,8 @@ package mekanism.client.sound; import java.util.HashMap; import java.util.Map; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.common.ObfuscatedNames; import mekanism.common.util.MekanismUtils; import net.minecraft.client.Minecraft; @@ -12,8 +14,6 @@ import net.minecraft.client.audio.PositionedSoundRecord; import net.minecraft.client.audio.SoundManager; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; /** * SoundHandler - a class that handles all Sounds used by Mekanism. @@ -22,135 +22,127 @@ import cpw.mods.fml.relauncher.SideOnly; * */ @SideOnly(Side.CLIENT) -public class SoundHandler -{ - public static Map> soundMaps = new HashMap>(); +public class SoundHandler { + public static Map> soundMaps + = new HashMap>(); - public static Map invPlayingSounds; + public static Map invPlayingSounds; - public static Minecraft mc = Minecraft.getMinecraft(); + public static Minecraft mc = Minecraft.getMinecraft(); - public static enum Channel - { - JETPACK("jetpack", JetpackSound.class), - GASMASK("gasMask", GasMaskSound.class), - FLAMETHROWER("flamethrower", FlamethrowerSound.class); + public static enum Channel { + JETPACK("jetpack", JetpackSound.class), + GASMASK("gasMask", GasMaskSound.class), + FLAMETHROWER("flamethrower", FlamethrowerSound.class); - String channelName; - Class soundClass; + String channelName; + Class soundClass; - private Channel(String name, Class clazz) - { - channelName = name; - soundClass = clazz; - } + private Channel(String name, Class clazz) { + channelName = name; + soundClass = clazz; + } - public String getName() - { - return channelName; - } + public String getName() { + return channelName; + } - public PlayerSound getNewSound(EntityPlayer player) - { - try { - return soundClass.getDeclaredConstructor(EntityPlayer.class).newInstance(player); - } catch(Exception e) { - return null; - } - } - } + public PlayerSound getNewSound(EntityPlayer player) { + try { + return soundClass.getDeclaredConstructor(EntityPlayer.class) + .newInstance(player); + } catch (Exception e) { + return null; + } + } + } - public static boolean soundPlaying(EntityPlayer player, Channel channel) - { - String name = player.getCommandSenderName(); - Map map = getMap(name); - IResettableSound sound = map.get(channel.getName()); + public static boolean soundPlaying(EntityPlayer player, Channel channel) { + String name = player.getCommandSenderName(); + Map map = getMap(name); + IResettableSound sound = map.get(channel.getName()); - return !(sound == null || sound.isDonePlaying()); - } + return !(sound == null || sound.isDonePlaying()); + } - public static void addSound(EntityPlayer player, Channel channel, boolean replace) - { - String name = player.getCommandSenderName(); - Map map = getMap(name); - IResettableSound sound = map.get(channel.getName()); - - if(sound == null || replace) - { - PlayerSound newSound = channel.getNewSound(player); - map.put(channel.getName(), newSound); - } - } + public static void addSound(EntityPlayer player, Channel channel, boolean replace) { + String name = player.getCommandSenderName(); + Map map = getMap(name); + IResettableSound sound = map.get(channel.getName()); - public static boolean playSound(EntityPlayer player, Channel channel) - { - String name = player.getCommandSenderName(); - Map map = getMap(name); - IResettableSound sound = map.get(channel.getName()); - - if(sound != null) - { - if(canRestartSound(sound)) - { - sound.reset(); - playSound(sound); - } - - return true; - } - - return false; - } + if (sound == null || replace) { + PlayerSound newSound = channel.getNewSound(player); + map.put(channel.getName(), newSound); + } + } - public static Map getMap(String name) - { - Map map = soundMaps.get(name); - - if(map == null) - { - map = new HashMap(); - soundMaps.put(name, map); - } + public static boolean playSound(EntityPlayer player, Channel channel) { + String name = player.getCommandSenderName(); + Map map = getMap(name); + IResettableSound sound = map.get(channel.getName()); - return map; - } + if (sound != null) { + if (canRestartSound(sound)) { + sound.reset(); + playSound(sound); + } - public static SoundManager getSoundManager() - { - try { - return (SoundManager)MekanismUtils.getPrivateValue(mc.getSoundHandler(), net.minecraft.client.audio.SoundHandler.class, ObfuscatedNames.SoundHandler_sndManager); - } catch(Exception e) { - return null; - } - } + return true; + } - //Fudge required because sound thread gets behind and the biMap crashes when rapidly toggling sounds. - public static Map getSoundMap() - { - if(invPlayingSounds == null) - { - try { - invPlayingSounds = (Map)MekanismUtils.getPrivateValue(getSoundManager(), net.minecraft.client.audio.SoundManager.class, ObfuscatedNames.SoundManager_invPlayingSounds); - } catch(Exception e) { - invPlayingSounds = null; - } - } - - return invPlayingSounds; - } + return false; + } - public static boolean canRestartSound(ITickableSound sound) - { - return sound.isDonePlaying() && !getSoundMap().containsKey(sound); - } - - public static void playSound(String sound) - { + public static Map getMap(String name) { + Map map = soundMaps.get(name); + + if (map == null) { + map = new HashMap(); + soundMaps.put(name, map); + } + + return map; + } + + public static SoundManager getSoundManager() { + try { + return (SoundManager) MekanismUtils.getPrivateValue( + mc.getSoundHandler(), + net.minecraft.client.audio.SoundHandler.class, + ObfuscatedNames.SoundHandler_sndManager + ); + } catch (Exception e) { + return null; + } + } + + //Fudge required because sound thread gets behind and the biMap crashes when rapidly + //toggling sounds. + public static Map getSoundMap() { + if (invPlayingSounds == null) { + try { + invPlayingSounds = (Map) MekanismUtils.getPrivateValue( + getSoundManager(), + net.minecraft.client.audio.SoundManager.class, + ObfuscatedNames.SoundManager_invPlayingSounds + ); + } catch (Exception e) { + invPlayingSounds = null; + } + } + + return invPlayingSounds; + } + + public static boolean canRestartSound(ITickableSound sound) { + return sound.isDonePlaying() && !getSoundMap().containsKey(sound); + } + + public static void playSound(String sound) { playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation(sound), 1.0F)); - } + } - public static void playSound(ISound sound) - { - mc.getSoundHandler().playSound(sound); - } + public static void playSound(ISound sound) { + mc.getSoundHandler().playSound(sound); + } } diff --git a/src/main/java/mekanism/client/sound/TileSound.java b/src/main/java/mekanism/client/sound/TileSound.java index f1fa3a7e9..62ecb6547 100644 --- a/src/main/java/mekanism/client/sound/TileSound.java +++ b/src/main/java/mekanism/client/sound/TileSound.java @@ -1,130 +1,205 @@ package mekanism.client.sound; -import mekanism.common.base.IHasSound; -import net.minecraft.util.ResourceLocation; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import mekanism.common.base.IHasSound; +import net.minecraft.util.ResourceLocation; @SideOnly(Side.CLIENT) -public class TileSound extends Sound implements IResettableSound -{ - IHasSound source; - - boolean beginFadeOut; - - boolean donePlaying = true; - - int ticks = 0; - - int fadeIn = 30; - - int fadeOut = 10; - - float baseVolume = 1.0F; +public class TileSound extends Sound implements IResettableSound { + IHasSound source; - public TileSound(IHasSound source, ISoundSource values) - { - this(source, values.getSoundLocation(), values.getVolume(), values.getPitch(), values.shouldRepeat(), values.getRepeatDelay(), values.getSoundPosition().xPos, values.getSoundPosition().yPos, values.getSoundPosition().zPos); - } + boolean beginFadeOut; - public TileSound(IHasSound source, ISoundSource values, ResourceLocation location) - { - this(source, location, values.getVolume(), values.getPitch(), values.shouldRepeat(), values.getRepeatDelay(), values.getSoundPosition().xPos, values.getSoundPosition().yPos, values.getSoundPosition().zPos); - } + boolean donePlaying = true; - public TileSound(IHasSound source, String sound, float volume, float pitch, boolean repeat, int repeatDelay, double x, double y, double z) - { - this(source, sound, volume, pitch, repeat, repeatDelay, x, y, z, AttenuationType.LINEAR); - } + int ticks = 0; - public TileSound(IHasSound source, String sound, float volume, float pitch, boolean repeat, int repeatDelay, double x, double y, double z, AttenuationType attenuation) - { - this(source, new ResourceLocation(sound), volume, pitch, repeat, repeatDelay, x, y, z, attenuation); - } + int fadeIn = 30; - public TileSound(IHasSound source, ResourceLocation sound, float volume, float pitch, boolean repeat, int repeatDelay, double x, double y, double z) - { - this(source, sound, volume, pitch, repeat, repeatDelay, x, y, z, AttenuationType.LINEAR); - } + int fadeOut = 10; - public TileSound(IHasSound soundSource, ResourceLocation resource, float volume, float pitch, boolean repeat, int repeatDelay, double x, double y, double z, AttenuationType attenuation) - { - super(resource, volume, pitch, repeat, repeatDelay, x, y, z, attenuation); + float baseVolume = 1.0F; - source = soundSource; - sound = resource; - baseVolume = volume; - } + public TileSound(IHasSound source, ISoundSource values) { + this( + source, + values.getSoundLocation(), + values.getVolume(), + values.getPitch(), + values.shouldRepeat(), + values.getRepeatDelay(), + values.getSoundPosition().xPos, + values.getSoundPosition().yPos, + values.getSoundPosition().zPos + ); + } - public TileSound setFadeIn(int fade) - { - fadeIn = Math.min(0, fade); - return this; - } + public TileSound(IHasSound source, ISoundSource values, ResourceLocation location) { + this( + source, + location, + values.getVolume(), + values.getPitch(), + values.shouldRepeat(), + values.getRepeatDelay(), + values.getSoundPosition().xPos, + values.getSoundPosition().yPos, + values.getSoundPosition().zPos + ); + } - public TileSound setFadeOut(int fade) - { - fadeOut = Math.min(0, fade); - return this; - } + public TileSound( + IHasSound source, + String sound, + float volume, + float pitch, + boolean repeat, + int repeatDelay, + double x, + double y, + double z + ) { + this( + source, + sound, + volume, + pitch, + repeat, + repeatDelay, + x, + y, + z, + AttenuationType.LINEAR + ); + } - public float getFadeInMultiplier() - { - return ticks >= fadeIn ? 1 : (float)(ticks / (float)fadeIn); - } + public TileSound( + IHasSound source, + String sound, + float volume, + float pitch, + boolean repeat, + int repeatDelay, + double x, + double y, + double z, + AttenuationType attenuation + ) { + this( + source, + new ResourceLocation(sound), + volume, + pitch, + repeat, + repeatDelay, + x, + y, + z, + attenuation + ); + } - public float getFadeOutMultiplier() - { - return ticks >= fadeOut ? 0 : (float)((fadeOut - ticks) / (float)fadeOut); - } + public TileSound( + IHasSound source, + ResourceLocation sound, + float volume, + float pitch, + boolean repeat, + int repeatDelay, + double x, + double y, + double z + ) { + this( + source, + sound, + volume, + pitch, + repeat, + repeatDelay, + x, + y, + z, + AttenuationType.LINEAR + ); + } - /* ITickableSound */ - @Override - public void update() - { - if(source instanceof ISoundSource) - { - baseVolume = ((ISoundSource)source).getVolume(); - } - - if(!beginFadeOut) - { - if(ticks < fadeIn) - { - ticks++; - } - - if(!(source.shouldPlaySound() && source.getSound().sound == this)) - { - beginFadeOut = true; - ticks = 0; - } - } - else { - ticks++; - } - - float multiplier = beginFadeOut ? getFadeOutMultiplier() : getFadeInMultiplier(); - volume = baseVolume * multiplier; + public TileSound( + IHasSound soundSource, + ResourceLocation resource, + float volume, + float pitch, + boolean repeat, + int repeatDelay, + double x, + double y, + double z, + AttenuationType attenuation + ) { + super(resource, volume, pitch, repeat, repeatDelay, x, y, z, attenuation); - if(multiplier <= 0) - { - donePlaying = true; - } - } + source = soundSource; + sound = resource; + baseVolume = volume; + } - @Override - public boolean isDonePlaying() - { - return donePlaying; - } + public TileSound setFadeIn(int fade) { + fadeIn = Math.min(0, fade); + return this; + } - @Override - public void reset() - { - donePlaying = false; - beginFadeOut = false; - volume = baseVolume; - ticks = 0; - } + public TileSound setFadeOut(int fade) { + fadeOut = Math.min(0, fade); + return this; + } + + public float getFadeInMultiplier() { + return ticks >= fadeIn ? 1 : (float) (ticks / (float) fadeIn); + } + + public float getFadeOutMultiplier() { + return ticks >= fadeOut ? 0 : (float) ((fadeOut - ticks) / (float) fadeOut); + } + + /* ITickableSound */ + @Override + public void update() { + if (source instanceof ISoundSource) { + baseVolume = ((ISoundSource) source).getVolume(); + } + + if (!beginFadeOut) { + if (ticks < fadeIn) { + ticks++; + } + + if (!(source.shouldPlaySound() && source.getSound().sound == this)) { + beginFadeOut = true; + ticks = 0; + } + } else { + ticks++; + } + + float multiplier = beginFadeOut ? getFadeOutMultiplier() : getFadeInMultiplier(); + volume = baseVolume * multiplier; + + if (multiplier <= 0) { + donePlaying = true; + } + } + + @Override + public boolean isDonePlaying() { + return donePlaying; + } + + @Override + public void reset() { + donePlaying = false; + beginFadeOut = false; + volume = baseVolume; + ticks = 0; + } } diff --git a/src/main/java/mekanism/client/voice/VoiceClient.java b/src/main/java/mekanism/client/voice/VoiceClient.java index 1adbb3872..a0a956e59 100644 --- a/src/main/java/mekanism/client/voice/VoiceClient.java +++ b/src/main/java/mekanism/client/voice/VoiceClient.java @@ -6,100 +6,96 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.net.ConnectException; import java.net.Socket; - import javax.sound.sampled.AudioFormat; -import mekanism.api.MekanismConfig.general; -import mekanism.common.Mekanism; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import mekanism.api.MekanismConfig.general; +import mekanism.common.Mekanism; @SideOnly(Side.CLIENT) -public class VoiceClient extends Thread -{ - public Socket socket; +public class VoiceClient extends Thread { + public Socket socket; - public String ip; + public String ip; - public AudioFormat format = new AudioFormat(16000F, 16, 1, true, true); + public AudioFormat format = new AudioFormat(16000F, 16, 1, true, true); - public VoiceInput inputThread; - public VoiceOutput outputThread; + public VoiceInput inputThread; + public VoiceOutput outputThread; - public DataInputStream input; - public DataOutputStream output; + public DataInputStream input; + public DataOutputStream output; - public boolean running; + public boolean running; - public VoiceClient(String s) - { - ip = s; - } + public VoiceClient(String s) { + ip = s; + } - @Override - public void run() - { - Mekanism.logger.info("VoiceServer: Starting client connection..."); + @Override + public void run() { + Mekanism.logger.info("VoiceServer: Starting client connection..."); - try { - socket = new Socket(ip, general.VOICE_PORT); - running = true; + try { + socket = new Socket(ip, general.VOICE_PORT); + running = true; - input = new DataInputStream(new BufferedInputStream(socket.getInputStream())); - output = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream())); + input = new DataInputStream(new BufferedInputStream(socket.getInputStream())); + output + = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream()) + ); - (outputThread = new VoiceOutput(this)).start(); - (inputThread = new VoiceInput(this)).start(); + (outputThread = new VoiceOutput(this)).start(); + (inputThread = new VoiceInput(this)).start(); - Mekanism.logger.info("VoiceServer: Successfully connected to server."); - } catch(ConnectException e) { - Mekanism.logger.error("VoiceServer: Server's VoiceServer is disabled."); - } catch(Exception e) { - Mekanism.logger.error("VoiceServer: Error while starting client connection."); - e.printStackTrace(); - } - } + Mekanism.logger.info("VoiceServer: Successfully connected to server."); + } catch (ConnectException e) { + Mekanism.logger.error("VoiceServer: Server's VoiceServer is disabled."); + } catch (Exception e) { + Mekanism.logger.error("VoiceServer: Error while starting client connection."); + e.printStackTrace(); + } + } - public void disconnect() - { - Mekanism.logger.info("VoiceServer: Stopping client connection..."); + public void disconnect() { + Mekanism.logger.info("VoiceServer: Stopping client connection..."); - try { - try { - inputThread.interrupt(); - outputThread.interrupt(); - } catch(Exception e) {} + try { + try { + inputThread.interrupt(); + outputThread.interrupt(); + } catch (Exception e) {} - try { - interrupt(); - } catch(Exception e) {} + try { + interrupt(); + } catch (Exception e) {} - try { - inputThread.close(); - outputThread.close(); - } catch(Exception e) {} + try { + inputThread.close(); + outputThread.close(); + } catch (Exception e) {} - try { - output.flush(); - output.close(); - output = null; - } catch(Exception e) {} + try { + output.flush(); + output.close(); + output = null; + } catch (Exception e) {} - try { - input.close(); - input = null; - } catch(Exception e) {} + try { + input.close(); + input = null; + } catch (Exception e) {} - try { - socket.close(); - socket = null; - } catch(Exception e) {} + try { + socket.close(); + socket = null; + } catch (Exception e) {} - - running = false; - } catch(Exception e) { - Mekanism.logger.error("VoiceServer: Error while stopping client connection."); - e.printStackTrace(); - } - } + running = false; + } catch (Exception e) { + Mekanism.logger.error("VoiceServer: Error while stopping client connection."); + e.printStackTrace(); + } + } } diff --git a/src/main/java/mekanism/client/voice/VoiceInput.java b/src/main/java/mekanism/client/voice/VoiceInput.java index c4c418cd2..32ee12b07 100644 --- a/src/main/java/mekanism/client/voice/VoiceInput.java +++ b/src/main/java/mekanism/client/voice/VoiceInput.java @@ -5,91 +5,85 @@ import javax.sound.sampled.AudioSystem; import javax.sound.sampled.DataLine; import javax.sound.sampled.TargetDataLine; -import mekanism.client.MekanismKeyHandler; -import mekanism.common.Mekanism; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import mekanism.client.MekanismKeyHandler; +import mekanism.common.Mekanism; @SideOnly(Side.CLIENT) -public class VoiceInput extends Thread -{ - public VoiceClient voiceClient; +public class VoiceInput extends Thread { + public VoiceClient voiceClient; - public DataLine.Info microphone; + public DataLine.Info microphone; - public TargetDataLine targetLine; + public TargetDataLine targetLine; - public VoiceInput(VoiceClient client) - { - voiceClient = client; - microphone = new DataLine.Info(TargetDataLine.class, voiceClient.format, 2200); + public VoiceInput(VoiceClient client) { + voiceClient = client; + microphone = new DataLine.Info(TargetDataLine.class, voiceClient.format, 2200); - setDaemon(true); - setName("VoiceServer Client Input Thread"); - } + setDaemon(true); + setName("VoiceServer Client Input Thread"); + } - @Override - public void run() - { - try { - targetLine = ((TargetDataLine)AudioSystem.getLine(microphone)); - targetLine.open(voiceClient.format, 2200); - targetLine.start(); - AudioInputStream audioInput = new AudioInputStream(targetLine); + @Override + public void run() { + try { + targetLine = ((TargetDataLine) AudioSystem.getLine(microphone)); + targetLine.open(voiceClient.format, 2200); + targetLine.start(); + AudioInputStream audioInput = new AudioInputStream(targetLine); - boolean doFlush = false; + boolean doFlush = false; - while(voiceClient.running) - { - if(MekanismKeyHandler.voiceKey.getIsKeyPressed()) - { - targetLine.flush(); + while (voiceClient.running) { + if (MekanismKeyHandler.voiceKey.getIsKeyPressed()) { + targetLine.flush(); - while(voiceClient.running && MekanismKeyHandler.voiceKey.getIsKeyPressed()) - { - try { - int availableBytes = audioInput.available(); - byte[] audioData = new byte[availableBytes > 2200 ? 2200 : availableBytes]; - int bytesRead = audioInput.read(audioData, 0, audioData.length); + while (voiceClient.running + && MekanismKeyHandler.voiceKey.getIsKeyPressed()) { + try { + int availableBytes = audioInput.available(); + byte[] audioData + = new byte[availableBytes > 2200 ? 2200 : availableBytes]; + int bytesRead + = audioInput.read(audioData, 0, audioData.length); - if(bytesRead > 0) - { - voiceClient.output.writeShort(audioData.length); - voiceClient.output.write(audioData); - } - } catch(Exception e) {} - } + if (bytesRead > 0) { + voiceClient.output.writeShort(audioData.length); + voiceClient.output.write(audioData); + } + } catch (Exception e) {} + } - try { - Thread.sleep(200L); - } catch(Exception e) {} + try { + Thread.sleep(200L); + } catch (Exception e) {} - doFlush = true; - } - else if(doFlush) - { - try { - voiceClient.output.flush(); - } catch(Exception e) {} + doFlush = true; + } else if (doFlush) { + try { + voiceClient.output.flush(); + } catch (Exception e) {} - doFlush = false; - } + doFlush = false; + } - try { - Thread.sleep(20L); - } catch(Exception e) {} - } + try { + Thread.sleep(20L); + } catch (Exception e) {} + } - audioInput.close(); - } catch(Exception e) { - Mekanism.logger.error("VoiceServer: Error while running client input thread."); - e.printStackTrace(); - } - } + audioInput.close(); + } catch (Exception e) { + Mekanism.logger.error("VoiceServer: Error while running client input thread." + ); + e.printStackTrace(); + } + } - public void close() - { - targetLine.flush(); - targetLine.close(); - } + public void close() { + targetLine.flush(); + targetLine.close(); + } } diff --git a/src/main/java/mekanism/client/voice/VoiceOutput.java b/src/main/java/mekanism/client/voice/VoiceOutput.java index f037c2481..23f78b7f6 100644 --- a/src/main/java/mekanism/client/voice/VoiceOutput.java +++ b/src/main/java/mekanism/client/voice/VoiceOutput.java @@ -4,55 +4,51 @@ import javax.sound.sampled.AudioSystem; import javax.sound.sampled.DataLine; import javax.sound.sampled.SourceDataLine; -import mekanism.common.Mekanism; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import mekanism.common.Mekanism; @SideOnly(Side.CLIENT) -public class VoiceOutput extends Thread -{ - public VoiceClient voiceClient; +public class VoiceOutput extends Thread { + public VoiceClient voiceClient; - public DataLine.Info speaker; + public DataLine.Info speaker; - public SourceDataLine sourceLine; + public SourceDataLine sourceLine; - public VoiceOutput(VoiceClient client) - { - voiceClient = client; - speaker = new DataLine.Info(SourceDataLine.class, voiceClient.format, 2200); + public VoiceOutput(VoiceClient client) { + voiceClient = client; + speaker = new DataLine.Info(SourceDataLine.class, voiceClient.format, 2200); - setDaemon(true); - setName("VoiceServer Client Output Thread"); - } + setDaemon(true); + setName("VoiceServer Client Output Thread"); + } - @Override - public void run() - { - try { - sourceLine = ((SourceDataLine)AudioSystem.getLine(speaker)); - sourceLine.open(voiceClient.format, 2200); - sourceLine.start(); + @Override + public void run() { + try { + sourceLine = ((SourceDataLine) AudioSystem.getLine(speaker)); + sourceLine.open(voiceClient.format, 2200); + sourceLine.start(); - while(voiceClient.running) - { - try { - short byteCount = voiceClient.input.readShort(); - byte[] audioData = new byte[byteCount]; - voiceClient.input.readFully(audioData); + while (voiceClient.running) { + try { + short byteCount = voiceClient.input.readShort(); + byte[] audioData = new byte[byteCount]; + voiceClient.input.readFully(audioData); - sourceLine.write(audioData, 0, audioData.length); - } catch(Exception e) {} - } - } catch(Exception e) { - Mekanism.logger.error("VoiceServer: Error while running client output thread."); - e.printStackTrace(); - } - } + sourceLine.write(audioData, 0, audioData.length); + } catch (Exception e) {} + } + } catch (Exception e) { + Mekanism.logger.error("VoiceServer: Error while running client output thread." + ); + e.printStackTrace(); + } + } - public void close() - { - sourceLine.flush(); - sourceLine.close(); - } + public void close() { + sourceLine.flush(); + sourceLine.close(); + } } diff --git a/src/main/java/mekanism/common/BoxBlacklistParser.java b/src/main/java/mekanism/common/BoxBlacklistParser.java index 0a18aafe7..7ed80c356 100644 --- a/src/main/java/mekanism/common/BoxBlacklistParser.java +++ b/src/main/java/mekanism/common/BoxBlacklistParser.java @@ -10,100 +10,97 @@ import java.io.IOException; import mekanism.api.MekanismAPI; import net.minecraft.block.Block; -public final class BoxBlacklistParser -{ - public static File mekanismDir = new File(Mekanism.proxy.getMinecraftDir(), "config/mekanism"); - public static File boxBlacklistFile = new File(mekanismDir, "BoxBlacklist.txt"); +public final class BoxBlacklistParser { + public static File mekanismDir + = new File(Mekanism.proxy.getMinecraftDir(), "config/mekanism"); + public static File boxBlacklistFile = new File(mekanismDir, "BoxBlacklist.txt"); - public static void load() - { - try { - generateFiles(); - readBlacklist(); - } catch(Exception e) { - e.printStackTrace(); - } - } + public static void load() { + try { + generateFiles(); + readBlacklist(); + } catch (Exception e) { + e.printStackTrace(); + } + } - private static void generateFiles() throws IOException - { - mekanismDir.mkdirs(); + private static void generateFiles() throws IOException { + mekanismDir.mkdirs(); - if(!boxBlacklistFile.exists()) - { - boxBlacklistFile.createNewFile(); - writeExamples(); - } - } + if (!boxBlacklistFile.exists()) { + boxBlacklistFile.createNewFile(); + writeExamples(); + } + } - private static boolean isInteger(String s) - { - try { - Integer.parseInt(s); - return true; - } - catch(Exception e) { - return false; - } - } + private static boolean isInteger(String s) { + try { + Integer.parseInt(s); + return true; + } catch (Exception e) { + return false; + } + } - private static void readBlacklist() throws IOException - { - BufferedReader reader = new BufferedReader(new FileReader(boxBlacklistFile)); - int entries = 0; + private static void readBlacklist() throws IOException { + BufferedReader reader = new BufferedReader(new FileReader(boxBlacklistFile)); + int entries = 0; - String readingLine; - int line = 0; + String readingLine; + int line = 0; - while((readingLine = reader.readLine()) != null) - { - line++; + while ((readingLine = reader.readLine()) != null) { + line++; - if(readingLine.startsWith("#") || readingLine.trim().isEmpty()) - { - continue; - } + if (readingLine.startsWith("#") || readingLine.trim().isEmpty()) { + continue; + } - String[] split = readingLine.split(" "); + String[] split = readingLine.split(" "); - if(split.length != 2 || !isInteger(split[split.length-1])) - { - Mekanism.logger.error("BoxBlacklist.txt: Couldn't parse blacklist data on line " + line); - continue; - } - - String blockName = split[0].trim(); - - Block block = Block.getBlockFromName(blockName); - - if(block == null) - { - Mekanism.logger.error("BoxBlacklist.txt: Couldn't find specified block on line " + line); - continue; - } + if (split.length != 2 || !isInteger(split[split.length - 1])) { + Mekanism.logger.error( + "BoxBlacklist.txt: Couldn't parse blacklist data on line " + line + ); + continue; + } - MekanismAPI.addBoxBlacklist(block, Integer.parseInt(split[split.length-1])); - entries++; - } + String blockName = split[0].trim(); - reader.close(); + Block block = Block.getBlockFromName(blockName); - Mekanism.logger.info("Finished loading Cardboard Box blacklist (loaded " + entries + " entries)"); - } + if (block == null) { + Mekanism.logger.error( + "BoxBlacklist.txt: Couldn't find specified block on line " + line + ); + continue; + } - private static void writeExamples() throws IOException - { - BufferedWriter writer = new BufferedWriter(new FileWriter(boxBlacklistFile)); + MekanismAPI.addBoxBlacklist(block, Integer.parseInt(split[split.length - 1])); + entries++; + } - writer.append("# Use this file to tell Mekanism which blocks should not be picked up by a cardboard box."); - writer.newLine(); + reader.close(); - writer.append("# Proper syntax is \"NAME META\". Example (for stone):"); - writer.newLine(); + Mekanism.logger.info( + "Finished loading Cardboard Box blacklist (loaded " + entries + " entries)" + ); + } - writer.append("# minecraft:stone 0"); + private static void writeExamples() throws IOException { + BufferedWriter writer = new BufferedWriter(new FileWriter(boxBlacklistFile)); - writer.flush(); - writer.close(); - } + writer.append( + "# Use this file to tell Mekanism which blocks should not be picked up by a cardboard box." + ); + writer.newLine(); + + writer.append("# Proper syntax is \"NAME META\". Example (for stone):"); + writer.newLine(); + + writer.append("# minecraft:stone 0"); + + writer.flush(); + writer.close(); + } } diff --git a/src/main/java/mekanism/common/CTMData.java b/src/main/java/mekanism/common/CTMData.java index c295f1800..2b51bf68d 100644 --- a/src/main/java/mekanism/common/CTMData.java +++ b/src/main/java/mekanism/common/CTMData.java @@ -4,6 +4,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map.Entry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.client.render.block.TextureSubmap; import net.minecraft.block.Block; @@ -11,128 +13,109 @@ import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraftforge.common.util.ForgeDirection; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class CTMData -{ - public CTMTextureData mainTextureData; +public class CTMData { + public CTMTextureData mainTextureData; - public HashMap> acceptableBlockMetas = new HashMap>(); + public HashMap> acceptableBlockMetas + = new HashMap>(); - public CTMTextureData[] sideOverrides = new CTMTextureData[6]; + public CTMTextureData[] sideOverrides = new CTMTextureData[6]; - public CTMTextureData facingOverride; + public CTMTextureData facingOverride; - public int facing; + public int facing; - public boolean renderConvexConnections = false; + public boolean renderConvexConnections = false; - public CTMData(String textureName, Block block, List connectableMeta) - { - mainTextureData = new CTMTextureData(textureName); - acceptableBlockMetas.put(block, connectableMeta); - } + public CTMData(String textureName, Block block, List connectableMeta) { + mainTextureData = new CTMTextureData(textureName); + acceptableBlockMetas.put(block, connectableMeta); + } - public CTMData addSideOverride(ForgeDirection side, String sideTexture) - { - sideOverrides[side.ordinal()] = new CTMTextureData(sideTexture); + public CTMData addSideOverride(ForgeDirection side, String sideTexture) { + sideOverrides[side.ordinal()] = new CTMTextureData(sideTexture); - return this; - } + return this; + } - public CTMData addFacingOverride(String facingTexture) - { - facingOverride = new CTMTextureData(facingTexture); + public CTMData addFacingOverride(String facingTexture) { + facingOverride = new CTMTextureData(facingTexture); - return this; - } + return this; + } - public boolean hasFacingOverride() - { - return facingOverride != null; - } + public boolean hasFacingOverride() { + return facingOverride != null; + } - public void setFacing(int newFacing) - { - facing = newFacing; - } + public void setFacing(int newFacing) { + facing = newFacing; + } - public CTMData registerIcons(IIconRegister register) - { - mainTextureData.registerIcons(register); + public CTMData registerIcons(IIconRegister register) { + mainTextureData.registerIcons(register); - if(facingOverride != null) - { - facingOverride.registerIcons(register); - } + if (facingOverride != null) { + facingOverride.registerIcons(register); + } - for(CTMTextureData data : sideOverrides) - { - if(data != null) - { - data.registerIcons(register); - } - } + for (CTMTextureData data : sideOverrides) { + if (data != null) { + data.registerIcons(register); + } + } - return this; - } + return this; + } - public CTMTextureData getTextureData(int side) - { - if(hasFacingOverride() && side == facing) - { - return facingOverride; - } - - if(sideOverrides[side] != null) - { - return sideOverrides[side]; - } - - return mainTextureData; - } + public CTMTextureData getTextureData(int side) { + if (hasFacingOverride() && side == facing) { + return facingOverride; + } - public IIcon getIcon(int side) - { - return getTextureData(side).icon; - } + if (sideOverrides[side] != null) { + return sideOverrides[side]; + } - public TextureSubmap getSubmap(int side) - { - return getTextureData(side).submap; - } + return mainTextureData; + } - public TextureSubmap getSmallSubmap(int side) - { - return getTextureData(side).submapSmall; - } + public IIcon getIcon(int side) { + return getTextureData(side).icon; + } - public CTMData addOtherBlockConnectivities(Block block, List connectableMeta) - { - acceptableBlockMetas.put(block, connectableMeta); - return this; - } + public TextureSubmap getSubmap(int side) { + return getTextureData(side).submap; + } - public CTMData setRenderConvexConnections() - { - renderConvexConnections = true; - return this; - } + public TextureSubmap getSmallSubmap(int side) { + return getTextureData(side).submapSmall; + } - @SideOnly(Side.CLIENT) - public boolean shouldRenderSide(IBlockAccess world, int x, int y, int z, int side) - { - Coord4D obj = new Coord4D(x, y, z); - Block coordBlock = obj.getBlock(world); - int coordMeta = obj.getMetadata(world); - boolean valid = false; + public CTMData + addOtherBlockConnectivities(Block block, List connectableMeta) { + acceptableBlockMetas.put(block, connectableMeta); + return this; + } - for(Entry> entry : acceptableBlockMetas.entrySet()) - { - valid |= entry.getKey().equals(coordBlock) && entry.getValue().contains(coordMeta); - } - - return !valid; - } + public CTMData setRenderConvexConnections() { + renderConvexConnections = true; + return this; + } + + @SideOnly(Side.CLIENT) + public boolean shouldRenderSide(IBlockAccess world, int x, int y, int z, int side) { + Coord4D obj = new Coord4D(x, y, z); + Block coordBlock = obj.getBlock(world); + int coordMeta = obj.getMetadata(world); + boolean valid = false; + + for (Entry> entry : acceptableBlockMetas.entrySet()) { + valid |= entry.getKey().equals(coordBlock) + && entry.getValue().contains(coordMeta); + } + + return !valid; + } } diff --git a/src/main/java/mekanism/common/CTMTextureData.java b/src/main/java/mekanism/common/CTMTextureData.java index fc1919fd6..20b62c1f5 100644 --- a/src/main/java/mekanism/common/CTMTextureData.java +++ b/src/main/java/mekanism/common/CTMTextureData.java @@ -4,27 +4,24 @@ import mekanism.client.render.block.TextureSubmap; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; -public class CTMTextureData -{ - public IIcon icon; +public class CTMTextureData { + public IIcon icon; - public TextureSubmap submap; + public TextureSubmap submap; - public TextureSubmap submapSmall; + public TextureSubmap submapSmall; - public String texture; - - public CTMTextureData(String textureName) - { - texture = textureName; - } - - public void registerIcons(IIconRegister register) - { - icon = register.registerIcon("mekanism:" + texture); - submap = new TextureSubmap(register.registerIcon("mekanism:" + texture + "-ctm"), 4, 4); - submapSmall = new TextureSubmap(icon, 2, 2); - } + public String texture; + public CTMTextureData(String textureName) { + texture = textureName; + } + public void registerIcons(IIconRegister register) { + icon = register.registerIcon("mekanism:" + texture); + submap = new TextureSubmap( + register.registerIcon("mekanism:" + texture + "-ctm"), 4, 4 + ); + submapSmall = new TextureSubmap(icon, 2, 2); + } } diff --git a/src/main/java/mekanism/common/CommandMekanism.java b/src/main/java/mekanism/common/CommandMekanism.java index 64b20fd5a..c4aacf497 100644 --- a/src/main/java/mekanism/common/CommandMekanism.java +++ b/src/main/java/mekanism/common/CommandMekanism.java @@ -13,202 +13,286 @@ import net.minecraft.command.ICommandSender; import net.minecraft.server.MinecraftServer; import net.minecraft.util.ChatComponentText; -public class CommandMekanism extends CommandBase -{ - @Override - public boolean canCommandSenderUseCommand(ICommandSender sender) - { - return MinecraftServer.getServer().isSinglePlayer() || super.canCommandSenderUseCommand(sender); - } +public class CommandMekanism extends CommandBase { + @Override + public boolean canCommandSenderUseCommand(ICommandSender sender) { + return MinecraftServer.getServer().isSinglePlayer() + || super.canCommandSenderUseCommand(sender); + } - @Override - public String getCommandName() - { - return "mk"; - } + @Override + public String getCommandName() { + return "mk"; + } - @Override - public String getCommandUsage(ICommandSender sender) - { - return "/mk "; - } + @Override + public String getCommandUsage(ICommandSender sender) { + return "/mk "; + } - @Override - public List getCommandAliases() - { - return Arrays.asList(new String[] {"mekanism", "mek"}); - } + @Override + public List getCommandAliases() { + return Arrays.asList(new String[] { "mekanism", "mek" }); + } - @Override - public void processCommand(ICommandSender sender, String[] params) - { - if(params.length < 1) - { - sender.addChatMessage(new ChatComponentText(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " -------------")); - sender.addChatMessage(new ChatComponentText(EnumColor.GREY + " *Version: " + EnumColor.DARK_GREY + Mekanism.versionNumber)); - sender.addChatMessage(new ChatComponentText(EnumColor.GREY + " *Code, textures, and ideas by aidancbrady")); - sender.addChatMessage(new ChatComponentText(EnumColor.GREY + " *Recent News: " + EnumColor.INDIGO + Mekanism.recentNews)); - sender.addChatMessage(new ChatComponentText(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------")); - } - else if(params.length >= 1) - { - if(params[0].equalsIgnoreCase("help")) - { - if(params.length == 1) - { - sender.addChatMessage(new ChatComponentText(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " -------------")); - sender.addChatMessage(new ChatComponentText(EnumColor.INDIGO + " /mk" + EnumColor.GREY + " -- displays the main page.")); - sender.addChatMessage(new ChatComponentText(EnumColor.INDIGO + " /mk help" + EnumColor.GREY + " -- displays this guide.")); - sender.addChatMessage(new ChatComponentText(EnumColor.INDIGO + " /mk version" + EnumColor.GREY + " -- displays the version number.")); - sender.addChatMessage(new ChatComponentText(EnumColor.INDIGO + " /mk latest" + EnumColor.GREY + " -- displays the latest version number.")); - sender.addChatMessage(new ChatComponentText(EnumColor.INDIGO + " /mk news" + EnumColor.GREY + " -- displays most recent recent news.")); - sender.addChatMessage(new ChatComponentText(EnumColor.INDIGO + " /mk debug" + EnumColor.GREY + " -- toggles Mekanism's debug mode.")); - sender.addChatMessage(new ChatComponentText(EnumColor.INDIGO + " /mk teleporter" + EnumColor.GREY + " -- provides information on teleporters.")); - sender.addChatMessage(new ChatComponentText(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------")); - } - else if(params[1].equalsIgnoreCase("teleporter")) - { - sender.addChatMessage(new ChatComponentText(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " -------------")); - sender.addChatMessage(new ChatComponentText(EnumColor.INDIGO + " /mk teleporter freq list" + EnumColor.GREY + " -- displays a list of the public frequencies.")); - sender.addChatMessage(new ChatComponentText(EnumColor.INDIGO + " /mk teleporter freq list [user]" + EnumColor.GREY + " -- displays a list of a certain user's private frequencies.")); - sender.addChatMessage(new ChatComponentText(EnumColor.INDIGO + " /mk teleporter freq delete [freq]" + EnumColor.GREY + " -- removes a frequency from the public list.")); - sender.addChatMessage(new ChatComponentText(EnumColor.INDIGO + " /mk teleporter freq delete [user] [freq]" + EnumColor.GREY + " -- removes a freqency from a certain user's private list.")); - sender.addChatMessage(new ChatComponentText(EnumColor.INDIGO + " /mk teleporter freq deleteAll [user]" + EnumColor.GREY + " -- removes all frequencies owned by a certain user.")); - sender.addChatMessage(new ChatComponentText(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------")); - } - } - else if(params[0].equalsIgnoreCase("version")) - { - sender.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Your client is up to date.")); - } - else if(params[0].equalsIgnoreCase("news")) - { - sender.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Most recent news: " + EnumColor.INDIGO + Mekanism.recentNews)); - } - else if(params[0].equalsIgnoreCase("teleporter")) - { - if(params.length == 2) - { - sender.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Invalid parameters.")); - } - else if(params[1].equalsIgnoreCase("freq") || params[1].equalsIgnoreCase("frequencies")) - { - if(params[2].equalsIgnoreCase("list")) - { - sender.addChatMessage(new ChatComponentText(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " -------------")); - - if(params.length == 3) - { - for(Frequency freq : Mekanism.publicTeleporters.getFrequencies()) - { - sender.addChatMessage(new ChatComponentText(EnumColor.INDIGO + " - " + freq.name + EnumColor.GREY + " (" + freq.owner + ")")); - } - } - else { - FrequencyManager manager = TileEntityTeleporter.loadManager(params[3].trim(), sender.getEntityWorld()); - - if(manager != null) - { - for(Frequency freq : manager.getFrequencies()) - { - sender.addChatMessage(new ChatComponentText(EnumColor.INDIGO + " - " + freq.name + EnumColor.GREY + " (" + freq.owner + ")")); - } - } - else { - sender.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " User profile doesn't exist.")); - } - } - - sender.addChatMessage(new ChatComponentText(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------")); - } - else if(params[2].equalsIgnoreCase("delete")) - { - if(params.length == 4) - { - if(Mekanism.publicTeleporters.containsFrequency(params[3].trim())) - { - Mekanism.publicTeleporters.remove(params[3].trim()); - sender.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Successfully removed frequency.")); - } - else { - sender.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " No such frequency found.")); - } - } - else if(params.length == 5) - { - FrequencyManager manager = TileEntityTeleporter.loadManager(params[3].trim(), sender.getEntityWorld()); - - if(manager != null) - { - if(manager.containsFrequency(params[4].trim())) - { - manager.remove(params[4].trim()); - sender.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Successfully removed frequency.")); - } - else { - sender.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " No such frequency found.")); - } - } - else { - sender.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " User profile doesn't exist.")); - } - } - } - else if(params[2].equalsIgnoreCase("deleteAll")) - { - if(params.length == 4) - { - String owner = params[3].trim(); - FrequencyManager manager = TileEntityTeleporter.loadManager(owner, sender.getEntityWorld()); - - if(manager != null) - { - int amount = Mekanism.publicTeleporters.removeAll(owner); - amount += manager.removeAll(owner); - - sender.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Successfully removed " + amount + " frequencies.")); - } - else { - sender.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " User profile doesn't exist.")); - } - } - } - } - } - else if(params[0].equalsIgnoreCase("debug")) - { - MekanismAPI.debug = !MekanismAPI.debug; - sender.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Debug mode set to " + EnumColor.DARK_GREY + MekanismAPI.debug)); - } - else if(params[0].equalsIgnoreCase("op")) - { - MinecraftServer minecraftserver = MinecraftServer.getServer(); + @Override + public void processCommand(ICommandSender sender, String[] params) { + if (params.length < 1) { + sender.addChatMessage(new ChatComponentText( + EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[Mekanism]" + + EnumColor.GREY + " -------------" + )); + sender.addChatMessage(new ChatComponentText( + EnumColor.GREY + " *Version: " + EnumColor.DARK_GREY + + Mekanism.versionNumber + )); + sender.addChatMessage(new ChatComponentText( + EnumColor.GREY + " *Code, textures, and ideas by aidancbrady" + )); + sender.addChatMessage(new ChatComponentText( + EnumColor.GREY + " *Recent News: " + EnumColor.INDIGO + + Mekanism.recentNews + )); + sender.addChatMessage(new ChatComponentText( + EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + + EnumColor.GREY + " -------------" + )); + } else if (params.length >= 1) { + if (params[0].equalsIgnoreCase("help")) { + if (params.length == 1) { + sender.addChatMessage(new ChatComponentText( + EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + + "[Mekanism]" + EnumColor.GREY + " -------------" + )); + sender.addChatMessage(new ChatComponentText( + EnumColor.INDIGO + " /mk" + EnumColor.GREY + + " -- displays the main page." + )); + sender.addChatMessage(new ChatComponentText( + EnumColor.INDIGO + " /mk help" + EnumColor.GREY + + " -- displays this guide." + )); + sender.addChatMessage(new ChatComponentText( + EnumColor.INDIGO + " /mk version" + EnumColor.GREY + + " -- displays the version number." + )); + sender.addChatMessage(new ChatComponentText( + EnumColor.INDIGO + " /mk latest" + EnumColor.GREY + + " -- displays the latest version number." + )); + sender.addChatMessage(new ChatComponentText( + EnumColor.INDIGO + " /mk news" + EnumColor.GREY + + " -- displays most recent recent news." + )); + sender.addChatMessage(new ChatComponentText( + EnumColor.INDIGO + " /mk debug" + EnumColor.GREY + + " -- toggles Mekanism's debug mode." + )); + sender.addChatMessage(new ChatComponentText( + EnumColor.INDIGO + " /mk teleporter" + EnumColor.GREY + + " -- provides information on teleporters." + )); + sender.addChatMessage(new ChatComponentText( + EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + + "[=======]" + EnumColor.GREY + " -------------" + )); + } else if (params[1].equalsIgnoreCase("teleporter")) { + sender.addChatMessage(new ChatComponentText( + EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + + "[Mekanism]" + EnumColor.GREY + " -------------" + )); + sender.addChatMessage(new ChatComponentText( + EnumColor.INDIGO + " /mk teleporter freq list" + EnumColor.GREY + + " -- displays a list of the public frequencies." + )); + sender.addChatMessage(new ChatComponentText( + EnumColor.INDIGO + " /mk teleporter freq list [user]" + + EnumColor.GREY + + " -- displays a list of a certain user's private frequencies." + )); + sender.addChatMessage(new ChatComponentText( + EnumColor.INDIGO + " /mk teleporter freq delete [freq]" + + EnumColor.GREY + " -- removes a frequency from the public list." + )); + sender.addChatMessage(new ChatComponentText( + EnumColor.INDIGO + " /mk teleporter freq delete [user] [freq]" + + EnumColor.GREY + + " -- removes a freqency from a certain user's private list." + )); + sender.addChatMessage(new ChatComponentText( + EnumColor.INDIGO + " /mk teleporter freq deleteAll [user]" + + EnumColor.GREY + + " -- removes all frequencies owned by a certain user." + )); + sender.addChatMessage(new ChatComponentText( + EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + + "[=======]" + EnumColor.GREY + " -------------" + )); + } + } else if (params[0].equalsIgnoreCase("version")) { + sender.addChatMessage(new ChatComponentText( + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + + " Your client is up to date." + )); + } else if (params[0].equalsIgnoreCase("news")) { + sender.addChatMessage(new ChatComponentText( + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + + " Most recent news: " + EnumColor.INDIGO + Mekanism.recentNews + )); + } else if (params[0].equalsIgnoreCase("teleporter")) { + if (params.length == 2) { + sender.addChatMessage(new ChatComponentText( + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + + " Invalid parameters." + )); + } else if (params[1].equalsIgnoreCase("freq") || params[1].equalsIgnoreCase("frequencies")) { + if (params[2].equalsIgnoreCase("list")) { + sender.addChatMessage(new ChatComponentText( + EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + + "[Mekanism]" + EnumColor.GREY + " -------------" + )); - if (Mekanism.gameProfile != null) - { - minecraftserver.getConfigurationManager().func_152605_a(Mekanism.gameProfile); - func_152373_a(sender, this, "commands.op.success", new Object[] {"[Mekanism]"}); - } - } - else if(params[0].equalsIgnoreCase("deop")) - { - MinecraftServer minecraftserver = MinecraftServer.getServer(); + if (params.length == 3) { + for (Frequency freq : + Mekanism.publicTeleporters.getFrequencies()) { + sender.addChatMessage(new ChatComponentText( + EnumColor.INDIGO + " - " + freq.name + EnumColor.GREY + + " (" + freq.owner + ")" + )); + } + } else { + FrequencyManager manager = TileEntityTeleporter.loadManager( + params[3].trim(), sender.getEntityWorld() + ); - if (Mekanism.gameProfile != null) - { - minecraftserver.getConfigurationManager().func_152610_b(Mekanism.gameProfile); - func_152373_a(sender, this, "commands.deop.success", new Object[] {"[Mekanism]"}); - } - } - else { - sender.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Unknown command. Type '" + EnumColor.INDIGO + "/mk help" + EnumColor.GREY + "' for help.")); - } - } - } + if (manager != null) { + for (Frequency freq : manager.getFrequencies()) { + sender.addChatMessage(new ChatComponentText( + EnumColor.INDIGO + " - " + freq.name + + EnumColor.GREY + " (" + freq.owner + ")" + )); + } + } else { + sender.addChatMessage(new ChatComponentText( + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + + " User profile doesn't exist." + )); + } + } - @Override - public int compareTo(Object obj) - { - return 0; - } + sender.addChatMessage(new ChatComponentText( + EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + + "[=======]" + EnumColor.GREY + " -------------" + )); + } else if (params[2].equalsIgnoreCase("delete")) { + if (params.length == 4) { + if (Mekanism.publicTeleporters.containsFrequency( + params[3].trim() + )) { + Mekanism.publicTeleporters.remove(params[3].trim()); + sender.addChatMessage(new ChatComponentText( + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + + " Successfully removed frequency." + )); + } else { + sender.addChatMessage(new ChatComponentText( + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + + " No such frequency found." + )); + } + } else if (params.length == 5) { + FrequencyManager manager = TileEntityTeleporter.loadManager( + params[3].trim(), sender.getEntityWorld() + ); + + if (manager != null) { + if (manager.containsFrequency(params[4].trim())) { + manager.remove(params[4].trim()); + sender.addChatMessage(new ChatComponentText( + EnumColor.DARK_BLUE + "[Mekanism]" + + EnumColor.GREY + + " Successfully removed frequency." + )); + } else { + sender.addChatMessage(new ChatComponentText( + EnumColor.DARK_BLUE + "[Mekanism]" + + EnumColor.GREY + " No such frequency found." + )); + } + } else { + sender.addChatMessage(new ChatComponentText( + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + + " User profile doesn't exist." + )); + } + } + } else if (params[2].equalsIgnoreCase("deleteAll")) { + if (params.length == 4) { + String owner = params[3].trim(); + FrequencyManager manager = TileEntityTeleporter.loadManager( + owner, sender.getEntityWorld() + ); + + if (manager != null) { + int amount = Mekanism.publicTeleporters.removeAll(owner); + amount += manager.removeAll(owner); + + sender.addChatMessage(new ChatComponentText( + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + + " Successfully removed " + amount + " frequencies." + )); + } else { + sender.addChatMessage(new ChatComponentText( + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + + " User profile doesn't exist." + )); + } + } + } + } + } else if (params[0].equalsIgnoreCase("debug")) { + MekanismAPI.debug = !MekanismAPI.debug; + sender.addChatMessage(new ChatComponentText( + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + + " Debug mode set to " + EnumColor.DARK_GREY + MekanismAPI.debug + )); + } else if (params[0].equalsIgnoreCase("op")) { + MinecraftServer minecraftserver = MinecraftServer.getServer(); + + if (Mekanism.gameProfile != null) { + minecraftserver.getConfigurationManager().func_152605_a( + Mekanism.gameProfile + ); + func_152373_a( + sender, this, "commands.op.success", new Object[] { "[Mekanism]" } + ); + } + } else if (params[0].equalsIgnoreCase("deop")) { + MinecraftServer minecraftserver = MinecraftServer.getServer(); + + if (Mekanism.gameProfile != null) { + minecraftserver.getConfigurationManager().func_152610_b( + Mekanism.gameProfile + ); + func_152373_a( + sender, + this, + "commands.deop.success", + new Object[] { "[Mekanism]" } + ); + } + } else { + sender.addChatMessage(new ChatComponentText( + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + + " Unknown command. Type '" + EnumColor.INDIGO + "/mk help" + + EnumColor.GREY + "' for help." + )); + } + } + } + + @Override + public int compareTo(Object obj) { + return 0; + } } diff --git a/src/main/java/mekanism/common/CommonPlayerTickHandler.java b/src/main/java/mekanism/common/CommonPlayerTickHandler.java index 45f73d635..1d541860d 100644 --- a/src/main/java/mekanism/common/CommonPlayerTickHandler.java +++ b/src/main/java/mekanism/common/CommonPlayerTickHandler.java @@ -1,5 +1,9 @@ package mekanism.common; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.TickEvent.Phase; +import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent; +import cpw.mods.fml.relauncher.Side; import mekanism.api.gas.GasStack; import mekanism.common.entity.EntityFlame; import mekanism.common.item.ItemFlamethrower; @@ -17,207 +21,172 @@ import net.minecraft.network.NetHandlerPlayServer; import net.minecraft.potion.PotionEffect; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.MathHelper; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.TickEvent.Phase; -import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent; -import cpw.mods.fml.relauncher.Side; -public class CommonPlayerTickHandler -{ - @SubscribeEvent - public void onTick(PlayerTickEvent event) - { - if(event.phase == Phase.END && event.side == Side.SERVER) - { - tickEnd(event.player); - } - } +public class CommonPlayerTickHandler { + @SubscribeEvent + public void onTick(PlayerTickEvent event) { + if (event.phase == Phase.END && event.side == Side.SERVER) { + tickEnd(event.player); + } + } - public void tickEnd(EntityPlayer player) - { - if(player.getEquipmentInSlot(1) != null && player.getEquipmentInSlot(1).getItem() instanceof ItemFreeRunners) - { - player.stepHeight = 1.002F; - } - else { - if(player.stepHeight == 1.002F) - { - player.stepHeight = 0.5F; - } - } - - if(isFlamethrowerOn(player)) - { - player.worldObj.spawnEntityInWorld(new EntityFlame(player)); - - if(!player.capabilities.isCreativeMode) - { - ((ItemFlamethrower)player.getCurrentEquippedItem().getItem()).useGas(player.getCurrentEquippedItem()); - } - } + public void tickEnd(EntityPlayer player) { + if (player.getEquipmentInSlot(1) != null + && player.getEquipmentInSlot(1).getItem() instanceof ItemFreeRunners) { + player.stepHeight = 1.002F; + } else { + if (player.stepHeight == 1.002F) { + player.stepHeight = 0.5F; + } + } - if(isJetpackOn(player)) - { - ItemJetpack jetpack = (ItemJetpack)player.getEquipmentInSlot(3).getItem(); + if (isFlamethrowerOn(player)) { + player.worldObj.spawnEntityInWorld(new EntityFlame(player)); - if(jetpack.getMode(player.getEquipmentInSlot(3)) == JetpackMode.NORMAL) - { - player.motionY = Math.min(player.motionY + 0.15D, 0.5D); - } - else if(jetpack.getMode(player.getEquipmentInSlot(3)) == JetpackMode.HOVER) - { - if((!Mekanism.keyMap.has(player, KeySync.ASCEND) && !Mekanism.keyMap.has(player, KeySync.DESCEND)) || (Mekanism.keyMap.has(player, KeySync.ASCEND) && Mekanism.keyMap.has(player, KeySync.DESCEND))) - { - if(player.motionY > 0) - { - player.motionY = Math.max(player.motionY - 0.15D, 0); - } - else if(player.motionY < 0) - { - if(!isOnGround(player)) - { - player.motionY = Math.min(player.motionY + 0.15D, 0); - } - } - } - else { - if(Mekanism.keyMap.has(player, KeySync.ASCEND)) - { - player.motionY = Math.min(player.motionY + 0.15D, 0.2D); - } - else if(Mekanism.keyMap.has(player, KeySync.DESCEND)) - { - if(!isOnGround(player)) - { - player.motionY = Math.max(player.motionY - 0.15D, -0.2D); - } - } - } - } + if (!player.capabilities.isCreativeMode) { + ((ItemFlamethrower) player.getCurrentEquippedItem().getItem()) + .useGas(player.getCurrentEquippedItem()); + } + } - player.fallDistance = 0.0F; + if (isJetpackOn(player)) { + ItemJetpack jetpack = (ItemJetpack) player.getEquipmentInSlot(3).getItem(); - if(player instanceof EntityPlayerMP) - { - MekanismUtils.setPrivateValue(((EntityPlayerMP)player).playerNetServerHandler, 0, NetHandlerPlayServer.class, ObfuscatedNames.NetHandlerPlayServer_floatingTickCount); - } + if (jetpack.getMode(player.getEquipmentInSlot(3)) == JetpackMode.NORMAL) { + player.motionY = Math.min(player.motionY + 0.15D, 0.5D); + } else if (jetpack.getMode(player.getEquipmentInSlot(3)) == JetpackMode.HOVER) { + if ((!Mekanism.keyMap.has(player, KeySync.ASCEND) + && !Mekanism.keyMap.has(player, KeySync.DESCEND)) + || (Mekanism.keyMap.has(player, KeySync.ASCEND) + && Mekanism.keyMap.has(player, KeySync.DESCEND))) { + if (player.motionY > 0) { + player.motionY = Math.max(player.motionY - 0.15D, 0); + } else if (player.motionY < 0) { + if (!isOnGround(player)) { + player.motionY = Math.min(player.motionY + 0.15D, 0); + } + } + } else { + if (Mekanism.keyMap.has(player, KeySync.ASCEND)) { + player.motionY = Math.min(player.motionY + 0.15D, 0.2D); + } else if (Mekanism.keyMap.has(player, KeySync.DESCEND)) { + if (!isOnGround(player)) { + player.motionY = Math.max(player.motionY - 0.15D, -0.2D); + } + } + } + } - jetpack.useGas(player.getEquipmentInSlot(3)); - } + player.fallDistance = 0.0F; - if(isGasMaskOn(player)) - { - ItemScubaTank tank = (ItemScubaTank)player.getEquipmentInSlot(3).getItem(); + if (player instanceof EntityPlayerMP) { + MekanismUtils.setPrivateValue( + ((EntityPlayerMP) player).playerNetServerHandler, + 0, + NetHandlerPlayServer.class, + ObfuscatedNames.NetHandlerPlayServer_floatingTickCount + ); + } - final int max = 300; - - tank.useGas(player.getEquipmentInSlot(3)); - GasStack received = tank.useGas(player.getEquipmentInSlot(3), max-player.getAir()); - - if(received != null) - { - player.setAir(player.getAir()+received.amount); - } - - if(player.getAir() == max) - { - for(Object obj : player.getActivePotionEffects()) - { - if(obj instanceof PotionEffect) - { - for(int i = 0; i < 9; i++) - { - ((PotionEffect)obj).onUpdate(player); - } - } - } - } - } - } - - public static boolean isOnGround(EntityPlayer player) - { - int x = MathHelper.floor_double(player.posX); - int y = (int)Math.round(player.posY-player.yOffset - 1); - int z = MathHelper.floor_double(player.posZ); - - Block b = player.worldObj.getBlock(x, y, z); - AxisAlignedBB box = b.getCollisionBoundingBoxFromPool(player.worldObj, x, y, z); - AxisAlignedBB playerBox = player.boundingBox.copy().offset(0, -0.01, 0); - - return box != null && playerBox.intersectsWith(box); - } + jetpack.useGas(player.getEquipmentInSlot(3)); + } - public boolean isJetpackOn(EntityPlayer player) - { - ItemStack stack = player.inventory.armorInventory[2]; + if (isGasMaskOn(player)) { + ItemScubaTank tank = (ItemScubaTank) player.getEquipmentInSlot(3).getItem(); - if(stack != null && !player.capabilities.isCreativeMode) - { - if(stack.getItem() instanceof ItemJetpack) - { - ItemJetpack jetpack = (ItemJetpack)stack.getItem(); + final int max = 300; - if(jetpack.getGas(stack) != null) - { - if((Mekanism.keyMap.has(player, KeySync.ASCEND) && jetpack.getMode(stack) == JetpackMode.NORMAL)) - { - return true; - } - else if(jetpack.getMode(stack) == JetpackMode.HOVER) - { - if((!Mekanism.keyMap.has(player, KeySync.ASCEND) && !Mekanism.keyMap.has(player, KeySync.DESCEND)) || (Mekanism.keyMap.has(player, KeySync.ASCEND) && Mekanism.keyMap.has(player, KeySync.DESCEND))) - { - return !player.onGround; - } - else if(Mekanism.keyMap.has(player, KeySync.DESCEND)) - { - return !player.onGround; - } - - return true; - } - } - } - } + tank.useGas(player.getEquipmentInSlot(3)); + GasStack received + = tank.useGas(player.getEquipmentInSlot(3), max - player.getAir()); - return false; - } + if (received != null) { + player.setAir(player.getAir() + received.amount); + } - public static boolean isGasMaskOn(EntityPlayer player) - { - ItemStack tank = player.inventory.armorInventory[2]; - ItemStack mask = player.inventory.armorInventory[3]; + if (player.getAir() == max) { + for (Object obj : player.getActivePotionEffects()) { + if (obj instanceof PotionEffect) { + for (int i = 0; i < 9; i++) { + ((PotionEffect) obj).onUpdate(player); + } + } + } + } + } + } - if(tank != null && mask != null) - { - if(tank.getItem() instanceof ItemScubaTank && mask.getItem() instanceof ItemGasMask) - { - ItemScubaTank scubaTank = (ItemScubaTank)tank.getItem(); + public static boolean isOnGround(EntityPlayer player) { + int x = MathHelper.floor_double(player.posX); + int y = (int) Math.round(player.posY - player.yOffset - 1); + int z = MathHelper.floor_double(player.posZ); - if(scubaTank.getGas(tank) != null) - { - if(scubaTank.getFlowing(tank)) - { - return true; - } - } - } - } + Block b = player.worldObj.getBlock(x, y, z); + AxisAlignedBB box = b.getCollisionBoundingBoxFromPool(player.worldObj, x, y, z); + AxisAlignedBB playerBox = player.boundingBox.copy().offset(0, -0.01, 0); - return false; - } - - public static boolean isFlamethrowerOn(EntityPlayer player) - { - if(Mekanism.flamethrowerActive.contains(player.getCommandSenderName())) - { - if(player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() instanceof ItemFlamethrower) - { - return true; - } - } - - return false; - } + return box != null && playerBox.intersectsWith(box); + } + + public boolean isJetpackOn(EntityPlayer player) { + ItemStack stack = player.inventory.armorInventory[2]; + + if (stack != null && !player.capabilities.isCreativeMode) { + if (stack.getItem() instanceof ItemJetpack) { + ItemJetpack jetpack = (ItemJetpack) stack.getItem(); + + if (jetpack.getGas(stack) != null) { + if ((Mekanism.keyMap.has(player, KeySync.ASCEND) + && jetpack.getMode(stack) == JetpackMode.NORMAL)) { + return true; + } else if (jetpack.getMode(stack) == JetpackMode.HOVER) { + if ((!Mekanism.keyMap.has(player, KeySync.ASCEND) + && !Mekanism.keyMap.has(player, KeySync.DESCEND)) + || (Mekanism.keyMap.has(player, KeySync.ASCEND) + && Mekanism.keyMap.has(player, KeySync.DESCEND))) { + return !player.onGround; + } else if (Mekanism.keyMap.has(player, KeySync.DESCEND)) { + return !player.onGround; + } + + return true; + } + } + } + } + + return false; + } + + public static boolean isGasMaskOn(EntityPlayer player) { + ItemStack tank = player.inventory.armorInventory[2]; + ItemStack mask = player.inventory.armorInventory[3]; + + if (tank != null && mask != null) { + if (tank.getItem() instanceof ItemScubaTank + && mask.getItem() instanceof ItemGasMask) { + ItemScubaTank scubaTank = (ItemScubaTank) tank.getItem(); + + if (scubaTank.getGas(tank) != null) { + if (scubaTank.getFlowing(tank)) { + return true; + } + } + } + } + + return false; + } + + public static boolean isFlamethrowerOn(EntityPlayer player) { + if (Mekanism.flamethrowerActive.contains(player.getCommandSenderName())) { + if (player.getCurrentEquippedItem() != null + && player.getCurrentEquippedItem().getItem() + instanceof ItemFlamethrower) { + return true; + } + } + + return false; + } } diff --git a/src/main/java/mekanism/common/CommonPlayerTracker.java b/src/main/java/mekanism/common/CommonPlayerTracker.java index ab16c46ac..8c5528f5f 100644 --- a/src/main/java/mekanism/common/CommonPlayerTracker.java +++ b/src/main/java/mekanism/common/CommonPlayerTracker.java @@ -1,5 +1,9 @@ package mekanism.common; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerChangedDimensionEvent; +import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent; +import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedOutEvent; import mekanism.common.network.PacketBoxBlacklist.BoxBlacklistMessage; import mekanism.common.network.PacketConfigSync.ConfigSyncMessage; import mekanism.common.network.PacketJetpackData.JetpackDataMessage; @@ -10,52 +14,62 @@ import mekanism.common.network.PacketSecurityUpdate.SecurityPacket; import mekanism.common.network.PacketSecurityUpdate.SecurityUpdateMessage; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraftforge.common.MinecraftForge; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerChangedDimensionEvent; -import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent; -import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedOutEvent; -public class CommonPlayerTracker -{ - public CommonPlayerTracker() - { - MinecraftForge.EVENT_BUS.register(this); - } - - @SubscribeEvent - public void onPlayerLoginEvent(PlayerLoggedInEvent event) - { - if(!event.player.worldObj.isRemote) - { - Mekanism.packetHandler.sendTo(new ConfigSyncMessage(), (EntityPlayerMP)event.player); - Mekanism.packetHandler.sendTo(new BoxBlacklistMessage(), (EntityPlayerMP)event.player); - Mekanism.packetHandler.sendTo(new JetpackDataMessage(JetpackPacket.FULL, null, false), (EntityPlayerMP)event.player); - Mekanism.packetHandler.sendTo(new ScubaTankDataMessage(ScubaTankPacket.FULL, null, false), (EntityPlayerMP)event.player); - Mekanism.packetHandler.sendTo(new SecurityUpdateMessage(SecurityPacket.FULL, null, null), (EntityPlayerMP)event.player); +public class CommonPlayerTracker { + public CommonPlayerTracker() { + MinecraftForge.EVENT_BUS.register(this); + } - Mekanism.logger.info("Sent config to '" + event.player.getDisplayName() + ".'"); - } - } + @SubscribeEvent + public void onPlayerLoginEvent(PlayerLoggedInEvent event) { + if (!event.player.worldObj.isRemote) { + Mekanism.packetHandler.sendTo( + new ConfigSyncMessage(), (EntityPlayerMP) event.player + ); + Mekanism.packetHandler.sendTo( + new BoxBlacklistMessage(), (EntityPlayerMP) event.player + ); + Mekanism.packetHandler.sendTo( + new JetpackDataMessage(JetpackPacket.FULL, null, false), + (EntityPlayerMP) event.player + ); + Mekanism.packetHandler.sendTo( + new ScubaTankDataMessage(ScubaTankPacket.FULL, null, false), + (EntityPlayerMP) event.player + ); + Mekanism.packetHandler.sendTo( + new SecurityUpdateMessage(SecurityPacket.FULL, null, null), + (EntityPlayerMP) event.player + ); - @SubscribeEvent - public void onPlayerLogoutEvent(PlayerLoggedOutEvent event) - { - Mekanism.jetpackOn.remove(event.player.getCommandSenderName()); - Mekanism.gasmaskOn.remove(event.player.getCommandSenderName()); - Mekanism.flamethrowerActive.remove(event.player.getCommandSenderName()); - } + Mekanism.logger.info( + "Sent config to '" + event.player.getDisplayName() + ".'" + ); + } + } - @SubscribeEvent - public void onPlayerDimChangedEvent(PlayerChangedDimensionEvent event) - { - Mekanism.jetpackOn.remove(event.player.getCommandSenderName()); - Mekanism.gasmaskOn.remove(event.player.getCommandSenderName()); - Mekanism.flamethrowerActive.remove(event.player.getCommandSenderName()); + @SubscribeEvent + public void onPlayerLogoutEvent(PlayerLoggedOutEvent event) { + Mekanism.jetpackOn.remove(event.player.getCommandSenderName()); + Mekanism.gasmaskOn.remove(event.player.getCommandSenderName()); + Mekanism.flamethrowerActive.remove(event.player.getCommandSenderName()); + } - if(!event.player.worldObj.isRemote) - { - Mekanism.packetHandler.sendTo(new JetpackDataMessage(JetpackPacket.FULL, null, false), (EntityPlayerMP)event.player); - Mekanism.packetHandler.sendTo(new ScubaTankDataMessage(ScubaTankPacket.FULL, null, false), (EntityPlayerMP)event.player); - } - } + @SubscribeEvent + public void onPlayerDimChangedEvent(PlayerChangedDimensionEvent event) { + Mekanism.jetpackOn.remove(event.player.getCommandSenderName()); + Mekanism.gasmaskOn.remove(event.player.getCommandSenderName()); + Mekanism.flamethrowerActive.remove(event.player.getCommandSenderName()); + + if (!event.player.worldObj.isRemote) { + Mekanism.packetHandler.sendTo( + new JetpackDataMessage(JetpackPacket.FULL, null, false), + (EntityPlayerMP) event.player + ); + Mekanism.packetHandler.sendTo( + new ScubaTankDataMessage(ScubaTankPacket.FULL, null, false), + (EntityPlayerMP) event.player + ); + } + } } diff --git a/src/main/java/mekanism/common/CommonProxy.java b/src/main/java/mekanism/common/CommonProxy.java index b6ac95cea..78ef732e8 100644 --- a/src/main/java/mekanism/common/CommonProxy.java +++ b/src/main/java/mekanism/common/CommonProxy.java @@ -3,6 +3,11 @@ package mekanism.common; import java.io.File; import java.lang.ref.WeakReference; +import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.FMLInjectionData; import mekanism.api.Coord4D; import mekanism.api.MekanismAPI; import mekanism.api.MekanismConfig.general; @@ -134,601 +139,963 @@ import net.minecraft.world.WorldServer; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.common.util.FakePlayerFactory; import net.minecraftforge.common.util.ForgeDirection; -import cpw.mods.fml.client.registry.RenderingRegistry; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.relauncher.FMLInjectionData; /** * Common proxy for the Mekanism mod. * @author AidanBrady * */ -public class CommonProxy implements IGuiProvider -{ - public static int MACHINE_RENDER_ID = RenderingRegistry.getNextAvailableRenderId(); - public static int BASIC_RENDER_ID = RenderingRegistry.getNextAvailableRenderId(); - public static int PLASTIC_RENDER_ID = RenderingRegistry.getNextAvailableRenderId(); - public static int CTM_RENDER_ID = RenderingRegistry.getNextAvailableRenderId(); +public class CommonProxy implements IGuiProvider { + public static int MACHINE_RENDER_ID = RenderingRegistry.getNextAvailableRenderId(); + public static int BASIC_RENDER_ID = RenderingRegistry.getNextAvailableRenderId(); + public static int PLASTIC_RENDER_ID = RenderingRegistry.getNextAvailableRenderId(); + public static int CTM_RENDER_ID = RenderingRegistry.getNextAvailableRenderId(); - protected static WeakReference dummyPlayer = new WeakReference(null); + protected static WeakReference dummyPlayer + = new WeakReference(null); - /** - * Register tile entities that have special models. Overwritten in client to register TESRs. - */ - public void registerSpecialTileEntities() - { - GameRegistry.registerTileEntity(TileEntityEnrichmentChamber.class, "EnrichmentChamber"); - GameRegistry.registerTileEntity(TileEntityOsmiumCompressor.class, "OsmiumCompressor"); - GameRegistry.registerTileEntity(TileEntityCombiner.class, "Combiner"); - GameRegistry.registerTileEntity(TileEntityCrusher.class, "Crusher"); - GameRegistry.registerTileEntity(TileEntityFactory.class, "SmeltingFactory"); - GameRegistry.registerTileEntity(TileEntityAdvancedFactory.class, "AdvancedSmeltingFactory"); - GameRegistry.registerTileEntity(TileEntityEliteFactory.class, "UltimateSmeltingFactory"); - GameRegistry.registerTileEntity(TileEntityPurificationChamber.class, "PurificationChamber"); - GameRegistry.registerTileEntity(TileEntityEnergizedSmelter.class, "EnergizedSmelter"); - GameRegistry.registerTileEntity(TileEntityMetallurgicInfuser.class, "MetallurgicInfuser"); - GameRegistry.registerTileEntity(TileEntityGasTank.class, "GasTank"); - GameRegistry.registerTileEntity(TileEntityEnergyCube.class, "EnergyCube"); - GameRegistry.registerTileEntity(TileEntityElectricPump.class, "ElectricPump"); - GameRegistry.registerTileEntity(TileEntityPersonalChest.class, "ElectricChest"); //TODO rename - GameRegistry.registerTileEntity(TileEntityDynamicTank.class, "DynamicTank"); - GameRegistry.registerTileEntity(TileEntityDynamicValve.class, "DynamicValve"); - GameRegistry.registerTileEntity(TileEntityChargepad.class, "Chargepad"); - GameRegistry.registerTileEntity(TileEntityLogisticalSorter.class, "LogisticalSorter"); - GameRegistry.registerTileEntity(TileEntityBin.class, "Bin"); - GameRegistry.registerTileEntity(TileEntityDigitalMiner.class, "DigitalMiner"); - GameRegistry.registerTileEntity(TileEntityObsidianTNT.class, "ObsidianTNT"); - GameRegistry.registerTileEntity(TileEntityRotaryCondensentrator.class, "RotaryCondensentrator"); - GameRegistry.registerTileEntity(TileEntityTeleporter.class, "MekanismTeleporter"); - GameRegistry.registerTileEntity(TileEntityChemicalOxidizer.class, "ChemicalOxidizer"); - GameRegistry.registerTileEntity(TileEntityChemicalInfuser.class, "ChemicalInfuser"); - GameRegistry.registerTileEntity(TileEntityChemicalInjectionChamber.class, "ChemicalInjectionChamber"); - GameRegistry.registerTileEntity(TileEntityElectrolyticSeparator.class, "ElectrolyticSeparator"); - GameRegistry.registerTileEntity(TileEntityThermalEvaporationController.class, "SalinationController"); //TODO rename - GameRegistry.registerTileEntity(TileEntityPrecisionSawmill.class, "PrecisionSawmill"); - GameRegistry.registerTileEntity(TileEntityChemicalDissolutionChamber.class, "ChemicalDissolutionChamber"); - GameRegistry.registerTileEntity(TileEntityChemicalWasher.class, "ChemicalWasher"); - GameRegistry.registerTileEntity(TileEntityChemicalCrystallizer.class, "ChemicalCrystallizer"); - GameRegistry.registerTileEntity(TileEntitySeismicVibrator.class, "SeismicVibrator"); - GameRegistry.registerTileEntity(TileEntityPRC.class, "PressurizedReactionChamber"); - GameRegistry.registerTileEntity(TileEntityFluidTank.class, "PortableTank"); //TODO rename - GameRegistry.registerTileEntity(TileEntityFluidicPlenisher.class, "FluidicPlenisher"); - GameRegistry.registerTileEntity(TileEntityLaser.class, "Laser"); - GameRegistry.registerTileEntity(TileEntityLaserAmplifier.class, "LaserAmplifier"); - GameRegistry.registerTileEntity(TileEntityLaserTractorBeam.class, "LaserTractorBeam"); - GameRegistry.registerTileEntity(TileEntitySolarNeutronActivator.class, "SolarNeutronActivator"); - GameRegistry.registerTileEntity(TileEntityAmbientAccumulator.class, "AmbientAccumulator"); - GameRegistry.registerTileEntity(TileEntityInductionCasing.class, "InductionCasing"); - GameRegistry.registerTileEntity(TileEntityInductionPort.class, "InductionPort"); - GameRegistry.registerTileEntity(TileEntityInductionCell.class, "InductionCell"); - GameRegistry.registerTileEntity(TileEntityInductionProvider.class, "InductionProvider"); - GameRegistry.registerTileEntity(TileEntityOredictionificator.class, "Oredictionificator"); - GameRegistry.registerTileEntity(TileEntityStructuralGlass.class, "StructuralGlass"); - GameRegistry.registerTileEntity(TileEntityFormulaicAssemblicator.class, "FormulaicAssemblicator"); - GameRegistry.registerTileEntity(TileEntityResistiveHeater.class, "ResistiveHeater"); - GameRegistry.registerTileEntity(TileEntityBoilerCasing.class, "BoilerCasing"); - GameRegistry.registerTileEntity(TileEntityBoilerValve.class, "BoilerValve"); - GameRegistry.registerTileEntity(TileEntitySecurityDesk.class, "SecurityDesk"); - GameRegistry.registerTileEntity(TileEntityQuantumEntangloporter.class, "QuantumEntangloporter"); - GameRegistry.registerTileEntity(TileEntityFuelwoodHeater.class, "FuelwoodHeater"); - GameRegistry.registerTileEntity(TileEntityTheoreticalElementizer.class, "TheoreticalElementizer"); - } - - public void handleTeleporterUpdate(PortableTeleporterMessage message) {} + /** + * Register tile entities that have special models. Overwritten in client to register + * TESRs. + */ + public void registerSpecialTileEntities() { + GameRegistry.registerTileEntity( + TileEntityEnrichmentChamber.class, "EnrichmentChamber" + ); + GameRegistry.registerTileEntity( + TileEntityOsmiumCompressor.class, "OsmiumCompressor" + ); + GameRegistry.registerTileEntity(TileEntityCombiner.class, "Combiner"); + GameRegistry.registerTileEntity(TileEntityCrusher.class, "Crusher"); + GameRegistry.registerTileEntity(TileEntityFactory.class, "SmeltingFactory"); + GameRegistry.registerTileEntity( + TileEntityAdvancedFactory.class, "AdvancedSmeltingFactory" + ); + GameRegistry.registerTileEntity( + TileEntityEliteFactory.class, "UltimateSmeltingFactory" + ); + GameRegistry.registerTileEntity( + TileEntityPurificationChamber.class, "PurificationChamber" + ); + GameRegistry.registerTileEntity( + TileEntityEnergizedSmelter.class, "EnergizedSmelter" + ); + GameRegistry.registerTileEntity( + TileEntityMetallurgicInfuser.class, "MetallurgicInfuser" + ); + GameRegistry.registerTileEntity(TileEntityGasTank.class, "GasTank"); + GameRegistry.registerTileEntity(TileEntityEnergyCube.class, "EnergyCube"); + GameRegistry.registerTileEntity(TileEntityElectricPump.class, "ElectricPump"); + GameRegistry.registerTileEntity( + TileEntityPersonalChest.class, "ElectricChest" + ); //TODO rename + GameRegistry.registerTileEntity(TileEntityDynamicTank.class, "DynamicTank"); + GameRegistry.registerTileEntity(TileEntityDynamicValve.class, "DynamicValve"); + GameRegistry.registerTileEntity(TileEntityChargepad.class, "Chargepad"); + GameRegistry.registerTileEntity( + TileEntityLogisticalSorter.class, "LogisticalSorter" + ); + GameRegistry.registerTileEntity(TileEntityBin.class, "Bin"); + GameRegistry.registerTileEntity(TileEntityDigitalMiner.class, "DigitalMiner"); + GameRegistry.registerTileEntity(TileEntityObsidianTNT.class, "ObsidianTNT"); + GameRegistry.registerTileEntity( + TileEntityRotaryCondensentrator.class, "RotaryCondensentrator" + ); + GameRegistry.registerTileEntity(TileEntityTeleporter.class, "MekanismTeleporter"); + GameRegistry.registerTileEntity( + TileEntityChemicalOxidizer.class, "ChemicalOxidizer" + ); + GameRegistry.registerTileEntity( + TileEntityChemicalInfuser.class, "ChemicalInfuser" + ); + GameRegistry.registerTileEntity( + TileEntityChemicalInjectionChamber.class, "ChemicalInjectionChamber" + ); + GameRegistry.registerTileEntity( + TileEntityElectrolyticSeparator.class, "ElectrolyticSeparator" + ); + GameRegistry.registerTileEntity( + TileEntityThermalEvaporationController.class, "SalinationController" + ); //TODO rename + GameRegistry.registerTileEntity( + TileEntityPrecisionSawmill.class, "PrecisionSawmill" + ); + GameRegistry.registerTileEntity( + TileEntityChemicalDissolutionChamber.class, "ChemicalDissolutionChamber" + ); + GameRegistry.registerTileEntity(TileEntityChemicalWasher.class, "ChemicalWasher"); + GameRegistry.registerTileEntity( + TileEntityChemicalCrystallizer.class, "ChemicalCrystallizer" + ); + GameRegistry.registerTileEntity( + TileEntitySeismicVibrator.class, "SeismicVibrator" + ); + GameRegistry.registerTileEntity( + TileEntityPRC.class, "PressurizedReactionChamber" + ); + GameRegistry.registerTileEntity( + TileEntityFluidTank.class, "PortableTank" + ); //TODO rename + GameRegistry.registerTileEntity( + TileEntityFluidicPlenisher.class, "FluidicPlenisher" + ); + GameRegistry.registerTileEntity(TileEntityLaser.class, "Laser"); + GameRegistry.registerTileEntity(TileEntityLaserAmplifier.class, "LaserAmplifier"); + GameRegistry.registerTileEntity( + TileEntityLaserTractorBeam.class, "LaserTractorBeam" + ); + GameRegistry.registerTileEntity( + TileEntitySolarNeutronActivator.class, "SolarNeutronActivator" + ); + GameRegistry.registerTileEntity( + TileEntityAmbientAccumulator.class, "AmbientAccumulator" + ); + GameRegistry.registerTileEntity( + TileEntityInductionCasing.class, "InductionCasing" + ); + GameRegistry.registerTileEntity(TileEntityInductionPort.class, "InductionPort"); + GameRegistry.registerTileEntity(TileEntityInductionCell.class, "InductionCell"); + GameRegistry.registerTileEntity( + TileEntityInductionProvider.class, "InductionProvider" + ); + GameRegistry.registerTileEntity( + TileEntityOredictionificator.class, "Oredictionificator" + ); + GameRegistry.registerTileEntity( + TileEntityStructuralGlass.class, "StructuralGlass" + ); + GameRegistry.registerTileEntity( + TileEntityFormulaicAssemblicator.class, "FormulaicAssemblicator" + ); + GameRegistry.registerTileEntity( + TileEntityResistiveHeater.class, "ResistiveHeater" + ); + GameRegistry.registerTileEntity(TileEntityBoilerCasing.class, "BoilerCasing"); + GameRegistry.registerTileEntity(TileEntityBoilerValve.class, "BoilerValve"); + GameRegistry.registerTileEntity(TileEntitySecurityDesk.class, "SecurityDesk"); + GameRegistry.registerTileEntity( + TileEntityQuantumEntangloporter.class, "QuantumEntangloporter" + ); + GameRegistry.registerTileEntity(TileEntityFuelwoodHeater.class, "FuelwoodHeater"); + GameRegistry.registerTileEntity( + TileEntityTheoreticalElementizer.class, "TheoreticalElementizer" + ); + } - /** - * Handles an PERSONAL_CHEST_CLIENT_OPEN packet via the proxy, not handled on the server-side. - * @param entityplayer - player the packet was sent from - * @param id - the gui ID to open - * @param windowId - the container-specific window ID - * @param isBlock - if the chest is a block - * @param x - x coordinate - * @param y - y coordinate - * @param z - z coordinate - */ - public void openPersonalChest(EntityPlayer entityplayer, int id, int windowId, boolean isBlock, int x, int y, int z) {} + public void handleTeleporterUpdate(PortableTeleporterMessage message) {} - /** - * Register and load client-only render information. - */ - public void registerRenderInformation() {} + /** + * Handles an PERSONAL_CHEST_CLIENT_OPEN packet via the proxy, not handled on the + * server-side. + * @param entityplayer - player the packet was sent from + * @param id - the gui ID to open + * @param windowId - the container-specific window ID + * @param isBlock - if the chest is a block + * @param x - x coordinate + * @param y - y coordinate + * @param z - z coordinate + */ + public void openPersonalChest( + EntityPlayer entityplayer, + int id, + int windowId, + boolean isBlock, + int x, + int y, + int z + ) {} - /** - * Gets the armor index number from ClientProxy. - * @param string - armor indicator - * @return armor index number - */ - public int getArmorIndex(String string) - { - return 0; - } + /** + * Register and load client-only render information. + */ + public void registerRenderInformation() {} - /** - * Set and load the mod's common configuration properties. - */ - public void loadConfiguration() - { - general.updateNotifications = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "UpdateNotificationsv2", true).getBoolean(); - general.controlCircuitOreDict = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ControlCircuitOreDict", true).getBoolean(); - general.logPackets = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "LogPackets", false).getBoolean(); - general.dynamicTankEasterEgg = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "DynamicTankEasterEgg", false).getBoolean(); - general.voiceServerEnabled = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "VoiceServerEnabled", false).getBoolean(); - general.cardboardSpawners = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "AllowSpawnerBoxPickup", true).getBoolean(); - general.enableWorldRegeneration = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EnableWorldRegeneration", false).getBoolean(); - general.spawnBabySkeletons = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "SpawnBabySkeletons", true).getBoolean(); - general.obsidianTNTDelay = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ObsidianTNTDelay", 100).getInt(); - general.obsidianTNTBlastRadius = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ObsidianTNTBlastRadius", 12).getInt(); - general.UPDATE_DELAY = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ClientUpdateDelay", 10).getInt(); - general.osmiumPerChunk = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "OsmiumPerChunk", 12).getInt(); - general.copperPerChunk = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "CopperPerChunk", 16).getInt(); - general.tinPerChunk = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "TinPerChunk", 14).getInt(); - general.saltPerChunk = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "SaltPerChunk", 2).getInt(); - general.userWorldGenVersion = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "WorldRegenVersion", 0).getInt(); - general.FROM_IC2 = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "JoulesToEU", 10D).getDouble(); - general.TO_IC2 = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EUToJoules", .1D).getDouble(); - general.FROM_TE = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "JoulesToRF", 2.5D).getDouble(); - general.TO_TE = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "RFToJoules", 0.4D).getDouble(); - general.FROM_H2 = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "HydrogenEnergyDensity", 200D, "Determines Electrolytic Separator usage").getDouble(); - general.ETHENE_BURN_TIME = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EthyleneBurnTime", 40).getInt(); - general.METHANE_BURN_TIME = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "MethaneBurnTime", 10).getInt(); - general.ENERGY_PER_REDSTONE = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EnergyPerRedstone", 10000D).getDouble(); - general.DISASSEMBLER_USAGE = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "DisassemblerEnergyUsage", 10).getInt(); - general.VOICE_PORT = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "VoicePort", 36123, null, 1, 65535).getInt(); - //If this is less than 1, upgrades make machines worse. If less than 0, I don't even know. - general.maxUpgradeMultiplier = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "UpgradeModifier", 10, null, 1, Integer.MAX_VALUE).getInt(); - general.minerSilkMultiplier = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "MinerSilkMultiplier", 6).getDouble(); - general.prefilledFluidTanks = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "PrefilledFluidTanks", true).getBoolean(); - general.prefilledGasTanks = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "PrefilledGasTanks", true).getBoolean(); - general.armoredJetpackDamageRatio = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ArmoredJetpackDamageRatio", 0.8).getDouble(); - general.armoredJetpackDamageMax = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ArmoredJepackDamageMax", 115).getInt(); - general.aestheticWorldDamage = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "AestheticWorldDamage", true).getBoolean(); - general.opsBypassRestrictions = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "OpsBypassRestrictions", false).getBoolean(); - general.thermalEvaporationSpeed = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "ThermalEvaporationSpeed", 1.0D).getDouble(); - general.maxJetpackGas = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "MaxJetpackGas", 24000).getInt(); - general.maxScubaGas = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "MaxScubaGas", 24000).getInt(); - general.maxFlamethrowerGas = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "MaxFlamethrowerGas", 24000).getInt(); - general.maxPumpRange = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "MaxPumpRange", 80).getInt(); - general.pumpWaterSources = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "PumpWaterSources", false).getBoolean(); - general.maxPlenisherNodes = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "MaxPlenisherNodes", 4000).getInt(); - general.evaporationHeatDissipation = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EvaporationHeatDissipation", 0.02D).getDouble(); - general.evaporationTempMultiplier = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EvaporationTempMultiplier", 0.1D).getDouble(); - general.evaporationSolarMultiplier = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EvaporationSolarMultiplier", 0.2D).getDouble(); - general.evaporationMaxTemp = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EvaporationMaxTemp", 3000D).getDouble(); - general.energyPerHeat = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EnergyPerHeat", 1000D).getDouble(); - general.maxEnergyPerSteam = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "MaxEnergyPerSteam", 100D).getDouble(); - general.superheatingHeatTransfer = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "SuperheatingHeatTransfer", 10000D).getDouble(); - general.heatPerFuelTick = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "HeatPerFuelTick", 4D).getDouble(); - general.allowTransmitterAlloyUpgrade = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "AllowTransmitterAlloyUpgrade", true).getBoolean(); - general.allowProtection = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "AllowProtection", true).getBoolean(); - - general.blacklistIC2 = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "BlacklistIC2Power", false).getBoolean(); - general.blacklistRF = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "BlacklistRFPower", false).getBoolean(); + /** + * Gets the armor index number from ClientProxy. + * @param string - armor indicator + * @return armor index number + */ + public int getArmorIndex(String string) { + return 0; + } - general.EnableQuartzCompat = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EnableQuartzCompat", true).getBoolean(); - general.EnableDiamondCompat = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EnableDiamondCompat", true).getBoolean(); - general.EnablePoorOresCompat = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EnablePoorOresCompat", true).getBoolean(); - general.OreDictOsmium = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "OreDictOsmium", true).getBoolean(); - general.OreDictPlatinum = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "OreDictPlatinum", false).getBoolean(); - - String s = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "EnergyType", "J", null, new String[]{"J", "RF", "MJ", "EU"}).getString(); + /** + * Set and load the mod's common configuration properties. + */ + public void loadConfiguration() { + general.updateNotifications + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "UpdateNotificationsv2", true) + .getBoolean(); + general.controlCircuitOreDict + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "ControlCircuitOreDict", true) + .getBoolean(); + general.logPackets = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "LogPackets", false) + .getBoolean(); + general.dynamicTankEasterEgg + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "DynamicTankEasterEgg", false) + .getBoolean(); + general.voiceServerEnabled + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "VoiceServerEnabled", false) + .getBoolean(); + general.cardboardSpawners + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "AllowSpawnerBoxPickup", true) + .getBoolean(); + general.enableWorldRegeneration + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "EnableWorldRegeneration", false) + .getBoolean(); + general.spawnBabySkeletons + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "SpawnBabySkeletons", true) + .getBoolean(); + general.obsidianTNTDelay + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "ObsidianTNTDelay", 100) + .getInt(); + general.obsidianTNTBlastRadius + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "ObsidianTNTBlastRadius", 12) + .getInt(); + general.UPDATE_DELAY + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "ClientUpdateDelay", 10) + .getInt(); + general.osmiumPerChunk + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "OsmiumPerChunk", 12) + .getInt(); + general.copperPerChunk + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "CopperPerChunk", 16) + .getInt(); + general.tinPerChunk = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "TinPerChunk", 14) + .getInt(); + general.saltPerChunk = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "SaltPerChunk", 2) + .getInt(); + general.userWorldGenVersion + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "WorldRegenVersion", 0) + .getInt(); + general.FROM_IC2 = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "JoulesToEU", 10D) + .getDouble(); + general.TO_IC2 = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "EUToJoules", .1D) + .getDouble(); + general.FROM_TE = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "JoulesToRF", 2.5D) + .getDouble(); + general.TO_TE = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "RFToJoules", 0.4D) + .getDouble(); + general.FROM_H2 = Mekanism.configuration + .get( + Configuration.CATEGORY_GENERAL, + "HydrogenEnergyDensity", + 200D, + "Determines Electrolytic Separator usage" + ) + .getDouble(); + general.ETHENE_BURN_TIME + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "EthyleneBurnTime", 40) + .getInt(); + general.METHANE_BURN_TIME + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "MethaneBurnTime", 10) + .getInt(); + general.ENERGY_PER_REDSTONE + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "EnergyPerRedstone", 10000D) + .getDouble(); + general.DISASSEMBLER_USAGE + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "DisassemblerEnergyUsage", 10) + .getInt(); + general.VOICE_PORT + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "VoicePort", 36123, null, 1, 65535) + .getInt(); + //If this is less than 1, upgrades make machines worse. If less than 0, I don't + //even know. + general.maxUpgradeMultiplier = Mekanism.configuration + .get( + Configuration.CATEGORY_GENERAL, + "UpgradeModifier", + 10, + null, + 1, + Integer.MAX_VALUE + ) + .getInt(); + general.minerSilkMultiplier + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "MinerSilkMultiplier", 6) + .getDouble(); + general.prefilledFluidTanks + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "PrefilledFluidTanks", true) + .getBoolean(); + general.prefilledGasTanks + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "PrefilledGasTanks", true) + .getBoolean(); + general.armoredJetpackDamageRatio + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "ArmoredJetpackDamageRatio", 0.8) + .getDouble(); + general.armoredJetpackDamageMax + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "ArmoredJepackDamageMax", 115) + .getInt(); + general.aestheticWorldDamage + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "AestheticWorldDamage", true) + .getBoolean(); + general.opsBypassRestrictions + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "OpsBypassRestrictions", false) + .getBoolean(); + general.thermalEvaporationSpeed + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "ThermalEvaporationSpeed", 1.0D) + .getDouble(); + general.maxJetpackGas + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "MaxJetpackGas", 24000) + .getInt(); + general.maxScubaGas + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "MaxScubaGas", 24000) + .getInt(); + general.maxFlamethrowerGas + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "MaxFlamethrowerGas", 24000) + .getInt(); + general.maxPumpRange + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "MaxPumpRange", 80) + .getInt(); + general.pumpWaterSources + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "PumpWaterSources", false) + .getBoolean(); + general.maxPlenisherNodes + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "MaxPlenisherNodes", 4000) + .getInt(); + general.evaporationHeatDissipation + = Mekanism.configuration + .get( + Configuration.CATEGORY_GENERAL, "EvaporationHeatDissipation", 0.02D + ) + .getDouble(); + general.evaporationTempMultiplier + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "EvaporationTempMultiplier", 0.1D) + .getDouble(); + general.evaporationSolarMultiplier + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "EvaporationSolarMultiplier", 0.2D) + .getDouble(); + general.evaporationMaxTemp + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "EvaporationMaxTemp", 3000D) + .getDouble(); + general.energyPerHeat + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "EnergyPerHeat", 1000D) + .getDouble(); + general.maxEnergyPerSteam + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "MaxEnergyPerSteam", 100D) + .getDouble(); + general.superheatingHeatTransfer + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "SuperheatingHeatTransfer", 10000D) + .getDouble(); + general.heatPerFuelTick + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "HeatPerFuelTick", 4D) + .getDouble(); + general.allowTransmitterAlloyUpgrade + = Mekanism.configuration + .get( + Configuration.CATEGORY_GENERAL, "AllowTransmitterAlloyUpgrade", true + ) + .getBoolean(); + general.allowProtection + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "AllowProtection", true) + .getBoolean(); - if(s != null) - { - if(s.trim().equalsIgnoreCase("j") || s.trim().equalsIgnoreCase("joules")) - { - general.energyUnit = EnergyType.J; - } + general.blacklistIC2 + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "BlacklistIC2Power", false) + .getBoolean(); + general.blacklistRF + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "BlacklistRFPower", false) + .getBoolean(); + + general.EnableQuartzCompat + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "EnableQuartzCompat", true) + .getBoolean(); + general.EnableDiamondCompat + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "EnableDiamondCompat", true) + .getBoolean(); + general.EnablePoorOresCompat + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "EnablePoorOresCompat", true) + .getBoolean(); + general.OreDictOsmium + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "OreDictOsmium", true) + .getBoolean(); + general.OreDictPlatinum + = Mekanism.configuration + .get(Configuration.CATEGORY_GENERAL, "OreDictPlatinum", false) + .getBoolean(); + + String s = Mekanism.configuration + .get( + Configuration.CATEGORY_GENERAL, + "EnergyType", + "J", + null, + new String[] { "J", "RF", "MJ", "EU" } + ) + .getString(); + + if (s != null) { + if (s.trim().equalsIgnoreCase("j") || s.trim().equalsIgnoreCase("joules")) { + general.energyUnit = EnergyType.J; + } else if(s.trim().equalsIgnoreCase("rf") || s.trim().equalsIgnoreCase("te") || s.trim().equalsIgnoreCase("thermal expansion")) { - general.energyUnit = EnergyType.RF; - } - else if(s.trim().equalsIgnoreCase("eu") || s.trim().equalsIgnoreCase("ic2")) - { - general.energyUnit = EnergyType.EU; - } + general.energyUnit = EnergyType.RF; + } else if (s.trim().equalsIgnoreCase("eu") || s.trim().equalsIgnoreCase("ic2")) { + general.energyUnit = EnergyType.EU; + } else if(s.trim().equalsIgnoreCase("mj") || s.trim().equalsIgnoreCase("bc") || s.trim().equalsIgnoreCase("buildcraft")) { - general.energyUnit = EnergyType.MJ; - } - } + general.energyUnit = EnergyType.MJ; + } + } - s = Mekanism.configuration.get(Configuration.CATEGORY_GENERAL, "Temperature Units", "K", null, new String[]{"K", "C", "R", "F"}).getString(); + s = Mekanism.configuration + .get( + Configuration.CATEGORY_GENERAL, + "Temperature Units", + "K", + null, + new String[] { "K", "C", "R", "F" } + ) + .getString(); - if(s != null) - { - if(s.trim().equalsIgnoreCase("k") || s.trim().equalsIgnoreCase("kelvin")) - { - general.tempUnit = TempType.K; - } + if (s != null) { + if (s.trim().equalsIgnoreCase("k") || s.trim().equalsIgnoreCase("kelvin")) { + general.tempUnit = TempType.K; + } else if(s.trim().equalsIgnoreCase("c") || s.trim().equalsIgnoreCase("celsius") || s.trim().equalsIgnoreCase("centigrade")) { - general.tempUnit = TempType.C; - } - else if(s.trim().equalsIgnoreCase("r") || s.trim().equalsIgnoreCase("rankine")) - { - general.tempUnit = TempType.R; - } - else if(s.trim().equalsIgnoreCase("f") || s.trim().equalsIgnoreCase("fahrenheit")) - { - general.tempUnit = TempType.F; - } + general.tempUnit = TempType.C; + } else if (s.trim().equalsIgnoreCase("r") || s.trim().equalsIgnoreCase("rankine")) { + general.tempUnit = TempType.R; + } else if (s.trim().equalsIgnoreCase("f") || s.trim().equalsIgnoreCase("fahrenheit")) { + general.tempUnit = TempType.F; + } else if(s.trim().equalsIgnoreCase("a") || s.trim().equalsIgnoreCase("ambient") || s.trim().equalsIgnoreCase("stp")) { - general.tempUnit = TempType.STP; - } - } + general.tempUnit = TempType.STP; + } + } - general.laserRange = Mekanism.configuration.get("general", "LaserRange", 64).getInt(); - general.laserEnergyNeededPerHardness = Mekanism.configuration.get("general", "LaserDiggingEnergy", 100000).getInt(); - general.destroyDisabledBlocks = Mekanism.configuration.get("general", "DestroyDisabledBlocks", true).getBoolean(); - general.elementizerFailChanceMultiplier = Mekanism.configuration.get("general", "ElementizerFailChanceMultiplier", 1).getInt(); + general.laserRange + = Mekanism.configuration.get("general", "LaserRange", 64).getInt(); + general.laserEnergyNeededPerHardness + = Mekanism.configuration.get("general", "LaserDiggingEnergy", 100000) + .getInt(); + general.destroyDisabledBlocks + = Mekanism.configuration.get("general", "DestroyDisabledBlocks", true) + .getBoolean(); + general.elementizerFailChanceMultiplier + = Mekanism.configuration.get("general", "ElementizerFailChanceMultiplier", 1) + .getInt(); - - for(MachineType type : MachineType.getValidMachines()) - { - machines.setEntry(type.name, Mekanism.configuration.get("machines", type.name + "Enabled", true).getBoolean()); - } - - usage.enrichmentChamberUsage = Mekanism.configuration.get("usage", "EnrichmentChamberUsage", 50D).getDouble(); - usage.osmiumCompressorUsage = Mekanism.configuration.get("usage", "OsmiumCompressorUsage", 100D).getDouble(); - usage.combinerUsage = Mekanism.configuration.get("usage", "CombinerUsage", 50D).getDouble(); - usage.crusherUsage = Mekanism.configuration.get("usage", "CrusherUsage", 50D).getDouble(); - usage.factoryUsage = Mekanism.configuration.get("usage", "FactoryUsage", 50D).getDouble(); - usage.metallurgicInfuserUsage = Mekanism.configuration.get("usage", "MetallurgicInfuserUsage", 50D).getDouble(); - usage.purificationChamberUsage = Mekanism.configuration.get("usage", "PurificationChamberUsage", 200D).getDouble(); - usage.energizedSmelterUsage = Mekanism.configuration.get("usage", "EnergizedSmelterUsage", 50D).getDouble(); - usage.digitalMinerUsage = Mekanism.configuration.get("usage", "DigitalMinerUsage", 100D).getDouble(); - usage.electricPumpUsage = Mekanism.configuration.get("usage", "ElectricPumpUsage", 100D).getDouble(); - usage.rotaryCondensentratorUsage = Mekanism.configuration.get("usage", "RotaryCondensentratorUsage", 50D).getDouble(); - usage.oxidationChamberUsage = Mekanism.configuration.get("usage", "OxidationChamberUsage", 200D).getDouble(); - usage.chemicalInfuserUsage = Mekanism.configuration.get("usage", "ChemicalInfuserUsage", 200D).getDouble(); - usage.chemicalInjectionChamberUsage = Mekanism.configuration.get("usage", "ChemicalInjectionChamberUsage", 400D).getDouble(); - usage.precisionSawmillUsage = Mekanism.configuration.get("usage", "PrecisionSawmillUsage", 50D).getDouble(); - usage.chemicalDissolutionChamberUsage = Mekanism.configuration.get("usage", "ChemicalDissolutionChamberUsage", 400D).getDouble(); - usage.chemicalWasherUsage = Mekanism.configuration.get("usage", "ChemicalWasherUsage", 200D).getDouble(); - usage.chemicalCrystallizerUsage = Mekanism.configuration.get("usage", "ChemicalCrystallizerUsage", 400D).getDouble(); - usage.seismicVibratorUsage = Mekanism.configuration.get("usage", "SeismicVibratorUsage", 50D).getDouble(); - usage.pressurizedReactionBaseUsage = Mekanism.configuration.get("usage", "PressurizedReactionBaseUsage", 5D).getDouble(); - usage.fluidicPlenisherUsage = Mekanism.configuration.get("usage", "FluidicPlenisherUsage", 100D).getDouble(); - usage.laserUsage = Mekanism.configuration.get("usage", "LaserUsage", 5000D).getDouble(); - usage.gasCentrifugeUsage = Mekanism.configuration.get("usage", "GasCentrifugeUsage", 100D).getDouble(); - usage.heavyWaterElectrolysisUsage = Mekanism.configuration.get("usage", "HeavyWaterElectrolysisUsage", 800D).getDouble(); - usage.formulaicAssemblicatorUsage = Mekanism.configuration.get("usage", "FormulaicAssemblicatorUsage", 100D).getDouble(); + for (MachineType type : MachineType.getValidMachines()) { + machines.setEntry( + type.name, + Mekanism.configuration.get("machines", type.name + "Enabled", true) + .getBoolean() + ); + } - Tier.loadConfig(); - - if(Mekanism.configuration.hasChanged()) - { - Mekanism.configuration.save(); - } - } + usage.enrichmentChamberUsage + = Mekanism.configuration.get("usage", "EnrichmentChamberUsage", 50D) + .getDouble(); + usage.osmiumCompressorUsage + = Mekanism.configuration.get("usage", "OsmiumCompressorUsage", 100D) + .getDouble(); + usage.combinerUsage + = Mekanism.configuration.get("usage", "CombinerUsage", 50D).getDouble(); + usage.crusherUsage + = Mekanism.configuration.get("usage", "CrusherUsage", 50D).getDouble(); + usage.factoryUsage + = Mekanism.configuration.get("usage", "FactoryUsage", 50D).getDouble(); + usage.metallurgicInfuserUsage + = Mekanism.configuration.get("usage", "MetallurgicInfuserUsage", 50D) + .getDouble(); + usage.purificationChamberUsage + = Mekanism.configuration.get("usage", "PurificationChamberUsage", 200D) + .getDouble(); + usage.energizedSmelterUsage + = Mekanism.configuration.get("usage", "EnergizedSmelterUsage", 50D) + .getDouble(); + usage.digitalMinerUsage + = Mekanism.configuration.get("usage", "DigitalMinerUsage", 100D).getDouble(); + usage.electricPumpUsage + = Mekanism.configuration.get("usage", "ElectricPumpUsage", 100D).getDouble(); + usage.rotaryCondensentratorUsage + = Mekanism.configuration.get("usage", "RotaryCondensentratorUsage", 50D) + .getDouble(); + usage.oxidationChamberUsage + = Mekanism.configuration.get("usage", "OxidationChamberUsage", 200D) + .getDouble(); + usage.chemicalInfuserUsage + = Mekanism.configuration.get("usage", "ChemicalInfuserUsage", 200D) + .getDouble(); + usage.chemicalInjectionChamberUsage + = Mekanism.configuration.get("usage", "ChemicalInjectionChamberUsage", 400D) + .getDouble(); + usage.precisionSawmillUsage + = Mekanism.configuration.get("usage", "PrecisionSawmillUsage", 50D) + .getDouble(); + usage.chemicalDissolutionChamberUsage + = Mekanism.configuration.get("usage", "ChemicalDissolutionChamberUsage", 400D) + .getDouble(); + usage.chemicalWasherUsage + = Mekanism.configuration.get("usage", "ChemicalWasherUsage", 200D) + .getDouble(); + usage.chemicalCrystallizerUsage + = Mekanism.configuration.get("usage", "ChemicalCrystallizerUsage", 400D) + .getDouble(); + usage.seismicVibratorUsage + = Mekanism.configuration.get("usage", "SeismicVibratorUsage", 50D) + .getDouble(); + usage.pressurizedReactionBaseUsage + = Mekanism.configuration.get("usage", "PressurizedReactionBaseUsage", 5D) + .getDouble(); + usage.fluidicPlenisherUsage + = Mekanism.configuration.get("usage", "FluidicPlenisherUsage", 100D) + .getDouble(); + usage.laserUsage + = Mekanism.configuration.get("usage", "LaserUsage", 5000D).getDouble(); + usage.gasCentrifugeUsage + = Mekanism.configuration.get("usage", "GasCentrifugeUsage", 100D).getDouble(); + usage.heavyWaterElectrolysisUsage + = Mekanism.configuration.get("usage", "HeavyWaterElectrolysisUsage", 800D) + .getDouble(); + usage.formulaicAssemblicatorUsage + = Mekanism.configuration.get("usage", "FormulaicAssemblicatorUsage", 100D) + .getDouble(); - /** - * Set up and load the utilities this mod uses. - */ - public void loadUtilities() - { - FMLCommonHandler.instance().bus().register(Mekanism.worldTickHandler); - } + Tier.loadConfig(); - /** - * Whether or not the game is paused. - */ - public boolean isPaused() - { - return false; - } - - /** - * Adds block hit effects on the client side. - */ - public void addHitEffects(Coord4D coord, MovingObjectPosition mop) {} - - /** - * Does a generic creation animation, starting from the rendering block. - */ - public void doGenericSparkle(TileEntity tileEntity, INodeChecker checker) {} + if (Mekanism.configuration.hasChanged()) { + Mekanism.configuration.save(); + } + } - /** - * Does the multiblock creation animation, starting from the rendering block. - */ - public void doMultiblockSparkle(TileEntityMultiblock tileEntity) {} + /** + * Set up and load the utilities this mod uses. + */ + public void loadUtilities() { + FMLCommonHandler.instance().bus().register(Mekanism.worldTickHandler); + } - @Override - public Object getClientGui(int ID, EntityPlayer player, World world, int x, int y, int z) - { - return null; - } + /** + * Whether or not the game is paused. + */ + public boolean isPaused() { + return false; + } - @Override - public Container getServerGui(int ID, EntityPlayer player, World world, int x, int y, int z) - { - TileEntity tileEntity = world.getTileEntity(x, y, z); + /** + * Adds block hit effects on the client side. + */ + public void addHitEffects(Coord4D coord, MovingObjectPosition mop) {} - switch(ID) - { - case 0: - return new ContainerDictionary(player.inventory); - case 2: - return new ContainerDigitalMiner(player.inventory, (TileEntityDigitalMiner)tileEntity); - case 3: - return new ContainerElectricMachine(player.inventory, (TileEntityElectricMachine)tileEntity); - case 4: - return new ContainerAdvancedElectricMachine(player.inventory, (TileEntityAdvancedElectricMachine)tileEntity); - case 5: - return new ContainerAdvancedElectricMachine(player.inventory, (TileEntityAdvancedElectricMachine)tileEntity); - case 6: - return new ContainerElectricMachine(player.inventory, (TileEntityElectricMachine)tileEntity); - case 7: - return new ContainerRotaryCondensentrator(player.inventory, (TileEntityRotaryCondensentrator)tileEntity); - case 8: - return new ContainerEnergyCube(player.inventory, (TileEntityEnergyCube)tileEntity); - case 9: - return new ContainerNull(player, (TileEntityContainerBlock)tileEntity); - case 10: - return new ContainerGasTank(player.inventory, (TileEntityGasTank)tileEntity); - case 11: - return new ContainerFactory(player.inventory, (TileEntityFactory)tileEntity); - case 12: - return new ContainerMetallurgicInfuser(player.inventory, (TileEntityMetallurgicInfuser)tileEntity); - case 13: - return new ContainerTeleporter(player.inventory, (TileEntityTeleporter)tileEntity); - case 14: - ItemStack itemStack = player.getCurrentEquippedItem(); + /** + * Does a generic creation animation, starting from the rendering block. + */ + public void doGenericSparkle(TileEntity tileEntity, INodeChecker checker) {} - if(itemStack != null && itemStack.getItem() instanceof ItemPortableTeleporter) - { - return new ContainerNull(); - } - case 15: - return new ContainerAdvancedElectricMachine(player.inventory, (TileEntityAdvancedElectricMachine)tileEntity); - case 16: - return new ContainerElectricMachine(player.inventory, (TileEntityElectricMachine)tileEntity); - case 17: - return new ContainerElectricPump(player.inventory, (TileEntityElectricPump)tileEntity); - case 18: - return new ContainerDynamicTank(player.inventory, (TileEntityDynamicTank)tileEntity); - case 21: - EntityRobit robit = (EntityRobit)world.getEntityByID(x); + /** + * Does the multiblock creation animation, starting from the rendering block. + */ + public void doMultiblockSparkle(TileEntityMultiblock tileEntity) {} - if(robit != null) - { - return new ContainerRobitMain(player.inventory, robit); - } - case 22: - robit = (EntityRobit)world.getEntityByID(x); + @Override + public Object + getClientGui(int ID, EntityPlayer player, World world, int x, int y, int z) { + return null; + } - if(robit != null) - { - return new ContainerRobitCrafting(player.inventory, robit); - } - case 23: - robit = (EntityRobit)world.getEntityByID(x); + @Override + public Container + getServerGui(int ID, EntityPlayer player, World world, int x, int y, int z) { + TileEntity tileEntity = world.getTileEntity(x, y, z); - if(robit != null) - { - return new ContainerRobitInventory(player.inventory, robit); - } - case 24: - robit = (EntityRobit)world.getEntityByID(x); + switch (ID) { + case 0: + return new ContainerDictionary(player.inventory); + case 2: + return new ContainerDigitalMiner( + player.inventory, (TileEntityDigitalMiner) tileEntity + ); + case 3: + return new ContainerElectricMachine( + player.inventory, (TileEntityElectricMachine) tileEntity + ); + case 4: + return new ContainerAdvancedElectricMachine( + player.inventory, (TileEntityAdvancedElectricMachine) tileEntity + ); + case 5: + return new ContainerAdvancedElectricMachine( + player.inventory, (TileEntityAdvancedElectricMachine) tileEntity + ); + case 6: + return new ContainerElectricMachine( + player.inventory, (TileEntityElectricMachine) tileEntity + ); + case 7: + return new ContainerRotaryCondensentrator( + player.inventory, (TileEntityRotaryCondensentrator) tileEntity + ); + case 8: + return new ContainerEnergyCube( + player.inventory, (TileEntityEnergyCube) tileEntity + ); + case 9: + return new ContainerNull(player, (TileEntityContainerBlock) tileEntity); + case 10: + return new ContainerGasTank( + player.inventory, (TileEntityGasTank) tileEntity + ); + case 11: + return new ContainerFactory( + player.inventory, (TileEntityFactory) tileEntity + ); + case 12: + return new ContainerMetallurgicInfuser( + player.inventory, (TileEntityMetallurgicInfuser) tileEntity + ); + case 13: + return new ContainerTeleporter( + player.inventory, (TileEntityTeleporter) tileEntity + ); + case 14: + ItemStack itemStack = player.getCurrentEquippedItem(); - if(robit != null) - { - return new ContainerRobitSmelting(player.inventory, robit); - } - case 25: - robit = (EntityRobit)world.getEntityByID(x); + if (itemStack != null + && itemStack.getItem() instanceof ItemPortableTeleporter) { + return new ContainerNull(); + } + case 15: + return new ContainerAdvancedElectricMachine( + player.inventory, (TileEntityAdvancedElectricMachine) tileEntity + ); + case 16: + return new ContainerElectricMachine( + player.inventory, (TileEntityElectricMachine) tileEntity + ); + case 17: + return new ContainerElectricPump( + player.inventory, (TileEntityElectricPump) tileEntity + ); + case 18: + return new ContainerDynamicTank( + player.inventory, (TileEntityDynamicTank) tileEntity + ); + case 21: + EntityRobit robit = (EntityRobit) world.getEntityByID(x); - if(robit != null) - { - return new ContainerRobitRepair(player.inventory, robit); - } - case 26: - return new ContainerNull(player, (TileEntityContainerBlock)tileEntity); - case 27: - return new ContainerFilter(player.inventory, (TileEntityContainerBlock)tileEntity); - case 28: - return new ContainerFilter(player.inventory, (TileEntityContainerBlock)tileEntity); - case 29: - return new ContainerChemicalOxidizer(player.inventory, (TileEntityChemicalOxidizer)tileEntity); - case 30: - return new ContainerChemicalInfuser(player.inventory, (TileEntityChemicalInfuser)tileEntity); - case 31: - return new ContainerAdvancedElectricMachine(player.inventory, (TileEntityAdvancedElectricMachine)tileEntity); - case 32: - return new ContainerElectrolyticSeparator(player.inventory, (TileEntityElectrolyticSeparator)tileEntity); - case 33: - return new ContainerThermalEvaporationController(player.inventory, (TileEntityThermalEvaporationController)tileEntity); - case 34: - return new ContainerChanceMachine(player.inventory, (TileEntityChanceMachine)tileEntity); - case 35: - return new ContainerChemicalDissolutionChamber(player.inventory, (TileEntityChemicalDissolutionChamber)tileEntity); - case 36: - return new ContainerChemicalWasher(player.inventory, (TileEntityChemicalWasher)tileEntity); - case 37: - return new ContainerChemicalCrystallizer(player.inventory, (TileEntityChemicalCrystallizer)tileEntity); - case 39: - return new ContainerSeismicVibrator(player.inventory, (TileEntitySeismicVibrator)tileEntity); - case 40: - return new ContainerPRC(player.inventory, (TileEntityPRC)tileEntity); - case 41: - return new ContainerFluidTank(player.inventory, (TileEntityFluidTank)tileEntity); - case 42: - return new ContainerFluidicPlenisher(player.inventory, (TileEntityFluidicPlenisher)tileEntity); - case 43: - return new ContainerUpgradeManagement(player.inventory, (IUpgradeTile)tileEntity); - case 44: - return new ContainerLaserAmplifier(player.inventory, (TileEntityLaserAmplifier)tileEntity); - case 45: - return new ContainerLaserTractorBeam(player.inventory, (TileEntityLaserTractorBeam)tileEntity); - case 46: - return new ContainerQuantumEntangloporter(player.inventory, (TileEntityQuantumEntangloporter)tileEntity); - case 47: - return new ContainerSolarNeutronActivator(player.inventory, (TileEntitySolarNeutronActivator)tileEntity); - case 48: - return new ContainerNull(player, (TileEntityContainerBlock)tileEntity); - case 49: - return new ContainerInductionMatrix(player.inventory, (TileEntityInductionCasing)tileEntity); - case 50: - return new ContainerNull(player, (TileEntityContainerBlock)tileEntity); - case 51: - return new ContainerNull(player, (TileEntityContainerBlock)tileEntity); - case 52: - return new ContainerOredictionificator(player.inventory, (TileEntityOredictionificator)tileEntity); - case 53: - return new ContainerResistiveHeater(player.inventory, (TileEntityResistiveHeater)tileEntity); - case 54: - return new ContainerFilter(player.inventory, (TileEntityContainerBlock)tileEntity); - case 55: - return new ContainerNull(player, (TileEntityContainerBlock)tileEntity); - case 56: - return new ContainerFormulaicAssemblicator(player.inventory, (TileEntityFormulaicAssemblicator)tileEntity); - case 57: - return new ContainerSecurityDesk(player.inventory, (TileEntitySecurityDesk)tileEntity); - case 58: - return new ContainerFuelwoodHeater(player.inventory, (TileEntityFuelwoodHeater)tileEntity); - case 60: - return new ContainerAdvancedElectricMachine(player.inventory, (TileEntityTheoreticalElementizer)tileEntity); - } + if (robit != null) { + return new ContainerRobitMain(player.inventory, robit); + } + case 22: + robit = (EntityRobit) world.getEntityByID(x); - return null; - } + if (robit != null) { + return new ContainerRobitCrafting(player.inventory, robit); + } + case 23: + robit = (EntityRobit) world.getEntityByID(x); - public void preInit() {} + if (robit != null) { + return new ContainerRobitInventory(player.inventory, robit); + } + case 24: + robit = (EntityRobit) world.getEntityByID(x); - public double getReach(EntityPlayer player) - { - if(player instanceof EntityPlayerMP) - { - return ((EntityPlayerMP)player).theItemInWorldManager.getBlockReachDistance(); - } + if (robit != null) { + return new ContainerRobitSmelting(player.inventory, robit); + } + case 25: + robit = (EntityRobit) world.getEntityByID(x); - return 0; - } + if (robit != null) { + return new ContainerRobitRepair(player.inventory, robit); + } + case 26: + return new ContainerNull(player, (TileEntityContainerBlock) tileEntity); + case 27: + return new ContainerFilter( + player.inventory, (TileEntityContainerBlock) tileEntity + ); + case 28: + return new ContainerFilter( + player.inventory, (TileEntityContainerBlock) tileEntity + ); + case 29: + return new ContainerChemicalOxidizer( + player.inventory, (TileEntityChemicalOxidizer) tileEntity + ); + case 30: + return new ContainerChemicalInfuser( + player.inventory, (TileEntityChemicalInfuser) tileEntity + ); + case 31: + return new ContainerAdvancedElectricMachine( + player.inventory, (TileEntityAdvancedElectricMachine) tileEntity + ); + case 32: + return new ContainerElectrolyticSeparator( + player.inventory, (TileEntityElectrolyticSeparator) tileEntity + ); + case 33: + return new ContainerThermalEvaporationController( + player.inventory, (TileEntityThermalEvaporationController) tileEntity + ); + case 34: + return new ContainerChanceMachine( + player.inventory, (TileEntityChanceMachine) tileEntity + ); + case 35: + return new ContainerChemicalDissolutionChamber( + player.inventory, (TileEntityChemicalDissolutionChamber) tileEntity + ); + case 36: + return new ContainerChemicalWasher( + player.inventory, (TileEntityChemicalWasher) tileEntity + ); + case 37: + return new ContainerChemicalCrystallizer( + player.inventory, (TileEntityChemicalCrystallizer) tileEntity + ); + case 39: + return new ContainerSeismicVibrator( + player.inventory, (TileEntitySeismicVibrator) tileEntity + ); + case 40: + return new ContainerPRC(player.inventory, (TileEntityPRC) tileEntity); + case 41: + return new ContainerFluidTank( + player.inventory, (TileEntityFluidTank) tileEntity + ); + case 42: + return new ContainerFluidicPlenisher( + player.inventory, (TileEntityFluidicPlenisher) tileEntity + ); + case 43: + return new ContainerUpgradeManagement( + player.inventory, (IUpgradeTile) tileEntity + ); + case 44: + return new ContainerLaserAmplifier( + player.inventory, (TileEntityLaserAmplifier) tileEntity + ); + case 45: + return new ContainerLaserTractorBeam( + player.inventory, (TileEntityLaserTractorBeam) tileEntity + ); + case 46: + return new ContainerQuantumEntangloporter( + player.inventory, (TileEntityQuantumEntangloporter) tileEntity + ); + case 47: + return new ContainerSolarNeutronActivator( + player.inventory, (TileEntitySolarNeutronActivator) tileEntity + ); + case 48: + return new ContainerNull(player, (TileEntityContainerBlock) tileEntity); + case 49: + return new ContainerInductionMatrix( + player.inventory, (TileEntityInductionCasing) tileEntity + ); + case 50: + return new ContainerNull(player, (TileEntityContainerBlock) tileEntity); + case 51: + return new ContainerNull(player, (TileEntityContainerBlock) tileEntity); + case 52: + return new ContainerOredictionificator( + player.inventory, (TileEntityOredictionificator) tileEntity + ); + case 53: + return new ContainerResistiveHeater( + player.inventory, (TileEntityResistiveHeater) tileEntity + ); + case 54: + return new ContainerFilter( + player.inventory, (TileEntityContainerBlock) tileEntity + ); + case 55: + return new ContainerNull(player, (TileEntityContainerBlock) tileEntity); + case 56: + return new ContainerFormulaicAssemblicator( + player.inventory, (TileEntityFormulaicAssemblicator) tileEntity + ); + case 57: + return new ContainerSecurityDesk( + player.inventory, (TileEntitySecurityDesk) tileEntity + ); + case 58: + return new ContainerFuelwoodHeater( + player.inventory, (TileEntityFuelwoodHeater) tileEntity + ); + case 60: + return new ContainerAdvancedElectricMachine( + player.inventory, (TileEntityTheoreticalElementizer) tileEntity + ); + } - /** - * Gets the Minecraft base directory. - * @return base directory - */ - public File getMinecraftDir() - { - return (File)FMLInjectionData.data()[6]; - } - - public void updateConfigRecipes() - { - for(MachineType type : MachineType.getValidMachines()) - { - if(machines.isEnabled(type.name)) - { - CraftingManager.getInstance().getRecipeList().removeAll(type.getRecipes()); - CraftingManager.getInstance().getRecipeList().addAll(type.getRecipes()); - } - else { - CraftingManager.getInstance().getRecipeList().removeAll(type.getRecipes()); - } - } - } + return null; + } - public void onConfigSync(boolean fromPacket) - { - if(general.cardboardSpawners) - { - MekanismAPI.removeBoxBlacklist(Blocks.mob_spawner, 0); - } - else { - MekanismAPI.addBoxBlacklist(Blocks.mob_spawner, 0); - } - - MachineType.updateAllUsages(); - - updateConfigRecipes(); + public void preInit() {} - if(fromPacket) - { - Mekanism.logger.info("Received config from server."); - } - } - - private WeakReference createNewPlayer(WorldServer world) - { - EntityPlayer player = FakePlayerFactory.get(world, Mekanism.gameProfile); + public double getReach(EntityPlayer player) { + if (player instanceof EntityPlayerMP) { + return ((EntityPlayerMP) player) + .theItemInWorldManager.getBlockReachDistance(); + } - return new WeakReference(player); - } + return 0; + } - private WeakReference createNewPlayer(WorldServer world, double x, double y, double z) - { - EntityPlayer player = FakePlayerFactory.get(world, Mekanism.gameProfile); - - player.posX = x; - player.posY = y; - player.posZ = z; - - return new WeakReference(player); - } + /** + * Gets the Minecraft base directory. + * @return base directory + */ + public File getMinecraftDir() { + return (File) FMLInjectionData.data()[6]; + } - public final WeakReference getDummyPlayer(WorldServer world) - { - if(dummyPlayer.get() == null) - { - dummyPlayer = createNewPlayer(world); - } - else { - dummyPlayer.get().worldObj = world; - } + public void updateConfigRecipes() { + for (MachineType type : MachineType.getValidMachines()) { + if (machines.isEnabled(type.name)) { + CraftingManager.getInstance().getRecipeList().removeAll(type.getRecipes() + ); + CraftingManager.getInstance().getRecipeList().addAll(type.getRecipes()); + } else { + CraftingManager.getInstance().getRecipeList().removeAll(type.getRecipes() + ); + } + } + } - return dummyPlayer; - } + public void onConfigSync(boolean fromPacket) { + if (general.cardboardSpawners) { + MekanismAPI.removeBoxBlacklist(Blocks.mob_spawner, 0); + } else { + MekanismAPI.addBoxBlacklist(Blocks.mob_spawner, 0); + } - public final WeakReference getDummyPlayer(WorldServer world, double x, double y, double z) - { - if(dummyPlayer.get() == null) - { - dummyPlayer = createNewPlayer(world, x, y, z); - } - else { - dummyPlayer.get().worldObj = world; - dummyPlayer.get().posX = x; - dummyPlayer.get().posY = y; - dummyPlayer.get().posZ = z; - } + MachineType.updateAllUsages(); - return dummyPlayer; - } + updateConfigRecipes(); - public EntityPlayer getPlayer(MessageContext context) - { - return context.getServerHandler().playerEntity; - } - - public int getGuiId(Block block, int metadata) - { - if(MachineType.get(block, metadata) != null) - { - return MachineType.get(block, metadata).guiId; - } - else if(block == MekanismBlocks.GasTank) - { - return 10; - } - else if(block == MekanismBlocks.EnergyCube) - { - return 8; - } - - return -1; - } + if (fromPacket) { + Mekanism.logger.info("Received config from server."); + } + } - public void renderLaser(World world, Pos3D from, Pos3D to, ForgeDirection direction, double energy) {} - - public Object getFontRenderer() - { - return null; - } + private WeakReference createNewPlayer(WorldServer world) { + EntityPlayer player = FakePlayerFactory.get(world, Mekanism.gameProfile); - public void Cape() { - } + return new WeakReference(player); + } + + private WeakReference + createNewPlayer(WorldServer world, double x, double y, double z) { + EntityPlayer player = FakePlayerFactory.get(world, Mekanism.gameProfile); + + player.posX = x; + player.posY = y; + player.posZ = z; + + return new WeakReference(player); + } + + public final WeakReference getDummyPlayer(WorldServer world) { + if (dummyPlayer.get() == null) { + dummyPlayer = createNewPlayer(world); + } else { + dummyPlayer.get().worldObj = world; + } + + return dummyPlayer; + } + + public final WeakReference + getDummyPlayer(WorldServer world, double x, double y, double z) { + if (dummyPlayer.get() == null) { + dummyPlayer = createNewPlayer(world, x, y, z); + } else { + dummyPlayer.get().worldObj = world; + dummyPlayer.get().posX = x; + dummyPlayer.get().posY = y; + dummyPlayer.get().posZ = z; + } + + return dummyPlayer; + } + + public EntityPlayer getPlayer(MessageContext context) { + return context.getServerHandler().playerEntity; + } + + public int getGuiId(Block block, int metadata) { + if (MachineType.get(block, metadata) != null) { + return MachineType.get(block, metadata).guiId; + } else if (block == MekanismBlocks.GasTank) { + return 10; + } else if (block == MekanismBlocks.EnergyCube) { + return 8; + } + + return -1; + } + + public void renderLaser( + World world, Pos3D from, Pos3D to, ForgeDirection direction, double energy + ) {} + + public Object getFontRenderer() { + return null; + } + + public void Cape() {} } diff --git a/src/main/java/mekanism/common/CommonWorldTickHandler.java b/src/main/java/mekanism/common/CommonWorldTickHandler.java index 323f8857b..98c42cbbe 100644 --- a/src/main/java/mekanism/common/CommonWorldTickHandler.java +++ b/src/main/java/mekanism/common/CommonWorldTickHandler.java @@ -5,120 +5,110 @@ import java.util.LinkedList; import java.util.Queue; import java.util.Random; -import mekanism.common.frequency.FrequencyManager; -import mekanism.common.multiblock.MultiblockManager; -import net.minecraft.world.ChunkCoordIntPair; -import net.minecraft.world.World; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent.Phase; import cpw.mods.fml.common.gameevent.TickEvent.WorldTickEvent; import cpw.mods.fml.relauncher.Side; +import mekanism.common.frequency.FrequencyManager; +import mekanism.common.multiblock.MultiblockManager; +import net.minecraft.world.ChunkCoordIntPair; +import net.minecraft.world.World; -public class CommonWorldTickHandler -{ - private static final long maximumDeltaTimeNanoSecs = 16000000; // 16 milliseconds - - private HashMap> chunkRegenMap; - - public void addRegenChunk(int dimensionId, ChunkCoordIntPair chunkCoord) - { - if(chunkRegenMap == null) - { - chunkRegenMap = new HashMap>(); - } +public class CommonWorldTickHandler { + private static final long maximumDeltaTimeNanoSecs = 16000000; // 16 milliseconds - if(!chunkRegenMap.containsKey(dimensionId)) - { - LinkedList list = new LinkedList(); - list.add(chunkCoord); - chunkRegenMap.put(dimensionId, list); - } - else { - if(!chunkRegenMap.get(dimensionId).contains(chunkCoord)) - { - chunkRegenMap.get(dimensionId).add(chunkCoord); - } - } - } - - public void resetRegenChunks() - { - if(chunkRegenMap != null) - { - chunkRegenMap.clear(); - } - } - - @SubscribeEvent - public void onTick(WorldTickEvent event) - { - if(event.side == Side.SERVER) - { - if(event.phase == Phase.START) - { - tickStart(event.world); - } - else if(event.phase == Phase.END) - { - tickEnd(event.world); - } - } - } - - public void tickStart(World world) - { - if(!world.isRemote) - { - if(!FrequencyManager.loaded) - { - FrequencyManager.load(world); - } - } - } + private HashMap> chunkRegenMap; - public void tickEnd(World world) - { - if(!world.isRemote) - { - MultiblockManager.tick(world); - FrequencyManager.tick(world); - - if(chunkRegenMap == null) - { - return; - } - - int dimensionId = world.provider.dimensionId; + public void addRegenChunk(int dimensionId, ChunkCoordIntPair chunkCoord) { + if (chunkRegenMap == null) { + chunkRegenMap = new HashMap>(); + } - //Credit to E. Beef - if(chunkRegenMap.containsKey(dimensionId)) - { - Queue chunksToGen = chunkRegenMap.get(dimensionId); - long startTime = System.nanoTime(); - - while(System.nanoTime() - startTime < maximumDeltaTimeNanoSecs && !chunksToGen.isEmpty()) - { - ChunkCoordIntPair nextChunk = chunksToGen.poll(); - - if(nextChunk == null) - { - break; - } + if (!chunkRegenMap.containsKey(dimensionId)) { + LinkedList list = new LinkedList(); + list.add(chunkCoord); + chunkRegenMap.put(dimensionId, list); + } else { + if (!chunkRegenMap.get(dimensionId).contains(chunkCoord)) { + chunkRegenMap.get(dimensionId).add(chunkCoord); + } + } + } - Random fmlRandom = new Random(world.getSeed()); - long xSeed = fmlRandom.nextLong() >> 2 + 1L; - long zSeed = fmlRandom.nextLong() >> 2 + 1L; - fmlRandom.setSeed((xSeed*nextChunk.chunkXPos + zSeed*nextChunk.chunkZPos) ^ world.getSeed()); + public void resetRegenChunks() { + if (chunkRegenMap != null) { + chunkRegenMap.clear(); + } + } - Mekanism.genHandler.generate(fmlRandom, nextChunk.chunkXPos, nextChunk.chunkZPos, world, world.getChunkProvider(), world.getChunkProvider()); - Mekanism.logger.info("[Mekanism] Regenerating ores at chunk " + nextChunk); - } + @SubscribeEvent + public void onTick(WorldTickEvent event) { + if (event.side == Side.SERVER) { + if (event.phase == Phase.START) { + tickStart(event.world); + } else if (event.phase == Phase.END) { + tickEnd(event.world); + } + } + } - if(chunksToGen.isEmpty()) - { - chunkRegenMap.remove(dimensionId); - } - } - } - } + public void tickStart(World world) { + if (!world.isRemote) { + if (!FrequencyManager.loaded) { + FrequencyManager.load(world); + } + } + } + + public void tickEnd(World world) { + if (!world.isRemote) { + MultiblockManager.tick(world); + FrequencyManager.tick(world); + + if (chunkRegenMap == null) { + return; + } + + int dimensionId = world.provider.dimensionId; + + //Credit to E. Beef + if (chunkRegenMap.containsKey(dimensionId)) { + Queue chunksToGen = chunkRegenMap.get(dimensionId); + long startTime = System.nanoTime(); + + while (System.nanoTime() - startTime < maximumDeltaTimeNanoSecs + && !chunksToGen.isEmpty()) { + ChunkCoordIntPair nextChunk = chunksToGen.poll(); + + if (nextChunk == null) { + break; + } + + Random fmlRandom = new Random(world.getSeed()); + long xSeed = fmlRandom.nextLong() >> 2 + 1L; + long zSeed = fmlRandom.nextLong() >> 2 + 1L; + fmlRandom.setSeed( + (xSeed * nextChunk.chunkXPos + zSeed * nextChunk.chunkZPos) + ^ world.getSeed() + ); + + Mekanism.genHandler.generate( + fmlRandom, + nextChunk.chunkXPos, + nextChunk.chunkZPos, + world, + world.getChunkProvider(), + world.getChunkProvider() + ); + Mekanism.logger.info( + "[Mekanism] Regenerating ores at chunk " + nextChunk + ); + } + + if (chunksToGen.isEmpty()) { + chunkRegenMap.remove(dimensionId); + } + } + } + } } diff --git a/src/main/java/mekanism/common/CoreGuiHandler.java b/src/main/java/mekanism/common/CoreGuiHandler.java index fdf9f934d..798c63069 100644 --- a/src/main/java/mekanism/common/CoreGuiHandler.java +++ b/src/main/java/mekanism/common/CoreGuiHandler.java @@ -1,8 +1,8 @@ package mekanism.common; +import cpw.mods.fml.common.network.IGuiHandler; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; -import cpw.mods.fml.common.network.IGuiHandler; /** * Client and server GUI hander for Mekanism. @@ -10,17 +10,16 @@ import cpw.mods.fml.common.network.IGuiHandler; * @author AidanBrady * */ -public class CoreGuiHandler implements IGuiHandler -{ - @Override - public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) - { - return Mekanism.proxy.getServerGui(ID, player, world, x, y, z); - } +public class CoreGuiHandler implements IGuiHandler { + @Override + public Object + getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + return Mekanism.proxy.getServerGui(ID, player, world, x, y, z); + } - @Override - public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) - { - return Mekanism.proxy.getClientGui(ID, player, world, x, y, z); - } + @Override + public Object + getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + return Mekanism.proxy.getClientGui(ID, player, world, x, y, z); + } } diff --git a/src/main/java/mekanism/common/CreativeTabMekanism.java b/src/main/java/mekanism/common/CreativeTabMekanism.java index 607eb82f4..6cd2c2fda 100644 --- a/src/main/java/mekanism/common/CreativeTabMekanism.java +++ b/src/main/java/mekanism/common/CreativeTabMekanism.java @@ -4,22 +4,18 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -public class CreativeTabMekanism extends CreativeTabs -{ - public CreativeTabMekanism() - { - super("tabMekanism"); - } +public class CreativeTabMekanism extends CreativeTabs { + public CreativeTabMekanism() { + super("tabMekanism"); + } - @Override - public ItemStack getIconItemStack() - { - return new ItemStack(MekanismItems.AtomicAlloy); - } + @Override + public ItemStack getIconItemStack() { + return new ItemStack(MekanismItems.AtomicAlloy); + } - @Override - public Item getTabIconItem() - { - return MekanismItems.AtomicAlloy; - } + @Override + public Item getTabIconItem() { + return MekanismItems.AtomicAlloy; + } } diff --git a/src/main/java/mekanism/common/EnergyNetwork.java b/src/main/java/mekanism/common/EnergyNetwork.java index e9679d2ae..a947aef40 100644 --- a/src/main/java/mekanism/common/EnergyNetwork.java +++ b/src/main/java/mekanism/common/EnergyNetwork.java @@ -8,6 +8,8 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.Event; import mekanism.api.Coord4D; import mekanism.api.energy.EnergyStack; import mekanism.api.transmitters.DynamicNetwork; @@ -17,296 +19,262 @@ import mekanism.common.util.MekanismUtils; 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; -public class EnergyNetwork extends DynamicNetwork -{ - private double lastPowerScale = 0; - private double joulesTransmitted = 0; - private double jouleBufferLastTick = 0; +public class EnergyNetwork extends DynamicNetwork { + private double lastPowerScale = 0; + private double joulesTransmitted = 0; + private double jouleBufferLastTick = 0; - public double clientEnergyScale = 0; + public double clientEnergyScale = 0; - public EnergyStack buffer = new EnergyStack(0); + public EnergyStack buffer = new EnergyStack(0); - public EnergyNetwork() {} + public EnergyNetwork() {} - public EnergyNetwork(Collection networks) - { - for(EnergyNetwork net : networks) - { - if(net != null) - { - if(net.jouleBufferLastTick > jouleBufferLastTick || net.clientEnergyScale > clientEnergyScale) - { - clientEnergyScale = net.clientEnergyScale; - jouleBufferLastTick = net.jouleBufferLastTick; - joulesTransmitted = net.joulesTransmitted; - lastPowerScale = net.lastPowerScale; - } + public EnergyNetwork(Collection networks) { + for (EnergyNetwork net : networks) { + if (net != null) { + if (net.jouleBufferLastTick > jouleBufferLastTick + || net.clientEnergyScale > clientEnergyScale) { + clientEnergyScale = net.clientEnergyScale; + jouleBufferLastTick = net.jouleBufferLastTick; + joulesTransmitted = net.joulesTransmitted; + lastPowerScale = net.lastPowerScale; + } - buffer.amount += net.buffer.amount; + buffer.amount += net.buffer.amount; - adoptTransmittersAndAcceptorsFrom(net); - net.deregister(); - } - } - - register(); - } - - public static double round(double d) - { - return Math.round(d * 10000)/10000; - } - - @Override - public void absorbBuffer(IGridTransmitter transmitter) - { - EnergyStack energy = (EnergyStack)transmitter.getBuffer(); - buffer.amount += energy.amount; - energy.amount = 0; - } - - @Override - public void clampBuffer() - { - if(buffer.amount > getCapacity()) - { - buffer.amount = getCapacity(); - } - - if(buffer.amount < 0) - { - buffer.amount = 0; - } - } - - @Override - protected void updateMeanCapacity() - { - int numCables = transmitters.size(); - double reciprocalSum = 0; - - for(IGridTransmitter cable : transmitters) - { - reciprocalSum += 1.0/(double)cable.getCapacity(); + adoptTransmittersAndAcceptorsFrom(net); + net.deregister(); + } } - meanCapacity = (double)numCables / reciprocalSum; - } - - public double getEnergyNeeded() - { - if(FMLCommonHandler.instance().getEffectiveSide().isClient()) - { - return 0; - } + register(); + } - return getCapacity()-buffer.amount; - } + public static double round(double d) { + return Math.round(d * 10000) / 10000; + } - public double tickEmit(double energyToSend) - { - if(FMLCommonHandler.instance().getEffectiveSide().isClient()) - { - return 0; - } + @Override + public void + absorbBuffer(IGridTransmitter transmitter) { + EnergyStack energy = (EnergyStack) transmitter.getBuffer(); + buffer.amount += energy.amount; + energy.amount = 0; + } - double sent = 0; - boolean tryAgain; - int i = 0; + @Override + public void clampBuffer() { + if (buffer.amount > getCapacity()) { + buffer.amount = getCapacity(); + } - do { - double prev = sent; - sent += doEmit(energyToSend-sent); + if (buffer.amount < 0) { + buffer.amount = 0; + } + } - tryAgain = energyToSend-sent > 0 && sent-prev > 0 && i < 100; + @Override + protected void updateMeanCapacity() { + int numCables = transmitters.size(); + double reciprocalSum = 0; - i++; - } while(tryAgain); + for (IGridTransmitter cable : + transmitters) { + reciprocalSum += 1.0 / (double) cable.getCapacity(); + } - joulesTransmitted = sent; - - return sent; - } + meanCapacity = (double) numCables / reciprocalSum; + } - public double emit(double energyToSend, boolean doEmit) - { - double toUse = Math.min(getEnergyNeeded(), energyToSend); - - if(doEmit) - { - buffer.amount += toUse; - } - - return energyToSend-toUse; - } + public double getEnergyNeeded() { + if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { + return 0; + } - /** - * @return sent - */ - public double doEmit(double energyToSend) - { - double sent = 0; + return getCapacity() - buffer.amount; + } - List availableAcceptors = new ArrayList<>(); - availableAcceptors.addAll(getAcceptors(null)); + public double tickEmit(double energyToSend) { + if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { + return 0; + } - Collections.shuffle(availableAcceptors); + double sent = 0; + boolean tryAgain; + int i = 0; - if(!availableAcceptors.isEmpty()) - { - int divider = availableAcceptors.size(); - double remaining = energyToSend % divider; - double sending = (energyToSend-remaining)/divider; + do { + double prev = sent; + sent += doEmit(energyToSend - sent); - for(EnergyAcceptorWrapper acceptor : availableAcceptors) - { - double currentSending = sending+remaining; - EnumSet sides = acceptorDirections.get(acceptor.coord); + tryAgain = energyToSend - sent > 0 && sent - prev > 0 && i < 100; - if(sides == null || sides.isEmpty()) - { - continue; - } + i++; + } while (tryAgain); - for(ForgeDirection side : sides) - { - double prev = sent; + joulesTransmitted = sent; - sent += acceptor.transferEnergyToAcceptor(side, currentSending); + return sent; + } - if(sent > prev) - { - break; - } - } - } - } + public double emit(double energyToSend, boolean doEmit) { + double toUse = Math.min(getEnergyNeeded(), energyToSend); - return sent; - } + if (doEmit) { + buffer.amount += toUse; + } - @Override - public Set getAcceptors(Object data) - { - Set toReturn = new HashSet<>(); + return energyToSend - toUse; + } - if(FMLCommonHandler.instance().getEffectiveSide().isClient()) - { - return toReturn; - } + /** + * @return sent + */ + public double doEmit(double energyToSend) { + double sent = 0; - for(Coord4D coord : possibleAcceptors.keySet()) - { - EnumSet sides = acceptorDirections.get(coord); + List availableAcceptors = new ArrayList<>(); + availableAcceptors.addAll(getAcceptors(null)); - if(sides == null || sides.isEmpty()) - { - continue; - } + Collections.shuffle(availableAcceptors); - TileEntity tile = coord.getTileEntity(getWorld()); - EnergyAcceptorWrapper acceptor = EnergyAcceptorWrapper.get(tile); + if (!availableAcceptors.isEmpty()) { + int divider = availableAcceptors.size(); + double remaining = energyToSend % divider; + double sending = (energyToSend - remaining) / divider; - if(acceptor != null) - { - for(ForgeDirection side : sides) - { - if(acceptor.canReceiveEnergy(side) && acceptor.needsEnergy(side)) - { - toReturn.add(acceptor); - break; - } - } - } - } + for (EnergyAcceptorWrapper acceptor : availableAcceptors) { + double currentSending = sending + remaining; + EnumSet sides = acceptorDirections.get(acceptor.coord); - return toReturn; - } + if (sides == null || sides.isEmpty()) { + continue; + } - public static class EnergyTransferEvent extends Event - { - public final EnergyNetwork energyNetwork; + for (ForgeDirection side : sides) { + double prev = sent; - public final double power; + sent += acceptor.transferEnergyToAcceptor(side, currentSending); - public EnergyTransferEvent(EnergyNetwork network, double currentPower) - { - energyNetwork = network; - power = currentPower; - } - } + if (sent > prev) { + break; + } + } + } + } - @Override - public String toString() - { - return "[EnergyNetwork] " + transmitters.size() + " transmitters, " + possibleAcceptors.size() + " acceptors."; - } + return sent; + } - @Override - public void onUpdate() - { - super.onUpdate(); + @Override + public Set getAcceptors(Object data) { + Set toReturn = new HashSet<>(); - clearJoulesTransmitted(); + if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { + return toReturn; + } - double currentPowerScale = getPowerScale(); + for (Coord4D coord : possibleAcceptors.keySet()) { + EnumSet sides = acceptorDirections.get(coord); - if(FMLCommonHandler.instance().getEffectiveSide().isServer()) - { - if(Math.abs(currentPowerScale-lastPowerScale) > 0.01 || (currentPowerScale != lastPowerScale && (currentPowerScale == 0 || currentPowerScale == 1))) - { - needsUpdate = true; - } + if (sides == null || sides.isEmpty()) { + continue; + } - if(needsUpdate) - { - MinecraftForge.EVENT_BUS.post(new EnergyTransferEvent(this, currentPowerScale)); - lastPowerScale = currentPowerScale; - needsUpdate = false; - } + TileEntity tile = coord.getTileEntity(getWorld()); + EnergyAcceptorWrapper acceptor = EnergyAcceptorWrapper.get(tile); - if(buffer.amount > 0) - { - buffer.amount -= tickEmit(buffer.amount); - } - } - } + if (acceptor != null) { + for (ForgeDirection side : sides) { + if (acceptor.canReceiveEnergy(side) && acceptor.needsEnergy(side)) { + toReturn.add(acceptor); + break; + } + } + } + } - public double getPowerScale() - { - return Math.max(jouleBufferLastTick == 0 ? 0 : Math.min(Math.ceil(Math.log10(getPower())*2)/10, 1), getCapacity() == 0 ? 0 : buffer.amount/getCapacity()); - } + return toReturn; + } - public void clearJoulesTransmitted() - { - jouleBufferLastTick = buffer.amount; - joulesTransmitted = 0; - } + public static class EnergyTransferEvent extends Event { + public final EnergyNetwork energyNetwork; - public double getPower() - { - return jouleBufferLastTick * 20; - } + public final double power; - @Override - public String getNeededInfo() - { - return MekanismUtils.getEnergyDisplay(getEnergyNeeded()); - } + public EnergyTransferEvent(EnergyNetwork network, double currentPower) { + energyNetwork = network; + power = currentPower; + } + } - @Override - public String getStoredInfo() - { - return MekanismUtils.getEnergyDisplay(buffer.amount); - } + @Override + public String toString() { + return "[EnergyNetwork] " + transmitters.size() + " transmitters, " + + possibleAcceptors.size() + " acceptors."; + } - @Override - public String getFlowInfo() - { - return MekanismUtils.getEnergyDisplay(joulesTransmitted) + "/t"; - } + @Override + public void onUpdate() { + super.onUpdate(); + + clearJoulesTransmitted(); + + double currentPowerScale = getPowerScale(); + + if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { + if (Math.abs(currentPowerScale - lastPowerScale) > 0.01 + || (currentPowerScale != lastPowerScale + && (currentPowerScale == 0 || currentPowerScale == 1))) { + needsUpdate = true; + } + + if (needsUpdate) { + MinecraftForge.EVENT_BUS.post( + new EnergyTransferEvent(this, currentPowerScale) + ); + lastPowerScale = currentPowerScale; + needsUpdate = false; + } + + if (buffer.amount > 0) { + buffer.amount -= tickEmit(buffer.amount); + } + } + } + + public double getPowerScale() { + return Math.max( + jouleBufferLastTick == 0 + ? 0 + : Math.min(Math.ceil(Math.log10(getPower()) * 2) / 10, 1), + getCapacity() == 0 ? 0 : buffer.amount / getCapacity() + ); + } + + public void clearJoulesTransmitted() { + jouleBufferLastTick = buffer.amount; + joulesTransmitted = 0; + } + + public double getPower() { + return jouleBufferLastTick * 20; + } + + @Override + public String getNeededInfo() { + return MekanismUtils.getEnergyDisplay(getEnergyNeeded()); + } + + @Override + public String getStoredInfo() { + return MekanismUtils.getEnergyDisplay(buffer.amount); + } + + @Override + public String getFlowInfo() { + return MekanismUtils.getEnergyDisplay(joulesTransmitted) + "/t"; + } } diff --git a/src/main/java/mekanism/common/FluidNetwork.java b/src/main/java/mekanism/common/FluidNetwork.java index 31eb4d296..7a2ca73fa 100644 --- a/src/main/java/mekanism/common/FluidNetwork.java +++ b/src/main/java/mekanism/common/FluidNetwork.java @@ -8,6 +8,8 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.Event; import mekanism.api.Coord4D; import mekanism.api.transmitters.DynamicNetwork; import mekanism.api.transmitters.IGridTransmitter; @@ -19,345 +21,298 @@ import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidHandler; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.eventhandler.Event; -public class FluidNetwork extends DynamicNetwork -{ - public int transferDelay = 0; +public class FluidNetwork extends DynamicNetwork { + public int transferDelay = 0; - public boolean didTransfer; - public boolean prevTransfer; + public boolean didTransfer; + public boolean prevTransfer; - public float fluidScale; + public float fluidScale; - public Fluid refFluid; + public Fluid refFluid; - public FluidStack buffer; - public int prevStored; + public FluidStack buffer; + public int prevStored; - public int prevTransferAmount = 0; + public int prevTransferAmount = 0; - public FluidNetwork() {} + public FluidNetwork() {} - public FluidNetwork(Collection networks) - { - for(FluidNetwork net : networks) - { - if(net != null) - { - if(net.buffer != null) - { - if(buffer == null) - { - buffer = net.buffer.copy(); - } - else { - if(buffer.getFluid() == net.buffer.getFluid()) - { - buffer.amount += net.buffer.amount; - } - else if(net.buffer.amount > buffer.amount) - { - buffer = net.buffer.copy(); - } + public FluidNetwork(Collection networks) { + for (FluidNetwork net : networks) { + if (net != null) { + if (net.buffer != null) { + if (buffer == null) { + buffer = net.buffer.copy(); + } else { + if (buffer.getFluid() == net.buffer.getFluid()) { + buffer.amount += net.buffer.amount; + } else if (net.buffer.amount > buffer.amount) { + buffer = net.buffer.copy(); + } + } - } + net.buffer = null; + } - net.buffer = null; - } + adoptTransmittersAndAcceptorsFrom(net); + net.deregister(); + } + } - adoptTransmittersAndAcceptorsFrom(net); - net.deregister(); - } - } + fluidScale = getScale(); - fluidScale = getScale(); + register(); + } - register(); - } + @Override + public void absorbBuffer(IGridTransmitter transmitter) { + Object b = transmitter.getBuffer(); - @Override - public void absorbBuffer(IGridTransmitter transmitter) - { - Object b = transmitter.getBuffer(); + if (!(b instanceof FluidStack) || ((FluidStack) b).getFluid() == null + || ((FluidStack) b).amount == 0) { + return; + } - if(!(b instanceof FluidStack) || ((FluidStack)b).getFluid() == null || ((FluidStack)b).amount == 0) - { - return; - } + FluidStack fluid = (FluidStack) b; - FluidStack fluid = (FluidStack)b; - - if(buffer == null || buffer.getFluid() == null || buffer.amount == 0) - { - buffer = fluid.copy(); + if (buffer == null || buffer.getFluid() == null || buffer.amount == 0) { + buffer = fluid.copy(); fluid.amount = 0; - return; - } - - //TODO better multiple buffer impl - if(buffer.isFluidEqual(fluid)) - { - buffer.amount += fluid.amount; - } + return; + } + + //TODO better multiple buffer impl + if (buffer.isFluidEqual(fluid)) { + buffer.amount += fluid.amount; + } fluid.amount = 0; - } + } - @Override - public void clampBuffer() - { - if(buffer != null && buffer.amount > getCapacity()) - { - buffer.amount = capacity; - } - } + @Override + public void clampBuffer() { + if (buffer != null && buffer.amount > getCapacity()) { + buffer.amount = capacity; + } + } - @Override - protected void updateMeanCapacity() - { - int numCables = transmitters.size(); - double sum = 0; + @Override + protected void updateMeanCapacity() { + int numCables = transmitters.size(); + double sum = 0; - for(IGridTransmitter pipe : transmitters) - { - sum += pipe.getCapacity(); - } + for (IGridTransmitter pipe : transmitters) { + sum += pipe.getCapacity(); + } - meanCapacity = sum / (double)numCables; - } + meanCapacity = sum / (double) numCables; + } - public int getFluidNeeded() - { - return getCapacity()-(buffer != null ? buffer.amount : 0); - } + public int getFluidNeeded() { + return getCapacity() - (buffer != null ? buffer.amount : 0); + } - public int tickEmit(FluidStack fluidToSend, boolean doTransfer) - { - List availableAcceptors = new ArrayList<>(); - availableAcceptors.addAll(getAcceptors(fluidToSend)); + public int tickEmit(FluidStack fluidToSend, boolean doTransfer) { + List availableAcceptors = new ArrayList<>(); + availableAcceptors.addAll(getAcceptors(fluidToSend)); - Collections.shuffle(availableAcceptors); + Collections.shuffle(availableAcceptors); - int fluidSent = 0; + int fluidSent = 0; - if(!availableAcceptors.isEmpty()) - { - int divider = availableAcceptors.size(); - int remaining = fluidToSend.amount % divider; - int sending = (fluidToSend.amount-remaining)/divider; + if (!availableAcceptors.isEmpty()) { + int divider = availableAcceptors.size(); + int remaining = fluidToSend.amount % divider; + int sending = (fluidToSend.amount - remaining) / divider; - for(IFluidHandler acceptor : availableAcceptors) - { - int currentSending = sending; - EnumSet sides = acceptorDirections.get(Coord4D.get((TileEntity)acceptor)); + for (IFluidHandler acceptor : availableAcceptors) { + int currentSending = sending; + EnumSet sides + = acceptorDirections.get(Coord4D.get((TileEntity) acceptor)); - if(remaining > 0) - { - currentSending++; - remaining--; - } + if (remaining > 0) { + currentSending++; + remaining--; + } - for(ForgeDirection side : sides) - { - int prev = fluidSent; + for (ForgeDirection side : sides) { + int prev = fluidSent; - if(acceptor != null && fluidToSend != null) - { - fluidSent += acceptor.fill(side, PipeUtils.copy(fluidToSend, currentSending), doTransfer); - } + if (acceptor != null && fluidToSend != null) { + fluidSent += acceptor.fill( + side, PipeUtils.copy(fluidToSend, currentSending), doTransfer + ); + } - if(fluidSent > prev) - { - break; - } - } - } - } + if (fluidSent > prev) { + break; + } + } + } + } - if(doTransfer && fluidSent > 0 && FMLCommonHandler.instance().getEffectiveSide().isServer()) - { - didTransfer = true; - transferDelay = 2; - } + if (doTransfer && fluidSent > 0 + && FMLCommonHandler.instance().getEffectiveSide().isServer()) { + didTransfer = true; + transferDelay = 2; + } - return fluidSent; - } + return fluidSent; + } - public int emit(FluidStack fluidToSend, boolean doTransfer) - { - if(fluidToSend == null || (buffer != null && buffer.getFluid() != fluidToSend.getFluid())) - { - return 0; - } + public int emit(FluidStack fluidToSend, boolean doTransfer) { + if (fluidToSend == null + || (buffer != null && buffer.getFluid() != fluidToSend.getFluid())) { + return 0; + } - int toUse = Math.min(getFluidNeeded(), fluidToSend.amount); + int toUse = Math.min(getFluidNeeded(), fluidToSend.amount); - if(doTransfer) - { - if(buffer == null) - { - buffer = fluidToSend.copy(); - buffer.amount = toUse; - } - else { - buffer.amount += toUse; - } - } + if (doTransfer) { + if (buffer == null) { + buffer = fluidToSend.copy(); + buffer.amount = toUse; + } else { + buffer.amount += toUse; + } + } - return toUse; - } + return toUse; + } - @Override - public void onUpdate() - { - super.onUpdate(); + @Override + public void onUpdate() { + super.onUpdate(); - if(FMLCommonHandler.instance().getEffectiveSide().isServer()) - { - prevTransferAmount = 0; + if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { + prevTransferAmount = 0; - if(transferDelay == 0) - { - didTransfer = false; - } - else { - transferDelay--; - } + if (transferDelay == 0) { + didTransfer = false; + } else { + transferDelay--; + } - int stored = buffer != null ? buffer.amount : 0; + int stored = buffer != null ? buffer.amount : 0; - if(stored != prevStored) - { - needsUpdate = true; - } + if (stored != prevStored) { + needsUpdate = true; + } - prevStored = stored; + prevStored = stored; - if(didTransfer != prevTransfer || needsUpdate) - { - MinecraftForge.EVENT_BUS.post(new FluidTransferEvent(this, buffer, didTransfer)); - needsUpdate = false; - } + if (didTransfer != prevTransfer || needsUpdate) { + MinecraftForge.EVENT_BUS.post( + new FluidTransferEvent(this, buffer, didTransfer) + ); + needsUpdate = false; + } - prevTransfer = didTransfer; + prevTransfer = didTransfer; - if(buffer != null) - { - prevTransferAmount = tickEmit(buffer, true); - if(buffer != null) - { - buffer.amount -= prevTransferAmount; + if (buffer != null) { + prevTransferAmount = tickEmit(buffer, true); + if (buffer != null) { + buffer.amount -= prevTransferAmount; - if(buffer.amount <= 0) - { - buffer = null; - } - } - } - } - } + if (buffer.amount <= 0) { + buffer = null; + } + } + } + } + } - @Override - public void clientTick() - { - super.clientTick(); + @Override + public void clientTick() { + super.clientTick(); - fluidScale = Math.max(fluidScale, getScale()); + fluidScale = Math.max(fluidScale, getScale()); - if(didTransfer && fluidScale < 1) - { - fluidScale = Math.max(getScale(), Math.min(1, fluidScale+0.02F)); - } - else if(!didTransfer && fluidScale > 0) - { - fluidScale = getScale(); + if (didTransfer && fluidScale < 1) { + fluidScale = Math.max(getScale(), Math.min(1, fluidScale + 0.02F)); + } else if (!didTransfer && fluidScale > 0) { + fluidScale = getScale(); - if(fluidScale == 0) - { - buffer = null; - } - } - } + if (fluidScale == 0) { + buffer = null; + } + } + } - @Override - public Set getAcceptors(Object data) - { - FluidStack fluidToSend = (FluidStack)data; - Set toReturn = new HashSet<>(); - - if(FMLCommonHandler.instance().getEffectiveSide().isClient()) - { - return toReturn; - } + @Override + public Set getAcceptors(Object data) { + FluidStack fluidToSend = (FluidStack) data; + Set toReturn = new HashSet<>(); - for(Coord4D coord : possibleAcceptors.keySet()) - { - EnumSet sides = acceptorDirections.get(coord); - TileEntity tile = coord.getTileEntity(getWorld()); + if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { + return toReturn; + } - if(sides == null || sides.isEmpty() || !(tile instanceof IFluidHandler)) - { - continue; - } - - IFluidHandler acceptor = (IFluidHandler)tile; + for (Coord4D coord : possibleAcceptors.keySet()) { + EnumSet sides = acceptorDirections.get(coord); + TileEntity tile = coord.getTileEntity(getWorld()); - for(ForgeDirection side : sides) - { - if(acceptor != null && acceptor.canFill(side, fluidToSend.getFluid())) - { - toReturn.add(acceptor); - break; - } - } - } + if (sides == null || sides.isEmpty() || !(tile instanceof IFluidHandler)) { + continue; + } - return toReturn; - } + IFluidHandler acceptor = (IFluidHandler) tile; - public static class FluidTransferEvent extends Event - { - public final FluidNetwork fluidNetwork; + for (ForgeDirection side : sides) { + if (acceptor != null && acceptor.canFill(side, fluidToSend.getFluid())) { + toReturn.add(acceptor); + break; + } + } + } - public final FluidStack fluidType; - public final boolean didTransfer; + return toReturn; + } - public FluidTransferEvent(FluidNetwork network, FluidStack type, boolean did) - { - fluidNetwork = network; - fluidType = type; - didTransfer = did; - } - } + public static class FluidTransferEvent extends Event { + public final FluidNetwork fluidNetwork; - public float getScale() - { - return Math.min(1, (buffer == null || getCapacity() == 0 ? 0 : (float)buffer.amount/getCapacity())); - } + public final FluidStack fluidType; + public final boolean didTransfer; - @Override - public String toString() - { - return "[FluidNetwork] " + transmitters.size() + " transmitters, " + possibleAcceptors.size() + " acceptors."; - } + public FluidTransferEvent(FluidNetwork network, FluidStack type, boolean did) { + fluidNetwork = network; + fluidType = type; + didTransfer = did; + } + } - @Override - public String getNeededInfo() - { - return (float)getFluidNeeded()/1000F + " buckets"; - } + public float getScale() { + return Math.min( + 1, + (buffer == null || getCapacity() == 0 ? 0 + : (float) buffer.amount / getCapacity()) + ); + } - @Override - public String getStoredInfo() - { - return buffer != null ? LangUtils.localizeFluidStack(buffer) + " (" + buffer.amount + " mB)" : "None"; - } + @Override + public String toString() { + return "[FluidNetwork] " + transmitters.size() + " transmitters, " + + possibleAcceptors.size() + " acceptors."; + } - @Override - public String getFlowInfo() - { - return Integer.toString(prevTransferAmount) + " mB/t"; - } + @Override + public String getNeededInfo() { + return (float) getFluidNeeded() / 1000F + " buckets"; + } + + @Override + public String getStoredInfo() { + return buffer != null + ? LangUtils.localizeFluidStack(buffer) + " (" + buffer.amount + " mB)" + : "None"; + } + + @Override + public String getFlowInfo() { + return Integer.toString(prevTransferAmount) + " mB/t"; + } } diff --git a/src/main/java/mekanism/common/FluidSlot.java b/src/main/java/mekanism/common/FluidSlot.java index 38ff5b9eb..8b1ff5928 100644 --- a/src/main/java/mekanism/common/FluidSlot.java +++ b/src/main/java/mekanism/common/FluidSlot.java @@ -6,34 +6,32 @@ package mekanism.common; * @author AidanBrady * */ -public class FluidSlot -{ - /** The amount of fluid this slot is currently holding. */ - public int fluidStored; +public class FluidSlot { + /** The amount of fluid this slot is currently holding. */ + public int fluidStored; - /** The maximum amount of fluid this slot can handle. */ - public int MAX_FLUID; + /** The maximum amount of fluid this slot can handle. */ + public int MAX_FLUID; - /** The fluid's ID. */ - public int fluidID; + /** The fluid's ID. */ + public int fluidID; - /** - * Creates a FluidSlot with a defined fluid ID and max fluid. The fluid stored starts at 0. - * @param max - max fluid - * @param id - fluid id - */ - public FluidSlot(int max, int id) - { - MAX_FLUID = max; - fluidID = id; - } + /** + * Creates a FluidSlot with a defined fluid ID and max fluid. The fluid stored starts + * at 0. + * @param max - max fluid + * @param id - fluid id + */ + public FluidSlot(int max, int id) { + MAX_FLUID = max; + fluidID = id; + } - /** - * Sets the fluid to a new amount. - * @param fluid - amount to store - */ - public void setFluid(int amount) - { - fluidStored = Math.max(Math.min(amount, MAX_FLUID), 0); - } + /** + * Sets the fluid to a new amount. + * @param fluid - amount to store + */ + public void setFluid(int amount) { + fluidStored = Math.max(Math.min(amount, MAX_FLUID), 0); + } } diff --git a/src/main/java/mekanism/common/FuelHandler.java b/src/main/java/mekanism/common/FuelHandler.java index 275353a10..112a66851 100644 --- a/src/main/java/mekanism/common/FuelHandler.java +++ b/src/main/java/mekanism/common/FuelHandler.java @@ -2,66 +2,59 @@ package mekanism.common; import java.util.HashMap; +import buildcraft.api.fuels.BuildcraftFuelRegistry; +import buildcraft.api.fuels.IFuel; +import cpw.mods.fml.common.ModAPIManager; import mekanism.api.MekanismConfig.general; import mekanism.api.gas.Gas; import mekanism.common.util.MekanismUtils; import net.minecraftforge.fluids.FluidContainerRegistry; -import buildcraft.api.fuels.BuildcraftFuelRegistry; -import buildcraft.api.fuels.IFuel; -import cpw.mods.fml.common.ModAPIManager; -public class FuelHandler -{ - public static HashMap fuels = new HashMap(); +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 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()); - } + public static FuelGas getFuel(Gas gas) { + if (fuels.containsKey(gas.getName())) { + return fuels.get(gas.getName()); + } - if(BCPresent() && gas.hasFluid() && BuildcraftFuelRegistry.fuel != null) - { - IFuel bcFuel = BuildcraftFuelRegistry.fuel.getFuel(gas.getFluid()); - - if(bcFuel != null) - { - FuelGas fuel = new FuelGas(bcFuel); - fuels.put(gas.getName(), fuel); - - return fuel; - } - } + if (BCPresent() && gas.hasFluid() && BuildcraftFuelRegistry.fuel != null) { + IFuel bcFuel = BuildcraftFuelRegistry.fuel.getFuel(gas.getFluid()); - return null; - } + if (bcFuel != null) { + FuelGas fuel = new FuelGas(bcFuel); + fuels.put(gas.getName(), fuel); - public static class FuelGas - { - public int burnTicks; - public double energyPerTick; + return fuel; + } + } - public FuelGas(int duration, double energyDensity) - { - burnTicks = duration; - energyPerTick = energyDensity / duration; - } + return null; + } - public FuelGas(IFuel bcFuel) - { - burnTicks = bcFuel.getTotalBurningTime() / FluidContainerRegistry.BUCKET_VOLUME; - energyPerTick = bcFuel.getPowerPerCycle() * general.FROM_TE; - } - } + public static class FuelGas { + public int burnTicks; + public double energyPerTick; - public static boolean BCPresent() - { - return ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|fuels") && MekanismUtils.classExists("buildcraft.api.fuels.BuildcraftFuelRegistry") && MekanismUtils.classExists("buildcraft.api.fuels.IFuel"); - } + public FuelGas(int duration, double energyDensity) { + burnTicks = duration; + energyPerTick = energyDensity / duration; + } + + public FuelGas(IFuel bcFuel) { + burnTicks + = bcFuel.getTotalBurningTime() / FluidContainerRegistry.BUCKET_VOLUME; + energyPerTick = bcFuel.getPowerPerCycle() * general.FROM_TE; + } + } + + public static boolean BCPresent() { + return ModAPIManager.INSTANCE.hasAPI("BuildCraftAPI|fuels") + && MekanismUtils.classExists("buildcraft.api.fuels.BuildcraftFuelRegistry") + && MekanismUtils.classExists("buildcraft.api.fuels.IFuel"); + } } diff --git a/src/main/java/mekanism/common/HashList.java b/src/main/java/mekanism/common/HashList.java index 5d1ed660b..9bfa18680 100644 --- a/src/main/java/mekanism/common/HashList.java +++ b/src/main/java/mekanism/common/HashList.java @@ -3,122 +3,102 @@ package mekanism.common; import java.util.ArrayList; import java.util.Iterator; -public class HashList implements Iterable -{ - private ArrayList list = new ArrayList(256); +public class HashList implements Iterable { + private ArrayList list = new ArrayList(256); - public boolean contains(T obj) - { - return list.contains(obj); - } + public boolean contains(T obj) { + return list.contains(obj); + } - public void clear() - { - list.clear(); - } + public void clear() { + list.clear(); + } - public T get(int index) - { - if(index > size()-1) - { - return null; - } + public T get(int index) { + if (index > size() - 1) { + return null; + } - return list.get(index); - } + return list.get(index); + } - public void add(T obj) - { - if(!list.contains(obj)) - { - list.add(obj); - } - } + public void add(T obj) { + if (!list.contains(obj)) { + list.add(obj); + } + } - public void add(int index, T obj) - { - if(!list.contains(obj)) - { - if(index > size()) - { - for(int i = size(); i <= index-1; i++) - { - list.add(i, null); - } - } + public void add(int index, T obj) { + if (!list.contains(obj)) { + if (index > size()) { + for (int i = size(); i <= index - 1; i++) { + list.add(i, null); + } + } - list.add(index, obj); - } - } + list.add(index, obj); + } + } - public boolean isEmpty() - { - return list.isEmpty(); - } + public boolean isEmpty() { + return list.isEmpty(); + } - public void remove(int index) - { - if(isEmpty() || index > size()-1) - { - return; - } + public void remove(int index) { + if (isEmpty() || index > size() - 1) { + return; + } - list.remove(index); - } + list.remove(index); + } - public void replace(int index, T obj) - { - if(get(index) != null) - { - remove(index); - } + public void replace(int index, T obj) { + if (get(index) != null) { + remove(index); + } - add(index, obj); - } + add(index, obj); + } - public void remove(T obj) - { - list.remove(obj); - } + public void remove(T obj) { + list.remove(obj); + } - public int indexOf(T obj) - { - return list.indexOf(obj); - } + public int indexOf(T obj) { + return list.indexOf(obj); + } - public int size() - { - return list.size(); - } - - public void swap(int source, int target) - { - // Make sure both source and target are legal values - if(source == target) return; - if(source < 0 || target < 0) return; - if(source >= list.size() || target >= list.size()) return; - - // Perform swap - T temp = list.get(source); - list.set(source, list.get( target)); - list.set(target, temp); - } + public int size() { + return list.size(); + } - @Override - public int hashCode() - { - return list.hashCode(); - } + public void swap(int source, int target) { + // Make sure both source and target are legal values + if (source == target) + return; + if (source < 0 || target < 0) + return; + if (source >= list.size() || target >= list.size()) + return; - @Override - public boolean equals(Object obj) - { - return list.equals(obj); - } + // Perform swap + T temp = list.get(source); + list.set(source, list.get(target)); + list.set(target, temp); + } - @Override - public Iterator iterator() - { - return list.iterator(); - } + @Override + public int hashCode() { + return list.hashCode(); + } + + @Override + public boolean equals(Object obj) { + return list.equals(obj); + } + + @Override + public Iterator iterator() { + return list.iterator(); + } } diff --git a/src/main/java/mekanism/common/HeatNetwork.java b/src/main/java/mekanism/common/HeatNetwork.java index 0e96fa2d4..83a642302 100644 --- a/src/main/java/mekanism/common/HeatNetwork.java +++ b/src/main/java/mekanism/common/HeatNetwork.java @@ -3,101 +3,105 @@ package mekanism.common; import java.util.Collection; import java.util.Set; +import cpw.mods.fml.common.FMLCommonHandler; import mekanism.api.IHeatTransfer; import mekanism.api.transmitters.DynamicNetwork; import mekanism.api.transmitters.IGridTransmitter; import mekanism.api.util.UnitDisplayUtils.TemperatureUnit; import mekanism.common.multipart.MultipartTransmitter; import mekanism.common.util.MekanismUtils; -import cpw.mods.fml.common.FMLCommonHandler; -public class HeatNetwork extends DynamicNetwork -{ - public double meanTemp = 0; +public class HeatNetwork extends DynamicNetwork { + public double meanTemp = 0; - public double heatLost = 0; - public double heatTransferred = 0; + public double heatLost = 0; + public double heatTransferred = 0; - public HeatNetwork() {} + public HeatNetwork() {} - public HeatNetwork(Collection networks) - { - for(HeatNetwork net : networks) - { - if(net != null) - { - adoptTransmittersAndAcceptorsFrom(net); - net.deregister(); - } - } + public HeatNetwork(Collection networks) { + for (HeatNetwork net : networks) { + if (net != null) { + adoptTransmittersAndAcceptorsFrom(net); + net.deregister(); + } + } - register(); - } + register(); + } - @Override - public String getNeededInfo() - { - return "Not Applicable"; - } + @Override + public String getNeededInfo() { + return "Not Applicable"; + } - @Override - public String getStoredInfo() - { - return MekanismUtils.getTemperatureDisplay(meanTemp, TemperatureUnit.KELVIN) + " above ambient"; - } + @Override + public String getStoredInfo() { + return MekanismUtils.getTemperatureDisplay(meanTemp, TemperatureUnit.KELVIN) + + " above ambient"; + } - @Override - public String getFlowInfo() - { - return MekanismUtils.getTemperatureDisplay(heatTransferred, TemperatureUnit.KELVIN) + " transferred to acceptors, " + MekanismUtils.getTemperatureDisplay(heatLost, TemperatureUnit.KELVIN) + " lost to environment, " + (heatTransferred + heatLost == 0 ? "" : heatTransferred / (heatTransferred + heatLost) * 100 + "% efficiency"); - } + @Override + public String getFlowInfo() { + return MekanismUtils.getTemperatureDisplay( + heatTransferred, TemperatureUnit.KELVIN + ) + + " transferred to acceptors, " + + MekanismUtils.getTemperatureDisplay(heatLost, TemperatureUnit.KELVIN) + + " lost to environment, " + + (heatTransferred + heatLost == 0 + ? "" + : heatTransferred / (heatTransferred + heatLost) * 100 + "% efficiency" + ); + } - @Override - public void absorbBuffer(IGridTransmitter transmitter) {} + @Override + public void absorbBuffer(IGridTransmitter transmitter) {} - @Override - public void clampBuffer() {} + @Override + public void clampBuffer() {} - @Override - public Set getAcceptors(Object data) - { - return null; - } + @Override + public Set getAcceptors(Object data) { + return null; + } - @Override - public void onUpdate() - { - super.onUpdate(); + @Override + public void onUpdate() { + super.onUpdate(); - double newSumTemp = 0; - double newHeatLost = 0; - double newHeatTransferred = 0; + double newSumTemp = 0; + double newHeatLost = 0; + double newHeatTransferred = 0; - if(FMLCommonHandler.instance().getEffectiveSide().isServer()) - { - for(IGridTransmitter transmitter : transmitters) - { - if(transmitter instanceof MultipartTransmitter && ((MultipartTransmitter)transmitter).getPart() instanceof IHeatTransfer) - { - IHeatTransfer heatTransmitter = (IHeatTransfer)((MultipartTransmitter)transmitter).getPart(); - double[] d = heatTransmitter.simulateHeat(); - newHeatTransferred += d[0]; - newHeatLost += d[1]; - } - } - - for(IGridTransmitter transmitter : transmitters) - { - if(transmitter instanceof MultipartTransmitter && ((MultipartTransmitter)transmitter).getPart() instanceof IHeatTransfer) - { - IHeatTransfer heatTransmitter = (IHeatTransfer)((MultipartTransmitter)transmitter).getPart(); - newSumTemp += heatTransmitter.applyTemperatureChange(); - } - } - } - - heatLost = newHeatLost; - heatTransferred = newHeatTransferred; - meanTemp = newSumTemp / transmitters.size(); - } + if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { + for (IGridTransmitter transmitter : + transmitters) { + if (transmitter instanceof MultipartTransmitter + && ((MultipartTransmitter) transmitter).getPart() + instanceof IHeatTransfer) { + IHeatTransfer heatTransmitter + = (IHeatTransfer) ((MultipartTransmitter) transmitter).getPart(); + double[] d = heatTransmitter.simulateHeat(); + newHeatTransferred += d[0]; + newHeatLost += d[1]; + } + } + + for (IGridTransmitter transmitter : + transmitters) { + if (transmitter instanceof MultipartTransmitter + && ((MultipartTransmitter) transmitter).getPart() + instanceof IHeatTransfer) { + IHeatTransfer heatTransmitter + = (IHeatTransfer) ((MultipartTransmitter) transmitter).getPart(); + newSumTemp += heatTransmitter.applyTemperatureChange(); + } + } + } + + heatLost = newHeatLost; + heatTransferred = newHeatTransferred; + meanTemp = newSumTemp / transmitters.size(); + } } diff --git a/src/main/java/mekanism/common/IMCHandler.java b/src/main/java/mekanism/common/IMCHandler.java index 4a3a49fd1..91fb29974 100644 --- a/src/main/java/mekanism/common/IMCHandler.java +++ b/src/main/java/mekanism/common/IMCHandler.java @@ -2,6 +2,9 @@ package mekanism.common; import java.util.List; +import cpw.mods.fml.common.Mod.EventHandler; +import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; +import cpw.mods.fml.common.registry.GameRegistry; import mekanism.common.recipe.RecipeHandler; import mekanism.common.recipe.RecipeHandler.Recipe; import mekanism.common.recipe.ShapedMekanismRecipe; @@ -10,120 +13,133 @@ import mekanism.common.recipe.inputs.MachineInput; import mekanism.common.recipe.machines.MachineRecipe; import mekanism.common.util.RecipeUtils; import net.minecraft.item.ItemStack; -import cpw.mods.fml.common.Mod.EventHandler; -import cpw.mods.fml.common.event.FMLInterModComms.IMCMessage; -import cpw.mods.fml.common.registry.GameRegistry; -public class IMCHandler -{ - @EventHandler - public void onIMCEvent(List messages) - { - for(IMCMessage msg : messages) - { - if(msg.isNBTMessage()) - { - try { - boolean found = false; - boolean delete = false; - - String message = msg.key; - - if(message.equals("ShapedMekanismRecipe")) - { - ShapedMekanismRecipe recipe = ShapedMekanismRecipe.create(msg.getNBTValue()); - - if(recipe != null) - { - GameRegistry.addRecipe(recipe); - Mekanism.logger.info("[Mekanism] " + msg.getSender() + " added a shaped recipe to the recipe list."); - } - else { - Mekanism.logger.error("[Mekanism] " + msg.getSender() + " attempted to add an invalid shaped recipe."); - } - - found = true; - } - else if(message.equals("ShapelessMekanismRecipe")) - { - ShapelessMekanismRecipe recipe = ShapelessMekanismRecipe.create(msg.getNBTValue()); - - if(recipe != null) - { - GameRegistry.addRecipe(recipe); - Mekanism.logger.info("[Mekanism] " + msg.getSender() + " added a shapeless recipe to the recipe list."); - } - else { - Mekanism.logger.error("[Mekanism] " + msg.getSender() + " attempted to add an invalid shapeless recipe."); - } - - found = true; - } - else if(message.equals("DeleteMekanismRecipes") || message.equals("RemoveMekanismRecipes")) - { - ItemStack stack = RecipeUtils.loadRecipeItemStack(msg.getNBTValue()); - - if(stack != null) - { - RecipeUtils.removeRecipes(stack); - Mekanism.logger.info("[Mekanism] " + msg.getSender() + " removed a Mekanism recipe from the recipe list."); - } - else { - Mekanism.logger.error("[Mekanism] " + msg.getSender() + " attempted to remove a Mekanism recipe with an invalid output."); - } - - found = true; - } +public class IMCHandler { + @EventHandler + public void onIMCEvent(List messages) { + for (IMCMessage msg : messages) { + if (msg.isNBTMessage()) { + try { + boolean found = false; + boolean delete = false; - if(message.startsWith("Delete") || message.startsWith("Remove")) - { - message = message.replace("Delete", "").replace("Remove", ""); - delete = true; - } + String message = msg.key; - for(Recipe type : Recipe.values()) - { - if(msg.key.equalsIgnoreCase(type.getRecipeName() + "Recipe")) - { - MachineInput input = type.createInput(msg.getNBTValue()); - - if(input != null && input.isValid()) - { - MachineRecipe recipe = type.createRecipe(input, msg.getNBTValue()); - - if(recipe != null && recipe.recipeOutput != null) - { - if(delete) - { - RecipeHandler.removeRecipe(type, recipe); - Mekanism.logger.info("[Mekanism] " + msg.getSender() + " removed recipe of type " + type.getRecipeName() + " from the recipe list."); - } - else { - RecipeHandler.addRecipe(type, recipe); - Mekanism.logger.info("[Mekanism] " + msg.getSender() + " added recipe of type " + type.getRecipeName() + " to the recipe list."); - } - } - else { - Mekanism.logger.error("[Mekanism] " + msg.getSender() + " attempted to " + (delete ? "remove" : "add") + " recipe of type " + type.getRecipeName() + " with an invalid output."); - } - } - else { - Mekanism.logger.error("[Mekanism] " + msg.getSender() + " attempted to " + (delete ? "remove" : "add") + " recipe of type " + type.getRecipeName() + " with an invalid input."); - } - - found = true; - break; - } - } - - if(!found) - { - Mekanism.logger.error("[Mekanism] " + msg.getSender() + " sent unknown IMC message with key '" + msg.key + ".'"); - } - } catch(Exception e) { - e.printStackTrace(); - } - } - } - } + if (message.equals("ShapedMekanismRecipe")) { + ShapedMekanismRecipe recipe + = ShapedMekanismRecipe.create(msg.getNBTValue()); + + if (recipe != null) { + GameRegistry.addRecipe(recipe); + Mekanism.logger.info( + "[Mekanism] " + msg.getSender() + + " added a shaped recipe to the recipe list." + ); + } else { + Mekanism.logger.error( + "[Mekanism] " + msg.getSender() + + " attempted to add an invalid shaped recipe." + ); + } + + found = true; + } else if (message.equals("ShapelessMekanismRecipe")) { + ShapelessMekanismRecipe recipe + = ShapelessMekanismRecipe.create(msg.getNBTValue()); + + if (recipe != null) { + GameRegistry.addRecipe(recipe); + Mekanism.logger.info( + "[Mekanism] " + msg.getSender() + + " added a shapeless recipe to the recipe list." + ); + } else { + Mekanism.logger.error( + "[Mekanism] " + msg.getSender() + + " attempted to add an invalid shapeless recipe." + ); + } + + found = true; + } else if (message.equals("DeleteMekanismRecipes") || message.equals("RemoveMekanismRecipes")) { + ItemStack stack + = RecipeUtils.loadRecipeItemStack(msg.getNBTValue()); + + if (stack != null) { + RecipeUtils.removeRecipes(stack); + Mekanism.logger.info( + "[Mekanism] " + msg.getSender() + + " removed a Mekanism recipe from the recipe list." + ); + } else { + Mekanism.logger.error("[Mekanism] " + msg.getSender() + " attempted to remove a Mekanism recipe with an invalid output."); + } + + found = true; + } + + if (message.startsWith("Delete") || message.startsWith("Remove")) { + message = message.replace("Delete", "").replace("Remove", ""); + delete = true; + } + + for (Recipe type : Recipe.values()) { + if (msg.key.equalsIgnoreCase(type.getRecipeName() + "Recipe")) { + MachineInput input = type.createInput(msg.getNBTValue()); + + if (input != null && input.isValid()) { + MachineRecipe recipe + = type.createRecipe(input, msg.getNBTValue()); + + if (recipe != null && recipe.recipeOutput != null) { + if (delete) { + RecipeHandler.removeRecipe(type, recipe); + Mekanism.logger.info( + "[Mekanism] " + msg.getSender() + + " removed recipe of type " + + type.getRecipeName() + + " from the recipe list." + ); + } else { + RecipeHandler.addRecipe(type, recipe); + Mekanism.logger.info( + "[Mekanism] " + msg.getSender() + + " added recipe of type " + + type.getRecipeName() + + " to the recipe list." + ); + } + } else { + Mekanism.logger.error( + "[Mekanism] " + msg.getSender() + " attempted to " + + (delete ? "remove" : "add") + " recipe of type " + + type.getRecipeName() + + " with an invalid output." + ); + } + } else { + Mekanism.logger.error( + "[Mekanism] " + msg.getSender() + " attempted to " + + (delete ? "remove" : "add") + " recipe of type " + + type.getRecipeName() + " with an invalid input." + ); + } + + found = true; + break; + } + } + + if (!found) { + Mekanism.logger.error( + "[Mekanism] " + msg.getSender() + + " sent unknown IMC message with key '" + msg.key + ".'" + ); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } } diff --git a/src/main/java/mekanism/common/InfuseStorage.java b/src/main/java/mekanism/common/InfuseStorage.java index 122330c19..ac7e55645 100644 --- a/src/main/java/mekanism/common/InfuseStorage.java +++ b/src/main/java/mekanism/common/InfuseStorage.java @@ -2,34 +2,27 @@ package mekanism.common; import mekanism.api.infuse.InfuseType; -public class InfuseStorage -{ - public InfuseType type; +public class InfuseStorage { + public InfuseType type; - public int amount; + public int amount; - public InfuseStorage() {} + public InfuseStorage() {} - public InfuseStorage(InfuseType infuseType, int infuseAmount) - { - type = infuseType; - amount = infuseAmount; - } + public InfuseStorage(InfuseType infuseType, int infuseAmount) { + type = infuseType; + amount = infuseAmount; + } - public boolean contains(InfuseStorage storage) - { - return type == storage.type && amount >= storage.amount; - } + public boolean contains(InfuseStorage storage) { + return type == storage.type && amount >= storage.amount; + } - public void subtract(InfuseStorage storage) - { - if(contains(storage)) - { - amount -= storage.amount; - } - else if(type == storage.type) - { - amount = 0; - } - } + public void subtract(InfuseStorage storage) { + if (contains(storage)) { + amount -= storage.amount; + } else if (type == storage.type) { + amount = 0; + } + } } diff --git a/src/main/java/mekanism/common/InventoryNetwork.java b/src/main/java/mekanism/common/InventoryNetwork.java index 492bd40f4..22b1cfeab 100644 --- a/src/main/java/mekanism/common/InventoryNetwork.java +++ b/src/main/java/mekanism/common/InventoryNetwork.java @@ -7,6 +7,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import cpw.mods.fml.common.FMLCommonHandler; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.transmitters.DynamicNetwork; @@ -16,137 +17,117 @@ import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -import cpw.mods.fml.common.FMLCommonHandler; -public class InventoryNetwork extends DynamicNetwork -{ - public InventoryNetwork() {} +public class InventoryNetwork extends DynamicNetwork { + public InventoryNetwork() {} - public InventoryNetwork(Collection networks) - { - for(InventoryNetwork net : networks) - { - if(net != null) - { - adoptTransmittersAndAcceptorsFrom(net); - net.deregister(); - } - } + public InventoryNetwork(Collection networks) { + for (InventoryNetwork net : networks) { + if (net != null) { + adoptTransmittersAndAcceptorsFrom(net); + net.deregister(); + } + } - register(); - } - - public List calculateAcceptors(ItemStack stack, EnumColor color) - { - List toReturn = new ArrayList(); - - for(Coord4D coord : possibleAcceptors.keySet()) - { - if(coord == null) - { - continue; - } - - EnumSet sides = acceptorDirections.get(coord); - IInventory acceptor = (IInventory)coord.getTileEntity(getWorld()); - - if(sides == null || sides.isEmpty()) - { - continue; - } - - AcceptorData data = null; - - for(ForgeDirection side : sides) - { - ItemStack returned = TransporterManager.getPredictedInsert((TileEntity)acceptor, color, stack, side.getOpposite().ordinal()); - - if(TransporterManager.didEmit(stack, returned)) - { - if(data == null) - { - data = new AcceptorData(coord, returned, side.getOpposite()); - } - else { - data.sides.add(side.getOpposite()); - } - } - } - - if(data != null) - { - toReturn.add(data); - } - } - - return toReturn; - } - - public static class AcceptorData - { - public Coord4D location; - public ItemStack rejected; - public EnumSet sides = EnumSet.noneOf(ForgeDirection.class); - - public AcceptorData(Coord4D coord, ItemStack stack, ForgeDirection side) - { - location = coord; - rejected = stack; - sides.add(side); - } - } + register(); + } - @Override - public void onUpdate() - { - super.onUpdate(); + public List calculateAcceptors(ItemStack stack, EnumColor color) { + List toReturn = new ArrayList(); - if(FMLCommonHandler.instance().getEffectiveSide().isServer()) - { - //Future! - } - } + for (Coord4D coord : possibleAcceptors.keySet()) { + if (coord == null) { + continue; + } - @Override - public void absorbBuffer(IGridTransmitter transmitter) {} + EnumSet sides = acceptorDirections.get(coord); + IInventory acceptor = (IInventory) coord.getTileEntity(getWorld()); - @Override - public void clampBuffer() {} + if (sides == null || sides.isEmpty()) { + continue; + } - @Override - public Set getAcceptors(Object data) - { - Set toReturn = new HashSet(); - - if(FMLCommonHandler.instance().getEffectiveSide().isClient()) - { - return toReturn; - } - - return toReturn; - } + AcceptorData data = null; - @Override - public String toString() - { - return "[InventoryNetwork] " + transmitters.size() + " transmitters, " + possibleAcceptors.size() + " acceptors."; - } + for (ForgeDirection side : sides) { + ItemStack returned = TransporterManager.getPredictedInsert( + (TileEntity) acceptor, color, stack, side.getOpposite().ordinal() + ); - @Override - public String getNeededInfo() - { - return null; - } + if (TransporterManager.didEmit(stack, returned)) { + if (data == null) { + data = new AcceptorData(coord, returned, side.getOpposite()); + } else { + data.sides.add(side.getOpposite()); + } + } + } - @Override - public String getStoredInfo() - { - return null; - } + if (data != null) { + toReturn.add(data); + } + } - @Override - public String getFlowInfo() - { - return null; - } + return toReturn; + } + + public static class AcceptorData { + public Coord4D location; + public ItemStack rejected; + public EnumSet sides = EnumSet.noneOf(ForgeDirection.class); + + public AcceptorData(Coord4D coord, ItemStack stack, ForgeDirection side) { + location = coord; + rejected = stack; + sides.add(side); + } + } + + @Override + public void onUpdate() { + super.onUpdate(); + + if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { + //Future! + } + } + + @Override + public void absorbBuffer(IGridTransmitter transmitter) { + } + + @Override + public void clampBuffer() {} + + @Override + public Set getAcceptors(Object data) { + Set toReturn = new HashSet(); + + if (FMLCommonHandler.instance().getEffectiveSide().isClient()) { + return toReturn; + } + + return toReturn; + } + + @Override + public String toString() { + return "[InventoryNetwork] " + transmitters.size() + " transmitters, " + + possibleAcceptors.size() + " acceptors."; + } + + @Override + public String getNeededInfo() { + return null; + } + + @Override + public String getStoredInfo() { + return null; + } + + @Override + public String getFlowInfo() { + return null; + } } diff --git a/src/main/java/mekanism/common/KeySync.java b/src/main/java/mekanism/common/KeySync.java index 9d9a39ad0..001872f03 100644 --- a/src/main/java/mekanism/common/KeySync.java +++ b/src/main/java/mekanism/common/KeySync.java @@ -7,67 +7,54 @@ import java.util.Set; import net.minecraft.entity.player.EntityPlayer; -public class KeySync -{ - public static int ASCEND = 0; - public static int DESCEND = 1; +public class KeySync { + public static int ASCEND = 0; + public static int DESCEND = 1; - public Map keys = new HashMap(); + public Map keys = new HashMap(); - public static class KeySet - { - public Set keysActive = new HashSet(); + public static class KeySet { + public Set keysActive = new HashSet(); - public KeySet(int key) - { - keysActive.add(key); - } - } + public KeySet(int key) { + keysActive.add(key); + } + } - public KeySet getPlayerKeys(EntityPlayer player) - { - return keys.get(player); - } + public KeySet getPlayerKeys(EntityPlayer player) { + return keys.get(player); + } - public void add(EntityPlayer player, int key) - { - if(!keys.containsKey(player)) - { - keys.put(player, new KeySet(key)); - return; - } + public void add(EntityPlayer player, int key) { + if (!keys.containsKey(player)) { + keys.put(player, new KeySet(key)); + return; + } - keys.get(player).keysActive.add(key); - } + keys.get(player).keysActive.add(key); + } - public void remove(EntityPlayer player, int key) - { - if(!keys.containsKey(player)) - { - return; - } + public void remove(EntityPlayer player, int key) { + if (!keys.containsKey(player)) { + return; + } - keys.get(player).keysActive.remove(key); - } + keys.get(player).keysActive.remove(key); + } - public boolean has(EntityPlayer player, int key) - { - if(!keys.containsKey(player)) - { - return false; - } + public boolean has(EntityPlayer player, int key) { + if (!keys.containsKey(player)) { + return false; + } - return keys.get(player).keysActive.contains(key); - } + return keys.get(player).keysActive.contains(key); + } - public void update(EntityPlayer player, int key, boolean add) - { - if(add) - { - add(player, key); - } - else { - remove(player, key); - } - } + public void update(EntityPlayer player, int key, boolean add) { + if (add) { + add(player, key); + } else { + remove(player, key); + } + } } diff --git a/src/main/java/mekanism/common/LaserManager.java b/src/main/java/mekanism/common/LaserManager.java index 3f8b06c91..3200956c3 100644 --- a/src/main/java/mekanism/common/LaserManager.java +++ b/src/main/java/mekanism/common/LaserManager.java @@ -20,123 +20,169 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.event.world.BlockEvent; -public class LaserManager -{ - public static LaserInfo fireLaser(TileEntity from, ForgeDirection direction, double energy, World world) - { - return fireLaser(new Pos3D(from).centre().translate(direction, 0.501), direction, energy, world); - } +public class LaserManager { + public static LaserInfo + fireLaser(TileEntity from, ForgeDirection direction, double energy, World world) { + return fireLaser( + new Pos3D(from).centre().translate(direction, 0.501), direction, energy, world + ); + } - public static LaserInfo fireLaser(Pos3D from, ForgeDirection direction, double energy, World world) - { - Pos3D to = from.clone().translate(direction, general.laserRange - 0.002); + public static LaserInfo + fireLaser(Pos3D from, ForgeDirection direction, double energy, World world) { + Pos3D to = from.clone().translate(direction, general.laserRange - 0.002); - MovingObjectPosition mop = world.rayTraceBlocks(Vec3.createVectorHelper(from.xPos, from.yPos, from.zPos), Vec3.createVectorHelper(to.xPos, to.yPos, to.zPos)); + MovingObjectPosition mop = world.rayTraceBlocks( + Vec3.createVectorHelper(from.xPos, from.yPos, from.zPos), + Vec3.createVectorHelper(to.xPos, to.yPos, to.zPos) + ); - if(mop != null) - { - to = new Pos3D(mop.hitVec); - Coord4D toCoord = new Coord4D(mop.blockX, mop.blockY, mop.blockZ, world.provider.dimensionId); - TileEntity tile = toCoord.getTileEntity(world); + if (mop != null) { + to = new Pos3D(mop.hitVec); + Coord4D toCoord = new Coord4D( + mop.blockX, mop.blockY, mop.blockZ, world.provider.dimensionId + ); + TileEntity tile = toCoord.getTileEntity(world); - if(tile instanceof ILaserReceptor) - { - if(!(((ILaserReceptor)tile).canLasersDig())) - { - ((ILaserReceptor)tile).receiveLaserEnergy(energy, ForgeDirection.getOrientation(mop.sideHit)); - } - } - } + if (tile instanceof ILaserReceptor) { + if (!(((ILaserReceptor) tile).canLasersDig())) { + ((ILaserReceptor) tile) + .receiveLaserEnergy( + energy, ForgeDirection.getOrientation(mop.sideHit) + ); + } + } + } - from.translateExcludingSide(direction, -0.1); - to.translateExcludingSide(direction, 0.1); - - boolean foundEntity = false; + from.translateExcludingSide(direction, -0.1); + to.translateExcludingSide(direction, 0.1); - for(Entity e : (List)world.getEntitiesWithinAABB(Entity.class, Pos3D.getAABB(from, to))) - { - foundEntity = true; - - if(!e.isImmuneToFire()) - { - e.setFire((int)(energy / 1000)); - } - - if(energy > 256) - { - e.attackEntityFrom(DamageSource.generic, (float)energy/1000F); - } - } - - return new LaserInfo(mop, foundEntity); - } + boolean foundEntity = false; - public static List breakBlock(Coord4D blockCoord, boolean dropAtBlock, World world) - { - if(!general.aestheticWorldDamage) - { - return null; - } - - List ret = null; - Block blockHit = blockCoord.getBlock(world); - int meta = blockCoord.getMetadata(world); - - EntityPlayer dummy = Mekanism.proxy.getDummyPlayer((WorldServer)world, blockCoord.xCoord, blockCoord.yCoord, blockCoord.zCoord).get(); - BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(blockCoord.xCoord, blockCoord.yCoord, blockCoord.zCoord, world, blockHit, meta, dummy); - MinecraftForge.EVENT_BUS.post(event); - - if(event.isCanceled()) - { - return null; - } - - if(dropAtBlock) - { - blockHit.dropBlockAsItem(world, blockCoord.xCoord, blockCoord.yCoord, blockCoord.zCoord, blockCoord.getMetadata(world), 0); - } - else { - ret = blockHit.getDrops(world, blockCoord.xCoord, blockCoord.yCoord, blockCoord.zCoord, blockCoord.getMetadata(world), 0); - } - - blockHit.breakBlock(world, blockCoord.xCoord, blockCoord.yCoord, blockCoord.zCoord, blockHit, blockCoord.getMetadata(world)); - world.setBlockToAir(blockCoord.xCoord, blockCoord.yCoord, blockCoord.zCoord); - world.playAuxSFX(2001, blockCoord.xCoord, blockCoord.yCoord, blockCoord.zCoord, Block.getIdFromBlock(blockHit)); - - return ret; - } + for (Entity e : (List) world.getEntitiesWithinAABB( + Entity.class, Pos3D.getAABB(from, to) + )) { + foundEntity = true; - public static MovingObjectPosition fireLaserClient(TileEntity from, ForgeDirection direction, double energy, World world) - { - return fireLaserClient(new Pos3D(from).centre().translate(direction, 0.501), direction, energy, world); - } + if (!e.isImmuneToFire()) { + e.setFire((int) (energy / 1000)); + } - public static MovingObjectPosition fireLaserClient(Pos3D from, ForgeDirection direction, double energy, World world) - { - Pos3D to = from.clone().translate(direction, general.laserRange - 0.002); - MovingObjectPosition mop = world.rayTraceBlocks(Vec3.createVectorHelper(from.xPos, from.yPos, from.zPos), Vec3.createVectorHelper(to.xPos, to.yPos, to.zPos)); + if (energy > 256) { + e.attackEntityFrom(DamageSource.generic, (float) energy / 1000F); + } + } - if(mop != null) - { - to = new Pos3D(mop.hitVec); - } - - from.translate(direction, -0.501); - Mekanism.proxy.renderLaser(world, from, to, direction, energy); - - return mop; - } - - public static class LaserInfo - { - public MovingObjectPosition movingPos; - - public boolean foundEntity; - - public LaserInfo(MovingObjectPosition mop, boolean b) - { - movingPos = mop; - foundEntity = b; - } - } + return new LaserInfo(mop, foundEntity); + } + + public static List + breakBlock(Coord4D blockCoord, boolean dropAtBlock, World world) { + if (!general.aestheticWorldDamage) { + return null; + } + + List ret = null; + Block blockHit = blockCoord.getBlock(world); + int meta = blockCoord.getMetadata(world); + + EntityPlayer dummy = Mekanism.proxy + .getDummyPlayer( + (WorldServer) world, + blockCoord.xCoord, + blockCoord.yCoord, + blockCoord.zCoord + ) + .get(); + BlockEvent.BreakEvent event = new BlockEvent.BreakEvent( + blockCoord.xCoord, + blockCoord.yCoord, + blockCoord.zCoord, + world, + blockHit, + meta, + dummy + ); + MinecraftForge.EVENT_BUS.post(event); + + if (event.isCanceled()) { + return null; + } + + if (dropAtBlock) { + blockHit.dropBlockAsItem( + world, + blockCoord.xCoord, + blockCoord.yCoord, + blockCoord.zCoord, + blockCoord.getMetadata(world), + 0 + ); + } else { + ret = blockHit.getDrops( + world, + blockCoord.xCoord, + blockCoord.yCoord, + blockCoord.zCoord, + blockCoord.getMetadata(world), + 0 + ); + } + + blockHit.breakBlock( + world, + blockCoord.xCoord, + blockCoord.yCoord, + blockCoord.zCoord, + blockHit, + blockCoord.getMetadata(world) + ); + world.setBlockToAir(blockCoord.xCoord, blockCoord.yCoord, blockCoord.zCoord); + world.playAuxSFX( + 2001, + blockCoord.xCoord, + blockCoord.yCoord, + blockCoord.zCoord, + Block.getIdFromBlock(blockHit) + ); + + return ret; + } + + public static MovingObjectPosition fireLaserClient( + TileEntity from, ForgeDirection direction, double energy, World world + ) { + return fireLaserClient( + new Pos3D(from).centre().translate(direction, 0.501), direction, energy, world + ); + } + + public static MovingObjectPosition + fireLaserClient(Pos3D from, ForgeDirection direction, double energy, World world) { + Pos3D to = from.clone().translate(direction, general.laserRange - 0.002); + MovingObjectPosition mop = world.rayTraceBlocks( + Vec3.createVectorHelper(from.xPos, from.yPos, from.zPos), + Vec3.createVectorHelper(to.xPos, to.yPos, to.zPos) + ); + + if (mop != null) { + to = new Pos3D(mop.hitVec); + } + + from.translate(direction, -0.501); + Mekanism.proxy.renderLaser(world, from, to, direction, energy); + + return mop; + } + + public static class LaserInfo { + public MovingObjectPosition movingPos; + + public boolean foundEntity; + + public LaserInfo(MovingObjectPosition mop, boolean b) { + movingPos = mop; + foundEntity = b; + } + } } \ No newline at end of file diff --git a/src/main/java/mekanism/common/Mekanism.java b/src/main/java/mekanism/common/Mekanism.java index 552998ae8..c4abdffe9 100644 --- a/src/main/java/mekanism/common/Mekanism.java +++ b/src/main/java/mekanism/common/Mekanism.java @@ -10,7 +10,21 @@ import java.util.Map; import java.util.Set; import java.util.UUID; +import codechicken.multipart.handler.MultipartProxy; +import com.mojang.authlib.GameProfile; +import cpw.mods.fml.client.event.ConfigChangedEvent; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.IFuelHandler; +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.Mod.EventHandler; +import cpw.mods.fml.common.Mod.Instance; +import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.*; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.registry.EntityRegistry; +import cpw.mods.fml.common.registry.GameRegistry; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.MekanismAPI; @@ -110,50 +124,40 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.RecipeSorter; import net.minecraftforge.oredict.RecipeSorter.Category; -import universalelectricity.api.CompatibilityModule; - import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; - -import codechicken.multipart.handler.MultipartProxy; - -import com.mojang.authlib.GameProfile; - -import cpw.mods.fml.client.event.ConfigChangedEvent; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.IFuelHandler; -import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.Mod; -import cpw.mods.fml.common.Mod.EventHandler; -import cpw.mods.fml.common.Mod.Instance; -import cpw.mods.fml.common.SidedProxy; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.network.NetworkRegistry; -import cpw.mods.fml.common.registry.EntityRegistry; -import cpw.mods.fml.common.registry.GameRegistry; +import universalelectricity.api.CompatibilityModule; /** * Mekanism - a Minecraft mod * @author AidanBrady * */ -@Mod(modid = "Mekanism", name = "Mekanism tilera Edition", version = "GRADLE_MODVERSION", guiFactory = "mekanism.client.gui.ConfigGuiFactory", - dependencies = "required-after:universalelectricity;required-after:ForgeMultipart;after:BuildCraft;after:BuildCraftAPI;after:IC2;after:CoFHCore;" + - "after:ComputerCraft;after:Galacticraft;after:MineTweaker3") -public class Mekanism -{ - /** Mekanism Packet Pipeline */ - public static PacketHandler packetHandler = new PacketHandler(); +@Mod( + modid = "Mekanism", + name = "Mekanism tilera Edition", + version = "GRADLE_MODVERSION", + guiFactory = "mekanism.client.gui.ConfigGuiFactory", + dependencies + = "required-after:universalelectricity;required-after:ForgeMultipart;after:BuildCraft;after:BuildCraftAPI;after:IC2;after:CoFHCore;" + + "after:ComputerCraft;after:Galacticraft;after:MineTweaker3" +) +public class Mekanism { + /** Mekanism Packet Pipeline */ + public static PacketHandler packetHandler = new PacketHandler(); - /** Mekanism logger instance */ - public static Logger logger = LogManager.getLogger("Mekanism"); + /** Mekanism logger instance */ + public static Logger logger = LogManager.getLogger("Mekanism"); - /** Mekanism proxy instance */ - @SidedProxy(clientSide = "mekanism.client.ClientProxy", serverSide = "mekanism.common.CommonProxy") - public static CommonProxy proxy; + /** Mekanism proxy instance */ + @SidedProxy( + clientSide = "mekanism.client.ClientProxy", + serverSide = "mekanism.common.CommonProxy" + ) + public static CommonProxy proxy; /** Mekanism mod instance */ - @Instance("Mekanism") + @Instance("Mekanism") public static Mekanism instance; /** Mekanism hooks instance */ @@ -162,1302 +166,3067 @@ public class Mekanism /** Mekanism configuration instance */ public static Configuration configuration; - /** Mekanism version number */ - //public static Version versionNumber = new Version(GRADLE_VERSIONMOD); - public static String versionNumber = "GRADLE_MODVERSION"; + /** Mekanism version number */ + //public static Version versionNumber = new Version(GRADLE_VERSIONMOD); + public static String versionNumber = "GRADLE_MODVERSION"; - /** MultiblockManagers for various structrures */ - public static MultiblockManager tankManager = new MultiblockManager("dynamicTank"); - public static MultiblockManager matrixManager = new MultiblockManager("inductionMatrix"); - public static MultiblockManager boilerManager = new MultiblockManager("thermoelectricBoiler"); + /** MultiblockManagers for various structrures */ + public static MultiblockManager tankManager + = new MultiblockManager("dynamicTank"); + public static MultiblockManager matrixManager + = new MultiblockManager("inductionMatrix"); + public static MultiblockManager boilerManager + = new MultiblockManager("thermoelectricBoiler"); - /** FrequencyManagers for various networks */ - public static FrequencyManager publicTeleporters = new FrequencyManager(Frequency.class, Frequency.TELEPORTER); - public static Map privateTeleporters = new HashMap(); - public static Map protectedTeleporters = new HashMap(); + /** FrequencyManagers for various networks */ + public static FrequencyManager publicTeleporters + = new FrequencyManager(Frequency.class, Frequency.TELEPORTER); + public static Map privateTeleporters + = new HashMap(); + public static Map protectedTeleporters + = new HashMap(); - public static FrequencyManager publicEntangloporters = new FrequencyManager(InventoryFrequency.class, InventoryFrequency.ENTANGLOPORTER); - public static Map privateEntangloporters = new HashMap(); - public static Map protectedEntangloporters = new HashMap(); + public static FrequencyManager publicEntangloporters = new FrequencyManager( + InventoryFrequency.class, InventoryFrequency.ENTANGLOPORTER + ); + public static Map privateEntangloporters + = new HashMap(); + public static Map protectedEntangloporters + = new HashMap(); - public static FrequencyManager securityFrequencies = new FrequencyManager(SecurityFrequency.class, SecurityFrequency.SECURITY); + public static FrequencyManager securityFrequencies + = new FrequencyManager(SecurityFrequency.class, SecurityFrequency.SECURITY); - /** Mekanism creative tab */ - public static CreativeTabMekanism tabMekanism = new CreativeTabMekanism(); + /** Mekanism creative tab */ + public static CreativeTabMekanism tabMekanism = new CreativeTabMekanism(); - /** List of Mekanism modules loaded */ - public static List modulesLoaded = new ArrayList(); + /** List of Mekanism modules loaded */ + public static List modulesLoaded = new ArrayList(); - /** The recent news which is received from the Mekanism server */ - public static String recentNews; + /** The recent news which is received from the Mekanism server */ + public static String recentNews; - /** The VoiceServer manager for walkie talkies */ - public static VoiceServerManager voiceManager; + /** The VoiceServer manager for walkie talkies */ + public static VoiceServerManager voiceManager; - /** A list of the usernames of players who have donated to Mekanism. */ - public static List donators = new ArrayList(); + /** A list of the usernames of players who have donated to Mekanism. */ + public static List donators = new ArrayList(); - /** The server's world tick handler. */ - public static CommonWorldTickHandler worldTickHandler = new CommonWorldTickHandler(); + /** The server's world tick handler. */ + public static CommonWorldTickHandler worldTickHandler = new CommonWorldTickHandler(); - /** The Mekanism world generation handler. */ - public static GenHandler genHandler = new GenHandler(); + /** The Mekanism world generation handler. */ + public static GenHandler genHandler = new GenHandler(); - /** The version of ore generation in this version of Mekanism. Increment this every time the default ore generation changes. */ - public static int baseWorldGenVersion = 0; + /** + * The version of ore generation in this version of Mekanism. Increment this every + * time the default ore generation changes. + */ + public static int baseWorldGenVersion = 0; - /** The GameProfile used by the dummy Mekanism player */ - public static GameProfile gameProfile = new GameProfile(UUID.nameUUIDFromBytes("mekanism.common".getBytes()), "[Mekanism]"); + /** The GameProfile used by the dummy Mekanism player */ + public static GameProfile gameProfile = new GameProfile( + UUID.nameUUIDFromBytes("mekanism.common".getBytes()), "[Mekanism]" + ); - public static KeySync keyMap = new KeySync(); + public static KeySync keyMap = new KeySync(); - public static Set jetpackOn = new HashSet(); - public static Set gasmaskOn = new HashSet(); - public static Set flamethrowerActive = new HashSet(); + public static Set jetpackOn = new HashSet(); + public static Set gasmaskOn = new HashSet(); + public static Set flamethrowerActive = new HashSet(); - public static Set activeVibrators = new HashSet(); + public static Set activeVibrators = new HashSet(); - /** - * Adds all in-game crafting, smelting and machine recipes. - */ - public void addRecipes() - { - //Storage Recipes - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.BasicBlock, 1, 3), new Object[] { - "***", "***", "***", Character.valueOf('*'), new ItemStack(Items.coal, 1, 1) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(Items.coal, 9, 1), new Object[] { - "*", Character.valueOf('*'), new ItemStack(MekanismBlocks.BasicBlock, 1, 3) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.BasicBlock, 1, 2), new Object[] { - "***", "***", "***", Character.valueOf('*'), "ingotRefinedObsidian" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.Ingot, 9, 0), new Object[] { - "*", Character.valueOf('*'), new ItemStack(MekanismBlocks.BasicBlock, 1, 2) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.BasicBlock, 1, 4), new Object[] { - "***", "***", "***", Character.valueOf('*'), "ingotRefinedGlowstone" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.Ingot, 9, 3), new Object[] { - "*", Character.valueOf('*'), new ItemStack(MekanismBlocks.BasicBlock, 1, 4) - })); + /** + * Adds all in-game crafting, smelting and machine recipes. + */ + public void addRecipes() { + //Storage Recipes + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.BasicBlock, 1, 3), + new Object[] { "***", + "***", + "***", + Character.valueOf('*'), + new ItemStack(Items.coal, 1, 1) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(Items.coal, 9, 1), + new Object[] { "*", + Character.valueOf('*'), + new ItemStack(MekanismBlocks.BasicBlock, 1, 3) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.BasicBlock, 1, 2), + new Object[] { + "***", "***", "***", Character.valueOf('*'), "ingotRefinedObsidian" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.Ingot, 9, 0), + new Object[] { "*", + Character.valueOf('*'), + new ItemStack(MekanismBlocks.BasicBlock, 1, 2) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.BasicBlock, 1, 4), + new Object[] { + "***", "***", "***", Character.valueOf('*'), "ingotRefinedGlowstone" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.Ingot, 9, 3), + new Object[] { "*", + Character.valueOf('*'), + new ItemStack(MekanismBlocks.BasicBlock, 1, 4) } + )); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.Ingot, 9, 1), new Object[] { - "*", Character.valueOf('*'), new ItemStack(MekanismBlocks.BasicBlock, 1, 0) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.BasicBlock, 1, 1), new Object[] { - "***", "***", "***", Character.valueOf('*'), "ingotBronze" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.Ingot, 9, 2), new Object[] { - "*", Character.valueOf('*'), new ItemStack(MekanismBlocks.BasicBlock, 1, 1) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.BasicBlock, 1, 5), new Object[] { - "***", "***", "***", Character.valueOf('*'), "ingotSteel" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.Ingot, 9, 4), new Object[] { - "*", Character.valueOf('*'), new ItemStack(MekanismBlocks.BasicBlock, 1, 5) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.BasicBlock, 1, 12), new Object[] { - "***", "***", "***", Character.valueOf('*'), "ingotCopper" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.Ingot, 9, 5), new Object[] { - "*", Character.valueOf('*'), new ItemStack(MekanismBlocks.BasicBlock, 1, 12) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.BasicBlock, 1, 13), new Object[] { - "***", "***", "***", Character.valueOf('*'), "ingotTin" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.Ingot, 9, 6), new Object[] { - "*", Character.valueOf('*'), new ItemStack(MekanismBlocks.BasicBlock, 1, 13) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.SaltBlock), new Object[] { - "**", "**", Character.valueOf('*'), MekanismItems.Salt - })); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.Ingot, 9, 1), + new Object[] { "*", + Character.valueOf('*'), + new ItemStack(MekanismBlocks.BasicBlock, 1, 0) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.BasicBlock, 1, 1), + new Object[] { "***", "***", "***", Character.valueOf('*'), "ingotBronze" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.Ingot, 9, 2), + new Object[] { "*", + Character.valueOf('*'), + new ItemStack(MekanismBlocks.BasicBlock, 1, 1) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.BasicBlock, 1, 5), + new Object[] { "***", "***", "***", Character.valueOf('*'), "ingotSteel" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.Ingot, 9, 4), + new Object[] { "*", + Character.valueOf('*'), + new ItemStack(MekanismBlocks.BasicBlock, 1, 5) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.BasicBlock, 1, 12), + new Object[] { "***", "***", "***", Character.valueOf('*'), "ingotCopper" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.Ingot, 9, 5), + new Object[] { "*", + Character.valueOf('*'), + new ItemStack(MekanismBlocks.BasicBlock, 1, 12) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.BasicBlock, 1, 13), + new Object[] { "***", "***", "***", Character.valueOf('*'), "ingotTin" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.Ingot, 9, 6), + new Object[] { "*", + Character.valueOf('*'), + new ItemStack(MekanismBlocks.BasicBlock, 1, 13) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.SaltBlock), + new Object[] { "**", "**", Character.valueOf('*'), MekanismItems.Salt } + )); - //Base Recipes - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.ObsidianTNT, 1), new Object[] { - "***", "XXX", "***", Character.valueOf('*'), Blocks.obsidian, Character.valueOf('X'), Blocks.tnt - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(MekanismItems.ElectricBow.getUnchargedItem(), new Object[] { - " AB", "E B", " AB", Character.valueOf('A'), MekanismItems.EnrichedAlloy, Character.valueOf('B'), Items.string, Character.valueOf('E'), MekanismItems.EnergyTablet.getUnchargedItem() - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(MekanismItems.EnergyTablet.getUnchargedItem(), new Object[] { - "RCR", "ECE", "RCR", Character.valueOf('C'), "ingotGold", Character.valueOf('R'), "dustRedstone", Character.valueOf('E'), MekanismItems.EnrichedAlloy - })); - MachineType.ENRICHMENT_CHAMBER.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock, 1, 0), new Object[] { - "RCR", "iIi", "RCR", Character.valueOf('i'), "ingotIron", Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.BASIC), Character.valueOf('R'), "alloyBasic", Character.valueOf('I'), new ItemStack(MekanismBlocks.BasicBlock, 1, 8) - })); - MachineType.OSMIUM_COMPRESSOR.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock, 1, 1), new Object[] { - "ECE", "BIB", "ECE", Character.valueOf('E'), "alloyAdvanced", Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.ADVANCED), Character.valueOf('B'), Items.bucket, Character.valueOf('I'), new ItemStack(MekanismBlocks.BasicBlock, 1, 8) - })); - MachineType.COMBINER.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock, 1, 2), new Object[] { - "RCR", "SIS", "RCR", Character.valueOf('S'), Blocks.cobblestone, Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.ELITE), Character.valueOf('R'), "alloyElite", Character.valueOf('I'), new ItemStack(MekanismBlocks.BasicBlock, 1, 8) - })); - MachineType.CRUSHER.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock, 1, 3), new Object[] { - "RCR", "LIL", "RCR", Character.valueOf('R'), "dustRedstone", Character.valueOf('L'), Items.lava_bucket, Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.BASIC), Character.valueOf('I'), new ItemStack(MekanismBlocks.BasicBlock, 1, 8) - })); + //Base Recipes + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.ObsidianTNT, 1), + new Object[] { "***", + "XXX", + "***", + Character.valueOf('*'), + Blocks.obsidian, + Character.valueOf('X'), + Blocks.tnt } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + MekanismItems.ElectricBow.getUnchargedItem(), + new Object[] { " AB", + "E B", + " AB", + Character.valueOf('A'), + MekanismItems.EnrichedAlloy, + Character.valueOf('B'), + Items.string, + Character.valueOf('E'), + MekanismItems.EnergyTablet.getUnchargedItem() } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + MekanismItems.EnergyTablet.getUnchargedItem(), + new Object[] { "RCR", + "ECE", + "RCR", + Character.valueOf('C'), + "ingotGold", + Character.valueOf('R'), + "dustRedstone", + Character.valueOf('E'), + MekanismItems.EnrichedAlloy } + )); + MachineType.ENRICHMENT_CHAMBER.addRecipe(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.MachineBlock, 1, 0), + new Object[] { "RCR", + "iIi", + "RCR", + Character.valueOf('i'), + "ingotIron", + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.BASIC), + Character.valueOf('R'), + "alloyBasic", + Character.valueOf('I'), + new ItemStack(MekanismBlocks.BasicBlock, 1, 8) } + )); + MachineType.OSMIUM_COMPRESSOR.addRecipe(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.MachineBlock, 1, 1), + new Object[] { "ECE", + "BIB", + "ECE", + Character.valueOf('E'), + "alloyAdvanced", + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.ADVANCED), + Character.valueOf('B'), + Items.bucket, + Character.valueOf('I'), + new ItemStack(MekanismBlocks.BasicBlock, 1, 8) } + )); + MachineType.COMBINER.addRecipe(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.MachineBlock, 1, 2), + new Object[] { "RCR", + "SIS", + "RCR", + Character.valueOf('S'), + Blocks.cobblestone, + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.ELITE), + Character.valueOf('R'), + "alloyElite", + Character.valueOf('I'), + new ItemStack(MekanismBlocks.BasicBlock, 1, 8) } + )); + MachineType.CRUSHER.addRecipe(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.MachineBlock, 1, 3), + new Object[] { "RCR", + "LIL", + "RCR", + Character.valueOf('R'), + "dustRedstone", + Character.valueOf('L'), + Items.lava_bucket, + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.BASIC), + Character.valueOf('I'), + new ItemStack(MekanismBlocks.BasicBlock, 1, 8) } + )); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.EnergyUpgrade), new Object[] { - " G ", "ADA", " G ", Character.valueOf('G'), "blockGlass", Character.valueOf('A'), MekanismItems.EnrichedAlloy, Character.valueOf('D'), "dustGold" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.GasUpgrade), new Object[] { - " G ", "ADA", " G ", Character.valueOf('G'), "blockGlass", Character.valueOf('A'), MekanismItems.EnrichedAlloy, Character.valueOf('D'), "dustIron" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.FilterUpgrade), new Object[] { - " G ", "ADA", " G ", Character.valueOf('G'), "blockGlass", Character.valueOf('A'), MekanismItems.EnrichedAlloy, Character.valueOf('D'), "dustTin" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.MufflingUpgrade), new Object[] { - " G ", "ADA", " G ", Character.valueOf('G'), "blockGlass", Character.valueOf('A'), MekanismItems.EnrichedAlloy, Character.valueOf('D'), "dustSteel" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(MekanismItems.AtomicDisassembler.getUnchargedItem(), new Object[] { - "AEA", "ACA", " O ", Character.valueOf('A'), MekanismItems.EnrichedAlloy, Character.valueOf('E'), MekanismItems.EnergyTablet.getUnchargedItem(), Character.valueOf('C'), MekanismItems.AtomicAlloy, Character.valueOf('O'), "ingotRefinedObsidian" - })); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.EnergyUpgrade), + new Object[] { " G ", + "ADA", + " G ", + Character.valueOf('G'), + "blockGlass", + Character.valueOf('A'), + MekanismItems.EnrichedAlloy, + Character.valueOf('D'), + "dustGold" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.GasUpgrade), + new Object[] { " G ", + "ADA", + " G ", + Character.valueOf('G'), + "blockGlass", + Character.valueOf('A'), + MekanismItems.EnrichedAlloy, + Character.valueOf('D'), + "dustIron" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.FilterUpgrade), + new Object[] { " G ", + "ADA", + " G ", + Character.valueOf('G'), + "blockGlass", + Character.valueOf('A'), + MekanismItems.EnrichedAlloy, + Character.valueOf('D'), + "dustTin" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.MufflingUpgrade), + new Object[] { " G ", + "ADA", + " G ", + Character.valueOf('G'), + "blockGlass", + Character.valueOf('A'), + MekanismItems.EnrichedAlloy, + Character.valueOf('D'), + "dustSteel" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + MekanismItems.AtomicDisassembler.getUnchargedItem(), + new Object[] { "AEA", + "ACA", + " O ", + Character.valueOf('A'), + MekanismItems.EnrichedAlloy, + Character.valueOf('E'), + MekanismItems.EnergyTablet.getUnchargedItem(), + Character.valueOf('C'), + MekanismItems.AtomicAlloy, + Character.valueOf('O'), + "ingotRefinedObsidian" } + )); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.TeleportationCore), new Object[] { - "LAL", "GDG", "LAL", Character.valueOf('L'), new ItemStack(Items.dye, 1, 4), Character.valueOf('A'), MekanismItems.AtomicAlloy, Character.valueOf('G'), "ingotGold", Character.valueOf('D'), Items.diamond - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(MekanismItems.PortableTeleporter.getUnchargedItem(), new Object[] { - " E ", "CTC", " E ", Character.valueOf('E'), MekanismItems.EnergyTablet.getUnchargedItem(), Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.BASIC), Character.valueOf('T'), MekanismItems.TeleportationCore - })); - MachineType.TELEPORTER.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock, 1, 11), new Object[] { - "COC", "OTO", "COC", Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.BASIC), Character.valueOf('O'), new ItemStack(MekanismBlocks.BasicBlock, 1, 8), Character.valueOf('T'), MekanismItems.TeleportationCore - })); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.TeleportationCore), + new Object[] { "LAL", + "GDG", + "LAL", + Character.valueOf('L'), + new ItemStack(Items.dye, 1, 4), + Character.valueOf('A'), + MekanismItems.AtomicAlloy, + Character.valueOf('G'), + "ingotGold", + Character.valueOf('D'), + Items.diamond } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + MekanismItems.PortableTeleporter.getUnchargedItem(), + new Object[] { " E ", + "CTC", + " E ", + Character.valueOf('E'), + MekanismItems.EnergyTablet.getUnchargedItem(), + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.BASIC), + Character.valueOf('T'), + MekanismItems.TeleportationCore } + )); + MachineType.TELEPORTER.addRecipe(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.MachineBlock, 1, 11), + new Object[] { "COC", + "OTO", + "COC", + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.BASIC), + Character.valueOf('O'), + new ItemStack(MekanismBlocks.BasicBlock, 1, 8), + Character.valueOf('T'), + MekanismItems.TeleportationCore } + )); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(MekanismItems.Configurator.getUnchargedItem(), new Object[] { - " L ", "AEA", " S ", Character.valueOf('L'), new ItemStack(Items.dye, 1, 4), Character.valueOf('A'), MekanismItems.EnrichedAlloy, Character.valueOf('E'), MekanismItems.EnergyTablet.getUnchargedItem(), Character.valueOf('S'), Items.stick - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.BasicBlock, 9, 7), new Object[] { - "OOO", "OGO", "OOO", Character.valueOf('O'), "ingotRefinedObsidian", Character.valueOf('G'), "ingotRefinedGlowstone" - })); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + MekanismItems.Configurator.getUnchargedItem(), + new Object[] { " L ", + "AEA", + " S ", + Character.valueOf('L'), + new ItemStack(Items.dye, 1, 4), + Character.valueOf('A'), + MekanismItems.EnrichedAlloy, + Character.valueOf('E'), + MekanismItems.EnergyTablet.getUnchargedItem(), + Character.valueOf('S'), + Items.stick } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.BasicBlock, 9, 7), + new Object[] { "OOO", + "OGO", + "OOO", + Character.valueOf('O'), + "ingotRefinedObsidian", + Character.valueOf('G'), + "ingotRefinedGlowstone" } + )); - MachineType.ENERGIZED_SMELTER.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock, 1, 10), new Object[] { - "RCR", "GIG", "RCR", Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.BASIC), Character.valueOf('R'), "alloyBasic", Character.valueOf('G'), "blockGlass", Character.valueOf('I'), new ItemStack(MekanismBlocks.BasicBlock, 1, 8) - })); + MachineType.ENERGIZED_SMELTER.addRecipe(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.MachineBlock, 1, 10), + new Object[] { "RCR", + "GIG", + "RCR", + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.BASIC), + Character.valueOf('R'), + "alloyBasic", + Character.valueOf('G'), + "blockGlass", + Character.valueOf('I'), + new ItemStack(MekanismBlocks.BasicBlock, 1, 8) } + )); - MachineType.PERSONAL_CHEST.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock, 1, 13), new Object[] { - "SGS", "CcC", "SSS", Character.valueOf('S'), "ingotSteel", Character.valueOf('G'), "blockGlass", Character.valueOf('C'), Blocks.chest, Character.valueOf('c'), MekanismUtils.getControlCircuit(BaseTier.BASIC) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.BasicBlock, 4, 9), new Object[] { - " I ", "IBI", " I ", Character.valueOf('I'), "ingotSteel", Character.valueOf('B'), Items.bucket - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.BasicBlock, 4, 10), new Object[] { - " I ", "IGI", " I ", Character.valueOf('I'), "ingotSteel", Character.valueOf('G'), "blockGlass" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.BasicBlock, 2, 11), new Object[] { - " I ", "ICI", " I ", Character.valueOf('I'), new ItemStack(MekanismBlocks.BasicBlock, 1, 9), Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.BASIC) - })); - MachineType.CHARGEPAD.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock, 1, 14), new Object[] { - "PPP", "SES", Character.valueOf('P'), Blocks.stone_pressure_plate, Character.valueOf('S'), "ingotSteel", Character.valueOf('E'), MekanismItems.EnergyTablet.getUnchargedItem() - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(MekanismItems.Robit.getUnchargedItem(), new Object[] { - " S ", "ECE", "OIO", Character.valueOf('S'), "ingotSteel", Character.valueOf('E'), MekanismItems.EnergyTablet.getUnchargedItem(), Character.valueOf('C'), MekanismItems.AtomicAlloy, Character.valueOf('O'), "ingotRefinedObsidian", Character.valueOf('I'), new ItemStack(MekanismBlocks.MachineBlock, 1, 13) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(MekanismItems.NetworkReader.getUnchargedItem(), new Object[] { - " G ", "AEA", " I ", Character.valueOf('G'), "blockGlass", Character.valueOf('A'), MekanismItems.EnrichedAlloy, Character.valueOf('E'), MekanismItems.EnergyTablet.getUnchargedItem(), Character.valueOf('I'), "ingotSteel" - })); + MachineType.PERSONAL_CHEST.addRecipe(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.MachineBlock, 1, 13), + new Object[] { "SGS", + "CcC", + "SSS", + Character.valueOf('S'), + "ingotSteel", + Character.valueOf('G'), + "blockGlass", + Character.valueOf('C'), + Blocks.chest, + Character.valueOf('c'), + MekanismUtils.getControlCircuit(BaseTier.BASIC) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.BasicBlock, 4, 9), + new Object[] { " I ", + "IBI", + " I ", + Character.valueOf('I'), + "ingotSteel", + Character.valueOf('B'), + Items.bucket } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.BasicBlock, 4, 10), + new Object[] { " I ", + "IGI", + " I ", + Character.valueOf('I'), + "ingotSteel", + Character.valueOf('G'), + "blockGlass" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.BasicBlock, 2, 11), + new Object[] { " I ", + "ICI", + " I ", + Character.valueOf('I'), + new ItemStack(MekanismBlocks.BasicBlock, 1, 9), + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.BASIC) } + )); + MachineType.CHARGEPAD.addRecipe(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.MachineBlock, 1, 14), + new Object[] { "PPP", + "SES", + Character.valueOf('P'), + Blocks.stone_pressure_plate, + Character.valueOf('S'), + "ingotSteel", + Character.valueOf('E'), + MekanismItems.EnergyTablet.getUnchargedItem() } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + MekanismItems.Robit.getUnchargedItem(), + new Object[] { " S ", + "ECE", + "OIO", + Character.valueOf('S'), + "ingotSteel", + Character.valueOf('E'), + MekanismItems.EnergyTablet.getUnchargedItem(), + Character.valueOf('C'), + MekanismItems.AtomicAlloy, + Character.valueOf('O'), + "ingotRefinedObsidian", + Character.valueOf('I'), + new ItemStack(MekanismBlocks.MachineBlock, 1, 13) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + MekanismItems.NetworkReader.getUnchargedItem(), + new Object[] { " G ", + "AEA", + " I ", + Character.valueOf('G'), + "blockGlass", + Character.valueOf('A'), + MekanismItems.EnrichedAlloy, + Character.valueOf('E'), + MekanismItems.EnergyTablet.getUnchargedItem(), + Character.valueOf('I'), + "ingotSteel" } + )); - MachineType.LOGISTICAL_SORTER.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock, 1, 15), new Object[] { - "IPI", "ICI", "III", Character.valueOf('I'), "ingotIron", Character.valueOf('P'), Blocks.piston, Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.BASIC) - })); - MachineType.DIGITAL_MINER.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock, 1, 4), new Object[] { - "ACA", "SES", "TIT", Character.valueOf('A'), MekanismItems.AtomicAlloy, Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.BASIC), Character.valueOf('S'), new ItemStack(MekanismBlocks.MachineBlock, 1, 15), Character.valueOf('E'), MekanismItems.Robit.getUnchargedItem(), - Character.valueOf('I'), new ItemStack(MekanismBlocks.BasicBlock, 1, 8), Character.valueOf('T'), MekanismItems.TeleportationCore - })); - MachineType.ROTARY_CONDENSENTRATOR.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock2, 1, 0), new Object[] { - "GCG", "tEI", "GCG", Character.valueOf('G'), "blockGlass", Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.BASIC), Character.valueOf('t'), MekanismUtils.getEmptyGasTank(GasTankTier.BASIC), Character.valueOf('E'), MekanismItems.EnergyTablet.getUnchargedItem(), - Character.valueOf('T'), new ItemStack(MekanismBlocks.BasicBlock, 1, 9), Character.valueOf('I'), MekanismUtils.getEmptyFluidTank(FluidTankTier.BASIC) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(MekanismItems.Jetpack.getEmptyItem(), new Object[] { - "SCS", "TGT", " T ", Character.valueOf('S'), "ingotSteel", Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.BASIC), Character.valueOf('T'), "ingotTin", Character.valueOf('G'), MekanismUtils.getEmptyGasTank(GasTankTier.BASIC) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.Dictionary), new Object[] { - "C", "B", Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.BASIC), Character.valueOf('B'), Items.book - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.GasMask), new Object[] { - " S ", "GCG", "S S", Character.valueOf('S'), "ingotSteel", Character.valueOf('G'), "blockGlass", Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.BASIC) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(MekanismItems.ScubaTank.getEmptyItem(), new Object[] { - " C ", "ATA", "SSS", Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.BASIC), Character.valueOf('A'), MekanismItems.EnrichedAlloy, Character.valueOf('S'), "ingotSteel" - })); - MachineType.CHEMICAL_OXIDIZER.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock2, 1, 1), new Object[] { - "ACA", "ERG", "ACA", Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.BASIC), Character.valueOf('R'), new ItemStack(MekanismBlocks.BasicBlock, 1, 9), Character.valueOf('G'), MekanismUtils.getEmptyGasTank(GasTankTier.BASIC), Character.valueOf('E'), new ItemStack(MekanismBlocks.MachineBlock, 1, 13), Character.valueOf('A'), MekanismItems.EnrichedAlloy - })); - MachineType.CHEMICAL_INFUSER.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock2, 1, 2), new Object[] { - "ACA", "GRG", "ACA", Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.BASIC), Character.valueOf('R'), new ItemStack(MekanismBlocks.BasicBlock, 1, 9), Character.valueOf('G'), MekanismUtils.getEmptyGasTank(GasTankTier.BASIC), Character.valueOf('A'), MekanismItems.EnrichedAlloy - })); - MachineType.CHEMICAL_INJECTION_CHAMBER.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock2, 1, 3), new Object[] { - "RCR", "GPG", "RCR", Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.ELITE), Character.valueOf('R'), "alloyElite", Character.valueOf('G'), "ingotGold", Character.valueOf('P'), new ItemStack(MekanismBlocks.MachineBlock, 1, 9) - })); - MachineType.ELECTROLYTIC_SEPARATOR.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock2, 1, 4), new Object[] { - "IRI", "ECE", "IRI", Character.valueOf('I'), "ingotIron", Character.valueOf('R'), "dustRedstone", Character.valueOf('E'), MekanismItems.EnrichedAlloy, Character.valueOf('C'), MekanismItems.ElectrolyticCore - })); + MachineType.LOGISTICAL_SORTER.addRecipe(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.MachineBlock, 1, 15), + new Object[] { "IPI", + "ICI", + "III", + Character.valueOf('I'), + "ingotIron", + Character.valueOf('P'), + Blocks.piston, + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.BASIC) } + )); + MachineType.DIGITAL_MINER.addRecipe(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.MachineBlock, 1, 4), + new Object[] { "ACA", + "SES", + "TIT", + Character.valueOf('A'), + MekanismItems.AtomicAlloy, + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.BASIC), + Character.valueOf('S'), + new ItemStack(MekanismBlocks.MachineBlock, 1, 15), + Character.valueOf('E'), + MekanismItems.Robit.getUnchargedItem(), + Character.valueOf('I'), + new ItemStack(MekanismBlocks.BasicBlock, 1, 8), + Character.valueOf('T'), + MekanismItems.TeleportationCore } + )); + MachineType.ROTARY_CONDENSENTRATOR.addRecipe(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.MachineBlock2, 1, 0), + new Object[] { "GCG", + "tEI", + "GCG", + Character.valueOf('G'), + "blockGlass", + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.BASIC), + Character.valueOf('t'), + MekanismUtils.getEmptyGasTank(GasTankTier.BASIC), + Character.valueOf('E'), + MekanismItems.EnergyTablet.getUnchargedItem(), + Character.valueOf('T'), + new ItemStack(MekanismBlocks.BasicBlock, 1, 9), + Character.valueOf('I'), + MekanismUtils.getEmptyFluidTank(FluidTankTier.BASIC) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + MekanismItems.Jetpack.getEmptyItem(), + new Object[] { "SCS", + "TGT", + " T ", + Character.valueOf('S'), + "ingotSteel", + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.BASIC), + Character.valueOf('T'), + "ingotTin", + Character.valueOf('G'), + MekanismUtils.getEmptyGasTank(GasTankTier.BASIC) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.Dictionary), + new Object[] { "C", + "B", + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.BASIC), + Character.valueOf('B'), + Items.book } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.GasMask), + new Object[] { " S ", + "GCG", + "S S", + Character.valueOf('S'), + "ingotSteel", + Character.valueOf('G'), + "blockGlass", + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.BASIC) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + MekanismItems.ScubaTank.getEmptyItem(), + new Object[] { " C ", + "ATA", + "SSS", + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.BASIC), + Character.valueOf('A'), + MekanismItems.EnrichedAlloy, + Character.valueOf('S'), + "ingotSteel" } + )); + MachineType.CHEMICAL_OXIDIZER.addRecipe(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.MachineBlock2, 1, 1), + new Object[] { "ACA", + "ERG", + "ACA", + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.BASIC), + Character.valueOf('R'), + new ItemStack(MekanismBlocks.BasicBlock, 1, 9), + Character.valueOf('G'), + MekanismUtils.getEmptyGasTank(GasTankTier.BASIC), + Character.valueOf('E'), + new ItemStack(MekanismBlocks.MachineBlock, 1, 13), + Character.valueOf('A'), + MekanismItems.EnrichedAlloy } + )); + MachineType.CHEMICAL_INFUSER.addRecipe(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.MachineBlock2, 1, 2), + new Object[] { "ACA", + "GRG", + "ACA", + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.BASIC), + Character.valueOf('R'), + new ItemStack(MekanismBlocks.BasicBlock, 1, 9), + Character.valueOf('G'), + MekanismUtils.getEmptyGasTank(GasTankTier.BASIC), + Character.valueOf('A'), + MekanismItems.EnrichedAlloy } + )); + MachineType.CHEMICAL_INJECTION_CHAMBER.addRecipe(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.MachineBlock2, 1, 3), + new Object[] { "RCR", + "GPG", + "RCR", + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.ELITE), + Character.valueOf('R'), + "alloyElite", + Character.valueOf('G'), + "ingotGold", + Character.valueOf('P'), + new ItemStack(MekanismBlocks.MachineBlock, 1, 9) } + )); + MachineType.ELECTROLYTIC_SEPARATOR.addRecipe(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.MachineBlock2, 1, 4), + new Object[] { "IRI", + "ECE", + "IRI", + Character.valueOf('I'), + "ingotIron", + Character.valueOf('R'), + "dustRedstone", + Character.valueOf('E'), + MekanismItems.EnrichedAlloy, + Character.valueOf('C'), + MekanismItems.ElectrolyticCore } + )); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.CardboardBox), new Object[] { - "SS", "SS", Character.valueOf('S'), "pulpWood" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(Items.paper, 6), new Object[] { - "SSS", Character.valueOf('S'), MekanismItems.Sawdust - })); - MachineType.PRECISION_SAWMILL.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock2, 1, 5), new Object[] { - "ICI", "ASA", "ICI", Character.valueOf('I'), "ingotIron", Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.BASIC), Character.valueOf('A'), MekanismItems.EnrichedAlloy, Character.valueOf('S'), new ItemStack(MekanismBlocks.BasicBlock, 1, 8) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.BasicBlock, 1, 14), new Object[] { - "CGC", "IBI", "III", Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.ADVANCED), Character.valueOf('G'), "paneGlass", Character.valueOf('I'), new ItemStack(MekanismBlocks.BasicBlock2, 1, 0), Character.valueOf('B'), Items.bucket - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.BasicBlock, 1, 15), new Object[] { - " I ", "ICI", " I ", Character.valueOf('I'), new ItemStack(MekanismBlocks.BasicBlock2, 1, 0), Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.ADVANCED) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.BasicBlock2, 4, 0), new Object[] { - " S ", "SCS", " S ", Character.valueOf('C'), "ingotCopper", Character.valueOf('S'), "ingotSteel" - })); - MachineType.CHEMICAL_DISSOLUTION_CHAMBER.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock2, 1, 6), new Object[] { - "CGC", "EAE", "CGC", Character.valueOf('G'), MekanismUtils.getEmptyGasTank(GasTankTier.BASIC), Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.BASIC), Character.valueOf('A'), MekanismItems.AtomicAlloy, Character.valueOf('E'), MekanismItems.EnrichedAlloy - })); - MachineType.CHEMICAL_WASHER.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock2, 1, 7), new Object[] { - "CWC", "EIE", "CGC", Character.valueOf('W'), Items.bucket, Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.BASIC), Character.valueOf('E'), MekanismItems.EnrichedAlloy, Character.valueOf('G'), MekanismUtils.getEmptyGasTank(GasTankTier.BASIC), Character.valueOf('I'), new ItemStack(MekanismBlocks.BasicBlock, 1, 8) - })); - MachineType.CHEMICAL_CRYSTALLIZER.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock2, 1, 8), new Object[] { - "CGC", "ASA", "CGC", Character.valueOf('G'), MekanismUtils.getEmptyGasTank(GasTankTier.BASIC), Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.BASIC), Character.valueOf('A'), MekanismItems.AtomicAlloy, Character.valueOf('S'), new ItemStack(MekanismBlocks.BasicBlock, 1, 8) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(MekanismItems.FreeRunners.getUnchargedItem(), new Object[] { - "C C", "A A", "T T", Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.BASIC), Character.valueOf('A'), MekanismItems.EnrichedAlloy, Character.valueOf('T'), MekanismItems.EnergyTablet.getUnchargedItem() - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(MekanismItems.ArmoredJetpack.getEmptyItem(), new Object[] { - "D D", "BSB", " J ", Character.valueOf('D'), "dustDiamond", Character.valueOf('B'), "ingotBronze", Character.valueOf('S'), "blockSteel", Character.valueOf('J'), MekanismItems.Jetpack.getEmptyItem() - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.ConfigurationCard), new Object[] { - " A ", "ACA", " A ", Character.valueOf('A'), MekanismItems.EnrichedAlloy, Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.BASIC) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(MekanismItems.SeismicReader.getUnchargedItem(), new Object[] { - "SLS", "STS", "SSS", Character.valueOf('S'), "ingotSteel", Character.valueOf('L'), new ItemStack(Items.dye, 1, 4), Character.valueOf('T'), MekanismItems.EnergyTablet.getUnchargedItem() - })); - MachineType.SEISMIC_VIBRATOR.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock2, 1, 9), new Object[] { - "TLT", "CIC", "TTT", Character.valueOf('T'), "ingotTin", Character.valueOf('L'), new ItemStack(Items.dye, 1, 4), Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.BASIC), Character.valueOf('I'), new ItemStack(MekanismBlocks.BasicBlock, 1, 8) - })); - MachineType.PRESSURIZED_REACTION_CHAMBER.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock2, 1, 10), new Object[] { - "TET", "CIC", "GFG", Character.valueOf('S'), "ingotSteel", Character.valueOf('E'), MekanismItems.EnrichedAlloy, Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.BASIC), Character.valueOf('G'), MekanismUtils.getEmptyGasTank(GasTankTier.BASIC), - Character.valueOf('I'), new ItemStack(MekanismBlocks.MachineBlock, 1, 0), Character.valueOf('F'), new ItemStack(MekanismBlocks.BasicBlock, 1, 9) - })); - MachineType.FLUIDIC_PLENISHER.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock2, 1, 12), new Object[] { - "TTT", "CPC", "TTT", Character.valueOf('P'), new ItemStack(MekanismBlocks.MachineBlock, 1, 12), Character.valueOf('T'), "ingotTin", Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.BASIC) - })); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.CardboardBox), + new Object[] { "SS", "SS", Character.valueOf('S'), "pulpWood" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(Items.paper, 6), + new Object[] { "SSS", Character.valueOf('S'), MekanismItems.Sawdust } + )); + MachineType.PRECISION_SAWMILL.addRecipe(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.MachineBlock2, 1, 5), + new Object[] { "ICI", + "ASA", + "ICI", + Character.valueOf('I'), + "ingotIron", + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.BASIC), + Character.valueOf('A'), + MekanismItems.EnrichedAlloy, + Character.valueOf('S'), + new ItemStack(MekanismBlocks.BasicBlock, 1, 8) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.BasicBlock, 1, 14), + new Object[] { "CGC", + "IBI", + "III", + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.ADVANCED), + Character.valueOf('G'), + "paneGlass", + Character.valueOf('I'), + new ItemStack(MekanismBlocks.BasicBlock2, 1, 0), + Character.valueOf('B'), + Items.bucket } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.BasicBlock, 1, 15), + new Object[] { " I ", + "ICI", + " I ", + Character.valueOf('I'), + new ItemStack(MekanismBlocks.BasicBlock2, 1, 0), + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.ADVANCED) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.BasicBlock2, 4, 0), + new Object[] { " S ", + "SCS", + " S ", + Character.valueOf('C'), + "ingotCopper", + Character.valueOf('S'), + "ingotSteel" } + )); + MachineType.CHEMICAL_DISSOLUTION_CHAMBER.addRecipe(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.MachineBlock2, 1, 6), + new Object[] { "CGC", + "EAE", + "CGC", + Character.valueOf('G'), + MekanismUtils.getEmptyGasTank(GasTankTier.BASIC), + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.BASIC), + Character.valueOf('A'), + MekanismItems.AtomicAlloy, + Character.valueOf('E'), + MekanismItems.EnrichedAlloy } + )); + MachineType.CHEMICAL_WASHER.addRecipe(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.MachineBlock2, 1, 7), + new Object[] { "CWC", + "EIE", + "CGC", + Character.valueOf('W'), + Items.bucket, + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.BASIC), + Character.valueOf('E'), + MekanismItems.EnrichedAlloy, + Character.valueOf('G'), + MekanismUtils.getEmptyGasTank(GasTankTier.BASIC), + Character.valueOf('I'), + new ItemStack(MekanismBlocks.BasicBlock, 1, 8) } + )); + MachineType.CHEMICAL_CRYSTALLIZER.addRecipe(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.MachineBlock2, 1, 8), + new Object[] { "CGC", + "ASA", + "CGC", + Character.valueOf('G'), + MekanismUtils.getEmptyGasTank(GasTankTier.BASIC), + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.BASIC), + Character.valueOf('A'), + MekanismItems.AtomicAlloy, + Character.valueOf('S'), + new ItemStack(MekanismBlocks.BasicBlock, 1, 8) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + MekanismItems.FreeRunners.getUnchargedItem(), + new Object[] { "C C", + "A A", + "T T", + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.BASIC), + Character.valueOf('A'), + MekanismItems.EnrichedAlloy, + Character.valueOf('T'), + MekanismItems.EnergyTablet.getUnchargedItem() } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + MekanismItems.ArmoredJetpack.getEmptyItem(), + new Object[] { "D D", + "BSB", + " J ", + Character.valueOf('D'), + "dustDiamond", + Character.valueOf('B'), + "ingotBronze", + Character.valueOf('S'), + "blockSteel", + Character.valueOf('J'), + MekanismItems.Jetpack.getEmptyItem() } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.ConfigurationCard), + new Object[] { " A ", + "ACA", + " A ", + Character.valueOf('A'), + MekanismItems.EnrichedAlloy, + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.BASIC) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + MekanismItems.SeismicReader.getUnchargedItem(), + new Object[] { "SLS", + "STS", + "SSS", + Character.valueOf('S'), + "ingotSteel", + Character.valueOf('L'), + new ItemStack(Items.dye, 1, 4), + Character.valueOf('T'), + MekanismItems.EnergyTablet.getUnchargedItem() } + )); + MachineType.SEISMIC_VIBRATOR.addRecipe(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.MachineBlock2, 1, 9), + new Object[] { "TLT", + "CIC", + "TTT", + Character.valueOf('T'), + "ingotTin", + Character.valueOf('L'), + new ItemStack(Items.dye, 1, 4), + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.BASIC), + Character.valueOf('I'), + new ItemStack(MekanismBlocks.BasicBlock, 1, 8) } + )); + MachineType.PRESSURIZED_REACTION_CHAMBER.addRecipe(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.MachineBlock2, 1, 10), + new Object[] { "TET", + "CIC", + "GFG", + Character.valueOf('S'), + "ingotSteel", + Character.valueOf('E'), + MekanismItems.EnrichedAlloy, + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.BASIC), + Character.valueOf('G'), + MekanismUtils.getEmptyGasTank(GasTankTier.BASIC), + Character.valueOf('I'), + new ItemStack(MekanismBlocks.MachineBlock, 1, 0), + Character.valueOf('F'), + new ItemStack(MekanismBlocks.BasicBlock, 1, 9) } + )); + MachineType.FLUIDIC_PLENISHER.addRecipe(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.MachineBlock2, 1, 12), + new Object[] { "TTT", + "CPC", + "TTT", + Character.valueOf('P'), + new ItemStack(MekanismBlocks.MachineBlock, 1, 12), + Character.valueOf('T'), + "ingotTin", + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.BASIC) } + )); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(MekanismItems.Flamethrower.getEmptyItem(), new Object[] { - "TTT", "TGS", "BCB", Character.valueOf('T'), "ingotTin", Character.valueOf('G'), MekanismUtils.getEmptyGasTank(GasTankTier.BASIC), Character.valueOf('S'), Items.flint_and_steel, Character.valueOf('B'), "ingotBronze", Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.ADVANCED) - })); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + MekanismItems.Flamethrower.getEmptyItem(), + new Object[] { "TTT", + "TGS", + "BCB", + Character.valueOf('T'), + "ingotTin", + Character.valueOf('G'), + MekanismUtils.getEmptyGasTank(GasTankTier.BASIC), + Character.valueOf('S'), + Items.flint_and_steel, + Character.valueOf('B'), + "ingotBronze", + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.ADVANCED) } + )); - MachineType.SOLAR_NEUTRON_ACTIVATOR.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock3, 1, 1), new Object[] { - "APA", "CSC", "BBB", Character.valueOf('A'), "alloyElite", Character.valueOf('S'), new ItemStack(MekanismBlocks.BasicBlock, 1, 8), Character.valueOf('P'), new ItemStack(MekanismItems.Polyethene, 1, 2), Character.valueOf('B'), "ingotBronze", Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.ELITE) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.BasicBlock2, 4, 1), new Object[] { - " S ", "SES", " S ", Character.valueOf('S'), "ingotSteel", Character.valueOf('E'), MekanismItems.EnergyTablet.getUnchargedItem() - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.BasicBlock2, 2, 2), new Object[] { - " I ", "ICI", " I ", Character.valueOf('I'), new ItemStack(MekanismBlocks.BasicBlock2, 1, 1), Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.ELITE) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.TierInstaller, 1, 0), new Object[] { - "RCR", "iWi", "RCR", Character.valueOf('R'), "alloyBasic", Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.BASIC), Character.valueOf('i'), "ingotIron", Character.valueOf('W'), "plankWood" - })); + MachineType.SOLAR_NEUTRON_ACTIVATOR.addRecipe(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.MachineBlock3, 1, 1), + new Object[] { "APA", + "CSC", + "BBB", + Character.valueOf('A'), + "alloyElite", + Character.valueOf('S'), + new ItemStack(MekanismBlocks.BasicBlock, 1, 8), + Character.valueOf('P'), + new ItemStack(MekanismItems.Polyethene, 1, 2), + Character.valueOf('B'), + "ingotBronze", + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.ELITE) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.BasicBlock2, 4, 1), + new Object[] { " S ", + "SES", + " S ", + Character.valueOf('S'), + "ingotSteel", + Character.valueOf('E'), + MekanismItems.EnergyTablet.getUnchargedItem() } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.BasicBlock2, 2, 2), + new Object[] { " I ", + "ICI", + " I ", + Character.valueOf('I'), + new ItemStack(MekanismBlocks.BasicBlock2, 1, 1), + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.ELITE) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.TierInstaller, 1, 0), + new Object[] { "RCR", + "iWi", + "RCR", + Character.valueOf('R'), + "alloyBasic", + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.BASIC), + Character.valueOf('i'), + "ingotIron", + Character.valueOf('W'), + "plankWood" } + )); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.TierInstaller, 1, 2), new Object[] { - "RCR", "gWg", "RCR", Character.valueOf('R'), "alloyElite", Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.ELITE), Character.valueOf('g'), "ingotGold", Character.valueOf('W'), "plankWood" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.TierInstaller, 1, 3), new Object[] { - "RCR", "dWd", "RCR", Character.valueOf('R'), "alloyUltimate", Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.ULTIMATE), Character.valueOf('d'), "gemDiamond", Character.valueOf('W'), "plankWood" - })); - MachineType.OREDICTIONIFICATOR.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock3, 1, 3), new Object[] { - "SGS", "CBC", "SWS", Character.valueOf('S'), "ingotSteel", Character.valueOf('G'), "paneGlass", Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.BASIC), Character.valueOf('B'), MekanismItems.Dictionary, Character.valueOf('W'), Blocks.chest - })); - MachineType.LASER.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock2, 1, 13), new Object[] { - "RE ", "RCD", "RE ", Character.valueOf('R'), "alloyElite", Character.valueOf('E'), MekanismItems.EnergyTablet.getUnchargedItem(), Character.valueOf('C'), new ItemStack(MekanismBlocks.BasicBlock, 1, 8), Character.valueOf('D'), "gemDiamond" - })); - MachineType.LASER_AMPLIFIER.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock2, 1, 14), new Object[] { - "SSS", "SED", "SSS", Character.valueOf('S'), "ingotSteel", Character.valueOf('E'), MekanismUtils.getEnergyCube(EnergyCubeTier.BASIC), Character.valueOf('D'), "gemDiamond" - })); - MachineType.LASER_TRACTOR_BEAM.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock2, 1, 15), new Object[] { - "C", "F", Character.valueOf('C'), new ItemStack(MekanismBlocks.MachineBlock, 1, 13), Character.valueOf('F'), new ItemStack(MekanismBlocks.MachineBlock2, 1, 14) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.BasicBlock2, 1, 6), new Object[] { - "SFS", "FAF", "SFS", Character.valueOf('S'), "ingotSteel", Character.valueOf('A'), MekanismItems.EnrichedAlloy, Character.valueOf('F'), Blocks.iron_bars - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.BasicBlock2, 4, 7), new Object[] { - " S ", "SIS", " S ", Character.valueOf('S'), "ingotSteel", Character.valueOf('I'), "ingotIron" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.BasicBlock2, 2, 8), new Object[] { - " I ", "ICI", " I ", Character.valueOf('I'), new ItemStack(MekanismBlocks.BasicBlock2, 1, 7), Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.ADVANCED) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.BasicBlock2, 1, 5), new Object[] { - "ACA", "CIC", "ACA", Character.valueOf('I'), new ItemStack(MekanismBlocks.BasicBlock, 1, 8), Character.valueOf('C'), "ingotCopper", Character.valueOf('A'), "alloyBasic" - })); - MachineType.RESISTIVE_HEATER.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock3, 1, 4), new Object[] { - "CRC", "RHR", "CEC", Character.valueOf('C'), "ingotTin", Character.valueOf('R'), "dustRedstone", Character.valueOf('H'), new ItemStack(MekanismBlocks.BasicBlock2, 1, 5), Character.valueOf('E'), MekanismItems.EnergyTablet.getUnchargedItem() - }));; - MachineType.QUANTUM_ENTANGLOPORTER.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock3, 1, 0), new Object[] { - "OCO", "ATA", "OCO", Character.valueOf('O'), "ingotRefinedObsidian", Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.ULTIMATE), Character.valueOf('A'), "alloyUltimate", Character.valueOf('T'), MekanismItems.TeleportationCore - })); - MachineType.FORMULAIC_ASSEMBLICATOR.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock3, 1, 5), new Object[] { - "STS", "BIB", "SCS", Character.valueOf('S'), "ingotSteel", Character.valueOf('T'), Blocks.crafting_table, Character.valueOf('B'), MekanismUtils.getControlCircuit(BaseTier.BASIC), Character.valueOf('I'), new ItemStack(MekanismBlocks.BasicBlock, 1, 8), Character.valueOf('C'), Blocks.chest - })); - CraftingManager.getInstance().getRecipeList().add(new ShapelessMekanismRecipe(new ItemStack(MekanismItems.CraftingFormula), new Object[] { - Items.paper, MekanismUtils.getControlCircuit(BaseTier.BASIC) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.BasicBlock2, 1, 9), new Object[] { - "SGS", "CIC", "STS", Character.valueOf('S'), "ingotSteel", Character.valueOf('G'), "blockGlass", Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.ELITE), Character.valueOf('I'), new ItemStack(MekanismBlocks.BasicBlock, 1, 8), - Character.valueOf('T'), MekanismItems.TeleportationCore - })); - MachineType.FUELWOOD_HEATER.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock3, 1, 6), new Object[] { - "SCS", "FHF", "SSS", Character.valueOf('S'), "ingotSteel", Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.BASIC), Character.valueOf('F'), Blocks.furnace, Character.valueOf('H'), new ItemStack(MekanismBlocks.BasicBlock, 1, 8) - })); - MachineType.THEORETICAL_ELEMENTIZER.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock3, 1, 7), new Object[] { - "AGA", "GDG", "AGA", Character.valueOf('A'), MekanismItems.AtomicAlloy, Character.valueOf('G'), "blockGlass", Character.valueOf('D'), "blockDiamond" - })); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.TierInstaller, 1, 2), + new Object[] { "RCR", + "gWg", + "RCR", + Character.valueOf('R'), + "alloyElite", + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.ELITE), + Character.valueOf('g'), + "ingotGold", + Character.valueOf('W'), + "plankWood" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.TierInstaller, 1, 3), + new Object[] { "RCR", + "dWd", + "RCR", + Character.valueOf('R'), + "alloyUltimate", + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.ULTIMATE), + Character.valueOf('d'), + "gemDiamond", + Character.valueOf('W'), + "plankWood" } + )); + MachineType.OREDICTIONIFICATOR.addRecipe(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.MachineBlock3, 1, 3), + new Object[] { "SGS", + "CBC", + "SWS", + Character.valueOf('S'), + "ingotSteel", + Character.valueOf('G'), + "paneGlass", + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.BASIC), + Character.valueOf('B'), + MekanismItems.Dictionary, + Character.valueOf('W'), + Blocks.chest } + )); + MachineType.LASER.addRecipe(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.MachineBlock2, 1, 13), + new Object[] { "RE ", + "RCD", + "RE ", + Character.valueOf('R'), + "alloyElite", + Character.valueOf('E'), + MekanismItems.EnergyTablet.getUnchargedItem(), + Character.valueOf('C'), + new ItemStack(MekanismBlocks.BasicBlock, 1, 8), + Character.valueOf('D'), + "gemDiamond" } + )); + MachineType.LASER_AMPLIFIER.addRecipe(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.MachineBlock2, 1, 14), + new Object[] { "SSS", + "SED", + "SSS", + Character.valueOf('S'), + "ingotSteel", + Character.valueOf('E'), + MekanismUtils.getEnergyCube(EnergyCubeTier.BASIC), + Character.valueOf('D'), + "gemDiamond" } + )); + MachineType.LASER_TRACTOR_BEAM.addRecipe(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.MachineBlock2, 1, 15), + new Object[] { "C", + "F", + Character.valueOf('C'), + new ItemStack(MekanismBlocks.MachineBlock, 1, 13), + Character.valueOf('F'), + new ItemStack(MekanismBlocks.MachineBlock2, 1, 14) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.BasicBlock2, 1, 6), + new Object[] { "SFS", + "FAF", + "SFS", + Character.valueOf('S'), + "ingotSteel", + Character.valueOf('A'), + MekanismItems.EnrichedAlloy, + Character.valueOf('F'), + Blocks.iron_bars } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.BasicBlock2, 4, 7), + new Object[] { " S ", + "SIS", + " S ", + Character.valueOf('S'), + "ingotSteel", + Character.valueOf('I'), + "ingotIron" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.BasicBlock2, 2, 8), + new Object[] { " I ", + "ICI", + " I ", + Character.valueOf('I'), + new ItemStack(MekanismBlocks.BasicBlock2, 1, 7), + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.ADVANCED) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.BasicBlock2, 1, 5), + new Object[] { "ACA", + "CIC", + "ACA", + Character.valueOf('I'), + new ItemStack(MekanismBlocks.BasicBlock, 1, 8), + Character.valueOf('C'), + "ingotCopper", + Character.valueOf('A'), + "alloyBasic" } + )); + MachineType.RESISTIVE_HEATER.addRecipe(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.MachineBlock3, 1, 4), + new Object[] { "CRC", + "RHR", + "CEC", + Character.valueOf('C'), + "ingotTin", + Character.valueOf('R'), + "dustRedstone", + Character.valueOf('H'), + new ItemStack(MekanismBlocks.BasicBlock2, 1, 5), + Character.valueOf('E'), + MekanismItems.EnergyTablet.getUnchargedItem() } + )); + ; + MachineType.QUANTUM_ENTANGLOPORTER.addRecipe(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.MachineBlock3, 1, 0), + new Object[] { "OCO", + "ATA", + "OCO", + Character.valueOf('O'), + "ingotRefinedObsidian", + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.ULTIMATE), + Character.valueOf('A'), + "alloyUltimate", + Character.valueOf('T'), + MekanismItems.TeleportationCore } + )); + MachineType.FORMULAIC_ASSEMBLICATOR.addRecipe(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.MachineBlock3, 1, 5), + new Object[] { "STS", + "BIB", + "SCS", + Character.valueOf('S'), + "ingotSteel", + Character.valueOf('T'), + Blocks.crafting_table, + Character.valueOf('B'), + MekanismUtils.getControlCircuit(BaseTier.BASIC), + Character.valueOf('I'), + new ItemStack(MekanismBlocks.BasicBlock, 1, 8), + Character.valueOf('C'), + Blocks.chest } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapelessMekanismRecipe( + new ItemStack(MekanismItems.CraftingFormula), + new Object[] { Items.paper, MekanismUtils.getControlCircuit(BaseTier.BASIC) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.BasicBlock2, 1, 9), + new Object[] { "SGS", + "CIC", + "STS", + Character.valueOf('S'), + "ingotSteel", + Character.valueOf('G'), + "blockGlass", + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.ELITE), + Character.valueOf('I'), + new ItemStack(MekanismBlocks.BasicBlock, 1, 8), + Character.valueOf('T'), + MekanismItems.TeleportationCore } + )); + MachineType.FUELWOOD_HEATER.addRecipe(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.MachineBlock3, 1, 6), + new Object[] { "SCS", + "FHF", + "SSS", + Character.valueOf('S'), + "ingotSteel", + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.BASIC), + Character.valueOf('F'), + Blocks.furnace, + Character.valueOf('H'), + new ItemStack(MekanismBlocks.BasicBlock, 1, 8) } + )); + MachineType.THEORETICAL_ELEMENTIZER.addRecipe(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.MachineBlock3, 1, 7), + new Object[] { "AGA", + "GDG", + "AGA", + Character.valueOf('A'), + MekanismItems.AtomicAlloy, + Character.valueOf('G'), + "blockGlass", + Character.valueOf('D'), + "blockDiamond" } + )); + //Energy Cube recipes + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + MekanismUtils.getEnergyCube(EnergyCubeTier.BASIC), + new Object[] { "RTR", + "iIi", + "RTR", + Character.valueOf('R'), + "alloyBasic", + Character.valueOf('i'), + "ingotIron", + Character.valueOf('T'), + MekanismItems.EnergyTablet.getUnchargedItem(), + Character.valueOf('I'), + new ItemStack(MekanismBlocks.BasicBlock, 1, 8) } + )); - //Energy Cube recipes - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(MekanismUtils.getEnergyCube(EnergyCubeTier.BASIC), new Object[] { - "RTR", "iIi", "RTR", Character.valueOf('R'), "alloyBasic", Character.valueOf('i'), "ingotIron", Character.valueOf('T'), MekanismItems.EnergyTablet.getUnchargedItem(), Character.valueOf('I'), new ItemStack(MekanismBlocks.BasicBlock, 1, 8) - })); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + MekanismUtils.getEnergyCube(EnergyCubeTier.ELITE), + new Object[] { "RTR", + "gAg", + "RTR", + Character.valueOf('R'), + "alloyElite", + Character.valueOf('g'), + "ingotGold", + Character.valueOf('T'), + MekanismItems.EnergyTablet.getUnchargedItem(), + Character.valueOf('A'), + MekanismUtils.getEnergyCube(EnergyCubeTier.ADVANCED) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + MekanismUtils.getEnergyCube(EnergyCubeTier.ULTIMATE), + new Object[] { "ATA", + "dEd", + "ATA", + Character.valueOf('A'), + "alloyUltimate", + Character.valueOf('d'), + "gemDiamond", + Character.valueOf('T'), + MekanismItems.EnergyTablet.getUnchargedItem(), + Character.valueOf('E'), + MekanismUtils.getEnergyCube(EnergyCubeTier.ELITE) } + )); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(MekanismUtils.getEnergyCube(EnergyCubeTier.ELITE), new Object[] { - "RTR", "gAg", "RTR", Character.valueOf('R'), "alloyElite", Character.valueOf('g'), "ingotGold", Character.valueOf('T'), MekanismItems.EnergyTablet.getUnchargedItem(), Character.valueOf('A'), MekanismUtils.getEnergyCube(EnergyCubeTier.ADVANCED) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(MekanismUtils.getEnergyCube(EnergyCubeTier.ULTIMATE), new Object[] { - "ATA", "dEd", "ATA", Character.valueOf('A'), "alloyUltimate", Character.valueOf('d'), "gemDiamond", Character.valueOf('T'), MekanismItems.EnergyTablet.getUnchargedItem(), Character.valueOf('E'), MekanismUtils.getEnergyCube(EnergyCubeTier.ELITE) - })); + //Fluid Tank Recipes + MachineType.FLUID_TANK.addRecipe(new ShapedMekanismRecipe( + MekanismUtils.getEmptyFluidTank(FluidTankTier.BASIC), + new Object[] { "AIA", + "I I", + "AIA", + Character.valueOf('I'), + "ingotIron", + Character.valueOf('A'), + "alloyBasic" } + )); + MachineType.FLUID_TANK.addRecipe(new ShapedMekanismRecipe( + MekanismUtils.getEmptyFluidTank(FluidTankTier.ADVANCED), + new Object[] { "AIA", + "ITI", + "AIA", + Character.valueOf('I'), + "ingotIron", + Character.valueOf('A'), + "alloyAdvanced", + Character.valueOf('T'), + MekanismUtils.getEmptyFluidTank(FluidTankTier.BASIC) } + )); + MachineType.FLUID_TANK.addRecipe(new ShapedMekanismRecipe( + MekanismUtils.getEmptyFluidTank(FluidTankTier.ELITE), + new Object[] { "AIA", + "ITI", + "AIA", + Character.valueOf('I'), + "ingotIron", + Character.valueOf('A'), + "alloyElite", + Character.valueOf('T'), + MekanismUtils.getEmptyFluidTank(FluidTankTier.ADVANCED) } + )); + MachineType.FLUID_TANK.addRecipe(new ShapedMekanismRecipe( + MekanismUtils.getEmptyFluidTank(FluidTankTier.ULTIMATE), + new Object[] { "AIA", + "ITI", + "AIA", + Character.valueOf('I'), + "ingotIron", + Character.valueOf('A'), + "alloyUltimate", + Character.valueOf('T'), + MekanismUtils.getEmptyFluidTank(FluidTankTier.ELITE) } + )); + //Bin recipes + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + MekanismUtils.getBin(BinTier.BASIC), + new Object[] { "SCS", + "A A", + "SSS", + Character.valueOf('S'), + Blocks.cobblestone, + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.BASIC), + Character.valueOf('A'), + "alloyBasic" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + MekanismUtils.getBin(BinTier.ADVANCED), + new Object[] { "SCS", + "ABA", + "SSS", + Character.valueOf('S'), + Blocks.cobblestone, + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.ADVANCED), + Character.valueOf('A'), + "alloyAdvanced", + Character.valueOf('B'), + MekanismUtils.getBin(BinTier.BASIC) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + MekanismUtils.getBin(BinTier.ELITE), + new Object[] { "SCS", + "ABA", + "SSS", + Character.valueOf('S'), + Blocks.cobblestone, + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.ELITE), + Character.valueOf('A'), + "alloyElite", + Character.valueOf('B'), + MekanismUtils.getBin(BinTier.ADVANCED) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + MekanismUtils.getBin(BinTier.ULTIMATE), + new Object[] { "SCS", + "ABA", + "SSS", + Character.valueOf('S'), + Blocks.cobblestone, + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.ULTIMATE), + Character.valueOf('A'), + "alloyUltimate", + Character.valueOf('B'), + MekanismUtils.getBin(BinTier.ELITE) } + )); + //Induction Cell recipes + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + MekanismUtils.getInductionCell(InductionCellTier.BASIC), + new Object[] { "LTL", + "TET", + "LTL", + Character.valueOf('T'), + MekanismItems.EnergyTablet.getUnchargedItem(), + Character.valueOf('E'), + MekanismUtils.getEnergyCube(EnergyCubeTier.BASIC), + Character.valueOf('L'), + "dustLithium" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + MekanismUtils.getInductionCell(InductionCellTier.ADVANCED), + new Object[] { "TCT", + "CEC", + "TCT", + Character.valueOf('T'), + MekanismItems.EnergyTablet.getUnchargedItem(), + Character.valueOf('E'), + MekanismUtils.getEnergyCube(EnergyCubeTier.ADVANCED), + Character.valueOf('C'), + MekanismUtils.getInductionCell(InductionCellTier.BASIC) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + MekanismUtils.getInductionCell(InductionCellTier.ELITE), + new Object[] { "TCT", + "CEC", + "TCT", + Character.valueOf('T'), + MekanismItems.EnergyTablet.getUnchargedItem(), + Character.valueOf('E'), + MekanismUtils.getEnergyCube(EnergyCubeTier.ELITE), + Character.valueOf('C'), + MekanismUtils.getInductionCell(InductionCellTier.ADVANCED) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + MekanismUtils.getInductionCell(InductionCellTier.ULTIMATE), + new Object[] { "TCT", + "CEC", + "TCT", + Character.valueOf('T'), + MekanismItems.EnergyTablet.getUnchargedItem(), + Character.valueOf('E'), + MekanismUtils.getEnergyCube(EnergyCubeTier.ULTIMATE), + Character.valueOf('C'), + MekanismUtils.getInductionCell(InductionCellTier.ELITE) } + )); - //Fluid Tank Recipes - MachineType.FLUID_TANK.addRecipe(new ShapedMekanismRecipe(MekanismUtils.getEmptyFluidTank(FluidTankTier.BASIC), new Object[] { - "AIA", "I I", "AIA", Character.valueOf('I'), "ingotIron", Character.valueOf('A'), "alloyBasic" - })); - MachineType.FLUID_TANK.addRecipe(new ShapedMekanismRecipe(MekanismUtils.getEmptyFluidTank(FluidTankTier.ADVANCED), new Object[] { - "AIA", "ITI", "AIA", Character.valueOf('I'), "ingotIron", Character.valueOf('A'), "alloyAdvanced", Character.valueOf('T'), MekanismUtils.getEmptyFluidTank(FluidTankTier.BASIC) - })); - MachineType.FLUID_TANK.addRecipe(new ShapedMekanismRecipe(MekanismUtils.getEmptyFluidTank(FluidTankTier.ELITE), new Object[] { - "AIA", "ITI", "AIA", Character.valueOf('I'), "ingotIron", Character.valueOf('A'), "alloyElite", Character.valueOf('T'), MekanismUtils.getEmptyFluidTank(FluidTankTier.ADVANCED) - })); - MachineType.FLUID_TANK.addRecipe(new ShapedMekanismRecipe(MekanismUtils.getEmptyFluidTank(FluidTankTier.ULTIMATE), new Object[] { - "AIA", "ITI", "AIA", Character.valueOf('I'), "ingotIron", Character.valueOf('A'), "alloyUltimate", Character.valueOf('T'), MekanismUtils.getEmptyFluidTank(FluidTankTier.ELITE) - })); + //Induction Provider recipes + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + MekanismUtils.getInductionProvider(InductionProviderTier.BASIC), + new Object[] { "LCL", + "CEC", + "LCL", + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.BASIC), + Character.valueOf('E'), + MekanismUtils.getEnergyCube(EnergyCubeTier.BASIC), + Character.valueOf('L'), + "dustLithium" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + MekanismUtils.getInductionProvider(InductionProviderTier.ADVANCED), + new Object[] { + "CPC", + "PEP", + "CPC", + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.ADVANCED), + Character.valueOf('E'), + MekanismUtils.getEnergyCube(EnergyCubeTier.ADVANCED), + Character.valueOf('P'), + MekanismUtils.getInductionProvider(InductionProviderTier.BASIC) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + MekanismUtils.getInductionProvider(InductionProviderTier.ELITE), + new Object[] { + "CPC", + "PEP", + "CPC", + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.ELITE), + Character.valueOf('E'), + MekanismUtils.getEnergyCube(EnergyCubeTier.ELITE), + Character.valueOf('P'), + MekanismUtils.getInductionProvider(InductionProviderTier.ADVANCED) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + MekanismUtils.getInductionProvider(InductionProviderTier.ULTIMATE), + new Object[] { + "CPC", + "PEP", + "CPC", + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.ULTIMATE), + Character.valueOf('E'), + MekanismUtils.getEnergyCube(EnergyCubeTier.ULTIMATE), + Character.valueOf('P'), + MekanismUtils.getInductionProvider(InductionProviderTier.ELITE) } + )); - //Bin recipes - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(MekanismUtils.getBin(BinTier.BASIC), new Object[] { - "SCS", "A A", "SSS", Character.valueOf('S'), Blocks.cobblestone, Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.BASIC), Character.valueOf('A'), "alloyBasic" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(MekanismUtils.getBin(BinTier.ADVANCED), new Object[] { - "SCS", "ABA", "SSS", Character.valueOf('S'), Blocks.cobblestone, Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.ADVANCED), Character.valueOf('A'), "alloyAdvanced", Character.valueOf('B'), MekanismUtils.getBin(BinTier.BASIC) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(MekanismUtils.getBin(BinTier.ELITE), new Object[] { - "SCS", "ABA", "SSS", Character.valueOf('S'), Blocks.cobblestone, Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.ELITE), Character.valueOf('A'), "alloyElite", Character.valueOf('B'), MekanismUtils.getBin(BinTier.ADVANCED) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(MekanismUtils.getBin(BinTier.ULTIMATE), new Object[] { - "SCS", "ABA", "SSS", Character.valueOf('S'), Blocks.cobblestone, Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.ULTIMATE), Character.valueOf('A'), "alloyUltimate", Character.valueOf('B'), MekanismUtils.getBin(BinTier.ELITE) - })); + //Circuit recipes + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.ControlCircuit, 1, 1), + new Object[] { "ECE", + Character.valueOf('C'), + new ItemStack(MekanismItems.ControlCircuit, 1, 0), + Character.valueOf('E'), + "alloyAdvanced" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.ControlCircuit, 1, 2), + new Object[] { "RCR", + Character.valueOf('C'), + new ItemStack(MekanismItems.ControlCircuit, 1, 1), + Character.valueOf('R'), + "alloyElite" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.ControlCircuit, 1, 3), + new Object[] { "ACA", + Character.valueOf('C'), + new ItemStack(MekanismItems.ControlCircuit, 1, 2), + Character.valueOf('A'), + "alloyUltimate" } + )); - //Induction Cell recipes - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(MekanismUtils.getInductionCell(InductionCellTier.BASIC), new Object[] { - "LTL", "TET", "LTL", Character.valueOf('T'), MekanismItems.EnergyTablet.getUnchargedItem(), Character.valueOf('E'), MekanismUtils.getEnergyCube(EnergyCubeTier.BASIC), Character.valueOf('L'), "dustLithium" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(MekanismUtils.getInductionCell(InductionCellTier.ADVANCED), new Object[] { - "TCT", "CEC", "TCT", Character.valueOf('T'), MekanismItems.EnergyTablet.getUnchargedItem(), Character.valueOf('E'), MekanismUtils.getEnergyCube(EnergyCubeTier.ADVANCED), Character.valueOf('C'), MekanismUtils.getInductionCell(InductionCellTier.BASIC) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(MekanismUtils.getInductionCell(InductionCellTier.ELITE), new Object[] { - "TCT", "CEC", "TCT", Character.valueOf('T'), MekanismItems.EnergyTablet.getUnchargedItem(), Character.valueOf('E'), MekanismUtils.getEnergyCube(EnergyCubeTier.ELITE), Character.valueOf('C'), MekanismUtils.getInductionCell(InductionCellTier.ADVANCED) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(MekanismUtils.getInductionCell(InductionCellTier.ULTIMATE), new Object[] { - "TCT", "CEC", "TCT", Character.valueOf('T'), MekanismItems.EnergyTablet.getUnchargedItem(), Character.valueOf('E'), MekanismUtils.getEnergyCube(EnergyCubeTier.ULTIMATE), Character.valueOf('C'), MekanismUtils.getInductionCell(InductionCellTier.ELITE) - })); + //Factory recipes + for (RecipeType type : RecipeType.values()) { + MachineType.BASIC_FACTORY.addRecipe(new ShapedMekanismRecipe( + MekanismUtils.getFactory(FactoryTier.BASIC, type), + new Object[] { "RCR", + "iOi", + "RCR", + Character.valueOf('R'), + "alloyBasic", + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.BASIC), + Character.valueOf('i'), + "ingotIron", + Character.valueOf('O'), + type.getStack() } + )); + if (general.OreDictOsmium) { + MachineType.ADVANCED_FACTORY.addRecipe(new ShapedMekanismRecipe( + MekanismUtils.getFactory(FactoryTier.ADVANCED, type), + new Object[] { "ECE", + "oOo", + "ECE", + Character.valueOf('E'), + "alloyAdvanced", + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.ADVANCED), + Character.valueOf('o'), + "ingotOsmium", + Character.valueOf('O'), + MekanismUtils.getFactory(FactoryTier.BASIC, type) } + )); + } + if (general.OreDictPlatinum) { + MachineType.ADVANCED_FACTORY.addRecipe(new ShapedMekanismRecipe( + MekanismUtils.getFactory(FactoryTier.ADVANCED, type), + new Object[] { "ECE", + "oOo", + "ECE", + Character.valueOf('E'), + "alloyAdvanced", + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.ADVANCED), + Character.valueOf('o'), + "ingotPlatinum", + Character.valueOf('O'), + MekanismUtils.getFactory(FactoryTier.BASIC, type) } + )); + } + MachineType.ELITE_FACTORY.addRecipe(new ShapedMekanismRecipe( + MekanismUtils.getFactory(FactoryTier.ELITE, type), + new Object[] { "RCR", + "gOg", + "RCR", + Character.valueOf('R'), + "alloyElite", + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.ELITE), + Character.valueOf('g'), + "ingotGold", + Character.valueOf('O'), + MekanismUtils.getFactory(FactoryTier.ADVANCED, type) } + )); + } - //Induction Provider recipes - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(MekanismUtils.getInductionProvider(InductionProviderTier.BASIC), new Object[] { - "LCL", "CEC", "LCL", Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.BASIC), Character.valueOf('E'), MekanismUtils.getEnergyCube(EnergyCubeTier.BASIC), Character.valueOf('L'), "dustLithium" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(MekanismUtils.getInductionProvider(InductionProviderTier.ADVANCED), new Object[] { - "CPC", "PEP", "CPC", Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.ADVANCED), Character.valueOf('E'), MekanismUtils.getEnergyCube(EnergyCubeTier.ADVANCED), Character.valueOf('P'), MekanismUtils.getInductionProvider(InductionProviderTier.BASIC) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(MekanismUtils.getInductionProvider(InductionProviderTier.ELITE), new Object[] { - "CPC", "PEP", "CPC", Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.ELITE), Character.valueOf('E'), MekanismUtils.getEnergyCube(EnergyCubeTier.ELITE), Character.valueOf('P'), MekanismUtils.getInductionProvider(InductionProviderTier.ADVANCED) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(MekanismUtils.getInductionProvider(InductionProviderTier.ULTIMATE), new Object[] { - "CPC", "PEP", "CPC", Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.ULTIMATE), Character.valueOf('E'), MekanismUtils.getEnergyCube(EnergyCubeTier.ULTIMATE), Character.valueOf('P'), MekanismUtils.getInductionProvider(InductionProviderTier.ELITE) - })); - - //Circuit recipes - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.ControlCircuit, 1, 1), new Object[] { - "ECE", Character.valueOf('C'), new ItemStack(MekanismItems.ControlCircuit, 1, 0), Character.valueOf('E'), "alloyAdvanced" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.ControlCircuit, 1, 2), new Object[] { - "RCR", Character.valueOf('C'), new ItemStack(MekanismItems.ControlCircuit, 1, 1), Character.valueOf('R'), "alloyElite" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.ControlCircuit, 1, 3), new Object[] { - "ACA", Character.valueOf('C'), new ItemStack(MekanismItems.ControlCircuit, 1, 2), Character.valueOf('A'), "alloyUltimate" - })); - - //Factory recipes - for(RecipeType type : RecipeType.values()) - { - MachineType.BASIC_FACTORY.addRecipe(new ShapedMekanismRecipe(MekanismUtils.getFactory(FactoryTier.BASIC, type), new Object[] { - "RCR", "iOi", "RCR", Character.valueOf('R'), "alloyBasic", Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.BASIC), Character.valueOf('i'), "ingotIron", Character.valueOf('O'), type.getStack() - })); - if(general.OreDictOsmium) { - MachineType.ADVANCED_FACTORY.addRecipe(new ShapedMekanismRecipe(MekanismUtils.getFactory(FactoryTier.ADVANCED, type), new Object[]{ - "ECE", "oOo", "ECE", Character.valueOf('E'), "alloyAdvanced", Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.ADVANCED), Character.valueOf('o'), "ingotOsmium", Character.valueOf('O'), MekanismUtils.getFactory(FactoryTier.BASIC, type) - })); - } - if(general.OreDictPlatinum) { - MachineType.ADVANCED_FACTORY.addRecipe(new ShapedMekanismRecipe(MekanismUtils.getFactory(FactoryTier.ADVANCED, type), new Object[]{ - "ECE", "oOo", "ECE", Character.valueOf('E'), "alloyAdvanced", Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.ADVANCED), Character.valueOf('o'), "ingotPlatinum", Character.valueOf('O'), MekanismUtils.getFactory(FactoryTier.BASIC, type) - })); - } - MachineType.ELITE_FACTORY.addRecipe(new ShapedMekanismRecipe(MekanismUtils.getFactory(FactoryTier.ELITE, type), new Object[] { - "RCR", "gOg", "RCR", Character.valueOf('R'), "alloyElite", Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.ELITE), Character.valueOf('g'), "ingotGold", Character.valueOf('O'), MekanismUtils.getFactory(FactoryTier.ADVANCED, type) - })); - } - - //Add the bin recipe system to the CraftingManager - CraftingManager.getInstance().getRecipeList().add(new BinRecipe()); + //Add the bin recipe system to the CraftingManager + CraftingManager.getInstance().getRecipeList().add(new BinRecipe()); //Transmitters - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.PartTransmitter, 8, 0), new Object[] { - "SRS", Character.valueOf('S'), "ingotSteel", Character.valueOf('R'), "dustRedstone" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.PartTransmitter, 8, 1), new Object[] { - "TTT", "TET", "TTT", Character.valueOf('E'), "alloyAdvanced", Character.valueOf('T'), new ItemStack(MekanismItems.PartTransmitter, 1, 0) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.PartTransmitter, 8, 2), new Object[] { - "TTT", "TRT", "TTT", Character.valueOf('R'), "alloyElite", Character.valueOf('T'), new ItemStack(MekanismItems.PartTransmitter, 1, 1) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.PartTransmitter, 8, 3), new Object[] { - "TTT", "TAT", "TTT", Character.valueOf('A'), "alloyUltimate", Character.valueOf('T'), new ItemStack(MekanismItems.PartTransmitter, 1, 2) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.PartTransmitter, 8, 4), new Object[] { - "SBS", Character.valueOf('S'), "ingotSteel", Character.valueOf('B'), Items.bucket - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.PartTransmitter, 8, 5), new Object[] { - "TTT", "TET", "TTT", Character.valueOf('E'), "alloyAdvanced", Character.valueOf('T'), new ItemStack(MekanismItems.PartTransmitter, 1, 4) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.PartTransmitter, 8, 6), new Object[] { - "TTT", "TRT", "TTT", Character.valueOf('R'), "alloyElite", Character.valueOf('T'), new ItemStack(MekanismItems.PartTransmitter, 1, 5) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.PartTransmitter, 8, 7), new Object[] { - "TTT", "TAT", "TTT", Character.valueOf('A'), "alloyUltimate", Character.valueOf('T'), new ItemStack(MekanismItems.PartTransmitter, 1, 6) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.PartTransmitter, 8, 8), new Object[] { - "SGS", Character.valueOf('S'), "ingotSteel", Character.valueOf('G'), "blockGlass" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.PartTransmitter, 8, 9), new Object[] { - "TTT", "TET", "TTT", Character.valueOf('E'), "alloyAdvanced", Character.valueOf('T'), new ItemStack(MekanismItems.PartTransmitter, 1, 8) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.PartTransmitter, 8, 10), new Object[] { - "TTT", "TRT", "TTT", Character.valueOf('R'), "alloyElite", Character.valueOf('T'), new ItemStack(MekanismItems.PartTransmitter, 1, 9) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.PartTransmitter, 8, 11), new Object[] { - "TTT", "TAT", "TTT", Character.valueOf('A'), "alloyUltimate", Character.valueOf('T'), new ItemStack(MekanismItems.PartTransmitter, 1, 10) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.PartTransmitter, 8, 12), new Object[] { - "SCS", Character.valueOf('S'), "ingotSteel", Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.BASIC) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.PartTransmitter, 8, 13), new Object[] { - "TTT", "TET", "TTT", Character.valueOf('E'), "alloyAdvanced", Character.valueOf('T'), new ItemStack(MekanismItems.PartTransmitter, 1, 12) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.PartTransmitter, 8, 14), new Object[] { - "TTT", "TRT", "TTT", Character.valueOf('R'), "alloyElite", Character.valueOf('T'), new ItemStack(MekanismItems.PartTransmitter, 1, 13) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.PartTransmitter, 8, 15), new Object[] { - "TTT", "TAT", "TTT", Character.valueOf('A'), "alloyUltimate", Character.valueOf('T'), new ItemStack(MekanismItems.PartTransmitter, 1, 14) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.PartTransmitter, 2, 16), new Object[] { - "SBS", Character.valueOf('S'), "ingotSteel", Character.valueOf('B'), Blocks.iron_bars - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.PartTransmitter, 2, 17), new Object[] { - "RRR", "SBS", "RRR", Character.valueOf('R'), "dustRedstone", Character.valueOf('S'), "ingotSteel", Character.valueOf('B'), Blocks.iron_bars - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.PartTransmitter, 8, 18), new Object[] { - "SCS", Character.valueOf('S'), "ingotSteel", Character.valueOf('C'), "ingotCopper" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.PartTransmitter, 8, 19), new Object[] { - "TTT", "TET", "TTT", Character.valueOf('E'), "alloyAdvanced", Character.valueOf('T'), new ItemStack(MekanismItems.PartTransmitter, 1, 18) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.PartTransmitter, 8, 20), new Object[] { - "TTT", "TRT", "TTT", Character.valueOf('R'), "alloyElite", Character.valueOf('T'), new ItemStack(MekanismItems.PartTransmitter, 1, 19) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.PartTransmitter, 8, 21), new Object[] { - "TTT", "TAT", "TTT", Character.valueOf('A'), "alloyUltimate", Character.valueOf('T'), new ItemStack(MekanismItems.PartTransmitter, 1, 20) - })); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.PartTransmitter, 8, 0), + new Object[] { "SRS", + Character.valueOf('S'), + "ingotSteel", + Character.valueOf('R'), + "dustRedstone" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.PartTransmitter, 8, 1), + new Object[] { "TTT", + "TET", + "TTT", + Character.valueOf('E'), + "alloyAdvanced", + Character.valueOf('T'), + new ItemStack(MekanismItems.PartTransmitter, 1, 0) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.PartTransmitter, 8, 2), + new Object[] { "TTT", + "TRT", + "TTT", + Character.valueOf('R'), + "alloyElite", + Character.valueOf('T'), + new ItemStack(MekanismItems.PartTransmitter, 1, 1) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.PartTransmitter, 8, 3), + new Object[] { "TTT", + "TAT", + "TTT", + Character.valueOf('A'), + "alloyUltimate", + Character.valueOf('T'), + new ItemStack(MekanismItems.PartTransmitter, 1, 2) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.PartTransmitter, 8, 4), + new Object[] { "SBS", + Character.valueOf('S'), + "ingotSteel", + Character.valueOf('B'), + Items.bucket } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.PartTransmitter, 8, 5), + new Object[] { "TTT", + "TET", + "TTT", + Character.valueOf('E'), + "alloyAdvanced", + Character.valueOf('T'), + new ItemStack(MekanismItems.PartTransmitter, 1, 4) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.PartTransmitter, 8, 6), + new Object[] { "TTT", + "TRT", + "TTT", + Character.valueOf('R'), + "alloyElite", + Character.valueOf('T'), + new ItemStack(MekanismItems.PartTransmitter, 1, 5) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.PartTransmitter, 8, 7), + new Object[] { "TTT", + "TAT", + "TTT", + Character.valueOf('A'), + "alloyUltimate", + Character.valueOf('T'), + new ItemStack(MekanismItems.PartTransmitter, 1, 6) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.PartTransmitter, 8, 8), + new Object[] { "SGS", + Character.valueOf('S'), + "ingotSteel", + Character.valueOf('G'), + "blockGlass" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.PartTransmitter, 8, 9), + new Object[] { "TTT", + "TET", + "TTT", + Character.valueOf('E'), + "alloyAdvanced", + Character.valueOf('T'), + new ItemStack(MekanismItems.PartTransmitter, 1, 8) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.PartTransmitter, 8, 10), + new Object[] { "TTT", + "TRT", + "TTT", + Character.valueOf('R'), + "alloyElite", + Character.valueOf('T'), + new ItemStack(MekanismItems.PartTransmitter, 1, 9) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.PartTransmitter, 8, 11), + new Object[] { "TTT", + "TAT", + "TTT", + Character.valueOf('A'), + "alloyUltimate", + Character.valueOf('T'), + new ItemStack(MekanismItems.PartTransmitter, 1, 10) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.PartTransmitter, 8, 12), + new Object[] { "SCS", + Character.valueOf('S'), + "ingotSteel", + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.BASIC) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.PartTransmitter, 8, 13), + new Object[] { "TTT", + "TET", + "TTT", + Character.valueOf('E'), + "alloyAdvanced", + Character.valueOf('T'), + new ItemStack(MekanismItems.PartTransmitter, 1, 12) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.PartTransmitter, 8, 14), + new Object[] { "TTT", + "TRT", + "TTT", + Character.valueOf('R'), + "alloyElite", + Character.valueOf('T'), + new ItemStack(MekanismItems.PartTransmitter, 1, 13) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.PartTransmitter, 8, 15), + new Object[] { "TTT", + "TAT", + "TTT", + Character.valueOf('A'), + "alloyUltimate", + Character.valueOf('T'), + new ItemStack(MekanismItems.PartTransmitter, 1, 14) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.PartTransmitter, 2, 16), + new Object[] { "SBS", + Character.valueOf('S'), + "ingotSteel", + Character.valueOf('B'), + Blocks.iron_bars } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.PartTransmitter, 2, 17), + new Object[] { "RRR", + "SBS", + "RRR", + Character.valueOf('R'), + "dustRedstone", + Character.valueOf('S'), + "ingotSteel", + Character.valueOf('B'), + Blocks.iron_bars } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.PartTransmitter, 8, 18), + new Object[] { "SCS", + Character.valueOf('S'), + "ingotSteel", + Character.valueOf('C'), + "ingotCopper" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.PartTransmitter, 8, 19), + new Object[] { "TTT", + "TET", + "TTT", + Character.valueOf('E'), + "alloyAdvanced", + Character.valueOf('T'), + new ItemStack(MekanismItems.PartTransmitter, 1, 18) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.PartTransmitter, 8, 20), + new Object[] { "TTT", + "TRT", + "TTT", + Character.valueOf('R'), + "alloyElite", + Character.valueOf('T'), + new ItemStack(MekanismItems.PartTransmitter, 1, 19) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.PartTransmitter, 8, 21), + new Object[] { "TTT", + "TAT", + "TTT", + Character.valueOf('A'), + "alloyUltimate", + Character.valueOf('T'), + new ItemStack(MekanismItems.PartTransmitter, 1, 20) } + )); - //Plastic stuff - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.Polyethene, 1, 1), new Object[] { - "PP", "PP", Character.valueOf('P'), new ItemStack(MekanismItems.Polyethene, 1, 0) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.Polyethene, 1, 2), new Object[] { - "PPP", "P P", "PPP", Character.valueOf('P'), new ItemStack(MekanismItems.Polyethene, 1, 0) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.Polyethene, 1, 3), new Object[] { - "R", "R", Character.valueOf('R'), new ItemStack(MekanismItems.Polyethene, 1, 1) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.PlasticBlock, 4, 15), new Object[] { - "SSS", "S S", "SSS", Character.valueOf('S'), new ItemStack(MekanismItems.Polyethene, 1, 2) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.GlowPanel, 2, 15), new Object[] { - "PSP", "S S", "GSG", Character.valueOf('P'), "paneGlass", Character.valueOf('S'), new ItemStack(MekanismItems.Polyethene, 1, 2), Character.valueOf('G'), Items.glowstone_dust - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.PlasticFence, 3, 15), new Object[] { - "BSB", "BSB", Character.valueOf('B'), new ItemStack(MekanismBlocks.PlasticBlock, 1, 15), Character.valueOf('S'), new ItemStack(MekanismItems.Polyethene, 1, 3) - })); + //Plastic stuff + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.Polyethene, 1, 1), + new Object[] { "PP", + "PP", + Character.valueOf('P'), + new ItemStack(MekanismItems.Polyethene, 1, 0) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.Polyethene, 1, 2), + new Object[] { "PPP", + "P P", + "PPP", + Character.valueOf('P'), + new ItemStack(MekanismItems.Polyethene, 1, 0) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.Polyethene, 1, 3), + new Object[] { "R", + "R", + Character.valueOf('R'), + new ItemStack(MekanismItems.Polyethene, 1, 1) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.PlasticBlock, 4, 15), + new Object[] { "SSS", + "S S", + "SSS", + Character.valueOf('S'), + new ItemStack(MekanismItems.Polyethene, 1, 2) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.GlowPanel, 2, 15), + new Object[] { "PSP", + "S S", + "GSG", + Character.valueOf('P'), + "paneGlass", + Character.valueOf('S'), + new ItemStack(MekanismItems.Polyethene, 1, 2), + Character.valueOf('G'), + Items.glowstone_dust } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.PlasticFence, 3, 15), + new Object[] { "BSB", + "BSB", + Character.valueOf('B'), + new ItemStack(MekanismBlocks.PlasticBlock, 1, 15), + Character.valueOf('S'), + new ItemStack(MekanismItems.Polyethene, 1, 3) } + )); - for(int i = 0; i < EnumColor.DYES.length-1; i++) - { - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.PlasticBlock, 4, i), new Object[] { - "SSS", "SDS", "SSS", Character.valueOf('S'), new ItemStack(MekanismItems.Polyethene, 1, 2), Character.valueOf('D'), "dye" + EnumColor.DYES[i].dyeName - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.GlowPanel, 2, i), new Object[] { - "PSP", "SDS", "GSG", Character.valueOf('P'), "paneGlass", Character.valueOf('S'), new ItemStack(MekanismItems.Polyethene, 1, 2), Character.valueOf('D'), "dye" + EnumColor.DYES[i].dyeName, Character.valueOf('G'), Items.glowstone_dust - })); - } - - for(int i = 0; i < EnumColor.DYES.length; i++) - { - CraftingManager.getInstance().getRecipeList().add(new ShapelessMekanismRecipe(new ItemStack(MekanismItems.Balloon, 2, i), new Object[] { - Items.leather, Items.string, "dye" + EnumColor.DYES[i].dyeName - })); - - for(int j = 0; j < EnumColor.DYES.length; j++) - { - CraftingManager.getInstance().getRecipeList().add(new ShapelessMekanismRecipe(new ItemStack(MekanismItems.Balloon, 1, i), new Object[] { - new ItemStack(MekanismItems.Balloon, 1, j), "dye" + EnumColor.DYES[i].dyeName - })); - - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.PlasticBlock, 4, i), new Object[] { - " P ", "PDP", " P ", Character.valueOf('P'), new ItemStack(MekanismBlocks.PlasticBlock, 1, j), Character.valueOf('D'), "dye" + EnumColor.DYES[i].dyeName - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.SlickPlasticBlock, 4, i), new Object[] { - " P ", "PDP", " P ", Character.valueOf('P'), new ItemStack(MekanismBlocks.SlickPlasticBlock, 1, j), Character.valueOf('D'), "dye" + EnumColor.DYES[i].dyeName - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.GlowPlasticBlock, 4, i), new Object[] { - " P ", "PDP", " P ", Character.valueOf('P'), new ItemStack(MekanismBlocks.GlowPlasticBlock, 1, j), Character.valueOf('D'), "dye" + EnumColor.DYES[i].dyeName - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.ReinforcedPlasticBlock, 4, i), new Object[] { - " P ", "PDP", " P ", Character.valueOf('P'), new ItemStack(MekanismBlocks.ReinforcedPlasticBlock, 1, j), Character.valueOf('D'), "dye" + EnumColor.DYES[i].dyeName - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.GlowPanel, 4, i), new Object[] { - " P ", "PDP", " P ", Character.valueOf('P'), new ItemStack(MekanismItems.GlowPanel, 1, j), Character.valueOf('D'), "dye" + EnumColor.DYES[i].dyeName - })); - } - - CraftingManager.getInstance().getRecipeList().add(new ShapelessMekanismRecipe(new ItemStack(MekanismBlocks.GlowPlasticBlock, 3, i), new Object[] { - new ItemStack(MekanismBlocks.PlasticBlock, 1, i), new ItemStack(MekanismBlocks.PlasticBlock, 1, i), new ItemStack(MekanismBlocks.PlasticBlock, 1, i), new ItemStack(Items.glowstone_dust) - })); - if(general.OreDictOsmium) { - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.ReinforcedPlasticBlock, 4, i), new Object[]{ - " P ", "POP", " P ", Character.valueOf('P'), new ItemStack(MekanismBlocks.PlasticBlock, 1, i), Character.valueOf('O'), "dustOsmium" - })); - } - if(general.OreDictPlatinum) { - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.ReinforcedPlasticBlock, 4, i), new Object[]{ - " P ", "POP", " P ", Character.valueOf('P'), new ItemStack(MekanismBlocks.PlasticBlock, 1, i), Character.valueOf('O'), "dustPlatinum" - })); - } - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.RoadPlasticBlock, 3, i), new Object[] { - "SSS", "PPP", "SSS", Character.valueOf('S'), Blocks.sand, Character.valueOf('P'), new ItemStack(MekanismBlocks.SlickPlasticBlock, 1, i) - })); + for (int i = 0; i < EnumColor.DYES.length - 1; i++) { + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.PlasticBlock, 4, i), + new Object[] { "SSS", + "SDS", + "SSS", + Character.valueOf('S'), + new ItemStack(MekanismItems.Polyethene, 1, 2), + Character.valueOf('D'), + "dye" + EnumColor.DYES[i].dyeName } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismItems.GlowPanel, 2, i), + new Object[] { "PSP", + "SDS", + "GSG", + Character.valueOf('P'), + "paneGlass", + Character.valueOf('S'), + new ItemStack(MekanismItems.Polyethene, 1, 2), + Character.valueOf('D'), + "dye" + EnumColor.DYES[i].dyeName, + Character.valueOf('G'), + Items.glowstone_dust } + )); } - //Furnace Recipes - FurnaceRecipes.smelting().func_151394_a(new ItemStack(MekanismBlocks.OreBlock, 1, 0), new ItemStack(MekanismItems.Ingot, 1, 1), 1.0F); - FurnaceRecipes.smelting().func_151394_a(new ItemStack(MekanismBlocks.OreBlock, 1, 1), new ItemStack(MekanismItems.Ingot, 1, 5), 1.0F); - FurnaceRecipes.smelting().func_151394_a(new ItemStack(MekanismBlocks.OreBlock, 1, 2), new ItemStack(MekanismItems.Ingot, 1, 6), 1.0F); - FurnaceRecipes.smelting().func_151394_a(new ItemStack(MekanismItems.Dust, 1, Resource.OSMIUM.ordinal()), new ItemStack(MekanismItems.Ingot, 1, 1), 0.0F); - FurnaceRecipes.smelting().func_151394_a(new ItemStack(MekanismItems.Dust, 1, Resource.IRON.ordinal()), new ItemStack(Items.iron_ingot), 0.0F); - FurnaceRecipes.smelting().func_151394_a(new ItemStack(MekanismItems.Dust, 1, Resource.GOLD.ordinal()), new ItemStack(Items.gold_ingot), 0.0F); - FurnaceRecipes.smelting().func_151394_a(new ItemStack(MekanismItems.OtherDust, 1, 1), new ItemStack(MekanismItems.Ingot, 1, 4), 0.0F); - FurnaceRecipes.smelting().func_151394_a(new ItemStack(MekanismItems.Dust, 1, Resource.COPPER.ordinal()), new ItemStack(MekanismItems.Ingot, 1, 5), 0.0F); - FurnaceRecipes.smelting().func_151394_a(new ItemStack(MekanismItems.Dust, 1, Resource.TIN.ordinal()), new ItemStack(MekanismItems.Ingot, 1, 6), 0.0F); + for (int i = 0; i < EnumColor.DYES.length; i++) { + CraftingManager.getInstance().getRecipeList().add(new ShapelessMekanismRecipe( + new ItemStack(MekanismItems.Balloon, 2, i), + new Object[] { + Items.leather, Items.string, "dye" + EnumColor.DYES[i].dyeName } + )); - //Enrichment Chamber Recipes - RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Blocks.redstone_ore), new ItemStack(Items.redstone, 12)); - RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Blocks.obsidian), new ItemStack(MekanismItems.OtherDust, 2, 6)); - RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Items.coal, 1, 0), new ItemStack(MekanismItems.CompressedCarbon)); - RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Items.coal, 1, 1), new ItemStack(MekanismItems.CompressedCarbon)); - RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Items.redstone), new ItemStack(MekanismItems.CompressedRedstone)); - RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Blocks.lapis_ore), new ItemStack(Items.dye, 12, 4)); - RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Blocks.coal_ore), new ItemStack(Items.coal, 2)); - RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Blocks.diamond_ore), new ItemStack(Items.diamond, 2)); - RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Blocks.mossy_cobblestone), new ItemStack(Blocks.cobblestone)); - RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Blocks.stone), new ItemStack(Blocks.stonebrick, 1, 2)); - RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Blocks.sand), new ItemStack(Blocks.gravel)); - RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Blocks.gravel), new ItemStack(Blocks.cobblestone)); - RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Items.gunpowder), new ItemStack(Items.flint)); - RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Blocks.stonebrick, 1, 2), new ItemStack(Blocks.stonebrick, 1, 0)); - RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Blocks.stonebrick, 1, 0), new ItemStack(Blocks.stonebrick, 1, 3)); - RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Blocks.stonebrick, 1, 1), new ItemStack(Blocks.stonebrick, 1, 0)); - RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Blocks.glowstone), new ItemStack(Items.glowstone_dust, 4)); - RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Blocks.clay), new ItemStack(Items.clay_ball, 4)); - RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(MekanismBlocks.SaltBlock), new ItemStack(MekanismItems.Salt, 4)); - RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(Items.diamond), new ItemStack(MekanismItems.CompressedDiamond)); - RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(MekanismItems.Polyethene, 3, 0), new ItemStack(MekanismItems.Polyethene, 1, 2)); + for (int j = 0; j < EnumColor.DYES.length; j++) { + CraftingManager.getInstance().getRecipeList().add( + new ShapelessMekanismRecipe( + new ItemStack(MekanismItems.Balloon, 1, i), + new Object[] { new ItemStack(MekanismItems.Balloon, 1, j), + "dye" + EnumColor.DYES[i].dyeName } + ) + ); - for(int i = 0; i < EnumColor.DYES.length; i++) - { - RecipeHandler.addEnrichmentChamberRecipe(new ItemStack(MekanismBlocks.PlasticBlock, 1, i), new ItemStack(MekanismBlocks.SlickPlasticBlock, 1, i)); - } + CraftingManager.getInstance().getRecipeList().add( + new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.PlasticBlock, 4, i), + new Object[] { " P ", + "PDP", + " P ", + Character.valueOf('P'), + new ItemStack(MekanismBlocks.PlasticBlock, 1, j), + Character.valueOf('D'), + "dye" + EnumColor.DYES[i].dyeName } + ) + ); + CraftingManager.getInstance().getRecipeList().add( + new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.SlickPlasticBlock, 4, i), + new Object[] { + " P ", + "PDP", + " P ", + Character.valueOf('P'), + new ItemStack(MekanismBlocks.SlickPlasticBlock, 1, j), + Character.valueOf('D'), + "dye" + EnumColor.DYES[i].dyeName } + ) + ); + CraftingManager.getInstance().getRecipeList().add( + new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.GlowPlasticBlock, 4, i), + new Object[] { + " P ", + "PDP", + " P ", + Character.valueOf('P'), + new ItemStack(MekanismBlocks.GlowPlasticBlock, 1, j), + Character.valueOf('D'), + "dye" + EnumColor.DYES[i].dyeName } + ) + ); + CraftingManager.getInstance().getRecipeList().add( + new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.ReinforcedPlasticBlock, 4, i), + new Object[] { + " P ", + "PDP", + " P ", + Character.valueOf('P'), + new ItemStack(MekanismBlocks.ReinforcedPlasticBlock, 1, j), + Character.valueOf('D'), + "dye" + EnumColor.DYES[i].dyeName } + ) + ); + CraftingManager.getInstance().getRecipeList().add( + new ShapedMekanismRecipe( + new ItemStack(MekanismItems.GlowPanel, 4, i), + new Object[] { " P ", + "PDP", + " P ", + Character.valueOf('P'), + new ItemStack(MekanismItems.GlowPanel, 1, j), + Character.valueOf('D'), + "dye" + EnumColor.DYES[i].dyeName } + ) + ); + } - //Combiner recipes - RecipeHandler.addCombinerRecipe(new ItemStack(Items.redstone, 16), new ItemStack(Blocks.redstone_ore)); - RecipeHandler.addCombinerRecipe(new ItemStack(Items.dye, 16, 4), new ItemStack(Blocks.lapis_ore)); - RecipeHandler.addCombinerRecipe(new ItemStack(Items.flint), new ItemStack(Blocks.gravel)); - - //Osmium Compressor Recipes - RecipeHandler.addOsmiumCompressorRecipe(new ItemStack(Items.glowstone_dust), new ItemStack(MekanismItems.Ingot, 1, 3)); - - //Crusher Recipes - RecipeHandler.addCrusherRecipe(new ItemStack(Items.diamond), new ItemStack(MekanismItems.OtherDust, 1, 0)); - RecipeHandler.addCrusherRecipe(new ItemStack(Items.iron_ingot), new ItemStack(MekanismItems.Dust, 1, Resource.IRON.ordinal())); - RecipeHandler.addCrusherRecipe(new ItemStack(Items.gold_ingot), new ItemStack(MekanismItems.Dust, 1, Resource.GOLD.ordinal())); - RecipeHandler.addCrusherRecipe(new ItemStack(Blocks.gravel), new ItemStack(Blocks.sand)); - RecipeHandler.addCrusherRecipe(new ItemStack(Blocks.stone), new ItemStack(Blocks.cobblestone)); - RecipeHandler.addCrusherRecipe(new ItemStack(Blocks.cobblestone), new ItemStack(Blocks.gravel)); - RecipeHandler.addCrusherRecipe(new ItemStack(Blocks.stonebrick, 1, 2), new ItemStack(Blocks.stone)); - RecipeHandler.addCrusherRecipe(new ItemStack(Blocks.stonebrick, 1, 0), new ItemStack(Blocks.stonebrick, 1, 2)); - RecipeHandler.addCrusherRecipe(new ItemStack(Blocks.stonebrick, 1, 3), new ItemStack(Blocks.stonebrick, 1, 0)); - RecipeHandler.addCrusherRecipe(new ItemStack(Items.flint), new ItemStack(Items.gunpowder)); - RecipeHandler.addCrusherRecipe(new ItemStack(Blocks.sandstone), new ItemStack(Blocks.sand, 2)); - - for(int i = 0; i < 16; i++) - { - RecipeHandler.addCrusherRecipe(new ItemStack(Blocks.wool, 1, i), new ItemStack(Items.string, 4)); + CraftingManager.getInstance().getRecipeList().add(new ShapelessMekanismRecipe( + new ItemStack(MekanismBlocks.GlowPlasticBlock, 3, i), + new Object[] { new ItemStack(MekanismBlocks.PlasticBlock, 1, i), + new ItemStack(MekanismBlocks.PlasticBlock, 1, i), + new ItemStack(MekanismBlocks.PlasticBlock, 1, i), + new ItemStack(Items.glowstone_dust) } + )); + if (general.OreDictOsmium) { + CraftingManager.getInstance().getRecipeList().add( + new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.ReinforcedPlasticBlock, 4, i), + new Object[] { " P ", + "POP", + " P ", + Character.valueOf('P'), + new ItemStack(MekanismBlocks.PlasticBlock, 1, i), + Character.valueOf('O'), + "dustOsmium" } + ) + ); + } + if (general.OreDictPlatinum) { + CraftingManager.getInstance().getRecipeList().add( + new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.ReinforcedPlasticBlock, 4, i), + new Object[] { " P ", + "POP", + " P ", + Character.valueOf('P'), + new ItemStack(MekanismBlocks.PlasticBlock, 1, i), + Character.valueOf('O'), + "dustPlatinum" } + ) + ); + } + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.RoadPlasticBlock, 3, i), + new Object[] { "SSS", + "PPP", + "SSS", + Character.valueOf('S'), + Blocks.sand, + Character.valueOf('P'), + new ItemStack(MekanismBlocks.SlickPlasticBlock, 1, i) } + )); } - //BioFuel Crusher Recipes - RecipeHandler.addCrusherRecipe(new ItemStack(Blocks.tallgrass), new ItemStack(MekanismItems.BioFuel, 4)); - RecipeHandler.addCrusherRecipe(new ItemStack(Items.reeds), new ItemStack(MekanismItems.BioFuel, 2)); - RecipeHandler.addCrusherRecipe(new ItemStack(Items.wheat_seeds), new ItemStack(MekanismItems.BioFuel, 2)); - RecipeHandler.addCrusherRecipe(new ItemStack(Items.wheat), new ItemStack(MekanismItems.BioFuel, 4)); - RecipeHandler.addCrusherRecipe(new ItemStack(Items.pumpkin_seeds), new ItemStack(MekanismItems.BioFuel, 2)); - RecipeHandler.addCrusherRecipe(new ItemStack(Items.melon_seeds), new ItemStack(MekanismItems.BioFuel, 2)); - RecipeHandler.addCrusherRecipe(new ItemStack(Items.apple), new ItemStack(MekanismItems.BioFuel, 4)); - RecipeHandler.addCrusherRecipe(new ItemStack(Items.bread), new ItemStack(MekanismItems.BioFuel, 4)); - RecipeHandler.addCrusherRecipe(new ItemStack(Items.potato), new ItemStack(MekanismItems.BioFuel, 4)); - RecipeHandler.addCrusherRecipe(new ItemStack(Items.carrot), new ItemStack(MekanismItems.BioFuel, 4)); - RecipeHandler.addCrusherRecipe(new ItemStack(Items.rotten_flesh), new ItemStack(MekanismItems.BioFuel, 2)); - RecipeHandler.addCrusherRecipe(new ItemStack(Items.melon), new ItemStack(MekanismItems.BioFuel, 4)); - RecipeHandler.addCrusherRecipe(new ItemStack(Blocks.pumpkin), new ItemStack(MekanismItems.BioFuel, 6)); + //Furnace Recipes + FurnaceRecipes.smelting().func_151394_a( + new ItemStack(MekanismBlocks.OreBlock, 1, 0), + new ItemStack(MekanismItems.Ingot, 1, 1), + 1.0F + ); + FurnaceRecipes.smelting().func_151394_a( + new ItemStack(MekanismBlocks.OreBlock, 1, 1), + new ItemStack(MekanismItems.Ingot, 1, 5), + 1.0F + ); + FurnaceRecipes.smelting().func_151394_a( + new ItemStack(MekanismBlocks.OreBlock, 1, 2), + new ItemStack(MekanismItems.Ingot, 1, 6), + 1.0F + ); + FurnaceRecipes.smelting().func_151394_a( + new ItemStack(MekanismItems.Dust, 1, Resource.OSMIUM.ordinal()), + new ItemStack(MekanismItems.Ingot, 1, 1), + 0.0F + ); + FurnaceRecipes.smelting().func_151394_a( + new ItemStack(MekanismItems.Dust, 1, Resource.IRON.ordinal()), + new ItemStack(Items.iron_ingot), + 0.0F + ); + FurnaceRecipes.smelting().func_151394_a( + new ItemStack(MekanismItems.Dust, 1, Resource.GOLD.ordinal()), + new ItemStack(Items.gold_ingot), + 0.0F + ); + FurnaceRecipes.smelting().func_151394_a( + new ItemStack(MekanismItems.OtherDust, 1, 1), + new ItemStack(MekanismItems.Ingot, 1, 4), + 0.0F + ); + FurnaceRecipes.smelting().func_151394_a( + new ItemStack(MekanismItems.Dust, 1, Resource.COPPER.ordinal()), + new ItemStack(MekanismItems.Ingot, 1, 5), + 0.0F + ); + FurnaceRecipes.smelting().func_151394_a( + new ItemStack(MekanismItems.Dust, 1, Resource.TIN.ordinal()), + new ItemStack(MekanismItems.Ingot, 1, 6), + 0.0F + ); - //Purification Chamber Recipes - RecipeHandler.addPurificationChamberRecipe(new ItemStack(Blocks.gravel), new ItemStack(Items.flint)); + //Enrichment Chamber Recipes + RecipeHandler.addEnrichmentChamberRecipe( + new ItemStack(Blocks.redstone_ore), new ItemStack(Items.redstone, 12) + ); + RecipeHandler.addEnrichmentChamberRecipe( + new ItemStack(Blocks.obsidian), new ItemStack(MekanismItems.OtherDust, 2, 6) + ); + RecipeHandler.addEnrichmentChamberRecipe( + new ItemStack(Items.coal, 1, 0), new ItemStack(MekanismItems.CompressedCarbon) + ); + RecipeHandler.addEnrichmentChamberRecipe( + new ItemStack(Items.coal, 1, 1), new ItemStack(MekanismItems.CompressedCarbon) + ); + RecipeHandler.addEnrichmentChamberRecipe( + new ItemStack(Items.redstone), new ItemStack(MekanismItems.CompressedRedstone) + ); + RecipeHandler.addEnrichmentChamberRecipe( + new ItemStack(Blocks.lapis_ore), new ItemStack(Items.dye, 12, 4) + ); + RecipeHandler.addEnrichmentChamberRecipe( + new ItemStack(Blocks.coal_ore), new ItemStack(Items.coal, 2) + ); + RecipeHandler.addEnrichmentChamberRecipe( + new ItemStack(Blocks.diamond_ore), new ItemStack(Items.diamond, 2) + ); + RecipeHandler.addEnrichmentChamberRecipe( + new ItemStack(Blocks.mossy_cobblestone), new ItemStack(Blocks.cobblestone) + ); + RecipeHandler.addEnrichmentChamberRecipe( + new ItemStack(Blocks.stone), new ItemStack(Blocks.stonebrick, 1, 2) + ); + RecipeHandler.addEnrichmentChamberRecipe( + new ItemStack(Blocks.sand), new ItemStack(Blocks.gravel) + ); + RecipeHandler.addEnrichmentChamberRecipe( + new ItemStack(Blocks.gravel), new ItemStack(Blocks.cobblestone) + ); + RecipeHandler.addEnrichmentChamberRecipe( + new ItemStack(Items.gunpowder), new ItemStack(Items.flint) + ); + RecipeHandler.addEnrichmentChamberRecipe( + new ItemStack(Blocks.stonebrick, 1, 2), new ItemStack(Blocks.stonebrick, 1, 0) + ); + RecipeHandler.addEnrichmentChamberRecipe( + new ItemStack(Blocks.stonebrick, 1, 0), new ItemStack(Blocks.stonebrick, 1, 3) + ); + RecipeHandler.addEnrichmentChamberRecipe( + new ItemStack(Blocks.stonebrick, 1, 1), new ItemStack(Blocks.stonebrick, 1, 0) + ); + RecipeHandler.addEnrichmentChamberRecipe( + new ItemStack(Blocks.glowstone), new ItemStack(Items.glowstone_dust, 4) + ); + RecipeHandler.addEnrichmentChamberRecipe( + new ItemStack(Blocks.clay), new ItemStack(Items.clay_ball, 4) + ); + RecipeHandler.addEnrichmentChamberRecipe( + new ItemStack(MekanismBlocks.SaltBlock), new ItemStack(MekanismItems.Salt, 4) + ); + RecipeHandler.addEnrichmentChamberRecipe( + new ItemStack(Items.diamond), new ItemStack(MekanismItems.CompressedDiamond) + ); + RecipeHandler.addEnrichmentChamberRecipe( + new ItemStack(MekanismItems.Polyethene, 3, 0), + new ItemStack(MekanismItems.Polyethene, 1, 2) + ); + + for (int i = 0; i < EnumColor.DYES.length; i++) { + RecipeHandler.addEnrichmentChamberRecipe( + new ItemStack(MekanismBlocks.PlasticBlock, 1, i), + new ItemStack(MekanismBlocks.SlickPlasticBlock, 1, i) + ); + } + + //Combiner recipes + RecipeHandler.addCombinerRecipe( + new ItemStack(Items.redstone, 16), new ItemStack(Blocks.redstone_ore) + ); + RecipeHandler.addCombinerRecipe( + new ItemStack(Items.dye, 16, 4), new ItemStack(Blocks.lapis_ore) + ); + RecipeHandler.addCombinerRecipe( + new ItemStack(Items.flint), new ItemStack(Blocks.gravel) + ); + + //Osmium Compressor Recipes + RecipeHandler.addOsmiumCompressorRecipe( + new ItemStack(Items.glowstone_dust), new ItemStack(MekanismItems.Ingot, 1, 3) + ); + + //Crusher Recipes + RecipeHandler.addCrusherRecipe( + new ItemStack(Items.diamond), new ItemStack(MekanismItems.OtherDust, 1, 0) + ); + RecipeHandler.addCrusherRecipe( + new ItemStack(Items.iron_ingot), + new ItemStack(MekanismItems.Dust, 1, Resource.IRON.ordinal()) + ); + RecipeHandler.addCrusherRecipe( + new ItemStack(Items.gold_ingot), + new ItemStack(MekanismItems.Dust, 1, Resource.GOLD.ordinal()) + ); + RecipeHandler.addCrusherRecipe( + new ItemStack(Blocks.gravel), new ItemStack(Blocks.sand) + ); + RecipeHandler.addCrusherRecipe( + new ItemStack(Blocks.stone), new ItemStack(Blocks.cobblestone) + ); + RecipeHandler.addCrusherRecipe( + new ItemStack(Blocks.cobblestone), new ItemStack(Blocks.gravel) + ); + RecipeHandler.addCrusherRecipe( + new ItemStack(Blocks.stonebrick, 1, 2), new ItemStack(Blocks.stone) + ); + RecipeHandler.addCrusherRecipe( + new ItemStack(Blocks.stonebrick, 1, 0), new ItemStack(Blocks.stonebrick, 1, 2) + ); + RecipeHandler.addCrusherRecipe( + new ItemStack(Blocks.stonebrick, 1, 3), new ItemStack(Blocks.stonebrick, 1, 0) + ); + RecipeHandler.addCrusherRecipe( + new ItemStack(Items.flint), new ItemStack(Items.gunpowder) + ); + RecipeHandler.addCrusherRecipe( + new ItemStack(Blocks.sandstone), new ItemStack(Blocks.sand, 2) + ); + + for (int i = 0; i < 16; i++) { + RecipeHandler.addCrusherRecipe( + new ItemStack(Blocks.wool, 1, i), new ItemStack(Items.string, 4) + ); + } + + //BioFuel Crusher Recipes + RecipeHandler.addCrusherRecipe( + new ItemStack(Blocks.tallgrass), new ItemStack(MekanismItems.BioFuel, 4) + ); + RecipeHandler.addCrusherRecipe( + new ItemStack(Items.reeds), new ItemStack(MekanismItems.BioFuel, 2) + ); + RecipeHandler.addCrusherRecipe( + new ItemStack(Items.wheat_seeds), new ItemStack(MekanismItems.BioFuel, 2) + ); + RecipeHandler.addCrusherRecipe( + new ItemStack(Items.wheat), new ItemStack(MekanismItems.BioFuel, 4) + ); + RecipeHandler.addCrusherRecipe( + new ItemStack(Items.pumpkin_seeds), new ItemStack(MekanismItems.BioFuel, 2) + ); + RecipeHandler.addCrusherRecipe( + new ItemStack(Items.melon_seeds), new ItemStack(MekanismItems.BioFuel, 2) + ); + RecipeHandler.addCrusherRecipe( + new ItemStack(Items.apple), new ItemStack(MekanismItems.BioFuel, 4) + ); + RecipeHandler.addCrusherRecipe( + new ItemStack(Items.bread), new ItemStack(MekanismItems.BioFuel, 4) + ); + RecipeHandler.addCrusherRecipe( + new ItemStack(Items.potato), new ItemStack(MekanismItems.BioFuel, 4) + ); + RecipeHandler.addCrusherRecipe( + new ItemStack(Items.carrot), new ItemStack(MekanismItems.BioFuel, 4) + ); + RecipeHandler.addCrusherRecipe( + new ItemStack(Items.rotten_flesh), new ItemStack(MekanismItems.BioFuel, 2) + ); + RecipeHandler.addCrusherRecipe( + new ItemStack(Items.melon), new ItemStack(MekanismItems.BioFuel, 4) + ); + RecipeHandler.addCrusherRecipe( + new ItemStack(Blocks.pumpkin), new ItemStack(MekanismItems.BioFuel, 6) + ); + + //Purification Chamber Recipes + RecipeHandler.addPurificationChamberRecipe( + new ItemStack(Blocks.gravel), new ItemStack(Items.flint) + ); //Chemical Injection Chamber Recipes - RecipeHandler.addChemicalInjectionChamberRecipe(new ItemStack(Blocks.dirt), "water", new ItemStack(Blocks.clay)); - RecipeHandler.addChemicalInjectionChamberRecipe(new ItemStack(Blocks.hardened_clay), "water", new ItemStack(Blocks.clay)); - RecipeHandler.addChemicalInjectionChamberRecipe(new ItemStack(Items.brick), "water", new ItemStack(Items.clay_ball)); - RecipeHandler.addChemicalInjectionChamberRecipe(new ItemStack(Items.gunpowder), "hydrogenChloride", new ItemStack(MekanismItems.OtherDust, 1, 3)); + RecipeHandler.addChemicalInjectionChamberRecipe( + new ItemStack(Blocks.dirt), "water", new ItemStack(Blocks.clay) + ); + RecipeHandler.addChemicalInjectionChamberRecipe( + new ItemStack(Blocks.hardened_clay), "water", new ItemStack(Blocks.clay) + ); + RecipeHandler.addChemicalInjectionChamberRecipe( + new ItemStack(Items.brick), "water", new ItemStack(Items.clay_ball) + ); + RecipeHandler.addChemicalInjectionChamberRecipe( + new ItemStack(Items.gunpowder), + "hydrogenChloride", + new ItemStack(MekanismItems.OtherDust, 1, 3) + ); - //Precision Sawmill Recipes - RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.ladder, 3), new ItemStack(Items.stick, 7)); - RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.torch, 4), new ItemStack(Items.stick), new ItemStack(Items.coal), 1); - RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.chest), new ItemStack(Blocks.planks, 8)); - RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.trapdoor), new ItemStack(Blocks.planks, 3)); - RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Items.boat), new ItemStack(Blocks.planks, 5)); - RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Items.bed), new ItemStack(Blocks.planks, 3), new ItemStack(Blocks.wool, 3), 1); - RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Items.wooden_door), new ItemStack(Blocks.planks, 6)); - RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.jukebox), new ItemStack(Blocks.planks, 8), new ItemStack(Items.diamond), 1); - RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.bookshelf), new ItemStack(Blocks.planks, 6), new ItemStack(Items.book, 3), 1); - RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.wooden_pressure_plate), new ItemStack(Blocks.planks, 2)); - RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.fence), new ItemStack(Items.stick, 3)); - RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.fence_gate), new ItemStack(Blocks.planks, 2), new ItemStack(Items.stick, 4), 1); - RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.noteblock), new ItemStack(Blocks.planks, 8), new ItemStack(Items.redstone), 1); - RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.redstone_torch), new ItemStack(Items.stick), new ItemStack(Items.redstone), 1); - RecipeHandler.addPrecisionSawmillRecipe(new ItemStack(Blocks.crafting_table), new ItemStack(Blocks.planks, 4)); + //Precision Sawmill Recipes + RecipeHandler.addPrecisionSawmillRecipe( + new ItemStack(Blocks.ladder, 3), new ItemStack(Items.stick, 7) + ); + RecipeHandler.addPrecisionSawmillRecipe( + new ItemStack(Blocks.torch, 4), + new ItemStack(Items.stick), + new ItemStack(Items.coal), + 1 + ); + RecipeHandler.addPrecisionSawmillRecipe( + new ItemStack(Blocks.chest), new ItemStack(Blocks.planks, 8) + ); + RecipeHandler.addPrecisionSawmillRecipe( + new ItemStack(Blocks.trapdoor), new ItemStack(Blocks.planks, 3) + ); + RecipeHandler.addPrecisionSawmillRecipe( + new ItemStack(Items.boat), new ItemStack(Blocks.planks, 5) + ); + RecipeHandler.addPrecisionSawmillRecipe( + new ItemStack(Items.bed), + new ItemStack(Blocks.planks, 3), + new ItemStack(Blocks.wool, 3), + 1 + ); + RecipeHandler.addPrecisionSawmillRecipe( + new ItemStack(Items.wooden_door), new ItemStack(Blocks.planks, 6) + ); + RecipeHandler.addPrecisionSawmillRecipe( + new ItemStack(Blocks.jukebox), + new ItemStack(Blocks.planks, 8), + new ItemStack(Items.diamond), + 1 + ); + RecipeHandler.addPrecisionSawmillRecipe( + new ItemStack(Blocks.bookshelf), + new ItemStack(Blocks.planks, 6), + new ItemStack(Items.book, 3), + 1 + ); + RecipeHandler.addPrecisionSawmillRecipe( + new ItemStack(Blocks.wooden_pressure_plate), new ItemStack(Blocks.planks, 2) + ); + RecipeHandler.addPrecisionSawmillRecipe( + new ItemStack(Blocks.fence), new ItemStack(Items.stick, 3) + ); + RecipeHandler.addPrecisionSawmillRecipe( + new ItemStack(Blocks.fence_gate), + new ItemStack(Blocks.planks, 2), + new ItemStack(Items.stick, 4), + 1 + ); + RecipeHandler.addPrecisionSawmillRecipe( + new ItemStack(Blocks.noteblock), + new ItemStack(Blocks.planks, 8), + new ItemStack(Items.redstone), + 1 + ); + RecipeHandler.addPrecisionSawmillRecipe( + new ItemStack(Blocks.redstone_torch), + new ItemStack(Items.stick), + new ItemStack(Items.redstone), + 1 + ); + RecipeHandler.addPrecisionSawmillRecipe( + new ItemStack(Blocks.crafting_table), new ItemStack(Blocks.planks, 4) + ); //Metallurgic Infuser Recipes - RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("CARBON"), 10, new ItemStack(Items.iron_ingot), new ItemStack(MekanismItems.EnrichedIron)); - RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("CARBON"), 10, new ItemStack(MekanismItems.EnrichedIron), new ItemStack(MekanismItems.OtherDust, 1, 1)); - RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("FUNGI"), 10, new ItemStack(Blocks.dirt), new ItemStack(Blocks.mycelium)); - RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("BIO"), 10, new ItemStack(Blocks.cobblestone), new ItemStack(Blocks.mossy_cobblestone)); - RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("BIO"), 10, new ItemStack(Blocks.stonebrick, 1, 0), new ItemStack(Blocks.stonebrick, 1, 1)); - RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("BIO"), 10, new ItemStack(Blocks.sand), new ItemStack(Blocks.dirt)); - RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("BIO"), 10, new ItemStack(Blocks.dirt), new ItemStack(Blocks.dirt, 1, 2)); - RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("DIAMOND"), 10, new ItemStack(MekanismItems.EnrichedAlloy), new ItemStack(MekanismItems.ReinforcedAlloy)); - RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("OBSIDIAN"), 10, new ItemStack(MekanismItems.ReinforcedAlloy), new ItemStack(MekanismItems.AtomicAlloy)); + RecipeHandler.addMetallurgicInfuserRecipe( + InfuseRegistry.get("CARBON"), + 10, + new ItemStack(Items.iron_ingot), + new ItemStack(MekanismItems.EnrichedIron) + ); + RecipeHandler.addMetallurgicInfuserRecipe( + InfuseRegistry.get("CARBON"), + 10, + new ItemStack(MekanismItems.EnrichedIron), + new ItemStack(MekanismItems.OtherDust, 1, 1) + ); + RecipeHandler.addMetallurgicInfuserRecipe( + InfuseRegistry.get("FUNGI"), + 10, + new ItemStack(Blocks.dirt), + new ItemStack(Blocks.mycelium) + ); + RecipeHandler.addMetallurgicInfuserRecipe( + InfuseRegistry.get("BIO"), + 10, + new ItemStack(Blocks.cobblestone), + new ItemStack(Blocks.mossy_cobblestone) + ); + RecipeHandler.addMetallurgicInfuserRecipe( + InfuseRegistry.get("BIO"), + 10, + new ItemStack(Blocks.stonebrick, 1, 0), + new ItemStack(Blocks.stonebrick, 1, 1) + ); + RecipeHandler.addMetallurgicInfuserRecipe( + InfuseRegistry.get("BIO"), + 10, + new ItemStack(Blocks.sand), + new ItemStack(Blocks.dirt) + ); + RecipeHandler.addMetallurgicInfuserRecipe( + InfuseRegistry.get("BIO"), + 10, + new ItemStack(Blocks.dirt), + new ItemStack(Blocks.dirt, 1, 2) + ); + RecipeHandler.addMetallurgicInfuserRecipe( + InfuseRegistry.get("DIAMOND"), + 10, + new ItemStack(MekanismItems.EnrichedAlloy), + new ItemStack(MekanismItems.ReinforcedAlloy) + ); + RecipeHandler.addMetallurgicInfuserRecipe( + InfuseRegistry.get("OBSIDIAN"), + 10, + new ItemStack(MekanismItems.ReinforcedAlloy), + new ItemStack(MekanismItems.AtomicAlloy) + ); //Chemical Infuser Recipes - RecipeHandler.addChemicalInfuserRecipe(new GasStack(GasRegistry.getGas("oxygen"), 1), new GasStack(GasRegistry.getGas("sulfurDioxideGas"), 2), new GasStack(GasRegistry.getGas("sulfurTrioxideGas"), 2)); - RecipeHandler.addChemicalInfuserRecipe(new GasStack(GasRegistry.getGas("sulfurTrioxideGas"), 1), new GasStack(GasRegistry.getGas("water"), 1), new GasStack(GasRegistry.getGas("sulfuricAcid"), 1)); - RecipeHandler.addChemicalInfuserRecipe(new GasStack(GasRegistry.getGas("hydrogen"), 1), new GasStack(GasRegistry.getGas("chlorine"), 1), new GasStack(GasRegistry.getGas("hydrogenChloride"), 1)); - RecipeHandler.addChemicalInfuserRecipe(new GasStack(GasRegistry.getGas("deuterium"), 1), new GasStack(GasRegistry.getGas("tritium"), 1), new GasStack(GasRegistry.getGas("fusionFuelDT"), 2)); + RecipeHandler.addChemicalInfuserRecipe( + new GasStack(GasRegistry.getGas("oxygen"), 1), + new GasStack(GasRegistry.getGas("sulfurDioxideGas"), 2), + new GasStack(GasRegistry.getGas("sulfurTrioxideGas"), 2) + ); + RecipeHandler.addChemicalInfuserRecipe( + new GasStack(GasRegistry.getGas("sulfurTrioxideGas"), 1), + new GasStack(GasRegistry.getGas("water"), 1), + new GasStack(GasRegistry.getGas("sulfuricAcid"), 1) + ); + RecipeHandler.addChemicalInfuserRecipe( + new GasStack(GasRegistry.getGas("hydrogen"), 1), + new GasStack(GasRegistry.getGas("chlorine"), 1), + new GasStack(GasRegistry.getGas("hydrogenChloride"), 1) + ); + RecipeHandler.addChemicalInfuserRecipe( + new GasStack(GasRegistry.getGas("deuterium"), 1), + new GasStack(GasRegistry.getGas("tritium"), 1), + new GasStack(GasRegistry.getGas("fusionFuelDT"), 2) + ); - //Electrolytic Separator Recipes - RecipeHandler.addElectrolyticSeparatorRecipe(FluidRegistry.getFluidStack("water", 2), 2 * general.FROM_H2, new GasStack(GasRegistry.getGas("hydrogen"), 2), new GasStack(GasRegistry.getGas("oxygen"), 1)); - RecipeHandler.addElectrolyticSeparatorRecipe(FluidRegistry.getFluidStack("brine", 10), 2 * general.FROM_H2, new GasStack(GasRegistry.getGas("sodium"), 1), new GasStack(GasRegistry.getGas("chlorine"), 1)); - RecipeHandler.addElectrolyticSeparatorRecipe(FluidRegistry.getFluidStack("heavywater", 2), usage.heavyWaterElectrolysisUsage, new GasStack(GasRegistry.getGas("deuterium"), 2), new GasStack(GasRegistry.getGas("oxygen"), 1)); + //Electrolytic Separator Recipes + RecipeHandler.addElectrolyticSeparatorRecipe( + FluidRegistry.getFluidStack("water", 2), + 2 * general.FROM_H2, + new GasStack(GasRegistry.getGas("hydrogen"), 2), + new GasStack(GasRegistry.getGas("oxygen"), 1) + ); + RecipeHandler.addElectrolyticSeparatorRecipe( + FluidRegistry.getFluidStack("brine", 10), + 2 * general.FROM_H2, + new GasStack(GasRegistry.getGas("sodium"), 1), + new GasStack(GasRegistry.getGas("chlorine"), 1) + ); + RecipeHandler.addElectrolyticSeparatorRecipe( + FluidRegistry.getFluidStack("heavywater", 2), + usage.heavyWaterElectrolysisUsage, + new GasStack(GasRegistry.getGas("deuterium"), 2), + new GasStack(GasRegistry.getGas("oxygen"), 1) + ); - //Thermal Evaporation Plant Recipes - RecipeHandler.addThermalEvaporationRecipe(FluidRegistry.getFluidStack("water", 10), FluidRegistry.getFluidStack("brine", 1)); - RecipeHandler.addThermalEvaporationRecipe(FluidRegistry.getFluidStack("brine", 10), FluidRegistry.getFluidStack("lithium", 1)); + //Thermal Evaporation Plant Recipes + RecipeHandler.addThermalEvaporationRecipe( + FluidRegistry.getFluidStack("water", 10), + FluidRegistry.getFluidStack("brine", 1) + ); + RecipeHandler.addThermalEvaporationRecipe( + FluidRegistry.getFluidStack("brine", 10), + FluidRegistry.getFluidStack("lithium", 1) + ); - //Chemical Crystallizer Recipes - RecipeHandler.addChemicalCrystallizerRecipe(new GasStack(GasRegistry.getGas("lithium"), 100), new ItemStack(MekanismItems.OtherDust, 1, 4)); - RecipeHandler.addChemicalCrystallizerRecipe(new GasStack(GasRegistry.getGas("brine"), 15), new ItemStack(MekanismItems.Salt)); + //Chemical Crystallizer Recipes + RecipeHandler.addChemicalCrystallizerRecipe( + new GasStack(GasRegistry.getGas("lithium"), 100), + new ItemStack(MekanismItems.OtherDust, 1, 4) + ); + RecipeHandler.addChemicalCrystallizerRecipe( + new GasStack(GasRegistry.getGas("brine"), 15), + new ItemStack(MekanismItems.Salt) + ); - //T4 Processing Recipes - for(Gas gas : GasRegistry.getRegisteredGasses()) - { - if(gas instanceof OreGas && !((OreGas)gas).isClean()) - { - OreGas oreGas = (OreGas)gas; + //T4 Processing Recipes + for (Gas gas : GasRegistry.getRegisteredGasses()) { + if (gas instanceof OreGas && !((OreGas) gas).isClean()) { + OreGas oreGas = (OreGas) gas; - RecipeHandler.addChemicalWasherRecipe(new GasStack(oreGas, 1), new GasStack(oreGas.getCleanGas(), 1)); - RecipeHandler.addChemicalCrystallizerRecipe(new GasStack(oreGas.getCleanGas(), 200), new ItemStack(MekanismItems.Crystal, 1, Resource.getFromName(oreGas.getName()).ordinal())); - } - } + RecipeHandler.addChemicalWasherRecipe( + new GasStack(oreGas, 1), new GasStack(oreGas.getCleanGas(), 1) + ); + RecipeHandler.addChemicalCrystallizerRecipe( + new GasStack(oreGas.getCleanGas(), 200), + new ItemStack( + MekanismItems.Crystal, + 1, + Resource.getFromName(oreGas.getName()).ordinal() + ) + ); + } + } - //Pressurized Reaction Chamber Recipes - RecipeHandler.addPRCRecipe( - new ItemStack(MekanismItems.BioFuel, 2), new FluidStack(FluidRegistry.WATER, 10), new GasStack(GasRegistry.getGas("hydrogen"), 100), - new ItemStack(MekanismItems.Substrate), new GasStack(GasRegistry.getGas("ethene"), 100), - 0, - 100 - ); - RecipeHandler.addPRCRecipe( - new ItemStack(MekanismItems.Substrate), new FluidStack(FluidRegistry.getFluid("ethene"), 50), new GasStack(GasRegistry.getGas("oxygen"), 10), - new ItemStack(MekanismItems.Polyethene), new GasStack(GasRegistry.getGas("oxygen"), 5), - 1000, - 60 - ); - RecipeHandler.addPRCRecipe( - new ItemStack(MekanismItems.Substrate), new FluidStack(FluidRegistry.WATER, 200), new GasStack(GasRegistry.getGas("ethene"), 100), - new ItemStack(MekanismItems.Substrate, 8), new GasStack(GasRegistry.getGas("oxygen"), 10), - 200, - 400 - ); + //Pressurized Reaction Chamber Recipes + RecipeHandler.addPRCRecipe( + new ItemStack(MekanismItems.BioFuel, 2), + new FluidStack(FluidRegistry.WATER, 10), + new GasStack(GasRegistry.getGas("hydrogen"), 100), + new ItemStack(MekanismItems.Substrate), + new GasStack(GasRegistry.getGas("ethene"), 100), + 0, + 100 + ); + RecipeHandler.addPRCRecipe( + new ItemStack(MekanismItems.Substrate), + new FluidStack(FluidRegistry.getFluid("ethene"), 50), + new GasStack(GasRegistry.getGas("oxygen"), 10), + new ItemStack(MekanismItems.Polyethene), + new GasStack(GasRegistry.getGas("oxygen"), 5), + 1000, + 60 + ); + RecipeHandler.addPRCRecipe( + new ItemStack(MekanismItems.Substrate), + new FluidStack(FluidRegistry.WATER, 200), + new GasStack(GasRegistry.getGas("ethene"), 100), + new ItemStack(MekanismItems.Substrate, 8), + new GasStack(GasRegistry.getGas("oxygen"), 10), + 200, + 400 + ); - //Solar Neutron Activator Recipes - RecipeHandler.addSolarNeutronRecipe(new GasStack(GasRegistry.getGas("lithium"), 1), new GasStack(GasRegistry.getGas("tritium"), 1)); + //Solar Neutron Activator Recipes + RecipeHandler.addSolarNeutronRecipe( + new GasStack(GasRegistry.getGas("lithium"), 1), + new GasStack(GasRegistry.getGas("tritium"), 1) + ); //Infuse objects - InfuseRegistry.registerInfuseObject(new ItemStack(MekanismItems.BioFuel), new InfuseObject(InfuseRegistry.get("BIO"), 5)); - InfuseRegistry.registerInfuseObject(new ItemStack(Items.coal, 1, 0), new InfuseObject(InfuseRegistry.get("CARBON"), 10)); - InfuseRegistry.registerInfuseObject(new ItemStack(Items.coal, 1, 1), new InfuseObject(InfuseRegistry.get("CARBON"), 20)); - InfuseRegistry.registerInfuseObject(new ItemStack(MekanismItems.CompressedCarbon), new InfuseObject(InfuseRegistry.get("CARBON"), 80)); - InfuseRegistry.registerInfuseObject(new ItemStack(Items.redstone), new InfuseObject(InfuseRegistry.get("REDSTONE"), 10)); - InfuseRegistry.registerInfuseObject(new ItemStack(Blocks.redstone_block), new InfuseObject(InfuseRegistry.get("REDSTONE"), 90)); - InfuseRegistry.registerInfuseObject(new ItemStack(MekanismItems.CompressedRedstone), new InfuseObject(InfuseRegistry.get("REDSTONE"), 80)); - InfuseRegistry.registerInfuseObject(new ItemStack(Blocks.red_mushroom), new InfuseObject(InfuseRegistry.get("FUNGI"), 10)); - InfuseRegistry.registerInfuseObject(new ItemStack(Blocks.brown_mushroom), new InfuseObject(InfuseRegistry.get("FUNGI"), 10)); - InfuseRegistry.registerInfuseObject(new ItemStack(MekanismItems.CompressedDiamond), new InfuseObject(InfuseRegistry.get("DIAMOND"), 80)); - InfuseRegistry.registerInfuseObject(new ItemStack(MekanismItems.CompressedObsidian), new InfuseObject(InfuseRegistry.get("OBSIDIAN"), 80)); + InfuseRegistry.registerInfuseObject( + new ItemStack(MekanismItems.BioFuel), + new InfuseObject(InfuseRegistry.get("BIO"), 5) + ); + InfuseRegistry.registerInfuseObject( + new ItemStack(Items.coal, 1, 0), + new InfuseObject(InfuseRegistry.get("CARBON"), 10) + ); + InfuseRegistry.registerInfuseObject( + new ItemStack(Items.coal, 1, 1), + new InfuseObject(InfuseRegistry.get("CARBON"), 20) + ); + InfuseRegistry.registerInfuseObject( + new ItemStack(MekanismItems.CompressedCarbon), + new InfuseObject(InfuseRegistry.get("CARBON"), 80) + ); + InfuseRegistry.registerInfuseObject( + new ItemStack(Items.redstone), + new InfuseObject(InfuseRegistry.get("REDSTONE"), 10) + ); + InfuseRegistry.registerInfuseObject( + new ItemStack(Blocks.redstone_block), + new InfuseObject(InfuseRegistry.get("REDSTONE"), 90) + ); + InfuseRegistry.registerInfuseObject( + new ItemStack(MekanismItems.CompressedRedstone), + new InfuseObject(InfuseRegistry.get("REDSTONE"), 80) + ); + InfuseRegistry.registerInfuseObject( + new ItemStack(Blocks.red_mushroom), + new InfuseObject(InfuseRegistry.get("FUNGI"), 10) + ); + InfuseRegistry.registerInfuseObject( + new ItemStack(Blocks.brown_mushroom), + new InfuseObject(InfuseRegistry.get("FUNGI"), 10) + ); + InfuseRegistry.registerInfuseObject( + new ItemStack(MekanismItems.CompressedDiamond), + new InfuseObject(InfuseRegistry.get("DIAMOND"), 80) + ); + InfuseRegistry.registerInfuseObject( + new ItemStack(MekanismItems.CompressedObsidian), + new InfuseObject(InfuseRegistry.get("OBSIDIAN"), 80) + ); //Fuels GameRegistry.registerFuelHandler(new IFuelHandler() { - @Override - public int getBurnTime(ItemStack fuel) - { - if(fuel.isItemEqual(new ItemStack(MekanismBlocks.BasicBlock, 1, 3))) - { - return 200*8*9; - } + @Override + public int getBurnTime(ItemStack fuel) { + if (fuel.isItemEqual(new ItemStack(MekanismBlocks.BasicBlock, 1, 3))) { + return 200 * 8 * 9; + } - return 0; - } - }); + return 0; + } + }); - //Fuel Gases - FuelHandler.addGas(GasRegistry.getGas("hydrogen"), 1, general.FROM_H2); + //Fuel Gases + FuelHandler.addGas(GasRegistry.getGas("hydrogen"), 1, general.FROM_H2); - //RecipeSorter registrations - RecipeSorter.register("mekanism_shaped", ShapedMekanismRecipe.class, Category.SHAPED, ""); - RecipeSorter.register("mekanism_shapeless", ShapelessMekanismRecipe.class, Category.SHAPELESS, ""); - RecipeSorter.register("bin", BinRecipe.class, Category.SHAPELESS, ""); + //RecipeSorter registrations + RecipeSorter.register( + "mekanism_shaped", ShapedMekanismRecipe.class, Category.SHAPED, "" + ); + RecipeSorter.register( + "mekanism_shapeless", ShapelessMekanismRecipe.class, Category.SHAPELESS, "" + ); + RecipeSorter.register("bin", BinRecipe.class, Category.SHAPELESS, ""); + } - } + /** + * Registers specified items with the Ore Dictionary. + */ + public void registerOreDict() { + //Add specific items to ore dictionary for recipe usage in other mods. + OreDictionary.registerOre( + "universalCable", new ItemStack(MekanismItems.PartTransmitter, 8, 0) + ); + OreDictionary.registerOre( + "battery", MekanismItems.EnergyTablet.getUnchargedItem() + ); + OreDictionary.registerOre("pulpWood", MekanismItems.Sawdust); + OreDictionary.registerOre("dustWood", MekanismItems.Sawdust); + OreDictionary.registerOre("blockSalt", MekanismBlocks.SaltBlock); - /** - * Registers specified items with the Ore Dictionary. - */ - public void registerOreDict() - { - //Add specific items to ore dictionary for recipe usage in other mods. - OreDictionary.registerOre("universalCable", new ItemStack(MekanismItems.PartTransmitter, 8, 0)); - OreDictionary.registerOre("battery", MekanismItems.EnergyTablet.getUnchargedItem()); - OreDictionary.registerOre("pulpWood", MekanismItems.Sawdust); - OreDictionary.registerOre("dustWood", MekanismItems.Sawdust); - OreDictionary.registerOre("blockSalt", MekanismBlocks.SaltBlock); + //Alloys! + OreDictionary.registerOre("alloyBasic", new ItemStack(Items.redstone)); + OreDictionary.registerOre( + "alloyAdvanced", new ItemStack(MekanismItems.EnrichedAlloy) + ); + OreDictionary.registerOre( + "alloyElite", new ItemStack(MekanismItems.ReinforcedAlloy) + ); + OreDictionary.registerOre( + "alloyUltimate", new ItemStack(MekanismItems.AtomicAlloy) + ); - //Alloys! - OreDictionary.registerOre("alloyBasic", new ItemStack(Items.redstone)); - OreDictionary.registerOre("alloyAdvanced", new ItemStack(MekanismItems.EnrichedAlloy)); - OreDictionary.registerOre("alloyElite", new ItemStack(MekanismItems.ReinforcedAlloy)); - OreDictionary.registerOre("alloyUltimate", new ItemStack(MekanismItems.AtomicAlloy)); + //GregoriousT? + OreDictionary.registerOre("itemSalt", MekanismItems.Salt); + OreDictionary.registerOre("dustSalt", MekanismItems.Salt); - //GregoriousT? - OreDictionary.registerOre("itemSalt", MekanismItems.Salt); - OreDictionary.registerOre("dustSalt", MekanismItems.Salt); + OreDictionary.registerOre( + "dustDiamond", new ItemStack(MekanismItems.OtherDust, 1, 0) + ); + OreDictionary.registerOre( + "dustSteel", new ItemStack(MekanismItems.OtherDust, 1, 1) + ); + //Lead was once here + OreDictionary.registerOre( + "dustSulfur", new ItemStack(MekanismItems.OtherDust, 1, 3) + ); + OreDictionary.registerOre( + "dustLithium", new ItemStack(MekanismItems.OtherDust, 1, 4) + ); + OreDictionary.registerOre( + "dustRefinedObsidian", new ItemStack(MekanismItems.OtherDust, 1, 5) + ); + OreDictionary.registerOre( + "dustObsidian", new ItemStack(MekanismItems.OtherDust, 1, 6) + ); - OreDictionary.registerOre("dustDiamond", new ItemStack(MekanismItems.OtherDust, 1, 0)); - OreDictionary.registerOre("dustSteel", new ItemStack(MekanismItems.OtherDust, 1, 1)); - //Lead was once here - OreDictionary.registerOre("dustSulfur", new ItemStack(MekanismItems.OtherDust, 1, 3)); - OreDictionary.registerOre("dustLithium", new ItemStack(MekanismItems.OtherDust, 1, 4)); - OreDictionary.registerOre("dustRefinedObsidian", new ItemStack(MekanismItems.OtherDust, 1, 5)); - OreDictionary.registerOre("dustObsidian", new ItemStack(MekanismItems.OtherDust, 1, 6)); + OreDictionary.registerOre( + "ingotRefinedObsidian", new ItemStack(MekanismItems.Ingot, 1, 0) + ); - OreDictionary.registerOre("ingotRefinedObsidian", new ItemStack(MekanismItems.Ingot, 1, 0)); + OreDictionary.registerOre( + "ingotBronze", new ItemStack(MekanismItems.Ingot, 1, 2) + ); + OreDictionary.registerOre( + "ingotRefinedGlowstone", new ItemStack(MekanismItems.Ingot, 1, 3) + ); + OreDictionary.registerOre("ingotSteel", new ItemStack(MekanismItems.Ingot, 1, 4)); + OreDictionary.registerOre( + "ingotCopper", new ItemStack(MekanismItems.Ingot, 1, 5) + ); + OreDictionary.registerOre("ingotTin", new ItemStack(MekanismItems.Ingot, 1, 6)); - OreDictionary.registerOre("ingotBronze", new ItemStack(MekanismItems.Ingot, 1, 2)); - OreDictionary.registerOre("ingotRefinedGlowstone", new ItemStack(MekanismItems.Ingot, 1, 3)); - OreDictionary.registerOre("ingotSteel", new ItemStack(MekanismItems.Ingot, 1, 4)); - OreDictionary.registerOre("ingotCopper", new ItemStack(MekanismItems.Ingot, 1, 5)); - OreDictionary.registerOre("ingotTin", new ItemStack(MekanismItems.Ingot, 1, 6)); + OreDictionary.registerOre( + "blockBronze", new ItemStack(MekanismBlocks.BasicBlock, 1, 1) + ); + OreDictionary.registerOre( + "blockRefinedObsidian", new ItemStack(MekanismBlocks.BasicBlock, 1, 2) + ); + OreDictionary.registerOre( + "blockCharcoal", new ItemStack(MekanismBlocks.BasicBlock, 1, 3) + ); + OreDictionary.registerOre( + "blockRefinedGlowstone", new ItemStack(MekanismBlocks.BasicBlock, 1, 4) + ); + OreDictionary.registerOre( + "blockSteel", new ItemStack(MekanismBlocks.BasicBlock, 1, 5) + ); + OreDictionary.registerOre( + "blockCopper", new ItemStack(MekanismBlocks.BasicBlock, 1, 12) + ); + OreDictionary.registerOre( + "blockTin", new ItemStack(MekanismBlocks.BasicBlock, 1, 13) + ); + for (Resource resource : Resource.values()) { + OreDictionary.registerOre( + "dust" + resource.getName(), + new ItemStack(MekanismItems.Dust, 1, resource.ordinal()) + ); + OreDictionary.registerOre( + "dustDirty" + resource.getName(), + new ItemStack(MekanismItems.DirtyDust, 1, resource.ordinal()) + ); + OreDictionary.registerOre( + "clump" + resource.getName(), + new ItemStack(MekanismItems.Clump, 1, resource.ordinal()) + ); + OreDictionary.registerOre( + "shard" + resource.getName(), + new ItemStack(MekanismItems.Shard, 1, resource.ordinal()) + ); + OreDictionary.registerOre( + "crystal" + resource.getName(), + new ItemStack(MekanismItems.Crystal, 1, resource.ordinal()) + ); + } + if (general.OreDictOsmium) { + OreDictionary.registerOre( + "oreOsmium", new ItemStack(MekanismBlocks.OreBlock, 1, 0) + ); + OreDictionary.registerOre( + "ingotOsmium", new ItemStack(MekanismItems.Ingot, 1, 1) + ); + OreDictionary.registerOre( + "blockOsmium", new ItemStack(MekanismBlocks.BasicBlock, 1, 0) + ); + } + if (general.OreDictPlatinum) { + OreDictionary.registerOre( + "orePlatinum", new ItemStack(MekanismBlocks.OreBlock, 1, 0) + ); + OreDictionary.registerOre( + "ingotPlatinum", new ItemStack(MekanismItems.Ingot, 1, 1) + ); + OreDictionary.registerOre( + "blockPlatinum", new ItemStack(MekanismBlocks.BasicBlock, 1, 0) + ); + } + OreDictionary.registerOre( + "oreCopper", new ItemStack(MekanismBlocks.OreBlock, 1, 1) + ); + OreDictionary.registerOre("oreTin", new ItemStack(MekanismBlocks.OreBlock, 1, 2)); - OreDictionary.registerOre("blockBronze", new ItemStack(MekanismBlocks.BasicBlock, 1, 1)); - OreDictionary.registerOre("blockRefinedObsidian", new ItemStack(MekanismBlocks.BasicBlock, 1, 2)); - OreDictionary.registerOre("blockCharcoal", new ItemStack(MekanismBlocks.BasicBlock, 1, 3)); - OreDictionary.registerOre("blockRefinedGlowstone", new ItemStack(MekanismBlocks.BasicBlock, 1, 4)); - OreDictionary.registerOre("blockSteel", new ItemStack(MekanismBlocks.BasicBlock, 1, 5)); - OreDictionary.registerOre("blockCopper", new ItemStack(MekanismBlocks.BasicBlock, 1, 12)); - OreDictionary.registerOre("blockTin", new ItemStack(MekanismBlocks.BasicBlock, 1, 13)); + if (general.controlCircuitOreDict) { + OreDictionary.registerOre( + "circuitBasic", new ItemStack(MekanismItems.ControlCircuit, 1, 0) + ); + OreDictionary.registerOre( + "circuitAdvanced", new ItemStack(MekanismItems.ControlCircuit, 1, 1) + ); + OreDictionary.registerOre( + "circuitElite", new ItemStack(MekanismItems.ControlCircuit, 1, 2) + ); + OreDictionary.registerOre( + "circuitUltimate", new ItemStack(MekanismItems.ControlCircuit, 1, 3) + ); + } - for(Resource resource : Resource.values()) - { - OreDictionary.registerOre("dust" + resource.getName(), new ItemStack(MekanismItems.Dust, 1, resource.ordinal())); - OreDictionary.registerOre("dustDirty" + resource.getName(), new ItemStack(MekanismItems.DirtyDust, 1, resource.ordinal())); - OreDictionary.registerOre("clump" + resource.getName(), new ItemStack(MekanismItems.Clump, 1, resource.ordinal())); - OreDictionary.registerOre("shard" + resource.getName(), new ItemStack(MekanismItems.Shard, 1, resource.ordinal())); - OreDictionary.registerOre("crystal" + resource.getName(), new ItemStack(MekanismItems.Crystal, 1, resource.ordinal())); - } - if(general.OreDictOsmium) - { - OreDictionary.registerOre("oreOsmium", new ItemStack(MekanismBlocks.OreBlock, 1, 0)); - OreDictionary.registerOre("ingotOsmium", new ItemStack(MekanismItems.Ingot, 1, 1)); - OreDictionary.registerOre("blockOsmium", new ItemStack(MekanismBlocks.BasicBlock, 1, 0)); - } - if(general.OreDictPlatinum) - { - OreDictionary.registerOre("orePlatinum", new ItemStack(MekanismBlocks.OreBlock, 1, 0)); - OreDictionary.registerOre("ingotPlatinum", new ItemStack(MekanismItems.Ingot, 1, 1)); - OreDictionary.registerOre("blockPlatinum", new ItemStack(MekanismBlocks.BasicBlock, 1, 0)); - } - OreDictionary.registerOre("oreCopper", new ItemStack(MekanismBlocks.OreBlock, 1, 1)); - OreDictionary.registerOre("oreTin", new ItemStack(MekanismBlocks.OreBlock, 1, 2)); + OreDictionary.registerOre( + "itemCompressedCarbon", new ItemStack(MekanismItems.CompressedCarbon) + ); + OreDictionary.registerOre( + "itemEnrichedAlloy", new ItemStack(MekanismItems.EnrichedAlloy) + ); + OreDictionary.registerOre("itemBioFuel", new ItemStack(MekanismItems.BioFuel)); + } - if(general.controlCircuitOreDict) - { - OreDictionary.registerOre("circuitBasic", new ItemStack(MekanismItems.ControlCircuit, 1, 0)); - OreDictionary.registerOre("circuitAdvanced", new ItemStack(MekanismItems.ControlCircuit, 1, 1)); - OreDictionary.registerOre("circuitElite", new ItemStack(MekanismItems.ControlCircuit, 1, 2)); - OreDictionary.registerOre("circuitUltimate", new ItemStack(MekanismItems.ControlCircuit, 1, 3)); - } + /** + * Integrates the mod with other mods -- registering items and blocks with the Forge + * Ore Dictionary and adding machine recipes with other items' corresponding + * resources. + */ - OreDictionary.registerOre("itemCompressedCarbon", new ItemStack(MekanismItems.CompressedCarbon)); - OreDictionary.registerOre("itemEnrichedAlloy", new ItemStack(MekanismItems.EnrichedAlloy)); - OreDictionary.registerOre("itemBioFuel", new ItemStack(MekanismItems.BioFuel)); - } + /** + * Adds and registers all entities and tile entities. + */ + public void addEntities() { + //Registrations + EntityRegistry.registerModEntity( + EntityObsidianTNT.class, "ObsidianTNT", 0, this, 64, 5, true + ); + EntityRegistry.registerModEntity( + EntityRobit.class, "Robit", 1, this, 64, 2, true + ); + EntityRegistry.registerModEntity( + EntityBalloon.class, "Balloon", 2, this, 64, 1, true + ); + EntityRegistry.registerModEntity( + EntityBabySkeleton.class, "BabySkeleton", 3, this, 64, 5, true + ); + EntityRegistry.registerModEntity( + EntityFlame.class, "Flame", 4, this, 64, 5, true + ); - /** - * Integrates the mod with other mods -- registering items and blocks with the Forge Ore Dictionary - * and adding machine recipes with other items' corresponding resources. - */ + //Tile entities + GameRegistry.registerTileEntity(TileEntityBoundingBlock.class, "BoundingBlock"); + GameRegistry.registerTileEntity( + TileEntityAdvancedBoundingBlock.class, "AdvancedBoundingBlock" + ); + GameRegistry.registerTileEntity(TileEntityCardboardBox.class, "CardboardBox"); + GameRegistry.registerTileEntity( + TileEntityThermalEvaporationValve.class, "SalinationValve" + ); //TODO rename + GameRegistry.registerTileEntity( + TileEntityThermalEvaporationBlock.class, "SalinationTank" + ); //TODO rename + GameRegistry.registerTileEntity( + TileEntityPressureDisperser.class, "PressureDisperser" + ); + GameRegistry.registerTileEntity( + TileEntitySuperheatingElement.class, "SuperheatingElement" + ); - /** - * Adds and registers all entities and tile entities. - */ - public void addEntities() - { - //Registrations - EntityRegistry.registerModEntity(EntityObsidianTNT.class, "ObsidianTNT", 0, this, 64, 5, true); - EntityRegistry.registerModEntity(EntityRobit.class, "Robit", 1, this, 64, 2, true); - EntityRegistry.registerModEntity(EntityBalloon.class, "Balloon", 2, this, 64, 1, true); - EntityRegistry.registerModEntity(EntityBabySkeleton.class, "BabySkeleton", 3, this, 64, 5, true); - EntityRegistry.registerModEntity(EntityFlame.class, "Flame", 4, this, 64, 5, true); + //Load tile entities that have special renderers. + proxy.registerSpecialTileEntities(); + } - //Tile entities - GameRegistry.registerTileEntity(TileEntityBoundingBlock.class, "BoundingBlock"); - GameRegistry.registerTileEntity(TileEntityAdvancedBoundingBlock.class, "AdvancedBoundingBlock"); - GameRegistry.registerTileEntity(TileEntityCardboardBox.class, "CardboardBox"); - GameRegistry.registerTileEntity(TileEntityThermalEvaporationValve.class, "SalinationValve"); //TODO rename - GameRegistry.registerTileEntity(TileEntityThermalEvaporationBlock.class, "SalinationTank"); //TODO rename - GameRegistry.registerTileEntity(TileEntityPressureDisperser.class, "PressureDisperser"); - GameRegistry.registerTileEntity(TileEntitySuperheatingElement.class, "SuperheatingElement"); + @EventHandler + public void serverStarting(FMLServerStartingEvent event) { + if (general.voiceServerEnabled) { + voiceManager.start(); + } - //Load tile entities that have special renderers. - proxy.registerSpecialTileEntities(); - } + //Load cached furnace recipes + Recipe.ENERGIZED_SMELTER.get().clear(); - @EventHandler - public void serverStarting(FMLServerStartingEvent event) - { - if(general.voiceServerEnabled) - { - voiceManager.start(); - } + for (Object obj : FurnaceRecipes.smelting().getSmeltingList().entrySet()) { + Map.Entry entry = (Map.Entry) obj; + SmeltingRecipe recipe = new SmeltingRecipe( + new ItemStackInput(entry.getKey()), new ItemStackOutput(entry.getValue()) + ); + Recipe.ENERGIZED_SMELTER.put(recipe); + } - //Load cached furnace recipes - Recipe.ENERGIZED_SMELTER.get().clear(); + event.registerServerCommand(new CommandMekanism()); + } - for(Object obj : FurnaceRecipes.smelting().getSmeltingList().entrySet()) - { - Map.Entry entry = (Map.Entry)obj; - SmeltingRecipe recipe = new SmeltingRecipe(new ItemStackInput(entry.getKey()), new ItemStackOutput(entry.getValue())); - Recipe.ENERGIZED_SMELTER.put(recipe); - } + @EventHandler + public void serverStopping(FMLServerStoppingEvent event) { + if (general.voiceServerEnabled) { + voiceManager.stop(); + } - event.registerServerCommand(new CommandMekanism()); - } + //Clear all cache data + jetpackOn.clear(); + gasmaskOn.clear(); + activeVibrators.clear(); + worldTickHandler.resetRegenChunks(); + privateTeleporters.clear(); + protectedTeleporters.clear(); + privateEntangloporters.clear(); + protectedEntangloporters.clear(); - @EventHandler - public void serverStopping(FMLServerStoppingEvent event) - { - if(general.voiceServerEnabled) - { - voiceManager.stop(); - } + //Reset consistent managers + MultiblockManager.reset(); + FrequencyManager.reset(); + TransporterManager.reset(); + PathfinderCache.reset(); + TransmitterNetworkRegistry.reset(); + } - //Clear all cache data - jetpackOn.clear(); - gasmaskOn.clear(); - activeVibrators.clear(); - worldTickHandler.resetRegenChunks(); - privateTeleporters.clear(); - protectedTeleporters.clear(); - privateEntangloporters.clear(); - protectedEntangloporters.clear(); + @EventHandler + public void loadComplete(FMLLoadCompleteEvent event) { + new IMCHandler().onIMCEvent(FMLInterModComms.fetchRuntimeMessages(this)); + } - //Reset consistent managers - MultiblockManager.reset(); - FrequencyManager.reset(); - TransporterManager.reset(); - PathfinderCache.reset(); - TransmitterNetworkRegistry.reset(); - } + @EventHandler + public void preInit(FMLPreInitializationEvent event) { + File config = event.getSuggestedConfigurationFile(); - @EventHandler - public void loadComplete(FMLLoadCompleteEvent event) - { - new IMCHandler().onIMCEvent(FMLInterModComms.fetchRuntimeMessages(this)); - } - - @EventHandler - public void preInit(FMLPreInitializationEvent event) - { - File config = event.getSuggestedConfigurationFile(); - - //Set the mod's configuration - configuration = new Configuration(config); + //Set the mod's configuration + configuration = new Configuration(config); //Register tier information Tier.init(); - if(config.getAbsolutePath().contains("voltz")) - { - logger.info("Detected Voltz in root directory - hello, fellow user!"); - } - else if(config.getAbsolutePath().contains("tekkit")) - { - logger.info("Detected Tekkit in root directory - hello, fellow user!"); - } + if (config.getAbsolutePath().contains("voltz")) { + logger.info("Detected Voltz in root directory - hello, fellow user!"); + } else if (config.getAbsolutePath().contains("tekkit")) { + logger.info("Detected Tekkit in root directory - hello, fellow user!"); + } - GasRegistry.register(new Gas("hydrogen")).registerFluid(); - GasRegistry.register(new Gas("oxygen")).registerFluid(); - GasRegistry.register(new Gas("water")).registerFluid(); - GasRegistry.register(new Gas("chlorine")).registerFluid(); - GasRegistry.register(new Gas("sulfurDioxideGas")).registerFluid(); - GasRegistry.register(new Gas("sulfurTrioxideGas")).registerFluid(); - GasRegistry.register(new Gas("sulfuricAcid")).registerFluid(); - GasRegistry.register(new Gas("hydrogenChloride")).registerFluid(); - GasRegistry.register(new Gas("liquidOsmium").setVisible(false)); - GasRegistry.register(new Gas("liquidStone").setVisible(false)); - GasRegistry.register(new Gas("elementizerFuel").setVisible(false)); - GasRegistry.register(new Gas("ethene").registerFluid()); - GasRegistry.register(new Gas("sodium").registerFluid()); - GasRegistry.register(new Gas("brine").registerFluid()); - GasRegistry.register(new Gas("deuterium")).registerFluid(); - GasRegistry.register(new Gas("tritium")).registerFluid(); - GasRegistry.register(new Gas("fusionFuelDT")).registerFluid(); - GasRegistry.register(new Gas("lithium")).registerFluid(); - GasRegistry.register(new Gas("methane")).registerFluid(); + GasRegistry.register(new Gas("hydrogen")).registerFluid(); + GasRegistry.register(new Gas("oxygen")).registerFluid(); + GasRegistry.register(new Gas("water")).registerFluid(); + GasRegistry.register(new Gas("chlorine")).registerFluid(); + GasRegistry.register(new Gas("sulfurDioxideGas")).registerFluid(); + GasRegistry.register(new Gas("sulfurTrioxideGas")).registerFluid(); + GasRegistry.register(new Gas("sulfuricAcid")).registerFluid(); + GasRegistry.register(new Gas("hydrogenChloride")).registerFluid(); + GasRegistry.register(new Gas("liquidOsmium").setVisible(false)); + GasRegistry.register(new Gas("liquidStone").setVisible(false)); + GasRegistry.register(new Gas("elementizerFuel").setVisible(false)); + GasRegistry.register(new Gas("ethene").registerFluid()); + GasRegistry.register(new Gas("sodium").registerFluid()); + GasRegistry.register(new Gas("brine").registerFluid()); + GasRegistry.register(new Gas("deuterium")).registerFluid(); + GasRegistry.register(new Gas("tritium")).registerFluid(); + GasRegistry.register(new Gas("fusionFuelDT")).registerFluid(); + GasRegistry.register(new Gas("lithium")).registerFluid(); + GasRegistry.register(new Gas("methane")).registerFluid(); - FluidRegistry.registerFluid(new Fluid("heavyWater")); - FluidRegistry.registerFluid(new Fluid("steam").setGaseous(true)); + FluidRegistry.registerFluid(new Fluid("heavyWater")); + FluidRegistry.registerFluid(new Fluid("steam").setGaseous(true)); - for(Resource resource : Resource.values()) - { - String name = resource.getName(); + for (Resource resource : Resource.values()) { + String name = resource.getName(); - OreGas clean = (OreGas)GasRegistry.register(new OreGas("clean" + name, "oregas." + name.toLowerCase()).setVisible(false)); - GasRegistry.register(new OreGas(name.toLowerCase(), "oregas." + name.toLowerCase()).setCleanGas(clean).setVisible(false)); - } - - CompatibilityModule.register(new UECompatModule()); + OreGas clean = (OreGas) GasRegistry.register( + new OreGas("clean" + name, "oregas." + name.toLowerCase()) + .setVisible(false) + ); + GasRegistry.register( + new OreGas(name.toLowerCase(), "oregas." + name.toLowerCase()) + .setCleanGas(clean) + .setVisible(false) + ); + } - Mekanism.proxy.preInit(); + CompatibilityModule.register(new UECompatModule()); - //Register blocks and items - MekanismItems.register(); - MekanismBlocks.register(); + Mekanism.proxy.preInit(); - //Register infuses - InfuseRegistry.registerInfuseType(new InfuseType("CARBON", "mekanism:infuse/Carbon").setUnlocalizedName("carbon")); - InfuseRegistry.registerInfuseType(new InfuseType("TIN", "mekanism:infuse/Tin").setUnlocalizedName("tin")); - InfuseRegistry.registerInfuseType(new InfuseType("DIAMOND", "mekanism:infuse/Diamond").setUnlocalizedName("diamond")); - InfuseRegistry.registerInfuseType(new InfuseType("REDSTONE", "mekanism:infuse/Redstone").setUnlocalizedName("redstone")); - InfuseRegistry.registerInfuseType(new InfuseType("FUNGI", "mekanism:infuse/Fungi").setUnlocalizedName("fungi")); - InfuseRegistry.registerInfuseType(new InfuseType("BIO", "mekanism:infuse/Bio").setUnlocalizedName("bio")); - InfuseRegistry.registerInfuseType(new InfuseType("OBSIDIAN", "mekanism:infuse/Obsidian").setUnlocalizedName("obsidian")); - } + //Register blocks and items + MekanismItems.register(); + MekanismBlocks.register(); - @EventHandler - public void init(FMLInitializationEvent event) - { - Mekanism.proxy.Cape(); + //Register infuses + InfuseRegistry.registerInfuseType( + new InfuseType("CARBON", "mekanism:infuse/Carbon") + .setUnlocalizedName("carbon") + ); + InfuseRegistry.registerInfuseType( + new InfuseType("TIN", "mekanism:infuse/Tin").setUnlocalizedName("tin") + ); + InfuseRegistry.registerInfuseType( + new InfuseType("DIAMOND", "mekanism:infuse/Diamond") + .setUnlocalizedName("diamond") + ); + InfuseRegistry.registerInfuseType( + new InfuseType("REDSTONE", "mekanism:infuse/Redstone") + .setUnlocalizedName("redstone") + ); + InfuseRegistry.registerInfuseType( + new InfuseType("FUNGI", "mekanism:infuse/Fungi").setUnlocalizedName("fungi") + ); + InfuseRegistry.registerInfuseType( + new InfuseType("BIO", "mekanism:infuse/Bio").setUnlocalizedName("bio") + ); + InfuseRegistry.registerInfuseType( + new InfuseType("OBSIDIAN", "mekanism:infuse/Obsidian") + .setUnlocalizedName("obsidian") + ); + } - //Register the mod's world generators - GameRegistry.registerWorldGenerator(genHandler, 1); + @EventHandler + public void init(FMLInitializationEvent event) { + Mekanism.proxy.Cape(); - //Register the mod's GUI handler - NetworkRegistry.INSTANCE.registerGuiHandler(this, new CoreGuiHandler()); + //Register the mod's world generators + GameRegistry.registerWorldGenerator(genHandler, 1); - //Register player tracker - FMLCommonHandler.instance().bus().register(new CommonPlayerTracker()); - FMLCommonHandler.instance().bus().register(new CommonPlayerTickHandler()); + //Register the mod's GUI handler + NetworkRegistry.INSTANCE.registerGuiHandler(this, new CoreGuiHandler()); - //Initialization notification - logger.info("Version " + versionNumber + " initializing..."); + //Register player tracker + FMLCommonHandler.instance().bus().register(new CommonPlayerTracker()); + FMLCommonHandler.instance().bus().register(new CommonPlayerTickHandler()); - //Register with ForgeChunkManager - ForgeChunkManager.setForcedChunkLoadingCallback(this, new ChunkManager()); + //Initialization notification + logger.info("Version " + versionNumber + " initializing..."); - //Register to receive subscribed events - FMLCommonHandler.instance().bus().register(this); - MinecraftForge.EVENT_BUS.register(this); + //Register with ForgeChunkManager + ForgeChunkManager.setForcedChunkLoadingCallback(this, new ChunkManager()); - //Register this module's GUI handler in the simple packet protocol - PacketSimpleGui.handlers.add(0, proxy); + //Register to receive subscribed events + FMLCommonHandler.instance().bus().register(this); + MinecraftForge.EVENT_BUS.register(this); - //Set up VoiceServerManager - if(general.voiceServerEnabled) - { - voiceManager = new VoiceServerManager(); - } + //Register this module's GUI handler in the simple packet protocol + PacketSimpleGui.handlers.add(0, proxy); - //Register with TransmitterNetworkRegistry - TransmitterNetworkRegistry.initiate(); + //Set up VoiceServerManager + if (general.voiceServerEnabled) { + voiceManager = new VoiceServerManager(); + } - //Load configuration - proxy.loadConfiguration(); - proxy.onConfigSync(false); + //Register with TransmitterNetworkRegistry + TransmitterNetworkRegistry.initiate(); - ElementizerRecipeHandler.loadDefaultItems(); + //Load configuration + proxy.loadConfiguration(); + proxy.onConfigSync(false); - //Add baby skeleton spawner - if(general.spawnBabySkeletons) - { - for(BiomeGenBase biome : WorldChunkManager.allowedBiomes) - { - if(biome.getSpawnableList(EnumCreatureType.monster) != null && biome.getSpawnableList(EnumCreatureType.monster).size() > 0) - { - EntityRegistry.addSpawn(EntityBabySkeleton.class, 40, 1, 3, EnumCreatureType.monster, new BiomeGenBase[] {biome}); - } - } - } + ElementizerRecipeHandler.loadDefaultItems(); - //Integrate certain OreDictionary recipes - registerOreDict(); + //Add baby skeleton spawner + if (general.spawnBabySkeletons) { + for (BiomeGenBase biome : WorldChunkManager.allowedBiomes) { + if (biome.getSpawnableList(EnumCreatureType.monster) != null + && biome.getSpawnableList(EnumCreatureType.monster).size() > 0) { + EntityRegistry.addSpawn( + EntityBabySkeleton.class, + 40, + 1, + 3, + EnumCreatureType.monster, + new BiomeGenBase[] { biome } + ); + } + } + } - //Load this module - addRecipes(); - addEntities(); + //Integrate certain OreDictionary recipes + registerOreDict(); - //Set up multiparts - new MultipartMekanism(); + //Load this module + addRecipes(); + addEntities(); - //Integrate with Waila - FMLInterModComms.sendMessage("Waila", "register", "mekanism.common.integration.WailaDataProvider.register"); + //Set up multiparts + new MultipartMekanism(); - //Integrate with OpenComputers - if(Loader.isModLoaded("OpenComputers")) - { - hooks.loadOCDrivers(); - } + //Integrate with Waila + FMLInterModComms.sendMessage( + "Waila", "register", "mekanism.common.integration.WailaDataProvider.register" + ); - if(Loader.isModLoaded("appliedenergistics2")) - { - hooks.registerAE2P2P(); - } + //Integrate with OpenComputers + if (Loader.isModLoaded("OpenComputers")) { + hooks.loadOCDrivers(); + } - //Packet registrations - packetHandler.initialize(); + if (Loader.isModLoaded("appliedenergistics2")) { + hooks.registerAE2P2P(); + } - //Load proxy - proxy.registerRenderInformation(); - proxy.loadUtilities(); + //Packet registrations + packetHandler.initialize(); - //Completion notification - logger.info("Loading complete."); + //Load proxy + proxy.registerRenderInformation(); + proxy.loadUtilities(); - //Success message - logger.info("Mod loaded."); - } + //Completion notification + logger.info("Loading complete."); - @EventHandler - public void postInit(FMLPostInitializationEvent event) - { - logger.info("Fake player readout: UUID = " + gameProfile.getId().toString() + ", name = " + gameProfile.getName()); + //Success message + logger.info("Mod loaded."); + } - hooks.hook(); + @EventHandler + public void postInit(FMLPostInitializationEvent event) { + logger.info( + "Fake player readout: UUID = " + gameProfile.getId().toString() + + ", name = " + gameProfile.getName() + ); - MinecraftForge.EVENT_BUS.post(new BoxBlacklistEvent()); + hooks.hook(); - OreDictManager.init(); + MinecraftForge.EVENT_BUS.post(new BoxBlacklistEvent()); - //Update the config-dependent recipes after the recipes have actually been added in the first place - Mekanism.proxy.updateConfigRecipes(); + OreDictManager.init(); - logger.info("Hooking complete."); - } + //Update the config-dependent recipes after the recipes have actually been added + //in the first place + Mekanism.proxy.updateConfigRecipes(); - @Mod.EventHandler - public void onServerAboutToStart(FMLServerAboutToStartEvent event) { - OreDictManager.terralizationcompat(); - } + logger.info("Hooking complete."); + } - @SubscribeEvent - public void onEnergyTransferred(EnergyTransferEvent event) - { - try { - packetHandler.sendToReceivers(new TransmitterUpdateMessage(PacketType.ENERGY, event.energyNetwork.transmitters.iterator().next().coord(), event.power), event.energyNetwork.getPacketRange()); - } catch(Exception e) {} - } + @Mod.EventHandler + public void onServerAboutToStart(FMLServerAboutToStartEvent event) { + OreDictManager.terralizationcompat(); + } - @SubscribeEvent - public void onGasTransferred(GasTransferEvent event) - { - try { - packetHandler.sendToReceivers(new TransmitterUpdateMessage(PacketType.GAS, event.gasNetwork.transmitters.iterator().next().coord(), event.transferType, event.didTransfer), event.gasNetwork.getPacketRange()); - } catch(Exception e) {} - } + @SubscribeEvent + public void onEnergyTransferred(EnergyTransferEvent event) { + try { + packetHandler.sendToReceivers( + new TransmitterUpdateMessage( + PacketType.ENERGY, + event.energyNetwork.transmitters.iterator().next().coord(), + event.power + ), + event.energyNetwork.getPacketRange() + ); + } catch (Exception e) {} + } - @SubscribeEvent - public void onLiquidTransferred(FluidTransferEvent event) - { - try { - packetHandler.sendToReceivers(new TransmitterUpdateMessage(PacketType.FLUID, event.fluidNetwork.transmitters.iterator().next().coord(), event.fluidType, event.didTransfer), event.fluidNetwork.getPacketRange()); - } catch(Exception e) {} - } + @SubscribeEvent + public void onGasTransferred(GasTransferEvent event) { + try { + packetHandler.sendToReceivers( + new TransmitterUpdateMessage( + PacketType.GAS, + event.gasNetwork.transmitters.iterator().next().coord(), + event.transferType, + event.didTransfer + ), + event.gasNetwork.getPacketRange() + ); + } catch (Exception e) {} + } - @SubscribeEvent - public void onTransmittersAddedEvent(TransmittersAddedEvent event) - { - try { - packetHandler.sendToReceivers(new TransmitterUpdateMessage(PacketType.UPDATE, event.network.transmitters.iterator().next().coord(), event.newNetwork, event.newTransmitters), event.network.getPacketRange()); - } catch(Exception e) {} - } + @SubscribeEvent + public void onLiquidTransferred(FluidTransferEvent event) { + try { + packetHandler.sendToReceivers( + new TransmitterUpdateMessage( + PacketType.FLUID, + event.fluidNetwork.transmitters.iterator().next().coord(), + event.fluidType, + event.didTransfer + ), + event.fluidNetwork.getPacketRange() + ); + } catch (Exception e) {} + } - @SubscribeEvent - public void onNetworkClientRequest(NetworkClientRequest event) - { - try { - packetHandler.sendToServer(new DataRequestMessage(Coord4D.get(event.tileEntity))); - } catch(Exception e) {} - } + @SubscribeEvent + public void onTransmittersAddedEvent(TransmittersAddedEvent event) { + try { + packetHandler.sendToReceivers( + new TransmitterUpdateMessage( + PacketType.UPDATE, + event.network.transmitters.iterator().next().coord(), + event.newNetwork, + event.newTransmitters + ), + event.network.getPacketRange() + ); + } catch (Exception e) {} + } - @SubscribeEvent - public void onClientTickUpdate(ClientTickUpdate event) - { - try { - if(event.operation == 0) - { - ClientTickHandler.tickingSet.remove(event.network); - } - else { - ClientTickHandler.tickingSet.add(event.network); - } - } catch(Exception e) {} - } + @SubscribeEvent + public void onNetworkClientRequest(NetworkClientRequest event) { + try { + packetHandler.sendToServer(new DataRequestMessage(Coord4D.get(event.tileEntity + ))); + } catch (Exception e) {} + } - @SubscribeEvent - public void onBlacklistUpdate(BoxBlacklistEvent event) - { - MekanismAPI.addBoxBlacklist(MekanismBlocks.CardboardBox, OreDictionary.WILDCARD_VALUE); - MekanismAPI.addBoxBlacklist(MekanismBlocks.BoundingBlock, OreDictionary.WILDCARD_VALUE); - MekanismAPI.addBoxBlacklist(Blocks.bedrock, 0); - MekanismAPI.addBoxBlacklist(Blocks.portal, OreDictionary.WILDCARD_VALUE); - MekanismAPI.addBoxBlacklist(Blocks.end_portal, OreDictionary.WILDCARD_VALUE); - MekanismAPI.addBoxBlacklist(Blocks.end_portal_frame, OreDictionary.WILDCARD_VALUE); - MekanismAPI.addBoxBlacklist(Blocks.bed, OreDictionary.WILDCARD_VALUE); - MekanismAPI.addBoxBlacklist(Blocks.wooden_door, OreDictionary.WILDCARD_VALUE); - MekanismAPI.addBoxBlacklist(Blocks.iron_door, OreDictionary.WILDCARD_VALUE); - MekanismAPI.addBoxBlacklist(MultipartProxy.block(), OreDictionary.WILDCARD_VALUE); + @SubscribeEvent + public void onClientTickUpdate(ClientTickUpdate event) { + try { + if (event.operation == 0) { + ClientTickHandler.tickingSet.remove(event.network); + } else { + ClientTickHandler.tickingSet.add(event.network); + } + } catch (Exception e) {} + } - BoxBlacklistParser.load(); - } + @SubscribeEvent + public void onBlacklistUpdate(BoxBlacklistEvent event) { + MekanismAPI.addBoxBlacklist( + MekanismBlocks.CardboardBox, OreDictionary.WILDCARD_VALUE + ); + MekanismAPI.addBoxBlacklist( + MekanismBlocks.BoundingBlock, OreDictionary.WILDCARD_VALUE + ); + MekanismAPI.addBoxBlacklist(Blocks.bedrock, 0); + MekanismAPI.addBoxBlacklist(Blocks.portal, OreDictionary.WILDCARD_VALUE); + MekanismAPI.addBoxBlacklist(Blocks.end_portal, OreDictionary.WILDCARD_VALUE); + MekanismAPI.addBoxBlacklist( + Blocks.end_portal_frame, OreDictionary.WILDCARD_VALUE + ); + MekanismAPI.addBoxBlacklist(Blocks.bed, OreDictionary.WILDCARD_VALUE); + MekanismAPI.addBoxBlacklist(Blocks.wooden_door, OreDictionary.WILDCARD_VALUE); + MekanismAPI.addBoxBlacklist(Blocks.iron_door, OreDictionary.WILDCARD_VALUE); + MekanismAPI.addBoxBlacklist(MultipartProxy.block(), OreDictionary.WILDCARD_VALUE); - @SubscribeEvent - public synchronized void onChunkLoad(ChunkEvent.Load event) - { - if(event.getChunk() != null && !event.world.isRemote) - { - //Map copy = (Map)((HashMap)event.getChunk().chunkTileEntityMap).clone(); + BoxBlacklistParser.load(); + } - for(Iterator iter = /*copy*/event.getChunk().chunkTileEntityMap.values().iterator(); iter.hasNext();) - { - Object obj = iter.next(); + @SubscribeEvent + public synchronized void onChunkLoad(ChunkEvent.Load event) { + if (event.getChunk() != null && !event.world.isRemote) { + //Map copy = (Map)((HashMap)event.getChunk().chunkTileEntityMap).clone(); - if(obj instanceof TileEntity) - { - TileEntity tileEntity = (TileEntity)obj; + for (Iterator iter + = /*copy*/ event.getChunk().chunkTileEntityMap.values().iterator(); + iter.hasNext();) { + Object obj = iter.next(); - if(tileEntity instanceof TileEntityElectricBlock && MekanismUtils.useIC2()) - { - ((TileEntityElectricBlock)tileEntity).register(); - } - else if(tileEntity instanceof IChunkLoadHandler) - { - ((IChunkLoadHandler)tileEntity).onChunkLoad(); - } - } - } - } - } + if (obj instanceof TileEntity) { + TileEntity tileEntity = (TileEntity) obj; - @SubscribeEvent - public void chunkSave(ChunkDataEvent.Save event) - { - if(!event.world.isRemote) - { - NBTTagCompound nbtTags = event.getData(); + if (tileEntity instanceof TileEntityElectricBlock + && MekanismUtils.useIC2()) { + ((TileEntityElectricBlock) tileEntity).register(); + } else if (tileEntity instanceof IChunkLoadHandler) { + ((IChunkLoadHandler) tileEntity).onChunkLoad(); + } + } + } + } + } - nbtTags.setInteger("MekanismWorldGen", baseWorldGenVersion); - nbtTags.setInteger("MekanismUserWorldGen", general.userWorldGenVersion); - } - } + @SubscribeEvent + public void chunkSave(ChunkDataEvent.Save event) { + if (!event.world.isRemote) { + NBTTagCompound nbtTags = event.getData(); - @SubscribeEvent - public synchronized void onChunkDataLoad(ChunkDataEvent.Load event) - { - if(!event.world.isRemote) - { - if(general.enableWorldRegeneration) - { - NBTTagCompound loadData = event.getData(); + nbtTags.setInteger("MekanismWorldGen", baseWorldGenVersion); + nbtTags.setInteger("MekanismUserWorldGen", general.userWorldGenVersion); + } + } - if(loadData.getInteger("MekanismWorldGen") == baseWorldGenVersion && loadData.getInteger("MekanismUserWorldGen") == general.userWorldGenVersion) - { - return; - } + @SubscribeEvent + public synchronized void onChunkDataLoad(ChunkDataEvent.Load event) { + if (!event.world.isRemote) { + if (general.enableWorldRegeneration) { + NBTTagCompound loadData = event.getData(); - ChunkCoordIntPair coordPair = event.getChunk().getChunkCoordIntPair(); - worldTickHandler.addRegenChunk(event.world.provider.dimensionId, coordPair); - } - } - } + if (loadData.getInteger("MekanismWorldGen") == baseWorldGenVersion + && loadData.getInteger("MekanismUserWorldGen") + == general.userWorldGenVersion) { + return; + } - @SubscribeEvent - public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) - { - if(event.modID.equals("Mekanism")) - { - proxy.loadConfiguration(); - proxy.onConfigSync(false); - } - } + ChunkCoordIntPair coordPair = event.getChunk().getChunkCoordIntPair(); + worldTickHandler.addRegenChunk( + event.world.provider.dimensionId, coordPair + ); + } + } + } + + @SubscribeEvent + public void onConfigChanged(ConfigChangedEvent.OnConfigChangedEvent event) { + if (event.modID.equals("Mekanism")) { + proxy.loadConfiguration(); + proxy.onConfigSync(false); + } + } } diff --git a/src/main/java/mekanism/common/MekanismBlocks.java b/src/main/java/mekanism/common/MekanismBlocks.java index 66d97b699..6be585651 100644 --- a/src/main/java/mekanism/common/MekanismBlocks.java +++ b/src/main/java/mekanism/common/MekanismBlocks.java @@ -5,6 +5,9 @@ import static mekanism.common.block.BlockBasic.BasicBlock.BASIC_BLOCK_2; import static mekanism.common.block.BlockMachine.MachineBlock.MACHINE_BLOCK_1; import static mekanism.common.block.BlockMachine.MachineBlock.MACHINE_BLOCK_2; import static mekanism.common.block.BlockMachine.MachineBlock.MACHINE_BLOCK_3; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.GameRegistry.ObjectHolder; import mekanism.common.block.BlockBasic; import mekanism.common.block.BlockBounding; import mekanism.common.block.BlockCardboardBox; @@ -24,53 +27,79 @@ import mekanism.common.item.ItemBlockMachine; import mekanism.common.item.ItemBlockOre; import mekanism.common.item.ItemBlockPlastic; import net.minecraft.block.Block; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.common.registry.GameRegistry.ObjectHolder; @ObjectHolder("Mekanism") -public class MekanismBlocks -{ - public static final Block BasicBlock = new BlockBasic(BASIC_BLOCK_1).setBlockName("BasicBlock"); - public static final Block BasicBlock2 = new BlockBasic(BASIC_BLOCK_2).setBlockName("BasicBlock2"); - public static final Block MachineBlock = new BlockMachine(MACHINE_BLOCK_1).setBlockName("MachineBlock"); - public static final Block MachineBlock2 = new BlockMachine(MACHINE_BLOCK_2).setBlockName("MachineBlock2"); - public static final Block MachineBlock3 = new BlockMachine(MACHINE_BLOCK_3).setBlockName("MachineBlock3"); - public static final Block OreBlock = new BlockOre().setBlockName("OreBlock"); - public static final Block ObsidianTNT = new BlockObsidianTNT().setBlockName("ObsidianTNT").setCreativeTab(Mekanism.tabMekanism); - public static final Block EnergyCube = new BlockEnergyCube().setBlockName("EnergyCube"); - public static final Block BoundingBlock = (BlockBounding)new BlockBounding().setBlockName("BoundingBlock"); - public static final Block GasTank = new BlockGasTank().setBlockName("GasTank"); - public static final Block CardboardBox = new BlockCardboardBox().setBlockName("CardboardBox"); - public static final Block PlasticBlock = new BlockPlastic().setBlockName("PlasticBlock"); - public static final Block SlickPlasticBlock = new BlockPlastic().setBlockName("SlickPlasticBlock"); - public static final Block GlowPlasticBlock = new BlockPlastic().setBlockName("GlowPlasticBlock"); - public static final Block ReinforcedPlasticBlock = new BlockPlastic().setBlockName("ReinforcedPlasticBlock"); - public static final Block RoadPlasticBlock = new BlockPlastic().setBlockName("RoadPlasticBlock"); - public static final Block PlasticFence = new BlockPlasticFence().setBlockName("PlasticFence"); - public static final Block SaltBlock = new BlockSalt().setBlockName("SaltBlock"); +public class MekanismBlocks { + public static final Block BasicBlock + = new BlockBasic(BASIC_BLOCK_1).setBlockName("BasicBlock"); + public static final Block BasicBlock2 + = new BlockBasic(BASIC_BLOCK_2).setBlockName("BasicBlock2"); + public static final Block MachineBlock + = new BlockMachine(MACHINE_BLOCK_1).setBlockName("MachineBlock"); + public static final Block MachineBlock2 + = new BlockMachine(MACHINE_BLOCK_2).setBlockName("MachineBlock2"); + public static final Block MachineBlock3 + = new BlockMachine(MACHINE_BLOCK_3).setBlockName("MachineBlock3"); + public static final Block OreBlock = new BlockOre().setBlockName("OreBlock"); + public static final Block ObsidianTNT = new BlockObsidianTNT() + .setBlockName("ObsidianTNT") + .setCreativeTab(Mekanism.tabMekanism); + public static final Block EnergyCube + = new BlockEnergyCube().setBlockName("EnergyCube"); + public static final Block BoundingBlock + = (BlockBounding) new BlockBounding().setBlockName("BoundingBlock"); + public static final Block GasTank = new BlockGasTank().setBlockName("GasTank"); + public static final Block CardboardBox + = new BlockCardboardBox().setBlockName("CardboardBox"); + public static final Block PlasticBlock + = new BlockPlastic().setBlockName("PlasticBlock"); + public static final Block SlickPlasticBlock + = new BlockPlastic().setBlockName("SlickPlasticBlock"); + public static final Block GlowPlasticBlock + = new BlockPlastic().setBlockName("GlowPlasticBlock"); + public static final Block ReinforcedPlasticBlock + = new BlockPlastic().setBlockName("ReinforcedPlasticBlock"); + public static final Block RoadPlasticBlock + = new BlockPlastic().setBlockName("RoadPlasticBlock"); + public static final Block PlasticFence + = new BlockPlasticFence().setBlockName("PlasticFence"); + public static final Block SaltBlock = new BlockSalt().setBlockName("SaltBlock"); - /** - * Adds and registers all blocks. - */ - public static void register() - { - GameRegistry.registerBlock(BasicBlock, ItemBlockBasic.class, "BasicBlock"); - GameRegistry.registerBlock(BasicBlock2, ItemBlockBasic.class, "BasicBlock2"); - GameRegistry.registerBlock(MachineBlock, ItemBlockMachine.class, "MachineBlock"); - GameRegistry.registerBlock(MachineBlock2, ItemBlockMachine.class, "MachineBlock2"); - GameRegistry.registerBlock(MachineBlock3, ItemBlockMachine.class, "MachineBlock3"); - GameRegistry.registerBlock(OreBlock, ItemBlockOre.class, "OreBlock"); - GameRegistry.registerBlock(EnergyCube, ItemBlockEnergyCube.class, "EnergyCube"); - GameRegistry.registerBlock(ObsidianTNT, "ObsidianTNT"); - GameRegistry.registerBlock(BoundingBlock, "BoundingBlock"); - GameRegistry.registerBlock(GasTank, ItemBlockGasTank.class, "GasTank"); - GameRegistry.registerBlock(CardboardBox, ItemBlockCardboardBox.class, "CardboardBox"); - GameRegistry.registerBlock(PlasticBlock, ItemBlockPlastic.class, "PlasticBlock"); - GameRegistry.registerBlock(SlickPlasticBlock, ItemBlockPlastic.class, "SlickPlasticBlock"); - GameRegistry.registerBlock(GlowPlasticBlock, ItemBlockPlastic.class, "GlowPlasticBlock"); - GameRegistry.registerBlock(ReinforcedPlasticBlock, ItemBlockPlastic.class, "ReinforcedPlasticBlock"); - GameRegistry.registerBlock(RoadPlasticBlock, ItemBlockPlastic.class, "RoadPlasticBlock"); - GameRegistry.registerBlock(PlasticFence, ItemBlockPlastic.class, "PlasticFence"); - GameRegistry.registerBlock(SaltBlock, "SaltBlock"); - } + /** + * Adds and registers all blocks. + */ + public static void register() { + GameRegistry.registerBlock(BasicBlock, ItemBlockBasic.class, "BasicBlock"); + GameRegistry.registerBlock(BasicBlock2, ItemBlockBasic.class, "BasicBlock2"); + GameRegistry.registerBlock(MachineBlock, ItemBlockMachine.class, "MachineBlock"); + GameRegistry.registerBlock( + MachineBlock2, ItemBlockMachine.class, "MachineBlock2" + ); + GameRegistry.registerBlock( + MachineBlock3, ItemBlockMachine.class, "MachineBlock3" + ); + GameRegistry.registerBlock(OreBlock, ItemBlockOre.class, "OreBlock"); + GameRegistry.registerBlock(EnergyCube, ItemBlockEnergyCube.class, "EnergyCube"); + GameRegistry.registerBlock(ObsidianTNT, "ObsidianTNT"); + GameRegistry.registerBlock(BoundingBlock, "BoundingBlock"); + GameRegistry.registerBlock(GasTank, ItemBlockGasTank.class, "GasTank"); + GameRegistry.registerBlock( + CardboardBox, ItemBlockCardboardBox.class, "CardboardBox" + ); + GameRegistry.registerBlock(PlasticBlock, ItemBlockPlastic.class, "PlasticBlock"); + GameRegistry.registerBlock( + SlickPlasticBlock, ItemBlockPlastic.class, "SlickPlasticBlock" + ); + GameRegistry.registerBlock( + GlowPlasticBlock, ItemBlockPlastic.class, "GlowPlasticBlock" + ); + GameRegistry.registerBlock( + ReinforcedPlasticBlock, ItemBlockPlastic.class, "ReinforcedPlasticBlock" + ); + GameRegistry.registerBlock( + RoadPlasticBlock, ItemBlockPlastic.class, "RoadPlasticBlock" + ); + GameRegistry.registerBlock(PlasticFence, ItemBlockPlastic.class, "PlasticFence"); + GameRegistry.registerBlock(SaltBlock, "SaltBlock"); + } } diff --git a/src/main/java/mekanism/common/MekanismItems.java b/src/main/java/mekanism/common/MekanismItems.java index 25d337778..cd12d4494 100644 --- a/src/main/java/mekanism/common/MekanismItems.java +++ b/src/main/java/mekanism/common/MekanismItems.java @@ -1,5 +1,7 @@ package mekanism.common; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.GameRegistry.ObjectHolder; import mekanism.common.item.ItemAlloy; import mekanism.common.item.ItemAtomicDisassembler; import mekanism.common.item.ItemBalloon; @@ -14,7 +16,6 @@ import mekanism.common.item.ItemDirtyDust; import mekanism.common.item.ItemDust; import mekanism.common.item.ItemElectricBow; import mekanism.common.item.ItemEnergized; -import mekanism.common.item.ItemTierInstaller; import mekanism.common.item.ItemFlamethrower; import mekanism.common.item.ItemFreeRunners; import mekanism.common.item.ItemGasMask; @@ -32,6 +33,7 @@ import mekanism.common.item.ItemScubaTank; import mekanism.common.item.ItemSeismicReader; import mekanism.common.item.ItemShard; import mekanism.common.item.ItemStopwatch; +import mekanism.common.item.ItemTierInstaller; import mekanism.common.item.ItemUpgrade; import mekanism.common.item.ItemWalkieTalkie; import mekanism.common.item.ItemWeatherOrb; @@ -43,140 +45,202 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.common.registry.GameRegistry.ObjectHolder; @ObjectHolder("Mekanism") -public class MekanismItems -{ - public static final Item EnrichedAlloy = new ItemAlloy().setUnlocalizedName("EnrichedAlloy"); - public static final Item ReinforcedAlloy = new ItemAlloy().setUnlocalizedName("ReinforcedAlloy"); - public static final Item AtomicAlloy = new ItemAlloy().setUnlocalizedName("AtomicAlloy"); - public static final Item TeleportationCore = new ItemMekanism().setUnlocalizedName("TeleportationCore"); - public static final Item ElectrolyticCore = new ItemMekanism().setUnlocalizedName("ElectrolyticCore"); - public static final Item Substrate = new ItemMekanism().setUnlocalizedName("Substrate"); - public static final Item Polyethene = new ItemHDPE().setUnlocalizedName("HDPE"); - public static final Item BioFuel = new ItemMekanism().setUnlocalizedName("BioFuel"); - public static final Item ItemProxy = new ItemProxy().setUnlocalizedName("ItemProxy"); - public static final Item EnrichedIron = new ItemMekanism().setUnlocalizedName("EnrichedIron"); - public static final Item CompressedCarbon = new ItemMekanism().setUnlocalizedName("CompressedCarbon"); - public static final Item CompressedRedstone = new ItemMekanism().setUnlocalizedName("CompressedRedstone"); - public static final Item CompressedDiamond = new ItemMekanism().setUnlocalizedName("CompressedDiamond"); - public static final Item CompressedObsidian = new ItemMekanism().setUnlocalizedName("CompressedObsidian"); - public static final Item BrineBucket = new ItemMekanism().setMaxStackSize(1).setContainerItem(Items.bucket).setUnlocalizedName("BrineBucket"); - public static final Item LithiumBucket = new ItemMekanism().setMaxStackSize(1).setContainerItem(Items.bucket).setUnlocalizedName("LithiumBucket"); - public static final Item HeavyWaterBucket = new ItemMekanism().setMaxStackSize(1).setContainerItem(Items.bucket).setUnlocalizedName("HeavyWaterBucket"); - public static final Item SpeedUpgrade = new ItemUpgrade(Upgrade.SPEED).setUnlocalizedName("SpeedUpgrade"); - public static final Item EnergyUpgrade = new ItemUpgrade(Upgrade.ENERGY).setUnlocalizedName("EnergyUpgrade"); - public static final Item FilterUpgrade = new ItemUpgrade(Upgrade.FILTER).setUnlocalizedName("FilterUpgrade"); - public static final Item MufflingUpgrade = new ItemUpgrade(Upgrade.MUFFLING).setUnlocalizedName("MufflingUpgrade"); - public static final Item GasUpgrade = new ItemUpgrade(Upgrade.GAS).setUnlocalizedName("GasUpgrade"); - public static final Item TierInstaller = new ItemTierInstaller().setUnlocalizedName("FactoryInstaller"); - public static final ItemEnergized EnergyTablet = (ItemEnergized)new ItemEnergized(1000000).setUnlocalizedName("EnergyTablet"); - public static final ItemRobit Robit = (ItemRobit)new ItemRobit().setUnlocalizedName("Robit"); - public static final ItemAtomicDisassembler AtomicDisassembler = (ItemAtomicDisassembler)new ItemAtomicDisassembler().setUnlocalizedName("AtomicDisassembler"); - public static final ItemPortableTeleporter PortableTeleporter = (ItemPortableTeleporter)new ItemPortableTeleporter().setUnlocalizedName("PortableTeleporter"); - public static final ItemConfigurator Configurator = (ItemConfigurator)new ItemConfigurator().setUnlocalizedName("Configurator"); - public static final ItemNetworkReader NetworkReader = (ItemNetworkReader)new ItemNetworkReader().setUnlocalizedName("NetworkReader"); - public static final Item WalkieTalkie = new ItemWalkieTalkie().setUnlocalizedName("WalkieTalkie"); - public static final ItemElectricBow ElectricBow = (ItemElectricBow)new ItemElectricBow().setUnlocalizedName("ElectricBow"); - public static final ItemFlamethrower Flamethrower = (ItemFlamethrower)new ItemFlamethrower().setUnlocalizedName("Flamethrower"); - public static final ItemSeismicReader SeismicReader = (ItemSeismicReader)new ItemSeismicReader().setUnlocalizedName("SeismicReader"); - public static final Item Dictionary = new ItemDictionary().setUnlocalizedName("Dictionary"); - public static final ItemGaugeDropper GaugeDropper = (ItemGaugeDropper)new ItemGaugeDropper().setUnlocalizedName("GaugeDropper"); - public static final Item ConfigurationCard = new ItemConfigurationCard().setUnlocalizedName("ConfigurationCard"); - public static final Item CraftingFormula = new ItemCraftingFormula().setUnlocalizedName("CraftingFormula"); - public static final Item PartTransmitter = new ItemPartTransmitter().setUnlocalizedName("MultipartTransmitter"); - public static final Item GlowPanel = new ItemGlowPanel().setUnlocalizedName("GlowPanel"); - public static final ItemScubaTank ScubaTank = (ItemScubaTank)new ItemScubaTank().setUnlocalizedName("ScubaTank"); - public static final ItemGasMask GasMask = (ItemGasMask)new ItemGasMask().setUnlocalizedName("GasMask"); - public static final ItemJetpack Jetpack = (ItemJetpack)new ItemJetpack().setUnlocalizedName("Jetpack"); - public static final ItemJetpack ArmoredJetpack = (ItemJetpack)new ItemJetpack().setUnlocalizedName("ArmoredJetpack"); - public static final ItemFreeRunners FreeRunners = (ItemFreeRunners)new ItemFreeRunners().setUnlocalizedName("FreeRunners"); - public static final Item Balloon = new ItemBalloon().setUnlocalizedName("Balloon"); - public static final Item Stopwatch = new ItemStopwatch().setUnlocalizedName("Stopwatch"); - public static final Item WeatherOrb = new ItemWeatherOrb().setUnlocalizedName("WeatherOrb"); +public class MekanismItems { + public static final Item EnrichedAlloy + = new ItemAlloy().setUnlocalizedName("EnrichedAlloy"); + public static final Item ReinforcedAlloy + = new ItemAlloy().setUnlocalizedName("ReinforcedAlloy"); + public static final Item AtomicAlloy + = new ItemAlloy().setUnlocalizedName("AtomicAlloy"); + public static final Item TeleportationCore + = new ItemMekanism().setUnlocalizedName("TeleportationCore"); + public static final Item ElectrolyticCore + = new ItemMekanism().setUnlocalizedName("ElectrolyticCore"); + public static final Item Substrate + = new ItemMekanism().setUnlocalizedName("Substrate"); + public static final Item Polyethene = new ItemHDPE().setUnlocalizedName("HDPE"); + public static final Item BioFuel = new ItemMekanism().setUnlocalizedName("BioFuel"); + public static final Item ItemProxy = new ItemProxy().setUnlocalizedName("ItemProxy"); + public static final Item EnrichedIron + = new ItemMekanism().setUnlocalizedName("EnrichedIron"); + public static final Item CompressedCarbon + = new ItemMekanism().setUnlocalizedName("CompressedCarbon"); + public static final Item CompressedRedstone + = new ItemMekanism().setUnlocalizedName("CompressedRedstone"); + public static final Item CompressedDiamond + = new ItemMekanism().setUnlocalizedName("CompressedDiamond"); + public static final Item CompressedObsidian + = new ItemMekanism().setUnlocalizedName("CompressedObsidian"); + public static final Item BrineBucket = new ItemMekanism() + .setMaxStackSize(1) + .setContainerItem(Items.bucket) + .setUnlocalizedName("BrineBucket"); + public static final Item LithiumBucket = new ItemMekanism() + .setMaxStackSize(1) + .setContainerItem(Items.bucket) + .setUnlocalizedName("LithiumBucket"); + public static final Item HeavyWaterBucket + = new ItemMekanism() + .setMaxStackSize(1) + .setContainerItem(Items.bucket) + .setUnlocalizedName("HeavyWaterBucket"); + public static final Item SpeedUpgrade + = new ItemUpgrade(Upgrade.SPEED).setUnlocalizedName("SpeedUpgrade"); + public static final Item EnergyUpgrade + = new ItemUpgrade(Upgrade.ENERGY).setUnlocalizedName("EnergyUpgrade"); + public static final Item FilterUpgrade + = new ItemUpgrade(Upgrade.FILTER).setUnlocalizedName("FilterUpgrade"); + public static final Item MufflingUpgrade + = new ItemUpgrade(Upgrade.MUFFLING).setUnlocalizedName("MufflingUpgrade"); + public static final Item GasUpgrade + = new ItemUpgrade(Upgrade.GAS).setUnlocalizedName("GasUpgrade"); + public static final Item TierInstaller + = new ItemTierInstaller().setUnlocalizedName("FactoryInstaller"); + public static final ItemEnergized EnergyTablet + = (ItemEnergized) new ItemEnergized(1000000).setUnlocalizedName("EnergyTablet"); + public static final ItemRobit Robit + = (ItemRobit) new ItemRobit().setUnlocalizedName("Robit"); + public static final ItemAtomicDisassembler AtomicDisassembler + = (ItemAtomicDisassembler) new ItemAtomicDisassembler().setUnlocalizedName( + "AtomicDisassembler" + ); + public static final ItemPortableTeleporter PortableTeleporter + = (ItemPortableTeleporter) new ItemPortableTeleporter().setUnlocalizedName( + "PortableTeleporter" + ); + public static final ItemConfigurator Configurator + = (ItemConfigurator) new ItemConfigurator().setUnlocalizedName("Configurator"); + public static final ItemNetworkReader NetworkReader + = (ItemNetworkReader) new ItemNetworkReader().setUnlocalizedName("NetworkReader"); + public static final Item WalkieTalkie + = new ItemWalkieTalkie().setUnlocalizedName("WalkieTalkie"); + public static final ItemElectricBow ElectricBow + = (ItemElectricBow) new ItemElectricBow().setUnlocalizedName("ElectricBow"); + public static final ItemFlamethrower Flamethrower + = (ItemFlamethrower) new ItemFlamethrower().setUnlocalizedName("Flamethrower"); + public static final ItemSeismicReader SeismicReader + = (ItemSeismicReader) new ItemSeismicReader().setUnlocalizedName("SeismicReader"); + public static final Item Dictionary + = new ItemDictionary().setUnlocalizedName("Dictionary"); + public static final ItemGaugeDropper GaugeDropper + = (ItemGaugeDropper) new ItemGaugeDropper().setUnlocalizedName("GaugeDropper"); + public static final Item ConfigurationCard + = new ItemConfigurationCard().setUnlocalizedName("ConfigurationCard"); + public static final Item CraftingFormula + = new ItemCraftingFormula().setUnlocalizedName("CraftingFormula"); + public static final Item PartTransmitter + = new ItemPartTransmitter().setUnlocalizedName("MultipartTransmitter"); + public static final Item GlowPanel + = new ItemGlowPanel().setUnlocalizedName("GlowPanel"); + public static final ItemScubaTank ScubaTank + = (ItemScubaTank) new ItemScubaTank().setUnlocalizedName("ScubaTank"); + public static final ItemGasMask GasMask + = (ItemGasMask) new ItemGasMask().setUnlocalizedName("GasMask"); + public static final ItemJetpack Jetpack + = (ItemJetpack) new ItemJetpack().setUnlocalizedName("Jetpack"); + public static final ItemJetpack ArmoredJetpack + = (ItemJetpack) new ItemJetpack().setUnlocalizedName("ArmoredJetpack"); + public static final ItemFreeRunners FreeRunners + = (ItemFreeRunners) new ItemFreeRunners().setUnlocalizedName("FreeRunners"); + public static final Item Balloon = new ItemBalloon().setUnlocalizedName("Balloon"); + public static final Item Stopwatch + = new ItemStopwatch().setUnlocalizedName("Stopwatch"); + public static final Item WeatherOrb + = new ItemWeatherOrb().setUnlocalizedName("WeatherOrb"); - //Multi-ID Items - public static final Item OtherDust = new ItemOtherDust(); - public static final Item Dust = new ItemDust(); - public static final Item Sawdust = new ItemMekanism().setUnlocalizedName("Sawdust"); - public static final Item Salt = new ItemMekanism().setUnlocalizedName("Salt"); - public static final Item Ingot = new ItemIngot(); - public static final Item Clump = new ItemClump(); - public static final Item DirtyDust = new ItemDirtyDust(); - public static final Item Shard = new ItemShard(); - public static final Item Crystal = new ItemCrystal(); - public static final Item ControlCircuit = new ItemControlCircuit(); + //Multi-ID Items + public static final Item OtherDust = new ItemOtherDust(); + public static final Item Dust = new ItemDust(); + public static final Item Sawdust = new ItemMekanism().setUnlocalizedName("Sawdust"); + public static final Item Salt = new ItemMekanism().setUnlocalizedName("Salt"); + public static final Item Ingot = new ItemIngot(); + public static final Item Clump = new ItemClump(); + public static final Item DirtyDust = new ItemDirtyDust(); + public static final Item Shard = new ItemShard(); + public static final Item Crystal = new ItemCrystal(); + public static final Item ControlCircuit = new ItemControlCircuit(); - /** - * Adds and registers all items. - */ - public static void register() - { - GameRegistry.registerItem(PartTransmitter, "PartTransmitter"); - GameRegistry.registerItem(ElectricBow, "ElectricBow"); - GameRegistry.registerItem(Dust, "Dust"); - GameRegistry.registerItem(Ingot, "Ingot"); - GameRegistry.registerItem(EnergyTablet, "EnergyTablet"); - GameRegistry.registerItem(SpeedUpgrade, "SpeedUpgrade"); - GameRegistry.registerItem(EnergyUpgrade, "EnergyUpgrade"); - GameRegistry.registerItem(FilterUpgrade, "FilterUpgrade"); - GameRegistry.registerItem(MufflingUpgrade, "MufflingUpgrade"); - GameRegistry.registerItem(GasUpgrade, "GasUpgrade"); - GameRegistry.registerItem(Robit, "Robit"); - GameRegistry.registerItem(AtomicDisassembler, "AtomicDisassembler"); - GameRegistry.registerItem(EnrichedAlloy, "EnrichedAlloy"); - GameRegistry.registerItem(ReinforcedAlloy, "ReinforcedAlloy"); - GameRegistry.registerItem(AtomicAlloy, "AtomicAlloy"); - GameRegistry.registerItem(ItemProxy, "ItemProxy"); - GameRegistry.registerItem(ControlCircuit, "ControlCircuit"); - GameRegistry.registerItem(EnrichedIron, "EnrichedIron"); - GameRegistry.registerItem(CompressedCarbon, "CompressedCarbon"); - GameRegistry.registerItem(CompressedRedstone, "CompressedRedstone"); - GameRegistry.registerItem(CompressedDiamond, "CompressedDiamond"); - GameRegistry.registerItem(CompressedObsidian, "CompressedObsidian"); - GameRegistry.registerItem(PortableTeleporter, "PortableTeleporter"); - GameRegistry.registerItem(TeleportationCore, "TeleportationCore"); - GameRegistry.registerItem(Clump, "Clump"); - GameRegistry.registerItem(DirtyDust, "DirtyDust"); - GameRegistry.registerItem(Configurator, "Configurator"); - GameRegistry.registerItem(NetworkReader, "NetworkReader"); - GameRegistry.registerItem(WalkieTalkie, "WalkieTalkie"); - GameRegistry.registerItem(Jetpack, "Jetpack"); - GameRegistry.registerItem(Dictionary, "Dictionary"); - GameRegistry.registerItem(GasMask, "GasMask"); - GameRegistry.registerItem(ScubaTank, "ScubaTank"); - GameRegistry.registerItem(Balloon, "Balloon"); - GameRegistry.registerItem(Shard, "Shard"); - GameRegistry.registerItem(ElectrolyticCore, "ElectrolyticCore"); - GameRegistry.registerItem(Sawdust, "Sawdust"); - GameRegistry.registerItem(Salt, "Salt"); - GameRegistry.registerItem(BrineBucket, "BrineBucket"); - GameRegistry.registerItem(LithiumBucket, "LithiumBucket"); - GameRegistry.registerItem(HeavyWaterBucket, "HeavyWaterBucket"); - GameRegistry.registerItem(Crystal, "Crystal"); - GameRegistry.registerItem(FreeRunners, "FreeRunners"); - GameRegistry.registerItem(ArmoredJetpack, "ArmoredJetpack"); - GameRegistry.registerItem(ConfigurationCard, "ConfigurationCard"); - GameRegistry.registerItem(CraftingFormula, "CraftingFormula"); - GameRegistry.registerItem(SeismicReader, "SeismicReader"); - GameRegistry.registerItem(Substrate, "Substrate"); - GameRegistry.registerItem(Polyethene, "Polyethene"); - GameRegistry.registerItem(BioFuel, "BioFuel"); - GameRegistry.registerItem(GlowPanel, "GlowPanel"); - GameRegistry.registerItem(Flamethrower, "Flamethrower"); - GameRegistry.registerItem(GaugeDropper, "GaugeDropper"); - GameRegistry.registerItem(TierInstaller, "FactoryInstaller"); - GameRegistry.registerItem(OtherDust, "OtherDust"); - GameRegistry.registerItem(Stopwatch, "Stopwatch"); - GameRegistry.registerItem(WeatherOrb, "WeatherOrb"); + /** + * Adds and registers all items. + */ + public static void register() { + GameRegistry.registerItem(PartTransmitter, "PartTransmitter"); + GameRegistry.registerItem(ElectricBow, "ElectricBow"); + GameRegistry.registerItem(Dust, "Dust"); + GameRegistry.registerItem(Ingot, "Ingot"); + GameRegistry.registerItem(EnergyTablet, "EnergyTablet"); + GameRegistry.registerItem(SpeedUpgrade, "SpeedUpgrade"); + GameRegistry.registerItem(EnergyUpgrade, "EnergyUpgrade"); + GameRegistry.registerItem(FilterUpgrade, "FilterUpgrade"); + GameRegistry.registerItem(MufflingUpgrade, "MufflingUpgrade"); + GameRegistry.registerItem(GasUpgrade, "GasUpgrade"); + GameRegistry.registerItem(Robit, "Robit"); + GameRegistry.registerItem(AtomicDisassembler, "AtomicDisassembler"); + GameRegistry.registerItem(EnrichedAlloy, "EnrichedAlloy"); + GameRegistry.registerItem(ReinforcedAlloy, "ReinforcedAlloy"); + GameRegistry.registerItem(AtomicAlloy, "AtomicAlloy"); + GameRegistry.registerItem(ItemProxy, "ItemProxy"); + GameRegistry.registerItem(ControlCircuit, "ControlCircuit"); + GameRegistry.registerItem(EnrichedIron, "EnrichedIron"); + GameRegistry.registerItem(CompressedCarbon, "CompressedCarbon"); + GameRegistry.registerItem(CompressedRedstone, "CompressedRedstone"); + GameRegistry.registerItem(CompressedDiamond, "CompressedDiamond"); + GameRegistry.registerItem(CompressedObsidian, "CompressedObsidian"); + GameRegistry.registerItem(PortableTeleporter, "PortableTeleporter"); + GameRegistry.registerItem(TeleportationCore, "TeleportationCore"); + GameRegistry.registerItem(Clump, "Clump"); + GameRegistry.registerItem(DirtyDust, "DirtyDust"); + GameRegistry.registerItem(Configurator, "Configurator"); + GameRegistry.registerItem(NetworkReader, "NetworkReader"); + GameRegistry.registerItem(WalkieTalkie, "WalkieTalkie"); + GameRegistry.registerItem(Jetpack, "Jetpack"); + GameRegistry.registerItem(Dictionary, "Dictionary"); + GameRegistry.registerItem(GasMask, "GasMask"); + GameRegistry.registerItem(ScubaTank, "ScubaTank"); + GameRegistry.registerItem(Balloon, "Balloon"); + GameRegistry.registerItem(Shard, "Shard"); + GameRegistry.registerItem(ElectrolyticCore, "ElectrolyticCore"); + GameRegistry.registerItem(Sawdust, "Sawdust"); + GameRegistry.registerItem(Salt, "Salt"); + GameRegistry.registerItem(BrineBucket, "BrineBucket"); + GameRegistry.registerItem(LithiumBucket, "LithiumBucket"); + GameRegistry.registerItem(HeavyWaterBucket, "HeavyWaterBucket"); + GameRegistry.registerItem(Crystal, "Crystal"); + GameRegistry.registerItem(FreeRunners, "FreeRunners"); + GameRegistry.registerItem(ArmoredJetpack, "ArmoredJetpack"); + GameRegistry.registerItem(ConfigurationCard, "ConfigurationCard"); + GameRegistry.registerItem(CraftingFormula, "CraftingFormula"); + GameRegistry.registerItem(SeismicReader, "SeismicReader"); + GameRegistry.registerItem(Substrate, "Substrate"); + GameRegistry.registerItem(Polyethene, "Polyethene"); + GameRegistry.registerItem(BioFuel, "BioFuel"); + GameRegistry.registerItem(GlowPanel, "GlowPanel"); + GameRegistry.registerItem(Flamethrower, "Flamethrower"); + GameRegistry.registerItem(GaugeDropper, "GaugeDropper"); + GameRegistry.registerItem(TierInstaller, "FactoryInstaller"); + GameRegistry.registerItem(OtherDust, "OtherDust"); + GameRegistry.registerItem(Stopwatch, "Stopwatch"); + GameRegistry.registerItem(WeatherOrb, "WeatherOrb"); - FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluid("brine"), new ItemStack(BrineBucket), FluidContainerRegistry.EMPTY_BUCKET); - FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluid("lithium"), new ItemStack(LithiumBucket), FluidContainerRegistry.EMPTY_BUCKET); - FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluid("heavywater"), new ItemStack(HeavyWaterBucket), FluidContainerRegistry.EMPTY_BUCKET); + FluidContainerRegistry.registerFluidContainer( + FluidRegistry.getFluid("brine"), + new ItemStack(BrineBucket), + FluidContainerRegistry.EMPTY_BUCKET + ); + FluidContainerRegistry.registerFluidContainer( + FluidRegistry.getFluid("lithium"), + new ItemStack(LithiumBucket), + FluidContainerRegistry.EMPTY_BUCKET + ); + FluidContainerRegistry.registerFluidContainer( + FluidRegistry.getFluid("heavywater"), + new ItemStack(HeavyWaterBucket), + FluidContainerRegistry.EMPTY_BUCKET + ); - MinecraftForge.EVENT_BUS.register(GasMask); - MinecraftForge.EVENT_BUS.register(FreeRunners); - } + MinecraftForge.EVENT_BUS.register(GasMask); + MinecraftForge.EVENT_BUS.register(FreeRunners); + } } diff --git a/src/main/java/mekanism/common/ObfuscatedNames.java b/src/main/java/mekanism/common/ObfuscatedNames.java index 9adbff7b0..ef567c6ab 100644 --- a/src/main/java/mekanism/common/ObfuscatedNames.java +++ b/src/main/java/mekanism/common/ObfuscatedNames.java @@ -1,15 +1,24 @@ package mekanism.common; -public final class ObfuscatedNames -{ - public static String[] TextureManager_listTickables = new String[] {"listTickables", "field_110583_b", "c"}; - public static String[] Minecraft_timer = new String[] {"timer", "field_71428_T", "S"}; - public static String[] GuiContainer_xSize = new String[] {"xSize", "field_146999_f", "c"}; - public static String[] GuiContainer_ySize = new String[] {"ySize", "field_147000_g", "d"}; - public static String[] GuiContainer_guiLeft = new String[] {"guiLeft", "field_147003_i"}; - public static String[] GuiContainer_guiTop = new String[] {"guiTop", "field_147009_r"}; - public static String[] NetHandlerPlayServer_floatingTickCount = new String[] {"floatingTickCount", "field_147365_f"}; - public static String[] SoundHandler_sndManager = new String[] {"sndManager", "field_147694_f"}; - public static String[] SoundManager_sndSystem = new String[] {"sndSystem", "field_148620_e"}; - public static String[] SoundManager_invPlayingSounds = new String[] {"invPlayingSounds", "field_148630_i"}; +public final class ObfuscatedNames { + public static String[] TextureManager_listTickables + = new String[] { "listTickables", "field_110583_b", "c" }; + public static String[] Minecraft_timer + = new String[] { "timer", "field_71428_T", "S" }; + public static String[] GuiContainer_xSize + = new String[] { "xSize", "field_146999_f", "c" }; + public static String[] GuiContainer_ySize + = new String[] { "ySize", "field_147000_g", "d" }; + public static String[] GuiContainer_guiLeft + = new String[] { "guiLeft", "field_147003_i" }; + public static String[] GuiContainer_guiTop + = new String[] { "guiTop", "field_147009_r" }; + public static String[] NetHandlerPlayServer_floatingTickCount + = new String[] { "floatingTickCount", "field_147365_f" }; + public static String[] SoundHandler_sndManager + = new String[] { "sndManager", "field_147694_f" }; + public static String[] SoundManager_sndSystem + = new String[] { "sndSystem", "field_148620_e" }; + public static String[] SoundManager_invPlayingSounds + = new String[] { "invPlayingSounds", "field_148630_i" }; } \ No newline at end of file diff --git a/src/main/java/mekanism/common/OreDictCache.java b/src/main/java/mekanism/common/OreDictCache.java index 1badf146d..8bd11d36a 100644 --- a/src/main/java/mekanism/common/OreDictCache.java +++ b/src/main/java/mekanism/common/OreDictCache.java @@ -10,153 +10,120 @@ import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; -public final class OreDictCache -{ - public static HashMap> cachedKeys = new HashMap>(); - public static HashMap> oreDictStacks = new HashMap>(); - public static HashMap> modIDStacks = new HashMap>(); +public final class OreDictCache { + public static HashMap> cachedKeys + = new HashMap>(); + public static HashMap> oreDictStacks + = new HashMap>(); + public static HashMap> modIDStacks + = new HashMap>(); - public static List getOreDictName(ItemStack check) - { - if(check == null || check.getItem() == null) - { - return new ArrayList(); - } + public static List getOreDictName(ItemStack check) { + if (check == null || check.getItem() == null) { + return new ArrayList(); + } - ItemInfo info = ItemInfo.get(check); - List cached = cachedKeys.get(info); + ItemInfo info = ItemInfo.get(check); + List cached = cachedKeys.get(info); - if(cached != null) - { - return cached; - } + if (cached != null) { + return cached; + } - int[] idsFound = OreDictionary.getOreIDs(check); + int[] idsFound = OreDictionary.getOreIDs(check); - List ret = new ArrayList(); + List ret = new ArrayList(); - for(Integer id : idsFound) - { - ret.add(OreDictionary.getOreName(id)); - } + for (Integer id : idsFound) { + ret.add(OreDictionary.getOreName(id)); + } - cachedKeys.put(info, ret); + cachedKeys.put(info, ret); - return ret; - } - - public static List getOreDictStacks(String oreName, boolean forceBlock) - { - if(oreDictStacks.get(oreName) != null) - { - return oreDictStacks.get(oreName); - } + return ret; + } - List keys = new ArrayList(); + public static List getOreDictStacks(String oreName, boolean forceBlock) { + if (oreDictStacks.get(oreName) != null) { + return oreDictStacks.get(oreName); + } - for(String s : OreDictionary.getOreNames()) - { - if(s == null) - { - continue; - } - - if(oreName.equals(s) || oreName.equals("*")) - { - keys.add(s); - } - else if(oreName.endsWith("*") && !oreName.startsWith("*")) - { - if(s.startsWith(oreName.substring(0, oreName.length()-1))) - { - keys.add(s); - } - } - else if(oreName.startsWith("*") && !oreName.endsWith("*")) - { - if(s.endsWith(oreName.substring(1))) - { - keys.add(s); - } - } - else if(oreName.startsWith("*") && oreName.endsWith("*")) - { - if(s.contains(oreName.substring(1, oreName.length()-1))) - { - keys.add(s); - } - } - } - - List stacks = new ArrayList(); + List keys = new ArrayList(); - for(String key : keys) - { - for(ItemStack stack : OreDictionary.getOres(key)) - { - ItemStack toAdd = stack.copy(); + for (String s : OreDictionary.getOreNames()) { + if (s == null) { + continue; + } - if(!stacks.contains(stack) && (!forceBlock || toAdd.getItem() instanceof ItemBlock)) - { - stacks.add(stack.copy()); - } - } - } - - oreDictStacks.put(oreName, stacks); - - return stacks; - } - - public static List getModIDStacks(String modName, boolean forceBlock) - { - if(modIDStacks.get(modName) != null) - { - return modIDStacks.get(modName); - } - - List stacks = new ArrayList(); + if (oreName.equals(s) || oreName.equals("*")) { + keys.add(s); + } else if (oreName.endsWith("*") && !oreName.startsWith("*")) { + if (s.startsWith(oreName.substring(0, oreName.length() - 1))) { + keys.add(s); + } + } else if (oreName.startsWith("*") && !oreName.endsWith("*")) { + if (s.endsWith(oreName.substring(1))) { + keys.add(s); + } + } else if (oreName.startsWith("*") && oreName.endsWith("*")) { + if (s.contains(oreName.substring(1, oreName.length() - 1))) { + keys.add(s); + } + } + } - for(String key : OreDictionary.getOreNames()) - { - for(ItemStack stack : OreDictionary.getOres(key)) - { - ItemStack toAdd = stack.copy(); - String s = MekanismUtils.getMod(toAdd); + List stacks = new ArrayList(); - if(!stacks.contains(stack) && toAdd.getItem() instanceof ItemBlock) - { - if(modName.equals(s) || modName.equals("*")) - { - stacks.add(stack.copy()); - } - else if(modName.endsWith("*") && !modName.startsWith("*")) - { - if(s.startsWith(modName.substring(0, modName.length()-1))) - { - stacks.add(stack.copy()); - } - } - else if(modName.startsWith("*") && !modName.endsWith("*")) - { - if(s.endsWith(modName.substring(1))) - { - stacks.add(stack.copy()); - } - } - else if(modName.startsWith("*") && modName.endsWith("*")) - { - if(s.contains(modName.substring(1, modName.length()-1))) - { - stacks.add(stack.copy()); - } - } - } - } - } - - modIDStacks.put(modName, stacks); - - return stacks; - } + for (String key : keys) { + for (ItemStack stack : OreDictionary.getOres(key)) { + ItemStack toAdd = stack.copy(); + + if (!stacks.contains(stack) + && (!forceBlock || toAdd.getItem() instanceof ItemBlock)) { + stacks.add(stack.copy()); + } + } + } + + oreDictStacks.put(oreName, stacks); + + return stacks; + } + + public static List getModIDStacks(String modName, boolean forceBlock) { + if (modIDStacks.get(modName) != null) { + return modIDStacks.get(modName); + } + + List stacks = new ArrayList(); + + for (String key : OreDictionary.getOreNames()) { + for (ItemStack stack : OreDictionary.getOres(key)) { + ItemStack toAdd = stack.copy(); + String s = MekanismUtils.getMod(toAdd); + + if (!stacks.contains(stack) && toAdd.getItem() instanceof ItemBlock) { + if (modName.equals(s) || modName.equals("*")) { + stacks.add(stack.copy()); + } else if (modName.endsWith("*") && !modName.startsWith("*")) { + if (s.startsWith(modName.substring(0, modName.length() - 1))) { + stacks.add(stack.copy()); + } + } else if (modName.startsWith("*") && !modName.endsWith("*")) { + if (s.endsWith(modName.substring(1))) { + stacks.add(stack.copy()); + } + } else if (modName.startsWith("*") && modName.endsWith("*")) { + if (s.contains(modName.substring(1, modName.length() - 1))) { + stacks.add(stack.copy()); + } + } + } + } + } + + modIDStacks.put(modName, stacks); + + return stacks; + } } diff --git a/src/main/java/mekanism/common/PacketHandler.java b/src/main/java/mekanism/common/PacketHandler.java index 7b2f2cc31..8e9c3ff3d 100644 --- a/src/main/java/mekanism/common/PacketHandler.java +++ b/src/main/java/mekanism/common/PacketHandler.java @@ -1,17 +1,21 @@ package mekanism.common; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.List; +import cpw.mods.fml.common.network.NetworkRegistry; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; +import cpw.mods.fml.relauncher.Side; +import io.netty.buffer.ByteBuf; import mekanism.api.MekanismConfig.general; import mekanism.api.Range4D; import mekanism.common.network.PacketBoxBlacklist; -import mekanism.common.network.PacketChangeTime; -import mekanism.common.network.PacketChangeWeather; import mekanism.common.network.PacketBoxBlacklist.BoxBlacklistMessage; +import mekanism.common.network.PacketChangeTime; import mekanism.common.network.PacketChangeTime.ChangeTimeMessage; +import mekanism.common.network.PacketChangeWeather; import mekanism.common.network.PacketChangeWeather.ChangeWeatherMessage; import mekanism.common.network.PacketConfigSync; import mekanism.common.network.PacketConfigSync.ConfigSyncMessage; @@ -83,313 +87,367 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.server.MinecraftServer; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.Vec3; -import cpw.mods.fml.common.network.NetworkRegistry; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper; -import cpw.mods.fml.relauncher.Side; /** * Mekanism packet handler. As always, use packets sparingly! * @author AidanBrady * */ -public class PacketHandler -{ - public SimpleNetworkWrapper netHandler = NetworkRegistry.INSTANCE.newSimpleChannel("MEK"); - - public void initialize() - { - netHandler.registerMessage(PacketRobit.class, RobitMessage.class, 0, Side.SERVER); - netHandler.registerMessage(PacketTransmitterUpdate.class, TransmitterUpdateMessage.class, 1, Side.CLIENT); - netHandler.registerMessage(PacketPersonalChest.class, PersonalChestMessage.class, 2, Side.CLIENT); - netHandler.registerMessage(PacketPersonalChest.class, PersonalChestMessage.class, 2, Side.SERVER); - netHandler.registerMessage(PacketElectricBowState.class, ElectricBowStateMessage.class, 3, Side.SERVER); - netHandler.registerMessage(PacketConfiguratorState.class, ConfiguratorStateMessage.class, 4, Side.SERVER); - netHandler.registerMessage(PacketTileEntity.class, TileEntityMessage.class, 5, Side.CLIENT); - netHandler.registerMessage(PacketTileEntity.class, TileEntityMessage.class, 5, Side.SERVER); - netHandler.registerMessage(PacketPortalFX.class, PortalFXMessage.class, 6, Side.CLIENT); - netHandler.registerMessage(PacketDataRequest.class, DataRequestMessage.class, 7, Side.SERVER); - netHandler.registerMessage(PacketOredictionificatorGui.class, OredictionificatorGuiMessage.class, 8, Side.CLIENT); - netHandler.registerMessage(PacketOredictionificatorGui.class, OredictionificatorGuiMessage.class, 8, Side.SERVER); - netHandler.registerMessage(PacketSecurityMode.class, SecurityModeMessage.class, 9, Side.SERVER); - netHandler.registerMessage(PacketPortableTeleporter.class, PortableTeleporterMessage.class, 10, Side.CLIENT); - netHandler.registerMessage(PacketPortableTeleporter.class, PortableTeleporterMessage.class, 10, Side.SERVER); - netHandler.registerMessage(PacketRemoveUpgrade.class, RemoveUpgradeMessage.class, 11, Side.SERVER); - netHandler.registerMessage(PacketRedstoneControl.class, RedstoneControlMessage.class, 12, Side.SERVER); - netHandler.registerMessage(PacketWalkieTalkieState.class, WalkieTalkieStateMessage.class, 13, Side.SERVER); - netHandler.registerMessage(PacketLogisticalSorterGui.class, LogisticalSorterGuiMessage.class, 14, Side.CLIENT); - netHandler.registerMessage(PacketLogisticalSorterGui.class, LogisticalSorterGuiMessage.class, 14, Side.SERVER); - netHandler.registerMessage(PacketNewFilter.class, NewFilterMessage.class, 15, Side.SERVER); - netHandler.registerMessage(PacketEditFilter.class, EditFilterMessage.class, 16, Side.SERVER); - netHandler.registerMessage(PacketConfigurationUpdate.class, ConfigurationUpdateMessage.class, 17, Side.SERVER); - netHandler.registerMessage(PacketSimpleGui.class, SimpleGuiMessage.class, 18, Side.CLIENT); - netHandler.registerMessage(PacketSimpleGui.class, SimpleGuiMessage.class, 18, Side.SERVER); - netHandler.registerMessage(PacketDigitalMinerGui.class, DigitalMinerGuiMessage.class, 19, Side.CLIENT); - netHandler.registerMessage(PacketDigitalMinerGui.class, DigitalMinerGuiMessage.class, 19, Side.SERVER); - netHandler.registerMessage(PacketJetpackData.class, JetpackDataMessage.class, 20, Side.CLIENT); - netHandler.registerMessage(PacketJetpackData.class, JetpackDataMessage.class, 20, Side.SERVER); - netHandler.registerMessage(PacketKey.class, KeyMessage.class, 21, Side.SERVER); - netHandler.registerMessage(PacketScubaTankData.class, ScubaTankDataMessage.class, 22, Side.CLIENT); - netHandler.registerMessage(PacketScubaTankData.class, ScubaTankDataMessage.class, 22, Side.SERVER); - netHandler.registerMessage(PacketConfigSync.class, ConfigSyncMessage.class, 23, Side.CLIENT); - netHandler.registerMessage(PacketBoxBlacklist.class, BoxBlacklistMessage.class, 24, Side.CLIENT); - netHandler.registerMessage(PacketPortableTankState.class, PortableTankStateMessage.class, 25, Side.SERVER); - netHandler.registerMessage(PacketContainerEditMode.class, ContainerEditModeMessage.class, 26, Side.SERVER); - netHandler.registerMessage(PacketFlamethrowerData.class, FlamethrowerDataMessage.class, 27, Side.CLIENT); - netHandler.registerMessage(PacketFlamethrowerData.class, FlamethrowerDataMessage.class, 27, Side.SERVER); - netHandler.registerMessage(PacketDropperUse.class, DropperUseMessage.class, 28, Side.SERVER); - netHandler.registerMessage(PacketEntityMove.class, EntityMoveMessage.class, 29, Side.CLIENT); - netHandler.registerMessage(PacketSecurityUpdate.class, SecurityUpdateMessage.class, 30, Side.CLIENT); - netHandler.registerMessage(PacketChangeTime.class, ChangeTimeMessage.class, 31, Side.SERVER); - netHandler.registerMessage(PacketChangeWeather.class, ChangeWeatherMessage.class, 32, Side.SERVER); - } - - /** - * Encodes an Object[] of data into a DataOutputStream. - * @param dataValues - an Object[] of data to encode - * @param output - the output stream to write to - */ - public static void encode(Object[] dataValues, ByteBuf output) - { - try { - for(Object data : dataValues) - { - if(data instanceof Integer) - { - output.writeInt((Integer)data); - } - else if(data instanceof Short) - { - output.writeShort((Short)data); - } - else if(data instanceof Boolean) - { - output.writeBoolean((Boolean)data); - } - else if(data instanceof Double) - { - output.writeDouble((Double)data); - } - else if(data instanceof Float) - { - output.writeFloat((Float)data); - } - else if(data instanceof String) - { - writeString(output, (String)data); - } - else if(data instanceof Byte) - { - output.writeByte((Byte)data); - } - else if(data instanceof ItemStack) - { - writeStack(output, (ItemStack)data); - } - else if(data instanceof NBTTagCompound) - { - writeNBT(output, (NBTTagCompound)data); - } - else if(data instanceof int[]) - { - for(int i : (int[])data) - { - output.writeInt(i); - } - } - else if(data instanceof byte[]) - { - for(byte b : (byte[])data) - { - output.writeByte(b); - } - } - else if(data instanceof ArrayList) - { - encode(((ArrayList)data).toArray(), output); - } - } - } catch(Exception e) { - Mekanism.logger.error("Error while encoding packet data."); - e.printStackTrace(); - } - } - - public static void writeString(ByteBuf output, String s) - { - output.writeInt(s.getBytes().length); - output.writeBytes(s.getBytes()); - } - - public static String readString(ByteBuf input) - { - return new String(input.readBytes(input.readInt()).array()); - } - - public static void writeStack(ByteBuf output, ItemStack stack) - { - output.writeInt(stack != null ? Item.getIdFromItem(stack.getItem()) : -1); - - if(stack != null) - { - output.writeInt(stack.stackSize); - output.writeInt(stack.getItemDamage()); - - if(stack.getTagCompound() != null && stack.getItem().getShareTag()) - { - output.writeBoolean(true); - writeNBT(output, stack.getTagCompound()); - } - else { - output.writeBoolean(false); - } - } - } - - public static ItemStack readStack(ByteBuf input) - { - int id = input.readInt(); - - if(id >= 0) - { - ItemStack stack = new ItemStack(Item.getItemById(id), input.readInt(), input.readInt()); - - if(input.readBoolean()) - { - stack.setTagCompound(readNBT(input)); - } - - return stack; - } - - return null; - } - - public static void writeNBT(ByteBuf output, NBTTagCompound nbtTags) - { - try { - byte[] buffer = CompressedStreamTools.compress(nbtTags); - - output.writeInt(buffer.length); - output.writeBytes(buffer); - } catch(Exception e) {} - } - - public static NBTTagCompound readNBT(ByteBuf input) - { - try { - byte[] buffer = new byte[input.readInt()]; - input.readBytes(buffer); - - return CompressedStreamTools.func_152457_a(buffer, new NBTSizeTracker(2097152L)); - } catch(Exception e) { - return null; - } - } - - public static void log(String log) - { - if(general.logPackets) - { - System.out.println("[Mekanism] " + log); - } - } - - public static EntityPlayer getPlayer(MessageContext context) - { - return Mekanism.proxy.getPlayer(context); - } +public class PacketHandler { + public SimpleNetworkWrapper netHandler + = NetworkRegistry.INSTANCE.newSimpleChannel("MEK"); - /** - * Send this message to the specified player. - * @param message - the message to send - * @param player - the player to send it to - */ - public void sendTo(IMessage message, EntityPlayerMP player) - { - netHandler.sendTo(message, player); - } - - /** - * Send this message to everyone connected to the server. - * @param message - message to send - */ - public void sendToAll(IMessage message) - { - MinecraftServer server = MinecraftServer.getServer(); - - for(EntityPlayer player : (List)server.getConfigurationManager().playerEntityList) - { - sendTo(message, (EntityPlayerMP)player); - } - } + public void initialize() { + netHandler.registerMessage(PacketRobit.class, RobitMessage.class, 0, Side.SERVER); + netHandler.registerMessage( + PacketTransmitterUpdate.class, TransmitterUpdateMessage.class, 1, Side.CLIENT + ); + netHandler.registerMessage( + PacketPersonalChest.class, PersonalChestMessage.class, 2, Side.CLIENT + ); + netHandler.registerMessage( + PacketPersonalChest.class, PersonalChestMessage.class, 2, Side.SERVER + ); + netHandler.registerMessage( + PacketElectricBowState.class, ElectricBowStateMessage.class, 3, Side.SERVER + ); + netHandler.registerMessage( + PacketConfiguratorState.class, ConfiguratorStateMessage.class, 4, Side.SERVER + ); + netHandler.registerMessage( + PacketTileEntity.class, TileEntityMessage.class, 5, Side.CLIENT + ); + netHandler.registerMessage( + PacketTileEntity.class, TileEntityMessage.class, 5, Side.SERVER + ); + netHandler.registerMessage( + PacketPortalFX.class, PortalFXMessage.class, 6, Side.CLIENT + ); + netHandler.registerMessage( + PacketDataRequest.class, DataRequestMessage.class, 7, Side.SERVER + ); + netHandler.registerMessage( + PacketOredictionificatorGui.class, + OredictionificatorGuiMessage.class, + 8, + Side.CLIENT + ); + netHandler.registerMessage( + PacketOredictionificatorGui.class, + OredictionificatorGuiMessage.class, + 8, + Side.SERVER + ); + netHandler.registerMessage( + PacketSecurityMode.class, SecurityModeMessage.class, 9, Side.SERVER + ); + netHandler.registerMessage( + PacketPortableTeleporter.class, + PortableTeleporterMessage.class, + 10, + Side.CLIENT + ); + netHandler.registerMessage( + PacketPortableTeleporter.class, + PortableTeleporterMessage.class, + 10, + Side.SERVER + ); + netHandler.registerMessage( + PacketRemoveUpgrade.class, RemoveUpgradeMessage.class, 11, Side.SERVER + ); + netHandler.registerMessage( + PacketRedstoneControl.class, RedstoneControlMessage.class, 12, Side.SERVER + ); + netHandler.registerMessage( + PacketWalkieTalkieState.class, WalkieTalkieStateMessage.class, 13, Side.SERVER + ); + netHandler.registerMessage( + PacketLogisticalSorterGui.class, + LogisticalSorterGuiMessage.class, + 14, + Side.CLIENT + ); + netHandler.registerMessage( + PacketLogisticalSorterGui.class, + LogisticalSorterGuiMessage.class, + 14, + Side.SERVER + ); + netHandler.registerMessage( + PacketNewFilter.class, NewFilterMessage.class, 15, Side.SERVER + ); + netHandler.registerMessage( + PacketEditFilter.class, EditFilterMessage.class, 16, Side.SERVER + ); + netHandler.registerMessage( + PacketConfigurationUpdate.class, + ConfigurationUpdateMessage.class, + 17, + Side.SERVER + ); + netHandler.registerMessage( + PacketSimpleGui.class, SimpleGuiMessage.class, 18, Side.CLIENT + ); + netHandler.registerMessage( + PacketSimpleGui.class, SimpleGuiMessage.class, 18, Side.SERVER + ); + netHandler.registerMessage( + PacketDigitalMinerGui.class, DigitalMinerGuiMessage.class, 19, Side.CLIENT + ); + netHandler.registerMessage( + PacketDigitalMinerGui.class, DigitalMinerGuiMessage.class, 19, Side.SERVER + ); + netHandler.registerMessage( + PacketJetpackData.class, JetpackDataMessage.class, 20, Side.CLIENT + ); + netHandler.registerMessage( + PacketJetpackData.class, JetpackDataMessage.class, 20, Side.SERVER + ); + netHandler.registerMessage(PacketKey.class, KeyMessage.class, 21, Side.SERVER); + netHandler.registerMessage( + PacketScubaTankData.class, ScubaTankDataMessage.class, 22, Side.CLIENT + ); + netHandler.registerMessage( + PacketScubaTankData.class, ScubaTankDataMessage.class, 22, Side.SERVER + ); + netHandler.registerMessage( + PacketConfigSync.class, ConfigSyncMessage.class, 23, Side.CLIENT + ); + netHandler.registerMessage( + PacketBoxBlacklist.class, BoxBlacklistMessage.class, 24, Side.CLIENT + ); + netHandler.registerMessage( + PacketPortableTankState.class, PortableTankStateMessage.class, 25, Side.SERVER + ); + netHandler.registerMessage( + PacketContainerEditMode.class, ContainerEditModeMessage.class, 26, Side.SERVER + ); + netHandler.registerMessage( + PacketFlamethrowerData.class, FlamethrowerDataMessage.class, 27, Side.CLIENT + ); + netHandler.registerMessage( + PacketFlamethrowerData.class, FlamethrowerDataMessage.class, 27, Side.SERVER + ); + netHandler.registerMessage( + PacketDropperUse.class, DropperUseMessage.class, 28, Side.SERVER + ); + netHandler.registerMessage( + PacketEntityMove.class, EntityMoveMessage.class, 29, Side.CLIENT + ); + netHandler.registerMessage( + PacketSecurityUpdate.class, SecurityUpdateMessage.class, 30, Side.CLIENT + ); + netHandler.registerMessage( + PacketChangeTime.class, ChangeTimeMessage.class, 31, Side.SERVER + ); + netHandler.registerMessage( + PacketChangeWeather.class, ChangeWeatherMessage.class, 32, Side.SERVER + ); + } - /** - * Send this message to everyone within a certain range of a point. - * - * @param message - the message to send - * @param point - the TargetPoint around which to send - */ - public void sendToAllAround(IMessage message, NetworkRegistry.TargetPoint point) - { - netHandler.sendToAllAround(message, point); - } + /** + * Encodes an Object[] of data into a DataOutputStream. + * @param dataValues - an Object[] of data to encode + * @param output - the output stream to write to + */ + public static void encode(Object[] dataValues, ByteBuf output) { + try { + for (Object data : dataValues) { + if (data instanceof Integer) { + output.writeInt((Integer) data); + } else if (data instanceof Short) { + output.writeShort((Short) data); + } else if (data instanceof Boolean) { + output.writeBoolean((Boolean) data); + } else if (data instanceof Double) { + output.writeDouble((Double) data); + } else if (data instanceof Float) { + output.writeFloat((Float) data); + } else if (data instanceof String) { + writeString(output, (String) data); + } else if (data instanceof Byte) { + output.writeByte((Byte) data); + } else if (data instanceof ItemStack) { + writeStack(output, (ItemStack) data); + } else if (data instanceof NBTTagCompound) { + writeNBT(output, (NBTTagCompound) data); + } else if (data instanceof int[]) { + for (int i : (int[]) data) { + output.writeInt(i); + } + } else if (data instanceof byte[]) { + for (byte b : (byte[]) data) { + output.writeByte(b); + } + } else if (data instanceof ArrayList) { + encode(((ArrayList) data).toArray(), output); + } + } + } catch (Exception e) { + Mekanism.logger.error("Error while encoding packet data."); + e.printStackTrace(); + } + } - /** - * Send this message to everyone within the supplied dimension. - * @param message - the message to send - * @param dimensionId - the dimension id to target - */ - public void sendToDimension(IMessage message, int dimensionId) - { - netHandler.sendToDimension(message, dimensionId); - } + public static void writeString(ByteBuf output, String s) { + output.writeInt(s.getBytes().length); + output.writeBytes(s.getBytes()); + } - /** - * Send this message to the server. - * @param message - the message to send - */ - public void sendToServer(IMessage message) - { - netHandler.sendToServer(message); - } - - /** - * Send this message to all players within a defined AABB cuboid. - * @param message - the message to send - * @param cuboid - the AABB cuboid to send the packet in - * @param dimId - the dimension the cuboid is in - */ - public void sendToCuboid(IMessage message, AxisAlignedBB cuboid, int dimId) - { - MinecraftServer server = MinecraftServer.getServer(); + public static String readString(ByteBuf input) { + return new String(input.readBytes(input.readInt()).array()); + } - if(server != null && cuboid != null) - { - for(EntityPlayerMP player : (List)server.getConfigurationManager().playerEntityList) - { - if(player.dimension == dimId && cuboid.isVecInside(Vec3.createVectorHelper(player.posX, player.posY, player.posZ))) - { - sendTo(message, player); - } - } - } - } - - public void sendToReceivers(IMessage message, Range4D range) - { - MinecraftServer server = MinecraftServer.getServer(); + public static void writeStack(ByteBuf output, ItemStack stack) { + output.writeInt(stack != null ? Item.getIdFromItem(stack.getItem()) : -1); - if(server != null) - { - for(EntityPlayerMP player : (List)server.getConfigurationManager().playerEntityList) - { - if(player.dimension == range.dimensionId && Range4D.getChunkRange(player).intersects(range)) - { - sendTo(message, player); - } - } - } - } + if (stack != null) { + output.writeInt(stack.stackSize); + output.writeInt(stack.getItemDamage()); + + if (stack.getTagCompound() != null && stack.getItem().getShareTag()) { + output.writeBoolean(true); + writeNBT(output, stack.getTagCompound()); + } else { + output.writeBoolean(false); + } + } + } + + public static ItemStack readStack(ByteBuf input) { + int id = input.readInt(); + + if (id >= 0) { + ItemStack stack + = new ItemStack(Item.getItemById(id), input.readInt(), input.readInt()); + + if (input.readBoolean()) { + stack.setTagCompound(readNBT(input)); + } + + return stack; + } + + return null; + } + + public static void writeNBT(ByteBuf output, NBTTagCompound nbtTags) { + try { + byte[] buffer = CompressedStreamTools.compress(nbtTags); + + output.writeInt(buffer.length); + output.writeBytes(buffer); + } catch (Exception e) {} + } + + public static NBTTagCompound readNBT(ByteBuf input) { + try { + byte[] buffer = new byte[input.readInt()]; + input.readBytes(buffer); + + return CompressedStreamTools.func_152457_a( + buffer, new NBTSizeTracker(2097152L) + ); + } catch (Exception e) { + return null; + } + } + + public static void log(String log) { + if (general.logPackets) { + System.out.println("[Mekanism] " + log); + } + } + + public static EntityPlayer getPlayer(MessageContext context) { + return Mekanism.proxy.getPlayer(context); + } + + /** + * Send this message to the specified player. + * @param message - the message to send + * @param player - the player to send it to + */ + public void sendTo(IMessage message, EntityPlayerMP player) { + netHandler.sendTo(message, player); + } + + /** + * Send this message to everyone connected to the server. + * @param message - message to send + */ + public void sendToAll(IMessage message) { + MinecraftServer server = MinecraftServer.getServer(); + + for (EntityPlayer player : + (List) server.getConfigurationManager().playerEntityList) { + sendTo(message, (EntityPlayerMP) player); + } + } + + /** + * Send this message to everyone within a certain range of a point. + * + * @param message - the message to send + * @param point - the TargetPoint around which to send + */ + public void sendToAllAround(IMessage message, NetworkRegistry.TargetPoint point) { + netHandler.sendToAllAround(message, point); + } + + /** + * Send this message to everyone within the supplied dimension. + * @param message - the message to send + * @param dimensionId - the dimension id to target + */ + public void sendToDimension(IMessage message, int dimensionId) { + netHandler.sendToDimension(message, dimensionId); + } + + /** + * Send this message to the server. + * @param message - the message to send + */ + public void sendToServer(IMessage message) { + netHandler.sendToServer(message); + } + + /** + * Send this message to all players within a defined AABB cuboid. + * @param message - the message to send + * @param cuboid - the AABB cuboid to send the packet in + * @param dimId - the dimension the cuboid is in + */ + public void sendToCuboid(IMessage message, AxisAlignedBB cuboid, int dimId) { + MinecraftServer server = MinecraftServer.getServer(); + + if (server != null && cuboid != null) { + for (EntityPlayerMP player : + (List) server.getConfigurationManager() + .playerEntityList) { + if (player.dimension == dimId + && cuboid.isVecInside( + Vec3.createVectorHelper(player.posX, player.posY, player.posZ) + )) { + sendTo(message, player); + } + } + } + } + + public void sendToReceivers(IMessage message, Range4D range) { + MinecraftServer server = MinecraftServer.getServer(); + + if (server != null) { + for (EntityPlayerMP player : + (List) server.getConfigurationManager() + .playerEntityList) { + if (player.dimension == range.dimensionId + && Range4D.getChunkRange(player).intersects(range)) { + sendTo(message, player); + } + } + } + } } diff --git a/src/main/java/mekanism/common/Resource.java b/src/main/java/mekanism/common/Resource.java index f54a5c833..1c9a97da7 100644 --- a/src/main/java/mekanism/common/Resource.java +++ b/src/main/java/mekanism/common/Resource.java @@ -1,37 +1,31 @@ package mekanism.common; -public enum Resource -{ - IRON("Iron"), - GOLD("Gold"), - OSMIUM("Osmium"), - COPPER("Copper"), - TIN("Tin"), - SILVER("Silver"), - LEAD("Lead"); +public enum Resource { + IRON("Iron"), + GOLD("Gold"), + OSMIUM("Osmium"), + COPPER("Copper"), + TIN("Tin"), + SILVER("Silver"), + LEAD("Lead"); - private String name; + private String name; - private Resource(String s) - { - name = s; - } + private Resource(String s) { + name = s; + } - public static Resource getFromName(String s) - { - for(Resource r : values()) - { - if(r.name.toLowerCase().equals(s.toLowerCase())) - { - return r; - } - } + public static Resource getFromName(String s) { + for (Resource r : values()) { + if (r.name.toLowerCase().equals(s.toLowerCase())) { + return r; + } + } - return null; - } + return null; + } - public String getName() - { - return name; - } + public String getName() { + return name; + } } diff --git a/src/main/java/mekanism/common/RobitAIFollow.java b/src/main/java/mekanism/common/RobitAIFollow.java index 0832e3d2b..5b9326f8c 100644 --- a/src/main/java/mekanism/common/RobitAIFollow.java +++ b/src/main/java/mekanism/common/RobitAIFollow.java @@ -7,135 +7,136 @@ import net.minecraft.pathfinding.PathNavigate; import net.minecraft.util.MathHelper; import net.minecraft.world.World; -public class RobitAIFollow extends EntityAIBase -{ - /** The robit entity. */ - private EntityRobit theRobit; +public class RobitAIFollow extends EntityAIBase { + /** The robit entity. */ + private EntityRobit theRobit; - /** The robit's owner. */ - private EntityPlayer theOwner; + /** The robit's owner. */ + private EntityPlayer theOwner; - /** The world the robit is located in. */ - private World theWorld; + /** The world the robit is located in. */ + private World theWorld; - /** How fast the robit can travel. */ - private float moveSpeed; + /** How fast the robit can travel. */ + private float moveSpeed; - /** The robit's pathfinder. */ - private PathNavigate thePathfinder; + /** The robit's pathfinder. */ + private PathNavigate thePathfinder; - /** The ticker for updates. */ - private int ticker; + /** The ticker for updates. */ + private int ticker; - /** The distance between the owner the robit must be at in order for the protocol to begin. */ - private float maxDist; + /** + * The distance between the owner the robit must be at in order for the protocol to + * begin. + */ + private float maxDist; - /** The distance between the owner the robit must reach before it stops the protocol. */ - private float minDist; + /** + * The distance between the owner the robit must reach before it stops the protocol. + */ + private float minDist; - /** Whether or not this robit avoids water. */ - private boolean avoidWater; + /** Whether or not this robit avoids water. */ + private boolean avoidWater; - public RobitAIFollow(EntityRobit entityRobit, float speed, float min, float max) - { - theRobit = entityRobit; - theWorld = entityRobit.worldObj; - moveSpeed = speed; - thePathfinder = entityRobit.getNavigator(); - minDist = min; - maxDist = max; - } + public RobitAIFollow(EntityRobit entityRobit, float speed, float min, float max) { + theRobit = entityRobit; + theWorld = entityRobit.worldObj; + moveSpeed = speed; + thePathfinder = entityRobit.getNavigator(); + minDist = min; + maxDist = max; + } - @Override - public boolean shouldExecute() - { - EntityPlayer player = theRobit.getOwner(); + @Override + public boolean shouldExecute() { + EntityPlayer player = theRobit.getOwner(); - if(player == null) - { - return false; - } - else if(theRobit.worldObj.provider.dimensionId != player.worldObj.provider.dimensionId) - { - return false; - } - else if(!theRobit.getFollowing()) - { - //Still looks up at the player if on chargepad or not following + if (player == null) { + return false; + } else if (theRobit.worldObj.provider.dimensionId != player.worldObj.provider.dimensionId) { + return false; + } else if (!theRobit.getFollowing()) { + //Still looks up at the player if on chargepad or not following - theRobit.getLookHelper().setLookPositionWithEntity(player, 6.0F, theRobit.getVerticalFaceSpeed()/10); - return false; - } - else if(theRobit.getDistanceSqToEntity(player) < (minDist * minDist)) - { - return false; - } - else if(theRobit.getEnergy() == 0) - { - return false; - } - else { - theOwner = player; - return true; - } - } + theRobit.getLookHelper().setLookPositionWithEntity( + player, 6.0F, theRobit.getVerticalFaceSpeed() / 10 + ); + return false; + } else if (theRobit.getDistanceSqToEntity(player) < (minDist * minDist)) { + return false; + } else if (theRobit.getEnergy() == 0) { + return false; + } else { + theOwner = player; + return true; + } + } - @Override - public boolean continueExecuting() - { - return !thePathfinder.noPath() && theRobit.getDistanceSqToEntity(theOwner) > (maxDist * maxDist) && theRobit.getFollowing() && theRobit.getEnergy() > 0 && theOwner.worldObj.provider.dimensionId == theRobit.worldObj.provider.dimensionId; - } + @Override + public boolean continueExecuting() { + return !thePathfinder.noPath() + && theRobit.getDistanceSqToEntity(theOwner) > (maxDist * maxDist) + && theRobit.getFollowing() && theRobit.getEnergy() > 0 + && theOwner.worldObj.provider.dimensionId + == theRobit.worldObj.provider.dimensionId; + } - @Override - public void startExecuting() - { - ticker = 0; - avoidWater = theRobit.getNavigator().getAvoidsWater(); - theRobit.getNavigator().setAvoidsWater(false); - } + @Override + public void startExecuting() { + ticker = 0; + avoidWater = theRobit.getNavigator().getAvoidsWater(); + theRobit.getNavigator().setAvoidsWater(false); + } - @Override - public void resetTask() - { - theOwner = null; - thePathfinder.clearPathEntity(); - theRobit.getNavigator().setAvoidsWater(avoidWater); - } + @Override + public void resetTask() { + theOwner = null; + thePathfinder.clearPathEntity(); + theRobit.getNavigator().setAvoidsWater(avoidWater); + } - @Override - public void updateTask() - { - theRobit.getLookHelper().setLookPositionWithEntity(theOwner, 6.0F, theRobit.getVerticalFaceSpeed()/10); + @Override + public void updateTask() { + theRobit.getLookHelper().setLookPositionWithEntity( + theOwner, 6.0F, theRobit.getVerticalFaceSpeed() / 10 + ); - if(theRobit.getFollowing()) - { - if(--ticker <= 0) - { - ticker = 10; + if (theRobit.getFollowing()) { + if (--ticker <= 0) { + ticker = 10; - if(!thePathfinder.tryMoveToEntityLiving(theOwner, moveSpeed)) - { - if(theRobit.getDistanceSqToEntity(theOwner) >= 144.0D) - { - int x = MathHelper.floor_double(theOwner.posX) - 2; - int y = MathHelper.floor_double(theOwner.posZ) - 2; - int z = MathHelper.floor_double(theOwner.boundingBox.minY); + if (!thePathfinder.tryMoveToEntityLiving(theOwner, moveSpeed)) { + if (theRobit.getDistanceSqToEntity(theOwner) >= 144.0D) { + int x = MathHelper.floor_double(theOwner.posX) - 2; + int y = MathHelper.floor_double(theOwner.posZ) - 2; + int z = MathHelper.floor_double(theOwner.boundingBox.minY); - for(int l = 0; l <= 4; ++l) - { - for(int i1 = 0; i1 <= 4; ++i1) - { - if((l < 1 || i1 < 1 || l > 3 || i1 > 3) && theWorld.doesBlockHaveSolidTopSurface(theWorld, x + l, z - 1, y + i1) && !theWorld.getBlock(x + l, z, y + i1).isNormalCube() && !theWorld.getBlock(x + l, z + 1, y + i1).isNormalCube()) - { - theRobit.setLocationAndAngles((x + l) + 0.5F, z, (y + i1) + 0.5F, theRobit.rotationYaw, theRobit.rotationPitch); - thePathfinder.clearPathEntity(); - return; - } - } - } - } - } - } - } - } + for (int l = 0; l <= 4; ++l) { + for (int i1 = 0; i1 <= 4; ++i1) { + if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) + && theWorld.doesBlockHaveSolidTopSurface( + theWorld, x + l, z - 1, y + i1 + ) + && !theWorld.getBlock(x + l, z, y + i1).isNormalCube() + && !theWorld.getBlock(x + l, z + 1, y + i1) + .isNormalCube()) { + theRobit.setLocationAndAngles( + (x + l) + 0.5F, + z, + (y + i1) + 0.5F, + theRobit.rotationYaw, + theRobit.rotationPitch + ); + thePathfinder.clearPathEntity(); + return; + } + } + } + } + } + } + } + } } diff --git a/src/main/java/mekanism/common/RobitAIPickup.java b/src/main/java/mekanism/common/RobitAIPickup.java index 74085d5d9..1a0595f46 100644 --- a/src/main/java/mekanism/common/RobitAIPickup.java +++ b/src/main/java/mekanism/common/RobitAIPickup.java @@ -15,139 +15,148 @@ import net.minecraft.world.World; * Written by pixlepix (I'm in mekanism! Yay!) * Boilerplate copied from RobitAIFollow */ -public class RobitAIPickup extends EntityAIBase -{ - /** The robit entity. */ - private EntityRobit theRobit; +public class RobitAIPickup extends EntityAIBase { + /** The robit entity. */ + private EntityRobit theRobit; - /** The world the robit is located in. */ - private World theWorld; + /** The world the robit is located in. */ + private World theWorld; - /** How fast the robit can travel. */ - private float moveSpeed; + /** How fast the robit can travel. */ + private float moveSpeed; - /** The robit's pathfinder. */ - private PathNavigate thePathfinder; + /** The robit's pathfinder. */ + private PathNavigate thePathfinder; - /** The ticker for updates. */ - private int ticker; + /** The ticker for updates. */ + private int ticker; - /** Whether or not this robit avoids water. */ - private boolean avoidWater; - private EntityItem closest; + /** Whether or not this robit avoids water. */ + private boolean avoidWater; + private EntityItem closest; - public RobitAIPickup(EntityRobit entityRobit, float speed) - { - theRobit = entityRobit; - theWorld = entityRobit.worldObj; - moveSpeed = speed; - thePathfinder = entityRobit.getNavigator(); - } + public RobitAIPickup(EntityRobit entityRobit, float speed) { + theRobit = entityRobit; + theWorld = entityRobit.worldObj; + moveSpeed = speed; + thePathfinder = entityRobit.getNavigator(); + } - @Override - public boolean shouldExecute() - { - if(!theRobit.getDropPickup()) - { - return false; - } - - if(closest != null && closest.getDistanceSqToEntity(closest) > 100 && thePathfinder.getPathToXYZ(closest.posX, closest.posY, closest.posZ) != null) - { - return true; - } + @Override + public boolean shouldExecute() { + if (!theRobit.getDropPickup()) { + return false; + } - List items = theRobit.worldObj.getEntitiesWithinAABB(EntityItem.class, AxisAlignedBB.getBoundingBox(theRobit.posX-10, theRobit.posY-10, theRobit.posZ-10, theRobit.posX+10, theRobit.posY+10, theRobit.posZ+10)); - Iterator iter = items.iterator(); - //Cached for slight performance - double closestDistance = -1; + if (closest != null && closest.getDistanceSqToEntity(closest) > 100 + && thePathfinder.getPathToXYZ(closest.posX, closest.posY, closest.posZ) + != null) { + return true; + } - while(iter.hasNext()) - { - EntityItem entity = (EntityItem)iter.next(); + List items = theRobit.worldObj.getEntitiesWithinAABB( + EntityItem.class, + AxisAlignedBB.getBoundingBox( + theRobit.posX - 10, + theRobit.posY - 10, + theRobit.posZ - 10, + theRobit.posX + 10, + theRobit.posY + 10, + theRobit.posZ + 10 + ) + ); + Iterator iter = items.iterator(); + //Cached for slight performance + double closestDistance = -1; - double distance = theRobit.getDistanceToEntity(entity); + while (iter.hasNext()) { + EntityItem entity = (EntityItem) iter.next(); - if(distance <= 10) - { - if(closestDistance == -1 || distance < closestDistance) - { - if(thePathfinder.getPathToXYZ(entity.posX, entity.posY, entity.posZ) != null) - { - closest = entity; - closestDistance = distance; - } - } - } - } + double distance = theRobit.getDistanceToEntity(entity); - if(closest == null || closest.isDead) - { - //No valid items - return false; - } + if (distance <= 10) { + if (closestDistance == -1 || distance < closestDistance) { + if (thePathfinder.getPathToXYZ(entity.posX, entity.posY, entity.posZ) + != null) { + closest = entity; + closestDistance = distance; + } + } + } + } - return true; + if (closest == null || closest.isDead) { + //No valid items + return false; + } - } + return true; + } - @Override - public boolean continueExecuting() - { - return !closest.isDead && !thePathfinder.noPath() && theRobit.getDistanceSqToEntity(closest) > 100 && theRobit.getDropPickup() && theRobit.getEnergy() > 0 && closest.worldObj.provider.dimensionId == theRobit.worldObj.provider.dimensionId; - } + @Override + public boolean continueExecuting() { + return !closest.isDead && !thePathfinder.noPath() + && theRobit.getDistanceSqToEntity(closest) > 100 && theRobit.getDropPickup() + && theRobit.getEnergy() > 0 + && closest.worldObj.provider.dimensionId + == theRobit.worldObj.provider.dimensionId; + } - @Override - public void startExecuting() - { - ticker = 0; - avoidWater = theRobit.getNavigator().getAvoidsWater(); - theRobit.getNavigator().setAvoidsWater(false); - } + @Override + public void startExecuting() { + ticker = 0; + avoidWater = theRobit.getNavigator().getAvoidsWater(); + theRobit.getNavigator().setAvoidsWater(false); + } - @Override - public void resetTask() - { - thePathfinder.clearPathEntity(); - theRobit.getNavigator().setAvoidsWater(avoidWater); - } + @Override + public void resetTask() { + thePathfinder.clearPathEntity(); + theRobit.getNavigator().setAvoidsWater(avoidWater); + } - @Override - public void updateTask() - { - if(!theRobit.getDropPickup()) - { - return; - } - - theRobit.getLookHelper().setLookPositionWithEntity(closest, 6.0F, theRobit.getVerticalFaceSpeed()/10); + @Override + public void updateTask() { + if (!theRobit.getDropPickup()) { + return; + } - if(--ticker <= 0) - { - ticker = 10; + theRobit.getLookHelper().setLookPositionWithEntity( + closest, 6.0F, theRobit.getVerticalFaceSpeed() / 10 + ); - if(!thePathfinder.tryMoveToEntityLiving(closest, moveSpeed)) - { - if(theRobit.getDistanceSqToEntity(closest) >= 144.0D) - { - int x = MathHelper.floor_double(closest.posX) - 2; - int y = MathHelper.floor_double(closest.posZ) - 2; - int z = MathHelper.floor_double(closest.boundingBox.minY); + if (--ticker <= 0) { + ticker = 10; - for(int l = 0; l <= 4; ++l) - { - for(int i1 = 0; i1 <= 4; ++i1) - { - if((l < 1 || i1 < 1 || l > 3 || i1 > 3) && theWorld.doesBlockHaveSolidTopSurface(theWorld, x + l, z - 1, y + i1) && !theWorld.getBlock(x + l, z, y + i1).isNormalCube() && !theWorld.getBlock(x + l, z + 1, y + i1).isNormalCube()) - { - theRobit.setLocationAndAngles((x + l) + 0.5F, z, (y + i1) + 0.5F, theRobit.rotationYaw, theRobit.rotationPitch); - thePathfinder.clearPathEntity(); - return; - } - } - } - } - } - } - } + if (!thePathfinder.tryMoveToEntityLiving(closest, moveSpeed)) { + if (theRobit.getDistanceSqToEntity(closest) >= 144.0D) { + int x = MathHelper.floor_double(closest.posX) - 2; + int y = MathHelper.floor_double(closest.posZ) - 2; + int z = MathHelper.floor_double(closest.boundingBox.minY); + + for (int l = 0; l <= 4; ++l) { + for (int i1 = 0; i1 <= 4; ++i1) { + if ((l < 1 || i1 < 1 || l > 3 || i1 > 3) + && theWorld.doesBlockHaveSolidTopSurface( + theWorld, x + l, z - 1, y + i1 + ) + && !theWorld.getBlock(x + l, z, y + i1).isNormalCube() + && !theWorld.getBlock(x + l, z + 1, y + i1) + .isNormalCube()) { + theRobit.setLocationAndAngles( + (x + l) + 0.5F, + z, + (y + i1) + 0.5F, + theRobit.rotationYaw, + theRobit.rotationPitch + ); + thePathfinder.clearPathEntity(); + return; + } + } + } + } + } + } + } } \ No newline at end of file diff --git a/src/main/java/mekanism/common/SideData.java b/src/main/java/mekanism/common/SideData.java index 68a174dcc..4d3947e7d 100644 --- a/src/main/java/mekanism/common/SideData.java +++ b/src/main/java/mekanism/common/SideData.java @@ -10,92 +10,77 @@ import mekanism.common.util.LangUtils; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidTank; -public class SideData -{ - /** The color of this SideData */ - public EnumColor color; - - /** The name of this SideData */ - public String name; +public class SideData { + /** The color of this SideData */ + public EnumColor color; - /** int[] of available side slots, can be used for items, gases, or items */ - public int[] availableSlots; - - /** IOState representing this SideData */ - public IOState ioState; + /** The name of this SideData */ + public String name; - public SideData(String n, EnumColor colour, int[] slots) - { - name = n; - color = colour; - availableSlots = slots; - } - - public SideData(String n, EnumColor colour, IOState state) - { - name = n; - color = colour; - ioState = state; - } - - public String localize() - { - return LangUtils.localize("sideData." + name); - } - - public boolean hasSlot(int... slots) - { - for(int i : availableSlots) - { - for(int slot : slots) - { - if(i == slot) - { - return true; - } - } - } - - return false; - } - - public FluidTankInfo[] getFluidTankInfo(ITankManager manager) - { - Object[] tanks = manager.getTanks(); - List infos = new ArrayList(); - - if(tanks == null) - { - return infos.toArray(new FluidTankInfo[] {}); - } - - for(int slot : availableSlots) - { - if(slot <= tanks.length-1 && tanks[slot] instanceof IFluidTank) - { - infos.add(((IFluidTank)tanks[slot]).getInfo()); - } - } - - return infos.toArray(new FluidTankInfo[] {}); - } - - public GasTank getGasTank(ITankManager manager) - { - Object[] tanks = manager.getTanks(); - - if(tanks == null || tanks.length < 1 || !(tanks[0] instanceof GasTank)) - { - return null; - } - - return (GasTank)tanks[0]; - } - - public static enum IOState - { - INPUT, - OUTPUT, - OFF; - } + /** int[] of available side slots, can be used for items, gases, or items */ + public int[] availableSlots; + + /** IOState representing this SideData */ + public IOState ioState; + + public SideData(String n, EnumColor colour, int[] slots) { + name = n; + color = colour; + availableSlots = slots; + } + + public SideData(String n, EnumColor colour, IOState state) { + name = n; + color = colour; + ioState = state; + } + + public String localize() { + return LangUtils.localize("sideData." + name); + } + + public boolean hasSlot(int... slots) { + for (int i : availableSlots) { + for (int slot : slots) { + if (i == slot) { + return true; + } + } + } + + return false; + } + + public FluidTankInfo[] getFluidTankInfo(ITankManager manager) { + Object[] tanks = manager.getTanks(); + List infos = new ArrayList(); + + if (tanks == null) { + return infos.toArray(new FluidTankInfo[] {}); + } + + for (int slot : availableSlots) { + if (slot <= tanks.length - 1 && tanks[slot] instanceof IFluidTank) { + infos.add(((IFluidTank) tanks[slot]).getInfo()); + } + } + + return infos.toArray(new FluidTankInfo[] {}); + } + + public GasTank getGasTank(ITankManager manager) { + Object[] tanks = manager.getTanks(); + + if (tanks == null || tanks.length < 1 || !(tanks[0] instanceof GasTank)) { + return null; + } + + return (GasTank) tanks[0]; + } + + public static enum IOState { + INPUT, + OUTPUT, + OFF; + } } diff --git a/src/main/java/mekanism/common/Tier.java b/src/main/java/mekanism/common/Tier.java index 49416a7b5..d5794f397 100644 --- a/src/main/java/mekanism/common/Tier.java +++ b/src/main/java/mekanism/common/Tier.java @@ -1,771 +1,786 @@ package mekanism.common; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.List; +import codechicken.lib.colour.ColourRGBA; +import io.netty.buffer.ByteBuf; import mekanism.api.EnumColor; import mekanism.common.multipart.TransmitterType; import mekanism.common.util.LangUtils; import net.minecraft.util.ResourceLocation; -import codechicken.lib.colour.ColourRGBA; /** - * Tier information for Mekanism. This currently includes tiers for Energy Cubes and Smelting Factories. + * Tier information for Mekanism. This currently includes tiers for Energy Cubes and + * Smelting Factories. * @author aidancbrady * */ -public final class Tier -{ - private static List tierTypes = new ArrayList(); - - private static boolean initiated = false; - - /** The default tiers used in Mekanism. - * @author aidancbrady - */ - public static enum BaseTier - { - BASIC("Basic", EnumColor.BRIGHT_GREEN), - ADVANCED("Advanced", EnumColor.DARK_RED), - ELITE("Elite", EnumColor.DARK_BLUE), - ULTIMATE("Ultimate", EnumColor.PURPLE), - CREATIVE("Creative", EnumColor.BLACK); - - public String getName() - { - return name; - } - - public String getLocalizedName() - { - return LangUtils.localize("tier." + getName()); - } - - public EnumColor getColor() - { - return color; - } - - public boolean isObtainable() - { - return this != CREATIVE; - } - - private String name; - private EnumColor color; - - private BaseTier(String s, EnumColor c) - { - name = s; - color = c; - } - } - - public static enum EnergyCubeTier implements ITier - { - BASIC(2000000, 800), - ADVANCED(8000000, 3200), - ELITE(32000000, 12800), - ULTIMATE(128000000, 51200), - CREATIVE(Double.MAX_VALUE, Double.MAX_VALUE); +public final class Tier { + private static List tierTypes = new ArrayList(); - public double maxEnergy; - private double baseMaxEnergy; - - public double output; - private double baseOutput; - - private EnergyCubeTier(double max, double out) - { - baseMaxEnergy = maxEnergy = max; - baseOutput = output = out; - } + private static boolean initiated = false; - public static EnergyCubeTier getFromName(String tierName) - { - for(EnergyCubeTier tier : values()) - { - if(tierName.contains(tier.getBaseTier().getName())) - { - return tier; - } - } - - return BASIC; - } - - @Override - public void loadConfig() - { - if(this != CREATIVE) - { - maxEnergy = Mekanism.configuration.get("tier", getBaseTier().getName() + "EnergyCubeMaxEnergy", baseMaxEnergy).getDouble(); - output = Mekanism.configuration.get("tier", getBaseTier().getName() + "EnergyCubeOutput", baseOutput).getDouble(); - } - } - - @Override - public void readConfig(ByteBuf dataStream) - { - if(this != CREATIVE) - { - maxEnergy = dataStream.readDouble(); - output = dataStream.readDouble(); - } - } - - @Override - public void writeConfig(ByteBuf dataStream) - { - if(this != CREATIVE) - { - dataStream.writeDouble(maxEnergy); - dataStream.writeDouble(output); - } - } - - @Override - public BaseTier getBaseTier() - { - return BaseTier.values()[ordinal()]; - } - } - - public static enum InductionCellTier implements ITier - { - BASIC(1E9D), - ADVANCED(8E9D), - ELITE(64E9D), - ULTIMATE(512E9D); + /** + * The default tiers used in Mekanism. + * @author aidancbrady + */ + public static enum BaseTier { + BASIC("Basic", EnumColor.BRIGHT_GREEN), + ADVANCED("Advanced", EnumColor.DARK_RED), + ELITE("Elite", EnumColor.DARK_BLUE), + ULTIMATE("Ultimate", EnumColor.PURPLE), + CREATIVE("Creative", EnumColor.BLACK); - public double maxEnergy; - private double baseMaxEnergy; - - private InductionCellTier(double max) - { - baseMaxEnergy = maxEnergy = max; - } - - @Override - public BaseTier getBaseTier() - { - return BaseTier.values()[ordinal()]; - } - - @Override - public void loadConfig() - { - maxEnergy = Mekanism.configuration.get("tier", getBaseTier().getName() + "InductionCellMaxEnergy", baseMaxEnergy).getDouble(); - } - - @Override - public void readConfig(ByteBuf dataStream) - { - maxEnergy = dataStream.readDouble(); - } - - @Override - public void writeConfig(ByteBuf dataStream) - { - dataStream.writeDouble(maxEnergy); - } - } - - public static enum InductionProviderTier implements ITier - { - BASIC(64000), - ADVANCED(512000), - ELITE(4096000), - ULTIMATE(32768000); + public String getName() { + return name; + } - public double output; - private double baseOutput; - - private InductionProviderTier(double out) - { - baseOutput = output = out; - } - - @Override - public BaseTier getBaseTier() - { - return BaseTier.values()[ordinal()]; - } - - @Override - public void loadConfig() - { - output = Mekanism.configuration.get("tier", getBaseTier().getName() + "InductionProviderOutput", baseOutput).getDouble(); - } - - @Override - public void readConfig(ByteBuf dataStream) - { - output = dataStream.readDouble(); - } - - @Override - public void writeConfig(ByteBuf dataStream) - { - dataStream.writeDouble(output); - } - } + public String getLocalizedName() { + return LangUtils.localize("tier." + getName()); + } - public static enum FactoryTier - { - BASIC(3, new ResourceLocation("mekanism", "gui/factory/GuiBasicFactory.png")), - ADVANCED(5, new ResourceLocation("mekanism", "gui/factory/GuiAdvancedFactory.png")), - ELITE(7, new ResourceLocation("mekanism", "gui/factory/GuiEliteFactory.png")); + public EnumColor getColor() { + return color; + } - public int processes; - public ResourceLocation guiLocation; + public boolean isObtainable() { + return this != CREATIVE; + } - public static FactoryTier getFromName(String tierName) - { - for(FactoryTier tier : values()) - { - if(tierName.contains(tier.getBaseTier().getName())) - { - return tier; - } - } + private String name; + private EnumColor color; - Mekanism.logger.error("Invalid tier identifier when retrieving with name."); - return BASIC; - } - - public BaseTier getBaseTier() - { - return BaseTier.values()[ordinal()]; - } + private BaseTier(String s, EnumColor c) { + name = s; + color = c; + } + } - private FactoryTier(int process, ResourceLocation gui) - { - processes = process; - guiLocation = gui; - } - } + public static enum EnergyCubeTier implements ITier { + BASIC(2000000, 800), + ADVANCED(8000000, 3200), + ELITE(32000000, 12800), + ULTIMATE(128000000, 51200), + CREATIVE(Double.MAX_VALUE, Double.MAX_VALUE); - public static enum CableTier implements ITier - { - BASIC(3200, TransmitterType.UNIVERSAL_CABLE_BASIC), - ADVANCED(12800, TransmitterType.UNIVERSAL_CABLE_ADVANCED), - ELITE(64000, TransmitterType.UNIVERSAL_CABLE_ELITE), - ULTIMATE(320000, TransmitterType.UNIVERSAL_CABLE_ULTIMATE); + public double maxEnergy; + private double baseMaxEnergy; - public int cableCapacity; - private int baseCapacity; - - public TransmitterType type; + public double output; + private double baseOutput; - private CableTier(int capacity, TransmitterType transmitterType) - { - baseCapacity = cableCapacity = capacity; - - type = transmitterType; - } - - @Override - public BaseTier getBaseTier() - { - return BaseTier.values()[ordinal()]; - } + private EnergyCubeTier(double max, double out) { + baseMaxEnergy = maxEnergy = max; + baseOutput = output = out; + } - @Override - public void loadConfig() - { - cableCapacity = Mekanism.configuration.get("tier", getBaseTier().getName() + "CableCapacity", baseCapacity).getInt(); - } + public static EnergyCubeTier getFromName(String tierName) { + for (EnergyCubeTier tier : values()) { + if (tierName.contains(tier.getBaseTier().getName())) { + return tier; + } + } - @Override - public void readConfig(ByteBuf dataStream) - { - cableCapacity = dataStream.readInt(); - } + return BASIC; + } - @Override - public void writeConfig(ByteBuf dataStream) - { - dataStream.writeInt(cableCapacity); - } - - public static CableTier get(BaseTier tier) - { - for(CableTier transmitter : values()) - { - if(transmitter.getBaseTier() == tier) - { - return transmitter; - } - } - - return BASIC; - } - } + @Override + public void loadConfig() { + if (this != CREATIVE) { + maxEnergy = Mekanism.configuration + .get( + "tier", + getBaseTier().getName() + "EnergyCubeMaxEnergy", + baseMaxEnergy + ) + .getDouble(); + output = Mekanism.configuration + .get( + "tier", + getBaseTier().getName() + "EnergyCubeOutput", + baseOutput + ) + .getDouble(); + } + } - public static enum PipeTier implements ITier - { - BASIC(1000, 100, TransmitterType.MECHANICAL_PIPE_BASIC), - ADVANCED(4000, 400, TransmitterType.MECHANICAL_PIPE_ADVANCED), - ELITE(16000, 1600, TransmitterType.MECHANICAL_PIPE_ELITE), - ULTIMATE(64000, 6400, TransmitterType.MECHANICAL_PIPE_ULTIMATE); + @Override + public void readConfig(ByteBuf dataStream) { + if (this != CREATIVE) { + maxEnergy = dataStream.readDouble(); + output = dataStream.readDouble(); + } + } - public int pipeCapacity; - private int baseCapacity; - - public int pipePullAmount; - private int basePull; - - public TransmitterType type; + @Override + public void writeConfig(ByteBuf dataStream) { + if (this != CREATIVE) { + dataStream.writeDouble(maxEnergy); + dataStream.writeDouble(output); + } + } - private PipeTier(int capacity, int pullAmount, TransmitterType transmitterType) - { - baseCapacity = pipeCapacity = capacity; - basePull = pipePullAmount = pullAmount; - - type = transmitterType; - } + @Override + public BaseTier getBaseTier() { + return BaseTier.values()[ordinal()]; + } + } - @Override - public BaseTier getBaseTier() - { - return BaseTier.values()[ordinal()]; - } + public static enum InductionCellTier implements ITier { + BASIC(1E9D), + ADVANCED(8E9D), + ELITE(64E9D), + ULTIMATE(512E9D); - @Override - public void loadConfig() - { - pipeCapacity = Mekanism.configuration.get("tier", getBaseTier().getName() + "PipeCapacity", baseCapacity).getInt(); - pipePullAmount = Mekanism.configuration.get("tier", getBaseTier().getName() + "PipePullAmount", basePull).getInt(); - } + public double maxEnergy; + private double baseMaxEnergy; - @Override - public void readConfig(ByteBuf dataStream) - { - pipeCapacity = dataStream.readInt(); - pipePullAmount = dataStream.readInt(); - } + private InductionCellTier(double max) { + baseMaxEnergy = maxEnergy = max; + } - @Override - public void writeConfig(ByteBuf dataStream) - { - dataStream.writeInt(pipeCapacity); - dataStream.writeInt(pipePullAmount); - } - - public static PipeTier get(BaseTier tier) - { - for(PipeTier transmitter : values()) - { - if(transmitter.getBaseTier() == tier) - { - return transmitter; - } - } - - return BASIC; - } - } + @Override + public BaseTier getBaseTier() { + return BaseTier.values()[ordinal()]; + } - public static enum TubeTier implements ITier - { - BASIC(256, 64, TransmitterType.PRESSURIZED_TUBE_BASIC), - ADVANCED(1024, 256, TransmitterType.PRESSURIZED_TUBE_ADVANCED), - ELITE(4096, 1024, TransmitterType.PRESSURIZED_TUBE_ELITE), - ULTIMATE(16384, 4096, TransmitterType.PRESSURIZED_TUBE_ULTIMATE); + @Override + public void loadConfig() { + maxEnergy = Mekanism.configuration + .get( + "tier", + getBaseTier().getName() + "InductionCellMaxEnergy", + baseMaxEnergy + ) + .getDouble(); + } - public int tubeCapacity; - private int baseCapacity; - - public int tubePullAmount; - private int basePull; - - public TransmitterType type; + @Override + public void readConfig(ByteBuf dataStream) { + maxEnergy = dataStream.readDouble(); + } - private TubeTier(int capacity, int pullAmount, TransmitterType transmitterType) - { - baseCapacity = tubeCapacity = capacity; - basePull = tubePullAmount = pullAmount; - - type = transmitterType; - } + @Override + public void writeConfig(ByteBuf dataStream) { + dataStream.writeDouble(maxEnergy); + } + } - @Override - public BaseTier getBaseTier() - { - return BaseTier.values()[ordinal()]; - } + public static enum InductionProviderTier implements ITier { + BASIC(64000), + ADVANCED(512000), + ELITE(4096000), + ULTIMATE(32768000); - @Override - public void loadConfig() - { - tubeCapacity = Mekanism.configuration.get("tier", getBaseTier().getName() + "TubeCapacity", baseCapacity).getInt(); - tubePullAmount = Mekanism.configuration.get("tier", getBaseTier().getName() + "TubePullAmount", basePull).getInt(); - } + public double output; + private double baseOutput; - @Override - public void readConfig(ByteBuf dataStream) - { - tubeCapacity = dataStream.readInt(); - tubePullAmount = dataStream.readInt(); - } + private InductionProviderTier(double out) { + baseOutput = output = out; + } - @Override - public void writeConfig(ByteBuf dataStream) - { - dataStream.writeInt(tubeCapacity); - dataStream.writeInt(tubePullAmount); - } - - public static TubeTier get(BaseTier tier) - { - for(TubeTier transmitter : values()) - { - if(transmitter.getBaseTier() == tier) - { - return transmitter; - } - } - - return BASIC; - } - } - - public static enum TransporterTier implements ITier - { - BASIC(1, 5, TransmitterType.LOGISTICAL_TRANSPORTER_BASIC), - ADVANCED(16, 10, TransmitterType.LOGISTICAL_TRANSPORTER_ADVANCED), - ELITE(32, 20, TransmitterType.LOGISTICAL_TRANSPORTER_ELITE), - ULTIMATE(64, 50, TransmitterType.LOGISTICAL_TRANSPORTER_ULTIMATE); + @Override + public BaseTier getBaseTier() { + return BaseTier.values()[ordinal()]; + } - public int pullAmount; - private int basePull; - - public int speed; - private int baseSpeed; - - public TransmitterType type; + @Override + public void loadConfig() { + output = Mekanism.configuration + .get( + "tier", + getBaseTier().getName() + "InductionProviderOutput", + baseOutput + ) + .getDouble(); + } - private TransporterTier(int pull, int s, TransmitterType transmitterType) - { - basePull = pullAmount = pull; - baseSpeed = speed = s; - - type = transmitterType; - } + @Override + public void readConfig(ByteBuf dataStream) { + output = dataStream.readDouble(); + } - @Override - public BaseTier getBaseTier() - { - return BaseTier.values()[ordinal()]; - } + @Override + public void writeConfig(ByteBuf dataStream) { + dataStream.writeDouble(output); + } + } - @Override - public void loadConfig() - { - pullAmount = Mekanism.configuration.get("tier", getBaseTier().getName() + "TransporterPullAmount", basePull).getInt(); - speed = Mekanism.configuration.get("tier", getBaseTier().getName() + "TransporterSpeed", baseSpeed).getInt(); - } + public static enum FactoryTier { + BASIC(3, new ResourceLocation("mekanism", "gui/factory/GuiBasicFactory.png")), + ADVANCED( + 5, new ResourceLocation("mekanism", "gui/factory/GuiAdvancedFactory.png") + ), + ELITE(7, new ResourceLocation("mekanism", "gui/factory/GuiEliteFactory.png")); - @Override - public void readConfig(ByteBuf dataStream) - { - pullAmount = dataStream.readInt(); - speed = dataStream.readInt(); - } + public int processes; + public ResourceLocation guiLocation; - @Override - public void writeConfig(ByteBuf dataStream) - { - dataStream.writeInt(pullAmount); - dataStream.writeInt(speed); - } - - public static TransporterTier get(BaseTier tier) - { - for(TransporterTier transmitter : values()) - { - if(transmitter.getBaseTier() == tier) - { - return transmitter; - } - } - - return BASIC; - } - } - - public static enum ConductorTier implements ITier - { - BASIC(5, 1, 10, new ColourRGBA(0.2, 0.2, 0.2, 1), TransmitterType.THERMODYNAMIC_CONDUCTOR_BASIC), - ADVANCED(5, 1, 400, new ColourRGBA(0.2, 0.2, 0.2, 1), TransmitterType.THERMODYNAMIC_CONDUCTOR_ADVANCED), - ELITE(5, 1, 8000, new ColourRGBA(0.2, 0.2, 0.2, 1), TransmitterType.THERMODYNAMIC_CONDUCTOR_ELITE), - ULTIMATE(5, 1, 100000, new ColourRGBA(0.2, 0.2, 0.2, 1), TransmitterType.THERMODYNAMIC_CONDUCTOR_ULTIMATE); + public static FactoryTier getFromName(String tierName) { + for (FactoryTier tier : values()) { + if (tierName.contains(tier.getBaseTier().getName())) { + return tier; + } + } - public double inverseConduction; - private double baseConduction; - - public double inverseHeatCapacity; - private double baseHeatCapacity; - - public double inverseConductionInsulation; - private double baseConductionInsulation; - - public ColourRGBA baseColour; - - public TransmitterType type; + Mekanism.logger.error("Invalid tier identifier when retrieving with name."); + return BASIC; + } - private ConductorTier(double inversek, double inverseC, double insulationInversek, ColourRGBA colour, TransmitterType transmitterType) - { - baseConduction = inverseConduction = inversek; - baseHeatCapacity = inverseHeatCapacity = inverseC; - baseConductionInsulation = inverseConductionInsulation = insulationInversek; - - baseColour = colour; - - type = transmitterType; - } + public BaseTier getBaseTier() { + return BaseTier.values()[ordinal()]; + } - @Override - public BaseTier getBaseTier() - { - return BaseTier.values()[ordinal()]; - } + private FactoryTier(int process, ResourceLocation gui) { + processes = process; + guiLocation = gui; + } + } - @Override - public void loadConfig() - { - inverseConduction = Mekanism.configuration.get("tier", getBaseTier().getName() + "ConductorInverseConduction", baseConduction).getDouble(); - inverseHeatCapacity = Mekanism.configuration.get("tier", getBaseTier().getName() + "ConductorHeatCapacity", baseHeatCapacity).getDouble(); - inverseConductionInsulation = Mekanism.configuration.get("tier", getBaseTier().getName() + "ConductorConductionInsulation", baseConductionInsulation).getDouble(); - } + public static enum CableTier implements ITier { + BASIC(3200, TransmitterType.UNIVERSAL_CABLE_BASIC), + ADVANCED(12800, TransmitterType.UNIVERSAL_CABLE_ADVANCED), + ELITE(64000, TransmitterType.UNIVERSAL_CABLE_ELITE), + ULTIMATE(320000, TransmitterType.UNIVERSAL_CABLE_ULTIMATE); - @Override - public void readConfig(ByteBuf dataStream) - { - inverseConduction = dataStream.readDouble(); - inverseHeatCapacity = dataStream.readDouble(); - inverseConductionInsulation = dataStream.readDouble(); - } + public int cableCapacity; + private int baseCapacity; - @Override - public void writeConfig(ByteBuf dataStream) - { - dataStream.writeDouble(inverseConduction); - dataStream.writeDouble(inverseHeatCapacity); - dataStream.writeDouble(inverseConductionInsulation); - } - - public static ConductorTier get(BaseTier tier) - { - for(ConductorTier transmitter : values()) - { - if(transmitter.getBaseTier() == tier) - { - return transmitter; - } - } - - return BASIC; - } - } - - public static enum FluidTankTier implements ITier - { - BASIC(14000, 400), - ADVANCED(28000, 800), - ELITE(56000, 1600), - ULTIMATE(112000, 3200); + public TransmitterType type; - public int storage; - private int baseStorage; - - public int output; - private int baseOutput; + private CableTier(int capacity, TransmitterType transmitterType) { + baseCapacity = cableCapacity = capacity; - private FluidTankTier(int s, int o) - { - baseStorage = storage = s; - baseOutput = output = o; - } - - @Override - public BaseTier getBaseTier() - { - return BaseTier.values()[ordinal()]; - } + type = transmitterType; + } - @Override - public void loadConfig() - { - storage = Mekanism.configuration.get("tier", getBaseTier().getName() + "FluidTankStorage", baseStorage).getInt(); - output = Mekanism.configuration.get("tier", getBaseTier().getName() + "FluidTankOutput", baseOutput).getInt(); - } + @Override + public BaseTier getBaseTier() { + return BaseTier.values()[ordinal()]; + } - @Override - public void readConfig(ByteBuf dataStream) - { - storage = dataStream.readInt(); - output = dataStream.readInt(); - } + @Override + public void loadConfig() { + cableCapacity + = Mekanism.configuration + .get( + "tier", getBaseTier().getName() + "CableCapacity", baseCapacity + ) + .getInt(); + } - @Override - public void writeConfig(ByteBuf dataStream) - { - dataStream.writeInt(storage); - dataStream.writeInt(output); - } - } + @Override + public void readConfig(ByteBuf dataStream) { + cableCapacity = dataStream.readInt(); + } - public static enum GasTankTier implements ITier - { - BASIC(64000, 256), - ADVANCED(128000, 512), - ELITE(256000, 1028), - ULTIMATE(512000, 2056); + @Override + public void writeConfig(ByteBuf dataStream) { + dataStream.writeInt(cableCapacity); + } - public int storage; - private int baseStorage; - - public int output; - private int baseOutput; + public static CableTier get(BaseTier tier) { + for (CableTier transmitter : values()) { + if (transmitter.getBaseTier() == tier) { + return transmitter; + } + } - private GasTankTier(int s, int o) - { - baseStorage = storage = s; - baseOutput = output = o; - } - - @Override - public BaseTier getBaseTier() - { - return BaseTier.values()[ordinal()]; - } + return BASIC; + } + } - @Override - public void loadConfig() - { - storage = Mekanism.configuration.get("tier", getBaseTier().getName() + "GasTankStorage", baseStorage).getInt(); - output = Mekanism.configuration.get("tier", getBaseTier().getName() + "GasTankOutput", baseOutput).getInt(); - } + public static enum PipeTier implements ITier { + BASIC(1000, 100, TransmitterType.MECHANICAL_PIPE_BASIC), + ADVANCED(4000, 400, TransmitterType.MECHANICAL_PIPE_ADVANCED), + ELITE(16000, 1600, TransmitterType.MECHANICAL_PIPE_ELITE), + ULTIMATE(64000, 6400, TransmitterType.MECHANICAL_PIPE_ULTIMATE); - @Override - public void readConfig(ByteBuf dataStream) - { - storage = dataStream.readInt(); - output = dataStream.readInt(); - } - - @Override - public void writeConfig(ByteBuf dataStream) - { - dataStream.writeInt(storage); - dataStream.writeInt(output); - } - } - - public static enum BinTier implements ITier - { - BASIC(4096), - ADVANCED(8192), - ELITE(32768), - ULTIMATE(262144); + public int pipeCapacity; + private int baseCapacity; - public int storage; - private int baseStorage; + public int pipePullAmount; + private int basePull; - private BinTier(int s) - { - baseStorage = storage = s; - } - - @Override - public BaseTier getBaseTier() - { - return BaseTier.values()[ordinal()]; - } + public TransmitterType type; - @Override - public void loadConfig() - { - storage = Mekanism.configuration.get("tier", getBaseTier().getName() + "BinStorage", baseStorage).getInt(); - } + private PipeTier(int capacity, int pullAmount, TransmitterType transmitterType) { + baseCapacity = pipeCapacity = capacity; + basePull = pipePullAmount = pullAmount; - @Override - public void readConfig(ByteBuf dataStream) - { - storage = dataStream.readInt(); - } - - @Override - public void writeConfig(ByteBuf dataStream) - { - dataStream.writeInt(storage); - } - } - - public static void init() - { - if(initiated) - { - return; - } - - for(Class c : Tier.class.getDeclaredClasses()) - { - if(c.isEnum()) - { - try { - for(Object obj : c.getEnumConstants()) - { - if(obj instanceof ITier) - { - tierTypes.add((ITier)obj); - } - } - } catch (Exception e) { - e.printStackTrace(); - } - } - } - - initiated = true; - } - - public static void loadConfig() - { - for(ITier tier : tierTypes) - { - tier.loadConfig(); - } - } - - public static void readConfig(ByteBuf dataStream) - { - for(ITier tier : tierTypes) - { - tier.readConfig(dataStream); - } - } - - public static void writeConfig(ByteBuf dataStream) - { - for(ITier tier : tierTypes) - { - tier.writeConfig(dataStream); - } - } - - public static interface ITier - { - public BaseTier getBaseTier(); - - public void loadConfig(); - - public void readConfig(ByteBuf dataStream); - - public void writeConfig(ByteBuf dataStream); - } + type = transmitterType; + } + + @Override + public BaseTier getBaseTier() { + return BaseTier.values()[ordinal()]; + } + + @Override + public void loadConfig() { + pipeCapacity + = Mekanism.configuration + .get("tier", getBaseTier().getName() + "PipeCapacity", baseCapacity) + .getInt(); + pipePullAmount + = Mekanism.configuration + .get("tier", getBaseTier().getName() + "PipePullAmount", basePull) + .getInt(); + } + + @Override + public void readConfig(ByteBuf dataStream) { + pipeCapacity = dataStream.readInt(); + pipePullAmount = dataStream.readInt(); + } + + @Override + public void writeConfig(ByteBuf dataStream) { + dataStream.writeInt(pipeCapacity); + dataStream.writeInt(pipePullAmount); + } + + public static PipeTier get(BaseTier tier) { + for (PipeTier transmitter : values()) { + if (transmitter.getBaseTier() == tier) { + return transmitter; + } + } + + return BASIC; + } + } + + public static enum TubeTier implements ITier { + BASIC(256, 64, TransmitterType.PRESSURIZED_TUBE_BASIC), + ADVANCED(1024, 256, TransmitterType.PRESSURIZED_TUBE_ADVANCED), + ELITE(4096, 1024, TransmitterType.PRESSURIZED_TUBE_ELITE), + ULTIMATE(16384, 4096, TransmitterType.PRESSURIZED_TUBE_ULTIMATE); + + public int tubeCapacity; + private int baseCapacity; + + public int tubePullAmount; + private int basePull; + + public TransmitterType type; + + private TubeTier(int capacity, int pullAmount, TransmitterType transmitterType) { + baseCapacity = tubeCapacity = capacity; + basePull = tubePullAmount = pullAmount; + + type = transmitterType; + } + + @Override + public BaseTier getBaseTier() { + return BaseTier.values()[ordinal()]; + } + + @Override + public void loadConfig() { + tubeCapacity + = Mekanism.configuration + .get("tier", getBaseTier().getName() + "TubeCapacity", baseCapacity) + .getInt(); + tubePullAmount + = Mekanism.configuration + .get("tier", getBaseTier().getName() + "TubePullAmount", basePull) + .getInt(); + } + + @Override + public void readConfig(ByteBuf dataStream) { + tubeCapacity = dataStream.readInt(); + tubePullAmount = dataStream.readInt(); + } + + @Override + public void writeConfig(ByteBuf dataStream) { + dataStream.writeInt(tubeCapacity); + dataStream.writeInt(tubePullAmount); + } + + public static TubeTier get(BaseTier tier) { + for (TubeTier transmitter : values()) { + if (transmitter.getBaseTier() == tier) { + return transmitter; + } + } + + return BASIC; + } + } + + public static enum TransporterTier implements ITier { + BASIC(1, 5, TransmitterType.LOGISTICAL_TRANSPORTER_BASIC), + ADVANCED(16, 10, TransmitterType.LOGISTICAL_TRANSPORTER_ADVANCED), + ELITE(32, 20, TransmitterType.LOGISTICAL_TRANSPORTER_ELITE), + ULTIMATE(64, 50, TransmitterType.LOGISTICAL_TRANSPORTER_ULTIMATE); + + public int pullAmount; + private int basePull; + + public int speed; + private int baseSpeed; + + public TransmitterType type; + + private TransporterTier(int pull, int s, TransmitterType transmitterType) { + basePull = pullAmount = pull; + baseSpeed = speed = s; + + type = transmitterType; + } + + @Override + public BaseTier getBaseTier() { + return BaseTier.values()[ordinal()]; + } + + @Override + public void loadConfig() { + pullAmount = Mekanism.configuration + .get( + "tier", + getBaseTier().getName() + "TransporterPullAmount", + basePull + ) + .getInt(); + speed + = Mekanism.configuration + .get( + "tier", getBaseTier().getName() + "TransporterSpeed", baseSpeed + ) + .getInt(); + } + + @Override + public void readConfig(ByteBuf dataStream) { + pullAmount = dataStream.readInt(); + speed = dataStream.readInt(); + } + + @Override + public void writeConfig(ByteBuf dataStream) { + dataStream.writeInt(pullAmount); + dataStream.writeInt(speed); + } + + public static TransporterTier get(BaseTier tier) { + for (TransporterTier transmitter : values()) { + if (transmitter.getBaseTier() == tier) { + return transmitter; + } + } + + return BASIC; + } + } + + public static enum ConductorTier implements ITier { + BASIC( + 5, + 1, + 10, + new ColourRGBA(0.2, 0.2, 0.2, 1), + TransmitterType.THERMODYNAMIC_CONDUCTOR_BASIC + ), + ADVANCED( + 5, + 1, + 400, + new ColourRGBA(0.2, 0.2, 0.2, 1), + TransmitterType.THERMODYNAMIC_CONDUCTOR_ADVANCED + ), + ELITE( + 5, + 1, + 8000, + new ColourRGBA(0.2, 0.2, 0.2, 1), + TransmitterType.THERMODYNAMIC_CONDUCTOR_ELITE + ), + ULTIMATE( + 5, + 1, + 100000, + new ColourRGBA(0.2, 0.2, 0.2, 1), + TransmitterType.THERMODYNAMIC_CONDUCTOR_ULTIMATE + ); + + public double inverseConduction; + private double baseConduction; + + public double inverseHeatCapacity; + private double baseHeatCapacity; + + public double inverseConductionInsulation; + private double baseConductionInsulation; + + public ColourRGBA baseColour; + + public TransmitterType type; + + private ConductorTier( + double inversek, + double inverseC, + double insulationInversek, + ColourRGBA colour, + TransmitterType transmitterType + ) { + baseConduction = inverseConduction = inversek; + baseHeatCapacity = inverseHeatCapacity = inverseC; + baseConductionInsulation = inverseConductionInsulation = insulationInversek; + + baseColour = colour; + + type = transmitterType; + } + + @Override + public BaseTier getBaseTier() { + return BaseTier.values()[ordinal()]; + } + + @Override + public void loadConfig() { + inverseConduction + = Mekanism.configuration + .get( + "tier", + getBaseTier().getName() + "ConductorInverseConduction", + baseConduction + ) + .getDouble(); + inverseHeatCapacity + = Mekanism.configuration + .get( + "tier", + getBaseTier().getName() + "ConductorHeatCapacity", + baseHeatCapacity + ) + .getDouble(); + inverseConductionInsulation + = Mekanism.configuration + .get( + "tier", + getBaseTier().getName() + "ConductorConductionInsulation", + baseConductionInsulation + ) + .getDouble(); + } + + @Override + public void readConfig(ByteBuf dataStream) { + inverseConduction = dataStream.readDouble(); + inverseHeatCapacity = dataStream.readDouble(); + inverseConductionInsulation = dataStream.readDouble(); + } + + @Override + public void writeConfig(ByteBuf dataStream) { + dataStream.writeDouble(inverseConduction); + dataStream.writeDouble(inverseHeatCapacity); + dataStream.writeDouble(inverseConductionInsulation); + } + + public static ConductorTier get(BaseTier tier) { + for (ConductorTier transmitter : values()) { + if (transmitter.getBaseTier() == tier) { + return transmitter; + } + } + + return BASIC; + } + } + + public static enum FluidTankTier implements ITier { + BASIC(14000, 400), + ADVANCED(28000, 800), + ELITE(56000, 1600), + ULTIMATE(112000, 3200); + + public int storage; + private int baseStorage; + + public int output; + private int baseOutput; + + private FluidTankTier(int s, int o) { + baseStorage = storage = s; + baseOutput = output = o; + } + + @Override + public BaseTier getBaseTier() { + return BaseTier.values()[ordinal()]; + } + + @Override + public void loadConfig() { + storage = Mekanism.configuration + .get( + "tier", + getBaseTier().getName() + "FluidTankStorage", + baseStorage + ) + .getInt(); + output + = Mekanism.configuration + .get( + "tier", getBaseTier().getName() + "FluidTankOutput", baseOutput + ) + .getInt(); + } + + @Override + public void readConfig(ByteBuf dataStream) { + storage = dataStream.readInt(); + output = dataStream.readInt(); + } + + @Override + public void writeConfig(ByteBuf dataStream) { + dataStream.writeInt(storage); + dataStream.writeInt(output); + } + } + + public static enum GasTankTier implements ITier { + BASIC(64000, 256), + ADVANCED(128000, 512), + ELITE(256000, 1028), + ULTIMATE(512000, 2056); + + public int storage; + private int baseStorage; + + public int output; + private int baseOutput; + + private GasTankTier(int s, int o) { + baseStorage = storage = s; + baseOutput = output = o; + } + + @Override + public BaseTier getBaseTier() { + return BaseTier.values()[ordinal()]; + } + + @Override + public void loadConfig() { + storage + = Mekanism.configuration + .get( + "tier", getBaseTier().getName() + "GasTankStorage", baseStorage + ) + .getInt(); + output + = Mekanism.configuration + .get("tier", getBaseTier().getName() + "GasTankOutput", baseOutput) + .getInt(); + } + + @Override + public void readConfig(ByteBuf dataStream) { + storage = dataStream.readInt(); + output = dataStream.readInt(); + } + + @Override + public void writeConfig(ByteBuf dataStream) { + dataStream.writeInt(storage); + dataStream.writeInt(output); + } + } + + public static enum BinTier implements ITier { + BASIC(4096), + ADVANCED(8192), + ELITE(32768), + ULTIMATE(262144); + + public int storage; + private int baseStorage; + + private BinTier(int s) { + baseStorage = storage = s; + } + + @Override + public BaseTier getBaseTier() { + return BaseTier.values()[ordinal()]; + } + + @Override + public void loadConfig() { + storage + = Mekanism.configuration + .get("tier", getBaseTier().getName() + "BinStorage", baseStorage) + .getInt(); + } + + @Override + public void readConfig(ByteBuf dataStream) { + storage = dataStream.readInt(); + } + + @Override + public void writeConfig(ByteBuf dataStream) { + dataStream.writeInt(storage); + } + } + + public static void init() { + if (initiated) { + return; + } + + for (Class c : Tier.class.getDeclaredClasses()) { + if (c.isEnum()) { + try { + for (Object obj : c.getEnumConstants()) { + if (obj instanceof ITier) { + tierTypes.add((ITier) obj); + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + initiated = true; + } + + public static void loadConfig() { + for (ITier tier : tierTypes) { + tier.loadConfig(); + } + } + + public static void readConfig(ByteBuf dataStream) { + for (ITier tier : tierTypes) { + tier.readConfig(dataStream); + } + } + + public static void writeConfig(ByteBuf dataStream) { + for (ITier tier : tierTypes) { + tier.writeConfig(dataStream); + } + } + + public static interface ITier { + public BaseTier getBaseTier(); + + public void loadConfig(); + + public void readConfig(ByteBuf dataStream); + + public void writeConfig(ByteBuf dataStream); + } } diff --git a/src/main/java/mekanism/common/Upgrade.java b/src/main/java/mekanism/common/Upgrade.java index cd8f18689..597a5d1ca 100644 --- a/src/main/java/mekanism/common/Upgrade.java +++ b/src/main/java/mekanism/common/Upgrade.java @@ -15,162 +15,143 @@ import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.Constants.NBT; -public enum Upgrade -{ - SPEED("speed", 8, EnumColor.RED), - ENERGY("energy", 8, EnumColor.BRIGHT_GREEN), - FILTER("filter", 1, EnumColor.DARK_AQUA), - GAS("gas", 8, EnumColor.YELLOW), - MUFFLING("muffling", 4, EnumColor.DARK_GREY); - - private String name; - private int maxStack; - private EnumColor color; - - private Upgrade(String s, int max, EnumColor c) - { - name = s; - maxStack = max; - color = c; - } - - public String getName() - { - return LangUtils.localize("upgrade." + name); - } - - public String getDescription() - { - return LangUtils.localize("upgrade." + name + ".desc"); - } - - public int getMax() - { - return maxStack; - } - - public EnumColor getColor() - { - return color; - } - - public boolean canMultiply() - { - return getMax() > 1; - } - - public ItemStack getStack() - { - switch(this) - { - case SPEED: - return new ItemStack(MekanismItems.SpeedUpgrade); - case ENERGY: - return new ItemStack(MekanismItems.EnergyUpgrade); - case FILTER: - return new ItemStack(MekanismItems.FilterUpgrade); - case MUFFLING: - return new ItemStack(MekanismItems.MufflingUpgrade); - case GAS: - return new ItemStack(MekanismItems.GasUpgrade); - } - - return null; - } - - public List getInfo(TileEntity tile) - { - List ret = new ArrayList(); - - if(tile instanceof IUpgradeTile) - { - if(tile instanceof IUpgradeInfoHandler) - { - return ((IUpgradeInfoHandler)tile).getInfo(this); - } - else { - ret = getMultScaledInfo((IUpgradeTile)tile); - } - } - - return ret; - } - - public List getMultScaledInfo(IUpgradeTile tile) - { - List ret = new ArrayList(); - - if(canMultiply()) - { - double effect = Math.pow(general.maxUpgradeMultiplier, (float)tile.getComponent().getUpgrades(this)/(float)getMax()); - - ret.add(LangUtils.localize("gui.upgrades.effect") + ": " + (Math.round(effect*100)/100F) + "x"); - } - - return ret; - } - - public List getExpScaledInfo(IUpgradeTile tile) - { - List ret = new ArrayList(); - - if(canMultiply()) - { - double effect = Math.pow(2, (float)tile.getComponent().getUpgrades(this)); - - ret.add(LangUtils.localize("gui.upgrades.effect") + ": " + effect + "x"); - } - - return ret; - } - - public static Map buildMap(NBTTagCompound nbtTags) - { - Map upgrades = new HashMap(); - - if(nbtTags != null) - { - if(nbtTags.hasKey("upgrades")) - { - NBTTagList list = nbtTags.getTagList("upgrades", NBT.TAG_COMPOUND); - - for(int tagCount = 0; tagCount < list.tagCount(); tagCount++) - { - NBTTagCompound compound = list.getCompoundTagAt(tagCount); - - Upgrade upgrade = Upgrade.values()[compound.getInteger("type")]; - upgrades.put(upgrade, compound.getInteger("amount")); - } - } - } - - return upgrades; - } - - public static void saveMap(Map upgrades, NBTTagCompound nbtTags) - { - NBTTagList list = new NBTTagList(); - - for(Map.Entry entry : upgrades.entrySet()) - { - list.appendTag(getTagFor(entry.getKey(), entry.getValue())); - } - - nbtTags.setTag("upgrades", list); - } - - public static NBTTagCompound getTagFor(Upgrade upgrade, int amount) - { - NBTTagCompound compound = new NBTTagCompound(); - - compound.setInteger("type", upgrade.ordinal()); - compound.setInteger("amount", amount); - - return compound; - } - - public static interface IUpgradeInfoHandler - { - public List getInfo(Upgrade upgrade); - } +public enum Upgrade { + SPEED("speed", 8, EnumColor.RED), + ENERGY("energy", 8, EnumColor.BRIGHT_GREEN), + FILTER("filter", 1, EnumColor.DARK_AQUA), + GAS("gas", 8, EnumColor.YELLOW), + MUFFLING("muffling", 4, EnumColor.DARK_GREY); + + private String name; + private int maxStack; + private EnumColor color; + + private Upgrade(String s, int max, EnumColor c) { + name = s; + maxStack = max; + color = c; + } + + public String getName() { + return LangUtils.localize("upgrade." + name); + } + + public String getDescription() { + return LangUtils.localize("upgrade." + name + ".desc"); + } + + public int getMax() { + return maxStack; + } + + public EnumColor getColor() { + return color; + } + + public boolean canMultiply() { + return getMax() > 1; + } + + public ItemStack getStack() { + switch (this) { + case SPEED: + return new ItemStack(MekanismItems.SpeedUpgrade); + case ENERGY: + return new ItemStack(MekanismItems.EnergyUpgrade); + case FILTER: + return new ItemStack(MekanismItems.FilterUpgrade); + case MUFFLING: + return new ItemStack(MekanismItems.MufflingUpgrade); + case GAS: + return new ItemStack(MekanismItems.GasUpgrade); + } + + return null; + } + + public List getInfo(TileEntity tile) { + List ret = new ArrayList(); + + if (tile instanceof IUpgradeTile) { + if (tile instanceof IUpgradeInfoHandler) { + return ((IUpgradeInfoHandler) tile).getInfo(this); + } else { + ret = getMultScaledInfo((IUpgradeTile) tile); + } + } + + return ret; + } + + public List getMultScaledInfo(IUpgradeTile tile) { + List ret = new ArrayList(); + + if (canMultiply()) { + double effect = Math.pow( + general.maxUpgradeMultiplier, + (float) tile.getComponent().getUpgrades(this) / (float) getMax() + ); + + ret.add( + LangUtils.localize("gui.upgrades.effect") + ": " + + (Math.round(effect * 100) / 100F) + "x" + ); + } + + return ret; + } + + public List getExpScaledInfo(IUpgradeTile tile) { + List ret = new ArrayList(); + + if (canMultiply()) { + double effect = Math.pow(2, (float) tile.getComponent().getUpgrades(this)); + + ret.add(LangUtils.localize("gui.upgrades.effect") + ": " + effect + "x"); + } + + return ret; + } + + public static Map buildMap(NBTTagCompound nbtTags) { + Map upgrades = new HashMap(); + + if (nbtTags != null) { + if (nbtTags.hasKey("upgrades")) { + NBTTagList list = nbtTags.getTagList("upgrades", NBT.TAG_COMPOUND); + + for (int tagCount = 0; tagCount < list.tagCount(); tagCount++) { + NBTTagCompound compound = list.getCompoundTagAt(tagCount); + + Upgrade upgrade = Upgrade.values()[compound.getInteger("type")]; + upgrades.put(upgrade, compound.getInteger("amount")); + } + } + } + + return upgrades; + } + + public static void saveMap(Map upgrades, NBTTagCompound nbtTags) { + NBTTagList list = new NBTTagList(); + + for (Map.Entry entry : upgrades.entrySet()) { + list.appendTag(getTagFor(entry.getKey(), entry.getValue())); + } + + nbtTags.setTag("upgrades", list); + } + + public static NBTTagCompound getTagFor(Upgrade upgrade, int amount) { + NBTTagCompound compound = new NBTTagCompound(); + + compound.setInteger("type", upgrade.ordinal()); + compound.setInteger("amount", amount); + + return compound; + } + + public static interface IUpgradeInfoHandler { + public List getInfo(Upgrade upgrade); + } } \ No newline at end of file diff --git a/src/main/java/mekanism/common/asm/LoadingHook.java b/src/main/java/mekanism/common/asm/LoadingHook.java index f2807c9cf..ef88059e9 100644 --- a/src/main/java/mekanism/common/asm/LoadingHook.java +++ b/src/main/java/mekanism/common/asm/LoadingHook.java @@ -5,41 +5,31 @@ import java.util.Map; import codechicken.core.launch.DepLoader; import cpw.mods.fml.relauncher.IFMLLoadingPlugin; -public class LoadingHook implements IFMLLoadingPlugin -{ - public LoadingHook() - { - DepLoader.load(); - } +public class LoadingHook implements IFMLLoadingPlugin { + public LoadingHook() { + DepLoader.load(); + } - public String[] getLibraryRequestClass() - { - return null; - } + public String[] getLibraryRequestClass() { + return null; + } - public String[] getASMTransformerClass() - { - return null; - } + public String[] getASMTransformerClass() { + return null; + } - public String getModContainerClass() - { - return null; - } + public String getModContainerClass() { + return null; + } - public String getSetupClass() - { - return null; - } + public String getSetupClass() { + return null; + } - public void injectData(Map data) - { + public void injectData(Map data) {} - } - - @Override - public String getAccessTransformerClass() - { - return null; - } + @Override + public String getAccessTransformerClass() { + return null; + } } diff --git a/src/main/java/mekanism/common/base/EnergyAcceptorWrapper.java b/src/main/java/mekanism/common/base/EnergyAcceptorWrapper.java index 9fd36df50..d0105ce63 100644 --- a/src/main/java/mekanism/common/base/EnergyAcceptorWrapper.java +++ b/src/main/java/mekanism/common/base/EnergyAcceptorWrapper.java @@ -1,5 +1,6 @@ package mekanism.common.base; +import cofh.api.energy.IEnergyReceiver; import ic2.api.energy.tile.IEnergySink; import mekanism.api.Coord4D; import mekanism.api.MekanismConfig.general; @@ -8,211 +9,177 @@ import mekanism.common.util.CableUtils; import mekanism.common.util.MekanismUtils; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -import cofh.api.energy.IEnergyReceiver; -public abstract class EnergyAcceptorWrapper implements IStrictEnergyAcceptor -{ - public Coord4D coord; +public abstract class EnergyAcceptorWrapper implements IStrictEnergyAcceptor { + public Coord4D coord; - public static EnergyAcceptorWrapper get(TileEntity tileEntity) - { - if(tileEntity != null && tileEntity.getWorldObj() == null) - { - return null; - } - - EnergyAcceptorWrapper wrapper = null; - - if(tileEntity instanceof IStrictEnergyAcceptor) - { - wrapper = new MekanismAcceptor((IStrictEnergyAcceptor)tileEntity); - } - else if(MekanismUtils.useRF() && tileEntity instanceof IEnergyReceiver) - { - wrapper = new RFAcceptor((IEnergyReceiver)tileEntity); - } - else if(MekanismUtils.useIC2() && CableUtils.getIC2Tile(tileEntity) instanceof IEnergySink) - { - wrapper = new IC2Acceptor((IEnergySink)CableUtils.getIC2Tile(tileEntity)); - } - - if(wrapper != null) - { - wrapper.coord = Coord4D.get(tileEntity); - } - - return wrapper; - } + public static EnergyAcceptorWrapper get(TileEntity tileEntity) { + if (tileEntity != null && tileEntity.getWorldObj() == null) { + return null; + } - public abstract boolean needsEnergy(ForgeDirection side); + EnergyAcceptorWrapper wrapper = null; - public static class MekanismAcceptor extends EnergyAcceptorWrapper - { - private IStrictEnergyAcceptor acceptor; + if (tileEntity instanceof IStrictEnergyAcceptor) { + wrapper = new MekanismAcceptor((IStrictEnergyAcceptor) tileEntity); + } else if (MekanismUtils.useRF() && tileEntity instanceof IEnergyReceiver) { + wrapper = new RFAcceptor((IEnergyReceiver) tileEntity); + } else if (MekanismUtils.useIC2() && CableUtils.getIC2Tile(tileEntity) instanceof IEnergySink) { + wrapper = new IC2Acceptor((IEnergySink) CableUtils.getIC2Tile(tileEntity)); + } - public MekanismAcceptor(IStrictEnergyAcceptor mekAcceptor) - { - acceptor = mekAcceptor; - } + if (wrapper != null) { + wrapper.coord = Coord4D.get(tileEntity); + } - @Override - public double transferEnergyToAcceptor(ForgeDirection side, double amount) - { - return acceptor.transferEnergyToAcceptor(side, amount); - } + return wrapper; + } - @Override - public boolean canReceiveEnergy(ForgeDirection side) - { - return acceptor.canReceiveEnergy(side); - } + public abstract boolean needsEnergy(ForgeDirection side); - @Override - public double getEnergy() - { - return acceptor.getEnergy(); - } + public static class MekanismAcceptor extends EnergyAcceptorWrapper { + private IStrictEnergyAcceptor acceptor; - @Override - public void setEnergy(double energy) - { - acceptor.setEnergy(energy); - } + public MekanismAcceptor(IStrictEnergyAcceptor mekAcceptor) { + acceptor = mekAcceptor; + } - @Override - public double getMaxEnergy() - { - return acceptor.getMaxEnergy(); - } + @Override + public double transferEnergyToAcceptor(ForgeDirection side, double amount) { + return acceptor.transferEnergyToAcceptor(side, amount); + } - @Override - public boolean needsEnergy(ForgeDirection side) - { - return acceptor.getMaxEnergy() - acceptor.getEnergy() > 0; - } - } + @Override + public boolean canReceiveEnergy(ForgeDirection side) { + return acceptor.canReceiveEnergy(side); + } - public static class RFAcceptor extends EnergyAcceptorWrapper - { - private IEnergyReceiver acceptor; + @Override + public double getEnergy() { + return acceptor.getEnergy(); + } - public RFAcceptor(IEnergyReceiver rfAcceptor) - { - acceptor = rfAcceptor; - } + @Override + public void setEnergy(double energy) { + acceptor.setEnergy(energy); + } - @Override - public double transferEnergyToAcceptor(ForgeDirection side, double amount) - { - int transferred = acceptor.receiveEnergy(side, Math.min(Integer.MAX_VALUE, toRF(amount)), false); - - return fromRF(transferred); - } + @Override + public double getMaxEnergy() { + return acceptor.getMaxEnergy(); + } - @Override - public boolean canReceiveEnergy(ForgeDirection side) - { - return acceptor.canConnectEnergy(side); - } + @Override + public boolean needsEnergy(ForgeDirection side) { + return acceptor.getMaxEnergy() - acceptor.getEnergy() > 0; + } + } - @Override - public double getEnergy() - { - return fromRF(acceptor.getEnergyStored(ForgeDirection.UNKNOWN)); - } + public static class RFAcceptor extends EnergyAcceptorWrapper { + private IEnergyReceiver acceptor; - @Override - public void setEnergy(double energy) - { - int rfToSet = toRF(energy); - int amountToReceive = rfToSet - acceptor.getEnergyStored(ForgeDirection.UNKNOWN); - acceptor.receiveEnergy(ForgeDirection.UNKNOWN, amountToReceive, false); - } + public RFAcceptor(IEnergyReceiver rfAcceptor) { + acceptor = rfAcceptor; + } - @Override - public double getMaxEnergy() - { - return fromRF(acceptor.getMaxEnergyStored(ForgeDirection.UNKNOWN)); - } + @Override + public double transferEnergyToAcceptor(ForgeDirection side, double amount) { + int transferred = acceptor.receiveEnergy( + side, Math.min(Integer.MAX_VALUE, toRF(amount)), false + ); - @Override - public boolean needsEnergy(ForgeDirection side) - { - return acceptor.receiveEnergy(side, 1, true) > 0 || getEnergyNeeded(side) > 0; - } + return fromRF(transferred); + } - public int toRF(double joules) - { - return (int)Math.round(joules * general.TO_TE); - } + @Override + public boolean canReceiveEnergy(ForgeDirection side) { + return acceptor.canConnectEnergy(side); + } - public double fromRF(int rf) - { - return rf * general.FROM_TE; - } - - public int getEnergyNeeded(ForgeDirection side) - { - return acceptor.getMaxEnergyStored(side) - acceptor.getEnergyStored(side); - } - } + @Override + public double getEnergy() { + return fromRF(acceptor.getEnergyStored(ForgeDirection.UNKNOWN)); + } - public static class IC2Acceptor extends EnergyAcceptorWrapper - { - private IEnergySink acceptor; + @Override + public void setEnergy(double energy) { + int rfToSet = toRF(energy); + int amountToReceive + = rfToSet - acceptor.getEnergyStored(ForgeDirection.UNKNOWN); + acceptor.receiveEnergy(ForgeDirection.UNKNOWN, amountToReceive, false); + } - public IC2Acceptor(IEnergySink ic2Acceptor) - { - acceptor = ic2Acceptor; - } + @Override + public double getMaxEnergy() { + return fromRF(acceptor.getMaxEnergyStored(ForgeDirection.UNKNOWN)); + } - @Override - public double transferEnergyToAcceptor(ForgeDirection side, double amount) - { - double toTransfer = Math.min(Math.min(acceptor.getDemandedEnergy(), toEU(amount)), Integer.MAX_VALUE); - double rejects = acceptor.injectEnergy(side, toTransfer, 0); - - return fromEU(toTransfer - rejects); - } + @Override + public boolean needsEnergy(ForgeDirection side) { + return acceptor.receiveEnergy(side, 1, true) > 0 || getEnergyNeeded(side) > 0; + } - @Override - public boolean canReceiveEnergy(ForgeDirection side) - { - return acceptor.acceptsEnergyFrom(null, side); - } + public int toRF(double joules) { + return (int) Math.round(joules * general.TO_TE); + } - @Override - public double getEnergy() - { - return 0; - } + public double fromRF(int rf) { + return rf * general.FROM_TE; + } - @Override - public void setEnergy(double energy) - { - return; - } + public int getEnergyNeeded(ForgeDirection side) { + return acceptor.getMaxEnergyStored(side) - acceptor.getEnergyStored(side); + } + } - @Override - public double getMaxEnergy() - { - return 0; - } + public static class IC2Acceptor extends EnergyAcceptorWrapper { + private IEnergySink acceptor; - @Override - public boolean needsEnergy(ForgeDirection side) - { - return acceptor.getDemandedEnergy() > 0; - } + public IC2Acceptor(IEnergySink ic2Acceptor) { + acceptor = ic2Acceptor; + } - public double toEU(double joules) - { - return joules * general.TO_IC2; - } - - public double fromEU(double eu) - { - return eu * general.FROM_IC2; - } - } + @Override + public double transferEnergyToAcceptor(ForgeDirection side, double amount) { + double toTransfer = Math.min( + Math.min(acceptor.getDemandedEnergy(), toEU(amount)), Integer.MAX_VALUE + ); + double rejects = acceptor.injectEnergy(side, toTransfer, 0); + + return fromEU(toTransfer - rejects); + } + + @Override + public boolean canReceiveEnergy(ForgeDirection side) { + return acceptor.acceptsEnergyFrom(null, side); + } + + @Override + public double getEnergy() { + return 0; + } + + @Override + public void setEnergy(double energy) { + return; + } + + @Override + public double getMaxEnergy() { + return 0; + } + + @Override + public boolean needsEnergy(ForgeDirection side) { + return acceptor.getDemandedEnergy() > 0; + } + + public double toEU(double joules) { + return joules * general.TO_IC2; + } + + public double fromEU(double eu) { + return eu * general.FROM_IC2; + } + } } diff --git a/src/main/java/mekanism/common/base/IActiveState.java b/src/main/java/mekanism/common/base/IActiveState.java index 804e7f9c3..59989dee4 100644 --- a/src/main/java/mekanism/common/base/IActiveState.java +++ b/src/main/java/mekanism/common/base/IActiveState.java @@ -5,25 +5,25 @@ package mekanism.common.base; * @author aidancbrady * */ -public interface IActiveState -{ - /** - * Gets the active state as a boolean. - * @return active state - */ - public boolean getActive(); +public interface IActiveState { + /** + * Gets the active state as a boolean. + * @return active state + */ + public boolean getActive(); - /** - * Sets the active state to a new value. - * @param active - new active state - */ - public void setActive(boolean active); + /** + * Sets the active state to a new value. + * @param active - new active state + */ + public void setActive(boolean active); - /** - * Whether or not this block has a visual effect when it is on it's active state. Used for rendering. - * @return if the block has a visual effect in it's active state - */ - public boolean renderUpdate(); + /** + * Whether or not this block has a visual effect when it is on it's active state. Used + * for rendering. + * @return if the block has a visual effect in it's active state + */ + public boolean renderUpdate(); - public boolean lightUpdate(); + public boolean lightUpdate(); } diff --git a/src/main/java/mekanism/common/base/IAdvancedBoundingBlock.java b/src/main/java/mekanism/common/base/IAdvancedBoundingBlock.java index 45089a060..ead65f150 100644 --- a/src/main/java/mekanism/common/base/IAdvancedBoundingBlock.java +++ b/src/main/java/mekanism/common/base/IAdvancedBoundingBlock.java @@ -1,5 +1,8 @@ package mekanism.common.base; +import cofh.api.energy.IEnergyHandler; +import cpw.mods.fml.common.Optional.Interface; +import cpw.mods.fml.common.Optional.InterfaceList; import ic2.api.energy.tile.IEnergySink; import mekanism.api.Coord4D; import mekanism.api.IConfigCardAccess.ISpecialConfigData; @@ -10,24 +13,24 @@ import mekanism.common.security.ISecurityTile; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; -import cofh.api.energy.IEnergyHandler; -import cpw.mods.fml.common.Optional.Interface; -import cpw.mods.fml.common.Optional.InterfaceList; @InterfaceList({ - @Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2"), + @Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2") + , }) -public interface IAdvancedBoundingBlock extends IBoundingBlock, ISidedInventory, IEnergySink, IStrictEnergyAcceptor, IStrictEnergyStorage, IEnergyHandler, IComputerIntegration, ISpecialConfigData, ISecurityTile -{ - public int[] getBoundSlots(Coord4D location, int side); +public interface IAdvancedBoundingBlock + extends IBoundingBlock, ISidedInventory, IEnergySink, IStrictEnergyAcceptor, + IStrictEnergyStorage, IEnergyHandler, IComputerIntegration, + ISpecialConfigData, ISecurityTile { + public int[] getBoundSlots(Coord4D location, int side); - public boolean canBoundInsert(Coord4D location, int i, ItemStack itemstack); + public boolean canBoundInsert(Coord4D location, int i, ItemStack itemstack); - public boolean canBoundExtract(Coord4D location, int i, ItemStack itemstack, int j); - - public boolean canBoundReceiveEnergy(Coord4D location, ForgeDirection side); + public boolean canBoundExtract(Coord4D location, int i, ItemStack itemstack, int j); - public void onPower(); + public boolean canBoundReceiveEnergy(Coord4D location, ForgeDirection side); - public void onNoPower(); + public void onPower(); + + public void onNoPower(); } diff --git a/src/main/java/mekanism/common/base/IBlockCTM.java b/src/main/java/mekanism/common/base/IBlockCTM.java index c00d69f55..410bd71a0 100644 --- a/src/main/java/mekanism/common/base/IBlockCTM.java +++ b/src/main/java/mekanism/common/base/IBlockCTM.java @@ -3,9 +3,8 @@ package mekanism.common.base; import mekanism.common.CTMData; import net.minecraft.world.IBlockAccess; -public interface IBlockCTM -{ - public CTMData getCTMData(IBlockAccess world, int x, int y, int z, int meta); - - public boolean shouldRenderBlock(IBlockAccess world, int x, int y, int z, int meta); +public interface IBlockCTM { + public CTMData getCTMData(IBlockAccess world, int x, int y, int z, int meta); + + public boolean shouldRenderBlock(IBlockAccess world, int x, int y, int z, int meta); } diff --git a/src/main/java/mekanism/common/base/IBoundingBlock.java b/src/main/java/mekanism/common/base/IBoundingBlock.java index 4792305dc..d13e5e76e 100644 --- a/src/main/java/mekanism/common/base/IBoundingBlock.java +++ b/src/main/java/mekanism/common/base/IBoundingBlock.java @@ -1,20 +1,19 @@ package mekanism.common.base; /** - * Internal interface. A bounding block is not actually a 'bounding' block, it is really just a fake block that is - * used to mimic actual block bounds. + * Internal interface. A bounding block is not actually a 'bounding' block, it is really + * just a fake block that is used to mimic actual block bounds. * @author AidanBrady * */ -public interface IBoundingBlock -{ - /** - * Called when the main block is placed. - */ - public void onPlace(); +public interface IBoundingBlock { + /** + * Called when the main block is placed. + */ + public void onPlace(); - /** - * Called when any part of the structure is broken. - */ - public void onBreak(); + /** + * Called when any part of the structure is broken. + */ + public void onBreak(); } diff --git a/src/main/java/mekanism/common/base/IChunkLoadHandler.java b/src/main/java/mekanism/common/base/IChunkLoadHandler.java index 9964514b7..7ced149cc 100644 --- a/src/main/java/mekanism/common/base/IChunkLoadHandler.java +++ b/src/main/java/mekanism/common/base/IChunkLoadHandler.java @@ -1,6 +1,5 @@ package mekanism.common.base; -public interface IChunkLoadHandler -{ - public void onChunkLoad(); +public interface IChunkLoadHandler { + public void onChunkLoad(); } diff --git a/src/main/java/mekanism/common/base/IElectricMachine.java b/src/main/java/mekanism/common/base/IElectricMachine.java index f2dab9cc2..1a1baefb6 100644 --- a/src/main/java/mekanism/common/base/IElectricMachine.java +++ b/src/main/java/mekanism/common/base/IElectricMachine.java @@ -7,35 +7,36 @@ import mekanism.common.recipe.machines.MachineRecipe; import mekanism.common.recipe.outputs.MachineOutput; /** - * Internal interface containing methods that are shared by many core Mekanism machines. TODO: remove next minor MC - * version. + * Internal interface containing methods that are shared by many core Mekanism machines. + * TODO: remove next minor MC version. * @author AidanBrady * */ -public interface IElectricMachine, OUTPUT extends MachineOutput, RECIPE extends MachineRecipe> -{ - /** - * Update call for machines. Use instead of updateEntity() - it's called every tick. - */ - public void onUpdate(); +public interface IElectricMachine, OUTPUT + extends MachineOutput, RECIPE + extends MachineRecipe> { + /** + * Update call for machines. Use instead of updateEntity() - it's called every tick. + */ + public void onUpdate(); - /** - * Whether or not this machine can operate. - * @return can operate - */ - public boolean canOperate(RECIPE recipe); + /** + * Whether or not this machine can operate. + * @return can operate + */ + public boolean canOperate(RECIPE recipe); - /** - * Runs this machine's operation -- or smelts the item. - */ - public void operate(RECIPE recipe); + /** + * Runs this machine's operation -- or smelts the item. + */ + public void operate(RECIPE recipe); - /** - * Gets this machine's recipes. - */ - public Map getRecipes(); + /** + * Gets this machine's recipes. + */ + public Map getRecipes(); - public RECIPE getRecipe(); + public RECIPE getRecipe(); - public INPUT getInput(); + public INPUT getInput(); } diff --git a/src/main/java/mekanism/common/base/IEnergyCube.java b/src/main/java/mekanism/common/base/IEnergyCube.java index 3858a86db..1e6076973 100644 --- a/src/main/java/mekanism/common/base/IEnergyCube.java +++ b/src/main/java/mekanism/common/base/IEnergyCube.java @@ -8,19 +8,18 @@ import net.minecraft.item.ItemStack; * @author AidanBrady * */ -public interface IEnergyCube -{ - /** - * Gets the tier of this energy cube. - * @param itemstack - ItemStack to check - * @return tier - */ - public EnergyCubeTier getEnergyCubeTier(ItemStack itemstack); +public interface IEnergyCube { + /** + * Gets the tier of this energy cube. + * @param itemstack - ItemStack to check + * @return tier + */ + public EnergyCubeTier getEnergyCubeTier(ItemStack itemstack); - /** - * Sets the tier of this energy cube - * @param itemstack - ItemStack to set - * @param tier - tier to set - */ - public void setEnergyCubeTier(ItemStack itemstack, EnergyCubeTier tier); + /** + * Sets the tier of this energy cube + * @param itemstack - ItemStack to set + * @param tier - tier to set + */ + public void setEnergyCubeTier(ItemStack itemstack, EnergyCubeTier tier); } diff --git a/src/main/java/mekanism/common/base/IEnergyWrapper.java b/src/main/java/mekanism/common/base/IEnergyWrapper.java index e1df80f7e..55aacfea7 100644 --- a/src/main/java/mekanism/common/base/IEnergyWrapper.java +++ b/src/main/java/mekanism/common/base/IEnergyWrapper.java @@ -1,30 +1,30 @@ package mekanism.common.base; -import ic2.api.energy.tile.IEnergySink; -import ic2.api.energy.tile.IEnergySource; -import ic2.api.tile.IEnergyStorage; - import java.util.EnumSet; +import cofh.api.energy.IEnergyHandler; +import cpw.mods.fml.common.Optional.Interface; +import cpw.mods.fml.common.Optional.InterfaceList; +import ic2.api.energy.tile.IEnergySink; +import ic2.api.energy.tile.IEnergySource; +import ic2.api.tile.IEnergyStorage; import mekanism.api.energy.ICableOutputter; import mekanism.api.energy.IStrictEnergyAcceptor; import mekanism.api.energy.IStrictEnergyStorage; import net.minecraft.inventory.IInventory; import net.minecraftforge.common.util.ForgeDirection; -import cofh.api.energy.IEnergyHandler; -import cpw.mods.fml.common.Optional.Interface; -import cpw.mods.fml.common.Optional.InterfaceList; @InterfaceList({ - @Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2"), - @Interface(iface = "ic2.api.energy.tile.IEnergySource", modid = "IC2"), - @Interface(iface = "ic2.api.tile.IEnergyStorage", modid = "IC2") + @Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2") + , @Interface(iface = "ic2.api.energy.tile.IEnergySource", modid = "IC2"), + @Interface(iface = "ic2.api.tile.IEnergyStorage", modid = "IC2") }) -public interface IEnergyWrapper extends IStrictEnergyStorage, IEnergyHandler, IEnergySink, IEnergySource, IEnergyStorage, IStrictEnergyAcceptor, ICableOutputter, IInventory -{ - public EnumSet getOutputtingSides(); +public interface IEnergyWrapper + extends IStrictEnergyStorage, IEnergyHandler, IEnergySink, IEnergySource, + IEnergyStorage, IStrictEnergyAcceptor, ICableOutputter, IInventory { + public EnumSet getOutputtingSides(); - public EnumSet getConsumingSides(); + public EnumSet getConsumingSides(); - public double getMaxOutput(); + public double getMaxOutput(); } diff --git a/src/main/java/mekanism/common/base/IFactory.java b/src/main/java/mekanism/common/base/IFactory.java index b4859abe2..3846dc461 100644 --- a/src/main/java/mekanism/common/base/IFactory.java +++ b/src/main/java/mekanism/common/base/IFactory.java @@ -28,247 +28,269 @@ import net.minecraftforge.common.util.ForgeDirection; * @author AidanBrady * */ -public interface IFactory -{ - /** - * Gets the recipe type this Smelting Factory currently has. - * @param itemStack - stack to check - * @return RecipeType ordinal - */ - public int getRecipeType(ItemStack itemStack); +public interface IFactory { + /** + * Gets the recipe type this Smelting Factory currently has. + * @param itemStack - stack to check + * @return RecipeType ordinal + */ + public int getRecipeType(ItemStack itemStack); - /** - * Sets the recipe type of this Smelting Factory to a new value. - * @param type - RecipeType ordinal - * @param itemStack - stack to set - */ - public void setRecipeType(int type, ItemStack itemStack); + /** + * Sets the recipe type of this Smelting Factory to a new value. + * @param type - RecipeType ordinal + * @param itemStack - stack to set + */ + public void setRecipeType(int type, ItemStack itemStack); - public static enum RecipeType - { - SMELTING("Smelting", "smelter", MachineType.ENERGIZED_SMELTER.getStack(), false, false, Recipe.ENERGIZED_SMELTER), - ENRICHING("Enriching", "enrichment", MachineType.ENRICHMENT_CHAMBER.getStack(), false, false, Recipe.ENRICHMENT_CHAMBER), - CRUSHING("Crushing", "crusher", MachineType.CRUSHER.getStack(), false, false, Recipe.CRUSHER), - COMPRESSING("Compressing", "compressor", MachineType.OSMIUM_COMPRESSOR.getStack(), true, false, Recipe.OSMIUM_COMPRESSOR), - COMBINING("Combining", "combiner", MachineType.COMBINER.getStack(), true, false, Recipe.COMBINER), - PURIFYING("Purifying", "purifier", MachineType.PURIFICATION_CHAMBER.getStack(), true, true, Recipe.PURIFICATION_CHAMBER), - INJECTING("Injecting", "injection", MachineType.CHEMICAL_INJECTION_CHAMBER.getStack(), true, true, Recipe.CHEMICAL_INJECTION_CHAMBER), - INFUSING("Infusing", "metalinfuser", MachineType.METALLURGIC_INFUSER.getStack(), false, false, Recipe.METALLURGIC_INFUSER); + public static enum RecipeType { + SMELTING( + "Smelting", + "smelter", + MachineType.ENERGIZED_SMELTER.getStack(), + false, + false, + Recipe.ENERGIZED_SMELTER + ), + ENRICHING( + "Enriching", + "enrichment", + MachineType.ENRICHMENT_CHAMBER.getStack(), + false, + false, + Recipe.ENRICHMENT_CHAMBER + ), + CRUSHING( + "Crushing", + "crusher", + MachineType.CRUSHER.getStack(), + false, + false, + Recipe.CRUSHER + ), + COMPRESSING( + "Compressing", + "compressor", + MachineType.OSMIUM_COMPRESSOR.getStack(), + true, + false, + Recipe.OSMIUM_COMPRESSOR + ), + COMBINING( + "Combining", + "combiner", + MachineType.COMBINER.getStack(), + true, + false, + Recipe.COMBINER + ), + PURIFYING( + "Purifying", + "purifier", + MachineType.PURIFICATION_CHAMBER.getStack(), + true, + true, + Recipe.PURIFICATION_CHAMBER + ), + INJECTING( + "Injecting", + "injection", + MachineType.CHEMICAL_INJECTION_CHAMBER.getStack(), + true, + true, + Recipe.CHEMICAL_INJECTION_CHAMBER + ), + INFUSING( + "Infusing", + "metalinfuser", + MachineType.METALLURGIC_INFUSER.getStack(), + false, + false, + Recipe.METALLURGIC_INFUSER + ); - private String name; - private ResourceLocation sound; - private ItemStack stack; - private boolean usesFuel; - private boolean fuelSpeed; - private Recipe recipe; - private TileEntityAdvancedElectricMachine cacheTile; + private String name; + private ResourceLocation sound; + private ItemStack stack; + private boolean usesFuel; + private boolean fuelSpeed; + private Recipe recipe; + private TileEntityAdvancedElectricMachine cacheTile; - public BasicMachineRecipe getRecipe(ItemStackInput input) - { - return RecipeHandler.getRecipe(input, recipe.get()); - } + public BasicMachineRecipe getRecipe(ItemStackInput input) { + return RecipeHandler.getRecipe(input, recipe.get()); + } - public BasicMachineRecipe getRecipe(ItemStack input) - { - return getRecipe(new ItemStackInput(input)); - } + public BasicMachineRecipe getRecipe(ItemStack input) { + return getRecipe(new ItemStackInput(input)); + } - public AdvancedMachineRecipe getRecipe(AdvancedMachineInput input) - { - return RecipeHandler.getRecipe(input, recipe.get()); - } + public AdvancedMachineRecipe getRecipe(AdvancedMachineInput input) { + return RecipeHandler.getRecipe(input, recipe.get()); + } - public AdvancedMachineRecipe getRecipe(ItemStack input, Gas gas) - { - return getRecipe(new AdvancedMachineInput(input, gas)); - } - - public MetallurgicInfuserRecipe getRecipe(InfusionInput input) - { - return RecipeHandler.getMetallurgicInfuserRecipe(input); - } - - public MetallurgicInfuserRecipe getRecipe(ItemStack input, InfuseStorage storage) - { - return getRecipe(new InfusionInput(storage, input)); - } + public AdvancedMachineRecipe getRecipe(ItemStack input, Gas gas) { + return getRecipe(new AdvancedMachineInput(input, gas)); + } - public MachineRecipe getAnyRecipe(ItemStack slotStack, Gas gasType, InfuseStorage infuse) - { - if(usesFuel()) - { - return getRecipe(slotStack, gasType); - } - else if(this == INFUSING) - { - if(infuse.type != null) - { - return RecipeHandler.getMetallurgicInfuserRecipe(new InfusionInput(infuse, slotStack)); - } - else { - for(Object obj : Recipe.METALLURGIC_INFUSER.get().entrySet()) - { - Map.Entry entry = (Map.Entry)obj; - InfusionInput input = (InfusionInput)entry.getKey(); - - if(input.inputStack.isItemEqual(slotStack)) - { - return (MetallurgicInfuserRecipe)entry.getValue(); - } - } - } - } - - return getRecipe(slotStack); - } + public MetallurgicInfuserRecipe getRecipe(InfusionInput input) { + return RecipeHandler.getMetallurgicInfuserRecipe(input); + } - public GasStack getItemGas(ItemStack itemstack) - { - if(usesFuel) - { - return getTile().getItemGas(itemstack); - } + public MetallurgicInfuserRecipe + getRecipe(ItemStack input, InfuseStorage storage) { + return getRecipe(new InfusionInput(storage, input)); + } - return null; - } + public MachineRecipe + getAnyRecipe(ItemStack slotStack, Gas gasType, InfuseStorage infuse) { + if (usesFuel()) { + return getRecipe(slotStack, gasType); + } else if (this == INFUSING) { + if (infuse.type != null) { + return RecipeHandler.getMetallurgicInfuserRecipe( + new InfusionInput(infuse, slotStack) + ); + } else { + for (Object obj : Recipe.METALLURGIC_INFUSER.get().entrySet()) { + Map.Entry entry = (Map.Entry) obj; + InfusionInput input = (InfusionInput) entry.getKey(); - public int getSecondaryEnergyPerTick() - { - if(usesFuel) - { - return getTile().BASE_SECONDARY_ENERGY_PER_TICK; - } + if (input.inputStack.isItemEqual(slotStack)) { + return (MetallurgicInfuserRecipe) entry.getValue(); + } + } + } + } - return 0; - } + return getRecipe(slotStack); + } - public boolean canReceiveGas(ForgeDirection side, Gas type) - { - if(usesFuel) - { - return getTile().canReceiveGas(side, type); - } + public GasStack getItemGas(ItemStack itemstack) { + if (usesFuel) { + return getTile().getItemGas(itemstack); + } - return false; - } + return null; + } - public boolean canTubeConnect(ForgeDirection side) - { - if(usesFuel) - { - return getTile().canTubeConnect(side); - } + public int getSecondaryEnergyPerTick() { + if (usesFuel) { + return getTile().BASE_SECONDARY_ENERGY_PER_TICK; + } - return false; - } + return 0; + } - public boolean isValidGas(Gas gas) - { - if(usesFuel) - { - return getTile().isValidGas(gas); - } + public boolean canReceiveGas(ForgeDirection side, Gas type) { + if (usesFuel) { + return getTile().canReceiveGas(side, type); + } - return false; - } + return false; + } - public boolean hasRecipe(ItemStack itemStack) - { - if(itemStack == null) - { - return false; - } + public boolean canTubeConnect(ForgeDirection side) { + if (usesFuel) { + return getTile().canTubeConnect(side); + } - for(Object obj : recipe.get().entrySet()) - { - if(((Map.Entry)obj).getKey() instanceof AdvancedMachineInput) - { - Map.Entry entry = (Map.Entry)obj; + return false; + } - ItemStack stack = ((AdvancedMachineInput)entry.getKey()).itemStack; + public boolean isValidGas(Gas gas) { + if (usesFuel) { + return getTile().isValidGas(gas); + } - if(StackUtils.equalsWildcard(stack, itemStack)) - { - return true; - } - } - } + return false; + } - return false; - } + public boolean hasRecipe(ItemStack itemStack) { + if (itemStack == null) { + return false; + } - public TileEntityAdvancedElectricMachine getTile() - { - if(cacheTile == null) - { - MachineType type = MachineType.get(Block.getBlockFromItem(getStack().getItem()), getStack().getItemDamage()); - cacheTile = (TileEntityAdvancedElectricMachine)type.create(); - } + for (Object obj : recipe.get().entrySet()) { + if (((Map.Entry) obj).getKey() instanceof AdvancedMachineInput) { + Map.Entry entry = (Map.Entry) obj; - return cacheTile; - } + ItemStack stack = ((AdvancedMachineInput) entry.getKey()).itemStack; - public int getMaxSecondaryEnergy() - { - return 200; - } + if (StackUtils.equalsWildcard(stack, itemStack)) { + return true; + } + } + } - public ItemStack getStack() - { - return stack; - } - - public String getUnlocalizedName() - { - return name; - } + return false; + } - public String getLocalizedName() - { - return LangUtils.localize("gui.factory." + name); - } + public TileEntityAdvancedElectricMachine getTile() { + if (cacheTile == null) { + MachineType type = MachineType.get( + Block.getBlockFromItem(getStack().getItem()), + getStack().getItemDamage() + ); + cacheTile = (TileEntityAdvancedElectricMachine) type.create(); + } - public ResourceLocation getSound() - { - return sound; - } + return cacheTile; + } - public boolean usesFuel() - { - return usesFuel; - } - - public boolean fuelEnergyUpgrades() - { - return fuelSpeed; - } - - public static RecipeType getFromMachine(Block block, int meta) - { - RecipeType type = null; - - for(RecipeType iterType : RecipeType.values()) - { - ItemStack machineStack = iterType.getStack(); - - if(Block.getBlockFromItem(machineStack.getItem()) == block && machineStack.getItemDamage() == meta) - { - type = iterType; - break; - } - } - - return type; - } + public int getMaxSecondaryEnergy() { + return 200; + } - private RecipeType(String s, String s1, ItemStack is, boolean b, boolean b1, Recipe r) - { - name = s; - sound = new ResourceLocation("mekanism", "tile.machine." + s1); - stack = is; - usesFuel = b; - fuelSpeed = b1; - recipe = r; - } - } + public ItemStack getStack() { + return stack; + } + + public String getUnlocalizedName() { + return name; + } + + public String getLocalizedName() { + return LangUtils.localize("gui.factory." + name); + } + + public ResourceLocation getSound() { + return sound; + } + + public boolean usesFuel() { + return usesFuel; + } + + public boolean fuelEnergyUpgrades() { + return fuelSpeed; + } + + public static RecipeType getFromMachine(Block block, int meta) { + RecipeType type = null; + + for (RecipeType iterType : RecipeType.values()) { + ItemStack machineStack = iterType.getStack(); + + if (Block.getBlockFromItem(machineStack.getItem()) == block + && machineStack.getItemDamage() == meta) { + type = iterType; + break; + } + } + + return type; + } + + private RecipeType( + String s, String s1, ItemStack is, boolean b, boolean b1, Recipe r + ) { + name = s; + sound = new ResourceLocation("mekanism", "tile.machine." + s1); + stack = is; + usesFuel = b; + fuelSpeed = b1; + recipe = r; + } + } } diff --git a/src/main/java/mekanism/common/base/IFluidContainerManager.java b/src/main/java/mekanism/common/base/IFluidContainerManager.java index 65cc5a0a2..6cc6a2c75 100644 --- a/src/main/java/mekanism/common/base/IFluidContainerManager.java +++ b/src/main/java/mekanism/common/base/IFluidContainerManager.java @@ -2,9 +2,8 @@ package mekanism.common.base; import mekanism.common.util.FluidContainerUtils.ContainerEditMode; -public interface IFluidContainerManager -{ - public ContainerEditMode getContainerEditMode(); - - public void setContainerEditMode(ContainerEditMode mode); +public interface IFluidContainerManager { + public ContainerEditMode getContainerEditMode(); + + public void setContainerEditMode(ContainerEditMode mode); } diff --git a/src/main/java/mekanism/common/base/IGuiProvider.java b/src/main/java/mekanism/common/base/IGuiProvider.java index 681546895..49a877ce9 100644 --- a/src/main/java/mekanism/common/base/IGuiProvider.java +++ b/src/main/java/mekanism/common/base/IGuiProvider.java @@ -4,29 +4,30 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.world.World; -public interface IGuiProvider -{ - /** - * Get the container for a GUI. Common. - * @param ID - gui ID - * @param player - player that opened the GUI - * @param world - world the GUI was opened in - * @param x - gui's x position - * @param y - gui's y position - * @param z - gui's z position - * @return the Container of the GUI - */ - public Container getServerGui(int ID, EntityPlayer player, World world, int x, int y, int z); - - /** - * Get the actual interface for a GUI. Client-only. - * @param ID - gui ID - * @param player - player that opened the GUI - * @param world - world the GUI was opened in - * @param x - gui's x position - * @param y - gui's y position - * @param z - gui's z position - * @return the GuiScreen of the GUI - */ - public Object getClientGui(int ID, EntityPlayer player, World world, int x, int y, int z); +public interface IGuiProvider { + /** + * Get the container for a GUI. Common. + * @param ID - gui ID + * @param player - player that opened the GUI + * @param world - world the GUI was opened in + * @param x - gui's x position + * @param y - gui's y position + * @param z - gui's z position + * @return the Container of the GUI + */ + public Container + getServerGui(int ID, EntityPlayer player, World world, int x, int y, int z); + + /** + * Get the actual interface for a GUI. Client-only. + * @param ID - gui ID + * @param player - player that opened the GUI + * @param world - world the GUI was opened in + * @param x - gui's x position + * @param y - gui's y position + * @param z - gui's z position + * @return the GuiScreen of the GUI + */ + public Object + getClientGui(int ID, EntityPlayer player, World world, int x, int y, int z); } diff --git a/src/main/java/mekanism/common/base/IHasSound.java b/src/main/java/mekanism/common/base/IHasSound.java index d1d29fc19..a1f3c3feb 100644 --- a/src/main/java/mekanism/common/base/IHasSound.java +++ b/src/main/java/mekanism/common/base/IHasSound.java @@ -8,11 +8,10 @@ import cpw.mods.fml.relauncher.SideOnly; * @author AidanBrady * */ -public interface IHasSound -{ - @SideOnly(Side.CLIENT) - public SoundWrapper getSound(); +public interface IHasSound { + @SideOnly(Side.CLIENT) + public SoundWrapper getSound(); - @SideOnly(Side.CLIENT) - public boolean shouldPlaySound(); + @SideOnly(Side.CLIENT) + public boolean shouldPlaySound(); } diff --git a/src/main/java/mekanism/common/base/ILogisticalTransporter.java b/src/main/java/mekanism/common/base/ILogisticalTransporter.java index ece1d5930..a88bd1437 100644 --- a/src/main/java/mekanism/common/base/ILogisticalTransporter.java +++ b/src/main/java/mekanism/common/base/ILogisticalTransporter.java @@ -12,21 +12,29 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -public interface ILogisticalTransporter extends IGridTransmitter, IBlockableConnection -{ - public ItemStack insert(Coord4D original, ItemStack itemStack, EnumColor color, boolean doEmit, int min); +public interface ILogisticalTransporter + extends IGridTransmitter, IBlockableConnection { + public ItemStack insert( + Coord4D original, ItemStack itemStack, EnumColor color, boolean doEmit, int min + ); - public ItemStack insertRR(TileEntityLogisticalSorter outputter, ItemStack itemStack, EnumColor color, boolean doEmit, int min); + public ItemStack insertRR( + TileEntityLogisticalSorter outputter, + ItemStack itemStack, + EnumColor color, + boolean doEmit, + int min + ); - public void entityEntering(TransporterStack stack, int progress); + public void entityEntering(TransporterStack stack, int progress); - public EnumColor getColor(); + public EnumColor getColor(); - public void setColor(EnumColor c); + public void setColor(EnumColor c); - public boolean canEmitTo(TileEntity tileEntity, ForgeDirection side); + public boolean canEmitTo(TileEntity tileEntity, ForgeDirection side); - public boolean canReceiveFrom(TileEntity tileEntity, ForgeDirection side); + public boolean canReceiveFrom(TileEntity tileEntity, ForgeDirection side); - public double getCost(); + public double getCost(); } diff --git a/src/main/java/mekanism/common/base/IModule.java b/src/main/java/mekanism/common/base/IModule.java index 810de751f..7a8204656 100644 --- a/src/main/java/mekanism/common/base/IModule.java +++ b/src/main/java/mekanism/common/base/IModule.java @@ -1,44 +1,44 @@ package mekanism.common.base; -import io.netty.buffer.ByteBuf; - import java.io.IOException; +import io.netty.buffer.ByteBuf; /** - * Implement in your main class if your mod happens to be completely reliant on Mekanism, or in other words, is a Mekanism module. + * Implement in your main class if your mod happens to be completely reliant on Mekanism, + * or in other words, is a Mekanism module. * @author aidancbrady * */ -public interface IModule -{ - /** - * Gets the version of the module. - * @return the module's version - */ - public String getVersion(); +public interface IModule { + /** + * Gets the version of the module. + * @return the module's version + */ + public String getVersion(); - /** - * Gets the name of the module. Note that this doesn't include "Mekanism" like the actual module's name does, just the - * unique name. For example, MekanismGenerators returns "Generators" here. - * @return unique name of the module - */ - public String getName(); + /** + * Gets the name of the module. Note that this doesn't include "Mekanism" like the + * actual module's name does, just the unique name. For example, MekanismGenerators + * returns "Generators" here. + * @return unique name of the module + */ + public String getName(); - /** - * Writes this module's configuration to a ConfigSync packet. - * @param dataStream - the ByteBuf of the sync packet - */ - public void writeConfig(ByteBuf dataStream) throws IOException; + /** + * Writes this module's configuration to a ConfigSync packet. + * @param dataStream - the ByteBuf of the sync packet + */ + public void writeConfig(ByteBuf dataStream) throws IOException; - /** - * Reads this module's configuration from the original ConfigSync packet. - * @param dataStream - the incoming ByteBuf of the sync packet - */ - public void readConfig(ByteBuf dataStream) throws IOException; - - /** - * Called when the player returns to the main menu. - */ - public void resetClient(); + /** + * Reads this module's configuration from the original ConfigSync packet. + * @param dataStream - the incoming ByteBuf of the sync packet + */ + public void readConfig(ByteBuf dataStream) throws IOException; + + /** + * Called when the player returns to the main menu. + */ + public void resetClient(); } diff --git a/src/main/java/mekanism/common/base/IRedstoneControl.java b/src/main/java/mekanism/common/base/IRedstoneControl.java index 709ed0d66..8f7710789 100644 --- a/src/main/java/mekanism/common/base/IRedstoneControl.java +++ b/src/main/java/mekanism/common/base/IRedstoneControl.java @@ -2,54 +2,50 @@ package mekanism.common.base; import mekanism.common.util.LangUtils; -public interface IRedstoneControl -{ - public static enum RedstoneControl - { - DISABLED("control.disabled"), - HIGH("control.high"), - LOW("control.low"), - PULSE("control.pulse"); +public interface IRedstoneControl { + public static enum RedstoneControl { + DISABLED("control.disabled"), + HIGH("control.high"), + LOW("control.low"), + PULSE("control.pulse"); - private String display; + private String display; - public String getDisplay() - { - return LangUtils.localize(display); - } + public String getDisplay() { + return LangUtils.localize(display); + } - private RedstoneControl(String s) - { - display = s; - } - } + private RedstoneControl(String s) { + display = s; + } + } - /** - * Gets the RedstoneControl type from this block. - * @return this block's RedstoneControl type - */ - public RedstoneControl getControlType(); + /** + * Gets the RedstoneControl type from this block. + * @return this block's RedstoneControl type + */ + public RedstoneControl getControlType(); - /** - * Sets this block's RedstoneControl type to a new value. - * @param type - RedstoneControl type to set - */ - public void setControlType(RedstoneControl type); + /** + * Sets this block's RedstoneControl type to a new value. + * @param type - RedstoneControl type to set + */ + public void setControlType(RedstoneControl type); - /** - * If the block is getting powered or not by redstone (indirectly). - * @return if the block is getting powered indirectly - */ - public boolean isPowered(); + /** + * If the block is getting powered or not by redstone (indirectly). + * @return if the block is getting powered indirectly + */ + public boolean isPowered(); - /** - * If the block was getting powered or not by redstone, last tick. - * Used for PULSE mode. - */ - public boolean wasPowered(); + /** + * If the block was getting powered or not by redstone, last tick. + * Used for PULSE mode. + */ + public boolean wasPowered(); - /** - * If the machine can be pulsed. - */ - public boolean canPulse(); + /** + * If the machine can be pulsed. + */ + public boolean canPulse(); } diff --git a/src/main/java/mekanism/common/base/ISideConfiguration.java b/src/main/java/mekanism/common/base/ISideConfiguration.java index 408d3bade..49234f38d 100644 --- a/src/main/java/mekanism/common/base/ISideConfiguration.java +++ b/src/main/java/mekanism/common/base/ISideConfiguration.java @@ -4,27 +4,27 @@ import mekanism.common.tile.component.TileComponentConfig; import mekanism.common.tile.component.TileComponentEjector; /** - * Implement this if your TileEntity is capable of being modified by a Configurator in it's 'modify' mode. + * Implement this if your TileEntity is capable of being modified by a Configurator in + * it's 'modify' mode. * @author AidanBrady * */ -public interface ISideConfiguration -{ - /** - * Gets the tile's configuration component. - * @return the tile's configuration component - */ - public TileComponentConfig getConfig(); +public interface ISideConfiguration { + /** + * Gets the tile's configuration component. + * @return the tile's configuration component + */ + public TileComponentConfig getConfig(); - /** - * Gets this machine's current orientation. - * @return machine's current orientation - */ - public int getOrientation(); + /** + * Gets this machine's current orientation. + * @return machine's current orientation + */ + public int getOrientation(); - /** - * Gets this machine's ejector. - * @return - */ - public TileComponentEjector getEjector(); + /** + * Gets this machine's ejector. + * @return + */ + public TileComponentEjector getEjector(); } diff --git a/src/main/java/mekanism/common/base/ISpecialBounds.java b/src/main/java/mekanism/common/base/ISpecialBounds.java index 2b4a0aff2..0ace878de 100644 --- a/src/main/java/mekanism/common/base/ISpecialBounds.java +++ b/src/main/java/mekanism/common/base/ISpecialBounds.java @@ -7,19 +7,19 @@ import net.minecraft.block.Block; * @author aidancbrady * */ -public interface ISpecialBounds -{ - /** - * Sets the render bounds for this particular block's subtype. - * @param block - the Block instance the renderer pertains to. - * @param metadata - metadata of the block being rendered - */ - public void setRenderBounds(Block block, int metadata); +public interface ISpecialBounds { + /** + * Sets the render bounds for this particular block's subtype. + * @param block - the Block instance the renderer pertains to. + * @param metadata - metadata of the block being rendered + */ + public void setRenderBounds(Block block, int metadata); - /** - * Whether or not to call the default setBlockBoundsForItemRender() before rendering this block as an item. - * @param metadata - metadata of the block being rendered - * @return whether or not to call default bound setting on this block's metadata. - */ - public boolean doDefaultBoundSetting(int metadata); + /** + * Whether or not to call the default setBlockBoundsForItemRender() before rendering + * this block as an item. + * @param metadata - metadata of the block being rendered + * @return whether or not to call default bound setting on this block's metadata. + */ + public boolean doDefaultBoundSetting(int metadata); } diff --git a/src/main/java/mekanism/common/base/ISustainedData.java b/src/main/java/mekanism/common/base/ISustainedData.java index 4fb80bf43..c0f9741be 100644 --- a/src/main/java/mekanism/common/base/ISustainedData.java +++ b/src/main/java/mekanism/common/base/ISustainedData.java @@ -2,9 +2,8 @@ package mekanism.common.base; import net.minecraft.item.ItemStack; -public interface ISustainedData -{ - public void writeSustainedData(ItemStack itemStack); - - public void readSustainedData(ItemStack itemStack); +public interface ISustainedData { + public void writeSustainedData(ItemStack itemStack); + + public void readSustainedData(ItemStack itemStack); } diff --git a/src/main/java/mekanism/common/base/ISustainedInventory.java b/src/main/java/mekanism/common/base/ISustainedInventory.java index e8d2bbb54..a47b09322 100644 --- a/src/main/java/mekanism/common/base/ISustainedInventory.java +++ b/src/main/java/mekanism/common/base/ISustainedInventory.java @@ -3,23 +3,23 @@ package mekanism.common.base; import net.minecraft.nbt.NBTTagList; /** - * Internal interface used in blocks and items that are capable of storing sustained inventories. + * Internal interface used in blocks and items that are capable of storing sustained + * inventories. * @author AidanBrady * */ -public interface ISustainedInventory -{ - /** - * Sets the inventory tag list to a new value. - * @param nbtTags - NBTTagList value to set - * @param data - ItemStack parameter if using on item - */ - public void setInventory(NBTTagList nbtTags, Object... data); +public interface ISustainedInventory { + /** + * Sets the inventory tag list to a new value. + * @param nbtTags - NBTTagList value to set + * @param data - ItemStack parameter if using on item + */ + public void setInventory(NBTTagList nbtTags, Object... data); - /** - * Gets the inventory tag list from an item or block. - * @param data - ItemStack parameter if using on item - * @return inventory tag list - */ - public NBTTagList getInventory(Object... data); + /** + * Gets the inventory tag list from an item or block. + * @param data - ItemStack parameter if using on item + * @return inventory tag list + */ + public NBTTagList getInventory(Object... data); } diff --git a/src/main/java/mekanism/common/base/ISustainedTank.java b/src/main/java/mekanism/common/base/ISustainedTank.java index 2ba21c411..25d45f429 100644 --- a/src/main/java/mekanism/common/base/ISustainedTank.java +++ b/src/main/java/mekanism/common/base/ISustainedTank.java @@ -3,30 +3,30 @@ package mekanism.common.base; import net.minecraftforge.fluids.FluidStack; /** - * Internal interface used in blocks and items that are capable of storing sustained tanks. + * Internal interface used in blocks and items that are capable of storing sustained + * tanks. * @author AidanBrady * */ -public interface ISustainedTank -{ - /** - * Sets the tank tag list to a new value. - * @param nbtTags - NBTTagList value to set - * @param data - ItemStack parameter if using on item - */ - public void setFluidStack(FluidStack fluidStack, Object... data); +public interface ISustainedTank { + /** + * Sets the tank tag list to a new value. + * @param nbtTags - NBTTagList value to set + * @param data - ItemStack parameter if using on item + */ + public void setFluidStack(FluidStack fluidStack, Object... data); - /** - * Gets the tank tag list from an item or block. - * @param data - ItemStack parameter if using on item - * @return inventory tag list - */ - public FluidStack getFluidStack(Object... data); + /** + * Gets the tank tag list from an item or block. + * @param data - ItemStack parameter if using on item + * @return inventory tag list + */ + public FluidStack getFluidStack(Object... data); - /** - * Whether or not this block or item has an internal tank. - * @param data - ItemStack parameter if using on item - * @return if the block or item has an internal tank - */ - public boolean hasTank(Object... data); + /** + * Whether or not this block or item has an internal tank. + * @param data - ItemStack parameter if using on item + * @return if the block or item has an internal tank + */ + public boolean hasTank(Object... data); } diff --git a/src/main/java/mekanism/common/base/ITankManager.java b/src/main/java/mekanism/common/base/ITankManager.java index a173d5ede..c23859946 100644 --- a/src/main/java/mekanism/common/base/ITankManager.java +++ b/src/main/java/mekanism/common/base/ITankManager.java @@ -9,116 +9,153 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; -public interface ITankManager -{ - public Object[] getTanks(); - - public static class DropperHandler - { - public static void useDropper(EntityPlayer player, Object tank, int button) - { - ItemStack stack = player.inventory.getItemStack(); - - if(stack == null || !(stack.getItem() instanceof ItemGaugeDropper)) - { - return; - } - - ItemGaugeDropper dropper = (ItemGaugeDropper)stack.getItem(); - - if(stack != null) - { - if(tank instanceof GasTank) - { - GasTank gasTank = (GasTank)tank; - int dropperStored = dropper.getGas(stack) != null ? dropper.getGas(stack).amount : 0; - - if(dropper.getGas(stack) != null && gasTank.getGas() != null && !dropper.getGas(stack).isGasEqual(gasTank.getGas())) - { - return; - } - - if(button == 0) //Insert gas into dropper - { - if(dropper.getFluid(stack) != null || gasTank.getGas() == null) - { - return; - } - - int toInsert = Math.min(gasTank.getStored(), ItemGaugeDropper.CAPACITY-dropperStored); - GasStack drawn = gasTank.draw(toInsert, true); - - if(drawn != null) - { - dropper.setGas(stack, new GasStack(drawn.getGas(), dropperStored+(drawn != null ? drawn.amount : 0))); - } - - ((EntityPlayerMP)player).sendContainerAndContentsToPlayer(player.openContainer, player.openContainer.getInventory()); - } - else if(button == 1) //Extract gas from dropper - { - if(dropper.getFluid(stack) != null || gasTank.getNeeded() == 0) - { - return; - } - - int toExtract = Math.min(gasTank.getNeeded(), dropperStored); - toExtract = gasTank.receive(new GasStack(dropper.getGas(stack).getGas(), toExtract), true); - dropper.setGas(stack, new GasStack(dropper.getGas(stack).getGas(), dropperStored-toExtract)); - - ((EntityPlayerMP)player).sendContainerAndContentsToPlayer(player.openContainer, player.openContainer.getInventory()); - } - else if(button == 2) //Dump the tank - { - gasTank.setGas(null); - } - } - else if(tank instanceof FluidTank) - { - FluidTank fluidTank = (FluidTank)tank; - int dropperStored = dropper.getFluid(stack) != null ? dropper.getFluid(stack).amount : 0; - - if(dropper.getFluid(stack) != null && fluidTank.getFluid() != null && !dropper.getFluid(stack).isFluidEqual(fluidTank.getFluid())) - { - return; - } - - if(button == 0) //Insert fluid into dropper - { - if(dropper.getGas(stack) != null || fluidTank.getFluid() == null) - { - return; - } - - int toInsert = Math.min(fluidTank.getFluidAmount(), ItemGaugeDropper.CAPACITY-dropperStored); - FluidStack drawn = fluidTank.drain(toInsert, true); - - if(drawn != null) - { - dropper.setFluid(stack, new FluidStack(drawn.getFluid(), dropperStored+(drawn != null ? drawn.amount : 0))); - } - - ((EntityPlayerMP)player).sendContainerAndContentsToPlayer(player.openContainer, player.openContainer.getInventory()); - } - else if(button == 1) //Extract fluid from dropper - { - if(dropper.getGas(stack) != null || fluidTank.getCapacity()-fluidTank.getFluidAmount() == 0) - { - return; - } - - int toExtract = Math.min(fluidTank.getCapacity()-fluidTank.getFluidAmount(), dropperStored); - toExtract = fluidTank.fill(new FluidStack(dropper.getFluid(stack).getFluid(), toExtract), true); - dropper.setFluid(stack, new FluidStack(dropper.getFluid(stack).getFluid(), dropperStored-toExtract)); - - ((EntityPlayerMP)player).sendContainerAndContentsToPlayer(player.openContainer, player.openContainer.getInventory()); - } - else if(button == 2) //Dump the tank - { - fluidTank.setFluid(null); - } - } - } - } - } +public interface ITankManager { + public Object[] getTanks(); + + public static class DropperHandler { + public static void useDropper(EntityPlayer player, Object tank, int button) { + ItemStack stack = player.inventory.getItemStack(); + + if (stack == null || !(stack.getItem() instanceof ItemGaugeDropper)) { + return; + } + + ItemGaugeDropper dropper = (ItemGaugeDropper) stack.getItem(); + + if (stack != null) { + if (tank instanceof GasTank) { + GasTank gasTank = (GasTank) tank; + int dropperStored = dropper.getGas(stack) != null + ? dropper.getGas(stack).amount + : 0; + + if (dropper.getGas(stack) != null && gasTank.getGas() != null + && !dropper.getGas(stack).isGasEqual(gasTank.getGas())) { + return; + } + + if (button == 0) //Insert gas into dropper + { + if (dropper.getFluid(stack) != null || gasTank.getGas() == null) { + return; + } + + int toInsert = Math.min( + gasTank.getStored(), ItemGaugeDropper.CAPACITY - dropperStored + ); + GasStack drawn = gasTank.draw(toInsert, true); + + if (drawn != null) { + dropper.setGas( + stack, + new GasStack( + drawn.getGas(), + dropperStored + (drawn != null ? drawn.amount : 0) + ) + ); + } + + ((EntityPlayerMP) player) + .sendContainerAndContentsToPlayer( + player.openContainer, player.openContainer.getInventory() + ); + } else if (button == 1) //Extract gas from dropper + { + if (dropper.getFluid(stack) != null || gasTank.getNeeded() == 0) { + return; + } + + int toExtract = Math.min(gasTank.getNeeded(), dropperStored); + toExtract = gasTank.receive( + new GasStack(dropper.getGas(stack).getGas(), toExtract), true + ); + dropper.setGas( + stack, + new GasStack( + dropper.getGas(stack).getGas(), dropperStored - toExtract + ) + ); + + ((EntityPlayerMP) player) + .sendContainerAndContentsToPlayer( + player.openContainer, player.openContainer.getInventory() + ); + } else if (button == 2) //Dump the tank + { + gasTank.setGas(null); + } + } else if (tank instanceof FluidTank) { + FluidTank fluidTank = (FluidTank) tank; + int dropperStored = dropper.getFluid(stack) != null + ? dropper.getFluid(stack).amount + : 0; + + if (dropper.getFluid(stack) != null && fluidTank.getFluid() != null + && !dropper.getFluid(stack).isFluidEqual(fluidTank.getFluid())) { + return; + } + + if (button == 0) //Insert fluid into dropper + { + if (dropper.getGas(stack) != null + || fluidTank.getFluid() == null) { + return; + } + + int toInsert = Math.min( + fluidTank.getFluidAmount(), + ItemGaugeDropper.CAPACITY - dropperStored + ); + FluidStack drawn = fluidTank.drain(toInsert, true); + + if (drawn != null) { + dropper.setFluid( + stack, + new FluidStack( + drawn.getFluid(), + dropperStored + (drawn != null ? drawn.amount : 0) + ) + ); + } + + ((EntityPlayerMP) player) + .sendContainerAndContentsToPlayer( + player.openContainer, player.openContainer.getInventory() + ); + } else if (button == 1) //Extract fluid from dropper + { + if (dropper.getGas(stack) != null + || fluidTank.getCapacity() - fluidTank.getFluidAmount() + == 0) { + return; + } + + int toExtract = Math.min( + fluidTank.getCapacity() - fluidTank.getFluidAmount(), + dropperStored + ); + toExtract = fluidTank.fill( + new FluidStack(dropper.getFluid(stack).getFluid(), toExtract), + true + ); + dropper.setFluid( + stack, + new FluidStack( + dropper.getFluid(stack).getFluid(), + dropperStored - toExtract + ) + ); + + ((EntityPlayerMP) player) + .sendContainerAndContentsToPlayer( + player.openContainer, player.openContainer.getInventory() + ); + } else if (button == 2) //Dump the tank + { + fluidTank.setFluid(null); + } + } + } + } + } } \ No newline at end of file diff --git a/src/main/java/mekanism/common/base/ITierItem.java b/src/main/java/mekanism/common/base/ITierItem.java index 31912c6d8..b8b9be20a 100644 --- a/src/main/java/mekanism/common/base/ITierItem.java +++ b/src/main/java/mekanism/common/base/ITierItem.java @@ -3,9 +3,8 @@ package mekanism.common.base; import mekanism.common.Tier.BaseTier; import net.minecraft.item.ItemStack; -public interface ITierItem -{ - public BaseTier getBaseTier(ItemStack stack); - - public void setBaseTier(ItemStack stack, BaseTier tier); +public interface ITierItem { + public BaseTier getBaseTier(ItemStack stack); + + public void setBaseTier(ItemStack stack, BaseTier tier); } diff --git a/src/main/java/mekanism/common/base/ITierUpgradeable.java b/src/main/java/mekanism/common/base/ITierUpgradeable.java index 591559591..4a776bba2 100644 --- a/src/main/java/mekanism/common/base/ITierUpgradeable.java +++ b/src/main/java/mekanism/common/base/ITierUpgradeable.java @@ -2,7 +2,6 @@ package mekanism.common.base; import mekanism.common.Tier.BaseTier; -public interface ITierUpgradeable -{ - public boolean upgrade(BaseTier upgradeTier); +public interface ITierUpgradeable { + public boolean upgrade(BaseTier upgradeTier); } diff --git a/src/main/java/mekanism/common/base/ITileComponent.java b/src/main/java/mekanism/common/base/ITileComponent.java index d14126ade..23d01569c 100644 --- a/src/main/java/mekanism/common/base/ITileComponent.java +++ b/src/main/java/mekanism/common/base/ITileComponent.java @@ -1,22 +1,20 @@ package mekanism.common.base; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import io.netty.buffer.ByteBuf; import net.minecraft.nbt.NBTTagCompound; -public interface ITileComponent -{ - public void tick(); +public interface ITileComponent { + public void tick(); - public void read(NBTTagCompound nbtTags); + public void read(NBTTagCompound nbtTags); - public void read(ByteBuf dataStream); + public void read(ByteBuf dataStream); - public void write(NBTTagCompound nbtTags); + public void write(NBTTagCompound nbtTags); - public void write(ArrayList data); - - public void invalidate(); + public void write(ArrayList data); + + public void invalidate(); } diff --git a/src/main/java/mekanism/common/base/ITileNetwork.java b/src/main/java/mekanism/common/base/ITileNetwork.java index 49f055270..d2d69b5dc 100644 --- a/src/main/java/mekanism/common/base/ITileNetwork.java +++ b/src/main/java/mekanism/common/base/ITileNetwork.java @@ -1,26 +1,25 @@ package mekanism.common.base; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import io.netty.buffer.ByteBuf; + /** * Internal interface used for blocks that send data between clients and the server * @author AidanBrady * */ -public interface ITileNetwork -{ - /** - * Receive and manage a packet's data. - * @param dataStream - */ - public void handlePacketData(ByteBuf dataStream) throws Exception; +public interface ITileNetwork { + /** + * Receive and manage a packet's data. + * @param dataStream + */ + public void handlePacketData(ByteBuf dataStream) throws Exception; - /** - * Gets an ArrayList of data this tile entity keeps synchronized with the client. - * @param data - list of data - * @return ArrayList - */ - public ArrayList getNetworkedData(ArrayList data); + /** + * Gets an ArrayList of data this tile entity keeps synchronized with the client. + * @param data - list of data + * @return ArrayList + */ + public ArrayList getNetworkedData(ArrayList data); } diff --git a/src/main/java/mekanism/common/base/ITransporterTile.java b/src/main/java/mekanism/common/base/ITransporterTile.java index 7ddf2d38d..aeaa1bbbd 100644 --- a/src/main/java/mekanism/common/base/ITransporterTile.java +++ b/src/main/java/mekanism/common/base/ITransporterTile.java @@ -1,12 +1,11 @@ package mekanism.common.base; - import mekanism.api.transmitters.IBlockableConnection; import mekanism.api.transmitters.ITransmitterTile; import mekanism.common.InventoryNetwork; import net.minecraft.inventory.IInventory; -public interface ITransporterTile extends ITransmitterTile, IBlockableConnection -{ - public ILogisticalTransporter getTransmitter(); +public interface ITransporterTile + extends ITransmitterTile, IBlockableConnection { + public ILogisticalTransporter getTransmitter(); } diff --git a/src/main/java/mekanism/common/base/IUpgradeItem.java b/src/main/java/mekanism/common/base/IUpgradeItem.java index ec33efa5a..3bcd3de3f 100644 --- a/src/main/java/mekanism/common/base/IUpgradeItem.java +++ b/src/main/java/mekanism/common/base/IUpgradeItem.java @@ -3,7 +3,6 @@ package mekanism.common.base; import mekanism.common.Upgrade; import net.minecraft.item.ItemStack; -public interface IUpgradeItem -{ - public Upgrade getUpgradeType(ItemStack stack); +public interface IUpgradeItem { + public Upgrade getUpgradeType(ItemStack stack); } diff --git a/src/main/java/mekanism/common/base/IUpgradeTile.java b/src/main/java/mekanism/common/base/IUpgradeTile.java index e278d77f7..e83037ae1 100644 --- a/src/main/java/mekanism/common/base/IUpgradeTile.java +++ b/src/main/java/mekanism/common/base/IUpgradeTile.java @@ -2,7 +2,6 @@ package mekanism.common.base; import mekanism.common.tile.component.TileComponentUpgrade; -public interface IUpgradeTile -{ - public TileComponentUpgrade getComponent(); +public interface IUpgradeTile { + public TileComponentUpgrade getComponent(); } diff --git a/src/main/java/mekanism/common/base/SoundWrapper.java b/src/main/java/mekanism/common/base/SoundWrapper.java index 83d04d4dc..b5586a7f4 100644 --- a/src/main/java/mekanism/common/base/SoundWrapper.java +++ b/src/main/java/mekanism/common/base/SoundWrapper.java @@ -1,47 +1,41 @@ package mekanism.common.base; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.sound.IResettableSound; import mekanism.client.sound.ISoundSource; import mekanism.client.sound.SoundHandler; import mekanism.client.sound.TileSound; import net.minecraft.util.ResourceLocation; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class SoundWrapper -{ - @SideOnly(Side.CLIENT) - public IResettableSound sound; - - public SoundWrapper(IHasSound tile, ISoundSource source) - { - try { - sound = new TileSound(tile, source); - } catch(Throwable t) {} - } - - public SoundWrapper(IHasSound tile, ISoundSource source, ResourceLocation location) - { - try { - sound = new TileSound(tile, source, location); - } catch(Throwable t) {} - } - - @SideOnly(Side.CLIENT) - public void reset() - { - sound.reset(); - } - - @SideOnly(Side.CLIENT) - public void play() - { - SoundHandler.playSound(sound); - } - - @SideOnly(Side.CLIENT) - public boolean canRestart() - { - return SoundHandler.canRestartSound(sound); - } +public class SoundWrapper { + @SideOnly(Side.CLIENT) + public IResettableSound sound; + + public SoundWrapper(IHasSound tile, ISoundSource source) { + try { + sound = new TileSound(tile, source); + } catch (Throwable t) {} + } + + public SoundWrapper(IHasSound tile, ISoundSource source, ResourceLocation location) { + try { + sound = new TileSound(tile, source, location); + } catch (Throwable t) {} + } + + @SideOnly(Side.CLIENT) + public void reset() { + sound.reset(); + } + + @SideOnly(Side.CLIENT) + public void play() { + SoundHandler.playSound(sound); + } + + @SideOnly(Side.CLIENT) + public boolean canRestart() { + return SoundHandler.canRestartSound(sound); + } } \ No newline at end of file diff --git a/src/main/java/mekanism/common/block/BlockBasic.java b/src/main/java/mekanism/common/block/BlockBasic.java index cea6e5be7..f2f6949b8 100644 --- a/src/main/java/mekanism/common/block/BlockBasic.java +++ b/src/main/java/mekanism/common/block/BlockBasic.java @@ -4,6 +4,10 @@ import java.util.Arrays; import java.util.List; import java.util.Random; +import buildcraft.api.tools.IToolWrench; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.energy.IEnergizedItem; import mekanism.api.energy.IStrictEnergyStorage; @@ -67,10 +71,6 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; -import buildcraft.api.tools.IToolWrench; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; /** * Block class for handling multiple metal block IDs. @@ -103,1116 +103,1253 @@ import cpw.mods.fml.relauncher.SideOnly; * @author AidanBrady * */ -public class BlockBasic extends Block implements IBlockCTM, ICustomBlockIcon -{ - public IIcon[][] icons = new IIcon[16][16]; - public IIcon[][] binIcons = new IIcon[16][16]; +public class BlockBasic extends Block implements IBlockCTM, ICustomBlockIcon { + public IIcon[][] icons = new IIcon[16][16]; + public IIcon[][] binIcons = new IIcon[16][16]; - public CTMData[][] ctms = new CTMData[16][4]; - - public static String ICON_BASE = "mekanism:SteelCasing"; + public CTMData[][] ctms = new CTMData[16][4]; - public BasicBlock blockType; + public static String ICON_BASE = "mekanism:SteelCasing"; - public BlockBasic(BasicBlock type) - { - super(Material.iron); - setHardness(5F); - setResistance(20F); - setCreativeTab(Mekanism.tabMekanism); - blockType = type; - } - - @Override - public IIcon getIcon(ItemStack stack, int side) - { - if(BasicType.get(stack) == BasicType.BIN) - { - return binIcons[((ItemBlockBasic)stack.getItem()).getBaseTier(stack).ordinal()][side]; - } - else if(BasicType.get(stack) == BasicType.INDUCTION_CELL) - { - return icons[3][((ItemBlockBasic)stack.getItem()).getBaseTier(stack).ordinal()]; - } - else if(BasicType.get(stack) == BasicType.INDUCTION_PROVIDER) - { - return icons[4][((ItemBlockBasic)stack.getItem()).getBaseTier(stack).ordinal()]; - } - - return getIcon(side, stack.getItemDamage()); - } + public BasicBlock blockType; - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) - { - if(!world.isRemote) - { - TileEntity tileEntity = world.getTileEntity(x, y, z); - - if(block == this && tileEntity instanceof IMultiblock) - { - ((IMultiblock)tileEntity).update(); - } - - if(tileEntity instanceof TileEntityBasicBlock) - { - ((TileEntityBasicBlock)tileEntity).onNeighborChange(block); - } - - if(tileEntity instanceof IStructuralMultiblock) - { - ((IStructuralMultiblock)tileEntity).update(); - } - } - } - - @Override - public float getExplosionResistance(Entity entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ) - { - BasicType type = BasicType.get(this, world.getBlockMetadata(x, y, z)); - - if(type == BasicType.REFINED_OBSIDIAN) - { - return 4000F; - } - - return blockResistance; + public BlockBasic(BasicBlock type) { + super(Material.iron); + setHardness(5F); + setResistance(20F); + setCreativeTab(Mekanism.tabMekanism); + blockType = type; } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister register) - { - switch(blockType) - { - case BASIC_BLOCK_1: - ctms[7][0] = new CTMData("ctm/TeleporterFrame", this, Arrays.asList(7)).addOtherBlockConnectivities(MekanismBlocks.MachineBlock, Arrays.asList(11)).registerIcons(register); - ctms[9][0] = new CTMData("ctm/DynamicTank", this, Arrays.asList(9, 11)).registerIcons(register); - ctms[10][0] = new CTMData("ctm/StructuralGlass", this, Arrays.asList(10)).registerIcons(register); - ctms[11][0] = new CTMData("ctm/DynamicValve", this, Arrays.asList(11, 9)).registerIcons(register); - - ctms[14][0] = new CTMData("ctm/ThermalEvaporationBlock", this, Arrays.asList(14, 15)).addOtherBlockConnectivities(MekanismBlocks.BasicBlock2, Arrays.asList(0)).addFacingOverride("ctm/ThermalEvaporationController").registerIcons(register); - ctms[14][1] = new CTMData("ctm/ThermalEvaporationBlock", this, Arrays.asList(14, 15)).addOtherBlockConnectivities(MekanismBlocks.BasicBlock2, Arrays.asList(0)).addFacingOverride("ctm/ThermalEvaporationControllerOn").registerIcons(register); - ctms[15][0] = new CTMData("ctm/ThermalEvaporationValve", this, Arrays.asList(15, 14)).addOtherBlockConnectivities(MekanismBlocks.BasicBlock2, Arrays.asList(0)).registerIcons(register); - - icons[0][0] = register.registerIcon("mekanism:OsmiumBlock"); - icons[1][0] = register.registerIcon("mekanism:BronzeBlock"); - icons[2][0] = register.registerIcon("mekanism:RefinedObsidian"); - icons[3][0] = register.registerIcon("mekanism:CoalBlock"); - icons[4][0] = register.registerIcon("mekanism:RefinedGlowstone"); - icons[5][0] = register.registerIcon("mekanism:SteelBlock"); - icons[6][0] = register.registerIcon(ICON_BASE); - - MekanismRenderer.loadDynamicTextures(register, "bin/BinBasic", binIcons[0], new DefIcon(register.registerIcon("mekanism:bin/BinBasicTop"), 0), new DefIcon(register.registerIcon("mekanism:bin/BinBasicTopOn"), 6)); - MekanismRenderer.loadDynamicTextures(register, "bin/BinAdvanced", binIcons[1], new DefIcon(register.registerIcon("mekanism:bin/BinAdvancedTop"), 0), new DefIcon(register.registerIcon("mekanism:bin/BinAdvancedTopOn"), 6)); - MekanismRenderer.loadDynamicTextures(register, "bin/BinElite", binIcons[2], new DefIcon(register.registerIcon("mekanism:bin/BinEliteTop"), 0), new DefIcon(register.registerIcon("mekanism:bin/BinEliteTopOn"), 6)); - MekanismRenderer.loadDynamicTextures(register, "bin/BinUltimate", binIcons[3], new DefIcon(register.registerIcon("mekanism:bin/BinUltimateTop"), 0), new DefIcon(register.registerIcon("mekanism:bin/BinUltimateTopOn"), 6)); - - icons[7][0] = ctms[7][0].mainTextureData.icon; - icons[8][0] = register.registerIcon("mekanism:SteelCasing"); - icons[9][0] = ctms[9][0].mainTextureData.icon; - icons[10][0] = ctms[10][0].mainTextureData.icon; - icons[11][0] = ctms[11][0].mainTextureData.icon; - icons[12][0] = register.registerIcon("mekanism:CopperBlock"); - icons[13][0] = register.registerIcon("mekanism:TinBlock"); - icons[14][0] = ctms[14][0].facingOverride.icon; - icons[14][1] = ctms[14][1].facingOverride.icon; - icons[14][2] = ctms[14][0].mainTextureData.icon; - icons[15][0] = ctms[15][0].mainTextureData.icon; - break; - case BASIC_BLOCK_2: - ctms[0][0] = new CTMData("ctm/ThermalEvaporationBlock", this, Arrays.asList(0)).addOtherBlockConnectivities(MekanismBlocks.BasicBlock, Arrays.asList(14, 15)).registerIcons(register); - ctms[1][0] = new CTMData("ctm/InductionCasing", this, Arrays.asList(1, 2)).registerIcons(register); - ctms[2][0] = new CTMData("ctm/InductionPortInput", this, Arrays.asList(1, 2)).registerIcons(register); - ctms[2][1] = new CTMData("ctm/InductionPortOutput", this, Arrays.asList(1, 2)).registerIcons(register); - ctms[3][0] = new CTMData("ctm/InductionCellBasic", this, Arrays.asList(3, 4)).registerIcons(register).setRenderConvexConnections(); - ctms[3][1] = new CTMData("ctm/InductionCellAdvanced", this, Arrays.asList(3, 4)).registerIcons(register).setRenderConvexConnections(); - ctms[3][2] = new CTMData("ctm/InductionCellElite", this, Arrays.asList(3, 4)).registerIcons(register).setRenderConvexConnections(); - ctms[3][3] = new CTMData("ctm/InductionCellUltimate", this, Arrays.asList(3, 4)).registerIcons(register).setRenderConvexConnections(); - ctms[4][0] = new CTMData("ctm/InductionProviderBasic", this, Arrays.asList(3, 4)).registerIcons(register).setRenderConvexConnections(); - ctms[4][1] = new CTMData("ctm/InductionProviderAdvanced", this, Arrays.asList(3, 4)).registerIcons(register).setRenderConvexConnections(); - ctms[4][2] = new CTMData("ctm/InductionProviderElite", this, Arrays.asList(3, 4)).registerIcons(register).setRenderConvexConnections(); - ctms[4][3] = new CTMData("ctm/InductionProviderUltimate", this, Arrays.asList(3, 4)).registerIcons(register).setRenderConvexConnections(); - ctms[5][0] = new CTMData("ctm/SuperheatingElement", this, Arrays.asList(5)).registerIcons(register).setRenderConvexConnections(); - ctms[5][1] = new CTMData("ctm/SuperheatingElementOn", this, Arrays.asList(5)).registerIcons(register).setRenderConvexConnections(); - ctms[7][0] = new CTMData("ctm/BoilerCasing", this, Arrays.asList(7, 8)).registerIcons(register); - ctms[8][0] = new CTMData("ctm/BoilerValve", this, Arrays.asList(7, 8)).registerIcons(register); - - icons[6][0] = register.registerIcon("mekanism:PressureDisperser"); - - icons[0][0] = ctms[0][0].mainTextureData.icon; - icons[1][0] = ctms[1][0].mainTextureData.icon; - icons[2][0] = ctms[2][0].mainTextureData.icon; - icons[2][1] = ctms[2][1].mainTextureData.icon; - icons[3][0] = ctms[3][0].mainTextureData.icon; - icons[3][1] = ctms[3][1].mainTextureData.icon; - icons[3][2] = ctms[3][2].mainTextureData.icon; - icons[3][3] = ctms[3][3].mainTextureData.icon; - icons[4][0] = ctms[4][0].mainTextureData.icon; - icons[4][1] = ctms[4][1].mainTextureData.icon; - icons[4][2] = ctms[4][2].mainTextureData.icon; - icons[4][3] = ctms[4][3].mainTextureData.icon; - icons[5][0] = ctms[5][0].mainTextureData.icon; - icons[5][1] = ctms[5][1].mainTextureData.icon; - icons[7][0] = ctms[7][0].mainTextureData.icon; - icons[8][0] = ctms[8][0].mainTextureData.icon; - - icons[9][0] = register.registerIcon(ICON_BASE); - - break; - } - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) - { - int meta = world.getBlockMetadata(x, y, z); - - switch(blockType) - { - case BASIC_BLOCK_1: - switch(meta) - { - case 6: - TileEntityBin tileEntity = (TileEntityBin)world.getTileEntity(x, y, z); - - boolean active = MekanismUtils.isActive(world, x, y, z); - return binIcons[tileEntity.tier.ordinal()][MekanismUtils.getBaseOrientation(side, tileEntity.facing)+(active ? 6 : 0)]; - case 14: - TileEntityThermalEvaporationController tileEntity1 = (TileEntityThermalEvaporationController)world.getTileEntity(x, y, z); - - if(side == tileEntity1.facing) - { - return MekanismUtils.isActive(world, x, y, z) ? icons[meta][1] : icons[meta][0]; - } - else { - return icons[meta][2]; - } - default: - return getIcon(side, meta); - } - case BASIC_BLOCK_2: - switch(meta) - { - case 2: - TileEntityInductionPort tileEntity = (TileEntityInductionPort)world.getTileEntity(x, y, z); - return icons[meta][tileEntity.mode ? 1 : 0]; - case 3: - TileEntityInductionCell tileEntity1 = (TileEntityInductionCell)world.getTileEntity(x, y, z); - return icons[meta][tileEntity1.tier.ordinal()]; - case 4: - TileEntityInductionProvider tileEntity2 = (TileEntityInductionProvider)world.getTileEntity(x, y, z); - return icons[meta][tileEntity2.tier.ordinal()]; - case 5: - TileEntitySuperheatingElement element = (TileEntitySuperheatingElement)world.getTileEntity(x, y, z); - - if(element.multiblockUUID != null && SynchronizedBoilerData.clientHotMap.get(element.multiblockUUID) != null) - { - return icons[meta][SynchronizedBoilerData.clientHotMap.get(element.multiblockUUID) ? 1 : 0]; - } - - return icons[meta][0]; - default: - return getIcon(side, meta); - } - } - - return null; - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int meta) - { - switch(blockType) - { - case BASIC_BLOCK_1: - switch(meta) - { - case 14: - if(side == 2) - { - return icons[meta][0]; - } - else { - return icons[meta][2]; - } - default: - return icons[meta][0]; - } - case BASIC_BLOCK_2: - return icons[meta][0]; - default: - return icons[meta][0]; - } - } - - @Override - public int damageDropped(int i) - { - return i; - } - - @Override - @SideOnly(Side.CLIENT) - public void getSubBlocks(Item item, CreativeTabs creativetabs, List list) - { - for(BasicType type : BasicType.values()) - { - if(type.typeBlock == blockType) - { - switch(type) - { - case INDUCTION_CELL: - case INDUCTION_PROVIDER: - case BIN: - for(BaseTier tier : BaseTier.values()) - { - if(tier.isObtainable()) - { - ItemStack stack = new ItemStack(item, 1, type.meta); - ((ItemBlockBasic)stack.getItem()).setBaseTier(stack, tier); - list.add(stack); - } - } - - break; - default: - list.add(new ItemStack(item, 1, type.meta)); - } - } - } - } - - @Override - public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) - { - int meta = world.getBlockMetadata(x, y, z); - - switch(blockType) - { - case BASIC_BLOCK_1: - switch(meta) - { - case 10: - return false; - case 9: - case 11: - TileEntityDynamicTank tileEntity = (TileEntityDynamicTank)world.getTileEntity(x, y, z); - - if(tileEntity != null) - { - if(FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) - { - if(tileEntity.structure != null) - { - return false; - } - } - else { - if(tileEntity.clientHasStructure) - { - return false; - } - } - } - default: - return super.canCreatureSpawn(type, world, x, y, z); - } - case BASIC_BLOCK_2: - switch(meta) - { - case 1: - case 2: - case 7: - case 8: - TileEntityMultiblock tileEntity = (TileEntityMultiblock)world.getTileEntity(x, y, z); - - if(tileEntity != null) - { - if(FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) - { - if(tileEntity.structure != null) - { - return false; - } - } - else { - if(tileEntity.clientHasStructure) - { - return false; - } - } - } - default: - return super.canCreatureSpawn(type, world, x, y, z); - } - default: - return super.canCreatureSpawn(type, world, x, y, z); - } - } - - @Override - public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) - { - BasicType type = BasicType.get(this, world.getBlockMetadata(x, y, z)); - - if(!world.isRemote && type == BasicType.BIN) - { - TileEntityBin bin = (TileEntityBin)world.getTileEntity(x, y, z); - MovingObjectPosition pos = MekanismUtils.rayTrace(world, player); - - if(pos != null && pos.sideHit == bin.facing) - { - if(bin.bottomStack != null) - { - if(!player.isSneaking()) - { - world.spawnEntityInWorld(new EntityItem(world, player.posX, player.posY, player.posZ, bin.removeStack().copy())); - } - else { - world.spawnEntityInWorld(new EntityItem(world, player.posX, player.posY, player.posZ, bin.remove(1).copy())); - } - } - } - } - } - - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int i1, float f1, float f2, float f3) - { - int metadata = world.getBlockMetadata(x, y, z); - BasicType type = BasicType.get(this, metadata); - TileEntity tile = world.getTileEntity(x, y, z); - - if(type == BasicType.REFINED_OBSIDIAN) - { - if(entityplayer.isSneaking()) - { - entityplayer.openGui(Mekanism.instance, 1, world, x, y, z); - return true; - } - } - - if(tile instanceof TileEntityThermalEvaporationController) - { - if(!entityplayer.isSneaking()) - { - if(!world.isRemote) - { - entityplayer.openGui(Mekanism.instance, 33, world, x, y, z); - } - - return true; - } - } - else if(tile instanceof TileEntitySecurityDesk) - { - String owner = ((TileEntitySecurityDesk)tile).owner; - - if(!entityplayer.isSneaking()) - { - if(!world.isRemote) - { - if(owner == null || entityplayer.getCommandSenderName().equals(owner)) - { - entityplayer.openGui(Mekanism.instance, 57, world, x, y, z); - } - else { - SecurityUtils.displayNoAccess(entityplayer); - } - } - - return true; - } - } - else if(tile instanceof TileEntityBin) - { - TileEntityBin bin = (TileEntityBin)world.getTileEntity(x, y, z); - - if(entityplayer.getCurrentEquippedItem() != null && MekanismUtils.hasUsableWrench(entityplayer, x, y, z)) - { - if(!world.isRemote) - { - Item tool = entityplayer.getCurrentEquippedItem().getItem(); - - if(entityplayer.isSneaking()) - { - dismantleBlock(world, x, y, z, false); - return true; - } - - if(MekanismUtils.isBCWrench(tool)) - { - ((IToolWrench)tool).wrenchUsed(entityplayer, x, y, z); - } - - int change = ForgeDirection.ROTATION_MATRIX[ForgeDirection.UP.ordinal()][bin.facing]; - - bin.setFacing((short)change); - world.notifyBlocksOfNeighborChange(x, y, z, this); - } - - return true; - } - - if(!world.isRemote) - { - if(bin.getItemCount() < bin.tier.storage) - { - if(bin.addTicks == 0 && entityplayer.getCurrentEquippedItem() != null) - { - if(entityplayer.getCurrentEquippedItem() != null) - { - ItemStack remain = bin.add(entityplayer.getCurrentEquippedItem()); - entityplayer.setCurrentItemOrArmor(0, remain); - bin.addTicks = 5; - } - } - else if(bin.addTicks > 0 && bin.getItemCount() > 0) - { - ItemStack[] inv = entityplayer.inventory.mainInventory; - - for(int i = 0; i < inv.length; i++) - { - if(bin.getItemCount() == bin.tier.storage) - { - break; - } - - if(inv[i] != null) - { - ItemStack remain = bin.add(inv[i]); - inv[i] = remain; - bin.addTicks = 5; - } - - ((EntityPlayerMP)entityplayer).sendContainerAndContentsToPlayer(entityplayer.openContainer, entityplayer.openContainer.getInventory()); - } - } - } - } - - return true; - } - else if(tile instanceof IMultiblock) - { - if(world.isRemote) - { - return true; - } - - return ((IMultiblock)world.getTileEntity(x, y, z)).onActivate(entityplayer); - } - else if(tile instanceof IStructuralMultiblock) - { - if(world.isRemote) - { - return true; - } - - return ((IStructuralMultiblock)world.getTileEntity(x, y, z)).onActivate(entityplayer); - } - - return false; - } - - @Override - public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) - { - return BasicType.get(this, world.getBlockMetadata(x, y, z)) != BasicType.STRUCTURAL_GLASS; - } - - public static boolean manageInventory(EntityPlayer player, TileEntityDynamicTank tileEntity) - { - ItemStack itemStack = player.getCurrentEquippedItem(); - - if(itemStack != null && tileEntity.structure != null) - { - if(FluidContainerRegistry.isEmptyContainer(itemStack)) - { - if(tileEntity.structure.fluidStored != null && tileEntity.structure.fluidStored.amount >= FluidContainerRegistry.BUCKET_VOLUME) - { - ItemStack filled = FluidContainerRegistry.fillFluidContainer(tileEntity.structure.fluidStored, itemStack); - - if(filled != null) - { - if(player.capabilities.isCreativeMode) - { - tileEntity.structure.fluidStored.amount -= FluidContainerRegistry.getFluidForFilledItem(filled).amount; - - if(tileEntity.structure.fluidStored.amount == 0) - { - tileEntity.structure.fluidStored = null; - } - - return true; - } - - if(itemStack.stackSize > 1) - { - if(player.inventory.addItemStackToInventory(filled)) - { - itemStack.stackSize--; - - tileEntity.structure.fluidStored.amount -= FluidContainerRegistry.getFluidForFilledItem(filled).amount; - - if(tileEntity.structure.fluidStored.amount == 0) - { - tileEntity.structure.fluidStored = null; - } - - return true; - } - } - else if(itemStack.stackSize == 1) - { - player.setCurrentItemOrArmor(0, filled); - - tileEntity.structure.fluidStored.amount -= FluidContainerRegistry.getFluidForFilledItem(filled).amount; - - if(tileEntity.structure.fluidStored.amount == 0) - { - tileEntity.structure.fluidStored = null; - } - - return true; - } - } - } - } - else if(FluidContainerRegistry.isFilledContainer(itemStack)) - { - FluidStack itemFluid = FluidContainerRegistry.getFluidForFilledItem(itemStack); - int max = tileEntity.structure.volume*TankUpdateProtocol.FLUID_PER_TANK; - - if(tileEntity.structure.fluidStored == null || (tileEntity.structure.fluidStored.isFluidEqual(itemFluid) && (tileEntity.structure.fluidStored.amount+itemFluid.amount <= max))) - { - boolean filled = false; - - if(player.capabilities.isCreativeMode) - { - filled = true; - } - else { - ItemStack containerItem = itemStack.getItem().getContainerItem(itemStack); - - if(containerItem != null) - { - if(itemStack.stackSize == 1) - { - player.setCurrentItemOrArmor(0, containerItem); - filled = true; - } - else { - if(player.inventory.addItemStackToInventory(containerItem)) - { - itemStack.stackSize--; - - filled = true; - } - } - } - else { - itemStack.stackSize--; - - if(itemStack.stackSize == 0) - { - player.setCurrentItemOrArmor(0, null); - } - - filled = true; - } - } - - if(filled) - { - if(tileEntity.structure.fluidStored == null) - { - tileEntity.structure.fluidStored = itemFluid; - } - else { - tileEntity.structure.fluidStored.amount += itemFluid.amount; - } - - return true; - } - } - } - } - - return false; - } - - @Override - public boolean renderAsNormalBlock() - { - return false; - } - - @Override - public boolean isOpaqueCube() - { - return false; - } - - @Override - public int getRenderType() - { - return Mekanism.proxy.CTM_RENDER_ID; - } - - @Override - public int getLightValue(IBlockAccess world, int x, int y, int z) - { - TileEntity tileEntity = world.getTileEntity(x, y, z); - int metadata = world.getBlockMetadata(x, y, z); - - if(tileEntity instanceof IActiveState) - { - if(((IActiveState)tileEntity).getActive() && ((IActiveState)tileEntity).lightUpdate()) - { - return 15; - } - } - - if(blockType == BasicBlock.BASIC_BLOCK_1) - { - switch(metadata) - { - case 2: - return 8; - case 4: - return 15; - case 7: - return 12; - } - } - else if(blockType == BasicBlock.BASIC_BLOCK_2) - { - if(metadata == 5) - { - TileEntitySuperheatingElement element = (TileEntitySuperheatingElement)tileEntity; - - if(element.multiblockUUID != null && SynchronizedBoilerData.clientHotMap.get(element.multiblockUUID) != null) - { - return SynchronizedBoilerData.clientHotMap.get(element.multiblockUUID) ? 15 : 0; - } - - return 0; - } - } - - return 0; - } - - @Override - public boolean hasTileEntity(int metadata) - { - BasicType type = BasicType.get(blockType, metadata); - - return type != null && type.tileEntityClass != null; - } - - @Override - public void onBlockAdded(World world, int x, int y, int z) - { - TileEntity tileEntity = world.getTileEntity(x, y, z); - - if(!world.isRemote) - { - if(tileEntity instanceof TileEntityBasicBlock) - { - ((TileEntityBasicBlock)tileEntity).onAdded(); - } - } - } - - @Override - public TileEntity createTileEntity(World world, int metadata) - { - if(BasicType.get(blockType, metadata) == null) - { - return null; - } - - return BasicType.get(blockType, metadata).create(); - } - - @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack itemstack) - { - if(world.getTileEntity(x, y, z) instanceof TileEntityBasicBlock) - { - TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(x, y, z); - int side = MathHelper.floor_double((entityliving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; - int height = Math.round(entityliving.rotationPitch); - int change = 3; - - if(tileEntity.canSetFacing(0) && tileEntity.canSetFacing(1)) - { - if(height >= 65) - { - change = 1; - } - else if(height <= -65) - { - change = 0; - } - } - - if(change != 0 && change != 1) - { - switch(side) - { - case 0: change = 2; break; - case 1: change = 5; break; - case 2: change = 3; break; - case 3: change = 4; break; - } - } - - tileEntity.setFacing((short)change); - tileEntity.redstone = world.isBlockIndirectlyGettingPowered(x, y, z); - - if(tileEntity instanceof TileEntitySecurityDesk) - { - ((TileEntitySecurityDesk)tileEntity).owner = entityliving.getCommandSenderName(); - } - - if(tileEntity instanceof IBoundingBlock) - { - ((IBoundingBlock)tileEntity).onPlace(); - } - } - - world.func_147479_m(x, y, z); - world.updateLightByType(EnumSkyBlock.Block, x, y, z); - world.updateLightByType(EnumSkyBlock.Sky, x, y, z); - - if(!world.isRemote && world.getTileEntity(x, y, z) != null) - { - TileEntity tileEntity = world.getTileEntity(x, y, z); - - if(tileEntity instanceof IMultiblock) - { - ((IMultiblock)tileEntity).update(); - } - - if(tileEntity instanceof IStructuralMultiblock) - { - ((IStructuralMultiblock)tileEntity).update(); - } - } - } - - @Override - public void breakBlock(World world, int x, int y, int z, Block block, int meta) - { - TileEntity tileEntity = world.getTileEntity(x, y, z); - - if(tileEntity instanceof IBoundingBlock) - { - ((IBoundingBlock)tileEntity).onBreak(); - } - - super.breakBlock(world, x, y, z, block, meta); - } - - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) - { - BasicType type = BasicType.get(this, world.getBlockMetadata(x, y, z)); - ItemStack ret = new ItemStack(this, 1, type.meta); - - if(type == BasicType.BIN) - { - TileEntityBin tileEntity = (TileEntityBin)world.getTileEntity(x, y, z); - InventoryBin inv = new InventoryBin(ret); - - ((ITierItem)ret.getItem()).setBaseTier(ret, tileEntity.tier.getBaseTier()); - inv.setItemCount(tileEntity.getItemCount()); - - if(tileEntity.getItemCount() > 0) - { - inv.setItemType(tileEntity.itemType); - } - } - else if(type == BasicType.INDUCTION_CELL) - { - TileEntityInductionCell tileEntity = (TileEntityInductionCell)world.getTileEntity(x, y, z); - ((ItemBlockBasic)ret.getItem()).setBaseTier(ret, tileEntity.tier.getBaseTier()); - } - else if(type == BasicType.INDUCTION_PROVIDER) - { - TileEntityInductionProvider tileEntity = (TileEntityInductionProvider)world.getTileEntity(x, y, z); - ((ItemBlockBasic)ret.getItem()).setBaseTier(ret, tileEntity.tier.getBaseTier()); - } - - TileEntity tileEntity = world.getTileEntity(x, y, z); - - if(tileEntity instanceof IStrictEnergyStorage) - { - IEnergizedItem energizedItem = (IEnergizedItem)ret.getItem(); - energizedItem.setEnergy(ret, ((IStrictEnergyStorage)tileEntity).getEnergy()); - } - - return ret; - } - - @Override - public Item getItemDropped(int i, Random random, int j) - { - return null; - } - - @Override - public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) - { - if(!player.capabilities.isCreativeMode && !world.isRemote && willHarvest) - { - float motion = 0.7F; - double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - - EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, getPickBlock(null, world, x, y, z, player)); - - world.spawnEntityInWorld(entityItem); - } - - return world.setBlockToAir(x, y, z); - } - - public ItemStack dismantleBlock(World world, int x, int y, int z, boolean returnBlock) - { - ItemStack itemStack = getPickBlock(null, world, x, y, z, null); - - world.setBlockToAir(x, y, z); - - if(!returnBlock) - { - float motion = 0.7F; - double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - - EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, itemStack); - - world.spawnEntityInWorld(entityItem); - } - - return itemStack; - } - - @Override - @SideOnly(Side.CLIENT) - public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) - { - Coord4D obj = new Coord4D(x, y, z).getFromSide(ForgeDirection.getOrientation(side).getOpposite()); - - if(BasicType.get(this, obj.getMetadata(world)) == BasicType.STRUCTURAL_GLASS) - { - return ctms[10][0].shouldRenderSide(world, x, y, z, side); - } - else { - return super.shouldSideBeRendered(world, x, y, z, side); - } - } - - @Override - public ForgeDirection[] getValidRotations(World world, int x, int y, int z) - { - TileEntity tile = world.getTileEntity(x, y, z); - ForgeDirection[] valid = new ForgeDirection[6]; - - if(tile instanceof TileEntityBasicBlock) - { - TileEntityBasicBlock basicTile = (TileEntityBasicBlock)tile; - - for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) - { - if(basicTile.canSetFacing(dir.ordinal())) - { - valid[dir.ordinal()] = dir; - } - } - } - - return valid; - } - - @Override - public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis) - { - TileEntity tile = world.getTileEntity(x, y, z); - - if(tile instanceof TileEntityBasicBlock) - { - TileEntityBasicBlock basicTile = (TileEntityBasicBlock)tile; - - if(basicTile.canSetFacing(axis.ordinal())) - { - basicTile.setFacing((short)axis.ordinal()); - return true; - } - } - - return false; - } - - @Override - public CTMData getCTMData(IBlockAccess world, int x, int y, int z, int meta) - { - if(ctms[meta][1] != null && MekanismUtils.isActive(world, x, y, z)) - { - return ctms[meta][1]; - } - - BasicType type = BasicType.get(this, world.getBlockMetadata(x, y, z)); - - if(type == BasicType.INDUCTION_CELL) - { - TileEntityInductionCell tileEntity = (TileEntityInductionCell)world.getTileEntity(x, y, z); - return ctms[meta][tileEntity.tier.ordinal()]; - } - else if(type == BasicType.INDUCTION_PROVIDER) - { - TileEntityInductionProvider tileEntity = (TileEntityInductionProvider)world.getTileEntity(x, y, z); - return ctms[meta][tileEntity.tier.ordinal()]; - } - else if(type == BasicType.SUPERHEATING_ELEMENT) - { - TileEntitySuperheatingElement element = (TileEntitySuperheatingElement)world.getTileEntity(x, y, z); - - if(element.multiblockUUID != null && SynchronizedBoilerData.clientHotMap.get(element.multiblockUUID) != null) - { - return ctms[meta][SynchronizedBoilerData.clientHotMap.get(element.multiblockUUID) ? 1 : 0]; - } - - return ctms[meta][0]; - } - - return ctms[meta][0]; - } - - @Override - public boolean shouldRenderBlock(IBlockAccess world, int x, int y, int z, int meta) - { - return BasicType.get(this, world.getBlockMetadata(x, y, z)) != BasicType.SECURITY_DESK; - } - - public static enum BasicType - { - OSMIUM_BLOCK(BasicBlock.BASIC_BLOCK_1, 0, "OsmiumBlock", null, false), - BRONZE_BLOCK(BasicBlock.BASIC_BLOCK_1, 1, "BronzeBlock", null, false), - REFINED_OBSIDIAN(BasicBlock.BASIC_BLOCK_1, 2, "RefinedObsidian", null, false), - CHARCOAL_BLOCK(BasicBlock.BASIC_BLOCK_1, 3, "CharcoalBlock", null, false), - REFINED_GLOWSTONE(BasicBlock.BASIC_BLOCK_1, 4, "RefinedGlowstone", null, false), - STEEL_BLOCK(BasicBlock.BASIC_BLOCK_1, 5, "SteelBlock", null, false), - BIN(BasicBlock.BASIC_BLOCK_1, 6, "Bin", TileEntityBin.class, true), - TELEPORTER_FRAME(BasicBlock.BASIC_BLOCK_1, 7, "TeleporterFrame", null, true), - STEEL_CASING(BasicBlock.BASIC_BLOCK_1, 8, "SteelCasing", null, true), - DYNAMIC_TANK(BasicBlock.BASIC_BLOCK_1, 9, "DynamicTank", TileEntityDynamicTank.class, true), - STRUCTURAL_GLASS(BasicBlock.BASIC_BLOCK_1, 10, "StructuralGlass", TileEntityStructuralGlass.class, true), - DYNAMIC_VALVE(BasicBlock.BASIC_BLOCK_1, 11, "DynamicValve", TileEntityDynamicValve.class, true), - COPPER_BLOCK(BasicBlock.BASIC_BLOCK_1, 12, "CopperBlock", null, false), - TIN_BLOCK(BasicBlock.BASIC_BLOCK_1, 13, "TinBlock", null, false), - THERMAL_EVAPORATION_CONTROLLER(BasicBlock.BASIC_BLOCK_1, 14, "ThermalEvaporationController", TileEntityThermalEvaporationController.class, true), - THERMAL_EVAPORATION_VALVE(BasicBlock.BASIC_BLOCK_1, 15, "ThermalEvaporationValve", TileEntityThermalEvaporationValve.class, true), - THERMAL_EVAPORATION_BLOCK(BasicBlock.BASIC_BLOCK_2, 0, "ThermalEvaporationBlock", TileEntityThermalEvaporationBlock.class, true), - INDUCTION_CASING(BasicBlock.BASIC_BLOCK_2, 1, "InductionCasing", TileEntityInductionCasing.class, true), - INDUCTION_PORT(BasicBlock.BASIC_BLOCK_2, 2, "InductionPort", TileEntityInductionPort.class, true), - INDUCTION_CELL(BasicBlock.BASIC_BLOCK_2, 3, "InductionCell", TileEntityInductionCell.class, true), - INDUCTION_PROVIDER(BasicBlock.BASIC_BLOCK_2, 4, "InductionProvider", TileEntityInductionProvider.class, true), - SUPERHEATING_ELEMENT(BasicBlock.BASIC_BLOCK_2, 5, "SuperheatingElement", TileEntitySuperheatingElement.class, true), - PRESSURE_DISPERSER(BasicBlock.BASIC_BLOCK_2, 6, "PressureDisperser", TileEntityPressureDisperser.class, true), - BOILER_CASING(BasicBlock.BASIC_BLOCK_2, 7, "BoilerCasing", TileEntityBoilerCasing.class, true), - BOILER_VALVE(BasicBlock.BASIC_BLOCK_2, 8, "BoilerValve", TileEntityBoilerValve.class, true), - SECURITY_DESK(BasicBlock.BASIC_BLOCK_2, 9, "SecurityDesk", TileEntitySecurityDesk.class, true); - - public BasicBlock typeBlock; - public int meta; - public String name; - public Class tileEntityClass; - public boolean hasDescription; - - private BasicType(BasicBlock block, int i, String s, Class tileClass, boolean hasDesc) - { - typeBlock = block; - meta = i; - name = s; - tileEntityClass = tileClass; - hasDescription = hasDesc; - } - - public static BasicType get(Block block, int meta) - { - if(block instanceof BlockBasic) - { - return get(((BlockBasic)block).blockType, meta); - } - - return null; - } - - public static BasicType get(BasicBlock block, int meta) - { - for(BasicType type : values()) - { - if(type.meta == meta && type.typeBlock == block) - { - return type; - } - } - - return null; - } - - public TileEntity create() - { - try { - return tileEntityClass.newInstance(); - } catch(Exception e) { - Mekanism.logger.error("Unable to indirectly create tile entity."); - e.printStackTrace(); - return null; - } - } - - public String getDescription() - { - return LangUtils.localize("tooltip." + name); - } - - public ItemStack getStack() - { - return new ItemStack(typeBlock.getBlock(), 1, meta); - } - - public static BasicType get(ItemStack stack) - { - return get(Block.getBlockFromItem(stack.getItem()), stack.getItemDamage()); - } - } - - public static enum BasicBlock - { - BASIC_BLOCK_1, - BASIC_BLOCK_2; - - public Block getBlock() - { - switch(this) - { - case BASIC_BLOCK_1: - return MekanismBlocks.BasicBlock; - case BASIC_BLOCK_2: - return MekanismBlocks.BasicBlock2; - default: - return null; - } - } - } + @Override + public IIcon getIcon(ItemStack stack, int side) { + if (BasicType.get(stack) == BasicType.BIN) { + return binIcons + [((ItemBlockBasic) stack.getItem()).getBaseTier(stack).ordinal()][side]; + } else if (BasicType.get(stack) == BasicType.INDUCTION_CELL) { + return icons[3] + [((ItemBlockBasic) stack.getItem()).getBaseTier(stack).ordinal()]; + } else if (BasicType.get(stack) == BasicType.INDUCTION_PROVIDER) { + return icons[4] + [((ItemBlockBasic) stack.getItem()).getBaseTier(stack).ordinal()]; + } + + return getIcon(side, stack.getItemDamage()); + } + + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + if (!world.isRemote) { + TileEntity tileEntity = world.getTileEntity(x, y, z); + + if (block == this && tileEntity instanceof IMultiblock) { + ((IMultiblock) tileEntity).update(); + } + + if (tileEntity instanceof TileEntityBasicBlock) { + ((TileEntityBasicBlock) tileEntity).onNeighborChange(block); + } + + if (tileEntity instanceof IStructuralMultiblock) { + ((IStructuralMultiblock) tileEntity).update(); + } + } + } + + @Override + public float getExplosionResistance( + Entity entity, + World world, + int x, + int y, + int z, + double explosionX, + double explosionY, + double explosionZ + ) { + BasicType type = BasicType.get(this, world.getBlockMetadata(x, y, z)); + + if (type == BasicType.REFINED_OBSIDIAN) { + return 4000F; + } + + return blockResistance; + } + + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister register) { + switch (blockType) { + case BASIC_BLOCK_1: + ctms[7][0] = new CTMData("ctm/TeleporterFrame", this, Arrays.asList(7)) + .addOtherBlockConnectivities( + MekanismBlocks.MachineBlock, Arrays.asList(11) + ) + .registerIcons(register); + ctms[9][0] = new CTMData("ctm/DynamicTank", this, Arrays.asList(9, 11)) + .registerIcons(register); + ctms[10][0] = new CTMData("ctm/StructuralGlass", this, Arrays.asList(10)) + .registerIcons(register); + ctms[11][0] = new CTMData("ctm/DynamicValve", this, Arrays.asList(11, 9)) + .registerIcons(register); + + ctms[14][0] + = new CTMData( + "ctm/ThermalEvaporationBlock", this, Arrays.asList(14, 15) + ) + .addOtherBlockConnectivities( + MekanismBlocks.BasicBlock2, Arrays.asList(0) + ) + .addFacingOverride("ctm/ThermalEvaporationController") + .registerIcons(register); + ctms[14][1] + = new CTMData( + "ctm/ThermalEvaporationBlock", this, Arrays.asList(14, 15) + ) + .addOtherBlockConnectivities( + MekanismBlocks.BasicBlock2, Arrays.asList(0) + ) + .addFacingOverride("ctm/ThermalEvaporationControllerOn") + .registerIcons(register); + ctms[15][0] + = new CTMData( + "ctm/ThermalEvaporationValve", this, Arrays.asList(15, 14) + ) + .addOtherBlockConnectivities( + MekanismBlocks.BasicBlock2, Arrays.asList(0) + ) + .registerIcons(register); + + icons[0][0] = register.registerIcon("mekanism:OsmiumBlock"); + icons[1][0] = register.registerIcon("mekanism:BronzeBlock"); + icons[2][0] = register.registerIcon("mekanism:RefinedObsidian"); + icons[3][0] = register.registerIcon("mekanism:CoalBlock"); + icons[4][0] = register.registerIcon("mekanism:RefinedGlowstone"); + icons[5][0] = register.registerIcon("mekanism:SteelBlock"); + icons[6][0] = register.registerIcon(ICON_BASE); + + MekanismRenderer.loadDynamicTextures( + register, + "bin/BinBasic", + binIcons[0], + new DefIcon(register.registerIcon("mekanism:bin/BinBasicTop"), 0), + new DefIcon(register.registerIcon("mekanism:bin/BinBasicTopOn"), 6) + ); + MekanismRenderer.loadDynamicTextures( + register, + "bin/BinAdvanced", + binIcons[1], + new DefIcon(register.registerIcon("mekanism:bin/BinAdvancedTop"), 0), + new DefIcon(register.registerIcon("mekanism:bin/BinAdvancedTopOn"), 6) + ); + MekanismRenderer.loadDynamicTextures( + register, + "bin/BinElite", + binIcons[2], + new DefIcon(register.registerIcon("mekanism:bin/BinEliteTop"), 0), + new DefIcon(register.registerIcon("mekanism:bin/BinEliteTopOn"), 6) + ); + MekanismRenderer.loadDynamicTextures( + register, + "bin/BinUltimate", + binIcons[3], + new DefIcon(register.registerIcon("mekanism:bin/BinUltimateTop"), 0), + new DefIcon(register.registerIcon("mekanism:bin/BinUltimateTopOn"), 6) + ); + + icons[7][0] = ctms[7][0].mainTextureData.icon; + icons[8][0] = register.registerIcon("mekanism:SteelCasing"); + icons[9][0] = ctms[9][0].mainTextureData.icon; + icons[10][0] = ctms[10][0].mainTextureData.icon; + icons[11][0] = ctms[11][0].mainTextureData.icon; + icons[12][0] = register.registerIcon("mekanism:CopperBlock"); + icons[13][0] = register.registerIcon("mekanism:TinBlock"); + icons[14][0] = ctms[14][0].facingOverride.icon; + icons[14][1] = ctms[14][1].facingOverride.icon; + icons[14][2] = ctms[14][0].mainTextureData.icon; + icons[15][0] = ctms[15][0].mainTextureData.icon; + break; + case BASIC_BLOCK_2: + ctms[0][0] + = new CTMData("ctm/ThermalEvaporationBlock", this, Arrays.asList(0)) + .addOtherBlockConnectivities( + MekanismBlocks.BasicBlock, Arrays.asList(14, 15) + ) + .registerIcons(register); + ctms[1][0] = new CTMData("ctm/InductionCasing", this, Arrays.asList(1, 2)) + .registerIcons(register); + ctms[2][0] + = new CTMData("ctm/InductionPortInput", this, Arrays.asList(1, 2)) + .registerIcons(register); + ctms[2][1] + = new CTMData("ctm/InductionPortOutput", this, Arrays.asList(1, 2)) + .registerIcons(register); + ctms[3][0] + = new CTMData("ctm/InductionCellBasic", this, Arrays.asList(3, 4)) + .registerIcons(register) + .setRenderConvexConnections(); + ctms[3][1] + = new CTMData("ctm/InductionCellAdvanced", this, Arrays.asList(3, 4)) + .registerIcons(register) + .setRenderConvexConnections(); + ctms[3][2] + = new CTMData("ctm/InductionCellElite", this, Arrays.asList(3, 4)) + .registerIcons(register) + .setRenderConvexConnections(); + ctms[3][3] + = new CTMData("ctm/InductionCellUltimate", this, Arrays.asList(3, 4)) + .registerIcons(register) + .setRenderConvexConnections(); + ctms[4][0] + = new CTMData("ctm/InductionProviderBasic", this, Arrays.asList(3, 4)) + .registerIcons(register) + .setRenderConvexConnections(); + ctms[4][1] + = new CTMData( + "ctm/InductionProviderAdvanced", this, Arrays.asList(3, 4) + ) + .registerIcons(register) + .setRenderConvexConnections(); + ctms[4][2] + = new CTMData("ctm/InductionProviderElite", this, Arrays.asList(3, 4)) + .registerIcons(register) + .setRenderConvexConnections(); + ctms[4][3] + = new CTMData( + "ctm/InductionProviderUltimate", this, Arrays.asList(3, 4) + ) + .registerIcons(register) + .setRenderConvexConnections(); + ctms[5][0] + = new CTMData("ctm/SuperheatingElement", this, Arrays.asList(5)) + .registerIcons(register) + .setRenderConvexConnections(); + ctms[5][1] + = new CTMData("ctm/SuperheatingElementOn", this, Arrays.asList(5)) + .registerIcons(register) + .setRenderConvexConnections(); + ctms[7][0] = new CTMData("ctm/BoilerCasing", this, Arrays.asList(7, 8)) + .registerIcons(register); + ctms[8][0] = new CTMData("ctm/BoilerValve", this, Arrays.asList(7, 8)) + .registerIcons(register); + + icons[6][0] = register.registerIcon("mekanism:PressureDisperser"); + + icons[0][0] = ctms[0][0].mainTextureData.icon; + icons[1][0] = ctms[1][0].mainTextureData.icon; + icons[2][0] = ctms[2][0].mainTextureData.icon; + icons[2][1] = ctms[2][1].mainTextureData.icon; + icons[3][0] = ctms[3][0].mainTextureData.icon; + icons[3][1] = ctms[3][1].mainTextureData.icon; + icons[3][2] = ctms[3][2].mainTextureData.icon; + icons[3][3] = ctms[3][3].mainTextureData.icon; + icons[4][0] = ctms[4][0].mainTextureData.icon; + icons[4][1] = ctms[4][1].mainTextureData.icon; + icons[4][2] = ctms[4][2].mainTextureData.icon; + icons[4][3] = ctms[4][3].mainTextureData.icon; + icons[5][0] = ctms[5][0].mainTextureData.icon; + icons[5][1] = ctms[5][1].mainTextureData.icon; + icons[7][0] = ctms[7][0].mainTextureData.icon; + icons[8][0] = ctms[8][0].mainTextureData.icon; + + icons[9][0] = register.registerIcon(ICON_BASE); + + break; + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { + int meta = world.getBlockMetadata(x, y, z); + + switch (blockType) { + case BASIC_BLOCK_1: + switch (meta) { + case 6: + TileEntityBin tileEntity + = (TileEntityBin) world.getTileEntity(x, y, z); + + boolean active = MekanismUtils.isActive(world, x, y, z); + return binIcons[tileEntity.tier.ordinal( + )][MekanismUtils.getBaseOrientation(side, tileEntity.facing) + + (active ? 6 : 0)]; + case 14: + TileEntityThermalEvaporationController tileEntity1 + = (TileEntityThermalEvaporationController + ) world.getTileEntity(x, y, z); + + if (side == tileEntity1.facing) { + return MekanismUtils.isActive(world, x, y, z) + ? icons[meta][1] + : icons[meta][0]; + } else { + return icons[meta][2]; + } + default: + return getIcon(side, meta); + } + case BASIC_BLOCK_2: + switch (meta) { + case 2: + TileEntityInductionPort tileEntity + = (TileEntityInductionPort) world.getTileEntity(x, y, z); + return icons[meta][tileEntity.mode ? 1 : 0]; + case 3: + TileEntityInductionCell tileEntity1 + = (TileEntityInductionCell) world.getTileEntity(x, y, z); + return icons[meta][tileEntity1.tier.ordinal()]; + case 4: + TileEntityInductionProvider tileEntity2 + = (TileEntityInductionProvider) world.getTileEntity(x, y, z); + return icons[meta][tileEntity2.tier.ordinal()]; + case 5: + TileEntitySuperheatingElement element + = (TileEntitySuperheatingElement + ) world.getTileEntity(x, y, z); + + if (element.multiblockUUID != null + && SynchronizedBoilerData.clientHotMap.get( + element.multiblockUUID + ) != null) { + return icons[meta] + [SynchronizedBoilerData.clientHotMap + .get(element.multiblockUUID) + ? 1 + : 0]; + } + + return icons[meta][0]; + default: + return getIcon(side, meta); + } + } + + return null; + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { + switch (blockType) { + case BASIC_BLOCK_1: + switch (meta) { + case 14: + if (side == 2) { + return icons[meta][0]; + } else { + return icons[meta][2]; + } + default: + return icons[meta][0]; + } + case BASIC_BLOCK_2: + return icons[meta][0]; + default: + return icons[meta][0]; + } + } + + @Override + public int damageDropped(int i) { + return i; + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item item, CreativeTabs creativetabs, List list) { + for (BasicType type : BasicType.values()) { + if (type.typeBlock == blockType) { + switch (type) { + case INDUCTION_CELL: + case INDUCTION_PROVIDER: + case BIN: + for (BaseTier tier : BaseTier.values()) { + if (tier.isObtainable()) { + ItemStack stack = new ItemStack(item, 1, type.meta); + ((ItemBlockBasic) stack.getItem()) + .setBaseTier(stack, tier); + list.add(stack); + } + } + + break; + default: + list.add(new ItemStack(item, 1, type.meta)); + } + } + } + } + + @Override + public boolean + canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) { + int meta = world.getBlockMetadata(x, y, z); + + switch (blockType) { + case BASIC_BLOCK_1: + switch (meta) { + case 10: + return false; + case 9: + case 11: + TileEntityDynamicTank tileEntity + = (TileEntityDynamicTank) world.getTileEntity(x, y, z); + + if (tileEntity != null) { + if (FMLCommonHandler.instance().getEffectiveSide() + == Side.SERVER) { + if (tileEntity.structure != null) { + return false; + } + } else { + if (tileEntity.clientHasStructure) { + return false; + } + } + } + default: + return super.canCreatureSpawn(type, world, x, y, z); + } + case BASIC_BLOCK_2: + switch (meta) { + case 1: + case 2: + case 7: + case 8: + TileEntityMultiblock tileEntity + = (TileEntityMultiblock) world.getTileEntity(x, y, z); + + if (tileEntity != null) { + if (FMLCommonHandler.instance().getEffectiveSide() + == Side.SERVER) { + if (tileEntity.structure != null) { + return false; + } + } else { + if (tileEntity.clientHasStructure) { + return false; + } + } + } + default: + return super.canCreatureSpawn(type, world, x, y, z); + } + default: + return super.canCreatureSpawn(type, world, x, y, z); + } + } + + @Override + public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) { + BasicType type = BasicType.get(this, world.getBlockMetadata(x, y, z)); + + if (!world.isRemote && type == BasicType.BIN) { + TileEntityBin bin = (TileEntityBin) world.getTileEntity(x, y, z); + MovingObjectPosition pos = MekanismUtils.rayTrace(world, player); + + if (pos != null && pos.sideHit == bin.facing) { + if (bin.bottomStack != null) { + if (!player.isSneaking()) { + world.spawnEntityInWorld(new EntityItem( + world, + player.posX, + player.posY, + player.posZ, + bin.removeStack().copy() + )); + } else { + world.spawnEntityInWorld(new EntityItem( + world, + player.posX, + player.posY, + player.posZ, + bin.remove(1).copy() + )); + } + } + } + } + } + + @Override + public boolean onBlockActivated( + World world, + int x, + int y, + int z, + EntityPlayer entityplayer, + int i1, + float f1, + float f2, + float f3 + ) { + int metadata = world.getBlockMetadata(x, y, z); + BasicType type = BasicType.get(this, metadata); + TileEntity tile = world.getTileEntity(x, y, z); + + if (type == BasicType.REFINED_OBSIDIAN) { + if (entityplayer.isSneaking()) { + entityplayer.openGui(Mekanism.instance, 1, world, x, y, z); + return true; + } + } + + if (tile instanceof TileEntityThermalEvaporationController) { + if (!entityplayer.isSneaking()) { + if (!world.isRemote) { + entityplayer.openGui(Mekanism.instance, 33, world, x, y, z); + } + + return true; + } + } else if (tile instanceof TileEntitySecurityDesk) { + String owner = ((TileEntitySecurityDesk) tile).owner; + + if (!entityplayer.isSneaking()) { + if (!world.isRemote) { + if (owner == null + || entityplayer.getCommandSenderName().equals(owner)) { + entityplayer.openGui(Mekanism.instance, 57, world, x, y, z); + } else { + SecurityUtils.displayNoAccess(entityplayer); + } + } + + return true; + } + } else if (tile instanceof TileEntityBin) { + TileEntityBin bin = (TileEntityBin) world.getTileEntity(x, y, z); + + if (entityplayer.getCurrentEquippedItem() != null + && MekanismUtils.hasUsableWrench(entityplayer, x, y, z)) { + if (!world.isRemote) { + Item tool = entityplayer.getCurrentEquippedItem().getItem(); + + if (entityplayer.isSneaking()) { + dismantleBlock(world, x, y, z, false); + return true; + } + + if (MekanismUtils.isBCWrench(tool)) { + ((IToolWrench) tool).wrenchUsed(entityplayer, x, y, z); + } + + int change + = ForgeDirection + .ROTATION_MATRIX[ForgeDirection.UP.ordinal()][bin.facing]; + + bin.setFacing((short) change); + world.notifyBlocksOfNeighborChange(x, y, z, this); + } + + return true; + } + + if (!world.isRemote) { + if (bin.getItemCount() < bin.tier.storage) { + if (bin.addTicks == 0 + && entityplayer.getCurrentEquippedItem() != null) { + if (entityplayer.getCurrentEquippedItem() != null) { + ItemStack remain + = bin.add(entityplayer.getCurrentEquippedItem()); + entityplayer.setCurrentItemOrArmor(0, remain); + bin.addTicks = 5; + } + } else if (bin.addTicks > 0 && bin.getItemCount() > 0) { + ItemStack[] inv = entityplayer.inventory.mainInventory; + + for (int i = 0; i < inv.length; i++) { + if (bin.getItemCount() == bin.tier.storage) { + break; + } + + if (inv[i] != null) { + ItemStack remain = bin.add(inv[i]); + inv[i] = remain; + bin.addTicks = 5; + } + + ((EntityPlayerMP) entityplayer) + .sendContainerAndContentsToPlayer( + entityplayer.openContainer, + entityplayer.openContainer.getInventory() + ); + } + } + } + } + + return true; + } else if (tile instanceof IMultiblock) { + if (world.isRemote) { + return true; + } + + return ((IMultiblock) world.getTileEntity(x, y, z)).onActivate(entityplayer); + } else if (tile instanceof IStructuralMultiblock) { + if (world.isRemote) { + return true; + } + + return ((IStructuralMultiblock) world.getTileEntity(x, y, z)) + .onActivate(entityplayer); + } + + return false; + } + + @Override + public boolean + isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + return BasicType.get(this, world.getBlockMetadata(x, y, z)) + != BasicType.STRUCTURAL_GLASS; + } + + public static boolean + manageInventory(EntityPlayer player, TileEntityDynamicTank tileEntity) { + ItemStack itemStack = player.getCurrentEquippedItem(); + + if (itemStack != null && tileEntity.structure != null) { + if (FluidContainerRegistry.isEmptyContainer(itemStack)) { + if (tileEntity.structure.fluidStored != null + && tileEntity.structure.fluidStored.amount + >= FluidContainerRegistry.BUCKET_VOLUME) { + ItemStack filled = FluidContainerRegistry.fillFluidContainer( + tileEntity.structure.fluidStored, itemStack + ); + + if (filled != null) { + if (player.capabilities.isCreativeMode) { + tileEntity.structure.fluidStored.amount + -= FluidContainerRegistry.getFluidForFilledItem(filled) + .amount; + + if (tileEntity.structure.fluidStored.amount == 0) { + tileEntity.structure.fluidStored = null; + } + + return true; + } + + if (itemStack.stackSize > 1) { + if (player.inventory.addItemStackToInventory(filled)) { + itemStack.stackSize--; + + tileEntity.structure.fluidStored.amount + -= FluidContainerRegistry + .getFluidForFilledItem(filled) + .amount; + + if (tileEntity.structure.fluidStored.amount == 0) { + tileEntity.structure.fluidStored = null; + } + + return true; + } + } else if (itemStack.stackSize == 1) { + player.setCurrentItemOrArmor(0, filled); + + tileEntity.structure.fluidStored.amount + -= FluidContainerRegistry.getFluidForFilledItem(filled) + .amount; + + if (tileEntity.structure.fluidStored.amount == 0) { + tileEntity.structure.fluidStored = null; + } + + return true; + } + } + } + } else if (FluidContainerRegistry.isFilledContainer(itemStack)) { + FluidStack itemFluid + = FluidContainerRegistry.getFluidForFilledItem(itemStack); + int max = tileEntity.structure.volume * TankUpdateProtocol.FLUID_PER_TANK; + + if (tileEntity.structure.fluidStored == null + || (tileEntity.structure.fluidStored.isFluidEqual(itemFluid) + && (tileEntity.structure.fluidStored.amount + itemFluid.amount + <= max))) { + boolean filled = false; + + if (player.capabilities.isCreativeMode) { + filled = true; + } else { + ItemStack containerItem + = itemStack.getItem().getContainerItem(itemStack); + + if (containerItem != null) { + if (itemStack.stackSize == 1) { + player.setCurrentItemOrArmor(0, containerItem); + filled = true; + } else { + if (player.inventory.addItemStackToInventory(containerItem + )) { + itemStack.stackSize--; + + filled = true; + } + } + } else { + itemStack.stackSize--; + + if (itemStack.stackSize == 0) { + player.setCurrentItemOrArmor(0, null); + } + + filled = true; + } + } + + if (filled) { + if (tileEntity.structure.fluidStored == null) { + tileEntity.structure.fluidStored = itemFluid; + } else { + tileEntity.structure.fluidStored.amount += itemFluid.amount; + } + + return true; + } + } + } + } + + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public int getRenderType() { + return Mekanism.proxy.CTM_RENDER_ID; + } + + @Override + public int getLightValue(IBlockAccess world, int x, int y, int z) { + TileEntity tileEntity = world.getTileEntity(x, y, z); + int metadata = world.getBlockMetadata(x, y, z); + + if (tileEntity instanceof IActiveState) { + if (((IActiveState) tileEntity).getActive() + && ((IActiveState) tileEntity).lightUpdate()) { + return 15; + } + } + + if (blockType == BasicBlock.BASIC_BLOCK_1) { + switch (metadata) { + case 2: + return 8; + case 4: + return 15; + case 7: + return 12; + } + } else if (blockType == BasicBlock.BASIC_BLOCK_2) { + if (metadata == 5) { + TileEntitySuperheatingElement element + = (TileEntitySuperheatingElement) tileEntity; + + if (element.multiblockUUID != null + && SynchronizedBoilerData.clientHotMap.get(element.multiblockUUID) + != null) { + return SynchronizedBoilerData.clientHotMap.get(element.multiblockUUID) + ? 15 + : 0; + } + + return 0; + } + } + + return 0; + } + + @Override + public boolean hasTileEntity(int metadata) { + BasicType type = BasicType.get(blockType, metadata); + + return type != null && type.tileEntityClass != null; + } + + @Override + public void onBlockAdded(World world, int x, int y, int z) { + TileEntity tileEntity = world.getTileEntity(x, y, z); + + if (!world.isRemote) { + if (tileEntity instanceof TileEntityBasicBlock) { + ((TileEntityBasicBlock) tileEntity).onAdded(); + } + } + } + + @Override + public TileEntity createTileEntity(World world, int metadata) { + if (BasicType.get(blockType, metadata) == null) { + return null; + } + + return BasicType.get(blockType, metadata).create(); + } + + @Override + public void onBlockPlacedBy( + World world, + int x, + int y, + int z, + EntityLivingBase entityliving, + ItemStack itemstack + ) { + if (world.getTileEntity(x, y, z) instanceof TileEntityBasicBlock) { + TileEntityBasicBlock tileEntity + = (TileEntityBasicBlock) world.getTileEntity(x, y, z); + int side = MathHelper.floor_double( + (entityliving.rotationYaw * 4.0F / 360.0F) + 0.5D + ) + & 3; + int height = Math.round(entityliving.rotationPitch); + int change = 3; + + if (tileEntity.canSetFacing(0) && tileEntity.canSetFacing(1)) { + if (height >= 65) { + change = 1; + } else if (height <= -65) { + change = 0; + } + } + + if (change != 0 && change != 1) { + switch (side) { + case 0: + change = 2; + break; + case 1: + change = 5; + break; + case 2: + change = 3; + break; + case 3: + change = 4; + break; + } + } + + tileEntity.setFacing((short) change); + tileEntity.redstone = world.isBlockIndirectlyGettingPowered(x, y, z); + + if (tileEntity instanceof TileEntitySecurityDesk) { + ((TileEntitySecurityDesk) tileEntity).owner + = entityliving.getCommandSenderName(); + } + + if (tileEntity instanceof IBoundingBlock) { + ((IBoundingBlock) tileEntity).onPlace(); + } + } + + world.func_147479_m(x, y, z); + world.updateLightByType(EnumSkyBlock.Block, x, y, z); + world.updateLightByType(EnumSkyBlock.Sky, x, y, z); + + if (!world.isRemote && world.getTileEntity(x, y, z) != null) { + TileEntity tileEntity = world.getTileEntity(x, y, z); + + if (tileEntity instanceof IMultiblock) { + ((IMultiblock) tileEntity).update(); + } + + if (tileEntity instanceof IStructuralMultiblock) { + ((IStructuralMultiblock) tileEntity).update(); + } + } + } + + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int meta) { + TileEntity tileEntity = world.getTileEntity(x, y, z); + + if (tileEntity instanceof IBoundingBlock) { + ((IBoundingBlock) tileEntity).onBreak(); + } + + super.breakBlock(world, x, y, z, block, meta); + } + + @Override + public ItemStack getPickBlock( + MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player + ) { + BasicType type = BasicType.get(this, world.getBlockMetadata(x, y, z)); + ItemStack ret = new ItemStack(this, 1, type.meta); + + if (type == BasicType.BIN) { + TileEntityBin tileEntity = (TileEntityBin) world.getTileEntity(x, y, z); + InventoryBin inv = new InventoryBin(ret); + + ((ITierItem) ret.getItem()).setBaseTier(ret, tileEntity.tier.getBaseTier()); + inv.setItemCount(tileEntity.getItemCount()); + + if (tileEntity.getItemCount() > 0) { + inv.setItemType(tileEntity.itemType); + } + } else if (type == BasicType.INDUCTION_CELL) { + TileEntityInductionCell tileEntity + = (TileEntityInductionCell) world.getTileEntity(x, y, z); + ((ItemBlockBasic) ret.getItem()) + .setBaseTier(ret, tileEntity.tier.getBaseTier()); + } else if (type == BasicType.INDUCTION_PROVIDER) { + TileEntityInductionProvider tileEntity + = (TileEntityInductionProvider) world.getTileEntity(x, y, z); + ((ItemBlockBasic) ret.getItem()) + .setBaseTier(ret, tileEntity.tier.getBaseTier()); + } + + TileEntity tileEntity = world.getTileEntity(x, y, z); + + if (tileEntity instanceof IStrictEnergyStorage) { + IEnergizedItem energizedItem = (IEnergizedItem) ret.getItem(); + energizedItem.setEnergy(ret, ((IStrictEnergyStorage) tileEntity).getEnergy()); + } + + return ret; + } + + @Override + public Item getItemDropped(int i, Random random, int j) { + return null; + } + + @Override + public boolean removedByPlayer( + World world, EntityPlayer player, int x, int y, int z, boolean willHarvest + ) { + if (!player.capabilities.isCreativeMode && !world.isRemote && willHarvest) { + float motion = 0.7F; + double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + + EntityItem entityItem = new EntityItem( + world, + x + motionX, + y + motionY, + z + motionZ, + getPickBlock(null, world, x, y, z, player) + ); + + world.spawnEntityInWorld(entityItem); + } + + return world.setBlockToAir(x, y, z); + } + + public ItemStack + dismantleBlock(World world, int x, int y, int z, boolean returnBlock) { + ItemStack itemStack = getPickBlock(null, world, x, y, z, null); + + world.setBlockToAir(x, y, z); + + if (!returnBlock) { + float motion = 0.7F; + double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + + EntityItem entityItem + = new EntityItem(world, x + motionX, y + motionY, z + motionZ, itemStack); + + world.spawnEntityInWorld(entityItem); + } + + return itemStack; + } + + @Override + @SideOnly(Side.CLIENT) + public boolean + shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) { + Coord4D obj = new Coord4D(x, y, z).getFromSide( + ForgeDirection.getOrientation(side).getOpposite() + ); + + if (BasicType.get(this, obj.getMetadata(world)) == BasicType.STRUCTURAL_GLASS) { + return ctms[10][0].shouldRenderSide(world, x, y, z, side); + } else { + return super.shouldSideBeRendered(world, x, y, z, side); + } + } + + @Override + public ForgeDirection[] getValidRotations(World world, int x, int y, int z) { + TileEntity tile = world.getTileEntity(x, y, z); + ForgeDirection[] valid = new ForgeDirection[6]; + + if (tile instanceof TileEntityBasicBlock) { + TileEntityBasicBlock basicTile = (TileEntityBasicBlock) tile; + + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + if (basicTile.canSetFacing(dir.ordinal())) { + valid[dir.ordinal()] = dir; + } + } + } + + return valid; + } + + @Override + public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis) { + TileEntity tile = world.getTileEntity(x, y, z); + + if (tile instanceof TileEntityBasicBlock) { + TileEntityBasicBlock basicTile = (TileEntityBasicBlock) tile; + + if (basicTile.canSetFacing(axis.ordinal())) { + basicTile.setFacing((short) axis.ordinal()); + return true; + } + } + + return false; + } + + @Override + public CTMData getCTMData(IBlockAccess world, int x, int y, int z, int meta) { + if (ctms[meta][1] != null && MekanismUtils.isActive(world, x, y, z)) { + return ctms[meta][1]; + } + + BasicType type = BasicType.get(this, world.getBlockMetadata(x, y, z)); + + if (type == BasicType.INDUCTION_CELL) { + TileEntityInductionCell tileEntity + = (TileEntityInductionCell) world.getTileEntity(x, y, z); + return ctms[meta][tileEntity.tier.ordinal()]; + } else if (type == BasicType.INDUCTION_PROVIDER) { + TileEntityInductionProvider tileEntity + = (TileEntityInductionProvider) world.getTileEntity(x, y, z); + return ctms[meta][tileEntity.tier.ordinal()]; + } else if (type == BasicType.SUPERHEATING_ELEMENT) { + TileEntitySuperheatingElement element + = (TileEntitySuperheatingElement) world.getTileEntity(x, y, z); + + if (element.multiblockUUID != null + && SynchronizedBoilerData.clientHotMap.get(element.multiblockUUID) + != null) { + return ctms[meta] + [SynchronizedBoilerData.clientHotMap.get(element.multiblockUUID + ) + ? 1 + : 0]; + } + + return ctms[meta][0]; + } + + return ctms[meta][0]; + } + + @Override + public boolean shouldRenderBlock(IBlockAccess world, int x, int y, int z, int meta) { + return BasicType.get(this, world.getBlockMetadata(x, y, z)) + != BasicType.SECURITY_DESK; + } + + public static enum BasicType { + OSMIUM_BLOCK(BasicBlock.BASIC_BLOCK_1, 0, "OsmiumBlock", null, false), + BRONZE_BLOCK(BasicBlock.BASIC_BLOCK_1, 1, "BronzeBlock", null, false), + REFINED_OBSIDIAN(BasicBlock.BASIC_BLOCK_1, 2, "RefinedObsidian", null, false), + CHARCOAL_BLOCK(BasicBlock.BASIC_BLOCK_1, 3, "CharcoalBlock", null, false), + REFINED_GLOWSTONE(BasicBlock.BASIC_BLOCK_1, 4, "RefinedGlowstone", null, false), + STEEL_BLOCK(BasicBlock.BASIC_BLOCK_1, 5, "SteelBlock", null, false), + BIN(BasicBlock.BASIC_BLOCK_1, 6, "Bin", TileEntityBin.class, true), + TELEPORTER_FRAME(BasicBlock.BASIC_BLOCK_1, 7, "TeleporterFrame", null, true), + STEEL_CASING(BasicBlock.BASIC_BLOCK_1, 8, "SteelCasing", null, true), + DYNAMIC_TANK( + BasicBlock.BASIC_BLOCK_1, 9, "DynamicTank", TileEntityDynamicTank.class, true + ), + STRUCTURAL_GLASS( + BasicBlock.BASIC_BLOCK_1, + 10, + "StructuralGlass", + TileEntityStructuralGlass.class, + true + ), + DYNAMIC_VALVE( + BasicBlock.BASIC_BLOCK_1, + 11, + "DynamicValve", + TileEntityDynamicValve.class, + true + ), + COPPER_BLOCK(BasicBlock.BASIC_BLOCK_1, 12, "CopperBlock", null, false), + TIN_BLOCK(BasicBlock.BASIC_BLOCK_1, 13, "TinBlock", null, false), + THERMAL_EVAPORATION_CONTROLLER( + BasicBlock.BASIC_BLOCK_1, + 14, + "ThermalEvaporationController", + TileEntityThermalEvaporationController.class, + true + ), + THERMAL_EVAPORATION_VALVE( + BasicBlock.BASIC_BLOCK_1, + 15, + "ThermalEvaporationValve", + TileEntityThermalEvaporationValve.class, + true + ), + THERMAL_EVAPORATION_BLOCK( + BasicBlock.BASIC_BLOCK_2, + 0, + "ThermalEvaporationBlock", + TileEntityThermalEvaporationBlock.class, + true + ), + INDUCTION_CASING( + BasicBlock.BASIC_BLOCK_2, + 1, + "InductionCasing", + TileEntityInductionCasing.class, + true + ), + INDUCTION_PORT( + BasicBlock.BASIC_BLOCK_2, + 2, + "InductionPort", + TileEntityInductionPort.class, + true + ), + INDUCTION_CELL( + BasicBlock.BASIC_BLOCK_2, + 3, + "InductionCell", + TileEntityInductionCell.class, + true + ), + INDUCTION_PROVIDER( + BasicBlock.BASIC_BLOCK_2, + 4, + "InductionProvider", + TileEntityInductionProvider.class, + true + ), + SUPERHEATING_ELEMENT( + BasicBlock.BASIC_BLOCK_2, + 5, + "SuperheatingElement", + TileEntitySuperheatingElement.class, + true + ), + PRESSURE_DISPERSER( + BasicBlock.BASIC_BLOCK_2, + 6, + "PressureDisperser", + TileEntityPressureDisperser.class, + true + ), + BOILER_CASING( + BasicBlock.BASIC_BLOCK_2, + 7, + "BoilerCasing", + TileEntityBoilerCasing.class, + true + ), + BOILER_VALVE( + BasicBlock.BASIC_BLOCK_2, 8, "BoilerValve", TileEntityBoilerValve.class, true + ), + SECURITY_DESK( + BasicBlock.BASIC_BLOCK_2, + 9, + "SecurityDesk", + TileEntitySecurityDesk.class, + true + ); + + public BasicBlock typeBlock; + public int meta; + public String name; + public Class tileEntityClass; + public boolean hasDescription; + + private BasicType( + BasicBlock block, + int i, + String s, + Class tileClass, + boolean hasDesc + ) { + typeBlock = block; + meta = i; + name = s; + tileEntityClass = tileClass; + hasDescription = hasDesc; + } + + public static BasicType get(Block block, int meta) { + if (block instanceof BlockBasic) { + return get(((BlockBasic) block).blockType, meta); + } + + return null; + } + + public static BasicType get(BasicBlock block, int meta) { + for (BasicType type : values()) { + if (type.meta == meta && type.typeBlock == block) { + return type; + } + } + + return null; + } + + public TileEntity create() { + try { + return tileEntityClass.newInstance(); + } catch (Exception e) { + Mekanism.logger.error("Unable to indirectly create tile entity."); + e.printStackTrace(); + return null; + } + } + + public String getDescription() { + return LangUtils.localize("tooltip." + name); + } + + public ItemStack getStack() { + return new ItemStack(typeBlock.getBlock(), 1, meta); + } + + public static BasicType get(ItemStack stack) { + return get(Block.getBlockFromItem(stack.getItem()), stack.getItemDamage()); + } + } + + public static enum BasicBlock { + BASIC_BLOCK_1, + BASIC_BLOCK_2; + + public Block getBlock() { + switch (this) { + case BASIC_BLOCK_1: + return MekanismBlocks.BasicBlock; + case BASIC_BLOCK_2: + return MekanismBlocks.BasicBlock2; + default: + return null; + } + } + } } \ No newline at end of file diff --git a/src/main/java/mekanism/common/block/BlockBounding.java b/src/main/java/mekanism/common/block/BlockBounding.java index 3a16ac6da..cd384d62e 100644 --- a/src/main/java/mekanism/common/block/BlockBounding.java +++ b/src/main/java/mekanism/common/block/BlockBounding.java @@ -2,6 +2,8 @@ package mekanism.common.block; import java.util.Random; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.common.tile.TileEntityAdvancedBoundingBlock; import mekanism.common.tile.TileEntityBoundingBlock; import net.minecraft.block.Block; @@ -13,147 +15,178 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class BlockBounding extends Block -{ - public BlockBounding() - { - super(Material.iron); - setHardness(3.5F); - setResistance(8F); - } +public class BlockBounding extends Block { + public BlockBounding() { + super(Material.iron); + setHardness(3.5F); + setResistance(8F); + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister register) - { - blockIcon = register.registerIcon(BlockBasic.ICON_BASE); - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister register) { + blockIcon = register.registerIcon(BlockBasic.ICON_BASE); + } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int facing, float playerX, float playerY, float playerZ) - { - try { - TileEntityBoundingBlock tileEntity = (TileEntityBoundingBlock)world.getTileEntity(x, y, z); - return getMainBlock(tileEntity, world).onBlockActivated(world, tileEntity.mainX, tileEntity.mainY, tileEntity.mainZ, entityplayer, facing, playerX, playerY, playerZ); - } catch(Exception e) { - return false; - } - } - - @Override - public void breakBlock(World world, int x, int y, int z, Block block, int meta) - { - super.breakBlock(world, x, y, z, block, meta); - - world.removeTileEntity(x, y, z); - } + @Override + public boolean onBlockActivated( + World world, + int x, + int y, + int z, + EntityPlayer entityplayer, + int facing, + float playerX, + float playerY, + float playerZ + ) { + try { + TileEntityBoundingBlock tileEntity + = (TileEntityBoundingBlock) world.getTileEntity(x, y, z); + return getMainBlock(tileEntity, world) + .onBlockActivated( + world, + tileEntity.mainX, + tileEntity.mainY, + tileEntity.mainZ, + entityplayer, + facing, + playerX, + playerY, + playerZ + ); + } catch (Exception e) { + return false; + } + } - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) - { - try { - TileEntityBoundingBlock tileEntity = (TileEntityBoundingBlock)world.getTileEntity(x, y, z); - return getMainBlock(tileEntity, world).getPickBlock(target, world, tileEntity.mainX, tileEntity.mainY, tileEntity.mainZ, player); - } catch(Exception e) { - return null; - } - } + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int meta) { + super.breakBlock(world, x, y, z, block, meta); - @Override - public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) - { - try { - TileEntityBoundingBlock tileEntity = (TileEntityBoundingBlock)world.getTileEntity(x, y, z); - return getMainBlock(tileEntity, world).removedByPlayer(world, player, tileEntity.mainX, tileEntity.mainY, tileEntity.mainZ, willHarvest); - } catch(Exception e) { - return false; - } - } + world.removeTileEntity(x, y, z); + } - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) - { - try { - TileEntityBoundingBlock tileEntity = (TileEntityBoundingBlock)world.getTileEntity(x, y, z); - tileEntity.onNeighborChange(block); - getMainBlock(tileEntity, world).onNeighborBlockChange(world, tileEntity.mainX, tileEntity.mainY, tileEntity.mainZ, this); - } catch(Exception e) {} - } - - @Override - public float getPlayerRelativeBlockHardness(EntityPlayer player, World world, int x, int y, int z) - { - try { - TileEntityBoundingBlock tileEntity = (TileEntityBoundingBlock)world.getTileEntity(x, y, z); - return getMainBlock(tileEntity, world).getPlayerRelativeBlockHardness(player, world, tileEntity.mainX, tileEntity.mainY, tileEntity.mainZ); - } catch(Exception e) { - return super.getPlayerRelativeBlockHardness(player, world, x, y, z); - } - } - - private Block getMainBlock(TileEntityBoundingBlock mainTile, World world) - { - Block block = world.getBlock(mainTile.mainX, mainTile.mainY, mainTile.mainZ); - - if(block instanceof BlockBounding) - { - return null; - } - - return block; - } + @Override + public ItemStack getPickBlock( + MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player + ) { + try { + TileEntityBoundingBlock tileEntity + = (TileEntityBoundingBlock) world.getTileEntity(x, y, z); + return getMainBlock(tileEntity, world) + .getPickBlock( + target, + world, + tileEntity.mainX, + tileEntity.mainY, + tileEntity.mainZ, + player + ); + } catch (Exception e) { + return null; + } + } - @Override - public int quantityDropped(Random random) - { - return 0; - } + @Override + public boolean removedByPlayer( + World world, EntityPlayer player, int x, int y, int z, boolean willHarvest + ) { + try { + TileEntityBoundingBlock tileEntity + = (TileEntityBoundingBlock) world.getTileEntity(x, y, z); + return getMainBlock(tileEntity, world) + .removedByPlayer( + world, + player, + tileEntity.mainX, + tileEntity.mainY, + tileEntity.mainZ, + willHarvest + ); + } catch (Exception e) { + return false; + } + } - @Override - public Item getItemDropped(int i, Random random, int j) - { - return null; - } + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + try { + TileEntityBoundingBlock tileEntity + = (TileEntityBoundingBlock) world.getTileEntity(x, y, z); + tileEntity.onNeighborChange(block); + getMainBlock(tileEntity, world) + .onNeighborBlockChange( + world, tileEntity.mainX, tileEntity.mainY, tileEntity.mainZ, this + ); + } catch (Exception e) {} + } - @Override - public int getRenderType() - { - return -1; - } + @Override + public float getPlayerRelativeBlockHardness( + EntityPlayer player, World world, int x, int y, int z + ) { + try { + TileEntityBoundingBlock tileEntity + = (TileEntityBoundingBlock) world.getTileEntity(x, y, z); + return getMainBlock(tileEntity, world) + .getPlayerRelativeBlockHardness( + player, world, tileEntity.mainX, tileEntity.mainY, tileEntity.mainZ + ); + } catch (Exception e) { + return super.getPlayerRelativeBlockHardness(player, world, x, y, z); + } + } - @Override - public boolean isOpaqueCube() - { - return false; - } + private Block getMainBlock(TileEntityBoundingBlock mainTile, World world) { + Block block = world.getBlock(mainTile.mainX, mainTile.mainY, mainTile.mainZ); - @Override - public boolean renderAsNormalBlock() - { - return false; - } + if (block instanceof BlockBounding) { + return null; + } - @Override - public boolean hasTileEntity(int metadata) - { - return true; - } + return block; + } - @Override - public TileEntity createTileEntity(World world, int metadata) - { - if(metadata == 0) - { - return new TileEntityBoundingBlock(); - } - else if(metadata == 1) - { - return new TileEntityAdvancedBoundingBlock(); - } + @Override + public int quantityDropped(Random random) { + return 0; + } - return null; - } + @Override + public Item getItemDropped(int i, Random random, int j) { + return null; + } + + @Override + public int getRenderType() { + return -1; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public boolean hasTileEntity(int metadata) { + return true; + } + + @Override + public TileEntity createTileEntity(World world, int metadata) { + if (metadata == 0) { + return new TileEntityBoundingBlock(); + } else if (metadata == 1) { + return new TileEntityAdvancedBoundingBlock(); + } + + return null; + } } diff --git a/src/main/java/mekanism/common/block/BlockCardboardBox.java b/src/main/java/mekanism/common/block/BlockCardboardBox.java index 0509b0ab3..599a6e4e4 100644 --- a/src/main/java/mekanism/common/block/BlockCardboardBox.java +++ b/src/main/java/mekanism/common/block/BlockCardboardBox.java @@ -2,6 +2,8 @@ package mekanism.common.block; import java.util.Random; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.common.Mekanism; import mekanism.common.MekanismBlocks; import mekanism.common.item.ItemBlockCardboardBox; @@ -20,232 +22,236 @@ import net.minecraft.util.IIcon; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class BlockCardboardBox extends BlockContainer -{ - private static boolean testingPlace = false; - - public IIcon[] icons = new IIcon[6]; +public class BlockCardboardBox extends BlockContainer { + private static boolean testingPlace = false; - public BlockCardboardBox() - { - super(Material.cloth); - setCreativeTab(Mekanism.tabMekanism); - setHardness(0.5F); - setResistance(1F); - } + public IIcon[] icons = new IIcon[6]; - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister register) - { - icons[0] = register.registerIcon("mekanism:CardboardBoxTop"); - icons[1] = register.registerIcon("mekanism:CardboardBoxSide"); - icons[2] = register.registerIcon("mekanism:CardboardBoxSideStorage"); - } + public BlockCardboardBox() { + super(Material.cloth); + setCreativeTab(Mekanism.tabMekanism); + setHardness(0.5F); + setResistance(1F); + } - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int meta) - { - if(side == 0 || side == 1) - { - return icons[0]; - } - else { - return meta == 0 ? icons[1] : icons[2]; - } - } - - @Override - public boolean isReplaceable(IBlockAccess world, int x, int y, int z) - { - return testingPlace; - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister register) { + icons[0] = register.registerIcon("mekanism:CardboardBoxTop"); + icons[1] = register.registerIcon("mekanism:CardboardBoxSide"); + icons[2] = register.registerIcon("mekanism:CardboardBoxSideStorage"); + } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int facing, float hitX, float hitY, float hitZ) - { - if(!world.isRemote && entityplayer.isSneaking()) - { - ItemStack itemStack = new ItemStack(MekanismBlocks.CardboardBox); - TileEntityCardboardBox tileEntity = (TileEntityCardboardBox)world.getTileEntity(x, y, z); + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { + if (side == 0 || side == 1) { + return icons[0]; + } else { + return meta == 0 ? icons[1] : icons[2]; + } + } - if(tileEntity.storedData != null) - { - BlockData data = tileEntity.storedData; - - testingPlace = true; - - if(!data.block.canPlaceBlockAt(world, x, y, z)) - { - testingPlace = false; - return true; - } - - testingPlace = false; + @Override + public boolean isReplaceable(IBlockAccess world, int x, int y, int z) { + return testingPlace; + } - if(data.block != null) - { - data.meta = data.block.onBlockPlaced(world, x, y, z, facing, hitX, hitY, hitZ, data.meta); - } + @Override + public boolean onBlockActivated( + World world, + int x, + int y, + int z, + EntityPlayer entityplayer, + int facing, + float hitX, + float hitY, + float hitZ + ) { + if (!world.isRemote && entityplayer.isSneaking()) { + ItemStack itemStack = new ItemStack(MekanismBlocks.CardboardBox); + TileEntityCardboardBox tileEntity + = (TileEntityCardboardBox) world.getTileEntity(x, y, z); - world.setBlock(x, y, z, data.block, data.meta, 3); + if (tileEntity.storedData != null) { + BlockData data = tileEntity.storedData; - if(data.tileTag != null && world.getTileEntity(x, y, z) != null) - { - data.updateLocation(x, y, z); - world.getTileEntity(x, y, z).readFromNBT(data.tileTag); - } + testingPlace = true; - if(data.block != null) - { - data.block.onBlockPlacedBy(world, x, y, z, entityplayer, new ItemStack(data.block, 1, data.meta)); - data.block.onPostBlockPlaced(world, x, y, z, data.meta); - } - - // float motion = 0.7F; - // double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - // double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - // double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + if (!data.block.canPlaceBlockAt(world, x, y, z)) { + testingPlace = false; + return true; + } - // EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, itemStack); + testingPlace = false; - // world.spawnEntityInWorld(entityItem); - } - } + if (data.block != null) { + data.meta = data.block.onBlockPlaced( + world, x, y, z, facing, hitX, hitY, hitZ, data.meta + ); + } - return false; - } + world.setBlock(x, y, z, data.block, data.meta, 3); - @Override - public TileEntity createNewTileEntity(World world, int meta) - { - return new TileEntityCardboardBox(); - } + if (data.tileTag != null && world.getTileEntity(x, y, z) != null) { + data.updateLocation(x, y, z); + world.getTileEntity(x, y, z).readFromNBT(data.tileTag); + } - public ItemStack dismantleBlock(World world, int x, int y, int z, boolean returnBlock) - { - ItemStack itemStack = getPickBlock(null, world, x, y, z, null); + if (data.block != null) { + data.block.onBlockPlacedBy( + world, + x, + y, + z, + entityplayer, + new ItemStack(data.block, 1, data.meta) + ); + data.block.onPostBlockPlaced(world, x, y, z, data.meta); + } - world.setBlockToAir(x, y, z); + // float motion = 0.7F; + // double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * + // 0.5D; double motionY = (world.rand.nextFloat() * motion) + (1.0F - + // motion) * 0.5D; double motionZ = (world.rand.nextFloat() * motion) + + // (1.0F - motion) * 0.5D; - if(!returnBlock) - { - float motion = 0.7F; - double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + // EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, + // z + motionZ, itemStack); - EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, itemStack); + // world.spawnEntityInWorld(entityItem); + } + } - world.spawnEntityInWorld(entityItem); - } + return false; + } - return itemStack; - } + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileEntityCardboardBox(); + } - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) - { - TileEntityCardboardBox tileEntity = (TileEntityCardboardBox)world.getTileEntity(x, y, z); + public ItemStack + dismantleBlock(World world, int x, int y, int z, boolean returnBlock) { + ItemStack itemStack = getPickBlock(null, world, x, y, z, null); - ItemStack itemStack = new ItemStack(MekanismBlocks.CardboardBox, 1, world.getBlockMetadata(x, y, z)); + world.setBlockToAir(x, y, z); - if(itemStack.getItemDamage() == 1) - { - if(tileEntity.storedData != null) - { - ((ItemBlockCardboardBox)itemStack.getItem()).setBlockData(itemStack, tileEntity.storedData); - } - } + if (!returnBlock) { + float motion = 0.7F; + double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - return itemStack; - } + EntityItem entityItem + = new EntityItem(world, x + motionX, y + motionY, z + motionZ, itemStack); - @Override - public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) - { - if(!player.capabilities.isCreativeMode && !world.isRemote && willHarvest) - { - float motion = 0.7F; - double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + world.spawnEntityInWorld(entityItem); + } - EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, getPickBlock(null, world, x, y, z, player)); + return itemStack; + } - world.spawnEntityInWorld(entityItem); - } + @Override + public ItemStack getPickBlock( + MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player + ) { + TileEntityCardboardBox tileEntity + = (TileEntityCardboardBox) world.getTileEntity(x, y, z); - return world.setBlockToAir(x, y, z); - } + ItemStack itemStack = new ItemStack( + MekanismBlocks.CardboardBox, 1, world.getBlockMetadata(x, y, z) + ); - @Override - public int quantityDropped(Random random) - { - return 0; - } + if (itemStack.getItemDamage() == 1) { + if (tileEntity.storedData != null) { + ((ItemBlockCardboardBox) itemStack.getItem()) + .setBlockData(itemStack, tileEntity.storedData); + } + } - @Override - public Item getItemDropped(int i, Random random, int j) - { - return null; - } + return itemStack; + } - public static class BlockData - { - public Block block; - public int meta; - public NBTTagCompound tileTag; + @Override + public boolean removedByPlayer( + World world, EntityPlayer player, int x, int y, int z, boolean willHarvest + ) { + if (!player.capabilities.isCreativeMode && !world.isRemote && willHarvest) { + float motion = 0.7F; + double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - public BlockData(Block b, int j, NBTTagCompound nbtTags) - { - block = b; - meta = j; - tileTag = nbtTags; - } + EntityItem entityItem = new EntityItem( + world, + x + motionX, + y + motionY, + z + motionZ, + getPickBlock(null, world, x, y, z, player) + ); - public BlockData() {} + world.spawnEntityInWorld(entityItem); + } - public void updateLocation(int x, int y, int z) - { - if(tileTag != null) - { - tileTag.setInteger("x", x); - tileTag.setInteger("y", y); - tileTag.setInteger("z", z); - } - } + return world.setBlockToAir(x, y, z); + } - public NBTTagCompound write(NBTTagCompound nbtTags) - { - nbtTags.setInteger("id", Block.getIdFromBlock(block)); - nbtTags.setInteger("meta", meta); + @Override + public int quantityDropped(Random random) { + return 0; + } - if(tileTag != null) - { - nbtTags.setTag("tileTag", tileTag); - } + @Override + public Item getItemDropped(int i, Random random, int j) { + return null; + } - return nbtTags; - } + public static class BlockData { + public Block block; + public int meta; + public NBTTagCompound tileTag; - public static BlockData read(NBTTagCompound nbtTags) - { - BlockData data = new BlockData(); + public BlockData(Block b, int j, NBTTagCompound nbtTags) { + block = b; + meta = j; + tileTag = nbtTags; + } - data.block = Block.getBlockById(nbtTags.getInteger("id")); - data.meta = nbtTags.getInteger("meta"); + public BlockData() {} - if(nbtTags.hasKey("tileTag")) - { - data.tileTag = nbtTags.getCompoundTag("tileTag"); - } + public void updateLocation(int x, int y, int z) { + if (tileTag != null) { + tileTag.setInteger("x", x); + tileTag.setInteger("y", y); + tileTag.setInteger("z", z); + } + } - return data; - } - } + public NBTTagCompound write(NBTTagCompound nbtTags) { + nbtTags.setInteger("id", Block.getIdFromBlock(block)); + nbtTags.setInteger("meta", meta); + + if (tileTag != null) { + nbtTags.setTag("tileTag", tileTag); + } + + return nbtTags; + } + + public static BlockData read(NBTTagCompound nbtTags) { + BlockData data = new BlockData(); + + data.block = Block.getBlockById(nbtTags.getInteger("id")); + data.meta = nbtTags.getInteger("meta"); + + if (nbtTags.hasKey("tileTag")) { + data.tileTag = nbtTags.getCompoundTag("tileTag"); + } + + return data; + } + } } diff --git a/src/main/java/mekanism/common/block/BlockEnergyCube.java b/src/main/java/mekanism/common/block/BlockEnergyCube.java index e0d06834a..5a7fa7544 100644 --- a/src/main/java/mekanism/common/block/BlockEnergyCube.java +++ b/src/main/java/mekanism/common/block/BlockEnergyCube.java @@ -3,6 +3,9 @@ package mekanism.common.block; import java.util.List; import java.util.Random; +import buildcraft.api.tools.IToolWrench; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.energy.IEnergizedItem; import mekanism.common.Mekanism; import mekanism.common.MekanismBlocks; @@ -33,9 +36,6 @@ import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import buildcraft.api.tools.IToolWrench; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; /** * Block class for handling multiple energy cube block IDs. @@ -47,318 +47,321 @@ import cpw.mods.fml.relauncher.SideOnly; * @author AidanBrady * */ -public class BlockEnergyCube extends BlockContainer -{ - public BlockEnergyCube() - { - super(Material.iron); - setHardness(2F); - setResistance(4F); - setCreativeTab(Mekanism.tabMekanism); - } +public class BlockEnergyCube extends BlockContainer { + public BlockEnergyCube() { + super(Material.iron); + setHardness(2F); + setResistance(4F); + setCreativeTab(Mekanism.tabMekanism); + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister register) - { - blockIcon = register.registerIcon(BlockBasic.ICON_BASE); - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister register) { + blockIcon = register.registerIcon(BlockBasic.ICON_BASE); + } - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) - { - if(!world.isRemote) - { - TileEntity tileEntity = world.getTileEntity(x, y, z); + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + if (!world.isRemote) { + TileEntity tileEntity = world.getTileEntity(x, y, z); - if(tileEntity instanceof TileEntityBasicBlock) - { - ((TileEntityBasicBlock)tileEntity).onNeighborChange(block); - } - } - } + if (tileEntity instanceof TileEntityBasicBlock) { + ((TileEntityBasicBlock) tileEntity).onNeighborChange(block); + } + } + } - @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack itemstack) - { - TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(x, y, z); - int side = MathHelper.floor_double((double)(entityliving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; - int height = Math.round(entityliving.rotationPitch); - int change = 3; + @Override + public void onBlockPlacedBy( + World world, + int x, + int y, + int z, + EntityLivingBase entityliving, + ItemStack itemstack + ) { + TileEntityBasicBlock tileEntity + = (TileEntityBasicBlock) world.getTileEntity(x, y, z); + int side = MathHelper.floor_double( + (double) (entityliving.rotationYaw * 4.0F / 360.0F) + 0.5D + ) + & 3; + int height = Math.round(entityliving.rotationPitch); + int change = 3; - if(height >= 65) - { - change = 1; - } - else if(height <= -65) - { - change = 0; - } - else { - switch(side) - { - case 0: change = 2; break; - case 1: change = 5; break; - case 2: change = 3; break; - case 3: change = 4; break; - } - } + if (height >= 65) { + change = 1; + } else if (height <= -65) { + change = 0; + } else { + switch (side) { + case 0: + change = 2; + break; + case 1: + change = 5; + break; + case 2: + change = 3; + break; + case 3: + change = 4; + break; + } + } - tileEntity.setFacing((short)change); - tileEntity.redstone = world.isBlockIndirectlyGettingPowered(x, y, z); - } + tileEntity.setFacing((short) change); + tileEntity.redstone = world.isBlockIndirectlyGettingPowered(x, y, z); + } - @Override - public int quantityDropped(Random random) - { - return 0; - } + @Override + public int quantityDropped(Random random) { + return 0; + } - @Override - public Item getItemDropped(int i, Random random, int j) - { - return null; - } + @Override + public Item getItemDropped(int i, Random random, int j) { + return null; + } - @Override - @SideOnly(Side.CLIENT) - public void getSubBlocks(Item item, CreativeTabs creativetabs, List list) - { - for(EnergyCubeTier tier : EnergyCubeTier.values()) - { - ItemStack discharged = new ItemStack(this); - ((ItemBlockEnergyCube)discharged.getItem()).setEnergyCubeTier(discharged, tier); - list.add(discharged); - ItemStack charged = new ItemStack(this); - ((ItemBlockEnergyCube)charged.getItem()).setEnergyCubeTier(charged, tier); - ((ItemBlockEnergyCube)charged.getItem()).setEnergy(charged, tier.maxEnergy); - list.add(charged); - } - } - - @Override - public float getPlayerRelativeBlockHardness(EntityPlayer player, World world, int x, int y, int z) - { - TileEntity tile = world.getTileEntity(x, y, z); - - return SecurityUtils.canAccess(player, tile) ? super.getPlayerRelativeBlockHardness(player, world, x, y, z) : 0.0F; - } + @Override + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item item, CreativeTabs creativetabs, List list) { + for (EnergyCubeTier tier : EnergyCubeTier.values()) { + ItemStack discharged = new ItemStack(this); + ((ItemBlockEnergyCube) discharged.getItem()) + .setEnergyCubeTier(discharged, tier); + list.add(discharged); + ItemStack charged = new ItemStack(this); + ((ItemBlockEnergyCube) charged.getItem()).setEnergyCubeTier(charged, tier); + ((ItemBlockEnergyCube) charged.getItem()).setEnergy(charged, tier.maxEnergy); + list.add(charged); + } + } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int side, float f1, float f2, float f3) - { - if(world.isRemote) - { - return true; - } + @Override + public float getPlayerRelativeBlockHardness( + EntityPlayer player, World world, int x, int y, int z + ) { + TileEntity tile = world.getTileEntity(x, y, z); - TileEntityEnergyCube tileEntity = (TileEntityEnergyCube)world.getTileEntity(x, y, z); + return SecurityUtils.canAccess(player, tile) + ? super.getPlayerRelativeBlockHardness(player, world, x, y, z) + : 0.0F; + } - if(entityplayer.getCurrentEquippedItem() != null) - { - Item tool = entityplayer.getCurrentEquippedItem().getItem(); + @Override + public boolean onBlockActivated( + World world, + int x, + int y, + int z, + EntityPlayer entityplayer, + int side, + float f1, + float f2, + float f3 + ) { + if (world.isRemote) { + return true; + } - if(MekanismUtils.hasUsableWrench(entityplayer, x, y, z)) - { - if(SecurityUtils.canAccess(entityplayer, tileEntity)) - { - if(entityplayer.isSneaking()) - { - dismantleBlock(world, x, y, z, false); - - return true; - } - - if(MekanismUtils.isBCWrench(tool)) - { - ((IToolWrench) tool).wrenchUsed(entityplayer, x, y, z); - } - - int change = ForgeDirection.ROTATION_MATRIX[side][tileEntity.facing]; - - tileEntity.setFacing((short)change); - world.notifyBlocksOfNeighborChange(x, y, z, this); - } - else { - SecurityUtils.displayNoAccess(entityplayer); - } - - return true; - } - } + TileEntityEnergyCube tileEntity + = (TileEntityEnergyCube) world.getTileEntity(x, y, z); - if(tileEntity != null) - { - if(!entityplayer.isSneaking()) - { - if(SecurityUtils.canAccess(entityplayer, tileEntity)) - { - entityplayer.openGui(Mekanism.instance, 8, world, x, y, z); - } - else { - SecurityUtils.displayNoAccess(entityplayer); - } - - return true; - } - } + if (entityplayer.getCurrentEquippedItem() != null) { + Item tool = entityplayer.getCurrentEquippedItem().getItem(); - return false; - } + if (MekanismUtils.hasUsableWrench(entityplayer, x, y, z)) { + if (SecurityUtils.canAccess(entityplayer, tileEntity)) { + if (entityplayer.isSneaking()) { + dismantleBlock(world, x, y, z, false); - @Override - public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) - { - if(!player.capabilities.isCreativeMode && !world.isRemote && willHarvest) - { - float motion = 0.7F; - double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + return true; + } - EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, getPickBlock(null, world, x, y, z, player)); - world.spawnEntityInWorld(entityItem); - } + if (MekanismUtils.isBCWrench(tool)) { + ((IToolWrench) tool).wrenchUsed(entityplayer, x, y, z); + } - return world.setBlockToAir(x, y, z); - } + int change = ForgeDirection.ROTATION_MATRIX[side][tileEntity.facing]; - @Override - public TileEntity createNewTileEntity(World world, int meta) - { - return new TileEntityEnergyCube(); - } + tileEntity.setFacing((short) change); + world.notifyBlocksOfNeighborChange(x, y, z, this); + } else { + SecurityUtils.displayNoAccess(entityplayer); + } - @Override - public boolean renderAsNormalBlock() - { - return false; - } + return true; + } + } - @Override - public boolean isOpaqueCube() - { - return false; - } + if (tileEntity != null) { + if (!entityplayer.isSneaking()) { + if (SecurityUtils.canAccess(entityplayer, tileEntity)) { + entityplayer.openGui(Mekanism.instance, 8, world, x, y, z); + } else { + SecurityUtils.displayNoAccess(entityplayer); + } - @Override - public int getRenderType() - { - return -1; - } + return true; + } + } - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) - { - TileEntityEnergyCube tileEntity = (TileEntityEnergyCube)world.getTileEntity(x, y, z); - ItemStack itemStack = new ItemStack(MekanismBlocks.EnergyCube); - - if(itemStack.stackTagCompound == null) - { - itemStack.setTagCompound(new NBTTagCompound()); - } - - if(tileEntity instanceof ISecurityTile) - { - ISecurityItem securityItem = (ISecurityItem)itemStack.getItem(); - - if(securityItem.hasSecurity(itemStack)) - { - securityItem.setOwner(itemStack, ((ISecurityTile)tileEntity).getSecurity().getOwner()); - securityItem.setSecurity(itemStack, ((ISecurityTile)tileEntity).getSecurity().getMode()); - } - } + return false; + } - IEnergyCube energyCube = (IEnergyCube)itemStack.getItem(); - energyCube.setEnergyCubeTier(itemStack, tileEntity.tier); + @Override + public boolean removedByPlayer( + World world, EntityPlayer player, int x, int y, int z, boolean willHarvest + ) { + if (!player.capabilities.isCreativeMode && !world.isRemote && willHarvest) { + float motion = 0.7F; + double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - IEnergizedItem energizedItem = (IEnergizedItem)itemStack.getItem(); - energizedItem.setEnergy(itemStack, tileEntity.electricityStored); + EntityItem entityItem = new EntityItem( + world, + x + motionX, + y + motionY, + z + motionZ, + getPickBlock(null, world, x, y, z, player) + ); + world.spawnEntityInWorld(entityItem); + } - ISustainedInventory inventory = (ISustainedInventory)itemStack.getItem(); - inventory.setInventory(tileEntity.getInventory(), itemStack); + return world.setBlockToAir(x, y, z); + } - return itemStack; - } + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileEntityEnergyCube(); + } - public ItemStack dismantleBlock(World world, int x, int y, int z, boolean returnBlock) - { - ItemStack itemStack = getPickBlock(null, world, x, y, z, null); + @Override + public boolean renderAsNormalBlock() { + return false; + } - world.setBlockToAir(x, y, z); + @Override + public boolean isOpaqueCube() { + return false; + } - if(!returnBlock) - { - float motion = 0.7F; - double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + @Override + public int getRenderType() { + return -1; + } - EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, itemStack); + @Override + public ItemStack getPickBlock( + MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player + ) { + TileEntityEnergyCube tileEntity + = (TileEntityEnergyCube) world.getTileEntity(x, y, z); + ItemStack itemStack = new ItemStack(MekanismBlocks.EnergyCube); - world.spawnEntityInWorld(entityItem); - } + if (itemStack.stackTagCompound == null) { + itemStack.setTagCompound(new NBTTagCompound()); + } - return itemStack; - } + if (tileEntity instanceof ISecurityTile) { + ISecurityItem securityItem = (ISecurityItem) itemStack.getItem(); - @Override - public boolean hasComparatorInputOverride() - { - return true; - } + if (securityItem.hasSecurity(itemStack)) { + securityItem.setOwner( + itemStack, ((ISecurityTile) tileEntity).getSecurity().getOwner() + ); + securityItem.setSecurity( + itemStack, ((ISecurityTile) tileEntity).getSecurity().getMode() + ); + } + } - @Override - public int getComparatorInputOverride(World world, int x, int y, int z, int par5) - { - TileEntityEnergyCube tileEntity = (TileEntityEnergyCube)world.getTileEntity(x, y, z); - return tileEntity.getRedstoneLevel(); - } + IEnergyCube energyCube = (IEnergyCube) itemStack.getItem(); + energyCube.setEnergyCubeTier(itemStack, tileEntity.tier); - @Override - public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) - { - return true; - } + IEnergizedItem energizedItem = (IEnergizedItem) itemStack.getItem(); + energizedItem.setEnergy(itemStack, tileEntity.electricityStored); - @Override - public ForgeDirection[] getValidRotations(World world, int x, int y, int z) - { - TileEntity tile = world.getTileEntity(x, y, z); - ForgeDirection[] valid = new ForgeDirection[6]; - - if(tile instanceof TileEntityBasicBlock) - { - TileEntityBasicBlock basicTile = (TileEntityBasicBlock)tile; - - for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) - { - if(basicTile.canSetFacing(dir.ordinal())) - { - valid[dir.ordinal()] = dir; - } - } - } - - return valid; - } + ISustainedInventory inventory = (ISustainedInventory) itemStack.getItem(); + inventory.setInventory(tileEntity.getInventory(), itemStack); - @Override - public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis) - { - TileEntity tile = world.getTileEntity(x, y, z); - - if(tile instanceof TileEntityBasicBlock) - { - TileEntityBasicBlock basicTile = (TileEntityBasicBlock)tile; - - if(basicTile.canSetFacing(axis.ordinal())) - { - basicTile.setFacing((short)axis.ordinal()); - return true; - } - } - - return false; - } + return itemStack; + } + + public ItemStack + dismantleBlock(World world, int x, int y, int z, boolean returnBlock) { + ItemStack itemStack = getPickBlock(null, world, x, y, z, null); + + world.setBlockToAir(x, y, z); + + if (!returnBlock) { + float motion = 0.7F; + double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + + EntityItem entityItem + = new EntityItem(world, x + motionX, y + motionY, z + motionZ, itemStack); + + world.spawnEntityInWorld(entityItem); + } + + return itemStack; + } + + @Override + public boolean hasComparatorInputOverride() { + return true; + } + + @Override + public int getComparatorInputOverride(World world, int x, int y, int z, int par5) { + TileEntityEnergyCube tileEntity + = (TileEntityEnergyCube) world.getTileEntity(x, y, z); + return tileEntity.getRedstoneLevel(); + } + + @Override + public boolean + isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + return true; + } + + @Override + public ForgeDirection[] getValidRotations(World world, int x, int y, int z) { + TileEntity tile = world.getTileEntity(x, y, z); + ForgeDirection[] valid = new ForgeDirection[6]; + + if (tile instanceof TileEntityBasicBlock) { + TileEntityBasicBlock basicTile = (TileEntityBasicBlock) tile; + + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + if (basicTile.canSetFacing(dir.ordinal())) { + valid[dir.ordinal()] = dir; + } + } + } + + return valid; + } + + @Override + public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis) { + TileEntity tile = world.getTileEntity(x, y, z); + + if (tile instanceof TileEntityBasicBlock) { + TileEntityBasicBlock basicTile = (TileEntityBasicBlock) tile; + + if (basicTile.canSetFacing(axis.ordinal())) { + basicTile.setFacing((short) axis.ordinal()); + return true; + } + } + + return false; + } } diff --git a/src/main/java/mekanism/common/block/BlockGasTank.java b/src/main/java/mekanism/common/block/BlockGasTank.java index e8b3bee6a..c6a8b640b 100644 --- a/src/main/java/mekanism/common/block/BlockGasTank.java +++ b/src/main/java/mekanism/common/block/BlockGasTank.java @@ -2,6 +2,9 @@ package mekanism.common.block; import java.util.Random; +import buildcraft.api.tools.IToolWrench; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.gas.IGasItem; import mekanism.common.Mekanism; import mekanism.common.MekanismBlocks; @@ -28,292 +31,298 @@ import net.minecraft.util.MathHelper; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import buildcraft.api.tools.IToolWrench; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class BlockGasTank extends BlockContainer -{ - public BlockGasTank() - { - super(Material.iron); - setBlockBounds(0.2F, 0.0F, 0.2F, 0.8F, 1.0F, 0.8F); - setHardness(3.5F); - setResistance(8F); - setCreativeTab(Mekanism.tabMekanism); - } +public class BlockGasTank extends BlockContainer { + public BlockGasTank() { + super(Material.iron); + setBlockBounds(0.2F, 0.0F, 0.2F, 0.8F, 1.0F, 0.8F); + setHardness(3.5F); + setResistance(8F); + setCreativeTab(Mekanism.tabMekanism); + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister register) - { - blockIcon = register.registerIcon("mekanism:SteelCasing"); - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister register) { + blockIcon = register.registerIcon("mekanism:SteelCasing"); + } - @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack itemstack) - { - TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(x, y, z); + @Override + public void onBlockPlacedBy( + World world, + int x, + int y, + int z, + EntityLivingBase entityliving, + ItemStack itemstack + ) { + TileEntityBasicBlock tileEntity + = (TileEntityBasicBlock) world.getTileEntity(x, y, z); - int side = MathHelper.floor_double((double)(entityliving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; - int change = 3; + int side = MathHelper.floor_double( + (double) (entityliving.rotationYaw * 4.0F / 360.0F) + 0.5D + ) + & 3; + int change = 3; - switch(side) - { - case 0: change = 2; break; - case 1: change = 5; break; - case 2: change = 3; break; - case 3: change = 4; break; - } + switch (side) { + case 0: + change = 2; + break; + case 1: + change = 5; + break; + case 2: + change = 3; + break; + case 3: + change = 4; + break; + } - tileEntity.setFacing((short)change); - tileEntity.redstone = world.isBlockIndirectlyGettingPowered(x, y, z); - } + tileEntity.setFacing((short) change); + tileEntity.redstone = world.isBlockIndirectlyGettingPowered(x, y, z); + } - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) - { - if(!world.isRemote) - { - TileEntity tileEntity = world.getTileEntity(x, y, z); + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + if (!world.isRemote) { + TileEntity tileEntity = world.getTileEntity(x, y, z); - if(tileEntity instanceof TileEntityBasicBlock) - { - ((TileEntityBasicBlock)tileEntity).onNeighborChange(block); - } - } - } - - @Override - public float getPlayerRelativeBlockHardness(EntityPlayer player, World world, int x, int y, int z) - { - TileEntity tile = world.getTileEntity(x, y, z); - - return SecurityUtils.canAccess(player, tile) ? super.getPlayerRelativeBlockHardness(player, world, x, y, z) : 0.0F; - } + if (tileEntity instanceof TileEntityBasicBlock) { + ((TileEntityBasicBlock) tileEntity).onNeighborChange(block); + } + } + } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int side, float playerX, float playerY, float playerZ) - { - if(world.isRemote) - { - return true; - } + @Override + public float getPlayerRelativeBlockHardness( + EntityPlayer player, World world, int x, int y, int z + ) { + TileEntity tile = world.getTileEntity(x, y, z); - TileEntityGasTank tileEntity = (TileEntityGasTank)world.getTileEntity(x, y, z); + return SecurityUtils.canAccess(player, tile) + ? super.getPlayerRelativeBlockHardness(player, world, x, y, z) + : 0.0F; + } - if(entityplayer.getCurrentEquippedItem() != null) - { - Item tool = entityplayer.getCurrentEquippedItem().getItem(); + @Override + public boolean onBlockActivated( + World world, + int x, + int y, + int z, + EntityPlayer entityplayer, + int side, + float playerX, + float playerY, + float playerZ + ) { + if (world.isRemote) { + return true; + } - if(MekanismUtils.hasUsableWrench(entityplayer, x, y, z)) - { - if(SecurityUtils.canAccess(entityplayer, tileEntity)) - { - if(entityplayer.isSneaking()) - { - dismantleBlock(world, x, y, z, false); - - return true; - } - - if(MekanismUtils.isBCWrench(tool)) - { - ((IToolWrench)tool).wrenchUsed(entityplayer, x, y, z); - } - - int change = ForgeDirection.ROTATION_MATRIX[ForgeDirection.UP.ordinal()][tileEntity.facing]; - - tileEntity.setFacing((short)change); - world.notifyBlocksOfNeighborChange(x, y, z, this); - } - else { - SecurityUtils.displayNoAccess(entityplayer); - } - - return true; - } - } + TileEntityGasTank tileEntity = (TileEntityGasTank) world.getTileEntity(x, y, z); - if(tileEntity != null) - { - if(!entityplayer.isSneaking()) - { - if(SecurityUtils.canAccess(entityplayer, tileEntity)) - { - entityplayer.openGui(Mekanism.instance, 10, world, x, y, z); - } - else { - SecurityUtils.displayNoAccess(entityplayer); - } - - return true; - } - } - - return false; - } + if (entityplayer.getCurrentEquippedItem() != null) { + Item tool = entityplayer.getCurrentEquippedItem().getItem(); - @Override - public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) - { - if(!player.capabilities.isCreativeMode && !world.isRemote && willHarvest) - { - float motion = 0.7F; - double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + if (MekanismUtils.hasUsableWrench(entityplayer, x, y, z)) { + if (SecurityUtils.canAccess(entityplayer, tileEntity)) { + if (entityplayer.isSneaking()) { + dismantleBlock(world, x, y, z, false); - EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, getPickBlock(null, world, x, y, z, player)); + return true; + } - world.spawnEntityInWorld(entityItem); - } + if (MekanismUtils.isBCWrench(tool)) { + ((IToolWrench) tool).wrenchUsed(entityplayer, x, y, z); + } - return world.setBlockToAir(x, y, z); - } + int change + = ForgeDirection.ROTATION_MATRIX[ForgeDirection.UP.ordinal()] + [tileEntity.facing]; - public ItemStack dismantleBlock(World world, int x, int y, int z, boolean returnBlock) - { - ItemStack itemStack = getPickBlock(null, world, x, y, z, null); + tileEntity.setFacing((short) change); + world.notifyBlocksOfNeighborChange(x, y, z, this); + } else { + SecurityUtils.displayNoAccess(entityplayer); + } - world.setBlockToAir(x, y, z); + return true; + } + } - if(!returnBlock) - { - float motion = 0.7F; - double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + if (tileEntity != null) { + if (!entityplayer.isSneaking()) { + if (SecurityUtils.canAccess(entityplayer, tileEntity)) { + entityplayer.openGui(Mekanism.instance, 10, world, x, y, z); + } else { + SecurityUtils.displayNoAccess(entityplayer); + } - EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, itemStack); + return true; + } + } - world.spawnEntityInWorld(entityItem); - } + return false; + } - return itemStack; - } + @Override + public boolean removedByPlayer( + World world, EntityPlayer player, int x, int y, int z, boolean willHarvest + ) { + if (!player.capabilities.isCreativeMode && !world.isRemote && willHarvest) { + float motion = 0.7F; + double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - @Override - public int quantityDropped(Random random) - { - return 0; - } + EntityItem entityItem = new EntityItem( + world, + x + motionX, + y + motionY, + z + motionZ, + getPickBlock(null, world, x, y, z, player) + ); - @Override - public Item getItemDropped(int i, Random random, int j) - { - return null; - } + world.spawnEntityInWorld(entityItem); + } - @Override - public boolean renderAsNormalBlock() - { - return false; - } + return world.setBlockToAir(x, y, z); + } - @Override - public boolean isOpaqueCube() - { - return false; - } + public ItemStack + dismantleBlock(World world, int x, int y, int z, boolean returnBlock) { + ItemStack itemStack = getPickBlock(null, world, x, y, z, null); - @Override - public int getRenderType() - { - return -1; - } + world.setBlockToAir(x, y, z); - @Override - public TileEntity createNewTileEntity(World world, int meta) - { - return new TileEntityGasTank(); - } + if (!returnBlock) { + float motion = 0.7F; + double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) - { - TileEntityGasTank tileEntity = (TileEntityGasTank)world.getTileEntity(x, y, z); - ItemStack itemStack = new ItemStack(MekanismBlocks.GasTank); - - if(itemStack.stackTagCompound == null) - { - itemStack.setTagCompound(new NBTTagCompound()); - } - - if(tileEntity instanceof ISecurityTile) - { - ISecurityItem securityItem = (ISecurityItem)itemStack.getItem(); - - if(securityItem.hasSecurity(itemStack)) - { - securityItem.setOwner(itemStack, ((ISecurityTile)tileEntity).getSecurity().getOwner()); - securityItem.setSecurity(itemStack, ((ISecurityTile)tileEntity).getSecurity().getMode()); - } - } - - ITierItem tierItem = (ITierItem)itemStack.getItem(); - tierItem.setBaseTier(itemStack, tileEntity.tier.getBaseTier()); + EntityItem entityItem + = new EntityItem(world, x + motionX, y + motionY, z + motionZ, itemStack); - IGasItem storageTank = (IGasItem)itemStack.getItem(); - storageTank.setGas(itemStack, tileEntity.gasTank.getGas()); + world.spawnEntityInWorld(entityItem); + } - ISustainedInventory inventory = (ISustainedInventory)itemStack.getItem(); - inventory.setInventory(((ISustainedInventory)tileEntity).getInventory(), itemStack); + return itemStack; + } - return itemStack; - } + @Override + public int quantityDropped(Random random) { + return 0; + } - @Override - public boolean hasComparatorInputOverride() - { - return true; - } + @Override + public Item getItemDropped(int i, Random random, int j) { + return null; + } - @Override - public int getComparatorInputOverride(World world, int x, int y, int z, int par5) - { - TileEntityGasTank tileEntity = (TileEntityGasTank)world.getTileEntity(x, y, z); - return tileEntity.getRedstoneLevel(); - } - - @Override - public ForgeDirection[] getValidRotations(World world, int x, int y, int z) - { - TileEntity tile = world.getTileEntity(x, y, z); - ForgeDirection[] valid = new ForgeDirection[6]; - - if(tile instanceof TileEntityBasicBlock) - { - TileEntityBasicBlock basicTile = (TileEntityBasicBlock)tile; - - for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) - { - if(basicTile.canSetFacing(dir.ordinal())) - { - valid[dir.ordinal()] = dir; - } - } - } - - return valid; - } + @Override + public boolean renderAsNormalBlock() { + return false; + } - @Override - public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis) - { - TileEntity tile = world.getTileEntity(x, y, z); - - if(tile instanceof TileEntityBasicBlock) - { - TileEntityBasicBlock basicTile = (TileEntityBasicBlock)tile; - - if(basicTile.canSetFacing(axis.ordinal())) - { - basicTile.setFacing((short)axis.ordinal()); - return true; - } - } - - return false; - } + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public int getRenderType() { + return -1; + } + + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return new TileEntityGasTank(); + } + + @Override + public ItemStack getPickBlock( + MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player + ) { + TileEntityGasTank tileEntity = (TileEntityGasTank) world.getTileEntity(x, y, z); + ItemStack itemStack = new ItemStack(MekanismBlocks.GasTank); + + if (itemStack.stackTagCompound == null) { + itemStack.setTagCompound(new NBTTagCompound()); + } + + if (tileEntity instanceof ISecurityTile) { + ISecurityItem securityItem = (ISecurityItem) itemStack.getItem(); + + if (securityItem.hasSecurity(itemStack)) { + securityItem.setOwner( + itemStack, ((ISecurityTile) tileEntity).getSecurity().getOwner() + ); + securityItem.setSecurity( + itemStack, ((ISecurityTile) tileEntity).getSecurity().getMode() + ); + } + } + + ITierItem tierItem = (ITierItem) itemStack.getItem(); + tierItem.setBaseTier(itemStack, tileEntity.tier.getBaseTier()); + + IGasItem storageTank = (IGasItem) itemStack.getItem(); + storageTank.setGas(itemStack, tileEntity.gasTank.getGas()); + + ISustainedInventory inventory = (ISustainedInventory) itemStack.getItem(); + inventory.setInventory( + ((ISustainedInventory) tileEntity).getInventory(), itemStack + ); + + return itemStack; + } + + @Override + public boolean hasComparatorInputOverride() { + return true; + } + + @Override + public int getComparatorInputOverride(World world, int x, int y, int z, int par5) { + TileEntityGasTank tileEntity = (TileEntityGasTank) world.getTileEntity(x, y, z); + return tileEntity.getRedstoneLevel(); + } + + @Override + public ForgeDirection[] getValidRotations(World world, int x, int y, int z) { + TileEntity tile = world.getTileEntity(x, y, z); + ForgeDirection[] valid = new ForgeDirection[6]; + + if (tile instanceof TileEntityBasicBlock) { + TileEntityBasicBlock basicTile = (TileEntityBasicBlock) tile; + + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + if (basicTile.canSetFacing(dir.ordinal())) { + valid[dir.ordinal()] = dir; + } + } + } + + return valid; + } + + @Override + public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis) { + TileEntity tile = world.getTileEntity(x, y, z); + + if (tile instanceof TileEntityBasicBlock) { + TileEntityBasicBlock basicTile = (TileEntityBasicBlock) tile; + + if (basicTile.canSetFacing(axis.ordinal())) { + basicTile.setFacing((short) axis.ordinal()); + return true; + } + } + + return false; + } } diff --git a/src/main/java/mekanism/common/block/BlockMachine.java b/src/main/java/mekanism/common/block/BlockMachine.java index 29c89799b..8f9126cda 100644 --- a/src/main/java/mekanism/common/block/BlockMachine.java +++ b/src/main/java/mekanism/common/block/BlockMachine.java @@ -7,6 +7,9 @@ import java.util.HashSet; import java.util.List; import java.util.Random; +import buildcraft.api.tools.IToolWrench; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.MekanismConfig.client; import mekanism.api.MekanismConfig.general; @@ -113,9 +116,6 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; -import buildcraft.api.tools.IToolWrench; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; /** * Block class for handling multiple machine block IDs. @@ -158,1358 +158,1907 @@ import cpw.mods.fml.relauncher.SideOnly; * 2:4: Resistive Heater * 2:5: Formulaic Assemblicator * 2:6: Fuelwood Heater - * + * * @author AidanBrady * */ -public class BlockMachine extends BlockContainer implements ISpecialBounds, IBlockCTM, ICustomBlockIcon -{ - public IIcon[][] icons = new IIcon[16][16]; - public IIcon[][][] factoryIcons = new IIcon[4][16][16]; - - public CTMData[][] ctms = new CTMData[16][4]; - - public IIcon BASE_ICON; +public class BlockMachine + extends BlockContainer implements ISpecialBounds, IBlockCTM, ICustomBlockIcon { + public IIcon[][] icons = new IIcon[16][16]; + public IIcon[][][] factoryIcons = new IIcon[4][16][16]; - public MachineBlock blockType; + public CTMData[][] ctms = new CTMData[16][4]; - public BlockMachine(MachineBlock type) - { - super(Material.iron); - setHardness(3.5F); - setResistance(16F); - setCreativeTab(Mekanism.tabMekanism); - blockType = type; - } + public IIcon BASE_ICON; - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister register) - { - BASE_ICON = register.registerIcon("mekanism:SteelCasing"); - DefIcon def = DefIcon.getAll(BASE_ICON).setOverrides(false); - - switch(blockType) - { - case MACHINE_BLOCK_1: - ctms[11][0] = new CTMData("ctm/Teleporter", this, Arrays.asList(11)).addOtherBlockConnectivities(MekanismBlocks.BasicBlock, Arrays.asList(7)).registerIcons(register); - - MekanismRenderer.loadDynamicTextures(register, "enrichment_chamber/" + MachineType.ENRICHMENT_CHAMBER.name, icons[0], def); - MekanismRenderer.loadDynamicTextures(register, "osmium_compressor/" + MachineType.OSMIUM_COMPRESSOR.name, icons[1], def); - MekanismRenderer.loadDynamicTextures(register, "combiner/" + MachineType.COMBINER.name, icons[2], def); - MekanismRenderer.loadDynamicTextures(register, "crusher/" + MachineType.CRUSHER.name, icons[3], def); - - for(RecipeType type : RecipeType.values()) - { - MekanismRenderer.loadDynamicTextures(register, "factory/basic/" + type.getUnlocalizedName().toLowerCase() + "/" + BaseTier.BASIC.getName() + type.getUnlocalizedName() + MachineType.BASIC_FACTORY.name, factoryIcons[0][type.ordinal()], - DefIcon.getActivePair(register.registerIcon("mekanism:factory/basic/BasicFactoryFront"), 2).setOverrides(false), - DefIcon.getActivePair(register.registerIcon("mekanism:factory/basic/BasicFactoryTop"), 1).setOverrides(false), - DefIcon.getActivePair(register.registerIcon("mekanism:factory/basic/BasicFactoryBottom"), 0).setOverrides(false), - DefIcon.getActivePair(register.registerIcon("mekanism:factory/basic/BasicFactorySide"), 3, 4, 5).setOverrides(false)); - MekanismRenderer.loadDynamicTextures(register, "factory/advanced/" + type.getUnlocalizedName().toLowerCase() + "/" + BaseTier.ADVANCED.getName() + type.getUnlocalizedName() + MachineType.ADVANCED_FACTORY.name, factoryIcons[1][type.ordinal()], - DefIcon.getActivePair(register.registerIcon("mekanism:factory/advanced/AdvancedFactoryFront"), 2).setOverrides(false), - DefIcon.getActivePair(register.registerIcon("mekanism:factory/advanced/AdvancedFactoryTop"), 1).setOverrides(false), - DefIcon.getActivePair(register.registerIcon("mekanism:factory/advanced/AdvancedFactoryBottom"), 0).setOverrides(false), - DefIcon.getActivePair(register.registerIcon("mekanism:factory/advanced/AdvancedFactorySide"), 3, 4, 5).setOverrides(false)); - MekanismRenderer.loadDynamicTextures(register, "factory/elite/" + type.getUnlocalizedName().toLowerCase() + "/" + BaseTier.ELITE.getName() + type.getUnlocalizedName() + MachineType.ELITE_FACTORY.name, factoryIcons[2][type.ordinal()], - DefIcon.getActivePair(register.registerIcon("mekanism:factory/elite/EliteFactoryFront"), 2).setOverrides(false), - DefIcon.getActivePair(register.registerIcon("mekanism:factory/elite/EliteFactoryTop"), 1).setOverrides(false), - DefIcon.getActivePair(register.registerIcon("mekanism:factory/elite/EliteFactoryBottom"), 0).setOverrides(false), - DefIcon.getActivePair(register.registerIcon("mekanism:factory/elite/EliteFactorySide"), 3, 4, 5).setOverrides(false)); - } - - MekanismRenderer.loadDynamicTextures(register, "purification_chamber/" + MachineType.PURIFICATION_CHAMBER.name, icons[9], def); - MekanismRenderer.loadDynamicTextures(register, "energized_smelter/" + MachineType.ENERGIZED_SMELTER.name, icons[10], def); - icons[11][0] = ctms[11][0].mainTextureData.icon; - - break; - case MACHINE_BLOCK_2: - MekanismRenderer.loadDynamicTextures(register, "chemical_injection_chamber/" + MachineType.CHEMICAL_INJECTION_CHAMBER.name, icons[3], def); - MekanismRenderer.loadDynamicTextures(register, "precision_sawmill/" + MachineType.PRECISION_SAWMILL.name, icons[5], def); - - break; - case MACHINE_BLOCK_3: - icons[0][0] = BASE_ICON; - icons[2][0] = BASE_ICON; - MekanismRenderer.loadDynamicTextures(register, "oredictionificator/" + MachineType.OREDICTIONIFICATOR.name, icons[3]); - icons[4][0] = BASE_ICON; - MekanismRenderer.loadDynamicTextures(register, "formulaic_assemblicator/" + MachineType.FORMULAIC_ASSEMBLICATOR.name, icons[5]); - MekanismRenderer.loadDynamicTextures(register, "fuelwood_heater/" + MachineType.FUELWOOD_HEATER.name, icons[6]); - - break; - } - } - - @Override - public IIcon getIcon(ItemStack stack, int side) - { - MachineType type = MachineType.get(stack); - ItemBlockMachine item = (ItemBlockMachine)stack.getItem(); - - if(type == MachineType.BASIC_FACTORY) - { - return factoryIcons[0][item.getRecipeType(stack)][side]; - } - else if(type == MachineType.ADVANCED_FACTORY) - { - return factoryIcons[1][item.getRecipeType(stack)][side]; - } - else if(type == MachineType.ELITE_FACTORY) - { - return factoryIcons[2][item.getRecipeType(stack)][side]; - } - - return getIcon(side, stack.getItemDamage()); - } + public MachineBlock blockType; - @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack itemstack) - { - TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(x, y, z); - int side = MathHelper.floor_double((entityliving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; - int height = Math.round(entityliving.rotationPitch); - int change = 3; - - if(tileEntity == null) - { - return; - } - - if(tileEntity.canSetFacing(0) && tileEntity.canSetFacing(1)) - { - if(height >= 65) - { - change = 1; - } - else if(height <= -65) - { - change = 0; - } - } - - if(change != 0 && change != 1) - { - switch(side) - { - case 0: change = 2; break; - case 1: change = 5; break; - case 2: change = 3; break; - case 3: change = 4; break; - } - } - - if(tileEntity instanceof TileEntityLogisticalSorter) - { - TileEntityLogisticalSorter transporter = (TileEntityLogisticalSorter)tileEntity; - - if(!transporter.hasInventory()) - { - for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) - { - TileEntity tile = Coord4D.get(transporter).getFromSide(dir).getTileEntity(world); - - if(tile instanceof IInventory) - { - change = dir.getOpposite().ordinal(); - break; - } - } - } - } - - tileEntity.setFacing((short)change); - tileEntity.redstone = world.isBlockIndirectlyGettingPowered(x, y, z); - - if(tileEntity instanceof IBoundingBlock) - { - ((IBoundingBlock)tileEntity).onPlace(); - } - } - - @Override - public void breakBlock(World world, int x, int y, int z, Block block, int meta) - { - TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(x, y, z); - - if(tileEntity instanceof IBoundingBlock) - { - ((IBoundingBlock)tileEntity).onBreak(); - } - - super.breakBlock(world, x, y, z, block, meta); - } - - @Override - @SideOnly(Side.CLIENT) - public void randomDisplayTick(World world, int x, int y, int z, Random random) - { - TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(x, y, z); - - if(MekanismUtils.isActive(world, x, y, z) && ((IActiveState)tileEntity).renderUpdate() && client.machineEffects) - { - float xRandom = (float)x + 0.5F; - float yRandom = (float)y + 0.0F + random.nextFloat() * 6.0F / 16.0F; - float zRandom = (float)z + 0.5F; - float iRandom = 0.52F; - float jRandom = random.nextFloat() * 0.6F - 0.3F; - - int side = tileEntity.facing; - - if(tileEntity instanceof TileEntityMetallurgicInfuser) - { - side = ForgeDirection.getOrientation(side).getOpposite().ordinal(); - } - - if(side == 4) - { - world.spawnParticle("smoke", (xRandom - iRandom), yRandom, (zRandom + jRandom), 0.0D, 0.0D, 0.0D); - world.spawnParticle("reddust", (xRandom - iRandom), yRandom, (zRandom + jRandom), 0.0D, 0.0D, 0.0D); - } - else if(side == 5) - { - world.spawnParticle("smoke", (xRandom + iRandom), yRandom, (zRandom + jRandom), 0.0D, 0.0D, 0.0D); - world.spawnParticle("reddust", (xRandom + iRandom), yRandom, (zRandom + jRandom), 0.0D, 0.0D, 0.0D); - } - else if(side == 2) - { - world.spawnParticle("smoke", (xRandom + jRandom), yRandom, (zRandom - iRandom), 0.0D, 0.0D, 0.0D); - world.spawnParticle("reddust", (xRandom + jRandom), yRandom, (zRandom - iRandom), 0.0D, 0.0D, 0.0D); - } - else if(side == 3) - { - world.spawnParticle("smoke", (xRandom + jRandom), yRandom, (zRandom + iRandom), 0.0D, 0.0D, 0.0D); - world.spawnParticle("reddust", (xRandom + jRandom), yRandom, (zRandom + iRandom), 0.0D, 0.0D, 0.0D); - } - } - } - - @Override - public int getLightValue(IBlockAccess world, int x, int y, int z) - { - if(client.enableAmbientLighting) - { - TileEntity tileEntity = world.getTileEntity(x, y, z); - - if(tileEntity instanceof IActiveState) - { - if(((IActiveState)tileEntity).getActive() && ((IActiveState)tileEntity).lightUpdate()) - { - return client.ambientLightingLevel; - } - } - } - - return 0; - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int meta) - { - switch(blockType) - { - case MACHINE_BLOCK_1: - switch(meta) - { - case 0: - case 1: - case 2: - case 3: - case 9: - case 10: - return icons[meta][side]; - default: - return icons[meta][0] != null ? icons[meta][0] : BASE_ICON; - } - case MACHINE_BLOCK_2: - switch(meta) - { - case 3: - case 5: - return icons[meta][side]; - default: - return icons[meta][0] != null ? icons[meta][0] : BASE_ICON; - } - case MACHINE_BLOCK_3: - switch(meta) - { - case 3: - case 5: - case 6: - return icons[meta][side]; - default: - return icons[meta][0] != null ? icons[meta][0] : BASE_ICON; - } - default: - return BASE_ICON; - } - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) - { - int meta = world.getBlockMetadata(x, y, z); - TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(x, y, z); - - switch(blockType) - { - case MACHINE_BLOCK_1: - switch(meta) - { - case 0: - case 1: - case 2: - case 3: - case 9: - case 10: - boolean active = MekanismUtils.isActive(world, x, y, z); - return icons[meta][MekanismUtils.getBaseOrientation(side, tileEntity.facing)+(active ? 6 : 0)]; - case 5: - case 6: - case 7: - TileEntityFactory factory = (TileEntityFactory)tileEntity; - active = MekanismUtils.isActive(world, x, y, z); - - return factoryIcons[factory.tier.ordinal()][factory.recipeType.ordinal()][MekanismUtils.getBaseOrientation(side, tileEntity.facing)+(active ? 6 : 0)]; - default: - return icons[meta][0]; - } - case MACHINE_BLOCK_2: - switch(meta) - { - case 3: - case 5: - boolean active = MekanismUtils.isActive(world, x, y, z); - return icons[meta][MekanismUtils.getBaseOrientation(side, tileEntity.facing)+(active ? 6 : 0)]; - default: - return icons[meta][0]; - } - case MACHINE_BLOCK_3: - switch(meta) - { - case 3: - case 5: - case 6: - boolean active = MekanismUtils.isActive(world, x, y, z); - return icons[meta][MekanismUtils.getBaseOrientation(side, tileEntity.facing)+(active ? 6 : 0)]; - default: - return icons[meta][0]; - } - } - - return null; - } - - @Override - public int damageDropped(int i) - { - return i; - } - - @Override - @SideOnly(Side.CLIENT) - public void getSubBlocks(Item item, CreativeTabs creativetabs, List list) - { - for(MachineType type : MachineType.getValidMachines()) - { - if(type.typeBlock == blockType && type.isEnabled()) - { - switch(type) - { - case BASIC_FACTORY: - case ADVANCED_FACTORY: - case ELITE_FACTORY: - for(RecipeType recipe : RecipeType.values()) - { - ItemStack stack = new ItemStack(item, 1, type.meta); - ((IFactory)stack.getItem()).setRecipeType(recipe.ordinal(), stack); - list.add(stack); - } - - break; - case FLUID_TANK: - ItemBlockMachine itemMachine = (ItemBlockMachine)item; - - for(FluidTankTier tier : FluidTankTier.values()) - { - ItemStack stack = new ItemStack(item, 1, type.meta); - itemMachine.setBaseTier(stack, tier.getBaseTier()); - list.add(stack); - } - - if(general.prefilledFluidTanks) - { - for(Fluid f : FluidRegistry.getRegisteredFluids().values()) - { - try { //Prevent bad IDs - ItemStack filled = new ItemStack(item, 1, type.meta); - itemMachine.setBaseTier(filled, BaseTier.ULTIMATE); - itemMachine.setFluidStack(new FluidStack(f, itemMachine.getCapacity(filled)), filled); - list.add(filled); - } catch(Exception e) {} - } - } - - break; - default: - list.add(new ItemStack(item, 1, type.meta)); - } - } - } - } - - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int side, float posX, float posY, float posZ) - { - if(world.isRemote) - { - return true; - } - - TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(x, y, z); - int metadata = world.getBlockMetadata(x, y, z); - - if(entityplayer.getCurrentEquippedItem() != null) - { - Item tool = entityplayer.getCurrentEquippedItem().getItem(); - - if(MekanismUtils.hasUsableWrench(entityplayer, x, y, z)) - { - if(SecurityUtils.canAccess(entityplayer, tileEntity)) - { - if(entityplayer.isSneaking()) - { - dismantleBlock(world, x, y, z, false); - - return true; - } - - if(MekanismUtils.isBCWrench(tool)) - { - ((IToolWrench)tool).wrenchUsed(entityplayer, x, y, z); - } - - int change = ForgeDirection.ROTATION_MATRIX[ForgeDirection.UP.ordinal()][tileEntity.facing]; - - if(tileEntity instanceof TileEntityLogisticalSorter) - { - if(!((TileEntityLogisticalSorter)tileEntity).hasInventory()) - { - for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) - { - TileEntity tile = Coord4D.get(tileEntity).getFromSide(dir).getTileEntity(world); - - if(tile instanceof IInventory) - { - change = dir.getOpposite().ordinal(); - break; - } - } - } - } - - tileEntity.setFacing((short)change); - world.notifyBlocksOfNeighborChange(x, y, z, this); - } - else { - SecurityUtils.displayNoAccess(entityplayer); - } - - return true; - } - } - - if(tileEntity != null) - { - MachineType type = MachineType.get(blockType, metadata); - switch(type) - { - case PERSONAL_CHEST: - if(!entityplayer.isSneaking() && !world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN)) - { - TileEntityPersonalChest chest = (TileEntityPersonalChest)tileEntity; - - if(SecurityUtils.canAccess(entityplayer, tileEntity)) - { - MekanismUtils.openPersonalChestGui((EntityPlayerMP)entityplayer, chest, null, true); - } - else { - SecurityUtils.displayNoAccess(entityplayer); - } - - return true; - } - - break; - case FLUID_TANK: - if(!entityplayer.isSneaking()) - { - if(SecurityUtils.canAccess(entityplayer, tileEntity)) - { - if(entityplayer.getCurrentEquippedItem() != null && FluidContainerRegistry.isContainer(entityplayer.getCurrentEquippedItem())) - { - if(manageInventory(entityplayer, (TileEntityFluidTank)tileEntity)) - { - entityplayer.inventory.markDirty(); - return true; - } - } - else { - entityplayer.openGui(Mekanism.instance, type.guiId, world, x, y, z); - } - } - else { - SecurityUtils.displayNoAccess(entityplayer); - } - - return true; - } - - break; - case LOGISTICAL_SORTER: - if(!entityplayer.isSneaking()) - { - if(SecurityUtils.canAccess(entityplayer, tileEntity)) - { - LogisticalSorterGuiMessage.openServerGui(SorterGuiPacket.SERVER, 0, world, (EntityPlayerMP)entityplayer, Coord4D.get(tileEntity), -1); - } - else { - SecurityUtils.displayNoAccess(entityplayer); - } - - return true; - } - - break; - case TELEPORTER: - case QUANTUM_ENTANGLOPORTER: - if(!entityplayer.isSneaking()) - { - String owner = ((ISecurityTile)tileEntity).getSecurity().getOwner(); - - if(MekanismUtils.isOp((EntityPlayerMP)entityplayer) || owner == null || entityplayer.getCommandSenderName().equals(owner)) - { - entityplayer.openGui(Mekanism.instance, type.guiId, world, x, y, z); - } - else { - SecurityUtils.displayNoAccess(entityplayer); - } - - return true; - } - - break; - default: - if(!entityplayer.isSneaking() && type.guiId != -1) - { - if(SecurityUtils.canAccess(entityplayer, tileEntity)) - { - entityplayer.openGui(Mekanism.instance, type.guiId, world, x, y, z); - } - else { - SecurityUtils.displayNoAccess(entityplayer); - } - - return true; - } - - break; - } - } - - return false; - } - - @Override - public TileEntity createTileEntity(World world, int metadata) - { - if(MachineType.get(blockType, metadata) == null) - { - return null; - } - - return MachineType.get(blockType, metadata).create(); - } - - @Override - public TileEntity createNewTileEntity(World world, int metadata) - { - return null; - } - - @Override - public boolean renderAsNormalBlock() - { - return false; - } - - @Override - public boolean isOpaqueCube() - { - return false; - } - - @Override - public Item getItemDropped(int i, Random random, int j) - { - return null; - } - - @Override - public int getRenderType() - { - return Mekanism.proxy.CTM_RENDER_ID; - } - - @Override - public float getPlayerRelativeBlockHardness(EntityPlayer player, World world, int x, int y, int z) - { - TileEntity tile = world.getTileEntity(x, y, z); - - return SecurityUtils.canAccess(player, tile) ? super.getPlayerRelativeBlockHardness(player, world, x, y, z) : 0.0F; - } - - @Override - public float getExplosionResistance(Entity entity, World world, int x, int y, int z, double explosionX, double explosionY, double explosionZ) - { - if(MachineType.get(blockType, world.getBlockMetadata(x, y, z)) != MachineType.PERSONAL_CHEST) - { - return blockResistance; - } - else { - return -1; - } + public BlockMachine(MachineBlock type) { + super(Material.iron); + setHardness(3.5F); + setResistance(16F); + setCreativeTab(Mekanism.tabMekanism); + blockType = type; } - @Override - public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) - { - if(!player.capabilities.isCreativeMode && !world.isRemote && willHarvest) - { - TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(x, y, z); + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister register) { + BASE_ICON = register.registerIcon("mekanism:SteelCasing"); + DefIcon def = DefIcon.getAll(BASE_ICON).setOverrides(false); - float motion = 0.7F; - double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + switch (blockType) { + case MACHINE_BLOCK_1: + ctms[11][0] = new CTMData("ctm/Teleporter", this, Arrays.asList(11)) + .addOtherBlockConnectivities( + MekanismBlocks.BasicBlock, Arrays.asList(7) + ) + .registerIcons(register); - EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, getPickBlock(null, world, x, y, z, player)); + MekanismRenderer.loadDynamicTextures( + register, + "enrichment_chamber/" + MachineType.ENRICHMENT_CHAMBER.name, + icons[0], + def + ); + MekanismRenderer.loadDynamicTextures( + register, + "osmium_compressor/" + MachineType.OSMIUM_COMPRESSOR.name, + icons[1], + def + ); + MekanismRenderer.loadDynamicTextures( + register, "combiner/" + MachineType.COMBINER.name, icons[2], def + ); + MekanismRenderer.loadDynamicTextures( + register, "crusher/" + MachineType.CRUSHER.name, icons[3], def + ); - world.spawnEntityInWorld(entityItem); - } + for (RecipeType type : RecipeType.values()) { + MekanismRenderer.loadDynamicTextures( + register, + "factory/basic/" + type.getUnlocalizedName().toLowerCase() + "/" + + BaseTier.BASIC.getName() + type.getUnlocalizedName() + + MachineType.BASIC_FACTORY.name, + factoryIcons[0][type.ordinal()], + DefIcon + .getActivePair( + register.registerIcon( + "mekanism:factory/basic/BasicFactoryFront" + ), + 2 + ) + .setOverrides(false), + DefIcon + .getActivePair( + register.registerIcon( + "mekanism:factory/basic/BasicFactoryTop" + ), + 1 + ) + .setOverrides(false), + DefIcon + .getActivePair( + register.registerIcon( + "mekanism:factory/basic/BasicFactoryBottom" + ), + 0 + ) + .setOverrides(false), + DefIcon + .getActivePair( + register.registerIcon( + "mekanism:factory/basic/BasicFactorySide" + ), + 3, + 4, + 5 + ) + .setOverrides(false) + ); + MekanismRenderer.loadDynamicTextures( + register, + "factory/advanced/" + type.getUnlocalizedName().toLowerCase() + + "/" + BaseTier.ADVANCED.getName() + + type.getUnlocalizedName() + + MachineType.ADVANCED_FACTORY.name, + factoryIcons[1][type.ordinal()], + DefIcon + .getActivePair( + register.registerIcon( + "mekanism:factory/advanced/AdvancedFactoryFront" + ), + 2 + ) + .setOverrides(false), + DefIcon + .getActivePair( + register.registerIcon( + "mekanism:factory/advanced/AdvancedFactoryTop" + ), + 1 + ) + .setOverrides(false), + DefIcon + .getActivePair( + register.registerIcon( + "mekanism:factory/advanced/AdvancedFactoryBottom" + ), + 0 + ) + .setOverrides(false), + DefIcon + .getActivePair( + register.registerIcon( + "mekanism:factory/advanced/AdvancedFactorySide" + ), + 3, + 4, + 5 + ) + .setOverrides(false) + ); + MekanismRenderer.loadDynamicTextures( + register, + "factory/elite/" + type.getUnlocalizedName().toLowerCase() + "/" + + BaseTier.ELITE.getName() + type.getUnlocalizedName() + + MachineType.ELITE_FACTORY.name, + factoryIcons[2][type.ordinal()], + DefIcon + .getActivePair( + register.registerIcon( + "mekanism:factory/elite/EliteFactoryFront" + ), + 2 + ) + .setOverrides(false), + DefIcon + .getActivePair( + register.registerIcon( + "mekanism:factory/elite/EliteFactoryTop" + ), + 1 + ) + .setOverrides(false), + DefIcon + .getActivePair( + register.registerIcon( + "mekanism:factory/elite/EliteFactoryBottom" + ), + 0 + ) + .setOverrides(false), + DefIcon + .getActivePair( + register.registerIcon( + "mekanism:factory/elite/EliteFactorySide" + ), + 3, + 4, + 5 + ) + .setOverrides(false) + ); + } - return world.setBlockToAir(x, y, z); - } - - @Override - public boolean hasComparatorInputOverride() - { - return true; - } - - @Override - public int getComparatorInputOverride(World world, int x, int y, int z, int par5) - { - TileEntity tileEntity = world.getTileEntity(x, y, z); - - if(tileEntity instanceof TileEntityFluidTank) - { - return ((TileEntityFluidTank)tileEntity).getRedstoneLevel(); - } - - if(tileEntity instanceof TileEntityLaserAmplifier) - { - TileEntityLaserAmplifier amplifier = (TileEntityLaserAmplifier)tileEntity; - - if(amplifier.outputMode == TileEntityLaserAmplifier.RedstoneOutput.ENERGY_CONTENTS) - { - return amplifier.getRedstoneLevel(); - } - else { - return isProvidingWeakPower(world, x, y, z, par5); - } - } - - return 0; - } - - private boolean manageInventory(EntityPlayer player, TileEntityFluidTank tileEntity) - { - ItemStack itemStack = player.getCurrentEquippedItem(); + MekanismRenderer.loadDynamicTextures( + register, + "purification_chamber/" + MachineType.PURIFICATION_CHAMBER.name, + icons[9], + def + ); + MekanismRenderer.loadDynamicTextures( + register, + "energized_smelter/" + MachineType.ENERGIZED_SMELTER.name, + icons[10], + def + ); + icons[11][0] = ctms[11][0].mainTextureData.icon; - if(itemStack != null) - { - if(FluidContainerRegistry.isEmptyContainer(itemStack)) - { - if(tileEntity.fluidTank.getFluid() != null && tileEntity.fluidTank.getFluid().amount >= FluidContainerRegistry.BUCKET_VOLUME) - { - ItemStack filled = FluidContainerRegistry.fillFluidContainer(tileEntity.fluidTank.getFluid(), itemStack); + break; + case MACHINE_BLOCK_2: + MekanismRenderer.loadDynamicTextures( + register, + "chemical_injection_chamber/" + + MachineType.CHEMICAL_INJECTION_CHAMBER.name, + icons[3], + def + ); + MekanismRenderer.loadDynamicTextures( + register, + "precision_sawmill/" + MachineType.PRECISION_SAWMILL.name, + icons[5], + def + ); - if(filled != null) - { - if(player.capabilities.isCreativeMode) - { - tileEntity.fluidTank.drain(FluidContainerRegistry.getFluidForFilledItem(filled).amount, true); + break; + case MACHINE_BLOCK_3: + icons[0][0] = BASE_ICON; + icons[2][0] = BASE_ICON; + MekanismRenderer.loadDynamicTextures( + register, + "oredictionificator/" + MachineType.OREDICTIONIFICATOR.name, + icons[3] + ); + icons[4][0] = BASE_ICON; + MekanismRenderer.loadDynamicTextures( + register, + "formulaic_assemblicator/" + MachineType.FORMULAIC_ASSEMBLICATOR.name, + icons[5] + ); + MekanismRenderer.loadDynamicTextures( + register, + "fuelwood_heater/" + MachineType.FUELWOOD_HEATER.name, + icons[6] + ); - return true; - } + break; + } + } - if(itemStack.stackSize > 1) - { - if(player.inventory.addItemStackToInventory(filled)) - { - itemStack.stackSize--; + @Override + public IIcon getIcon(ItemStack stack, int side) { + MachineType type = MachineType.get(stack); + ItemBlockMachine item = (ItemBlockMachine) stack.getItem(); - tileEntity.fluidTank.drain(FluidContainerRegistry.getFluidForFilledItem(filled).amount, true); - } - } - else if(itemStack.stackSize == 1) - { - player.setCurrentItemOrArmor(0, filled); + if (type == MachineType.BASIC_FACTORY) { + return factoryIcons[0][item.getRecipeType(stack)][side]; + } else if (type == MachineType.ADVANCED_FACTORY) { + return factoryIcons[1][item.getRecipeType(stack)][side]; + } else if (type == MachineType.ELITE_FACTORY) { + return factoryIcons[2][item.getRecipeType(stack)][side]; + } - tileEntity.fluidTank.drain(FluidContainerRegistry.getFluidForFilledItem(filled).amount, true); + return getIcon(side, stack.getItemDamage()); + } - return true; - } - } - } - } - else if(FluidContainerRegistry.isFilledContainer(itemStack)) - { - FluidStack itemFluid = FluidContainerRegistry.getFluidForFilledItem(itemStack); - int needed = tileEntity.getCurrentNeeded(); - - if((tileEntity.fluidTank.getFluid() == null && itemFluid.amount <= tileEntity.fluidTank.getCapacity()) || itemFluid.amount <= needed) - { - if(tileEntity.fluidTank.getFluid() != null && !tileEntity.fluidTank.getFluid().isFluidEqual(itemFluid)) - { - return false; - } - - boolean filled = false; - - if(player.capabilities.isCreativeMode) - { - filled = true; - } - else { - ItemStack containerItem = itemStack.getItem().getContainerItem(itemStack); - - if(containerItem != null) - { - if(itemStack.stackSize == 1) - { - player.setCurrentItemOrArmor(0, containerItem); - filled = true; - } - else { - if(player.inventory.addItemStackToInventory(containerItem)) - { - itemStack.stackSize--; - - filled = true; - } - } - } - else { - itemStack.stackSize--; - - if(itemStack.stackSize == 0) - { - player.setCurrentItemOrArmor(0, null); - } - - filled = true; - } - } + @Override + public void onBlockPlacedBy( + World world, + int x, + int y, + int z, + EntityLivingBase entityliving, + ItemStack itemstack + ) { + TileEntityBasicBlock tileEntity + = (TileEntityBasicBlock) world.getTileEntity(x, y, z); + int side + = MathHelper.floor_double((entityliving.rotationYaw * 4.0F / 360.0F) + 0.5D) + & 3; + int height = Math.round(entityliving.rotationPitch); + int change = 3; - if(filled) - { - int toFill = Math.min(tileEntity.fluidTank.getCapacity()-tileEntity.fluidTank.getFluidAmount(), itemFluid.amount); - - tileEntity.fluidTank.fill(itemFluid, true); - - if(itemFluid.amount-toFill > 0) - { - tileEntity.pushUp(PipeUtils.copy(itemFluid, itemFluid.amount-toFill), true); - } - - return true; - } - } - } - } + if (tileEntity == null) { + return; + } - return false; - } + if (tileEntity.canSetFacing(0) && tileEntity.canSetFacing(1)) { + if (height >= 65) { + change = 1; + } else if (height <= -65) { + change = 0; + } + } - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) - { - if(!world.isRemote) - { - TileEntity tileEntity = world.getTileEntity(x, y, z); + if (change != 0 && change != 1) { + switch (side) { + case 0: + change = 2; + break; + case 1: + change = 5; + break; + case 2: + change = 3; + break; + case 3: + change = 4; + break; + } + } - if(tileEntity instanceof TileEntityBasicBlock) - { - ((TileEntityBasicBlock)tileEntity).onNeighborChange(block); - } - - if(tileEntity instanceof TileEntityLogisticalSorter) - { - TileEntityLogisticalSorter sorter = (TileEntityLogisticalSorter)tileEntity; + if (tileEntity instanceof TileEntityLogisticalSorter) { + TileEntityLogisticalSorter transporter + = (TileEntityLogisticalSorter) tileEntity; - if(!sorter.hasInventory()) - { - for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) - { - TileEntity tile = Coord4D.get(tileEntity).getFromSide(dir).getTileEntity(world); + if (!transporter.hasInventory()) { + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + TileEntity tile + = Coord4D.get(transporter).getFromSide(dir).getTileEntity(world); - if(tile instanceof IInventory) - { - sorter.setFacing((short)dir.getOpposite().ordinal()); - return; - } - } - } - } - } - } + if (tile instanceof IInventory) { + change = dir.getOpposite().ordinal(); + break; + } + } + } + } - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) - { - TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(x, y, z); - ItemStack itemStack = new ItemStack(this, 1, world.getBlockMetadata(x, y, z)); + tileEntity.setFacing((short) change); + tileEntity.redstone = world.isBlockIndirectlyGettingPowered(x, y, z); - if(itemStack.stackTagCompound == null) - { - itemStack.setTagCompound(new NBTTagCompound()); - } - - if(tileEntity instanceof TileEntityFluidTank) - { - ITierItem tierItem = (ITierItem)itemStack.getItem(); - tierItem.setBaseTier(itemStack, ((TileEntityFluidTank)tileEntity).tier.getBaseTier()); - } - - if(tileEntity instanceof ISecurityTile) - { - ISecurityItem securityItem = (ISecurityItem)itemStack.getItem(); - - if(securityItem.hasSecurity(itemStack)) - { - securityItem.setOwner(itemStack, ((ISecurityTile)tileEntity).getSecurity().getOwner()); - securityItem.setSecurity(itemStack, ((ISecurityTile)tileEntity).getSecurity().getMode()); - } - } + if (tileEntity instanceof IBoundingBlock) { + ((IBoundingBlock) tileEntity).onPlace(); + } + } - if(tileEntity instanceof IUpgradeTile) - { - ((IUpgradeTile)tileEntity).getComponent().write(itemStack.stackTagCompound); - } + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int meta) { + TileEntityBasicBlock tileEntity + = (TileEntityBasicBlock) world.getTileEntity(x, y, z); - if(tileEntity instanceof ISideConfiguration) - { - ISideConfiguration config = (ISideConfiguration)tileEntity; + if (tileEntity instanceof IBoundingBlock) { + ((IBoundingBlock) tileEntity).onBreak(); + } - config.getConfig().write(itemStack.stackTagCompound); - } - - if(tileEntity instanceof ISustainedData) - { - ((ISustainedData)tileEntity).writeSustainedData(itemStack); - } + super.breakBlock(world, x, y, z, block, meta); + } - if(tileEntity instanceof IRedstoneControl) - { - IRedstoneControl control = (IRedstoneControl)tileEntity; - itemStack.stackTagCompound.setInteger("controlType", control.getControlType().ordinal()); - } + @Override + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World world, int x, int y, int z, Random random) { + TileEntityBasicBlock tileEntity + = (TileEntityBasicBlock) world.getTileEntity(x, y, z); - if(tileEntity instanceof IStrictEnergyStorage) - { - IEnergizedItem energizedItem = (IEnergizedItem)itemStack.getItem(); - energizedItem.setEnergy(itemStack, ((IStrictEnergyStorage)tileEntity).getEnergy()); - } + if (MekanismUtils.isActive(world, x, y, z) + && ((IActiveState) tileEntity).renderUpdate() && client.machineEffects) { + float xRandom = (float) x + 0.5F; + float yRandom = (float) y + 0.0F + random.nextFloat() * 6.0F / 16.0F; + float zRandom = (float) z + 0.5F; + float iRandom = 0.52F; + float jRandom = random.nextFloat() * 0.6F - 0.3F; - if(tileEntity instanceof TileEntityContainerBlock && ((TileEntityContainerBlock)tileEntity).inventory.length > 0) - { - ISustainedInventory inventory = (ISustainedInventory)itemStack.getItem(); - inventory.setInventory(((ISustainedInventory)tileEntity).getInventory(), itemStack); - } + int side = tileEntity.facing; - if(((ISustainedTank)itemStack.getItem()).hasTank(itemStack)) - { - if(tileEntity instanceof ISustainedTank) - { - if(((ISustainedTank)tileEntity).getFluidStack() != null) - { - ((ISustainedTank)itemStack.getItem()).setFluidStack(((ISustainedTank)tileEntity).getFluidStack(), itemStack); - } - } - } + if (tileEntity instanceof TileEntityMetallurgicInfuser) { + side = ForgeDirection.getOrientation(side).getOpposite().ordinal(); + } - if(tileEntity instanceof TileEntityFactory) - { - IFactory factoryItem = (IFactory)itemStack.getItem(); - factoryItem.setRecipeType(((TileEntityFactory)tileEntity).recipeType.ordinal(), itemStack); - } + if (side == 4) { + world.spawnParticle( + "smoke", + (xRandom - iRandom), + yRandom, + (zRandom + jRandom), + 0.0D, + 0.0D, + 0.0D + ); + world.spawnParticle( + "reddust", + (xRandom - iRandom), + yRandom, + (zRandom + jRandom), + 0.0D, + 0.0D, + 0.0D + ); + } else if (side == 5) { + world.spawnParticle( + "smoke", + (xRandom + iRandom), + yRandom, + (zRandom + jRandom), + 0.0D, + 0.0D, + 0.0D + ); + world.spawnParticle( + "reddust", + (xRandom + iRandom), + yRandom, + (zRandom + jRandom), + 0.0D, + 0.0D, + 0.0D + ); + } else if (side == 2) { + world.spawnParticle( + "smoke", + (xRandom + jRandom), + yRandom, + (zRandom - iRandom), + 0.0D, + 0.0D, + 0.0D + ); + world.spawnParticle( + "reddust", + (xRandom + jRandom), + yRandom, + (zRandom - iRandom), + 0.0D, + 0.0D, + 0.0D + ); + } else if (side == 3) { + world.spawnParticle( + "smoke", + (xRandom + jRandom), + yRandom, + (zRandom + iRandom), + 0.0D, + 0.0D, + 0.0D + ); + world.spawnParticle( + "reddust", + (xRandom + jRandom), + yRandom, + (zRandom + iRandom), + 0.0D, + 0.0D, + 0.0D + ); + } + } + } - return itemStack; - } - - @Override - public void onBlockAdded(World world, int x, int y, int z) - { - TileEntity tileEntity = world.getTileEntity(x, y, z); + @Override + public int getLightValue(IBlockAccess world, int x, int y, int z) { + if (client.enableAmbientLighting) { + TileEntity tileEntity = world.getTileEntity(x, y, z); - if(!world.isRemote) - { - if(tileEntity instanceof TileEntityBasicBlock) - { - ((TileEntityBasicBlock)tileEntity).onAdded(); - } - } - } + if (tileEntity instanceof IActiveState) { + if (((IActiveState) tileEntity).getActive() + && ((IActiveState) tileEntity).lightUpdate()) { + return client.ambientLightingLevel; + } + } + } - @Override - public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) - { - MachineType type = MachineType.get(blockType, world.getBlockMetadata(x, y, z)); - - switch(type) - { - case LASER_AMPLIFIER: - return true; - default: - return false; - } - } - - public ItemStack dismantleBlock(World world, int x, int y, int z, boolean returnBlock) - { - ItemStack itemStack = getPickBlock(null, world, x, y, z, null); - - world.setBlockToAir(x, y, z); - - if(!returnBlock) - { - float motion = 0.7F; - double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - - EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, itemStack); - - world.spawnEntityInWorld(entityItem); - } - - return itemStack; - } - - @Override - public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) - { - MachineType type = MachineType.get(blockType, world.getBlockMetadata(x, y, z)); - - if(type == null) - { - return; - } - - switch(type) - { - case CHARGEPAD: - setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.06F, 1.0F); - break; - case FLUID_TANK: - setBlockBounds(0.125F, 0.0F, 0.125F, 0.875F, 1.0F, 0.875F); - break; - default: - setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - break; - } - } - - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) - { - setBlockBoundsBasedOnState(world, x, y, z); - - if(world.getTileEntity(x, y, z) instanceof TileEntityChargepad) - { - return null; - } - - return super.getCollisionBoundingBoxFromPool(world, x, y, z); - } - - @Override - public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) - { - MachineType type = MachineType.get(blockType, world.getBlockMetadata(x, y, z)); - - switch(type) - { - case CHARGEPAD: - case PERSONAL_CHEST: - return false; - case FLUID_TANK: - return side == ForgeDirection.UP || side == ForgeDirection.DOWN; - default: - return true; - } - } - - public static enum MachineBlock - { - MACHINE_BLOCK_1, - MACHINE_BLOCK_2, - MACHINE_BLOCK_3; - - public Block getBlock() - { - switch(this) - { - case MACHINE_BLOCK_1: - return MekanismBlocks.MachineBlock; - case MACHINE_BLOCK_2: - return MekanismBlocks.MachineBlock2; - case MACHINE_BLOCK_3: - return MekanismBlocks.MachineBlock3; - default: - return null; - } - } - } - - public static enum MachineType - { - ENRICHMENT_CHAMBER(MachineBlock.MACHINE_BLOCK_1, 0, "EnrichmentChamber", 3, TileEntityEnrichmentChamber.class, true, false, true), - OSMIUM_COMPRESSOR(MachineBlock.MACHINE_BLOCK_1, 1, "OsmiumCompressor", 4, TileEntityOsmiumCompressor.class, true, false, true), - COMBINER(MachineBlock.MACHINE_BLOCK_1, 2, "Combiner", 5, TileEntityCombiner.class, true, false, true), - CRUSHER(MachineBlock.MACHINE_BLOCK_1, 3, "Crusher", 6, TileEntityCrusher.class, true, false, true), - DIGITAL_MINER(MachineBlock.MACHINE_BLOCK_1, 4, "DigitalMiner", 2, TileEntityDigitalMiner.class, true, true, true), - BASIC_FACTORY(MachineBlock.MACHINE_BLOCK_1, 5, "Factory", 11, TileEntityFactory.class, true, false, true), - ADVANCED_FACTORY(MachineBlock.MACHINE_BLOCK_1, 6, "Factory", 11, TileEntityAdvancedFactory.class, true, false, true), - ELITE_FACTORY(MachineBlock.MACHINE_BLOCK_1, 7, "Factory", 11, TileEntityEliteFactory.class, true, false, true), - METALLURGIC_INFUSER(MachineBlock.MACHINE_BLOCK_1, 8, "MetallurgicInfuser", 12, TileEntityMetallurgicInfuser.class, true, true, true), - PURIFICATION_CHAMBER(MachineBlock.MACHINE_BLOCK_1, 9, "PurificationChamber", 15, TileEntityPurificationChamber.class, true, false, true), - ENERGIZED_SMELTER(MachineBlock.MACHINE_BLOCK_1, 10, "EnergizedSmelter", 16, TileEntityEnergizedSmelter.class, true, false, true), - TELEPORTER(MachineBlock.MACHINE_BLOCK_1, 11, "Teleporter", 13, TileEntityTeleporter.class, true, false, false), - ELECTRIC_PUMP(MachineBlock.MACHINE_BLOCK_1, 12, "ElectricPump", 17, TileEntityElectricPump.class, true, true, false), - PERSONAL_CHEST(MachineBlock.MACHINE_BLOCK_1, 13, "PersonalChest", -1, TileEntityPersonalChest.class, false, true, false), - CHARGEPAD(MachineBlock.MACHINE_BLOCK_1, 14, "Chargepad", -1, TileEntityChargepad.class, true, true, false), - LOGISTICAL_SORTER(MachineBlock.MACHINE_BLOCK_1, 15, "LogisticalSorter", -1, TileEntityLogisticalSorter.class, false, true, false), - ROTARY_CONDENSENTRATOR(MachineBlock.MACHINE_BLOCK_2, 0, "RotaryCondensentrator", 7, TileEntityRotaryCondensentrator.class, true, true, false), - CHEMICAL_OXIDIZER(MachineBlock.MACHINE_BLOCK_2, 1, "ChemicalOxidizer", 29, TileEntityChemicalOxidizer.class, true, true, true), - CHEMICAL_INFUSER(MachineBlock.MACHINE_BLOCK_2, 2, "ChemicalInfuser", 30, TileEntityChemicalInfuser.class, true, true, false), - CHEMICAL_INJECTION_CHAMBER(MachineBlock.MACHINE_BLOCK_2, 3, "ChemicalInjectionChamber", 31, TileEntityChemicalInjectionChamber.class, true, false, true), - ELECTROLYTIC_SEPARATOR(MachineBlock.MACHINE_BLOCK_2, 4, "ElectrolyticSeparator", 32, TileEntityElectrolyticSeparator.class, true, true, false), - PRECISION_SAWMILL(MachineBlock.MACHINE_BLOCK_2, 5, "PrecisionSawmill", 34, TileEntityPrecisionSawmill.class, true, false, true), - CHEMICAL_DISSOLUTION_CHAMBER(MachineBlock.MACHINE_BLOCK_2, 6, "ChemicalDissolutionChamber", 35, TileEntityChemicalDissolutionChamber.class, true, true, true), - CHEMICAL_WASHER(MachineBlock.MACHINE_BLOCK_2, 7, "ChemicalWasher", 36, TileEntityChemicalWasher.class, true, true, false), - CHEMICAL_CRYSTALLIZER(MachineBlock.MACHINE_BLOCK_2, 8, "ChemicalCrystallizer", 37, TileEntityChemicalCrystallizer.class, true, true, true), - SEISMIC_VIBRATOR(MachineBlock.MACHINE_BLOCK_2, 9, "SeismicVibrator", 39, TileEntitySeismicVibrator.class, true, true, false), - PRESSURIZED_REACTION_CHAMBER(MachineBlock.MACHINE_BLOCK_2, 10, "PressurizedReactionChamber", 40, TileEntityPRC.class, true, true, false), - FLUID_TANK(MachineBlock.MACHINE_BLOCK_2, 11, "FluidTank", 41, TileEntityFluidTank.class, false, true, false), - FLUIDIC_PLENISHER(MachineBlock.MACHINE_BLOCK_2, 12, "FluidicPlenisher", 42, TileEntityFluidicPlenisher.class, true, true, false), - LASER(MachineBlock.MACHINE_BLOCK_2, 13, "Laser", -1, TileEntityLaser.class, true, true, false), - LASER_AMPLIFIER(MachineBlock.MACHINE_BLOCK_2, 14, "LaserAmplifier", 44, TileEntityLaserAmplifier.class, false, true, false), - LASER_TRACTOR_BEAM(MachineBlock.MACHINE_BLOCK_2, 15, "LaserTractorBeam", 45, TileEntityLaserTractorBeam.class, false, true, false), - QUANTUM_ENTANGLOPORTER(MachineBlock.MACHINE_BLOCK_3, 0, "QuantumEntangloporter", 46, TileEntityQuantumEntangloporter.class, true, true, false), - SOLAR_NEUTRON_ACTIVATOR(MachineBlock.MACHINE_BLOCK_3, 1, "SolarNeutronActivator", 47, TileEntitySolarNeutronActivator.class, false, true, false), - AMBIENT_ACCUMULATOR(MachineBlock.MACHINE_BLOCK_3, 2, "AmbientAccumulator", 48, TileEntityAmbientAccumulator.class, true, false, false), - OREDICTIONIFICATOR(MachineBlock.MACHINE_BLOCK_3, 3, "Oredictionificator", 52, TileEntityOredictionificator.class, false, false, false), - RESISTIVE_HEATER(MachineBlock.MACHINE_BLOCK_3, 4, "ResistiveHeater", 53, TileEntityResistiveHeater.class, true, true, false), - FORMULAIC_ASSEMBLICATOR(MachineBlock.MACHINE_BLOCK_3, 5, "FormulaicAssemblicator", 56, TileEntityFormulaicAssemblicator.class, true, false, true), - FUELWOOD_HEATER(MachineBlock.MACHINE_BLOCK_3, 6, "FuelwoodHeater", 58, TileEntityFuelwoodHeater.class, false, false, false), - THEORETICAL_ELEMENTIZER(MachineBlock.MACHINE_BLOCK_3, 7, "TheoreticalElementizer", 60, TileEntityTheoreticalElementizer.class, true, true, false); - - public MachineBlock typeBlock; - public int meta; - public String name; - public int guiId; - public double baseEnergy; - public Class tileEntityClass; - public boolean isElectric; - public boolean hasModel; - public boolean supportsUpgrades; - public Collection machineRecipes = new HashSet(); - - private MachineType(MachineBlock block, int i, String s, int j, Class tileClass, boolean electric, boolean model, boolean upgrades) - { - typeBlock = block; - meta = i; - name = s; - guiId = j; - tileEntityClass = tileClass; - isElectric = electric; - hasModel = model; - supportsUpgrades = upgrades; - } - - public boolean isEnabled() - { - return machines.isEnabled(this.name); - } - - public void addRecipes(Collection recipes) - { - machineRecipes.addAll(recipes); - } - - public void addRecipe(ShapedMekanismRecipe recipe) - { - machineRecipes.add(recipe); - } - - public Collection getRecipes() - { - return machineRecipes; - } - - public static List getValidMachines() - { - List ret = new ArrayList(); - - for(MachineType type : MachineType.values()) - { - if(type != AMBIENT_ACCUMULATOR) - { - ret.add(type); - } - } - - return ret; - } - - public static MachineType get(Block block, int meta) - { - if(block instanceof BlockMachine) - { - return get(((BlockMachine)block).blockType, meta); - } - - return null; - } - - public static MachineType get(MachineBlock block, int meta) - { - for(MachineType type : values()) - { - if(type.meta == meta && type.typeBlock == block) - { - return type; - } - } - - return null; - } - - public TileEntity create() - { - try { - return tileEntityClass.newInstance(); - } catch(Exception e) { - Mekanism.logger.error("Unable to indirectly create tile entity."); - e.printStackTrace(); - return null; - } - } - - /** Used for getting the base energy storage. */ - public double getUsage() - { - switch(this) - { - case ENRICHMENT_CHAMBER: - return usage.enrichmentChamberUsage; - case OSMIUM_COMPRESSOR: - return usage.osmiumCompressorUsage; - case COMBINER: - return usage.combinerUsage; - case CRUSHER: - return usage.crusherUsage; - case DIGITAL_MINER: - return usage.digitalMinerUsage; - case BASIC_FACTORY: - return usage.factoryUsage * 3; - case ADVANCED_FACTORY: - return usage.factoryUsage * 5; - case ELITE_FACTORY: - return usage.factoryUsage * 7; - case METALLURGIC_INFUSER: - return usage.metallurgicInfuserUsage; - case PURIFICATION_CHAMBER: - return usage.purificationChamberUsage; - case ENERGIZED_SMELTER: - return usage.energizedSmelterUsage; - case TELEPORTER: - return 12500; - case ELECTRIC_PUMP: - return usage.electricPumpUsage; - case CHARGEPAD: - return 25; - case LOGISTICAL_SORTER: - return 0; - case ROTARY_CONDENSENTRATOR: - return usage.rotaryCondensentratorUsage; - case CHEMICAL_OXIDIZER: - return usage.oxidationChamberUsage; - case CHEMICAL_INFUSER: - return usage.chemicalInfuserUsage; - case CHEMICAL_INJECTION_CHAMBER: - return usage.chemicalInjectionChamberUsage; - case ELECTROLYTIC_SEPARATOR: - return general.FROM_H2 * 2; - case PRECISION_SAWMILL: - return usage.precisionSawmillUsage; - case CHEMICAL_DISSOLUTION_CHAMBER: - return usage.chemicalDissolutionChamberUsage; - case CHEMICAL_WASHER: - return usage.chemicalWasherUsage; - case CHEMICAL_CRYSTALLIZER: - return usage.chemicalCrystallizerUsage; - case SEISMIC_VIBRATOR: - return usage.seismicVibratorUsage; - case PRESSURIZED_REACTION_CHAMBER: - return usage.pressurizedReactionBaseUsage; - case FLUID_TANK: - return 0; - case FLUIDIC_PLENISHER: - return usage.fluidicPlenisherUsage; - case LASER: - return usage.laserUsage; - case LASER_AMPLIFIER: - return 0; - case LASER_TRACTOR_BEAM: - return 0; - case QUANTUM_ENTANGLOPORTER: - return 0; - case SOLAR_NEUTRON_ACTIVATOR: - return 0; - case AMBIENT_ACCUMULATOR: - return 0; - case RESISTIVE_HEATER: - return 100; - case FORMULAIC_ASSEMBLICATOR: - return usage.formulaicAssemblicatorUsage; - case THEORETICAL_ELEMENTIZER: - return 20000.0; - default: - return 0; - } - } - - public static void updateAllUsages() - { - for(MachineType type : values()) - { - type.updateUsage(); - } - } - - public void updateUsage() - { - baseEnergy = 400 * getUsage(); - } - - public String getDescription() - { - return LangUtils.localize("tooltip." + name); - } - - public ItemStack getStack() - { - return new ItemStack(typeBlock.getBlock(), 1, meta); - } - - public static MachineType get(ItemStack stack) - { - return get(Block.getBlockFromItem(stack.getItem()), stack.getItemDamage()); - } - } - - @Override - public void setRenderBounds(Block block, int metadata) {} - - @Override - public boolean doDefaultBoundSetting(int metadata) - { - return false; - } - - @Override - public ForgeDirection[] getValidRotations(World world, int x, int y, int z) - { - TileEntity tile = world.getTileEntity(x, y, z); - ForgeDirection[] valid = new ForgeDirection[6]; - - if(tile instanceof TileEntityBasicBlock) - { - TileEntityBasicBlock basicTile = (TileEntityBasicBlock)tile; - - for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) - { - if(basicTile.canSetFacing(dir.ordinal())) - { - valid[dir.ordinal()] = dir; - } - } - } - - return valid; - } - - @Override - public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis) - { - TileEntity tile = world.getTileEntity(x, y, z); - - if(tile instanceof TileEntityBasicBlock) - { - TileEntityBasicBlock basicTile = (TileEntityBasicBlock)tile; - - if(basicTile.canSetFacing(axis.ordinal())) - { - basicTile.setFacing((short)axis.ordinal()); - return true; - } - } - - return false; - } - - @Override - public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) - { - TileEntity tile = world.getTileEntity(x, y, z); - - if(tile instanceof TileEntityLaserAmplifier) - { - return ((TileEntityLaserAmplifier)tile).emittingRedstone ? 15 : 0; - } - return 0; } - - @Override - public CTMData getCTMData(IBlockAccess world, int x, int y, int z, int meta) - { - if(ctms[meta][1] != null && MekanismUtils.isActive(world, x, y, z)) - { - return ctms[meta][1]; - } - - return ctms[meta][0]; - } - - @Override - public boolean shouldRenderBlock(IBlockAccess world, int x, int y, int z, int meta) - { - return !MachineType.get(this, meta).hasModel; - } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { + switch (blockType) { + case MACHINE_BLOCK_1: + switch (meta) { + case 0: + case 1: + case 2: + case 3: + case 9: + case 10: + return icons[meta][side]; + default: + return icons[meta][0] != null ? icons[meta][0] : BASE_ICON; + } + case MACHINE_BLOCK_2: + switch (meta) { + case 3: + case 5: + return icons[meta][side]; + default: + return icons[meta][0] != null ? icons[meta][0] : BASE_ICON; + } + case MACHINE_BLOCK_3: + switch (meta) { + case 3: + case 5: + case 6: + return icons[meta][side]; + default: + return icons[meta][0] != null ? icons[meta][0] : BASE_ICON; + } + default: + return BASE_ICON; + } + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { + int meta = world.getBlockMetadata(x, y, z); + TileEntityBasicBlock tileEntity + = (TileEntityBasicBlock) world.getTileEntity(x, y, z); + + switch (blockType) { + case MACHINE_BLOCK_1: + switch (meta) { + case 0: + case 1: + case 2: + case 3: + case 9: + case 10: + boolean active = MekanismUtils.isActive(world, x, y, z); + return icons[meta] + [MekanismUtils + .getBaseOrientation(side, tileEntity.facing) + + (active ? 6 : 0)]; + case 5: + case 6: + case 7: + TileEntityFactory factory = (TileEntityFactory) tileEntity; + active = MekanismUtils.isActive(world, x, y, z); + + return factoryIcons[factory.tier + .ordinal()][factory.recipeType.ordinal( + )][MekanismUtils.getBaseOrientation(side, tileEntity.facing) + + (active ? 6 : 0)]; + default: + return icons[meta][0]; + } + case MACHINE_BLOCK_2: + switch (meta) { + case 3: + case 5: + boolean active = MekanismUtils.isActive(world, x, y, z); + return icons[meta] + [MekanismUtils + .getBaseOrientation(side, tileEntity.facing) + + (active ? 6 : 0)]; + default: + return icons[meta][0]; + } + case MACHINE_BLOCK_3: + switch (meta) { + case 3: + case 5: + case 6: + boolean active = MekanismUtils.isActive(world, x, y, z); + return icons[meta] + [MekanismUtils + .getBaseOrientation(side, tileEntity.facing) + + (active ? 6 : 0)]; + default: + return icons[meta][0]; + } + } + + return null; + } + + @Override + public int damageDropped(int i) { + return i; + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item item, CreativeTabs creativetabs, List list) { + for (MachineType type : MachineType.getValidMachines()) { + if (type.typeBlock == blockType && type.isEnabled()) { + switch (type) { + case BASIC_FACTORY: + case ADVANCED_FACTORY: + case ELITE_FACTORY: + for (RecipeType recipe : RecipeType.values()) { + ItemStack stack = new ItemStack(item, 1, type.meta); + ((IFactory) stack.getItem()) + .setRecipeType(recipe.ordinal(), stack); + list.add(stack); + } + + break; + case FLUID_TANK: + ItemBlockMachine itemMachine = (ItemBlockMachine) item; + + for (FluidTankTier tier : FluidTankTier.values()) { + ItemStack stack = new ItemStack(item, 1, type.meta); + itemMachine.setBaseTier(stack, tier.getBaseTier()); + list.add(stack); + } + + if (general.prefilledFluidTanks) { + for (Fluid f : FluidRegistry.getRegisteredFluids().values()) { + try { //Prevent bad IDs + ItemStack filled = new ItemStack(item, 1, type.meta); + itemMachine.setBaseTier(filled, BaseTier.ULTIMATE); + itemMachine.setFluidStack( + new FluidStack( + f, itemMachine.getCapacity(filled) + ), + filled + ); + list.add(filled); + } catch (Exception e) {} + } + } + + break; + default: + list.add(new ItemStack(item, 1, type.meta)); + } + } + } + } + + @Override + public boolean onBlockActivated( + World world, + int x, + int y, + int z, + EntityPlayer entityplayer, + int side, + float posX, + float posY, + float posZ + ) { + if (world.isRemote) { + return true; + } + + TileEntityBasicBlock tileEntity + = (TileEntityBasicBlock) world.getTileEntity(x, y, z); + int metadata = world.getBlockMetadata(x, y, z); + + if (entityplayer.getCurrentEquippedItem() != null) { + Item tool = entityplayer.getCurrentEquippedItem().getItem(); + + if (MekanismUtils.hasUsableWrench(entityplayer, x, y, z)) { + if (SecurityUtils.canAccess(entityplayer, tileEntity)) { + if (entityplayer.isSneaking()) { + dismantleBlock(world, x, y, z, false); + + return true; + } + + if (MekanismUtils.isBCWrench(tool)) { + ((IToolWrench) tool).wrenchUsed(entityplayer, x, y, z); + } + + int change + = ForgeDirection.ROTATION_MATRIX[ForgeDirection.UP.ordinal()] + [tileEntity.facing]; + + if (tileEntity instanceof TileEntityLogisticalSorter) { + if (!((TileEntityLogisticalSorter) tileEntity).hasInventory()) { + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + TileEntity tile = Coord4D.get(tileEntity) + .getFromSide(dir) + .getTileEntity(world); + + if (tile instanceof IInventory) { + change = dir.getOpposite().ordinal(); + break; + } + } + } + } + + tileEntity.setFacing((short) change); + world.notifyBlocksOfNeighborChange(x, y, z, this); + } else { + SecurityUtils.displayNoAccess(entityplayer); + } + + return true; + } + } + + if (tileEntity != null) { + MachineType type = MachineType.get(blockType, metadata); + switch (type) { + case PERSONAL_CHEST: + if (!entityplayer.isSneaking() + && !world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN)) { + TileEntityPersonalChest chest + = (TileEntityPersonalChest) tileEntity; + + if (SecurityUtils.canAccess(entityplayer, tileEntity)) { + MekanismUtils.openPersonalChestGui( + (EntityPlayerMP) entityplayer, chest, null, true + ); + } else { + SecurityUtils.displayNoAccess(entityplayer); + } + + return true; + } + + break; + case FLUID_TANK: + if (!entityplayer.isSneaking()) { + if (SecurityUtils.canAccess(entityplayer, tileEntity)) { + if (entityplayer.getCurrentEquippedItem() != null + && FluidContainerRegistry.isContainer( + entityplayer.getCurrentEquippedItem() + )) { + if (manageInventory( + entityplayer, (TileEntityFluidTank) tileEntity + )) { + entityplayer.inventory.markDirty(); + return true; + } + } else { + entityplayer.openGui( + Mekanism.instance, type.guiId, world, x, y, z + ); + } + } else { + SecurityUtils.displayNoAccess(entityplayer); + } + + return true; + } + + break; + case LOGISTICAL_SORTER: + if (!entityplayer.isSneaking()) { + if (SecurityUtils.canAccess(entityplayer, tileEntity)) { + LogisticalSorterGuiMessage.openServerGui( + SorterGuiPacket.SERVER, + 0, + world, + (EntityPlayerMP) entityplayer, + Coord4D.get(tileEntity), + -1 + ); + } else { + SecurityUtils.displayNoAccess(entityplayer); + } + + return true; + } + + break; + case TELEPORTER: + case QUANTUM_ENTANGLOPORTER: + if (!entityplayer.isSneaking()) { + String owner + = ((ISecurityTile) tileEntity).getSecurity().getOwner(); + + if (MekanismUtils.isOp((EntityPlayerMP) entityplayer) + || owner == null + || entityplayer.getCommandSenderName().equals(owner)) { + entityplayer.openGui( + Mekanism.instance, type.guiId, world, x, y, z + ); + } else { + SecurityUtils.displayNoAccess(entityplayer); + } + + return true; + } + + break; + default: + if (!entityplayer.isSneaking() && type.guiId != -1) { + if (SecurityUtils.canAccess(entityplayer, tileEntity)) { + entityplayer.openGui( + Mekanism.instance, type.guiId, world, x, y, z + ); + } else { + SecurityUtils.displayNoAccess(entityplayer); + } + + return true; + } + + break; + } + } + + return false; + } + + @Override + public TileEntity createTileEntity(World world, int metadata) { + if (MachineType.get(blockType, metadata) == null) { + return null; + } + + return MachineType.get(blockType, metadata).create(); + } + + @Override + public TileEntity createNewTileEntity(World world, int metadata) { + return null; + } + + @Override + public boolean renderAsNormalBlock() { + return false; + } + + @Override + public boolean isOpaqueCube() { + return false; + } + + @Override + public Item getItemDropped(int i, Random random, int j) { + return null; + } + + @Override + public int getRenderType() { + return Mekanism.proxy.CTM_RENDER_ID; + } + + @Override + public float getPlayerRelativeBlockHardness( + EntityPlayer player, World world, int x, int y, int z + ) { + TileEntity tile = world.getTileEntity(x, y, z); + + return SecurityUtils.canAccess(player, tile) + ? super.getPlayerRelativeBlockHardness(player, world, x, y, z) + : 0.0F; + } + + @Override + public float getExplosionResistance( + Entity entity, + World world, + int x, + int y, + int z, + double explosionX, + double explosionY, + double explosionZ + ) { + if (MachineType.get(blockType, world.getBlockMetadata(x, y, z)) + != MachineType.PERSONAL_CHEST) { + return blockResistance; + } else { + return -1; + } + } + + @Override + public boolean removedByPlayer( + World world, EntityPlayer player, int x, int y, int z, boolean willHarvest + ) { + if (!player.capabilities.isCreativeMode && !world.isRemote && willHarvest) { + TileEntityBasicBlock tileEntity + = (TileEntityBasicBlock) world.getTileEntity(x, y, z); + + float motion = 0.7F; + double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + + EntityItem entityItem = new EntityItem( + world, + x + motionX, + y + motionY, + z + motionZ, + getPickBlock(null, world, x, y, z, player) + ); + + world.spawnEntityInWorld(entityItem); + } + + return world.setBlockToAir(x, y, z); + } + + @Override + public boolean hasComparatorInputOverride() { + return true; + } + + @Override + public int getComparatorInputOverride(World world, int x, int y, int z, int par5) { + TileEntity tileEntity = world.getTileEntity(x, y, z); + + if (tileEntity instanceof TileEntityFluidTank) { + return ((TileEntityFluidTank) tileEntity).getRedstoneLevel(); + } + + if (tileEntity instanceof TileEntityLaserAmplifier) { + TileEntityLaserAmplifier amplifier = (TileEntityLaserAmplifier) tileEntity; + + if (amplifier.outputMode + == TileEntityLaserAmplifier.RedstoneOutput.ENERGY_CONTENTS) { + return amplifier.getRedstoneLevel(); + } else { + return isProvidingWeakPower(world, x, y, z, par5); + } + } + + return 0; + } + + private boolean manageInventory(EntityPlayer player, TileEntityFluidTank tileEntity) { + ItemStack itemStack = player.getCurrentEquippedItem(); + + if (itemStack != null) { + if (FluidContainerRegistry.isEmptyContainer(itemStack)) { + if (tileEntity.fluidTank.getFluid() != null + && tileEntity.fluidTank.getFluid().amount + >= FluidContainerRegistry.BUCKET_VOLUME) { + ItemStack filled = FluidContainerRegistry.fillFluidContainer( + tileEntity.fluidTank.getFluid(), itemStack + ); + + if (filled != null) { + if (player.capabilities.isCreativeMode) { + tileEntity.fluidTank.drain( + FluidContainerRegistry.getFluidForFilledItem(filled) + .amount, + true + ); + + return true; + } + + if (itemStack.stackSize > 1) { + if (player.inventory.addItemStackToInventory(filled)) { + itemStack.stackSize--; + + tileEntity.fluidTank.drain( + FluidContainerRegistry.getFluidForFilledItem(filled) + .amount, + true + ); + } + } else if (itemStack.stackSize == 1) { + player.setCurrentItemOrArmor(0, filled); + + tileEntity.fluidTank.drain( + FluidContainerRegistry.getFluidForFilledItem(filled) + .amount, + true + ); + + return true; + } + } + } + } else if (FluidContainerRegistry.isFilledContainer(itemStack)) { + FluidStack itemFluid + = FluidContainerRegistry.getFluidForFilledItem(itemStack); + int needed = tileEntity.getCurrentNeeded(); + + if ((tileEntity.fluidTank.getFluid() == null + && itemFluid.amount <= tileEntity.fluidTank.getCapacity()) + || itemFluid.amount <= needed) { + if (tileEntity.fluidTank.getFluid() != null + && !tileEntity.fluidTank.getFluid().isFluidEqual(itemFluid)) { + return false; + } + + boolean filled = false; + + if (player.capabilities.isCreativeMode) { + filled = true; + } else { + ItemStack containerItem + = itemStack.getItem().getContainerItem(itemStack); + + if (containerItem != null) { + if (itemStack.stackSize == 1) { + player.setCurrentItemOrArmor(0, containerItem); + filled = true; + } else { + if (player.inventory.addItemStackToInventory(containerItem + )) { + itemStack.stackSize--; + + filled = true; + } + } + } else { + itemStack.stackSize--; + + if (itemStack.stackSize == 0) { + player.setCurrentItemOrArmor(0, null); + } + + filled = true; + } + } + + if (filled) { + int toFill = Math.min( + tileEntity.fluidTank.getCapacity() + - tileEntity.fluidTank.getFluidAmount(), + itemFluid.amount + ); + + tileEntity.fluidTank.fill(itemFluid, true); + + if (itemFluid.amount - toFill > 0) { + tileEntity.pushUp( + PipeUtils.copy(itemFluid, itemFluid.amount - toFill), true + ); + } + + return true; + } + } + } + } + + return false; + } + + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + if (!world.isRemote) { + TileEntity tileEntity = world.getTileEntity(x, y, z); + + if (tileEntity instanceof TileEntityBasicBlock) { + ((TileEntityBasicBlock) tileEntity).onNeighborChange(block); + } + + if (tileEntity instanceof TileEntityLogisticalSorter) { + TileEntityLogisticalSorter sorter + = (TileEntityLogisticalSorter) tileEntity; + + if (!sorter.hasInventory()) { + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + TileEntity tile = Coord4D.get(tileEntity) + .getFromSide(dir) + .getTileEntity(world); + + if (tile instanceof IInventory) { + sorter.setFacing((short) dir.getOpposite().ordinal()); + return; + } + } + } + } + } + } + + @Override + public ItemStack getPickBlock( + MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player + ) { + TileEntityBasicBlock tileEntity + = (TileEntityBasicBlock) world.getTileEntity(x, y, z); + ItemStack itemStack = new ItemStack(this, 1, world.getBlockMetadata(x, y, z)); + + if (itemStack.stackTagCompound == null) { + itemStack.setTagCompound(new NBTTagCompound()); + } + + if (tileEntity instanceof TileEntityFluidTank) { + ITierItem tierItem = (ITierItem) itemStack.getItem(); + tierItem.setBaseTier( + itemStack, ((TileEntityFluidTank) tileEntity).tier.getBaseTier() + ); + } + + if (tileEntity instanceof ISecurityTile) { + ISecurityItem securityItem = (ISecurityItem) itemStack.getItem(); + + if (securityItem.hasSecurity(itemStack)) { + securityItem.setOwner( + itemStack, ((ISecurityTile) tileEntity).getSecurity().getOwner() + ); + securityItem.setSecurity( + itemStack, ((ISecurityTile) tileEntity).getSecurity().getMode() + ); + } + } + + if (tileEntity instanceof IUpgradeTile) { + ((IUpgradeTile) tileEntity).getComponent().write(itemStack.stackTagCompound); + } + + if (tileEntity instanceof ISideConfiguration) { + ISideConfiguration config = (ISideConfiguration) tileEntity; + + config.getConfig().write(itemStack.stackTagCompound); + } + + if (tileEntity instanceof ISustainedData) { + ((ISustainedData) tileEntity).writeSustainedData(itemStack); + } + + if (tileEntity instanceof IRedstoneControl) { + IRedstoneControl control = (IRedstoneControl) tileEntity; + itemStack.stackTagCompound.setInteger( + "controlType", control.getControlType().ordinal() + ); + } + + if (tileEntity instanceof IStrictEnergyStorage) { + IEnergizedItem energizedItem = (IEnergizedItem) itemStack.getItem(); + energizedItem.setEnergy( + itemStack, ((IStrictEnergyStorage) tileEntity).getEnergy() + ); + } + + if (tileEntity instanceof TileEntityContainerBlock + && ((TileEntityContainerBlock) tileEntity).inventory.length > 0) { + ISustainedInventory inventory = (ISustainedInventory) itemStack.getItem(); + inventory.setInventory( + ((ISustainedInventory) tileEntity).getInventory(), itemStack + ); + } + + if (((ISustainedTank) itemStack.getItem()).hasTank(itemStack)) { + if (tileEntity instanceof ISustainedTank) { + if (((ISustainedTank) tileEntity).getFluidStack() != null) { + ((ISustainedTank) itemStack.getItem()) + .setFluidStack( + ((ISustainedTank) tileEntity).getFluidStack(), itemStack + ); + } + } + } + + if (tileEntity instanceof TileEntityFactory) { + IFactory factoryItem = (IFactory) itemStack.getItem(); + factoryItem.setRecipeType( + ((TileEntityFactory) tileEntity).recipeType.ordinal(), itemStack + ); + } + + return itemStack; + } + + @Override + public void onBlockAdded(World world, int x, int y, int z) { + TileEntity tileEntity = world.getTileEntity(x, y, z); + + if (!world.isRemote) { + if (tileEntity instanceof TileEntityBasicBlock) { + ((TileEntityBasicBlock) tileEntity).onAdded(); + } + } + } + + @Override + public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) { + MachineType type = MachineType.get(blockType, world.getBlockMetadata(x, y, z)); + + switch (type) { + case LASER_AMPLIFIER: + return true; + default: + return false; + } + } + + public ItemStack + dismantleBlock(World world, int x, int y, int z, boolean returnBlock) { + ItemStack itemStack = getPickBlock(null, world, x, y, z, null); + + world.setBlockToAir(x, y, z); + + if (!returnBlock) { + float motion = 0.7F; + double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + + EntityItem entityItem + = new EntityItem(world, x + motionX, y + motionY, z + motionZ, itemStack); + + world.spawnEntityInWorld(entityItem); + } + + return itemStack; + } + + @Override + public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { + MachineType type = MachineType.get(blockType, world.getBlockMetadata(x, y, z)); + + if (type == null) { + return; + } + + switch (type) { + case CHARGEPAD: + setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.06F, 1.0F); + break; + case FLUID_TANK: + setBlockBounds(0.125F, 0.0F, 0.125F, 0.875F, 1.0F, 0.875F); + break; + default: + setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + break; + } + } + + @Override + public AxisAlignedBB + getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { + setBlockBoundsBasedOnState(world, x, y, z); + + if (world.getTileEntity(x, y, z) instanceof TileEntityChargepad) { + return null; + } + + return super.getCollisionBoundingBoxFromPool(world, x, y, z); + } + + @Override + public boolean + isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + MachineType type = MachineType.get(blockType, world.getBlockMetadata(x, y, z)); + + switch (type) { + case CHARGEPAD: + case PERSONAL_CHEST: + return false; + case FLUID_TANK: + return side == ForgeDirection.UP || side == ForgeDirection.DOWN; + default: + return true; + } + } + + public static enum MachineBlock { + MACHINE_BLOCK_1, + MACHINE_BLOCK_2, + MACHINE_BLOCK_3; + + public Block getBlock() { + switch (this) { + case MACHINE_BLOCK_1: + return MekanismBlocks.MachineBlock; + case MACHINE_BLOCK_2: + return MekanismBlocks.MachineBlock2; + case MACHINE_BLOCK_3: + return MekanismBlocks.MachineBlock3; + default: + return null; + } + } + } + + public static enum MachineType { + ENRICHMENT_CHAMBER( + MachineBlock.MACHINE_BLOCK_1, + 0, + "EnrichmentChamber", + 3, + TileEntityEnrichmentChamber.class, + true, + false, + true + ), + OSMIUM_COMPRESSOR( + MachineBlock.MACHINE_BLOCK_1, + 1, + "OsmiumCompressor", + 4, + TileEntityOsmiumCompressor.class, + true, + false, + true + ), + COMBINER( + MachineBlock.MACHINE_BLOCK_1, + 2, + "Combiner", + 5, + TileEntityCombiner.class, + true, + false, + true + ), + CRUSHER( + MachineBlock.MACHINE_BLOCK_1, + 3, + "Crusher", + 6, + TileEntityCrusher.class, + true, + false, + true + ), + DIGITAL_MINER( + MachineBlock.MACHINE_BLOCK_1, + 4, + "DigitalMiner", + 2, + TileEntityDigitalMiner.class, + true, + true, + true + ), + BASIC_FACTORY( + MachineBlock.MACHINE_BLOCK_1, + 5, + "Factory", + 11, + TileEntityFactory.class, + true, + false, + true + ), + ADVANCED_FACTORY( + MachineBlock.MACHINE_BLOCK_1, + 6, + "Factory", + 11, + TileEntityAdvancedFactory.class, + true, + false, + true + ), + ELITE_FACTORY( + MachineBlock.MACHINE_BLOCK_1, + 7, + "Factory", + 11, + TileEntityEliteFactory.class, + true, + false, + true + ), + METALLURGIC_INFUSER( + MachineBlock.MACHINE_BLOCK_1, + 8, + "MetallurgicInfuser", + 12, + TileEntityMetallurgicInfuser.class, + true, + true, + true + ), + PURIFICATION_CHAMBER( + MachineBlock.MACHINE_BLOCK_1, + 9, + "PurificationChamber", + 15, + TileEntityPurificationChamber.class, + true, + false, + true + ), + ENERGIZED_SMELTER( + MachineBlock.MACHINE_BLOCK_1, + 10, + "EnergizedSmelter", + 16, + TileEntityEnergizedSmelter.class, + true, + false, + true + ), + TELEPORTER( + MachineBlock.MACHINE_BLOCK_1, + 11, + "Teleporter", + 13, + TileEntityTeleporter.class, + true, + false, + false + ), + ELECTRIC_PUMP( + MachineBlock.MACHINE_BLOCK_1, + 12, + "ElectricPump", + 17, + TileEntityElectricPump.class, + true, + true, + false + ), + PERSONAL_CHEST( + MachineBlock.MACHINE_BLOCK_1, + 13, + "PersonalChest", + -1, + TileEntityPersonalChest.class, + false, + true, + false + ), + CHARGEPAD( + MachineBlock.MACHINE_BLOCK_1, + 14, + "Chargepad", + -1, + TileEntityChargepad.class, + true, + true, + false + ), + LOGISTICAL_SORTER( + MachineBlock.MACHINE_BLOCK_1, + 15, + "LogisticalSorter", + -1, + TileEntityLogisticalSorter.class, + false, + true, + false + ), + ROTARY_CONDENSENTRATOR( + MachineBlock.MACHINE_BLOCK_2, + 0, + "RotaryCondensentrator", + 7, + TileEntityRotaryCondensentrator.class, + true, + true, + false + ), + CHEMICAL_OXIDIZER( + MachineBlock.MACHINE_BLOCK_2, + 1, + "ChemicalOxidizer", + 29, + TileEntityChemicalOxidizer.class, + true, + true, + true + ), + CHEMICAL_INFUSER( + MachineBlock.MACHINE_BLOCK_2, + 2, + "ChemicalInfuser", + 30, + TileEntityChemicalInfuser.class, + true, + true, + false + ), + CHEMICAL_INJECTION_CHAMBER( + MachineBlock.MACHINE_BLOCK_2, + 3, + "ChemicalInjectionChamber", + 31, + TileEntityChemicalInjectionChamber.class, + true, + false, + true + ), + ELECTROLYTIC_SEPARATOR( + MachineBlock.MACHINE_BLOCK_2, + 4, + "ElectrolyticSeparator", + 32, + TileEntityElectrolyticSeparator.class, + true, + true, + false + ), + PRECISION_SAWMILL( + MachineBlock.MACHINE_BLOCK_2, + 5, + "PrecisionSawmill", + 34, + TileEntityPrecisionSawmill.class, + true, + false, + true + ), + CHEMICAL_DISSOLUTION_CHAMBER( + MachineBlock.MACHINE_BLOCK_2, + 6, + "ChemicalDissolutionChamber", + 35, + TileEntityChemicalDissolutionChamber.class, + true, + true, + true + ), + CHEMICAL_WASHER( + MachineBlock.MACHINE_BLOCK_2, + 7, + "ChemicalWasher", + 36, + TileEntityChemicalWasher.class, + true, + true, + false + ), + CHEMICAL_CRYSTALLIZER( + MachineBlock.MACHINE_BLOCK_2, + 8, + "ChemicalCrystallizer", + 37, + TileEntityChemicalCrystallizer.class, + true, + true, + true + ), + SEISMIC_VIBRATOR( + MachineBlock.MACHINE_BLOCK_2, + 9, + "SeismicVibrator", + 39, + TileEntitySeismicVibrator.class, + true, + true, + false + ), + PRESSURIZED_REACTION_CHAMBER( + MachineBlock.MACHINE_BLOCK_2, + 10, + "PressurizedReactionChamber", + 40, + TileEntityPRC.class, + true, + true, + false + ), + FLUID_TANK( + MachineBlock.MACHINE_BLOCK_2, + 11, + "FluidTank", + 41, + TileEntityFluidTank.class, + false, + true, + false + ), + FLUIDIC_PLENISHER( + MachineBlock.MACHINE_BLOCK_2, + 12, + "FluidicPlenisher", + 42, + TileEntityFluidicPlenisher.class, + true, + true, + false + ), + LASER( + MachineBlock.MACHINE_BLOCK_2, + 13, + "Laser", + -1, + TileEntityLaser.class, + true, + true, + false + ), + LASER_AMPLIFIER( + MachineBlock.MACHINE_BLOCK_2, + 14, + "LaserAmplifier", + 44, + TileEntityLaserAmplifier.class, + false, + true, + false + ), + LASER_TRACTOR_BEAM( + MachineBlock.MACHINE_BLOCK_2, + 15, + "LaserTractorBeam", + 45, + TileEntityLaserTractorBeam.class, + false, + true, + false + ), + QUANTUM_ENTANGLOPORTER( + MachineBlock.MACHINE_BLOCK_3, + 0, + "QuantumEntangloporter", + 46, + TileEntityQuantumEntangloporter.class, + true, + true, + false + ), + SOLAR_NEUTRON_ACTIVATOR( + MachineBlock.MACHINE_BLOCK_3, + 1, + "SolarNeutronActivator", + 47, + TileEntitySolarNeutronActivator.class, + false, + true, + false + ), + AMBIENT_ACCUMULATOR( + MachineBlock.MACHINE_BLOCK_3, + 2, + "AmbientAccumulator", + 48, + TileEntityAmbientAccumulator.class, + true, + false, + false + ), + OREDICTIONIFICATOR( + MachineBlock.MACHINE_BLOCK_3, + 3, + "Oredictionificator", + 52, + TileEntityOredictionificator.class, + false, + false, + false + ), + RESISTIVE_HEATER( + MachineBlock.MACHINE_BLOCK_3, + 4, + "ResistiveHeater", + 53, + TileEntityResistiveHeater.class, + true, + true, + false + ), + FORMULAIC_ASSEMBLICATOR( + MachineBlock.MACHINE_BLOCK_3, + 5, + "FormulaicAssemblicator", + 56, + TileEntityFormulaicAssemblicator.class, + true, + false, + true + ), + FUELWOOD_HEATER( + MachineBlock.MACHINE_BLOCK_3, + 6, + "FuelwoodHeater", + 58, + TileEntityFuelwoodHeater.class, + false, + false, + false + ), + THEORETICAL_ELEMENTIZER( + MachineBlock.MACHINE_BLOCK_3, + 7, + "TheoreticalElementizer", + 60, + TileEntityTheoreticalElementizer.class, + true, + true, + false + ); + + public MachineBlock typeBlock; + public int meta; + public String name; + public int guiId; + public double baseEnergy; + public Class tileEntityClass; + public boolean isElectric; + public boolean hasModel; + public boolean supportsUpgrades; + public Collection machineRecipes + = new HashSet(); + + private MachineType( + MachineBlock block, + int i, + String s, + int j, + Class tileClass, + boolean electric, + boolean model, + boolean upgrades + ) { + typeBlock = block; + meta = i; + name = s; + guiId = j; + tileEntityClass = tileClass; + isElectric = electric; + hasModel = model; + supportsUpgrades = upgrades; + } + + public boolean isEnabled() { + return machines.isEnabled(this.name); + } + + public void addRecipes(Collection recipes) { + machineRecipes.addAll(recipes); + } + + public void addRecipe(ShapedMekanismRecipe recipe) { + machineRecipes.add(recipe); + } + + public Collection getRecipes() { + return machineRecipes; + } + + public static List getValidMachines() { + List ret = new ArrayList(); + + for (MachineType type : MachineType.values()) { + if (type != AMBIENT_ACCUMULATOR) { + ret.add(type); + } + } + + return ret; + } + + public static MachineType get(Block block, int meta) { + if (block instanceof BlockMachine) { + return get(((BlockMachine) block).blockType, meta); + } + + return null; + } + + public static MachineType get(MachineBlock block, int meta) { + for (MachineType type : values()) { + if (type.meta == meta && type.typeBlock == block) { + return type; + } + } + + return null; + } + + public TileEntity create() { + try { + return tileEntityClass.newInstance(); + } catch (Exception e) { + Mekanism.logger.error("Unable to indirectly create tile entity."); + e.printStackTrace(); + return null; + } + } + + /** Used for getting the base energy storage. */ + public double getUsage() { + switch (this) { + case ENRICHMENT_CHAMBER: + return usage.enrichmentChamberUsage; + case OSMIUM_COMPRESSOR: + return usage.osmiumCompressorUsage; + case COMBINER: + return usage.combinerUsage; + case CRUSHER: + return usage.crusherUsage; + case DIGITAL_MINER: + return usage.digitalMinerUsage; + case BASIC_FACTORY: + return usage.factoryUsage * 3; + case ADVANCED_FACTORY: + return usage.factoryUsage * 5; + case ELITE_FACTORY: + return usage.factoryUsage * 7; + case METALLURGIC_INFUSER: + return usage.metallurgicInfuserUsage; + case PURIFICATION_CHAMBER: + return usage.purificationChamberUsage; + case ENERGIZED_SMELTER: + return usage.energizedSmelterUsage; + case TELEPORTER: + return 12500; + case ELECTRIC_PUMP: + return usage.electricPumpUsage; + case CHARGEPAD: + return 25; + case LOGISTICAL_SORTER: + return 0; + case ROTARY_CONDENSENTRATOR: + return usage.rotaryCondensentratorUsage; + case CHEMICAL_OXIDIZER: + return usage.oxidationChamberUsage; + case CHEMICAL_INFUSER: + return usage.chemicalInfuserUsage; + case CHEMICAL_INJECTION_CHAMBER: + return usage.chemicalInjectionChamberUsage; + case ELECTROLYTIC_SEPARATOR: + return general.FROM_H2 * 2; + case PRECISION_SAWMILL: + return usage.precisionSawmillUsage; + case CHEMICAL_DISSOLUTION_CHAMBER: + return usage.chemicalDissolutionChamberUsage; + case CHEMICAL_WASHER: + return usage.chemicalWasherUsage; + case CHEMICAL_CRYSTALLIZER: + return usage.chemicalCrystallizerUsage; + case SEISMIC_VIBRATOR: + return usage.seismicVibratorUsage; + case PRESSURIZED_REACTION_CHAMBER: + return usage.pressurizedReactionBaseUsage; + case FLUID_TANK: + return 0; + case FLUIDIC_PLENISHER: + return usage.fluidicPlenisherUsage; + case LASER: + return usage.laserUsage; + case LASER_AMPLIFIER: + return 0; + case LASER_TRACTOR_BEAM: + return 0; + case QUANTUM_ENTANGLOPORTER: + return 0; + case SOLAR_NEUTRON_ACTIVATOR: + return 0; + case AMBIENT_ACCUMULATOR: + return 0; + case RESISTIVE_HEATER: + return 100; + case FORMULAIC_ASSEMBLICATOR: + return usage.formulaicAssemblicatorUsage; + case THEORETICAL_ELEMENTIZER: + return 20000.0; + default: + return 0; + } + } + + public static void updateAllUsages() { + for (MachineType type : values()) { + type.updateUsage(); + } + } + + public void updateUsage() { + baseEnergy = 400 * getUsage(); + } + + public String getDescription() { + return LangUtils.localize("tooltip." + name); + } + + public ItemStack getStack() { + return new ItemStack(typeBlock.getBlock(), 1, meta); + } + + public static MachineType get(ItemStack stack) { + return get(Block.getBlockFromItem(stack.getItem()), stack.getItemDamage()); + } + } + + @Override + public void setRenderBounds(Block block, int metadata) {} + + @Override + public boolean doDefaultBoundSetting(int metadata) { + return false; + } + + @Override + public ForgeDirection[] getValidRotations(World world, int x, int y, int z) { + TileEntity tile = world.getTileEntity(x, y, z); + ForgeDirection[] valid = new ForgeDirection[6]; + + if (tile instanceof TileEntityBasicBlock) { + TileEntityBasicBlock basicTile = (TileEntityBasicBlock) tile; + + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + if (basicTile.canSetFacing(dir.ordinal())) { + valid[dir.ordinal()] = dir; + } + } + } + + return valid; + } + + @Override + public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis) { + TileEntity tile = world.getTileEntity(x, y, z); + + if (tile instanceof TileEntityBasicBlock) { + TileEntityBasicBlock basicTile = (TileEntityBasicBlock) tile; + + if (basicTile.canSetFacing(axis.ordinal())) { + basicTile.setFacing((short) axis.ordinal()); + return true; + } + } + + return false; + } + + @Override + public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) { + TileEntity tile = world.getTileEntity(x, y, z); + + if (tile instanceof TileEntityLaserAmplifier) { + return ((TileEntityLaserAmplifier) tile).emittingRedstone ? 15 : 0; + } + + return 0; + } + + @Override + public CTMData getCTMData(IBlockAccess world, int x, int y, int z, int meta) { + if (ctms[meta][1] != null && MekanismUtils.isActive(world, x, y, z)) { + return ctms[meta][1]; + } + + return ctms[meta][0]; + } + + @Override + public boolean shouldRenderBlock(IBlockAccess world, int x, int y, int z, int meta) { + return !MachineType.get(this, meta).hasModel; + } } diff --git a/src/main/java/mekanism/common/block/BlockObsidianTNT.java b/src/main/java/mekanism/common/block/BlockObsidianTNT.java index 4fc6002d0..7f89f2b4f 100644 --- a/src/main/java/mekanism/common/block/BlockObsidianTNT.java +++ b/src/main/java/mekanism/common/block/BlockObsidianTNT.java @@ -1,5 +1,7 @@ package mekanism.common.block; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.common.Mekanism; import mekanism.common.entity.EntityObsidianTNT; import mekanism.common.tile.TileEntityObsidianTNT; @@ -14,136 +16,126 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.Explosion; import net.minecraft.world.World; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class BlockObsidianTNT extends Block -{ - public IIcon[] icons = new IIcon[256]; +public class BlockObsidianTNT extends Block { + public IIcon[] icons = new IIcon[256]; - public BlockObsidianTNT() - { - super(Material.tnt); - setCreativeTab(Mekanism.tabMekanism); - } + public BlockObsidianTNT() { + super(Material.tnt); + setCreativeTab(Mekanism.tabMekanism); + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister register) {} - - @Override - public void breakBlock(World world, int x, int y, int z, Block block, int meta) - { - super.breakBlock(world, x, y, z, block, meta); - - world.removeTileEntity(x, y, z); - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister register) {} - @Override - public void onBlockAdded(World world, int x, int y, int z) - { - super.onBlockAdded(world, x, y, z); + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int meta) { + super.breakBlock(world, x, y, z, block, meta); - if(world.isBlockIndirectlyGettingPowered(x, y, z)) - { - explode(world, x, y, z); - world.setBlockToAir(x, y, z); - } - } + world.removeTileEntity(x, y, z); + } - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) - { - if(world.isBlockIndirectlyGettingPowered(x, y, z)) - { - explode(world, x, y, z); - world.setBlockToAir(x, y, z); - } - } + @Override + public void onBlockAdded(World world, int x, int y, int z) { + super.onBlockAdded(world, x, y, z); - @Override - public void onBlockDestroyedByExplosion(World world, int x, int y, int z, Explosion explosion) - { - if(!world.isRemote) - { - EntityObsidianTNT entity = new EntityObsidianTNT(world, x + 0.5F, y + 0.5F, z + 0.5F); - entity.fuse = world.rand.nextInt(entity.fuse / 4) + entity.fuse / 8; - world.spawnEntityInWorld(entity); - } - } + if (world.isBlockIndirectlyGettingPowered(x, y, z)) { + explode(world, x, y, z); + world.setBlockToAir(x, y, z); + } + } - public void explode(World world, int x, int y, int z) - { - if(!world.isRemote) - { - EntityObsidianTNT entity = new EntityObsidianTNT(world, x + 0.5F, y + 0.5F, z + 0.5F); - world.spawnEntityInWorld(entity); - world.playSoundAtEntity(entity, "game.tnt.primed", 1.0F, 1.0F); - } - } + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + if (world.isBlockIndirectlyGettingPowered(x, y, z)) { + explode(world, x, y, z); + world.setBlockToAir(x, y, z); + } + } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int i1, float f1, float f2, float f3) - { - if(entityplayer.getCurrentEquippedItem() != null && entityplayer.getCurrentEquippedItem().getItem() == Items.flint_and_steel) - { - explode(world, x, y, z); - world.setBlockToAir(x, y, z); - return true; - } - else { - return super.onBlockActivated(world, x, y, z, entityplayer, i1, f1, f2, f3); - } - } + @Override + public void + onBlockDestroyedByExplosion(World world, int x, int y, int z, Explosion explosion) { + if (!world.isRemote) { + EntityObsidianTNT entity + = new EntityObsidianTNT(world, x + 0.5F, y + 0.5F, z + 0.5F); + entity.fuse = world.rand.nextInt(entity.fuse / 4) + entity.fuse / 8; + world.spawnEntityInWorld(entity); + } + } - @Override - public boolean canDropFromExplosion(Explosion explosion) - { - return false; - } + public void explode(World world, int x, int y, int z) { + if (!world.isRemote) { + EntityObsidianTNT entity + = new EntityObsidianTNT(world, x + 0.5F, y + 0.5F, z + 0.5F); + world.spawnEntityInWorld(entity); + world.playSoundAtEntity(entity, "game.tnt.primed", 1.0F, 1.0F); + } + } - @Override - public boolean hasTileEntity(int metadata) - { - return true; - } + @Override + public boolean onBlockActivated( + World world, + int x, + int y, + int z, + EntityPlayer entityplayer, + int i1, + float f1, + float f2, + float f3 + ) { + if (entityplayer.getCurrentEquippedItem() != null + && entityplayer.getCurrentEquippedItem().getItem() == Items.flint_and_steel) { + explode(world, x, y, z); + world.setBlockToAir(x, y, z); + return true; + } else { + return super.onBlockActivated(world, x, y, z, entityplayer, i1, f1, f2, f3); + } + } - @Override - public TileEntity createTileEntity(World world, int metadata) - { - return new TileEntityObsidianTNT(); - } + @Override + public boolean canDropFromExplosion(Explosion explosion) { + return false; + } - @Override - public boolean renderAsNormalBlock() - { - return false; - } + @Override + public boolean hasTileEntity(int metadata) { + return true; + } - @Override - public boolean isOpaqueCube() - { - return false; - } + @Override + public TileEntity createTileEntity(World world, int metadata) { + return new TileEntityObsidianTNT(); + } - @Override - public int getRenderType() - { - return -1; - } + @Override + public boolean renderAsNormalBlock() { + return false; + } - @Override - public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) - { - if(entity instanceof EntityArrow && !world.isRemote) - { - EntityArrow entityarrow = (EntityArrow)entity; + @Override + public boolean isOpaqueCube() { + return false; + } - if(entityarrow.isBurning()) - { - explode(world, x, y, z); - world.setBlockToAir(x, y, z); - } - } - } + @Override + public int getRenderType() { + return -1; + } + + @Override + public void + onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { + if (entity instanceof EntityArrow && !world.isRemote) { + EntityArrow entityarrow = (EntityArrow) entity; + + if (entityarrow.isBurning()) { + explode(world, x, y, z); + world.setBlockToAir(x, y, z); + } + } + } } diff --git a/src/main/java/mekanism/common/block/BlockOre.java b/src/main/java/mekanism/common/block/BlockOre.java index d8679fa69..28d6250c4 100644 --- a/src/main/java/mekanism/common/block/BlockOre.java +++ b/src/main/java/mekanism/common/block/BlockOre.java @@ -2,6 +2,8 @@ package mekanism.common.block; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.common.Mekanism; import net.minecraft.block.Block; import net.minecraft.block.material.Material; @@ -10,8 +12,6 @@ import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; /** * Block class for handling multiple ore block IDs. @@ -21,46 +21,40 @@ import cpw.mods.fml.relauncher.SideOnly; * @author AidanBrady * */ -public class BlockOre extends Block -{ - public IIcon[] icons = new IIcon[256]; +public class BlockOre extends Block { + public IIcon[] icons = new IIcon[256]; - public BlockOre() - { - super(Material.rock); - setHardness(3F); - setResistance(5F); - setCreativeTab(Mekanism.tabMekanism); - } + public BlockOre() { + super(Material.rock); + setHardness(3F); + setResistance(5F); + setCreativeTab(Mekanism.tabMekanism); + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister register) - { - icons[0] = register.registerIcon("mekanism:OsmiumOre"); - icons[1] = register.registerIcon("mekanism:CopperOre"); - icons[2] = register.registerIcon("mekanism:TinOre"); - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister register) { + icons[0] = register.registerIcon("mekanism:OsmiumOre"); + icons[1] = register.registerIcon("mekanism:CopperOre"); + icons[2] = register.registerIcon("mekanism:TinOre"); + } - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int meta) - { - return icons[meta]; - } + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { + return icons[meta]; + } - @Override - public int damageDropped(int i) - { - return i; - } + @Override + public int damageDropped(int i) { + return i; + } - @Override - @SideOnly(Side.CLIENT) - public void getSubBlocks(Item item, CreativeTabs creativetabs, List list) - { - list.add(new ItemStack(item, 1, 0)); - list.add(new ItemStack(item, 1, 1)); - list.add(new ItemStack(item, 1, 2)); - } + @Override + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item item, CreativeTabs creativetabs, List list) { + list.add(new ItemStack(item, 1, 0)); + list.add(new ItemStack(item, 1, 1)); + list.add(new ItemStack(item, 1, 2)); + } } diff --git a/src/main/java/mekanism/common/block/BlockPlastic.java b/src/main/java/mekanism/common/block/BlockPlastic.java index 03c4d8a73..7e3435b14 100644 --- a/src/main/java/mekanism/common/block/BlockPlastic.java +++ b/src/main/java/mekanism/common/block/BlockPlastic.java @@ -2,6 +2,8 @@ package mekanism.common.block; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.EnumColor; import mekanism.common.Mekanism; import mekanism.common.MekanismBlocks; @@ -15,120 +17,95 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class BlockPlastic extends Block -{ - public BlockPlastic() - { - super(Material.wood); - setHardness(this == MekanismBlocks.ReinforcedPlasticBlock ? 50F : 5F); - setResistance(this == MekanismBlocks.ReinforcedPlasticBlock ? 2000F : 10F); - setCreativeTab(Mekanism.tabMekanism); - - if(this == MekanismBlocks.SlickPlasticBlock) - { - slipperiness = 0.98F; - } - } +public class BlockPlastic extends Block { + public BlockPlastic() { + super(Material.wood); + setHardness(this == MekanismBlocks.ReinforcedPlasticBlock ? 50F : 5F); + setResistance(this == MekanismBlocks.ReinforcedPlasticBlock ? 2000F : 10F); + setCreativeTab(Mekanism.tabMekanism); - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister register) - { - if(this == MekanismBlocks.PlasticBlock) - { - blockIcon = register.registerIcon("mekanism:PlasticBlock"); - } - else if(this == MekanismBlocks.SlickPlasticBlock) - { - blockIcon = register.registerIcon("mekanism:SlickPlasticBlock"); - } - else if(this == MekanismBlocks.GlowPlasticBlock) - { - blockIcon = register.registerIcon("mekanism:GlowPlasticBlock"); - } - else if(this == MekanismBlocks.ReinforcedPlasticBlock) - { - blockIcon = register.registerIcon("mekanism:ReinforcedPlasticBlock"); - } - else if(this == MekanismBlocks.RoadPlasticBlock) - { - blockIcon = register.registerIcon("mekanism:RoadPlasticBlock"); - } - } + if (this == MekanismBlocks.SlickPlasticBlock) { + slipperiness = 0.98F; + } + } - @Override - public void onEntityWalking(World world, int x, int y, int z, Entity e) - { - if(this == MekanismBlocks.RoadPlasticBlock) - { - double boost = 1.6; + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister register) { + if (this == MekanismBlocks.PlasticBlock) { + blockIcon = register.registerIcon("mekanism:PlasticBlock"); + } else if (this == MekanismBlocks.SlickPlasticBlock) { + blockIcon = register.registerIcon("mekanism:SlickPlasticBlock"); + } else if (this == MekanismBlocks.GlowPlasticBlock) { + blockIcon = register.registerIcon("mekanism:GlowPlasticBlock"); + } else if (this == MekanismBlocks.ReinforcedPlasticBlock) { + blockIcon = register.registerIcon("mekanism:ReinforcedPlasticBlock"); + } else if (this == MekanismBlocks.RoadPlasticBlock) { + blockIcon = register.registerIcon("mekanism:RoadPlasticBlock"); + } + } - double a = Math.atan2(e.motionX, e.motionZ); - e.motionX += Math.sin(a) * boost * slipperiness; - e.motionZ += Math.cos(a) * boost * slipperiness; - } - } + @Override + public void onEntityWalking(World world, int x, int y, int z, Entity e) { + if (this == MekanismBlocks.RoadPlasticBlock) { + double boost = 1.6; - @Override - public int damageDropped(int i) - { - return i; - } + double a = Math.atan2(e.motionX, e.motionZ); + e.motionX += Math.sin(a) * boost * slipperiness; + e.motionZ += Math.cos(a) * boost * slipperiness; + } + } - @Override - @SideOnly(Side.CLIENT) - public void getSubBlocks(Item item, CreativeTabs creativetabs, List list) - { - for(int i = 0; i < EnumColor.DYES.length; i++) - { - list.add(new ItemStack(item, 1, i)); - } - } + @Override + public int damageDropped(int i) { + return i; + } - @Override - public int colorMultiplier(IBlockAccess world, int x, int y, int z) - { - return getRenderColor(world.getBlockMetadata(x, y, z)); - } + @Override + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item item, CreativeTabs creativetabs, List list) { + for (int i = 0; i < EnumColor.DYES.length; i++) { + list.add(new ItemStack(item, 1, i)); + } + } - @Override - public int getRenderColor(int meta) - { - EnumColor colour = EnumColor.DYES[meta]; - return (int)(colour.getColor(0)*255) << 16 | (int)(colour.getColor(1)*255) << 8 | (int)(colour.getColor(2)*255); - } + @Override + public int colorMultiplier(IBlockAccess world, int x, int y, int z) { + return getRenderColor(world.getBlockMetadata(x, y, z)); + } - @Override - public int getLightValue() - { - if(this == MekanismBlocks.GlowPlasticBlock) - { - return 10; - } + @Override + public int getRenderColor(int meta) { + EnumColor colour = EnumColor.DYES[meta]; + return (int) (colour.getColor(0) * 255) << 16 + | (int) (colour.getColor(1) * 255) << 8 | (int) (colour.getColor(2) * 255); + } - return 0; - } + @Override + public int getLightValue() { + if (this == MekanismBlocks.GlowPlasticBlock) { + return 10; + } - @Override - public boolean recolourBlock(World world, int x, int y, int z, ForgeDirection side, int colour) - { - int meta = world.getBlockMetadata(x, y, z); - - if(meta != (15 - colour)) - { - world.setBlockMetadataWithNotify(x, y, z, 15-colour, 3); - return true; - } - - return false; - } + return 0; + } - @Override - public int getRenderType() - { - return Mekanism.proxy.PLASTIC_RENDER_ID; - } + @Override + public boolean + recolourBlock(World world, int x, int y, int z, ForgeDirection side, int colour) { + int meta = world.getBlockMetadata(x, y, z); + + if (meta != (15 - colour)) { + world.setBlockMetadataWithNotify(x, y, z, 15 - colour, 3); + return true; + } + + return false; + } + + @Override + public int getRenderType() { + return Mekanism.proxy.PLASTIC_RENDER_ID; + } } diff --git a/src/main/java/mekanism/common/block/BlockPlasticFence.java b/src/main/java/mekanism/common/block/BlockPlasticFence.java index bef99a790..4cdb4e7b2 100644 --- a/src/main/java/mekanism/common/block/BlockPlasticFence.java +++ b/src/main/java/mekanism/common/block/BlockPlasticFence.java @@ -2,6 +2,8 @@ package mekanism.common.block; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.EnumColor; import mekanism.common.Mekanism; import net.minecraft.block.BlockFence; @@ -12,57 +14,47 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class BlockPlasticFence extends BlockFence -{ - public BlockPlasticFence() - { - super("mekanism:PlasticFence", Material.clay); - setCreativeTab(Mekanism.tabMekanism); - } +public class BlockPlasticFence extends BlockFence { + public BlockPlasticFence() { + super("mekanism:PlasticFence", Material.clay); + setCreativeTab(Mekanism.tabMekanism); + } @Override @SideOnly(Side.CLIENT) - public void getSubBlocks(Item item, CreativeTabs creativetabs, List list) - { - for(int i = 0; i < EnumColor.DYES.length; i++) - { + public void getSubBlocks(Item item, CreativeTabs creativetabs, List list) { + for (int i = 0; i < EnumColor.DYES.length; i++) { list.add(new ItemStack(item, 1, i)); } } @Override - public int colorMultiplier(IBlockAccess world, int x, int y, int z) - { + public int colorMultiplier(IBlockAccess world, int x, int y, int z) { return getRenderColor(world.getBlockMetadata(x, y, z)); } @Override - public int getRenderColor(int meta) - { + public int getRenderColor(int meta) { EnumColor colour = EnumColor.DYES[meta]; - return (int)(colour.getColor(0)*255) << 16 | (int)(colour.getColor(1)*255) << 8 | (int)(colour.getColor(2)*255); - + return (int) (colour.getColor(0) * 255) << 16 + | (int) (colour.getColor(1) * 255) << 8 | (int) (colour.getColor(2) * 255); } - public boolean recolourBlock(World world, int x, int y, int z, ForgeDirection side, int colour) - { + public boolean + recolourBlock(World world, int x, int y, int z, ForgeDirection side, int colour) { int meta = world.getBlockMetadata(x, y, z); - - if(meta != (15 - colour)) - { - world.setBlockMetadataWithNotify(x, y, z, 15-colour, 3); + + if (meta != (15 - colour)) { + world.setBlockMetadataWithNotify(x, y, z, 15 - colour, 3); return true; } - + return false; } - @Override - public int damageDropped(int i) - { - return i; - } + @Override + public int damageDropped(int i) { + return i; + } } diff --git a/src/main/java/mekanism/common/block/BlockSalt.java b/src/main/java/mekanism/common/block/BlockSalt.java index d34b7251f..927eaa66a 100644 --- a/src/main/java/mekanism/common/block/BlockSalt.java +++ b/src/main/java/mekanism/common/block/BlockSalt.java @@ -2,41 +2,36 @@ package mekanism.common.block; import java.util.Random; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.common.Mekanism; import mekanism.common.MekanismItems; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.Item; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class BlockSalt extends Block -{ - public BlockSalt() - { +public class BlockSalt extends Block { + public BlockSalt() { super(Material.sand); setCreativeTab(Mekanism.tabMekanism); setHardness(0.5F); setStepSound(soundTypeSand); } - - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister register) - { - blockIcon = register.registerIcon("mekanism:SaltBlock"); - } @Override - public Item getItemDropped(int i, Random random, int j) - { + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister register) { + blockIcon = register.registerIcon("mekanism:SaltBlock"); + } + + @Override + public Item getItemDropped(int i, Random random, int j) { return MekanismItems.Salt; } @Override - public int quantityDropped(Random random) - { + public int quantityDropped(Random random) { return 4; } } diff --git a/src/main/java/mekanism/common/chunkloading/ChunkManager.java b/src/main/java/mekanism/common/chunkloading/ChunkManager.java index 7a182397c..8db2e3437 100644 --- a/src/main/java/mekanism/common/chunkloading/ChunkManager.java +++ b/src/main/java/mekanism/common/chunkloading/ChunkManager.java @@ -7,23 +7,19 @@ import net.minecraft.world.World; import net.minecraftforge.common.ForgeChunkManager.LoadingCallback; import net.minecraftforge.common.ForgeChunkManager.Ticket; -public class ChunkManager implements LoadingCallback -{ - @Override - public void ticketsLoaded(List tickets, World world) - { - for(Ticket ticket : tickets) - { - int x = ticket.getModData().getInteger("xCoord"); - int y = ticket.getModData().getInteger("yCoord"); - int z = ticket.getModData().getInteger("zCoord"); - - TileEntity tileEntity = world.getTileEntity(x, y, z); - - if(tileEntity instanceof IChunkLoader) - { - ((IChunkLoader)tileEntity).forceChunks(ticket); - } - } - } +public class ChunkManager implements LoadingCallback { + @Override + public void ticketsLoaded(List tickets, World world) { + for (Ticket ticket : tickets) { + int x = ticket.getModData().getInteger("xCoord"); + int y = ticket.getModData().getInteger("yCoord"); + int z = ticket.getModData().getInteger("zCoord"); + + TileEntity tileEntity = world.getTileEntity(x, y, z); + + if (tileEntity instanceof IChunkLoader) { + ((IChunkLoader) tileEntity).forceChunks(ticket); + } + } + } } diff --git a/src/main/java/mekanism/common/chunkloading/IChunkLoader.java b/src/main/java/mekanism/common/chunkloading/IChunkLoader.java index 9496b6e38..d0d117251 100644 --- a/src/main/java/mekanism/common/chunkloading/IChunkLoader.java +++ b/src/main/java/mekanism/common/chunkloading/IChunkLoader.java @@ -2,7 +2,6 @@ package mekanism.common.chunkloading; import net.minecraftforge.common.ForgeChunkManager.Ticket; -public interface IChunkLoader -{ - public void forceChunks(Ticket ticket); +public interface IChunkLoader { + public void forceChunks(Ticket ticket); } diff --git a/src/main/java/mekanism/common/content/assemblicator/RecipeFormula.java b/src/main/java/mekanism/common/content/assemblicator/RecipeFormula.java index 3713ca9d1..0db875c57 100644 --- a/src/main/java/mekanism/common/content/assemblicator/RecipeFormula.java +++ b/src/main/java/mekanism/common/content/assemblicator/RecipeFormula.java @@ -8,86 +8,71 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.world.World; -public class RecipeFormula -{ - private InventoryCrafting dummy = MekanismUtils.getDummyCraftingInv(); - - public ItemStack[] input = new ItemStack[9]; - - public IRecipe recipe = null; - - public RecipeFormula(World world, ItemStack[] inv) - { - this(world, inv, 0); - } - - public RecipeFormula(World world, ItemStack[] inv, int start) - { - for(int i = 0; i < 9; i++) - { - input[i] = StackUtils.size(inv[start+i], 1); - } - - resetToRecipe(); - - recipe = RecipeUtils.getRecipeFromGrid(dummy, world); - } - - private void resetToRecipe() - { - for(int i = 0; i < 9; i++) - { - dummy.setInventorySlotContents(i, input[i]); - } - } - - public boolean matches(World world, ItemStack[] newInput, int start) - { - for(int i = 0; i < 9; i++) - { - dummy.setInventorySlotContents(i, newInput[start+i]); - } - - return recipe.matches(dummy, world); - } - - public boolean isIngredientInPos(World world, ItemStack stack, int i) - { - resetToRecipe(); - dummy.setInventorySlotContents(i, stack); - - return recipe.matches(dummy, world); - } - - public boolean isIngredient(World world, ItemStack stack) - { - for(int i = 0; i < 9; i++) - { - dummy.setInventorySlotContents(i, stack); - - if(recipe.matches(dummy, world)) - { - return true; - } - - dummy.setInventorySlotContents(i, input[i]); - } - - return false; - } - - public boolean isValidFormula(World world) - { - return getRecipe(world) != null; - } - - public IRecipe getRecipe(World world) - { - return recipe; - } - - public boolean isFormulaEqual(World world, RecipeFormula formula) - { - return formula.getRecipe(world) == getRecipe(world); - } +public class RecipeFormula { + private InventoryCrafting dummy = MekanismUtils.getDummyCraftingInv(); + + public ItemStack[] input = new ItemStack[9]; + + public IRecipe recipe = null; + + public RecipeFormula(World world, ItemStack[] inv) { + this(world, inv, 0); + } + + public RecipeFormula(World world, ItemStack[] inv, int start) { + for (int i = 0; i < 9; i++) { + input[i] = StackUtils.size(inv[start + i], 1); + } + + resetToRecipe(); + + recipe = RecipeUtils.getRecipeFromGrid(dummy, world); + } + + private void resetToRecipe() { + for (int i = 0; i < 9; i++) { + dummy.setInventorySlotContents(i, input[i]); + } + } + + public boolean matches(World world, ItemStack[] newInput, int start) { + for (int i = 0; i < 9; i++) { + dummy.setInventorySlotContents(i, newInput[start + i]); + } + + return recipe.matches(dummy, world); + } + + public boolean isIngredientInPos(World world, ItemStack stack, int i) { + resetToRecipe(); + dummy.setInventorySlotContents(i, stack); + + return recipe.matches(dummy, world); + } + + public boolean isIngredient(World world, ItemStack stack) { + for (int i = 0; i < 9; i++) { + dummy.setInventorySlotContents(i, stack); + + if (recipe.matches(dummy, world)) { + return true; + } + + dummy.setInventorySlotContents(i, input[i]); + } + + return false; + } + + public boolean isValidFormula(World world) { + return getRecipe(world) != null; + } + + public IRecipe getRecipe(World world) { + return recipe; + } + + public boolean isFormulaEqual(World world, RecipeFormula formula) { + return formula.getRecipe(world) == getRecipe(world); + } } diff --git a/src/main/java/mekanism/common/content/boiler/BoilerCache.java b/src/main/java/mekanism/common/content/boiler/BoilerCache.java index d74696e7d..c3dc10e76 100644 --- a/src/main/java/mekanism/common/content/boiler/BoilerCache.java +++ b/src/main/java/mekanism/common/content/boiler/BoilerCache.java @@ -4,58 +4,51 @@ import mekanism.common.multiblock.MultiblockCache; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.FluidStack; -public class BoilerCache extends MultiblockCache -{ - public FluidStack water; - public FluidStack steam; - - public double temperature; +public class BoilerCache extends MultiblockCache { + public FluidStack water; + public FluidStack steam; - @Override - public void apply(SynchronizedBoilerData data) - { - data.waterStored = water; - data.steamStored = steam; - data.temperature = temperature; - } + public double temperature; - @Override - public void sync(SynchronizedBoilerData data) - { - water = data.waterStored; - steam = data.steamStored; - temperature = data.temperature; - } + @Override + public void apply(SynchronizedBoilerData data) { + data.waterStored = water; + data.steamStored = steam; + data.temperature = temperature; + } - @Override - public void load(NBTTagCompound nbtTags) - { - if(nbtTags.hasKey("cachedWater")) - { - water = FluidStack.loadFluidStackFromNBT(nbtTags.getCompoundTag("cachedWater")); - } - - if(nbtTags.hasKey("cachedSteam")) - { - steam = FluidStack.loadFluidStackFromNBT(nbtTags.getCompoundTag("cachedSteam")); - } - - temperature = nbtTags.getDouble("temperature"); - } + @Override + public void sync(SynchronizedBoilerData data) { + water = data.waterStored; + steam = data.steamStored; + temperature = data.temperature; + } - @Override - public void save(NBTTagCompound nbtTags) - { - if(water != null) - { - nbtTags.setTag("cachedWater", water.writeToNBT(new NBTTagCompound())); - } - - if(steam != null) - { - nbtTags.setTag("cachedSteam", steam.writeToNBT(new NBTTagCompound())); - } - - nbtTags.setDouble("temperature", temperature); - } + @Override + public void load(NBTTagCompound nbtTags) { + if (nbtTags.hasKey("cachedWater")) { + water + = FluidStack.loadFluidStackFromNBT(nbtTags.getCompoundTag("cachedWater")); + } + + if (nbtTags.hasKey("cachedSteam")) { + steam + = FluidStack.loadFluidStackFromNBT(nbtTags.getCompoundTag("cachedSteam")); + } + + temperature = nbtTags.getDouble("temperature"); + } + + @Override + public void save(NBTTagCompound nbtTags) { + if (water != null) { + nbtTags.setTag("cachedWater", water.writeToNBT(new NBTTagCompound())); + } + + if (steam != null) { + nbtTags.setTag("cachedSteam", steam.writeToNBT(new NBTTagCompound())); + } + + nbtTags.setDouble("temperature", temperature); + } } diff --git a/src/main/java/mekanism/common/content/boiler/BoilerSteamTank.java b/src/main/java/mekanism/common/content/boiler/BoilerSteamTank.java index 32086fd6f..c76d76b91 100644 --- a/src/main/java/mekanism/common/content/boiler/BoilerSteamTank.java +++ b/src/main/java/mekanism/common/content/boiler/BoilerSteamTank.java @@ -3,28 +3,25 @@ package mekanism.common.content.boiler; import mekanism.common.tile.TileEntityBoilerCasing; import net.minecraftforge.fluids.FluidStack; -public class BoilerSteamTank extends BoilerTank -{ - public BoilerSteamTank(TileEntityBoilerCasing tileEntity) - { - super(tileEntity); - } +public class BoilerSteamTank extends BoilerTank { + public BoilerSteamTank(TileEntityBoilerCasing tileEntity) { + super(tileEntity); + } - @Override - public FluidStack getFluid() - { - return steamBoiler.structure != null ? steamBoiler.structure.steamStored : null; - } + @Override + public FluidStack getFluid() { + return steamBoiler.structure != null ? steamBoiler.structure.steamStored : null; + } - @Override - public void setFluid(FluidStack stack) - { - steamBoiler.structure.steamStored = stack; - } - - @Override - public int getCapacity() - { - return steamBoiler.structure != null ? steamBoiler.structure.steamVolume*BoilerUpdateProtocol.STEAM_PER_TANK : 0; - } + @Override + public void setFluid(FluidStack stack) { + steamBoiler.structure.steamStored = stack; + } + + @Override + public int getCapacity() { + return steamBoiler.structure != null + ? steamBoiler.structure.steamVolume * BoilerUpdateProtocol.STEAM_PER_TANK + : 0; + } } diff --git a/src/main/java/mekanism/common/content/boiler/BoilerTank.java b/src/main/java/mekanism/common/content/boiler/BoilerTank.java index 284926bb7..abfd0ceb9 100644 --- a/src/main/java/mekanism/common/content/boiler/BoilerTank.java +++ b/src/main/java/mekanism/common/content/boiler/BoilerTank.java @@ -8,176 +8,142 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidTank; -public abstract class BoilerTank implements IFluidTank -{ - public TileEntityBoilerCasing steamBoiler; +public abstract class BoilerTank implements IFluidTank { + public TileEntityBoilerCasing steamBoiler; - public BoilerTank(TileEntityBoilerCasing tileEntity) - { - steamBoiler = tileEntity; - } + public BoilerTank(TileEntityBoilerCasing tileEntity) { + steamBoiler = tileEntity; + } - public abstract void setFluid(FluidStack stack); + public abstract void setFluid(FluidStack stack); - @Override - public int fill(FluidStack resource, boolean doFill) - { - if(steamBoiler.structure != null && !steamBoiler.getWorldObj().isRemote) - { - if(resource == null || resource.getFluidID() <= 0) - { - return 0; - } + @Override + public int fill(FluidStack resource, boolean doFill) { + if (steamBoiler.structure != null && !steamBoiler.getWorldObj().isRemote) { + if (resource == null || resource.getFluidID() <= 0) { + return 0; + } - if(getFluid() == null || getFluid().getFluidID() <= 0) - { - if(resource.amount <= getCapacity()) - { - if(doFill) - { - setFluid(resource.copy()); - } + if (getFluid() == null || getFluid().getFluidID() <= 0) { + if (resource.amount <= getCapacity()) { + if (doFill) { + setFluid(resource.copy()); + } - if(resource.amount > 0 && doFill) - { - MekanismUtils.saveChunk(steamBoiler); - updateValveData(); - } + if (resource.amount > 0 && doFill) { + MekanismUtils.saveChunk(steamBoiler); + updateValveData(); + } - return resource.amount; - } - else { - if(doFill) - { - setFluid(resource.copy()); - getFluid().amount = getCapacity(); - } + return resource.amount; + } else { + if (doFill) { + setFluid(resource.copy()); + getFluid().amount = getCapacity(); + } - if(getCapacity() > 0 && doFill) - { - MekanismUtils.saveChunk(steamBoiler); - updateValveData(); - } + if (getCapacity() > 0 && doFill) { + MekanismUtils.saveChunk(steamBoiler); + updateValveData(); + } - return getCapacity(); - } - } + return getCapacity(); + } + } - if(!getFluid().isFluidEqual(resource)) - { - return 0; - } + if (!getFluid().isFluidEqual(resource)) { + return 0; + } - int space = getCapacity() - getFluid().amount; + int space = getCapacity() - getFluid().amount; - if(resource.amount <= space) - { - if(doFill) - { - getFluid().amount += resource.amount; - } + if (resource.amount <= space) { + if (doFill) { + getFluid().amount += resource.amount; + } - if(resource.amount > 0 && doFill) - { - MekanismUtils.saveChunk(steamBoiler); - updateValveData(); - } + if (resource.amount > 0 && doFill) { + MekanismUtils.saveChunk(steamBoiler); + updateValveData(); + } - return resource.amount; - } - else { - if(doFill) - { - getFluid().amount = getCapacity(); - } + return resource.amount; + } else { + if (doFill) { + getFluid().amount = getCapacity(); + } - if(space > 0 && doFill) - { - MekanismUtils.saveChunk(steamBoiler); - updateValveData(); - } + if (space > 0 && doFill) { + MekanismUtils.saveChunk(steamBoiler); + updateValveData(); + } - return space; - } - } + return space; + } + } - return 0; - } + return 0; + } - public void updateValveData() - { - if(steamBoiler.structure != null) - { - for(ValveData data : steamBoiler.structure.valves) - { - if(data.location.equals(Coord4D.get(steamBoiler))) - { - data.onTransfer(); - } - } - } - } + public void updateValveData() { + if (steamBoiler.structure != null) { + for (ValveData data : steamBoiler.structure.valves) { + if (data.location.equals(Coord4D.get(steamBoiler))) { + data.onTransfer(); + } + } + } + } - @Override - public FluidStack drain(int maxDrain, boolean doDrain) - { - if(steamBoiler.structure != null && !steamBoiler.getWorldObj().isRemote) - { - if(getFluid() == null || getFluid().getFluidID() <= 0) - { - return null; - } + @Override + public FluidStack drain(int maxDrain, boolean doDrain) { + if (steamBoiler.structure != null && !steamBoiler.getWorldObj().isRemote) { + if (getFluid() == null || getFluid().getFluidID() <= 0) { + return null; + } - if(getFluid().amount <= 0) - { - return null; - } + if (getFluid().amount <= 0) { + return null; + } - int used = maxDrain; + int used = maxDrain; - if(getFluid().amount < used) - { - used = getFluid().amount; - } + if (getFluid().amount < used) { + used = getFluid().amount; + } - if(doDrain) - { - getFluid().amount -= used; - } + if (doDrain) { + getFluid().amount -= used; + } - FluidStack drained = new FluidStack(getFluid(), used); + FluidStack drained = new FluidStack(getFluid(), used); - if(getFluid().amount <= 0) - { - setFluid(null); - } + if (getFluid().amount <= 0) { + setFluid(null); + } - if(drained.amount > 0 && doDrain) - { - MekanismUtils.saveChunk(steamBoiler); - steamBoiler.sendPacketToRenderer(); - } + if (drained.amount > 0 && doDrain) { + MekanismUtils.saveChunk(steamBoiler); + steamBoiler.sendPacketToRenderer(); + } - return drained; - } + return drained; + } - return null; - } + return null; + } - @Override - public int getFluidAmount() - { - if(steamBoiler.structure != null) - { - return getFluid().amount; - } + @Override + public int getFluidAmount() { + if (steamBoiler.structure != null) { + return getFluid().amount; + } - return 0; - } + return 0; + } - @Override - public FluidTankInfo getInfo() - { - return new FluidTankInfo(this); - } + @Override + public FluidTankInfo getInfo() { + return new FluidTankInfo(this); + } } diff --git a/src/main/java/mekanism/common/content/boiler/BoilerUpdateProtocol.java b/src/main/java/mekanism/common/content/boiler/BoilerUpdateProtocol.java index f7f018faa..dfaaf053b 100644 --- a/src/main/java/mekanism/common/content/boiler/BoilerUpdateProtocol.java +++ b/src/main/java/mekanism/common/content/boiler/BoilerUpdateProtocol.java @@ -18,236 +18,272 @@ import mekanism.common.tile.TileEntitySuperheatingElement; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -public class BoilerUpdateProtocol extends UpdateProtocol -{ - public static final int WATER_PER_TANK = 16000; - public static final int STEAM_PER_TANK = 160000; +public class BoilerUpdateProtocol extends UpdateProtocol { + public static final int WATER_PER_TANK = 16000; + public static final int STEAM_PER_TANK = 160000; - public BoilerUpdateProtocol(TileEntityBoilerCasing tileEntity) - { - super(tileEntity); - } + public BoilerUpdateProtocol(TileEntityBoilerCasing tileEntity) { + super(tileEntity); + } - @Override - protected boolean isValidFrame(int x, int y, int z) - { - return BasicType.get(pointer.getWorldObj().getBlock(x, y, z), pointer.getWorldObj().getBlockMetadata(x, y, z)) == BasicType.BOILER_CASING; - } - - @Override - protected boolean isValidInnerNode(int x, int y, int z) - { - if(super.isValidInnerNode(x, y, z)) - { - return true; - } + @Override + protected boolean isValidFrame(int x, int y, int z) { + return BasicType.get( + pointer.getWorldObj().getBlock(x, y, z), + pointer.getWorldObj().getBlockMetadata(x, y, z) + ) + == BasicType.BOILER_CASING; + } - TileEntity tile = pointer.getWorldObj().getTileEntity(x, y, z); - - return tile instanceof TileEntityPressureDisperser || tile instanceof TileEntitySuperheatingElement; - } - - @Override - protected boolean canForm(SynchronizedBoilerData structure) - { - if(structure.volHeight >= 3) - { - Set dispersers = new HashSet(); - Set elements = new HashSet(); - - for(Coord4D coord : innerNodes) - { - TileEntity tile = coord.getTileEntity(pointer.getWorldObj()); - - if(tile instanceof TileEntityPressureDisperser) - { - dispersers.add(coord); - } - else if(tile instanceof TileEntitySuperheatingElement) - { - structure.internalLocations.add(coord); - elements.add(coord); - } - } - - int prevDispersers = dispersers.size(); - - //Ensure at least one disperser exists - if(dispersers.size() == 0) - { - return false; - } - - //Find a single disperser contained within this multiblock - final Coord4D initDisperser = dispersers.iterator().next(); - - //Ensure that a full horizontal plane of dispersers exist, surrounding the found disperser - for(int x = structure.renderLocation.xCoord+1; x < structure.renderLocation.xCoord+structure.volLength-1; x++) - { - for(int z = structure.renderLocation.zCoord+1; z < structure.renderLocation.zCoord+structure.volWidth-1; z++) - { - TileEntity tile = pointer.getWorldObj().getTileEntity(x, initDisperser.yCoord, z); - - if(!(tile instanceof TileEntityPressureDisperser)) - { - return false; - } - - dispersers.remove(new Coord4D(x, initDisperser.yCoord, z, pointer.getWorldObj().provider.dimensionId)); - } - } - - //If there are more dispersers than those on the plane found, the structure is invalid - if(dispersers.size() > 0) - { - return false; - } - - if(elements.size() > 0) - { - structure.superheatingElements = new NodeCounter(new NodeChecker() { - @Override - public boolean isValid(Coord4D coord) - { - return coord.getTileEntity(pointer.getWorldObj()) instanceof TileEntitySuperheatingElement; - } - }).calculate(elements.iterator().next()); - } - - if(elements.size() > structure.superheatingElements) - { - return false; - } - - Coord4D initAir = null; - int totalAir = 0; - - //Find the first available block in the structure for water storage (including casings) - for(int x = structure.renderLocation.xCoord; x < structure.renderLocation.xCoord+structure.volLength; x++) - { - for(int y = structure.renderLocation.yCoord; y < initDisperser.yCoord; y++) - { - for(int z = structure.renderLocation.zCoord; z < structure.renderLocation.zCoord+structure.volWidth; z++) - { - if(pointer.getWorldObj().isAirBlock(x, y, z) || isViableNode(x, y, z)) - { - initAir = new Coord4D(x, y, z, pointer.getWorldObj().provider.dimensionId); - totalAir++; - } - } - } - } - - //Some air must exist for the structure to be valid - if(initAir == null) - { - return false; - } - - //Gradle build requires these fields to be final - final Coord4D renderLocation = structure.renderLocation.clone(); - final int volLength = structure.volLength; - final int volWidth = structure.volWidth; - - structure.waterVolume = new NodeCounter(new NodeChecker() { - @Override - public final boolean isValid(Coord4D coord) - { - return coord.yCoord >= renderLocation.yCoord-1 && coord.yCoord < initDisperser.yCoord && - coord.xCoord >= renderLocation.xCoord && coord.xCoord < renderLocation.xCoord+volLength && - coord.zCoord >= renderLocation.zCoord && coord.zCoord < renderLocation.zCoord+volWidth && - (coord.isAirBlock(pointer.getWorldObj()) || isViableNode(coord.xCoord, coord.yCoord, coord.zCoord)); - } - }).calculate(initAir); - - //Make sure all air blocks are connected - if(totalAir > structure.waterVolume) - { - return false; - } - - int steamHeight = (structure.renderLocation.yCoord+structure.volHeight-2)-initDisperser.yCoord; - structure.steamVolume = structure.volWidth*structure.volLength*steamHeight; - - structure.upperRenderLocation = new Coord4D(structure.renderLocation.xCoord, initDisperser.yCoord+1, structure.renderLocation.zCoord, pointer.getWorldObj().provider.dimensionId); - - return true; - } - - return false; - } + @Override + protected boolean isValidInnerNode(int x, int y, int z) { + if (super.isValidInnerNode(x, y, z)) { + return true; + } - @Override - protected BoilerCache getNewCache() - { - return new BoilerCache(); - } + TileEntity tile = pointer.getWorldObj().getTileEntity(x, y, z); - @Override - protected SynchronizedBoilerData getNewStructure() - { - return new SynchronizedBoilerData(); - } + return tile instanceof TileEntityPressureDisperser + || tile instanceof TileEntitySuperheatingElement; + } - @Override - protected MultiblockManager getManager() - { - return Mekanism.boilerManager; - } + @Override + protected boolean canForm(SynchronizedBoilerData structure) { + if (structure.volHeight >= 3) { + Set dispersers = new HashSet(); + Set elements = new HashSet(); - @Override - protected void mergeCaches(List rejectedItems, MultiblockCache cache, MultiblockCache merge) - { - if(((BoilerCache)cache).water == null) - { - ((BoilerCache)cache).water = ((BoilerCache)merge).water; - } + for (Coord4D coord : innerNodes) { + TileEntity tile = coord.getTileEntity(pointer.getWorldObj()); + + if (tile instanceof TileEntityPressureDisperser) { + dispersers.add(coord); + } else if (tile instanceof TileEntitySuperheatingElement) { + structure.internalLocations.add(coord); + elements.add(coord); + } + } + + int prevDispersers = dispersers.size(); + + //Ensure at least one disperser exists + if (dispersers.size() == 0) { + return false; + } + + //Find a single disperser contained within this multiblock + final Coord4D initDisperser = dispersers.iterator().next(); + + //Ensure that a full horizontal plane of dispersers exist, surrounding the + //found disperser + for (int x = structure.renderLocation.xCoord + 1; + x < structure.renderLocation.xCoord + structure.volLength - 1; + x++) { + for (int z = structure.renderLocation.zCoord + 1; + z < structure.renderLocation.zCoord + structure.volWidth - 1; + z++) { + TileEntity tile + = pointer.getWorldObj().getTileEntity(x, initDisperser.yCoord, z); + + if (!(tile instanceof TileEntityPressureDisperser)) { + return false; + } + + dispersers.remove(new Coord4D( + x, + initDisperser.yCoord, + z, + pointer.getWorldObj().provider.dimensionId + )); + } + } + + //If there are more dispersers than those on the plane found, the structure is + //invalid + if (dispersers.size() > 0) { + return false; + } + + if (elements.size() > 0) { + structure.superheatingElements + = new NodeCounter(new NodeChecker() { + @Override + public boolean isValid(Coord4D coord) { + return coord.getTileEntity(pointer.getWorldObj()) + instanceof TileEntitySuperheatingElement; + } + }).calculate(elements.iterator().next()); + } + + if (elements.size() > structure.superheatingElements) { + return false; + } + + Coord4D initAir = null; + int totalAir = 0; + + //Find the first available block in the structure for water storage (including + //casings) + for (int x = structure.renderLocation.xCoord; + x < structure.renderLocation.xCoord + structure.volLength; + x++) { + for (int y = structure.renderLocation.yCoord; y < initDisperser.yCoord; + y++) { + for (int z = structure.renderLocation.zCoord; + z < structure.renderLocation.zCoord + structure.volWidth; + z++) { + if (pointer.getWorldObj().isAirBlock(x, y, z) + || isViableNode(x, y, z)) { + initAir = new Coord4D( + x, y, z, pointer.getWorldObj().provider.dimensionId + ); + totalAir++; + } + } + } + } + + //Some air must exist for the structure to be valid + if (initAir == null) { + return false; + } + + //Gradle build requires these fields to be final + final Coord4D renderLocation = structure.renderLocation.clone(); + final int volLength = structure.volLength; + final int volWidth = structure.volWidth; + + structure.waterVolume + = new NodeCounter(new NodeChecker() { + @Override + public final boolean isValid(Coord4D coord) { + return coord.yCoord >= renderLocation.yCoord - 1 + && coord.yCoord < initDisperser.yCoord + && coord.xCoord >= renderLocation.xCoord + && coord.xCoord < renderLocation.xCoord + volLength + && coord.zCoord >= renderLocation.zCoord + && coord.zCoord < renderLocation.zCoord + volWidth + && (coord.isAirBlock(pointer.getWorldObj()) + || isViableNode( + coord.xCoord, coord.yCoord, coord.zCoord + )); + } + }).calculate(initAir); + + //Make sure all air blocks are connected + if (totalAir > structure.waterVolume) { + return false; + } + + int steamHeight = (structure.renderLocation.yCoord + structure.volHeight - 2) + - initDisperser.yCoord; + structure.steamVolume + = structure.volWidth * structure.volLength * steamHeight; + + structure.upperRenderLocation = new Coord4D( + structure.renderLocation.xCoord, + initDisperser.yCoord + 1, + structure.renderLocation.zCoord, + pointer.getWorldObj().provider.dimensionId + ); + + return true; + } + + return false; + } + + @Override + protected BoilerCache getNewCache() { + return new BoilerCache(); + } + + @Override + protected SynchronizedBoilerData getNewStructure() { + return new SynchronizedBoilerData(); + } + + @Override + protected MultiblockManager getManager() { + return Mekanism.boilerManager; + } + + @Override + protected void mergeCaches( + List rejectedItems, + MultiblockCache cache, + MultiblockCache merge + ) { + if (((BoilerCache) cache).water == null) { + ((BoilerCache) cache).water = ((BoilerCache) merge).water; + } else if(((BoilerCache)merge).water != null && ((BoilerCache)cache).water.isFluidEqual(((BoilerCache)merge).water)) { - ((BoilerCache)cache).water.amount += ((BoilerCache)merge).water.amount; - } + ((BoilerCache) cache).water.amount += ((BoilerCache) merge).water.amount; + } - if(((BoilerCache)cache).steam == null) - { - ((BoilerCache)cache).steam = ((BoilerCache)merge).steam; - } + if (((BoilerCache) cache).steam == null) { + ((BoilerCache) cache).steam = ((BoilerCache) merge).steam; + } else if(((BoilerCache)merge).steam != null && ((BoilerCache)cache).steam.isFluidEqual(((BoilerCache)merge).steam)) { - ((BoilerCache)cache).steam.amount += ((BoilerCache)merge).steam.amount; - } - - ((BoilerCache)cache).temperature = Math.max(((BoilerCache)cache).temperature, ((BoilerCache)merge).temperature); - } + ((BoilerCache) cache).steam.amount += ((BoilerCache) merge).steam.amount; + } - @Override - protected void onFormed() - { - super.onFormed(); - - if((structureFound).waterStored != null) - { - (structureFound).waterStored.amount = Math.min((structureFound).waterStored.amount, structureFound.waterVolume*WATER_PER_TANK); - } - - if((structureFound).steamStored != null) - { - (structureFound).steamStored.amount = Math.min((structureFound).steamStored.amount, structureFound.steamVolume*STEAM_PER_TANK); - } - } + ((BoilerCache) cache).temperature = Math.max( + ((BoilerCache) cache).temperature, ((BoilerCache) merge).temperature + ); + } - @Override - protected void onStructureCreated(SynchronizedBoilerData structure, int origX, int origY, int origZ, int xmin, int xmax, int ymin, int ymax, int zmin, int zmax) - { - for(Coord4D obj : structure.locations) - { - if(obj.getTileEntity(pointer.getWorldObj()) instanceof TileEntityBoilerValve) - { - ValveData data = new ValveData(); - data.location = obj; - data.side = getSide(obj, origX+xmin, origX+xmax, origY+ymin, origY+ymax, origZ+zmin, origZ+zmax); + @Override + protected void onFormed() { + super.onFormed(); - structure.valves.add(data); - } - } - } + if ((structureFound).waterStored != null) { + (structureFound).waterStored.amount = Math.min( + (structureFound).waterStored.amount, + structureFound.waterVolume * WATER_PER_TANK + ); + } + + if ((structureFound).steamStored != null) { + (structureFound).steamStored.amount = Math.min( + (structureFound).steamStored.amount, + structureFound.steamVolume * STEAM_PER_TANK + ); + } + } + + @Override + protected void onStructureCreated( + SynchronizedBoilerData structure, + int origX, + int origY, + int origZ, + int xmin, + int xmax, + int ymin, + int ymax, + int zmin, + int zmax + ) { + for (Coord4D obj : structure.locations) { + if (obj.getTileEntity(pointer.getWorldObj()) + instanceof TileEntityBoilerValve) { + ValveData data = new ValveData(); + data.location = obj; + data.side = getSide( + obj, + origX + xmin, + origX + xmax, + origY + ymin, + origY + ymax, + origZ + zmin, + origZ + zmax + ); + + structure.valves.add(data); + } + } + } } diff --git a/src/main/java/mekanism/common/content/boiler/BoilerWaterTank.java b/src/main/java/mekanism/common/content/boiler/BoilerWaterTank.java index ec1aab932..81236c27b 100644 --- a/src/main/java/mekanism/common/content/boiler/BoilerWaterTank.java +++ b/src/main/java/mekanism/common/content/boiler/BoilerWaterTank.java @@ -3,28 +3,25 @@ package mekanism.common.content.boiler; import mekanism.common.tile.TileEntityBoilerCasing; import net.minecraftforge.fluids.FluidStack; -public class BoilerWaterTank extends BoilerTank -{ - public BoilerWaterTank(TileEntityBoilerCasing tileEntity) - { - super(tileEntity); - } +public class BoilerWaterTank extends BoilerTank { + public BoilerWaterTank(TileEntityBoilerCasing tileEntity) { + super(tileEntity); + } - @Override - public FluidStack getFluid() - { - return steamBoiler.structure != null ? steamBoiler.structure.waterStored : null; - } + @Override + public FluidStack getFluid() { + return steamBoiler.structure != null ? steamBoiler.structure.waterStored : null; + } - @Override - public void setFluid(FluidStack stack) - { - steamBoiler.structure.waterStored = stack; - } - - @Override - public int getCapacity() - { - return steamBoiler.structure != null ? steamBoiler.structure.waterVolume*BoilerUpdateProtocol.WATER_PER_TANK : 0; - } + @Override + public void setFluid(FluidStack stack) { + steamBoiler.structure.waterStored = stack; + } + + @Override + public int getCapacity() { + return steamBoiler.structure != null + ? steamBoiler.structure.waterVolume * BoilerUpdateProtocol.WATER_PER_TANK + : 0; + } } diff --git a/src/main/java/mekanism/common/content/boiler/SynchronizedBoilerData.java b/src/main/java/mekanism/common/content/boiler/SynchronizedBoilerData.java index a22be07e3..0622534e9 100644 --- a/src/main/java/mekanism/common/content/boiler/SynchronizedBoilerData.java +++ b/src/main/java/mekanism/common/content/boiler/SynchronizedBoilerData.java @@ -16,147 +16,138 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -public class SynchronizedBoilerData extends SynchronizedData implements IHeatTransfer -{ - public static Map clientHotMap = new HashMap(); - - public static double CASING_INSULATION_COEFFICIENT = 1; - public static double CASING_INVERSE_CONDUCTION_COEFFICIENT = 1; - public static double BASE_BOIL_TEMP = 100-(TemperatureUnit.AMBIENT.zeroOffset-TemperatureUnit.CELSIUS.zeroOffset); - - public FluidStack waterStored; - public FluidStack prevWater; +public class SynchronizedBoilerData + extends SynchronizedData implements IHeatTransfer { + public static Map clientHotMap = new HashMap(); - public FluidStack steamStored; - public FluidStack prevSteam; - - public double lastEnvironmentLoss; - public int lastBoilRate; - public int lastMaxBoil; - - public boolean clientHot; + public static double CASING_INSULATION_COEFFICIENT = 1; + public static double CASING_INVERSE_CONDUCTION_COEFFICIENT = 1; + public static double BASE_BOIL_TEMP + = 100 - (TemperatureUnit.AMBIENT.zeroOffset - TemperatureUnit.CELSIUS.zeroOffset); - public double temperature; + public FluidStack waterStored; + public FluidStack prevWater; - public double heatToAbsorb; + public FluidStack steamStored; + public FluidStack prevSteam; - public double heatCapacity = 1000; - - public int superheatingElements; - - public int waterVolume; - - public int steamVolume; + public double lastEnvironmentLoss; + public int lastBoilRate; + public int lastMaxBoil; - public ItemStack[] inventory = new ItemStack[2]; - - public Coord4D upperRenderLocation; + public boolean clientHot; - public Set valves = new HashSet(); - - /** - * @return how much heat energy is needed to convert one unit of water into steam - */ - public static double getHeatEnthalpy() - { - return general.maxEnergyPerSteam/general.energyPerHeat; - } - - public double getHeatAvailable() - { - double heatAvailable = (temperature-BASE_BOIL_TEMP)*locations.size(); - return Math.min(heatAvailable, superheatingElements*general.superheatingHeatTransfer); - } - - public boolean needsRenderUpdate() - { - if((waterStored == null && prevWater != null) || (waterStored != null && prevWater == null)) - { - return true; - } - - if(waterStored != null && prevWater != null) - { - if((waterStored.getFluid() != prevWater.getFluid()) || (waterStored.amount != prevWater.amount)) - { - return true; - } - } - - if((steamStored == null && prevSteam != null) || (steamStored != null && prevSteam == null)) - { - return true; - } - - if(steamStored != null && prevSteam != null) - { - if((steamStored.getFluid() != prevSteam.getFluid()) || (steamStored.amount != prevSteam.amount)) - { - return true; - } - } - - return false; - } + public double temperature; - @Override - public ItemStack[] getInventory() - { - return inventory; - } + public double heatToAbsorb; - @Override - public double getTemp() - { - return temperature; - } + public double heatCapacity = 1000; - @Override - public double getInverseConductionCoefficient() - { - return CASING_INVERSE_CONDUCTION_COEFFICIENT*locations.size(); - } + public int superheatingElements; - @Override - public double getInsulationCoefficient(ForgeDirection side) - { - return CASING_INSULATION_COEFFICIENT*locations.size(); - } + public int waterVolume; - @Override - public void transferHeatTo(double heat) - { - heatToAbsorb += heat; - } + public int steamVolume; - @Override - public double[] simulateHeat() - { - double invConduction = IHeatTransfer.AIR_INVERSE_COEFFICIENT + (CASING_INSULATION_COEFFICIENT + CASING_INVERSE_CONDUCTION_COEFFICIENT)*locations.size(); - double heatToTransfer = temperature / invConduction; - transferHeatTo(-heatToTransfer); - - return new double[] {0, heatToTransfer}; - } + public ItemStack[] inventory = new ItemStack[2]; - @Override - public double applyTemperatureChange() - { - temperature += heatToAbsorb / locations.size(); - heatToAbsorb = 0; - - return temperature; - } + public Coord4D upperRenderLocation; - @Override - public boolean canConnectHeat(ForgeDirection side) - { - return false; - } + public Set valves = new HashSet(); - @Override - public IHeatTransfer getAdjacent(ForgeDirection side) - { - return null; - } + /** + * @return how much heat energy is needed to convert one unit of water into steam + */ + public static double getHeatEnthalpy() { + return general.maxEnergyPerSteam / general.energyPerHeat; + } + + public double getHeatAvailable() { + double heatAvailable = (temperature - BASE_BOIL_TEMP) * locations.size(); + return Math.min( + heatAvailable, superheatingElements * general.superheatingHeatTransfer + ); + } + + public boolean needsRenderUpdate() { + if ((waterStored == null && prevWater != null) + || (waterStored != null && prevWater == null)) { + return true; + } + + if (waterStored != null && prevWater != null) { + if ((waterStored.getFluid() != prevWater.getFluid()) + || (waterStored.amount != prevWater.amount)) { + return true; + } + } + + if ((steamStored == null && prevSteam != null) + || (steamStored != null && prevSteam == null)) { + return true; + } + + if (steamStored != null && prevSteam != null) { + if ((steamStored.getFluid() != prevSteam.getFluid()) + || (steamStored.amount != prevSteam.amount)) { + return true; + } + } + + return false; + } + + @Override + public ItemStack[] getInventory() { + return inventory; + } + + @Override + public double getTemp() { + return temperature; + } + + @Override + public double getInverseConductionCoefficient() { + return CASING_INVERSE_CONDUCTION_COEFFICIENT * locations.size(); + } + + @Override + public double getInsulationCoefficient(ForgeDirection side) { + return CASING_INSULATION_COEFFICIENT * locations.size(); + } + + @Override + public void transferHeatTo(double heat) { + heatToAbsorb += heat; + } + + @Override + public double[] simulateHeat() { + double invConduction = IHeatTransfer.AIR_INVERSE_COEFFICIENT + + (CASING_INSULATION_COEFFICIENT + CASING_INVERSE_CONDUCTION_COEFFICIENT) + * locations.size(); + double heatToTransfer = temperature / invConduction; + transferHeatTo(-heatToTransfer); + + return new double[] { 0, heatToTransfer }; + } + + @Override + public double applyTemperatureChange() { + temperature += heatToAbsorb / locations.size(); + heatToAbsorb = 0; + + return temperature; + } + + @Override + public boolean canConnectHeat(ForgeDirection side) { + return false; + } + + @Override + public IHeatTransfer getAdjacent(ForgeDirection side) { + return null; + } } diff --git a/src/main/java/mekanism/common/content/entangloporter/InventoryFrequency.java b/src/main/java/mekanism/common/content/entangloporter/InventoryFrequency.java index 952e1744d..a3b068c6f 100644 --- a/src/main/java/mekanism/common/content/entangloporter/InventoryFrequency.java +++ b/src/main/java/mekanism/common/content/entangloporter/InventoryFrequency.java @@ -1,9 +1,8 @@ package mekanism.common.content.entangloporter; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import io.netty.buffer.ByteBuf; import mekanism.api.gas.GasStack; import mekanism.api.gas.GasTank; import mekanism.common.frequency.Frequency; @@ -13,145 +12,126 @@ import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; -public class InventoryFrequency extends Frequency -{ - public static final String ENTANGLOPORTER = "Entangloporter"; - - public static final double MAX_ENERGY = 1000000000; - - public double storedEnergy; - public FluidTank storedFluid; - public GasTank storedGas; - public ItemStack storedItem; - public double temperature; - - public InventoryFrequency(String n, String o) - { - super(n, o); - - storedFluid = new FluidTank(1000); - storedGas = new GasTank(1000); - } - - public InventoryFrequency(NBTTagCompound nbtTags) - { - super(nbtTags); - } - - public InventoryFrequency(ByteBuf dataStream) - { - super(dataStream); - } - - @Override - public void write(NBTTagCompound nbtTags) - { - super.write(nbtTags); - - nbtTags.setDouble("storedEnergy", storedEnergy); - - if(storedFluid.getFluid() != null) - { - nbtTags.setTag("storedFluid", storedFluid.writeToNBT(new NBTTagCompound())); - } - - if(storedGas.getGas() != null) - { - nbtTags.setTag("storedGas", storedGas.write(new NBTTagCompound())); - } - - if(storedItem != null) - { - nbtTags.setTag("storedItem", storedItem.writeToNBT(new NBTTagCompound())); - } - - nbtTags.setDouble("temperature", temperature); - } +public class InventoryFrequency extends Frequency { + public static final String ENTANGLOPORTER = "Entangloporter"; - @Override - protected void read(NBTTagCompound nbtTags) - { - super.read(nbtTags); - - storedFluid = new FluidTank(1000); - storedGas = new GasTank(1000); - - storedEnergy = nbtTags.getDouble("storedEnergy"); - - if(nbtTags.hasKey("storedFluid")) - { - storedFluid.readFromNBT(nbtTags.getCompoundTag("storedFluid")); - } - - if(nbtTags.hasKey("storedGas")) - { - storedGas.read(nbtTags.getCompoundTag("storedGas")); - } - - if(nbtTags.hasKey("storedItem")) - { - storedItem = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("storedItem")); - } - - temperature = nbtTags.getDouble("temperature"); - } + public static final double MAX_ENERGY = 1000000000; - @Override - public void write(ArrayList data) - { - super.write(data); - - data.add(storedEnergy); - - if(storedFluid.getFluid() != null) - { - data.add(true); - data.add(storedFluid.getFluid().getFluidID()); - data.add(storedFluid.getFluidAmount()); - } - else { - data.add(false); - } - - if(storedGas.getGas() != null) - { - data.add(true); - data.add(storedGas.getGasType().getID()); - data.add(storedGas.getStored()); - } - else { - data.add(false); - } - - data.add(temperature); - } + public double storedEnergy; + public FluidTank storedFluid; + public GasTank storedGas; + public ItemStack storedItem; + public double temperature; - @Override - protected void read(ByteBuf dataStream) - { - super.read(dataStream); - - storedFluid = new FluidTank(1000); - storedGas = new GasTank(1000); - - storedEnergy = dataStream.readDouble(); - - if(dataStream.readBoolean()) - { - storedFluid.setFluid(new FluidStack(FluidRegistry.getFluid(dataStream.readInt()), dataStream.readInt())); - } - else { - storedFluid.setFluid(null); - } - - if(dataStream.readBoolean()) - { - storedGas.setGas(new GasStack(dataStream.readInt(), dataStream.readInt())); - } - else { - storedGas.setGas(null); - } - - temperature = dataStream.readDouble(); - } + public InventoryFrequency(String n, String o) { + super(n, o); + + storedFluid = new FluidTank(1000); + storedGas = new GasTank(1000); + } + + public InventoryFrequency(NBTTagCompound nbtTags) { + super(nbtTags); + } + + public InventoryFrequency(ByteBuf dataStream) { + super(dataStream); + } + + @Override + public void write(NBTTagCompound nbtTags) { + super.write(nbtTags); + + nbtTags.setDouble("storedEnergy", storedEnergy); + + if (storedFluid.getFluid() != null) { + nbtTags.setTag("storedFluid", storedFluid.writeToNBT(new NBTTagCompound())); + } + + if (storedGas.getGas() != null) { + nbtTags.setTag("storedGas", storedGas.write(new NBTTagCompound())); + } + + if (storedItem != null) { + nbtTags.setTag("storedItem", storedItem.writeToNBT(new NBTTagCompound())); + } + + nbtTags.setDouble("temperature", temperature); + } + + @Override + protected void read(NBTTagCompound nbtTags) { + super.read(nbtTags); + + storedFluid = new FluidTank(1000); + storedGas = new GasTank(1000); + + storedEnergy = nbtTags.getDouble("storedEnergy"); + + if (nbtTags.hasKey("storedFluid")) { + storedFluid.readFromNBT(nbtTags.getCompoundTag("storedFluid")); + } + + if (nbtTags.hasKey("storedGas")) { + storedGas.read(nbtTags.getCompoundTag("storedGas")); + } + + if (nbtTags.hasKey("storedItem")) { + storedItem + = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("storedItem")); + } + + temperature = nbtTags.getDouble("temperature"); + } + + @Override + public void write(ArrayList data) { + super.write(data); + + data.add(storedEnergy); + + if (storedFluid.getFluid() != null) { + data.add(true); + data.add(storedFluid.getFluid().getFluidID()); + data.add(storedFluid.getFluidAmount()); + } else { + data.add(false); + } + + if (storedGas.getGas() != null) { + data.add(true); + data.add(storedGas.getGasType().getID()); + data.add(storedGas.getStored()); + } else { + data.add(false); + } + + data.add(temperature); + } + + @Override + protected void read(ByteBuf dataStream) { + super.read(dataStream); + + storedFluid = new FluidTank(1000); + storedGas = new GasTank(1000); + + storedEnergy = dataStream.readDouble(); + + if (dataStream.readBoolean()) { + storedFluid.setFluid(new FluidStack( + FluidRegistry.getFluid(dataStream.readInt()), dataStream.readInt() + )); + } else { + storedFluid.setFluid(null); + } + + if (dataStream.readBoolean()) { + storedGas.setGas(new GasStack(dataStream.readInt(), dataStream.readInt())); + } else { + storedGas.setGas(null); + } + + temperature = dataStream.readDouble(); + } } diff --git a/src/main/java/mekanism/common/content/matrix/MatrixCache.java b/src/main/java/mekanism/common/content/matrix/MatrixCache.java index 482a2a4ec..8ea493924 100644 --- a/src/main/java/mekanism/common/content/matrix/MatrixCache.java +++ b/src/main/java/mekanism/common/content/matrix/MatrixCache.java @@ -6,56 +6,48 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraftforge.common.util.Constants.NBT; -public class MatrixCache extends MultiblockCache -{ - public ItemStack[] inventory = new ItemStack[2]; - - @Override - public void apply(SynchronizedMatrixData data) - { - data.inventory = inventory; - } +public class MatrixCache extends MultiblockCache { + public ItemStack[] inventory = new ItemStack[2]; - @Override - public void sync(SynchronizedMatrixData data) - { - inventory = data.inventory; - } + @Override + public void apply(SynchronizedMatrixData data) { + data.inventory = inventory; + } - @Override - public void load(NBTTagCompound nbtTags) - { - NBTTagList tagList = nbtTags.getTagList("Items", NBT.TAG_COMPOUND); - inventory = new ItemStack[2]; + @Override + public void sync(SynchronizedMatrixData data) { + inventory = data.inventory; + } - for(int tagCount = 0; tagCount < tagList.tagCount(); tagCount++) - { - NBTTagCompound tagCompound = (NBTTagCompound)tagList.getCompoundTagAt(tagCount); - byte slotID = tagCompound.getByte("Slot"); + @Override + public void load(NBTTagCompound nbtTags) { + NBTTagList tagList = nbtTags.getTagList("Items", NBT.TAG_COMPOUND); + inventory = new ItemStack[2]; - if(slotID >= 0 && slotID < 2) - { - inventory[slotID] = ItemStack.loadItemStackFromNBT(tagCompound); - } - } - } + for (int tagCount = 0; tagCount < tagList.tagCount(); tagCount++) { + NBTTagCompound tagCompound + = (NBTTagCompound) tagList.getCompoundTagAt(tagCount); + byte slotID = tagCompound.getByte("Slot"); - @Override - public void save(NBTTagCompound nbtTags) - { - NBTTagList tagList = new NBTTagList(); + if (slotID >= 0 && slotID < 2) { + inventory[slotID] = ItemStack.loadItemStackFromNBT(tagCompound); + } + } + } - for(int slotCount = 0; slotCount < 2; slotCount++) - { - if(inventory[slotCount] != null) - { - NBTTagCompound tagCompound = new NBTTagCompound(); - tagCompound.setByte("Slot", (byte)slotCount); - inventory[slotCount].writeToNBT(tagCompound); - tagList.appendTag(tagCompound); - } - } + @Override + public void save(NBTTagCompound nbtTags) { + NBTTagList tagList = new NBTTagList(); - nbtTags.setTag("Items", tagList); - } + for (int slotCount = 0; slotCount < 2; slotCount++) { + if (inventory[slotCount] != null) { + NBTTagCompound tagCompound = new NBTTagCompound(); + tagCompound.setByte("Slot", (byte) slotCount); + inventory[slotCount].writeToNBT(tagCompound); + tagList.appendTag(tagCompound); + } + } + + nbtTags.setTag("Items", tagList); + } } diff --git a/src/main/java/mekanism/common/content/matrix/MatrixUpdateProtocol.java b/src/main/java/mekanism/common/content/matrix/MatrixUpdateProtocol.java index 9a401ae86..969d53b8b 100644 --- a/src/main/java/mekanism/common/content/matrix/MatrixUpdateProtocol.java +++ b/src/main/java/mekanism/common/content/matrix/MatrixUpdateProtocol.java @@ -15,82 +15,78 @@ import mekanism.common.tile.TileEntityInductionProvider; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -public class MatrixUpdateProtocol extends UpdateProtocol -{ - public MatrixUpdateProtocol(TileEntityInductionCasing tileEntity) - { - super(tileEntity); - } +public class MatrixUpdateProtocol extends UpdateProtocol { + public MatrixUpdateProtocol(TileEntityInductionCasing tileEntity) { + super(tileEntity); + } - @Override - protected boolean isValidFrame(int x, int y, int z) - { - return pointer.getWorldObj().getBlock(x, y, z) == MekanismBlocks.BasicBlock2 && pointer.getWorldObj().getBlockMetadata(x, y, z) == 1; - } - - @Override - public boolean isValidInnerNode(int x, int y, int z) - { - TileEntity tile = pointer.getWorldObj().getTileEntity(x, y, z); - - if(tile != null && (tile instanceof TileEntityInductionCell || tile instanceof TileEntityInductionProvider)) - { - return true; - } - - return isAir(x, y, z); - } + @Override + protected boolean isValidFrame(int x, int y, int z) { + return pointer.getWorldObj().getBlock(x, y, z) == MekanismBlocks.BasicBlock2 + && pointer.getWorldObj().getBlockMetadata(x, y, z) == 1; + } - @Override - protected MatrixCache getNewCache() - { - return new MatrixCache(); - } + @Override + public boolean isValidInnerNode(int x, int y, int z) { + TileEntity tile = pointer.getWorldObj().getTileEntity(x, y, z); - @Override - protected SynchronizedMatrixData getNewStructure() - { - return new SynchronizedMatrixData(); - } + if (tile != null + && (tile instanceof TileEntityInductionCell + || tile instanceof TileEntityInductionProvider)) { + return true; + } - @Override - protected MultiblockManager getManager() - { - return Mekanism.matrixManager; - } + return isAir(x, y, z); + } - @Override - protected void mergeCaches(List rejectedItems, MultiblockCache cache, MultiblockCache merge) - { - List rejects = StackUtils.getMergeRejects(((MatrixCache)cache).inventory, ((MatrixCache)merge).inventory); - - if(!rejects.isEmpty()) - { - rejectedItems.addAll(rejects); - } - - StackUtils.merge(((MatrixCache)cache).inventory, ((MatrixCache)merge).inventory); - } - - @Override - protected boolean canForm(SynchronizedMatrixData structure) - { - for(Coord4D coord : innerNodes) - { - TileEntity tile = coord.getTileEntity(pointer.getWorldObj()); - - if(tile instanceof TileEntityInductionCell) - { - structure.cells.add(coord); - structure.storageCap += ((TileEntityInductionCell)tile).tier.maxEnergy; - } - else if(tile instanceof TileEntityInductionProvider) - { - structure.providers.add(coord); - structure.transferCap += ((TileEntityInductionProvider)tile).tier.output; - } - } - - return true; - } + @Override + protected MatrixCache getNewCache() { + return new MatrixCache(); + } + + @Override + protected SynchronizedMatrixData getNewStructure() { + return new SynchronizedMatrixData(); + } + + @Override + protected MultiblockManager getManager() { + return Mekanism.matrixManager; + } + + @Override + protected void mergeCaches( + List rejectedItems, + MultiblockCache cache, + MultiblockCache merge + ) { + List rejects = StackUtils.getMergeRejects( + ((MatrixCache) cache).inventory, ((MatrixCache) merge).inventory + ); + + if (!rejects.isEmpty()) { + rejectedItems.addAll(rejects); + } + + StackUtils.merge( + ((MatrixCache) cache).inventory, ((MatrixCache) merge).inventory + ); + } + + @Override + protected boolean canForm(SynchronizedMatrixData structure) { + for (Coord4D coord : innerNodes) { + TileEntity tile = coord.getTileEntity(pointer.getWorldObj()); + + if (tile instanceof TileEntityInductionCell) { + structure.cells.add(coord); + structure.storageCap += ((TileEntityInductionCell) tile).tier.maxEnergy; + } else if (tile instanceof TileEntityInductionProvider) { + structure.providers.add(coord); + structure.transferCap += ((TileEntityInductionProvider) tile).tier.output; + } + } + + return true; + } } diff --git a/src/main/java/mekanism/common/content/matrix/SynchronizedMatrixData.java b/src/main/java/mekanism/common/content/matrix/SynchronizedMatrixData.java index 2398d2d66..2cfdb802d 100644 --- a/src/main/java/mekanism/common/content/matrix/SynchronizedMatrixData.java +++ b/src/main/java/mekanism/common/content/matrix/SynchronizedMatrixData.java @@ -10,63 +10,55 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -public class SynchronizedMatrixData extends SynchronizedData -{ - public ItemStack[] inventory = new ItemStack[2]; - - public Set cells = new HashSet(); - - public Set providers = new HashSet(); - - public double remainingInput; - public double lastInput; - - public double remainingOutput; - public double lastOutput; - - public double clientEnergy; - public double storageCap; - public double transferCap; - - @Override - public ItemStack[] getInventory() - { - return inventory; - } - - public double getEnergy(World world) - { - double ret = 0; - - for(Coord4D coord : cells) - { - TileEntity tile = coord.getTileEntity(world); - - if(tile instanceof TileEntityInductionCell) - { - ret += ((TileEntityInductionCell)tile).getEnergy(); - } - } - - return ret; - } - - public void setEnergy(World world, double energy) - { - for(Coord4D coord : cells) - { - TileEntity tile = coord.getTileEntity(world); - - if(tile instanceof TileEntityInductionCell) - { - TileEntityInductionCell cell = (TileEntityInductionCell)tile; - - cell.setEnergy(0); - - double toAdd = Math.min(cell.getMaxEnergy(), energy); - cell.setEnergy(toAdd); - energy -= toAdd; - } - } - } +public class SynchronizedMatrixData extends SynchronizedData { + public ItemStack[] inventory = new ItemStack[2]; + + public Set cells = new HashSet(); + + public Set providers = new HashSet(); + + public double remainingInput; + public double lastInput; + + public double remainingOutput; + public double lastOutput; + + public double clientEnergy; + public double storageCap; + public double transferCap; + + @Override + public ItemStack[] getInventory() { + return inventory; + } + + public double getEnergy(World world) { + double ret = 0; + + for (Coord4D coord : cells) { + TileEntity tile = coord.getTileEntity(world); + + if (tile instanceof TileEntityInductionCell) { + ret += ((TileEntityInductionCell) tile).getEnergy(); + } + } + + return ret; + } + + public void setEnergy(World world, double energy) { + for (Coord4D coord : cells) { + TileEntity tile = coord.getTileEntity(world); + + if (tile instanceof TileEntityInductionCell) { + TileEntityInductionCell cell = (TileEntityInductionCell) tile; + + cell.setEnergy(0); + + double toAdd = Math.min(cell.getMaxEnergy(), energy); + cell.setEnergy(toAdd); + energy -= toAdd; + } + } + } } \ No newline at end of file diff --git a/src/main/java/mekanism/common/content/miner/MItemStackFilter.java b/src/main/java/mekanism/common/content/miner/MItemStackFilter.java index d4ac726f0..3da2b6887 100644 --- a/src/main/java/mekanism/common/content/miner/MItemStackFilter.java +++ b/src/main/java/mekanism/common/content/miner/MItemStackFilter.java @@ -1,113 +1,105 @@ package mekanism.common.content.miner; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import io.netty.buffer.ByteBuf; import mekanism.common.util.MekanismUtils; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -public class MItemStackFilter extends MinerFilter -{ - public ItemStack itemType; - public boolean fuzzy; +public class MItemStackFilter extends MinerFilter { + public ItemStack itemType; + public boolean fuzzy; - public MItemStackFilter(ItemStack item) - { - itemType = item; - } + public MItemStackFilter(ItemStack item) { + itemType = item; + } - public MItemStackFilter() {} + public MItemStackFilter() {} - @Override - public boolean canFilter(ItemStack itemStack) - { - if(itemStack == null) - { - return false; - } + @Override + public boolean canFilter(ItemStack itemStack) { + if (itemStack == null) { + return false; + } - if(itemStack.getItem() == itemType.getItem() && fuzzy) - { - return true; - } + if (itemStack.getItem() == itemType.getItem() && fuzzy) { + return true; + } - return itemType.isItemEqual(itemStack); - } + return itemType.isItemEqual(itemStack); + } - @Override - public NBTTagCompound write(NBTTagCompound nbtTags) - { - super.write(nbtTags); - - nbtTags.setInteger("type", 0); - - nbtTags.setBoolean("fuzzy", fuzzy); - itemType.writeToNBT(nbtTags); + @Override + public NBTTagCompound write(NBTTagCompound nbtTags) { + super.write(nbtTags); - return nbtTags; - } + nbtTags.setInteger("type", 0); - @Override - protected void read(NBTTagCompound nbtTags) - { - super.read(nbtTags); - - fuzzy = nbtTags.getBoolean("fuzzy"); - itemType = ItemStack.loadItemStackFromNBT(nbtTags); - } + nbtTags.setBoolean("fuzzy", fuzzy); + itemType.writeToNBT(nbtTags); - @Override - public void write(ArrayList data) - { - data.add(0); - - super.write(data); + return nbtTags; + } - data.add(fuzzy); - - data.add(MekanismUtils.getID(itemType)); - data.add(itemType.stackSize); - data.add(itemType.getItemDamage()); - } + @Override + protected void read(NBTTagCompound nbtTags) { + super.read(nbtTags); - @Override - protected void read(ByteBuf dataStream) - { - super.read(dataStream); - - fuzzy = dataStream.readBoolean(); - - itemType = new ItemStack(Item.getItemById(dataStream.readInt()), dataStream.readInt(), dataStream.readInt()); - } + fuzzy = nbtTags.getBoolean("fuzzy"); + itemType = ItemStack.loadItemStackFromNBT(nbtTags); + } - @Override - public int hashCode() - { - int code = 1; - code = 31 * code + MekanismUtils.getID(itemType); - code = 31 * code + itemType.stackSize; - code = 31 * code + itemType.getItemDamage(); - return code; - } + @Override + public void write(ArrayList data) { + data.add(0); - @Override - public boolean equals(Object filter) - { - return super.equals(filter) && filter instanceof MItemStackFilter && ((MItemStackFilter)filter).itemType.isItemEqual(itemType); - } + super.write(data); - @Override - public MItemStackFilter clone() - { - MItemStackFilter filter = new MItemStackFilter(); - filter.replaceStack = replaceStack; - filter.requireStack = requireStack; - filter.fuzzy = fuzzy; - filter.itemType = itemType.copy(); + data.add(fuzzy); - return filter; - } + data.add(MekanismUtils.getID(itemType)); + data.add(itemType.stackSize); + data.add(itemType.getItemDamage()); + } + + @Override + protected void read(ByteBuf dataStream) { + super.read(dataStream); + + fuzzy = dataStream.readBoolean(); + + itemType = new ItemStack( + Item.getItemById(dataStream.readInt()), + dataStream.readInt(), + dataStream.readInt() + ); + } + + @Override + public int hashCode() { + int code = 1; + code = 31 * code + MekanismUtils.getID(itemType); + code = 31 * code + itemType.stackSize; + code = 31 * code + itemType.getItemDamage(); + return code; + } + + @Override + public boolean equals(Object filter) { + return super.equals(filter) && filter instanceof MItemStackFilter + && ((MItemStackFilter) filter).itemType.isItemEqual(itemType); + } + + @Override + public MItemStackFilter clone() { + MItemStackFilter filter = new MItemStackFilter(); + filter.replaceStack = replaceStack; + filter.requireStack = requireStack; + filter.fuzzy = fuzzy; + filter.itemType = itemType.copy(); + + return filter; + } } diff --git a/src/main/java/mekanism/common/content/miner/MMaterialFilter.java b/src/main/java/mekanism/common/content/miner/MMaterialFilter.java index a429c4c33..8b65573fd 100644 --- a/src/main/java/mekanism/common/content/miner/MMaterialFilter.java +++ b/src/main/java/mekanism/common/content/miner/MMaterialFilter.java @@ -1,9 +1,8 @@ package mekanism.common.content.miner; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import io.netty.buffer.ByteBuf; import mekanism.common.content.transporter.Finder.MaterialFinder; import mekanism.common.util.MekanismUtils; import net.minecraft.block.Block; @@ -13,89 +12,83 @@ import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -public class MMaterialFilter extends MinerFilter -{ - public ItemStack materialItem; - - public Material getMaterial() - { - return Block.getBlockFromItem(materialItem.getItem()).getMaterial(); - } +public class MMaterialFilter extends MinerFilter { + public ItemStack materialItem; - @Override - public boolean canFilter(ItemStack itemStack) - { - if(itemStack == null || !(itemStack.getItem() instanceof ItemBlock)) - { - return false; - } + public Material getMaterial() { + return Block.getBlockFromItem(materialItem.getItem()).getMaterial(); + } - return new MaterialFinder(getMaterial()).modifies(itemStack); - } + @Override + public boolean canFilter(ItemStack itemStack) { + if (itemStack == null || !(itemStack.getItem() instanceof ItemBlock)) { + return false; + } - @Override - public NBTTagCompound write(NBTTagCompound nbtTags) - { - super.write(nbtTags); - - nbtTags.setInteger("type", 2); - materialItem.writeToNBT(nbtTags); + return new MaterialFinder(getMaterial()).modifies(itemStack); + } - return nbtTags; - } + @Override + public NBTTagCompound write(NBTTagCompound nbtTags) { + super.write(nbtTags); - @Override - protected void read(NBTTagCompound nbtTags) - { - super.read(nbtTags); - - materialItem = ItemStack.loadItemStackFromNBT(nbtTags); - } + nbtTags.setInteger("type", 2); + materialItem.writeToNBT(nbtTags); - @Override - public void write(ArrayList data) - { - data.add(2); - - super.write(data); + return nbtTags; + } - data.add(MekanismUtils.getID(materialItem)); - data.add(materialItem.stackSize); - data.add(materialItem.getItemDamage()); - } + @Override + protected void read(NBTTagCompound nbtTags) { + super.read(nbtTags); - @Override - protected void read(ByteBuf dataStream) - { - super.read(dataStream); - - materialItem = new ItemStack(Item.getItemById(dataStream.readInt()), dataStream.readInt(), dataStream.readInt()); - } + materialItem = ItemStack.loadItemStackFromNBT(nbtTags); + } - @Override - public int hashCode() - { - int code = 1; - code = 31 * code + MekanismUtils.getID(materialItem); - code = 31 * code + materialItem.stackSize; - code = 31 * code + materialItem.getItemDamage(); - return code; - } + @Override + public void write(ArrayList data) { + data.add(2); - @Override - public boolean equals(Object filter) - { - return super.equals(filter) && filter instanceof MMaterialFilter && ((MMaterialFilter)filter).materialItem.isItemEqual(materialItem); - } + super.write(data); - @Override - public MMaterialFilter clone() - { - MMaterialFilter filter = new MMaterialFilter(); - filter.replaceStack = replaceStack; - filter.requireStack = requireStack; - filter.materialItem = materialItem; + data.add(MekanismUtils.getID(materialItem)); + data.add(materialItem.stackSize); + data.add(materialItem.getItemDamage()); + } - return filter; - } + @Override + protected void read(ByteBuf dataStream) { + super.read(dataStream); + + materialItem = new ItemStack( + Item.getItemById(dataStream.readInt()), + dataStream.readInt(), + dataStream.readInt() + ); + } + + @Override + public int hashCode() { + int code = 1; + code = 31 * code + MekanismUtils.getID(materialItem); + code = 31 * code + materialItem.stackSize; + code = 31 * code + materialItem.getItemDamage(); + return code; + } + + @Override + public boolean equals(Object filter) { + return super.equals(filter) && filter instanceof MMaterialFilter + && ((MMaterialFilter) filter).materialItem.isItemEqual(materialItem); + } + + @Override + public MMaterialFilter clone() { + MMaterialFilter filter = new MMaterialFilter(); + filter.replaceStack = replaceStack; + filter.requireStack = requireStack; + filter.materialItem = materialItem; + + return filter; + } } diff --git a/src/main/java/mekanism/common/content/miner/MModIDFilter.java b/src/main/java/mekanism/common/content/miner/MModIDFilter.java index c92ba95c5..5533e9f3a 100644 --- a/src/main/java/mekanism/common/content/miner/MModIDFilter.java +++ b/src/main/java/mekanism/common/content/miner/MModIDFilter.java @@ -1,89 +1,79 @@ package mekanism.common.content.miner; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import io.netty.buffer.ByteBuf; import mekanism.common.PacketHandler; import mekanism.common.content.transporter.Finder.ModIDFinder; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -public class MModIDFilter extends MinerFilter -{ - public String modID; +public class MModIDFilter extends MinerFilter { + public String modID; - @Override - public boolean canFilter(ItemStack itemStack) - { - if(itemStack == null || !(itemStack.getItem() instanceof ItemBlock)) - { - return false; - } + @Override + public boolean canFilter(ItemStack itemStack) { + if (itemStack == null || !(itemStack.getItem() instanceof ItemBlock)) { + return false; + } - return new ModIDFinder(modID).modifies(itemStack); - } + return new ModIDFinder(modID).modifies(itemStack); + } - @Override - public NBTTagCompound write(NBTTagCompound nbtTags) - { - super.write(nbtTags); - - nbtTags.setInteger("type", 3); - nbtTags.setString("modID", modID); + @Override + public NBTTagCompound write(NBTTagCompound nbtTags) { + super.write(nbtTags); - return nbtTags; - } + nbtTags.setInteger("type", 3); + nbtTags.setString("modID", modID); - @Override - protected void read(NBTTagCompound nbtTags) - { - super.read(nbtTags); - - modID = nbtTags.getString("modID"); - } + return nbtTags; + } - @Override - public void write(ArrayList data) - { - data.add(3); - - super.write(data); - - data.add(modID); - } + @Override + protected void read(NBTTagCompound nbtTags) { + super.read(nbtTags); - @Override - protected void read(ByteBuf dataStream) - { - super.read(dataStream); - - modID = PacketHandler.readString(dataStream); - } + modID = nbtTags.getString("modID"); + } - @Override - public int hashCode() - { - int code = 1; - code = 31 * code + modID.hashCode(); - return code; - } + @Override + public void write(ArrayList data) { + data.add(3); - @Override - public boolean equals(Object filter) - { - return super.equals(filter) && filter instanceof MModIDFilter && ((MModIDFilter)filter).modID.equals(modID); - } + super.write(data); - @Override - public MModIDFilter clone() - { - MModIDFilter filter = new MModIDFilter(); - filter.replaceStack = replaceStack; - filter.requireStack = requireStack; - filter.modID = modID; + data.add(modID); + } - return filter; - } + @Override + protected void read(ByteBuf dataStream) { + super.read(dataStream); + + modID = PacketHandler.readString(dataStream); + } + + @Override + public int hashCode() { + int code = 1; + code = 31 * code + modID.hashCode(); + return code; + } + + @Override + public boolean equals(Object filter) { + return super.equals(filter) && filter instanceof MModIDFilter + && ((MModIDFilter) filter).modID.equals(modID); + } + + @Override + public MModIDFilter clone() { + MModIDFilter filter = new MModIDFilter(); + filter.replaceStack = replaceStack; + filter.requireStack = requireStack; + filter.modID = modID; + + return filter; + } } diff --git a/src/main/java/mekanism/common/content/miner/MOreDictFilter.java b/src/main/java/mekanism/common/content/miner/MOreDictFilter.java index 6a71326d1..cda5b1356 100644 --- a/src/main/java/mekanism/common/content/miner/MOreDictFilter.java +++ b/src/main/java/mekanism/common/content/miner/MOreDictFilter.java @@ -1,89 +1,79 @@ package mekanism.common.content.miner; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import io.netty.buffer.ByteBuf; import mekanism.common.PacketHandler; import mekanism.common.content.transporter.Finder.OreDictFinder; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -public class MOreDictFilter extends MinerFilter -{ - public String oreDictName; +public class MOreDictFilter extends MinerFilter { + public String oreDictName; - @Override - public boolean canFilter(ItemStack itemStack) - { - if(itemStack == null || !(itemStack.getItem() instanceof ItemBlock)) - { - return false; - } + @Override + public boolean canFilter(ItemStack itemStack) { + if (itemStack == null || !(itemStack.getItem() instanceof ItemBlock)) { + return false; + } - return new OreDictFinder(oreDictName).modifies(itemStack); - } + return new OreDictFinder(oreDictName).modifies(itemStack); + } - @Override - public NBTTagCompound write(NBTTagCompound nbtTags) - { - super.write(nbtTags); - - nbtTags.setInteger("type", 1); - nbtTags.setString("oreDictName", oreDictName); + @Override + public NBTTagCompound write(NBTTagCompound nbtTags) { + super.write(nbtTags); - return nbtTags; - } + nbtTags.setInteger("type", 1); + nbtTags.setString("oreDictName", oreDictName); - @Override - protected void read(NBTTagCompound nbtTags) - { - super.read(nbtTags); - - oreDictName = nbtTags.getString("oreDictName"); - } + return nbtTags; + } - @Override - public void write(ArrayList data) - { - data.add(1); - - super.write(data); - - data.add(oreDictName); - } + @Override + protected void read(NBTTagCompound nbtTags) { + super.read(nbtTags); - @Override - protected void read(ByteBuf dataStream) - { - super.read(dataStream); - - oreDictName = PacketHandler.readString(dataStream); - } + oreDictName = nbtTags.getString("oreDictName"); + } - @Override - public int hashCode() - { - int code = 1; - code = 31 * code + oreDictName.hashCode(); - return code; - } + @Override + public void write(ArrayList data) { + data.add(1); - @Override - public boolean equals(Object filter) - { - return super.equals(filter) && filter instanceof MOreDictFilter && ((MOreDictFilter)filter).oreDictName.equals(oreDictName); - } + super.write(data); - @Override - public MOreDictFilter clone() - { - MOreDictFilter filter = new MOreDictFilter(); - filter.replaceStack = replaceStack; - filter.requireStack = requireStack; - filter.oreDictName = oreDictName; + data.add(oreDictName); + } - return filter; - } + @Override + protected void read(ByteBuf dataStream) { + super.read(dataStream); + + oreDictName = PacketHandler.readString(dataStream); + } + + @Override + public int hashCode() { + int code = 1; + code = 31 * code + oreDictName.hashCode(); + return code; + } + + @Override + public boolean equals(Object filter) { + return super.equals(filter) && filter instanceof MOreDictFilter + && ((MOreDictFilter) filter).oreDictName.equals(oreDictName); + } + + @Override + public MOreDictFilter clone() { + MOreDictFilter filter = new MOreDictFilter(); + filter.replaceStack = replaceStack; + filter.requireStack = requireStack; + filter.oreDictName = oreDictName; + + return filter; + } } diff --git a/src/main/java/mekanism/common/content/miner/MinerFilter.java b/src/main/java/mekanism/common/content/miner/MinerFilter.java index 560fced04..639c72215 100644 --- a/src/main/java/mekanism/common/content/miner/MinerFilter.java +++ b/src/main/java/mekanism/common/content/miner/MinerFilter.java @@ -1,131 +1,105 @@ package mekanism.common.content.miner; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import io.netty.buffer.ByteBuf; import mekanism.common.util.MekanismUtils; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -public abstract class MinerFilter -{ - public ItemStack replaceStack; - - public boolean requireStack; - - public abstract boolean canFilter(ItemStack itemStack); +public abstract class MinerFilter { + public ItemStack replaceStack; - public NBTTagCompound write(NBTTagCompound nbtTags) - { - nbtTags.setBoolean("requireStack", requireStack); + public boolean requireStack; - if(replaceStack != null) - { - nbtTags.setTag("replaceStack", replaceStack.writeToNBT(new NBTTagCompound())); - } - - return nbtTags; - } + public abstract boolean canFilter(ItemStack itemStack); - protected void read(NBTTagCompound nbtTags) - { - requireStack = nbtTags.getBoolean("requireStack"); - - if(nbtTags.hasKey("replaceStack")) - { - replaceStack = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("replaceStack")); - } - } + public NBTTagCompound write(NBTTagCompound nbtTags) { + nbtTags.setBoolean("requireStack", requireStack); - public void write(ArrayList data) - { - data.add(requireStack); - - if(replaceStack != null) - { - data.add(true); - data.add(MekanismUtils.getID(replaceStack)); - data.add(replaceStack.getItemDamage()); - } - else { - data.add(false); - } - } + if (replaceStack != null) { + nbtTags.setTag("replaceStack", replaceStack.writeToNBT(new NBTTagCompound())); + } - protected void read(ByteBuf dataStream) - { - requireStack = dataStream.readBoolean(); - - if(dataStream.readBoolean()) - { - replaceStack = new ItemStack(Block.getBlockById(dataStream.readInt()), 1, dataStream.readInt()); - } - else { - replaceStack = null; - } - } + return nbtTags; + } - public static MinerFilter readFromNBT(NBTTagCompound nbtTags) - { - int type = nbtTags.getInteger("type"); + protected void read(NBTTagCompound nbtTags) { + requireStack = nbtTags.getBoolean("requireStack"); - MinerFilter filter = null; + if (nbtTags.hasKey("replaceStack")) { + replaceStack + = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("replaceStack")); + } + } - if(type == 0) - { - filter = new MItemStackFilter(); - } - else if(type == 1) - { - filter = new MOreDictFilter(); - } - else if(type == 2) - { - filter = new MMaterialFilter(); - } - else if(type == 3) - { - filter = new MModIDFilter(); - } + public void write(ArrayList data) { + data.add(requireStack); - filter.read(nbtTags); + if (replaceStack != null) { + data.add(true); + data.add(MekanismUtils.getID(replaceStack)); + data.add(replaceStack.getItemDamage()); + } else { + data.add(false); + } + } - return filter; - } + protected void read(ByteBuf dataStream) { + requireStack = dataStream.readBoolean(); - public static MinerFilter readFromPacket(ByteBuf dataStream) - { - int type = dataStream.readInt(); + if (dataStream.readBoolean()) { + replaceStack = new ItemStack( + Block.getBlockById(dataStream.readInt()), 1, dataStream.readInt() + ); + } else { + replaceStack = null; + } + } - MinerFilter filter = null; + public static MinerFilter readFromNBT(NBTTagCompound nbtTags) { + int type = nbtTags.getInteger("type"); - if(type == 0) - { - filter = new MItemStackFilter(); - } - else if(type == 1) - { - filter = new MOreDictFilter(); - } - else if(type == 2) - { - filter = new MMaterialFilter(); - } - else if(type == 3) - { - filter = new MModIDFilter(); - } + MinerFilter filter = null; - filter.read(dataStream); + if (type == 0) { + filter = new MItemStackFilter(); + } else if (type == 1) { + filter = new MOreDictFilter(); + } else if (type == 2) { + filter = new MMaterialFilter(); + } else if (type == 3) { + filter = new MModIDFilter(); + } - return filter; - } + filter.read(nbtTags); - @Override - public boolean equals(Object filter) - { - return filter instanceof MinerFilter; - } + return filter; + } + + public static MinerFilter readFromPacket(ByteBuf dataStream) { + int type = dataStream.readInt(); + + MinerFilter filter = null; + + if (type == 0) { + filter = new MItemStackFilter(); + } else if (type == 1) { + filter = new MOreDictFilter(); + } else if (type == 2) { + filter = new MMaterialFilter(); + } else if (type == 3) { + filter = new MModIDFilter(); + } + + filter.read(dataStream); + + return filter; + } + + @Override + public boolean equals(Object filter) { + return filter instanceof MinerFilter; + } } diff --git a/src/main/java/mekanism/common/content/miner/ThreadMinerSearch.java b/src/main/java/mekanism/common/content/miner/ThreadMinerSearch.java index 93a01abbb..8a00d9139 100644 --- a/src/main/java/mekanism/common/content/miner/ThreadMinerSearch.java +++ b/src/main/java/mekanism/common/content/miner/ThreadMinerSearch.java @@ -15,154 +15,143 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.fluids.IFluidBlock; -public class ThreadMinerSearch extends Thread -{ - public TileEntityDigitalMiner tileEntity; +public class ThreadMinerSearch extends Thread { + public TileEntityDigitalMiner tileEntity; - public State state = State.IDLE; + public State state = State.IDLE; - public Map oresToMine = new HashMap(); - public Map replaceMap = new HashMap(); + public Map oresToMine = new HashMap(); + public Map replaceMap = new HashMap(); - public Map acceptedItems = new HashMap(); + public Map acceptedItems + = new HashMap(); - public int found = 0; + public int found = 0; - public ThreadMinerSearch(TileEntityDigitalMiner tile) - { - tileEntity = tile; - } + public ThreadMinerSearch(TileEntityDigitalMiner tile) { + tileEntity = tile; + } - @Override - public void run() - { - state = State.SEARCHING; + @Override + public void run() { + state = State.SEARCHING; - if(!tileEntity.inverse && tileEntity.filters.isEmpty()) - { - state = State.FINISHED; - return; - } + if (!tileEntity.inverse && tileEntity.filters.isEmpty()) { + state = State.FINISHED; + return; + } - Coord4D coord = tileEntity.getStartingCoord(); - int diameter = tileEntity.getDiameter(); - int size = tileEntity.getTotalSize(); - BlockInfo info = new BlockInfo(null, 0); + Coord4D coord = tileEntity.getStartingCoord(); + int diameter = tileEntity.getDiameter(); + int size = tileEntity.getTotalSize(); + BlockInfo info = new BlockInfo(null, 0); - for(int i = 0; i < size; i++) - { - int x = coord.xCoord+i%diameter; - int z = coord.zCoord+(i/diameter)%diameter; - int y = coord.yCoord+(i/diameter/diameter); + for (int i = 0; i < size; i++) { + int x = coord.xCoord + i % diameter; + int z = coord.zCoord + (i / diameter) % diameter; + int y = coord.yCoord + (i / diameter / diameter); - if(tileEntity.isInvalid()) - { - return; - } + if (tileEntity.isInvalid()) { + return; + } - try { - if(tileEntity.xCoord == x && tileEntity.yCoord == y && tileEntity.zCoord == z) - { - continue; - } - - if(!tileEntity.getWorldObj().getChunkProvider().chunkExists(x >> 4, z >> 4)) - { - continue; - } - - TileEntity tile = tileEntity.getWorldObj().getTileEntity(x, y, z); - - if(tile instanceof TileEntityBoundingBlock) - { - continue; - } - - info.block = tileEntity.getWorldObj().getBlock(x, y, z); - info.meta = tileEntity.getWorldObj().getBlockMetadata(x, y, z); - - if(info.block instanceof BlockLiquid || info.block instanceof IFluidBlock) - { - continue; - } - - if(info.block != null && !tileEntity.getWorldObj().isAirBlock(x, y, z) && info.block.getBlockHardness(tileEntity.getWorldObj(), x, y, z) >= 0) - { - MinerFilter filterFound = null; - boolean canFilter = false; - - if(acceptedItems.containsKey(info)) - { - filterFound = acceptedItems.get(info); - } - else { - ItemStack stack = new ItemStack(info.block, 1, info.meta); - - if(tileEntity.isReplaceStack(stack)) - { - continue; - } - - for(MinerFilter filter : tileEntity.filters) - { - if(filter.canFilter(stack)) - { - filterFound = filter; - break; - } - } - - acceptedItems.put(info, filterFound); - } - - canFilter = tileEntity.inverse ? filterFound == null : filterFound != null; - - if(canFilter) - { - set(i, new Coord4D(x, y, z, tileEntity.getWorldObj().provider.dimensionId)); - replaceMap.put(i, filterFound); - - found++; - } - } - } catch(Exception e) {} - } + try { + if (tileEntity.xCoord == x && tileEntity.yCoord == y + && tileEntity.zCoord == z) { + continue; + } - state = State.FINISHED; - tileEntity.oresToMine = oresToMine; - tileEntity.replaceMap = replaceMap; - MekanismUtils.saveChunk(tileEntity); - } - - public void set(int i, Coord4D location) - { - Chunk3D chunk = new Chunk3D(location); - - if(oresToMine.get(chunk) == null) - { - oresToMine.put(chunk, new BitSet()); - } - - oresToMine.get(chunk).set(i); - } + if (!tileEntity.getWorldObj().getChunkProvider().chunkExists( + x >> 4, z >> 4 + )) { + continue; + } - public void reset() - { - state = State.IDLE; - } + TileEntity tile = tileEntity.getWorldObj().getTileEntity(x, y, z); - public static enum State - { - IDLE("Not ready"), - SEARCHING("Searching"), - PAUSED("Paused"), - FINISHED("Ready"); + if (tile instanceof TileEntityBoundingBlock) { + continue; + } - public String desc; + info.block = tileEntity.getWorldObj().getBlock(x, y, z); + info.meta = tileEntity.getWorldObj().getBlockMetadata(x, y, z); - private State(String s) - { - desc = s; - } - } + if (info.block instanceof BlockLiquid + || info.block instanceof IFluidBlock) { + continue; + } + + if (info.block != null && !tileEntity.getWorldObj().isAirBlock(x, y, z) + && info.block.getBlockHardness(tileEntity.getWorldObj(), x, y, z) + >= 0) { + MinerFilter filterFound = null; + boolean canFilter = false; + + if (acceptedItems.containsKey(info)) { + filterFound = acceptedItems.get(info); + } else { + ItemStack stack = new ItemStack(info.block, 1, info.meta); + + if (tileEntity.isReplaceStack(stack)) { + continue; + } + + for (MinerFilter filter : tileEntity.filters) { + if (filter.canFilter(stack)) { + filterFound = filter; + break; + } + } + + acceptedItems.put(info, filterFound); + } + + canFilter + = tileEntity.inverse ? filterFound == null : filterFound != null; + + if (canFilter) { + set(i, + new Coord4D( + x, y, z, tileEntity.getWorldObj().provider.dimensionId + )); + replaceMap.put(i, filterFound); + + found++; + } + } + } catch (Exception e) {} + } + + state = State.FINISHED; + tileEntity.oresToMine = oresToMine; + tileEntity.replaceMap = replaceMap; + MekanismUtils.saveChunk(tileEntity); + } + + public void set(int i, Coord4D location) { + Chunk3D chunk = new Chunk3D(location); + + if (oresToMine.get(chunk) == null) { + oresToMine.put(chunk, new BitSet()); + } + + oresToMine.get(chunk).set(i); + } + + public void reset() { + state = State.IDLE; + } + + public static enum State { + IDLE("Not ready"), + SEARCHING("Searching"), + PAUSED("Paused"), + FINISHED("Ready"); + + public String desc; + + private State(String s) { + desc = s; + } + } } diff --git a/src/main/java/mekanism/common/content/tank/DynamicFluidTank.java b/src/main/java/mekanism/common/content/tank/DynamicFluidTank.java index 994d2ed5f..3393be3c8 100644 --- a/src/main/java/mekanism/common/content/tank/DynamicFluidTank.java +++ b/src/main/java/mekanism/common/content/tank/DynamicFluidTank.java @@ -8,190 +8,158 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidTank; -public class DynamicFluidTank implements IFluidTank -{ - public TileEntityDynamicTank dynamicTank; +public class DynamicFluidTank implements IFluidTank { + public TileEntityDynamicTank dynamicTank; - public DynamicFluidTank(TileEntityDynamicTank tileEntity) - { - dynamicTank = tileEntity; - } + public DynamicFluidTank(TileEntityDynamicTank tileEntity) { + dynamicTank = tileEntity; + } - @Override - public FluidStack getFluid() - { - return dynamicTank.structure != null ? dynamicTank.structure.fluidStored : null; - } + @Override + public FluidStack getFluid() { + return dynamicTank.structure != null ? dynamicTank.structure.fluidStored : null; + } - @Override - public int getCapacity() - { - return dynamicTank.structure != null ? dynamicTank.structure.volume*TankUpdateProtocol.FLUID_PER_TANK : 0; - } + @Override + public int getCapacity() { + return dynamicTank.structure != null + ? dynamicTank.structure.volume * TankUpdateProtocol.FLUID_PER_TANK + : 0; + } - @Override - public int fill(FluidStack resource, boolean doFill) - { - if(dynamicTank.structure != null && !dynamicTank.getWorldObj().isRemote) - { - if(resource == null || resource.getFluidID() <= 0) - { - return 0; - } - - if(dynamicTank.structure.fluidStored != null && !dynamicTank.structure.fluidStored.isFluidEqual(resource)) - { - return 0; - } + @Override + public int fill(FluidStack resource, boolean doFill) { + if (dynamicTank.structure != null && !dynamicTank.getWorldObj().isRemote) { + if (resource == null || resource.getFluidID() <= 0) { + return 0; + } - if(dynamicTank.structure.fluidStored == null || dynamicTank.structure.fluidStored.getFluidID() <= 0) - { - if(resource.amount <= getCapacity()) - { - if(doFill) - { - dynamicTank.structure.fluidStored = resource.copy(); - - if(resource.amount > 0) - { - MekanismUtils.saveChunk(dynamicTank); - updateValveData(); - } - } + if (dynamicTank.structure.fluidStored != null + && !dynamicTank.structure.fluidStored.isFluidEqual(resource)) { + return 0; + } - return resource.amount; - } - else { - if(doFill) - { - dynamicTank.structure.fluidStored = resource.copy(); - dynamicTank.structure.fluidStored.amount = getCapacity(); - - if(getCapacity() > 0) - { - MekanismUtils.saveChunk(dynamicTank); - updateValveData(); - } - } + if (dynamicTank.structure.fluidStored == null + || dynamicTank.structure.fluidStored.getFluidID() <= 0) { + if (resource.amount <= getCapacity()) { + if (doFill) { + dynamicTank.structure.fluidStored = resource.copy(); - return getCapacity(); - } - } - else if(resource.amount <= getNeeded()) - { - if(doFill) - { - dynamicTank.structure.fluidStored.amount += resource.amount; - - if(resource.amount > 0) - { - MekanismUtils.saveChunk(dynamicTank); - updateValveData(); - } - } + if (resource.amount > 0) { + MekanismUtils.saveChunk(dynamicTank); + updateValveData(); + } + } - return resource.amount; - } - else { - int prevNeeded = getNeeded(); - - if(doFill) - { - dynamicTank.structure.fluidStored.amount = getCapacity(); - - if(prevNeeded > 0) - { - MekanismUtils.saveChunk(dynamicTank); - updateValveData(); - } - } + return resource.amount; + } else { + if (doFill) { + dynamicTank.structure.fluidStored = resource.copy(); + dynamicTank.structure.fluidStored.amount = getCapacity(); - return prevNeeded; - } - } + if (getCapacity() > 0) { + MekanismUtils.saveChunk(dynamicTank); + updateValveData(); + } + } - return 0; - } + return getCapacity(); + } + } else if (resource.amount <= getNeeded()) { + if (doFill) { + dynamicTank.structure.fluidStored.amount += resource.amount; - public void updateValveData() - { - if(dynamicTank.structure != null) - { - for(ValveData data : dynamicTank.structure.valves) - { - if(data.location.equals(Coord4D.get(dynamicTank))) - { - data.onTransfer(); - } - } - } - } + if (resource.amount > 0) { + MekanismUtils.saveChunk(dynamicTank); + updateValveData(); + } + } - @Override - public FluidStack drain(int maxDrain, boolean doDrain) - { - if(dynamicTank.structure != null && !dynamicTank.getWorldObj().isRemote) - { - if(dynamicTank.structure.fluidStored == null || dynamicTank.structure.fluidStored.getFluidID() <= 0) - { - return null; - } + return resource.amount; + } else { + int prevNeeded = getNeeded(); - if(dynamicTank.structure.fluidStored.amount <= 0) - { - return null; - } + if (doFill) { + dynamicTank.structure.fluidStored.amount = getCapacity(); - int used = maxDrain; + if (prevNeeded > 0) { + MekanismUtils.saveChunk(dynamicTank); + updateValveData(); + } + } - if(dynamicTank.structure.fluidStored.amount < used) - { - used = dynamicTank.structure.fluidStored.amount; - } + return prevNeeded; + } + } - if(doDrain) - { - dynamicTank.structure.fluidStored.amount -= used; - } + return 0; + } - FluidStack drained = new FluidStack(dynamicTank.structure.fluidStored.getFluid(), used); + public void updateValveData() { + if (dynamicTank.structure != null) { + for (ValveData data : dynamicTank.structure.valves) { + if (data.location.equals(Coord4D.get(dynamicTank))) { + data.onTransfer(); + } + } + } + } - if(dynamicTank.structure.fluidStored.amount <= 0) - { - dynamicTank.structure.fluidStored = null; - } + @Override + public FluidStack drain(int maxDrain, boolean doDrain) { + if (dynamicTank.structure != null && !dynamicTank.getWorldObj().isRemote) { + if (dynamicTank.structure.fluidStored == null + || dynamicTank.structure.fluidStored.getFluidID() <= 0) { + return null; + } - if(drained.amount > 0 && doDrain) - { - MekanismUtils.saveChunk(dynamicTank); - dynamicTank.sendPacketToRenderer(); - } + if (dynamicTank.structure.fluidStored.amount <= 0) { + return null; + } - return drained; - } + int used = maxDrain; - return null; - } - - public int getNeeded() - { - return getCapacity()-getFluidAmount(); - } + if (dynamicTank.structure.fluidStored.amount < used) { + used = dynamicTank.structure.fluidStored.amount; + } - @Override - public int getFluidAmount() - { - if(dynamicTank.structure != null) - { - return dynamicTank.structure.fluidStored.amount; - } + if (doDrain) { + dynamicTank.structure.fluidStored.amount -= used; + } - return 0; - } + FluidStack drained + = new FluidStack(dynamicTank.structure.fluidStored.getFluid(), used); - @Override - public FluidTankInfo getInfo() - { - return new FluidTankInfo(this); - } + if (dynamicTank.structure.fluidStored.amount <= 0) { + dynamicTank.structure.fluidStored = null; + } + + if (drained.amount > 0 && doDrain) { + MekanismUtils.saveChunk(dynamicTank); + dynamicTank.sendPacketToRenderer(); + } + + return drained; + } + + return null; + } + + public int getNeeded() { + return getCapacity() - getFluidAmount(); + } + + @Override + public int getFluidAmount() { + if (dynamicTank.structure != null) { + return dynamicTank.structure.fluidStored.amount; + } + + return 0; + } + + @Override + public FluidTankInfo getInfo() { + return new FluidTankInfo(this); + } } diff --git a/src/main/java/mekanism/common/content/tank/SynchronizedTankData.java b/src/main/java/mekanism/common/content/tank/SynchronizedTankData.java index db2251dbe..fc33fe76e 100644 --- a/src/main/java/mekanism/common/content/tank/SynchronizedTankData.java +++ b/src/main/java/mekanism/common/content/tank/SynchronizedTankData.java @@ -10,69 +10,62 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; -public class SynchronizedTankData extends SynchronizedData -{ - public FluidStack fluidStored; - - /** For use by rendering segment */ - public FluidStack prevFluid; - - public ContainerEditMode editMode = ContainerEditMode.BOTH; +public class SynchronizedTankData extends SynchronizedData { + public FluidStack fluidStored; - public ItemStack[] inventory = new ItemStack[2]; + /** For use by rendering segment */ + public FluidStack prevFluid; - public Set valves = new HashSet(); - - public boolean needsRenderUpdate() - { - if((fluidStored == null && prevFluid != null) || (fluidStored != null && prevFluid == null)) - { - return true; - } - - if(fluidStored != null && prevFluid != null) - { - if((fluidStored.getFluid() != prevFluid.getFluid()) || (fluidStored.amount != prevFluid.amount)) - { - return true; - } - } - - return false; - } - - @Override - public ItemStack[] getInventory() - { - return inventory; - } + public ContainerEditMode editMode = ContainerEditMode.BOTH; - public static class ValveData - { - public ForgeDirection side; - public Coord4D location; - - public boolean prevActive; - public int activeTicks; - - public void onTransfer() - { - activeTicks = 30; - } + public ItemStack[] inventory = new ItemStack[2]; - @Override - public int hashCode() - { - int code = 1; - code = 31 * code + side.ordinal(); - code = 31 * code + location.hashCode(); - return code; - } + public Set valves = new HashSet(); - @Override - public boolean equals(Object obj) - { - return obj instanceof ValveData && ((ValveData)obj).side == side && ((ValveData)obj).location.equals(location); - } - } + public boolean needsRenderUpdate() { + if ((fluidStored == null && prevFluid != null) + || (fluidStored != null && prevFluid == null)) { + return true; + } + + if (fluidStored != null && prevFluid != null) { + if ((fluidStored.getFluid() != prevFluid.getFluid()) + || (fluidStored.amount != prevFluid.amount)) { + return true; + } + } + + return false; + } + + @Override + public ItemStack[] getInventory() { + return inventory; + } + + public static class ValveData { + public ForgeDirection side; + public Coord4D location; + + public boolean prevActive; + public int activeTicks; + + public void onTransfer() { + activeTicks = 30; + } + + @Override + public int hashCode() { + int code = 1; + code = 31 * code + side.ordinal(); + code = 31 * code + location.hashCode(); + return code; + } + + @Override + public boolean equals(Object obj) { + return obj instanceof ValveData && ((ValveData) obj).side == side + && ((ValveData) obj).location.equals(location); + } + } } diff --git a/src/main/java/mekanism/common/content/tank/TankCache.java b/src/main/java/mekanism/common/content/tank/TankCache.java index eb23200c4..9b5060b0b 100644 --- a/src/main/java/mekanism/common/content/tank/TankCache.java +++ b/src/main/java/mekanism/common/content/tank/TankCache.java @@ -8,78 +8,69 @@ import net.minecraft.nbt.NBTTagList; import net.minecraftforge.common.util.Constants.NBT; import net.minecraftforge.fluids.FluidStack; -public class TankCache extends MultiblockCache -{ - public ItemStack[] inventory = new ItemStack[2]; - - public FluidStack fluid; - - public ContainerEditMode editMode = ContainerEditMode.BOTH; - - @Override - public void apply(SynchronizedTankData data) - { - data.inventory = inventory; - data.fluidStored = fluid; - data.editMode = editMode; - } - - @Override - public void sync(SynchronizedTankData data) - { - inventory = data.inventory; - fluid = data.fluidStored; - editMode = data.editMode; - } - - @Override - public void load(NBTTagCompound nbtTags) - { - editMode = ContainerEditMode.values()[nbtTags.getInteger("editMode")]; - - NBTTagList tagList = nbtTags.getTagList("Items", NBT.TAG_COMPOUND); - inventory = new ItemStack[2]; +public class TankCache extends MultiblockCache { + public ItemStack[] inventory = new ItemStack[2]; - for(int tagCount = 0; tagCount < tagList.tagCount(); tagCount++) - { - NBTTagCompound tagCompound = (NBTTagCompound)tagList.getCompoundTagAt(tagCount); - byte slotID = tagCompound.getByte("Slot"); + public FluidStack fluid; - if(slotID >= 0 && slotID < 2) - { - inventory[slotID] = ItemStack.loadItemStackFromNBT(tagCompound); - } - } - - if(nbtTags.hasKey("cachedFluid")) - { - fluid = FluidStack.loadFluidStackFromNBT(nbtTags.getCompoundTag("cachedFluid")); - } - } - - @Override - public void save(NBTTagCompound nbtTags) - { - nbtTags.setInteger("editMode", editMode.ordinal()); - - NBTTagList tagList = new NBTTagList(); + public ContainerEditMode editMode = ContainerEditMode.BOTH; - for(int slotCount = 0; slotCount < 2; slotCount++) - { - if(inventory[slotCount] != null) - { - NBTTagCompound tagCompound = new NBTTagCompound(); - tagCompound.setByte("Slot", (byte)slotCount); - inventory[slotCount].writeToNBT(tagCompound); - tagList.appendTag(tagCompound); - } - } + @Override + public void apply(SynchronizedTankData data) { + data.inventory = inventory; + data.fluidStored = fluid; + data.editMode = editMode; + } - nbtTags.setTag("Items", tagList); - - if(fluid != null) - { - nbtTags.setTag("cachedFluid", fluid.writeToNBT(new NBTTagCompound())); - } - } + @Override + public void sync(SynchronizedTankData data) { + inventory = data.inventory; + fluid = data.fluidStored; + editMode = data.editMode; + } + + @Override + public void load(NBTTagCompound nbtTags) { + editMode = ContainerEditMode.values()[nbtTags.getInteger("editMode")]; + + NBTTagList tagList = nbtTags.getTagList("Items", NBT.TAG_COMPOUND); + inventory = new ItemStack[2]; + + for (int tagCount = 0; tagCount < tagList.tagCount(); tagCount++) { + NBTTagCompound tagCompound + = (NBTTagCompound) tagList.getCompoundTagAt(tagCount); + byte slotID = tagCompound.getByte("Slot"); + + if (slotID >= 0 && slotID < 2) { + inventory[slotID] = ItemStack.loadItemStackFromNBT(tagCompound); + } + } + + if (nbtTags.hasKey("cachedFluid")) { + fluid + = FluidStack.loadFluidStackFromNBT(nbtTags.getCompoundTag("cachedFluid")); + } + } + + @Override + public void save(NBTTagCompound nbtTags) { + nbtTags.setInteger("editMode", editMode.ordinal()); + + NBTTagList tagList = new NBTTagList(); + + for (int slotCount = 0; slotCount < 2; slotCount++) { + if (inventory[slotCount] != null) { + NBTTagCompound tagCompound = new NBTTagCompound(); + tagCompound.setByte("Slot", (byte) slotCount); + inventory[slotCount].writeToNBT(tagCompound); + tagList.appendTag(tagCompound); + } + } + + nbtTags.setTag("Items", tagList); + + if (fluid != null) { + nbtTags.setTag("cachedFluid", fluid.writeToNBT(new NBTTagCompound())); + } + } } diff --git a/src/main/java/mekanism/common/content/tank/TankUpdateProtocol.java b/src/main/java/mekanism/common/content/tank/TankUpdateProtocol.java index 995051974..7ccd6244f 100644 --- a/src/main/java/mekanism/common/content/tank/TankUpdateProtocol.java +++ b/src/main/java/mekanism/common/content/tank/TankUpdateProtocol.java @@ -14,85 +14,103 @@ import mekanism.common.tile.TileEntityDynamicTank; import mekanism.common.tile.TileEntityDynamicValve; import net.minecraft.item.ItemStack; -public class TankUpdateProtocol extends UpdateProtocol -{ - public static final int FLUID_PER_TANK = 64000; +public class TankUpdateProtocol extends UpdateProtocol { + public static final int FLUID_PER_TANK = 64000; - public TankUpdateProtocol(TileEntityDynamicTank tileEntity) - { - super(tileEntity); - } + public TankUpdateProtocol(TileEntityDynamicTank tileEntity) { + super(tileEntity); + } - @Override - protected boolean isValidFrame(int x, int y, int z) - { - return BasicType.get(pointer.getWorldObj().getBlock(x, y, z), pointer.getWorldObj().getBlockMetadata(x, y, z)) == BasicType.DYNAMIC_TANK; - } - - @Override - protected TankCache getNewCache() - { - return new TankCache(); - } - - @Override - protected SynchronizedTankData getNewStructure() - { - return new SynchronizedTankData(); - } - - @Override - protected MultiblockManager getManager() - { - return Mekanism.tankManager; - } - - @Override - protected void mergeCaches(List rejectedItems, MultiblockCache cache, MultiblockCache merge) - { - if(((TankCache)cache).fluid == null) - { - ((TankCache)cache).fluid = ((TankCache)merge).fluid; - } + @Override + protected boolean isValidFrame(int x, int y, int z) { + return BasicType.get( + pointer.getWorldObj().getBlock(x, y, z), + pointer.getWorldObj().getBlockMetadata(x, y, z) + ) + == BasicType.DYNAMIC_TANK; + } + + @Override + protected TankCache getNewCache() { + return new TankCache(); + } + + @Override + protected SynchronizedTankData getNewStructure() { + return new SynchronizedTankData(); + } + + @Override + protected MultiblockManager getManager() { + return Mekanism.tankManager; + } + + @Override + protected void mergeCaches( + List rejectedItems, + MultiblockCache cache, + MultiblockCache merge + ) { + if (((TankCache) cache).fluid == null) { + ((TankCache) cache).fluid = ((TankCache) merge).fluid; + } else if(((TankCache)merge).fluid != null && ((TankCache)cache).fluid.isFluidEqual(((TankCache)merge).fluid)) { - ((TankCache)cache).fluid.amount += ((TankCache)merge).fluid.amount; - } - - List rejects = StackUtils.getMergeRejects(((TankCache)cache).inventory, ((TankCache)merge).inventory); - - if(!rejects.isEmpty()) - { - rejectedItems.addAll(rejects); - } - - StackUtils.merge(((TankCache)cache).inventory, ((TankCache)merge).inventory); - } - - @Override - protected void onFormed() - { - super.onFormed(); - - if(structureFound.fluidStored != null) - { - structureFound.fluidStored.amount = Math.min(structureFound.fluidStored.amount, structureFound.volume*FLUID_PER_TANK); - } - } - - @Override - protected void onStructureCreated(SynchronizedTankData structure, int origX, int origY, int origZ, int xmin, int xmax, int ymin, int ymax, int zmin, int zmax) - { - for(Coord4D obj : structure.locations) - { - if(obj.getTileEntity(pointer.getWorldObj()) instanceof TileEntityDynamicValve) - { - ValveData data = new ValveData(); - data.location = obj; - data.side = getSide(obj, origX+xmin, origX+xmax, origY+ymin, origY+ymax, origZ+zmin, origZ+zmax); + ((TankCache) cache).fluid.amount += ((TankCache) merge).fluid.amount; + } - structure.valves.add(data); - } - } - } + List rejects = StackUtils.getMergeRejects( + ((TankCache) cache).inventory, ((TankCache) merge).inventory + ); + + if (!rejects.isEmpty()) { + rejectedItems.addAll(rejects); + } + + StackUtils.merge(((TankCache) cache).inventory, ((TankCache) merge).inventory); + } + + @Override + protected void onFormed() { + super.onFormed(); + + if (structureFound.fluidStored != null) { + structureFound.fluidStored.amount = Math.min( + structureFound.fluidStored.amount, structureFound.volume * FLUID_PER_TANK + ); + } + } + + @Override + protected void onStructureCreated( + SynchronizedTankData structure, + int origX, + int origY, + int origZ, + int xmin, + int xmax, + int ymin, + int ymax, + int zmin, + int zmax + ) { + for (Coord4D obj : structure.locations) { + if (obj.getTileEntity(pointer.getWorldObj()) + instanceof TileEntityDynamicValve) { + ValveData data = new ValveData(); + data.location = obj; + data.side = getSide( + obj, + origX + xmin, + origX + xmax, + origY + ymin, + origY + ymax, + origZ + zmin, + origZ + zmax + ); + + structure.valves.add(data); + } + } + } } diff --git a/src/main/java/mekanism/common/content/transporter/Finder.java b/src/main/java/mekanism/common/content/transporter/Finder.java index f4f13981f..6db7ec61d 100644 --- a/src/main/java/mekanism/common/content/transporter/Finder.java +++ b/src/main/java/mekanism/common/content/transporter/Finder.java @@ -9,154 +9,118 @@ import net.minecraft.block.material.Material; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; -public abstract class Finder -{ - public abstract boolean modifies(ItemStack stack); +public abstract class Finder { + public abstract boolean modifies(ItemStack stack); - public static class FirstFinder extends Finder - { - @Override - public boolean modifies(ItemStack stack) - { - return true; - } - } + public static class FirstFinder extends Finder { + @Override + public boolean modifies(ItemStack stack) { + return true; + } + } - public static class OreDictFinder extends Finder - { - public String oreDictName; + public static class OreDictFinder extends Finder { + public String oreDictName; - public OreDictFinder(String name) - { - oreDictName = name; - } + public OreDictFinder(String name) { + oreDictName = name; + } - @Override - public boolean modifies(ItemStack stack) - { - List oreKeys = MekanismUtils.getOreDictName(stack); + @Override + public boolean modifies(ItemStack stack) { + List oreKeys = MekanismUtils.getOreDictName(stack); - if(oreKeys.isEmpty()) - { - return false; - } + if (oreKeys.isEmpty()) { + return false; + } - for(String oreKey : oreKeys) - { - if(oreDictName.equals(oreKey) || oreDictName.equals("*")) - { - return true; - } - else if(oreDictName.endsWith("*") && !oreDictName.startsWith("*")) - { - if(oreKey.startsWith(oreDictName.substring(0, oreDictName.length()-1))) - { - return true; - } - } - else if(oreDictName.startsWith("*") && !oreDictName.endsWith("*")) - { - if(oreKey.endsWith(oreDictName.substring(1))) - { - return true; - } - } - else if(oreDictName.startsWith("*") && oreDictName.endsWith("*")) - { - if(oreKey.contains(oreDictName.substring(1, oreDictName.length()-1))) - { - return true; - } - } - } + for (String oreKey : oreKeys) { + if (oreDictName.equals(oreKey) || oreDictName.equals("*")) { + return true; + } else if (oreDictName.endsWith("*") && !oreDictName.startsWith("*")) { + if (oreKey.startsWith( + oreDictName.substring(0, oreDictName.length() - 1) + )) { + return true; + } + } else if (oreDictName.startsWith("*") && !oreDictName.endsWith("*")) { + if (oreKey.endsWith(oreDictName.substring(1))) { + return true; + } + } else if (oreDictName.startsWith("*") && oreDictName.endsWith("*")) { + if (oreKey.contains(oreDictName.substring(1, oreDictName.length() - 1) + )) { + return true; + } + } + } - return false; - } - } + return false; + } + } - public static class ItemStackFinder extends Finder - { - public ItemStack itemType; + public static class ItemStackFinder extends Finder { + public ItemStack itemType; - public ItemStackFinder(ItemStack type) - { - itemType = type; - } + public ItemStackFinder(ItemStack type) { + itemType = type; + } - @Override - public boolean modifies(ItemStack stack) - { - return StackUtils.equalsWildcard(itemType, stack); - } - } - - public static class MaterialFinder extends Finder - { - public Material materialType; - - public MaterialFinder(Material type) - { - materialType = type; - } - - @Override - public boolean modifies(ItemStack stack) - { - if(stack == null || !(stack.getItem() instanceof ItemBlock)) - { - return false; - } - - return Block.getBlockFromItem(stack.getItem()).getMaterial() == materialType; - } - } - - public static class ModIDFinder extends Finder - { - public String modID; - - public ModIDFinder(String mod) - { - modID = mod; - } - - @Override - public boolean modifies(ItemStack stack) - { - if(stack == null || !(stack.getItem() instanceof ItemBlock)) - { - return false; - } - - String id = MekanismUtils.getMod(stack); - - if(modID.equals(id) || modID.equals("*")) - { - return true; - } - else if(modID.endsWith("*") && !modID.startsWith("*")) - { - if(id.startsWith(modID.substring(0, modID.length()-1))) - { - return true; - } - } - else if(modID.startsWith("*") && !modID.endsWith("*")) - { - if(id.endsWith(modID.substring(1))) - { - return true; - } - } - else if(modID.startsWith("*") && modID.endsWith("*")) - { - if(id.contains(modID.substring(1, modID.length()-1))) - { - return true; - } - } - - return false; - } - } + @Override + public boolean modifies(ItemStack stack) { + return StackUtils.equalsWildcard(itemType, stack); + } + } + + public static class MaterialFinder extends Finder { + public Material materialType; + + public MaterialFinder(Material type) { + materialType = type; + } + + @Override + public boolean modifies(ItemStack stack) { + if (stack == null || !(stack.getItem() instanceof ItemBlock)) { + return false; + } + + return Block.getBlockFromItem(stack.getItem()).getMaterial() == materialType; + } + } + + public static class ModIDFinder extends Finder { + public String modID; + + public ModIDFinder(String mod) { + modID = mod; + } + + @Override + public boolean modifies(ItemStack stack) { + if (stack == null || !(stack.getItem() instanceof ItemBlock)) { + return false; + } + + String id = MekanismUtils.getMod(stack); + + if (modID.equals(id) || modID.equals("*")) { + return true; + } else if (modID.endsWith("*") && !modID.startsWith("*")) { + if (id.startsWith(modID.substring(0, modID.length() - 1))) { + return true; + } + } else if (modID.startsWith("*") && !modID.endsWith("*")) { + if (id.endsWith(modID.substring(1))) { + return true; + } + } else if (modID.startsWith("*") && modID.endsWith("*")) { + if (id.contains(modID.substring(1, modID.length() - 1))) { + return true; + } + } + + return false; + } + } } diff --git a/src/main/java/mekanism/common/content/transporter/InvStack.java b/src/main/java/mekanism/common/content/transporter/InvStack.java index b1644d378..fefd155a6 100644 --- a/src/main/java/mekanism/common/content/transporter/InvStack.java +++ b/src/main/java/mekanism/common/content/transporter/InvStack.java @@ -5,81 +5,70 @@ import java.util.ArrayList; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; -public final class InvStack -{ - public IInventory inventory; - public ArrayList itemStacks; - public ArrayList slotIDs; +public final class InvStack { + public IInventory inventory; + public ArrayList itemStacks; + public ArrayList slotIDs; - public InvStack(IInventory inv) - { - inventory = inv; - itemStacks = new ArrayList(); - slotIDs = new ArrayList(); - } + public InvStack(IInventory inv) { + inventory = inv; + itemStacks = new ArrayList(); + slotIDs = new ArrayList(); + } - public InvStack(IInventory inv, int id, ItemStack stack) - { - inventory = inv; - itemStacks = new ArrayList(); - slotIDs = new ArrayList(); + public InvStack(IInventory inv, int id, ItemStack stack) { + inventory = inv; + itemStacks = new ArrayList(); + slotIDs = new ArrayList(); - appendStack(id, stack); - } + appendStack(id, stack); + } - public ItemStack getStack() - { - int size = 0; + public ItemStack getStack() { + int size = 0; - for(ItemStack stack : itemStacks) - { - size += stack.stackSize; - } + for (ItemStack stack : itemStacks) { + size += stack.stackSize; + } - if(!itemStacks.isEmpty()) - { - ItemStack ret = itemStacks.get(0).copy(); - ret.stackSize = size; + if (!itemStacks.isEmpty()) { + ItemStack ret = itemStacks.get(0).copy(); + ret.stackSize = size; - return ret; - } + return ret; + } - return null; - } + return null; + } - public void appendStack(int id, ItemStack stack) - { - slotIDs.add(id); - itemStacks.add(stack); - } + public void appendStack(int id, ItemStack stack) { + slotIDs.add(id); + itemStacks.add(stack); + } - public void use(int amount) - { - for(int i = 0; i < slotIDs.size(); i++) - { - ItemStack stack = itemStacks.get(i); + public void use(int amount) { + for (int i = 0; i < slotIDs.size(); i++) { + ItemStack stack = itemStacks.get(i); - if(inventory.getStackInSlot(slotIDs.get(i)).stackSize == stack.stackSize && stack.stackSize <= amount) - { - inventory.setInventorySlotContents(slotIDs.get(i), null); - amount -= stack.stackSize; - } - else { - ItemStack ret = stack.copy(); - ret.stackSize = inventory.getStackInSlot(slotIDs.get(i)).stackSize - Math.min(stack.stackSize, amount); - inventory.setInventorySlotContents(slotIDs.get(i), ret); - amount -= ret.stackSize; - } + if (inventory.getStackInSlot(slotIDs.get(i)).stackSize == stack.stackSize + && stack.stackSize <= amount) { + inventory.setInventorySlotContents(slotIDs.get(i), null); + amount -= stack.stackSize; + } else { + ItemStack ret = stack.copy(); + ret.stackSize = inventory.getStackInSlot(slotIDs.get(i)).stackSize + - Math.min(stack.stackSize, amount); + inventory.setInventorySlotContents(slotIDs.get(i), ret); + amount -= ret.stackSize; + } - if(amount == 0) - { - return; - } - } - } + if (amount == 0) { + return; + } + } + } - public void use() - { - use(getStack().stackSize); - } + public void use() { + use(getStack().stackSize); + } } diff --git a/src/main/java/mekanism/common/content/transporter/PathfinderCache.java b/src/main/java/mekanism/common/content/transporter/PathfinderCache.java index 0fd041199..850d003cb 100644 --- a/src/main/java/mekanism/common/content/transporter/PathfinderCache.java +++ b/src/main/java/mekanism/common/content/transporter/PathfinderCache.java @@ -8,71 +8,63 @@ import java.util.Map; import mekanism.api.Coord4D; import net.minecraftforge.common.util.ForgeDirection; -public class PathfinderCache -{ - public static Map> cachedPaths = new HashMap>(); - - public static void onChanged(Coord4D location) - { - reset(); - } - - public static List getCache(Coord4D start, Coord4D end, EnumSet sides) - { - List ret = null; - - for(ForgeDirection side : sides) - { - PathData data = new PathData(start, end, side); +public class PathfinderCache { + public static Map> cachedPaths + = new HashMap>(); - List test = cachedPaths.get(data); - - if(ret == null || (test != null && test.size() < ret.size())) - { - ret = test; - } - } - - return ret; - } - - public static void reset() - { - cachedPaths.clear(); - } - - public static class PathData - { - public Coord4D startTransporter; - - public Coord4D end; - public ForgeDirection endSide; - - public PathData(Coord4D s, Coord4D e, ForgeDirection es) - { - startTransporter = s; - - end = e; - endSide = es; - } - - @Override - public boolean equals(Object obj) - { - return obj instanceof PathData && - ((PathData)obj).startTransporter.equals(startTransporter) && - ((PathData)obj).end.equals(end) && - ((PathData)obj).endSide.equals(endSide); - } + public static void onChanged(Coord4D location) { + reset(); + } - @Override - public int hashCode() - { - int code = 1; - code = 31 * code + startTransporter.hashCode(); - code = 31 * code + end.hashCode(); - code = 31 * code + endSide.hashCode(); - return code; - } - } + public static List + getCache(Coord4D start, Coord4D end, EnumSet sides) { + List ret = null; + + for (ForgeDirection side : sides) { + PathData data = new PathData(start, end, side); + + List test = cachedPaths.get(data); + + if (ret == null || (test != null && test.size() < ret.size())) { + ret = test; + } + } + + return ret; + } + + public static void reset() { + cachedPaths.clear(); + } + + public static class PathData { + public Coord4D startTransporter; + + public Coord4D end; + public ForgeDirection endSide; + + public PathData(Coord4D s, Coord4D e, ForgeDirection es) { + startTransporter = s; + + end = e; + endSide = es; + } + + @Override + public boolean equals(Object obj) { + return obj instanceof PathData + && ((PathData) obj).startTransporter.equals(startTransporter) + && ((PathData) obj).end.equals(end) + && ((PathData) obj).endSide.equals(endSide); + } + + @Override + public int hashCode() { + int code = 1; + code = 31 * code + startTransporter.hashCode(); + code = 31 * code + end.hashCode(); + code = 31 * code + endSide.hashCode(); + return code; + } + } } \ No newline at end of file diff --git a/src/main/java/mekanism/common/content/transporter/StackSearcher.java b/src/main/java/mekanism/common/content/transporter/StackSearcher.java index 3ed763b85..a2e1f5336 100644 --- a/src/main/java/mekanism/common/content/transporter/StackSearcher.java +++ b/src/main/java/mekanism/common/content/transporter/StackSearcher.java @@ -7,146 +7,131 @@ import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; -public class StackSearcher -{ - public int i; - public int[] slots; - public IInventory theInventory; - public ForgeDirection side; +public class StackSearcher { + public int i; + public int[] slots; + public IInventory theInventory; + public ForgeDirection side; - public StackSearcher(IInventory inventory, ForgeDirection direction) - { - theInventory = InventoryUtils.checkChestInv(inventory); - side = direction; - - if(!(theInventory instanceof ISidedInventory)) - { - i = inventory.getSizeInventory(); - } - else { - slots = ((ISidedInventory)theInventory).getAccessibleSlotsFromSide(side.getOpposite().ordinal()); - - if(slots != null) - { - i = slots.length; - } - } - } + public StackSearcher(IInventory inventory, ForgeDirection direction) { + theInventory = InventoryUtils.checkChestInv(inventory); + side = direction; - public InvStack takeTopStack(Finder id) - { - if(!(theInventory instanceof ISidedInventory)) - { - for(i = i - 1; i >= 0; i--) - { - if(theInventory.getStackInSlot(i) != null && id.modifies(theInventory.getStackInSlot(i))) - { - ItemStack toSend = theInventory.getStackInSlot(i).copy(); - return new InvStack(theInventory, i, toSend); - } - } - } - else { - if(slots != null && slots.length != 0) - { - for(i = i - 1; i >= 0; i--) - { - int slotID = slots[i]; + if (!(theInventory instanceof ISidedInventory)) { + i = inventory.getSizeInventory(); + } else { + slots = ((ISidedInventory) theInventory) + .getAccessibleSlotsFromSide(side.getOpposite().ordinal()); - if(theInventory.getStackInSlot(slotID) != null && id.modifies(theInventory.getStackInSlot(slotID))) - { - ItemStack toSend = theInventory.getStackInSlot(slotID); + if (slots != null) { + i = slots.length; + } + } + } - if(((ISidedInventory)theInventory).canExtractItem(slotID, toSend, side.getOpposite().ordinal())) - { - return new InvStack(theInventory, slotID, toSend); - } - } - } - } - } + public InvStack takeTopStack(Finder id) { + if (!(theInventory instanceof ISidedInventory)) { + for (i = i - 1; i >= 0; i--) { + if (theInventory.getStackInSlot(i) != null + && id.modifies(theInventory.getStackInSlot(i))) { + ItemStack toSend = theInventory.getStackInSlot(i).copy(); + return new InvStack(theInventory, i, toSend); + } + } + } else { + if (slots != null && slots.length != 0) { + for (i = i - 1; i >= 0; i--) { + int slotID = slots[i]; - return null; - } + if (theInventory.getStackInSlot(slotID) != null + && id.modifies(theInventory.getStackInSlot(slotID))) { + ItemStack toSend = theInventory.getStackInSlot(slotID); - public InvStack takeDefinedItem(ItemStack type, int min, int max) - { - InvStack ret = new InvStack(theInventory); + if (((ISidedInventory) theInventory) + .canExtractItem( + slotID, toSend, side.getOpposite().ordinal() + )) { + return new InvStack(theInventory, slotID, toSend); + } + } + } + } + } - if(!(theInventory instanceof ISidedInventory)) - { - for(i = i - 1; i >= 0; i--) - { - if(theInventory.getStackInSlot(i) != null && StackUtils.equalsWildcard(theInventory.getStackInSlot(i), type)) - { - ItemStack stack = theInventory.getStackInSlot(i); - int current = ret.getStack() != null ? ret.getStack().stackSize : 0; + return null; + } - if(current+stack.stackSize <= max) - { - ret.appendStack(i, stack.copy()); - } - else { - ItemStack copy = stack.copy(); - copy.stackSize = max-current; - ret.appendStack(i, copy); - } + public InvStack takeDefinedItem(ItemStack type, int min, int max) { + InvStack ret = new InvStack(theInventory); - if(ret.getStack() != null && ret.getStack().stackSize == max) - { - return ret; - } - } - } - } - else { - ISidedInventory sidedInventory = (ISidedInventory)theInventory; - int[] slots = sidedInventory.getAccessibleSlotsFromSide(side.getOpposite().ordinal()); + if (!(theInventory instanceof ISidedInventory)) { + for (i = i - 1; i >= 0; i--) { + if (theInventory.getStackInSlot(i) != null + && StackUtils.equalsWildcard(theInventory.getStackInSlot(i), type)) { + ItemStack stack = theInventory.getStackInSlot(i); + int current = ret.getStack() != null ? ret.getStack().stackSize : 0; - if(slots != null && slots.length != 0) - { - for(i = i - 1; i >= 0; i--) - { - int slotID = slots[i]; + if (current + stack.stackSize <= max) { + ret.appendStack(i, stack.copy()); + } else { + ItemStack copy = stack.copy(); + copy.stackSize = max - current; + ret.appendStack(i, copy); + } - if(sidedInventory.getStackInSlot(slotID) != null && StackUtils.equalsWildcard(theInventory.getStackInSlot(slotID), type)) - { - ItemStack stack = sidedInventory.getStackInSlot(slotID); - int current = ret.getStack() != null ? ret.getStack().stackSize : 0; + if (ret.getStack() != null && ret.getStack().stackSize == max) { + return ret; + } + } + } + } else { + ISidedInventory sidedInventory = (ISidedInventory) theInventory; + int[] slots + = sidedInventory.getAccessibleSlotsFromSide(side.getOpposite().ordinal()); - if(current+stack.stackSize <= max) - { - ItemStack copy = stack.copy(); + if (slots != null && slots.length != 0) { + for (i = i - 1; i >= 0; i--) { + int slotID = slots[i]; - if(sidedInventory.canExtractItem(slotID, copy, side.getOpposite().ordinal())) - { - ret.appendStack(slotID, copy); - } - } - else { - ItemStack copy = stack.copy(); + if (sidedInventory.getStackInSlot(slotID) != null + && StackUtils.equalsWildcard( + theInventory.getStackInSlot(slotID), type + )) { + ItemStack stack = sidedInventory.getStackInSlot(slotID); + int current + = ret.getStack() != null ? ret.getStack().stackSize : 0; - if(sidedInventory.canExtractItem(slotID, copy, side.getOpposite().ordinal())) - { - copy.stackSize = max-current; - ret.appendStack(slotID, copy); - } - } + if (current + stack.stackSize <= max) { + ItemStack copy = stack.copy(); - if(ret.getStack() != null && ret.getStack().stackSize == max) - { - return ret; - } - } - } - } - } + if (sidedInventory.canExtractItem( + slotID, copy, side.getOpposite().ordinal() + )) { + ret.appendStack(slotID, copy); + } + } else { + ItemStack copy = stack.copy(); - if(ret != null && ret.getStack() != null && ret.getStack().stackSize >= min) - { - return ret; - } + if (sidedInventory.canExtractItem( + slotID, copy, side.getOpposite().ordinal() + )) { + copy.stackSize = max - current; + ret.appendStack(slotID, copy); + } + } - return null; - } + if (ret.getStack() != null && ret.getStack().stackSize == max) { + return ret; + } + } + } + } + } + + if (ret != null && ret.getStack() != null && ret.getStack().stackSize >= min) { + return ret; + } + + return null; + } } diff --git a/src/main/java/mekanism/common/content/transporter/TItemStackFilter.java b/src/main/java/mekanism/common/content/transporter/TItemStackFilter.java index b2481ab00..d0518782b 100644 --- a/src/main/java/mekanism/common/content/transporter/TItemStackFilter.java +++ b/src/main/java/mekanism/common/content/transporter/TItemStackFilter.java @@ -1,140 +1,133 @@ package mekanism.common.content.transporter; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import io.netty.buffer.ByteBuf; import mekanism.common.content.transporter.Finder.ItemStackFinder; import mekanism.common.util.MekanismUtils; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -public class TItemStackFilter extends TransporterFilter -{ - public boolean sizeMode; +public class TItemStackFilter extends TransporterFilter { + public boolean sizeMode; - public int min; - public int max; + public int min; + public int max; - public ItemStack itemType; + public ItemStack itemType; - @Override - public boolean canFilter(ItemStack itemStack) - { - if(itemStack == null) - { - return false; - } + @Override + public boolean canFilter(ItemStack itemStack) { + if (itemStack == null) { + return false; + } - if(sizeMode && max == 0) - { - return false; - } + if (sizeMode && max == 0) { + return false; + } - return (itemType.getHasSubtypes() ? itemType.isItemEqual(itemStack) : itemType.getItem() == itemStack.getItem()) && (!sizeMode || itemStack.stackSize >= min); - } + return (itemType.getHasSubtypes() ? itemType.isItemEqual(itemStack) + : itemType.getItem() == itemStack.getItem()) + && (!sizeMode || itemStack.stackSize >= min); + } - @Override - public InvStack getStackFromInventory(StackSearcher searcher) - { - if(sizeMode) - { - return searcher.takeDefinedItem(itemType, min, max); - } - else { - return super.getStackFromInventory(searcher); - } - } + @Override + public InvStack getStackFromInventory(StackSearcher searcher) { + if (sizeMode) { + return searcher.takeDefinedItem(itemType, min, max); + } else { + return super.getStackFromInventory(searcher); + } + } - public Finder getFinder() - { - return new ItemStackFinder(itemType); - } + public Finder getFinder() { + return new ItemStackFinder(itemType); + } - @Override - public void write(NBTTagCompound nbtTags) - { - super.write(nbtTags); + @Override + public void write(NBTTagCompound nbtTags) { + super.write(nbtTags); - nbtTags.setInteger("type", 0); - nbtTags.setBoolean("sizeMode", sizeMode); - nbtTags.setInteger("min", min); - nbtTags.setInteger("max", max); - itemType.writeToNBT(nbtTags); - } + nbtTags.setInteger("type", 0); + nbtTags.setBoolean("sizeMode", sizeMode); + nbtTags.setInteger("min", min); + nbtTags.setInteger("max", max); + itemType.writeToNBT(nbtTags); + } - @Override - protected void read(NBTTagCompound nbtTags) - { - super.read(nbtTags); + @Override + protected void read(NBTTagCompound nbtTags) { + super.read(nbtTags); - sizeMode = nbtTags.getBoolean("sizeMode"); - min = nbtTags.getInteger("min"); - max = nbtTags.getInteger("max"); + sizeMode = nbtTags.getBoolean("sizeMode"); + min = nbtTags.getInteger("min"); + max = nbtTags.getInteger("max"); - itemType = ItemStack.loadItemStackFromNBT(nbtTags); - } + itemType = ItemStack.loadItemStackFromNBT(nbtTags); + } - @Override - public void write(ArrayList data) - { - data.add(0); + @Override + public void write(ArrayList data) { + data.add(0); - super.write(data); + super.write(data); - data.add(sizeMode); - data.add(min); - data.add(max); + data.add(sizeMode); + data.add(min); + data.add(max); - data.add(MekanismUtils.getID(itemType)); - data.add(itemType.stackSize); - data.add(itemType.getItemDamage()); - } + data.add(MekanismUtils.getID(itemType)); + data.add(itemType.stackSize); + data.add(itemType.getItemDamage()); + } - @Override - protected void read(ByteBuf dataStream) - { - super.read(dataStream); + @Override + protected void read(ByteBuf dataStream) { + super.read(dataStream); - sizeMode = dataStream.readBoolean(); - min = dataStream.readInt(); - max = dataStream.readInt(); + sizeMode = dataStream.readBoolean(); + min = dataStream.readInt(); + max = dataStream.readInt(); - itemType = new ItemStack(Item.getItemById(dataStream.readInt()), dataStream.readInt(), dataStream.readInt()); - } + itemType = new ItemStack( + Item.getItemById(dataStream.readInt()), + dataStream.readInt(), + dataStream.readInt() + ); + } - @Override - public int hashCode() - { - int code = 1; - code = 31 * code + super.hashCode(); - code = 31 * code + MekanismUtils.getID(itemType); - code = 31 * code + itemType.stackSize; - code = 31 * code + itemType.getItemDamage(); - code = 31 * code + (sizeMode ? 1 : 0); - code = 31 * code + min; - code = 31 * code + max; - return code; - } + @Override + public int hashCode() { + int code = 1; + code = 31 * code + super.hashCode(); + code = 31 * code + MekanismUtils.getID(itemType); + code = 31 * code + itemType.stackSize; + code = 31 * code + itemType.getItemDamage(); + code = 31 * code + (sizeMode ? 1 : 0); + code = 31 * code + min; + code = 31 * code + max; + return code; + } - @Override - public boolean equals(Object filter) - { - return super.equals(filter) && filter instanceof TItemStackFilter && ((TItemStackFilter)filter).itemType.isItemEqual(itemType) - && ((TItemStackFilter)filter).sizeMode == sizeMode && ((TItemStackFilter)filter).min == min && ((TItemStackFilter)filter).max == max; - } + @Override + public boolean equals(Object filter) { + return super.equals(filter) && filter instanceof TItemStackFilter + && ((TItemStackFilter) filter).itemType.isItemEqual(itemType) + && ((TItemStackFilter) filter).sizeMode == sizeMode + && ((TItemStackFilter) filter).min == min + && ((TItemStackFilter) filter).max == max; + } - @Override - public TItemStackFilter clone() - { - TItemStackFilter filter = new TItemStackFilter(); - filter.color = color; - filter.itemType = itemType.copy(); - filter.sizeMode = sizeMode; - filter.min = min; - filter.max = max; + @Override + public TItemStackFilter clone() { + TItemStackFilter filter = new TItemStackFilter(); + filter.color = color; + filter.itemType = itemType.copy(); + filter.sizeMode = sizeMode; + filter.min = min; + filter.max = max; - return filter; - } + return filter; + } } diff --git a/src/main/java/mekanism/common/content/transporter/TMaterialFilter.java b/src/main/java/mekanism/common/content/transporter/TMaterialFilter.java index dceba2777..fdca60c46 100644 --- a/src/main/java/mekanism/common/content/transporter/TMaterialFilter.java +++ b/src/main/java/mekanism/common/content/transporter/TMaterialFilter.java @@ -1,9 +1,8 @@ package mekanism.common.content.transporter; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import io.netty.buffer.ByteBuf; import mekanism.common.content.transporter.Finder.MaterialFinder; import mekanism.common.util.MekanismUtils; import net.minecraft.block.Block; @@ -13,91 +12,84 @@ import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -public class TMaterialFilter extends TransporterFilter -{ - public ItemStack materialItem; - - public Material getMaterial() - { - return Block.getBlockFromItem(materialItem.getItem()).getMaterial(); - } +public class TMaterialFilter extends TransporterFilter { + public ItemStack materialItem; - @Override - public boolean canFilter(ItemStack itemStack) - { - if(itemStack == null || !(itemStack.getItem() instanceof ItemBlock)) - { - return false; - } + public Material getMaterial() { + return Block.getBlockFromItem(materialItem.getItem()).getMaterial(); + } - return new MaterialFinder(getMaterial()).modifies(itemStack); - } - - @Override - public Finder getFinder() - { - return new MaterialFinder(getMaterial()); - } + @Override + public boolean canFilter(ItemStack itemStack) { + if (itemStack == null || !(itemStack.getItem() instanceof ItemBlock)) { + return false; + } - @Override - public void write(NBTTagCompound nbtTags) - { - super.write(nbtTags); - - nbtTags.setInteger("type", 2); - materialItem.writeToNBT(nbtTags); - } + return new MaterialFinder(getMaterial()).modifies(itemStack); + } - @Override - protected void read(NBTTagCompound nbtTags) - { - super.read(nbtTags); - - materialItem = ItemStack.loadItemStackFromNBT(nbtTags); - } + @Override + public Finder getFinder() { + return new MaterialFinder(getMaterial()); + } - @Override - public void write(ArrayList data) - { - data.add(2); - - super.write(data); + @Override + public void write(NBTTagCompound nbtTags) { + super.write(nbtTags); - data.add(MekanismUtils.getID(materialItem)); - data.add(materialItem.stackSize); - data.add(materialItem.getItemDamage()); - } + nbtTags.setInteger("type", 2); + materialItem.writeToNBT(nbtTags); + } - @Override - protected void read(ByteBuf dataStream) - { - super.read(dataStream); - - materialItem = new ItemStack(Item.getItemById(dataStream.readInt()), dataStream.readInt(), dataStream.readInt()); - } + @Override + protected void read(NBTTagCompound nbtTags) { + super.read(nbtTags); - @Override - public int hashCode() - { - int code = 1; - code = 31 * code + MekanismUtils.getID(materialItem); - code = 31 * code + materialItem.stackSize; - code = 31 * code + materialItem.getItemDamage(); - return code; - } + materialItem = ItemStack.loadItemStackFromNBT(nbtTags); + } - @Override - public boolean equals(Object filter) - { - return super.equals(filter) && filter instanceof TMaterialFilter && ((TMaterialFilter)filter).materialItem.isItemEqual(materialItem); - } + @Override + public void write(ArrayList data) { + data.add(2); - @Override - public TMaterialFilter clone() - { - TMaterialFilter filter = new TMaterialFilter(); - filter.materialItem = materialItem; + super.write(data); - return filter; - } + data.add(MekanismUtils.getID(materialItem)); + data.add(materialItem.stackSize); + data.add(materialItem.getItemDamage()); + } + + @Override + protected void read(ByteBuf dataStream) { + super.read(dataStream); + + materialItem = new ItemStack( + Item.getItemById(dataStream.readInt()), + dataStream.readInt(), + dataStream.readInt() + ); + } + + @Override + public int hashCode() { + int code = 1; + code = 31 * code + MekanismUtils.getID(materialItem); + code = 31 * code + materialItem.stackSize; + code = 31 * code + materialItem.getItemDamage(); + return code; + } + + @Override + public boolean equals(Object filter) { + return super.equals(filter) && filter instanceof TMaterialFilter + && ((TMaterialFilter) filter).materialItem.isItemEqual(materialItem); + } + + @Override + public TMaterialFilter clone() { + TMaterialFilter filter = new TMaterialFilter(); + filter.materialItem = materialItem; + + return filter; + } } diff --git a/src/main/java/mekanism/common/content/transporter/TModIDFilter.java b/src/main/java/mekanism/common/content/transporter/TModIDFilter.java index af23ece04..3c767fb21 100644 --- a/src/main/java/mekanism/common/content/transporter/TModIDFilter.java +++ b/src/main/java/mekanism/common/content/transporter/TModIDFilter.java @@ -1,92 +1,81 @@ package mekanism.common.content.transporter; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import io.netty.buffer.ByteBuf; import mekanism.common.PacketHandler; import mekanism.common.content.transporter.Finder.ModIDFinder; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -public class TModIDFilter extends TransporterFilter -{ - public String modID; +public class TModIDFilter extends TransporterFilter { + public String modID; - @Override - public boolean canFilter(ItemStack itemStack) - { - if(itemStack == null) - { - return false; - } + @Override + public boolean canFilter(ItemStack itemStack) { + if (itemStack == null) { + return false; + } - return new ModIDFinder(modID).modifies(itemStack); - } + return new ModIDFinder(modID).modifies(itemStack); + } - @Override - public Finder getFinder() - { - return new ModIDFinder(modID); - } + @Override + public Finder getFinder() { + return new ModIDFinder(modID); + } - @Override - public void write(NBTTagCompound nbtTags) - { - super.write(nbtTags); + @Override + public void write(NBTTagCompound nbtTags) { + super.write(nbtTags); - nbtTags.setInteger("type", 3); - nbtTags.setString("modID", modID); - } + nbtTags.setInteger("type", 3); + nbtTags.setString("modID", modID); + } - @Override - protected void read(NBTTagCompound nbtTags) - { - super.read(nbtTags); + @Override + protected void read(NBTTagCompound nbtTags) { + super.read(nbtTags); - modID = nbtTags.getString("modID"); - } + modID = nbtTags.getString("modID"); + } - @Override - public void write(ArrayList data) - { - data.add(3); + @Override + public void write(ArrayList data) { + data.add(3); - super.write(data); + super.write(data); - data.add(modID); - } + data.add(modID); + } - @Override - protected void read(ByteBuf dataStream) - { - super.read(dataStream); + @Override + protected void read(ByteBuf dataStream) { + super.read(dataStream); - modID = PacketHandler.readString(dataStream); - } + modID = PacketHandler.readString(dataStream); + } - @Override - public int hashCode() - { - int code = 1; - code = 31 * code + super.hashCode(); - code = 31 * code + modID.hashCode(); - return code; - } + @Override + public int hashCode() { + int code = 1; + code = 31 * code + super.hashCode(); + code = 31 * code + modID.hashCode(); + return code; + } - @Override - public boolean equals(Object filter) - { - return super.equals(filter) && filter instanceof TModIDFilter && ((TModIDFilter)filter).modID.equals(modID); - } + @Override + public boolean equals(Object filter) { + return super.equals(filter) && filter instanceof TModIDFilter + && ((TModIDFilter) filter).modID.equals(modID); + } - @Override - public TModIDFilter clone() - { - TModIDFilter filter = new TModIDFilter(); - filter.color = color; - filter.modID = modID; + @Override + public TModIDFilter clone() { + TModIDFilter filter = new TModIDFilter(); + filter.color = color; + filter.modID = modID; - return filter; - } + return filter; + } } diff --git a/src/main/java/mekanism/common/content/transporter/TOreDictFilter.java b/src/main/java/mekanism/common/content/transporter/TOreDictFilter.java index 0549b18ca..5f21e9fd4 100644 --- a/src/main/java/mekanism/common/content/transporter/TOreDictFilter.java +++ b/src/main/java/mekanism/common/content/transporter/TOreDictFilter.java @@ -1,92 +1,81 @@ package mekanism.common.content.transporter; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import io.netty.buffer.ByteBuf; import mekanism.common.PacketHandler; import mekanism.common.content.transporter.Finder.OreDictFinder; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -public class TOreDictFilter extends TransporterFilter -{ - public String oreDictName; +public class TOreDictFilter extends TransporterFilter { + public String oreDictName; - @Override - public boolean canFilter(ItemStack itemStack) - { - if(itemStack == null) - { - return false; - } + @Override + public boolean canFilter(ItemStack itemStack) { + if (itemStack == null) { + return false; + } - return new OreDictFinder(oreDictName).modifies(itemStack); - } + return new OreDictFinder(oreDictName).modifies(itemStack); + } - @Override - public Finder getFinder() - { - return new OreDictFinder(oreDictName); - } + @Override + public Finder getFinder() { + return new OreDictFinder(oreDictName); + } - @Override - public void write(NBTTagCompound nbtTags) - { - super.write(nbtTags); + @Override + public void write(NBTTagCompound nbtTags) { + super.write(nbtTags); - nbtTags.setInteger("type", 1); - nbtTags.setString("oreDictName", oreDictName); - } + nbtTags.setInteger("type", 1); + nbtTags.setString("oreDictName", oreDictName); + } - @Override - protected void read(NBTTagCompound nbtTags) - { - super.read(nbtTags); + @Override + protected void read(NBTTagCompound nbtTags) { + super.read(nbtTags); - oreDictName = nbtTags.getString("oreDictName"); - } + oreDictName = nbtTags.getString("oreDictName"); + } - @Override - public void write(ArrayList data) - { - data.add(1); + @Override + public void write(ArrayList data) { + data.add(1); - super.write(data); + super.write(data); - data.add(oreDictName); - } + data.add(oreDictName); + } - @Override - protected void read(ByteBuf dataStream) - { - super.read(dataStream); + @Override + protected void read(ByteBuf dataStream) { + super.read(dataStream); - oreDictName = PacketHandler.readString(dataStream); - } + oreDictName = PacketHandler.readString(dataStream); + } - @Override - public int hashCode() - { - int code = 1; - code = 31 * code + super.hashCode(); - code = 31 * code + oreDictName.hashCode(); - return code; - } + @Override + public int hashCode() { + int code = 1; + code = 31 * code + super.hashCode(); + code = 31 * code + oreDictName.hashCode(); + return code; + } - @Override - public boolean equals(Object filter) - { - return super.equals(filter) && filter instanceof TOreDictFilter && ((TOreDictFilter)filter).oreDictName.equals(oreDictName); - } + @Override + public boolean equals(Object filter) { + return super.equals(filter) && filter instanceof TOreDictFilter + && ((TOreDictFilter) filter).oreDictName.equals(oreDictName); + } - @Override - public TOreDictFilter clone() - { - TOreDictFilter filter = new TOreDictFilter(); - filter.color = color; - filter.oreDictName = oreDictName; + @Override + public TOreDictFilter clone() { + TOreDictFilter filter = new TOreDictFilter(); + filter.color = color; + filter.oreDictName = oreDictName; - return filter; - } + return filter; + } } diff --git a/src/main/java/mekanism/common/content/transporter/TransporterFilter.java b/src/main/java/mekanism/common/content/transporter/TransporterFilter.java index e91045972..249c5e34c 100644 --- a/src/main/java/mekanism/common/content/transporter/TransporterFilter.java +++ b/src/main/java/mekanism/common/content/transporter/TransporterFilter.java @@ -1,140 +1,110 @@ package mekanism.common.content.transporter; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import io.netty.buffer.ByteBuf; import mekanism.api.EnumColor; import mekanism.common.util.TransporterUtils; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -public abstract class TransporterFilter -{ - public static final int MAX_LENGTH = 24; - - public static final List SPECIAL_CHARS = Arrays.asList('*', '-', ' ', '|'); - - public EnumColor color; +public abstract class TransporterFilter { + public static final int MAX_LENGTH = 24; - public abstract boolean canFilter(ItemStack itemStack); + public static final List SPECIAL_CHARS = Arrays.asList('*', '-', ' ', '|'); - public abstract Finder getFinder(); + public EnumColor color; - public InvStack getStackFromInventory(StackSearcher searcher) - { - return searcher.takeTopStack(getFinder()); - } + public abstract boolean canFilter(ItemStack itemStack); - public void write(NBTTagCompound nbtTags) - { - if(color != null) - { - nbtTags.setInteger("color", TransporterUtils.colors.indexOf(color)); - } - } + public abstract Finder getFinder(); - protected void read(NBTTagCompound nbtTags) - { - if(nbtTags.hasKey("color")) - { - color = TransporterUtils.colors.get(nbtTags.getInteger("color")); - } - } + public InvStack getStackFromInventory(StackSearcher searcher) { + return searcher.takeTopStack(getFinder()); + } - public void write(ArrayList data) - { - if(color != null) - { - data.add(TransporterUtils.colors.indexOf(color)); - } - else { - data.add(-1); - } - } + public void write(NBTTagCompound nbtTags) { + if (color != null) { + nbtTags.setInteger("color", TransporterUtils.colors.indexOf(color)); + } + } - protected void read(ByteBuf dataStream) - { - int c = dataStream.readInt(); + protected void read(NBTTagCompound nbtTags) { + if (nbtTags.hasKey("color")) { + color = TransporterUtils.colors.get(nbtTags.getInteger("color")); + } + } - if(c != -1) - { - color = TransporterUtils.colors.get(c); - } - else { - color = null; - } - } + public void write(ArrayList data) { + if (color != null) { + data.add(TransporterUtils.colors.indexOf(color)); + } else { + data.add(-1); + } + } - public static TransporterFilter readFromNBT(NBTTagCompound nbtTags) - { - int type = nbtTags.getInteger("type"); + protected void read(ByteBuf dataStream) { + int c = dataStream.readInt(); - TransporterFilter filter = null; + if (c != -1) { + color = TransporterUtils.colors.get(c); + } else { + color = null; + } + } - if(type == 0) - { - filter = new TItemStackFilter(); - } - else if(type == 1) - { - filter = new TOreDictFilter(); - } - else if(type == 2) - { - filter = new TMaterialFilter(); - } - else if(type == 3) - { - filter = new TModIDFilter(); - } + public static TransporterFilter readFromNBT(NBTTagCompound nbtTags) { + int type = nbtTags.getInteger("type"); - filter.read(nbtTags); + TransporterFilter filter = null; - return filter; - } + if (type == 0) { + filter = new TItemStackFilter(); + } else if (type == 1) { + filter = new TOreDictFilter(); + } else if (type == 2) { + filter = new TMaterialFilter(); + } else if (type == 3) { + filter = new TModIDFilter(); + } - public static TransporterFilter readFromPacket(ByteBuf dataStream) - { - int type = dataStream.readInt(); + filter.read(nbtTags); - TransporterFilter filter = null; + return filter; + } - if(type == 0) - { - filter = new TItemStackFilter(); - } - else if(type == 1) - { - filter = new TOreDictFilter(); - } - else if(type == 2) - { - filter = new TMaterialFilter(); - } - else if(type == 3) - { - filter = new TModIDFilter(); - } + public static TransporterFilter readFromPacket(ByteBuf dataStream) { + int type = dataStream.readInt(); - filter.read(dataStream); + TransporterFilter filter = null; - return filter; - } + if (type == 0) { + filter = new TItemStackFilter(); + } else if (type == 1) { + filter = new TOreDictFilter(); + } else if (type == 2) { + filter = new TMaterialFilter(); + } else if (type == 3) { + filter = new TModIDFilter(); + } - @Override - public int hashCode() - { - int code = 1; - code = 31 * code + (color != null ? color.ordinal() : -1); - return code; - } + filter.read(dataStream); - @Override - public boolean equals(Object filter) - { - return filter instanceof TransporterFilter && ((TransporterFilter)filter).color == color; - } + return filter; + } + + @Override + public int hashCode() { + int code = 1; + code = 31 * code + (color != null ? color.ordinal() : -1); + return code; + } + + @Override + public boolean equals(Object filter) { + return filter instanceof TransporterFilter + && ((TransporterFilter) filter).color == color; + } } diff --git a/src/main/java/mekanism/common/content/transporter/TransporterManager.java b/src/main/java/mekanism/common/content/transporter/TransporterManager.java index eddcc7eb7..a77a6e4a4 100644 --- a/src/main/java/mekanism/common/content/transporter/TransporterManager.java +++ b/src/main/java/mekanism/common/content/transporter/TransporterManager.java @@ -7,6 +7,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import cpw.mods.fml.common.Loader; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.util.StackUtils; @@ -21,479 +22,456 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; import powercrystals.minefactoryreloaded.api.IDeepStorageUnit; -import cpw.mods.fml.common.Loader; -public class TransporterManager -{ - public static Map> flowingStacks = new HashMap>(); - - public static void reset() - { - flowingStacks.clear(); - } +public class TransporterManager { + public static Map> flowingStacks + = new HashMap>(); - public static void add(TransporterStack stack) - { - Set set = new HashSet(); - set.add(stack); - - if(flowingStacks.get(stack.getDest()) == null) - { - flowingStacks.put(stack.getDest(), set); - } - else { - flowingStacks.get(stack.getDest()).addAll(set); - } - } + public static void reset() { + flowingStacks.clear(); + } - public static void remove(TransporterStack stack) - { - if(stack.hasPath() && stack.pathType != Path.NONE) - { - flowingStacks.get(stack.getDest()).remove(stack); - } - } + public static void add(TransporterStack stack) { + Set set = new HashSet(); + set.add(stack); - public static List getStacksToDest(Coord4D dest) - { - List ret = new ArrayList(); + if (flowingStacks.get(stack.getDest()) == null) { + flowingStacks.put(stack.getDest(), set); + } else { + flowingStacks.get(stack.getDest()).addAll(set); + } + } - if(flowingStacks.containsKey(dest)) - { - for(TransporterStack stack : flowingStacks.get(dest)) - { - if(stack != null && stack.pathType != Path.NONE && stack.hasPath()) - { - if(stack.getDest().equals(dest)) - { - ret.add(stack); - } - } - } - } + public static void remove(TransporterStack stack) { + if (stack.hasPath() && stack.pathType != Path.NONE) { + flowingStacks.get(stack.getDest()).remove(stack); + } + } - return ret; - } + public static List getStacksToDest(Coord4D dest) { + List ret = new ArrayList(); - public static InventoryCopy copyInvFromSide(IInventory inv, int side) - { - inv = InventoryUtils.checkChestInv(inv); + if (flowingStacks.containsKey(dest)) { + for (TransporterStack stack : flowingStacks.get(dest)) { + if (stack != null && stack.pathType != Path.NONE && stack.hasPath()) { + if (stack.getDest().equals(dest)) { + ret.add(stack); + } + } + } + } - ItemStack[] ret = new ItemStack[inv.getSizeInventory()]; + return ret; + } - if(!(inv instanceof ISidedInventory)) - { - for(int i = 0; i <= inv.getSizeInventory() - 1; i++) - { - ret[i] = inv.getStackInSlot(i) != null ? inv.getStackInSlot(i).copy() : null; - } - } - else { - ISidedInventory sidedInventory = (ISidedInventory)inv; - int[] slots = sidedInventory.getAccessibleSlotsFromSide(ForgeDirection.getOrientation(side).getOpposite().ordinal()); + public static InventoryCopy copyInvFromSide(IInventory inv, int side) { + inv = InventoryUtils.checkChestInv(inv); - if(slots == null || slots.length == 0) - { - return null; - } + ItemStack[] ret = new ItemStack[inv.getSizeInventory()]; - for(int get = 0; get <= slots.length - 1; get++) - { - int slotID = slots[get]; + if (!(inv instanceof ISidedInventory)) { + for (int i = 0; i <= inv.getSizeInventory() - 1; i++) { + ret[i] + = inv.getStackInSlot(i) != null ? inv.getStackInSlot(i).copy() : null; + } + } else { + ISidedInventory sidedInventory = (ISidedInventory) inv; + int[] slots = sidedInventory.getAccessibleSlotsFromSide( + ForgeDirection.getOrientation(side).getOpposite().ordinal() + ); - ret[slotID] = sidedInventory.getStackInSlot(slotID) != null ? sidedInventory.getStackInSlot(slotID).copy() : null; - } - - if(inv instanceof TileEntityBin) - { - return new InventoryCopy(ret, ((TileEntityBin)inv).getItemCount()); - } - else { - return new InventoryCopy(ret); - } - } + if (slots == null || slots.length == 0) { + return null; + } - return new InventoryCopy(ret); - } + for (int get = 0; get <= slots.length - 1; get++) { + int slotID = slots[get]; - public static void testInsert(IInventory inv, InventoryCopy copy, int side, TransporterStack stack) - { - ItemStack toInsert = stack.itemStack.copy(); + ret[slotID] = sidedInventory.getStackInSlot(slotID) != null + ? sidedInventory.getStackInSlot(slotID).copy() + : null; + } - if(stack.pathType != Path.HOME && inv instanceof ISideConfiguration) - { - ISideConfiguration config = (ISideConfiguration)inv; - int tileSide = config.getOrientation(); - EnumColor configColor = config.getEjector().getInputColor(ForgeDirection.getOrientation(MekanismUtils.getBaseOrientation(side, tileSide)).getOpposite()); + if (inv instanceof TileEntityBin) { + return new InventoryCopy(ret, ((TileEntityBin) inv).getItemCount()); + } else { + return new InventoryCopy(ret); + } + } - if(config.getEjector().hasStrictInput() && configColor != null && configColor != stack.color) - { - return; - } - } - - if(Loader.isModLoaded("MinefactoryReloaded") && inv instanceof IDeepStorageUnit && !(inv instanceof TileEntityBin)) - { - return; - } + return new InventoryCopy(ret); + } - if(!(inv instanceof ISidedInventory)) - { - for(int i = 0; i <= inv.getSizeInventory() - 1; i++) - { - if(stack.pathType != Path.HOME) - { - if(!inv.isItemValidForSlot(i, toInsert)) - { - continue; - } - } + public static void + testInsert(IInventory inv, InventoryCopy copy, int side, TransporterStack stack) { + ItemStack toInsert = stack.itemStack.copy(); - ItemStack inSlot = copy.inventory[i]; + if (stack.pathType != Path.HOME && inv instanceof ISideConfiguration) { + ISideConfiguration config = (ISideConfiguration) inv; + int tileSide = config.getOrientation(); + EnumColor configColor = config.getEjector().getInputColor( + ForgeDirection + .getOrientation(MekanismUtils.getBaseOrientation(side, tileSide)) + .getOpposite() + ); - if(inSlot == null) - { - if(toInsert.stackSize <= inv.getInventoryStackLimit()) - { - copy.inventory[i] = toInsert; - return; - } - else { - int rejects = toInsert.stackSize - inv.getInventoryStackLimit(); - - ItemStack toSet = toInsert.copy(); - toSet.stackSize = inv.getInventoryStackLimit(); + if (config.getEjector().hasStrictInput() && configColor != null + && configColor != stack.color) { + return; + } + } - ItemStack remains = toInsert.copy(); - remains.stackSize = rejects; + if (Loader.isModLoaded("MinefactoryReloaded") && inv instanceof IDeepStorageUnit + && !(inv instanceof TileEntityBin)) { + return; + } - copy.inventory[i] = toSet; + if (!(inv instanceof ISidedInventory)) { + for (int i = 0; i <= inv.getSizeInventory() - 1; i++) { + if (stack.pathType != Path.HOME) { + if (!inv.isItemValidForSlot(i, toInsert)) { + continue; + } + } - toInsert = remains; - } - } + ItemStack inSlot = copy.inventory[i]; + + if (inSlot == null) { + if (toInsert.stackSize <= inv.getInventoryStackLimit()) { + copy.inventory[i] = toInsert; + return; + } else { + int rejects = toInsert.stackSize - inv.getInventoryStackLimit(); + + ItemStack toSet = toInsert.copy(); + toSet.stackSize = inv.getInventoryStackLimit(); + + ItemStack remains = toInsert.copy(); + remains.stackSize = rejects; + + copy.inventory[i] = toSet; + + toInsert = remains; + } + } else if(InventoryUtils.areItemsStackable(toInsert, inSlot) && inSlot.stackSize < Math.min(inSlot.getMaxStackSize(), inv.getInventoryStackLimit())) { - int max = Math.min(inSlot.getMaxStackSize(), inv.getInventoryStackLimit()); - - if(inSlot.stackSize + toInsert.stackSize <= max) - { - ItemStack toSet = toInsert.copy(); - toSet.stackSize += inSlot.stackSize; + int max = Math.min( + inSlot.getMaxStackSize(), inv.getInventoryStackLimit() + ); - copy.inventory[i] = toSet; - return; - } - else { - int rejects = (inSlot.stackSize + toInsert.stackSize) - max; + if (inSlot.stackSize + toInsert.stackSize <= max) { + ItemStack toSet = toInsert.copy(); + toSet.stackSize += inSlot.stackSize; - ItemStack toSet = toInsert.copy(); - toSet.stackSize = max; + copy.inventory[i] = toSet; + return; + } else { + int rejects = (inSlot.stackSize + toInsert.stackSize) - max; - ItemStack remains = toInsert.copy(); - remains.stackSize = rejects; + ItemStack toSet = toInsert.copy(); + toSet.stackSize = max; - copy.inventory[i] = toSet; + ItemStack remains = toInsert.copy(); + remains.stackSize = rejects; - toInsert = remains; - } - } - } - } - else { - ISidedInventory sidedInventory = (ISidedInventory)inv; - int[] slots = sidedInventory.getAccessibleSlotsFromSide(ForgeDirection.getOrientation(side).getOpposite().ordinal()); + copy.inventory[i] = toSet; - if(slots != null && slots.length != 0) - { - if(stack.pathType != Path.HOME && sidedInventory instanceof TileEntityBin && ForgeDirection.getOrientation(side).getOpposite().ordinal() == 0) - { - slots = sidedInventory.getAccessibleSlotsFromSide(1); - } + toInsert = remains; + } + } + } + } else { + ISidedInventory sidedInventory = (ISidedInventory) inv; + int[] slots = sidedInventory.getAccessibleSlotsFromSide( + ForgeDirection.getOrientation(side).getOpposite().ordinal() + ); - if(inv instanceof TileEntityBin) - { - int slot = slots[0]; - - if(!sidedInventory.isItemValidForSlot(slot, toInsert) || !sidedInventory.canInsertItem(slot, toInsert, ForgeDirection.getOrientation(side).getOpposite().ordinal())) - { - return; - } - - int amountRemaining = ((TileEntityBin)inv).getMaxStoredCount()-copy.binAmount; - copy.binAmount += Math.min(amountRemaining, toInsert.stackSize); - - return; - } - else { - for(int get = 0; get <= slots.length - 1; get++) - { - int slotID = slots[get]; - - if(stack.pathType != Path.HOME) - { - if(!sidedInventory.isItemValidForSlot(slotID, toInsert) || !sidedInventory.canInsertItem(slotID, toInsert, ForgeDirection.getOrientation(side).getOpposite().ordinal())) - { - continue; - } - } - - ItemStack inSlot = copy.inventory[slotID]; - - if(inSlot == null) - { - if(toInsert.stackSize <= inv.getInventoryStackLimit()) - { - copy.inventory[slotID] = toInsert; - return; - } - else { - int rejects = toInsert.stackSize - inv.getInventoryStackLimit(); - - ItemStack toSet = toInsert.copy(); - toSet.stackSize = inv.getInventoryStackLimit(); + if (slots != null && slots.length != 0) { + if (stack.pathType != Path.HOME && sidedInventory instanceof TileEntityBin + && ForgeDirection.getOrientation(side).getOpposite().ordinal() == 0) { + slots = sidedInventory.getAccessibleSlotsFromSide(1); + } - ItemStack remains = toInsert.copy(); - remains.stackSize = rejects; + if (inv instanceof TileEntityBin) { + int slot = slots[0]; - copy.inventory[slotID] = toSet; + if (!sidedInventory.isItemValidForSlot(slot, toInsert) + || !sidedInventory.canInsertItem( + slot, + toInsert, + ForgeDirection.getOrientation(side).getOpposite().ordinal() + )) { + return; + } - toInsert = remains; - } - } + int amountRemaining + = ((TileEntityBin) inv).getMaxStoredCount() - copy.binAmount; + copy.binAmount += Math.min(amountRemaining, toInsert.stackSize); + + return; + } else { + for (int get = 0; get <= slots.length - 1; get++) { + int slotID = slots[get]; + + if (stack.pathType != Path.HOME) { + if (!sidedInventory.isItemValidForSlot(slotID, toInsert) + || !sidedInventory.canInsertItem( + slotID, + toInsert, + ForgeDirection.getOrientation(side) + .getOpposite() + .ordinal() + )) { + continue; + } + } + + ItemStack inSlot = copy.inventory[slotID]; + + if (inSlot == null) { + if (toInsert.stackSize <= inv.getInventoryStackLimit()) { + copy.inventory[slotID] = toInsert; + return; + } else { + int rejects + = toInsert.stackSize - inv.getInventoryStackLimit(); + + ItemStack toSet = toInsert.copy(); + toSet.stackSize = inv.getInventoryStackLimit(); + + ItemStack remains = toInsert.copy(); + remains.stackSize = rejects; + + copy.inventory[slotID] = toSet; + + toInsert = remains; + } + } else if(InventoryUtils.areItemsStackable(toInsert, inSlot) && inSlot.stackSize < Math.min(inSlot.getMaxStackSize(), inv.getInventoryStackLimit())) { - int max = Math.min(inSlot.getMaxStackSize(), inv.getInventoryStackLimit()); - - if(inSlot.stackSize + toInsert.stackSize <= max) - { - ItemStack toSet = toInsert.copy(); - toSet.stackSize += inSlot.stackSize; - - copy.inventory[slotID] = toSet; - return; - } - else { - int rejects = (inSlot.stackSize + toInsert.stackSize) - max; - - ItemStack toSet = toInsert.copy(); - toSet.stackSize = max; - - ItemStack remains = toInsert.copy(); - remains.stackSize = rejects; - - copy.inventory[slotID] = toSet; - - toInsert = remains; - } - } - } - } - } - } - } + int max = Math.min( + inSlot.getMaxStackSize(), inv.getInventoryStackLimit() + ); - public static boolean didEmit(ItemStack stack, ItemStack returned) - { - return returned == null || returned.stackSize < stack.stackSize; - } + if (inSlot.stackSize + toInsert.stackSize <= max) { + ItemStack toSet = toInsert.copy(); + toSet.stackSize += inSlot.stackSize; - public static ItemStack getToUse(ItemStack stack, ItemStack returned) - { - if(returned == null || returned.stackSize == 0) - { - return stack; - } + copy.inventory[slotID] = toSet; + return; + } else { + int rejects + = (inSlot.stackSize + toInsert.stackSize) - max; - return MekanismUtils.size(stack, stack.stackSize-returned.stackSize); - } + ItemStack toSet = toInsert.copy(); + toSet.stackSize = max; - /** - * @return rejects - */ - public static ItemStack getPredictedInsert(TileEntity tileEntity, EnumColor color, ItemStack itemStack, int side) - { - if(!(tileEntity instanceof IInventory)) - { - return itemStack; - } + ItemStack remains = toInsert.copy(); + remains.stackSize = rejects; - if(tileEntity instanceof ISideConfiguration) - { - ISideConfiguration config = (ISideConfiguration)tileEntity; - int tileSide = config.getOrientation(); - EnumColor configColor = config.getEjector().getInputColor(ForgeDirection.getOrientation(MekanismUtils.getBaseOrientation(side, tileSide)).getOpposite()); + copy.inventory[slotID] = toSet; - if(config.getEjector().hasStrictInput() && configColor != null && configColor != color) - { - return itemStack; - } - } + toInsert = remains; + } + } + } + } + } + } + } - IInventory inventory = (IInventory)tileEntity; - InventoryCopy copy = copyInvFromSide(inventory, side); + public static boolean didEmit(ItemStack stack, ItemStack returned) { + return returned == null || returned.stackSize < stack.stackSize; + } - if(copy == null) - { - return itemStack; - } + public static ItemStack getToUse(ItemStack stack, ItemStack returned) { + if (returned == null || returned.stackSize == 0) { + return stack; + } - List insertQueue = getStacksToDest(Coord4D.get(tileEntity)); + return MekanismUtils.size(stack, stack.stackSize - returned.stackSize); + } - for(TransporterStack tStack : insertQueue) - { - testInsert(inventory, copy, side, tStack); - } + /** + * @return rejects + */ + public static ItemStack getPredictedInsert( + TileEntity tileEntity, EnumColor color, ItemStack itemStack, int side + ) { + if (!(tileEntity instanceof IInventory)) { + return itemStack; + } - ItemStack toInsert = itemStack.copy(); + if (tileEntity instanceof ISideConfiguration) { + ISideConfiguration config = (ISideConfiguration) tileEntity; + int tileSide = config.getOrientation(); + EnumColor configColor = config.getEjector().getInputColor( + ForgeDirection + .getOrientation(MekanismUtils.getBaseOrientation(side, tileSide)) + .getOpposite() + ); - if(!(inventory instanceof ISidedInventory)) - { - inventory = InventoryUtils.checkChestInv(inventory); + if (config.getEjector().hasStrictInput() && configColor != null + && configColor != color) { + return itemStack; + } + } - for(int i = 0; i <= inventory.getSizeInventory() - 1; i++) - { - if(!inventory.isItemValidForSlot(i, toInsert)) - { - continue; - } + IInventory inventory = (IInventory) tileEntity; + InventoryCopy copy = copyInvFromSide(inventory, side); - ItemStack inSlot = copy.inventory[i]; + if (copy == null) { + return itemStack; + } - if(toInsert == null) - { - return null; - } - else if(inSlot == null) - { - if(toInsert.stackSize <= inventory.getInventoryStackLimit()) - { - return null; - } - else { - int rejects = toInsert.stackSize - inventory.getInventoryStackLimit(); - - if(rejects < toInsert.stackSize) - { - toInsert = StackUtils.size(toInsert, rejects); - } - } - } + List insertQueue = getStacksToDest(Coord4D.get(tileEntity)); + + for (TransporterStack tStack : insertQueue) { + testInsert(inventory, copy, side, tStack); + } + + ItemStack toInsert = itemStack.copy(); + + if (!(inventory instanceof ISidedInventory)) { + inventory = InventoryUtils.checkChestInv(inventory); + + for (int i = 0; i <= inventory.getSizeInventory() - 1; i++) { + if (!inventory.isItemValidForSlot(i, toInsert)) { + continue; + } + + ItemStack inSlot = copy.inventory[i]; + + if (toInsert == null) { + return null; + } else if (inSlot == null) { + if (toInsert.stackSize <= inventory.getInventoryStackLimit()) { + return null; + } else { + int rejects + = toInsert.stackSize - inventory.getInventoryStackLimit(); + + if (rejects < toInsert.stackSize) { + toInsert = StackUtils.size(toInsert, rejects); + } + } + } else if(InventoryUtils.areItemsStackable(toInsert, inSlot) && inSlot.stackSize < Math.min(inSlot.getMaxStackSize(), inventory.getInventoryStackLimit())) { - int max = Math.min(inSlot.getMaxStackSize(), inventory.getInventoryStackLimit()); - - if(inSlot.stackSize + toInsert.stackSize <= max) - { - return null; - } - else { - int rejects = (inSlot.stackSize + toInsert.stackSize) - max; + int max = Math.min( + inSlot.getMaxStackSize(), inventory.getInventoryStackLimit() + ); - if(rejects < toInsert.stackSize) - { - toInsert = StackUtils.size(toInsert, rejects); - } - } - } - } - } - else { - ISidedInventory sidedInventory = (ISidedInventory)inventory; - int[] slots = sidedInventory.getAccessibleSlotsFromSide(ForgeDirection.getOrientation(side).getOpposite().ordinal()); + if (inSlot.stackSize + toInsert.stackSize <= max) { + return null; + } else { + int rejects = (inSlot.stackSize + toInsert.stackSize) - max; - if(slots != null && slots.length != 0) - { - if(inventory instanceof TileEntityBin) - { - int slot = slots[0]; - - if(!sidedInventory.isItemValidForSlot(slot, toInsert) || !sidedInventory.canInsertItem(slot, toInsert, ForgeDirection.getOrientation(side).getOpposite().ordinal())) - { - return toInsert; - } - - int amountRemaining = ((TileEntityBin)inventory).getMaxStoredCount()-copy.binAmount; - - if(toInsert.stackSize <= amountRemaining) - { - return null; - } - else { - return StackUtils.size(toInsert, toInsert.stackSize-amountRemaining); - } - } - else { - for(int get = 0; get <= slots.length - 1; get++) - { - int slotID = slots[get]; - - if(!sidedInventory.isItemValidForSlot(slotID, toInsert) || !sidedInventory.canInsertItem(slotID, toInsert, ForgeDirection.getOrientation(side).getOpposite().ordinal())) - { - continue; - } - - ItemStack inSlot = copy.inventory[slotID]; - - if(toInsert == null) - { - return null; - } - else if(inSlot == null) - { - if(toInsert.stackSize <= inventory.getInventoryStackLimit()) - { - return null; - } - else { - int rejects = toInsert.stackSize - inventory.getInventoryStackLimit(); - - if(rejects < toInsert.stackSize) - { - toInsert = StackUtils.size(toInsert, rejects); - } - } - } + if (rejects < toInsert.stackSize) { + toInsert = StackUtils.size(toInsert, rejects); + } + } + } + } + } else { + ISidedInventory sidedInventory = (ISidedInventory) inventory; + int[] slots = sidedInventory.getAccessibleSlotsFromSide( + ForgeDirection.getOrientation(side).getOpposite().ordinal() + ); + + if (slots != null && slots.length != 0) { + if (inventory instanceof TileEntityBin) { + int slot = slots[0]; + + if (!sidedInventory.isItemValidForSlot(slot, toInsert) + || !sidedInventory.canInsertItem( + slot, + toInsert, + ForgeDirection.getOrientation(side).getOpposite().ordinal() + )) { + return toInsert; + } + + int amountRemaining = ((TileEntityBin) inventory).getMaxStoredCount() + - copy.binAmount; + + if (toInsert.stackSize <= amountRemaining) { + return null; + } else { + return StackUtils.size( + toInsert, toInsert.stackSize - amountRemaining + ); + } + } else { + for (int get = 0; get <= slots.length - 1; get++) { + int slotID = slots[get]; + + if (!sidedInventory.isItemValidForSlot(slotID, toInsert) + || !sidedInventory.canInsertItem( + slotID, + toInsert, + ForgeDirection.getOrientation(side).getOpposite().ordinal( + ) + )) { + continue; + } + + ItemStack inSlot = copy.inventory[slotID]; + + if (toInsert == null) { + return null; + } else if (inSlot == null) { + if (toInsert.stackSize + <= inventory.getInventoryStackLimit()) { + return null; + } else { + int rejects = toInsert.stackSize + - inventory.getInventoryStackLimit(); + + if (rejects < toInsert.stackSize) { + toInsert = StackUtils.size(toInsert, rejects); + } + } + } else if(InventoryUtils.areItemsStackable(toInsert, inSlot) && inSlot.stackSize < Math.min(inSlot.getMaxStackSize(), inventory.getInventoryStackLimit())) { - int max = Math.min(inSlot.getMaxStackSize(), inventory.getInventoryStackLimit()); - - if(inSlot.stackSize + toInsert.stackSize <= max) - { - return null; - } - else { - int rejects = (inSlot.stackSize + toInsert.stackSize) - max; - - if(rejects < toInsert.stackSize) - { - toInsert = StackUtils.size(toInsert, rejects); - } - } - } - } - } - } - } + int max = Math.min( + inSlot.getMaxStackSize(), + inventory.getInventoryStackLimit() + ); - return toInsert; - } - - public static class InventoryCopy - { - public ItemStack[] inventory; - - public int binAmount; - - public InventoryCopy(ItemStack[] inv) - { - inventory = inv; - } - - public InventoryCopy(ItemStack[] inv, int amount) - { - this(inv); - binAmount = amount; - } - } + if (inSlot.stackSize + toInsert.stackSize <= max) { + return null; + } else { + int rejects + = (inSlot.stackSize + toInsert.stackSize) - max; + + if (rejects < toInsert.stackSize) { + toInsert = StackUtils.size(toInsert, rejects); + } + } + } + } + } + } + } + + return toInsert; + } + + public static class InventoryCopy { + public ItemStack[] inventory; + + public int binAmount; + + public InventoryCopy(ItemStack[] inv) { + inventory = inv; + } + + public InventoryCopy(ItemStack[] inv, int amount) { + this(inv); + binAmount = amount; + } + } } diff --git a/src/main/java/mekanism/common/content/transporter/TransporterPathfinder.java b/src/main/java/mekanism/common/content/transporter/TransporterPathfinder.java index aa24bf12e..762487845 100644 --- a/src/main/java/mekanism/common/content/transporter/TransporterPathfinder.java +++ b/src/main/java/mekanism/common/content/transporter/TransporterPathfinder.java @@ -23,559 +23,538 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; - import org.apache.commons.lang3.tuple.Pair; -public final class TransporterPathfinder -{ - public static class IdlePath - { - public World worldObj; +public final class TransporterPathfinder { + public static class IdlePath { + public World worldObj; - public Coord4D start; + public Coord4D start; - public TransporterStack transportStack; + public TransporterStack transportStack; - public IdlePath(World world, Coord4D obj, TransporterStack stack) - { - worldObj = world; - start = obj; - transportStack = stack; - } + public IdlePath(World world, Coord4D obj, TransporterStack stack) { + worldObj = world; + start = obj; + transportStack = stack; + } - public Destination find() - { - ArrayList ret = new ArrayList(); - ret.add(start); - - if(transportStack.idleDir == ForgeDirection.UNKNOWN) - { - ForgeDirection newSide = findSide(); - - if(newSide == null) - { - return null; - } - - transportStack.idleDir = newSide; - loopSide(ret, newSide); - - return new Destination(ret, true, null, 0).setPathType(Path.NONE); - } - else { - TileEntity tile = start.getFromSide(transportStack.idleDir).getTileEntity(worldObj); - - if(transportStack.canInsertToTransporter(tile, transportStack.idleDir)) - { - loopSide(ret, transportStack.idleDir); - - return new Destination(ret, true, null, 0).setPathType(Path.NONE); - } - else { - Destination newPath = TransporterPathfinder.getNewBasePath(((ITransporterTile)start.getTileEntity(worldObj)).getTransmitter(), transportStack, 0); - - if(newPath != null && TransporterManager.didEmit(transportStack.itemStack, newPath.rejected)) - { - transportStack.idleDir = ForgeDirection.UNKNOWN; - newPath.setPathType(Path.DEST); - - return newPath; - } - else { - ForgeDirection newSide = findSide(); - - if(newSide == null) - { - return null; - } - - transportStack.idleDir = newSide; - loopSide(ret, newSide); - - return new Destination(ret, true, null, 0).setPathType(Path.NONE); - } - } - } - } - - private void loopSide(List list, ForgeDirection side) - { - int count = 1; - - while(true) - { - Coord4D coord = start.getFromSide(side, count); - - if(transportStack.canInsertToTransporter(coord.getTileEntity(worldObj), side)) - { - list.add(coord); - count++; - } - else { - break; - } - } - } - - private ForgeDirection findSide() - { - if(transportStack.idleDir == ForgeDirection.UNKNOWN) - { - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - TileEntity tile = start.getFromSide(side).getTileEntity(worldObj); - - if(transportStack.canInsertToTransporter(tile, side)) - { - return side; - } - } - } - else { - for(ForgeDirection side : EnumSet.complementOf(EnumSet.of(ForgeDirection.UNKNOWN, transportStack.idleDir.getOpposite()))) - { - TileEntity tile = start.getFromSide(side).getTileEntity(worldObj); - - if(transportStack.canInsertToTransporter(tile, side)) - { - return side; - } - } - - TileEntity tile = start.getFromSide(transportStack.idleDir.getOpposite()).getTileEntity(worldObj); - - if(transportStack.canInsertToTransporter(tile, transportStack.idleDir.getOpposite())) - { - return transportStack.idleDir.getOpposite(); - } - } - - return null; - } - } + public Destination find() { + ArrayList ret = new ArrayList(); + ret.add(start); - public static class Destination implements Comparable - { - public List path; - public Path pathType; - public ItemStack rejected; - public double score; + if (transportStack.idleDir == ForgeDirection.UNKNOWN) { + ForgeDirection newSide = findSide(); - public Destination(List list, boolean inv, ItemStack rejects, double gScore) - { - path = new ArrayList<>(list); + if (newSide == null) { + return null; + } - if(inv) - { - Collections.reverse(path); - } + transportStack.idleDir = newSide; + loopSide(ret, newSide); - rejected = rejects; - score = gScore; - } - - public Destination setPathType(Path type) - { - pathType = type; - return this; - } + return new Destination(ret, true, null, 0).setPathType(Path.NONE); + } else { + TileEntity tile + = start.getFromSide(transportStack.idleDir).getTileEntity(worldObj); - public Destination calculateScore(World world) - { - score = 0; - - for(Coord4D location : path) - { - TileEntity tile = location.getTileEntity(world); - - if(tile instanceof ITransporterTile) - { - score += ((ITransporterTile)tile).getTransmitter().getCost(); - } - } - - return this; - } + if (transportStack.canInsertToTransporter(tile, transportStack.idleDir)) { + loopSide(ret, transportStack.idleDir); - @Override - public int hashCode() - { - int code = 1; - code = 31 * code + path.hashCode(); - return code; - } + return new Destination(ret, true, null, 0).setPathType(Path.NONE); + } else { + Destination newPath = TransporterPathfinder.getNewBasePath( + ((ITransporterTile) start.getTileEntity(worldObj)) + .getTransmitter(), + transportStack, + 0 + ); - @Override - public boolean equals(Object dest) - { - return dest instanceof Destination && ((Destination)dest).path.equals(path); - } + if (newPath != null + && TransporterManager.didEmit( + transportStack.itemStack, newPath.rejected + )) { + transportStack.idleDir = ForgeDirection.UNKNOWN; + newPath.setPathType(Path.DEST); - @Override - public int compareTo(Destination dest) - { - if(score < dest.score) - { - return -1; - } - else if(score > dest.score) - { - return 1; - } - else { - return path.size() - dest.path.size(); - } - } - } + return newPath; + } else { + ForgeDirection newSide = findSide(); - public static List getPaths(ILogisticalTransporter start, TransporterStack stack, int min) - { - List paths = new ArrayList(); - InventoryNetwork network = start.getTransmitterNetwork(); - - if(network == null) - { - return paths; - } - - List acceptors = network.calculateAcceptors(stack.itemStack, stack.color); + if (newSide == null) { + return null; + } - for(AcceptorData entry : acceptors) - { - DestChecker checker = new DestChecker() - { - @Override - public boolean isValid(TransporterStack stack, int dir, TileEntity tile) - { - return InventoryUtils.canInsert(tile, stack.color, stack.itemStack, dir, false); - } - }; - - Destination d = getPath(checker, entry.sides, start, entry.location, stack, entry.rejected, min); - - if(d != null) - { - paths.add(d); - } - } + transportStack.idleDir = newSide; + loopSide(ret, newSide); - Collections.sort(paths); + return new Destination(ret, true, null, 0).setPathType(Path.NONE); + } + } + } + } - return paths; - } - - public static boolean checkPath(World world, List path, TransporterStack stack) - { - for(int i = path.size()-1; i > 0; i--) - { - TileEntity tile = path.get(i).getTileEntity(world); - - if(!(tile instanceof ITransporterTile)) - { - return false; - } - - ITransporterTile transporterTile = (ITransporterTile)tile; - - if(transporterTile.getTransmitter() == null || (transporterTile.getTransmitter().getColor() != null && transporterTile.getTransmitter().getColor() != stack.color)) - { - return false; - } - } - - return true; - } - - public static Destination getPath(DestChecker checker, EnumSet sides, ILogisticalTransporter start, Coord4D dest, TransporterStack stack, ItemStack rejects, int min) - { - List test = PathfinderCache.getCache(start.coord(), dest, sides); - - if(test != null && checkPath(start.world(), test, stack)) - { - return new Destination(test, false, rejects, 0).calculateScore(start.world()); - } - - Pathfinder p = new Pathfinder(checker, start.world(), dest, start.coord(), stack); - - if(p.getPath().size() >= 2) - { - if(TransporterManager.getToUse(stack.itemStack, rejects).stackSize >= min) - { - PathfinderCache.cachedPaths.put(new PathData(start.coord(), dest, p.side), p.getPath()); - - return new Destination(p.getPath(), false, rejects, p.finalScore); - } - } - - return null; - } - - public static Destination getNewBasePath(ILogisticalTransporter start, TransporterStack stack, int min) - { - List paths = getPaths(start, stack, min); + private void loopSide(List list, ForgeDirection side) { + int count = 1; - if(paths.isEmpty()) - { - return null; - } - - return paths.get(0); - } + while (true) { + Coord4D coord = start.getFromSide(side, count); - public static Destination getNewRRPath(ILogisticalTransporter start, TransporterStack stack, TileEntityLogisticalSorter outputter, int min) - { - List paths = getPaths(start, stack, min); + if (transportStack.canInsertToTransporter( + coord.getTileEntity(worldObj), side + )) { + list.add(coord); + count++; + } else { + break; + } + } + } - Map destPaths = new HashMap(); + private ForgeDirection findSide() { + if (transportStack.idleDir == ForgeDirection.UNKNOWN) { + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + TileEntity tile = start.getFromSide(side).getTileEntity(worldObj); - for(Destination d : paths) - { - if(destPaths.get(d.path.get(0)) == null || destPaths.get(d.path.get(0)).path.size() < d.path.size()) - { - destPaths.put(d.path.get(0), d); - } - } + if (transportStack.canInsertToTransporter(tile, side)) { + return side; + } + } + } else { + for (ForgeDirection side : EnumSet.complementOf(EnumSet.of( + ForgeDirection.UNKNOWN, transportStack.idleDir.getOpposite() + ))) { + TileEntity tile = start.getFromSide(side).getTileEntity(worldObj); - List dests = new ArrayList(); - dests.addAll(destPaths.values()); + if (transportStack.canInsertToTransporter(tile, side)) { + return side; + } + } - Collections.sort(dests); + TileEntity tile = start.getFromSide(transportStack.idleDir.getOpposite()) + .getTileEntity(worldObj); - Destination closest = null; + if (transportStack.canInsertToTransporter( + tile, transportStack.idleDir.getOpposite() + )) { + return transportStack.idleDir.getOpposite(); + } + } - if(!dests.isEmpty()) - { - if(outputter.rrIndex <= dests.size()-1) - { - closest = dests.get(outputter.rrIndex); + return null; + } + } - if(outputter.rrIndex == dests.size()-1) - { - outputter.rrIndex = 0; - } - else if(outputter.rrIndex < dests.size()-1) - { - outputter.rrIndex++; - } - } - else { - closest = dests.get(dests.size()-1); - outputter.rrIndex = 0; - } - } + public static class Destination implements Comparable { + public List path; + public Path pathType; + public ItemStack rejected; + public double score; - if(closest == null) - { - return null; - } + public Destination( + List list, boolean inv, ItemStack rejects, double gScore + ) { + path = new ArrayList<>(list); - return closest; - } + if (inv) { + Collections.reverse(path); + } - public static class Pathfinder - { - public final Set openSet, closedSet; + rejected = rejects; + score = gScore; + } - public final HashMap navMap; + public Destination setPathType(Path type) { + pathType = type; + return this; + } - public final HashMap gScore, fScore; + public Destination calculateScore(World world) { + score = 0; - public final Coord4D start; + for (Coord4D location : path) { + TileEntity tile = location.getTileEntity(world); - public final Coord4D finalNode; + if (tile instanceof ITransporterTile) { + score += ((ITransporterTile) tile).getTransmitter().getCost(); + } + } - public final TransporterStack transportStack; + return this; + } - public final DestChecker destChecker; + @Override + public int hashCode() { + int code = 1; + code = 31 * code + path.hashCode(); + return code; + } - public double finalScore; - - public ForgeDirection side; + @Override + public boolean equals(Object dest) { + return dest instanceof Destination && ((Destination) dest).path.equals(path); + } - public ArrayList results; + @Override + public int compareTo(Destination dest) { + if (score < dest.score) { + return -1; + } else if (score > dest.score) { + return 1; + } else { + return path.size() - dest.path.size(); + } + } + } - private World worldObj; + public static List + getPaths(ILogisticalTransporter start, TransporterStack stack, int min) { + List paths = new ArrayList(); + InventoryNetwork network = start.getTransmitterNetwork(); - public Pathfinder(DestChecker checker, World world, Coord4D finishObj, Coord4D startObj, TransporterStack stack) - { - destChecker = checker; - worldObj = world; + if (network == null) { + return paths; + } - finalNode = finishObj; - start = startObj; + List acceptors + = network.calculateAcceptors(stack.itemStack, stack.color); - transportStack = stack; + for (AcceptorData entry : acceptors) { + DestChecker checker = new DestChecker() { + @Override + public boolean isValid(TransporterStack stack, int dir, TileEntity tile) { + return InventoryUtils.canInsert( + tile, stack.color, stack.itemStack, dir, false + ); + } + }; - openSet = new HashSet(); - closedSet = new HashSet(); + Destination d = getPath( + checker, entry.sides, start, entry.location, stack, entry.rejected, min + ); - navMap = new HashMap(); + if (d != null) { + paths.add(d); + } + } - gScore = new HashMap(); - fScore = new HashMap(); + Collections.sort(paths); - results = new ArrayList(); + return paths; + } - find(start); - } + public static boolean + checkPath(World world, List path, TransporterStack stack) { + for (int i = path.size() - 1; i > 0; i--) { + TileEntity tile = path.get(i).getTileEntity(world); - public boolean find(Coord4D start) - { - openSet.add(start); - gScore.put(start, 0D); - fScore.put(start, gScore.get(start) + getEstimate(start, finalNode)); + if (!(tile instanceof ITransporterTile)) { + return false; + } - int blockCount = 0; + ITransporterTile transporterTile = (ITransporterTile) tile; - for(int i = 0; i < 6; i++) - { - ForgeDirection direction = ForgeDirection.getOrientation(i); - Coord4D neighbor = start.getFromSide(direction); + if (transporterTile.getTransmitter() == null + || (transporterTile.getTransmitter().getColor() != null + && transporterTile.getTransmitter().getColor() != stack.color)) { + return false; + } + } - if(!transportStack.canInsertToTransporter(neighbor.getTileEntity(worldObj), direction) && (!neighbor.equals(finalNode) || !destChecker.isValid(transportStack, i, neighbor.getTileEntity(worldObj)))) - { - blockCount++; - } - } + return true; + } - if(blockCount >= 6) - { - return false; - } + public static Destination getPath( + DestChecker checker, + EnumSet sides, + ILogisticalTransporter start, + Coord4D dest, + TransporterStack stack, + ItemStack rejects, + int min + ) { + List test = PathfinderCache.getCache(start.coord(), dest, sides); - double maxSearchDistance = start.distanceTo(finalNode) * 2; + if (test != null && checkPath(start.world(), test, stack)) { + return new Destination(test, false, rejects, 0).calculateScore(start.world()); + } - while(!openSet.isEmpty()) - { - Coord4D currentNode = null; - double lowestFScore = 0; + Pathfinder p = new Pathfinder(checker, start.world(), dest, start.coord(), stack); - for(Coord4D node : openSet) - { - if(currentNode == null || fScore.get(node) < lowestFScore) - { - currentNode = node; - lowestFScore = fScore.get(node); - } - } + if (p.getPath().size() >= 2) { + if (TransporterManager.getToUse(stack.itemStack, rejects).stackSize >= min) { + PathfinderCache.cachedPaths.put( + new PathData(start.coord(), dest, p.side), p.getPath() + ); - if(currentNode == null && start.distanceTo(currentNode) > maxSearchDistance) - { - break; - } + return new Destination(p.getPath(), false, rejects, p.finalScore); + } + } - openSet.remove(currentNode); - closedSet.add(currentNode); + return null; + } - for(ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) - { - Coord4D neighbor = currentNode.getFromSide(direction); + public static Destination + getNewBasePath(ILogisticalTransporter start, TransporterStack stack, int min) { + List paths = getPaths(start, stack, min); - if(transportStack.canInsertToTransporter(neighbor.getTileEntity(worldObj), direction)) - { - TileEntity tile = neighbor.getTileEntity(worldObj); - double tentativeG = gScore.get(currentNode) + ((ITransporterTile)tile).getTransmitter().getCost(); + if (paths.isEmpty()) { + return null; + } - if(closedSet.contains(neighbor)) - { - if(tentativeG >= gScore.get(neighbor)) - { - continue; - } - } + return paths.get(0); + } - if(!openSet.contains(neighbor) || tentativeG < gScore.get(neighbor)) - { - navMap.put(neighbor, currentNode); - gScore.put(neighbor, tentativeG); - fScore.put(neighbor, gScore.get(neighbor) + getEstimate(neighbor, finalNode)); - openSet.add(neighbor); - } - } + public static Destination getNewRRPath( + ILogisticalTransporter start, + TransporterStack stack, + TileEntityLogisticalSorter outputter, + int min + ) { + List paths = getPaths(start, stack, min); + + Map destPaths = new HashMap(); + + for (Destination d : paths) { + if (destPaths.get(d.path.get(0)) == null + || destPaths.get(d.path.get(0)).path.size() < d.path.size()) { + destPaths.put(d.path.get(0), d); + } + } + + List dests = new ArrayList(); + dests.addAll(destPaths.values()); + + Collections.sort(dests); + + Destination closest = null; + + if (!dests.isEmpty()) { + if (outputter.rrIndex <= dests.size() - 1) { + closest = dests.get(outputter.rrIndex); + + if (outputter.rrIndex == dests.size() - 1) { + outputter.rrIndex = 0; + } else if (outputter.rrIndex < dests.size() - 1) { + outputter.rrIndex++; + } + } else { + closest = dests.get(dests.size() - 1); + outputter.rrIndex = 0; + } + } + + if (closest == null) { + return null; + } + + return closest; + } + + public static class Pathfinder { + public final Set openSet, closedSet; + + public final HashMap navMap; + + public final HashMap gScore, fScore; + + public final Coord4D start; + + public final Coord4D finalNode; + + public final TransporterStack transportStack; + + public final DestChecker destChecker; + + public double finalScore; + + public ForgeDirection side; + + public ArrayList results; + + private World worldObj; + + public Pathfinder( + DestChecker checker, + World world, + Coord4D finishObj, + Coord4D startObj, + TransporterStack stack + ) { + destChecker = checker; + worldObj = world; + + finalNode = finishObj; + start = startObj; + + transportStack = stack; + + openSet = new HashSet(); + closedSet = new HashSet(); + + navMap = new HashMap(); + + gScore = new HashMap(); + fScore = new HashMap(); + + results = new ArrayList(); + + find(start); + } + + public boolean find(Coord4D start) { + openSet.add(start); + gScore.put(start, 0D); + fScore.put(start, gScore.get(start) + getEstimate(start, finalNode)); + + int blockCount = 0; + + for (int i = 0; i < 6; i++) { + ForgeDirection direction = ForgeDirection.getOrientation(i); + Coord4D neighbor = start.getFromSide(direction); + + if (!transportStack.canInsertToTransporter( + neighbor.getTileEntity(worldObj), direction + ) + && (!neighbor.equals(finalNode) + || !destChecker.isValid( + transportStack, i, neighbor.getTileEntity(worldObj) + ))) { + blockCount++; + } + } + + if (blockCount >= 6) { + return false; + } + + double maxSearchDistance = start.distanceTo(finalNode) * 2; + + while (!openSet.isEmpty()) { + Coord4D currentNode = null; + double lowestFScore = 0; + + for (Coord4D node : openSet) { + if (currentNode == null || fScore.get(node) < lowestFScore) { + currentNode = node; + lowestFScore = fScore.get(node); + } + } + + if (currentNode == null + && start.distanceTo(currentNode) > maxSearchDistance) { + break; + } + + openSet.remove(currentNode); + closedSet.add(currentNode); + + for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) { + Coord4D neighbor = currentNode.getFromSide(direction); + + if (transportStack.canInsertToTransporter( + neighbor.getTileEntity(worldObj), direction + )) { + TileEntity tile = neighbor.getTileEntity(worldObj); + double tentativeG = gScore.get(currentNode) + + ((ITransporterTile) tile).getTransmitter().getCost(); + + if (closedSet.contains(neighbor)) { + if (tentativeG >= gScore.get(neighbor)) { + continue; + } + } + + if (!openSet.contains(neighbor) + || tentativeG < gScore.get(neighbor)) { + navMap.put(neighbor, currentNode); + gScore.put(neighbor, tentativeG); + fScore.put( + neighbor, + gScore.get(neighbor) + getEstimate(neighbor, finalNode) + ); + openSet.add(neighbor); + } + } else if(neighbor.equals(finalNode) && destChecker.isValid(transportStack, direction.ordinal(), neighbor.getTileEntity(worldObj))) { - side = direction; - results = reconstructPath(navMap, currentNode); - return true; - } - } - } + side = direction; + results = reconstructPath(navMap, currentNode); + return true; + } + } + } - return false; - } + return false; + } - private ArrayList reconstructPath(HashMap naviMap, Coord4D currentNode) - { - ArrayList path = new ArrayList(); + private ArrayList + reconstructPath(HashMap naviMap, Coord4D currentNode) { + ArrayList path = new ArrayList(); - path.add(currentNode); + path.add(currentNode); - if(naviMap.containsKey(currentNode)) - { - path.addAll(reconstructPath(naviMap, naviMap.get(currentNode))); - } + if (naviMap.containsKey(currentNode)) { + path.addAll(reconstructPath(naviMap, naviMap.get(currentNode))); + } - finalScore = gScore.get(currentNode) + currentNode.distanceTo(finalNode); + finalScore = gScore.get(currentNode) + currentNode.distanceTo(finalNode); - return path; - } + return path; + } - public ArrayList getPath() - { - ArrayList path = new ArrayList(); - path.add(finalNode); - path.addAll(results); + public ArrayList getPath() { + ArrayList path = new ArrayList(); + path.add(finalNode); + path.addAll(results); - return path; - } + return path; + } - private double getEstimate(Coord4D start, Coord4D target2) - { - return start.distanceTo(target2); - } + private double getEstimate(Coord4D start, Coord4D target2) { + return start.distanceTo(target2); + } - public static class DestChecker - { - public boolean isValid(TransporterStack stack, int side, TileEntity tile) - { - return false; - } - } - } + public static class DestChecker { + public boolean isValid(TransporterStack stack, int side, TileEntity tile) { + return false; + } + } + } - public static Pair, Path> getIdlePath(ILogisticalTransporter start, TransporterStack stack) - { - if(stack.homeLocation != null) - { - DestChecker checker = new DestChecker() - { - @Override - public boolean isValid(TransporterStack stack, int side, TileEntity tile) - { - return InventoryUtils.canInsert(tile, stack.color, stack.itemStack, side, true); - } - }; + public static Pair, Path> + getIdlePath(ILogisticalTransporter start, TransporterStack stack) { + if (stack.homeLocation != null) { + DestChecker checker = new DestChecker() { + @Override + public boolean isValid( + TransporterStack stack, int side, TileEntity tile + ) { + return InventoryUtils.canInsert( + tile, stack.color, stack.itemStack, side, true + ); + } + }; - Pathfinder p = new Pathfinder(checker, start.world(), stack.homeLocation, start.coord(), stack); - List path = p.getPath(); + Pathfinder p = new Pathfinder( + checker, start.world(), stack.homeLocation, start.coord(), stack + ); + List path = p.getPath(); - if(path.size() >= 2) - { - return Pair.of(path, Path.HOME); - } - else { - stack.homeLocation = null; - } - } + if (path.size() >= 2) { + return Pair.of(path, Path.HOME); + } else { + stack.homeLocation = null; + } + } - IdlePath d = new IdlePath(start.world(), start.coord(), stack); - Destination dest = d.find(); + IdlePath d = new IdlePath(start.world(), start.coord(), stack); + Destination dest = d.find(); - if(dest == null) - { - return null; - } + if (dest == null) { + return null; + } - return Pair.of(dest.path, dest.pathType); - } + return Pair.of(dest.path, dest.pathType); + } } diff --git a/src/main/java/mekanism/common/content/transporter/TransporterStack.java b/src/main/java/mekanism/common/content/transporter/TransporterStack.java index 3acf60e81..bf43423fe 100644 --- a/src/main/java/mekanism/common/content/transporter/TransporterStack.java +++ b/src/main/java/mekanism/common/content/transporter/TransporterStack.java @@ -1,10 +1,9 @@ package mekanism.common.content.transporter; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.List; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.common.PacketHandler; @@ -17,325 +16,274 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; - import org.apache.commons.lang3.tuple.Pair; -public class TransporterStack -{ - public ItemStack itemStack; +public class TransporterStack { + public ItemStack itemStack; - public int progress; + public int progress; - public EnumColor color = null; + public EnumColor color = null; - public boolean initiatedPath = false; - - public ForgeDirection idleDir = ForgeDirection.UNKNOWN; + public boolean initiatedPath = false; - private List pathToTarget = new ArrayList(); + public ForgeDirection idleDir = ForgeDirection.UNKNOWN; - public Coord4D originalLocation; - public Coord4D homeLocation; + private List pathToTarget = new ArrayList(); - public Coord4D clientNext; - public Coord4D clientPrev; + public Coord4D originalLocation; + public Coord4D homeLocation; - public Path pathType; + public Coord4D clientNext; + public Coord4D clientPrev; - public void write(ILogisticalTransporter transporter, ArrayList data) - { - if(color != null) - { - data.add(TransporterUtils.colors.indexOf(color)); - } - else { - data.add(-1); - } + public Path pathType; - data.add(progress); - originalLocation.write(data); - data.add(pathType.ordinal()); + public void write(ILogisticalTransporter transporter, ArrayList data) { + if (color != null) { + data.add(TransporterUtils.colors.indexOf(color)); + } else { + data.add(-1); + } - if(pathToTarget.indexOf(transporter.coord()) > 0) - { - data.add(true); - getNext(transporter).write(data); - } - else { - data.add(false); - } + data.add(progress); + originalLocation.write(data); + data.add(pathType.ordinal()); - getPrev(transporter).write(data); + if (pathToTarget.indexOf(transporter.coord()) > 0) { + data.add(true); + getNext(transporter).write(data); + } else { + data.add(false); + } - data.add(itemStack); - } + getPrev(transporter).write(data); - public void read(ByteBuf dataStream) - { - int c = dataStream.readInt(); + data.add(itemStack); + } - if(c != -1) - { - color = TransporterUtils.colors.get(c); - } - else { - color = null; - } + public void read(ByteBuf dataStream) { + int c = dataStream.readInt(); - progress = dataStream.readInt(); - originalLocation = Coord4D.read(dataStream); - pathType = Path.values()[dataStream.readInt()]; + if (c != -1) { + color = TransporterUtils.colors.get(c); + } else { + color = null; + } - if(dataStream.readBoolean()) - { - clientNext = Coord4D.read(dataStream); - } + progress = dataStream.readInt(); + originalLocation = Coord4D.read(dataStream); + pathType = Path.values()[dataStream.readInt()]; - clientPrev = Coord4D.read(dataStream); + if (dataStream.readBoolean()) { + clientNext = Coord4D.read(dataStream); + } - itemStack = PacketHandler.readStack(dataStream); - } + clientPrev = Coord4D.read(dataStream); - public void write(NBTTagCompound nbtTags) - { - if(color != null) - { - nbtTags.setInteger("color", TransporterUtils.colors.indexOf(color)); - } + itemStack = PacketHandler.readStack(dataStream); + } - nbtTags.setInteger("progress", progress); - nbtTags.setTag("originalLocation", originalLocation.write(new NBTTagCompound())); - nbtTags.setInteger("idleDir", idleDir.ordinal()); + public void write(NBTTagCompound nbtTags) { + if (color != null) { + nbtTags.setInteger("color", TransporterUtils.colors.indexOf(color)); + } - if(homeLocation != null) - { - nbtTags.setTag("homeLocation", homeLocation.write(new NBTTagCompound())); - } + nbtTags.setInteger("progress", progress); + nbtTags.setTag("originalLocation", originalLocation.write(new NBTTagCompound())); + nbtTags.setInteger("idleDir", idleDir.ordinal()); - nbtTags.setInteger("pathType", pathType.ordinal()); - itemStack.writeToNBT(nbtTags); - } + if (homeLocation != null) { + nbtTags.setTag("homeLocation", homeLocation.write(new NBTTagCompound())); + } - public void read(NBTTagCompound nbtTags) - { - if(nbtTags.hasKey("color")) - { - color = TransporterUtils.colors.get(nbtTags.getInteger("color")); - } + nbtTags.setInteger("pathType", pathType.ordinal()); + itemStack.writeToNBT(nbtTags); + } - progress = nbtTags.getInteger("progress"); - originalLocation = Coord4D.read(nbtTags.getCompoundTag("originalLocation")); - idleDir = ForgeDirection.values()[nbtTags.getInteger("idleDir")]; + public void read(NBTTagCompound nbtTags) { + if (nbtTags.hasKey("color")) { + color = TransporterUtils.colors.get(nbtTags.getInteger("color")); + } - if(nbtTags.hasKey("homeLocation")) - { - homeLocation = Coord4D.read(nbtTags.getCompoundTag("homeLocation")); - } + progress = nbtTags.getInteger("progress"); + originalLocation = Coord4D.read(nbtTags.getCompoundTag("originalLocation")); + idleDir = ForgeDirection.values()[nbtTags.getInteger("idleDir")]; - pathType = Path.values()[nbtTags.getInteger("pathType")]; - itemStack = ItemStack.loadItemStackFromNBT(nbtTags); - } + if (nbtTags.hasKey("homeLocation")) { + homeLocation = Coord4D.read(nbtTags.getCompoundTag("homeLocation")); + } - public static TransporterStack readFromNBT(NBTTagCompound nbtTags) - { - TransporterStack stack = new TransporterStack(); - stack.read(nbtTags); + pathType = Path.values()[nbtTags.getInteger("pathType")]; + itemStack = ItemStack.loadItemStackFromNBT(nbtTags); + } - return stack; - } + public static TransporterStack readFromNBT(NBTTagCompound nbtTags) { + TransporterStack stack = new TransporterStack(); + stack.read(nbtTags); - public static TransporterStack readFromPacket(ByteBuf dataStream) - { - TransporterStack stack = new TransporterStack(); - stack.read(dataStream); + return stack; + } - return stack; - } - - public void setPath(List path, Path type) - { - //Make sure old path isn't null - if(pathType != Path.NONE) - { - TransporterManager.remove(this); - } - - pathToTarget = path; - pathType = type; - - if(pathType != Path.NONE) - { - TransporterManager.add(this); - } - } + public static TransporterStack readFromPacket(ByteBuf dataStream) { + TransporterStack stack = new TransporterStack(); + stack.read(dataStream); - public boolean hasPath() - { - return getPath() != null && getPath().size() >= 2; - } - - public List getPath() - { - return pathToTarget; - } + return stack; + } - public ItemStack recalculatePath(ILogisticalTransporter transporter, int min) - { - Destination newPath = TransporterPathfinder.getNewBasePath(transporter, this, min); + public void setPath(List path, Path type) { + //Make sure old path isn't null + if (pathType != Path.NONE) { + TransporterManager.remove(this); + } - if(newPath == null) - { - return itemStack; - } + pathToTarget = path; + pathType = type; - idleDir = ForgeDirection.UNKNOWN; - setPath(newPath.path, Path.DEST); - initiatedPath = true; + if (pathType != Path.NONE) { + TransporterManager.add(this); + } + } - return newPath.rejected; - } + public boolean hasPath() { + return getPath() != null && getPath().size() >= 2; + } - public ItemStack recalculateRRPath(TileEntityLogisticalSorter outputter, ILogisticalTransporter transporter, int min) - { - Destination newPath = TransporterPathfinder.getNewRRPath(transporter, this, outputter, min); + public List getPath() { + return pathToTarget; + } - if(newPath == null) - { - return itemStack; - } + public ItemStack recalculatePath(ILogisticalTransporter transporter, int min) { + Destination newPath + = TransporterPathfinder.getNewBasePath(transporter, this, min); - idleDir = ForgeDirection.UNKNOWN; - setPath(newPath.path, Path.DEST); - initiatedPath = true; + if (newPath == null) { + return itemStack; + } - return newPath.rejected; - } + idleDir = ForgeDirection.UNKNOWN; + setPath(newPath.path, Path.DEST); + initiatedPath = true; - public boolean calculateIdle(ILogisticalTransporter transporter) - { - Pair, Path> newPath = TransporterPathfinder.getIdlePath(transporter, this); + return newPath.rejected; + } - if(newPath == null) - { - return false; - } - - if(newPath.getRight() == Path.HOME) - { - idleDir = ForgeDirection.UNKNOWN; - } - - setPath(newPath.getLeft(), newPath.getRight()); + public ItemStack recalculateRRPath( + TileEntityLogisticalSorter outputter, ILogisticalTransporter transporter, int min + ) { + Destination newPath + = TransporterPathfinder.getNewRRPath(transporter, this, outputter, min); - originalLocation = transporter.coord(); - initiatedPath = true; + if (newPath == null) { + return itemStack; + } - return true; - } + idleDir = ForgeDirection.UNKNOWN; + setPath(newPath.path, Path.DEST); + initiatedPath = true; - public boolean isFinal(ILogisticalTransporter transporter) - { - return pathToTarget.indexOf(transporter.coord()) == (pathType == Path.NONE ? 0 : 1); - } + return newPath.rejected; + } - public Coord4D getNext(ILogisticalTransporter transporter) - { - if(!transporter.world().isRemote) - { - int index = pathToTarget.indexOf(transporter.coord())-1; + public boolean calculateIdle(ILogisticalTransporter transporter) { + Pair, Path> newPath + = TransporterPathfinder.getIdlePath(transporter, this); - if(index < 0) - { - return null; - } + if (newPath == null) { + return false; + } - return pathToTarget.get(index); - } - else { - return clientNext; - } - } + if (newPath.getRight() == Path.HOME) { + idleDir = ForgeDirection.UNKNOWN; + } - public Coord4D getPrev(ILogisticalTransporter transporter) - { - if(!transporter.world().isRemote) - { - int index = pathToTarget.indexOf(transporter.coord())+1; + setPath(newPath.getLeft(), newPath.getRight()); - if(index < pathToTarget.size()) - { - return pathToTarget.get(index); - } - else { - return originalLocation; - } - } - else { - return clientPrev; - } - } + originalLocation = transporter.coord(); + initiatedPath = true; - public int getSide(ILogisticalTransporter transporter) - { - if(progress < 50) - { - if(getPrev(transporter) != null) - { - return transporter.coord().sideDifference(getPrev(transporter)).ordinal(); - } - } - else if(progress == 50) - { - if(getNext(transporter) != null) - { - return getNext(transporter).sideDifference(transporter.coord()).ordinal(); - } - } - else if(progress > 50) - { - if(getNext(transporter) != null) - { - return getNext(transporter).sideDifference(transporter.coord()).ordinal(); - } - } + return true; + } - return 0; - } + public boolean isFinal(ILogisticalTransporter transporter) { + return pathToTarget.indexOf(transporter.coord()) + == (pathType == Path.NONE ? 0 : 1); + } - public boolean canInsertToTransporter(TileEntity tileEntity, ForgeDirection from) - { - if(!(tileEntity instanceof ITransporterTile)) - { - return false; - } + public Coord4D getNext(ILogisticalTransporter transporter) { + if (!transporter.world().isRemote) { + int index = pathToTarget.indexOf(transporter.coord()) - 1; - ILogisticalTransporter transporter = ((ITransporterTile)tileEntity).getTransmitter(); + if (index < 0) { + return null; + } - if(!((ITransporterTile)tileEntity).canConnectMutual(from.getOpposite())) - { - return false; - } + return pathToTarget.get(index); + } else { + return clientNext; + } + } - return transporter.getColor() == color || transporter.getColor() == null; - } + public Coord4D getPrev(ILogisticalTransporter transporter) { + if (!transporter.world().isRemote) { + int index = pathToTarget.indexOf(transporter.coord()) + 1; - public boolean canInsertToTransporter(ILogisticalTransporter transporter, ForgeDirection side) - { - if(!transporter.canConnectMutual(side)) - { - return false; - } + if (index < pathToTarget.size()) { + return pathToTarget.get(index); + } else { + return originalLocation; + } + } else { + return clientPrev; + } + } - return transporter.getColor() == color || transporter.getColor() == null; - } + public int getSide(ILogisticalTransporter transporter) { + if (progress < 50) { + if (getPrev(transporter) != null) { + return transporter.coord().sideDifference(getPrev(transporter)).ordinal(); + } + } else if (progress == 50) { + if (getNext(transporter) != null) { + return getNext(transporter).sideDifference(transporter.coord()).ordinal(); + } + } else if (progress > 50) { + if (getNext(transporter) != null) { + return getNext(transporter).sideDifference(transporter.coord()).ordinal(); + } + } - public Coord4D getDest() - { - return getPath().get(0); - } + return 0; + } - public static enum Path - { - DEST, HOME, NONE - } + public boolean canInsertToTransporter(TileEntity tileEntity, ForgeDirection from) { + if (!(tileEntity instanceof ITransporterTile)) { + return false; + } + + ILogisticalTransporter transporter + = ((ITransporterTile) tileEntity).getTransmitter(); + + if (!((ITransporterTile) tileEntity).canConnectMutual(from.getOpposite())) { + return false; + } + + return transporter.getColor() == color || transporter.getColor() == null; + } + + public boolean + canInsertToTransporter(ILogisticalTransporter transporter, ForgeDirection side) { + if (!transporter.canConnectMutual(side)) { + return false; + } + + return transporter.getColor() == color || transporter.getColor() == null; + } + + public Coord4D getDest() { + return getPath().get(0); + } + + public static enum Path { DEST, HOME, NONE } } diff --git a/src/main/java/mekanism/common/entity/EntityBabySkeleton.java b/src/main/java/mekanism/common/entity/EntityBabySkeleton.java index 2a1237bdc..b9ecf8a00 100644 --- a/src/main/java/mekanism/common/entity/EntityBabySkeleton.java +++ b/src/main/java/mekanism/common/entity/EntityBabySkeleton.java @@ -9,67 +9,59 @@ import net.minecraft.entity.monster.EntitySkeleton; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; -public class EntityBabySkeleton extends EntitySkeleton -{ - private static final UUID babySpeedBoostUUID = UUID.fromString("B9766B59-9566-4402-BC1F-2EE2A276D836"); - private static final AttributeModifier babySpeedBoostModifier = new AttributeModifier(babySpeedBoostUUID, "Baby speed boost", 0.5D, 1); - - public EntityBabySkeleton(World world) - { - super(world); - setChild(true); - } - - @Override - protected void entityInit() - { - super.entityInit(); - - getDataWatcher().addObject(12, new Byte((byte)0)); - } - - public void setChild(boolean child) - { - getDataWatcher().updateObject(12, Byte.valueOf((byte)(child ? 1 : 0))); +public class EntityBabySkeleton extends EntitySkeleton { + private static final UUID babySpeedBoostUUID + = UUID.fromString("B9766B59-9566-4402-BC1F-2EE2A276D836"); + private static final AttributeModifier babySpeedBoostModifier + = new AttributeModifier(babySpeedBoostUUID, "Baby speed boost", 0.5D, 1); - if(worldObj != null && !worldObj.isRemote) - { - IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed); + public EntityBabySkeleton(World world) { + super(world); + setChild(true); + } + + @Override + protected void entityInit() { + super.entityInit(); + + getDataWatcher().addObject(12, new Byte((byte) 0)); + } + + public void setChild(boolean child) { + getDataWatcher().updateObject(12, Byte.valueOf((byte) (child ? 1 : 0))); + + if (worldObj != null && !worldObj.isRemote) { + IAttributeInstance iattributeinstance + = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed); iattributeinstance.removeModifier(babySpeedBoostModifier); - if(child) - { + if (child) { iattributeinstance.applyModifier(babySpeedBoostModifier); } } updateChildSize(child); } - + @Override - public boolean isChild() - { + public boolean isChild() { return getDataWatcher().getWatchableObjectByte(12) == 1; } - + @Override - protected int getExperiencePoints(EntityPlayer p_70693_1_) - { - if(isChild()) - { - experienceValue = (int)((float)experienceValue * 2.5F); + protected int getExperiencePoints(EntityPlayer p_70693_1_) { + if (isChild()) { + experienceValue = (int) ((float) experienceValue * 2.5F); } return super.getExperiencePoints(p_70693_1_); } - - public void updateChildSize(boolean child) - { + + public void updateChildSize(boolean child) { updateSize(child ? 0.5F : 1.0F); } - protected final void updateSize(float size) - { - super.setSize(size, size+0.4F); + protected final void updateSize(float size) { + super.setSize(size, size + 0.4F); } } diff --git a/src/main/java/mekanism/common/entity/EntityBalloon.java b/src/main/java/mekanism/common/entity/EntityBalloon.java index ae707b420..0e5bb8273 100644 --- a/src/main/java/mekanism/common/entity/EntityBalloon.java +++ b/src/main/java/mekanism/common/entity/EntityBalloon.java @@ -1,9 +1,11 @@ package mekanism.common.entity; -import io.netty.buffer.ByteBuf; - import java.util.UUID; +import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.Pos3D; @@ -17,439 +19,416 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; import net.minecraft.world.World; -import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData -{ - public EnumColor color = EnumColor.DARK_BLUE; - - public Coord4D latched; - public EntityLivingBase latchedEntity; - - /* server-only */ - public boolean hasCachedEntity; - - public UUID cachedEntityUUID; - - public EntityBalloon(World world) - { - super(world); - - ignoreFrustumCheck = true; - preventEntitySpawning = true; - setPosition(posX + 0.5F, posY + 3F, posZ + 0.5F); - yOffset = height / 2.0F; - setSize(0.25F, 0.25F); - motionY = 0.04; - - dataWatcher.addObject(2, new Byte((byte)0)); /* Is latched */ - dataWatcher.addObject(3, new Integer(0)); /* Latched X */ - dataWatcher.addObject(4, new Integer(0)); /* Latched Y */ - dataWatcher.addObject(5, new Integer(0)); /* Latched Z */ - dataWatcher.addObject(6, new Integer(-1)); /* Latched entity ID */ - } - - public EntityBalloon(World world, double x, double y, double z, EnumColor c) - { - this(world); - - setPosition(x + 0.5F, y + 3F, z + 0.5F); - - prevPosX = posX; - prevPosY = posY; - prevPosZ = posZ; - - color = c; - } - - public EntityBalloon(EntityLivingBase entity, EnumColor c) - { - this(entity.worldObj); - - latchedEntity = entity; - setPosition(latchedEntity.posX, latchedEntity.posY + latchedEntity.height + 1.7F, latchedEntity.posZ); - - prevPosX = posX; - prevPosY = posY; - prevPosZ = posZ; - - color = c; - - dataWatcher.updateObject(2, new Byte((byte)2)); /* Is latched */ - dataWatcher.updateObject(3, new Integer(0)); /* Latched X */ - dataWatcher.updateObject(4, new Integer(0)); /* Latched Y */ - dataWatcher.updateObject(5, new Integer(0)); /* Latched Z */ - dataWatcher.updateObject(6, new Integer(entity.getEntityId())); /* Latched entity ID */ - } - - public EntityBalloon(World world, Coord4D obj, EnumColor c) - { - this(world); - - latched = obj; - setPosition(latched.xCoord + 0.5F, latched.yCoord + 2.8F, latched.zCoord + 0.5F); - - prevPosX = posX; - prevPosY = posY; - prevPosZ = posZ; - - color = c; - - dataWatcher.updateObject(2, new Byte((byte)1)); /* Is latched */ - dataWatcher.updateObject(3, new Integer(latched != null ? latched.xCoord : 0)); /* Latched X */ - dataWatcher.updateObject(4, new Integer(latched != null ? latched.yCoord : 0)); /* Latched Y */ - dataWatcher.updateObject(5, new Integer(latched != null ? latched.zCoord : 0)); /* Latched Z */ - dataWatcher.updateObject(6, new Integer(-1)); /* Latched entity ID */ - } - - @Override - public void onUpdate() - { - prevPosX = posX; - prevPosY = posY; - prevPosZ = posZ; - - if(posY > 255) - { - pop(); - return; - } - - if(worldObj.isRemote) - { - if(dataWatcher.getWatchableObjectByte(2) == 1) - { - latched = new Coord4D(dataWatcher.getWatchableObjectInt(3), dataWatcher.getWatchableObjectInt(4), dataWatcher.getWatchableObjectInt(5), worldObj.provider.dimensionId); - } - else { - latched = null; - } - - if(dataWatcher.getWatchableObjectByte(2) == 2) - { - latchedEntity = (EntityLivingBase)worldObj.getEntityByID(dataWatcher.getWatchableObjectInt(6)); - } - else { - latchedEntity = null; - } - } - else { - if(hasCachedEntity) - { - findCachedEntity(); - cachedEntityUUID = null; - hasCachedEntity = false; - } - - if(ticksExisted == 1) - { - dataWatcher.updateObject(2, new Byte(latched != null ? (byte)1 : (latchedEntity != null ? (byte)2 : (byte)0))); /* Is latched */ - dataWatcher.updateObject(3, new Integer(latched != null ? latched.xCoord : 0)); /* Latched X */ - dataWatcher.updateObject(4, new Integer(latched != null ? latched.yCoord : 0)); /* Latched Y */ - dataWatcher.updateObject(5, new Integer(latched != null ? latched.zCoord : 0)); /* Latched Z */ - dataWatcher.updateObject(6, new Integer(latchedEntity != null ? latchedEntity.getEntityId() : -1)); /* Latched entity ID */ - } - } - - if(!worldObj.isRemote) - { - if(latched != null && (latched.exists(worldObj) && latched.isAirBlock(worldObj))) - { - latched = null; - - dataWatcher.updateObject(2, (byte)0); /* Is latched */ - } - - if(latchedEntity != null && (latchedEntity.getHealth() <= 0 || latchedEntity.isDead || !worldObj.loadedEntityList.contains(latchedEntity))) - { - latchedEntity = null; - - dataWatcher.updateObject(2, (byte)0); /* Is latched */ - } - } - - if(!isLatched()) - { - motionY = Math.min(motionY*1.02F, 0.2F); - - moveEntity(motionX, motionY, motionZ); - - motionX *= 0.98; - motionZ *= 0.98; - - if(onGround) - { - motionX *= 0.7; - motionZ *= 0.7; - } - - if(motionY == 0) - { - motionY = 0.04; - } - } - else if(latched != null) - { - motionX = 0; - motionY = 0; - motionZ = 0; - } - else if(latchedEntity != null && latchedEntity.getHealth() > 0) - { - int floor = getFloor(latchedEntity); - - if(latchedEntity.posY-(floor+1) < -0.1) - { - latchedEntity.motionY = Math.max(0.04, latchedEntity.motionY*1.015); - } - else if(latchedEntity.posY-(floor+1) > 0.1) - { - latchedEntity.motionY = Math.min(-0.04, latchedEntity.motionY*1.015); - } - else { - latchedEntity.motionY = 0; - } - - setPosition(latchedEntity.posX, latchedEntity.posY + getAddedHeight(), latchedEntity.posZ); - } - } - - public double getAddedHeight() - { - return latchedEntity.height + (latchedEntity instanceof EntityPlayer ? 0.25F : 1.7F); - } - - private int getFloor(EntityLivingBase entity) - { - int xPos = MathHelper.floor_double(entity.posX); - int yPos = MathHelper.floor_double(entity.posY); - int zPos = MathHelper.floor_double(entity.posZ); - - for(int i = yPos; i > 0; i--) - { - if(i < 256 && !worldObj.isAirBlock(xPos, i, zPos)) - { - return i+1+(entity instanceof EntityPlayer ? 1 : 0); - } - } - - return -1; - } - - private void findCachedEntity() - { - for(Object obj : worldObj.loadedEntityList) - { - if(obj instanceof EntityLivingBase) - { - EntityLivingBase entity = (EntityLivingBase)obj; - - if(entity.getUniqueID().equals(cachedEntityUUID)) - { - latchedEntity = entity; - } - } - } - } - - private void pop() - { - worldObj.playSoundAtEntity(this, "mekanism:etc.Pop", 1, 1); - - if(worldObj.isRemote) - { - for(int i = 0; i < 10; i++) - { - try { - doParticle(); - } catch(Throwable t) {} - } - } - - setDead(); - } - - @SideOnly(Side.CLIENT) - private void doParticle() - { - Pos3D pos = new Pos3D(posX + (rand.nextFloat()*.6 - 0.3), posY - 0.8 + (rand.nextFloat()*.6 - 0.3), posZ + (rand.nextFloat()*.6 - 0.3)); - - EntityFX fx = new EntityReddustFX(worldObj, pos.xPos, pos.yPos, pos.zPos, 1, 0, 0, 0); - fx.setRBGColorF(color.getColor(0), color.getColor(1), color.getColor(2)); - - Minecraft.getMinecraft().effectRenderer.addEffect(fx); - } - - @Override - public boolean canBePushed() - { - return latched == null; - } - - @Override - public boolean canBeCollidedWith() - { - return !isDead; - } - - @Override - protected boolean canTriggerWalking() - { - return false; - } - - @Override - protected void entityInit() {} - - @Override - protected void readEntityFromNBT(NBTTagCompound nbtTags) - { - color = EnumColor.values()[nbtTags.getInteger("color")]; - - if(nbtTags.hasKey("latched")) - { - latched = Coord4D.read(nbtTags.getCompoundTag("latched")); - } - - if(nbtTags.hasKey("idMost")) - { - hasCachedEntity = true; - cachedEntityUUID = new UUID(nbtTags.getLong("idMost"), nbtTags.getLong("idLeast")); - } - } - - @Override - protected void writeEntityToNBT(NBTTagCompound nbtTags) - { - nbtTags.setInteger("color", color.ordinal()); - - if(latched != null) - { - nbtTags.setTag("latched", latched.write(new NBTTagCompound())); - } - - if(latchedEntity != null) - { - nbtTags.setLong("idMost", latchedEntity.getUniqueID().getMostSignificantBits()); - nbtTags.setLong("idLeast", latchedEntity.getUniqueID().getLeastSignificantBits()); - } - } - - @Override - public boolean hitByEntity(Entity entity) - { - pop(); - return true; - } - - @Override - public void writeSpawnData(ByteBuf data) - { - data.writeDouble(posX); - data.writeDouble(posY); - data.writeDouble(posZ); - - data.writeInt(color.ordinal()); - - if(latched != null) - { - data.writeByte((byte)1); - - data.writeInt(latched.xCoord); - data.writeInt(latched.yCoord); - data.writeInt(latched.zCoord); - data.writeInt(latched.dimensionId); - } - else if(latchedEntity != null) - { - data.writeByte((byte)2); - data.writeInt(latchedEntity.getEntityId()); - } - else { - data.writeByte((byte)0); - } - } - - @Override - public void readSpawnData(ByteBuf data) - { - setPosition(data.readDouble(), data.readDouble(), data.readDouble()); - - color = EnumColor.values()[data.readInt()]; - - byte type = data.readByte(); - - if(type == 1) - { - latched = Coord4D.read(data); - } - else if(type == 2) - { - latchedEntity = (EntityLivingBase)worldObj.getEntityByID(data.readInt()); - } - else { - latched = null; - } - } - - @Override - public void setDead() - { - super.setDead(); - - if(latchedEntity != null) - { - latchedEntity.isAirBorne = false; - } - } - - @Override - public boolean isInRangeToRenderDist(double dist) - { - return dist <= 64; - } - - @Override - public boolean isInRangeToRender3d(double p_145770_1_, double p_145770_3_, double p_145770_5_) - { - return true; - } - - @Override - public boolean attackEntityFrom(DamageSource dmgSource, float damage) - { - if(isEntityInvulnerable()) - { - return false; - } - else { - setBeenAttacked(); - - if(dmgSource != DamageSource.magic && dmgSource != DamageSource.drown && dmgSource != DamageSource.fall) - { - pop(); - return true; - } - - return false; - } - } - - public boolean isLatched() - { - if(!worldObj.isRemote) - { - return latched != null || latchedEntity != null; - } - else { - return dataWatcher.getWatchableObjectByte(2) > 0; - } - } - - public boolean isLatchedToEntity() - { - return dataWatcher.getWatchableObjectByte(2) == 2 && latchedEntity != null; - } + +public class EntityBalloon extends Entity implements IEntityAdditionalSpawnData { + public EnumColor color = EnumColor.DARK_BLUE; + + public Coord4D latched; + public EntityLivingBase latchedEntity; + + /* server-only */ + public boolean hasCachedEntity; + + public UUID cachedEntityUUID; + + public EntityBalloon(World world) { + super(world); + + ignoreFrustumCheck = true; + preventEntitySpawning = true; + setPosition(posX + 0.5F, posY + 3F, posZ + 0.5F); + yOffset = height / 2.0F; + setSize(0.25F, 0.25F); + motionY = 0.04; + + dataWatcher.addObject(2, new Byte((byte) 0)); /* Is latched */ + dataWatcher.addObject(3, new Integer(0)); /* Latched X */ + dataWatcher.addObject(4, new Integer(0)); /* Latched Y */ + dataWatcher.addObject(5, new Integer(0)); /* Latched Z */ + dataWatcher.addObject(6, new Integer(-1)); /* Latched entity ID */ + } + + public EntityBalloon(World world, double x, double y, double z, EnumColor c) { + this(world); + + setPosition(x + 0.5F, y + 3F, z + 0.5F); + + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + + color = c; + } + + public EntityBalloon(EntityLivingBase entity, EnumColor c) { + this(entity.worldObj); + + latchedEntity = entity; + setPosition( + latchedEntity.posX, + latchedEntity.posY + latchedEntity.height + 1.7F, + latchedEntity.posZ + ); + + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + + color = c; + + dataWatcher.updateObject(2, new Byte((byte) 2)); /* Is latched */ + dataWatcher.updateObject(3, new Integer(0)); /* Latched X */ + dataWatcher.updateObject(4, new Integer(0)); /* Latched Y */ + dataWatcher.updateObject(5, new Integer(0)); /* Latched Z */ + dataWatcher.updateObject( + 6, new Integer(entity.getEntityId()) + ); /* Latched entity ID */ + } + + public EntityBalloon(World world, Coord4D obj, EnumColor c) { + this(world); + + latched = obj; + setPosition(latched.xCoord + 0.5F, latched.yCoord + 2.8F, latched.zCoord + 0.5F); + + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + + color = c; + + dataWatcher.updateObject(2, new Byte((byte) 1)); /* Is latched */ + dataWatcher.updateObject( + 3, new Integer(latched != null ? latched.xCoord : 0) + ); /* Latched X */ + dataWatcher.updateObject( + 4, new Integer(latched != null ? latched.yCoord : 0) + ); /* Latched Y */ + dataWatcher.updateObject( + 5, new Integer(latched != null ? latched.zCoord : 0) + ); /* Latched Z */ + dataWatcher.updateObject(6, new Integer(-1)); /* Latched entity ID */ + } + + @Override + public void onUpdate() { + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; + + if (posY > 255) { + pop(); + return; + } + + if (worldObj.isRemote) { + if (dataWatcher.getWatchableObjectByte(2) == 1) { + latched = new Coord4D( + dataWatcher.getWatchableObjectInt(3), + dataWatcher.getWatchableObjectInt(4), + dataWatcher.getWatchableObjectInt(5), + worldObj.provider.dimensionId + ); + } else { + latched = null; + } + + if (dataWatcher.getWatchableObjectByte(2) == 2) { + latchedEntity = (EntityLivingBase + ) worldObj.getEntityByID(dataWatcher.getWatchableObjectInt(6)); + } else { + latchedEntity = null; + } + } else { + if (hasCachedEntity) { + findCachedEntity(); + cachedEntityUUID = null; + hasCachedEntity = false; + } + + if (ticksExisted == 1) { + dataWatcher.updateObject( + 2, + new Byte( + latched != null ? (byte) 1 + : (latchedEntity != null ? (byte) 2 : (byte) 0) + ) + ); /* Is latched */ + dataWatcher.updateObject( + 3, new Integer(latched != null ? latched.xCoord : 0) + ); /* Latched X */ + dataWatcher.updateObject( + 4, new Integer(latched != null ? latched.yCoord : 0) + ); /* Latched Y */ + dataWatcher.updateObject( + 5, new Integer(latched != null ? latched.zCoord : 0) + ); /* Latched Z */ + dataWatcher.updateObject( + 6, + new Integer(latchedEntity != null ? latchedEntity.getEntityId() : -1) + ); /* Latched entity ID */ + } + } + + if (!worldObj.isRemote) { + if (latched != null + && (latched.exists(worldObj) && latched.isAirBlock(worldObj))) { + latched = null; + + dataWatcher.updateObject(2, (byte) 0); /* Is latched */ + } + + if (latchedEntity != null + && (latchedEntity.getHealth() <= 0 || latchedEntity.isDead + || !worldObj.loadedEntityList.contains(latchedEntity))) { + latchedEntity = null; + + dataWatcher.updateObject(2, (byte) 0); /* Is latched */ + } + } + + if (!isLatched()) { + motionY = Math.min(motionY * 1.02F, 0.2F); + + moveEntity(motionX, motionY, motionZ); + + motionX *= 0.98; + motionZ *= 0.98; + + if (onGround) { + motionX *= 0.7; + motionZ *= 0.7; + } + + if (motionY == 0) { + motionY = 0.04; + } + } else if (latched != null) { + motionX = 0; + motionY = 0; + motionZ = 0; + } else if (latchedEntity != null && latchedEntity.getHealth() > 0) { + int floor = getFloor(latchedEntity); + + if (latchedEntity.posY - (floor + 1) < -0.1) { + latchedEntity.motionY = Math.max(0.04, latchedEntity.motionY * 1.015); + } else if (latchedEntity.posY - (floor + 1) > 0.1) { + latchedEntity.motionY = Math.min(-0.04, latchedEntity.motionY * 1.015); + } else { + latchedEntity.motionY = 0; + } + + setPosition( + latchedEntity.posX, + latchedEntity.posY + getAddedHeight(), + latchedEntity.posZ + ); + } + } + + public double getAddedHeight() { + return latchedEntity.height + + (latchedEntity instanceof EntityPlayer ? 0.25F : 1.7F); + } + + private int getFloor(EntityLivingBase entity) { + int xPos = MathHelper.floor_double(entity.posX); + int yPos = MathHelper.floor_double(entity.posY); + int zPos = MathHelper.floor_double(entity.posZ); + + for (int i = yPos; i > 0; i--) { + if (i < 256 && !worldObj.isAirBlock(xPos, i, zPos)) { + return i + 1 + (entity instanceof EntityPlayer ? 1 : 0); + } + } + + return -1; + } + + private void findCachedEntity() { + for (Object obj : worldObj.loadedEntityList) { + if (obj instanceof EntityLivingBase) { + EntityLivingBase entity = (EntityLivingBase) obj; + + if (entity.getUniqueID().equals(cachedEntityUUID)) { + latchedEntity = entity; + } + } + } + } + + private void pop() { + worldObj.playSoundAtEntity(this, "mekanism:etc.Pop", 1, 1); + + if (worldObj.isRemote) { + for (int i = 0; i < 10; i++) { + try { + doParticle(); + } catch (Throwable t) {} + } + } + + setDead(); + } + + @SideOnly(Side.CLIENT) + private void doParticle() { + Pos3D pos = new Pos3D( + posX + (rand.nextFloat() * .6 - 0.3), + posY - 0.8 + (rand.nextFloat() * .6 - 0.3), + posZ + (rand.nextFloat() * .6 - 0.3) + ); + + EntityFX fx + = new EntityReddustFX(worldObj, pos.xPos, pos.yPos, pos.zPos, 1, 0, 0, 0); + fx.setRBGColorF(color.getColor(0), color.getColor(1), color.getColor(2)); + + Minecraft.getMinecraft().effectRenderer.addEffect(fx); + } + + @Override + public boolean canBePushed() { + return latched == null; + } + + @Override + public boolean canBeCollidedWith() { + return !isDead; + } + + @Override + protected boolean canTriggerWalking() { + return false; + } + + @Override + protected void entityInit() {} + + @Override + protected void readEntityFromNBT(NBTTagCompound nbtTags) { + color = EnumColor.values()[nbtTags.getInteger("color")]; + + if (nbtTags.hasKey("latched")) { + latched = Coord4D.read(nbtTags.getCompoundTag("latched")); + } + + if (nbtTags.hasKey("idMost")) { + hasCachedEntity = true; + cachedEntityUUID + = new UUID(nbtTags.getLong("idMost"), nbtTags.getLong("idLeast")); + } + } + + @Override + protected void writeEntityToNBT(NBTTagCompound nbtTags) { + nbtTags.setInteger("color", color.ordinal()); + + if (latched != null) { + nbtTags.setTag("latched", latched.write(new NBTTagCompound())); + } + + if (latchedEntity != null) { + nbtTags.setLong( + "idMost", latchedEntity.getUniqueID().getMostSignificantBits() + ); + nbtTags.setLong( + "idLeast", latchedEntity.getUniqueID().getLeastSignificantBits() + ); + } + } + + @Override + public boolean hitByEntity(Entity entity) { + pop(); + return true; + } + + @Override + public void writeSpawnData(ByteBuf data) { + data.writeDouble(posX); + data.writeDouble(posY); + data.writeDouble(posZ); + + data.writeInt(color.ordinal()); + + if (latched != null) { + data.writeByte((byte) 1); + + data.writeInt(latched.xCoord); + data.writeInt(latched.yCoord); + data.writeInt(latched.zCoord); + data.writeInt(latched.dimensionId); + } else if (latchedEntity != null) { + data.writeByte((byte) 2); + data.writeInt(latchedEntity.getEntityId()); + } else { + data.writeByte((byte) 0); + } + } + + @Override + public void readSpawnData(ByteBuf data) { + setPosition(data.readDouble(), data.readDouble(), data.readDouble()); + + color = EnumColor.values()[data.readInt()]; + + byte type = data.readByte(); + + if (type == 1) { + latched = Coord4D.read(data); + } else if (type == 2) { + latchedEntity = (EntityLivingBase) worldObj.getEntityByID(data.readInt()); + } else { + latched = null; + } + } + + @Override + public void setDead() { + super.setDead(); + + if (latchedEntity != null) { + latchedEntity.isAirBorne = false; + } + } + + @Override + public boolean isInRangeToRenderDist(double dist) { + return dist <= 64; + } + + @Override + public boolean + isInRangeToRender3d(double p_145770_1_, double p_145770_3_, double p_145770_5_) { + return true; + } + + @Override + public boolean attackEntityFrom(DamageSource dmgSource, float damage) { + if (isEntityInvulnerable()) { + return false; + } else { + setBeenAttacked(); + + if (dmgSource != DamageSource.magic && dmgSource != DamageSource.drown + && dmgSource != DamageSource.fall) { + pop(); + return true; + } + + return false; + } + } + + public boolean isLatched() { + if (!worldObj.isRemote) { + return latched != null || latchedEntity != null; + } else { + return dataWatcher.getWatchableObjectByte(2) > 0; + } + } + + public boolean isLatchedToEntity() { + return dataWatcher.getWatchableObjectByte(2) == 2 && latchedEntity != null; + } } diff --git a/src/main/java/mekanism/common/entity/EntityFlame.java b/src/main/java/mekanism/common/entity/EntityFlame.java index ac5aeeea6..10f2b809b 100644 --- a/src/main/java/mekanism/common/entity/EntityFlame.java +++ b/src/main/java/mekanism/common/entity/EntityFlame.java @@ -1,9 +1,9 @@ package mekanism.common.entity; -import io.netty.buffer.ByteBuf; - import java.util.List; +import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.MekanismConfig.general; import mekanism.api.Pos3D; @@ -25,121 +25,125 @@ import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.Vec3; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import cpw.mods.fml.common.registry.IEntityAdditionalSpawnData; -public class EntityFlame extends Entity implements IEntityAdditionalSpawnData -{ - public static final int LIFESPAN = 80; - public static final int DAMAGE = 10; - - public Entity owner = null; - public ItemFlamethrower.FlamethrowerMode mode = ItemFlamethrower.FlamethrowerMode.COMBAT; - - public EntityFlame(World world) - { - super(world); - - setSize(0.5F, 0.5F); - } - - public EntityFlame(EntityPlayer player) - { - this(player.worldObj); - - Pos3D playerPos = new Pos3D(player).translate(0, 1.6, 0); - Pos3D flameVec = new Pos3D(1, 1, 1); - - flameVec.multiply(new Pos3D(player.getLook(90))); - flameVec.rotateYaw(6); - - Pos3D mergedVec = playerPos.clone().translate(flameVec); - setPosition(mergedVec.xPos, mergedVec.yPos, mergedVec.zPos); - - Pos3D motion = new Pos3D(0.4, 0.4, 0.4); - motion.multiply(new Pos3D(player.getLookVec())); - - setHeading(motion); - - motionX = motion.xPos; - motionY = motion.yPos; - motionZ = motion.zPos; - - owner = player; - mode = ((ItemFlamethrower)player.getCurrentEquippedItem().getItem()).getMode(player.getCurrentEquippedItem()); - } - - public void setHeading(Pos3D motion) - { - float d = MathHelper.sqrt_double((motion.xPos * motion.xPos) + (motion.zPos * motion.zPos)); - - prevRotationYaw = rotationYaw = (float)(Math.atan2(motion.xPos, motion.zPos) * 180.0D / Math.PI); - prevRotationPitch = rotationPitch = (float)(Math.atan2(motion.yPos, d) * 180.0D / Math.PI); +public class EntityFlame extends Entity implements IEntityAdditionalSpawnData { + public static final int LIFESPAN = 80; + public static final int DAMAGE = 10; + + public Entity owner = null; + public ItemFlamethrower.FlamethrowerMode mode + = ItemFlamethrower.FlamethrowerMode.COMBAT; + + public EntityFlame(World world) { + super(world); + + setSize(0.5F, 0.5F); } - - @Override - public void onUpdate() - { - if(isDead) - { - return; - } - - ticksExisted++; - + + public EntityFlame(EntityPlayer player) { + this(player.worldObj); + + Pos3D playerPos = new Pos3D(player).translate(0, 1.6, 0); + Pos3D flameVec = new Pos3D(1, 1, 1); + + flameVec.multiply(new Pos3D(player.getLook(90))); + flameVec.rotateYaw(6); + + Pos3D mergedVec = playerPos.clone().translate(flameVec); + setPosition(mergedVec.xPos, mergedVec.yPos, mergedVec.zPos); + + Pos3D motion = new Pos3D(0.4, 0.4, 0.4); + motion.multiply(new Pos3D(player.getLookVec())); + + setHeading(motion); + + motionX = motion.xPos; + motionY = motion.yPos; + motionZ = motion.zPos; + + owner = player; + mode = ((ItemFlamethrower) player.getCurrentEquippedItem().getItem()) + .getMode(player.getCurrentEquippedItem()); + } + + public void setHeading(Pos3D motion) { + float d = MathHelper.sqrt_double( + (motion.xPos * motion.xPos) + (motion.zPos * motion.zPos) + ); + + prevRotationYaw = rotationYaw + = (float) (Math.atan2(motion.xPos, motion.zPos) * 180.0D / Math.PI); + prevRotationPitch = rotationPitch + = (float) (Math.atan2(motion.yPos, d) * 180.0D / Math.PI); + } + + @Override + public void onUpdate() { + if (isDead) { + return; + } + + ticksExisted++; + prevPosX = posX; prevPosY = posY; prevPosZ = posZ; - + prevRotationPitch = rotationPitch; prevRotationYaw = rotationYaw; - + posX += motionX; posY += motionY; posZ += motionZ; - - setPosition(posX, posY, posZ); - - calculateVector(); - - if(ticksExisted > LIFESPAN) - { - setDead(); - return; - } - } - - private void calculateVector() - { - Vec3 localVec = Vec3.createVectorHelper(posX, posY, posZ); - Vec3 motionVec = Vec3.createVectorHelper(posX + motionX*2, posY + motionY*2, posZ + motionZ*2); - MovingObjectPosition mop = worldObj.func_147447_a(localVec, motionVec, true, false, false); - localVec = Vec3.createVectorHelper(posX, posY, posZ); - motionVec = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ); - if(mop != null) - { - motionVec = Vec3.createVectorHelper(mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord); + setPosition(posX, posY, posZ); + + calculateVector(); + + if (ticksExisted > LIFESPAN) { + setDead(); + return; + } + } + + private void calculateVector() { + Vec3 localVec = Vec3.createVectorHelper(posX, posY, posZ); + Vec3 motionVec = Vec3.createVectorHelper( + posX + motionX * 2, posY + motionY * 2, posZ + motionZ * 2 + ); + MovingObjectPosition mop + = worldObj.func_147447_a(localVec, motionVec, true, false, false); + localVec = Vec3.createVectorHelper(posX, posY, posZ); + motionVec + = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ); + + if (mop != null) { + motionVec = Vec3.createVectorHelper( + mop.hitVec.xCoord, mop.hitVec.yCoord, mop.hitVec.zCoord + ); } Entity entity = null; - List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D)); + List list = worldObj.getEntitiesWithinAABBExcludingEntity( + this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D) + ); double entityDist = 0.0D; int i; - for(Entity entity1 : (List)list) - { - if((entity1 instanceof EntityItem || entity1.canBeCollidedWith()) && entity1 != owner) - { + for (Entity entity1 : (List) list) { + if ((entity1 instanceof EntityItem || entity1.canBeCollidedWith()) + && entity1 != owner) { float boundsScale = 0.3F; - AxisAlignedBB newBounds = entity1.boundingBox.expand((double)boundsScale, (double)boundsScale, (double)boundsScale); - MovingObjectPosition movingobjectposition1 = newBounds.calculateIntercept(localVec, motionVec); + AxisAlignedBB newBounds = entity1.boundingBox.expand( + (double) boundsScale, (double) boundsScale, (double) boundsScale + ); + MovingObjectPosition movingobjectposition1 + = newBounds.calculateIntercept(localVec, motionVec); - if(movingobjectposition1 != null) - { + if (movingobjectposition1 != null) { double dist = localVec.distanceTo(movingobjectposition1.hitVec); - if(dist < entityDist || entityDist == 0) - { + if (dist < entityDist || entityDist == 0) { entity = entity1; entityDist = dist; } @@ -147,178 +151,203 @@ public class EntityFlame extends Entity implements IEntityAdditionalSpawnData } } - if(entity != null) - { + if (entity != null) { mop = new MovingObjectPosition(entity); } - if(mop != null && mop.entityHit instanceof EntityPlayer) - { - EntityPlayer entityplayer = (EntityPlayer)mop.entityHit; + if (mop != null && mop.entityHit instanceof EntityPlayer) { + EntityPlayer entityplayer = (EntityPlayer) mop.entityHit; - if(entityplayer.capabilities.disableDamage || owner instanceof EntityPlayer && !((EntityPlayer)owner).canAttackPlayer(entityplayer)) - { + if (entityplayer.capabilities.disableDamage + || owner instanceof EntityPlayer + && !((EntityPlayer) owner).canAttackPlayer(entityplayer)) { mop = null; } } - if(mop != null) - { - if(mop.entityHit != null && !mop.entityHit.isImmuneToFire()) - { - if(mop.entityHit instanceof EntityItem && mode != ItemFlamethrower.FlamethrowerMode.COMBAT) - { - if(mop.entityHit.ticksExisted > 100) - { - if(!smeltItem((EntityItem)mop.entityHit)) - { - burn(mop.entityHit); - } - } - } - else { - burn(mop.entityHit); - } - } - else { + if (mop != null) { + if (mop.entityHit != null && !mop.entityHit.isImmuneToFire()) { + if (mop.entityHit instanceof EntityItem + && mode != ItemFlamethrower.FlamethrowerMode.COMBAT) { + if (mop.entityHit.ticksExisted > 100) { + if (!smeltItem((EntityItem) mop.entityHit)) { + burn(mop.entityHit); + } + } + } else { + burn(mop.entityHit); + } + } else { Block block = worldObj.getBlock(mop.blockX, mop.blockY, mop.blockZ); int meta = worldObj.getBlockMetadata(mop.blockX, mop.blockY, mop.blockZ); - boolean fluid = MekanismUtils.isFluid(worldObj, new Coord4D(mop)) || MekanismUtils.isDeadFluid(worldObj, new Coord4D(mop)); - - Coord4D sideCoord = new Coord4D(mop.blockX, mop.blockY, mop.blockZ, worldObj.provider.dimensionId).getFromSide(ForgeDirection.getOrientation(mop.sideHit)); - - if(general.aestheticWorldDamage && !fluid && (sideCoord.isAirBlock(worldObj) || sideCoord.isReplaceable(worldObj))) - { - if(mode != ItemFlamethrower.FlamethrowerMode.COMBAT && !smeltBlock(new Coord4D(mop.blockX, mop.blockY, mop.blockZ, worldObj.provider.dimensionId))) - { - if(mode == ItemFlamethrower.FlamethrowerMode.INFERNO && !worldObj.isRemote) - { - worldObj.setBlock(sideCoord.xCoord, sideCoord.yCoord, sideCoord.zCoord, Blocks.fire); - } - } + boolean fluid = MekanismUtils.isFluid(worldObj, new Coord4D(mop)) + || MekanismUtils.isDeadFluid(worldObj, new Coord4D(mop)); + + Coord4D sideCoord + = new Coord4D( + mop.blockX, + mop.blockY, + mop.blockZ, + worldObj.provider.dimensionId + ) + .getFromSide(ForgeDirection.getOrientation(mop.sideHit)); + + if (general.aestheticWorldDamage && !fluid + && (sideCoord.isAirBlock(worldObj) + || sideCoord.isReplaceable(worldObj))) { + if (mode != ItemFlamethrower.FlamethrowerMode.COMBAT + && !smeltBlock(new Coord4D( + mop.blockX, + mop.blockY, + mop.blockZ, + worldObj.provider.dimensionId + ))) { + if (mode == ItemFlamethrower.FlamethrowerMode.INFERNO + && !worldObj.isRemote) { + worldObj.setBlock( + sideCoord.xCoord, + sideCoord.yCoord, + sideCoord.zCoord, + Blocks.fire + ); + } + } } - - if(fluid) - { - spawnParticlesAt(new Pos3D(this)); - worldObj.playSoundAtEntity(this, "random.fizz", 1.0F, 1.0F); + + if (fluid) { + spawnParticlesAt(new Pos3D(this)); + worldObj.playSoundAtEntity(this, "random.fizz", 1.0F, 1.0F); } } - + setDead(); } - } - - private boolean smeltItem(EntityItem item) - { - ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(item.getEntityItem()); - - if(result != null) - { - item.setEntityItemStack(StackUtils.size(result, item.getEntityItem().stackSize)); - item.ticksExisted = 0; - - spawnParticlesAt(new Pos3D(item)); - worldObj.playSoundAtEntity(item, "random.fizz", 1.0F, 1.0F); - - return true; - } - - return false; - } - - private boolean smeltBlock(Coord4D block) - { - ItemStack stack = block.getStack(worldObj); - - if(stack == null) - { - return false; - } - - ItemStack result = FurnaceRecipes.smelting().getSmeltingResult(block.getStack(worldObj)); - - if(result != null) - { - if(!worldObj.isRemote) - { - Block b = block.getBlock(worldObj); - int meta = block.getMetadata(worldObj); - - if(Block.getBlockFromItem(result.getItem()) != Blocks.air) - { - worldObj.setBlock(block.xCoord, block.yCoord, block.zCoord, Block.getBlockFromItem(result.getItem()), result.getItemDamage(), 3); - } - else { - worldObj.setBlockToAir(block.xCoord, block.yCoord, block.zCoord); - - EntityItem item = new EntityItem(worldObj, block.xCoord + 0.5, block.yCoord + 0.5, block.zCoord + 0.5, result.copy()); - item.motionX = 0; - item.motionY = 0; - item.motionZ = 0; - worldObj.spawnEntityInWorld(item); - } - - worldObj.playAuxSFXAtEntity(null, 2001, block.xCoord, block.yCoord, block.zCoord, Block.getIdFromBlock(b) + (meta << 12)); - } - - spawnParticlesAt(new Pos3D(block).translate(0.5, 0.5, 0.5)); - - return true; - } - - return false; - } - - private void burn(Entity entity) - { - entity.setFire(20); + } + + private boolean smeltItem(EntityItem item) { + ItemStack result + = FurnaceRecipes.smelting().getSmeltingResult(item.getEntityItem()); + + if (result != null) { + item.setEntityItemStack( + StackUtils.size(result, item.getEntityItem().stackSize) + ); + item.ticksExisted = 0; + + spawnParticlesAt(new Pos3D(item)); + worldObj.playSoundAtEntity(item, "random.fizz", 1.0F, 1.0F); + + return true; + } + + return false; + } + + private boolean smeltBlock(Coord4D block) { + ItemStack stack = block.getStack(worldObj); + + if (stack == null) { + return false; + } + + ItemStack result + = FurnaceRecipes.smelting().getSmeltingResult(block.getStack(worldObj)); + + if (result != null) { + if (!worldObj.isRemote) { + Block b = block.getBlock(worldObj); + int meta = block.getMetadata(worldObj); + + if (Block.getBlockFromItem(result.getItem()) != Blocks.air) { + worldObj.setBlock( + block.xCoord, + block.yCoord, + block.zCoord, + Block.getBlockFromItem(result.getItem()), + result.getItemDamage(), + 3 + ); + } else { + worldObj.setBlockToAir(block.xCoord, block.yCoord, block.zCoord); + + EntityItem item = new EntityItem( + worldObj, + block.xCoord + 0.5, + block.yCoord + 0.5, + block.zCoord + 0.5, + result.copy() + ); + item.motionX = 0; + item.motionY = 0; + item.motionZ = 0; + worldObj.spawnEntityInWorld(item); + } + + worldObj.playAuxSFXAtEntity( + null, + 2001, + block.xCoord, + block.yCoord, + block.zCoord, + Block.getIdFromBlock(b) + (meta << 12) + ); + } + + spawnParticlesAt(new Pos3D(block).translate(0.5, 0.5, 0.5)); + + return true; + } + + return false; + } + + private void burn(Entity entity) { + entity.setFire(20); entity.attackEntityFrom(getFlamethrowerDamage(), DAMAGE); - } - - private DamageSource getFlamethrowerDamage() - { - if(owner == null) - { - return DamageSource.causeThrownDamage(this, this); - } - else { - return DamageSource.causeThrownDamage(this, owner); - } - } - - private void spawnParticlesAt(Pos3D pos) - { - for(int i = 0; i < 10; i++) - { - worldObj.spawnParticle("smoke", pos.xPos + (rand.nextFloat()-0.5), pos.yPos + (rand.nextFloat()-0.5), pos.zPos + (rand.nextFloat()-0.5), 0, 0, 0); - } - } + } - @Override - protected void entityInit() {} + private DamageSource getFlamethrowerDamage() { + if (owner == null) { + return DamageSource.causeThrownDamage(this, this); + } else { + return DamageSource.causeThrownDamage(this, owner); + } + } - @Override - protected void readEntityFromNBT(NBTTagCompound nbtTags) - { + private void spawnParticlesAt(Pos3D pos) { + for (int i = 0; i < 10; i++) { + worldObj.spawnParticle( + "smoke", + pos.xPos + (rand.nextFloat() - 0.5), + pos.yPos + (rand.nextFloat() - 0.5), + pos.zPos + (rand.nextFloat() - 0.5), + 0, + 0, + 0 + ); + } + } + + @Override + protected void entityInit() {} + + @Override + protected void readEntityFromNBT(NBTTagCompound nbtTags) { mode = ItemFlamethrower.FlamethrowerMode.values()[nbtTags.getInteger("mode")]; } - @Override - protected void writeEntityToNBT(NBTTagCompound nbtTags) - { + @Override + protected void writeEntityToNBT(NBTTagCompound nbtTags) { nbtTags.setInteger("mode", mode.ordinal()); } - @Override - public void writeSpawnData(ByteBuf dataStream) - { + @Override + public void writeSpawnData(ByteBuf dataStream) { dataStream.writeInt(mode.ordinal()); } - @Override - public void readSpawnData(ByteBuf dataStream) - { + @Override + public void readSpawnData(ByteBuf dataStream) { mode = ItemFlamethrower.FlamethrowerMode.values()[dataStream.readInt()]; } } diff --git a/src/main/java/mekanism/common/entity/EntityObsidianTNT.java b/src/main/java/mekanism/common/entity/EntityObsidianTNT.java index 310d71173..b86abb1f1 100644 --- a/src/main/java/mekanism/common/entity/EntityObsidianTNT.java +++ b/src/main/java/mekanism/common/entity/EntityObsidianTNT.java @@ -5,128 +5,112 @@ import net.minecraft.entity.Entity; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; -public class EntityObsidianTNT extends Entity -{ - /** How long the fuse is */ - public int fuse; +public class EntityObsidianTNT extends Entity { + /** How long the fuse is */ + public int fuse; - /** Whether or not the TNT has exploded */ - private boolean hasExploded = false; + /** Whether or not the TNT has exploded */ + private boolean hasExploded = false; - public EntityObsidianTNT(World world) - { - super(world); - fuse = 0; - preventEntitySpawning = true; - setSize(0.98F, 0.98F); - yOffset = height / 2.0F; - } + public EntityObsidianTNT(World world) { + super(world); + fuse = 0; + preventEntitySpawning = true; + setSize(0.98F, 0.98F); + yOffset = height / 2.0F; + } - public EntityObsidianTNT(World world, double x, double y, double z) - { - this(world); + public EntityObsidianTNT(World world, double x, double y, double z) { + this(world); - setPosition(x, y, z); + setPosition(x, y, z); - float randPi = (float)(Math.random()*Math.PI*2); + float randPi = (float) (Math.random() * Math.PI * 2); - motionX = -(Math.sin(randPi))*0.02F; - motionY = 0.2; - motionZ = -(Math.cos(randPi))*0.02F; + motionX = -(Math.sin(randPi)) * 0.02F; + motionY = 0.2; + motionZ = -(Math.cos(randPi)) * 0.02F; - fuse = general.obsidianTNTDelay; + fuse = general.obsidianTNTDelay; - prevPosX = x; - prevPosY = y; - prevPosZ = z; - } + prevPosX = x; + prevPosY = y; + prevPosZ = z; + } - @Override - protected void entityInit() {} + @Override + protected void entityInit() {} - @Override - protected boolean canTriggerWalking() - { - return false; - } + @Override + protected boolean canTriggerWalking() { + return false; + } - @Override - public boolean canBeCollidedWith() - { - return !isDead; - } + @Override + public boolean canBeCollidedWith() { + return !isDead; + } - @Override - public boolean canBePushed() - { - return true; - } + @Override + public boolean canBePushed() { + return true; + } - @Override - public void onUpdate() - { - prevPosX = posX; - prevPosY = posY; - prevPosZ = posZ; + @Override + public void onUpdate() { + prevPosX = posX; + prevPosY = posY; + prevPosZ = posZ; - motionY -= 0.04; + motionY -= 0.04; - moveEntity(motionX, motionY, motionZ); + moveEntity(motionX, motionY, motionZ); - motionX *= 0.98; - motionY *= 0.98; - motionZ *= 0.98; + motionX *= 0.98; + motionY *= 0.98; + motionZ *= 0.98; - if(onGround) - { - motionX *= 0.7; - motionZ *= 0.7; - motionY *= -0.5; - } + if (onGround) { + motionX *= 0.7; + motionZ *= 0.7; + motionY *= -0.5; + } - if(fuse-- <= 0) - { - if(!worldObj.isRemote) - { - setDead(); - explode(); - } - else { - if(hasExploded) - { - setDead(); - } - else { - worldObj.spawnParticle("lava", posX, posY + 0.5, posZ, 0, 0, 0); - } - } - } - else { - worldObj.spawnParticle("lava", posX, posY + 0.5, posZ, 0, 0, 0); - } - } + if (fuse-- <= 0) { + if (!worldObj.isRemote) { + setDead(); + explode(); + } else { + if (hasExploded) { + setDead(); + } else { + worldObj.spawnParticle("lava", posX, posY + 0.5, posZ, 0, 0, 0); + } + } + } else { + worldObj.spawnParticle("lava", posX, posY + 0.5, posZ, 0, 0, 0); + } + } - private void explode() - { - worldObj.createExplosion(null, posX, posY, posZ, general.obsidianTNTBlastRadius, true); - hasExploded = true; - } + private void explode() { + worldObj.createExplosion( + null, posX, posY, posZ, general.obsidianTNTBlastRadius, true + ); + hasExploded = true; + } - @Override - protected void writeEntityToNBT(NBTTagCompound nbtTags) - { - nbtTags.setByte("Fuse", (byte)fuse); - } + @Override + protected void writeEntityToNBT(NBTTagCompound nbtTags) { + nbtTags.setByte("Fuse", (byte) fuse); + } - @Override - protected void readEntityFromNBT(NBTTagCompound nbtTags) - { - fuse = nbtTags.getByte("Fuse"); - } + @Override + protected void readEntityFromNBT(NBTTagCompound nbtTags) { + fuse = nbtTags.getByte("Fuse"); + } - @Override - public float getShadowSize() - { - return 0; - } + @Override + public float getShadowSize() { + return 0; + } } diff --git a/src/main/java/mekanism/common/entity/EntityRobit.java b/src/main/java/mekanism/common/entity/EntityRobit.java index c34dd0eca..995ba0f7b 100644 --- a/src/main/java/mekanism/common/entity/EntityRobit.java +++ b/src/main/java/mekanism/common/entity/EntityRobit.java @@ -1,12 +1,13 @@ package mekanism.common.entity; -import ic2.api.item.ElectricItem; -import ic2.api.item.IElectricItem; - import java.math.BigDecimal; import java.math.RoundingMode; import java.util.List; +import cofh.api.energy.IEnergyContainerItem; +import cpw.mods.fml.common.Optional.Interface; +import ic2.api.item.ElectricItem; +import ic2.api.item.IElectricItem; import mekanism.api.Coord4D; import mekanism.api.MekanismConfig.general; import mekanism.api.energy.EnergizedItemManager; @@ -41,701 +42,656 @@ import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraftforge.common.ForgeHooks; import net.minecraftforge.common.util.Constants; -import cofh.api.energy.IEnergyContainerItem; -import cpw.mods.fml.common.Optional.Interface; -@Interface(iface = "micdoodle8.mods.galacticraft.api.entity.IEntityBreathable", modid = "Galacticraft API") -public class EntityRobit extends EntityCreature implements IInventory, ISustainedInventory, IEntityBreathable -{ - public double MAX_ELECTRICITY = 100000; +@Interface( + iface = "micdoodle8.mods.galacticraft.api.entity.IEntityBreathable", + modid = "Galacticraft API" +) +public class EntityRobit + extends EntityCreature implements IInventory, ISustainedInventory, IEntityBreathable { + public double MAX_ELECTRICITY = 100000; - public Coord4D homeLocation; + public Coord4D homeLocation; - public ItemStack[] inventory = new ItemStack[31]; + public ItemStack[] inventory = new ItemStack[31]; - public int furnaceBurnTime = 0; - public int currentItemBurnTime = 0; - public int furnaceCookTime = 0; + public int furnaceBurnTime = 0; + public int currentItemBurnTime = 0; + public int furnaceCookTime = 0; - public boolean texTick; + public boolean texTick; - public EntityRobit(World world) - { - super(world); + public EntityRobit(World world) { + super(world); - setSize(0.5F, 0.5F); + setSize(0.5F, 0.5F); - getNavigator().setAvoidsWater(true); + getNavigator().setAvoidsWater(true); - tasks.addTask(1, new RobitAIPickup(this, 1.0F)); - tasks.addTask(2, new RobitAIFollow(this, 1.0F, 4.0F, 2.0F)); - tasks.addTask(3, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); - tasks.addTask(3, new EntityAILookIdle(this)); - tasks.addTask(4, new EntityAISwimming(this)); + tasks.addTask(1, new RobitAIPickup(this, 1.0F)); + tasks.addTask(2, new RobitAIFollow(this, 1.0F, 4.0F, 2.0F)); + tasks.addTask(3, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); + tasks.addTask(3, new EntityAILookIdle(this)); + tasks.addTask(4, new EntityAISwimming(this)); - setAlwaysRenderNameTag(true); - } + setAlwaysRenderNameTag(true); + } - public EntityRobit(World world, double x, double y, double z) - { - this(world); + public EntityRobit(World world, double x, double y, double z) { + this(world); - setPosition(x, y, z); + setPosition(x, y, z); - prevPosX = x; - prevPosY = y; - prevPosZ = z; - } + prevPosX = x; + prevPosY = y; + prevPosZ = z; + } - @Override - protected void applyEntityAttributes() - { - super.applyEntityAttributes(); + @Override + protected void applyEntityAttributes() { + super.applyEntityAttributes(); - getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.3); - getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(1); - } + getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.3); + getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(1); + } - @Override - public boolean isAIEnabled() - { - return true; - } + @Override + public boolean isAIEnabled() { + return true; + } - @Override - protected boolean canDespawn() - { - return false; - } + @Override + protected boolean canDespawn() { + return false; + } - @Override - protected void updateAITick() {} + @Override + protected void updateAITick() {} - @Override - protected void entityInit() - { - super.entityInit(); + @Override + protected void entityInit() { + super.entityInit(); - dataWatcher.addObject(12, new String("")); /* Electricity */ - dataWatcher.addObject(13, new String("")); /* Owner */ - dataWatcher.addObject(14, new Byte((byte)0)); /* Follow */ - dataWatcher.addObject(15, new String("")); /* Name */ - dataWatcher.addObject(16, new Byte((byte)0)); /* Drop Pickup */ - } + dataWatcher.addObject(12, new String("")); /* Electricity */ + dataWatcher.addObject(13, new String("")); /* Owner */ + dataWatcher.addObject(14, new Byte((byte) 0)); /* Follow */ + dataWatcher.addObject(15, new String("")); /* Name */ + dataWatcher.addObject(16, new Byte((byte) 0)); /* Drop Pickup */ + } - public double getRoundedTravelEnergy() - { - return new BigDecimal(getDistance(prevPosX, prevPosY, prevPosZ)*1.5).setScale(2, RoundingMode.HALF_EVEN).doubleValue(); - } + public double getRoundedTravelEnergy() { + return new BigDecimal(getDistance(prevPosX, prevPosY, prevPosZ) * 1.5) + .setScale(2, RoundingMode.HALF_EVEN) + .doubleValue(); + } - @Override - public void onEntityUpdate() - { - if(!worldObj.isRemote) - { - if(getFollowing() && getOwner() != null && getDistanceSqToEntity(getOwner()) > 4 && !getNavigator().noPath() && getEnergy() > 0) - { - setEnergy(getEnergy() - getRoundedTravelEnergy()); - } - } + @Override + public void onEntityUpdate() { + if (!worldObj.isRemote) { + if (getFollowing() && getOwner() != null + && getDistanceSqToEntity(getOwner()) > 4 && !getNavigator().noPath() + && getEnergy() > 0) { + setEnergy(getEnergy() - getRoundedTravelEnergy()); + } + } - super.onEntityUpdate(); + super.onEntityUpdate(); - if(!worldObj.isRemote) - { - if(getDropPickup()) - { - collectItems(); - } + if (!worldObj.isRemote) { + if (getDropPickup()) { + collectItems(); + } - if(homeLocation == null) - { - setDead(); + if (homeLocation == null) { + setDead(); - return; - } + return; + } - if(!(homeLocation.getTileEntity(MinecraftServer.getServer().worldServerForDimension(homeLocation.dimensionId)) instanceof TileEntityChargepad)) - { - drop(); - setDead(); + if (!(homeLocation.getTileEntity( + MinecraftServer.getServer().worldServerForDimension( + homeLocation.dimensionId + ) + ) instanceof TileEntityChargepad)) { + drop(); + setDead(); - return; - } + return; + } - if(getEnergy() == 0 && !isOnChargepad()) - { - goHome(); - } + if (getEnergy() == 0 && !isOnChargepad()) { + goHome(); + } - if(inventory[27] != null && getEnergy() < MAX_ELECTRICITY) - { - if(inventory[27].getItem() instanceof IEnergizedItem) - { - setEnergy(getEnergy() + EnergizedItemManager.discharge(inventory[27], MAX_ELECTRICITY - getEnergy())); - } - else if(MekanismUtils.useIC2() && inventory[27].getItem() instanceof IElectricItem) - { - IElectricItem item = (IElectricItem)inventory[27].getItem(); + if (inventory[27] != null && getEnergy() < MAX_ELECTRICITY) { + if (inventory[27].getItem() instanceof IEnergizedItem) { + setEnergy( + getEnergy() + + EnergizedItemManager.discharge( + inventory[27], MAX_ELECTRICITY - getEnergy() + ) + ); + } else if (MekanismUtils.useIC2() && inventory[27].getItem() instanceof IElectricItem) { + IElectricItem item = (IElectricItem) inventory[27].getItem(); - if(item.canProvideEnergy(inventory[27])) - { - double gain = ElectricItem.manager.discharge(inventory[27], (MAX_ELECTRICITY - getEnergy())* general.TO_IC2, 4, true, true, false)* general.FROM_IC2; - setEnergy(getEnergy() + gain); - } - } - else if(MekanismUtils.useRF() && inventory[27].getItem() instanceof IEnergyContainerItem) - { - ItemStack itemStack = inventory[27]; - IEnergyContainerItem item = (IEnergyContainerItem)inventory[27].getItem(); + if (item.canProvideEnergy(inventory[27])) { + double gain + = ElectricItem.manager.discharge( + inventory[27], + (MAX_ELECTRICITY - getEnergy()) * general.TO_IC2, + 4, + true, + true, + false + ) + * general.FROM_IC2; + setEnergy(getEnergy() + gain); + } + } else if (MekanismUtils.useRF() && inventory[27].getItem() instanceof IEnergyContainerItem) { + ItemStack itemStack = inventory[27]; + IEnergyContainerItem item + = (IEnergyContainerItem) inventory[27].getItem(); - int itemEnergy = (int)Math.round(Math.min(Math.sqrt(item.getMaxEnergyStored(itemStack)), item.getEnergyStored(itemStack))); - int toTransfer = (int)Math.round(Math.min(itemEnergy, ((MAX_ELECTRICITY - getEnergy())* general.TO_TE))); + int itemEnergy = (int) Math.round(Math.min( + Math.sqrt(item.getMaxEnergyStored(itemStack)), + item.getEnergyStored(itemStack) + )); + int toTransfer = (int) Math.round(Math.min( + itemEnergy, ((MAX_ELECTRICITY - getEnergy()) * general.TO_TE) + )); - setEnergy(getEnergy() + (item.extractEnergy(itemStack, toTransfer, false)* general.FROM_TE)); - } + setEnergy( + getEnergy() + + (item.extractEnergy(itemStack, toTransfer, false) + * general.FROM_TE) + ); + } else if(inventory[27].getItem() == Items.redstone && getEnergy()+ general.ENERGY_PER_REDSTONE <= MAX_ELECTRICITY) { - setEnergy(getEnergy() + general.ENERGY_PER_REDSTONE); - inventory[27].stackSize--; + setEnergy(getEnergy() + general.ENERGY_PER_REDSTONE); + inventory[27].stackSize--; - if(inventory[27].stackSize <= 0) - { - inventory[27] = null; - } - } - } + if (inventory[27].stackSize <= 0) { + inventory[27] = null; + } + } + } - if(furnaceBurnTime > 0) - { - furnaceBurnTime--; - } + if (furnaceBurnTime > 0) { + furnaceBurnTime--; + } - if(!worldObj.isRemote) - { - if(furnaceBurnTime == 0 && canSmelt()) - { - currentItemBurnTime = furnaceBurnTime = TileEntityFurnace.getItemBurnTime(inventory[29]); + if (!worldObj.isRemote) { + if (furnaceBurnTime == 0 && canSmelt()) { + currentItemBurnTime = furnaceBurnTime + = TileEntityFurnace.getItemBurnTime(inventory[29]); - if(furnaceBurnTime > 0) - { - if(inventory[29] != null) - { - inventory[29].stackSize--; + if (furnaceBurnTime > 0) { + if (inventory[29] != null) { + inventory[29].stackSize--; - if(inventory[29].stackSize == 0) - { - inventory[29] = inventory[29].getItem().getContainerItem(inventory[29]); - } - } - } - } + if (inventory[29].stackSize == 0) { + inventory[29] = inventory[29].getItem().getContainerItem( + inventory[29] + ); + } + } + } + } - if(furnaceBurnTime > 0 && canSmelt()) - { - furnaceCookTime++; + if (furnaceBurnTime > 0 && canSmelt()) { + furnaceCookTime++; - if(furnaceCookTime == 200) - { - furnaceCookTime = 0; - smeltItem(); - } - } - else { - furnaceCookTime = 0; - } - } - } - } + if (furnaceCookTime == 200) { + furnaceCookTime = 0; + smeltItem(); + } + } else { + furnaceCookTime = 0; + } + } + } + } - private void collectItems() - { - List items = worldObj.getEntitiesWithinAABB(EntityItem.class, boundingBox.expand(1.5, 1.5, 1.5)); + private void collectItems() { + List items = worldObj.getEntitiesWithinAABB( + EntityItem.class, boundingBox.expand(1.5, 1.5, 1.5) + ); - if(items != null && !items.isEmpty()) - { - for(EntityItem item : items) - { - if(item.delayBeforeCanPickup > 0 || item.getEntityItem().getItem() instanceof ItemRobit) - { - continue; - } + if (items != null && !items.isEmpty()) { + for (EntityItem item : items) { + if (item.delayBeforeCanPickup > 0 + || item.getEntityItem().getItem() instanceof ItemRobit) { + continue; + } - for(int i = 0; i < 27; i++) - { - ItemStack itemStack = inventory[i]; + for (int i = 0; i < 27; i++) { + ItemStack itemStack = inventory[i]; - if(itemStack == null) - { - inventory[i] = item.getEntityItem(); - onItemPickup(item, item.getEntityItem().stackSize); - item.setDead(); + if (itemStack == null) { + inventory[i] = item.getEntityItem(); + onItemPickup(item, item.getEntityItem().stackSize); + item.setDead(); - playSound("random.pop", 1.0F, ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); + playSound( + "random.pop", + 1.0F, + ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F + ); - break; - } + break; + } else if(itemStack.isItemEqual(item.getEntityItem()) && itemStack.stackSize < itemStack.getMaxStackSize()) { - int needed = itemStack.getMaxStackSize() - itemStack.stackSize; - int toAdd = Math.min(needed, item.getEntityItem().stackSize); - - itemStack.stackSize += toAdd; - item.getEntityItem().stackSize -= toAdd; - - onItemPickup(item, toAdd); - - if(item.getEntityItem().stackSize == 0) - { - item.setDead(); - } - - playSound("random.pop", 1.0F, ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); - - break; - } - } - } - } - } - - public void goHome() - { - setFollowing(false); - - if(worldObj.provider.dimensionId != homeLocation.dimensionId) - { - travelToDimension(homeLocation.dimensionId); - } - - setPositionAndUpdate(homeLocation.xCoord+0.5, homeLocation.yCoord+0.3, homeLocation.zCoord+0.5); - - motionX = 0; - motionY = 0; - motionZ = 0; - } - - private boolean canSmelt() - { - if(inventory[28] == null) - { - return false; - } - else { - ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(inventory[28]); - if(itemstack == null) return false; - if(inventory[30] == null) return true; - if(!inventory[30].isItemEqual(itemstack)) return false; - int result = inventory[30].stackSize + itemstack.stackSize; - return (result <= getInventoryStackLimit() && result <= itemstack.getMaxStackSize()); - } - } - - public void smeltItem() - { - if(canSmelt()) - { - ItemStack itemstack = FurnaceRecipes.smelting().getSmeltingResult(inventory[28]); - - if(inventory[30] == null) - { - inventory[30] = itemstack.copy(); - } - else if(inventory[30].isItemEqual(itemstack)) - { - inventory[30].stackSize += itemstack.stackSize; - } - - inventory[28].stackSize--; - - if(inventory[28].stackSize <= 0) - { - inventory[28] = null; - } - } - } - - public boolean isOnChargepad() - { - int x = MathHelper.floor_double(posX); - int y = MathHelper.floor_double(posY); - int z = MathHelper.floor_double(posZ); - - if(worldObj.getTileEntity(x, y, z) instanceof TileEntityChargepad) - { - return true; - } - - return false; - } - - @Override - public boolean interact(EntityPlayer entityplayer) - { - if(entityplayer.isSneaking()) - { - ItemStack itemStack = entityplayer.getCurrentEquippedItem(); - - if(itemStack != null && itemStack.getItem() instanceof ItemConfigurator) - { - if(!worldObj.isRemote) - { - drop(); - } - - setDead(); - - entityplayer.swingItem(); - return true; - } - } - else { - entityplayer.openGui(Mekanism.instance, 21, worldObj, getEntityId(), 0, 0); - } - - return false; - } - - public void drop() - { - EntityItem entityItem = new EntityItem(worldObj, posX, posY+0.3, posZ, new ItemStack(MekanismItems.Robit)); - - ItemRobit item = (ItemRobit)entityItem.getEntityItem().getItem(); - item.setEnergy(entityItem.getEntityItem(), getEnergy()); - item.setInventory(getInventory(), entityItem.getEntityItem()); - item.setName(entityItem.getEntityItem(), getCommandSenderName()); - - float k = 0.05F; - entityItem.motionX = 0; - entityItem.motionY = rand.nextGaussian() * k + 0.2F; - entityItem.motionZ = 0; - - worldObj.spawnEntityInWorld(entityItem); - } - - @Override - public void writeEntityToNBT(NBTTagCompound nbtTags) - { - super.writeEntityToNBT(nbtTags); - - nbtTags.setDouble("electricityStored", getEnergy()); - - nbtTags.setString("name", getName()); - - if(getOwnerName() != null) - { - nbtTags.setString("owner", getOwnerName()); - } - - nbtTags.setBoolean("follow", getFollowing()); - - nbtTags.setBoolean("dropPickup", getDropPickup()); - - homeLocation.write(nbtTags); - - NBTTagList tagList = new NBTTagList(); - - for(int slotCount = 0; slotCount < inventory.length; slotCount++) - { - if(inventory[slotCount] != null) - { - NBTTagCompound tagCompound = new NBTTagCompound(); - tagCompound.setByte("Slot", (byte)slotCount); - inventory[slotCount].writeToNBT(tagCompound); - tagList.appendTag(tagCompound); - } - } - - nbtTags.setTag("Items", tagList); - } - - @Override - public void readEntityFromNBT(NBTTagCompound nbtTags) - { - super.readEntityFromNBT(nbtTags); - - setEnergy(nbtTags.getDouble("electricityStored")); - - setName(nbtTags.getString("name")); - - if(nbtTags.hasKey("owner")) - { - setOwner(nbtTags.getString("owner")); - } - - setFollowing(nbtTags.getBoolean("follow")); - - setDropPickup(nbtTags.getBoolean("dropPickup")); - - homeLocation = Coord4D.read(nbtTags); - - NBTTagList tagList = nbtTags.getTagList("Items", Constants.NBT.TAG_COMPOUND); - inventory = new ItemStack[getSizeInventory()]; - - for(int tagCount = 0; tagCount < tagList.tagCount(); tagCount++) - { - NBTTagCompound tagCompound = (NBTTagCompound)tagList.getCompoundTagAt(tagCount); - byte slotID = tagCompound.getByte("Slot"); - - if(slotID >= 0 && slotID < inventory.length) - { - inventory[slotID] = ItemStack.loadItemStackFromNBT(tagCompound); - } - } - } - - @Override - protected void damageEntity(DamageSource damageSource, float amount) - { - amount = ForgeHooks.onLivingHurt(this, damageSource, amount); - - if(amount <= 0) - { - return; - } - - amount = applyArmorCalculations(damageSource, amount); - amount = applyPotionDamageCalculations(damageSource, amount); - float j = getHealth(); - - setEnergy(Math.max(0, getEnergy() - (amount*1000))); - func_110142_aN().func_94547_a(damageSource, j, amount); - } - - @Override - protected void onDeathUpdate() {} - - public void setHome(Coord4D home) - { - homeLocation = home; - } - - @Override - public boolean canBePushed() - { - return getEnergy() > 0; - } - - public double getEnergy() - { - try { - return Double.parseDouble(dataWatcher.getWatchableObjectString(12)); - } catch(Exception e) { - return 0; - } - } - - public void setEnergy(double energy) - { - dataWatcher.updateObject(12, Double.toString(Math.max(Math.min(energy, MAX_ELECTRICITY), 0))); - } - - public EntityPlayer getOwner() - { - return worldObj.getPlayerEntityByName(getOwnerName()); - } - - public String getOwnerName() - { - return dataWatcher.getWatchableObjectString(13); - } - - public void setOwner(String username) - { - dataWatcher.updateObject(13, username); - } - - public boolean getFollowing() - { - return dataWatcher.getWatchableObjectByte(14) == 1; - } - - public void setFollowing(boolean follow) - { - dataWatcher.updateObject(14, follow ? (byte)1 : (byte)0); - } - - public String getName() - { - return dataWatcher.getWatchableObjectString(15); - } - - public void setName(String name) - { - dataWatcher.updateObject(15, name); - } - - public boolean getDropPickup() - { - return dataWatcher.getWatchableObjectByte(16) == 1; - } - - public void setDropPickup(boolean pickup) - { - dataWatcher.updateObject(16, pickup ? (byte)1 : (byte)0); - } - - @Override - public int getSizeInventory() - { - return inventory.length; - } - - @Override - public ItemStack getStackInSlot(int slotID) - { - return inventory[slotID]; - } - - @Override - public ItemStack decrStackSize(int slotID, int amount) - { - if(getStackInSlot(slotID) != null) - { - ItemStack tempStack; - - if(getStackInSlot(slotID).stackSize <= amount) - { - tempStack = getStackInSlot(slotID); - setInventorySlotContents(slotID, null); - return tempStack; - } - else { - tempStack = getStackInSlot(slotID).splitStack(amount); - - if(getStackInSlot(slotID).stackSize == 0) - { - setInventorySlotContents(slotID, null); - } - - return tempStack; - } - } - else { - return null; - } - } - - @Override - public ItemStack getStackInSlotOnClosing(int slotID) - { - if(getStackInSlot(slotID) != null) - { - ItemStack tempStack = getStackInSlot(slotID); - setInventorySlotContents(slotID, null); - return tempStack; - } - else { - return null; - } - } - - @Override - public void setInventorySlotContents(int slotID, ItemStack itemstack) - { - inventory[slotID] = itemstack; - - if(itemstack != null && itemstack.stackSize > getInventoryStackLimit()) - { - itemstack.stackSize = getInventoryStackLimit(); - } - } - - @Override - public String getInventoryName() - { - return "Robit"; - } - - @Override - public boolean hasCustomInventoryName() - { - return true; - } - - @Override - public int getInventoryStackLimit() - { - return 64; - } - - @Override - public void markDirty() {} - - @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) - { - return true; - } - - @Override - public void openInventory() {} - - @Override - public void closeInventory() {} - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) - { - return true; - } - - @Override - public void setInventory(NBTTagList nbtTags, Object... data) - { - if(nbtTags == null || nbtTags.tagCount() == 0) - { - return; - } - - inventory = new ItemStack[getSizeInventory()]; - - for(int slots = 0; slots < nbtTags.tagCount(); slots++) - { - NBTTagCompound tagCompound = (NBTTagCompound)nbtTags.getCompoundTagAt(slots); - byte slotID = tagCompound.getByte("Slot"); - - if(slotID >= 0 && slotID < inventory.length) - { - inventory[slotID] = ItemStack.loadItemStackFromNBT(tagCompound); - } - } - } - - @Override - public NBTTagList getInventory(Object... data) - { - NBTTagList tagList = new NBTTagList(); - - for(int slots = 0; slots < inventory.length; slots++) - { - if(inventory[slots] != null) - { - NBTTagCompound tagCompound = new NBTTagCompound(); - tagCompound.setByte("Slot", (byte)slots); - inventory[slots].writeToNBT(tagCompound); - tagList.appendTag(tagCompound); - } - } - - return tagList; - } - - @Override - public String getCommandSenderName() - { - return getName().isEmpty() ? "Robit" : getName(); - } - - @Override - public float getShadowSize() - { - return 0.25F; - } - - @Override - public boolean canBreath() - { - return true; - } + int needed = itemStack.getMaxStackSize() - itemStack.stackSize; + int toAdd = Math.min(needed, item.getEntityItem().stackSize); + + itemStack.stackSize += toAdd; + item.getEntityItem().stackSize -= toAdd; + + onItemPickup(item, toAdd); + + if (item.getEntityItem().stackSize == 0) { + item.setDead(); + } + + playSound( + "random.pop", + 1.0F, + ((rand.nextFloat() - rand.nextFloat()) * 0.7F + 1.0F) * 2.0F + ); + + break; + } + } + } + } + } + + public void goHome() { + setFollowing(false); + + if (worldObj.provider.dimensionId != homeLocation.dimensionId) { + travelToDimension(homeLocation.dimensionId); + } + + setPositionAndUpdate( + homeLocation.xCoord + 0.5, + homeLocation.yCoord + 0.3, + homeLocation.zCoord + 0.5 + ); + + motionX = 0; + motionY = 0; + motionZ = 0; + } + + private boolean canSmelt() { + if (inventory[28] == null) { + return false; + } else { + ItemStack itemstack + = FurnaceRecipes.smelting().getSmeltingResult(inventory[28]); + if (itemstack == null) + return false; + if (inventory[30] == null) + return true; + if (!inventory[30].isItemEqual(itemstack)) + return false; + int result = inventory[30].stackSize + itemstack.stackSize; + return ( + result <= getInventoryStackLimit() + && result <= itemstack.getMaxStackSize() + ); + } + } + + public void smeltItem() { + if (canSmelt()) { + ItemStack itemstack + = FurnaceRecipes.smelting().getSmeltingResult(inventory[28]); + + if (inventory[30] == null) { + inventory[30] = itemstack.copy(); + } else if (inventory[30].isItemEqual(itemstack)) { + inventory[30].stackSize += itemstack.stackSize; + } + + inventory[28].stackSize--; + + if (inventory[28].stackSize <= 0) { + inventory[28] = null; + } + } + } + + public boolean isOnChargepad() { + int x = MathHelper.floor_double(posX); + int y = MathHelper.floor_double(posY); + int z = MathHelper.floor_double(posZ); + + if (worldObj.getTileEntity(x, y, z) instanceof TileEntityChargepad) { + return true; + } + + return false; + } + + @Override + public boolean interact(EntityPlayer entityplayer) { + if (entityplayer.isSneaking()) { + ItemStack itemStack = entityplayer.getCurrentEquippedItem(); + + if (itemStack != null && itemStack.getItem() instanceof ItemConfigurator) { + if (!worldObj.isRemote) { + drop(); + } + + setDead(); + + entityplayer.swingItem(); + return true; + } + } else { + entityplayer.openGui(Mekanism.instance, 21, worldObj, getEntityId(), 0, 0); + } + + return false; + } + + public void drop() { + EntityItem entityItem = new EntityItem( + worldObj, posX, posY + 0.3, posZ, new ItemStack(MekanismItems.Robit) + ); + + ItemRobit item = (ItemRobit) entityItem.getEntityItem().getItem(); + item.setEnergy(entityItem.getEntityItem(), getEnergy()); + item.setInventory(getInventory(), entityItem.getEntityItem()); + item.setName(entityItem.getEntityItem(), getCommandSenderName()); + + float k = 0.05F; + entityItem.motionX = 0; + entityItem.motionY = rand.nextGaussian() * k + 0.2F; + entityItem.motionZ = 0; + + worldObj.spawnEntityInWorld(entityItem); + } + + @Override + public void writeEntityToNBT(NBTTagCompound nbtTags) { + super.writeEntityToNBT(nbtTags); + + nbtTags.setDouble("electricityStored", getEnergy()); + + nbtTags.setString("name", getName()); + + if (getOwnerName() != null) { + nbtTags.setString("owner", getOwnerName()); + } + + nbtTags.setBoolean("follow", getFollowing()); + + nbtTags.setBoolean("dropPickup", getDropPickup()); + + homeLocation.write(nbtTags); + + NBTTagList tagList = new NBTTagList(); + + for (int slotCount = 0; slotCount < inventory.length; slotCount++) { + if (inventory[slotCount] != null) { + NBTTagCompound tagCompound = new NBTTagCompound(); + tagCompound.setByte("Slot", (byte) slotCount); + inventory[slotCount].writeToNBT(tagCompound); + tagList.appendTag(tagCompound); + } + } + + nbtTags.setTag("Items", tagList); + } + + @Override + public void readEntityFromNBT(NBTTagCompound nbtTags) { + super.readEntityFromNBT(nbtTags); + + setEnergy(nbtTags.getDouble("electricityStored")); + + setName(nbtTags.getString("name")); + + if (nbtTags.hasKey("owner")) { + setOwner(nbtTags.getString("owner")); + } + + setFollowing(nbtTags.getBoolean("follow")); + + setDropPickup(nbtTags.getBoolean("dropPickup")); + + homeLocation = Coord4D.read(nbtTags); + + NBTTagList tagList = nbtTags.getTagList("Items", Constants.NBT.TAG_COMPOUND); + inventory = new ItemStack[getSizeInventory()]; + + for (int tagCount = 0; tagCount < tagList.tagCount(); tagCount++) { + NBTTagCompound tagCompound + = (NBTTagCompound) tagList.getCompoundTagAt(tagCount); + byte slotID = tagCompound.getByte("Slot"); + + if (slotID >= 0 && slotID < inventory.length) { + inventory[slotID] = ItemStack.loadItemStackFromNBT(tagCompound); + } + } + } + + @Override + protected void damageEntity(DamageSource damageSource, float amount) { + amount = ForgeHooks.onLivingHurt(this, damageSource, amount); + + if (amount <= 0) { + return; + } + + amount = applyArmorCalculations(damageSource, amount); + amount = applyPotionDamageCalculations(damageSource, amount); + float j = getHealth(); + + setEnergy(Math.max(0, getEnergy() - (amount * 1000))); + func_110142_aN().func_94547_a(damageSource, j, amount); + } + + @Override + protected void onDeathUpdate() {} + + public void setHome(Coord4D home) { + homeLocation = home; + } + + @Override + public boolean canBePushed() { + return getEnergy() > 0; + } + + public double getEnergy() { + try { + return Double.parseDouble(dataWatcher.getWatchableObjectString(12)); + } catch (Exception e) { + return 0; + } + } + + public void setEnergy(double energy) { + dataWatcher.updateObject( + 12, Double.toString(Math.max(Math.min(energy, MAX_ELECTRICITY), 0)) + ); + } + + public EntityPlayer getOwner() { + return worldObj.getPlayerEntityByName(getOwnerName()); + } + + public String getOwnerName() { + return dataWatcher.getWatchableObjectString(13); + } + + public void setOwner(String username) { + dataWatcher.updateObject(13, username); + } + + public boolean getFollowing() { + return dataWatcher.getWatchableObjectByte(14) == 1; + } + + public void setFollowing(boolean follow) { + dataWatcher.updateObject(14, follow ? (byte) 1 : (byte) 0); + } + + public String getName() { + return dataWatcher.getWatchableObjectString(15); + } + + public void setName(String name) { + dataWatcher.updateObject(15, name); + } + + public boolean getDropPickup() { + return dataWatcher.getWatchableObjectByte(16) == 1; + } + + public void setDropPickup(boolean pickup) { + dataWatcher.updateObject(16, pickup ? (byte) 1 : (byte) 0); + } + + @Override + public int getSizeInventory() { + return inventory.length; + } + + @Override + public ItemStack getStackInSlot(int slotID) { + return inventory[slotID]; + } + + @Override + public ItemStack decrStackSize(int slotID, int amount) { + if (getStackInSlot(slotID) != null) { + ItemStack tempStack; + + if (getStackInSlot(slotID).stackSize <= amount) { + tempStack = getStackInSlot(slotID); + setInventorySlotContents(slotID, null); + return tempStack; + } else { + tempStack = getStackInSlot(slotID).splitStack(amount); + + if (getStackInSlot(slotID).stackSize == 0) { + setInventorySlotContents(slotID, null); + } + + return tempStack; + } + } else { + return null; + } + } + + @Override + public ItemStack getStackInSlotOnClosing(int slotID) { + if (getStackInSlot(slotID) != null) { + ItemStack tempStack = getStackInSlot(slotID); + setInventorySlotContents(slotID, null); + return tempStack; + } else { + return null; + } + } + + @Override + public void setInventorySlotContents(int slotID, ItemStack itemstack) { + inventory[slotID] = itemstack; + + if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { + itemstack.stackSize = getInventoryStackLimit(); + } + } + + @Override + public String getInventoryName() { + return "Robit"; + } + + @Override + public boolean hasCustomInventoryName() { + return true; + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + @Override + public void markDirty() {} + + @Override + public boolean isUseableByPlayer(EntityPlayer entityplayer) { + return true; + } + + @Override + public void openInventory() {} + + @Override + public void closeInventory() {} + + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return true; + } + + @Override + public void setInventory(NBTTagList nbtTags, Object... data) { + if (nbtTags == null || nbtTags.tagCount() == 0) { + return; + } + + inventory = new ItemStack[getSizeInventory()]; + + for (int slots = 0; slots < nbtTags.tagCount(); slots++) { + NBTTagCompound tagCompound = (NBTTagCompound) nbtTags.getCompoundTagAt(slots); + byte slotID = tagCompound.getByte("Slot"); + + if (slotID >= 0 && slotID < inventory.length) { + inventory[slotID] = ItemStack.loadItemStackFromNBT(tagCompound); + } + } + } + + @Override + public NBTTagList getInventory(Object... data) { + NBTTagList tagList = new NBTTagList(); + + for (int slots = 0; slots < inventory.length; slots++) { + if (inventory[slots] != null) { + NBTTagCompound tagCompound = new NBTTagCompound(); + tagCompound.setByte("Slot", (byte) slots); + inventory[slots].writeToNBT(tagCompound); + tagList.appendTag(tagCompound); + } + } + + return tagList; + } + + @Override + public String getCommandSenderName() { + return getName().isEmpty() ? "Robit" : getName(); + } + + @Override + public float getShadowSize() { + return 0.25F; + } + + @Override + public boolean canBreath() { + return true; + } } diff --git a/src/main/java/mekanism/common/frequency/Frequency.java b/src/main/java/mekanism/common/frequency/Frequency.java index 2866ee607..9779bfdb2 100644 --- a/src/main/java/mekanism/common/frequency/Frequency.java +++ b/src/main/java/mekanism/common/frequency/Frequency.java @@ -1,11 +1,10 @@ package mekanism.common.frequency; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.HashSet; import java.util.Set; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.common.PacketHandler; import mekanism.common.security.ISecurityTile; @@ -67,7 +66,8 @@ public class Frequency { continue; } - if (coord.dimensionId != closest.dimensionId && coord.dimensionId == iterCoord.dimensionId) { + if (coord.dimensionId != closest.dimensionId + && coord.dimensionId == iterCoord.dimensionId) { closest = iterCoord; continue; } else if (coord.dimensionId == closest.dimensionId && coord.dimensionId != iterCoord.dimensionId) { @@ -134,6 +134,7 @@ public class Frequency { @Override public boolean equals(Object obj) { return obj instanceof Frequency && ((Frequency) obj).name.equals(name) - && ((Frequency) obj).owner.equals(owner) && ((Frequency) obj).access == access; + && ((Frequency) obj).owner.equals(owner) + && ((Frequency) obj).access == access; } } \ No newline at end of file diff --git a/src/main/java/mekanism/common/frequency/FrequencyManager.java b/src/main/java/mekanism/common/frequency/FrequencyManager.java index a8d46c96c..fa06dcbfe 100644 --- a/src/main/java/mekanism/common/frequency/FrequencyManager.java +++ b/src/main/java/mekanism/common/frequency/FrequencyManager.java @@ -1,7 +1,5 @@ package mekanism.common.frequency; -import io.netty.buffer.ByteBuf; - import java.lang.reflect.Constructor; import java.util.ArrayList; import java.util.Arrays; @@ -10,6 +8,7 @@ import java.util.Iterator; import java.util.List; import java.util.Set; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; @@ -18,383 +17,348 @@ import net.minecraft.world.World; import net.minecraft.world.WorldSavedData; import net.minecraftforge.common.util.Constants.NBT; -public class FrequencyManager -{ - public static final int MAX_FREQ_LENGTH = 16; - public static final List SPECIAL_CHARS = Arrays.asList('-', ' ', '|', '\'', '\"', '_', '+', ':', '(', ')', - '?', '!', '/', '@', '$', '`', '~', ',', '.', '#'); +public class FrequencyManager { + public static final int MAX_FREQ_LENGTH = 16; + public static final List SPECIAL_CHARS = Arrays.asList( + '-', + ' ', + '|', + '\'', + '\"', + '_', + '+', + ':', + '(', + ')', + '?', + '!', + '/', + '@', + '$', + '`', + '~', + ',', + '.', + '#' + ); - public static boolean loaded; - - private static Set managers = new HashSet(); - - private Set frequencies = new HashSet(); - - private FrequencyDataHandler dataHandler; - - private String owner; - - private String name; - - private Class frequencyClass; - - public FrequencyManager(Class c, String n) - { - frequencyClass = c; - name = n; - - managers.add(this); - } - - public FrequencyManager(Class c, String n, String s) - { - this(c, n); - - owner = s; - } - - public static void load(World world) - { - loaded = true; - - for(FrequencyManager manager : managers) - { - manager.createOrLoad(world); - } - } - - public Frequency update(String user, Coord4D coord, Frequency freq) - { - for(Frequency iterFreq : frequencies) - { - if(freq.equals(iterFreq)) - { - iterFreq.activeCoords.add(coord); - dataHandler.markDirty(); - - return iterFreq; - } - } - - deactivate(coord); - - return null; - } - - public void remove(String name, String owner) - { - for(Iterator iter = getFrequencies().iterator(); iter.hasNext();) - { - Frequency iterFreq = iter.next(); - - if(iterFreq.name.equals(name) && iterFreq.owner.equals(owner)) - { - iter.remove(); - dataHandler.markDirty(); - } - } - } - - public void remove(String name) - { - for(Iterator iter = getFrequencies().iterator(); iter.hasNext();) - { - Frequency iterFreq = iter.next(); - - if(iterFreq.name.equals(name)) - { - iter.remove(); - dataHandler.markDirty(); - } - } - } - - public int removeAll(String user) - { - int amount = 0; - - for(Iterator iter = getFrequencies().iterator(); iter.hasNext();) - { - Frequency iterFreq = iter.next(); - - if(iterFreq.owner.equals(user)) - { - iter.remove(); - dataHandler.markDirty(); - amount++; - } - } - - return amount; - } - - public void deactivate(Coord4D coord) - { - for(Frequency freq : frequencies) - { - freq.activeCoords.remove(coord); - dataHandler.markDirty(); - } - } - - public Frequency validateFrequency(String user, Coord4D coord, Frequency freq) - { - for(Frequency iterFreq : frequencies) - { - if(freq.equals(iterFreq)) - { - iterFreq.activeCoords.add(coord); - dataHandler.markDirty(); - - return iterFreq; - } - } - - if(user.equals(freq.owner)) - { - freq.activeCoords.add(coord); - freq.valid = true; - frequencies.add(freq); - dataHandler.markDirty(); - - return freq; - } - - return null; - } - - public void createOrLoad(World world) - { - String name = getName(); - - if(dataHandler == null) - { - dataHandler = (FrequencyDataHandler)world.perWorldStorage.loadData(FrequencyDataHandler.class, name); - - if(dataHandler == null) - { - dataHandler = new FrequencyDataHandler(name); - dataHandler.setManager(this); - world.perWorldStorage.setData(name, dataHandler); - } - else { - dataHandler.setManager(this); - dataHandler.syncManager(); - } - } - } - - public static FrequencyManager loadOnly(World world, String owner, Class freqClass, String n) - { - FrequencyManager manager = new FrequencyManager(freqClass, n); - String name = manager.getName(); - - FrequencyDataHandler handler = (FrequencyDataHandler)world.perWorldStorage.loadData(FrequencyDataHandler.class, name); - - if(handler == null) - { - return null; - } - else { - manager.dataHandler = handler; - manager.dataHandler.syncManager(); - - return manager; - } - } - - public Set getFrequencies() - { - return frequencies; - } - - public void addFrequency(Frequency freq) - { - frequencies.add(freq); - dataHandler.markDirty(); - } - - public boolean containsFrequency(String name) - { - for(Frequency freq : frequencies) - { - if(freq.name.equals(name)) - { - return true; - } - } - - return false; - } - - public static void tick(World world) - { - if(!loaded) - { - load(world); - } - - for(FrequencyManager manager : managers) - { - manager.tickSelf(world); - } - } + public static boolean loaded; - public void tickSelf(World world) - { - for(Frequency iterFreq : frequencies) - { - for(Iterator iter = iterFreq.activeCoords.iterator(); iter.hasNext();) - { - Coord4D coord = iter.next(); - - if(coord.dimensionId == world.provider.dimensionId) - { - if(!coord.exists(world)) - { - iter.remove(); - } - else { - TileEntity tile = coord.getTileEntity(world); - - if(!(tile instanceof IFrequencyHandler)) - { - iter.remove(); - } - else { - Frequency freq = ((IFrequencyHandler)tile).getFrequency(this); - - if(freq == null || !freq.equals(iterFreq)) - { - iter.remove(); - } - } - } - } - } - } - } - - public void writeFrequencies(ArrayList data) - { - data.add(frequencies.size()); - - for(Frequency freq : frequencies) - { - freq.write(data); - } - } - - public Set readFrequencies(ByteBuf dataStream) - { - Set ret = new HashSet(); - int size = dataStream.readInt(); - - try { - for(int i = 0; i < size; i++) - { - Frequency freq = frequencyClass.getConstructor(new Class[] {ByteBuf.class}).newInstance(dataStream); - freq.read(dataStream); - ret.add(freq); - } - } catch(Exception e) { - e.printStackTrace(); - } - - return ret; - } - - public String getName() - { - return owner != null ? (owner + "_" + name + "FrequencyHandler") : (name + "FrequencyHandler"); - } - - public static void reset() - { - for(FrequencyManager manager : managers) - { - manager.frequencies.clear(); - manager.dataHandler = null; - } - - loaded = false; - } - - public static class FrequencyDataHandler extends WorldSavedData - { - public FrequencyManager manager; - - public Set loadedFrequencies; - public String loadedOwner; - - public FrequencyDataHandler(String tagName) - { - super(tagName); - } - - public void setManager(FrequencyManager m) - { - manager = m; - } - - public void syncManager() - { - if(loadedFrequencies != null) - { - manager.frequencies = loadedFrequencies; - manager.owner = loadedOwner; - } - } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - try { - String frequencyClass = nbtTags.getString("frequencyClass"); - - if(nbtTags.hasKey("owner")) - { - loadedOwner = nbtTags.getString("owner"); - } - - NBTTagList list = nbtTags.getTagList("freqList", NBT.TAG_COMPOUND); - - loadedFrequencies = new HashSet(); - - for(int i = 0; i < list.tagCount(); i++) - { - NBTTagCompound compound = list.getCompoundTagAt(i); - - Constructor c = Class.forName(frequencyClass).getConstructor(new Class[] {NBTTagCompound.class}); - Frequency freq = (Frequency)c.newInstance(compound); - - loadedFrequencies.add(freq); - } - } catch(Exception e) { - e.printStackTrace(); - } - } + private static Set managers = new HashSet(); - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - nbtTags.setString("frequencyClass", manager.frequencyClass.getName()); - - if(manager.owner != null) - { - nbtTags.setString("owner", manager.owner); - } - - NBTTagList list = new NBTTagList(); - - for(Frequency freq : manager.getFrequencies()) - { - NBTTagCompound compound = new NBTTagCompound(); - freq.write(compound); - list.appendTag(compound); - } - - nbtTags.setTag("freqList", list); - } - } + private Set frequencies = new HashSet(); + + private FrequencyDataHandler dataHandler; + + private String owner; + + private String name; + + private Class frequencyClass; + + public FrequencyManager(Class c, String n) { + frequencyClass = c; + name = n; + + managers.add(this); + } + + public FrequencyManager(Class c, String n, String s) { + this(c, n); + + owner = s; + } + + public static void load(World world) { + loaded = true; + + for (FrequencyManager manager : managers) { + manager.createOrLoad(world); + } + } + + public Frequency update(String user, Coord4D coord, Frequency freq) { + for (Frequency iterFreq : frequencies) { + if (freq.equals(iterFreq)) { + iterFreq.activeCoords.add(coord); + dataHandler.markDirty(); + + return iterFreq; + } + } + + deactivate(coord); + + return null; + } + + public void remove(String name, String owner) { + for (Iterator iter = getFrequencies().iterator(); iter.hasNext();) { + Frequency iterFreq = iter.next(); + + if (iterFreq.name.equals(name) && iterFreq.owner.equals(owner)) { + iter.remove(); + dataHandler.markDirty(); + } + } + } + + public void remove(String name) { + for (Iterator iter = getFrequencies().iterator(); iter.hasNext();) { + Frequency iterFreq = iter.next(); + + if (iterFreq.name.equals(name)) { + iter.remove(); + dataHandler.markDirty(); + } + } + } + + public int removeAll(String user) { + int amount = 0; + + for (Iterator iter = getFrequencies().iterator(); iter.hasNext();) { + Frequency iterFreq = iter.next(); + + if (iterFreq.owner.equals(user)) { + iter.remove(); + dataHandler.markDirty(); + amount++; + } + } + + return amount; + } + + public void deactivate(Coord4D coord) { + for (Frequency freq : frequencies) { + freq.activeCoords.remove(coord); + dataHandler.markDirty(); + } + } + + public Frequency validateFrequency(String user, Coord4D coord, Frequency freq) { + for (Frequency iterFreq : frequencies) { + if (freq.equals(iterFreq)) { + iterFreq.activeCoords.add(coord); + dataHandler.markDirty(); + + return iterFreq; + } + } + + if (user.equals(freq.owner)) { + freq.activeCoords.add(coord); + freq.valid = true; + frequencies.add(freq); + dataHandler.markDirty(); + + return freq; + } + + return null; + } + + public void createOrLoad(World world) { + String name = getName(); + + if (dataHandler == null) { + dataHandler = (FrequencyDataHandler + ) world.perWorldStorage.loadData(FrequencyDataHandler.class, name); + + if (dataHandler == null) { + dataHandler = new FrequencyDataHandler(name); + dataHandler.setManager(this); + world.perWorldStorage.setData(name, dataHandler); + } else { + dataHandler.setManager(this); + dataHandler.syncManager(); + } + } + } + + public static FrequencyManager + loadOnly(World world, String owner, Class freqClass, String n) { + FrequencyManager manager = new FrequencyManager(freqClass, n); + String name = manager.getName(); + + FrequencyDataHandler handler = (FrequencyDataHandler + ) world.perWorldStorage.loadData(FrequencyDataHandler.class, name); + + if (handler == null) { + return null; + } else { + manager.dataHandler = handler; + manager.dataHandler.syncManager(); + + return manager; + } + } + + public Set getFrequencies() { + return frequencies; + } + + public void addFrequency(Frequency freq) { + frequencies.add(freq); + dataHandler.markDirty(); + } + + public boolean containsFrequency(String name) { + for (Frequency freq : frequencies) { + if (freq.name.equals(name)) { + return true; + } + } + + return false; + } + + public static void tick(World world) { + if (!loaded) { + load(world); + } + + for (FrequencyManager manager : managers) { + manager.tickSelf(world); + } + } + + public void tickSelf(World world) { + for (Frequency iterFreq : frequencies) { + for (Iterator iter = iterFreq.activeCoords.iterator(); + iter.hasNext();) { + Coord4D coord = iter.next(); + + if (coord.dimensionId == world.provider.dimensionId) { + if (!coord.exists(world)) { + iter.remove(); + } else { + TileEntity tile = coord.getTileEntity(world); + + if (!(tile instanceof IFrequencyHandler)) { + iter.remove(); + } else { + Frequency freq + = ((IFrequencyHandler) tile).getFrequency(this); + + if (freq == null || !freq.equals(iterFreq)) { + iter.remove(); + } + } + } + } + } + } + } + + public void writeFrequencies(ArrayList data) { + data.add(frequencies.size()); + + for (Frequency freq : frequencies) { + freq.write(data); + } + } + + public Set readFrequencies(ByteBuf dataStream) { + Set ret = new HashSet(); + int size = dataStream.readInt(); + + try { + for (int i = 0; i < size; i++) { + Frequency freq + = frequencyClass.getConstructor(new Class[] { ByteBuf.class }) + .newInstance(dataStream); + freq.read(dataStream); + ret.add(freq); + } + } catch (Exception e) { + e.printStackTrace(); + } + + return ret; + } + + public String getName() { + return owner != null ? (owner + "_" + name + "FrequencyHandler") + : (name + "FrequencyHandler"); + } + + public static void reset() { + for (FrequencyManager manager : managers) { + manager.frequencies.clear(); + manager.dataHandler = null; + } + + loaded = false; + } + + public static class FrequencyDataHandler extends WorldSavedData { + public FrequencyManager manager; + + public Set loadedFrequencies; + public String loadedOwner; + + public FrequencyDataHandler(String tagName) { + super(tagName); + } + + public void setManager(FrequencyManager m) { + manager = m; + } + + public void syncManager() { + if (loadedFrequencies != null) { + manager.frequencies = loadedFrequencies; + manager.owner = loadedOwner; + } + } + + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + try { + String frequencyClass = nbtTags.getString("frequencyClass"); + + if (nbtTags.hasKey("owner")) { + loadedOwner = nbtTags.getString("owner"); + } + + NBTTagList list = nbtTags.getTagList("freqList", NBT.TAG_COMPOUND); + + loadedFrequencies = new HashSet(); + + for (int i = 0; i < list.tagCount(); i++) { + NBTTagCompound compound = list.getCompoundTagAt(i); + + Constructor c + = Class.forName(frequencyClass) + .getConstructor(new Class[] { NBTTagCompound.class }); + Frequency freq = (Frequency) c.newInstance(compound); + + loadedFrequencies.add(freq); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + nbtTags.setString("frequencyClass", manager.frequencyClass.getName()); + + if (manager.owner != null) { + nbtTags.setString("owner", manager.owner); + } + + NBTTagList list = new NBTTagList(); + + for (Frequency freq : manager.getFrequencies()) { + NBTTagCompound compound = new NBTTagCompound(); + freq.write(compound); + list.appendTag(compound); + } + + nbtTags.setTag("freqList", list); + } + } } diff --git a/src/main/java/mekanism/common/frequency/IFrequencyHandler.java b/src/main/java/mekanism/common/frequency/IFrequencyHandler.java index 4a760495c..da298f068 100644 --- a/src/main/java/mekanism/common/frequency/IFrequencyHandler.java +++ b/src/main/java/mekanism/common/frequency/IFrequencyHandler.java @@ -1,6 +1,5 @@ package mekanism.common.frequency; -public interface IFrequencyHandler -{ - public Frequency getFrequency(FrequencyManager manager); +public interface IFrequencyHandler { + public Frequency getFrequency(FrequencyManager manager); } diff --git a/src/main/java/mekanism/common/integration/CCPeripheral.java b/src/main/java/mekanism/common/integration/CCPeripheral.java index 5d92d54d9..6a9561476 100644 --- a/src/main/java/mekanism/common/integration/CCPeripheral.java +++ b/src/main/java/mekanism/common/integration/CCPeripheral.java @@ -1,52 +1,51 @@ package mekanism.common.integration; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; import cpw.mods.fml.common.Optional; import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.lua.LuaException; import dan200.computercraft.api.peripheral.IComputerAccess; import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.api.peripheral.IPeripheralProvider; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; /** * Created by aidancbrady on 7/20/15. */ -@Optional.Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft") -public class CCPeripheral implements IPeripheral -{ +@Optional.Interface( + iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft" +) +public class CCPeripheral implements IPeripheral { public IComputerIntegration computerTile; - public CCPeripheral(IComputerIntegration tile) - { + public CCPeripheral(IComputerIntegration tile) { computerTile = tile; } @Override @Optional.Method(modid = "ComputerCraft") - public String getType() - { + public String getType() { return computerTile.getInventoryName(); } @Override @Optional.Method(modid = "ComputerCraft") - public String[] getMethodNames() - { + public String[] getMethodNames() { return computerTile.getMethods(); } @Override @Optional.Method(modid = "ComputerCraft") - public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws LuaException, InterruptedException - { + public Object[] callMethod( + IComputerAccess computer, ILuaContext context, int method, Object[] arguments + ) throws LuaException, InterruptedException { try { return computerTile.invoke(method, arguments); - } catch(NoSuchMethodException e) { - return new Object[] {"Unknown command."}; - } catch(Exception e) { - e.printStackTrace(); - return new Object[] {"Error."}; + } catch (NoSuchMethodException e) { + return new Object[] { "Unknown command." }; + } catch (Exception e) { + e.printStackTrace(); + return new Object[] { "Error." }; } } @@ -60,21 +59,17 @@ public class CCPeripheral implements IPeripheral @Override @Optional.Method(modid = "ComputerCraft") - public boolean equals(IPeripheral other) - { + public boolean equals(IPeripheral other) { return this == other; } - public static class CCPeripheralProvider implements IPeripheralProvider - { + public static class CCPeripheralProvider implements IPeripheralProvider { @Override - public IPeripheral getPeripheral(World world, int x, int y, int z, int side) - { + public IPeripheral getPeripheral(World world, int x, int y, int z, int side) { TileEntity te = world.getTileEntity(x, y, z); - if(te != null && te instanceof IComputerIntegration) - { - return new CCPeripheral((IComputerIntegration)te); + if (te != null && te instanceof IComputerIntegration) { + return new CCPeripheral((IComputerIntegration) te); } return null; diff --git a/src/main/java/mekanism/common/integration/IC2ItemManager.java b/src/main/java/mekanism/common/integration/IC2ItemManager.java index 04d2c1539..f7e8cbd64 100644 --- a/src/main/java/mekanism/common/integration/IC2ItemManager.java +++ b/src/main/java/mekanism/common/integration/IC2ItemManager.java @@ -6,83 +6,95 @@ import mekanism.api.energy.IEnergizedItem; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; -public class IC2ItemManager implements IElectricItemManager -{ - public IEnergizedItem energizedItem; +public class IC2ItemManager implements IElectricItemManager { + public IEnergizedItem energizedItem; - public static IC2ItemManager getManager(IEnergizedItem item) - { - IC2ItemManager manager = new IC2ItemManager(); - manager.energizedItem = item; + public static IC2ItemManager getManager(IEnergizedItem item) { + IC2ItemManager manager = new IC2ItemManager(); + manager.energizedItem = item; - return manager; - } + return manager; + } - @Override - public double charge(ItemStack itemStack, double amount, int tier, boolean ignoreTransferLimit, boolean simulate) - { - if(energizedItem.canReceive(itemStack)) - { - double energyNeeded = energizedItem.getMaxEnergy(itemStack)-energizedItem.getEnergy(itemStack); - double energyToStore = Math.min(Math.min(amount* general.FROM_IC2, energizedItem.getMaxEnergy(itemStack)*0.01), energyNeeded); + @Override + public double charge( + ItemStack itemStack, + double amount, + int tier, + boolean ignoreTransferLimit, + boolean simulate + ) { + if (energizedItem.canReceive(itemStack)) { + double energyNeeded = energizedItem.getMaxEnergy(itemStack) + - energizedItem.getEnergy(itemStack); + double energyToStore = Math.min( + Math.min( + amount * general.FROM_IC2, + energizedItem.getMaxEnergy(itemStack) * 0.01 + ), + energyNeeded + ); - if(!simulate) - { - energizedItem.setEnergy(itemStack, energizedItem.getEnergy(itemStack) + energyToStore); - } + if (!simulate) { + energizedItem.setEnergy( + itemStack, energizedItem.getEnergy(itemStack) + energyToStore + ); + } - return (int)Math.round(energyToStore* general.TO_IC2); - } + return (int) Math.round(energyToStore * general.TO_IC2); + } - return 0; - } + return 0; + } - @Override - public double discharge(ItemStack itemStack, double amount, int tier, boolean ignoreTransferLimit, boolean external, boolean simulate) - { - if(energizedItem.canSend(itemStack)) - { - double energyWanted = amount* general.FROM_IC2; - double energyToGive = Math.min(Math.min(energyWanted, energizedItem.getMaxEnergy(itemStack)*0.01), energizedItem.getEnergy(itemStack)); + @Override + public double discharge( + ItemStack itemStack, + double amount, + int tier, + boolean ignoreTransferLimit, + boolean external, + boolean simulate + ) { + if (energizedItem.canSend(itemStack)) { + double energyWanted = amount * general.FROM_IC2; + double energyToGive = Math.min( + Math.min(energyWanted, energizedItem.getMaxEnergy(itemStack) * 0.01), + energizedItem.getEnergy(itemStack) + ); - if(!simulate) - { - energizedItem.setEnergy(itemStack, energizedItem.getEnergy(itemStack) - energyToGive); - } + if (!simulate) { + energizedItem.setEnergy( + itemStack, energizedItem.getEnergy(itemStack) - energyToGive + ); + } - return (int)Math.round(energyToGive* general.TO_IC2); - } + return (int) Math.round(energyToGive * general.TO_IC2); + } - return 0; - } + return 0; + } - @Override - public boolean canUse(ItemStack itemStack, double amount) - { - return energizedItem.getEnergy(itemStack) >= amount* general.FROM_IC2; - } + @Override + public boolean canUse(ItemStack itemStack, double amount) { + return energizedItem.getEnergy(itemStack) >= amount * general.FROM_IC2; + } - @Override - public double getCharge(ItemStack itemStack) - { - return (int)Math.round(energizedItem.getEnergy(itemStack)* general.TO_IC2); - } + @Override + public double getCharge(ItemStack itemStack) { + return (int) Math.round(energizedItem.getEnergy(itemStack) * general.TO_IC2); + } - @Override - public boolean use(ItemStack itemStack, double amount, EntityLivingBase entity) - { - return false; - } + @Override + public boolean use(ItemStack itemStack, double amount, EntityLivingBase entity) { + return false; + } - @Override - public void chargeFromArmor(ItemStack itemStack, EntityLivingBase entity) - { + @Override + public void chargeFromArmor(ItemStack itemStack, EntityLivingBase entity) {} - } - - @Override - public String getToolTip(ItemStack itemStack) - { - return null; - } + @Override + public String getToolTip(ItemStack itemStack) { + return null; + } } diff --git a/src/main/java/mekanism/common/integration/IComputerIntegration.java b/src/main/java/mekanism/common/integration/IComputerIntegration.java index 7fe1d4b30..2150d66d9 100644 --- a/src/main/java/mekanism/common/integration/IComputerIntegration.java +++ b/src/main/java/mekanism/common/integration/IComputerIntegration.java @@ -5,8 +5,7 @@ import net.minecraft.inventory.IInventory; /** * Created by aidancbrady on 7/20/15. */ -public interface IComputerIntegration extends IInventory -{ +public interface IComputerIntegration extends IInventory { public String[] getMethods(); public Object[] invoke(int method, Object[] args) throws Exception; diff --git a/src/main/java/mekanism/common/integration/MekanismHooks.java b/src/main/java/mekanism/common/integration/MekanismHooks.java index 709456cb5..1d21a001c 100644 --- a/src/main/java/mekanism/common/integration/MekanismHooks.java +++ b/src/main/java/mekanism/common/integration/MekanismHooks.java @@ -1,14 +1,17 @@ package mekanism.common.integration; +import java.util.List; +import java.util.Map; + +import cpw.mods.fml.common.Loader; +import cpw.mods.fml.common.Optional.Method; +import cpw.mods.fml.common.event.FMLInterModComms; +import dan200.computercraft.api.ComputerCraftAPI; import ic2.api.recipe.IRecipeInput; import ic2.api.recipe.RecipeInputItemStack; import ic2.api.recipe.RecipeInputOreDict; import ic2.api.recipe.RecipeOutput; import ic2.api.recipe.Recipes; - -import java.util.List; -import java.util.Map; - import li.cil.oc.api.Driver; import mekanism.api.MekanismConfig; import mekanism.api.transmitters.TransmissionType; @@ -21,168 +24,200 @@ import mekanism.common.util.MekanismUtils; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import cpw.mods.fml.common.Loader; -import cpw.mods.fml.common.Optional.Method; -import cpw.mods.fml.common.event.FMLInterModComms; -import dan200.computercraft.api.ComputerCraftAPI; /** * Hooks for Mekanism. Use to grab items or blocks out of different mods. * @author AidanBrady * */ -public final class MekanismHooks -{ - private Class BuildCraftEnergy; +public final class MekanismHooks { + private Class BuildCraftEnergy; - public boolean IC2Loaded = false; - public boolean RailcraftLoaded = false; - public boolean CoFHCoreLoaded = false; - public boolean TELoaded = false; - public boolean CCLoaded = false; - public boolean AE2Loaded = false; + public boolean IC2Loaded = false; + public boolean RailcraftLoaded = false; + public boolean CoFHCoreLoaded = false; + public boolean TELoaded = false; + public boolean CCLoaded = false; + public boolean AE2Loaded = false; - public void hook() - { - if(Loader.isModLoaded("CoFHCore")) CoFHCoreLoaded = true; - if(Loader.isModLoaded("IC2")) IC2Loaded = true; - if(Loader.isModLoaded("Railcraft")) RailcraftLoaded = true; - if(Loader.isModLoaded("ThermalExpansion")) TELoaded = true; - if(Loader.isModLoaded("ComputerCraft")) CCLoaded = true; - if(Loader.isModLoaded("appliedenergistics2")) AE2Loaded = true; + public void hook() { + if (Loader.isModLoaded("CoFHCore")) + CoFHCoreLoaded = true; + if (Loader.isModLoaded("IC2")) + IC2Loaded = true; + if (Loader.isModLoaded("Railcraft")) + RailcraftLoaded = true; + if (Loader.isModLoaded("ThermalExpansion")) + TELoaded = true; + if (Loader.isModLoaded("ComputerCraft")) + CCLoaded = true; + if (Loader.isModLoaded("appliedenergistics2")) + AE2Loaded = true; - if(IC2Loaded) - { - hookIC2Recipes(); - Mekanism.logger.info("Hooked into IC2 successfully."); - } + if (IC2Loaded) { + hookIC2Recipes(); + Mekanism.logger.info("Hooked into IC2 successfully."); + } - if(CCLoaded) - { - loadCCPeripheralProviders(); - } + if (CCLoaded) { + loadCCPeripheralProviders(); + } + } - - } + @Method(modid = "IC2") + public void hookIC2Recipes() { + for (Map.Entry entry : + Recipes.macerator.getRecipes().entrySet()) { + if (!entry.getKey().getInputs().isEmpty()) { + List names + = MekanismUtils.getOreDictName(entry.getKey().getInputs().get(0)); - @Method(modid = "IC2") - public void hookIC2Recipes() - { - for(Map.Entry entry : Recipes.macerator.getRecipes().entrySet()) - { - if(!entry.getKey().getInputs().isEmpty()) - { - List names = MekanismUtils.getOreDictName(entry.getKey().getInputs().get(0)); + for (String name : names) { + boolean did = false; - for(String name : names) - { - boolean did = false; + if (name.startsWith("ingot")) { + RecipeHandler.addCrusherRecipe( + entry.getKey().getInputs().get(0), + entry.getValue().items.get(0) + ); + did = true; + } - if(name.startsWith("ingot")) - { - RecipeHandler.addCrusherRecipe(entry.getKey().getInputs().get(0), entry.getValue().items.get(0)); - did = true; - } + if (did) { + break; + } + } + } + } - if(did) - { - break; - } - } - } - } + try { + if (MekanismConfig.general.OreDictOsmium) { + Recipes.macerator.addRecipe( + new RecipeInputOreDict("oreOsmium"), + null, + new ItemStack(MekanismItems.Dust, 2, Resource.OSMIUM.ordinal()) + ); + } + if (MekanismConfig.general.OreDictPlatinum) { + Recipes.macerator.addRecipe( + new RecipeInputOreDict("orePlatinum"), + null, + new ItemStack(MekanismItems.Dust, 2, Resource.OSMIUM.ordinal()) + ); + } + } catch (Exception e) {} - try { - if(MekanismConfig.general.OreDictOsmium) { - Recipes.macerator.addRecipe(new RecipeInputOreDict("oreOsmium"), null, new ItemStack(MekanismItems.Dust, 2, Resource.OSMIUM.ordinal())); - } - if(MekanismConfig.general.OreDictPlatinum) { - Recipes.macerator.addRecipe(new RecipeInputOreDict("orePlatinum"), null, new ItemStack(MekanismItems.Dust, 2, Resource.OSMIUM.ordinal())); - } - } catch(Exception e) {} + try { + if (MekanismConfig.general.OreDictOsmium) { + Recipes.macerator.addRecipe( + new RecipeInputOreDict("ingotOsmium"), + null, + new ItemStack(MekanismItems.Dust, 1, Resource.OSMIUM.ordinal()) + ); + } + if (MekanismConfig.general.OreDictPlatinum) { + Recipes.macerator.addRecipe( + new RecipeInputOreDict("ingotPlatinum"), + null, + new ItemStack(MekanismItems.Dust, 1, Resource.OSMIUM.ordinal()) + ); + } + Recipes.macerator.addRecipe( + new RecipeInputOreDict("ingotRefinedObsidian"), + null, + new ItemStack(MekanismItems.OtherDust, 1, 5) + ); + Recipes.macerator.addRecipe( + new RecipeInputOreDict("ingotRefinedGlowstone"), + null, + new ItemStack(Items.glowstone_dust) + ); + Recipes.macerator.addRecipe( + new RecipeInputOreDict("ingotSteel"), + null, + new ItemStack(MekanismItems.OtherDust, 1, 1) + ); + } catch (Exception e) {} - try { - if(MekanismConfig.general.OreDictOsmium) { - Recipes.macerator.addRecipe(new RecipeInputOreDict("ingotOsmium"), null, new ItemStack(MekanismItems.Dust, 1, Resource.OSMIUM.ordinal())); - } - if(MekanismConfig.general.OreDictPlatinum) { - Recipes.macerator.addRecipe(new RecipeInputOreDict("ingotPlatinum"), null, new ItemStack(MekanismItems.Dust, 1, Resource.OSMIUM.ordinal())); - } - Recipes.macerator.addRecipe(new RecipeInputOreDict("ingotRefinedObsidian"), null, new ItemStack(MekanismItems.OtherDust, 1, 5)); - Recipes.macerator.addRecipe(new RecipeInputOreDict("ingotRefinedGlowstone"), null, new ItemStack(Items.glowstone_dust)); - Recipes.macerator.addRecipe(new RecipeInputOreDict("ingotSteel"), null, new ItemStack(MekanismItems.OtherDust, 1, 1)); - } catch(Exception e) {} + try { + for (Resource resource : Resource.values()) { + Recipes.macerator.addRecipe( + new RecipeInputOreDict("clump" + resource.getName()), + null, + new ItemStack(MekanismItems.DirtyDust, 1, resource.ordinal()) + ); + } + } catch (Exception e) {} - try { - for(Resource resource : Resource.values()) - { - Recipes.macerator.addRecipe(new RecipeInputOreDict("clump" + resource.getName()), null, new ItemStack(MekanismItems.DirtyDust, 1, resource.ordinal())); - } - } catch(Exception e) {} + NBTTagCompound tag = new NBTTagCompound(); - NBTTagCompound tag = new NBTTagCompound(); + tag.setInteger("amplification", 50000); - tag.setInteger("amplification", 50000); + Recipes.matterAmplifier.addRecipe( + new RecipeInputItemStack(new ItemStack(MekanismItems.EnrichedAlloy), 1), tag + ); + } - Recipes.matterAmplifier.addRecipe(new RecipeInputItemStack(new ItemStack(MekanismItems.EnrichedAlloy), 1), tag); - } + @Method(modid = "ComputerCraft") + public void loadCCPeripheralProviders() { + try { + ComputerCraftAPI.registerPeripheralProvider( + new CCPeripheral.CCPeripheralProvider() + ); + } catch (Exception e) {} + } - @Method(modid = "ComputerCraft") - public void loadCCPeripheralProviders() - { - try { - ComputerCraftAPI.registerPeripheralProvider(new CCPeripheral.CCPeripheralProvider()); - } catch(Exception e) {} - } + @Method(modid = "OpenComputers") + public void loadOCDrivers() { + try { + Driver.add(new OCDriver()); + } catch (Exception e) {} + } - @Method(modid = "OpenComputers") - public void loadOCDrivers() - { - try { - Driver.add(new OCDriver()); - } catch(Exception e) {} - } + public void addPulverizerRecipe(ItemStack input, ItemStack output, int energy) { + NBTTagCompound nbtTags = new NBTTagCompound(); - public void addPulverizerRecipe(ItemStack input, ItemStack output, int energy) - { - NBTTagCompound nbtTags = new NBTTagCompound(); + nbtTags.setInteger("energy", energy); + nbtTags.setTag("input", input.writeToNBT(new NBTTagCompound())); + nbtTags.setTag("primaryOutput", output.writeToNBT(new NBTTagCompound())); - nbtTags.setInteger("energy", energy); - nbtTags.setTag("input", input.writeToNBT(new NBTTagCompound())); - nbtTags.setTag("primaryOutput", output.writeToNBT(new NBTTagCompound())); + FMLInterModComms.sendMessage("mekanism", "PulverizerRecipe", nbtTags); + } - FMLInterModComms.sendMessage("mekanism", "PulverizerRecipe", nbtTags); - } - - @Method(modid = "appliedenergistics2") - public void registerAE2P2P() { - String energyP2P = "add-p2p-attunement-rf-power"; - if(IC2Loaded) - { - energyP2P = "add-p2p-attunement-ic2-power"; - } - - for(TransmitterType type : TransmitterType.values()) - { - if(type.getTransmission().equals(TransmissionType.ITEM)) - { - FMLInterModComms.sendMessage("appliedenergistics2","add-p2p-attunement-item",new ItemStack(MekanismItems.PartTransmitter, 1, type.ordinal())); - continue; - } - - if(type.getTransmission().equals(TransmissionType.FLUID)) - { - FMLInterModComms.sendMessage("appliedenergistics2","add-p2p-attunement-fluid",new ItemStack(MekanismItems.PartTransmitter, 1, type.ordinal())); - continue; - } - - if(type.getTransmission().equals(TransmissionType.ENERGY)) - { - FMLInterModComms.sendMessage("appliedenergistics2",energyP2P,new ItemStack(MekanismItems.PartTransmitter, 1, type.ordinal())); - continue; - } - - } - - } + @Method(modid = "appliedenergistics2") + public void registerAE2P2P() { + String energyP2P = "add-p2p-attunement-rf-power"; + if (IC2Loaded) { + energyP2P = "add-p2p-attunement-ic2-power"; + } + + for (TransmitterType type : TransmitterType.values()) { + if (type.getTransmission().equals(TransmissionType.ITEM)) { + FMLInterModComms.sendMessage( + "appliedenergistics2", + "add-p2p-attunement-item", + new ItemStack(MekanismItems.PartTransmitter, 1, type.ordinal()) + ); + continue; + } + + if (type.getTransmission().equals(TransmissionType.FLUID)) { + FMLInterModComms.sendMessage( + "appliedenergistics2", + "add-p2p-attunement-fluid", + new ItemStack(MekanismItems.PartTransmitter, 1, type.ordinal()) + ); + continue; + } + + if (type.getTransmission().equals(TransmissionType.ENERGY)) { + FMLInterModComms.sendMessage( + "appliedenergistics2", + energyP2P, + new ItemStack(MekanismItems.PartTransmitter, 1, type.ordinal()) + ); + continue; + } + } + } } diff --git a/src/main/java/mekanism/common/integration/OCDriver.java b/src/main/java/mekanism/common/integration/OCDriver.java index bd65d7595..0a74bfce4 100644 --- a/src/main/java/mekanism/common/integration/OCDriver.java +++ b/src/main/java/mekanism/common/integration/OCDriver.java @@ -17,62 +17,58 @@ import net.minecraft.world.World; /** * Created by aidancbrady on 7/20/15. */ -public class OCDriver extends DriverTileEntity -{ +public class OCDriver extends DriverTileEntity { @Override - public Class getTileEntityClass() - { + public Class getTileEntityClass() { return IComputerIntegration.class; } @Override - public ManagedEnvironment createEnvironment(World world, int x, int y, int z) - { + public ManagedEnvironment createEnvironment(World world, int x, int y, int z) { TileEntity tile = world.getTileEntity(x, y, z); - if(tile instanceof IComputerIntegration) - { - return new OCManagedEnvironment((IComputerIntegration)tile); + if (tile instanceof IComputerIntegration) { + return new OCManagedEnvironment((IComputerIntegration) tile); } return null; } - public class OCManagedEnvironment extends ManagedEnvironment implements NamedBlock, ManagedPeripheral - { + public class OCManagedEnvironment + extends ManagedEnvironment implements NamedBlock, ManagedPeripheral { public IComputerIntegration computerTile; public String name; - public OCManagedEnvironment(IComputerIntegration tile) - { + public OCManagedEnvironment(IComputerIntegration tile) { computerTile = tile; name = tile.getInventoryName().toLowerCase(Locale.ENGLISH).replace(" ", "_"); - setNode(Network.newNode(this, Visibility.Network).withComponent(name, Visibility.Network).create()); + setNode(Network.newNode(this, Visibility.Network) + .withComponent(name, Visibility.Network) + .create()); } @Override - public String[] methods() - { + public String[] methods() { return computerTile.getMethods(); } @Override - public Object[] invoke(String method, Context context, Arguments args) throws Exception - { - return computerTile.invoke(Arrays.asList(methods()).indexOf(method), args.toArray()); + public Object[] invoke(String method, Context context, Arguments args) + throws Exception { + return computerTile.invoke( + Arrays.asList(methods()).indexOf(method), args.toArray() + ); } @Override - public int priority() - { + public int priority() { return 4; } @Override - public String preferredName() - { + public String preferredName() { return name; } } diff --git a/src/main/java/mekanism/common/integration/OreDictManager.java b/src/main/java/mekanism/common/integration/OreDictManager.java index 323c9143a..6da18af9d 100644 --- a/src/main/java/mekanism/common/integration/OreDictManager.java +++ b/src/main/java/mekanism/common/integration/OreDictManager.java @@ -1,12 +1,12 @@ package mekanism.common.integration; -import ic2.api.recipe.RecipeInputOreDict; -import ic2.api.recipe.Recipes; - import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import cpw.mods.fml.common.Optional.Method; +import ic2.api.recipe.RecipeInputOreDict; +import ic2.api.recipe.Recipes; import mekanism.api.MekanismConfig; import mekanism.api.gas.GasRegistry; import mekanism.api.gas.GasStack; @@ -29,450 +29,799 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraftforge.oredict.OreDictionary; -import cpw.mods.fml.common.Optional.Method; -public final class OreDictManager -{ - private static final List minorCompat = Arrays.asList("Nickel", "Aluminum"); - private static List osmiumcompat = new ArrayList<>(); +public final class OreDictManager { + private static final List minorCompat = Arrays.asList("Nickel", "Aluminum"); + private static List osmiumcompat = new ArrayList<>(); - - public static void init() { - if (MekanismConfig.general.OreDictOsmium) { - osmiumcompat.add("Osmium"); - } - if (MekanismConfig.general.OreDictPlatinum) { - osmiumcompat.add("Platinum"); - } - addLogRecipes(); + public static void init() { + if (MekanismConfig.general.OreDictOsmium) { + osmiumcompat.add("Osmium"); + } + if (MekanismConfig.general.OreDictPlatinum) { + osmiumcompat.add("Platinum"); + } + addLogRecipes(); - for (ItemStack ore : OreDictionary.getOres("plankWood")) { - if (ore.getHasSubtypes()) { - ItemStack wildStack = new ItemStack(ore.getItem(), 1, OreDictionary.WILDCARD_VALUE); + for (ItemStack ore : OreDictionary.getOres("plankWood")) { + if (ore.getHasSubtypes()) { + ItemStack wildStack + = new ItemStack(ore.getItem(), 1, OreDictionary.WILDCARD_VALUE); - if (!Recipe.PRECISION_SAWMILL.containsRecipe(wildStack)) { - RecipeHandler.addPrecisionSawmillRecipe(wildStack, new ItemStack(Items.stick, 6), new ItemStack(MekanismItems.Sawdust), 0.25); - } - } else { - RecipeHandler.addPrecisionSawmillRecipe(StackUtils.size(ore, 1), new ItemStack(Items.stick, 6), new ItemStack(MekanismItems.Sawdust), 0.25); - } - } - for (ItemStack ore : OreDictionary.getOres("ingotSteel")) { - RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("REDSTONE"), 10, StackUtils.size(ore, 1), new ItemStack(MekanismItems.EnrichedAlloy)); - } - for (ItemStack ore : OreDictionary.getOres("oreNetherSteel")) { - RecipeHandler.addEnrichmentChamberRecipe(StackUtils.size(ore, 1), new ItemStack(MekanismItems.OtherDust, 4, 1)); - } + if (!Recipe.PRECISION_SAWMILL.containsRecipe(wildStack)) { + RecipeHandler.addPrecisionSawmillRecipe( + wildStack, + new ItemStack(Items.stick, 6), + new ItemStack(MekanismItems.Sawdust), + 0.25 + ); + } + } else { + RecipeHandler.addPrecisionSawmillRecipe( + StackUtils.size(ore, 1), + new ItemStack(Items.stick, 6), + new ItemStack(MekanismItems.Sawdust), + 0.25 + ); + } + } + for (ItemStack ore : OreDictionary.getOres("ingotSteel")) { + RecipeHandler.addMetallurgicInfuserRecipe( + InfuseRegistry.get("REDSTONE"), + 10, + StackUtils.size(ore, 1), + new ItemStack(MekanismItems.EnrichedAlloy) + ); + } + for (ItemStack ore : OreDictionary.getOres("oreNetherSteel")) { + RecipeHandler.addEnrichmentChamberRecipe( + StackUtils.size(ore, 1), new ItemStack(MekanismItems.OtherDust, 4, 1) + ); + } - if (OreDictionary.getOres("itemRubber").size() > 0) { - for (ItemStack ore : OreDictionary.getOres("woodRubber")) { - RecipeHandler.addPrecisionSawmillRecipe(StackUtils.size(ore, 1), new ItemStack(Blocks.planks, 4), StackUtils.size(OreDictionary.getOres("itemRawRubber").get(0), 2), 1F); } - } + if (OreDictionary.getOres("itemRubber").size() > 0) { + for (ItemStack ore : OreDictionary.getOres("woodRubber")) { + RecipeHandler.addPrecisionSawmillRecipe( + StackUtils.size(ore, 1), + new ItemStack(Blocks.planks, 4), + StackUtils.size(OreDictionary.getOres("itemRawRubber").get(0), 2), + 1F + ); + } + } - for (ItemStack ore : OreDictionary.getOres("dustSulfur")) { - RecipeHandler.addChemicalOxidizerRecipe(StackUtils.size(ore, 1), new GasStack(GasRegistry.getGas("sulfurDioxideGas"), 100)); - } + for (ItemStack ore : OreDictionary.getOres("dustSulfur")) { + RecipeHandler.addChemicalOxidizerRecipe( + StackUtils.size(ore, 1), + new GasStack(GasRegistry.getGas("sulfurDioxideGas"), 100) + ); + } - for (ItemStack ore : OreDictionary.getOres("dustSalt")) { - RecipeHandler.addChemicalOxidizerRecipe(StackUtils.size(ore, 1), new GasStack(GasRegistry.getGas("brine"), 15)); - } + for (ItemStack ore : OreDictionary.getOres("dustSalt")) { + RecipeHandler.addChemicalOxidizerRecipe( + StackUtils.size(ore, 1), new GasStack(GasRegistry.getGas("brine"), 15) + ); + } - for (ItemStack ore : OreDictionary.getOres("dustRefinedObsidian")) { - RecipeHandler.addOsmiumCompressorRecipe(StackUtils.size(ore, 1), new ItemStack(MekanismItems.Ingot, 1, 0)); - RecipeHandler.addCrusherRecipe(StackUtils.size(ore, 1), new ItemStack(MekanismItems.OtherDust, 1, 6)); - RecipeHandler.addEnrichmentChamberRecipe(StackUtils.size(ore, 1), new ItemStack(MekanismItems.CompressedObsidian)); + for (ItemStack ore : OreDictionary.getOres("dustRefinedObsidian")) { + RecipeHandler.addOsmiumCompressorRecipe( + StackUtils.size(ore, 1), new ItemStack(MekanismItems.Ingot, 1, 0) + ); + RecipeHandler.addCrusherRecipe( + StackUtils.size(ore, 1), new ItemStack(MekanismItems.OtherDust, 1, 6) + ); + RecipeHandler.addEnrichmentChamberRecipe( + StackUtils.size(ore, 1), new ItemStack(MekanismItems.CompressedObsidian) + ); - InfuseRegistry.registerInfuseObject(StackUtils.size(ore, 1), new InfuseObject(InfuseRegistry.get("OBSIDIAN"), 10)); - } + InfuseRegistry.registerInfuseObject( + StackUtils.size(ore, 1), + new InfuseObject(InfuseRegistry.get("OBSIDIAN"), 10) + ); + } - for (Resource resource : Resource.values()) { - for (ItemStack ore : OreDictionary.getOres("clump" + resource.getName())) { - RecipeHandler.addCrusherRecipe(StackUtils.size(ore, 1), new ItemStack(MekanismItems.DirtyDust, 1, resource.ordinal())); - } + for (Resource resource : Resource.values()) { + for (ItemStack ore : OreDictionary.getOres("clump" + resource.getName())) { + RecipeHandler.addCrusherRecipe( + StackUtils.size(ore, 1), + new ItemStack(MekanismItems.DirtyDust, 1, resource.ordinal()) + ); + } - for (ItemStack ore : OreDictionary.getOres("shard" + resource.getName())) { - RecipeHandler.addPurificationChamberRecipe(StackUtils.size(ore, 1), new ItemStack(MekanismItems.Clump, 1, resource.ordinal())); - } + for (ItemStack ore : OreDictionary.getOres("shard" + resource.getName())) { + RecipeHandler.addPurificationChamberRecipe( + StackUtils.size(ore, 1), + new ItemStack(MekanismItems.Clump, 1, resource.ordinal()) + ); + } - for (ItemStack ore : OreDictionary.getOres("crystal" + resource.getName())) { - RecipeHandler.addChemicalInjectionChamberRecipe(StackUtils.size(ore, 1), "hydrogenChloride", new ItemStack(MekanismItems.Shard, 1, resource.ordinal())); - } + for (ItemStack ore : OreDictionary.getOres("crystal" + resource.getName())) { + RecipeHandler.addChemicalInjectionChamberRecipe( + StackUtils.size(ore, 1), + "hydrogenChloride", + new ItemStack(MekanismItems.Shard, 1, resource.ordinal()) + ); + } - for (ItemStack ore : OreDictionary.getOres("dustDirty" + resource.getName())) { - RecipeHandler.addEnrichmentChamberRecipe(StackUtils.size(ore, 1), new ItemStack(MekanismItems.Dust, 1, resource.ordinal())); - } + for (ItemStack ore : + OreDictionary.getOres("dustDirty" + resource.getName())) { + RecipeHandler.addEnrichmentChamberRecipe( + StackUtils.size(ore, 1), + new ItemStack(MekanismItems.Dust, 1, resource.ordinal()) + ); + } - for (ItemStack ore : OreDictionary.getOres("ore" + resource.getName())) { - RecipeHandler.addEnrichmentChamberRecipe(StackUtils.size(ore, 1), new ItemStack(MekanismItems.Dust, 2, resource.ordinal())); - RecipeHandler.addPurificationChamberRecipe(StackUtils.size(ore, 1), new ItemStack(MekanismItems.Clump, 3, resource.ordinal())); - RecipeHandler.addChemicalInjectionChamberRecipe(StackUtils.size(ore, 1), "hydrogenChloride", new ItemStack(MekanismItems.Shard, 4, resource.ordinal())); - RecipeHandler.addChemicalDissolutionChamberRecipe(StackUtils.size(ore, 1), new GasStack(GasRegistry.getGas(resource.getName().toLowerCase()), 1000)); - } + for (ItemStack ore : OreDictionary.getOres("ore" + resource.getName())) { + RecipeHandler.addEnrichmentChamberRecipe( + StackUtils.size(ore, 1), + new ItemStack(MekanismItems.Dust, 2, resource.ordinal()) + ); + RecipeHandler.addPurificationChamberRecipe( + StackUtils.size(ore, 1), + new ItemStack(MekanismItems.Clump, 3, resource.ordinal()) + ); + RecipeHandler.addChemicalInjectionChamberRecipe( + StackUtils.size(ore, 1), + "hydrogenChloride", + new ItemStack(MekanismItems.Shard, 4, resource.ordinal()) + ); + RecipeHandler.addChemicalDissolutionChamberRecipe( + StackUtils.size(ore, 1), + new GasStack( + GasRegistry.getGas(resource.getName().toLowerCase()), 1000 + ) + ); + } - for (ItemStack ore : OreDictionary.getOres("ingot" + resource.getName())) { - RecipeHandler.addCrusherRecipe(StackUtils.size(ore, 1), new ItemStack(MekanismItems.Dust, 1, resource.ordinal())); - } + for (ItemStack ore : OreDictionary.getOres("ingot" + resource.getName())) { + RecipeHandler.addCrusherRecipe( + StackUtils.size(ore, 1), + new ItemStack(MekanismItems.Dust, 1, resource.ordinal()) + ); + } - try { - for (ItemStack ore : OreDictionary.getOres("dust" + resource.getName())) { - RecipeHandler.addCombinerRecipe(StackUtils.size(ore, 8), StackUtils.size(OreDictionary.getOres("ore" + resource.getName()).get(0), 1)); - } - } catch (Exception e) { - } - } - if (MekanismConfig.general.OreDictOsmium || MekanismConfig.general.OreDictPlatinum) { - for (String s : osmiumcompat) { - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.BasicBlock, 1, 0), new Object[]{ - "XXX", "XXX", "XXX", Character.valueOf('X'), "ingot" + s - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.SpeedUpgrade), new Object[]{ - " G ", "ADA", " G ", Character.valueOf('G'), "blockGlass", Character.valueOf('A'), MekanismItems.EnrichedAlloy, Character.valueOf('D'), "dust" + s - })); - BlockMachine.MachineType.METALLURGIC_INFUSER.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock, 1, 8), new Object[]{ - "IFI", "ROR", "IFI", Character.valueOf('I'), "ingotIron", Character.valueOf('F'), Blocks.furnace, Character.valueOf('R'), "dustRedstone", Character.valueOf('O'), "ingot" + s - })); - BlockMachine.MachineType.PURIFICATION_CHAMBER.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock, 1, 9), new Object[]{ - "ECE", "ORO", "ECE", Character.valueOf('C'), MekanismUtils.getControlCircuit(Tier.BaseTier.ADVANCED), Character.valueOf('E'), "alloyAdvanced", Character.valueOf('O'), "ingot" + s, Character.valueOf('R'), new ItemStack(MekanismBlocks.MachineBlock, 1, 0) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.BasicBlock, 1, 8), new Object[]{ - "SGS", "GPG", "SGS", Character.valueOf('S'), "ingotSteel", Character.valueOf('P'), "ingot" + s, Character.valueOf('G'), "blockGlass" - })); - BlockMachine.MachineType.ELECTRIC_PUMP.addRecipe(new ShapedMekanismRecipe(new ItemStack(MekanismBlocks.MachineBlock, 1, 12), new Object[]{ - " B ", "ECE", "OOO", Character.valueOf('B'), Items.bucket, Character.valueOf('E'), MekanismItems.EnrichedAlloy, Character.valueOf('C'), new ItemStack(MekanismBlocks.BasicBlock, 1, 8), Character.valueOf('O'), "ingot" + s - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.WalkieTalkie), new Object[]{ - " O", "SCS", " S ", Character.valueOf('O'), "ingot" + s, Character.valueOf('S'), "ingotSteel", Character.valueOf('C'), MekanismUtils.getControlCircuit(Tier.BaseTier.BASIC) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.ElectrolyticCore), new Object[]{ - "EPE", "IEG", "EPE", Character.valueOf('E'), MekanismItems.EnrichedAlloy, Character.valueOf('P'), "dust" + s, Character.valueOf('I'), "dustIron", Character.valueOf('G'), "dustGold" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(Blocks.rail, 24), new Object[]{ - "O O", "OSO", "O O", Character.valueOf('O'), "ingot" + s, Character.valueOf('S'), "stickWood" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(MekanismItems.GaugeDropper.getEmptyItem(), new Object[]{ - " O ", "G G", "GGG", Character.valueOf('O'), "ingot" + s, Character.valueOf('G'), "paneGlass" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(MekanismItems.TierInstaller, 1, 1), new Object[]{ - "ECE", "oWo", "ECE", Character.valueOf('E'), "alloyAdvanced", Character.valueOf('C'), MekanismUtils.getControlCircuit(Tier.BaseTier.ADVANCED), Character.valueOf('o'), "ingot" + s, Character.valueOf('W'), "plankWood" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(MekanismUtils.getEnergyCube(Tier.EnergyCubeTier.ADVANCED), new Object[]{ - "ETE", "oBo", "ETE", Character.valueOf('E'), "alloyAdvanced", Character.valueOf('o'), "ingot" + s, Character.valueOf('T'), MekanismItems.EnergyTablet.getUnchargedItem(), Character.valueOf('B'), MekanismUtils.getEnergyCube(Tier.EnergyCubeTier.BASIC) - })); - //Gas Tank Recipes - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(MekanismUtils.getEmptyGasTank(Tier.GasTankTier.BASIC), new Object[]{ - "APA", "P P", "APA", Character.valueOf('P'), "ingot" + s, Character.valueOf('A'), "alloyBasic" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(MekanismUtils.getEmptyGasTank(Tier.GasTankTier.ADVANCED), new Object[]{ - "APA", "PTP", "APA", Character.valueOf('P'), "ingot" + s, Character.valueOf('A'), "alloyAdvanced", Character.valueOf('T'), MekanismUtils.getEmptyGasTank(Tier.GasTankTier.BASIC) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(MekanismUtils.getEmptyGasTank(Tier.GasTankTier.ELITE), new Object[]{ - "APA", "PTP", "APA", Character.valueOf('P'), "ingot" + s, Character.valueOf('A'), "alloyElite", Character.valueOf('T'), MekanismUtils.getEmptyGasTank(Tier.GasTankTier.ADVANCED) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(MekanismUtils.getEmptyGasTank(Tier.GasTankTier.ULTIMATE), new Object[]{ - "APA", "PTP", "APA", Character.valueOf('P'), "ingot" + s, Character.valueOf('A'), "alloyUltimate", Character.valueOf('T'), MekanismUtils.getEmptyGasTank(Tier.GasTankTier.ELITE) - })); - for (ItemStack ore : OreDictionary.getOres("ingot" + s)) { - RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("REDSTONE"), 10, StackUtils.size(ore, 1), new ItemStack(MekanismItems.ControlCircuit, 1, 0)); - } - } - } + try { + for (ItemStack ore : OreDictionary.getOres("dust" + resource.getName())) { + RecipeHandler.addCombinerRecipe( + StackUtils.size(ore, 8), + StackUtils.size( + OreDictionary.getOres("ore" + resource.getName()).get(0), 1 + ) + ); + } + } catch (Exception e) {} + } + if (MekanismConfig.general.OreDictOsmium + || MekanismConfig.general.OreDictPlatinum) { + for (String s : osmiumcompat) { + CraftingManager.getInstance().getRecipeList().add( + new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.BasicBlock, 1, 0), + new Object[] { + "XXX", "XXX", "XXX", Character.valueOf('X'), "ingot" + s } + ) + ); + CraftingManager.getInstance().getRecipeList().add( + new ShapedMekanismRecipe( + new ItemStack(MekanismItems.SpeedUpgrade), + new Object[] { " G ", + "ADA", + " G ", + Character.valueOf('G'), + "blockGlass", + Character.valueOf('A'), + MekanismItems.EnrichedAlloy, + Character.valueOf('D'), + "dust" + s } + ) + ); + BlockMachine.MachineType.METALLURGIC_INFUSER.addRecipe( + new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.MachineBlock, 1, 8), + new Object[] { "IFI", + "ROR", + "IFI", + Character.valueOf('I'), + "ingotIron", + Character.valueOf('F'), + Blocks.furnace, + Character.valueOf('R'), + "dustRedstone", + Character.valueOf('O'), + "ingot" + s } + ) + ); + BlockMachine.MachineType.PURIFICATION_CHAMBER.addRecipe( + new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.MachineBlock, 1, 9), + new Object[] { + "ECE", + "ORO", + "ECE", + Character.valueOf('C'), + MekanismUtils.getControlCircuit(Tier.BaseTier.ADVANCED), + Character.valueOf('E'), + "alloyAdvanced", + Character.valueOf('O'), + "ingot" + s, + Character.valueOf('R'), + new ItemStack(MekanismBlocks.MachineBlock, 1, 0) } + ) + ); + CraftingManager.getInstance().getRecipeList().add( + new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.BasicBlock, 1, 8), + new Object[] { "SGS", + "GPG", + "SGS", + Character.valueOf('S'), + "ingotSteel", + Character.valueOf('P'), + "ingot" + s, + Character.valueOf('G'), + "blockGlass" } + ) + ); + BlockMachine.MachineType.ELECTRIC_PUMP.addRecipe(new ShapedMekanismRecipe( + new ItemStack(MekanismBlocks.MachineBlock, 1, 12), + new Object[] { " B ", + "ECE", + "OOO", + Character.valueOf('B'), + Items.bucket, + Character.valueOf('E'), + MekanismItems.EnrichedAlloy, + Character.valueOf('C'), + new ItemStack(MekanismBlocks.BasicBlock, 1, 8), + Character.valueOf('O'), + "ingot" + s } + )); + CraftingManager.getInstance().getRecipeList().add( + new ShapedMekanismRecipe( + new ItemStack(MekanismItems.WalkieTalkie), + new Object[] { + " O", + "SCS", + " S ", + Character.valueOf('O'), + "ingot" + s, + Character.valueOf('S'), + "ingotSteel", + Character.valueOf('C'), + MekanismUtils.getControlCircuit(Tier.BaseTier.BASIC) } + ) + ); + CraftingManager.getInstance().getRecipeList().add( + new ShapedMekanismRecipe( + new ItemStack(MekanismItems.ElectrolyticCore), + new Object[] { "EPE", + "IEG", + "EPE", + Character.valueOf('E'), + MekanismItems.EnrichedAlloy, + Character.valueOf('P'), + "dust" + s, + Character.valueOf('I'), + "dustIron", + Character.valueOf('G'), + "dustGold" } + ) + ); + CraftingManager.getInstance().getRecipeList().add( + new ShapedMekanismRecipe( + new ItemStack(Blocks.rail, 24), + new Object[] { "O O", + "OSO", + "O O", + Character.valueOf('O'), + "ingot" + s, + Character.valueOf('S'), + "stickWood" } + ) + ); + CraftingManager.getInstance().getRecipeList().add( + new ShapedMekanismRecipe( + MekanismItems.GaugeDropper.getEmptyItem(), + new Object[] { " O ", + "G G", + "GGG", + Character.valueOf('O'), + "ingot" + s, + Character.valueOf('G'), + "paneGlass" } + ) + ); + CraftingManager.getInstance().getRecipeList().add( + new ShapedMekanismRecipe( + new ItemStack(MekanismItems.TierInstaller, 1, 1), + new Object[] { + "ECE", + "oWo", + "ECE", + Character.valueOf('E'), + "alloyAdvanced", + Character.valueOf('C'), + MekanismUtils.getControlCircuit(Tier.BaseTier.ADVANCED), + Character.valueOf('o'), + "ingot" + s, + Character.valueOf('W'), + "plankWood" } + ) + ); + CraftingManager.getInstance().getRecipeList().add( + new ShapedMekanismRecipe( + MekanismUtils.getEnergyCube(Tier.EnergyCubeTier.ADVANCED), + new Object[] { + "ETE", + "oBo", + "ETE", + Character.valueOf('E'), + "alloyAdvanced", + Character.valueOf('o'), + "ingot" + s, + Character.valueOf('T'), + MekanismItems.EnergyTablet.getUnchargedItem(), + Character.valueOf('B'), + MekanismUtils.getEnergyCube(Tier.EnergyCubeTier.BASIC) } + ) + ); + //Gas Tank Recipes + CraftingManager.getInstance().getRecipeList().add( + new ShapedMekanismRecipe( + MekanismUtils.getEmptyGasTank(Tier.GasTankTier.BASIC), + new Object[] { "APA", + "P P", + "APA", + Character.valueOf('P'), + "ingot" + s, + Character.valueOf('A'), + "alloyBasic" } + ) + ); + CraftingManager.getInstance().getRecipeList().add( + new ShapedMekanismRecipe( + MekanismUtils.getEmptyGasTank(Tier.GasTankTier.ADVANCED), + new Object[] { + "APA", + "PTP", + "APA", + Character.valueOf('P'), + "ingot" + s, + Character.valueOf('A'), + "alloyAdvanced", + Character.valueOf('T'), + MekanismUtils.getEmptyGasTank(Tier.GasTankTier.BASIC) } + ) + ); + CraftingManager.getInstance().getRecipeList().add( + new ShapedMekanismRecipe( + MekanismUtils.getEmptyGasTank(Tier.GasTankTier.ELITE), + new Object[] { + "APA", + "PTP", + "APA", + Character.valueOf('P'), + "ingot" + s, + Character.valueOf('A'), + "alloyElite", + Character.valueOf('T'), + MekanismUtils.getEmptyGasTank(Tier.GasTankTier.ADVANCED) } + ) + ); + CraftingManager.getInstance().getRecipeList().add( + new ShapedMekanismRecipe( + MekanismUtils.getEmptyGasTank(Tier.GasTankTier.ULTIMATE), + new Object[] { + "APA", + "PTP", + "APA", + Character.valueOf('P'), + "ingot" + s, + Character.valueOf('A'), + "alloyUltimate", + Character.valueOf('T'), + MekanismUtils.getEmptyGasTank(Tier.GasTankTier.ELITE) } + ) + ); + for (ItemStack ore : OreDictionary.getOres("ingot" + s)) { + RecipeHandler.addMetallurgicInfuserRecipe( + InfuseRegistry.get("REDSTONE"), + 10, + StackUtils.size(ore, 1), + new ItemStack(MekanismItems.ControlCircuit, 1, 0) + ); + } + } + } - for (String s : minorCompat) { - for (ItemStack ore : OreDictionary.getOres("ore" + s)) { - try { - RecipeHandler.addEnrichmentChamberRecipe(StackUtils.size(ore, 1), StackUtils.size(OreDictionary.getOres("dust" + s).get(0), 2)); - } catch (Exception e) { - } - } + for (String s : minorCompat) { + for (ItemStack ore : OreDictionary.getOres("ore" + s)) { + try { + RecipeHandler.addEnrichmentChamberRecipe( + StackUtils.size(ore, 1), + StackUtils.size(OreDictionary.getOres("dust" + s).get(0), 2) + ); + } catch (Exception e) {} + } - for (ItemStack ore : OreDictionary.getOres("ingot" + s)) { - try { - RecipeHandler.addCrusherRecipe(StackUtils.size(ore, 1), StackUtils.size(OreDictionary.getOres("dust" + s).get(0), 1)); - } catch (Exception e) { - } - } + for (ItemStack ore : OreDictionary.getOres("ingot" + s)) { + try { + RecipeHandler.addCrusherRecipe( + StackUtils.size(ore, 1), + StackUtils.size(OreDictionary.getOres("dust" + s).get(0), 1) + ); + } catch (Exception e) {} + } - for (ItemStack ore : OreDictionary.getOres("dust" + s)) { - try { - RecipeHandler.addCombinerRecipe(StackUtils.size(ore, 8), StackUtils.size(OreDictionary.getOres("ore" + s).get(0), 1)); - } catch (Exception e) { - } - } - } + for (ItemStack ore : OreDictionary.getOres("dust" + s)) { + try { + RecipeHandler.addCombinerRecipe( + StackUtils.size(ore, 8), + StackUtils.size(OreDictionary.getOres("ore" + s).get(0), 1) + ); + } catch (Exception e) {} + } + } - for (ItemStack ore : OreDictionary.getOres("oreYellorite")) { - try { - RecipeHandler.addEnrichmentChamberRecipe(StackUtils.size(ore, 1), StackUtils.size(OreDictionary.getOres("dustYellorium").get(0), 2)); - } catch (Exception e) { - } - } + for (ItemStack ore : OreDictionary.getOres("oreYellorite")) { + try { + RecipeHandler.addEnrichmentChamberRecipe( + StackUtils.size(ore, 1), + StackUtils.size(OreDictionary.getOres("dustYellorium").get(0), 2) + ); + } catch (Exception e) {} + } - for (ItemStack ore : OreDictionary.getOres("oreCertusQuartz")) { - try { - RecipeHandler.addEnrichmentChamberRecipe(StackUtils.size(ore, 1), StackUtils.size(OreDictionary.getOres("dustCertusQuartz").get(0), 4)); - } catch (Exception e) { - } - } + for (ItemStack ore : OreDictionary.getOres("oreCertusQuartz")) { + try { + RecipeHandler.addEnrichmentChamberRecipe( + StackUtils.size(ore, 1), + StackUtils.size(OreDictionary.getOres("dustCertusQuartz").get(0), 4) + ); + } catch (Exception e) {} + } - for (ItemStack ore : OreDictionary.getOres("crystalCertusQuartz")) { - try { - RecipeHandler.addCrusherRecipe(StackUtils.size(ore, 1), StackUtils.size(OreDictionary.getOres("dustCertusQuartz").get(0), 1)); - } catch (Exception e) { - } - } + for (ItemStack ore : OreDictionary.getOres("crystalCertusQuartz")) { + try { + RecipeHandler.addCrusherRecipe( + StackUtils.size(ore, 1), + StackUtils.size(OreDictionary.getOres("dustCertusQuartz").get(0), 1) + ); + } catch (Exception e) {} + } - for (ItemStack ore : OreDictionary.getOres("dustCertusQuartz")) { - try { - RecipeHandler.addEnrichmentChamberRecipe(StackUtils.size(ore, 1), StackUtils.size(OreDictionary.getOres("crystalCertusQuartz").get(0), 1)); - } catch (Exception e) { - } - } + for (ItemStack ore : OreDictionary.getOres("dustCertusQuartz")) { + try { + RecipeHandler.addEnrichmentChamberRecipe( + StackUtils.size(ore, 1), + StackUtils.size( + OreDictionary.getOres("crystalCertusQuartz").get(0), 1 + ) + ); + } catch (Exception e) {} + } - for (ItemStack ore : OreDictionary.getOres("gemQuartz")) { - try { - RecipeHandler.addCrusherRecipe(StackUtils.size(ore, 1), StackUtils.size(OreDictionary.getOres("dustNetherQuartz").get(0), 1)); - } catch (Exception e) { - } - } + for (ItemStack ore : OreDictionary.getOres("gemQuartz")) { + try { + RecipeHandler.addCrusherRecipe( + StackUtils.size(ore, 1), + StackUtils.size(OreDictionary.getOres("dustNetherQuartz").get(0), 1) + ); + } catch (Exception e) {} + } - for (ItemStack ore : OreDictionary.getOres("dustNetherQuartz")) { - try { - RecipeHandler.addEnrichmentChamberRecipe(StackUtils.size(ore, 1), StackUtils.size(OreDictionary.getOres("gemQuartz").get(0), 1)); - } catch (Exception e) { - } - } + for (ItemStack ore : OreDictionary.getOres("dustNetherQuartz")) { + try { + RecipeHandler.addEnrichmentChamberRecipe( + StackUtils.size(ore, 1), + StackUtils.size(OreDictionary.getOres("gemQuartz").get(0), 1) + ); + } catch (Exception e) {} + } - for (ItemStack ore : OreDictionary.getOres("oreQuartz")) { - RecipeHandler.addEnrichmentChamberRecipe(StackUtils.size(ore, 1), new ItemStack(Items.quartz, 6)); - } + for (ItemStack ore : OreDictionary.getOres("oreQuartz")) { + RecipeHandler.addEnrichmentChamberRecipe( + StackUtils.size(ore, 1), new ItemStack(Items.quartz, 6) + ); + } - for (ItemStack ore : OreDictionary.getOres("crystalFluix")) { - try { - RecipeHandler.addCrusherRecipe(StackUtils.size(ore, 1), StackUtils.size(OreDictionary.getOres("dustFluix").get(0), 1)); - } catch (Exception e) { - } - } + for (ItemStack ore : OreDictionary.getOres("crystalFluix")) { + try { + RecipeHandler.addCrusherRecipe( + StackUtils.size(ore, 1), + StackUtils.size(OreDictionary.getOres("dustFluix").get(0), 1) + ); + } catch (Exception e) {} + } - for (ItemStack ore : OreDictionary.getOres("dustFluix")) { - try { - RecipeHandler.addEnrichmentChamberRecipe(StackUtils.size(ore, 1), StackUtils.size(OreDictionary.getOres("crystalFluix").get(0), 1)); - } catch (Exception e) { - } - } + for (ItemStack ore : OreDictionary.getOres("dustFluix")) { + try { + RecipeHandler.addEnrichmentChamberRecipe( + StackUtils.size(ore, 1), + StackUtils.size(OreDictionary.getOres("crystalFluix").get(0), 1) + ); + } catch (Exception e) {} + } - for (ItemStack ore : OreDictionary.getOres("ingotCopper")) { - RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("TIN"), 10, StackUtils.size(ore, 1), new ItemStack(MekanismItems.Ingot, 1, 2)); - } + for (ItemStack ore : OreDictionary.getOres("ingotCopper")) { + RecipeHandler.addMetallurgicInfuserRecipe( + InfuseRegistry.get("TIN"), + 10, + StackUtils.size(ore, 1), + new ItemStack(MekanismItems.Ingot, 1, 2) + ); + } - for (ItemStack ore : OreDictionary.getOres("ingotRefinedObsidian")) { - RecipeHandler.addCrusherRecipe(StackUtils.size(ore, 1), new ItemStack(MekanismItems.OtherDust, 1, 6)); - } - for(ItemStack ore : OreDictionary.getOres("ingotRedstone")) - { - RecipeHandler.addCrusherRecipe(StackUtils.size(ore, 1), new ItemStack(Items.redstone)); - } - - for(ItemStack ore : OreDictionary.getOres("ingotRefinedGlowstone")) - { - RecipeHandler.addCrusherRecipe(StackUtils.size(ore, 1), new ItemStack(Items.glowstone_dust)); - } - - try { - RecipeHandler.addCrusherRecipe(new ItemStack(MekanismItems.Ingot, 1, 2), StackUtils.size(OreDictionary.getOres("dustBronze").get(0), 1)); - - if(Mekanism.hooks.IC2Loaded) - { - addIC2BronzeRecipe(); - } - } catch(Exception e) {} - - try { - FurnaceRecipes.smelting().func_151394_a(new ItemStack(MekanismItems.Dust, 1, Resource.SILVER.ordinal()), StackUtils.size(OreDictionary.getOres("ingotSilver").get(0), 1), 0.0F); - } catch(Exception e) {} - - try { - FurnaceRecipes.smelting().func_151394_a(new ItemStack(MekanismItems.Dust, 1, Resource.LEAD.ordinal()), StackUtils.size(OreDictionary.getOres("ingotLead").get(0), 1), 0.0F); - } catch(Exception e) {} - - try { - RecipeHandler.addCrusherRecipe(new ItemStack(Items.coal), StackUtils.size(OreDictionary.getOres("dustCoal").get(0), 1)); - } catch(Exception e) {} - - try { - RecipeHandler.addCrusherRecipe(new ItemStack(Items.coal, 1, 1), StackUtils.size(OreDictionary.getOres("dustCharcoal").get(0), 1)); - } catch(Exception e) {} - - try { - RecipeHandler.addCrusherRecipe(new ItemStack(Items.gunpowder), StackUtils.size(OreDictionary.getOres("dustSaltpeter").get(0), 1)); - } catch(Exception e) {} - - for(ItemStack ore : OreDictionary.getOres("sand")) - { - try { - RecipeHandler.addCrusherRecipe(StackUtils.size(ore, 1), StackUtils.size(OreDictionary.getOres("itemSilicon").get(0), 1)); - } catch(Exception e) {} - } - - for(ItemStack ore : OreDictionary.getOres("dustSaltpeter")) - { - RecipeHandler.addEnrichmentChamberRecipe(StackUtils.size(ore, 1), new ItemStack(Items.gunpowder)); - } - - for(ItemStack ore : OreDictionary.getOres("ingotSteel")) - { - RecipeHandler.addCrusherRecipe(StackUtils.size(ore, 1), new ItemStack(MekanismItems.OtherDust, 1, 1)); - } - - for(ItemStack ore : OreDictionary.getOres("dustLapis")) - { - RecipeHandler.addCrusherRecipe(new ItemStack(Items.dye, 1, 4), StackUtils.size(ore, 1)); - } - - for(ItemStack ore : OreDictionary.getOres("dustLithium")) - { - RecipeHandler.addChemicalOxidizerRecipe(StackUtils.size(ore, 1), new GasStack(GasRegistry.getGas("lithium"), 100)); - } - - for(ItemStack ore : OreDictionary.getOres("dustObsidian")) - { - RecipeHandler.addCombinerRecipe(StackUtils.size(ore, 4), new ItemStack(Blocks.obsidian)); - RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("DIAMOND"), 10, StackUtils.size(ore, 1), new ItemStack(MekanismItems.OtherDust, 1, 5)); - } - - for(ItemStack ore : OreDictionary.getOres("dustDiamond")) - { - InfuseRegistry.registerInfuseObject(ore, new InfuseObject(InfuseRegistry.get("DIAMOND"), 10)); - RecipeHandler.addEnrichmentChamberRecipe(StackUtils.size(ore, 1), new ItemStack(Items.diamond)); - } - - for(ItemStack ore : OreDictionary.getOres("dustTin")) - { - InfuseRegistry.registerInfuseObject(ore, new InfuseObject(InfuseRegistry.get("TIN"), 50)); - } + for (ItemStack ore : OreDictionary.getOres("ingotRefinedObsidian")) { + RecipeHandler.addCrusherRecipe( + StackUtils.size(ore, 1), new ItemStack(MekanismItems.OtherDust, 1, 6) + ); + } + for (ItemStack ore : OreDictionary.getOres("ingotRedstone")) { + RecipeHandler.addCrusherRecipe( + StackUtils.size(ore, 1), new ItemStack(Items.redstone) + ); + } - try { - for(ItemStack ore : OreDictionary.getOres("treeSapling")) - { - if(ore.getItemDamage() == 0 || ore.getItemDamage() == OreDictionary.WILDCARD_VALUE) - { - RecipeHandler.addCrusherRecipe(new ItemStack(ore.getItem(), 1, OreDictionary.WILDCARD_VALUE), new ItemStack(MekanismItems.BioFuel, 2)); - } - } - } catch(Exception e) {} - } - - @Method(modid = "IC2") - public static void addIC2BronzeRecipe() - { - try { - Recipes.macerator.addRecipe(new RecipeInputOreDict("ingotBronze"), null, StackUtils.size(OreDictionary.getOres("dustBronze").get(0), 1)); - } catch(Exception e) {} - } + for (ItemStack ore : OreDictionary.getOres("ingotRefinedGlowstone")) { + RecipeHandler.addCrusherRecipe( + StackUtils.size(ore, 1), new ItemStack(Items.glowstone_dust) + ); + } + try { + RecipeHandler.addCrusherRecipe( + new ItemStack(MekanismItems.Ingot, 1, 2), + StackUtils.size(OreDictionary.getOres("dustBronze").get(0), 1) + ); - /** - * Handy method for retrieving all log items, finding their corresponding planks, and making recipes with them. Credit to CofhCore. - */ - public static void addLogRecipes() - { - Container tempContainer = new Container() { - @Override - public boolean canInteractWith(EntityPlayer player) - { - return false; - } - }; - - InventoryCrafting tempCrafting = new InventoryCrafting(tempContainer, 3, 3); - ArrayList recipeList = (ArrayList)CraftingManager.getInstance().getRecipeList(); + if (Mekanism.hooks.IC2Loaded) { + addIC2BronzeRecipe(); + } + } catch (Exception e) {} - for(int i = 1; i < 9; i++) - { - tempCrafting.setInventorySlotContents(i, null); - } + try { + FurnaceRecipes.smelting().func_151394_a( + new ItemStack(MekanismItems.Dust, 1, Resource.SILVER.ordinal()), + StackUtils.size(OreDictionary.getOres("ingotSilver").get(0), 1), + 0.0F + ); + } catch (Exception e) {} - ArrayList registeredOres = OreDictionary.getOres("logWood"); - - for(int i = 0; i < registeredOres.size(); i++) - { - ItemStack logEntry = (ItemStack)registeredOres.get(i); + try { + FurnaceRecipes.smelting().func_151394_a( + new ItemStack(MekanismItems.Dust, 1, Resource.LEAD.ordinal()), + StackUtils.size(OreDictionary.getOres("ingotLead").get(0), 1), + 0.0F + ); + } catch (Exception e) {} - if(logEntry.getItemDamage() == OreDictionary.WILDCARD_VALUE) - { - for(int j = 0; j < 16; j++) - { - ItemStack log = new ItemStack(logEntry.getItem(), 1, j); - tempCrafting.setInventorySlotContents(0, log); - ItemStack resultEntry = MekanismUtils.findMatchingRecipe(tempCrafting, null); + try { + RecipeHandler.addCrusherRecipe( + new ItemStack(Items.coal), + StackUtils.size(OreDictionary.getOres("dustCoal").get(0), 1) + ); + } catch (Exception e) {} - if(resultEntry != null) - { - RecipeHandler.addPrecisionSawmillRecipe(log, StackUtils.size(resultEntry, 6), new ItemStack(MekanismItems.Sawdust), 1); - } - } - } - else { - ItemStack log = StackUtils.size(logEntry, 1); - tempCrafting.setInventorySlotContents(0, log); - ItemStack resultEntry = MekanismUtils.findMatchingRecipe(tempCrafting, null); + try { + RecipeHandler.addCrusherRecipe( + new ItemStack(Items.coal, 1, 1), + StackUtils.size(OreDictionary.getOres("dustCharcoal").get(0), 1) + ); + } catch (Exception e) {} - if(resultEntry != null) - { - RecipeHandler.addPrecisionSawmillRecipe(log, StackUtils.size(resultEntry, 6), new ItemStack(MekanismItems.Sawdust), 1); - } - } - } - } - public static void terralizationcompat() { - if (MekanismConfig.general.EnableQuartzCompat) { - // Enrich quartz dust into quartz - for (ItemStack ore : OreDictionary.getOres("dustQuartz")) { - RecipeHelper.addEnrichmentChamberRecipe(StackUtils.size(ore, 1), new ItemStack(Items.quartz)); - } - for (ItemStack ore : OreDictionary.getOres("dustNetherQuartz")) { - RecipeHelper.addEnrichmentChamberRecipe(StackUtils.size(ore, 1), new ItemStack(Items.quartz)); - } - // Enrich quartz ore into 2 quartz dust - for (ItemStack ore : OreDictionary.getOres("dustQuartz")) { - RecipeHelper.addEnrichmentChamberRecipe(new ItemStack(Blocks.quartz_ore), StackUtils.size(ore, 2)); - } - for (ItemStack ore : OreDictionary.getOres("dustNetherQuartz")) { - RecipeHelper.addEnrichmentChamberRecipe(new ItemStack(Blocks.quartz_ore), StackUtils.size(ore, 2)); - } - } - // Add gemdiamond oredict for compressed diamond - if (MekanismConfig.general.EnableDiamondCompat) { - for (ItemStack ore : OreDictionary.getOres("gemDiamond")) { - InfuseRegistry.registerInfuseObject(ore, new InfuseObject(InfuseRegistry.get("DIAMOND"), 10)); - RecipeHelper.addEnrichmentChamberRecipe(StackUtils.size(ore, 1), new ItemStack(MekanismItems.CompressedDiamond)); - } - } - if (MekanismConfig.general.EnablePoorOresCompat) { - for (ItemStack ore : OreDictionary.getOres("orePoorIron")) { - for (ItemStack ore2 : OreDictionary.getOres("clumpIron")) { - RecipeHelper.addPurificationChamberRecipe(ore, ore2); - } - } - for (ItemStack ore : OreDictionary.getOres("orePoorGold")) { - for (ItemStack ore2 : OreDictionary.getOres("clumpGold")) { - RecipeHelper.addPurificationChamberRecipe(ore, ore2); - } - } - for (ItemStack ore : OreDictionary.getOres("orePoorCopper")) { - for (ItemStack ore2 : OreDictionary.getOres("clumpCopper")) { - RecipeHelper.addPurificationChamberRecipe(ore, ore2); - } - } - for (ItemStack ore : OreDictionary.getOres("orePoorTin")) { - for (ItemStack ore2 : OreDictionary.getOres("clumpTin")) { - RecipeHelper.addPurificationChamberRecipe(ore, ore2); - } - } - for (ItemStack ore : OreDictionary.getOres("orePoorLead")) { - for (ItemStack ore2 : OreDictionary.getOres("clumpLead")) { - RecipeHelper.addPurificationChamberRecipe(ore, ore2); - } - } - } - } + try { + RecipeHandler.addCrusherRecipe( + new ItemStack(Items.gunpowder), + StackUtils.size(OreDictionary.getOres("dustSaltpeter").get(0), 1) + ); + } catch (Exception e) {} + + for (ItemStack ore : OreDictionary.getOres("sand")) { + try { + RecipeHandler.addCrusherRecipe( + StackUtils.size(ore, 1), + StackUtils.size(OreDictionary.getOres("itemSilicon").get(0), 1) + ); + } catch (Exception e) {} + } + + for (ItemStack ore : OreDictionary.getOres("dustSaltpeter")) { + RecipeHandler.addEnrichmentChamberRecipe( + StackUtils.size(ore, 1), new ItemStack(Items.gunpowder) + ); + } + + for (ItemStack ore : OreDictionary.getOres("ingotSteel")) { + RecipeHandler.addCrusherRecipe( + StackUtils.size(ore, 1), new ItemStack(MekanismItems.OtherDust, 1, 1) + ); + } + + for (ItemStack ore : OreDictionary.getOres("dustLapis")) { + RecipeHandler.addCrusherRecipe( + new ItemStack(Items.dye, 1, 4), StackUtils.size(ore, 1) + ); + } + + for (ItemStack ore : OreDictionary.getOres("dustLithium")) { + RecipeHandler.addChemicalOxidizerRecipe( + StackUtils.size(ore, 1), new GasStack(GasRegistry.getGas("lithium"), 100) + ); + } + + for (ItemStack ore : OreDictionary.getOres("dustObsidian")) { + RecipeHandler.addCombinerRecipe( + StackUtils.size(ore, 4), new ItemStack(Blocks.obsidian) + ); + RecipeHandler.addMetallurgicInfuserRecipe( + InfuseRegistry.get("DIAMOND"), + 10, + StackUtils.size(ore, 1), + new ItemStack(MekanismItems.OtherDust, 1, 5) + ); + } + + for (ItemStack ore : OreDictionary.getOres("dustDiamond")) { + InfuseRegistry.registerInfuseObject( + ore, new InfuseObject(InfuseRegistry.get("DIAMOND"), 10) + ); + RecipeHandler.addEnrichmentChamberRecipe( + StackUtils.size(ore, 1), new ItemStack(Items.diamond) + ); + } + + for (ItemStack ore : OreDictionary.getOres("dustTin")) { + InfuseRegistry.registerInfuseObject( + ore, new InfuseObject(InfuseRegistry.get("TIN"), 50) + ); + } + + try { + for (ItemStack ore : OreDictionary.getOres("treeSapling")) { + if (ore.getItemDamage() == 0 + || ore.getItemDamage() == OreDictionary.WILDCARD_VALUE) { + RecipeHandler.addCrusherRecipe( + new ItemStack(ore.getItem(), 1, OreDictionary.WILDCARD_VALUE), + new ItemStack(MekanismItems.BioFuel, 2) + ); + } + } + } catch (Exception e) {} + } + + @Method(modid = "IC2") + public static void addIC2BronzeRecipe() { + try { + Recipes.macerator.addRecipe( + new RecipeInputOreDict("ingotBronze"), + null, + StackUtils.size(OreDictionary.getOres("dustBronze").get(0), 1) + ); + } catch (Exception e) {} + } + + /** + * Handy method for retrieving all log items, finding their corresponding planks, and + * making recipes with them. Credit to CofhCore. + */ + public static void addLogRecipes() { + Container tempContainer = new Container() { + @Override + public boolean canInteractWith(EntityPlayer player) { + return false; + } + }; + + InventoryCrafting tempCrafting = new InventoryCrafting(tempContainer, 3, 3); + ArrayList recipeList = (ArrayList) CraftingManager.getInstance().getRecipeList(); + + for (int i = 1; i < 9; i++) { + tempCrafting.setInventorySlotContents(i, null); + } + + ArrayList registeredOres = OreDictionary.getOres("logWood"); + + for (int i = 0; i < registeredOres.size(); i++) { + ItemStack logEntry = (ItemStack) registeredOres.get(i); + + if (logEntry.getItemDamage() == OreDictionary.WILDCARD_VALUE) { + for (int j = 0; j < 16; j++) { + ItemStack log = new ItemStack(logEntry.getItem(), 1, j); + tempCrafting.setInventorySlotContents(0, log); + ItemStack resultEntry + = MekanismUtils.findMatchingRecipe(tempCrafting, null); + + if (resultEntry != null) { + RecipeHandler.addPrecisionSawmillRecipe( + log, + StackUtils.size(resultEntry, 6), + new ItemStack(MekanismItems.Sawdust), + 1 + ); + } + } + } else { + ItemStack log = StackUtils.size(logEntry, 1); + tempCrafting.setInventorySlotContents(0, log); + ItemStack resultEntry + = MekanismUtils.findMatchingRecipe(tempCrafting, null); + + if (resultEntry != null) { + RecipeHandler.addPrecisionSawmillRecipe( + log, + StackUtils.size(resultEntry, 6), + new ItemStack(MekanismItems.Sawdust), + 1 + ); + } + } + } + } + + public static void terralizationcompat() { + if (MekanismConfig.general.EnableQuartzCompat) { + // Enrich quartz dust into quartz + for (ItemStack ore : OreDictionary.getOres("dustQuartz")) { + RecipeHelper.addEnrichmentChamberRecipe( + StackUtils.size(ore, 1), new ItemStack(Items.quartz) + ); + } + for (ItemStack ore : OreDictionary.getOres("dustNetherQuartz")) { + RecipeHelper.addEnrichmentChamberRecipe( + StackUtils.size(ore, 1), new ItemStack(Items.quartz) + ); + } + // Enrich quartz ore into 2 quartz dust + for (ItemStack ore : OreDictionary.getOres("dustQuartz")) { + RecipeHelper.addEnrichmentChamberRecipe( + new ItemStack(Blocks.quartz_ore), StackUtils.size(ore, 2) + ); + } + for (ItemStack ore : OreDictionary.getOres("dustNetherQuartz")) { + RecipeHelper.addEnrichmentChamberRecipe( + new ItemStack(Blocks.quartz_ore), StackUtils.size(ore, 2) + ); + } + } + // Add gemdiamond oredict for compressed diamond + if (MekanismConfig.general.EnableDiamondCompat) { + for (ItemStack ore : OreDictionary.getOres("gemDiamond")) { + InfuseRegistry.registerInfuseObject( + ore, new InfuseObject(InfuseRegistry.get("DIAMOND"), 10) + ); + RecipeHelper.addEnrichmentChamberRecipe( + StackUtils.size(ore, 1), + new ItemStack(MekanismItems.CompressedDiamond) + ); + } + } + if (MekanismConfig.general.EnablePoorOresCompat) { + for (ItemStack ore : OreDictionary.getOres("orePoorIron")) { + for (ItemStack ore2 : OreDictionary.getOres("clumpIron")) { + RecipeHelper.addPurificationChamberRecipe(ore, ore2); + } + } + for (ItemStack ore : OreDictionary.getOres("orePoorGold")) { + for (ItemStack ore2 : OreDictionary.getOres("clumpGold")) { + RecipeHelper.addPurificationChamberRecipe(ore, ore2); + } + } + for (ItemStack ore : OreDictionary.getOres("orePoorCopper")) { + for (ItemStack ore2 : OreDictionary.getOres("clumpCopper")) { + RecipeHelper.addPurificationChamberRecipe(ore, ore2); + } + } + for (ItemStack ore : OreDictionary.getOres("orePoorTin")) { + for (ItemStack ore2 : OreDictionary.getOres("clumpTin")) { + RecipeHelper.addPurificationChamberRecipe(ore, ore2); + } + } + for (ItemStack ore : OreDictionary.getOres("orePoorLead")) { + for (ItemStack ore2 : OreDictionary.getOres("clumpLead")) { + RecipeHelper.addPurificationChamberRecipe(ore, ore2); + } + } + } + } } diff --git a/src/main/java/mekanism/common/integration/UECompatModule.java b/src/main/java/mekanism/common/integration/UECompatModule.java index f7765270f..a9743de99 100644 --- a/src/main/java/mekanism/common/integration/UECompatModule.java +++ b/src/main/java/mekanism/common/integration/UECompatModule.java @@ -11,9 +11,10 @@ import net.minecraftforge.common.util.ForgeDirection; import universalelectricity.api.CompatibilityModule; public class UECompatModule extends CompatibilityModule { - @Override - public double doReceiveEnergy(Object handler, ForgeDirection direction, double energy, boolean doReceive) { + public double doReceiveEnergy( + Object handler, ForgeDirection direction, double energy, boolean doReceive + ) { if (doCanReceive(handler, direction)) { IStrictEnergyAcceptor acceptor = (IStrictEnergyAcceptor) handler; return acceptor.transferEnergyToAcceptor(direction, energy); @@ -22,7 +23,9 @@ public class UECompatModule extends CompatibilityModule { } @Override - public double doExtractEnergy(Object handler, ForgeDirection direction, double energy, boolean doExtract) { + public double doExtractEnergy( + Object handler, ForgeDirection direction, double energy, boolean doExtract + ) { if (doCanExtract(handler, direction) && handler instanceof IStrictEnergyStorage) { double provided = doGetProvidedJoules(handler); double toExtract = Math.min(provided, energy); @@ -42,15 +45,19 @@ public class UECompatModule extends CompatibilityModule { } @Override - public double doDischargeItem(ItemStack itemStack, double joules, boolean doDischarge) { + public double + doDischargeItem(ItemStack itemStack, double joules, boolean doDischarge) { // TODO Auto-generated method stub return 0; } @Override public boolean doIsHandler(Object obj) { - if (obj instanceof PartUniversalCable) return false; - return obj instanceof IStrictEnergyAcceptor || (obj instanceof ICableOutputter && obj instanceof IStrictEnergyStorage) || obj instanceof IEnergizedItem; + if (obj instanceof PartUniversalCable) + return false; + return obj instanceof IStrictEnergyAcceptor + || (obj instanceof ICableOutputter && obj instanceof IStrictEnergyStorage) + || obj instanceof IEnergizedItem; } @Override @@ -61,16 +68,17 @@ public class UECompatModule extends CompatibilityModule { @Override public double doGetEnergy(Object obj, ForgeDirection direction) { if (obj instanceof IStrictEnergyStorage) { - return ((IStrictEnergyStorage)obj).getEnergy(); + return ((IStrictEnergyStorage) obj).getEnergy(); } return 0; } @Override public boolean doCanConnect(Object obj, ForgeDirection direction, Object source) { - if (obj instanceof IStrictEnergyAcceptor && ((IStrictEnergyAcceptor)obj).canReceiveEnergy(direction)) { + if (obj instanceof IStrictEnergyAcceptor + && ((IStrictEnergyAcceptor) obj).canReceiveEnergy(direction)) { return true; - } else if (obj instanceof ICableOutputter && ((ICableOutputter)obj).canOutputTo(direction)) { + } else if (obj instanceof ICableOutputter && ((ICableOutputter) obj).canOutputTo(direction)) { return true; } return false; @@ -87,7 +95,7 @@ public class UECompatModule extends CompatibilityModule { @Override public double doGetMaxEnergy(Object handler, ForgeDirection direction) { if (handler instanceof IStrictEnergyStorage) { - return ((IStrictEnergyStorage)handler).getMaxEnergy(); + return ((IStrictEnergyStorage) handler).getMaxEnergy(); } return 0; } @@ -116,10 +124,11 @@ public class UECompatModule extends CompatibilityModule { @Override public boolean doCanReceive(Object handler, ForgeDirection side) { - if (!(handler instanceof IStrictEnergyAcceptor)) return false; - + if (!(handler instanceof IStrictEnergyAcceptor)) + return false; + if (side != ForgeDirection.UNKNOWN) { - return ((IStrictEnergyAcceptor)handler).canReceiveEnergy(side); + return ((IStrictEnergyAcceptor) handler).canReceiveEnergy(side); } return true; @@ -127,10 +136,11 @@ public class UECompatModule extends CompatibilityModule { @Override public boolean doCanExtract(Object handler, ForgeDirection side) { - if (!(handler instanceof ICableOutputter)) return false; - + if (!(handler instanceof ICableOutputter)) + return false; + if (side != ForgeDirection.UNKNOWN) { - return ((ICableOutputter)handler).canOutputTo(side); + return ((ICableOutputter) handler).canOutputTo(side); } return true; @@ -149,13 +159,13 @@ public class UECompatModule extends CompatibilityModule { public double doGetProvidedJoules(Object handler) { double maxOutput = 10000.0; if (handler instanceof IEnergyWrapper) { - maxOutput = ((IEnergyWrapper)handler).getMaxOutput(); + maxOutput = ((IEnergyWrapper) handler).getMaxOutput(); } - if (handler instanceof IStrictEnergyStorage && handler instanceof ICableOutputter) { + if (handler instanceof IStrictEnergyStorage + && handler instanceof ICableOutputter) { IStrictEnergyStorage storage = (IStrictEnergyStorage) handler; return Math.min(storage.getEnergy(), maxOutput); } return 0; } - } diff --git a/src/main/java/mekanism/common/integration/WailaDataProvider.java b/src/main/java/mekanism/common/integration/WailaDataProvider.java index 6e43034c2..7702d85fd 100644 --- a/src/main/java/mekanism/common/integration/WailaDataProvider.java +++ b/src/main/java/mekanism/common/integration/WailaDataProvider.java @@ -2,6 +2,8 @@ package mekanism.common.integration; import java.util.List; +import cpw.mods.fml.common.Optional.Interface; +import cpw.mods.fml.common.Optional.Method; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; import mcp.mobius.waila.api.IWailaDataProvider; @@ -23,101 +25,126 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import cpw.mods.fml.common.Optional.Interface; -import cpw.mods.fml.common.Optional.Method; @Interface(iface = "mcp.mobius.waila.api.IWailaDataProvider", modid = "Waila") -public class WailaDataProvider implements IWailaDataProvider -{ - @Method(modid = "Waila") - public static void register(IWailaRegistrar registrar) - { - WailaDataProvider provider = new WailaDataProvider(); - - registrar.registerHeadProvider(provider, TileEntityInductionCell.class); - registrar.registerHeadProvider(provider, TileEntityInductionProvider.class); - registrar.registerHeadProvider(provider, TileEntityFactory.class); - registrar.registerHeadProvider(provider, TileEntityBoundingBlock.class); - registrar.registerHeadProvider(provider, TileEntityAdvancedBoundingBlock.class); - registrar.registerHeadProvider(provider, TileEntityFluidTank.class); - registrar.registerHeadProvider(provider, TileEntityGasTank.class); - registrar.registerHeadProvider(provider, TileEntityBin.class); - registrar.registerHeadProvider(provider, TileEntityEnergyCube.class); - } - - @Override - @Method(modid = "Waila") - public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) - { - return null; - } +public class WailaDataProvider implements IWailaDataProvider { + @Method(modid = "Waila") + public static void register(IWailaRegistrar registrar) { + WailaDataProvider provider = new WailaDataProvider(); - @Override - @Method(modid = "Waila") - public List getWailaHead(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) - { - TileEntity tile = accessor.getTileEntity(); - - if(tile instanceof TileEntityInductionCell) - { - currenttip.set(0, EnumColor.WHITE + ((TileEntityInductionCell)tile).getInventoryName()); - } - else if(tile instanceof TileEntityInductionProvider) - { - currenttip.set(0, EnumColor.WHITE + ((TileEntityInductionProvider)tile).getInventoryName()); - } - else if(tile instanceof TileEntityFactory) - { - currenttip.set(0, EnumColor.WHITE + ((TileEntityFactory)tile).getInventoryName()); - } - else if(tile instanceof TileEntityFluidTank) - { - currenttip.set(0, EnumColor.WHITE + ((TileEntityFluidTank)tile).getInventoryName()); - } - else if(tile instanceof TileEntityGasTank) - { - currenttip.set(0, EnumColor.WHITE + ((TileEntityGasTank)tile).getInventoryName()); - } - else if(tile instanceof TileEntityBin) - { - currenttip.set(0, EnumColor.WHITE + ((TileEntityBin)tile).getInventoryName()); - } - else if(tile instanceof TileEntityEnergyCube) - { - currenttip.set(0, EnumColor.WHITE + ((TileEntityEnergyCube)tile).getInventoryName()); - } - else if(tile instanceof TileEntityBoundingBlock) - { - TileEntityBoundingBlock bound = (TileEntityBoundingBlock)tile; - Coord4D coord = new Coord4D(bound.mainX, bound.mainY, bound.mainZ, tile.getWorldObj().provider.dimensionId); - - if(bound.receivedCoords && coord.getTileEntity(tile.getWorldObj()) instanceof IInventory) - { - currenttip.set(0, EnumColor.WHITE + ((IInventory)coord.getTileEntity(tile.getWorldObj())).getInventoryName()); - } - } - - return currenttip; - } + registrar.registerHeadProvider(provider, TileEntityInductionCell.class); + registrar.registerHeadProvider(provider, TileEntityInductionProvider.class); + registrar.registerHeadProvider(provider, TileEntityFactory.class); + registrar.registerHeadProvider(provider, TileEntityBoundingBlock.class); + registrar.registerHeadProvider(provider, TileEntityAdvancedBoundingBlock.class); + registrar.registerHeadProvider(provider, TileEntityFluidTank.class); + registrar.registerHeadProvider(provider, TileEntityGasTank.class); + registrar.registerHeadProvider(provider, TileEntityBin.class); + registrar.registerHeadProvider(provider, TileEntityEnergyCube.class); + } - @Override - @Method(modid = "Waila") - public List getWailaBody(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) - { - return currenttip; - } + @Override + @Method(modid = "Waila") + public ItemStack + getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) { + return null; + } - @Override - @Method(modid = "Waila") - public List getWailaTail(ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) - { - return currenttip; - } + @Override + @Method(modid = "Waila") + public List getWailaHead( + ItemStack itemStack, + List currenttip, + IWailaDataAccessor accessor, + IWailaConfigHandler config + ) { + TileEntity tile = accessor.getTileEntity(); - @Override - @Method(modid = "Waila") - public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, int x, int y, int z) - { - return tag; - } + if (tile instanceof TileEntityInductionCell) { + currenttip.set( + 0, EnumColor.WHITE + ((TileEntityInductionCell) tile).getInventoryName() + ); + } else if (tile instanceof TileEntityInductionProvider) { + currenttip.set( + 0, + EnumColor.WHITE + ((TileEntityInductionProvider) tile).getInventoryName() + ); + } else if (tile instanceof TileEntityFactory) { + currenttip.set( + 0, EnumColor.WHITE + ((TileEntityFactory) tile).getInventoryName() + ); + } else if (tile instanceof TileEntityFluidTank) { + currenttip.set( + 0, EnumColor.WHITE + ((TileEntityFluidTank) tile).getInventoryName() + ); + } else if (tile instanceof TileEntityGasTank) { + currenttip.set( + 0, EnumColor.WHITE + ((TileEntityGasTank) tile).getInventoryName() + ); + } else if (tile instanceof TileEntityBin) { + currenttip.set( + 0, EnumColor.WHITE + ((TileEntityBin) tile).getInventoryName() + ); + } else if (tile instanceof TileEntityEnergyCube) { + currenttip.set( + 0, EnumColor.WHITE + ((TileEntityEnergyCube) tile).getInventoryName() + ); + } else if (tile instanceof TileEntityBoundingBlock) { + TileEntityBoundingBlock bound = (TileEntityBoundingBlock) tile; + Coord4D coord = new Coord4D( + bound.mainX, + bound.mainY, + bound.mainZ, + tile.getWorldObj().provider.dimensionId + ); + + if (bound.receivedCoords + && coord.getTileEntity(tile.getWorldObj()) instanceof IInventory) { + currenttip.set( + 0, + EnumColor.WHITE + + ((IInventory) coord.getTileEntity(tile.getWorldObj())) + .getInventoryName() + ); + } + } + + return currenttip; + } + + @Override + @Method(modid = "Waila") + public List getWailaBody( + ItemStack itemStack, + List currenttip, + IWailaDataAccessor accessor, + IWailaConfigHandler config + ) { + return currenttip; + } + + @Override + @Method(modid = "Waila") + public List getWailaTail( + ItemStack itemStack, + List currenttip, + IWailaDataAccessor accessor, + IWailaConfigHandler config + ) { + return currenttip; + } + + @Override + @Method(modid = "Waila") + public NBTTagCompound getNBTData( + EntityPlayerMP player, + TileEntity te, + NBTTagCompound tag, + World world, + int x, + int y, + int z + ) { + return tag; + } } diff --git a/src/main/java/mekanism/common/inventory/InventoryBin.java b/src/main/java/mekanism/common/inventory/InventoryBin.java index a843aad30..1a762bf0f 100644 --- a/src/main/java/mekanism/common/inventory/InventoryBin.java +++ b/src/main/java/mekanism/common/inventory/InventoryBin.java @@ -7,148 +7,127 @@ import mekanism.common.block.BlockBasic.BasicType; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -public class InventoryBin -{ - public ItemStack bin; +public class InventoryBin { + public ItemStack bin; - public InventoryBin(ItemStack stack) - { - bin = stack; - } + public InventoryBin(ItemStack stack) { + bin = stack; + } - public ItemStack getStack() - { - if(getItemCount() > 0 && getItemType() != null) - { - ItemStack ret = getItemType().copy(); - ret.stackSize = Math.min(getItemType().getMaxStackSize(), getItemCount()); + public ItemStack getStack() { + if (getItemCount() > 0 && getItemType() != null) { + ItemStack ret = getItemType().copy(); + ret.stackSize = Math.min(getItemType().getMaxStackSize(), getItemCount()); - return ret; - } + return ret; + } - return null; - } + return null; + } - public ItemStack removeStack() - { - ItemStack stack = getStack(); + public ItemStack removeStack() { + ItemStack stack = getStack(); - if(stack == null) - { - return null; - } + if (stack == null) { + return null; + } - setItemCount(getItemCount() - stack.stackSize); - return stack.copy(); - } + setItemCount(getItemCount() - stack.stackSize); + return stack.copy(); + } - public ItemStack add(ItemStack stack) - { - if(isValid(stack) && getItemCount() != getMaxStorage()) - { - if(getItemType() == null) - { - setItemType(stack); - } + public ItemStack add(ItemStack stack) { + if (isValid(stack) && getItemCount() != getMaxStorage()) { + if (getItemType() == null) { + setItemType(stack); + } - if(getItemCount() + stack.stackSize <= getMaxStorage()) - { - setItemCount(getItemCount() + stack.stackSize); - return null; - } - else { - ItemStack rejects = getItemType().copy(); - rejects.stackSize = (getItemCount()+stack.stackSize) - getMaxStorage(); + if (getItemCount() + stack.stackSize <= getMaxStorage()) { + setItemCount(getItemCount() + stack.stackSize); + return null; + } else { + ItemStack rejects = getItemType().copy(); + rejects.stackSize = (getItemCount() + stack.stackSize) - getMaxStorage(); - setItemCount(getMaxStorage()); + setItemCount(getMaxStorage()); - return rejects; - } - } + return rejects; + } + } - return stack; - } + return stack; + } - public boolean isValid(ItemStack stack) - { - if(stack == null || stack.stackSize <= 0) - { - return false; - } + public boolean isValid(ItemStack stack) { + if (stack == null || stack.stackSize <= 0) { + return false; + } - if(BasicType.get(stack) == BasicType.BIN) - { - return false; - } + if (BasicType.get(stack) == BasicType.BIN) { + return false; + } - if(getItemType() == null) - { - return true; - } + if (getItemType() == null) { + return true; + } - if(!stack.isItemEqual(getItemType()) || !ItemStack.areItemStackTagsEqual(stack, getItemType())) - { - return false; - } + if (!stack.isItemEqual(getItemType()) + || !ItemStack.areItemStackTagsEqual(stack, getItemType())) { + return false; + } - return true; - } - - public int getMaxStorage() - { - return BinTier.values()[((ITierItem)bin.getItem()).getBaseTier(bin).ordinal()].storage; - } + return true; + } - public int getItemCount() - { - if(bin.stackTagCompound == null) - { - return 0; - } + public int getMaxStorage() { + return BinTier.values()[((ITierItem) bin.getItem()).getBaseTier(bin).ordinal()] + .storage; + } - return bin.stackTagCompound.getInteger("itemCount"); - } + public int getItemCount() { + if (bin.stackTagCompound == null) { + return 0; + } - public void setItemCount(int count) - { - if(bin.stackTagCompound == null) - { - bin.setTagCompound(new NBTTagCompound()); - } + return bin.stackTagCompound.getInteger("itemCount"); + } - bin.stackTagCompound.setInteger("itemCount", Math.max(0, count)); + public void setItemCount(int count) { + if (bin.stackTagCompound == null) { + bin.setTagCompound(new NBTTagCompound()); + } - if(getItemCount() == 0) - { - setItemType(null); - } - } + bin.stackTagCompound.setInteger("itemCount", Math.max(0, count)); - public ItemStack getItemType() - { - if(bin.stackTagCompound == null || getItemCount() == 0) - { - return null; - } + if (getItemCount() == 0) { + setItemType(null); + } + } - return ItemStack.loadItemStackFromNBT(bin.stackTagCompound.getCompoundTag("storedItem")); - } + public ItemStack getItemType() { + if (bin.stackTagCompound == null || getItemCount() == 0) { + return null; + } - public void setItemType(ItemStack stack) - { - if(bin.stackTagCompound == null) - { - bin.setTagCompound(new NBTTagCompound()); - } + return ItemStack.loadItemStackFromNBT( + bin.stackTagCompound.getCompoundTag("storedItem") + ); + } - if(stack == null) - { - bin.stackTagCompound.removeTag("storedItem"); - return; - } + public void setItemType(ItemStack stack) { + if (bin.stackTagCompound == null) { + bin.setTagCompound(new NBTTagCompound()); + } - ItemStack ret = StackUtils.size(stack, 1); + if (stack == null) { + bin.stackTagCompound.removeTag("storedItem"); + return; + } - bin.stackTagCompound.setTag("storedItem", StackUtils.size(stack, 1).writeToNBT(new NBTTagCompound())); - } + ItemStack ret = StackUtils.size(stack, 1); + + bin.stackTagCompound.setTag( + "storedItem", StackUtils.size(stack, 1).writeToNBT(new NBTTagCompound()) + ); + } } diff --git a/src/main/java/mekanism/common/inventory/InventoryPersonalChest.java b/src/main/java/mekanism/common/inventory/InventoryPersonalChest.java index b9d147453..41d867866 100644 --- a/src/main/java/mekanism/common/inventory/InventoryPersonalChest.java +++ b/src/main/java/mekanism/common/inventory/InventoryPersonalChest.java @@ -7,108 +7,101 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; -public class InventoryPersonalChest extends InventoryBasic -{ - public EntityPlayer entityPlayer; - public ItemStack itemStack; +public class InventoryPersonalChest extends InventoryBasic { + public EntityPlayer entityPlayer; + public ItemStack itemStack; - public boolean reading; + public boolean reading; - public InventoryPersonalChest(EntityPlayer player) - { - super("PersonalChest", false, 55); - entityPlayer = player; + public InventoryPersonalChest(EntityPlayer player) { + super("PersonalChest", false, 55); + entityPlayer = player; - read(); - } + read(); + } - public InventoryPersonalChest(ItemStack stack) - { - super("PersonalChest", false, 55); - itemStack = stack; + public InventoryPersonalChest(ItemStack stack) { + super("PersonalChest", false, 55); + itemStack = stack; - read(); - } + read(); + } - @Override - public void markDirty() - { - super.markDirty(); + @Override + public void markDirty() { + super.markDirty(); - if(!reading) - { - write(); - } - } + if (!reading) { + write(); + } + } - @Override - public void openInventory() - { - read(); - } + @Override + public void openInventory() { + read(); + } - @Override - public void closeInventory() - { - write(); - } + @Override + public void closeInventory() { + write(); + } - public void write() - { - NBTTagList tagList = new NBTTagList(); + public void write() { + NBTTagList tagList = new NBTTagList(); - for(int slotCount = 0; slotCount < getSizeInventory(); slotCount++) - { - if(getStackInSlot(slotCount) != null) - { - NBTTagCompound tagCompound = new NBTTagCompound(); - tagCompound.setByte("Slot", (byte)slotCount); - getStackInSlot(slotCount).writeToNBT(tagCompound); - tagList.appendTag(tagCompound); - } - } + for (int slotCount = 0; slotCount < getSizeInventory(); slotCount++) { + if (getStackInSlot(slotCount) != null) { + NBTTagCompound tagCompound = new NBTTagCompound(); + tagCompound.setByte("Slot", (byte) slotCount); + getStackInSlot(slotCount).writeToNBT(tagCompound); + tagList.appendTag(tagCompound); + } + } - if(getStack() != null) - { - if (getStack().getItem() instanceof ISustainedInventory) { - ((ISustainedInventory)getStack().getItem()).setInventory(tagList, getStack()); - } else { - System.out.println("Avoiding a server crash as : " + getStack().getItem().getClass().getName() + " is not a sustained inventory."); - } - } - } + if (getStack() != null) { + if (getStack().getItem() instanceof ISustainedInventory) { + ((ISustainedInventory) getStack().getItem()) + .setInventory(tagList, getStack()); + } else { + System.out.println( + "Avoiding a server crash as : " + + getStack().getItem().getClass().getName() + + " is not a sustained inventory." + ); + } + } + } - public void read() - { - if(reading) - { - return; - } + public void read() { + if (reading) { + return; + } - if (getStack() != null && !(getStack().getItem() instanceof ISustainedInventory)) return; - reading = true; + if (getStack() != null && !(getStack().getItem() instanceof ISustainedInventory)) + return; + reading = true; - NBTTagList tagList = ((ISustainedInventory)getStack().getItem()).getInventory(getStack()); + NBTTagList tagList + = ((ISustainedInventory) getStack().getItem()).getInventory(getStack()); - if(tagList != null) - { - for(int tagCount = 0; tagCount < tagList.tagCount(); tagCount++) - { - NBTTagCompound tagCompound = (NBTTagCompound)tagList.getCompoundTagAt(tagCount); - byte slotID = tagCompound.getByte("Slot"); + if (tagList != null) { + for (int tagCount = 0; tagCount < tagList.tagCount(); tagCount++) { + NBTTagCompound tagCompound + = (NBTTagCompound) tagList.getCompoundTagAt(tagCount); + byte slotID = tagCompound.getByte("Slot"); - if(slotID >= 0 && slotID < getSizeInventory()) - { - setInventorySlotContents(slotID, ItemStack.loadItemStackFromNBT(tagCompound)); - } - } - } + if (slotID >= 0 && slotID < getSizeInventory()) { + setInventorySlotContents( + slotID, ItemStack.loadItemStackFromNBT(tagCompound) + ); + } + } + } - reading = false; - } + reading = false; + } - public ItemStack getStack() - { - return itemStack != null ? itemStack : entityPlayer.getCurrentEquippedItem(); - } + public ItemStack getStack() { + return itemStack != null ? itemStack : entityPlayer.getCurrentEquippedItem(); + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerAdvancedElectricMachine.java b/src/main/java/mekanism/common/inventory/container/ContainerAdvancedElectricMachine.java index f7bcae5df..f11cd38f9 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerAdvancedElectricMachine.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerAdvancedElectricMachine.java @@ -13,170 +13,133 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerAdvancedElectricMachine extends Container -{ - private TileEntityAdvancedElectricMachine tileEntity; +public class ContainerAdvancedElectricMachine extends Container { + private TileEntityAdvancedElectricMachine tileEntity; - public ContainerAdvancedElectricMachine(InventoryPlayer inventory, TileEntityAdvancedElectricMachine tentity) - { - tileEntity = tentity; - addSlotToContainer(new Slot(tentity, 0, 56, 17)); - addSlotToContainer(new Slot(tentity, 1, 56, 53)); - addSlotToContainer(new SlotOutput(tentity, 2, 116, 35)); - addSlotToContainer(new SlotDischarge(tentity, 3, 31, 35)); + public ContainerAdvancedElectricMachine( + InventoryPlayer inventory, TileEntityAdvancedElectricMachine tentity + ) { + tileEntity = tentity; + addSlotToContainer(new Slot(tentity, 0, 56, 17)); + addSlotToContainer(new Slot(tentity, 1, 56, 53)); + addSlotToContainer(new SlotOutput(tentity, 2, 116, 35)); + addSlotToContainer(new SlotDischarge(tentity, 3, 31, 35)); - int slotY; + int slotY; - for(slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); - } - } + for (slotY = 0; slotY < 3; slotY++) { + for (int slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot( + inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18 + )); + } + } - for(slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); - } + for (slotY = 0; slotY < 9; slotY++) { + addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); + } - tileEntity.open(inventory.player); - tileEntity.openInventory(); - } + tileEntity.open(inventory.player); + tileEntity.openInventory(); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - tileEntity.close(entityplayer); - tileEntity.closeInventory(); - } + tileEntity.close(entityplayer); + tileEntity.closeInventory(); + } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(slotID == 2) - { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - else if(ChargeUtils.canBeDischarged(slotStack)) - { - if(slotID != 3) - { - if(!mergeItemStack(slotStack, 3, 4, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(tileEntity.getItemGas(slotStack) != null) - { - if(slotID != 1) - { - if(!mergeItemStack(slotStack, 1, 2, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(isInputItem(slotStack)) - { - if(slotID != 0) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID >= 4 && slotID <= 30) - { - if(!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 30) - { - if(!mergeItemStack(slotStack, 4, 30, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - } + if (slotID == 2) { + if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { + return null; + } + } else if (ChargeUtils.canBeDischarged(slotStack)) { + if (slotID != 3) { + if (!mergeItemStack(slotStack, 3, 4, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { + return null; + } + } + } else if (tileEntity.getItemGas(slotStack) != null) { + if (slotID != 1) { + if (!mergeItemStack(slotStack, 1, 2, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { + return null; + } + } + } else if (isInputItem(slotStack)) { + if (slotID != 0) { + if (!mergeItemStack(slotStack, 0, 1, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { + return null; + } + } + } else { + if (slotID >= 4 && slotID <= 30) { + if (!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) { + return null; + } + } else if (slotID > 30) { + if (!mergeItemStack(slotStack, 4, 30, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { + return null; + } + } + } - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - currentSlot.onPickupFromSlot(player, slotStack); - } + currentSlot.onPickupFromSlot(player, slotStack); + } - return stack; - } + return stack; + } - private boolean isInputItem(ItemStack itemstack) - { - for(Map.Entry entry : ((Map)tileEntity.getRecipes()).entrySet()) - { - if(entry.getKey().itemStack.isItemEqual(itemstack)) - { - return true; - } - } + private boolean isInputItem(ItemStack itemstack) { + for (Map.Entry entry : + ((Map) tileEntity.getRecipes()) + .entrySet()) { + if (entry.getKey().itemStack.isItemEqual(itemstack)) { + return true; + } + } - return false; - } + return false; + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerChanceMachine.java b/src/main/java/mekanism/common/inventory/container/ContainerChanceMachine.java index a2ca72c74..02527c389 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerChanceMachine.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerChanceMachine.java @@ -12,142 +12,113 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerChanceMachine extends Container -{ - private TileEntityChanceMachine tileEntity; +public class ContainerChanceMachine extends Container { + private TileEntityChanceMachine tileEntity; - public ContainerChanceMachine(InventoryPlayer inventory, TileEntityChanceMachine tentity) - { - tileEntity = tentity; - addSlotToContainer(new Slot(tentity, 0, 56, 17)); - addSlotToContainer(new SlotDischarge(tentity, 1, 56, 53)); - addSlotToContainer(new SlotOutput(tentity, 2, 116, 35)); - addSlotToContainer(new SlotOutput(tentity, 4, 132, 35)); - - int slotY; + public ContainerChanceMachine( + InventoryPlayer inventory, TileEntityChanceMachine tentity + ) { + tileEntity = tentity; + addSlotToContainer(new Slot(tentity, 0, 56, 17)); + addSlotToContainer(new SlotDischarge(tentity, 1, 56, 53)); + addSlotToContainer(new SlotOutput(tentity, 2, 116, 35)); + addSlotToContainer(new SlotOutput(tentity, 4, 132, 35)); - for(slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); - } - } + int slotY; - for(slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); - } + for (slotY = 0; slotY < 3; slotY++) { + for (int slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot( + inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18 + )); + } + } - tileEntity.open(inventory.player); - tileEntity.openInventory(); - } + for (slotY = 0; slotY < 9; slotY++) { + addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + tileEntity.open(inventory.player); + tileEntity.openInventory(); + } - tileEntity.close(entityplayer); - tileEntity.closeInventory(); - } + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } + tileEntity.close(entityplayer); + tileEntity.closeInventory(); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(slotID == 2 || slotID == 3) - { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - else if(ChargeUtils.canBeDischarged(slotStack)) - { - if(slotID != 1) - { - if(!mergeItemStack(slotStack, 1, 2, false)) - { - return null; - } - } - else if(slotID == 1) - { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - } + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); + + if (slotID == 2 || slotID == 3) { + if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { + return null; + } + } else if (ChargeUtils.canBeDischarged(slotStack)) { + if (slotID != 1) { + if (!mergeItemStack(slotStack, 1, 2, false)) { + return null; + } + } else if (slotID == 1) { + if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { + return null; + } + } + } else if(RecipeHandler.getChanceRecipe(new ItemStackInput(slotStack), tileEntity.getRecipes()) != null) { - if(slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID >= 4 && slotID <= 30) - { - if(!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 30) - { - if(!mergeItemStack(slotStack, 4, 30, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - } + if (slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3) { + if (!mergeItemStack(slotStack, 0, 1, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { + return null; + } + } + } else { + if (slotID >= 4 && slotID <= 30) { + if (!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) { + return null; + } + } else if (slotID > 30) { + if (!mergeItemStack(slotStack, 4, 30, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { + return null; + } + } + } - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - currentSlot.onPickupFromSlot(player, slotStack); - } + currentSlot.onPickupFromSlot(player, slotStack); + } - return stack; - } + return stack; + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerChemicalCrystallizer.java b/src/main/java/mekanism/common/inventory/container/ContainerChemicalCrystallizer.java index fab2cfbaa..9c4f0e636 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerChemicalCrystallizer.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerChemicalCrystallizer.java @@ -12,141 +12,110 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerChemicalCrystallizer extends Container -{ - private TileEntityChemicalCrystallizer tileEntity; +public class ContainerChemicalCrystallizer extends Container { + private TileEntityChemicalCrystallizer tileEntity; - public ContainerChemicalCrystallizer(InventoryPlayer inventory, TileEntityChemicalCrystallizer tentity) - { - tileEntity = tentity; - addSlotToContainer(new SlotStorageTank(tentity, 0, 6, 65)); - addSlotToContainer(new SlotOutput(tentity, 1, 131, 57)); - addSlotToContainer(new SlotDischarge(tentity, 2, 155, 5)); + public ContainerChemicalCrystallizer( + InventoryPlayer inventory, TileEntityChemicalCrystallizer tentity + ) { + tileEntity = tentity; + addSlotToContainer(new SlotStorageTank(tentity, 0, 6, 65)); + addSlotToContainer(new SlotOutput(tentity, 1, 131, 57)); + addSlotToContainer(new SlotDischarge(tentity, 2, 155, 5)); - int slotY; + int slotY; - for(slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); - } - } + for (slotY = 0; slotY < 3; slotY++) { + for (int slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot( + inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18 + )); + } + } - for(slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); - } + for (slotY = 0; slotY < 9; slotY++) { + addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); + } - tileEntity.open(inventory.player); - tileEntity.openInventory(); - } + tileEntity.open(inventory.player); + tileEntity.openInventory(); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - tileEntity.close(entityplayer); - tileEntity.closeInventory(); - } + tileEntity.close(entityplayer); + tileEntity.closeInventory(); + } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(slotStack.getItem() instanceof IGasItem) - { - if(slotID != 0) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(slotID == 1) - { - if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) - { - return null; - } - } - else if(ChargeUtils.canBeDischarged(slotStack)) - { - if(slotID != 2) - { - if(!mergeItemStack(slotStack, 2, 3, false)) - { - return null; - } - } - else if(slotID == 2) - { - if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID >= 3 && slotID <= 29) - { - if(!mergeItemStack(slotStack, 30, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 29) - { - if(!mergeItemStack(slotStack, 3, 29, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) - { - return null; - } - } - } + if (slotStack.getItem() instanceof IGasItem) { + if (slotID != 0) { + if (!mergeItemStack(slotStack, 0, 1, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { + return null; + } + } + } else if (slotID == 1) { + if (!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { + return null; + } + } else if (ChargeUtils.canBeDischarged(slotStack)) { + if (slotID != 2) { + if (!mergeItemStack(slotStack, 2, 3, false)) { + return null; + } + } else if (slotID == 2) { + if (!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { + return null; + } + } + } else { + if (slotID >= 3 && slotID <= 29) { + if (!mergeItemStack(slotStack, 30, inventorySlots.size(), false)) { + return null; + } + } else if (slotID > 29) { + if (!mergeItemStack(slotStack, 3, 29, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { + return null; + } + } + } - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - currentSlot.onPickupFromSlot(player, slotStack); - } + currentSlot.onPickupFromSlot(player, slotStack); + } - return stack; - } + return stack; + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerChemicalDissolutionChamber.java b/src/main/java/mekanism/common/inventory/container/ContainerChemicalDissolutionChamber.java index 5af4f16df..f3fce44d4 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerChemicalDissolutionChamber.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerChemicalDissolutionChamber.java @@ -13,154 +13,120 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerChemicalDissolutionChamber extends Container -{ - private TileEntityChemicalDissolutionChamber tileEntity; +public class ContainerChemicalDissolutionChamber extends Container { + private TileEntityChemicalDissolutionChamber tileEntity; - public ContainerChemicalDissolutionChamber(InventoryPlayer inventory, TileEntityChemicalDissolutionChamber tentity) - { - tileEntity = tentity; - addSlotToContainer(new SlotStorageTank(tentity, 0, 6, 65)); - addSlotToContainer(new Slot(tentity, 1, 26, 36)); - addSlotToContainer(new SlotStorageTank(tentity, 2, 155, 25)); - addSlotToContainer(new SlotDischarge(tentity, 3, 155, 5)); + public ContainerChemicalDissolutionChamber( + InventoryPlayer inventory, TileEntityChemicalDissolutionChamber tentity + ) { + tileEntity = tentity; + addSlotToContainer(new SlotStorageTank(tentity, 0, 6, 65)); + addSlotToContainer(new Slot(tentity, 1, 26, 36)); + addSlotToContainer(new SlotStorageTank(tentity, 2, 155, 25)); + addSlotToContainer(new SlotDischarge(tentity, 3, 155, 5)); - int slotY; + int slotY; - for(slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); - } - } + for (slotY = 0; slotY < 3; slotY++) { + for (int slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot( + inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18 + )); + } + } - for(slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); - } + for (slotY = 0; slotY < 9; slotY++) { + addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); + } - tileEntity.open(inventory.player); - tileEntity.openInventory(); - } + tileEntity.open(inventory.player); + tileEntity.openInventory(); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - tileEntity.close(entityplayer); - tileEntity.closeInventory(); - } + tileEntity.close(entityplayer); + tileEntity.closeInventory(); + } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(RecipeHandler.getDissolutionRecipe(new ItemStackInput(slotStack)) != null) - { - if(slotID != 1) - { - if(!mergeItemStack(slotStack, 1, 2, true)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(ChargeUtils.canBeDischarged(slotStack)) - { - if(slotID != 3) - { - if(!mergeItemStack(slotStack, 3, 4, false)) - { - return null; - } - } - else if(slotID == 3) - { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(slotStack.getItem() instanceof IGasItem) - { - if(slotID != 0 && slotID != 2) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - if(!mergeItemStack(slotStack, 2, 3, false)) - { - return null; - } - } - } - else { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID >= 4 && slotID <= 30) - { - if(!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 30) - { - if(!mergeItemStack(slotStack, 4, 30, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - } + if (RecipeHandler.getDissolutionRecipe(new ItemStackInput(slotStack)) + != null) { + if (slotID != 1) { + if (!mergeItemStack(slotStack, 1, 2, true)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { + return null; + } + } + } else if (ChargeUtils.canBeDischarged(slotStack)) { + if (slotID != 3) { + if (!mergeItemStack(slotStack, 3, 4, false)) { + return null; + } + } else if (slotID == 3) { + if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { + return null; + } + } + } else if (slotStack.getItem() instanceof IGasItem) { + if (slotID != 0 && slotID != 2) { + if (!mergeItemStack(slotStack, 0, 1, false)) { + if (!mergeItemStack(slotStack, 2, 3, false)) { + return null; + } + } + } else { + if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { + return null; + } + } + } else { + if (slotID >= 4 && slotID <= 30) { + if (!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) { + return null; + } + } else if (slotID > 30) { + if (!mergeItemStack(slotStack, 4, 30, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { + return null; + } + } + } - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - currentSlot.onPickupFromSlot(player, slotStack); - } + currentSlot.onPickupFromSlot(player, slotStack); + } - return stack; - } + return stack; + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerChemicalInfuser.java b/src/main/java/mekanism/common/inventory/container/ContainerChemicalInfuser.java index c01f44061..0013f0815 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerChemicalInfuser.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerChemicalInfuser.java @@ -11,135 +11,107 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerChemicalInfuser extends Container -{ - private TileEntityChemicalInfuser tileEntity; +public class ContainerChemicalInfuser extends Container { + private TileEntityChemicalInfuser tileEntity; - public ContainerChemicalInfuser(InventoryPlayer inventory, TileEntityChemicalInfuser tentity) - { - tileEntity = tentity; - addSlotToContainer(new SlotStorageTank(tentity, 0, 5, 56)); - addSlotToContainer(new SlotStorageTank(tentity, 1, 155, 56)); - addSlotToContainer(new SlotStorageTank(tentity, 2, 80, 65)); - addSlotToContainer(new SlotDischarge(tentity, 3, 155, 5)); + public ContainerChemicalInfuser( + InventoryPlayer inventory, TileEntityChemicalInfuser tentity + ) { + tileEntity = tentity; + addSlotToContainer(new SlotStorageTank(tentity, 0, 5, 56)); + addSlotToContainer(new SlotStorageTank(tentity, 1, 155, 56)); + addSlotToContainer(new SlotStorageTank(tentity, 2, 80, 65)); + addSlotToContainer(new SlotDischarge(tentity, 3, 155, 5)); - int slotY; + int slotY; - for(slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); - } - } + for (slotY = 0; slotY < 3; slotY++) { + for (int slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot( + inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18 + )); + } + } - for(slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); - } + for (slotY = 0; slotY < 9; slotY++) { + addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); + } - tileEntity.open(inventory.player); - tileEntity.openInventory(); - } + tileEntity.open(inventory.player); + tileEntity.openInventory(); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - tileEntity.close(entityplayer); - tileEntity.closeInventory(); - } + tileEntity.close(entityplayer); + tileEntity.closeInventory(); + } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(ChargeUtils.canBeDischarged(slotStack)) - { - if(slotID != 3) - { - if(!mergeItemStack(slotStack, 3, 4, false)) - { - return null; - } - } - else if(slotID == 3) - { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(slotStack.getItem() instanceof IGasItem) - { - if(slotID != 0 && slotID != 1 && slotID != 2) - { - if(!mergeItemStack(slotStack, 0, 3, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID >= 4 && slotID <= 30) - { - if(!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 30) - { - if(!mergeItemStack(slotStack, 4, 30, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - } + if (ChargeUtils.canBeDischarged(slotStack)) { + if (slotID != 3) { + if (!mergeItemStack(slotStack, 3, 4, false)) { + return null; + } + } else if (slotID == 3) { + if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { + return null; + } + } + } else if (slotStack.getItem() instanceof IGasItem) { + if (slotID != 0 && slotID != 1 && slotID != 2) { + if (!mergeItemStack(slotStack, 0, 3, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) { + return null; + } + } + } else { + if (slotID >= 4 && slotID <= 30) { + if (!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) { + return null; + } + } else if (slotID > 30) { + if (!mergeItemStack(slotStack, 4, 30, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { + return null; + } + } + } - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - currentSlot.onPickupFromSlot(player, slotStack); - } + currentSlot.onPickupFromSlot(player, slotStack); + } - return stack; - } + return stack; + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerChemicalOxidizer.java b/src/main/java/mekanism/common/inventory/container/ContainerChemicalOxidizer.java index 25c0d6b0d..86f7605e6 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerChemicalOxidizer.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerChemicalOxidizer.java @@ -13,151 +13,116 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerChemicalOxidizer extends Container -{ - private TileEntityChemicalOxidizer tileEntity; +public class ContainerChemicalOxidizer extends Container { + private TileEntityChemicalOxidizer tileEntity; - public ContainerChemicalOxidizer(InventoryPlayer inventory, TileEntityChemicalOxidizer tentity) - { - tileEntity = tentity; - addSlotToContainer(new Slot(tentity, 0, 26, 36)); - addSlotToContainer(new SlotDischarge(tentity, 1, 155, 5)); - addSlotToContainer(new SlotStorageTank(tentity, 2, 155, 25)); + public ContainerChemicalOxidizer( + InventoryPlayer inventory, TileEntityChemicalOxidizer tentity + ) { + tileEntity = tentity; + addSlotToContainer(new Slot(tentity, 0, 26, 36)); + addSlotToContainer(new SlotDischarge(tentity, 1, 155, 5)); + addSlotToContainer(new SlotStorageTank(tentity, 2, 155, 25)); - int slotY; + int slotY; - for(slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); - } - } + for (slotY = 0; slotY < 3; slotY++) { + for (int slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot( + inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18 + )); + } + } - for(slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); - } + for (slotY = 0; slotY < 9; slotY++) { + addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); + } - tileEntity.open(inventory.player); - tileEntity.openInventory(); - } + tileEntity.open(inventory.player); + tileEntity.openInventory(); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - tileEntity.close(entityplayer); - tileEntity.closeInventory(); - } + tileEntity.close(entityplayer); + tileEntity.closeInventory(); + } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(RecipeHandler.getOxidizerRecipe(new ItemStackInput(slotStack)) != null) - { - if(slotID != 0) - { - if(!mergeItemStack(slotStack, 0, 1, true)) - { - return null; - } - } - else if(slotID == 0) - { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(ChargeUtils.canBeDischarged(slotStack)) - { - if(slotID != 1) - { - if(!mergeItemStack(slotStack, 1, 2, false)) - { - return null; - } - } - else if(slotID == 1) - { - if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(slotStack.getItem() instanceof IGasItem) - { - if(slotID != 0 && slotID != 1 && slotID != 2) - { - if(!mergeItemStack(slotStack, 2, 3, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID >= 3 && slotID <= 29) - { - if(!mergeItemStack(slotStack, 30, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 29) - { - if(!mergeItemStack(slotStack, 3, 29, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) - { - return null; - } - } - } + if (RecipeHandler.getOxidizerRecipe(new ItemStackInput(slotStack)) != null) { + if (slotID != 0) { + if (!mergeItemStack(slotStack, 0, 1, true)) { + return null; + } + } else if (slotID == 0) { + if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { + return null; + } + } + } else if (ChargeUtils.canBeDischarged(slotStack)) { + if (slotID != 1) { + if (!mergeItemStack(slotStack, 1, 2, false)) { + return null; + } + } else if (slotID == 1) { + if (!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { + return null; + } + } + } else if (slotStack.getItem() instanceof IGasItem) { + if (slotID != 0 && slotID != 1 && slotID != 2) { + if (!mergeItemStack(slotStack, 2, 3, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { + return null; + } + } + } else { + if (slotID >= 3 && slotID <= 29) { + if (!mergeItemStack(slotStack, 30, inventorySlots.size(), false)) { + return null; + } + } else if (slotID > 29) { + if (!mergeItemStack(slotStack, 3, 29, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { + return null; + } + } + } - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - currentSlot.onPickupFromSlot(player, slotStack); - } + currentSlot.onPickupFromSlot(player, slotStack); + } - return stack; - } + return stack; + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerChemicalWasher.java b/src/main/java/mekanism/common/inventory/container/ContainerChemicalWasher.java index 8c18b893d..da0bf97f8 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerChemicalWasher.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerChemicalWasher.java @@ -14,169 +14,149 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; -public class ContainerChemicalWasher extends Container -{ - private TileEntityChemicalWasher tileEntity; +public class ContainerChemicalWasher extends Container { + private TileEntityChemicalWasher tileEntity; - public ContainerChemicalWasher(InventoryPlayer inventory, TileEntityChemicalWasher tentity) - { - tileEntity = tentity; - addSlotToContainer(new Slot(tentity, 0, 180, 71)); - addSlotToContainer(new SlotOutput(tentity, 1, 180, 102)); - addSlotToContainer(new SlotStorageTank(tentity, 2, 155, 56)); - addSlotToContainer(new SlotDischarge(tentity, 3, 155, 5)); + public ContainerChemicalWasher( + InventoryPlayer inventory, TileEntityChemicalWasher tentity + ) { + tileEntity = tentity; + addSlotToContainer(new Slot(tentity, 0, 180, 71)); + addSlotToContainer(new SlotOutput(tentity, 1, 180, 102)); + addSlotToContainer(new SlotStorageTank(tentity, 2, 155, 56)); + addSlotToContainer(new SlotDischarge(tentity, 3, 155, 5)); - int slotY; + int slotY; - for(slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); - } - } + for (slotY = 0; slotY < 3; slotY++) { + for (int slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot( + inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18 + )); + } + } - for(slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); - } + for (slotY = 0; slotY < 9; slotY++) { + addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); + } - tileEntity.open(inventory.player); - tileEntity.openInventory(); - } + tileEntity.open(inventory.player); + tileEntity.openInventory(); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - tileEntity.close(entityplayer); - tileEntity.closeInventory(); - } + tileEntity.close(entityplayer); + tileEntity.closeInventory(); + } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(currentSlot != null && currentSlot.getHasStack()) - { - - int inputSlot = 0; - int outputSlot = 1; - int tankSlot = 2; - int dischargeSlot = 3; - int firstGenericInvSlot = 4; - int firstHotbarSlot = 31; - int lastHotbarSlot = inventorySlots.size(); + if (currentSlot != null && currentSlot.getHasStack()) { + int inputSlot = 0; + int outputSlot = 1; + int tankSlot = 2; + int dischargeSlot = 3; + int firstGenericInvSlot = 4; + int firstHotbarSlot = 31; + int lastHotbarSlot = inventorySlots.size(); - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - System.out.println(inventorySlots.size()); + System.out.println(inventorySlots.size()); - if(slotID == outputSlot) - { - if(!mergeItemStack(slotStack, firstGenericInvSlot, lastHotbarSlot, true)) - { - return null; - } - } + if (slotID == outputSlot) { + if (!mergeItemStack( + slotStack, firstGenericInvSlot, lastHotbarSlot, true + )) { + return null; + } + } else if(FluidContainerRegistry.isFilledContainer(slotStack) && FluidContainerRegistry.getFluidForFilledItem(slotStack).getFluid() == FluidRegistry.WATER) { - if(slotID != inputSlot) - { - if(!mergeItemStack(slotStack, inputSlot, outputSlot, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, firstGenericInvSlot, lastHotbarSlot, true)) - { - return null; - } - } - } - else if(slotStack.getItem() instanceof IGasItem) - { - if(slotID != tankSlot) - { - if(!mergeItemStack(slotStack, tankSlot, dischargeSlot, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, firstGenericInvSlot, lastHotbarSlot, true)) - { - return null; - } - } - } - else if(ChargeUtils.canBeDischarged(slotStack)) - { - if(slotID != dischargeSlot) - { - if(!mergeItemStack(slotStack, dischargeSlot, firstGenericInvSlot, false)) - { - return null; - } - } - else - { - if(!mergeItemStack(slotStack, firstGenericInvSlot, lastHotbarSlot, true)) - { - return null; - } - } - } - else { - if(slotID >= firstGenericInvSlot && slotID < firstHotbarSlot) - { - if(!mergeItemStack(slotStack, firstHotbarSlot, lastHotbarSlot, false)) - { - return null; - } - } - else if(slotID >= firstHotbarSlot && slotID <= lastHotbarSlot) - { - if(!mergeItemStack(slotStack, firstGenericInvSlot, firstHotbarSlot, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, firstGenericInvSlot, lastHotbarSlot, true)) - { - return null; - } - } - } + if (slotID != inputSlot) { + if (!mergeItemStack(slotStack, inputSlot, outputSlot, false)) { + return null; + } + } else { + if (!mergeItemStack( + slotStack, firstGenericInvSlot, lastHotbarSlot, true + )) { + return null; + } + } + } else if (slotStack.getItem() instanceof IGasItem) { + if (slotID != tankSlot) { + if (!mergeItemStack(slotStack, tankSlot, dischargeSlot, false)) { + return null; + } + } else { + if (!mergeItemStack( + slotStack, firstGenericInvSlot, lastHotbarSlot, true + )) { + return null; + } + } + } else if (ChargeUtils.canBeDischarged(slotStack)) { + if (slotID != dischargeSlot) { + if (!mergeItemStack( + slotStack, dischargeSlot, firstGenericInvSlot, false + )) { + return null; + } + } else { + if (!mergeItemStack( + slotStack, firstGenericInvSlot, lastHotbarSlot, true + )) { + return null; + } + } + } else { + if (slotID >= firstGenericInvSlot && slotID < firstHotbarSlot) { + if (!mergeItemStack( + slotStack, firstHotbarSlot, lastHotbarSlot, false + )) { + return null; + } + } else if (slotID >= firstHotbarSlot && slotID <= lastHotbarSlot) { + if (!mergeItemStack( + slotStack, firstGenericInvSlot, firstHotbarSlot, false + )) { + return null; + } + } else { + if (!mergeItemStack( + slotStack, firstGenericInvSlot, lastHotbarSlot, true + )) { + return null; + } + } + } - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - currentSlot.onPickupFromSlot(player, slotStack); - } + currentSlot.onPickupFromSlot(player, slotStack); + } - return stack; - } + return stack; + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerDictionary.java b/src/main/java/mekanism/common/inventory/container/ContainerDictionary.java index 231ffec87..33369e5c5 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerDictionary.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerDictionary.java @@ -6,80 +6,64 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerDictionary extends Container -{ - public ContainerDictionary(InventoryPlayer inventory) - { - int slotY; +public class ContainerDictionary extends Container { + public ContainerDictionary(InventoryPlayer inventory) { + int slotY; - for(slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); - } - } + for (slotY = 0; slotY < 3; slotY++) { + for (int slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot( + inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18 + )); + } + } - for(slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); - } - } + for (slotY = 0; slotY < 9; slotY++) { + addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); + } + } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return true; - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return true; + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(slotID >= 0 && slotID <= 26) - { - if(!mergeItemStack(slotStack, 27, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 26) - { - if(!mergeItemStack(slotStack, 0, 26, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 0, inventorySlots.size(), true)) - { - return null; - } - } + if (slotID >= 0 && slotID <= 26) { + if (!mergeItemStack(slotStack, 27, inventorySlots.size(), false)) { + return null; + } + } else if (slotID > 26) { + if (!mergeItemStack(slotStack, 0, 26, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 0, inventorySlots.size(), true)) { + return null; + } + } - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - currentSlot.onPickupFromSlot(player, slotStack); - } + currentSlot.onPickupFromSlot(player, slotStack); + } - return stack; - } + return stack; + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerDigitalMiner.java b/src/main/java/mekanism/common/inventory/container/ContainerDigitalMiner.java index 9b366169a..12fb7085f 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerDigitalMiner.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerDigitalMiner.java @@ -9,116 +9,97 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerDigitalMiner extends Container -{ - private TileEntityDigitalMiner tileEntity; +public class ContainerDigitalMiner extends Container { + private TileEntityDigitalMiner tileEntity; - public ContainerDigitalMiner(InventoryPlayer inventory, TileEntityDigitalMiner tentity) - { - tileEntity = tentity; + public ContainerDigitalMiner( + InventoryPlayer inventory, TileEntityDigitalMiner tentity + ) { + tileEntity = tentity; - for(int slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(tentity, slotX + slotY * 9, 8 + slotX * 18, 80 + slotY * 18)); - } - } + for (int slotY = 0; slotY < 3; slotY++) { + for (int slotX = 0; slotX < 9; slotX++) { + addSlotToContainer( + new Slot(tentity, slotX + slotY * 9, 8 + slotX * 18, 80 + slotY * 18) + ); + } + } - addSlotToContainer(new SlotDischarge(tentity, 27, 152, 6)); + addSlotToContainer(new SlotDischarge(tentity, 27, 152, 6)); - int slotY; + int slotY; - for(slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 148 + slotY * 18)); - } - } + for (slotY = 0; slotY < 3; slotY++) { + for (int slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot( + inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 148 + slotY * 18 + )); + } + } - for(slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 206)); - } + for (slotY = 0; slotY < 9; slotY++) { + addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 206)); + } - tileEntity.open(inventory.player); - tileEntity.openInventory(); - } + tileEntity.open(inventory.player); + tileEntity.openInventory(); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - tileEntity.close(entityplayer); - tileEntity.closeInventory(); - } + tileEntity.close(entityplayer); + tileEntity.closeInventory(); + } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(ChargeUtils.canBeDischarged(slotStack)) - { - if(slotID > 27) - { - if(!mergeItemStack(slotStack, 27, 28, false)) - { - return null; - } - } - else if(slotID <= 27) - { - if(!mergeItemStack(slotStack, 28, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID < 27) - { - if(!mergeItemStack(slotStack, 28, inventorySlots.size(), true)) - { - return null; - } - } - else if(!mergeItemStack(slotStack, 0, 27, false)) - { - return null; - } - } + if (ChargeUtils.canBeDischarged(slotStack)) { + if (slotID > 27) { + if (!mergeItemStack(slotStack, 27, 28, false)) { + return null; + } + } else if (slotID <= 27) { + if (!mergeItemStack(slotStack, 28, inventorySlots.size(), true)) { + return null; + } + } + } else { + if (slotID < 27) { + if (!mergeItemStack(slotStack, 28, inventorySlots.size(), true)) { + return null; + } + } else if (!mergeItemStack(slotStack, 0, 27, false)) { + return null; + } + } - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - currentSlot.onPickupFromSlot(player, slotStack); - } + currentSlot.onPickupFromSlot(player, slotStack); + } - return stack; - } + return stack; + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerDynamicTank.java b/src/main/java/mekanism/common/inventory/container/ContainerDynamicTank.java index d1d854d68..37418845d 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerDynamicTank.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerDynamicTank.java @@ -9,116 +9,96 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidContainerRegistry; -public class ContainerDynamicTank extends Container -{ - private TileEntityDynamicTank tileEntity; +public class ContainerDynamicTank extends Container { + private TileEntityDynamicTank tileEntity; - public ContainerDynamicTank(InventoryPlayer inventory, TileEntityDynamicTank tentity) - { - tileEntity = tentity; - addSlotToContainer(new Slot(tentity, 0, 146, 20)); - addSlotToContainer(new SlotOutput(tentity, 1, 146, 51)); - - int slotY; + public ContainerDynamicTank( + InventoryPlayer inventory, TileEntityDynamicTank tentity + ) { + tileEntity = tentity; + addSlotToContainer(new Slot(tentity, 0, 146, 20)); + addSlotToContainer(new SlotOutput(tentity, 1, 146, 51)); - for(slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); - } - } + int slotY; - for(slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); - } + for (slotY = 0; slotY < 3; slotY++) { + for (int slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot( + inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18 + )); + } + } - tileEntity.open(inventory.player); - tileEntity.openInventory(); - } + for (slotY = 0; slotY < 9; slotY++) { + addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + tileEntity.open(inventory.player); + tileEntity.openInventory(); + } - tileEntity.close(entityplayer); - tileEntity.closeInventory(); - } + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } + tileEntity.close(entityplayer); + tileEntity.closeInventory(); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(FluidContainerRegistry.isEmptyContainer(slotStack) || FluidContainerRegistry.isFilledContainer(slotStack)) - { - if(slotID != 0 && slotID != 1) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID >= 2 && slotID <= 28) - { - if(!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 28) - { - if(!mergeItemStack(slotStack, 2, 28, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (FluidContainerRegistry.isEmptyContainer(slotStack) + || FluidContainerRegistry.isFilledContainer(slotStack)) { + if (slotID != 0 && slotID != 1) { + if (!mergeItemStack(slotStack, 0, 1, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) { + return null; + } + } + } else { + if (slotID >= 2 && slotID <= 28) { + if (!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) { + return null; + } + } else if (slotID > 28) { + if (!mergeItemStack(slotStack, 2, 28, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) { + return null; + } + } + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - currentSlot.onPickupFromSlot(player, slotStack); - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - return stack; - } + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerElectricMachine.java b/src/main/java/mekanism/common/inventory/container/ContainerElectricMachine.java index 849d968b3..ba61be2f7 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerElectricMachine.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerElectricMachine.java @@ -12,141 +12,110 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerElectricMachine extends Container -{ - private TileEntityElectricMachine tileEntity; +public class ContainerElectricMachine extends Container { + private TileEntityElectricMachine tileEntity; - public ContainerElectricMachine(InventoryPlayer inventory, TileEntityElectricMachine tentity) - { - tileEntity = tentity; - addSlotToContainer(new Slot(tentity, 0, 56, 17)); - addSlotToContainer(new SlotDischarge(tentity, 1, 56, 53)); - addSlotToContainer(new SlotOutput(tentity, 2, 116, 35)); - - int slotY; + public ContainerElectricMachine( + InventoryPlayer inventory, TileEntityElectricMachine tentity + ) { + tileEntity = tentity; + addSlotToContainer(new Slot(tentity, 0, 56, 17)); + addSlotToContainer(new SlotDischarge(tentity, 1, 56, 53)); + addSlotToContainer(new SlotOutput(tentity, 2, 116, 35)); - for(slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); - } - } + int slotY; - for(slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); - } + for (slotY = 0; slotY < 3; slotY++) { + for (int slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot( + inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18 + )); + } + } - tileEntity.open(inventory.player); - tileEntity.openInventory(); - } + for (slotY = 0; slotY < 9; slotY++) { + addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + tileEntity.open(inventory.player); + tileEntity.openInventory(); + } - tileEntity.close(entityplayer); - tileEntity.closeInventory(); - } + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } + tileEntity.close(entityplayer); + tileEntity.closeInventory(); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(slotID == 2) - { - if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) - { - return null; - } - } - else if(RecipeHandler.getRecipe(new ItemStackInput(slotStack), tileEntity.getRecipes()) != null) - { - if(slotID != 0 && slotID != 1 && slotID != 2) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(ChargeUtils.canBeDischarged(slotStack)) - { - if(slotID != 1) - { - if(!mergeItemStack(slotStack, 1, 2, false)) - { - return null; - } - } - else if(slotID == 1) - { - if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID >= 3 && slotID <= 29) - { - if(!mergeItemStack(slotStack, 30, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 29) - { - if(!mergeItemStack(slotStack, 3, 29, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) - { - return null; - } - } - } + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (slotID == 2) { + if (!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { + return null; + } + } else if (RecipeHandler.getRecipe(new ItemStackInput(slotStack), tileEntity.getRecipes()) != null) { + if (slotID != 0 && slotID != 1 && slotID != 2) { + if (!mergeItemStack(slotStack, 0, 1, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { + return null; + } + } + } else if (ChargeUtils.canBeDischarged(slotStack)) { + if (slotID != 1) { + if (!mergeItemStack(slotStack, 1, 2, false)) { + return null; + } + } else if (slotID == 1) { + if (!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { + return null; + } + } + } else { + if (slotID >= 3 && slotID <= 29) { + if (!mergeItemStack(slotStack, 30, inventorySlots.size(), false)) { + return null; + } + } else if (slotID > 29) { + if (!mergeItemStack(slotStack, 3, 29, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { + return null; + } + } + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - currentSlot.onPickupFromSlot(player, slotStack); - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - return stack; - } + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerElectricPump.java b/src/main/java/mekanism/common/inventory/container/ContainerElectricPump.java index d517c727d..f610340b9 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerElectricPump.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerElectricPump.java @@ -11,141 +11,110 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidContainerRegistry; -public class ContainerElectricPump extends Container -{ - private TileEntityElectricPump tileEntity; +public class ContainerElectricPump extends Container { + private TileEntityElectricPump tileEntity; - public ContainerElectricPump(InventoryPlayer inventory, TileEntityElectricPump tentity) - { - tileEntity = tentity; - addSlotToContainer(new Slot(tentity, 0, 28, 20)); - addSlotToContainer(new SlotOutput(tentity, 1, 28, 51)); - addSlotToContainer(new SlotDischarge(tentity, 2, 143, 35)); - - int slotY; + public ContainerElectricPump( + InventoryPlayer inventory, TileEntityElectricPump tentity + ) { + tileEntity = tentity; + addSlotToContainer(new Slot(tentity, 0, 28, 20)); + addSlotToContainer(new SlotOutput(tentity, 1, 28, 51)); + addSlotToContainer(new SlotDischarge(tentity, 2, 143, 35)); - for(slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); - } - } + int slotY; - for(slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); - } + for (slotY = 0; slotY < 3; slotY++) { + for (int slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot( + inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18 + )); + } + } - tileEntity.open(inventory.player); - tileEntity.openInventory(); - } + for (slotY = 0; slotY < 9; slotY++) { + addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + tileEntity.open(inventory.player); + tileEntity.openInventory(); + } - tileEntity.close(entityplayer); - tileEntity.closeInventory(); - } + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } + tileEntity.close(entityplayer); + tileEntity.closeInventory(); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(ChargeUtils.canBeDischarged(slotStack)) - { - if(slotID != 2) - { - if(!mergeItemStack(slotStack, 2, 3, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(FluidContainerRegistry.isEmptyContainer(slotStack)) - { - if(slotID != 0) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else if(slotID == 0) - { - if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(slotID == 1) - { - if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) - { - return null; - } - } - else { - if(slotID >= 3 && slotID <= 29) - { - if(!mergeItemStack(slotStack, 30, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 29) - { - if(!mergeItemStack(slotStack, 3, 29, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) - { - return null; - } - } - } + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (ChargeUtils.canBeDischarged(slotStack)) { + if (slotID != 2) { + if (!mergeItemStack(slotStack, 2, 3, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { + return null; + } + } + } else if (FluidContainerRegistry.isEmptyContainer(slotStack)) { + if (slotID != 0) { + if (!mergeItemStack(slotStack, 0, 1, false)) { + return null; + } + } else if (slotID == 0) { + if (!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { + return null; + } + } + } else if (slotID == 1) { + if (!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { + return null; + } + } else { + if (slotID >= 3 && slotID <= 29) { + if (!mergeItemStack(slotStack, 30, inventorySlots.size(), false)) { + return null; + } + } else if (slotID > 29) { + if (!mergeItemStack(slotStack, 3, 29, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { + return null; + } + } + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - currentSlot.onPickupFromSlot(player, slotStack); - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - return stack; - } + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerElectrolyticSeparator.java b/src/main/java/mekanism/common/inventory/container/ContainerElectrolyticSeparator.java index 9154a4525..14176a55b 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerElectrolyticSeparator.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerElectrolyticSeparator.java @@ -13,160 +13,128 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerElectrolyticSeparator extends Container -{ - private TileEntityElectrolyticSeparator tileEntity; +public class ContainerElectrolyticSeparator extends Container { + private TileEntityElectrolyticSeparator tileEntity; - public ContainerElectrolyticSeparator(InventoryPlayer inventory, TileEntityElectrolyticSeparator tentity) - { - tileEntity = tentity; - addSlotToContainer(new Slot(tentity, 0, 26, 35)); - addSlotToContainer(new SlotStorageTank(tentity, 1, 59, 52)); - addSlotToContainer(new SlotStorageTank(tentity, 2, 101, 52)); - addSlotToContainer(new SlotDischarge(tentity, 3, 143, 35)); - - int slotY; + public ContainerElectrolyticSeparator( + InventoryPlayer inventory, TileEntityElectrolyticSeparator tentity + ) { + tileEntity = tentity; + addSlotToContainer(new Slot(tentity, 0, 26, 35)); + addSlotToContainer(new SlotStorageTank(tentity, 1, 59, 52)); + addSlotToContainer(new SlotStorageTank(tentity, 2, 101, 52)); + addSlotToContainer(new SlotDischarge(tentity, 3, 143, 35)); - for(slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); - } - } + int slotY; - for(slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); - } + for (slotY = 0; slotY < 3; slotY++) { + for (int slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot( + inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18 + )); + } + } - tileEntity.openInventory(); - tileEntity.open(inventory.player); - } + for (slotY = 0; slotY < 9; slotY++) { + addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + tileEntity.openInventory(); + tileEntity.open(inventory.player); + } - tileEntity.closeInventory(); - tileEntity.close(entityplayer); - } + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } + tileEntity.closeInventory(); + tileEntity.close(entityplayer); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3) - { - if(isCorrectFluid(slotStack)) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else if(slotStack.getItem() instanceof IGasItem) - { - if(((IGasItem)slotStack.getItem()).getGas(slotStack) != null) - { - if(((IGasItem)slotStack.getItem()).getGas(slotStack).getGas() == GasRegistry.getGas("hydrogen")) - { - if(!mergeItemStack(slotStack, 1, 2, false)) - { - return null; - } - } + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); + + if (slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3) { + if (isCorrectFluid(slotStack)) { + if (!mergeItemStack(slotStack, 0, 1, false)) { + return null; + } + } else if (slotStack.getItem() instanceof IGasItem) { + if (((IGasItem) slotStack.getItem()).getGas(slotStack) != null) { + if (((IGasItem) slotStack.getItem()).getGas(slotStack).getGas() + == GasRegistry.getGas("hydrogen")) { + if (!mergeItemStack(slotStack, 1, 2, false)) { + return null; + } + } else if(((IGasItem)slotStack.getItem()).getGas(slotStack).getGas() == GasRegistry.getGas("oxygen")) { - if(!mergeItemStack(slotStack, 2, 3, false)) - { - return null; - } - } - } - else if(((IGasItem)slotStack.getItem()).getGas(slotStack) == null) - { - if(!mergeItemStack(slotStack, 1, 2, false)) - { - if(!mergeItemStack(slotStack, 2, 3, false)) - { - return null; - } - } - } - } - else if(ChargeUtils.canBeDischarged(slotStack)) - { - if(!mergeItemStack(slotStack, 3, 4, false)) - { - return null; - } - } - else { - if(slotID >= 4 && slotID <= 30) - { - if(!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 30) - { - if(!mergeItemStack(slotStack, 4, 30, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - } - } - else { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } + if (!mergeItemStack(slotStack, 2, 3, false)) { + return null; + } + } + } else if (((IGasItem) slotStack.getItem()).getGas(slotStack) == null) { + if (!mergeItemStack(slotStack, 1, 2, false)) { + if (!mergeItemStack(slotStack, 2, 3, false)) { + return null; + } + } + } + } else if (ChargeUtils.canBeDischarged(slotStack)) { + if (!mergeItemStack(slotStack, 3, 4, false)) { + return null; + } + } else { + if (slotID >= 4 && slotID <= 30) { + if (!mergeItemStack( + slotStack, 31, inventorySlots.size(), false + )) { + return null; + } + } else if (slotID > 30) { + if (!mergeItemStack(slotStack, 4, 30, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { + return null; + } + } + } + } else { + if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { + return null; + } + } - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - currentSlot.onPickupFromSlot(player, slotStack); - } + currentSlot.onPickupFromSlot(player, slotStack); + } - return stack; - } + return stack; + } - public boolean isCorrectFluid(ItemStack itemStack) - { - return RecipeHandler.Recipe.ELECTROLYTIC_SEPARATOR.containsRecipe(itemStack); - } + public boolean isCorrectFluid(ItemStack itemStack) { + return RecipeHandler.Recipe.ELECTROLYTIC_SEPARATOR.containsRecipe(itemStack); + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerEnergyCube.java b/src/main/java/mekanism/common/inventory/container/ContainerEnergyCube.java index fe03c6ad3..21c324c6e 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerEnergyCube.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerEnergyCube.java @@ -13,176 +13,137 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerEnergyCube extends Container -{ - private TileEntityEnergyCube tileEntity; +public class ContainerEnergyCube extends Container { + private TileEntityEnergyCube tileEntity; - public ContainerEnergyCube(InventoryPlayer inventory, TileEntityEnergyCube unit) - { - tileEntity = unit; - - addSlotToContainer(new SlotCharge(unit, 0, 143, 35)); - addSlotToContainer(new SlotDischarge(unit, 1, 17, 35)); + public ContainerEnergyCube(InventoryPlayer inventory, TileEntityEnergyCube unit) { + tileEntity = unit; - int slotY; + addSlotToContainer(new SlotCharge(unit, 0, 143, 35)); + addSlotToContainer(new SlotDischarge(unit, 1, 17, 35)); - for(slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); - } - } + int slotY; - for(slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); - } + for (slotY = 0; slotY < 3; slotY++) { + for (int slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot( + inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18 + )); + } + } - tileEntity.open(inventory.player); - tileEntity.openInventory(); - } + for (slotY = 0; slotY < 9; slotY++) { + addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + tileEntity.open(inventory.player); + tileEntity.openInventory(); + } - tileEntity.close(entityplayer); - tileEntity.closeInventory(); - } + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } + tileEntity.close(entityplayer); + tileEntity.closeInventory(); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(ChargeUtils.canBeCharged(slotStack) || ChargeUtils.canBeDischarged(slotStack)) - { - if(slotStack.getItem() == Items.redstone) - { - if(slotID != 1) - { - if(!mergeItemStack(slotStack, 1, 2, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID != 1 && slotID != 0) - { - if(ChargeUtils.canBeDischarged(slotStack)) - { - if(!mergeItemStack(slotStack, 1, 2, false)) - { - if(canTransfer(slotStack)) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - } - } - else if(canTransfer(slotStack)) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - } - else if(slotID == 1) - { - if(canTransfer(slotStack)) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(slotID == 0) - { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } - } - else { - if(slotID >= 2 && slotID <= 28) - { - if(!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 28) - { - if(!mergeItemStack(slotStack, 2, 28, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (ChargeUtils.canBeCharged(slotStack) + || ChargeUtils.canBeDischarged(slotStack)) { + if (slotStack.getItem() == Items.redstone) { + if (slotID != 1) { + if (!mergeItemStack(slotStack, 1, 2, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) { + return null; + } + } + } else { + if (slotID != 1 && slotID != 0) { + if (ChargeUtils.canBeDischarged(slotStack)) { + if (!mergeItemStack(slotStack, 1, 2, false)) { + if (canTransfer(slotStack)) { + if (!mergeItemStack(slotStack, 0, 1, false)) { + return null; + } + } + } + } else if (canTransfer(slotStack)) { + if (!mergeItemStack(slotStack, 0, 1, false)) { + return null; + } + } + } else if (slotID == 1) { + if (canTransfer(slotStack)) { + if (!mergeItemStack(slotStack, 0, 1, false)) { + if (!mergeItemStack( + slotStack, 2, inventorySlots.size(), true + )) { + return null; + } + } + } else { + if (!mergeItemStack( + slotStack, 2, inventorySlots.size(), true + )) { + return null; + } + } + } else if (slotID == 0) { + if (!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) { + return null; + } + } + } + } else { + if (slotID >= 2 && slotID <= 28) { + if (!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) { + return null; + } + } else if (slotID > 28) { + if (!mergeItemStack(slotStack, 2, 28, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) { + return null; + } + } + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - currentSlot.onPickupFromSlot(player, slotStack); - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - return stack; - } + currentSlot.onPickupFromSlot(player, slotStack); + } - private boolean canTransfer(ItemStack slotStack) - { - return MekanismUtils.useIC2() && slotStack.getItem() instanceof IElectricItem; - } + return stack; + } + + private boolean canTransfer(ItemStack slotStack) { + return MekanismUtils.useIC2() && slotStack.getItem() instanceof IElectricItem; + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerFactory.java b/src/main/java/mekanism/common/inventory/container/ContainerFactory.java index 03643cb52..35bd456d5 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerFactory.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerFactory.java @@ -15,263 +15,245 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerFactory extends Container -{ - private TileEntityFactory tileEntity; +public class ContainerFactory extends Container { + private TileEntityFactory tileEntity; - public ContainerFactory(InventoryPlayer inventory, TileEntityFactory tentity) - { - tileEntity = tentity; + public ContainerFactory(InventoryPlayer inventory, TileEntityFactory tentity) { + tileEntity = tentity; - addSlotToContainer(new SlotDischarge(tentity, 1, 7, 13)); - addSlotToContainer(new Slot(tentity, 2, 180, 75)); - addSlotToContainer(new Slot(tentity, 3, 180, 112)); - addSlotToContainer(new Slot(tentity, 4, 7, 57)); + addSlotToContainer(new SlotDischarge(tentity, 1, 7, 13)); + addSlotToContainer(new Slot(tentity, 2, 180, 75)); + addSlotToContainer(new Slot(tentity, 3, 180, 112)); + addSlotToContainer(new Slot(tentity, 4, 7, 57)); - if(tileEntity.tier == FactoryTier.BASIC) - { - for(int i = 0; i < tileEntity.tier.processes; i++) - { - int xAxis = 55 + (i*38); + if (tileEntity.tier == FactoryTier.BASIC) { + for (int i = 0; i < tileEntity.tier.processes; i++) { + int xAxis = 55 + (i * 38); - addSlotToContainer(new Slot(tentity, 5+i, xAxis, 13)); - } + addSlotToContainer(new Slot(tentity, 5 + i, xAxis, 13)); + } - for(int i = 0; i < tileEntity.tier.processes; i++) - { - int xAxis = 55 + (i*38); + for (int i = 0; i < tileEntity.tier.processes; i++) { + int xAxis = 55 + (i * 38); - addSlotToContainer(new SlotOutput(tentity, tileEntity.tier.processes+5+i, xAxis, 57)); - } - } - else if(tileEntity.tier == FactoryTier.ADVANCED) - { - for(int i = 0; i < tileEntity.tier.processes; i++) - { - int xAxis = 35 + (i*26); + addSlotToContainer( + new SlotOutput(tentity, tileEntity.tier.processes + 5 + i, xAxis, 57) + ); + } + } else if (tileEntity.tier == FactoryTier.ADVANCED) { + for (int i = 0; i < tileEntity.tier.processes; i++) { + int xAxis = 35 + (i * 26); - addSlotToContainer(new Slot(tentity, 5+i, xAxis, 13)); - } + addSlotToContainer(new Slot(tentity, 5 + i, xAxis, 13)); + } - for(int i = 0; i < tileEntity.tier.processes; i++) - { - int xAxis = 35 + (i*26); + for (int i = 0; i < tileEntity.tier.processes; i++) { + int xAxis = 35 + (i * 26); - addSlotToContainer(new SlotOutput(tentity, tileEntity.tier.processes+5+i, xAxis, 57)); - } - } - else if(tileEntity.tier == FactoryTier.ELITE) - { - for(int i = 0; i < tileEntity.tier.processes; i++) - { - int xAxis = 29 + (i*19); + addSlotToContainer( + new SlotOutput(tentity, tileEntity.tier.processes + 5 + i, xAxis, 57) + ); + } + } else if (tileEntity.tier == FactoryTier.ELITE) { + for (int i = 0; i < tileEntity.tier.processes; i++) { + int xAxis = 29 + (i * 19); - addSlotToContainer(new Slot(tentity, 5+i, xAxis, 13)); - } + addSlotToContainer(new Slot(tentity, 5 + i, xAxis, 13)); + } - for(int i = 0; i < tileEntity.tier.processes; i++) - { - int xAxis = 29 + (i*19); + for (int i = 0; i < tileEntity.tier.processes; i++) { + int xAxis = 29 + (i * 19); - addSlotToContainer(new SlotOutput(tentity, tileEntity.tier.processes+5+i, xAxis, 57)); - } - } + addSlotToContainer( + new SlotOutput(tentity, tileEntity.tier.processes + 5 + i, xAxis, 57) + ); + } + } - int slotY; + int slotY; - for(slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 95 + slotY * 18)); - } - } + for (slotY = 0; slotY < 3; slotY++) { + for (int slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot( + inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 95 + slotY * 18 + )); + } + } - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 153)); - } + for (int slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 153)); + } - tileEntity.open(inventory.player); - tileEntity.openInventory(); - } + tileEntity.open(inventory.player); + tileEntity.openInventory(); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - tileEntity.close(entityplayer); - tileEntity.closeInventory(); - } + tileEntity.close(entityplayer); + tileEntity.closeInventory(); + } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); - - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(isOutputSlot(slotID)) - { - if(!mergeItemStack(slotStack, tileEntity.inventory.length-1, inventorySlots.size(), true)) - { - return null; - } - } + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); + + if (isOutputSlot(slotID)) { + if (!mergeItemStack( + slotStack, + tileEntity.inventory.length - 1, + inventorySlots.size(), + true + )) { + return null; + } + } else if(slotID != 1 && slotID != 2 && isProperMachine(slotStack) && !slotStack.isItemEqual(tileEntity.getMachineStack())) { - if(!mergeItemStack(slotStack, 1, 2, false)) - { - return null; - } - } - else if(slotID == 2) - { - if(!mergeItemStack(slotStack, tileEntity.inventory.length-1, inventorySlots.size(), true)) - { - return null; - } - } + if (!mergeItemStack(slotStack, 1, 2, false)) { + return null; + } + } else if (slotID == 2) { + if (!mergeItemStack( + slotStack, + tileEntity.inventory.length - 1, + inventorySlots.size(), + true + )) { + return null; + } + } else if(tileEntity.recipeType.getAnyRecipe(slotStack, tileEntity.gasTank.getGasType(), tileEntity.infuseStored) != null) { - if(!isInputSlot(slotID)) - { - if(!mergeItemStack(slotStack, 4, 4+tileEntity.tier.processes, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, tileEntity.inventory.length-1, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(ChargeUtils.canBeDischarged(slotStack)) - { - if(slotID != 0) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else if(slotID == 0) - { - if(!mergeItemStack(slotStack, tileEntity.inventory.length-1, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(tileEntity.recipeType.getItemGas(slotStack) != null) - { - if(slotID >= tileEntity.inventory.length-1) - { - if(!mergeItemStack(slotStack, 3, 4, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, tileEntity.inventory.length-1, inventorySlots.size(), true)) - { - return null; - } - } - } + if (!isInputSlot(slotID)) { + if (!mergeItemStack( + slotStack, 4, 4 + tileEntity.tier.processes, false + )) { + return null; + } + } else { + if (!mergeItemStack( + slotStack, + tileEntity.inventory.length - 1, + inventorySlots.size(), + true + )) { + return null; + } + } + } else if (ChargeUtils.canBeDischarged(slotStack)) { + if (slotID != 0) { + if (!mergeItemStack(slotStack, 0, 1, false)) { + return null; + } + } else if (slotID == 0) { + if (!mergeItemStack( + slotStack, + tileEntity.inventory.length - 1, + inventorySlots.size(), + true + )) { + return null; + } + } + } else if (tileEntity.recipeType.getItemGas(slotStack) != null) { + if (slotID >= tileEntity.inventory.length - 1) { + if (!mergeItemStack(slotStack, 3, 4, false)) { + return null; + } + } else { + if (!mergeItemStack( + slotStack, + tileEntity.inventory.length - 1, + inventorySlots.size(), + true + )) { + return null; + } + } + } else if(tileEntity.recipeType == RecipeType.INFUSING && InfuseRegistry.getObject(slotStack) != null && (tileEntity.infuseStored.type == null || tileEntity.infuseStored.type == InfuseRegistry.getObject(slotStack).type)) { - if(slotID >= tileEntity.inventory.length-1) - { - if(!mergeItemStack(slotStack, 3, 4, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, tileEntity.inventory.length-1, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - int slotEnd = tileEntity.inventory.length-1; + if (slotID >= tileEntity.inventory.length - 1) { + if (!mergeItemStack(slotStack, 3, 4, false)) { + return null; + } + } else { + if (!mergeItemStack( + slotStack, + tileEntity.inventory.length - 1, + inventorySlots.size(), + true + )) { + return null; + } + } + } else { + int slotEnd = tileEntity.inventory.length - 1; - if(slotID >= slotEnd && slotID <= (slotEnd+26)) - { - if(!mergeItemStack(slotStack, (slotEnd+27), inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > (slotEnd+26)) - { - if(!mergeItemStack(slotStack, slotEnd, (slotEnd+26), false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, slotEnd, inventorySlots.size(), true)) - { - return null; - } - } - } + if (slotID >= slotEnd && slotID <= (slotEnd + 26)) { + if (!mergeItemStack( + slotStack, (slotEnd + 27), inventorySlots.size(), false + )) { + return null; + } + } else if (slotID > (slotEnd + 26)) { + if (!mergeItemStack(slotStack, slotEnd, (slotEnd + 26), false)) { + return null; + } + } else { + if (!mergeItemStack( + slotStack, slotEnd, inventorySlots.size(), true + )) { + return null; + } + } + } - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - currentSlot.onPickupFromSlot(player, slotStack); - } + currentSlot.onPickupFromSlot(player, slotStack); + } - return stack; - } + return stack; + } - public boolean isProperMachine(ItemStack itemStack) - { - if(itemStack != null && itemStack.getItem() instanceof ItemBlockMachine) - { - for(RecipeType type : RecipeType.values()) - { - return itemStack.isItemEqual(type.getStack()); - } - } + public boolean isProperMachine(ItemStack itemStack) { + if (itemStack != null && itemStack.getItem() instanceof ItemBlockMachine) { + for (RecipeType type : RecipeType.values()) { + return itemStack.isItemEqual(type.getStack()); + } + } - return false; - } + return false; + } - public boolean isInputSlot(int slot) - { - return slot >= 4 && slot < 4+tileEntity.tier.processes; - } + public boolean isInputSlot(int slot) { + return slot >= 4 && slot < 4 + tileEntity.tier.processes; + } - public boolean isOutputSlot(int slot) - { - return slot >= 4+tileEntity.tier.processes && slot < 4+tileEntity.tier.processes*2; - } + public boolean isOutputSlot(int slot) { + return slot >= 4 + tileEntity.tier.processes + && slot < 4 + tileEntity.tier.processes * 2; + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerFilter.java b/src/main/java/mekanism/common/inventory/container/ContainerFilter.java index aad856607..92613d62f 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerFilter.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerFilter.java @@ -7,96 +7,79 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerFilter extends Container -{ - private TileEntityContainerBlock tileEntity; +public class ContainerFilter extends Container { + private TileEntityContainerBlock tileEntity; - public ContainerFilter(InventoryPlayer inventory, TileEntityContainerBlock tile) - { - tileEntity = tile; + public ContainerFilter(InventoryPlayer inventory, TileEntityContainerBlock tile) { + tileEntity = tile; - int slotY; + int slotY; - for(slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); - } - } + for (slotY = 0; slotY < 3; slotY++) { + for (int slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot( + inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18 + )); + } + } - for(slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); - } + for (slotY = 0; slotY < 9; slotY++) { + addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); + } - tileEntity.open(inventory.player); - tileEntity.openInventory(); - } + tileEntity.open(inventory.player); + tileEntity.openInventory(); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - tileEntity.close(entityplayer); - tileEntity.closeInventory(); - } + tileEntity.close(entityplayer); + tileEntity.closeInventory(); + } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(slotID >= 0 && slotID <= 26) - { - if(!mergeItemStack(slotStack, 27, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 26) - { - if(!mergeItemStack(slotStack, 0, 26, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 0, inventorySlots.size(), true)) - { - return null; - } - } + if (slotID >= 0 && slotID <= 26) { + if (!mergeItemStack(slotStack, 27, inventorySlots.size(), false)) { + return null; + } + } else if (slotID > 26) { + if (!mergeItemStack(slotStack, 0, 26, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 0, inventorySlots.size(), true)) { + return null; + } + } - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - currentSlot.onPickupFromSlot(player, slotStack); - } + currentSlot.onPickupFromSlot(player, slotStack); + } - return stack; - } + return stack; + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerFluidTank.java b/src/main/java/mekanism/common/inventory/container/ContainerFluidTank.java index e1bcb12fd..cf7eb470f 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerFluidTank.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerFluidTank.java @@ -9,123 +9,108 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidContainerRegistry; -public class ContainerFluidTank extends Container -{ - private TileEntityFluidTank tileEntity; +public class ContainerFluidTank extends Container { + private TileEntityFluidTank tileEntity; - public ContainerFluidTank(InventoryPlayer inventory, TileEntityFluidTank tentity) - { - tileEntity = tentity; - addSlotToContainer(new Slot(tentity, 0, 146, 19)); - addSlotToContainer(new SlotOutput(tentity, 1, 146, 51)); - - int slotY; + public ContainerFluidTank(InventoryPlayer inventory, TileEntityFluidTank tentity) { + tileEntity = tentity; + addSlotToContainer(new Slot(tentity, 0, 146, 19)); + addSlotToContainer(new SlotOutput(tentity, 1, 146, 51)); - for(slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); - } - } + int slotY; - for(slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); - } + for (slotY = 0; slotY < 3; slotY++) { + for (int slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot( + inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18 + )); + } + } - tileEntity.open(inventory.player); - tileEntity.openInventory(); - } + for (slotY = 0; slotY < 9; slotY++) { + addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + tileEntity.open(inventory.player); + tileEntity.openInventory(); + } - tileEntity.close(entityplayer); - tileEntity.closeInventory(); - } + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + tileEntity.close(entityplayer); + tileEntity.closeInventory(); + } - if(currentSlot != null && currentSlot.getHasStack()) - { + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - int inputSlot = 0; - int outputSlot = 1; - int firstGenericInvSlot = 2; - int firstHotbarSlot = 29; - int lastHotbarSlot = 38; + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + if (currentSlot != null && currentSlot.getHasStack()) { + int inputSlot = 0; + int outputSlot = 1; + int firstGenericInvSlot = 2; + int firstHotbarSlot = 29; + int lastHotbarSlot = 38; - if(FluidContainerRegistry.isEmptyContainer(slotStack) || FluidContainerRegistry.isFilledContainer(slotStack)) - { - if (slotID != inputSlot && slotID != outputSlot) - { - if(!mergeItemStack(slotStack, inputSlot, outputSlot, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, firstGenericInvSlot, lastHotbarSlot, true)) - { - return null; - } - } - } - else { - if(slotID >= firstGenericInvSlot && slotID < firstHotbarSlot) - { - if(!mergeItemStack(slotStack, firstHotbarSlot, lastHotbarSlot, false)) - { - return null; - } - } - else if(slotID >= firstHotbarSlot && slotID <= lastHotbarSlot) - { - if(!mergeItemStack(slotStack, firstGenericInvSlot, firstHotbarSlot, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, firstGenericInvSlot, lastHotbarSlot, true)) - { - return null; - } - } - } + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (FluidContainerRegistry.isEmptyContainer(slotStack) + || FluidContainerRegistry.isFilledContainer(slotStack)) { + if (slotID != inputSlot && slotID != outputSlot) { + if (!mergeItemStack(slotStack, inputSlot, outputSlot, false)) { + return null; + } + } else { + if (!mergeItemStack( + slotStack, firstGenericInvSlot, lastHotbarSlot, true + )) { + return null; + } + } + } else { + if (slotID >= firstGenericInvSlot && slotID < firstHotbarSlot) { + if (!mergeItemStack( + slotStack, firstHotbarSlot, lastHotbarSlot, false + )) { + return null; + } + } else if (slotID >= firstHotbarSlot && slotID <= lastHotbarSlot) { + if (!mergeItemStack( + slotStack, firstGenericInvSlot, firstHotbarSlot, false + )) { + return null; + } + } else { + if (!mergeItemStack( + slotStack, firstGenericInvSlot, lastHotbarSlot, true + )) { + return null; + } + } + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - currentSlot.onPickupFromSlot(player, slotStack); - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - return stack; - } + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerFluidicPlenisher.java b/src/main/java/mekanism/common/inventory/container/ContainerFluidicPlenisher.java index 3f1fc8452..e74f4f4fe 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerFluidicPlenisher.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerFluidicPlenisher.java @@ -11,141 +11,110 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidContainerRegistry; -public class ContainerFluidicPlenisher extends Container -{ - private TileEntityFluidicPlenisher tileEntity; +public class ContainerFluidicPlenisher extends Container { + private TileEntityFluidicPlenisher tileEntity; - public ContainerFluidicPlenisher(InventoryPlayer inventory, TileEntityFluidicPlenisher tentity) - { - tileEntity = tentity; - addSlotToContainer(new Slot(tentity, 0, 28, 20)); - addSlotToContainer(new SlotOutput(tentity, 1, 28, 51)); - addSlotToContainer(new SlotDischarge(tentity, 2, 143, 35)); - - int slotY; + public ContainerFluidicPlenisher( + InventoryPlayer inventory, TileEntityFluidicPlenisher tentity + ) { + tileEntity = tentity; + addSlotToContainer(new Slot(tentity, 0, 28, 20)); + addSlotToContainer(new SlotOutput(tentity, 1, 28, 51)); + addSlotToContainer(new SlotDischarge(tentity, 2, 143, 35)); - for(slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); - } - } + int slotY; - for(slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); - } + for (slotY = 0; slotY < 3; slotY++) { + for (int slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot( + inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18 + )); + } + } - tileEntity.open(inventory.player); - tileEntity.openInventory(); - } + for (slotY = 0; slotY < 9; slotY++) { + addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + tileEntity.open(inventory.player); + tileEntity.openInventory(); + } - tileEntity.close(entityplayer); - tileEntity.closeInventory(); - } + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } + tileEntity.close(entityplayer); + tileEntity.closeInventory(); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(ChargeUtils.canBeDischarged(slotStack)) - { - if(slotID != 2) - { - if(!mergeItemStack(slotStack, 2, 3, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(FluidContainerRegistry.isFilledContainer(slotStack)) - { - if(slotID != 0) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else if(slotID == 0) - { - if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(slotID == 1) - { - if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) - { - return null; - } - } - else { - if(slotID >= 3 && slotID <= 29) - { - if(!mergeItemStack(slotStack, 30, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 29) - { - if(!mergeItemStack(slotStack, 3, 29, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) - { - return null; - } - } - } + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (ChargeUtils.canBeDischarged(slotStack)) { + if (slotID != 2) { + if (!mergeItemStack(slotStack, 2, 3, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { + return null; + } + } + } else if (FluidContainerRegistry.isFilledContainer(slotStack)) { + if (slotID != 0) { + if (!mergeItemStack(slotStack, 0, 1, false)) { + return null; + } + } else if (slotID == 0) { + if (!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { + return null; + } + } + } else if (slotID == 1) { + if (!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { + return null; + } + } else { + if (slotID >= 3 && slotID <= 29) { + if (!mergeItemStack(slotStack, 30, inventorySlots.size(), false)) { + return null; + } + } else if (slotID > 29) { + if (!mergeItemStack(slotStack, 3, 29, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { + return null; + } + } + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - currentSlot.onPickupFromSlot(player, slotStack); - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - return stack; - } + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerFormulaicAssemblicator.java b/src/main/java/mekanism/common/inventory/container/ContainerFormulaicAssemblicator.java index f9e4c74a0..ab398d25b 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerFormulaicAssemblicator.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerFormulaicAssemblicator.java @@ -1,5 +1,7 @@ package mekanism.common.inventory.container; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.common.inventory.slot.SlotEnergy.SlotDischarge; import mekanism.common.inventory.slot.SlotOutput; import mekanism.common.inventory.slot.SlotSpecific; @@ -11,191 +13,156 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class ContainerFormulaicAssemblicator extends Container -{ - private TileEntityFormulaicAssemblicator tileEntity; +public class ContainerFormulaicAssemblicator extends Container { + private TileEntityFormulaicAssemblicator tileEntity; - public ContainerFormulaicAssemblicator(InventoryPlayer inventory, TileEntityFormulaicAssemblicator tentity) - { - tileEntity = tentity; - addSlotToContainer(new SlotDischarge(tentity, 1, 152, 76)); - addSlotToContainer(new SlotSpecific(tentity, 2, 6, 26, ItemCraftingFormula.class)); - - int slotY; - - for(slotY = 0; slotY < 2; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(tentity, slotX + slotY * 9 + 3, 8 + slotX * 18, 98 + slotY * 18)); - } - } - - for(slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 3; slotX++) - { - addSlotToContainer(new Slot(tentity, slotX + slotY * 3 + 27, 26 + slotX * 18, 17 + slotY * 18) { - @Override - public boolean isItemValid(ItemStack stack) - { - return !tileEntity.autoMode; - } - - @Override - public boolean canTakeStack(EntityPlayer player) - { - return !tileEntity.autoMode; - } - - @SideOnly(Side.CLIENT) - public boolean func_111238_b() - { - return !tileEntity.autoMode; - } - }); - } - } - - for(slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 2; slotX++) - { - addSlotToContainer(new SlotOutput(tentity, slotX + slotY * 2 + 21, 116 + slotX * 18, 17 + slotY * 18)); - } - } + public ContainerFormulaicAssemblicator( + InventoryPlayer inventory, TileEntityFormulaicAssemblicator tentity + ) { + tileEntity = tentity; + addSlotToContainer(new SlotDischarge(tentity, 1, 152, 76)); + addSlotToContainer(new SlotSpecific(tentity, 2, 6, 26, ItemCraftingFormula.class) + ); - for(slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 148 + slotY * 18)); - } - } + int slotY; - for(slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 206)); - } + for (slotY = 0; slotY < 2; slotY++) { + for (int slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot( + tentity, slotX + slotY * 9 + 3, 8 + slotX * 18, 98 + slotY * 18 + )); + } + } - tileEntity.open(inventory.player); - tileEntity.openInventory(); - } + for (slotY = 0; slotY < 3; slotY++) { + for (int slotX = 0; slotX < 3; slotX++) { + addSlotToContainer(new Slot( + tentity, slotX + slotY * 3 + 27, 26 + slotX * 18, 17 + slotY * 18 + ) { + @Override + public boolean isItemValid(ItemStack stack) { + return !tileEntity.autoMode; + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + @Override + public boolean canTakeStack(EntityPlayer player) { + return !tileEntity.autoMode; + } - tileEntity.close(entityplayer); - tileEntity.closeInventory(); - } + @SideOnly(Side.CLIENT) + public boolean func_111238_b() { + return !tileEntity.autoMode; + } + }); + } + } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } + for (slotY = 0; slotY < 3; slotY++) { + for (int slotX = 0; slotX < 2; slotX++) { + addSlotToContainer(new SlotOutput( + tentity, slotX + slotY * 2 + 21, 116 + slotX * 18, 17 + slotY * 18 + )); + } + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + for (slotY = 0; slotY < 3; slotY++) { + for (int slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot( + inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 148 + slotY * 18 + )); + } + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + for (slotY = 0; slotY < 9; slotY++) { + addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 206)); + } - if(ChargeUtils.canBeDischarged(slotStack)) - { - if(slotID != 0) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 34, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(slotStack.getItem() instanceof ItemCraftingFormula) - { - if(slotID != 1) - { - if(!mergeItemStack(slotStack, 1, 2, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 34, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(slotID >= 2 && slotID <= 19) - { - if(!mergeItemStack(slotStack, 34, inventorySlots.size(), true)) - { - return null; - } - } + tileEntity.open(inventory.player); + tileEntity.openInventory(); + } + + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); + + tileEntity.close(entityplayer); + tileEntity.closeInventory(); + } + + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); + + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); + + if (ChargeUtils.canBeDischarged(slotStack)) { + if (slotID != 0) { + if (!mergeItemStack(slotStack, 0, 1, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 34, inventorySlots.size(), true)) { + return null; + } + } + } else if (slotStack.getItem() instanceof ItemCraftingFormula) { + if (slotID != 1) { + if (!mergeItemStack(slotStack, 1, 2, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 34, inventorySlots.size(), true)) { + return null; + } + } + } else if (slotID >= 2 && slotID <= 19) { + if (!mergeItemStack(slotStack, 34, inventorySlots.size(), true)) { + return null; + } + } else if(tileEntity.formula == null || tileEntity.formula.isIngredient(tileEntity.getWorldObj(), slotStack)) { - if(!mergeItemStack(slotStack, 2, 20, false)) - { - return null; - } - } - else { - if(slotID >= 34 && slotID <= 60) - { - if(!mergeItemStack(slotStack, 61, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 60) - { - if(!mergeItemStack(slotStack, 34, 60, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 34, inventorySlots.size(), true)) - { - return null; - } - } - } + if (!mergeItemStack(slotStack, 2, 20, false)) { + return null; + } + } else { + if (slotID >= 34 && slotID <= 60) { + if (!mergeItemStack(slotStack, 61, inventorySlots.size(), false)) { + return null; + } + } else if (slotID > 60) { + if (!mergeItemStack(slotStack, 34, 60, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 34, inventorySlots.size(), true)) { + return null; + } + } + } - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - currentSlot.onPickupFromSlot(player, slotStack); - } + currentSlot.onPickupFromSlot(player, slotStack); + } - return stack; - } + return stack; + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerFuelwoodHeater.java b/src/main/java/mekanism/common/inventory/container/ContainerFuelwoodHeater.java index d22546b70..f8d16fa59 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerFuelwoodHeater.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerFuelwoodHeater.java @@ -8,116 +8,94 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntityFurnace; -public class ContainerFuelwoodHeater extends Container -{ - private TileEntityFuelwoodHeater tileEntity; +public class ContainerFuelwoodHeater extends Container { + private TileEntityFuelwoodHeater tileEntity; - public ContainerFuelwoodHeater(InventoryPlayer inventory, TileEntityFuelwoodHeater tentity) - { - tileEntity = tentity; - addSlotToContainer(new Slot(tentity, 0, 15, 29)); - - int slotY; + public ContainerFuelwoodHeater( + InventoryPlayer inventory, TileEntityFuelwoodHeater tentity + ) { + tileEntity = tentity; + addSlotToContainer(new Slot(tentity, 0, 15, 29)); - for(slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); - } - } + int slotY; - for(slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); - } + for (slotY = 0; slotY < 3; slotY++) { + for (int slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot( + inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18 + )); + } + } - tileEntity.open(inventory.player); - tileEntity.openInventory(); - } + for (slotY = 0; slotY < 9; slotY++) { + addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + tileEntity.open(inventory.player); + tileEntity.openInventory(); + } - tileEntity.close(entityplayer); - tileEntity.closeInventory(); - } + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } + tileEntity.close(entityplayer); + tileEntity.closeInventory(); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(TileEntityFurnace.getItemBurnTime(slotStack) > 0) - { - if(slotID != 0) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else if(slotID == 0) - { - if(!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID >= 1 && slotID <= 27) - { - if(!mergeItemStack(slotStack, 28, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 27) - { - if(!mergeItemStack(slotStack, 1, 27, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) - { - return null; - } - } - } + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (TileEntityFurnace.getItemBurnTime(slotStack) > 0) { + if (slotID != 0) { + if (!mergeItemStack(slotStack, 0, 1, false)) { + return null; + } + } else if (slotID == 0) { + if (!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) { + return null; + } + } + } else { + if (slotID >= 1 && slotID <= 27) { + if (!mergeItemStack(slotStack, 28, inventorySlots.size(), false)) { + return null; + } + } else if (slotID > 27) { + if (!mergeItemStack(slotStack, 1, 27, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) { + return null; + } + } + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - currentSlot.onPickupFromSlot(player, slotStack); - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - return stack; - } + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerGasTank.java b/src/main/java/mekanism/common/inventory/container/ContainerGasTank.java index 7350b823a..5c5122f18 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerGasTank.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerGasTank.java @@ -9,120 +9,95 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerGasTank extends Container -{ - private TileEntityGasTank tileEntity; +public class ContainerGasTank extends Container { + private TileEntityGasTank tileEntity; - public ContainerGasTank(InventoryPlayer inventory, TileEntityGasTank tentity) - { - tileEntity = tentity; - addSlotToContainer(new SlotStorageTank(tentity, 0, 8, 8)); - addSlotToContainer(new SlotStorageTank(tentity, 1, 8, 40)); + public ContainerGasTank(InventoryPlayer inventory, TileEntityGasTank tentity) { + tileEntity = tentity; + addSlotToContainer(new SlotStorageTank(tentity, 0, 8, 8)); + addSlotToContainer(new SlotStorageTank(tentity, 1, 8, 40)); - int slotY; + int slotY; - for(slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); - } - } + for (slotY = 0; slotY < 3; slotY++) { + for (int slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot( + inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18 + )); + } + } - for(slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); - } + for (slotY = 0; slotY < 9; slotY++) { + addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); + } - tileEntity.open(inventory.player); - tileEntity.openInventory(); - } + tileEntity.open(inventory.player); + tileEntity.openInventory(); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - tileEntity.close(entityplayer); - tileEntity.closeInventory(); - } + tileEntity.close(entityplayer); + tileEntity.closeInventory(); + } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(slotStack.getItem() instanceof IGasItem) - { - if(slotID != 0 && slotID != 1) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - if(!mergeItemStack(slotStack, 1, 2, false)) - { - return null; - } - } - } - else - { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID >= 2 && slotID <= 28) - { - if(!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 28) - { - if(!mergeItemStack(slotStack, 2, 28, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } + if (slotStack.getItem() instanceof IGasItem) { + if (slotID != 0 && slotID != 1) { + if (!mergeItemStack(slotStack, 0, 1, false)) { + if (!mergeItemStack(slotStack, 1, 2, false)) { + return null; + } + } + } else { + if (!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) { + return null; + } + } + } else { + if (slotID >= 2 && slotID <= 28) { + if (!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) { + return null; + } + } else if (slotID > 28) { + if (!mergeItemStack(slotStack, 2, 28, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) { + return null; + } + } + } - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - currentSlot.onPickupFromSlot(player, slotStack); - } + currentSlot.onPickupFromSlot(player, slotStack); + } - return stack; - } + return stack; + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerInductionMatrix.java b/src/main/java/mekanism/common/inventory/container/ContainerInductionMatrix.java index 1477cdfce..c9a33460c 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerInductionMatrix.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerInductionMatrix.java @@ -13,175 +13,138 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerInductionMatrix extends Container -{ - private TileEntityInductionCasing tileEntity; +public class ContainerInductionMatrix extends Container { + private TileEntityInductionCasing tileEntity; - public ContainerInductionMatrix(InventoryPlayer inventory, TileEntityInductionCasing tentity) - { - tileEntity = tentity; - addSlotToContainer(new SlotCharge(tentity, 0, 146, 20)); - addSlotToContainer(new SlotDischarge(tentity, 1, 146, 51)); - - int slotY; + public ContainerInductionMatrix( + InventoryPlayer inventory, TileEntityInductionCasing tentity + ) { + tileEntity = tentity; + addSlotToContainer(new SlotCharge(tentity, 0, 146, 20)); + addSlotToContainer(new SlotDischarge(tentity, 1, 146, 51)); - for(slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); - } - } + int slotY; - for(slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); - } + for (slotY = 0; slotY < 3; slotY++) { + for (int slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot( + inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18 + )); + } + } - tileEntity.open(inventory.player); - tileEntity.openInventory(); - } + for (slotY = 0; slotY < 9; slotY++) { + addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + tileEntity.open(inventory.player); + tileEntity.openInventory(); + } - tileEntity.close(entityplayer); - tileEntity.closeInventory(); - } + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } + tileEntity.close(entityplayer); + tileEntity.closeInventory(); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(ChargeUtils.canBeCharged(slotStack) || ChargeUtils.canBeDischarged(slotStack)) - { - if(slotStack.getItem() == Items.redstone) - { - if(slotID != 1) - { - if(!mergeItemStack(slotStack, 1, 2, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID != 1 && slotID != 0) - { - if(ChargeUtils.canBeDischarged(slotStack)) - { - if(!mergeItemStack(slotStack, 1, 2, false)) - { - if(canTransfer(slotStack)) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - } - } - else if(canTransfer(slotStack)) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - } - else if(slotID == 1) - { - if(canTransfer(slotStack)) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(slotID == 0) - { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } - } - else { - if(slotID >= 2 && slotID <= 28) - { - if(!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 28) - { - if(!mergeItemStack(slotStack, 2, 28, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (ChargeUtils.canBeCharged(slotStack) + || ChargeUtils.canBeDischarged(slotStack)) { + if (slotStack.getItem() == Items.redstone) { + if (slotID != 1) { + if (!mergeItemStack(slotStack, 1, 2, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) { + return null; + } + } + } else { + if (slotID != 1 && slotID != 0) { + if (ChargeUtils.canBeDischarged(slotStack)) { + if (!mergeItemStack(slotStack, 1, 2, false)) { + if (canTransfer(slotStack)) { + if (!mergeItemStack(slotStack, 0, 1, false)) { + return null; + } + } + } + } else if (canTransfer(slotStack)) { + if (!mergeItemStack(slotStack, 0, 1, false)) { + return null; + } + } + } else if (slotID == 1) { + if (canTransfer(slotStack)) { + if (!mergeItemStack(slotStack, 0, 1, false)) { + if (!mergeItemStack( + slotStack, 2, inventorySlots.size(), true + )) { + return null; + } + } + } else { + if (!mergeItemStack( + slotStack, 2, inventorySlots.size(), true + )) { + return null; + } + } + } else if (slotID == 0) { + if (!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) { + return null; + } + } + } + } else { + if (slotID >= 2 && slotID <= 28) { + if (!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) { + return null; + } + } else if (slotID > 28) { + if (!mergeItemStack(slotStack, 2, 28, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) { + return null; + } + } + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - currentSlot.onPickupFromSlot(player, slotStack); - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - return stack; - } - - private boolean canTransfer(ItemStack slotStack) - { - return MekanismUtils.useIC2() && slotStack.getItem() instanceof IElectricItem; - } + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } + + private boolean canTransfer(ItemStack slotStack) { + return MekanismUtils.useIC2() && slotStack.getItem() instanceof IElectricItem; + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerLaserAmplifier.java b/src/main/java/mekanism/common/inventory/container/ContainerLaserAmplifier.java index 2c7fdfd3a..e9c874bb9 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerLaserAmplifier.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerLaserAmplifier.java @@ -7,96 +7,81 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerLaserAmplifier extends Container -{ - private TileEntityLaserAmplifier tileEntity; +public class ContainerLaserAmplifier extends Container { + private TileEntityLaserAmplifier tileEntity; - public ContainerLaserAmplifier(InventoryPlayer inventory, TileEntityLaserAmplifier tentity) - { - tileEntity = tentity; - - int slotY; + public ContainerLaserAmplifier( + InventoryPlayer inventory, TileEntityLaserAmplifier tentity + ) { + tileEntity = tentity; - for(slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); - } - } + int slotY; - for(slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); - } + for (slotY = 0; slotY < 3; slotY++) { + for (int slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot( + inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18 + )); + } + } - tileEntity.open(inventory.player); - tileEntity.openInventory(); - } + for (slotY = 0; slotY < 9; slotY++) { + addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + tileEntity.open(inventory.player); + tileEntity.openInventory(); + } - tileEntity.close(entityplayer); - tileEntity.closeInventory(); - } + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + tileEntity.close(entityplayer); + tileEntity.closeInventory(); + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - if(slotID >= 0 && slotID <= 26) - { - if(!mergeItemStack(slotStack, 27, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 26) - { - if(!mergeItemStack(slotStack, 0, 26, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 0, inventorySlots.size(), true)) - { - return null; - } - } + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotID >= 0 && slotID <= 26) { + if (!mergeItemStack(slotStack, 27, inventorySlots.size(), false)) { + return null; + } + } else if (slotID > 26) { + if (!mergeItemStack(slotStack, 0, 26, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 0, inventorySlots.size(), true)) { + return null; + } + } - currentSlot.onPickupFromSlot(player, slotStack); - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - return stack; - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } + + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerLaserTractorBeam.java b/src/main/java/mekanism/common/inventory/container/ContainerLaserTractorBeam.java index ea012cca9..787dc9637 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerLaserTractorBeam.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerLaserTractorBeam.java @@ -7,94 +7,82 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerLaserTractorBeam extends Container -{ - private TileEntityLaserTractorBeam tileEntity; +public class ContainerLaserTractorBeam extends Container { + private TileEntityLaserTractorBeam tileEntity; - public ContainerLaserTractorBeam(InventoryPlayer inventory, TileEntityLaserTractorBeam tentity) - { - tileEntity = tentity; - int slotX; + public ContainerLaserTractorBeam( + InventoryPlayer inventory, TileEntityLaserTractorBeam tentity + ) { + tileEntity = tentity; + int slotX; - for(slotX = 0; slotX < 9; slotX++) - { - for(int slotY = 0; slotY < 3; slotY++) - { - addSlotToContainer(new Slot(tentity, slotX + slotY * 9, 8 + slotX * 18, 16 + slotY * 18)); - } - } + for (slotX = 0; slotX < 9; slotX++) { + for (int slotY = 0; slotY < 3; slotY++) { + addSlotToContainer( + new Slot(tentity, slotX + slotY * 9, 8 + slotX * 18, 16 + slotY * 18) + ); + } + } - for(slotX = 0; slotX < 9; slotX++) - { - for(int slotY = 0; slotY < 3; slotY++) - { - addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); - } - } + for (slotX = 0; slotX < 9; slotX++) { + for (int slotY = 0; slotY < 3; slotY++) { + addSlotToContainer(new Slot( + inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18 + )); + } + } - for(slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); - } + for (slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); + } - tileEntity.open(inventory.player); - tileEntity.openInventory(); - } + tileEntity.open(inventory.player); + tileEntity.openInventory(); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - tileEntity.close(entityplayer); - tileEntity.closeInventory(); - } + tileEntity.close(entityplayer); + tileEntity.closeInventory(); + } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); - - if(slotID < 27) - { - if(!mergeItemStack(slotStack, 27, inventorySlots.size(), true)) - { - return null; - } - } - else if(!mergeItemStack(slotStack, 0, 27, false)) - { - return null; - } + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotID < 27) { + if (!mergeItemStack(slotStack, 27, inventorySlots.size(), true)) { + return null; + } + } else if (!mergeItemStack(slotStack, 0, 27, false)) { + return null; + } - currentSlot.onPickupFromSlot(player, slotStack); - } - - return stack; - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } + + if (slotStack.stackSize == stack.stackSize) { + return null; + } + + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerMetallurgicInfuser.java b/src/main/java/mekanism/common/inventory/container/ContainerMetallurgicInfuser.java index 036d745c9..f9c0f6937 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerMetallurgicInfuser.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerMetallurgicInfuser.java @@ -14,155 +14,130 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerMetallurgicInfuser extends Container -{ - private TileEntityMetallurgicInfuser tileEntity; +public class ContainerMetallurgicInfuser extends Container { + private TileEntityMetallurgicInfuser tileEntity; - public ContainerMetallurgicInfuser(InventoryPlayer inventory, TileEntityMetallurgicInfuser tentity) - { - tileEntity = tentity; - addSlotToContainer(new Slot(tentity, 1, 17, 35)); - addSlotToContainer(new Slot(tentity, 2, 51, 43)); - addSlotToContainer(new SlotOutput(tentity, 3, 109, 43)); + public ContainerMetallurgicInfuser( + InventoryPlayer inventory, TileEntityMetallurgicInfuser tentity + ) { + tileEntity = tentity; + addSlotToContainer(new Slot(tentity, 1, 17, 35)); + addSlotToContainer(new Slot(tentity, 2, 51, 43)); + addSlotToContainer(new SlotOutput(tentity, 3, 109, 43)); addSlotToContainer(new SlotEnergy.SlotDischarge(tentity, 4, 143, 35)); - - int slotY; - for(slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); - } - } + int slotY; - for(slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); - } + for (slotY = 0; slotY < 3; slotY++) { + for (int slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot( + inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18 + )); + } + } - tileEntity.open(inventory.player); - tileEntity.openInventory(); - } + for (slotY = 0; slotY < 9; slotY++) { + addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + tileEntity.open(inventory.player); + tileEntity.openInventory(); + } - tileEntity.close(entityplayer); - tileEntity.closeInventory(); - } + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } + tileEntity.close(entityplayer); + tileEntity.closeInventory(); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3) - { - if(InfuseRegistry.getObject(slotStack) != null && (tileEntity.infuseStored.type == null || tileEntity.infuseStored.type == InfuseRegistry.getObject(slotStack).type)) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else if(ChargeUtils.canBeDischarged(slotStack)) - { - if(!mergeItemStack(slotStack, 3, 4, false)) - { - return null; - } - } - else if(isInputItem(slotStack)) - { - if(!mergeItemStack(slotStack, 1, 2, false)) - { - return null; - } - } - else { - if(slotID >= 4 && slotID <= 30) - { - if(!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 30) - { - if(!mergeItemStack(slotStack, 4, 30, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - } - } - else { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3) { + if (InfuseRegistry.getObject(slotStack) != null + && (tileEntity.infuseStored.type == null + || tileEntity.infuseStored.type + == InfuseRegistry.getObject(slotStack).type)) { + if (!mergeItemStack(slotStack, 0, 1, false)) { + return null; + } + } else if (ChargeUtils.canBeDischarged(slotStack)) { + if (!mergeItemStack(slotStack, 3, 4, false)) { + return null; + } + } else if (isInputItem(slotStack)) { + if (!mergeItemStack(slotStack, 1, 2, false)) { + return null; + } + } else { + if (slotID >= 4 && slotID <= 30) { + if (!mergeItemStack( + slotStack, 31, inventorySlots.size(), false + )) { + return null; + } + } else if (slotID > 30) { + if (!mergeItemStack(slotStack, 4, 30, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { + return null; + } + } + } + } else { + if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { + return null; + } + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - currentSlot.onPickupFromSlot(player, slotStack); - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - return stack; - } + currentSlot.onPickupFromSlot(player, slotStack); + } - public boolean isInputItem(ItemStack itemStack) - { - if(tileEntity.infuseStored.type != null) - { - if(RecipeHandler.getMetallurgicInfuserRecipe(new InfusionInput(tileEntity.infuseStored, itemStack)) != null) - { - return true; - } - } - else { - for(Object obj : Recipe.METALLURGIC_INFUSER.get().keySet()) - { - InfusionInput input = (InfusionInput)obj; - if(input.inputStack.isItemEqual(itemStack)) - { - return true; - } - } - } + return stack; + } - return false; - } + public boolean isInputItem(ItemStack itemStack) { + if (tileEntity.infuseStored.type != null) { + if (RecipeHandler.getMetallurgicInfuserRecipe( + new InfusionInput(tileEntity.infuseStored, itemStack) + ) + != null) { + return true; + } + } else { + for (Object obj : Recipe.METALLURGIC_INFUSER.get().keySet()) { + InfusionInput input = (InfusionInput) obj; + if (input.inputStack.isItemEqual(itemStack)) { + return true; + } + } + } + + return false; + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerNull.java b/src/main/java/mekanism/common/inventory/container/ContainerNull.java index 8ee419179..c3ce90133 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerNull.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerNull.java @@ -4,48 +4,40 @@ import mekanism.common.tile.TileEntityContainerBlock; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; -public class ContainerNull extends Container -{ - private TileEntityContainerBlock tileEntity; +public class ContainerNull extends Container { + private TileEntityContainerBlock tileEntity; - public ContainerNull(EntityPlayer player, TileEntityContainerBlock tile) - { - tileEntity = tile; + public ContainerNull(EntityPlayer player, TileEntityContainerBlock tile) { + tileEntity = tile; - if(tileEntity != null) - { - tileEntity.open(player); - tileEntity.openInventory(); - } - } - - public ContainerNull(TileEntityContainerBlock tile) - { - tileEntity = tile; - } - - public ContainerNull() {} + if (tileEntity != null) { + tileEntity.open(player); + tileEntity.openInventory(); + } + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + public ContainerNull(TileEntityContainerBlock tile) { + tileEntity = tile; + } - if(tileEntity != null) - { - tileEntity.close(entityplayer); - tileEntity.closeInventory(); - } - } + public ContainerNull() {} - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - if(tileEntity != null) - { - return tileEntity.isUseableByPlayer(entityplayer); - } - - return true; - } + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); + + if (tileEntity != null) { + tileEntity.close(entityplayer); + tileEntity.closeInventory(); + } + } + + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + if (tileEntity != null) { + return tileEntity.isUseableByPlayer(entityplayer); + } + + return true; + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerOredictionificator.java b/src/main/java/mekanism/common/inventory/container/ContainerOredictionificator.java index 16f359877..eb67f69a0 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerOredictionificator.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerOredictionificator.java @@ -8,123 +8,99 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerOredictionificator extends Container -{ - private TileEntityOredictionificator tileEntity; +public class ContainerOredictionificator extends Container { + private TileEntityOredictionificator tileEntity; - public ContainerOredictionificator(InventoryPlayer inventory, TileEntityOredictionificator tentity) - { - tileEntity = tentity; - addSlotToContainer(new Slot(tentity, 0, 26, 115)); - addSlotToContainer(new SlotOutput(tentity, 1, 134, 115)); - - int slotX; + public ContainerOredictionificator( + InventoryPlayer inventory, TileEntityOredictionificator tentity + ) { + tileEntity = tentity; + addSlotToContainer(new Slot(tentity, 0, 26, 115)); + addSlotToContainer(new SlotOutput(tentity, 1, 134, 115)); - for(slotX = 0; slotX < 3; slotX++) - { - for(int slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 148 + slotX * 18)); - } - } + int slotX; - for(slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 206)); - } - - tileEntity.open(inventory.player); - tileEntity.openInventory(); - } - - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + for (slotX = 0; slotX < 3; slotX++) { + for (int slotY = 0; slotY < 9; slotY++) { + addSlotToContainer(new Slot( + inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 148 + slotX * 18 + )); + } + } - tileEntity.close(entityplayer); - tileEntity.closeInventory(); - } + for (slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 206)); + } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } - - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + tileEntity.open(inventory.player); + tileEntity.openInventory(); + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - if(slotID == 1) - { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - else if(tileEntity.getResult(slotStack) != null) - { - if(slotID != 0 && slotID != 1) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID >= 2 && slotID <= 28) - { - if(!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 28) - { - if(!mergeItemStack(slotStack, 2, 28, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } + tileEntity.close(entityplayer); + tileEntity.closeInventory(); + } - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - currentSlot.onPickupFromSlot(player, slotStack); - } + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - return stack; - } + if (slotID == 1) { + if (!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) { + return null; + } + } else if (tileEntity.getResult(slotStack) != null) { + if (slotID != 0 && slotID != 1) { + if (!mergeItemStack(slotStack, 0, 1, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) { + return null; + } + } + } else { + if (slotID >= 2 && slotID <= 28) { + if (!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) { + return null; + } + } else if (slotID > 28) { + if (!mergeItemStack(slotStack, 2, 28, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) { + return null; + } + } + } + + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } + + if (slotStack.stackSize == stack.stackSize) { + return null; + } + + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerPRC.java b/src/main/java/mekanism/common/inventory/container/ContainerPRC.java index 1a85acf7d..1201833e0 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerPRC.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerPRC.java @@ -11,141 +11,108 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerPRC extends Container -{ - private TileEntityPRC tileEntity; +public class ContainerPRC extends Container { + private TileEntityPRC tileEntity; - public ContainerPRC(InventoryPlayer inventory, TileEntityPRC tentity) - { - tileEntity = tentity; - addSlotToContainer(new Slot(tentity, 0, 54, 35)); - addSlotToContainer(new SlotDischarge(tentity, 1, 141, 19)); - addSlotToContainer(new SlotOutput(tentity, 2, 116, 35)); - - int slotY; + public ContainerPRC(InventoryPlayer inventory, TileEntityPRC tentity) { + tileEntity = tentity; + addSlotToContainer(new Slot(tentity, 0, 54, 35)); + addSlotToContainer(new SlotDischarge(tentity, 1, 141, 19)); + addSlotToContainer(new SlotOutput(tentity, 2, 116, 35)); - for(slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); - } - } + int slotY; - for(slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); - } + for (slotY = 0; slotY < 3; slotY++) { + for (int slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot( + inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18 + )); + } + } - tileEntity.open(inventory.player); - tileEntity.openInventory(); - } + for (slotY = 0; slotY < 9; slotY++) { + addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + tileEntity.open(inventory.player); + tileEntity.openInventory(); + } - tileEntity.close(entityplayer); - tileEntity.closeInventory(); - } + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } + tileEntity.close(entityplayer); + tileEntity.closeInventory(); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(slotID == 2) - { - if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) - { - return null; - } - } - else if(ChargeUtils.canBeDischarged(slotStack)) - { - if(slotID != 1) - { - if(!mergeItemStack(slotStack, 1, 2, false)) - { - return null; - } - } - else if(slotID == 1) - { - if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(RecipeHandler.isInPressurizedRecipe(slotStack)) - { - if(slotID != 0) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID >= 3 && slotID <= 29) - { - if(!mergeItemStack(slotStack, 30, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 29) - { - if(!mergeItemStack(slotStack, 3, 29, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) - { - return null; - } - } - } + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (slotID == 2) { + if (!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { + return null; + } + } else if (ChargeUtils.canBeDischarged(slotStack)) { + if (slotID != 1) { + if (!mergeItemStack(slotStack, 1, 2, false)) { + return null; + } + } else if (slotID == 1) { + if (!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { + return null; + } + } + } else if (RecipeHandler.isInPressurizedRecipe(slotStack)) { + if (slotID != 0) { + if (!mergeItemStack(slotStack, 0, 1, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { + return null; + } + } + } else { + if (slotID >= 3 && slotID <= 29) { + if (!mergeItemStack(slotStack, 30, inventorySlots.size(), false)) { + return null; + } + } else if (slotID > 29) { + if (!mergeItemStack(slotStack, 3, 29, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 3, inventorySlots.size(), true)) { + return null; + } + } + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - currentSlot.onPickupFromSlot(player, slotStack); - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - return stack; - } + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerPersonalChest.java b/src/main/java/mekanism/common/inventory/container/ContainerPersonalChest.java index 6bf6161d6..4983c887a 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerPersonalChest.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerPersonalChest.java @@ -11,144 +11,127 @@ import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -@ChestContainer(isLargeChest=true) -public class ContainerPersonalChest extends Container -{ - private TileEntityPersonalChest tileEntity; - private IInventory itemInventory; - private boolean isBlock; +@ChestContainer(isLargeChest = true) +public class ContainerPersonalChest extends Container { + private TileEntityPersonalChest tileEntity; + private IInventory itemInventory; + private boolean isBlock; - public ContainerPersonalChest(InventoryPlayer inventory, TileEntityPersonalChest tentity, IInventory inv, boolean b) - { - tileEntity = tentity; - itemInventory = inv; - isBlock = b; + public ContainerPersonalChest( + InventoryPlayer inventory, + TileEntityPersonalChest tentity, + IInventory inv, + boolean b + ) { + tileEntity = tentity; + itemInventory = inv; + isBlock = b; - if(isBlock) - { - tileEntity.open(inventory.player); - tileEntity.openInventory(); - } - else { - itemInventory.openInventory(); - } + if (isBlock) { + tileEntity.open(inventory.player); + tileEntity.openInventory(); + } else { + itemInventory.openInventory(); + } - for(int slotY = 0; slotY < 6; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new SlotPersonalChest(getInv(), slotX + slotY * 9, 8 + slotX * 18, 26 + slotY * 18)); - } - } + for (int slotY = 0; slotY < 6; slotY++) { + for (int slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new SlotPersonalChest( + getInv(), slotX + slotY * 9, 8 + slotX * 18, 26 + slotY * 18 + )); + } + } - int slotX; + int slotX; - for(slotX = 0; slotX < 3; ++slotX) - { - for(int slotY = 0; slotY < 9; ++slotY) - { - addSlotToContainer(new SlotPersonalChest(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 148 + slotX * 18)); - } - } + for (slotX = 0; slotX < 3; ++slotX) { + for (int slotY = 0; slotY < 9; ++slotY) { + addSlotToContainer(new SlotPersonalChest( + inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 148 + slotX * 18 + )); + } + } - for(slotX = 0; slotX < 9; ++slotX) - { - addSlotToContainer(new SlotPersonalChest(inventory, slotX, 8 + slotX * 18, 206)); - } - } + for (slotX = 0; slotX < 9; ++slotX) { + addSlotToContainer( + new SlotPersonalChest(inventory, slotX, 8 + slotX * 18, 206) + ); + } + } - public IInventory getInv() - { - if(isBlock) - { - return tileEntity; - } - else { - return itemInventory; - } - } + public IInventory getInv() { + if (isBlock) { + return tileEntity; + } else { + return itemInventory; + } + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - if(isBlock) - { - tileEntity.close(entityplayer); - tileEntity.closeInventory(); - } - else { - itemInventory.closeInventory(); - } - } + if (isBlock) { + tileEntity.close(entityplayer); + tileEntity.closeInventory(); + } else { + itemInventory.closeInventory(); + } + } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - if(isBlock) - { - return tileEntity.isUseableByPlayer(entityplayer); - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + if (isBlock) { + return tileEntity.isUseableByPlayer(entityplayer); + } - return true; - } + return true; + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(slotID < 54) - { - if(!mergeItemStack(slotStack, 54, inventorySlots.size(), true)) - { - return null; - } - } - else if(!mergeItemStack(slotStack, 0, 54, false)) - { - return null; - } + if (slotID < 54) { + if (!mergeItemStack(slotStack, 54, inventorySlots.size(), true)) { + return null; + } + } else if (!mergeItemStack(slotStack, 0, 54, false)) { + return null; + } - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - currentSlot.onPickupFromSlot(player, slotStack); - } + currentSlot.onPickupFromSlot(player, slotStack); + } - return stack; - } + return stack; + } - @Override - public ItemStack slotClick(int slotNumber, int destSlot, int modifier, EntityPlayer player) - { - if(modifier == 2 && destSlot >= 0 && destSlot < 9) - { - ItemStack itemStack = player.inventory.getStackInSlot(destSlot); - - if(MachineType.get(itemStack) == MachineType.PERSONAL_CHEST) - { - return null; - } - } + @Override + public ItemStack + slotClick(int slotNumber, int destSlot, int modifier, EntityPlayer player) { + if (modifier == 2 && destSlot >= 0 && destSlot < 9) { + ItemStack itemStack = player.inventory.getStackInSlot(destSlot); - return super.slotClick(slotNumber, destSlot, modifier, player); - } + if (MachineType.get(itemStack) == MachineType.PERSONAL_CHEST) { + return null; + } + } + + return super.slotClick(slotNumber, destSlot, modifier, player); + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerQuantumEntangloporter.java b/src/main/java/mekanism/common/inventory/container/ContainerQuantumEntangloporter.java index e43016c93..a5ea77ebd 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerQuantumEntangloporter.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerQuantumEntangloporter.java @@ -7,96 +7,81 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerQuantumEntangloporter extends Container -{ - private TileEntityQuantumEntangloporter tileEntity; +public class ContainerQuantumEntangloporter extends Container { + private TileEntityQuantumEntangloporter tileEntity; - public ContainerQuantumEntangloporter(InventoryPlayer inventory, TileEntityQuantumEntangloporter tentity) - { - tileEntity = tentity; - - int slotX; + public ContainerQuantumEntangloporter( + InventoryPlayer inventory, TileEntityQuantumEntangloporter tentity + ) { + tileEntity = tentity; - for(slotX = 0; slotX < 3; slotX++) - { - for(int slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 148 + slotX * 18)); - } - } + int slotX; - for(slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 206)); - } + for (slotX = 0; slotX < 3; slotX++) { + for (int slotY = 0; slotY < 9; slotY++) { + addSlotToContainer(new Slot( + inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 148 + slotX * 18 + )); + } + } - tileEntity.open(inventory.player); - tileEntity.openInventory(); - } + for (slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 206)); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + tileEntity.open(inventory.player); + tileEntity.openInventory(); + } - tileEntity.close(entityplayer); - tileEntity.closeInventory(); - } + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } + tileEntity.close(entityplayer); + tileEntity.closeInventory(); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(slotID >= 0 && slotID <= 26) - { - if(!mergeItemStack(slotStack, 27, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 26) - { - if(!mergeItemStack(slotStack, 0, 26, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 0, inventorySlots.size(), true)) - { - return null; - } - } + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (slotID >= 0 && slotID <= 26) { + if (!mergeItemStack(slotStack, 27, inventorySlots.size(), false)) { + return null; + } + } else if (slotID > 26) { + if (!mergeItemStack(slotStack, 0, 26, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 0, inventorySlots.size(), true)) { + return null; + } + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - currentSlot.onPickupFromSlot(player, slotStack); - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - return stack; - } + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerResistiveHeater.java b/src/main/java/mekanism/common/inventory/container/ContainerResistiveHeater.java index 2f67947f6..695029df7 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerResistiveHeater.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerResistiveHeater.java @@ -9,116 +9,94 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerResistiveHeater extends Container -{ - private TileEntityResistiveHeater tileEntity; +public class ContainerResistiveHeater extends Container { + private TileEntityResistiveHeater tileEntity; - public ContainerResistiveHeater(InventoryPlayer inventory, TileEntityResistiveHeater tentity) - { - tileEntity = tentity; - addSlotToContainer(new SlotDischarge(tentity, 0, 15, 35)); - - int slotY; + public ContainerResistiveHeater( + InventoryPlayer inventory, TileEntityResistiveHeater tentity + ) { + tileEntity = tentity; + addSlotToContainer(new SlotDischarge(tentity, 0, 15, 35)); - for(slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); - } - } + int slotY; - for(slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); - } + for (slotY = 0; slotY < 3; slotY++) { + for (int slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot( + inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18 + )); + } + } - tileEntity.open(inventory.player); - tileEntity.openInventory(); - } + for (slotY = 0; slotY < 9; slotY++) { + addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + tileEntity.open(inventory.player); + tileEntity.openInventory(); + } - tileEntity.close(entityplayer); - tileEntity.closeInventory(); - } + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } + tileEntity.close(entityplayer); + tileEntity.closeInventory(); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(ChargeUtils.canBeDischarged(slotStack)) - { - if(slotID != 0) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else if(slotID == 0) - { - if(!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID >= 1 && slotID <= 27) - { - if(!mergeItemStack(slotStack, 28, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 27) - { - if(!mergeItemStack(slotStack, 1, 27, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) - { - return null; - } - } - } + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (ChargeUtils.canBeDischarged(slotStack)) { + if (slotID != 0) { + if (!mergeItemStack(slotStack, 0, 1, false)) { + return null; + } + } else if (slotID == 0) { + if (!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) { + return null; + } + } + } else { + if (slotID >= 1 && slotID <= 27) { + if (!mergeItemStack(slotStack, 28, inventorySlots.size(), false)) { + return null; + } + } else if (slotID > 27) { + if (!mergeItemStack(slotStack, 1, 27, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) { + return null; + } + } + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - currentSlot.onPickupFromSlot(player, slotStack); - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - return stack; - } + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerRobitCrafting.java b/src/main/java/mekanism/common/inventory/container/ContainerRobitCrafting.java index f46e7a244..1135677f1 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerRobitCrafting.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerRobitCrafting.java @@ -5,20 +5,17 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.ContainerWorkbench; -public class ContainerRobitCrafting extends ContainerWorkbench -{ - public EntityRobit robit; - - public ContainerRobitCrafting(InventoryPlayer inventory, EntityRobit entity) - { - super(inventory, entity.worldObj, 0, 0, 0); - - robit = entity; - } +public class ContainerRobitCrafting extends ContainerWorkbench { + public EntityRobit robit; - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return !robit.isDead; - } + public ContainerRobitCrafting(InventoryPlayer inventory, EntityRobit entity) { + super(inventory, entity.worldObj, 0, 0, 0); + + robit = entity; + } + + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return !robit.isDead; + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerRobitInventory.java b/src/main/java/mekanism/common/inventory/container/ContainerRobitInventory.java index c75bc5154..097e91e8c 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerRobitInventory.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerRobitInventory.java @@ -7,91 +7,77 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerRobitInventory extends Container -{ - public EntityRobit robit; +public class ContainerRobitInventory extends Container { + public EntityRobit robit; - public ContainerRobitInventory(InventoryPlayer inventory, EntityRobit entity) - { - robit = entity; - robit.openInventory(); + public ContainerRobitInventory(InventoryPlayer inventory, EntityRobit entity) { + robit = entity; + robit.openInventory(); - for(int slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(entity, slotX + slotY * 9, 8 + slotX * 18, 18 + slotY * 18)); - } - } + for (int slotY = 0; slotY < 3; slotY++) { + for (int slotX = 0; slotX < 9; slotX++) { + addSlotToContainer( + new Slot(entity, slotX + slotY * 9, 8 + slotX * 18, 18 + slotY * 18) + ); + } + } - int slotX; + int slotX; - for(slotX = 0; slotX < 3; ++slotX) - { - for(int slotY = 0; slotY < 9; ++slotY) - { - addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); - } - } + for (slotX = 0; slotX < 3; ++slotX) { + for (int slotY = 0; slotY < 9; ++slotY) { + addSlotToContainer(new Slot( + inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18 + )); + } + } - for(slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); - } - } + for (slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); + } + } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return !robit.isDead; - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return !robit.isDead; + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(slotID < 27) - { - if(!mergeItemStack(slotStack, 27, inventorySlots.size(), true)) - { - return null; - } - } - else if(!mergeItemStack(slotStack, 0, 27, false)) - { - return null; - } + if (slotID < 27) { + if (!mergeItemStack(slotStack, 27, inventorySlots.size(), true)) { + return null; + } + } else if (!mergeItemStack(slotStack, 0, 27, false)) { + return null; + } - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - currentSlot.onPickupFromSlot(player, slotStack); - } + currentSlot.onPickupFromSlot(player, slotStack); + } - return stack; - } + return stack; + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); - robit.closeInventory(); - } + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); + robit.closeInventory(); + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerRobitMain.java b/src/main/java/mekanism/common/inventory/container/ContainerRobitMain.java index bc3f21585..c307353ad 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerRobitMain.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerRobitMain.java @@ -8,49 +8,43 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerRobitMain extends Container -{ - private EntityRobit robit; +public class ContainerRobitMain extends Container { + private EntityRobit robit; - public ContainerRobitMain(InventoryPlayer inventory, EntityRobit entity) - { - robit = entity; - addSlotToContainer(new SlotDischarge(entity, 27, 153, 17)); + public ContainerRobitMain(InventoryPlayer inventory, EntityRobit entity) { + robit = entity; + addSlotToContainer(new SlotDischarge(entity, 27, 153, 17)); - robit.openInventory(); + robit.openInventory(); - int slotY; + int slotY; - for(slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); - } - } + for (slotY = 0; slotY < 3; slotY++) { + for (int slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot( + inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18 + )); + } + } - for(slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); - } - } + for (slotY = 0; slotY < 9; slotY++) { + addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); + } + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); - robit.closeInventory(); - } + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); + robit.closeInventory(); + } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return !robit.isDead; - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return !robit.isDead; + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - return null; - } + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + return null; + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerRobitRepair.java b/src/main/java/mekanism/common/inventory/container/ContainerRobitRepair.java index 34ca22493..4944178a5 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerRobitRepair.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerRobitRepair.java @@ -5,20 +5,17 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.ContainerRepair; -public class ContainerRobitRepair extends ContainerRepair -{ - public EntityRobit robit; - - public ContainerRobitRepair(InventoryPlayer inventory, EntityRobit entity) - { - super(inventory, entity.worldObj, 0, 0, 0, inventory.player); - - robit = entity; - } +public class ContainerRobitRepair extends ContainerRepair { + public EntityRobit robit; - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return !robit.isDead; - } + public ContainerRobitRepair(InventoryPlayer inventory, EntityRobit entity) { + super(inventory, entity.worldObj, 0, 0, 0, inventory.player); + + robit = entity; + } + + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return !robit.isDead; + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerRobitSmelting.java b/src/main/java/mekanism/common/inventory/container/ContainerRobitSmelting.java index f0d6c27a6..f073f8704 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerRobitSmelting.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerRobitSmelting.java @@ -11,177 +11,141 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.FurnaceRecipes; import net.minecraft.tileentity.TileEntityFurnace; -public class ContainerRobitSmelting extends Container -{ - public EntityRobit robit; +public class ContainerRobitSmelting extends Container { + public EntityRobit robit; - private int lastCookTime = 0; - private int lastBurnTime = 0; - private int lastItemBurnTime = 0; + private int lastCookTime = 0; + private int lastBurnTime = 0; + private int lastItemBurnTime = 0; - public ContainerRobitSmelting(InventoryPlayer inventory, EntityRobit entity) - { - robit = entity; - robit.openInventory(); + public ContainerRobitSmelting(InventoryPlayer inventory, EntityRobit entity) { + robit = entity; + robit.openInventory(); - addSlotToContainer(new Slot(entity, 28, 56, 17)); - addSlotToContainer(new Slot(entity, 29, 56, 53)); - addSlotToContainer(new SlotFurnace(inventory.player, entity, 30, 116, 35)); + addSlotToContainer(new Slot(entity, 28, 56, 17)); + addSlotToContainer(new Slot(entity, 29, 56, 53)); + addSlotToContainer(new SlotFurnace(inventory.player, entity, 30, 116, 35)); - int slotY; + int slotY; - for(slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); - } - } + for (slotY = 0; slotY < 3; slotY++) { + for (int slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot( + inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18 + )); + } + } - for(slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); - } - } + for (slotY = 0; slotY < 9; slotY++) { + addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); + } + } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return !robit.isDead; - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return !robit.isDead; + } - @Override - public void addCraftingToCrafters(ICrafting icrafting) - { - super.addCraftingToCrafters(icrafting); - icrafting.sendProgressBarUpdate(this, 0, robit.furnaceCookTime); - icrafting.sendProgressBarUpdate(this, 1, robit.furnaceBurnTime); - icrafting.sendProgressBarUpdate(this, 2, robit.currentItemBurnTime); - } + @Override + public void addCraftingToCrafters(ICrafting icrafting) { + super.addCraftingToCrafters(icrafting); + icrafting.sendProgressBarUpdate(this, 0, robit.furnaceCookTime); + icrafting.sendProgressBarUpdate(this, 1, robit.furnaceBurnTime); + icrafting.sendProgressBarUpdate(this, 2, robit.currentItemBurnTime); + } - @Override - public void detectAndSendChanges() - { - super.detectAndSendChanges(); + @Override + public void detectAndSendChanges() { + super.detectAndSendChanges(); - for(int i = 0; i < crafters.size(); ++i) - { - ICrafting icrafting = (ICrafting)crafters.get(i); + for (int i = 0; i < crafters.size(); ++i) { + ICrafting icrafting = (ICrafting) crafters.get(i); - if(lastCookTime != robit.furnaceCookTime) - { - icrafting.sendProgressBarUpdate(this, 0, robit.furnaceCookTime); - } + if (lastCookTime != robit.furnaceCookTime) { + icrafting.sendProgressBarUpdate(this, 0, robit.furnaceCookTime); + } - if(lastBurnTime != robit.furnaceBurnTime) - { - icrafting.sendProgressBarUpdate(this, 1, robit.furnaceBurnTime); - } + if (lastBurnTime != robit.furnaceBurnTime) { + icrafting.sendProgressBarUpdate(this, 1, robit.furnaceBurnTime); + } - if(lastItemBurnTime != robit.currentItemBurnTime) - { - icrafting.sendProgressBarUpdate(this, 2, robit.currentItemBurnTime); - } - } + if (lastItemBurnTime != robit.currentItemBurnTime) { + icrafting.sendProgressBarUpdate(this, 2, robit.currentItemBurnTime); + } + } - lastCookTime = robit.furnaceCookTime; - lastBurnTime = robit.furnaceBurnTime; - lastItemBurnTime = robit.currentItemBurnTime; - } + lastCookTime = robit.furnaceCookTime; + lastBurnTime = robit.furnaceBurnTime; + lastItemBurnTime = robit.currentItemBurnTime; + } - @Override - public void updateProgressBar(int i, int j) - { - if(i == 0) - { - robit.furnaceCookTime = j; - } + @Override + public void updateProgressBar(int i, int j) { + if (i == 0) { + robit.furnaceCookTime = j; + } - if(i == 1) - { - robit.furnaceBurnTime = j; - } + if (i == 1) { + robit.furnaceBurnTime = j; + } - if(i == 2) - { - robit.currentItemBurnTime = j; - } - } + if (i == 2) { + robit.currentItemBurnTime = j; + } + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(slotID == 2) - { - if(!mergeItemStack(slotStack, 3, 39, true)) - { - return null; - } - } - else if(slotID != 1 && slotID != 0) - { - if(FurnaceRecipes.smelting().getSmeltingResult(slotStack) != null) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else if(TileEntityFurnace.isItemFuel(slotStack)) - { - if(!mergeItemStack(slotStack, 1, 2, false)) - { - return null; - } - } - else if(slotID >= 3 && slotID < 30) - { - if(!mergeItemStack(slotStack, 30, 39, false)) - { - return null; - } - } - else if(slotID >= 30 && slotID < 39 && !mergeItemStack(slotStack, 3, 30, false)) - { - return null; - } - } - else if(!mergeItemStack(slotStack, 3, 39, false)) - { - return null; - } + if (slotID == 2) { + if (!mergeItemStack(slotStack, 3, 39, true)) { + return null; + } + } else if (slotID != 1 && slotID != 0) { + if (FurnaceRecipes.smelting().getSmeltingResult(slotStack) != null) { + if (!mergeItemStack(slotStack, 0, 1, false)) { + return null; + } + } else if (TileEntityFurnace.isItemFuel(slotStack)) { + if (!mergeItemStack(slotStack, 1, 2, false)) { + return null; + } + } else if (slotID >= 3 && slotID < 30) { + if (!mergeItemStack(slotStack, 30, 39, false)) { + return null; + } + } else if (slotID >= 30 && slotID < 39 && !mergeItemStack(slotStack, 3, 30, false)) { + return null; + } + } else if (!mergeItemStack(slotStack, 3, 39, false)) { + return null; + } - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - currentSlot.onPickupFromSlot(player, slotStack); - } + currentSlot.onPickupFromSlot(player, slotStack); + } - return stack; - } + return stack; + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); - robit.closeInventory(); - } + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); + robit.closeInventory(); + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerRotaryCondensentrator.java b/src/main/java/mekanism/common/inventory/container/ContainerRotaryCondensentrator.java index 6528d0110..2613deb87 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerRotaryCondensentrator.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerRotaryCondensentrator.java @@ -13,161 +13,138 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidContainerRegistry; -public class ContainerRotaryCondensentrator extends Container -{ - private TileEntityRotaryCondensentrator tileEntity; +public class ContainerRotaryCondensentrator extends Container { + private TileEntityRotaryCondensentrator tileEntity; - public ContainerRotaryCondensentrator(InventoryPlayer inventory, TileEntityRotaryCondensentrator tentity) - { - tileEntity = tentity; - addSlotToContainer(new SlotStorageTank(tentity, 0, 5, 25)); - addSlotToContainer(new SlotStorageTank(tentity, 1, 5, 56)); - addSlotToContainer(new Slot(tentity, 2, 155, 25)); - addSlotToContainer(new SlotOutput(tentity, 3, 155, 56)); - addSlotToContainer(new SlotDischarge(tentity, 4, 155, 5)); + public ContainerRotaryCondensentrator( + InventoryPlayer inventory, TileEntityRotaryCondensentrator tentity + ) { + tileEntity = tentity; + addSlotToContainer(new SlotStorageTank(tentity, 0, 5, 25)); + addSlotToContainer(new SlotStorageTank(tentity, 1, 5, 56)); + addSlotToContainer(new Slot(tentity, 2, 155, 25)); + addSlotToContainer(new SlotOutput(tentity, 3, 155, 56)); + addSlotToContainer(new SlotDischarge(tentity, 4, 155, 5)); - int slotY; + int slotY; - for(slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); - } - } + for (slotY = 0; slotY < 3; slotY++) { + for (int slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot( + inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18 + )); + } + } - for(slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); - } + for (slotY = 0; slotY < 9; slotY++) { + addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); + } - tileEntity.open(inventory.player); - tileEntity.openInventory(); - } + tileEntity.open(inventory.player); + tileEntity.openInventory(); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - tileEntity.close(entityplayer); - tileEntity.closeInventory(); - } + tileEntity.close(entityplayer); + tileEntity.closeInventory(); + } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(ChargeUtils.canBeDischarged(slotStack)) - { - if(slotID != 4) - { - if(!mergeItemStack(slotStack, 4, 5, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) - { - return null; - } - } - } + if (ChargeUtils.canBeDischarged(slotStack)) { + if (slotID != 4) { + if (!mergeItemStack(slotStack, 4, 5, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) { + return null; + } + } + } else if(FluidContainerRegistry.isEmptyContainer(slotStack) || FluidContainerRegistry.isFilledContainer(slotStack)) { - if(slotID != 2 && slotID != 3) - { - if(!mergeItemStack(slotStack, 2, 3, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) - { - return null; - } - } - } - else if(slotStack.getItem() instanceof IGasItem) - { - if(slotID != 0 && slotID != 1) - { - if(((IGasItem)slotStack.getItem()).canProvideGas(slotStack, tileEntity.gasTank.getGas() != null ? tileEntity.gasTank.getGas().getGas() : null)) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else if(((IGasItem)slotStack.getItem()).canReceiveGas(slotStack, tileEntity.gasTank.getGas() != null ? tileEntity.gasTank.getGas().getGas() : null)) - { - if(!mergeItemStack(slotStack, 1, 2, false)) - { - return null; - } - } - } - else { - if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID >= 5 && slotID <= 31) - { - if(!mergeItemStack(slotStack, 32, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 31) - { - if(!mergeItemStack(slotStack, 5, 31, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) - { - return null; - } - } - } + if (slotID != 2 && slotID != 3) { + if (!mergeItemStack(slotStack, 2, 3, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) { + return null; + } + } + } else if (slotStack.getItem() instanceof IGasItem) { + if (slotID != 0 && slotID != 1) { + if (((IGasItem) slotStack.getItem()) + .canProvideGas( + slotStack, + tileEntity.gasTank.getGas() != null + ? tileEntity.gasTank.getGas().getGas() + : null + )) { + if (!mergeItemStack(slotStack, 0, 1, false)) { + return null; + } + } else if (((IGasItem) slotStack.getItem()) + .canReceiveGas( + slotStack, + tileEntity.gasTank.getGas() != null + ? tileEntity.gasTank.getGas().getGas() + : null + )) { + if (!mergeItemStack(slotStack, 1, 2, false)) { + return null; + } + } + } else { + if (!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) { + return null; + } + } + } else { + if (slotID >= 5 && slotID <= 31) { + if (!mergeItemStack(slotStack, 32, inventorySlots.size(), false)) { + return null; + } + } else if (slotID > 31) { + if (!mergeItemStack(slotStack, 5, 31, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 5, inventorySlots.size(), true)) { + return null; + } + } + } - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - currentSlot.onPickupFromSlot(player, slotStack); - } + currentSlot.onPickupFromSlot(player, slotStack); + } - return stack; - } + return stack; + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerSecurityDesk.java b/src/main/java/mekanism/common/inventory/container/ContainerSecurityDesk.java index 289a34f6c..76ad8b9d5 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerSecurityDesk.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerSecurityDesk.java @@ -8,117 +8,97 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerSecurityDesk extends Container -{ - private TileEntitySecurityDesk tileEntity; +public class ContainerSecurityDesk extends Container { + private TileEntitySecurityDesk tileEntity; - public ContainerSecurityDesk(InventoryPlayer inventory, TileEntitySecurityDesk tentity) - { - tileEntity = tentity; - - addSlotToContainer(new Slot(tentity, 0, 146, 18)); - addSlotToContainer(new Slot(tentity, 1, 146, 97)); + public ContainerSecurityDesk( + InventoryPlayer inventory, TileEntitySecurityDesk tentity + ) { + tileEntity = tentity; - int slotY; + addSlotToContainer(new Slot(tentity, 0, 146, 18)); + addSlotToContainer(new Slot(tentity, 1, 146, 97)); - for(slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 148 + slotY * 18)); - } - } + int slotY; - for(slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 206)); - } + for (slotY = 0; slotY < 3; slotY++) { + for (int slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot( + inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 148 + slotY * 18 + )); + } + } - tileEntity.open(inventory.player); - tileEntity.openInventory(); - } + for (slotY = 0; slotY < 9; slotY++) { + addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 206)); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + tileEntity.open(inventory.player); + tileEntity.openInventory(); + } - tileEntity.close(entityplayer); - tileEntity.closeInventory(); - } + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } + tileEntity.close(entityplayer); + tileEntity.closeInventory(); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(slotStack.getItem() instanceof ISecurityItem && ((ISecurityItem)slotStack.getItem()).hasSecurity(slotStack)) - { - if(slotID != 0 && slotID != 1) - { - if(!mergeItemStack(slotStack, 1, 2, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) - { - return null; - } - } - } - else { - if(slotID >= 2 && slotID <= 28) - { - if(!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 28) - { - if(!mergeItemStack(slotStack, 2, 28, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (slotStack.getItem() instanceof ISecurityItem + && ((ISecurityItem) slotStack.getItem()).hasSecurity(slotStack)) { + if (slotID != 0 && slotID != 1) { + if (!mergeItemStack(slotStack, 1, 2, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) { + return null; + } + } + } else { + if (slotID >= 2 && slotID <= 28) { + if (!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) { + return null; + } + } else if (slotID > 28) { + if (!mergeItemStack(slotStack, 2, 28, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) { + return null; + } + } + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - currentSlot.onPickupFromSlot(player, slotStack); - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - return stack; - } + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerSeismicVibrator.java b/src/main/java/mekanism/common/inventory/container/ContainerSeismicVibrator.java index 7c58cad90..3cdc1b23c 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerSeismicVibrator.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerSeismicVibrator.java @@ -9,116 +9,94 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerSeismicVibrator extends Container -{ - private TileEntitySeismicVibrator tileEntity; +public class ContainerSeismicVibrator extends Container { + private TileEntitySeismicVibrator tileEntity; - public ContainerSeismicVibrator(InventoryPlayer inventory, TileEntitySeismicVibrator tentity) - { - tileEntity = tentity; - addSlotToContainer(new SlotDischarge(tentity, 0, 143, 35)); - - int slotY; + public ContainerSeismicVibrator( + InventoryPlayer inventory, TileEntitySeismicVibrator tentity + ) { + tileEntity = tentity; + addSlotToContainer(new SlotDischarge(tentity, 0, 143, 35)); - for(slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); - } - } + int slotY; - for(slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); - } + for (slotY = 0; slotY < 3; slotY++) { + for (int slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot( + inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18 + )); + } + } - tileEntity.open(inventory.player); - tileEntity.openInventory(); - } + for (slotY = 0; slotY < 9; slotY++) { + addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + tileEntity.open(inventory.player); + tileEntity.openInventory(); + } - tileEntity.close(entityplayer); - tileEntity.closeInventory(); - } + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } + tileEntity.close(entityplayer); + tileEntity.closeInventory(); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(ChargeUtils.canBeDischarged(slotStack)) - { - if(slotID != 0) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else if(slotID == 0) - { - if(!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID >= 1 && slotID <= 27) - { - if(!mergeItemStack(slotStack, 28, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 27) - { - if(!mergeItemStack(slotStack, 1, 27, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) - { - return null; - } - } - } + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (ChargeUtils.canBeDischarged(slotStack)) { + if (slotID != 0) { + if (!mergeItemStack(slotStack, 0, 1, false)) { + return null; + } + } else if (slotID == 0) { + if (!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) { + return null; + } + } + } else { + if (slotID >= 1 && slotID <= 27) { + if (!mergeItemStack(slotStack, 28, inventorySlots.size(), false)) { + return null; + } + } else if (slotID > 27) { + if (!mergeItemStack(slotStack, 1, 27, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) { + return null; + } + } + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - currentSlot.onPickupFromSlot(player, slotStack); - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - return stack; - } + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerSolarNeutronActivator.java b/src/main/java/mekanism/common/inventory/container/ContainerSolarNeutronActivator.java index d99db7e5b..4304e0c3c 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerSolarNeutronActivator.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerSolarNeutronActivator.java @@ -9,126 +9,113 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerSolarNeutronActivator extends Container -{ - private TileEntitySolarNeutronActivator tileEntity; +public class ContainerSolarNeutronActivator extends Container { + private TileEntitySolarNeutronActivator tileEntity; - public ContainerSolarNeutronActivator(InventoryPlayer inventory, TileEntitySolarNeutronActivator tentity) - { - tileEntity = tentity; - addSlotToContainer(new SlotStorageTank(tentity, 0, 5, 56)); - addSlotToContainer(new SlotStorageTank(tentity, 1, 155, 56)); + public ContainerSolarNeutronActivator( + InventoryPlayer inventory, TileEntitySolarNeutronActivator tentity + ) { + tileEntity = tentity; + addSlotToContainer(new SlotStorageTank(tentity, 0, 5, 56)); + addSlotToContainer(new SlotStorageTank(tentity, 1, 155, 56)); - int slotY; + int slotY; - for(slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); - } - } + for (slotY = 0; slotY < 3; slotY++) { + for (int slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot( + inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18 + )); + } + } - for(slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); - } + for (slotY = 0; slotY < 9; slotY++) { + addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); + } - tileEntity.open(inventory.player); - tileEntity.openInventory(); - } + tileEntity.open(inventory.player); + tileEntity.openInventory(); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - tileEntity.close(entityplayer); - tileEntity.closeInventory(); - } + tileEntity.close(entityplayer); + tileEntity.closeInventory(); + } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(slotStack.getItem() instanceof IGasItem) - { - if(slotID != 0 && slotID != 1) - { - if(((IGasItem)slotStack.getItem()).canProvideGas(slotStack, tileEntity.inputTank.getGas() != null ? tileEntity.inputTank.getGas().getGas() : null)) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else if(((IGasItem)slotStack.getItem()).canReceiveGas(slotStack, tileEntity.outputTank.getGas() != null ? tileEntity.outputTank.getGas().getGas() : null)) - { - if(!mergeItemStack(slotStack, 1, 2, false)) - { - return null; - } - } - } - else { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID >= 2 && slotID <= 28) - { - if(!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 28) - { - if(!mergeItemStack(slotStack, 2, 28, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } + if (slotStack.getItem() instanceof IGasItem) { + if (slotID != 0 && slotID != 1) { + if (((IGasItem) slotStack.getItem()) + .canProvideGas( + slotStack, + tileEntity.inputTank.getGas() != null + ? tileEntity.inputTank.getGas().getGas() + : null + )) { + if (!mergeItemStack(slotStack, 0, 1, false)) { + return null; + } + } else if (((IGasItem) slotStack.getItem()) + .canReceiveGas( + slotStack, + tileEntity.outputTank.getGas() != null + ? tileEntity.outputTank.getGas().getGas() + : null + )) { + if (!mergeItemStack(slotStack, 1, 2, false)) { + return null; + } + } + } else { + if (!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) { + return null; + } + } + } else { + if (slotID >= 2 && slotID <= 28) { + if (!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) { + return null; + } + } else if (slotID > 28) { + if (!mergeItemStack(slotStack, 2, 28, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) { + return null; + } + } + } - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - currentSlot.onPickupFromSlot(player, slotStack); - } + currentSlot.onPickupFromSlot(player, slotStack); + } - return stack; - } + return stack; + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerTeleporter.java b/src/main/java/mekanism/common/inventory/container/ContainerTeleporter.java index 466163f55..1d9649cde 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerTeleporter.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerTeleporter.java @@ -9,116 +9,92 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerTeleporter extends Container -{ - private TileEntityTeleporter tileEntity; +public class ContainerTeleporter extends Container { + private TileEntityTeleporter tileEntity; - public ContainerTeleporter(InventoryPlayer inventory, TileEntityTeleporter tentity) - { - tileEntity = tentity; - addSlotToContainer(new SlotDischarge(tentity, 0, 153, 7)); - - int slotX; + public ContainerTeleporter(InventoryPlayer inventory, TileEntityTeleporter tentity) { + tileEntity = tentity; + addSlotToContainer(new SlotDischarge(tentity, 0, 153, 7)); - for(slotX = 0; slotX < 3; slotX++) - { - for(int slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 148 + slotX * 18)); - } - } + int slotX; - for(slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 206)); - } + for (slotX = 0; slotX < 3; slotX++) { + for (int slotY = 0; slotY < 9; slotY++) { + addSlotToContainer(new Slot( + inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 148 + slotX * 18 + )); + } + } - tileEntity.open(inventory.player); - tileEntity.openInventory(); - } + for (slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 206)); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + tileEntity.open(inventory.player); + tileEntity.openInventory(); + } - tileEntity.close(entityplayer); - tileEntity.closeInventory(); - } + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } + tileEntity.close(entityplayer); + tileEntity.closeInventory(); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(ChargeUtils.canBeDischarged(slotStack)) - { - if(slotID != 0) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else if(slotID == 0) - { - if(!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID >= 1 && slotID <= 27) - { - if(!mergeItemStack(slotStack, 28, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 27) - { - if(!mergeItemStack(slotStack, 1, 27, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) - { - return null; - } - } - } + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (ChargeUtils.canBeDischarged(slotStack)) { + if (slotID != 0) { + if (!mergeItemStack(slotStack, 0, 1, false)) { + return null; + } + } else if (slotID == 0) { + if (!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) { + return null; + } + } + } else { + if (slotID >= 1 && slotID <= 27) { + if (!mergeItemStack(slotStack, 28, inventorySlots.size(), false)) { + return null; + } + } else if (slotID > 27) { + if (!mergeItemStack(slotStack, 1, 27, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) { + return null; + } + } + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - currentSlot.onPickupFromSlot(player, slotStack); - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - return stack; - } + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerThermalEvaporationController.java b/src/main/java/mekanism/common/inventory/container/ContainerThermalEvaporationController.java index e6f0302b2..69c149816 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerThermalEvaporationController.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerThermalEvaporationController.java @@ -10,144 +10,114 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; -public class ContainerThermalEvaporationController extends Container -{ - private TileEntityThermalEvaporationController tileEntity; +public class ContainerThermalEvaporationController extends Container { + private TileEntityThermalEvaporationController tileEntity; - public ContainerThermalEvaporationController(InventoryPlayer inventory, TileEntityThermalEvaporationController tentity) - { - tileEntity = tentity; + public ContainerThermalEvaporationController( + InventoryPlayer inventory, TileEntityThermalEvaporationController tentity + ) { + tileEntity = tentity; - addSlotToContainer(new Slot(tentity, 0, 28, 20)); - addSlotToContainer(new SlotOutput(tentity, 1, 28, 51)); - addSlotToContainer(new Slot(tentity, 2, 132, 20)); - addSlotToContainer(new SlotOutput(tentity, 3, 132, 51)); + addSlotToContainer(new Slot(tentity, 0, 28, 20)); + addSlotToContainer(new SlotOutput(tentity, 1, 28, 51)); + addSlotToContainer(new Slot(tentity, 2, 132, 20)); + addSlotToContainer(new SlotOutput(tentity, 3, 132, 51)); - int slotY; + int slotY; - for(slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); - } - } + for (slotY = 0; slotY < 3; slotY++) { + for (int slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot( + inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18 + )); + } + } - for(slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); - } + for (slotY = 0; slotY < 9; slotY++) { + addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); + } - tileEntity.open(inventory.player); - tileEntity.openInventory(); - } + tileEntity.open(inventory.player); + tileEntity.openInventory(); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - tileEntity.close(entityplayer); - tileEntity.closeInventory(); - } + tileEntity.close(entityplayer); + tileEntity.closeInventory(); + } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(slotID == 1 || slotID == 3) - { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - else if(FluidContainerRegistry.isEmptyContainer(slotStack)) - { - if(slotID != 2) - { - if(!mergeItemStack(slotStack, 2, 3, false)) - { - return null; - } - } - else if(slotID == 2) - { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - } + if (slotID == 1 || slotID == 3) { + if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { + return null; + } + } else if (FluidContainerRegistry.isEmptyContainer(slotStack)) { + if (slotID != 2) { + if (!mergeItemStack(slotStack, 2, 3, false)) { + return null; + } + } else if (slotID == 2) { + if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { + return null; + } + } + } else if(FluidContainerRegistry.isFilledContainer(slotStack) && FluidContainerRegistry.getFluidForFilledItem(slotStack).getFluid() == FluidRegistry.WATER) { - if(slotID != 0) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else if(slotID == 0) - { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID >= 4 && slotID <= 30) - { - if(!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 30) - { - if(!mergeItemStack(slotStack, 4, 30, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) - { - return null; - } - } - } + if (slotID != 0) { + if (!mergeItemStack(slotStack, 0, 1, false)) { + return null; + } + } else if (slotID == 0) { + if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { + return null; + } + } + } else { + if (slotID >= 4 && slotID <= 30) { + if (!mergeItemStack(slotStack, 31, inventorySlots.size(), false)) { + return null; + } + } else if (slotID > 30) { + if (!mergeItemStack(slotStack, 4, 30, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 4, inventorySlots.size(), true)) { + return null; + } + } + } - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - currentSlot.onPickupFromSlot(player, slotStack); - } + currentSlot.onPickupFromSlot(player, slotStack); + } - return stack; - } + return stack; + } } diff --git a/src/main/java/mekanism/common/inventory/container/ContainerUpgradeManagement.java b/src/main/java/mekanism/common/inventory/container/ContainerUpgradeManagement.java index 580d62c1c..9ab6ff747 100644 --- a/src/main/java/mekanism/common/inventory/container/ContainerUpgradeManagement.java +++ b/src/main/java/mekanism/common/inventory/container/ContainerUpgradeManagement.java @@ -10,115 +10,97 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerUpgradeManagement extends Container -{ - private IUpgradeTile tileEntity; +public class ContainerUpgradeManagement extends Container { + private IUpgradeTile tileEntity; - public ContainerUpgradeManagement(InventoryPlayer inventory, IUpgradeTile tile) - { - tileEntity = tile; - addSlotToContainer(new SlotMachineUpgrade((TileEntityContainerBlock)tile, tileEntity.getComponent().getUpgradeSlot(), 154, 7)); - - int slotY; + public ContainerUpgradeManagement(InventoryPlayer inventory, IUpgradeTile tile) { + tileEntity = tile; + addSlotToContainer(new SlotMachineUpgrade( + (TileEntityContainerBlock) tile, + tileEntity.getComponent().getUpgradeSlot(), + 154, + 7 + )); - for(slotY = 0; slotY < 3; slotY++) - { - for(int slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18)); - } - } + int slotY; - for(slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); - } + for (slotY = 0; slotY < 3; slotY++) { + for (int slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot( + inventory, slotX + slotY * 9 + 9, 8 + slotX * 18, 84 + slotY * 18 + )); + } + } - ((TileEntityContainerBlock)tileEntity).open(inventory.player); - ((TileEntityContainerBlock)tileEntity).openInventory(); - } + for (slotY = 0; slotY < 9; slotY++) { + addSlotToContainer(new Slot(inventory, slotY, 8 + slotY * 18, 142)); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + ((TileEntityContainerBlock) tileEntity).open(inventory.player); + ((TileEntityContainerBlock) tileEntity).openInventory(); + } - ((TileEntityContainerBlock)tileEntity).close(entityplayer); - ((TileEntityContainerBlock)tileEntity).closeInventory(); - } + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return ((TileEntityContainerBlock)tileEntity).isUseableByPlayer(entityplayer); - } + ((TileEntityContainerBlock) tileEntity).close(entityplayer); + ((TileEntityContainerBlock) tileEntity).closeInventory(); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return ((TileEntityContainerBlock) tileEntity).isUseableByPlayer(entityplayer); + } - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(slotStack.getItem() instanceof IUpgradeItem) - { - if(slotID != 0) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID >= 1 && slotID <= 27) - { - if(!mergeItemStack(slotStack, 28, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 27) - { - if(!mergeItemStack(slotStack, 1, 27, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) - { - return null; - } - } - } + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (slotStack.getItem() instanceof IUpgradeItem) { + if (slotID != 0) { + if (!mergeItemStack(slotStack, 0, 1, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) { + return null; + } + } + } else { + if (slotID >= 1 && slotID <= 27) { + if (!mergeItemStack(slotStack, 28, inventorySlots.size(), false)) { + return null; + } + } else if (slotID > 27) { + if (!mergeItemStack(slotStack, 1, 27, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) { + return null; + } + } + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - currentSlot.onPickupFromSlot(player, slotStack); - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - return stack; - } + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } } diff --git a/src/main/java/mekanism/common/inventory/slot/SlotEnergy.java b/src/main/java/mekanism/common/inventory/slot/SlotEnergy.java index 370bcc29e..d25f91497 100644 --- a/src/main/java/mekanism/common/inventory/slot/SlotEnergy.java +++ b/src/main/java/mekanism/common/inventory/slot/SlotEnergy.java @@ -5,33 +5,26 @@ import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class SlotEnergy -{ - public static class SlotCharge extends Slot - { - public SlotCharge(IInventory inventory, int index, int x, int y) - { - super(inventory, index, x, y); - } +public class SlotEnergy { + public static class SlotCharge extends Slot { + public SlotCharge(IInventory inventory, int index, int x, int y) { + super(inventory, index, x, y); + } - @Override - public boolean isItemValid(ItemStack itemstack) - { - return ChargeUtils.canBeCharged(itemstack); - } - } + @Override + public boolean isItemValid(ItemStack itemstack) { + return ChargeUtils.canBeCharged(itemstack); + } + } - public static class SlotDischarge extends Slot - { - public SlotDischarge(IInventory inventory, int index, int x, int y) - { - super(inventory, index, x, y); - } + public static class SlotDischarge extends Slot { + public SlotDischarge(IInventory inventory, int index, int x, int y) { + super(inventory, index, x, y); + } - @Override - public boolean isItemValid(ItemStack itemstack) - { - return ChargeUtils.canBeDischarged(itemstack); - } - } + @Override + public boolean isItemValid(ItemStack itemstack) { + return ChargeUtils.canBeDischarged(itemstack); + } + } } diff --git a/src/main/java/mekanism/common/inventory/slot/SlotMachineUpgrade.java b/src/main/java/mekanism/common/inventory/slot/SlotMachineUpgrade.java index 3b2882ee4..1c2d6ffe3 100644 --- a/src/main/java/mekanism/common/inventory/slot/SlotMachineUpgrade.java +++ b/src/main/java/mekanism/common/inventory/slot/SlotMachineUpgrade.java @@ -5,16 +5,13 @@ import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class SlotMachineUpgrade extends Slot -{ - public SlotMachineUpgrade(IInventory inventory, int index, int x, int y) - { - super(inventory, index, x, y); - } +public class SlotMachineUpgrade extends Slot { + public SlotMachineUpgrade(IInventory inventory, int index, int x, int y) { + super(inventory, index, x, y); + } - @Override - public boolean isItemValid(ItemStack itemstack) - { - return itemstack.getItem() instanceof IUpgradeItem; - } + @Override + public boolean isItemValid(ItemStack itemstack) { + return itemstack.getItem() instanceof IUpgradeItem; + } } diff --git a/src/main/java/mekanism/common/inventory/slot/SlotOutput.java b/src/main/java/mekanism/common/inventory/slot/SlotOutput.java index 398db49ce..82bb496bb 100644 --- a/src/main/java/mekanism/common/inventory/slot/SlotOutput.java +++ b/src/main/java/mekanism/common/inventory/slot/SlotOutput.java @@ -4,16 +4,13 @@ import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class SlotOutput extends Slot -{ - public SlotOutput(IInventory inventory, int index, int x, int y) - { - super(inventory, index, x, y); - } +public class SlotOutput extends Slot { + public SlotOutput(IInventory inventory, int index, int x, int y) { + super(inventory, index, x, y); + } - @Override - public boolean isItemValid(ItemStack itemstack) - { - return false; - } + @Override + public boolean isItemValid(ItemStack itemstack) { + return false; + } } diff --git a/src/main/java/mekanism/common/inventory/slot/SlotPersonalChest.java b/src/main/java/mekanism/common/inventory/slot/SlotPersonalChest.java index 881c4fbc7..d3e41141e 100644 --- a/src/main/java/mekanism/common/inventory/slot/SlotPersonalChest.java +++ b/src/main/java/mekanism/common/inventory/slot/SlotPersonalChest.java @@ -5,21 +5,18 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; -public class SlotPersonalChest extends Slot -{ - public SlotPersonalChest(IInventory inventory, int index, int x, int y) - { - super(inventory, index, x, y); - } +public class SlotPersonalChest extends Slot { + public SlotPersonalChest(IInventory inventory, int index, int x, int y) { + super(inventory, index, x, y); + } - @Override - public boolean canTakeStack(EntityPlayer player) - { - if(inventory.getStackInSlot(getSlotIndex()) == null) - { - return false; - } - - return MachineType.get(inventory.getStackInSlot(getSlotIndex())) != MachineType.PERSONAL_CHEST; - } + @Override + public boolean canTakeStack(EntityPlayer player) { + if (inventory.getStackInSlot(getSlotIndex()) == null) { + return false; + } + + return MachineType.get(inventory.getStackInSlot(getSlotIndex())) + != MachineType.PERSONAL_CHEST; + } } diff --git a/src/main/java/mekanism/common/inventory/slot/SlotSpecific.java b/src/main/java/mekanism/common/inventory/slot/SlotSpecific.java index c516f3f84..592ea6882 100644 --- a/src/main/java/mekanism/common/inventory/slot/SlotSpecific.java +++ b/src/main/java/mekanism/common/inventory/slot/SlotSpecific.java @@ -5,20 +5,20 @@ import net.minecraft.inventory.Slot; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -public class SlotSpecific extends Slot -{ +public class SlotSpecific extends Slot { private Class itemClass; - public SlotSpecific(IInventory inventory, int index, int x, int y, Class c) - { + public SlotSpecific( + IInventory inventory, int index, int x, int y, Class c + ) { super(inventory, index, x, y); itemClass = c; } @Override - public boolean isItemValid(ItemStack itemstack) - { - return itemClass.equals(itemstack.getItem().getClass()) || itemClass.isInstance(itemstack.getItem()); + public boolean isItemValid(ItemStack itemstack) { + return itemClass.equals(itemstack.getItem().getClass()) + || itemClass.isInstance(itemstack.getItem()); } } diff --git a/src/main/java/mekanism/common/inventory/slot/SlotStorageTank.java b/src/main/java/mekanism/common/inventory/slot/SlotStorageTank.java index eed145d7b..cb53809b8 100644 --- a/src/main/java/mekanism/common/inventory/slot/SlotStorageTank.java +++ b/src/main/java/mekanism/common/inventory/slot/SlotStorageTank.java @@ -9,45 +9,45 @@ import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class SlotStorageTank extends Slot -{ - public Collection types; - public boolean acceptsAllGasses; +public class SlotStorageTank extends Slot { + public Collection types; + public boolean acceptsAllGasses; - public SlotStorageTank(IInventory inventory, int index, int x, int y) - { - super(inventory, index, x, y); - types = null; - acceptsAllGasses = true; - } + public SlotStorageTank(IInventory inventory, int index, int x, int y) { + super(inventory, index, x, y); + types = null; + acceptsAllGasses = true; + } - public SlotStorageTank(IInventory inventory, Gas gas, boolean all, int index, int x, int y) - { - super(inventory, index, x, y); - types = Collections.singletonList(gas); - acceptsAllGasses = all; - } + public SlotStorageTank( + IInventory inventory, Gas gas, boolean all, int index, int x, int y + ) { + super(inventory, index, x, y); + types = Collections.singletonList(gas); + acceptsAllGasses = all; + } - public SlotStorageTank(IInventory inventory, Collection gases, boolean all, int index, int x, int y) - { - super(inventory, index, x, y); - types = gases; - acceptsAllGasses = all; - } + public SlotStorageTank( + IInventory inventory, Collection gases, boolean all, int index, int x, int y + ) { + super(inventory, index, x, y); + types = gases; + acceptsAllGasses = all; + } - @Override - public boolean isItemValid(ItemStack itemstack) - { - if(acceptsAllGasses) - { - return itemstack.getItem() instanceof IGasItem; - } + @Override + public boolean isItemValid(ItemStack itemstack) { + if (acceptsAllGasses) { + return itemstack.getItem() instanceof IGasItem; + } - if(itemstack.getItem() instanceof IGasItem) - { - return ((IGasItem)itemstack.getItem()).getGas(itemstack) == null || types.contains(((IGasItem)itemstack.getItem()).getGas(itemstack).getGas()); - } + if (itemstack.getItem() instanceof IGasItem) { + return ((IGasItem) itemstack.getItem()).getGas(itemstack) == null + || types.contains( + ((IGasItem) itemstack.getItem()).getGas(itemstack).getGas() + ); + } - return false; - } + return false; + } } diff --git a/src/main/java/mekanism/common/item/ItemAlloy.java b/src/main/java/mekanism/common/item/ItemAlloy.java index e0aba921b..4755bae5d 100644 --- a/src/main/java/mekanism/common/item/ItemAlloy.java +++ b/src/main/java/mekanism/common/item/ItemAlloy.java @@ -8,29 +8,37 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -public class ItemAlloy extends ItemMekanism -{ - public ItemAlloy() - { - super(); - } - - @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) - { - TileEntity tile = world.getTileEntity(x, y, z); - - if(general.allowTransmitterAlloyUpgrade && tile instanceof IAlloyInteraction) - { - if(!world.isRemote) - { - int ordinal = stack.getItem() == MekanismItems.EnrichedAlloy? 1 : (stack.getItem() == MekanismItems.ReinforcedAlloy ? 2 : 3); - ((IAlloyInteraction)tile).onAlloyInteraction(player, ordinal); - } - - return true; - } - +public class ItemAlloy extends ItemMekanism { + public ItemAlloy() { + super(); + } + + @Override + public boolean onItemUse( + ItemStack stack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int side, + float hitX, + float hitY, + float hitZ + ) { + TileEntity tile = world.getTileEntity(x, y, z); + + if (general.allowTransmitterAlloyUpgrade && tile instanceof IAlloyInteraction) { + if (!world.isRemote) { + int ordinal = stack.getItem() == MekanismItems.EnrichedAlloy + ? 1 + : (stack.getItem() == MekanismItems.ReinforcedAlloy ? 2 : 3); + ((IAlloyInteraction) tile).onAlloyInteraction(player, ordinal); + } + + return true; + } + return false; } } diff --git a/src/main/java/mekanism/common/item/ItemAtomicDisassembler.java b/src/main/java/mekanism/common/item/ItemAtomicDisassembler.java index d06d9a204..05c57d6eb 100644 --- a/src/main/java/mekanism/common/item/ItemAtomicDisassembler.java +++ b/src/main/java/mekanism/common/item/ItemAtomicDisassembler.java @@ -6,6 +6,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import cpw.mods.fml.common.eventhandler.Event.Result; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.MekanismConfig.general; @@ -25,358 +26,398 @@ import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.event.entity.player.UseHoeEvent; -import cpw.mods.fml.common.eventhandler.Event.Result; -public class ItemAtomicDisassembler extends ItemEnergized -{ - public double HOE_USAGE = 10 * general.DISASSEMBLER_USAGE; +public class ItemAtomicDisassembler extends ItemEnergized { + public double HOE_USAGE = 10 * general.DISASSEMBLER_USAGE; - public ItemAtomicDisassembler() - { - super(1000000); - } + public ItemAtomicDisassembler() { + super(1000000); + } - @Override - public void registerIcons(IIconRegister register) {} + @Override + public void registerIcons(IIconRegister register) {} - @Override - public boolean canHarvestBlock(Block block, ItemStack stack) - { - return block != Blocks.bedrock; - } + @Override + public boolean canHarvestBlock(Block block, ItemStack stack) { + return block != Blocks.bedrock; + } - @Override - public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) - { - super.addInformation(itemstack, entityplayer, list, flag); + @Override + public void addInformation( + ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag + ) { + super.addInformation(itemstack, entityplayer, list, flag); - list.add(LangUtils.localize("tooltip.mode") + ": " + EnumColor.INDIGO + getModeName(itemstack)); - list.add(LangUtils.localize("tooltip.efficiency") + ": " + EnumColor.INDIGO + getEfficiency(itemstack)); - } + list.add( + LangUtils.localize("tooltip.mode") + ": " + EnumColor.INDIGO + + getModeName(itemstack) + ); + list.add( + LangUtils.localize("tooltip.efficiency") + ": " + EnumColor.INDIGO + + getEfficiency(itemstack) + ); + } - @Override - public boolean hitEntity(ItemStack itemstack, EntityLivingBase hitEntity, EntityLivingBase player) - { - if(getEnergy(itemstack) > 0) - { - hitEntity.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer)player), 20); - setEnergy(itemstack, getEnergy(itemstack) - 2000); - } - else { - hitEntity.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer)player), 4); - } + @Override + public boolean + hitEntity(ItemStack itemstack, EntityLivingBase hitEntity, EntityLivingBase player) { + if (getEnergy(itemstack) > 0) { + hitEntity.attackEntityFrom( + DamageSource.causePlayerDamage((EntityPlayer) player), 20 + ); + setEnergy(itemstack, getEnergy(itemstack) - 2000); + } else { + hitEntity.attackEntityFrom( + DamageSource.causePlayerDamage((EntityPlayer) player), 4 + ); + } - return false; - } + return false; + } - @Override - public float getDigSpeed(ItemStack itemstack, Block block, int meta) - { - return getEnergy(itemstack) != 0 ? getEfficiency(itemstack) : 1F; - } + @Override + public float getDigSpeed(ItemStack itemstack, Block block, int meta) { + return getEnergy(itemstack) != 0 ? getEfficiency(itemstack) : 1F; + } - @Override - public boolean onBlockDestroyed(ItemStack itemstack, World world, Block block, int x, int y, int z, EntityLivingBase entityliving) - { - if(block.getBlockHardness(world, x, y, z) != 0.0D) - { - setEnergy(itemstack, getEnergy(itemstack) - (general.DISASSEMBLER_USAGE*getEfficiency(itemstack))); - } - else { - setEnergy(itemstack, getEnergy(itemstack) - (general.DISASSEMBLER_USAGE*(getEfficiency(itemstack))/2)); - } + @Override + public boolean onBlockDestroyed( + ItemStack itemstack, + World world, + Block block, + int x, + int y, + int z, + EntityLivingBase entityliving + ) { + if (block.getBlockHardness(world, x, y, z) != 0.0D) { + setEnergy( + itemstack, + getEnergy(itemstack) + - (general.DISASSEMBLER_USAGE * getEfficiency(itemstack)) + ); + } else { + setEnergy( + itemstack, + getEnergy(itemstack) + - (general.DISASSEMBLER_USAGE * (getEfficiency(itemstack)) / 2) + ); + } - return true; - } + return true; + } - @Override - public boolean onBlockStartBreak(ItemStack itemstack, int x, int y, int z, EntityPlayer player) - { - super.onBlockStartBreak(itemstack, x, y, z, player); + @Override + public boolean + onBlockStartBreak(ItemStack itemstack, int x, int y, int z, EntityPlayer player) { + super.onBlockStartBreak(itemstack, x, y, z, player); - if(!player.worldObj.isRemote) - { - Block block = player.worldObj.getBlock(x, y, z); - int meta = player.worldObj.getBlockMetadata(x, y, z); - - if(block == Blocks.lit_redstone_ore) - { - block = Blocks.redstone_ore; - } + if (!player.worldObj.isRemote) { + Block block = player.worldObj.getBlock(x, y, z); + int meta = player.worldObj.getBlockMetadata(x, y, z); - ItemStack stack = new ItemStack(block, 1, meta); - Coord4D orig = new Coord4D(x, y, z, player.worldObj.provider.dimensionId); + if (block == Blocks.lit_redstone_ore) { + block = Blocks.redstone_ore; + } - List names = MekanismUtils.getOreDictName(stack); + ItemStack stack = new ItemStack(block, 1, meta); + Coord4D orig = new Coord4D(x, y, z, player.worldObj.provider.dimensionId); - boolean isOre = false; + List names = MekanismUtils.getOreDictName(stack); - for(String s : names) - { - if(s.startsWith("ore") || s.equals("logWood")) - { - isOre = true; - } - } + boolean isOre = false; - if(getMode(itemstack) == 3 && isOre && !player.capabilities.isCreativeMode) - { - Set found = new Finder(player.worldObj, stack, new Coord4D(x, y, z, player.worldObj.provider.dimensionId)).calc(); + for (String s : names) { + if (s.startsWith("ore") || s.equals("logWood")) { + isOre = true; + } + } - for(Coord4D coord : found) - { - if(coord.equals(orig) || getEnergy(itemstack) < (general.DISASSEMBLER_USAGE*getEfficiency(itemstack))) - { - continue; - } + if (getMode(itemstack) == 3 && isOre && !player.capabilities.isCreativeMode) { + Set found + = new Finder( + player.worldObj, + stack, + new Coord4D(x, y, z, player.worldObj.provider.dimensionId) + ) + .calc(); - Block block2 = coord.getBlock(player.worldObj); + for (Coord4D coord : found) { + if (coord.equals(orig) + || getEnergy(itemstack) + < (general.DISASSEMBLER_USAGE * getEfficiency(itemstack))) { + continue; + } - block2.onBlockDestroyedByPlayer(player.worldObj, coord.xCoord, coord.yCoord, coord.zCoord, meta); - player.worldObj.playAuxSFXAtEntity(null, 2001, coord.xCoord, coord.yCoord, coord.zCoord, meta << 12); - player.worldObj.setBlockToAir(coord.xCoord, coord.yCoord, coord.zCoord); - block2.breakBlock(player.worldObj, coord.xCoord, coord.yCoord, coord.zCoord, block, meta); - block2.dropBlockAsItem(player.worldObj, coord.xCoord, coord.yCoord, coord.zCoord, meta, 0); + Block block2 = coord.getBlock(player.worldObj); - setEnergy(itemstack, getEnergy(itemstack) - (general.DISASSEMBLER_USAGE*getEfficiency(itemstack))); - } - } - } + block2.onBlockDestroyedByPlayer( + player.worldObj, coord.xCoord, coord.yCoord, coord.zCoord, meta + ); + player.worldObj.playAuxSFXAtEntity( + null, 2001, coord.xCoord, coord.yCoord, coord.zCoord, meta << 12 + ); + player.worldObj.setBlockToAir( + coord.xCoord, coord.yCoord, coord.zCoord + ); + block2.breakBlock( + player.worldObj, + coord.xCoord, + coord.yCoord, + coord.zCoord, + block, + meta + ); + block2.dropBlockAsItem( + player.worldObj, coord.xCoord, coord.yCoord, coord.zCoord, meta, 0 + ); - return false; - } + setEnergy( + itemstack, + getEnergy(itemstack) + - (general.DISASSEMBLER_USAGE * getEfficiency(itemstack)) + ); + } + } + } - @Override - public boolean isFull3D() - { - return true; - } + return false; + } - @Override - public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) - { - if(!world.isRemote && entityplayer.isSneaking()) - { - toggleMode(itemstack); - entityplayer.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + LangUtils.localize("tooltip.modeToggle") + " " + EnumColor.INDIGO + getModeName(itemstack) + EnumColor.AQUA + " (" + getEfficiency(itemstack) + ")")); - } + @Override + public boolean isFull3D() { + return true; + } - return itemstack; - } + @Override + public ItemStack + onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { + if (!world.isRemote && entityplayer.isSneaking()) { + toggleMode(itemstack); + entityplayer.addChatMessage(new ChatComponentText( + EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + + LangUtils.localize("tooltip.modeToggle") + " " + EnumColor.INDIGO + + getModeName(itemstack) + EnumColor.AQUA + " (" + + getEfficiency(itemstack) + ")" + )); + } - @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) - { - if(!player.isSneaking()) - { - if(!useHoe(stack, player, world, x, y, z, side)) - { - if(world.getBlock(x, y, z) != Blocks.farmland) - { - return false; - } - } + return itemstack; + } - switch(getEfficiency(stack)) - { - case 20: - for(int x1 = x-1; x1 <= x+1; x1++) - { - for(int z1 = z-1; z1 <= z+1; z1++) - { - useHoe(stack, player, world, x1, y, z1, side); - } - } + @Override + public boolean onItemUse( + ItemStack stack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int side, + float hitX, + float hitY, + float hitZ + ) { + if (!player.isSneaking()) { + if (!useHoe(stack, player, world, x, y, z, side)) { + if (world.getBlock(x, y, z) != Blocks.farmland) { + return false; + } + } - break; - case 128: - for(int x1 = x-2; x1 <= x+2; x1++) - { - for(int z1 = z-2; z1 <= z+2; z1++) - { - useHoe(stack, player, world, x1, y, z1, side); - } - } + switch (getEfficiency(stack)) { + case 20: + for (int x1 = x - 1; x1 <= x + 1; x1++) { + for (int z1 = z - 1; z1 <= z + 1; z1++) { + useHoe(stack, player, world, x1, y, z1, side); + } + } - break; - } + break; + case 128: + for (int x1 = x - 2; x1 <= x + 2; x1++) { + for (int z1 = z - 2; z1 <= z + 2; z1++) { + useHoe(stack, player, world, x1, y, z1, side); + } + } - return true; - } + break; + } - return false; - } + return true; + } - private boolean useHoe(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side) - { - if(!player.canPlayerEdit(x, y, z, side, stack) || (!player.capabilities.isCreativeMode && getEnergy(stack) < HOE_USAGE)) - { - return false; - } - else { - UseHoeEvent event = new UseHoeEvent(player, stack, world, x, y, z); + return false; + } - if(MinecraftForge.EVENT_BUS.post(event)) - { - return false; - } + private boolean useHoe( + ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side + ) { + if (!player.canPlayerEdit(x, y, z, side, stack) + || (!player.capabilities.isCreativeMode && getEnergy(stack) < HOE_USAGE)) { + return false; + } else { + UseHoeEvent event = new UseHoeEvent(player, stack, world, x, y, z); - if(event.getResult() == Result.ALLOW) - { - setEnergy(stack, getEnergy(stack)-HOE_USAGE); - return true; - } + if (MinecraftForge.EVENT_BUS.post(event)) { + return false; + } - Block block1 = world.getBlock(x, y, z); - boolean air = world.isAirBlock(x, y + 1, z); + if (event.getResult() == Result.ALLOW) { + setEnergy(stack, getEnergy(stack) - HOE_USAGE); + return true; + } - if(side != 0 && air && (block1 == Blocks.grass || block1 == Blocks.dirt)) - { - Block farm = Blocks.farmland; - world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, farm.stepSound.getStepResourcePath(), (farm.stepSound.getVolume() + 1.0F) / 2.0F, farm.stepSound.getPitch() * 0.8F); + Block block1 = world.getBlock(x, y, z); + boolean air = world.isAirBlock(x, y + 1, z); - if(world.isRemote) - { - return true; - } - else { - world.setBlock(x, y, z, farm); - - if(!player.capabilities.isCreativeMode) - { - setEnergy(stack, getEnergy(stack)-HOE_USAGE); - } - - return true; - } - } - else { - return false; - } - } - } + if (side != 0 && air && (block1 == Blocks.grass || block1 == Blocks.dirt)) { + Block farm = Blocks.farmland; + world.playSoundEffect( + x + 0.5F, + y + 0.5F, + z + 0.5F, + farm.stepSound.getStepResourcePath(), + (farm.stepSound.getVolume() + 1.0F) / 2.0F, + farm.stepSound.getPitch() * 0.8F + ); - public int getEfficiency(ItemStack itemStack) - { - switch(getMode(itemStack)) - { - case 0: - return 20; - case 1: - return 8; - case 2: - return 128; - case 3: - return 20; - case 4: - return 0; - } + if (world.isRemote) { + return true; + } else { + world.setBlock(x, y, z, farm); - return 0; - } + if (!player.capabilities.isCreativeMode) { + setEnergy(stack, getEnergy(stack) - HOE_USAGE); + } - public int getMode(ItemStack itemStack) - { - if(itemStack.stackTagCompound == null) - { - return 0; - } + return true; + } + } else { + return false; + } + } + } - return itemStack.stackTagCompound.getInteger("mode"); - } + public int getEfficiency(ItemStack itemStack) { + switch (getMode(itemStack)) { + case 0: + return 20; + case 1: + return 8; + case 2: + return 128; + case 3: + return 20; + case 4: + return 0; + } - public String getModeName(ItemStack itemStack) - { - int mode = getMode(itemStack); + return 0; + } - switch(mode) - { - case 0: - return LangUtils.localize("tooltip.disassembler.normal"); - case 1: - return LangUtils.localize("tooltip.disassembler.slow"); - case 2: - return LangUtils.localize("tooltip.disassembler.fast"); - case 3: - return LangUtils.localize("tooltip.disassembler.vein"); - case 4: - return LangUtils.localize("tooltip.disassembler.off"); - } + public int getMode(ItemStack itemStack) { + if (itemStack.stackTagCompound == null) { + return 0; + } - return null; - } + return itemStack.stackTagCompound.getInteger("mode"); + } - public void toggleMode(ItemStack itemStack) - { - if(itemStack.stackTagCompound == null) - { - itemStack.setTagCompound(new NBTTagCompound()); - } + public String getModeName(ItemStack itemStack) { + int mode = getMode(itemStack); - itemStack.stackTagCompound.setInteger("mode", getMode(itemStack) < 4 ? getMode(itemStack)+1 : 0); - } + switch (mode) { + case 0: + return LangUtils.localize("tooltip.disassembler.normal"); + case 1: + return LangUtils.localize("tooltip.disassembler.slow"); + case 2: + return LangUtils.localize("tooltip.disassembler.fast"); + case 3: + return LangUtils.localize("tooltip.disassembler.vein"); + case 4: + return LangUtils.localize("tooltip.disassembler.off"); + } - @Override - public boolean canSend(ItemStack itemStack) - { - return false; - } + return null; + } - public static class Finder - { - public World world; + public void toggleMode(ItemStack itemStack) { + if (itemStack.stackTagCompound == null) { + itemStack.setTagCompound(new NBTTagCompound()); + } - public ItemStack stack; + itemStack.stackTagCompound.setInteger( + "mode", getMode(itemStack) < 4 ? getMode(itemStack) + 1 : 0 + ); + } - public Coord4D location; + @Override + public boolean canSend(ItemStack itemStack) { + return false; + } - public Set found = new HashSet(); + public static class Finder { + public World world; - public static Map> ignoreBlocks = new HashMap>(); + public ItemStack stack; - public Finder(World w, ItemStack s, Coord4D loc) - { - world = w; - stack = s; - location = loc; - } + public Coord4D location; - public void loop(Coord4D pointer) - { - if(found.contains(pointer) || found.size() > 128) - { - return; - } + public Set found = new HashSet(); - found.add(pointer); + public static Map> ignoreBlocks + = new HashMap>(); - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - Coord4D coord = pointer.getFromSide(side); + public Finder(World w, ItemStack s, Coord4D loc) { + world = w; + stack = s; + location = loc; + } - if(coord.exists(world) && checkID(coord.getBlock(world)) && (coord.getMetadata(world) == stack.getItemDamage() || (MekanismUtils.getOreDictName(stack).contains("logWood") && coord.getMetadata(world) % 4 == stack.getItemDamage() % 4))) - { - loop(coord); - } - } - } + public void loop(Coord4D pointer) { + if (found.contains(pointer) || found.size() > 128) { + return; + } - public Set calc() - { - loop(location); + found.add(pointer); - return found; - } + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + Coord4D coord = pointer.getFromSide(side); - public boolean checkID(Block b) - { - Block origBlock = location.getBlock(world); - return (ignoreBlocks.get(origBlock) == null && b == origBlock) || (ignoreBlocks.get(origBlock) != null && ignoreBlocks.get(origBlock).contains(b)); - } + if (coord.exists(world) && checkID(coord.getBlock(world)) + && (coord.getMetadata(world) == stack.getItemDamage() + || (MekanismUtils.getOreDictName(stack).contains("logWood") + && coord.getMetadata(world) % 4 == stack.getItemDamage() % 4) + )) { + loop(coord); + } + } + } - static { - ignoreBlocks.put(Blocks.redstone_ore, ListUtils.asList(Blocks.redstone_ore, Blocks.lit_redstone_ore)); - ignoreBlocks.put(Blocks.lit_redstone_ore, ListUtils.asList(Blocks.redstone_ore, Blocks.lit_redstone_ore)); - } - } + public Set calc() { + loop(location); + + return found; + } + + public boolean checkID(Block b) { + Block origBlock = location.getBlock(world); + return (ignoreBlocks.get(origBlock) == null && b == origBlock) + || (ignoreBlocks.get(origBlock) != null + && ignoreBlocks.get(origBlock).contains(b)); + } + + static { + ignoreBlocks.put( + Blocks.redstone_ore, + ListUtils.asList(Blocks.redstone_ore, Blocks.lit_redstone_ore) + ); + ignoreBlocks.put( + Blocks.lit_redstone_ore, + ListUtils.asList(Blocks.redstone_ore, Blocks.lit_redstone_ore) + ); + } + } } diff --git a/src/main/java/mekanism/common/item/ItemBalloon.java b/src/main/java/mekanism/common/item/ItemBalloon.java index 9e1750c04..0bd0f1ea6 100644 --- a/src/main/java/mekanism/common/item/ItemBalloon.java +++ b/src/main/java/mekanism/common/item/ItemBalloon.java @@ -2,6 +2,8 @@ package mekanism.common.item; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.Pos3D; @@ -20,228 +22,250 @@ import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.StatCollector; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class ItemBalloon extends ItemMekanism -{ - public ItemBalloon() - { - super(); - setHasSubtypes(true); - BlockDispenser.dispenseBehaviorRegistry.putObject(this, new DispenserBehavior()); - } +public class ItemBalloon extends ItemMekanism { + public ItemBalloon() { + super(); + setHasSubtypes(true); + BlockDispenser.dispenseBehaviorRegistry.putObject(this, new DispenserBehavior()); + } - public EnumColor getColor(ItemStack stack) - { - return EnumColor.DYES[stack.getItemDamage()]; - } + public EnumColor getColor(ItemStack stack) { + return EnumColor.DYES[stack.getItemDamage()]; + } - @Override - public void getSubItems(Item item, CreativeTabs tabs, List list) - { - for(int i = 0; i < EnumColor.DYES.length; i++) - { - EnumColor color = EnumColor.DYES[i]; + @Override + public void getSubItems(Item item, CreativeTabs tabs, List list) { + for (int i = 0; i < EnumColor.DYES.length; i++) { + EnumColor color = EnumColor.DYES[i]; - if(color != null) - { - ItemStack stack = new ItemStack(this); - stack.setItemDamage(i); - list.add(stack); - } - } - } + if (color != null) { + ItemStack stack = new ItemStack(this); + stack.setItemDamage(i); + list.add(stack); + } + } + } - @Override - public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) - { - if(!world.isRemote) - { - Pos3D pos = new Pos3D(); - pos.zPos += 0.3; - pos.xPos -= 0.4; - pos.rotateYaw(entityplayer.renderYawOffset); - pos.translate(new Pos3D(entityplayer)); + @Override + public ItemStack + onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { + if (!world.isRemote) { + Pos3D pos = new Pos3D(); + pos.zPos += 0.3; + pos.xPos -= 0.4; + pos.rotateYaw(entityplayer.renderYawOffset); + pos.translate(new Pos3D(entityplayer)); - world.spawnEntityInWorld(new EntityBalloon(world, pos.xPos-0.5, pos.yPos-0.25, pos.zPos-0.5, getColor(itemstack))); - } + world.spawnEntityInWorld(new EntityBalloon( + world, + pos.xPos - 0.5, + pos.yPos - 0.25, + pos.zPos - 0.5, + getColor(itemstack) + )); + } - itemstack.stackSize--; + itemstack.stackSize--; - return itemstack; - } + return itemstack; + } - @Override - public String getItemStackDisplayName(ItemStack stack) - { - EnumColor color = getColor(stack); + @Override + public String getItemStackDisplayName(ItemStack stack) { + EnumColor color = getColor(stack); String dyeName = color.getDyedName(); - if(StatCollector.canTranslate(getUnlocalizedName(stack) + "." + color.dyeName)) - { + if (StatCollector.canTranslate(getUnlocalizedName(stack) + "." + color.dyeName)) { return LangUtils.localize(getUnlocalizedName(stack) + "." + color.dyeName); } - if(getColor(stack) == EnumColor.BLACK) - { - dyeName = EnumColor.DARK_GREY + color.getDyeName(); - } + if (getColor(stack) == EnumColor.BLACK) { + dyeName = EnumColor.DARK_GREY + color.getDyeName(); + } - return dyeName + " " + LangUtils.localize("tooltip.balloon"); - } + return dyeName + " " + LangUtils.localize("tooltip.balloon"); + } - @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) - { - if(player.isSneaking()) - { - AxisAlignedBB bound = AxisAlignedBB.getBoundingBox(x, y, z, x+1, y+3, z+1); + @Override + public boolean onItemUse( + ItemStack stack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int side, + float hitX, + float hitY, + float hitZ + ) { + if (player.isSneaking()) { + AxisAlignedBB bound + = AxisAlignedBB.getBoundingBox(x, y, z, x + 1, y + 3, z + 1); - List balloonsNear = player.worldObj.getEntitiesWithinAABB(EntityBalloon.class, bound); + List balloonsNear + = player.worldObj.getEntitiesWithinAABB(EntityBalloon.class, bound); - if(balloonsNear.size() > 0) - { - return true; - } + if (balloonsNear.size() > 0) { + return true; + } - Coord4D obj = new Coord4D(x, y, z, world.provider.dimensionId); + Coord4D obj = new Coord4D(x, y, z, world.provider.dimensionId); - if(obj.getBlock(world).isReplaceable(world, x, y, z)) - { - obj.yCoord--; - } - - if(!world.isSideSolid(x, y, z, ForgeDirection.UP)) - { - return true; - } + if (obj.getBlock(world).isReplaceable(world, x, y, z)) { + obj.yCoord--; + } - if(canReplace(world, obj.xCoord, obj.yCoord+1, obj.zCoord) && canReplace(world, obj.xCoord, obj.yCoord+2, obj.zCoord)) - { - world.setBlockToAir(obj.xCoord, obj.yCoord+1, obj.zCoord); - world.setBlockToAir(obj.xCoord, obj.yCoord+2, obj.zCoord); + if (!world.isSideSolid(x, y, z, ForgeDirection.UP)) { + return true; + } - if(!world.isRemote) - { - world.spawnEntityInWorld(new EntityBalloon(world, obj, getColor(stack))); - stack.stackSize--; - } - } + if (canReplace(world, obj.xCoord, obj.yCoord + 1, obj.zCoord) + && canReplace(world, obj.xCoord, obj.yCoord + 2, obj.zCoord)) { + world.setBlockToAir(obj.xCoord, obj.yCoord + 1, obj.zCoord); + world.setBlockToAir(obj.xCoord, obj.yCoord + 2, obj.zCoord); - return true; - } + if (!world.isRemote) { + world.spawnEntityInWorld( + new EntityBalloon(world, obj, getColor(stack)) + ); + stack.stackSize--; + } + } - return false; - } + return true; + } - @Override - public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer player, EntityLivingBase entity) - { - if(player.isSneaking()) - { - if(!player.worldObj.isRemote) - { - AxisAlignedBB bound = AxisAlignedBB.getBoundingBox(entity.posX - 0.2, entity.posY - 0.5, entity.posZ - 0.2, entity.posX + 0.2, entity.posY + entity.ySize + 4, entity.posZ + 0.2); + return false; + } - List balloonsNear = player.worldObj.getEntitiesWithinAABB(EntityBalloon.class, bound); + @Override + public boolean itemInteractionForEntity( + ItemStack stack, EntityPlayer player, EntityLivingBase entity + ) { + if (player.isSneaking()) { + if (!player.worldObj.isRemote) { + AxisAlignedBB bound = AxisAlignedBB.getBoundingBox( + entity.posX - 0.2, + entity.posY - 0.5, + entity.posZ - 0.2, + entity.posX + 0.2, + entity.posY + entity.ySize + 4, + entity.posZ + 0.2 + ); - for(EntityBalloon balloon : balloonsNear) - { - if(balloon.latchedEntity == entity) - { - return true; - } - } + List balloonsNear + = player.worldObj.getEntitiesWithinAABB(EntityBalloon.class, bound); - player.worldObj.spawnEntityInWorld(new EntityBalloon(entity, getColor(stack))); - stack.stackSize--; - } + for (EntityBalloon balloon : balloonsNear) { + if (balloon.latchedEntity == entity) { + return true; + } + } - return true; - } + player.worldObj.spawnEntityInWorld( + new EntityBalloon(entity, getColor(stack)) + ); + stack.stackSize--; + } - return false; - } + return true; + } - private boolean canReplace(World world, int x, int y, int z) - { - return world.isAirBlock(x, y, z) || world.getBlock(x, y, z).isReplaceable(world, x, y, z); - } + return false; + } - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister register) {} - - public class DispenserBehavior extends BehaviorDefaultDispenseItem - { - @Override - public ItemStack dispenseStack(IBlockSource source, ItemStack stack) - { - Coord4D coord = new Coord4D(source.getXInt(), source.getYInt(), source.getZInt(), source.getWorld().provider.dimensionId); - ForgeDirection side = ForgeDirection.getOrientation(BlockDispenser.func_149937_b(source.getBlockMetadata()).ordinal()); + private boolean canReplace(World world, int x, int y, int z) { + return world.isAirBlock(x, y, z) + || world.getBlock(x, y, z).isReplaceable(world, x, y, z); + } - List entities = source.getWorld().getEntitiesWithinAABB(EntityLivingBase.class, coord.getFromSide(side).getBoundingBox()); - boolean latched = false; - - for(EntityLivingBase entity : entities) - { - AxisAlignedBB bound = AxisAlignedBB.getBoundingBox(entity.posX - 0.2, entity.posY - 0.5, entity.posZ - 0.2, entity.posX + 0.2, entity.posY + entity.ySize + 4, entity.posZ + 0.2); + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister register) {} - List balloonsNear = source.getWorld().getEntitiesWithinAABB(EntityBalloon.class, bound); - boolean hasBalloon = false; - - for(EntityBalloon balloon : balloonsNear) - { - if(balloon.latchedEntity == entity) - { - hasBalloon = true; - } - } - - if(!hasBalloon) - { - source.getWorld().spawnEntityInWorld(new EntityBalloon(entity, getColor(stack))); - latched = true; - } - } - - if(!latched) - { - Pos3D pos = new Pos3D(coord); - - switch(side) - { - case DOWN: - pos.translate(0, -2.5, 0); - break; - case UP: - pos.translate(0, 0, 0); - break; - case NORTH: - pos.translate(0, -1, -0.5); - break; - case SOUTH: - pos.translate(0, -1, 0.5); - break; - case WEST: - pos.translate(-0.5, -1, 0); - break; - case EAST: - pos.translate(0.5, -1, 0); - break; - default: - break; - } - - if(!source.getWorld().isRemote) - { - source.getWorld().spawnEntityInWorld(new EntityBalloon(source.getWorld(), pos.xPos, pos.yPos, pos.zPos, getColor(stack))); - } - } - - stack.stackSize--; - return stack; - } - } + public class DispenserBehavior extends BehaviorDefaultDispenseItem { + @Override + public ItemStack dispenseStack(IBlockSource source, ItemStack stack) { + Coord4D coord = new Coord4D( + source.getXInt(), + source.getYInt(), + source.getZInt(), + source.getWorld().provider.dimensionId + ); + ForgeDirection side = ForgeDirection.getOrientation( + BlockDispenser.func_149937_b(source.getBlockMetadata()).ordinal() + ); + + List entities = source.getWorld().getEntitiesWithinAABB( + EntityLivingBase.class, coord.getFromSide(side).getBoundingBox() + ); + boolean latched = false; + + for (EntityLivingBase entity : entities) { + AxisAlignedBB bound = AxisAlignedBB.getBoundingBox( + entity.posX - 0.2, + entity.posY - 0.5, + entity.posZ - 0.2, + entity.posX + 0.2, + entity.posY + entity.ySize + 4, + entity.posZ + 0.2 + ); + + List balloonsNear + = source.getWorld().getEntitiesWithinAABB(EntityBalloon.class, bound); + boolean hasBalloon = false; + + for (EntityBalloon balloon : balloonsNear) { + if (balloon.latchedEntity == entity) { + hasBalloon = true; + } + } + + if (!hasBalloon) { + source.getWorld().spawnEntityInWorld( + new EntityBalloon(entity, getColor(stack)) + ); + latched = true; + } + } + + if (!latched) { + Pos3D pos = new Pos3D(coord); + + switch (side) { + case DOWN: + pos.translate(0, -2.5, 0); + break; + case UP: + pos.translate(0, 0, 0); + break; + case NORTH: + pos.translate(0, -1, -0.5); + break; + case SOUTH: + pos.translate(0, -1, 0.5); + break; + case WEST: + pos.translate(-0.5, -1, 0); + break; + case EAST: + pos.translate(0.5, -1, 0); + break; + default: + break; + } + + if (!source.getWorld().isRemote) { + source.getWorld().spawnEntityInWorld(new EntityBalloon( + source.getWorld(), pos.xPos, pos.yPos, pos.zPos, getColor(stack) + )); + } + } + + stack.stackSize--; + return stack; + } + } } diff --git a/src/main/java/mekanism/common/item/ItemBlockBasic.java b/src/main/java/mekanism/common/item/ItemBlockBasic.java index cfa7dcb33..2de2d5483 100644 --- a/src/main/java/mekanism/common/item/ItemBlockBasic.java +++ b/src/main/java/mekanism/common/item/ItemBlockBasic.java @@ -3,6 +3,8 @@ package mekanism.common.item; import java.util.ArrayList; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.Range4D; @@ -35,8 +37,6 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; /** * Item class for handling multiple metal block IDs. @@ -69,307 +69,322 @@ import cpw.mods.fml.relauncher.SideOnly; * @author AidanBrady * */ -public class ItemBlockBasic extends ItemBlock implements IEnergizedItem, ITierItem -{ - public Block metaBlock; +public class ItemBlockBasic extends ItemBlock implements IEnergizedItem, ITierItem { + public Block metaBlock; - public ItemBlockBasic(Block block) - { - super(block); - metaBlock = block; - setHasSubtypes(true); - } - - @Override - public int getItemStackLimit(ItemStack stack) - { - if(BasicType.get(stack) == BasicType.BIN) - { - return 1; - } - - return super.getItemStackLimit(stack); + public ItemBlockBasic(Block block) { + super(block); + metaBlock = block; + setHasSubtypes(true); } - - public ItemStack getUnchargedCell(InductionCellTier tier) - { - ItemStack stack = new ItemStack(MekanismBlocks.BasicBlock2, 1, 3); - setBaseTier(stack, tier.getBaseTier()); - - return stack; - } - - public ItemStack getUnchargedProvider(InductionProviderTier tier) - { - ItemStack stack = new ItemStack(MekanismBlocks.BasicBlock2, 1, 4); - setBaseTier(stack, tier.getBaseTier()); - - return stack; - } - - @Override - public BaseTier getBaseTier(ItemStack itemstack) - { - if(itemstack.stackTagCompound == null) - { - return BaseTier.BASIC; - } - return BaseTier.values()[itemstack.stackTagCompound.getInteger("tier")]; - } + @Override + public int getItemStackLimit(ItemStack stack) { + if (BasicType.get(stack) == BasicType.BIN) { + return 1; + } - @Override - public void setBaseTier(ItemStack itemstack, BaseTier tier) - { - if(itemstack.stackTagCompound == null) - { - itemstack.setTagCompound(new NBTTagCompound()); - } + return super.getItemStackLimit(stack); + } - itemstack.stackTagCompound.setInteger("tier", tier.ordinal()); - } + public ItemStack getUnchargedCell(InductionCellTier tier) { + ItemStack stack = new ItemStack(MekanismBlocks.BasicBlock2, 1, 3); + setBaseTier(stack, tier.getBaseTier()); - @Override - public int getMetadata(int i) - { - return i; - } + return stack; + } - @Override - public IIcon getIconFromDamage(int i) - { - return metaBlock.getIcon(2, i); - } + public ItemStack getUnchargedProvider(InductionProviderTier tier) { + ItemStack stack = new ItemStack(MekanismBlocks.BasicBlock2, 1, 4); + setBaseTier(stack, tier.getBaseTier()); - @Override - @SideOnly(Side.CLIENT) - public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) - { - BasicType type = BasicType.get(itemstack); - - if(type.hasDescription) - { - if(!MekKeyHandler.getIsKeyPressed(MekanismKeyHandler.sneakKey)) - { - if(type == BasicType.BIN) - { - InventoryBin inv = new InventoryBin(itemstack); - - if(inv.getItemCount() > 0) - { - list.add(EnumColor.BRIGHT_GREEN + inv.getItemType().getDisplayName()); - list.add(EnumColor.PURPLE + LangUtils.localize("tooltip.itemAmount") + ": " + EnumColor.GREY + inv.getItemCount()); - } - else { - list.add(EnumColor.DARK_RED + LangUtils.localize("gui.empty")); - } - - list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.capacity") + ": " + EnumColor.GREY + BinTier.values()[getBaseTier(itemstack).ordinal()].storage + " " + LangUtils.localize("transmission.Items")); - } - else if(type == BasicType.INDUCTION_CELL) - { - InductionCellTier tier = InductionCellTier.values()[getBaseTier(itemstack).ordinal()]; - - list.add(tier.getBaseTier().getColor() + LangUtils.localize("tooltip.capacity") + ": " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(tier.maxEnergy)); - } - else if(type == BasicType.INDUCTION_PROVIDER) - { - InductionProviderTier tier = InductionProviderTier.values()[getBaseTier(itemstack).ordinal()]; - - list.add(tier.getBaseTier().getColor() + LangUtils.localize("tooltip.outputRate") + ": " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(tier.output)); - } - - if(getMaxEnergy(itemstack) > 0) - { - list.add(EnumColor.BRIGHT_GREEN + LangUtils.localize("tooltip.storedEnergy") + ": " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(getEnergy(itemstack))); - } - - list.add(LangUtils.localize("tooltip.hold") + " " + EnumColor.INDIGO + GameSettings.getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode()) + EnumColor.GREY + " " + LangUtils.localize("tooltip.forDetails") + "."); - } - else { - list.addAll(MekanismUtils.splitTooltip(type.getDescription(), itemstack)); - } - } - } + return stack; + } - @Override - public boolean hasContainerItem(ItemStack stack) - { - return BasicType.get(stack) == BasicType.BIN && stack.stackTagCompound != null && stack.stackTagCompound.hasKey("newCount"); - } + @Override + public BaseTier getBaseTier(ItemStack itemstack) { + if (itemstack.stackTagCompound == null) { + return BaseTier.BASIC; + } - @Override - public boolean doesContainerItemLeaveCraftingGrid(ItemStack stack) - { - if(BasicType.get(stack) != BasicType.BIN) - { - return true; - } + return BaseTier.values()[itemstack.stackTagCompound.getInteger("tier")]; + } - return false; - } + @Override + public void setBaseTier(ItemStack itemstack, BaseTier tier) { + if (itemstack.stackTagCompound == null) { + itemstack.setTagCompound(new NBTTagCompound()); + } - @Override - public ItemStack getContainerItem(ItemStack stack) - { - if(BasicType.get(stack) == BasicType.BIN) - { - if(stack.stackTagCompound == null || !stack.stackTagCompound.hasKey("newCount")) - { - return null; - } - - int newCount = stack.stackTagCompound.getInteger("newCount"); - stack.stackTagCompound.removeTag("newCount"); + itemstack.stackTagCompound.setInteger("tier", tier.ordinal()); + } + + @Override + public int getMetadata(int i) { + return i; + } + + @Override + public IIcon getIconFromDamage(int i) { + return metaBlock.getIcon(2, i); + } + + @Override + @SideOnly(Side.CLIENT) + public void addInformation( + ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag + ) { + BasicType type = BasicType.get(itemstack); + + if (type.hasDescription) { + if (!MekKeyHandler.getIsKeyPressed(MekanismKeyHandler.sneakKey)) { + if (type == BasicType.BIN) { + InventoryBin inv = new InventoryBin(itemstack); + + if (inv.getItemCount() > 0) { + list.add( + EnumColor.BRIGHT_GREEN + inv.getItemType().getDisplayName() + ); + list.add( + EnumColor.PURPLE + LangUtils.localize("tooltip.itemAmount") + + ": " + EnumColor.GREY + inv.getItemCount() + ); + } else { + list.add(EnumColor.DARK_RED + LangUtils.localize("gui.empty")); + } + + list.add( + EnumColor.INDIGO + LangUtils.localize("tooltip.capacity") + ": " + + EnumColor.GREY + + BinTier.values()[getBaseTier(itemstack).ordinal()].storage + " " + + LangUtils.localize("transmission.Items") + ); + } else if (type == BasicType.INDUCTION_CELL) { + InductionCellTier tier + = InductionCellTier.values()[getBaseTier(itemstack).ordinal()]; + + list.add( + tier.getBaseTier().getColor() + + LangUtils.localize("tooltip.capacity") + ": " + EnumColor.GREY + + MekanismUtils.getEnergyDisplay(tier.maxEnergy) + ); + } else if (type == BasicType.INDUCTION_PROVIDER) { + InductionProviderTier tier = InductionProviderTier.values( + )[getBaseTier(itemstack).ordinal()]; + + list.add( + tier.getBaseTier().getColor() + + LangUtils.localize("tooltip.outputRate") + ": " + EnumColor.GREY + + MekanismUtils.getEnergyDisplay(tier.output) + ); + } + + if (getMaxEnergy(itemstack) > 0) { + list.add( + EnumColor.BRIGHT_GREEN + + LangUtils.localize("tooltip.storedEnergy") + ": " + + EnumColor.GREY + + MekanismUtils.getEnergyDisplay(getEnergy(itemstack)) + ); + } + + list.add( + LangUtils.localize("tooltip.hold") + " " + EnumColor.INDIGO + + GameSettings.getKeyDisplayString( + MekanismKeyHandler.sneakKey.getKeyCode() + ) + + EnumColor.GREY + " " + LangUtils.localize("tooltip.forDetails") + + "." + ); + } else { + list.addAll(MekanismUtils.splitTooltip(type.getDescription(), itemstack)); + } + } + } + + @Override + public boolean hasContainerItem(ItemStack stack) { + return BasicType.get(stack) == BasicType.BIN && stack.stackTagCompound != null + && stack.stackTagCompound.hasKey("newCount"); + } + + @Override + public boolean doesContainerItemLeaveCraftingGrid(ItemStack stack) { + if (BasicType.get(stack) != BasicType.BIN) { + return true; + } + + return false; + } + + @Override + public ItemStack getContainerItem(ItemStack stack) { + if (BasicType.get(stack) == BasicType.BIN) { + if (stack.stackTagCompound == null + || !stack.stackTagCompound.hasKey("newCount")) { + return null; + } + + int newCount = stack.stackTagCompound.getInteger("newCount"); + stack.stackTagCompound.removeTag("newCount"); ItemStack ret = stack.copy(); ret.stackTagCompound.setInteger("itemCount", newCount); return ret; - } + } - return null; - } + return null; + } - @Override - public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) - { - boolean place = true; - - BasicType type = BasicType.get(stack); - - if(type == BasicType.SECURITY_DESK) - { - if(y+1 > 255 || !world.getBlock(x, y+1, z).isReplaceable(world, x, y+1, z)) - { - place = false; - } - } + @Override + public boolean placeBlockAt( + ItemStack stack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int side, + float hitX, + float hitY, + float hitZ, + int metadata + ) { + boolean place = true; - if(place && super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata)) - { - if(type == BasicType.BIN && stack.stackTagCompound != null) - { - TileEntityBin tileEntity = (TileEntityBin)world.getTileEntity(x, y, z); - InventoryBin inv = new InventoryBin(stack); - - tileEntity.tier = BinTier.values()[getBaseTier(stack).ordinal()]; + BasicType type = BasicType.get(stack); - if(inv.getItemType() != null) - { - tileEntity.setItemType(inv.getItemType()); - } + if (type == BasicType.SECURITY_DESK) { + if (y + 1 > 255 + || !world.getBlock(x, y + 1, z).isReplaceable(world, x, y + 1, z)) { + place = false; + } + } - tileEntity.setItemCount(inv.getItemCount()); - } - else if(type == BasicType.INDUCTION_CELL) - { - TileEntityInductionCell tileEntity = (TileEntityInductionCell)world.getTileEntity(x, y, z); - tileEntity.tier = InductionCellTier.values()[getBaseTier(stack).ordinal()]; - - if(!world.isRemote) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tileEntity), tileEntity.getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(tileEntity))); - } - } - else if(type == BasicType.INDUCTION_PROVIDER) - { - TileEntityInductionProvider tileEntity = (TileEntityInductionProvider)world.getTileEntity(x, y, z); - tileEntity.tier = InductionProviderTier.values()[getBaseTier(stack).ordinal()]; - - if(!world.isRemote) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tileEntity), tileEntity.getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(tileEntity))); - } - } - - TileEntity tileEntity = world.getTileEntity(x, y, z); - - if(tileEntity instanceof IStrictEnergyStorage && !(tileEntity instanceof TileEntityMultiblock)) - { - ((IStrictEnergyStorage)tileEntity).setEnergy(getEnergy(stack)); - } - } + if (place + && super.placeBlockAt( + stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata + )) { + if (type == BasicType.BIN && stack.stackTagCompound != null) { + TileEntityBin tileEntity = (TileEntityBin) world.getTileEntity(x, y, z); + InventoryBin inv = new InventoryBin(stack); - return place; - } - - @Override - public String getUnlocalizedName(ItemStack itemstack) - { - BasicType type = BasicType.get(itemstack); - - if(type != null) - { - String name = getUnlocalizedName() + "." + BasicType.get(itemstack).name; - - if(type == BasicType.BIN || type == BasicType.INDUCTION_CELL || type == BasicType.INDUCTION_PROVIDER) - { - name += getBaseTier(itemstack).getName(); - } - - return name; - } + tileEntity.tier = BinTier.values()[getBaseTier(stack).ordinal()]; - return "null"; - } - - @Override - public double getEnergy(ItemStack itemStack) - { - if(BasicType.get(itemStack) == BasicType.INDUCTION_CELL) - { - if(itemStack.stackTagCompound == null) - { - return 0; - } - - return itemStack.stackTagCompound.getDouble("energyStored"); - } - - return 0; - } + if (inv.getItemType() != null) { + tileEntity.setItemType(inv.getItemType()); + } - @Override - public void setEnergy(ItemStack itemStack, double amount) - { - if(BasicType.get(itemStack) == BasicType.INDUCTION_CELL) - { - if(itemStack.stackTagCompound == null) - { - itemStack.setTagCompound(new NBTTagCompound()); - } - - itemStack.stackTagCompound.setDouble("energyStored", Math.max(Math.min(amount, getMaxEnergy(itemStack)), 0)); - } - } + tileEntity.setItemCount(inv.getItemCount()); + } else if (type == BasicType.INDUCTION_CELL) { + TileEntityInductionCell tileEntity + = (TileEntityInductionCell) world.getTileEntity(x, y, z); + tileEntity.tier + = InductionCellTier.values()[getBaseTier(stack).ordinal()]; - @Override - public double getMaxEnergy(ItemStack itemStack) - { - if(BasicType.get(itemStack) == BasicType.INDUCTION_CELL) - { - return InductionCellTier.values()[getBaseTier(itemStack).ordinal()].maxEnergy; - } - - return 0; - } + if (!world.isRemote) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(tileEntity), + tileEntity.getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(tileEntity)) + ); + } + } else if (type == BasicType.INDUCTION_PROVIDER) { + TileEntityInductionProvider tileEntity + = (TileEntityInductionProvider) world.getTileEntity(x, y, z); + tileEntity.tier + = InductionProviderTier.values()[getBaseTier(stack).ordinal()]; - @Override - public double getMaxTransfer(ItemStack itemStack) - { - return 0; - } + if (!world.isRemote) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(tileEntity), + tileEntity.getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(tileEntity)) + ); + } + } - @Override - public boolean canReceive(ItemStack itemStack) - { - return false; - } + TileEntity tileEntity = world.getTileEntity(x, y, z); - @Override - public boolean canSend(ItemStack itemStack) - { - return false; - } + if (tileEntity instanceof IStrictEnergyStorage + && !(tileEntity instanceof TileEntityMultiblock) ) { + ((IStrictEnergyStorage) tileEntity).setEnergy(getEnergy(stack)); + } + } + + return place; + } + + @Override + public String getUnlocalizedName(ItemStack itemstack) { + BasicType type = BasicType.get(itemstack); + + if (type != null) { + String name = getUnlocalizedName() + "." + BasicType.get(itemstack).name; + + if (type == BasicType.BIN || type == BasicType.INDUCTION_CELL + || type == BasicType.INDUCTION_PROVIDER) { + name += getBaseTier(itemstack).getName(); + } + + return name; + } + + return "null"; + } + + @Override + public double getEnergy(ItemStack itemStack) { + if (BasicType.get(itemStack) == BasicType.INDUCTION_CELL) { + if (itemStack.stackTagCompound == null) { + return 0; + } + + return itemStack.stackTagCompound.getDouble("energyStored"); + } + + return 0; + } + + @Override + public void setEnergy(ItemStack itemStack, double amount) { + if (BasicType.get(itemStack) == BasicType.INDUCTION_CELL) { + if (itemStack.stackTagCompound == null) { + itemStack.setTagCompound(new NBTTagCompound()); + } + + itemStack.stackTagCompound.setDouble( + "energyStored", Math.max(Math.min(amount, getMaxEnergy(itemStack)), 0) + ); + } + } + + @Override + public double getMaxEnergy(ItemStack itemStack) { + if (BasicType.get(itemStack) == BasicType.INDUCTION_CELL) { + return InductionCellTier.values()[getBaseTier(itemStack).ordinal()].maxEnergy; + } + + return 0; + } + + @Override + public double getMaxTransfer(ItemStack itemStack) { + return 0; + } + + @Override + public boolean canReceive(ItemStack itemStack) { + return false; + } + + @Override + public boolean canSend(ItemStack itemStack) { + return false; + } } diff --git a/src/main/java/mekanism/common/item/ItemBlockCardboardBox.java b/src/main/java/mekanism/common/item/ItemBlockCardboardBox.java index 2473f140c..1ddd97d4c 100644 --- a/src/main/java/mekanism/common/item/ItemBlockCardboardBox.java +++ b/src/main/java/mekanism/common/item/ItemBlockCardboardBox.java @@ -2,6 +2,9 @@ package mekanism.common.item; import java.util.List; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.EnumColor; import mekanism.api.MekanismAPI; import mekanism.common.MekanismBlocks; @@ -20,152 +23,173 @@ import net.minecraft.util.IIcon; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.EntityJoinWorldEvent; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class ItemBlockCardboardBox extends ItemBlock -{ - private static boolean isMonitoring; +public class ItemBlockCardboardBox extends ItemBlock { + private static boolean isMonitoring; - public Block metaBlock; + public Block metaBlock; - public ItemBlockCardboardBox(Block block) - { - super(block); - setMaxStackSize(1); - metaBlock = block; + public ItemBlockCardboardBox(Block block) { + super(block); + setMaxStackSize(1); + metaBlock = block; - MinecraftForge.EVENT_BUS.register(this); - } + MinecraftForge.EVENT_BUS.register(this); + } - @Override - @SideOnly(Side.CLIENT) - public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) - { - list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.blockData") + ": " + LangUtils.transYesNo(getBlockData(itemstack) != null)); + @Override + @SideOnly(Side.CLIENT) + public void addInformation( + ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag + ) { + list.add( + EnumColor.INDIGO + LangUtils.localize("tooltip.blockData") + ": " + + LangUtils.transYesNo(getBlockData(itemstack) != null) + ); - if(getBlockData(itemstack) != null) - { - list.add(LangUtils.localize("tooltip.block") + ": " + new ItemStack(getBlockData(itemstack).block, getBlockData(itemstack).meta).getDisplayName()); - list.add(LangUtils.localize("tooltip.meta") + ": " + getBlockData(itemstack).meta); + if (getBlockData(itemstack) != null) { + list.add( + LangUtils.localize("tooltip.block") + ": " + + new ItemStack( + getBlockData(itemstack).block, getBlockData(itemstack).meta + ) + .getDisplayName() + ); + list.add( + LangUtils.localize("tooltip.meta") + ": " + getBlockData(itemstack).meta + ); - if(getBlockData(itemstack).tileTag != null) - { - list.add(LangUtils.localize("tooltip.tile") + ": " + getBlockData(itemstack).tileTag.getString("id")); - } - } - } + if (getBlockData(itemstack).tileTag != null) { + list.add( + LangUtils.localize("tooltip.tile") + ": " + + getBlockData(itemstack).tileTag.getString("id") + ); + } + } + } - @Override - public int getMetadata(int i) - { - return i; - } + @Override + public int getMetadata(int i) { + return i; + } - @Override - public IIcon getIconFromDamage(int i) - { - return metaBlock.getIcon(2, i); - } + @Override + public IIcon getIconFromDamage(int i) { + return metaBlock.getIcon(2, i); + } - @Override - public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) - { - if(!player.isSneaking() && !world.isAirBlock(x, y, z) && stack.getItemDamage() == 0) - { - Block block = world.getBlock(x, y, z); - int meta = world.getBlockMetadata(x, y, z); + @Override + public boolean onItemUseFirst( + ItemStack stack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int side, + float hitX, + float hitY, + float hitZ + ) { + if (!player.isSneaking() && !world.isAirBlock(x, y, z) + && stack.getItemDamage() == 0) { + Block block = world.getBlock(x, y, z); + int meta = world.getBlockMetadata(x, y, z); - if(!world.isRemote && MekanismAPI.isBlockCompatible(Item.getItemFromBlock(block), meta) && block.getBlockHardness(world, x, y, z) != -1) - { - BlockData data = new BlockData(); - data.block = block; - data.meta = meta; + if (!world.isRemote + && MekanismAPI.isBlockCompatible(Item.getItemFromBlock(block), meta) + && block.getBlockHardness(world, x, y, z) != -1) { + BlockData data = new BlockData(); + data.block = block; + data.meta = meta; - isMonitoring = true; + isMonitoring = true; - if(world.getTileEntity(x, y, z) != null) - { - TileEntity tile = world.getTileEntity(x, y, z); - NBTTagCompound tag = new NBTTagCompound(); + if (world.getTileEntity(x, y, z) != null) { + TileEntity tile = world.getTileEntity(x, y, z); + NBTTagCompound tag = new NBTTagCompound(); - tile.writeToNBT(tag); - data.tileTag = tag; - } + tile.writeToNBT(tag); + data.tileTag = tag; + } - if(!player.capabilities.isCreativeMode) - { - stack.stackSize--; - } + if (!player.capabilities.isCreativeMode) { + stack.stackSize--; + } - world.setBlock(x, y, z, MekanismBlocks.CardboardBox, 1, 3); + world.setBlock(x, y, z, MekanismBlocks.CardboardBox, 1, 3); - isMonitoring = false; + isMonitoring = false; - TileEntityCardboardBox tileEntity = (TileEntityCardboardBox)world.getTileEntity(x, y, z); + TileEntityCardboardBox tileEntity + = (TileEntityCardboardBox) world.getTileEntity(x, y, z); - if(tileEntity != null) - { - tileEntity.storedData = data; - } + if (tileEntity != null) { + tileEntity.storedData = data; + } - return true; - } - } + return true; + } + } - return false; - } + return false; + } - @Override - public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) - { - if(world.isRemote) - { - return true; - } + @Override + public boolean placeBlockAt( + ItemStack stack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int side, + float hitX, + float hitY, + float hitZ, + int metadata + ) { + if (world.isRemote) { + return true; + } - boolean place = super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata); + boolean place = super.placeBlockAt( + stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata + ); - if(place) - { - TileEntityCardboardBox tileEntity = (TileEntityCardboardBox)world.getTileEntity(x, y, z); + if (place) { + TileEntityCardboardBox tileEntity + = (TileEntityCardboardBox) world.getTileEntity(x, y, z); - if(tileEntity != null) - { - tileEntity.storedData = getBlockData(stack); - } - } + if (tileEntity != null) { + tileEntity.storedData = getBlockData(stack); + } + } - return place; - } + return place; + } - public void setBlockData(ItemStack itemstack, BlockData data) - { - if(itemstack.stackTagCompound == null) - { - itemstack.setTagCompound(new NBTTagCompound()); - } + public void setBlockData(ItemStack itemstack, BlockData data) { + if (itemstack.stackTagCompound == null) { + itemstack.setTagCompound(new NBTTagCompound()); + } - itemstack.stackTagCompound.setTag("blockData", data.write(new NBTTagCompound())); - } + itemstack.stackTagCompound.setTag("blockData", data.write(new NBTTagCompound())); + } - public BlockData getBlockData(ItemStack itemstack) - { - if(itemstack.stackTagCompound == null || !itemstack.stackTagCompound.hasKey("blockData")) - { - return null; - } + public BlockData getBlockData(ItemStack itemstack) { + if (itemstack.stackTagCompound == null + || !itemstack.stackTagCompound.hasKey("blockData")) { + return null; + } - return BlockData.read(itemstack.stackTagCompound.getCompoundTag("blockData")); - } + return BlockData.read(itemstack.stackTagCompound.getCompoundTag("blockData")); + } - @SubscribeEvent - public void onEntitySpawn(EntityJoinWorldEvent event) - { - if(event.entity instanceof EntityItem && isMonitoring) - { - event.setCanceled(true); - } - } + @SubscribeEvent + public void onEntitySpawn(EntityJoinWorldEvent event) { + if (event.entity instanceof EntityItem && isMonitoring) { + event.setCanceled(true); + } + } } diff --git a/src/main/java/mekanism/common/item/ItemBlockEnergyCube.java b/src/main/java/mekanism/common/item/ItemBlockEnergyCube.java index d467beb84..b58357296 100644 --- a/src/main/java/mekanism/common/item/ItemBlockEnergyCube.java +++ b/src/main/java/mekanism/common/item/ItemBlockEnergyCube.java @@ -1,11 +1,16 @@ package mekanism.common.item; -import ic2.api.item.IElectricItemManager; -import ic2.api.item.ISpecialElectricItem; - import java.util.ArrayList; import java.util.List; +import cofh.api.energy.IEnergyContainerItem; +import cpw.mods.fml.common.Optional.Interface; +import cpw.mods.fml.common.Optional.InterfaceList; +import cpw.mods.fml.common.Optional.Method; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ic2.api.item.IElectricItemManager; +import ic2.api.item.ISpecialElectricItem; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.MekanismConfig.general; @@ -36,391 +41,375 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.world.World; import net.minecraftforge.common.util.Constants.NBT; -import cofh.api.energy.IEnergyContainerItem; -import cpw.mods.fml.common.Optional.Interface; -import cpw.mods.fml.common.Optional.InterfaceList; -import cpw.mods.fml.common.Optional.Method; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -@InterfaceList({ - @Interface(iface = "ic2.api.item.ISpecialElectricItem", modid = "IC2") -}) -public class ItemBlockEnergyCube extends ItemBlock implements IEnergizedItem, IEnergyCube, ISpecialElectricItem, ISustainedInventory, IEnergyContainerItem, ISecurityItem -{ - public Block metaBlock; +@InterfaceList({ @Interface(iface = "ic2.api.item.ISpecialElectricItem", modid = "IC2") }) +public class ItemBlockEnergyCube extends ItemBlock + implements IEnergizedItem, IEnergyCube, ISpecialElectricItem, ISustainedInventory, + IEnergyContainerItem, ISecurityItem { + public Block metaBlock; - public ItemBlockEnergyCube(Block block) - { - super(block); - metaBlock = block; - setMaxStackSize(1); - setNoRepair(); - setCreativeTab(Mekanism.tabMekanism); - } + public ItemBlockEnergyCube(Block block) { + super(block); + metaBlock = block; + setMaxStackSize(1); + setNoRepair(); + setCreativeTab(Mekanism.tabMekanism); + } - @Override - @SideOnly(Side.CLIENT) - public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) - { - list.add(EnumColor.BRIGHT_GREEN + LangUtils.localize("tooltip.storedEnergy") + ": " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(getEnergy(itemstack))); - list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.capacity") + ": " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(getEnergyCubeTier(itemstack).maxEnergy)); - - if(!MekKeyHandler.getIsKeyPressed(MekanismKeyHandler.sneakKey)) - { - list.add(LangUtils.localize("tooltip.hold") + " " + EnumColor.AQUA + GameSettings.getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode()) + EnumColor.GREY + " " + LangUtils.localize("tooltip.forDetails") + "."); - } - else { - if(hasSecurity(itemstack)) - { - list.add(SecurityUtils.getOwnerDisplay(entityplayer.getCommandSenderName(), getOwner(itemstack))); - list.add(EnumColor.GREY + LangUtils.localize("gui.security") + ": " + SecurityUtils.getSecurityDisplay(itemstack, Side.CLIENT)); - - if(SecurityUtils.isOverridden(itemstack, Side.CLIENT)) - { - list.add(EnumColor.RED + "(" + LangUtils.localize("gui.overridden") + ")"); - } - } - - list.add(EnumColor.AQUA + LangUtils.localize("tooltip.inventory") + ": " + EnumColor.GREY + LangUtils.transYesNo(getInventory(itemstack) != null && getInventory(itemstack).tagCount() != 0)); - } - } + @Override + @SideOnly(Side.CLIENT) + public void addInformation( + ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag + ) { + list.add( + EnumColor.BRIGHT_GREEN + LangUtils.localize("tooltip.storedEnergy") + ": " + + EnumColor.GREY + MekanismUtils.getEnergyDisplay(getEnergy(itemstack)) + ); + list.add( + EnumColor.INDIGO + LangUtils.localize("tooltip.capacity") + ": " + + EnumColor.GREY + + MekanismUtils.getEnergyDisplay(getEnergyCubeTier(itemstack).maxEnergy) + ); - public ItemStack getUnchargedItem(EnergyCubeTier tier) - { - ItemStack stack = new ItemStack(this); - setEnergyCubeTier(stack, tier); - - return stack; - } - - @Override - public String getItemStackDisplayName(ItemStack itemstack) - { - return LangUtils.localize("tile.EnergyCube" + getEnergyCubeTier(itemstack).getBaseTier().getName() + ".name"); - } + if (!MekKeyHandler.getIsKeyPressed(MekanismKeyHandler.sneakKey)) { + list.add( + LangUtils.localize("tooltip.hold") + " " + EnumColor.AQUA + + GameSettings.getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode( + )) + + EnumColor.GREY + " " + LangUtils.localize("tooltip.forDetails") + "." + ); + } else { + if (hasSecurity(itemstack)) { + list.add(SecurityUtils.getOwnerDisplay( + entityplayer.getCommandSenderName(), getOwner(itemstack) + )); + list.add( + EnumColor.GREY + LangUtils.localize("gui.security") + ": " + + SecurityUtils.getSecurityDisplay(itemstack, Side.CLIENT) + ); - @Override - public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) - { - boolean place = super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata); + if (SecurityUtils.isOverridden(itemstack, Side.CLIENT)) { + list.add( + EnumColor.RED + "(" + LangUtils.localize("gui.overridden") + ")" + ); + } + } - if(place) - { - TileEntityEnergyCube tileEntity = (TileEntityEnergyCube)world.getTileEntity(x, y, z); - tileEntity.tier = ((IEnergyCube)stack.getItem()).getEnergyCubeTier(stack); - tileEntity.electricityStored = getEnergy(stack); - - if(tileEntity instanceof ISecurityTile) - { - ISecurityTile security = (ISecurityTile)tileEntity; - security.getSecurity().setOwner(getOwner(stack)); - - if(hasSecurity(stack)) - { - security.getSecurity().setMode(getSecurity(stack)); - } - - if(getOwner(stack) == null) - { - security.getSecurity().setOwner(player.getCommandSenderName()); - } - } + list.add( + EnumColor.AQUA + LangUtils.localize("tooltip.inventory") + ": " + + EnumColor.GREY + + LangUtils.transYesNo( + getInventory(itemstack) != null + && getInventory(itemstack).tagCount() != 0 + ) + ); + } + } - ((ISustainedInventory)tileEntity).setInventory(getInventory(stack)); + public ItemStack getUnchargedItem(EnergyCubeTier tier) { + ItemStack stack = new ItemStack(this); + setEnergyCubeTier(stack, tier); - if(!world.isRemote) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tileEntity), tileEntity.getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(tileEntity))); - } - } + return stack; + } - return place; - } + @Override + public String getItemStackDisplayName(ItemStack itemstack) { + return LangUtils.localize( + "tile.EnergyCube" + getEnergyCubeTier(itemstack).getBaseTier().getName() + + ".name" + ); + } - @Override - public EnergyCubeTier getEnergyCubeTier(ItemStack itemstack) - { - if(itemstack.stackTagCompound == null) - { - return EnergyCubeTier.BASIC; - } + @Override + public boolean placeBlockAt( + ItemStack stack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int side, + float hitX, + float hitY, + float hitZ, + int metadata + ) { + boolean place = super.placeBlockAt( + stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata + ); - if(itemstack.stackTagCompound.getString("tier") == null) - { - return EnergyCubeTier.BASIC; - } + if (place) { + TileEntityEnergyCube tileEntity + = (TileEntityEnergyCube) world.getTileEntity(x, y, z); + tileEntity.tier = ((IEnergyCube) stack.getItem()).getEnergyCubeTier(stack); + tileEntity.electricityStored = getEnergy(stack); - return EnergyCubeTier.getFromName(itemstack.stackTagCompound.getString("tier")); - } + if (tileEntity instanceof ISecurityTile) { + ISecurityTile security = (ISecurityTile) tileEntity; + security.getSecurity().setOwner(getOwner(stack)); - @Override - public void setEnergyCubeTier(ItemStack itemstack, EnergyCubeTier tier) - { - if(itemstack.stackTagCompound == null) - { - itemstack.setTagCompound(new NBTTagCompound()); - } + if (hasSecurity(stack)) { + security.getSecurity().setMode(getSecurity(stack)); + } - itemstack.stackTagCompound.setString("tier", tier.getBaseTier().getName()); - } + if (getOwner(stack) == null) { + security.getSecurity().setOwner(player.getCommandSenderName()); + } + } - @Override - @Method(modid = "IC2") - public boolean canProvideEnergy(ItemStack itemStack) - { - return true; - } + ((ISustainedInventory) tileEntity).setInventory(getInventory(stack)); - @Override - @Method(modid = "IC2") - public double getMaxCharge(ItemStack itemStack) - { - return 0; - } + if (!world.isRemote) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(tileEntity), + tileEntity.getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(tileEntity)) + ); + } + } - @Override - @Method(modid = "IC2") - public int getTier(ItemStack itemStack) - { - return 4; - } + return place; + } - @Override - @Method(modid = "IC2") - public double getTransferLimit(ItemStack itemStack) - { - return 0; - } + @Override + public EnergyCubeTier getEnergyCubeTier(ItemStack itemstack) { + if (itemstack.stackTagCompound == null) { + return EnergyCubeTier.BASIC; + } - @Override - public void setInventory(NBTTagList nbtTags, Object... data) - { - if(data[0] instanceof ItemStack) - { - ItemStack itemStack = (ItemStack)data[0]; + if (itemstack.stackTagCompound.getString("tier") == null) { + return EnergyCubeTier.BASIC; + } - if(itemStack.stackTagCompound == null) - { - itemStack.setTagCompound(new NBTTagCompound()); - } + return EnergyCubeTier.getFromName(itemstack.stackTagCompound.getString("tier")); + } - itemStack.stackTagCompound.setTag("Items", nbtTags); - } - } + @Override + public void setEnergyCubeTier(ItemStack itemstack, EnergyCubeTier tier) { + if (itemstack.stackTagCompound == null) { + itemstack.setTagCompound(new NBTTagCompound()); + } - @Override - public NBTTagList getInventory(Object... data) - { - if(data[0] instanceof ItemStack) - { - ItemStack itemStack = (ItemStack)data[0]; + itemstack.stackTagCompound.setString("tier", tier.getBaseTier().getName()); + } - if(itemStack.stackTagCompound == null) - { - return null; - } + @Override + @Method(modid = "IC2") + public boolean canProvideEnergy(ItemStack itemStack) { + return true; + } - return itemStack.stackTagCompound.getTagList("Items", NBT.TAG_COMPOUND); - } + @Override + @Method(modid = "IC2") + public double getMaxCharge(ItemStack itemStack) { + return 0; + } - return null; - } + @Override + @Method(modid = "IC2") + public int getTier(ItemStack itemStack) { + return 4; + } - @Override - public double getEnergy(ItemStack itemStack) - { - if(itemStack.stackTagCompound == null) - { - return 0; - } + @Override + @Method(modid = "IC2") + public double getTransferLimit(ItemStack itemStack) { + return 0; + } - return itemStack.stackTagCompound.getDouble("electricity"); - } + @Override + public void setInventory(NBTTagList nbtTags, Object... data) { + if (data[0] instanceof ItemStack) { + ItemStack itemStack = (ItemStack) data[0]; - @Override - public void setEnergy(ItemStack itemStack, double amount) - { - if(getEnergyCubeTier(itemStack) == EnergyCubeTier.CREATIVE && amount != Double.MAX_VALUE) - { - return; - } - - if(itemStack.stackTagCompound == null) - { - itemStack.setTagCompound(new NBTTagCompound()); - } + if (itemStack.stackTagCompound == null) { + itemStack.setTagCompound(new NBTTagCompound()); + } - double electricityStored = Math.max(Math.min(amount, getMaxEnergy(itemStack)), 0); - itemStack.stackTagCompound.setDouble("electricity", electricityStored); - } + itemStack.stackTagCompound.setTag("Items", nbtTags); + } + } - @Override - public double getMaxEnergy(ItemStack itemStack) - { - return getEnergyCubeTier(itemStack).maxEnergy; - } + @Override + public NBTTagList getInventory(Object... data) { + if (data[0] instanceof ItemStack) { + ItemStack itemStack = (ItemStack) data[0]; - @Override - public double getMaxTransfer(ItemStack itemStack) - { - return getMaxEnergy(itemStack)*0.005; - } + if (itemStack.stackTagCompound == null) { + return null; + } - @Override - public boolean canReceive(ItemStack itemStack) - { - return true; - } + return itemStack.stackTagCompound.getTagList("Items", NBT.TAG_COMPOUND); + } - @Override - public boolean canSend(ItemStack itemStack) - { - return true; - } + return null; + } - @Override - public int receiveEnergy(ItemStack theItem, int energy, boolean simulate) - { - if(canReceive(theItem)) - { - double energyNeeded = getMaxEnergy(theItem)-getEnergy(theItem); - double toReceive = Math.min(energy*general.FROM_TE, energyNeeded); + @Override + public double getEnergy(ItemStack itemStack) { + if (itemStack.stackTagCompound == null) { + return 0; + } - if(!simulate) - { - setEnergy(theItem, getEnergy(theItem) + toReceive); - } + return itemStack.stackTagCompound.getDouble("electricity"); + } - return (int)Math.round(toReceive*general.TO_TE); - } + @Override + public void setEnergy(ItemStack itemStack, double amount) { + if (getEnergyCubeTier(itemStack) == EnergyCubeTier.CREATIVE + && amount != Double.MAX_VALUE) { + return; + } - return 0; - } + if (itemStack.stackTagCompound == null) { + itemStack.setTagCompound(new NBTTagCompound()); + } - @Override - public int extractEnergy(ItemStack theItem, int energy, boolean simulate) - { - if(canSend(theItem)) - { - double energyRemaining = getEnergy(theItem); - double toSend = Math.min((energy*general.FROM_TE), energyRemaining); + double electricityStored = Math.max(Math.min(amount, getMaxEnergy(itemStack)), 0); + itemStack.stackTagCompound.setDouble("electricity", electricityStored); + } - if(!simulate) - { - setEnergy(theItem, getEnergy(theItem) - toSend); - } + @Override + public double getMaxEnergy(ItemStack itemStack) { + return getEnergyCubeTier(itemStack).maxEnergy; + } - return (int)Math.round(toSend*general.TO_TE); - } + @Override + public double getMaxTransfer(ItemStack itemStack) { + return getMaxEnergy(itemStack) * 0.005; + } - return 0; - } + @Override + public boolean canReceive(ItemStack itemStack) { + return true; + } - @Override - public int getEnergyStored(ItemStack theItem) - { - return (int)(getEnergy(theItem)*general.TO_TE); - } + @Override + public boolean canSend(ItemStack itemStack) { + return true; + } - @Override - public int getMaxEnergyStored(ItemStack theItem) - { - return (int)(getMaxEnergy(theItem)*general.TO_TE); - } + @Override + public int receiveEnergy(ItemStack theItem, int energy, boolean simulate) { + if (canReceive(theItem)) { + double energyNeeded = getMaxEnergy(theItem) - getEnergy(theItem); + double toReceive = Math.min(energy * general.FROM_TE, energyNeeded); - @Override - public boolean showDurabilityBar(ItemStack stack) - { - return true; - } - - @Override - public double getDurabilityForDisplay(ItemStack stack) - { - return 1D-(getEnergy(stack)/getMaxEnergy(stack)); - } + if (!simulate) { + setEnergy(theItem, getEnergy(theItem) + toReceive); + } - @Override - @Method(modid = "IC2") - public IElectricItemManager getManager(ItemStack itemStack) - { - return IC2ItemManager.getManager(this); - } + return (int) Math.round(toReceive * general.TO_TE); + } - @Override - @Method(modid = "IC2") - public Item getChargedItem(ItemStack itemStack) - { - return this; - } + return 0; + } - @Override - @Method(modid = "IC2") - public Item getEmptyItem(ItemStack itemStack) - { - return this; - } - - @Override - public String getOwner(ItemStack stack) - { - if(stack.stackTagCompound != null && stack.stackTagCompound.hasKey("owner")) - { - return stack.stackTagCompound.getString("owner"); - } - - return null; - } + @Override + public int extractEnergy(ItemStack theItem, int energy, boolean simulate) { + if (canSend(theItem)) { + double energyRemaining = getEnergy(theItem); + double toSend = Math.min((energy * general.FROM_TE), energyRemaining); - @Override - public void setOwner(ItemStack stack, String owner) - { - if(stack.stackTagCompound == null) - { - stack.setTagCompound(new NBTTagCompound()); - } - - if(owner == null || owner.isEmpty()) - { - stack.stackTagCompound.removeTag("owner"); - return; - } - - stack.stackTagCompound.setString("owner", owner); - } + if (!simulate) { + setEnergy(theItem, getEnergy(theItem) - toSend); + } - @Override - public SecurityMode getSecurity(ItemStack stack) - { - if(stack.stackTagCompound == null || !general.allowProtection) - { - return SecurityMode.PUBLIC; - } + return (int) Math.round(toSend * general.TO_TE); + } - return SecurityMode.values()[stack.stackTagCompound.getInteger("security")]; - } + return 0; + } - @Override - public void setSecurity(ItemStack stack, SecurityMode mode) - { - if(stack.stackTagCompound == null) - { - stack.setTagCompound(new NBTTagCompound()); - } - - stack.stackTagCompound.setInteger("security", mode.ordinal()); - } + @Override + public int getEnergyStored(ItemStack theItem) { + return (int) (getEnergy(theItem) * general.TO_TE); + } - @Override - public boolean hasSecurity(ItemStack stack) - { - return true; - } - - @Override - public boolean hasOwner(ItemStack stack) - { - return hasSecurity(stack); - } + @Override + public int getMaxEnergyStored(ItemStack theItem) { + return (int) (getMaxEnergy(theItem) * general.TO_TE); + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return true; + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) { + return 1D - (getEnergy(stack) / getMaxEnergy(stack)); + } + + @Override + @Method(modid = "IC2") + public IElectricItemManager getManager(ItemStack itemStack) { + return IC2ItemManager.getManager(this); + } + + @Override + @Method(modid = "IC2") + public Item getChargedItem(ItemStack itemStack) { + return this; + } + + @Override + @Method(modid = "IC2") + public Item getEmptyItem(ItemStack itemStack) { + return this; + } + + @Override + public String getOwner(ItemStack stack) { + if (stack.stackTagCompound != null && stack.stackTagCompound.hasKey("owner")) { + return stack.stackTagCompound.getString("owner"); + } + + return null; + } + + @Override + public void setOwner(ItemStack stack, String owner) { + if (stack.stackTagCompound == null) { + stack.setTagCompound(new NBTTagCompound()); + } + + if (owner == null || owner.isEmpty()) { + stack.stackTagCompound.removeTag("owner"); + return; + } + + stack.stackTagCompound.setString("owner", owner); + } + + @Override + public SecurityMode getSecurity(ItemStack stack) { + if (stack.stackTagCompound == null || !general.allowProtection) { + return SecurityMode.PUBLIC; + } + + return SecurityMode.values()[stack.stackTagCompound.getInteger("security")]; + } + + @Override + public void setSecurity(ItemStack stack, SecurityMode mode) { + if (stack.stackTagCompound == null) { + stack.setTagCompound(new NBTTagCompound()); + } + + stack.stackTagCompound.setInteger("security", mode.ordinal()); + } + + @Override + public boolean hasSecurity(ItemStack stack) { + return true; + } + + @Override + public boolean hasOwner(ItemStack stack) { + return hasSecurity(stack); + } } diff --git a/src/main/java/mekanism/common/item/ItemBlockGasTank.java b/src/main/java/mekanism/common/item/ItemBlockGasTank.java index 1f9be49f8..8cbb11490 100644 --- a/src/main/java/mekanism/common/item/ItemBlockGasTank.java +++ b/src/main/java/mekanism/common/item/ItemBlockGasTank.java @@ -3,6 +3,7 @@ package mekanism.common.item; import java.util.ArrayList; import java.util.List; +import cpw.mods.fml.relauncher.Side; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.MekanismConfig.general; @@ -37,370 +38,373 @@ import net.minecraft.nbt.NBTTagList; import net.minecraft.util.IIcon; import net.minecraft.world.World; import net.minecraftforge.common.util.Constants.NBT; -import cpw.mods.fml.relauncher.Side; -public class ItemBlockGasTank extends ItemBlock implements IGasItem, ISustainedInventory, ITierItem, ISecurityItem -{ - public Block metaBlock; +public class ItemBlockGasTank + extends ItemBlock implements IGasItem, ISustainedInventory, ITierItem, ISecurityItem { + public Block metaBlock; - /** The maximum amount of gas this tank can hold. */ - public int MAX_GAS = 96000; + /** The maximum amount of gas this tank can hold. */ + public int MAX_GAS = 96000; - /** How fast this tank can transfer gas. */ - public static final int TRANSFER_RATE = 256; + /** How fast this tank can transfer gas. */ + public static final int TRANSFER_RATE = 256; - public ItemBlockGasTank(Block block) - { - super(block); - metaBlock = block; - setHasSubtypes(true); - setMaxStackSize(1); - setCreativeTab(Mekanism.tabMekanism); - } + public ItemBlockGasTank(Block block) { + super(block); + metaBlock = block; + setHasSubtypes(true); + setMaxStackSize(1); + setCreativeTab(Mekanism.tabMekanism); + } - @Override - public int getMetadata(int i) - { - return i; - } + @Override + public int getMetadata(int i) { + return i; + } - @Override - public IIcon getIconFromDamage(int i) - { - return metaBlock.getIcon(2, i); - } - - @Override - public String getItemStackDisplayName(ItemStack itemstack) - { - return LangUtils.localize("tile.GasTank" + getBaseTier(itemstack).getName() + ".name"); - } + @Override + public IIcon getIconFromDamage(int i) { + return metaBlock.getIcon(2, i); + } - @Override - public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) - { - boolean place = super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata); + @Override + public String getItemStackDisplayName(ItemStack itemstack) { + return LangUtils.localize( + "tile.GasTank" + getBaseTier(itemstack).getName() + ".name" + ); + } - if(place) - { - TileEntityGasTank tileEntity = (TileEntityGasTank)world.getTileEntity(x, y, z); - tileEntity.tier = GasTankTier.values()[getBaseTier(stack).ordinal()]; - tileEntity.gasTank.setMaxGas(tileEntity.tier.storage); - tileEntity.gasTank.setGas(getGas(stack)); - - if(tileEntity instanceof ISecurityTile) - { - ISecurityTile security = (ISecurityTile)tileEntity; - security.getSecurity().setOwner(getOwner(stack)); - - if(hasSecurity(stack)) - { - security.getSecurity().setMode(getSecurity(stack)); - } - - if(getOwner(stack) == null) - { - security.getSecurity().setOwner(player.getCommandSenderName()); - } - } + @Override + public boolean placeBlockAt( + ItemStack stack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int side, + float hitX, + float hitY, + float hitZ, + int metadata + ) { + boolean place = super.placeBlockAt( + stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata + ); - ((ISustainedInventory)tileEntity).setInventory(getInventory(stack)); - - if(!world.isRemote) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tileEntity), tileEntity.getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(tileEntity))); - } - } + if (place) { + TileEntityGasTank tileEntity + = (TileEntityGasTank) world.getTileEntity(x, y, z); + tileEntity.tier = GasTankTier.values()[getBaseTier(stack).ordinal()]; + tileEntity.gasTank.setMaxGas(tileEntity.tier.storage); + tileEntity.gasTank.setGas(getGas(stack)); - return place; - } + if (tileEntity instanceof ISecurityTile) { + ISecurityTile security = (ISecurityTile) tileEntity; + security.getSecurity().setOwner(getOwner(stack)); - @Override - public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) - { - GasStack gasStack = getGas(itemstack); + if (hasSecurity(stack)) { + security.getSecurity().setMode(getSecurity(stack)); + } - if(gasStack == null) - { - list.add(EnumColor.DARK_RED + LangUtils.localize("gui.empty") + "."); - } - else { - list.add(EnumColor.ORANGE + gasStack.getGas().getLocalizedName() + ": " + EnumColor.GREY + gasStack.amount); - } - - list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.capacity") + ": " + EnumColor.GREY + GasTankTier.values()[getBaseTier(itemstack).ordinal()].storage); + if (getOwner(stack) == null) { + security.getSecurity().setOwner(player.getCommandSenderName()); + } + } - if(!MekKeyHandler.getIsKeyPressed(MekanismKeyHandler.sneakKey)) - { - list.add(LangUtils.localize("tooltip.hold") + " " + EnumColor.AQUA + GameSettings.getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode()) + EnumColor.GREY + " " + LangUtils.localize("tooltip.forDetails") + "."); - } - else { - if(hasSecurity(itemstack)) - { - list.add(SecurityUtils.getOwnerDisplay(entityplayer.getCommandSenderName(), getOwner(itemstack))); - list.add(EnumColor.GREY + LangUtils.localize("gui.security") + ": " + SecurityUtils.getSecurityDisplay(itemstack, Side.CLIENT)); - - if(SecurityUtils.isOverridden(itemstack, Side.CLIENT)) - { - list.add(EnumColor.RED + "(" + LangUtils.localize("gui.overridden") + ")"); - } - } - - list.add(EnumColor.AQUA + LangUtils.localize("tooltip.inventory") + ": " + EnumColor.GREY + LangUtils.transYesNo(getInventory(itemstack) != null && getInventory(itemstack).tagCount() != 0)); - } - } + ((ISustainedInventory) tileEntity).setInventory(getInventory(stack)); - @Override - public GasStack getGas(ItemStack itemstack) - { - if(itemstack.stackTagCompound == null) - { - return null; - } + if (!world.isRemote) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(tileEntity), + tileEntity.getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(tileEntity)) + ); + } + } - return GasStack.readFromNBT(itemstack.stackTagCompound.getCompoundTag("stored")); - } + return place; + } - @Override - public void setGas(ItemStack itemstack, GasStack stack) - { - if(itemstack.stackTagCompound == null) - { - itemstack.setTagCompound(new NBTTagCompound()); - } + @Override + public void addInformation( + ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag + ) { + GasStack gasStack = getGas(itemstack); - if(stack == null || stack.amount == 0) - { - itemstack.stackTagCompound.removeTag("stored"); - } - else { - int amount = Math.max(0, Math.min(stack.amount, getMaxGas(itemstack))); - GasStack gasStack = new GasStack(stack.getGas(), amount); + if (gasStack == null) { + list.add(EnumColor.DARK_RED + LangUtils.localize("gui.empty") + "."); + } else { + list.add( + EnumColor.ORANGE + gasStack.getGas().getLocalizedName() + ": " + + EnumColor.GREY + gasStack.amount + ); + } - itemstack.stackTagCompound.setTag("stored", gasStack.write(new NBTTagCompound())); - } - } + list.add( + EnumColor.INDIGO + LangUtils.localize("tooltip.capacity") + ": " + + EnumColor.GREY + + GasTankTier.values()[getBaseTier(itemstack).ordinal()].storage + ); - public ItemStack getEmptyItem(GasTankTier tier) - { - ItemStack empty = new ItemStack(this); - setBaseTier(empty, tier.getBaseTier()); - setGas(empty, null); - - return empty; - } + if (!MekKeyHandler.getIsKeyPressed(MekanismKeyHandler.sneakKey)) { + list.add( + LangUtils.localize("tooltip.hold") + " " + EnumColor.AQUA + + GameSettings.getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode( + )) + + EnumColor.GREY + " " + LangUtils.localize("tooltip.forDetails") + "." + ); + } else { + if (hasSecurity(itemstack)) { + list.add(SecurityUtils.getOwnerDisplay( + entityplayer.getCommandSenderName(), getOwner(itemstack) + )); + list.add( + EnumColor.GREY + LangUtils.localize("gui.security") + ": " + + SecurityUtils.getSecurityDisplay(itemstack, Side.CLIENT) + ); - @Override - public void getSubItems(Item item, CreativeTabs tabs, List list) - { - for(GasTankTier tier : GasTankTier.values()) - { - ItemStack empty = new ItemStack(this); - setBaseTier(empty, tier.getBaseTier()); - list.add(empty); - } + if (SecurityUtils.isOverridden(itemstack, Side.CLIENT)) { + list.add( + EnumColor.RED + "(" + LangUtils.localize("gui.overridden") + ")" + ); + } + } - if(general.prefilledGasTanks) - { - for(Gas type : GasRegistry.getRegisteredGasses()) - { - if(type.isVisible()) - { - ItemStack filled = new ItemStack(this); - setBaseTier(filled, BaseTier.ULTIMATE); - setGas(filled, new GasStack(type, ((IGasItem)filled.getItem()).getMaxGas(filled))); - list.add(filled); - } - } - } - } - - @Override - public BaseTier getBaseTier(ItemStack itemstack) - { - if(itemstack.stackTagCompound == null) - { - return BaseTier.BASIC; - } + list.add( + EnumColor.AQUA + LangUtils.localize("tooltip.inventory") + ": " + + EnumColor.GREY + + LangUtils.transYesNo( + getInventory(itemstack) != null + && getInventory(itemstack).tagCount() != 0 + ) + ); + } + } - return BaseTier.values()[itemstack.stackTagCompound.getInteger("tier")]; - } + @Override + public GasStack getGas(ItemStack itemstack) { + if (itemstack.stackTagCompound == null) { + return null; + } - @Override - public void setBaseTier(ItemStack itemstack, BaseTier tier) - { - if(itemstack.stackTagCompound == null) - { - itemstack.setTagCompound(new NBTTagCompound()); - } + return GasStack.readFromNBT(itemstack.stackTagCompound.getCompoundTag("stored")); + } - itemstack.stackTagCompound.setInteger("tier", tier.ordinal()); - } + @Override + public void setGas(ItemStack itemstack, GasStack stack) { + if (itemstack.stackTagCompound == null) { + itemstack.setTagCompound(new NBTTagCompound()); + } - @Override - public int getMaxGas(ItemStack itemstack) - { - return GasTankTier.values()[getBaseTier(itemstack).ordinal()].storage; - } + if (stack == null || stack.amount == 0) { + itemstack.stackTagCompound.removeTag("stored"); + } else { + int amount = Math.max(0, Math.min(stack.amount, getMaxGas(itemstack))); + GasStack gasStack = new GasStack(stack.getGas(), amount); - @Override - public int getRate(ItemStack itemstack) - { - return GasTankTier.values()[getBaseTier(itemstack).ordinal()].output; - } + itemstack.stackTagCompound.setTag( + "stored", gasStack.write(new NBTTagCompound()) + ); + } + } - @Override - public int addGas(ItemStack itemstack, GasStack stack) - { - if(getGas(itemstack) != null && getGas(itemstack).getGas() != stack.getGas()) - { - return 0; - } + public ItemStack getEmptyItem(GasTankTier tier) { + ItemStack empty = new ItemStack(this); + setBaseTier(empty, tier.getBaseTier()); + setGas(empty, null); - int toUse = Math.min(getMaxGas(itemstack)-getStored(itemstack), Math.min(getRate(itemstack), stack.amount)); - setGas(itemstack, new GasStack(stack.getGas(), getStored(itemstack)+toUse)); + return empty; + } - return toUse; - } + @Override + public void getSubItems(Item item, CreativeTabs tabs, List list) { + for (GasTankTier tier : GasTankTier.values()) { + ItemStack empty = new ItemStack(this); + setBaseTier(empty, tier.getBaseTier()); + list.add(empty); + } - @Override - public GasStack removeGas(ItemStack itemstack, int amount) - { - if(getGas(itemstack) == null) - { - return null; - } + if (general.prefilledGasTanks) { + for (Gas type : GasRegistry.getRegisteredGasses()) { + if (type.isVisible()) { + ItemStack filled = new ItemStack(this); + setBaseTier(filled, BaseTier.ULTIMATE); + setGas( + filled, + new GasStack( + type, ((IGasItem) filled.getItem()).getMaxGas(filled) + ) + ); + list.add(filled); + } + } + } + } - Gas type = getGas(itemstack).getGas(); + @Override + public BaseTier getBaseTier(ItemStack itemstack) { + if (itemstack.stackTagCompound == null) { + return BaseTier.BASIC; + } - int gasToUse = Math.min(getStored(itemstack), Math.min(getRate(itemstack), amount)); - setGas(itemstack, new GasStack(type, getStored(itemstack)-gasToUse)); + return BaseTier.values()[itemstack.stackTagCompound.getInteger("tier")]; + } - return new GasStack(type, gasToUse); - } + @Override + public void setBaseTier(ItemStack itemstack, BaseTier tier) { + if (itemstack.stackTagCompound == null) { + itemstack.setTagCompound(new NBTTagCompound()); + } - private int getStored(ItemStack itemstack) - { - return getGas(itemstack) != null ? getGas(itemstack).amount : 0; - } + itemstack.stackTagCompound.setInteger("tier", tier.ordinal()); + } - @Override - public boolean canReceiveGas(ItemStack itemstack, Gas type) - { - return getGas(itemstack) == null || getGas(itemstack).getGas() == type; - } + @Override + public int getMaxGas(ItemStack itemstack) { + return GasTankTier.values()[getBaseTier(itemstack).ordinal()].storage; + } - @Override - public boolean canProvideGas(ItemStack itemstack, Gas type) - { - return getGas(itemstack) != null && (type == null || getGas(itemstack).getGas() == type); - } + @Override + public int getRate(ItemStack itemstack) { + return GasTankTier.values()[getBaseTier(itemstack).ordinal()].output; + } - @Override - public void setInventory(NBTTagList nbtTags, Object... data) - { - if(data[0] instanceof ItemStack) - { - ItemStack itemStack = (ItemStack)data[0]; + @Override + public int addGas(ItemStack itemstack, GasStack stack) { + if (getGas(itemstack) != null && getGas(itemstack).getGas() != stack.getGas()) { + return 0; + } - if(itemStack.stackTagCompound == null) - { - itemStack.setTagCompound(new NBTTagCompound()); - } + int toUse = Math.min( + getMaxGas(itemstack) - getStored(itemstack), + Math.min(getRate(itemstack), stack.amount) + ); + setGas(itemstack, new GasStack(stack.getGas(), getStored(itemstack) + toUse)); - itemStack.stackTagCompound.setTag("Items", nbtTags); - } - } + return toUse; + } - @Override - public NBTTagList getInventory(Object... data) - { - if(data[0] instanceof ItemStack) - { - ItemStack itemStack = (ItemStack)data[0]; + @Override + public GasStack removeGas(ItemStack itemstack, int amount) { + if (getGas(itemstack) == null) { + return null; + } - if(itemStack.stackTagCompound == null) - { - return null; - } + Gas type = getGas(itemstack).getGas(); - return itemStack.stackTagCompound.getTagList("Items", NBT.TAG_COMPOUND); - } + int gasToUse + = Math.min(getStored(itemstack), Math.min(getRate(itemstack), amount)); + setGas(itemstack, new GasStack(type, getStored(itemstack) - gasToUse)); - return null; - } - - @Override - public boolean showDurabilityBar(ItemStack stack) - { - return true; - } - - @Override - public double getDurabilityForDisplay(ItemStack stack) - { - return 1D-((getGas(stack) != null ? (double)getGas(stack).amount : 0D)/(double)getMaxGas(stack)); - } - - @Override - public String getOwner(ItemStack stack) - { - if(stack.stackTagCompound != null && stack.stackTagCompound.hasKey("owner")) - { - return stack.stackTagCompound.getString("owner"); - } - - return null; - } + return new GasStack(type, gasToUse); + } - @Override - public void setOwner(ItemStack stack, String owner) - { - if(stack.stackTagCompound == null) - { - stack.setTagCompound(new NBTTagCompound()); - } - - if(owner == null || owner.isEmpty()) - { - stack.stackTagCompound.removeTag("owner"); - return; - } - - stack.stackTagCompound.setString("owner", owner); - } + private int getStored(ItemStack itemstack) { + return getGas(itemstack) != null ? getGas(itemstack).amount : 0; + } - @Override - public SecurityMode getSecurity(ItemStack stack) - { - if(stack.stackTagCompound == null || !general.allowProtection) - { - return SecurityMode.PUBLIC; - } + @Override + public boolean canReceiveGas(ItemStack itemstack, Gas type) { + return getGas(itemstack) == null || getGas(itemstack).getGas() == type; + } - return SecurityMode.values()[stack.stackTagCompound.getInteger("security")]; - } + @Override + public boolean canProvideGas(ItemStack itemstack, Gas type) { + return getGas(itemstack) != null + && (type == null || getGas(itemstack).getGas() == type); + } - @Override - public void setSecurity(ItemStack stack, SecurityMode mode) - { - if(stack.stackTagCompound == null) - { - stack.setTagCompound(new NBTTagCompound()); - } - - stack.stackTagCompound.setInteger("security", mode.ordinal()); - } + @Override + public void setInventory(NBTTagList nbtTags, Object... data) { + if (data[0] instanceof ItemStack) { + ItemStack itemStack = (ItemStack) data[0]; - @Override - public boolean hasSecurity(ItemStack stack) - { - return true; - } - - @Override - public boolean hasOwner(ItemStack stack) - { - return hasSecurity(stack); - } + if (itemStack.stackTagCompound == null) { + itemStack.setTagCompound(new NBTTagCompound()); + } + + itemStack.stackTagCompound.setTag("Items", nbtTags); + } + } + + @Override + public NBTTagList getInventory(Object... data) { + if (data[0] instanceof ItemStack) { + ItemStack itemStack = (ItemStack) data[0]; + + if (itemStack.stackTagCompound == null) { + return null; + } + + return itemStack.stackTagCompound.getTagList("Items", NBT.TAG_COMPOUND); + } + + return null; + } + + @Override + public boolean showDurabilityBar(ItemStack stack) { + return true; + } + + @Override + public double getDurabilityForDisplay(ItemStack stack) { + return 1D + - ((getGas(stack) != null ? (double) getGas(stack).amount : 0D) + / (double) getMaxGas(stack)); + } + + @Override + public String getOwner(ItemStack stack) { + if (stack.stackTagCompound != null && stack.stackTagCompound.hasKey("owner")) { + return stack.stackTagCompound.getString("owner"); + } + + return null; + } + + @Override + public void setOwner(ItemStack stack, String owner) { + if (stack.stackTagCompound == null) { + stack.setTagCompound(new NBTTagCompound()); + } + + if (owner == null || owner.isEmpty()) { + stack.stackTagCompound.removeTag("owner"); + return; + } + + stack.stackTagCompound.setString("owner", owner); + } + + @Override + public SecurityMode getSecurity(ItemStack stack) { + if (stack.stackTagCompound == null || !general.allowProtection) { + return SecurityMode.PUBLIC; + } + + return SecurityMode.values()[stack.stackTagCompound.getInteger("security")]; + } + + @Override + public void setSecurity(ItemStack stack, SecurityMode mode) { + if (stack.stackTagCompound == null) { + stack.setTagCompound(new NBTTagCompound()); + } + + stack.stackTagCompound.setInteger("security", mode.ordinal()); + } + + @Override + public boolean hasSecurity(ItemStack stack) { + return true; + } + + @Override + public boolean hasOwner(ItemStack stack) { + return hasSecurity(stack); + } } diff --git a/src/main/java/mekanism/common/item/ItemBlockMachine.java b/src/main/java/mekanism/common/item/ItemBlockMachine.java index 7d695f6b2..d37d63a20 100644 --- a/src/main/java/mekanism/common/item/ItemBlockMachine.java +++ b/src/main/java/mekanism/common/item/ItemBlockMachine.java @@ -1,11 +1,16 @@ package mekanism.common.item; -import ic2.api.item.IElectricItemManager; -import ic2.api.item.ISpecialElectricItem; - import java.util.List; import java.util.Map; +import cofh.api.energy.IEnergyContainerItem; +import cpw.mods.fml.common.Optional.Interface; +import cpw.mods.fml.common.Optional.InterfaceList; +import cpw.mods.fml.common.Optional.Method; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ic2.api.item.IElectricItemManager; +import ic2.api.item.ISpecialElectricItem; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.MekanismConfig.general; @@ -57,12 +62,6 @@ import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidContainerItem; -import cofh.api.energy.IEnergyContainerItem; -import cpw.mods.fml.common.Optional.Interface; -import cpw.mods.fml.common.Optional.InterfaceList; -import cpw.mods.fml.common.Optional.Method; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; /** * Item class for handling multiple machine block IDs. @@ -108,347 +107,421 @@ import cpw.mods.fml.relauncher.SideOnly; * @author AidanBrady * */ -@InterfaceList({ - @Interface(iface = "ic2.api.item.ISpecialElectricItem", modid = "IC2") -}) -public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpecialElectricItem, IFactory, ISustainedInventory, ISustainedTank, IEnergyContainerItem, IFluidContainerItem, ITierItem, ISecurityItem -{ - public Block metaBlock; +@InterfaceList({ @Interface(iface = "ic2.api.item.ISpecialElectricItem", modid = "IC2") }) +public class ItemBlockMachine extends ItemBlock + implements IEnergizedItem, ISpecialElectricItem, IFactory, ISustainedInventory, + ISustainedTank, IEnergyContainerItem, IFluidContainerItem, ITierItem, + ISecurityItem { + public Block metaBlock; - public ItemBlockMachine(Block block) - { - super(block); - metaBlock = block; - setHasSubtypes(true); - setNoRepair(); - setMaxStackSize(1); - } - - @Override - public int getMetadata(int i) - { - return i; - } - - @Override - public String getUnlocalizedName(ItemStack itemstack) - { - if(MachineType.get(itemstack) != null) - { - return getUnlocalizedName() + "." + MachineType.get(itemstack).name; - } - - return "null"; - } - - @Override - public String getItemStackDisplayName(ItemStack itemstack) - { - MachineType type = MachineType.get(itemstack); - - if(type == MachineType.BASIC_FACTORY || type == MachineType.ADVANCED_FACTORY || type == MachineType.ELITE_FACTORY) - { - BaseTier tier = type == MachineType.BASIC_FACTORY ? BaseTier.BASIC : (type == MachineType.ADVANCED_FACTORY ? BaseTier.ADVANCED : BaseTier.ELITE); - - if(StatCollector.canTranslate("tile." + tier.getName() + RecipeType.values()[getRecipeType(itemstack)].getUnlocalizedName() + "Factory")) - { - return LangUtils.localize("tile." + tier.getName() + RecipeType.values()[getRecipeType(itemstack)].getUnlocalizedName() + "Factory"); - } - - return tier.getLocalizedName() + " " + RecipeType.values()[getRecipeType(itemstack)].getLocalizedName() + " " + super.getItemStackDisplayName(itemstack); - } - else if(type == MachineType.FLUID_TANK) - { - return LangUtils.localize("tile.FluidTank" + getBaseTier(itemstack).getName() + ".name"); - } - - return super.getItemStackDisplayName(itemstack); - } - - @Override - @SideOnly(Side.CLIENT) - public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) - { - MachineType type = MachineType.get(itemstack); - - if(!MekKeyHandler.getIsKeyPressed(MekanismKeyHandler.sneakKey)) - { - if(type == MachineType.FLUID_TANK) - { - FluidStack fluidStack = getFluidStack(itemstack); - - if(fluidStack != null) - { - list.add(EnumColor.AQUA + LangUtils.localizeFluidStack(fluidStack) + ": " + EnumColor.GREY + getFluidStack(itemstack).amount + "mB"); - } - else { - list.add(EnumColor.DARK_RED + LangUtils.localize("gui.empty") + "."); - } - - list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.capacity") + ": " + EnumColor.GREY + FluidTankTier.values()[getBaseTier(itemstack).ordinal()].storage + " mB"); - } - - list.add(LangUtils.localize("tooltip.hold") + " " + EnumColor.INDIGO + GameSettings.getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode()) + EnumColor.GREY + " " + LangUtils.localize("tooltip.forDetails") + "."); - list.add(LangUtils.localize("tooltip.hold") + " " + EnumColor.AQUA + GameSettings.getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode()) + EnumColor.GREY + " " + LangUtils.localize("tooltip.and") + " " + EnumColor.AQUA + GameSettings.getKeyDisplayString(MekanismKeyHandler.modeSwitchKey.getKeyCode()) + EnumColor.GREY + " " + LangUtils.localize("tooltip.forDesc") + "."); - } - else if(!MekKeyHandler.getIsKeyPressed(MekanismKeyHandler.modeSwitchKey)) - { - if(hasSecurity(itemstack)) - { - list.add(SecurityUtils.getOwnerDisplay(entityplayer.getCommandSenderName(), getOwner(itemstack))); - list.add(EnumColor.GREY + LangUtils.localize("gui.security") + ": " + SecurityUtils.getSecurityDisplay(itemstack, Side.CLIENT)); - - if(SecurityUtils.isOverridden(itemstack, Side.CLIENT)) - { - list.add(EnumColor.RED + "(" + LangUtils.localize("gui.overridden") + ")"); - } - } - - if(type == MachineType.BASIC_FACTORY || type == MachineType.ADVANCED_FACTORY || type == MachineType.ELITE_FACTORY) - { - list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.recipeType") + ": " + EnumColor.GREY + RecipeType.values()[getRecipeType(itemstack)].getLocalizedName()); - } - - if(type == MachineType.FLUID_TANK) - { - list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.portableTank.bucketMode") + ": " + EnumColor.GREY + LangUtils.transYesNo(getBucketMode(itemstack))); - } - - if(type.isElectric) - { - list.add(EnumColor.BRIGHT_GREEN + LangUtils.localize("tooltip.storedEnergy") + ": " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(getEnergy(itemstack))); - } - - if(hasTank(itemstack) && type != MachineType.FLUID_TANK) - { - FluidStack fluidStack = getFluidStack(itemstack); - - if(fluidStack != null) - { - list.add(EnumColor.PINK + LangUtils.localizeFluidStack(fluidStack) + ": " + EnumColor.GREY + getFluidStack(itemstack).amount + "mB"); - } - } - - if(type != MachineType.CHARGEPAD && type != MachineType.LOGISTICAL_SORTER) - { - list.add(EnumColor.AQUA + LangUtils.localize("tooltip.inventory") + ": " + EnumColor.GREY + LangUtils.transYesNo(getInventory(itemstack) != null && getInventory(itemstack).tagCount() != 0)); - } - - if(type.supportsUpgrades && itemstack.stackTagCompound != null && itemstack.stackTagCompound.hasKey("upgrades")) - { - Map upgrades = Upgrade.buildMap(itemstack.stackTagCompound); - - for(Map.Entry entry : upgrades.entrySet()) - { - list.add(entry.getKey().getColor() + "- " + entry.getKey().getName() + (entry.getKey().canMultiply() ? ": " + EnumColor.GREY + "x" + entry.getValue(): "")); - } - } - } - else { - list.addAll(MekanismUtils.splitTooltip(type.getDescription(), itemstack)); - } - } - - @Override - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) - { - MachineType type = MachineType.get(stack); - - if(type == MachineType.FLUID_TANK && getBucketMode(stack)) - { - return false; - } - - return super.onItemUse(stack, player, world, x, y, z, side, hitX, hitY, hitZ); + public ItemBlockMachine(Block block) { + super(block); + metaBlock = block; + setHasSubtypes(true); + setNoRepair(); + setMaxStackSize(1); } - @Override - public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) - { - boolean place = true; - - MachineType type = MachineType.get(stack); + @Override + public int getMetadata(int i) { + return i; + } - if(type == MachineType.DIGITAL_MINER) - { - for(int xPos = x-1; xPos <= x+1; xPos++) - { - for(int yPos = y; yPos <= y+1; yPos++) - { - for(int zPos = z-1; zPos <= z+1; zPos++) - { - Block b = world.getBlock(xPos, yPos, zPos); + @Override + public String getUnlocalizedName(ItemStack itemstack) { + if (MachineType.get(itemstack) != null) { + return getUnlocalizedName() + "." + MachineType.get(itemstack).name; + } - if(yPos > 255 || !b.isReplaceable(world, xPos, yPos, zPos)) - { - place = false; - } - } - } - } - } - else if(type == MachineType.SOLAR_NEUTRON_ACTIVATOR || type == MachineType.SEISMIC_VIBRATOR) - { - if(y+1 > 255 || !world.getBlock(x, y+1, z).isReplaceable(world, x, y+1, z)) - { - place = false; - } - } + return "null"; + } - if(place && super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata)) - { - TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(x, y, z); + @Override + public String getItemStackDisplayName(ItemStack itemstack) { + MachineType type = MachineType.get(itemstack); - if(tileEntity instanceof TileEntityFluidTank) - { - TileEntityFluidTank tile = (TileEntityFluidTank)tileEntity; - tile.tier = FluidTankTier.values()[getBaseTier(stack).ordinal()]; - tile.fluidTank.setCapacity(tile.tier.storage); - } - - if(tileEntity instanceof ISecurityTile) - { - ISecurityTile security = (ISecurityTile)tileEntity; - security.getSecurity().setOwner(getOwner(stack)); - - if(hasSecurity(stack)) - { - security.getSecurity().setMode(getSecurity(stack)); - } - - if(getOwner(stack) == null) - { - security.getSecurity().setOwner(player.getCommandSenderName()); - } - } - - if(tileEntity instanceof IUpgradeTile) - { - if(stack.stackTagCompound != null && stack.stackTagCompound.hasKey("upgrades")) - { - ((IUpgradeTile)tileEntity).getComponent().read(stack.stackTagCompound); - } - } + if (type == MachineType.BASIC_FACTORY || type == MachineType.ADVANCED_FACTORY + || type == MachineType.ELITE_FACTORY) { + BaseTier tier = type == MachineType.BASIC_FACTORY + ? BaseTier.BASIC + : (type == MachineType.ADVANCED_FACTORY ? BaseTier.ADVANCED + : BaseTier.ELITE); - if(tileEntity instanceof ISideConfiguration) - { - ISideConfiguration config = (ISideConfiguration)tileEntity; + if (StatCollector.canTranslate( + "tile." + tier.getName() + + RecipeType.values()[getRecipeType(itemstack)].getUnlocalizedName() + + "Factory" + )) { + return LangUtils.localize( + "tile." + tier.getName() + + RecipeType.values()[getRecipeType(itemstack)].getUnlocalizedName() + + "Factory" + ); + } - if(stack.stackTagCompound != null && stack.stackTagCompound.hasKey("sideDataStored")) - { - config.getConfig().read(stack.stackTagCompound); - } - } - - if(tileEntity instanceof ISustainedData) - { - if(stack.stackTagCompound != null) - { - ((ISustainedData)tileEntity).readSustainedData(stack); - } - } + return tier.getLocalizedName() + " " + + RecipeType.values()[getRecipeType(itemstack)].getLocalizedName() + " " + + super.getItemStackDisplayName(itemstack); + } else if (type == MachineType.FLUID_TANK) { + return LangUtils.localize( + "tile.FluidTank" + getBaseTier(itemstack).getName() + ".name" + ); + } - if(tileEntity instanceof IRedstoneControl) - { - if(stack.stackTagCompound != null && stack.stackTagCompound.hasKey("controlType")) - { - ((IRedstoneControl)tileEntity).setControlType(RedstoneControl.values()[stack.stackTagCompound.getInteger("controlType")]); - } - } + return super.getItemStackDisplayName(itemstack); + } - if(tileEntity instanceof TileEntityFactory) - { - TileEntityFactory factory = (TileEntityFactory)tileEntity; - RecipeType recipeType = RecipeType.values()[getRecipeType(stack)]; - factory.recipeType = recipeType; - factory.upgradeComponent.setSupported(Upgrade.GAS, recipeType.fuelEnergyUpgrades()); - factory.secondaryEnergyPerTick = factory.getSecondaryEnergyPerTick(recipeType); - world.notifyBlocksOfNeighborChange(x, y, z, tileEntity.getBlockType()); - } + @Override + @SideOnly(Side.CLIENT) + public void addInformation( + ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag + ) { + MachineType type = MachineType.get(itemstack); - if(tileEntity instanceof ISustainedTank) - { - if(hasTank(stack) && getFluidStack(stack) != null) - { - ((ISustainedTank)tileEntity).setFluidStack(getFluidStack(stack)); - } - } + if (!MekKeyHandler.getIsKeyPressed(MekanismKeyHandler.sneakKey)) { + if (type == MachineType.FLUID_TANK) { + FluidStack fluidStack = getFluidStack(itemstack); - if(tileEntity instanceof ISustainedInventory) - { - ((ISustainedInventory)tileEntity).setInventory(getInventory(stack)); - } + if (fluidStack != null) { + list.add( + EnumColor.AQUA + LangUtils.localizeFluidStack(fluidStack) + ": " + + EnumColor.GREY + getFluidStack(itemstack).amount + "mB" + ); + } else { + list.add(EnumColor.DARK_RED + LangUtils.localize("gui.empty") + "."); + } - if(tileEntity instanceof TileEntityElectricBlock) - { - ((TileEntityElectricBlock)tileEntity).electricityStored = getEnergy(stack); - } + list.add( + EnumColor.INDIGO + LangUtils.localize("tooltip.capacity") + ": " + + EnumColor.GREY + + FluidTankTier.values()[getBaseTier(itemstack).ordinal()].storage + + " mB" + ); + } - return true; - } + list.add( + LangUtils.localize("tooltip.hold") + " " + EnumColor.INDIGO + + GameSettings.getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode( + )) + + EnumColor.GREY + " " + LangUtils.localize("tooltip.forDetails") + "." + ); + list.add( + LangUtils.localize("tooltip.hold") + " " + EnumColor.AQUA + + GameSettings.getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode( + )) + + EnumColor.GREY + " " + LangUtils.localize("tooltip.and") + " " + + EnumColor.AQUA + + GameSettings.getKeyDisplayString( + MekanismKeyHandler.modeSwitchKey.getKeyCode() + ) + + EnumColor.GREY + " " + LangUtils.localize("tooltip.forDesc") + "." + ); + } else if (!MekKeyHandler.getIsKeyPressed(MekanismKeyHandler.modeSwitchKey)) { + if (hasSecurity(itemstack)) { + list.add(SecurityUtils.getOwnerDisplay( + entityplayer.getCommandSenderName(), getOwner(itemstack) + )); + list.add( + EnumColor.GREY + LangUtils.localize("gui.security") + ": " + + SecurityUtils.getSecurityDisplay(itemstack, Side.CLIENT) + ); - return false; - } + if (SecurityUtils.isOverridden(itemstack, Side.CLIENT)) { + list.add( + EnumColor.RED + "(" + LangUtils.localize("gui.overridden") + ")" + ); + } + } - @Override - @Method(modid = "IC2") - public boolean canProvideEnergy(ItemStack itemStack) - { - return false; - } + if (type == MachineType.BASIC_FACTORY || type == MachineType.ADVANCED_FACTORY + || type == MachineType.ELITE_FACTORY) { + list.add( + EnumColor.INDIGO + LangUtils.localize("tooltip.recipeType") + ": " + + EnumColor.GREY + + RecipeType.values()[getRecipeType(itemstack)].getLocalizedName() + ); + } - @Override - @Method(modid = "IC2") - public double getMaxCharge(ItemStack itemStack) - { - return 0; - } + if (type == MachineType.FLUID_TANK) { + list.add( + EnumColor.INDIGO + + LangUtils.localize("tooltip.portableTank.bucketMode") + ": " + + EnumColor.GREY + LangUtils.transYesNo(getBucketMode(itemstack)) + ); + } - @Override - @Method(modid = "IC2") - public int getTier(ItemStack itemStack) - { - return 4; - } + if (type.isElectric) { + list.add( + EnumColor.BRIGHT_GREEN + LangUtils.localize("tooltip.storedEnergy") + + ": " + EnumColor.GREY + + MekanismUtils.getEnergyDisplay(getEnergy(itemstack)) + ); + } - @Override - @Method(modid = "IC2") - public double getTransferLimit(ItemStack itemStack) - { - return 0; - } + if (hasTank(itemstack) && type != MachineType.FLUID_TANK) { + FluidStack fluidStack = getFluidStack(itemstack); - public boolean tryPlaceContainedLiquid(World world, ItemStack itemstack, int x, int y, int z) - { - if(getFluidStack(itemstack) == null || !getFluidStack(itemstack).getFluid().canBePlacedInWorld()) - { + if (fluidStack != null) { + list.add( + EnumColor.PINK + LangUtils.localizeFluidStack(fluidStack) + ": " + + EnumColor.GREY + getFluidStack(itemstack).amount + "mB" + ); + } + } + + if (type != MachineType.CHARGEPAD && type != MachineType.LOGISTICAL_SORTER) { + list.add( + EnumColor.AQUA + LangUtils.localize("tooltip.inventory") + ": " + + EnumColor.GREY + + LangUtils.transYesNo( + getInventory(itemstack) != null + && getInventory(itemstack).tagCount() != 0 + ) + ); + } + + if (type.supportsUpgrades && itemstack.stackTagCompound != null + && itemstack.stackTagCompound.hasKey("upgrades")) { + Map upgrades + = Upgrade.buildMap(itemstack.stackTagCompound); + + for (Map.Entry entry : upgrades.entrySet()) { + list.add( + entry.getKey().getColor() + "- " + entry.getKey().getName() + + (entry.getKey().canMultiply() + ? ": " + EnumColor.GREY + "x" + entry.getValue() + : "") + ); + } + } + } else { + list.addAll(MekanismUtils.splitTooltip(type.getDescription(), itemstack)); + } + } + + @Override + public boolean onItemUse( + ItemStack stack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int side, + float hitX, + float hitY, + float hitZ + ) { + MachineType type = MachineType.get(stack); + + if (type == MachineType.FLUID_TANK && getBucketMode(stack)) { return false; } - else { + + return super.onItemUse(stack, player, world, x, y, z, side, hitX, hitY, hitZ); + } + + @Override + public boolean placeBlockAt( + ItemStack stack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int side, + float hitX, + float hitY, + float hitZ, + int metadata + ) { + boolean place = true; + + MachineType type = MachineType.get(stack); + + if (type == MachineType.DIGITAL_MINER) { + for (int xPos = x - 1; xPos <= x + 1; xPos++) { + for (int yPos = y; yPos <= y + 1; yPos++) { + for (int zPos = z - 1; zPos <= z + 1; zPos++) { + Block b = world.getBlock(xPos, yPos, zPos); + + if (yPos > 255 || !b.isReplaceable(world, xPos, yPos, zPos)) { + place = false; + } + } + } + } + } else if (type == MachineType.SOLAR_NEUTRON_ACTIVATOR || type == MachineType.SEISMIC_VIBRATOR) { + if (y + 1 > 255 + || !world.getBlock(x, y + 1, z).isReplaceable(world, x, y + 1, z)) { + place = false; + } + } + + if (place + && super.placeBlockAt( + stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata + )) { + TileEntityBasicBlock tileEntity + = (TileEntityBasicBlock) world.getTileEntity(x, y, z); + + if (tileEntity instanceof TileEntityFluidTank) { + TileEntityFluidTank tile = (TileEntityFluidTank) tileEntity; + tile.tier = FluidTankTier.values()[getBaseTier(stack).ordinal()]; + tile.fluidTank.setCapacity(tile.tier.storage); + } + + if (tileEntity instanceof ISecurityTile) { + ISecurityTile security = (ISecurityTile) tileEntity; + security.getSecurity().setOwner(getOwner(stack)); + + if (hasSecurity(stack)) { + security.getSecurity().setMode(getSecurity(stack)); + } + + if (getOwner(stack) == null) { + security.getSecurity().setOwner(player.getCommandSenderName()); + } + } + + if (tileEntity instanceof IUpgradeTile) { + if (stack.stackTagCompound != null + && stack.stackTagCompound.hasKey("upgrades")) { + ((IUpgradeTile) tileEntity) + .getComponent() + .read(stack.stackTagCompound); + } + } + + if (tileEntity instanceof ISideConfiguration) { + ISideConfiguration config = (ISideConfiguration) tileEntity; + + if (stack.stackTagCompound != null + && stack.stackTagCompound.hasKey("sideDataStored")) { + config.getConfig().read(stack.stackTagCompound); + } + } + + if (tileEntity instanceof ISustainedData) { + if (stack.stackTagCompound != null) { + ((ISustainedData) tileEntity).readSustainedData(stack); + } + } + + if (tileEntity instanceof IRedstoneControl) { + if (stack.stackTagCompound != null + && stack.stackTagCompound.hasKey("controlType")) { + ((IRedstoneControl) tileEntity) + .setControlType(RedstoneControl.values( + )[stack.stackTagCompound.getInteger("controlType")]); + } + } + + if (tileEntity instanceof TileEntityFactory) { + TileEntityFactory factory = (TileEntityFactory) tileEntity; + RecipeType recipeType = RecipeType.values()[getRecipeType(stack)]; + factory.recipeType = recipeType; + factory.upgradeComponent.setSupported( + Upgrade.GAS, recipeType.fuelEnergyUpgrades() + ); + factory.secondaryEnergyPerTick + = factory.getSecondaryEnergyPerTick(recipeType); + world.notifyBlocksOfNeighborChange(x, y, z, tileEntity.getBlockType()); + } + + if (tileEntity instanceof ISustainedTank) { + if (hasTank(stack) && getFluidStack(stack) != null) { + ((ISustainedTank) tileEntity).setFluidStack(getFluidStack(stack)); + } + } + + if (tileEntity instanceof ISustainedInventory) { + ((ISustainedInventory) tileEntity).setInventory(getInventory(stack)); + } + + if (tileEntity instanceof TileEntityElectricBlock) { + ((TileEntityElectricBlock) tileEntity).electricityStored + = getEnergy(stack); + } + + return true; + } + + return false; + } + + @Override + @Method(modid = "IC2") + public boolean canProvideEnergy(ItemStack itemStack) { + return false; + } + + @Override + @Method(modid = "IC2") + public double getMaxCharge(ItemStack itemStack) { + return 0; + } + + @Override + @Method(modid = "IC2") + public int getTier(ItemStack itemStack) { + return 4; + } + + @Override + @Method(modid = "IC2") + public double getTransferLimit(ItemStack itemStack) { + return 0; + } + + public boolean + tryPlaceContainedLiquid(World world, ItemStack itemstack, int x, int y, int z) { + if (getFluidStack(itemstack) == null + || !getFluidStack(itemstack).getFluid().canBePlacedInWorld()) { + return false; + } else { Material material = world.getBlock(x, y, z).getMaterial(); boolean flag = !material.isSolid(); - if(!world.isAirBlock(x, y, z) && !flag) - { + if (!world.isAirBlock(x, y, z) && !flag) { return false; - } - else { - if(world.provider.isHellWorld && getFluidStack(itemstack).getFluid() == FluidRegistry.WATER) - { - world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); + } else { + if (world.provider.isHellWorld + && getFluidStack(itemstack).getFluid() == FluidRegistry.WATER) { + world.playSoundEffect( + x + 0.5F, + y + 0.5F, + z + 0.5F, + "random.fizz", + 0.5F, + 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F + ); - for(int l = 0; l < 8; l++) - { - world.spawnParticle("largesmoke", x + Math.random(), y + Math.random(), z + Math.random(), 0.0D, 0.0D, 0.0D); + for (int l = 0; l < 8; l++) { + world.spawnParticle( + "largesmoke", + x + Math.random(), + y + Math.random(), + z + Math.random(), + 0.0D, + 0.0D, + 0.0D + ); } - } - else { - if(!world.isRemote && flag && !material.isLiquid()) - { + } else { + if (!world.isRemote && flag && !material.isLiquid()) { world.func_147480_a(x, y, z, true); } - - world.setBlock(x, y, z, MekanismUtils.getFlowingBlock(getFluidStack(itemstack).getFluid()), 0, 3); + + world.setBlock( + x, + y, + z, + MekanismUtils.getFlowingBlock(getFluidStack(itemstack).getFluid() + ), + 0, + 3 + ); } return true; @@ -456,529 +529,498 @@ public class ItemBlockMachine extends ItemBlock implements IEnergizedItem, ISpec } } - @Override - public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) - { - MachineType type = MachineType.get(itemstack); - - if(MachineType.get(itemstack) == MachineType.PERSONAL_CHEST) - { - if(!world.isRemote) - { - if(getOwner(itemstack) == null) - { - setOwner(itemstack, entityplayer.getCommandSenderName()); - } - - if(SecurityUtils.canAccess(entityplayer, itemstack)) - { - InventoryPersonalChest inventory = new InventoryPersonalChest(entityplayer); - MekanismUtils.openPersonalChestGui((EntityPlayerMP)entityplayer, null, inventory, false); - } - else { - SecurityUtils.displayNoAccess(entityplayer); - } - } - } - else if(type == MachineType.FLUID_TANK && getBucketMode(itemstack)) - { - if(SecurityUtils.canAccess(entityplayer, itemstack)) - { - MovingObjectPosition pos = getMovingObjectPositionFromPlayer(world, entityplayer, !entityplayer.isSneaking()); - - if(pos == null) - { - return itemstack; - } - else { - if(pos.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) - { - Coord4D coord = new Coord4D(pos.blockX, pos.blockY, pos.blockZ, world.provider.dimensionId); - - if(!world.canMineBlock(entityplayer, coord.xCoord, coord.yCoord, coord.zCoord)) - { - return itemstack; - } - - if(!entityplayer.isSneaking()) - { - if(!entityplayer.canPlayerEdit(coord.xCoord, coord.yCoord, coord.zCoord, pos.sideHit, itemstack)) - { - return itemstack; - } - - FluidStack fluid = MekanismUtils.getFluid(world, coord, false); - - if(fluid != null && (getFluidStack(itemstack) == null || getFluidStack(itemstack).isFluidEqual(fluid))) - { - int needed = getCapacity(itemstack)-(getFluidStack(itemstack) != null ? getFluidStack(itemstack).amount : 0); - - if(fluid.amount > needed) - { - return itemstack; - } - - if(getFluidStack(itemstack) == null) - { - setFluidStack(fluid, itemstack); - } - else { - FluidStack newStack = getFluidStack(itemstack); - newStack.amount += fluid.amount; - setFluidStack(newStack, itemstack); - } - - world.setBlockToAir(coord.xCoord, coord.yCoord, coord.zCoord); - } - } - else { - FluidStack stored = getFluidStack(itemstack); - - if(stored == null || stored.amount < FluidContainerRegistry.BUCKET_VOLUME) - { - return itemstack; - } - - Coord4D trans = coord.getFromSide(ForgeDirection.getOrientation(pos.sideHit)); - - if(!entityplayer.canPlayerEdit(trans.xCoord, trans.yCoord, trans.zCoord, pos.sideHit, itemstack)) - { - return itemstack; - } - - if(tryPlaceContainedLiquid(world, itemstack, trans.xCoord, trans.yCoord, trans.zCoord) && !entityplayer.capabilities.isCreativeMode) - { - FluidStack newStack = stored.copy(); - newStack.amount -= FluidContainerRegistry.BUCKET_VOLUME; - - setFluidStack(newStack.amount > 0 ? newStack : null, itemstack); - } - } - } - - return itemstack; - } - } - else { - SecurityUtils.displayNoAccess(entityplayer); - } - } + @Override + public ItemStack + onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { + MachineType type = MachineType.get(itemstack); - return itemstack; - } + if (MachineType.get(itemstack) == MachineType.PERSONAL_CHEST) { + if (!world.isRemote) { + if (getOwner(itemstack) == null) { + setOwner(itemstack, entityplayer.getCommandSenderName()); + } - @Override - public int getRecipeType(ItemStack itemStack) - { - if(itemStack.stackTagCompound == null) - { - return 0; - } + if (SecurityUtils.canAccess(entityplayer, itemstack)) { + InventoryPersonalChest inventory + = new InventoryPersonalChest(entityplayer); + MekanismUtils.openPersonalChestGui( + (EntityPlayerMP) entityplayer, null, inventory, false + ); + } else { + SecurityUtils.displayNoAccess(entityplayer); + } + } + } else if (type == MachineType.FLUID_TANK && getBucketMode(itemstack)) { + if (SecurityUtils.canAccess(entityplayer, itemstack)) { + MovingObjectPosition pos = getMovingObjectPositionFromPlayer( + world, entityplayer, !entityplayer.isSneaking() + ); - return itemStack.stackTagCompound.getInteger("recipeType"); - } + if (pos == null) { + return itemstack; + } else { + if (pos.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) { + Coord4D coord = new Coord4D( + pos.blockX, pos.blockY, pos.blockZ, world.provider.dimensionId + ); - @Override - public void setRecipeType(int type, ItemStack itemStack) - { - if(itemStack.stackTagCompound == null) - { - itemStack.setTagCompound(new NBTTagCompound()); - } + if (!world.canMineBlock( + entityplayer, coord.xCoord, coord.yCoord, coord.zCoord + )) { + return itemstack; + } - itemStack.stackTagCompound.setInteger("recipeType", type); - } + if (!entityplayer.isSneaking()) { + if (!entityplayer.canPlayerEdit( + coord.xCoord, + coord.yCoord, + coord.zCoord, + pos.sideHit, + itemstack + )) { + return itemstack; + } - @Override - public void setInventory(NBTTagList nbtTags, Object... data) - { - if(data[0] instanceof ItemStack) - { - ItemStack itemStack = (ItemStack)data[0]; + FluidStack fluid + = MekanismUtils.getFluid(world, coord, false); - if(itemStack.stackTagCompound == null) - { - itemStack.setTagCompound(new NBTTagCompound()); - } - - itemStack.stackTagCompound.setTag("Items", nbtTags); - } - } + if (fluid != null + && (getFluidStack(itemstack) == null + || getFluidStack(itemstack).isFluidEqual(fluid))) { + int needed = getCapacity(itemstack) + - (getFluidStack(itemstack) != null + ? getFluidStack(itemstack).amount + : 0); - @Override - public NBTTagList getInventory(Object... data) - { - if(data[0] instanceof ItemStack) - { - ItemStack itemStack = (ItemStack)data[0]; + if (fluid.amount > needed) { + return itemstack; + } - if(itemStack.stackTagCompound == null) - { - return null; - } - - return itemStack.stackTagCompound.getTagList("Items", NBT.TAG_COMPOUND); - } + if (getFluidStack(itemstack) == null) { + setFluidStack(fluid, itemstack); + } else { + FluidStack newStack = getFluidStack(itemstack); + newStack.amount += fluid.amount; + setFluidStack(newStack, itemstack); + } - return null; - } + world.setBlockToAir( + coord.xCoord, coord.yCoord, coord.zCoord + ); + } + } else { + FluidStack stored = getFluidStack(itemstack); - @Override - public void setFluidStack(FluidStack fluidStack, Object... data) - { - if(data[0] instanceof ItemStack) - { - ItemStack itemStack = (ItemStack)data[0]; + if (stored == null + || stored.amount < FluidContainerRegistry.BUCKET_VOLUME) { + return itemstack; + } - if(itemStack.stackTagCompound == null) - { - itemStack.setTagCompound(new NBTTagCompound()); - } - - if(fluidStack == null || fluidStack.amount == 0 || fluidStack.getFluidID() == 0) - { - itemStack.stackTagCompound.removeTag("fluidTank"); - } - else { - itemStack.stackTagCompound.setTag("fluidTank", fluidStack.writeToNBT(new NBTTagCompound())); - } - } - } + Coord4D trans = coord.getFromSide( + ForgeDirection.getOrientation(pos.sideHit) + ); - @Override - public FluidStack getFluidStack(Object... data) - { - if(data[0] instanceof ItemStack) - { - ItemStack itemStack = (ItemStack)data[0]; + if (!entityplayer.canPlayerEdit( + trans.xCoord, + trans.yCoord, + trans.zCoord, + pos.sideHit, + itemstack + )) { + return itemstack; + } - if(itemStack.stackTagCompound == null) - { - return null; - } + if (tryPlaceContainedLiquid( + world, + itemstack, + trans.xCoord, + trans.yCoord, + trans.zCoord + ) + && !entityplayer.capabilities.isCreativeMode) { + FluidStack newStack = stored.copy(); + newStack.amount -= FluidContainerRegistry.BUCKET_VOLUME; - if(itemStack.stackTagCompound.hasKey("fluidTank")) - { - return FluidStack.loadFluidStackFromNBT(itemStack.stackTagCompound.getCompoundTag("fluidTank")); - } - } + setFluidStack( + newStack.amount > 0 ? newStack : null, itemstack + ); + } + } + } - return null; - } + return itemstack; + } + } else { + SecurityUtils.displayNoAccess(entityplayer); + } + } - @Override - public boolean hasTank(Object... data) - { - if(!(data[0] instanceof ItemStack) || !(((ItemStack)data[0]).getItem() instanceof ISustainedTank)) - { - return false; - } - - MachineType type = MachineType.get((ItemStack)data[0]); - - return type == MachineType.ELECTRIC_PUMP || type == MachineType.FLUID_TANK || type == MachineType.FLUIDIC_PLENISHER; - } - - public void setBucketMode(ItemStack itemStack, boolean bucketMode) - { - if(itemStack.stackTagCompound == null) - { - itemStack.setTagCompound(new NBTTagCompound()); - } + return itemstack; + } - itemStack.stackTagCompound.setBoolean("bucketMode", bucketMode); - } - - public boolean getBucketMode(ItemStack itemStack) - { - if(itemStack.stackTagCompound == null) - { - return false; - } + @Override + public int getRecipeType(ItemStack itemStack) { + if (itemStack.stackTagCompound == null) { + return 0; + } - return itemStack.stackTagCompound.getBoolean("bucketMode"); - } + return itemStack.stackTagCompound.getInteger("recipeType"); + } - @Override - public double getEnergy(ItemStack itemStack) - { - if(itemStack.stackTagCompound == null || !MachineType.get(itemStack).isElectric) - { - return 0; - } + @Override + public void setRecipeType(int type, ItemStack itemStack) { + if (itemStack.stackTagCompound == null) { + itemStack.setTagCompound(new NBTTagCompound()); + } - return itemStack.stackTagCompound.getDouble("electricity"); - } + itemStack.stackTagCompound.setInteger("recipeType", type); + } - @Override - public void setEnergy(ItemStack itemStack, double amount) - { - if(!MachineType.get(itemStack).isElectric) - { - return; - } - - if(itemStack.stackTagCompound == null) - { - itemStack.setTagCompound(new NBTTagCompound()); - } + @Override + public void setInventory(NBTTagList nbtTags, Object... data) { + if (data[0] instanceof ItemStack) { + ItemStack itemStack = (ItemStack) data[0]; - double electricityStored = Math.max(Math.min(amount, getMaxEnergy(itemStack)), 0); - itemStack.stackTagCompound.setDouble("electricity", electricityStored); - } + if (itemStack.stackTagCompound == null) { + itemStack.setTagCompound(new NBTTagCompound()); + } - @Override - public double getMaxEnergy(ItemStack itemStack) - { - return MekanismUtils.getMaxEnergy(itemStack, MachineType.get(Block.getBlockFromItem(itemStack.getItem()), itemStack.getItemDamage()).baseEnergy); - } + itemStack.stackTagCompound.setTag("Items", nbtTags); + } + } - @Override - public double getMaxTransfer(ItemStack itemStack) - { - return getMaxEnergy(itemStack)*0.005; - } + @Override + public NBTTagList getInventory(Object... data) { + if (data[0] instanceof ItemStack) { + ItemStack itemStack = (ItemStack) data[0]; - @Override - public boolean canReceive(ItemStack itemStack) - { - return MachineType.get(itemStack).isElectric; - } + if (itemStack.stackTagCompound == null) { + return null; + } - @Override - public boolean canSend(ItemStack itemStack) - { - return false; - } + return itemStack.stackTagCompound.getTagList("Items", NBT.TAG_COMPOUND); + } - @Override - public int receiveEnergy(ItemStack theItem, int energy, boolean simulate) - { - if(canReceive(theItem)) - { - double energyNeeded = getMaxEnergy(theItem)-getEnergy(theItem); - double toReceive = Math.min(energy* general.FROM_TE, energyNeeded); + return null; + } - if(!simulate) - { - setEnergy(theItem, getEnergy(theItem) + toReceive); - } + @Override + public void setFluidStack(FluidStack fluidStack, Object... data) { + if (data[0] instanceof ItemStack) { + ItemStack itemStack = (ItemStack) data[0]; - return (int)Math.round(toReceive* general.TO_TE); - } + if (itemStack.stackTagCompound == null) { + itemStack.setTagCompound(new NBTTagCompound()); + } - return 0; - } + if (fluidStack == null || fluidStack.amount == 0 + || fluidStack.getFluidID() == 0) { + itemStack.stackTagCompound.removeTag("fluidTank"); + } else { + itemStack.stackTagCompound.setTag( + "fluidTank", fluidStack.writeToNBT(new NBTTagCompound()) + ); + } + } + } - @Override - public int extractEnergy(ItemStack theItem, int energy, boolean simulate) - { - if(canSend(theItem)) - { - double energyRemaining = getEnergy(theItem); - double toSend = Math.min((energy* general.FROM_TE), energyRemaining); + @Override + public FluidStack getFluidStack(Object... data) { + if (data[0] instanceof ItemStack) { + ItemStack itemStack = (ItemStack) data[0]; - if(!simulate) - { - setEnergy(theItem, getEnergy(theItem) - toSend); - } + if (itemStack.stackTagCompound == null) { + return null; + } - return (int)Math.round(toSend* general.TO_TE); - } + if (itemStack.stackTagCompound.hasKey("fluidTank")) { + return FluidStack.loadFluidStackFromNBT( + itemStack.stackTagCompound.getCompoundTag("fluidTank") + ); + } + } - return 0; - } + return null; + } - @Override - public int getEnergyStored(ItemStack theItem) - { - return (int)(getEnergy(theItem) * general.TO_TE); - } + @Override + public boolean hasTank(Object... data) { + if (!(data[0] instanceof ItemStack) + || !(((ItemStack) data[0]).getItem() instanceof ISustainedTank)) { + return false; + } - @Override - public int getMaxEnergyStored(ItemStack theItem) - { - return (int)(getMaxEnergy(theItem) * general.TO_TE); - } + MachineType type = MachineType.get((ItemStack) data[0]); - @Override - @Method(modid = "IC2") - public IElectricItemManager getManager(ItemStack itemStack) - { - return IC2ItemManager.getManager(this); - } - - @Override - @Method(modid = "IC2") - public Item getChargedItem(ItemStack itemStack) - { - return this; - } + return type == MachineType.ELECTRIC_PUMP || type == MachineType.FLUID_TANK + || type == MachineType.FLUIDIC_PLENISHER; + } - @Override - @Method(modid = "IC2") - public Item getEmptyItem(ItemStack itemStack) - { - return this; - } + public void setBucketMode(ItemStack itemStack, boolean bucketMode) { + if (itemStack.stackTagCompound == null) { + itemStack.setTagCompound(new NBTTagCompound()); + } - @Override - public FluidStack getFluid(ItemStack container) - { - return getFluidStack(container); - } + itemStack.stackTagCompound.setBoolean("bucketMode", bucketMode); + } - @Override - public int getCapacity(ItemStack container) - { - return FluidTankTier.values()[getBaseTier(container).ordinal()].storage; - } + public boolean getBucketMode(ItemStack itemStack) { + if (itemStack.stackTagCompound == null) { + return false; + } - @Override - public int fill(ItemStack container, FluidStack resource, boolean doFill) - { - if(MachineType.get(container) == MachineType.FLUID_TANK && resource != null) - { - FluidStack stored = getFluidStack(container); - int toFill; + return itemStack.stackTagCompound.getBoolean("bucketMode"); + } - if(stored != null && stored.getFluid() != resource.getFluid()) - { - return 0; - } - - if(stored == null) - { - toFill = Math.min(resource.amount, getCapacity(container)); - } - else { - toFill = Math.min(resource.amount, getCapacity(container)-stored.amount); - } - - if(doFill) - { - int fillAmount = toFill + (stored == null ? 0 : stored.amount); - setFluidStack(PipeUtils.copy(resource, (stored != null ? stored.amount : 0)+toFill), container); - } - - return toFill; - } - - return 0; - } + @Override + public double getEnergy(ItemStack itemStack) { + if (itemStack.stackTagCompound == null + || !MachineType.get(itemStack).isElectric) { + return 0; + } - @Override - public FluidStack drain(ItemStack container, int maxDrain, boolean doDrain) - { - if(MachineType.get(container) == MachineType.FLUID_TANK) - { - FluidStack stored = getFluidStack(container); - - if(stored != null) - { - FluidStack toDrain = PipeUtils.copy(stored, Math.min(stored.amount, maxDrain)); - - if(doDrain) - { - stored.amount -= toDrain.amount; - setFluidStack(stored.amount > 0 ? stored : null, container); - } - - return toDrain; - } - } - - return null; - } - - @Override - public BaseTier getBaseTier(ItemStack itemstack) - { - if(itemstack.stackTagCompound == null) - { - return BaseTier.BASIC; - } + return itemStack.stackTagCompound.getDouble("electricity"); + } - return BaseTier.values()[itemstack.stackTagCompound.getInteger("tier")]; - } + @Override + public void setEnergy(ItemStack itemStack, double amount) { + if (!MachineType.get(itemStack).isElectric) { + return; + } - @Override - public void setBaseTier(ItemStack itemstack, BaseTier tier) - { - if(itemstack.stackTagCompound == null) - { - itemstack.setTagCompound(new NBTTagCompound()); - } + if (itemStack.stackTagCompound == null) { + itemStack.setTagCompound(new NBTTagCompound()); + } - itemstack.stackTagCompound.setInteger("tier", tier.ordinal()); - } + double electricityStored = Math.max(Math.min(amount, getMaxEnergy(itemStack)), 0); + itemStack.stackTagCompound.setDouble("electricity", electricityStored); + } - @Override - public String getOwner(ItemStack stack) - { - if(stack.stackTagCompound != null && stack.stackTagCompound.hasKey("owner")) - { - return stack.stackTagCompound.getString("owner"); - } - - return null; - } + @Override + public double getMaxEnergy(ItemStack itemStack) { + return MekanismUtils.getMaxEnergy( + itemStack, + MachineType + .get( + Block.getBlockFromItem(itemStack.getItem()), itemStack.getItemDamage() + ) + .baseEnergy + ); + } - @Override - public void setOwner(ItemStack stack, String owner) - { - if(stack.stackTagCompound == null) - { - stack.setTagCompound(new NBTTagCompound()); - } - - if(owner == null || owner.isEmpty()) - { - stack.stackTagCompound.removeTag("owner"); - return; - } - - stack.stackTagCompound.setString("owner", owner); - } + @Override + public double getMaxTransfer(ItemStack itemStack) { + return getMaxEnergy(itemStack) * 0.005; + } - @Override - public SecurityMode getSecurity(ItemStack stack) - { - if(stack.stackTagCompound == null || !general.allowProtection) - { - return SecurityMode.PUBLIC; - } + @Override + public boolean canReceive(ItemStack itemStack) { + return MachineType.get(itemStack).isElectric; + } - return SecurityMode.values()[stack.stackTagCompound.getInteger("security")]; - } + @Override + public boolean canSend(ItemStack itemStack) { + return false; + } - @Override - public void setSecurity(ItemStack stack, SecurityMode mode) - { - if(stack.stackTagCompound == null) - { - stack.setTagCompound(new NBTTagCompound()); - } - - stack.stackTagCompound.setInteger("security", mode.ordinal()); - } + @Override + public int receiveEnergy(ItemStack theItem, int energy, boolean simulate) { + if (canReceive(theItem)) { + double energyNeeded = getMaxEnergy(theItem) - getEnergy(theItem); + double toReceive = Math.min(energy * general.FROM_TE, energyNeeded); - @Override - public boolean hasSecurity(ItemStack stack) - { - MachineType type = MachineType.get(stack); - - if(type != MachineType.LASER && type != MachineType.CHARGEPAD && type != MachineType.TELEPORTER && type != MachineType.QUANTUM_ENTANGLOPORTER) - { - return true; - } - - return false; - } - - @Override - public boolean hasOwner(ItemStack stack) - { - return hasSecurity(stack); - } + if (!simulate) { + setEnergy(theItem, getEnergy(theItem) + toReceive); + } + + return (int) Math.round(toReceive * general.TO_TE); + } + + return 0; + } + + @Override + public int extractEnergy(ItemStack theItem, int energy, boolean simulate) { + if (canSend(theItem)) { + double energyRemaining = getEnergy(theItem); + double toSend = Math.min((energy * general.FROM_TE), energyRemaining); + + if (!simulate) { + setEnergy(theItem, getEnergy(theItem) - toSend); + } + + return (int) Math.round(toSend * general.TO_TE); + } + + return 0; + } + + @Override + public int getEnergyStored(ItemStack theItem) { + return (int) (getEnergy(theItem) * general.TO_TE); + } + + @Override + public int getMaxEnergyStored(ItemStack theItem) { + return (int) (getMaxEnergy(theItem) * general.TO_TE); + } + + @Override + @Method(modid = "IC2") + public IElectricItemManager getManager(ItemStack itemStack) { + return IC2ItemManager.getManager(this); + } + + @Override + @Method(modid = "IC2") + public Item getChargedItem(ItemStack itemStack) { + return this; + } + + @Override + @Method(modid = "IC2") + public Item getEmptyItem(ItemStack itemStack) { + return this; + } + + @Override + public FluidStack getFluid(ItemStack container) { + return getFluidStack(container); + } + + @Override + public int getCapacity(ItemStack container) { + return FluidTankTier.values()[getBaseTier(container).ordinal()].storage; + } + + @Override + public int fill(ItemStack container, FluidStack resource, boolean doFill) { + if (MachineType.get(container) == MachineType.FLUID_TANK && resource != null) { + FluidStack stored = getFluidStack(container); + int toFill; + + if (stored != null && stored.getFluid() != resource.getFluid()) { + return 0; + } + + if (stored == null) { + toFill = Math.min(resource.amount, getCapacity(container)); + } else { + toFill + = Math.min(resource.amount, getCapacity(container) - stored.amount); + } + + if (doFill) { + int fillAmount = toFill + (stored == null ? 0 : stored.amount); + setFluidStack( + PipeUtils.copy( + resource, (stored != null ? stored.amount : 0) + toFill + ), + container + ); + } + + return toFill; + } + + return 0; + } + + @Override + public FluidStack drain(ItemStack container, int maxDrain, boolean doDrain) { + if (MachineType.get(container) == MachineType.FLUID_TANK) { + FluidStack stored = getFluidStack(container); + + if (stored != null) { + FluidStack toDrain + = PipeUtils.copy(stored, Math.min(stored.amount, maxDrain)); + + if (doDrain) { + stored.amount -= toDrain.amount; + setFluidStack(stored.amount > 0 ? stored : null, container); + } + + return toDrain; + } + } + + return null; + } + + @Override + public BaseTier getBaseTier(ItemStack itemstack) { + if (itemstack.stackTagCompound == null) { + return BaseTier.BASIC; + } + + return BaseTier.values()[itemstack.stackTagCompound.getInteger("tier")]; + } + + @Override + public void setBaseTier(ItemStack itemstack, BaseTier tier) { + if (itemstack.stackTagCompound == null) { + itemstack.setTagCompound(new NBTTagCompound()); + } + + itemstack.stackTagCompound.setInteger("tier", tier.ordinal()); + } + + @Override + public String getOwner(ItemStack stack) { + if (stack.stackTagCompound != null && stack.stackTagCompound.hasKey("owner")) { + return stack.stackTagCompound.getString("owner"); + } + + return null; + } + + @Override + public void setOwner(ItemStack stack, String owner) { + if (stack.stackTagCompound == null) { + stack.setTagCompound(new NBTTagCompound()); + } + + if (owner == null || owner.isEmpty()) { + stack.stackTagCompound.removeTag("owner"); + return; + } + + stack.stackTagCompound.setString("owner", owner); + } + + @Override + public SecurityMode getSecurity(ItemStack stack) { + if (stack.stackTagCompound == null || !general.allowProtection) { + return SecurityMode.PUBLIC; + } + + return SecurityMode.values()[stack.stackTagCompound.getInteger("security")]; + } + + @Override + public void setSecurity(ItemStack stack, SecurityMode mode) { + if (stack.stackTagCompound == null) { + stack.setTagCompound(new NBTTagCompound()); + } + + stack.stackTagCompound.setInteger("security", mode.ordinal()); + } + + @Override + public boolean hasSecurity(ItemStack stack) { + MachineType type = MachineType.get(stack); + + if (type != MachineType.LASER && type != MachineType.CHARGEPAD + && type != MachineType.TELEPORTER + && type != MachineType.QUANTUM_ENTANGLOPORTER) { + return true; + } + + return false; + } + + @Override + public boolean hasOwner(ItemStack stack) { + return hasSecurity(stack); + } } diff --git a/src/main/java/mekanism/common/item/ItemBlockOre.java b/src/main/java/mekanism/common/item/ItemBlockOre.java index 14055a59f..2b17265e5 100644 --- a/src/main/java/mekanism/common/item/ItemBlockOre.java +++ b/src/main/java/mekanism/common/item/ItemBlockOre.java @@ -2,6 +2,8 @@ package mekanism.common.item; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.EnumColor; import mekanism.client.MekKeyHandler; import mekanism.client.MekanismKeyHandler; @@ -13,8 +15,6 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; /** * Item class for handling multiple ore block IDs. @@ -24,63 +24,67 @@ import cpw.mods.fml.relauncher.SideOnly; * @author AidanBrady * */ -public class ItemBlockOre extends ItemBlock -{ - public Block metaBlock; +public class ItemBlockOre extends ItemBlock { + public Block metaBlock; - public ItemBlockOre(Block block) - { - super(block); - metaBlock = block; - setHasSubtypes(true); - } + public ItemBlockOre(Block block) { + super(block); + metaBlock = block; + setHasSubtypes(true); + } - @Override - @SideOnly(Side.CLIENT) - public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) - { - if(!MekKeyHandler.getIsKeyPressed(MekanismKeyHandler.sneakKey)) - { - list.add("Hold " + EnumColor.AQUA + GameSettings.getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode()) + EnumColor.GREY + LangUtils.localize("tooltip.forDetails") + "."); - } - else { - list.addAll(MekanismUtils.splitTooltip(LangUtils.localize("tooltip." + getUnlocalizedName(itemstack).replace("tile.OreBlock.", "")), itemstack)); - } - } + @Override + @SideOnly(Side.CLIENT) + public void addInformation( + ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag + ) { + if (!MekKeyHandler.getIsKeyPressed(MekanismKeyHandler.sneakKey)) { + list.add( + "Hold " + EnumColor.AQUA + + GameSettings.getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode( + )) + + EnumColor.GREY + LangUtils.localize("tooltip.forDetails") + "." + ); + } else { + list.addAll(MekanismUtils.splitTooltip( + LangUtils.localize( + "tooltip." + + getUnlocalizedName(itemstack).replace("tile.OreBlock.", "") + ), + itemstack + )); + } + } - @Override - public int getMetadata(int i) - { - return i; - } + @Override + public int getMetadata(int i) { + return i; + } - @Override - public IIcon getIconFromDamage(int i) - { - return metaBlock.getIcon(2, i); - } + @Override + public IIcon getIconFromDamage(int i) { + return metaBlock.getIcon(2, i); + } - @Override - public String getUnlocalizedName(ItemStack itemstack) - { - String name = ""; + @Override + public String getUnlocalizedName(ItemStack itemstack) { + String name = ""; - switch(itemstack.getItemDamage()) - { - case 0: - name = "OsmiumOre"; - break; - case 1: - name = "CopperOre"; - break; - case 2: - name = "TinOre"; - break; - default: - name = "Unknown"; - break; - } + switch (itemstack.getItemDamage()) { + case 0: + name = "OsmiumOre"; + break; + case 1: + name = "CopperOre"; + break; + case 2: + name = "TinOre"; + break; + default: + name = "Unknown"; + break; + } - return getUnlocalizedName() + "." + name; - } + return getUnlocalizedName() + "." + name; + } } diff --git a/src/main/java/mekanism/common/item/ItemBlockPlastic.java b/src/main/java/mekanism/common/item/ItemBlockPlastic.java index 1558d3fe2..c77a23eb8 100644 --- a/src/main/java/mekanism/common/item/ItemBlockPlastic.java +++ b/src/main/java/mekanism/common/item/ItemBlockPlastic.java @@ -1,5 +1,7 @@ package mekanism.common.item; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.EnumColor; import mekanism.common.util.LangUtils; import net.minecraft.block.Block; @@ -7,58 +9,50 @@ import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.util.StatCollector; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class ItemBlockPlastic extends ItemBlock -{ - public Block metaBlock; +public class ItemBlockPlastic extends ItemBlock { + public Block metaBlock; - public ItemBlockPlastic(Block block) - { - super(block); - metaBlock = block; - setHasSubtypes(true); - } + public ItemBlockPlastic(Block block) { + super(block); + metaBlock = block; + setHasSubtypes(true); + } - @Override - public int getMetadata(int i) - { - return i; - } + @Override + public int getMetadata(int i) { + return i; + } - @Override - public IIcon getIconFromDamage(int i) - { - return metaBlock.getIcon(2, i); - } + @Override + public IIcon getIconFromDamage(int i) { + return metaBlock.getIcon(2, i); + } - @Override - public String getItemStackDisplayName(ItemStack stack) - { - EnumColor colour = EnumColor.DYES[stack.getItemDamage()&15]; - String colourName; + @Override + public String getItemStackDisplayName(ItemStack stack) { + EnumColor colour = EnumColor.DYES[stack.getItemDamage() & 15]; + String colourName; - if(StatCollector.canTranslate(getUnlocalizedName(stack) + "." + colour.dyeName)) - { + if (StatCollector.canTranslate( + getUnlocalizedName(stack) + "." + colour.dyeName + )) { return LangUtils.localize(getUnlocalizedName(stack) + "." + colour.dyeName); } - if(colour == EnumColor.BLACK) - { - colourName = EnumColor.DARK_GREY + colour.getDyeName(); - } - else { - colourName = colour.getDyedName(); - } + if (colour == EnumColor.BLACK) { + colourName = EnumColor.DARK_GREY + colour.getDyeName(); + } else { + colourName = colour.getDyedName(); + } - return colourName + " " + super.getItemStackDisplayName(stack); - } + return colourName + " " + super.getItemStackDisplayName(stack); + } - @SideOnly(Side.CLIENT) - public int getColorFromItemStack(ItemStack stack, int par2) - { - EnumColor colour = EnumColor.DYES[stack.getItemDamage()&15]; - return (int)(colour.getColor(0)*255) << 16 | (int)(colour.getColor(1)*255) << 8 | (int)(colour.getColor(2)*255); - } + @SideOnly(Side.CLIENT) + public int getColorFromItemStack(ItemStack stack, int par2) { + EnumColor colour = EnumColor.DYES[stack.getItemDamage() & 15]; + return (int) (colour.getColor(0) * 255) << 16 + | (int) (colour.getColor(1) * 255) << 8 | (int) (colour.getColor(2) * 255); + } } diff --git a/src/main/java/mekanism/common/item/ItemClump.java b/src/main/java/mekanism/common/item/ItemClump.java index ff03f16b1..a9f5c2e54 100644 --- a/src/main/java/mekanism/common/item/ItemClump.java +++ b/src/main/java/mekanism/common/item/ItemClump.java @@ -9,48 +9,43 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -public class ItemClump extends ItemMekanism -{ - public IIcon[] icons = new IIcon[256]; +public class ItemClump extends ItemMekanism { + public IIcon[] icons = new IIcon[256]; - public ItemClump() - { - super(); - setHasSubtypes(true); - } + public ItemClump() { + super(); + setHasSubtypes(true); + } - @Override - public void registerIcons(IIconRegister register) - { - for(int i = 0; i < Resource.values().length; i++) - { - icons[i] = register.registerIcon("mekanism:" + Resource.values()[i].getName() + "Clump"); - } - } + @Override + public void registerIcons(IIconRegister register) { + for (int i = 0; i < Resource.values().length; i++) { + icons[i] = register.registerIcon( + "mekanism:" + Resource.values()[i].getName() + "Clump" + ); + } + } - @Override - public IIcon getIconFromDamage(int meta) - { - return icons[meta]; - } + @Override + public IIcon getIconFromDamage(int meta) { + return icons[meta]; + } - @Override - public void getSubItems(Item item, CreativeTabs tabs, List itemList) - { - for(int counter = 0; counter < Resource.values().length; counter++) - { - itemList.add(new ItemStack(this, 1, counter)); - } - } + @Override + public void getSubItems(Item item, CreativeTabs tabs, List itemList) { + for (int counter = 0; counter < Resource.values().length; counter++) { + itemList.add(new ItemStack(this, 1, counter)); + } + } - @Override - public String getUnlocalizedName(ItemStack item) - { - if(item.getItemDamage() <= Resource.values().length-1) - { - return "item." + Resource.values()[item.getItemDamage()].getName().toLowerCase() + "Clump"; - } - - return "Invalid"; - } + @Override + public String getUnlocalizedName(ItemStack item) { + if (item.getItemDamage() <= Resource.values().length - 1) { + return "item." + + Resource.values()[item.getItemDamage()].getName().toLowerCase() + + "Clump"; + } + + return "Invalid"; + } } diff --git a/src/main/java/mekanism/common/item/ItemConfigurationCard.java b/src/main/java/mekanism/common/item/ItemConfigurationCard.java index ce4af3e1a..478483b2e 100644 --- a/src/main/java/mekanism/common/item/ItemConfigurationCard.java +++ b/src/main/java/mekanism/common/item/ItemConfigurationCard.java @@ -17,168 +17,180 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChatComponentText; import net.minecraft.world.World; -public class ItemConfigurationCard extends ItemMekanism -{ - public ItemConfigurationCard() - { - super(); - - setMaxStackSize(1); - } - - @Override - public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) - { - super.addInformation(itemstack, entityplayer, list, flag); - - list.add(EnumColor.GREY + LangUtils.localize("gui.data") + ": " + EnumColor.INDIGO + LangUtils.localize(getDataType(itemstack))); - } - - @Override - public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) - { - if(!world.isRemote) - { - TileEntity tileEntity = world.getTileEntity(x, y, z); - - if(tileEntity instanceof IConfigCardAccess) - { - if(player.isSneaking()) - { - NBTTagCompound data = getBaseData(tileEntity); - - if(tileEntity instanceof ISpecialConfigData) - { - data = ((ISpecialConfigData)tileEntity).getConfigurationData(data); - } - - if(data != null) - { - data.setString("dataType", getNameFromTile(tileEntity)); - setData(stack, data); - player.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + LangUtils.localize("tooltip.configurationCard.got").replaceAll("%s", EnumColor.INDIGO + LangUtils.localize(data.getString("dataType")) + EnumColor.GREY))); - } - - return true; - } - else if(getData(stack) != null) - { - if(getNameFromTile(tileEntity).equals(getDataType(stack))) - { - setBaseData(getData(stack), tileEntity); - - if(tileEntity instanceof ISpecialConfigData) - { - ((ISpecialConfigData)tileEntity).setConfigurationData(getData(stack)); - } - - player.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.DARK_GREEN + LangUtils.localize("tooltip.configurationCard.set").replaceAll("%s", EnumColor.INDIGO + LangUtils.localize(getDataType(stack)) + EnumColor.DARK_GREEN))); - setData(stack, null); - } - else { - player.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.RED + LangUtils.localize("tooltip.configurationCard.unequal") + ".")); - } - - return true; - } - } - } - - return false; - } - - private NBTTagCompound getBaseData(TileEntity tile) - { - NBTTagCompound nbtTags = new NBTTagCompound(); - - if(tile instanceof IRedstoneControl) - { - nbtTags.setInteger("controlType", ((IRedstoneControl)tile).getControlType().ordinal()); - } - - if(tile instanceof ISideConfiguration) - { - ((ISideConfiguration)tile).getConfig().write(nbtTags); - ((ISideConfiguration)tile).getEjector().write(nbtTags); - } - - return nbtTags; - } - - private void setBaseData(NBTTagCompound nbtTags, TileEntity tile) - { - if(tile instanceof IRedstoneControl) - { - ((IRedstoneControl)tile).setControlType(RedstoneControl.values()[nbtTags.getInteger("controlType")]); - } - - if(tile instanceof ISideConfiguration) - { - ((ISideConfiguration)tile).getConfig().read(nbtTags); - ((ISideConfiguration)tile).getEjector().read(nbtTags); - } - } - - private String getNameFromTile(TileEntity tile) - { - String ret = Integer.toString(tile.hashCode()); - - if(tile instanceof TileEntityContainerBlock) - { - ret = tile.getBlockType().getUnlocalizedName() + "." + ((TileEntityContainerBlock)tile).fullName + ".name"; - } - - if(tile instanceof ISpecialConfigData) - { - ret = ((ISpecialConfigData)tile).getDataType(); - } - - return ret; - } - - public void setData(ItemStack itemstack, NBTTagCompound data) - { - if(itemstack.stackTagCompound == null) - { - itemstack.setTagCompound(new NBTTagCompound()); - } +public class ItemConfigurationCard extends ItemMekanism { + public ItemConfigurationCard() { + super(); - if(data != null) - { - itemstack.stackTagCompound.setTag("data", data); - } - else { - itemstack.stackTagCompound.removeTag("data"); - } - } + setMaxStackSize(1); + } - public NBTTagCompound getData(ItemStack itemstack) - { - if(itemstack.stackTagCompound == null) - { - return null; - } - - NBTTagCompound data = itemstack.stackTagCompound.getCompoundTag("data"); - - if(data.hasNoTags()) - { - return null; - } - else { - return itemstack.stackTagCompound.getCompoundTag("data"); - } - } + @Override + public void addInformation( + ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag + ) { + super.addInformation(itemstack, entityplayer, list, flag); - public String getDataType(ItemStack itemstack) - { - NBTTagCompound data = getData(itemstack); - - if(data != null) - { - return data.getString("dataType"); - } - - return "gui.none"; - } + list.add( + EnumColor.GREY + LangUtils.localize("gui.data") + ": " + EnumColor.INDIGO + + LangUtils.localize(getDataType(itemstack)) + ); + } + + @Override + public boolean onItemUseFirst( + ItemStack stack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int side, + float hitX, + float hitY, + float hitZ + ) { + if (!world.isRemote) { + TileEntity tileEntity = world.getTileEntity(x, y, z); + + if (tileEntity instanceof IConfigCardAccess) { + if (player.isSneaking()) { + NBTTagCompound data = getBaseData(tileEntity); + + if (tileEntity instanceof ISpecialConfigData) { + data = ((ISpecialConfigData) tileEntity) + .getConfigurationData(data); + } + + if (data != null) { + data.setString("dataType", getNameFromTile(tileEntity)); + setData(stack, data); + player.addChatMessage(new ChatComponentText( + EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + + LangUtils.localize("tooltip.configurationCard.got") + .replaceAll( + "%s", + EnumColor.INDIGO + + LangUtils.localize(data.getString("dataType")) + + EnumColor.GREY + ) + )); + } + + return true; + } else if (getData(stack) != null) { + if (getNameFromTile(tileEntity).equals(getDataType(stack))) { + setBaseData(getData(stack), tileEntity); + + if (tileEntity instanceof ISpecialConfigData) { + ((ISpecialConfigData) tileEntity) + .setConfigurationData(getData(stack)); + } + + player.addChatMessage(new ChatComponentText( + EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.DARK_GREEN + + LangUtils.localize("tooltip.configurationCard.set") + .replaceAll( + "%s", + EnumColor.INDIGO + + LangUtils.localize(getDataType(stack)) + + EnumColor.DARK_GREEN + ) + )); + setData(stack, null); + } else { + player.addChatMessage(new ChatComponentText( + EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.RED + + LangUtils.localize("tooltip.configurationCard.unequal") + + "." + )); + } + + return true; + } + } + } + + return false; + } + + private NBTTagCompound getBaseData(TileEntity tile) { + NBTTagCompound nbtTags = new NBTTagCompound(); + + if (tile instanceof IRedstoneControl) { + nbtTags.setInteger( + "controlType", ((IRedstoneControl) tile).getControlType().ordinal() + ); + } + + if (tile instanceof ISideConfiguration) { + ((ISideConfiguration) tile).getConfig().write(nbtTags); + ((ISideConfiguration) tile).getEjector().write(nbtTags); + } + + return nbtTags; + } + + private void setBaseData(NBTTagCompound nbtTags, TileEntity tile) { + if (tile instanceof IRedstoneControl) { + ((IRedstoneControl) tile) + .setControlType(RedstoneControl.values( + )[nbtTags.getInteger("controlType")]); + } + + if (tile instanceof ISideConfiguration) { + ((ISideConfiguration) tile).getConfig().read(nbtTags); + ((ISideConfiguration) tile).getEjector().read(nbtTags); + } + } + + private String getNameFromTile(TileEntity tile) { + String ret = Integer.toString(tile.hashCode()); + + if (tile instanceof TileEntityContainerBlock) { + ret = tile.getBlockType().getUnlocalizedName() + "." + + ((TileEntityContainerBlock) tile).fullName + ".name"; + } + + if (tile instanceof ISpecialConfigData) { + ret = ((ISpecialConfigData) tile).getDataType(); + } + + return ret; + } + + public void setData(ItemStack itemstack, NBTTagCompound data) { + if (itemstack.stackTagCompound == null) { + itemstack.setTagCompound(new NBTTagCompound()); + } + + if (data != null) { + itemstack.stackTagCompound.setTag("data", data); + } else { + itemstack.stackTagCompound.removeTag("data"); + } + } + + public NBTTagCompound getData(ItemStack itemstack) { + if (itemstack.stackTagCompound == null) { + return null; + } + + NBTTagCompound data = itemstack.stackTagCompound.getCompoundTag("data"); + + if (data.hasNoTags()) { + return null; + } else { + return itemstack.stackTagCompound.getCompoundTag("data"); + } + } + + public String getDataType(ItemStack itemstack) { + NBTTagCompound data = getData(itemstack); + + if (data != null) { + return data.getString("dataType"); + } + + return "gui.none"; + } } diff --git a/src/main/java/mekanism/common/item/ItemConfigurator.java b/src/main/java/mekanism/common/item/ItemConfigurator.java index 54cb1d919..0575131ed 100644 --- a/src/main/java/mekanism/common/item/ItemConfigurator.java +++ b/src/main/java/mekanism/common/item/ItemConfigurator.java @@ -5,6 +5,11 @@ import java.util.Arrays; import java.util.List; import java.util.Random; +import buildcraft.api.tools.IToolWrench; +import cofh.api.item.IToolHammer; +import cpw.mods.fml.common.Optional.Interface; +import cpw.mods.fml.common.Optional.InterfaceList; +import cpw.mods.fml.common.Optional.Method; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.IConfigurable; @@ -32,327 +37,365 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChatComponentText; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import buildcraft.api.tools.IToolWrench; -import cofh.api.item.IToolHammer; -import cpw.mods.fml.common.Optional.Interface; -import cpw.mods.fml.common.Optional.InterfaceList; -import cpw.mods.fml.common.Optional.Method; @InterfaceList({ - @Interface(iface = "buildcraft.api.tools.IToolWrench", modid = "BuildCraft") + @Interface(iface = "buildcraft.api.tools.IToolWrench", modid = "BuildCraft") }) -public class ItemConfigurator extends ItemEnergized implements IMekWrench, IToolWrench, IToolHammer -{ - public final int ENERGY_PER_CONFIGURE = 400; - public final int ENERGY_PER_ITEM_DUMP = 8; +public class ItemConfigurator + extends ItemEnergized implements IMekWrench, IToolWrench, IToolHammer { + public final int ENERGY_PER_CONFIGURE = 400; + public final int ENERGY_PER_ITEM_DUMP = 8; - private Random random = new Random(); + private Random random = new Random(); - public ItemConfigurator() - { - super(60000); - } + public ItemConfigurator() { + super(60000); + } - @Override - public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) - { - super.addInformation(itemstack, entityplayer, list, flag); - list.add(EnumColor.PINK + LangUtils.localize("gui.state") + ": " + getColor(getState(itemstack)) + getStateDisplay(getState(itemstack))); - } + @Override + public void addInformation( + ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag + ) { + super.addInformation(itemstack, entityplayer, list, flag); + list.add( + EnumColor.PINK + LangUtils.localize("gui.state") + ": " + + getColor(getState(itemstack)) + getStateDisplay(getState(itemstack)) + ); + } - @Override - public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) - { - if(!world.isRemote) - { - Block block = world.getBlock(x, y, z); - TileEntity tile = world.getTileEntity(x, y, z); + @Override + public boolean onItemUseFirst( + ItemStack stack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int side, + float hitX, + float hitY, + float hitZ + ) { + if (!world.isRemote) { + Block block = world.getBlock(x, y, z); + TileEntity tile = world.getTileEntity(x, y, z); - if(getState(stack).isConfigurating()) //Configurate - { - if(tile instanceof ISideConfiguration && ((ISideConfiguration)tile).getConfig().supports(getState(stack).getTransmission())) - { - ISideConfiguration config = (ISideConfiguration)tile; - SideData initial = config.getConfig().getOutput(getState(stack).getTransmission(), side, config.getOrientation()); + if (getState(stack).isConfigurating()) //Configurate + { + if (tile instanceof ISideConfiguration + && ((ISideConfiguration) tile) + .getConfig() + .supports(getState(stack).getTransmission())) { + ISideConfiguration config = (ISideConfiguration) tile; + SideData initial = config.getConfig().getOutput( + getState(stack).getTransmission(), side, config.getOrientation() + ); - if(initial != TileComponentConfig.EMPTY) - { - if(!player.isSneaking()) - { - player.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + getViewModeText(getState(stack).getTransmission()) + ": " + initial.color + initial.localize() + " (" + initial.color.getName() + ")")); - } - else { - if(getEnergy(stack) >= ENERGY_PER_CONFIGURE) - { - if(SecurityUtils.canAccess(player, tile)) - { - setEnergy(stack, getEnergy(stack) - ENERGY_PER_CONFIGURE); - MekanismUtils.incrementOutput(config, getState(stack).getTransmission(), MekanismUtils.getBaseOrientation(side, config.getOrientation())); - SideData data = config.getConfig().getOutput(getState(stack).getTransmission(), side, config.getOrientation()); - player.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + getToggleModeText(getState(stack).getTransmission()) + ": " + data.color + data.localize() + " (" + data.color.getName() + ")")); - - if(config instanceof TileEntityBasicBlock) - { - TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)config; - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tileEntity), tileEntity.getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(tileEntity))); - } - } - else { - SecurityUtils.displayNoAccess(player); - } - } - } - } - - return true; - } - else if(tile instanceof IConfigurable) - { - IConfigurable config = (IConfigurable)tile; + if (initial != TileComponentConfig.EMPTY) { + if (!player.isSneaking()) { + player.addChatMessage(new ChatComponentText( + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + + getViewModeText(getState(stack).getTransmission()) + + ": " + initial.color + initial.localize() + " (" + + initial.color.getName() + ")" + )); + } else { + if (getEnergy(stack) >= ENERGY_PER_CONFIGURE) { + if (SecurityUtils.canAccess(player, tile)) { + setEnergy( + stack, getEnergy(stack) - ENERGY_PER_CONFIGURE + ); + MekanismUtils.incrementOutput( + config, + getState(stack).getTransmission(), + MekanismUtils.getBaseOrientation( + side, config.getOrientation() + ) + ); + SideData data = config.getConfig().getOutput( + getState(stack).getTransmission(), + side, + config.getOrientation() + ); + player.addChatMessage(new ChatComponentText( + EnumColor.DARK_BLUE + "[Mekanism]" + + EnumColor.GREY + " " + + getToggleModeText( + getState(stack).getTransmission() + ) + + ": " + data.color + data.localize() + " (" + + data.color.getName() + ")" + )); - if(SecurityUtils.canAccess(player, tile)) - { - if(player.isSneaking()) - { - return config.onSneakRightClick(player, side); - } - else { - return config.onRightClick(player, side); - } - } - else { - SecurityUtils.displayNoAccess(player); - - return true; - } - } - } - else if(getState(stack) == ConfiguratorMode.EMPTY) //Empty - { - if(tile instanceof TileEntityContainerBlock) - { - IInventory inv = (IInventory)tile; + if (config instanceof TileEntityBasicBlock) { + TileEntityBasicBlock tileEntity + = (TileEntityBasicBlock) config; + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(tileEntity), + tileEntity.getNetworkedData(new ArrayList( + )) + ), + new Range4D(Coord4D.get(tileEntity)) + ); + } + } else { + SecurityUtils.displayNoAccess(player); + } + } + } + } - if(SecurityUtils.canAccess(player, tile)) - { - for(int i = 0; i < inv.getSizeInventory(); i++) - { - ItemStack slotStack = inv.getStackInSlot(i); + return true; + } else if (tile instanceof IConfigurable) { + IConfigurable config = (IConfigurable) tile; - if(slotStack != null) - { - if(getEnergy(stack) < ENERGY_PER_ITEM_DUMP) - { - break; - } + if (SecurityUtils.canAccess(player, tile)) { + if (player.isSneaking()) { + return config.onSneakRightClick(player, side); + } else { + return config.onRightClick(player, side); + } + } else { + SecurityUtils.displayNoAccess(player); - float xRandom = random.nextFloat() * 0.8F + 0.1F; - float yRandom = random.nextFloat() * 0.8F + 0.1F; - float zRandom = random.nextFloat() * 0.8F + 0.1F; + return true; + } + } + } else if (getState(stack) == ConfiguratorMode.EMPTY) //Empty + { + if (tile instanceof TileEntityContainerBlock) { + IInventory inv = (IInventory) tile; - while(slotStack.stackSize > 0) - { - int j = random.nextInt(21) + 10; + if (SecurityUtils.canAccess(player, tile)) { + for (int i = 0; i < inv.getSizeInventory(); i++) { + ItemStack slotStack = inv.getStackInSlot(i); - if(j > slotStack.stackSize) - { - j = slotStack.stackSize; - } + if (slotStack != null) { + if (getEnergy(stack) < ENERGY_PER_ITEM_DUMP) { + break; + } - slotStack.stackSize -= j; - EntityItem item = new EntityItem(world, x + xRandom, y + yRandom, z + zRandom, new ItemStack(slotStack.getItem(), j, slotStack.getItemDamage())); + float xRandom = random.nextFloat() * 0.8F + 0.1F; + float yRandom = random.nextFloat() * 0.8F + 0.1F; + float zRandom = random.nextFloat() * 0.8F + 0.1F; - if(slotStack.hasTagCompound()) - { - item.getEntityItem().setTagCompound((NBTTagCompound)slotStack.getTagCompound().copy()); - } + while (slotStack.stackSize > 0) { + int j = random.nextInt(21) + 10; - float k = 0.05F; - item.motionX = random.nextGaussian() * k; - item.motionY = random.nextGaussian() * k + 0.2F; - item.motionZ = random.nextGaussian() * k; - world.spawnEntityInWorld(item); + if (j > slotStack.stackSize) { + j = slotStack.stackSize; + } - inv.setInventorySlotContents(i, null); - setEnergy(stack, getEnergy(stack) - ENERGY_PER_ITEM_DUMP); - } - } - } + slotStack.stackSize -= j; + EntityItem item = new EntityItem( + world, + x + xRandom, + y + yRandom, + z + zRandom, + new ItemStack( + slotStack.getItem(), + j, + slotStack.getItemDamage() + ) + ); - return true; - } - else { - SecurityUtils.displayNoAccess(player); - return true; - } - } - } - else if(getState(stack) == ConfiguratorMode.ROTATE) //Rotate - { - ForgeDirection axis = ForgeDirection.getOrientation(side); - List l = Arrays.asList(block.getValidRotations(world, x, y, z)); + if (slotStack.hasTagCompound()) { + item.getEntityItem().setTagCompound( + (NBTTagCompound) slotStack.getTagCompound() + .copy() + ); + } - if(!player.isSneaking() && l.contains(axis)) - { - block.rotateBlock(world, x, y, z, axis); - } - else if(player.isSneaking() && l.contains(axis.getOpposite())) - { - block.rotateBlock(world, x, y, z, axis.getOpposite()); - } + float k = 0.05F; + item.motionX = random.nextGaussian() * k; + item.motionY = random.nextGaussian() * k + 0.2F; + item.motionZ = random.nextGaussian() * k; + world.spawnEntityInWorld(item); - return true; - } - else if(getState(stack) == ConfiguratorMode.WRENCH) //Wrench - { - return false; - } - } + inv.setInventorySlotContents(i, null); + setEnergy( + stack, getEnergy(stack) - ENERGY_PER_ITEM_DUMP + ); + } + } + } - return false; - } - - public String getViewModeText(TransmissionType type) - { - String base = LangUtils.localize("tooltip.configurator.viewMode"); - return String.format(base, type.localize().toLowerCase()); - } - - public String getToggleModeText(TransmissionType type) - { - String base = LangUtils.localize("tooltip.configurator.toggleMode"); - return String.format(base, type.localize()); - } + return true; + } else { + SecurityUtils.displayNoAccess(player); + return true; + } + } + } else if (getState(stack) == ConfiguratorMode.ROTATE) //Rotate + { + ForgeDirection axis = ForgeDirection.getOrientation(side); + List l + = Arrays.asList(block.getValidRotations(world, x, y, z)); - public String getStateDisplay(ConfiguratorMode mode) - { - return mode.getName(); - } + if (!player.isSneaking() && l.contains(axis)) { + block.rotateBlock(world, x, y, z, axis); + } else if (player.isSneaking() && l.contains(axis.getOpposite())) { + block.rotateBlock(world, x, y, z, axis.getOpposite()); + } - public EnumColor getColor(ConfiguratorMode mode) - { - return mode.getColor(); - } + return true; + } else if (getState(stack) == ConfiguratorMode.WRENCH) //Wrench + { + return false; + } + } - public void setState(ItemStack itemstack, ConfiguratorMode state) - { - if(itemstack.stackTagCompound == null) - { - itemstack.setTagCompound(new NBTTagCompound()); - } + return false; + } - itemstack.stackTagCompound.setInteger("state", state.ordinal()); - } + public String getViewModeText(TransmissionType type) { + String base = LangUtils.localize("tooltip.configurator.viewMode"); + return String.format(base, type.localize().toLowerCase()); + } - public ConfiguratorMode getState(ItemStack itemstack) - { - if(itemstack.stackTagCompound == null) - { - return ConfiguratorMode.CONFIGURATE_ITEMS; - } + public String getToggleModeText(TransmissionType type) { + String base = LangUtils.localize("tooltip.configurator.toggleMode"); + return String.format(base, type.localize()); + } - if(itemstack.stackTagCompound.getTag("state") != null) - { - return ConfiguratorMode.values()[itemstack.stackTagCompound.getInteger("state")]; - } + public String getStateDisplay(ConfiguratorMode mode) { + return mode.getName(); + } - return ConfiguratorMode.CONFIGURATE_ITEMS; - } + public EnumColor getColor(ConfiguratorMode mode) { + return mode.getColor(); + } - @Override - public boolean canSend(ItemStack itemStack) - { - return false; - } + public void setState(ItemStack itemstack, ConfiguratorMode state) { + if (itemstack.stackTagCompound == null) { + itemstack.setTagCompound(new NBTTagCompound()); + } - @Override - @Method(modid = "BuildCraft") - public boolean canWrench(EntityPlayer player, int x, int y, int z) - { - return canUseWrench(player, x, y, z); - } + itemstack.stackTagCompound.setInteger("state", state.ordinal()); + } - @Override - @Method(modid = "BuildCraft") - public void wrenchUsed(EntityPlayer player, int x, int y, int z) {} + public ConfiguratorMode getState(ItemStack itemstack) { + if (itemstack.stackTagCompound == null) { + return ConfiguratorMode.CONFIGURATE_ITEMS; + } - @Override - public boolean canUseWrench(EntityPlayer player, int x, int y, int z) - { - return getState(player.getCurrentEquippedItem()) == ConfiguratorMode.WRENCH; - } + if (itemstack.stackTagCompound.getTag("state") != null) { + return ConfiguratorMode.values( + )[itemstack.stackTagCompound.getInteger("state")]; + } - @Override - public boolean doesSneakBypassUse(World world, int x, int y, int z, EntityPlayer player) - { - return getState(player.getCurrentEquippedItem()) == ConfiguratorMode.WRENCH; - } + return ConfiguratorMode.CONFIGURATE_ITEMS; + } - @Override - public boolean isUsable(ItemStack item, EntityLivingBase user, int x, int y, int z) - { - return user instanceof EntityPlayer && canUseWrench((EntityPlayer)user, x, y, z); - } + @Override + public boolean canSend(ItemStack itemStack) { + return false; + } - @Override - public void toolUsed(ItemStack item, EntityLivingBase user, int x, int y, int z) {} - - public static enum ConfiguratorMode - { - CONFIGURATE_ITEMS("configurate", "(" + TransmissionType.ITEM.localize() + ")", EnumColor.BRIGHT_GREEN, true), - CONFIGURATE_FLUIDS("configurate", "(" + TransmissionType.FLUID.localize() + ")", EnumColor.BRIGHT_GREEN, true), - CONFIGURATE_GASES("configurate", "(" + TransmissionType.GAS.localize() + ")", EnumColor.BRIGHT_GREEN, true), - CONFIGURATE_ENERGY("configurate", "(" + TransmissionType.ENERGY.localize() + ")", EnumColor.BRIGHT_GREEN, true), - CONFIGURATE_HEAT("configurate", "(" + TransmissionType.HEAT.localize() + ")", EnumColor.BRIGHT_GREEN, true), - EMPTY("empty", "", EnumColor.DARK_RED, false), - ROTATE("rotate", "", EnumColor.YELLOW, false), - WRENCH("wrench", "", EnumColor.PINK, false); - - private String name; - private String info; - private EnumColor color; - private boolean configurating; - - private ConfiguratorMode(String s, String s1, EnumColor c, boolean b) - { - name = s; - info = s1; - color = c; - configurating = b; - } - - public String getName() - { - return LangUtils.localize("tooltip.configurator." + name) + " " + info; - } - - public EnumColor getColor() - { - return color; - } - - public boolean isConfigurating() - { - return configurating; - } - - public TransmissionType getTransmission() - { - switch(this) - { - case CONFIGURATE_ITEMS: - return TransmissionType.ITEM; - case CONFIGURATE_FLUIDS: - return TransmissionType.FLUID; - case CONFIGURATE_GASES: - return TransmissionType.GAS; - case CONFIGURATE_ENERGY: - return TransmissionType.ENERGY; - case CONFIGURATE_HEAT: - return TransmissionType.HEAT; - default: - return null; - } - } - } + @Override + @Method(modid = "BuildCraft") + public boolean canWrench(EntityPlayer player, int x, int y, int z) { + return canUseWrench(player, x, y, z); + } + + @Override + @Method(modid = "BuildCraft") + public void wrenchUsed(EntityPlayer player, int x, int y, int z) {} + + @Override + public boolean canUseWrench(EntityPlayer player, int x, int y, int z) { + return getState(player.getCurrentEquippedItem()) == ConfiguratorMode.WRENCH; + } + + @Override + public boolean + doesSneakBypassUse(World world, int x, int y, int z, EntityPlayer player) { + return getState(player.getCurrentEquippedItem()) == ConfiguratorMode.WRENCH; + } + + @Override + public boolean isUsable(ItemStack item, EntityLivingBase user, int x, int y, int z) { + return user instanceof EntityPlayer && canUseWrench((EntityPlayer) user, x, y, z); + } + + @Override + public void toolUsed(ItemStack item, EntityLivingBase user, int x, int y, int z) {} + + public static enum ConfiguratorMode { + CONFIGURATE_ITEMS( + "configurate", + "(" + TransmissionType.ITEM.localize() + ")", + EnumColor.BRIGHT_GREEN, + true + ), + CONFIGURATE_FLUIDS( + "configurate", + "(" + TransmissionType.FLUID.localize() + ")", + EnumColor.BRIGHT_GREEN, + true + ), + CONFIGURATE_GASES( + "configurate", + "(" + TransmissionType.GAS.localize() + ")", + EnumColor.BRIGHT_GREEN, + true + ), + CONFIGURATE_ENERGY( + "configurate", + "(" + TransmissionType.ENERGY.localize() + ")", + EnumColor.BRIGHT_GREEN, + true + ), + CONFIGURATE_HEAT( + "configurate", + "(" + TransmissionType.HEAT.localize() + ")", + EnumColor.BRIGHT_GREEN, + true + ), + EMPTY("empty", "", EnumColor.DARK_RED, false), + ROTATE("rotate", "", EnumColor.YELLOW, false), + WRENCH("wrench", "", EnumColor.PINK, false); + + private String name; + private String info; + private EnumColor color; + private boolean configurating; + + private ConfiguratorMode(String s, String s1, EnumColor c, boolean b) { + name = s; + info = s1; + color = c; + configurating = b; + } + + public String getName() { + return LangUtils.localize("tooltip.configurator." + name) + " " + info; + } + + public EnumColor getColor() { + return color; + } + + public boolean isConfigurating() { + return configurating; + } + + public TransmissionType getTransmission() { + switch (this) { + case CONFIGURATE_ITEMS: + return TransmissionType.ITEM; + case CONFIGURATE_FLUIDS: + return TransmissionType.FLUID; + case CONFIGURATE_GASES: + return TransmissionType.GAS; + case CONFIGURATE_ENERGY: + return TransmissionType.ENERGY; + case CONFIGURATE_HEAT: + return TransmissionType.HEAT; + default: + return null; + } + } + } } diff --git a/src/main/java/mekanism/common/item/ItemControlCircuit.java b/src/main/java/mekanism/common/item/ItemControlCircuit.java index 40f14426a..711af0d68 100644 --- a/src/main/java/mekanism/common/item/ItemControlCircuit.java +++ b/src/main/java/mekanism/common/item/ItemControlCircuit.java @@ -9,49 +9,42 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -public class ItemControlCircuit extends ItemMekanism -{ - public IIcon[] icons = new IIcon[256]; +public class ItemControlCircuit extends ItemMekanism { + public IIcon[] icons = new IIcon[256]; - public ItemControlCircuit() - { - super(); - setHasSubtypes(true); - } + public ItemControlCircuit() { + super(); + setHasSubtypes(true); + } - @Override - public void registerIcons(IIconRegister register) - { - for(BaseTier tier : BaseTier.values()) - { - if(tier.isObtainable()) - { - icons[tier.ordinal()] = register.registerIcon("mekanism:" + tier.getName() + "ControlCircuit"); - } - } - } + @Override + public void registerIcons(IIconRegister register) { + for (BaseTier tier : BaseTier.values()) { + if (tier.isObtainable()) { + icons[tier.ordinal()] = register.registerIcon( + "mekanism:" + tier.getName() + "ControlCircuit" + ); + } + } + } - @Override - public IIcon getIconFromDamage(int meta) - { - return icons[meta]; - } + @Override + public IIcon getIconFromDamage(int meta) { + return icons[meta]; + } - @Override - public void getSubItems(Item item, CreativeTabs tabs, List itemList) - { - for(BaseTier tier : BaseTier.values()) - { - if(tier.isObtainable()) - { - itemList.add(new ItemStack(item, 1, tier.ordinal())); - } - } - } + @Override + public void getSubItems(Item item, CreativeTabs tabs, List itemList) { + for (BaseTier tier : BaseTier.values()) { + if (tier.isObtainable()) { + itemList.add(new ItemStack(item, 1, tier.ordinal())); + } + } + } - @Override - public String getUnlocalizedName(ItemStack item) - { - return "item." + BaseTier.values()[item.getItemDamage()].getName() + "ControlCircuit"; - } + @Override + public String getUnlocalizedName(ItemStack item) { + return "item." + BaseTier.values()[item.getItemDamage()].getName() + + "ControlCircuit"; + } } diff --git a/src/main/java/mekanism/common/item/ItemCraftingFormula.java b/src/main/java/mekanism/common/item/ItemCraftingFormula.java index 846aaafef..55f70093b 100644 --- a/src/main/java/mekanism/common/item/ItemCraftingFormula.java +++ b/src/main/java/mekanism/common/item/ItemCraftingFormula.java @@ -3,6 +3,9 @@ package mekanism.common.item; import java.util.ArrayList; import java.util.List; +import codechicken.lib.inventory.InventoryUtils; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.EnumColor; import mekanism.common.util.LangUtils; import net.minecraft.client.renderer.texture.IIconRegister; @@ -14,192 +17,169 @@ import net.minecraft.nbt.NBTTagList; import net.minecraft.util.IIcon; import net.minecraft.world.World; import net.minecraftforge.common.util.Constants.NBT; -import codechicken.lib.inventory.InventoryUtils; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class ItemCraftingFormula extends ItemMekanism -{ - public IIcon[] icons = new IIcon[3]; - - public ItemCraftingFormula() - { - super(); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister register) - { - icons[0] = register.registerIcon("mekanism:CraftingFormula"); - icons[1] = register.registerIcon("mekanism:CraftingFormulaInvalid"); - icons[2] = register.registerIcon("mekanism:CraftingFormulaEncoded"); - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(ItemStack stack, int pass) - { - return getInventory(stack) == null ? icons[0] : (isInvalid(stack) ? icons[1] : icons[2]); - } - - @Override - @SideOnly(Side.CLIENT) - public boolean requiresMultipleRenderPasses() - { - return true; - } - - @Override - @SideOnly(Side.CLIENT) - public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) - { - ItemStack[] inv = getInventory(itemstack); - - if(inv != null) - { - addIngredientDetails(inv, list); - } - } - - private void addIngredientDetails(ItemStack[] inv, List list) - { - List stacks = new ArrayList(); - - for(ItemStack stack : inv) - { - if(stack != null) - { - boolean found = false; - - for(ItemStack iterStack : stacks) - { - if(InventoryUtils.canStack(stack, iterStack)) - { - iterStack.stackSize += stack.stackSize; - found = true; - } - } - - if(!found) - { - stacks.add(stack); - } - } - } - - list.add(EnumColor.GREY + LangUtils.localize("tooltip.ingredients") + ":"); - - for(ItemStack stack : stacks) - { - list.add(EnumColor.GREY + " - " + stack.getDisplayName() + " (" + stack.stackSize + ")"); - } - } - - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) - { - if(player.isSneaking() && !world.isRemote) - { - setInventory(stack, null); - setInvalid(stack, false); - - ((EntityPlayerMP)player).sendContainerAndContentsToPlayer(player.openContainer, player.openContainer.getInventory()); - - return stack; - } - - return stack; - } - - @Override - public int getItemStackLimit(ItemStack stack) - { - return getInventory(stack) != null ? 1 : 64; - } - - @Override - public String getItemStackDisplayName(ItemStack stack) - { - if(getInventory(stack) == null) - { - return super.getItemStackDisplayName(stack); - } - - return super.getItemStackDisplayName(stack) + " " + (isInvalid(stack) ? EnumColor.DARK_RED + "(" + LangUtils.localize("tooltip.invalid") - : EnumColor.DARK_GREEN + "(" + LangUtils.localize("tooltip.encoded")) + ")"; - } - - public boolean isInvalid(ItemStack stack) - { - if(stack.stackTagCompound == null) - { - return false; - } - - return stack.stackTagCompound.getBoolean("invalid"); - } - - public void setInvalid(ItemStack stack, boolean invalid) - { - if(stack.stackTagCompound == null) - { - stack.setTagCompound(new NBTTagCompound()); - } - - stack.stackTagCompound.setBoolean("invalid", invalid); - } - - public ItemStack[] getInventory(ItemStack stack) - { - if(stack.stackTagCompound == null || !stack.stackTagCompound.hasKey("Items")) - { - return null; - } - - NBTTagList tagList = stack.stackTagCompound.getTagList("Items", NBT.TAG_COMPOUND); - ItemStack[] inventory = new ItemStack[9]; +public class ItemCraftingFormula extends ItemMekanism { + public IIcon[] icons = new IIcon[3]; - for(int tagCount = 0; tagCount < tagList.tagCount(); tagCount++) - { - NBTTagCompound tagCompound = tagList.getCompoundTagAt(tagCount); - byte slotID = tagCompound.getByte("Slot"); + public ItemCraftingFormula() { + super(); + } - if(slotID >= 0 && slotID < 9) - { - inventory[slotID] = ItemStack.loadItemStackFromNBT(tagCompound); - } - } - - return inventory; - } - - public void setInventory(ItemStack stack, ItemStack[] inv) - { - if(stack.stackTagCompound == null) - { - stack.setTagCompound(new NBTTagCompound()); - } - - if(inv == null) - { - stack.stackTagCompound.removeTag("Items"); - return; - } - - NBTTagList tagList = new NBTTagList(); + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister register) { + icons[0] = register.registerIcon("mekanism:CraftingFormula"); + icons[1] = register.registerIcon("mekanism:CraftingFormulaInvalid"); + icons[2] = register.registerIcon("mekanism:CraftingFormulaEncoded"); + } - for(int slotCount = 0; slotCount < 9; slotCount++) - { - if(inv[slotCount] != null) - { - NBTTagCompound tagCompound = new NBTTagCompound(); - tagCompound.setByte("Slot", (byte)slotCount); - inv[slotCount].writeToNBT(tagCompound); - tagList.appendTag(tagCompound); - } - } + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(ItemStack stack, int pass) { + return getInventory(stack) == null ? icons[0] + : (isInvalid(stack) ? icons[1] : icons[2]); + } - stack.stackTagCompound.setTag("Items", tagList); - } + @Override + @SideOnly(Side.CLIENT) + public boolean requiresMultipleRenderPasses() { + return true; + } + + @Override + @SideOnly(Side.CLIENT) + public void addInformation( + ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag + ) { + ItemStack[] inv = getInventory(itemstack); + + if (inv != null) { + addIngredientDetails(inv, list); + } + } + + private void addIngredientDetails(ItemStack[] inv, List list) { + List stacks = new ArrayList(); + + for (ItemStack stack : inv) { + if (stack != null) { + boolean found = false; + + for (ItemStack iterStack : stacks) { + if (InventoryUtils.canStack(stack, iterStack)) { + iterStack.stackSize += stack.stackSize; + found = true; + } + } + + if (!found) { + stacks.add(stack); + } + } + } + + list.add(EnumColor.GREY + LangUtils.localize("tooltip.ingredients") + ":"); + + for (ItemStack stack : stacks) { + list.add( + EnumColor.GREY + " - " + stack.getDisplayName() + " (" + stack.stackSize + + ")" + ); + } + } + + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + if (player.isSneaking() && !world.isRemote) { + setInventory(stack, null); + setInvalid(stack, false); + + ((EntityPlayerMP) player) + .sendContainerAndContentsToPlayer( + player.openContainer, player.openContainer.getInventory() + ); + + return stack; + } + + return stack; + } + + @Override + public int getItemStackLimit(ItemStack stack) { + return getInventory(stack) != null ? 1 : 64; + } + + @Override + public String getItemStackDisplayName(ItemStack stack) { + if (getInventory(stack) == null) { + return super.getItemStackDisplayName(stack); + } + + return super.getItemStackDisplayName(stack) + " " + + (isInvalid(stack) + ? EnumColor.DARK_RED + "(" + LangUtils.localize("tooltip.invalid") + : EnumColor.DARK_GREEN + "(" + LangUtils.localize("tooltip.encoded")) + + ")"; + } + + public boolean isInvalid(ItemStack stack) { + if (stack.stackTagCompound == null) { + return false; + } + + return stack.stackTagCompound.getBoolean("invalid"); + } + + public void setInvalid(ItemStack stack, boolean invalid) { + if (stack.stackTagCompound == null) { + stack.setTagCompound(new NBTTagCompound()); + } + + stack.stackTagCompound.setBoolean("invalid", invalid); + } + + public ItemStack[] getInventory(ItemStack stack) { + if (stack.stackTagCompound == null || !stack.stackTagCompound.hasKey("Items")) { + return null; + } + + NBTTagList tagList = stack.stackTagCompound.getTagList("Items", NBT.TAG_COMPOUND); + ItemStack[] inventory = new ItemStack[9]; + + for (int tagCount = 0; tagCount < tagList.tagCount(); tagCount++) { + NBTTagCompound tagCompound = tagList.getCompoundTagAt(tagCount); + byte slotID = tagCompound.getByte("Slot"); + + if (slotID >= 0 && slotID < 9) { + inventory[slotID] = ItemStack.loadItemStackFromNBT(tagCompound); + } + } + + return inventory; + } + + public void setInventory(ItemStack stack, ItemStack[] inv) { + if (stack.stackTagCompound == null) { + stack.setTagCompound(new NBTTagCompound()); + } + + if (inv == null) { + stack.stackTagCompound.removeTag("Items"); + return; + } + + NBTTagList tagList = new NBTTagList(); + + for (int slotCount = 0; slotCount < 9; slotCount++) { + if (inv[slotCount] != null) { + NBTTagCompound tagCompound = new NBTTagCompound(); + tagCompound.setByte("Slot", (byte) slotCount); + inv[slotCount].writeToNBT(tagCompound); + tagList.appendTag(tagCompound); + } + } + + stack.stackTagCompound.setTag("Items", tagList); + } } diff --git a/src/main/java/mekanism/common/item/ItemCrystal.java b/src/main/java/mekanism/common/item/ItemCrystal.java index b271c9c26..c98344cc9 100644 --- a/src/main/java/mekanism/common/item/ItemCrystal.java +++ b/src/main/java/mekanism/common/item/ItemCrystal.java @@ -9,48 +9,43 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -public class ItemCrystal extends ItemMekanism -{ - public IIcon[] icons = new IIcon[256]; +public class ItemCrystal extends ItemMekanism { + public IIcon[] icons = new IIcon[256]; - public ItemCrystal() - { - super(); - setHasSubtypes(true); - } + public ItemCrystal() { + super(); + setHasSubtypes(true); + } - @Override - public void registerIcons(IIconRegister register) - { - for(int i = 0; i < Resource.values().length; i++) - { - icons[i] = register.registerIcon("mekanism:" + Resource.values()[i].getName() + "Crystal"); - } - } + @Override + public void registerIcons(IIconRegister register) { + for (int i = 0; i < Resource.values().length; i++) { + icons[i] = register.registerIcon( + "mekanism:" + Resource.values()[i].getName() + "Crystal" + ); + } + } - @Override - public IIcon getIconFromDamage(int meta) - { - return icons[meta]; - } + @Override + public IIcon getIconFromDamage(int meta) { + return icons[meta]; + } - @Override - public void getSubItems(Item item, CreativeTabs tabs, List itemList) - { - for(int counter = 0; counter < Resource.values().length; counter++) - { - itemList.add(new ItemStack(item, 1, counter)); - } - } + @Override + public void getSubItems(Item item, CreativeTabs tabs, List itemList) { + for (int counter = 0; counter < Resource.values().length; counter++) { + itemList.add(new ItemStack(item, 1, counter)); + } + } - @Override - public String getUnlocalizedName(ItemStack item) - { - if(item.getItemDamage() <= Resource.values().length-1) - { - return "item." + Resource.values()[item.getItemDamage()].getName().toLowerCase() + "Crystal"; - } - - return "Invalid"; - } + @Override + public String getUnlocalizedName(ItemStack item) { + if (item.getItemDamage() <= Resource.values().length - 1) { + return "item." + + Resource.values()[item.getItemDamage()].getName().toLowerCase() + + "Crystal"; + } + + return "Invalid"; + } } diff --git a/src/main/java/mekanism/common/item/ItemDictionary.java b/src/main/java/mekanism/common/item/ItemDictionary.java index 88cd564dc..82630e4f4 100644 --- a/src/main/java/mekanism/common/item/ItemDictionary.java +++ b/src/main/java/mekanism/common/item/ItemDictionary.java @@ -12,57 +12,67 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ChatComponentText; import net.minecraft.world.World; -public class ItemDictionary extends ItemMekanism -{ - public ItemDictionary() - { - super(); - setMaxStackSize(1); - } +public class ItemDictionary extends ItemMekanism { + public ItemDictionary() { + super(); + setMaxStackSize(1); + } - @Override - public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) - { - if(!player.isSneaking()) - { - Block block = world.getBlock(x, y, z); + @Override + public boolean onItemUseFirst( + ItemStack stack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int side, + float hitX, + float hitY, + float hitZ + ) { + if (!player.isSneaking()) { + Block block = world.getBlock(x, y, z); - if(block != null) - { - if(world.isRemote) - { - ItemStack testStack = new ItemStack(block, 1, world.getBlockMetadata(x, y, z)); - List names = MekanismUtils.getOreDictName(testStack); + if (block != null) { + if (world.isRemote) { + ItemStack testStack + = new ItemStack(block, 1, world.getBlockMetadata(x, y, z)); + List names = MekanismUtils.getOreDictName(testStack); - if(!names.isEmpty()) - { - player.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + LangUtils.localize("tooltip.keysFound") + ":")); + if (!names.isEmpty()) { + player.addChatMessage(new ChatComponentText( + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + + LangUtils.localize("tooltip.keysFound") + ":" + )); - for(String name : names) - { - player.addChatMessage(new ChatComponentText(EnumColor.DARK_GREEN + " - " + name)); - } - } - else { - player.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + LangUtils.localize("tooltip.noKey") + ".")); - } - } + for (String name : names) { + player.addChatMessage( + new ChatComponentText(EnumColor.DARK_GREEN + " - " + name) + ); + } + } else { + player.addChatMessage(new ChatComponentText( + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + + LangUtils.localize("tooltip.noKey") + "." + )); + } + } - return true; - } - } + return true; + } + } - return false; - } + return false; + } - @Override - public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) - { - if(entityplayer.isSneaking()) - { - entityplayer.openGui(Mekanism.instance, 0, world, 0, 0, 0); - } + @Override + public ItemStack + onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { + if (entityplayer.isSneaking()) { + entityplayer.openGui(Mekanism.instance, 0, world, 0, 0, 0); + } - return itemstack; - } + return itemstack; + } } diff --git a/src/main/java/mekanism/common/item/ItemDirtyDust.java b/src/main/java/mekanism/common/item/ItemDirtyDust.java index b76ef2608..b021fbfd4 100644 --- a/src/main/java/mekanism/common/item/ItemDirtyDust.java +++ b/src/main/java/mekanism/common/item/ItemDirtyDust.java @@ -10,49 +10,43 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -public class ItemDirtyDust extends ItemMekanism -{ - public IIcon[] icons = new IIcon[256]; +public class ItemDirtyDust extends ItemMekanism { + public IIcon[] icons = new IIcon[256]; - public ItemDirtyDust() - { - super(); - setHasSubtypes(true); - setCreativeTab(Mekanism.tabMekanism); - } + public ItemDirtyDust() { + super(); + setHasSubtypes(true); + setCreativeTab(Mekanism.tabMekanism); + } - @Override - public void registerIcons(IIconRegister register) - { - for(int i = 0; i < Resource.values().length; i++) - { - icons[i] = register.registerIcon("mekanism:Dirty" + Resource.values()[i].getName() + "Dust"); - } - } + @Override + public void registerIcons(IIconRegister register) { + for (int i = 0; i < Resource.values().length; i++) { + icons[i] = register.registerIcon( + "mekanism:Dirty" + Resource.values()[i].getName() + "Dust" + ); + } + } - @Override - public IIcon getIconFromDamage(int meta) - { - return icons[meta]; - } + @Override + public IIcon getIconFromDamage(int meta) { + return icons[meta]; + } - @Override - public void getSubItems(Item item, CreativeTabs tabs, List itemList) - { - for(int counter = 0; counter < Resource.values().length; counter++) - { - itemList.add(new ItemStack(item, 1, counter)); - } - } + @Override + public void getSubItems(Item item, CreativeTabs tabs, List itemList) { + for (int counter = 0; counter < Resource.values().length; counter++) { + itemList.add(new ItemStack(item, 1, counter)); + } + } - @Override - public String getUnlocalizedName(ItemStack item) - { - if(item.getItemDamage() <= Resource.values().length-1) - { - return "item.dirty" + Resource.values()[item.getItemDamage()].getName() + "Dust"; - } - - return "Invalid"; - } + @Override + public String getUnlocalizedName(ItemStack item) { + if (item.getItemDamage() <= Resource.values().length - 1) { + return "item.dirty" + Resource.values()[item.getItemDamage()].getName() + + "Dust"; + } + + return "Invalid"; + } } diff --git a/src/main/java/mekanism/common/item/ItemDust.java b/src/main/java/mekanism/common/item/ItemDust.java index 4d47a0fd4..5dd48591a 100644 --- a/src/main/java/mekanism/common/item/ItemDust.java +++ b/src/main/java/mekanism/common/item/ItemDust.java @@ -9,48 +9,43 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -public class ItemDust extends ItemMekanism -{ - public IIcon[] icons = new IIcon[256]; - - public ItemDust() - { - super(); - setHasSubtypes(true); - } +public class ItemDust extends ItemMekanism { + public IIcon[] icons = new IIcon[256]; - @Override - public void registerIcons(IIconRegister register) - { - for(int i = 0; i < Resource.values().length; i++) - { - icons[i] = register.registerIcon("mekanism:" + Resource.values()[i].getName() + "Dust"); - } - } + public ItemDust() { + super(); + setHasSubtypes(true); + } - @Override - public IIcon getIconFromDamage(int meta) - { - return icons[meta]; - } + @Override + public void registerIcons(IIconRegister register) { + for (int i = 0; i < Resource.values().length; i++) { + icons[i] = register.registerIcon( + "mekanism:" + Resource.values()[i].getName() + "Dust" + ); + } + } - @Override - public void getSubItems(Item item, CreativeTabs tabs, List itemList) - { - for(int counter = 0; counter < Resource.values().length; counter++) - { - itemList.add(new ItemStack(this, 1, counter)); - } - } + @Override + public IIcon getIconFromDamage(int meta) { + return icons[meta]; + } - @Override - public String getUnlocalizedName(ItemStack item) - { - if(item.getItemDamage() <= Resource.values().length-1) - { - return "item." + Resource.values()[item.getItemDamage()].getName().toLowerCase() + "Dust"; - } - - return "Invalid"; - } + @Override + public void getSubItems(Item item, CreativeTabs tabs, List itemList) { + for (int counter = 0; counter < Resource.values().length; counter++) { + itemList.add(new ItemStack(this, 1, counter)); + } + } + + @Override + public String getUnlocalizedName(ItemStack item) { + if (item.getItemDamage() <= Resource.values().length - 1) { + return "item." + + Resource.values()[item.getItemDamage()].getName().toLowerCase() + + "Dust"; + } + + return "Invalid"; + } } diff --git a/src/main/java/mekanism/common/item/ItemElectricBow.java b/src/main/java/mekanism/common/item/ItemElectricBow.java index 1a30b9acc..f3555351e 100644 --- a/src/main/java/mekanism/common/item/ItemElectricBow.java +++ b/src/main/java/mekanism/common/item/ItemElectricBow.java @@ -14,139 +14,136 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; -public class ItemElectricBow extends ItemEnergized -{ - public ItemElectricBow() - { - super(120000); - setFull3D(); - } +public class ItemElectricBow extends ItemEnergized { + public ItemElectricBow() { + super(120000); + setFull3D(); + } - @Override - public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) - { - super.addInformation(itemstack, entityplayer, list, flag); - - list.add(EnumColor.PINK + LangUtils.localize("tooltip.fireMode") + ": " + EnumColor.GREY + LangUtils.transOnOff(getFireState(itemstack))); - } + @Override + public void addInformation( + ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag + ) { + super.addInformation(itemstack, entityplayer, list, flag); - @Override - public void onPlayerStoppedUsing(ItemStack itemstack, World world, EntityPlayer player, int itemUseCount) - { - if(getEnergy(itemstack) > 0) - { - boolean flag = player.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, itemstack) > 0; + list.add( + EnumColor.PINK + LangUtils.localize("tooltip.fireMode") + ": " + + EnumColor.GREY + LangUtils.transOnOff(getFireState(itemstack)) + ); + } - if(flag || player.inventory.hasItem(Items.arrow)) - { - int maxItemUse = getMaxItemUseDuration(itemstack) - itemUseCount; - float f = maxItemUse / 20F; - f = (f * f + f * 2.0F) / 3F; + @Override + public void onPlayerStoppedUsing( + ItemStack itemstack, World world, EntityPlayer player, int itemUseCount + ) { + if (getEnergy(itemstack) > 0) { + boolean flag = player.capabilities.isCreativeMode + || EnchantmentHelper.getEnchantmentLevel( + Enchantment.infinity.effectId, itemstack + ) > 0; - if(f < 0.1D) - { - return; - } + if (flag || player.inventory.hasItem(Items.arrow)) { + int maxItemUse = getMaxItemUseDuration(itemstack) - itemUseCount; + float f = maxItemUse / 20F; + f = (f * f + f * 2.0F) / 3F; - if(f > 1.0F) - { - f = 1.0F; - } + if (f < 0.1D) { + return; + } - EntityArrow entityarrow = new EntityArrow(world, player, f * 2.0F); + if (f > 1.0F) { + f = 1.0F; + } - if(f == 1.0F) - { - entityarrow.setIsCritical(true); - } + EntityArrow entityarrow = new EntityArrow(world, player, f * 2.0F); - if(!player.capabilities.isCreativeMode) - { - setEnergy(itemstack, getEnergy(itemstack) - (getFireState(itemstack) ? 1200 : 120)); - } + if (f == 1.0F) { + entityarrow.setIsCritical(true); + } - world.playSoundAtEntity(player, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F); + if (!player.capabilities.isCreativeMode) { + setEnergy( + itemstack, + getEnergy(itemstack) - (getFireState(itemstack) ? 1200 : 120) + ); + } - if(flag) - { - entityarrow.canBePickedUp = 2; - } - else { - player.inventory.consumeInventoryItem(Items.arrow); - } + world.playSoundAtEntity( + player, + "random.bow", + 1.0F, + 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F + ); - if(!world.isRemote) - { - world.spawnEntityInWorld(entityarrow); - entityarrow.setFire(getFireState(itemstack) ? 60 : 0); - } - } - } - } + if (flag) { + entityarrow.canBePickedUp = 2; + } else { + player.inventory.consumeInventoryItem(Items.arrow); + } - @Override - public int getMaxItemUseDuration(ItemStack itemstack) - { - return 72000; - } + if (!world.isRemote) { + world.spawnEntityInWorld(entityarrow); + entityarrow.setFire(getFireState(itemstack) ? 60 : 0); + } + } + } + } - @Override - public EnumAction getItemUseAction(ItemStack itemstack) - { - return EnumAction.bow; - } + @Override + public int getMaxItemUseDuration(ItemStack itemstack) { + return 72000; + } - @Override - public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) - { - if(entityplayer.capabilities.isCreativeMode || entityplayer.inventory.hasItem(Items.arrow)) - { - entityplayer.setItemInUse(itemstack, getMaxItemUseDuration(itemstack)); - } + @Override + public EnumAction getItemUseAction(ItemStack itemstack) { + return EnumAction.bow; + } - return itemstack; - } + @Override + public ItemStack + onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { + if (entityplayer.capabilities.isCreativeMode + || entityplayer.inventory.hasItem(Items.arrow)) { + entityplayer.setItemInUse(itemstack, getMaxItemUseDuration(itemstack)); + } - /** - * Sets the bow's fire state in NBT. - * @param itemstack - the bow's itemstack - * @param state - state to change to - */ - public void setFireState(ItemStack itemstack, boolean state) - { - if(itemstack.stackTagCompound == null) - { - itemstack.setTagCompound(new NBTTagCompound()); - } + return itemstack; + } - itemstack.stackTagCompound.setBoolean("fireState", state); - } + /** + * Sets the bow's fire state in NBT. + * @param itemstack - the bow's itemstack + * @param state - state to change to + */ + public void setFireState(ItemStack itemstack, boolean state) { + if (itemstack.stackTagCompound == null) { + itemstack.setTagCompound(new NBTTagCompound()); + } - /** - * Gets the bow's fire state from NBT. - * @param itemstack - the bow's itemstack - * @return fire state - */ - public boolean getFireState(ItemStack itemstack) - { - if(itemstack.stackTagCompound == null) - { - return false; - } + itemstack.stackTagCompound.setBoolean("fireState", state); + } - boolean state = false; + /** + * Gets the bow's fire state from NBT. + * @param itemstack - the bow's itemstack + * @return fire state + */ + public boolean getFireState(ItemStack itemstack) { + if (itemstack.stackTagCompound == null) { + return false; + } - if(itemstack.stackTagCompound.getTag("fireState") != null) - { - state = itemstack.stackTagCompound.getBoolean("fireState"); - } + boolean state = false; - return state; - } + if (itemstack.stackTagCompound.getTag("fireState") != null) { + state = itemstack.stackTagCompound.getBoolean("fireState"); + } - @Override - public boolean canSend(ItemStack itemStack) - { - return false; - } + return state; + } + + @Override + public boolean canSend(ItemStack itemStack) { + return false; + } } diff --git a/src/main/java/mekanism/common/item/ItemEnergized.java b/src/main/java/mekanism/common/item/ItemEnergized.java index 4400a3ef5..cf1463077 100644 --- a/src/main/java/mekanism/common/item/ItemEnergized.java +++ b/src/main/java/mekanism/common/item/ItemEnergized.java @@ -1,10 +1,13 @@ package mekanism.common.item; -import ic2.api.item.IElectricItemManager; -import ic2.api.item.ISpecialElectricItem; - import java.util.List; +import cofh.api.energy.IEnergyContainerItem; +import cpw.mods.fml.common.Optional.Interface; +import cpw.mods.fml.common.Optional.InterfaceList; +import cpw.mods.fml.common.Optional.Method; +import ic2.api.item.IElectricItemManager; +import ic2.api.item.ISpecialElectricItem; import mekanism.api.EnumColor; import mekanism.api.MekanismConfig.general; import mekanism.api.energy.IEnergizedItem; @@ -17,203 +20,173 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import cofh.api.energy.IEnergyContainerItem; -import cpw.mods.fml.common.Optional.Interface; -import cpw.mods.fml.common.Optional.InterfaceList; -import cpw.mods.fml.common.Optional.Method; -@InterfaceList({ - @Interface(iface = "ic2.api.item.ISpecialElectricItem", modid = "IC2") -}) -public class ItemEnergized extends ItemMekanism implements IEnergizedItem, ISpecialElectricItem, IEnergyContainerItem -{ - /** The maximum amount of energy this item can hold. */ - public double MAX_ELECTRICITY; +@InterfaceList({ @Interface(iface = "ic2.api.item.ISpecialElectricItem", modid = "IC2") }) +public class ItemEnergized extends ItemMekanism + implements IEnergizedItem, ISpecialElectricItem, IEnergyContainerItem { + /** The maximum amount of energy this item can hold. */ + public double MAX_ELECTRICITY; - public ItemEnergized(double maxElectricity) - { - super(); - MAX_ELECTRICITY = maxElectricity; - setMaxStackSize(1); - setCreativeTab(Mekanism.tabMekanism); - } - - @Override - public boolean showDurabilityBar(ItemStack stack) - { - return true; - } - - @Override - public double getDurabilityForDisplay(ItemStack stack) - { - return 1D-(getEnergy(stack)/getMaxEnergy(stack)); - } + public ItemEnergized(double maxElectricity) { + super(); + MAX_ELECTRICITY = maxElectricity; + setMaxStackSize(1); + setCreativeTab(Mekanism.tabMekanism); + } - @Override - public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) - { - list.add(EnumColor.AQUA + LangUtils.localize("tooltip.storedEnergy") + ": " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(getEnergy(itemstack))); - } + @Override + public boolean showDurabilityBar(ItemStack stack) { + return true; + } - public ItemStack getUnchargedItem() - { - return new ItemStack(this); - } + @Override + public double getDurabilityForDisplay(ItemStack stack) { + return 1D - (getEnergy(stack) / getMaxEnergy(stack)); + } - @Override - public void getSubItems(Item item, CreativeTabs tabs, List list) - { - ItemStack discharged = new ItemStack(this); - list.add(discharged); - ItemStack charged = new ItemStack(this); - setEnergy(charged, ((IEnergizedItem)charged.getItem()).getMaxEnergy(charged)); - list.add(charged); - } + @Override + public void addInformation( + ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag + ) { + list.add( + EnumColor.AQUA + LangUtils.localize("tooltip.storedEnergy") + ": " + + EnumColor.GREY + MekanismUtils.getEnergyDisplay(getEnergy(itemstack)) + ); + } - @Override - @Method(modid = "IC2") - public boolean canProvideEnergy(ItemStack itemStack) - { - return canSend(itemStack); - } + public ItemStack getUnchargedItem() { + return new ItemStack(this); + } - @Override - @Method(modid = "IC2") - public Item getChargedItem(ItemStack itemStack) - { - return this; - } + @Override + public void getSubItems(Item item, CreativeTabs tabs, List list) { + ItemStack discharged = new ItemStack(this); + list.add(discharged); + ItemStack charged = new ItemStack(this); + setEnergy(charged, ((IEnergizedItem) charged.getItem()).getMaxEnergy(charged)); + list.add(charged); + } - @Override - @Method(modid = "IC2") - public Item getEmptyItem(ItemStack itemStack) - { - return this; - } + @Override + @Method(modid = "IC2") + public boolean canProvideEnergy(ItemStack itemStack) { + return canSend(itemStack); + } - @Override - @Method(modid = "IC2") - public double getMaxCharge(ItemStack itemStack) - { - return 0; - } + @Override + @Method(modid = "IC2") + public Item getChargedItem(ItemStack itemStack) { + return this; + } - @Override - @Method(modid = "IC2") - public int getTier(ItemStack itemStack) - { - return 4; - } + @Override + @Method(modid = "IC2") + public Item getEmptyItem(ItemStack itemStack) { + return this; + } - @Override - @Method(modid = "IC2") - public double getTransferLimit(ItemStack itemStack) - { - return 0; - } + @Override + @Method(modid = "IC2") + public double getMaxCharge(ItemStack itemStack) { + return 0; + } - @Override - public double getEnergy(ItemStack itemStack) - { - if(itemStack.stackTagCompound == null) - { - return 0; - } + @Override + @Method(modid = "IC2") + public int getTier(ItemStack itemStack) { + return 4; + } - return itemStack.stackTagCompound.getDouble("electricity"); - } + @Override + @Method(modid = "IC2") + public double getTransferLimit(ItemStack itemStack) { + return 0; + } - @Override - public void setEnergy(ItemStack itemStack, double amount) - { - if(itemStack.stackTagCompound == null) - { - itemStack.setTagCompound(new NBTTagCompound()); - } + @Override + public double getEnergy(ItemStack itemStack) { + if (itemStack.stackTagCompound == null) { + return 0; + } - double electricityStored = Math.max(Math.min(amount, getMaxEnergy(itemStack)), 0); - itemStack.stackTagCompound.setDouble("electricity", electricityStored); - } + return itemStack.stackTagCompound.getDouble("electricity"); + } - @Override - public double getMaxEnergy(ItemStack itemStack) - { - return MAX_ELECTRICITY; - } + @Override + public void setEnergy(ItemStack itemStack, double amount) { + if (itemStack.stackTagCompound == null) { + itemStack.setTagCompound(new NBTTagCompound()); + } - @Override - public double getMaxTransfer(ItemStack itemStack) - { - return getMaxEnergy(itemStack)*0.005; - } + double electricityStored = Math.max(Math.min(amount, getMaxEnergy(itemStack)), 0); + itemStack.stackTagCompound.setDouble("electricity", electricityStored); + } - @Override - public boolean canReceive(ItemStack itemStack) - { - return getMaxEnergy(itemStack)-getEnergy(itemStack) > 0; - } + @Override + public double getMaxEnergy(ItemStack itemStack) { + return MAX_ELECTRICITY; + } - @Override - public boolean canSend(ItemStack itemStack) - { - return getEnergy(itemStack) > 0; - } + @Override + public double getMaxTransfer(ItemStack itemStack) { + return getMaxEnergy(itemStack) * 0.005; + } - @Override - public int receiveEnergy(ItemStack theItem, int energy, boolean simulate) - { - if(canReceive(theItem)) - { - double energyNeeded = getMaxEnergy(theItem)-getEnergy(theItem); - double toReceive = Math.min(energy* general.FROM_TE, energyNeeded); + @Override + public boolean canReceive(ItemStack itemStack) { + return getMaxEnergy(itemStack) - getEnergy(itemStack) > 0; + } - if(!simulate) - { - setEnergy(theItem, getEnergy(theItem) + toReceive); - } + @Override + public boolean canSend(ItemStack itemStack) { + return getEnergy(itemStack) > 0; + } - return (int)Math.round(toReceive* general.TO_TE); - } + @Override + public int receiveEnergy(ItemStack theItem, int energy, boolean simulate) { + if (canReceive(theItem)) { + double energyNeeded = getMaxEnergy(theItem) - getEnergy(theItem); + double toReceive = Math.min(energy * general.FROM_TE, energyNeeded); - return 0; - } + if (!simulate) { + setEnergy(theItem, getEnergy(theItem) + toReceive); + } - @Override - public int extractEnergy(ItemStack theItem, int energy, boolean simulate) - { - if(canSend(theItem)) - { - double energyRemaining = getEnergy(theItem); - double toSend = Math.min((energy* general.FROM_TE), energyRemaining); + return (int) Math.round(toReceive * general.TO_TE); + } - if(!simulate) - { - setEnergy(theItem, getEnergy(theItem) - toSend); - } + return 0; + } - return (int)Math.round(toSend* general.TO_TE); - } + @Override + public int extractEnergy(ItemStack theItem, int energy, boolean simulate) { + if (canSend(theItem)) { + double energyRemaining = getEnergy(theItem); + double toSend = Math.min((energy * general.FROM_TE), energyRemaining); - return 0; - } + if (!simulate) { + setEnergy(theItem, getEnergy(theItem) - toSend); + } - @Override - public int getEnergyStored(ItemStack theItem) - { - return (int)Math.round(getEnergy(theItem)* general.TO_TE); - } + return (int) Math.round(toSend * general.TO_TE); + } - @Override - public int getMaxEnergyStored(ItemStack theItem) - { - return (int)Math.round(getMaxEnergy(theItem)* general.TO_TE); - } + return 0; + } - @Override - @Method(modid = "IC2") - public IElectricItemManager getManager(ItemStack itemStack) - { - return IC2ItemManager.getManager(this); - } + @Override + public int getEnergyStored(ItemStack theItem) { + return (int) Math.round(getEnergy(theItem) * general.TO_TE); + } + + @Override + public int getMaxEnergyStored(ItemStack theItem) { + return (int) Math.round(getMaxEnergy(theItem) * general.TO_TE); + } + + @Override + @Method(modid = "IC2") + public IElectricItemManager getManager(ItemStack itemStack) { + return IC2ItemManager.getManager(this); + } } diff --git a/src/main/java/mekanism/common/item/ItemFlamethrower.java b/src/main/java/mekanism/common/item/ItemFlamethrower.java index ab0c9a337..ce6d16708 100644 --- a/src/main/java/mekanism/common/item/ItemFlamethrower.java +++ b/src/main/java/mekanism/common/item/ItemFlamethrower.java @@ -2,6 +2,8 @@ package mekanism.common.item; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.EnumColor; import mekanism.api.MekanismConfig.general; import mekanism.api.gas.Gas; @@ -15,187 +17,175 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class ItemFlamethrower extends ItemMekanism implements IGasItem -{ - public int TRANSFER_RATE = 16; - - public ItemFlamethrower() - { - super(); - setMaxStackSize(1); - } - - @Override - public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) - { - GasStack gasStack = getGas(itemstack); +public class ItemFlamethrower extends ItemMekanism implements IGasItem { + public int TRANSFER_RATE = 16; - if(gasStack == null) - { - list.add(LangUtils.localize("tooltip.noGas") + "."); - } - else { - list.add(LangUtils.localize("tooltip.stored") + " " + gasStack.getGas().getLocalizedName() + ": " + gasStack.amount); - } + public ItemFlamethrower() { + super(); + setMaxStackSize(1); + } - list.add(EnumColor.GREY + LangUtils.localize("tooltip.mode") + ": " + EnumColor.GREY + getMode(itemstack).getName()); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister register) {} - - public void useGas(ItemStack stack) - { - setGas(stack, new GasStack(getGas(stack).getGas(), getGas(stack).amount - 1)); - } + @Override + public void addInformation( + ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag + ) { + GasStack gasStack = getGas(itemstack); - @Override - public int getMaxGas(ItemStack itemstack) - { - return general.maxFlamethrowerGas; - } + if (gasStack == null) { + list.add(LangUtils.localize("tooltip.noGas") + "."); + } else { + list.add( + LangUtils.localize("tooltip.stored") + " " + + gasStack.getGas().getLocalizedName() + ": " + gasStack.amount + ); + } - @Override - public int getRate(ItemStack itemstack) - { - return TRANSFER_RATE; - } + list.add( + EnumColor.GREY + LangUtils.localize("tooltip.mode") + ": " + EnumColor.GREY + + getMode(itemstack).getName() + ); + } - @Override - public int addGas(ItemStack itemstack, GasStack stack) - { - if(getGas(itemstack) != null && getGas(itemstack).getGas() != stack.getGas()) - { - return 0; - } + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister register) {} - if(stack.getGas() != GasRegistry.getGas("hydrogen")) - { - return 0; - } + public void useGas(ItemStack stack) { + setGas(stack, new GasStack(getGas(stack).getGas(), getGas(stack).amount - 1)); + } - int toUse = Math.min(getMaxGas(itemstack)-getStored(itemstack), Math.min(getRate(itemstack), stack.amount)); - setGas(itemstack, new GasStack(stack.getGas(), getStored(itemstack)+toUse)); + @Override + public int getMaxGas(ItemStack itemstack) { + return general.maxFlamethrowerGas; + } - return toUse; - } + @Override + public int getRate(ItemStack itemstack) { + return TRANSFER_RATE; + } - @Override - public GasStack removeGas(ItemStack itemstack, int amount) - { - return null; - } + @Override + public int addGas(ItemStack itemstack, GasStack stack) { + if (getGas(itemstack) != null && getGas(itemstack).getGas() != stack.getGas()) { + return 0; + } - public int getStored(ItemStack itemstack) - { - return getGas(itemstack) != null ? getGas(itemstack).amount : 0; - } + if (stack.getGas() != GasRegistry.getGas("hydrogen")) { + return 0; + } - @Override - public boolean canReceiveGas(ItemStack itemstack, Gas type) - { - return type == GasRegistry.getGas("hydrogen"); - } + int toUse = Math.min( + getMaxGas(itemstack) - getStored(itemstack), + Math.min(getRate(itemstack), stack.amount) + ); + setGas(itemstack, new GasStack(stack.getGas(), getStored(itemstack) + toUse)); - @Override - public boolean canProvideGas(ItemStack itemstack, Gas type) - { - return false; - } + return toUse; + } - @Override - public GasStack getGas(ItemStack itemstack) - { - if(itemstack.stackTagCompound == null) - { - return null; - } + @Override + public GasStack removeGas(ItemStack itemstack, int amount) { + return null; + } - return GasStack.readFromNBT(itemstack.stackTagCompound.getCompoundTag("stored")); - } - - @Override - public boolean showDurabilityBar(ItemStack stack) - { - return true; - } - - @Override - public double getDurabilityForDisplay(ItemStack stack) - { - return 1D-((getGas(stack) != null ? (double)getGas(stack).amount : 0D)/(double)getMaxGas(stack)); - } + public int getStored(ItemStack itemstack) { + return getGas(itemstack) != null ? getGas(itemstack).amount : 0; + } - @Override - public void setGas(ItemStack itemstack, GasStack stack) - { - if(itemstack.stackTagCompound == null) - { - itemstack.setTagCompound(new NBTTagCompound()); - } + @Override + public boolean canReceiveGas(ItemStack itemstack, Gas type) { + return type == GasRegistry.getGas("hydrogen"); + } - if(stack == null || stack.amount == 0) - { - itemstack.stackTagCompound.removeTag("stored"); - } - else { - int amount = Math.max(0, Math.min(stack.amount, getMaxGas(itemstack))); - GasStack gasStack = new GasStack(stack.getGas(), amount); + @Override + public boolean canProvideGas(ItemStack itemstack, Gas type) { + return false; + } - itemstack.stackTagCompound.setTag("stored", gasStack.write(new NBTTagCompound())); - } - } + @Override + public GasStack getGas(ItemStack itemstack) { + if (itemstack.stackTagCompound == null) { + return null; + } - public ItemStack getEmptyItem() - { - ItemStack empty = new ItemStack(this); - setGas(empty, null); - return empty; - } + return GasStack.readFromNBT(itemstack.stackTagCompound.getCompoundTag("stored")); + } - @Override - public void getSubItems(Item item, CreativeTabs tabs, List list) - { - ItemStack empty = new ItemStack(this); - setGas(empty, null); - list.add(empty); + @Override + public boolean showDurabilityBar(ItemStack stack) { + return true; + } - ItemStack filled = new ItemStack(this); - setGas(filled, new GasStack(GasRegistry.getGas("hydrogen"), ((IGasItem)filled.getItem()).getMaxGas(filled))); - list.add(filled); - } + @Override + public double getDurabilityForDisplay(ItemStack stack) { + return 1D + - ((getGas(stack) != null ? (double) getGas(stack).amount : 0D) + / (double) getMaxGas(stack)); + } - public void incrementMode(ItemStack stack) - { + @Override + public void setGas(ItemStack itemstack, GasStack stack) { + if (itemstack.stackTagCompound == null) { + itemstack.setTagCompound(new NBTTagCompound()); + } + + if (stack == null || stack.amount == 0) { + itemstack.stackTagCompound.removeTag("stored"); + } else { + int amount = Math.max(0, Math.min(stack.amount, getMaxGas(itemstack))); + GasStack gasStack = new GasStack(stack.getGas(), amount); + + itemstack.stackTagCompound.setTag( + "stored", gasStack.write(new NBTTagCompound()) + ); + } + } + + public ItemStack getEmptyItem() { + ItemStack empty = new ItemStack(this); + setGas(empty, null); + return empty; + } + + @Override + public void getSubItems(Item item, CreativeTabs tabs, List list) { + ItemStack empty = new ItemStack(this); + setGas(empty, null); + list.add(empty); + + ItemStack filled = new ItemStack(this); + setGas( + filled, + new GasStack( + GasRegistry.getGas("hydrogen"), + ((IGasItem) filled.getItem()).getMaxGas(filled) + ) + ); + list.add(filled); + } + + public void incrementMode(ItemStack stack) { setMode(stack, getMode(stack).increment()); } - public FlamethrowerMode getMode(ItemStack stack) - { - if(stack.stackTagCompound == null) - { + public FlamethrowerMode getMode(ItemStack stack) { + if (stack.stackTagCompound == null) { return FlamethrowerMode.COMBAT; } return FlamethrowerMode.values()[stack.stackTagCompound.getInteger("mode")]; } - public void setMode(ItemStack stack, FlamethrowerMode mode) - { - if(stack.stackTagCompound == null) - { + public void setMode(ItemStack stack, FlamethrowerMode mode) { + if (stack.stackTagCompound == null) { stack.setTagCompound(new NBTTagCompound()); } stack.stackTagCompound.setInteger("mode", mode.ordinal()); } - public static enum FlamethrowerMode - { + public static enum FlamethrowerMode { COMBAT("tooltip.flamethrower.combat", EnumColor.YELLOW), HEAT("tooltip.flamethrower.heat", EnumColor.ORANGE), INFERNO("tooltip.flamethrower.inferno", EnumColor.DARK_RED); @@ -203,19 +193,17 @@ public class ItemFlamethrower extends ItemMekanism implements IGasItem private String unlocalized; private EnumColor color; - private FlamethrowerMode(String s, EnumColor c) - { + private FlamethrowerMode(String s, EnumColor c) { unlocalized = s; color = c; } - public FlamethrowerMode increment() - { - return ordinal() < values().length-1 ? values()[ordinal()+1] : values()[0]; + public FlamethrowerMode increment() { + return ordinal() < values().length - 1 ? values()[ordinal() + 1] + : values()[0]; } - public String getName() - { + public String getName() { return color + LangUtils.localize(unlocalized); } } diff --git a/src/main/java/mekanism/common/item/ItemFreeRunners.java b/src/main/java/mekanism/common/item/ItemFreeRunners.java index 556610497..4b50140a7 100644 --- a/src/main/java/mekanism/common/item/ItemFreeRunners.java +++ b/src/main/java/mekanism/common/item/ItemFreeRunners.java @@ -1,10 +1,16 @@ package mekanism.common.item; -import ic2.api.item.IElectricItemManager; -import ic2.api.item.ISpecialElectricItem; - import java.util.List; +import cofh.api.energy.IEnergyContainerItem; +import cpw.mods.fml.common.Optional.Interface; +import cpw.mods.fml.common.Optional.InterfaceList; +import cpw.mods.fml.common.Optional.Method; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ic2.api.item.IElectricItemManager; +import ic2.api.item.ISpecialElectricItem; import mekanism.api.EnumColor; import mekanism.api.MekanismConfig.general; import mekanism.api.energy.IEnergizedItem; @@ -27,248 +33,215 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; import net.minecraftforge.common.util.EnumHelper; import net.minecraftforge.event.entity.living.LivingAttackEvent; -import cofh.api.energy.IEnergyContainerItem; -import cpw.mods.fml.common.Optional.Interface; -import cpw.mods.fml.common.Optional.InterfaceList; -import cpw.mods.fml.common.Optional.Method; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -@InterfaceList({ - @Interface(iface = "ic2.api.item.ISpecialElectricItem", modid = "IC2") -}) -public class ItemFreeRunners extends ItemArmor implements IEnergizedItem, ISpecialElectricItem, IEnergyContainerItem -{ - /** The maximum amount of energy this item can hold. */ - public double MAX_ELECTRICITY = 64000; +@InterfaceList({ @Interface(iface = "ic2.api.item.ISpecialElectricItem", modid = "IC2") }) +public class ItemFreeRunners extends ItemArmor + implements IEnergizedItem, ISpecialElectricItem, IEnergyContainerItem { + /** The maximum amount of energy this item can hold. */ + public double MAX_ELECTRICITY = 64000; - public ItemFreeRunners() - { - super(EnumHelper.addArmorMaterial("FRICTIONBOOTS", 0, new int[] {0, 0, 0, 0}, 0), 0, 3); - setMaxStackSize(1); - setCreativeTab(Mekanism.tabMekanism); - } + public ItemFreeRunners() { + super( + EnumHelper.addArmorMaterial("FRICTIONBOOTS", 0, new int[] { 0, 0, 0, 0 }, 0), + 0, + 3 + ); + setMaxStackSize(1); + setCreativeTab(Mekanism.tabMekanism); + } - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister register) {} + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister register) {} - @Override - public boolean isValidArmor(ItemStack stack, int armorType, Entity entity) - { - return armorType == 3; - } + @Override + public boolean isValidArmor(ItemStack stack, int armorType, Entity entity) { + return armorType == 3; + } - @Override - public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) - { - return "mekanism:render/NullArmor.png"; - } + @Override + public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { + return "mekanism:render/NullArmor.png"; + } - @Override - @SideOnly(Side.CLIENT) - public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) - { - ModelCustomArmor model = ModelCustomArmor.INSTANCE; - model.modelType = ArmorModel.FREERUNNERS; - return model; - } + @Override + @SideOnly(Side.CLIENT) + public ModelBiped + getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) { + ModelCustomArmor model = ModelCustomArmor.INSTANCE; + model.modelType = ArmorModel.FREERUNNERS; + return model; + } - @Override - public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) - { - list.add(EnumColor.AQUA + LangUtils.localize("tooltip.storedEnergy") + ": " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(getEnergy(itemstack))); - } + @Override + public void addInformation( + ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag + ) { + list.add( + EnumColor.AQUA + LangUtils.localize("tooltip.storedEnergy") + ": " + + EnumColor.GREY + MekanismUtils.getEnergyDisplay(getEnergy(itemstack)) + ); + } - public ItemStack getUnchargedItem() - { - return new ItemStack(this); - } + public ItemStack getUnchargedItem() { + return new ItemStack(this); + } - @Override - public void getSubItems(Item item, CreativeTabs tabs, List list) - { - ItemStack discharged = new ItemStack(this); - list.add(discharged); - ItemStack charged = new ItemStack(this); - setEnergy(charged, ((IEnergizedItem)charged.getItem()).getMaxEnergy(charged)); - list.add(charged); - } + @Override + public void getSubItems(Item item, CreativeTabs tabs, List list) { + ItemStack discharged = new ItemStack(this); + list.add(discharged); + ItemStack charged = new ItemStack(this); + setEnergy(charged, ((IEnergizedItem) charged.getItem()).getMaxEnergy(charged)); + list.add(charged); + } - @Override - @Method(modid = "IC2") - public boolean canProvideEnergy(ItemStack itemStack) - { - return canSend(itemStack); - } + @Override + @Method(modid = "IC2") + public boolean canProvideEnergy(ItemStack itemStack) { + return canSend(itemStack); + } - @Override - @Method(modid = "IC2") - public Item getChargedItem(ItemStack itemStack) - { - return this; - } + @Override + @Method(modid = "IC2") + public Item getChargedItem(ItemStack itemStack) { + return this; + } - @Override - @Method(modid = "IC2") - public Item getEmptyItem(ItemStack itemStack) - { - return this; - } + @Override + @Method(modid = "IC2") + public Item getEmptyItem(ItemStack itemStack) { + return this; + } - @Override - @Method(modid = "IC2") - public double getMaxCharge(ItemStack itemStack) - { - return 0; - } + @Override + @Method(modid = "IC2") + public double getMaxCharge(ItemStack itemStack) { + return 0; + } - @Override - @Method(modid = "IC2") - public int getTier(ItemStack itemStack) - { - return 4; - } + @Override + @Method(modid = "IC2") + public int getTier(ItemStack itemStack) { + return 4; + } - @Override - @Method(modid = "IC2") - public double getTransferLimit(ItemStack itemStack) - { - return 0; - } + @Override + @Method(modid = "IC2") + public double getTransferLimit(ItemStack itemStack) { + return 0; + } - @Override - public double getEnergy(ItemStack itemStack) - { - if(itemStack.stackTagCompound == null) - { - return 0; - } + @Override + public double getEnergy(ItemStack itemStack) { + if (itemStack.stackTagCompound == null) { + return 0; + } - return itemStack.stackTagCompound.getDouble("electricity"); - } + return itemStack.stackTagCompound.getDouble("electricity"); + } - @Override - public void setEnergy(ItemStack itemStack, double amount) - { - if(itemStack.stackTagCompound == null) - { - itemStack.setTagCompound(new NBTTagCompound()); - } + @Override + public void setEnergy(ItemStack itemStack, double amount) { + if (itemStack.stackTagCompound == null) { + itemStack.setTagCompound(new NBTTagCompound()); + } - double electricityStored = Math.max(Math.min(amount, getMaxEnergy(itemStack)), 0); - itemStack.stackTagCompound.setDouble("electricity", electricityStored); - } + double electricityStored = Math.max(Math.min(amount, getMaxEnergy(itemStack)), 0); + itemStack.stackTagCompound.setDouble("electricity", electricityStored); + } - @Override - public double getMaxEnergy(ItemStack itemStack) - { - return MAX_ELECTRICITY; - } + @Override + public double getMaxEnergy(ItemStack itemStack) { + return MAX_ELECTRICITY; + } - @Override - public double getMaxTransfer(ItemStack itemStack) - { - return getMaxEnergy(itemStack)*0.005; - } + @Override + public double getMaxTransfer(ItemStack itemStack) { + return getMaxEnergy(itemStack) * 0.005; + } - @Override - public boolean canReceive(ItemStack itemStack) - { - return getMaxEnergy(itemStack)-getEnergy(itemStack) > 0; - } + @Override + public boolean canReceive(ItemStack itemStack) { + return getMaxEnergy(itemStack) - getEnergy(itemStack) > 0; + } - @Override - public boolean canSend(ItemStack itemStack) - { - return false; - } + @Override + public boolean canSend(ItemStack itemStack) { + return false; + } - @Override - public int receiveEnergy(ItemStack theItem, int energy, boolean simulate) - { - if(canReceive(theItem)) - { - double energyNeeded = getMaxEnergy(theItem)-getEnergy(theItem); - double toReceive = Math.min(energy* general.FROM_TE, energyNeeded); + @Override + public int receiveEnergy(ItemStack theItem, int energy, boolean simulate) { + if (canReceive(theItem)) { + double energyNeeded = getMaxEnergy(theItem) - getEnergy(theItem); + double toReceive = Math.min(energy * general.FROM_TE, energyNeeded); - if(!simulate) - { - setEnergy(theItem, getEnergy(theItem) + toReceive); - } + if (!simulate) { + setEnergy(theItem, getEnergy(theItem) + toReceive); + } - return (int)Math.round(toReceive* general.TO_TE); - } + return (int) Math.round(toReceive * general.TO_TE); + } - return 0; - } + return 0; + } - @Override - public int extractEnergy(ItemStack theItem, int energy, boolean simulate) - { - if(canSend(theItem)) - { - double energyRemaining = getEnergy(theItem); - double toSend = Math.min((energy* general.FROM_TE), energyRemaining); + @Override + public int extractEnergy(ItemStack theItem, int energy, boolean simulate) { + if (canSend(theItem)) { + double energyRemaining = getEnergy(theItem); + double toSend = Math.min((energy * general.FROM_TE), energyRemaining); - if(!simulate) - { - setEnergy(theItem, getEnergy(theItem) - toSend); - } + if (!simulate) { + setEnergy(theItem, getEnergy(theItem) - toSend); + } - return (int)Math.round(toSend* general.TO_TE); - } + return (int) Math.round(toSend * general.TO_TE); + } - return 0; - } + return 0; + } - @Override - public int getEnergyStored(ItemStack theItem) - { - return (int)Math.round(getEnergy(theItem)* general.TO_TE); - } + @Override + public int getEnergyStored(ItemStack theItem) { + return (int) Math.round(getEnergy(theItem) * general.TO_TE); + } - @Override - public int getMaxEnergyStored(ItemStack theItem) - { - return (int)Math.round(getMaxEnergy(theItem)* general.TO_TE); - } + @Override + public int getMaxEnergyStored(ItemStack theItem) { + return (int) Math.round(getMaxEnergy(theItem) * general.TO_TE); + } - @Override - public boolean showDurabilityBar(ItemStack stack) - { - return true; - } - - @Override - public double getDurabilityForDisplay(ItemStack stack) - { - return 1D-(getEnergy(stack)/getMaxEnergy(stack)); - } + @Override + public boolean showDurabilityBar(ItemStack stack) { + return true; + } - @Override - @Method(modid = "IC2") - public IElectricItemManager getManager(ItemStack itemStack) - { - return IC2ItemManager.getManager(this); - } + @Override + public double getDurabilityForDisplay(ItemStack stack) { + return 1D - (getEnergy(stack) / getMaxEnergy(stack)); + } - @SubscribeEvent - public void onEntityAttacked(LivingAttackEvent event) - { - EntityLivingBase base = event.entityLiving; + @Override + @Method(modid = "IC2") + public IElectricItemManager getManager(ItemStack itemStack) { + return IC2ItemManager.getManager(this); + } - if(base.getEquipmentInSlot(1) != null && base.getEquipmentInSlot(1).getItem() instanceof ItemFreeRunners) - { - ItemStack stack = base.getEquipmentInSlot(1); - ItemFreeRunners boots = (ItemFreeRunners)stack.getItem(); + @SubscribeEvent + public void onEntityAttacked(LivingAttackEvent event) { + EntityLivingBase base = event.entityLiving; - if(boots.getEnergy(stack) > 0 && event.source == DamageSource.fall) - { - boots.setEnergy(stack, boots.getEnergy(stack)-event.ammount*50); - event.setCanceled(true); - } - } - } + if (base.getEquipmentInSlot(1) != null + && base.getEquipmentInSlot(1).getItem() instanceof ItemFreeRunners) { + ItemStack stack = base.getEquipmentInSlot(1); + ItemFreeRunners boots = (ItemFreeRunners) stack.getItem(); + + if (boots.getEnergy(stack) > 0 && event.source == DamageSource.fall) { + boots.setEnergy(stack, boots.getEnergy(stack) - event.ammount * 50); + event.setCanceled(true); + } + } + } } diff --git a/src/main/java/mekanism/common/item/ItemGasMask.java b/src/main/java/mekanism/common/item/ItemGasMask.java index 208c3c42b..5d35b96ef 100644 --- a/src/main/java/mekanism/common/item/ItemGasMask.java +++ b/src/main/java/mekanism/common/item/ItemGasMask.java @@ -1,5 +1,8 @@ package mekanism.common.item; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.render.ModelCustomArmor; import mekanism.client.render.ModelCustomArmor.ArmorModel; import mekanism.common.Mekanism; @@ -12,64 +15,57 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.DamageSource; import net.minecraftforge.common.util.EnumHelper; import net.minecraftforge.event.entity.living.LivingAttackEvent; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class ItemGasMask extends ItemArmor -{ - public ItemGasMask() - { - super(EnumHelper.addArmorMaterial("GASMASK", 0, new int[] {0, 0, 0, 0}, 0), 0, 0); - setCreativeTab(Mekanism.tabMekanism); - } +public class ItemGasMask extends ItemArmor { + public ItemGasMask() { + super( + EnumHelper.addArmorMaterial("GASMASK", 0, new int[] { 0, 0, 0, 0 }, 0), 0, 0 + ); + setCreativeTab(Mekanism.tabMekanism); + } - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister register) {} + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister register) {} - @Override - public boolean isValidArmor(ItemStack stack, int armorType, Entity entity) - { - return armorType == 0; - } + @Override + public boolean isValidArmor(ItemStack stack, int armorType, Entity entity) { + return armorType == 0; + } - @Override - public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) - { - return "mekanism:render/NullArmor.png"; - } + @Override + public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { + return "mekanism:render/NullArmor.png"; + } - @Override - @SideOnly(Side.CLIENT) - public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) - { - ModelCustomArmor model = ModelCustomArmor.INSTANCE; - model.modelType = ArmorModel.GASMASK; - return model; - } + @Override + @SideOnly(Side.CLIENT) + public ModelBiped + getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) { + ModelCustomArmor model = ModelCustomArmor.INSTANCE; + model.modelType = ArmorModel.GASMASK; + return model; + } - @SubscribeEvent - public void onEntityAttacked(LivingAttackEvent event) - { - EntityLivingBase base = event.entityLiving; + @SubscribeEvent + public void onEntityAttacked(LivingAttackEvent event) { + EntityLivingBase base = event.entityLiving; - if(base.getEquipmentInSlot(4) != null && base.getEquipmentInSlot(4).getItem() instanceof ItemGasMask) - { - ItemGasMask mask = (ItemGasMask)base.getEquipmentInSlot(4).getItem(); + if (base.getEquipmentInSlot(4) != null + && base.getEquipmentInSlot(4).getItem() instanceof ItemGasMask) { + ItemGasMask mask = (ItemGasMask) base.getEquipmentInSlot(4).getItem(); - if(base.getEquipmentInSlot(3) != null && base.getEquipmentInSlot(3).getItem() instanceof ItemScubaTank) - { - ItemScubaTank tank = (ItemScubaTank)base.getEquipmentInSlot(3).getItem(); + if (base.getEquipmentInSlot(3) != null + && base.getEquipmentInSlot(3).getItem() instanceof ItemScubaTank) { + ItemScubaTank tank = (ItemScubaTank) base.getEquipmentInSlot(3).getItem(); - if(tank.getFlowing(base.getEquipmentInSlot(3)) && tank.getGas(base.getEquipmentInSlot(3)) != null) - { - if(event.source == DamageSource.magic) - { - event.setCanceled(true); - } - } - } - } - } + if (tank.getFlowing(base.getEquipmentInSlot(3)) + && tank.getGas(base.getEquipmentInSlot(3)) != null) { + if (event.source == DamageSource.magic) { + event.setCanceled(true); + } + } + } + } + } } diff --git a/src/main/java/mekanism/common/item/ItemGaugeDropper.java b/src/main/java/mekanism/common/item/ItemGaugeDropper.java index ac4e83efd..90f9d16ea 100644 --- a/src/main/java/mekanism/common/item/ItemGaugeDropper.java +++ b/src/main/java/mekanism/common/item/ItemGaugeDropper.java @@ -2,6 +2,8 @@ package mekanism.common.item; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.gas.Gas; import mekanism.api.gas.GasStack; import mekanism.api.gas.IGasItem; @@ -18,272 +20,256 @@ import net.minecraft.world.World; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidContainerItem; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class ItemGaugeDropper extends ItemMekanism implements IGasItem, IFluidContainerItem -{ - public static int CAPACITY = FluidContainerRegistry.BUCKET_VOLUME; - - public static final int TRANSFER_RATE = 16; - - public ItemGaugeDropper() - { - super(); - setMaxStackSize(1); - setCreativeTab(Mekanism.tabMekanism); - } - - public ItemStack getEmptyItem() - { - ItemStack empty = new ItemStack(this); - setGas(empty, null); - setFluid(empty, null); - return empty; - } - - @Override - public void getSubItems(Item item, CreativeTabs tabs, List list) - { - list.add(getEmptyItem()); - } - - @Override - public boolean showDurabilityBar(ItemStack stack) - { - return true; - } - - @Override - public double getDurabilityForDisplay(ItemStack stack) - { - double gasRatio = ((getGas(stack) != null ? (double)getGas(stack).amount : 0D)/(double)CAPACITY); - double fluidRatio = ((getFluid(stack) != null ? (double)getFluid(stack).amount : 0D)/(double)CAPACITY); - - return 1D-Math.max(gasRatio, fluidRatio); - } - - @Override - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) - { - if(player.isSneaking() && !world.isRemote) - { - setGas(stack, null); - setFluid(stack, null); - - ((EntityPlayerMP)player).sendContainerAndContentsToPlayer(player.openContainer, player.openContainer.getInventory()); - - return stack; - } - - return stack; - } - - @Override - @SideOnly(Side.CLIENT) - public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) - { - GasStack gasStack = getGas(itemstack); - FluidStack fluidStack = getFluid(itemstack); +public class ItemGaugeDropper + extends ItemMekanism implements IGasItem, IFluidContainerItem { + public static int CAPACITY = FluidContainerRegistry.BUCKET_VOLUME; - if(gasStack == null && fluidStack == null) - { - list.add(LangUtils.localize("gui.empty") + "."); - } - else if(gasStack != null) - { - list.add(LangUtils.localize("tooltip.stored") + " " + gasStack.getGas().getLocalizedName() + ": " + gasStack.amount); - } - else if(fluidStack != null) - { - list.add(LangUtils.localize("tooltip.stored") + " " + fluidStack.getFluid().getLocalizedName(fluidStack) + ": " + fluidStack.amount); - } - } + public static final int TRANSFER_RATE = 16; - private FluidStack getFluid_do(ItemStack container) - { - if(container.stackTagCompound == null) - { - return null; - } + public ItemGaugeDropper() { + super(); + setMaxStackSize(1); + setCreativeTab(Mekanism.tabMekanism); + } - if(container.stackTagCompound.hasKey("fluidStack")) - { - return FluidStack.loadFluidStackFromNBT(container.stackTagCompound.getCompoundTag("fluidStack")); - } - - return null; - } - - @Override - public FluidStack getFluid(ItemStack container) - { - return getFluid_do(container); - } - - public void setFluid(ItemStack container, FluidStack stack) - { - if(container.stackTagCompound == null) - { - container.setTagCompound(new NBTTagCompound()); - } - - if(stack == null || stack.amount == 0 || stack.getFluidID() == 0) - { - container.stackTagCompound.removeTag("fluidStack"); - } - else { - container.stackTagCompound.setTag("fluidStack", stack.writeToNBT(new NBTTagCompound())); - } - } + public ItemStack getEmptyItem() { + ItemStack empty = new ItemStack(this); + setGas(empty, null); + setFluid(empty, null); + return empty; + } - @Override - public int getCapacity(ItemStack container) - { - return CAPACITY; - } + @Override + public void getSubItems(Item item, CreativeTabs tabs, List list) { + list.add(getEmptyItem()); + } - @Override - public int fill(ItemStack container, FluidStack resource, boolean doFill) - { - FluidStack stored = getFluid(container); - int toFill; + @Override + public boolean showDurabilityBar(ItemStack stack) { + return true; + } - if(stored != null && stored.getFluid() != resource.getFluid()) - { - return 0; - } - - if(stored == null) - { - toFill = Math.min(resource.amount, CAPACITY); - } - else { - toFill = Math.min(resource.amount, CAPACITY-stored.amount); - } - - if(doFill) - { - int fillAmount = toFill + (stored == null ? 0 : stored.amount); - setFluid(container, PipeUtils.copy(resource, (stored != null ? stored.amount : 0)+toFill)); - } - - return toFill; - } + @Override + public double getDurabilityForDisplay(ItemStack stack) { + double gasRatio + = ((getGas(stack) != null ? (double) getGas(stack).amount : 0D) + / (double) CAPACITY); + double fluidRatio + = ((getFluid(stack) != null ? (double) getFluid(stack).amount : 0D) + / (double) CAPACITY); - @Override - public FluidStack drain(ItemStack container, int maxDrain, boolean doDrain) - { - FluidStack stored = getFluid(container); - - if(stored != null) - { - FluidStack toDrain = PipeUtils.copy(stored, Math.min(stored.amount, maxDrain)); - - if(doDrain) - { - stored.amount -= toDrain.amount; - setFluid(container, stored.amount > 0 ? stored : null); - } - - return toDrain; - } - - return null; - } + return 1D - Math.max(gasRatio, fluidRatio); + } - @Override - public int getRate(ItemStack itemstack) - { - return TRANSFER_RATE; - } + @Override + public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { + if (player.isSneaking() && !world.isRemote) { + setGas(stack, null); + setFluid(stack, null); - @Override - public int addGas(ItemStack itemstack, GasStack stack) - { - if(getGas(itemstack) != null && getGas(itemstack).getGas() != stack.getGas()) - { - return 0; - } + ((EntityPlayerMP) player) + .sendContainerAndContentsToPlayer( + player.openContainer, player.openContainer.getInventory() + ); - int toUse = Math.min(getMaxGas(itemstack)-getStored(itemstack), Math.min(getRate(itemstack), stack.amount)); - setGas(itemstack, new GasStack(stack.getGas(), getStored(itemstack)+toUse)); + return stack; + } - return toUse; - } + return stack; + } - @Override - public GasStack removeGas(ItemStack itemstack, int amount) - { - if(getGas(itemstack) == null) - { - return null; - } + @Override + @SideOnly(Side.CLIENT) + public void addInformation( + ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag + ) { + GasStack gasStack = getGas(itemstack); + FluidStack fluidStack = getFluid(itemstack); - Gas type = getGas(itemstack).getGas(); + if (gasStack == null && fluidStack == null) { + list.add(LangUtils.localize("gui.empty") + "."); + } else if (gasStack != null) { + list.add( + LangUtils.localize("tooltip.stored") + " " + + gasStack.getGas().getLocalizedName() + ": " + gasStack.amount + ); + } else if (fluidStack != null) { + list.add( + LangUtils.localize("tooltip.stored") + " " + + fluidStack.getFluid().getLocalizedName(fluidStack) + ": " + + fluidStack.amount + ); + } + } - int gasToUse = Math.min(getStored(itemstack), Math.min(getRate(itemstack), amount)); - setGas(itemstack, new GasStack(type, getStored(itemstack)-gasToUse)); + private FluidStack getFluid_do(ItemStack container) { + if (container.stackTagCompound == null) { + return null; + } - return new GasStack(type, gasToUse); - } + if (container.stackTagCompound.hasKey("fluidStack")) { + return FluidStack.loadFluidStackFromNBT( + container.stackTagCompound.getCompoundTag("fluidStack") + ); + } - private int getStored(ItemStack itemstack) - { - return getGas(itemstack) != null ? getGas(itemstack).amount : 0; - } - - @Override - public boolean canReceiveGas(ItemStack itemstack, Gas type) - { - return getGas(itemstack) == null || getGas(itemstack).getGas() == type; - } + return null; + } - @Override - public boolean canProvideGas(ItemStack itemstack, Gas type) - { - return getGas(itemstack) != null && (type == null || getGas(itemstack).getGas() == type); - } + @Override + public FluidStack getFluid(ItemStack container) { + return getFluid_do(container); + } - private GasStack getGas_do(ItemStack itemstack) - { - if(itemstack.stackTagCompound == null) - { - return null; - } + public void setFluid(ItemStack container, FluidStack stack) { + if (container.stackTagCompound == null) { + container.setTagCompound(new NBTTagCompound()); + } - return GasStack.readFromNBT(itemstack.stackTagCompound.getCompoundTag("gasStack")); - } - - @Override - public GasStack getGas(ItemStack itemstack) - { - return getGas_do(itemstack); - } + if (stack == null || stack.amount == 0 || stack.getFluidID() == 0) { + container.stackTagCompound.removeTag("fluidStack"); + } else { + container.stackTagCompound.setTag( + "fluidStack", stack.writeToNBT(new NBTTagCompound()) + ); + } + } - @Override - public void setGas(ItemStack itemstack, GasStack stack) - { - if(itemstack.stackTagCompound == null) - { - itemstack.setTagCompound(new NBTTagCompound()); - } + @Override + public int getCapacity(ItemStack container) { + return CAPACITY; + } - if(stack == null || stack.amount == 0) - { - itemstack.stackTagCompound.removeTag("gasStack"); - } - else { - int amount = Math.max(0, Math.min(stack.amount, getMaxGas(itemstack))); - GasStack gasStack = new GasStack(stack.getGas(), amount); + @Override + public int fill(ItemStack container, FluidStack resource, boolean doFill) { + FluidStack stored = getFluid(container); + int toFill; - itemstack.stackTagCompound.setTag("gasStack", gasStack.write(new NBTTagCompound())); - } - } + if (stored != null && stored.getFluid() != resource.getFluid()) { + return 0; + } - @Override - public int getMaxGas(ItemStack itemstack) - { - return CAPACITY; - } + if (stored == null) { + toFill = Math.min(resource.amount, CAPACITY); + } else { + toFill = Math.min(resource.amount, CAPACITY - stored.amount); + } + + if (doFill) { + int fillAmount = toFill + (stored == null ? 0 : stored.amount); + setFluid( + container, + PipeUtils.copy(resource, (stored != null ? stored.amount : 0) + toFill) + ); + } + + return toFill; + } + + @Override + public FluidStack drain(ItemStack container, int maxDrain, boolean doDrain) { + FluidStack stored = getFluid(container); + + if (stored != null) { + FluidStack toDrain + = PipeUtils.copy(stored, Math.min(stored.amount, maxDrain)); + + if (doDrain) { + stored.amount -= toDrain.amount; + setFluid(container, stored.amount > 0 ? stored : null); + } + + return toDrain; + } + + return null; + } + + @Override + public int getRate(ItemStack itemstack) { + return TRANSFER_RATE; + } + + @Override + public int addGas(ItemStack itemstack, GasStack stack) { + if (getGas(itemstack) != null && getGas(itemstack).getGas() != stack.getGas()) { + return 0; + } + + int toUse = Math.min( + getMaxGas(itemstack) - getStored(itemstack), + Math.min(getRate(itemstack), stack.amount) + ); + setGas(itemstack, new GasStack(stack.getGas(), getStored(itemstack) + toUse)); + + return toUse; + } + + @Override + public GasStack removeGas(ItemStack itemstack, int amount) { + if (getGas(itemstack) == null) { + return null; + } + + Gas type = getGas(itemstack).getGas(); + + int gasToUse + = Math.min(getStored(itemstack), Math.min(getRate(itemstack), amount)); + setGas(itemstack, new GasStack(type, getStored(itemstack) - gasToUse)); + + return new GasStack(type, gasToUse); + } + + private int getStored(ItemStack itemstack) { + return getGas(itemstack) != null ? getGas(itemstack).amount : 0; + } + + @Override + public boolean canReceiveGas(ItemStack itemstack, Gas type) { + return getGas(itemstack) == null || getGas(itemstack).getGas() == type; + } + + @Override + public boolean canProvideGas(ItemStack itemstack, Gas type) { + return getGas(itemstack) != null + && (type == null || getGas(itemstack).getGas() == type); + } + + private GasStack getGas_do(ItemStack itemstack) { + if (itemstack.stackTagCompound == null) { + return null; + } + + return GasStack.readFromNBT(itemstack.stackTagCompound.getCompoundTag("gasStack") + ); + } + + @Override + public GasStack getGas(ItemStack itemstack) { + return getGas_do(itemstack); + } + + @Override + public void setGas(ItemStack itemstack, GasStack stack) { + if (itemstack.stackTagCompound == null) { + itemstack.setTagCompound(new NBTTagCompound()); + } + + if (stack == null || stack.amount == 0) { + itemstack.stackTagCompound.removeTag("gasStack"); + } else { + int amount = Math.max(0, Math.min(stack.amount, getMaxGas(itemstack))); + GasStack gasStack = new GasStack(stack.getGas(), amount); + + itemstack.stackTagCompound.setTag( + "gasStack", gasStack.write(new NBTTagCompound()) + ); + } + } + + @Override + public int getMaxGas(ItemStack itemstack) { + return CAPACITY; + } } diff --git a/src/main/java/mekanism/common/item/ItemHDPE.java b/src/main/java/mekanism/common/item/ItemHDPE.java index 068e42271..73fceb326 100644 --- a/src/main/java/mekanism/common/item/ItemHDPE.java +++ b/src/main/java/mekanism/common/item/ItemHDPE.java @@ -9,64 +9,54 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -public class ItemHDPE extends ItemMekanism -{ - public IIcon[] icons = new IIcon[256]; +public class ItemHDPE extends ItemMekanism { + public IIcon[] icons = new IIcon[256]; - public ItemHDPE() - { - super(); - setHasSubtypes(true); - setCreativeTab(Mekanism.tabMekanism); - } + public ItemHDPE() { + super(); + setHasSubtypes(true); + setCreativeTab(Mekanism.tabMekanism); + } - @Override - public void registerIcons(IIconRegister register) - { - for(int i = 0; i < PlasticItem.values().length; i++) - { - icons[i] = register.registerIcon("mekanism:" + PlasticItem.values()[i].getName()); - } - } + @Override + public void registerIcons(IIconRegister register) { + for (int i = 0; i < PlasticItem.values().length; i++) { + icons[i] + = register.registerIcon("mekanism:" + PlasticItem.values()[i].getName()); + } + } - @Override - public IIcon getIconFromDamage(int meta) - { - return icons[meta]; - } + @Override + public IIcon getIconFromDamage(int meta) { + return icons[meta]; + } - @Override - public void getSubItems(Item item, CreativeTabs tabs, List itemList) - { - for(int counter = 0; counter < PlasticItem.values().length; counter++) - { - itemList.add(new ItemStack(item, 1, counter)); - } - } + @Override + public void getSubItems(Item item, CreativeTabs tabs, List itemList) { + for (int counter = 0; counter < PlasticItem.values().length; counter++) { + itemList.add(new ItemStack(item, 1, counter)); + } + } - @Override - public String getUnlocalizedName(ItemStack item) - { - return "item." + PlasticItem.values()[item.getItemDamage()].getName(); - } + @Override + public String getUnlocalizedName(ItemStack item) { + return "item." + PlasticItem.values()[item.getItemDamage()].getName(); + } - public enum PlasticItem - { - PELLET("HDPEPellet"), - ROD("HDPERod"), - SHEET("HDPESheet"), - STICK("PlaStick"); + public enum PlasticItem { + PELLET("HDPEPellet"), + ROD("HDPERod"), + SHEET("HDPESheet"), + STICK("PlaStick"); - private String name; + private String name; - private PlasticItem(String itemName) - { - name = itemName; - } + private PlasticItem(String itemName) { + name = itemName; + } - public String getName() - { - return name; - } - } + public String getName() { + return name; + } + } } diff --git a/src/main/java/mekanism/common/item/ItemIngot.java b/src/main/java/mekanism/common/item/ItemIngot.java index 7f03241c3..b04d1f0e2 100644 --- a/src/main/java/mekanism/common/item/ItemIngot.java +++ b/src/main/java/mekanism/common/item/ItemIngot.java @@ -8,47 +8,38 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -public class ItemIngot extends ItemMekanism -{ - public IIcon[] icons = new IIcon[256]; +public class ItemIngot extends ItemMekanism { + public IIcon[] icons = new IIcon[256]; - public static String[] en_USNames = {"Obsidian", "Osmium", "Bronze", - "Glowstone", "Steel", "Copper", - "Tin"}; + public static String[] en_USNames + = { "Obsidian", "Osmium", "Bronze", "Glowstone", "Steel", "Copper", "Tin" }; - public ItemIngot() - { - super(); - setHasSubtypes(true); - } + public ItemIngot() { + super(); + setHasSubtypes(true); + } - @Override - public void registerIcons(IIconRegister register) - { - for(int i = 0; i <= 6; i++) - { - icons[i] = register.registerIcon("mekanism:" + en_USNames[i] + "Ingot"); - } - } + @Override + public void registerIcons(IIconRegister register) { + for (int i = 0; i <= 6; i++) { + icons[i] = register.registerIcon("mekanism:" + en_USNames[i] + "Ingot"); + } + } - @Override - public IIcon getIconFromDamage(int meta) - { - return icons[meta]; - } + @Override + public IIcon getIconFromDamage(int meta) { + return icons[meta]; + } - @Override - public void getSubItems(Item item, CreativeTabs tabs, List itemList) - { - for(int counter = 0; counter <= 6; counter++) - { - itemList.add(new ItemStack(item, 1, counter)); - } - } + @Override + public void getSubItems(Item item, CreativeTabs tabs, List itemList) { + for (int counter = 0; counter <= 6; counter++) { + itemList.add(new ItemStack(item, 1, counter)); + } + } - @Override - public String getUnlocalizedName(ItemStack item) - { - return "item." + en_USNames[item.getItemDamage()].toLowerCase() + "Ingot"; - } + @Override + public String getUnlocalizedName(ItemStack item) { + return "item." + en_USNames[item.getItemDamage()].toLowerCase() + "Ingot"; + } } diff --git a/src/main/java/mekanism/common/item/ItemJetpack.java b/src/main/java/mekanism/common/item/ItemJetpack.java index db5100d2e..99735a707 100644 --- a/src/main/java/mekanism/common/item/ItemJetpack.java +++ b/src/main/java/mekanism/common/item/ItemJetpack.java @@ -2,6 +2,8 @@ package mekanism.common.item; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.EnumColor; import mekanism.api.MekanismConfig.general; import mekanism.api.gas.Gas; @@ -26,272 +28,261 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.DamageSource; import net.minecraftforge.common.ISpecialArmor; import net.minecraftforge.common.util.EnumHelper; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class ItemJetpack extends ItemArmor implements IGasItem, ISpecialArmor -{ - public int TRANSFER_RATE = 16; +public class ItemJetpack extends ItemArmor implements IGasItem, ISpecialArmor { + public int TRANSFER_RATE = 16; - public ItemJetpack() - { - super(EnumHelper.addArmorMaterial("JETPACK", 0, new int[] {0, 0, 0, 0}, 0), 0, 1); - setCreativeTab(Mekanism.tabMekanism); - } + public ItemJetpack() { + super( + EnumHelper.addArmorMaterial("JETPACK", 0, new int[] { 0, 0, 0, 0 }, 0), 0, 1 + ); + setCreativeTab(Mekanism.tabMekanism); + } - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister register) {} - - @Override - public boolean showDurabilityBar(ItemStack stack) - { - return true; - } - - @Override - public double getDurabilityForDisplay(ItemStack stack) - { - return 1D-((getGas(stack) != null ? (double)getGas(stack).amount : 0D)/(double)getMaxGas(stack)); - } + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister register) {} - @Override - public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) - { - GasStack gasStack = getGas(itemstack); + @Override + public boolean showDurabilityBar(ItemStack stack) { + return true; + } - if(gasStack == null) - { - list.add(LangUtils.localize("tooltip.noGas") + "."); - } - else { - list.add(LangUtils.localize("tooltip.stored") + " " + gasStack.getGas().getLocalizedName() + ": " + gasStack.amount); - } + @Override + public double getDurabilityForDisplay(ItemStack stack) { + return 1D + - ((getGas(stack) != null ? (double) getGas(stack).amount : 0D) + / (double) getMaxGas(stack)); + } - list.add(EnumColor.GREY + LangUtils.localize("tooltip.mode") + ": " + EnumColor.GREY + getMode(itemstack).getName()); - } + @Override + public void addInformation( + ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag + ) { + GasStack gasStack = getGas(itemstack); - @Override - public boolean isValidArmor(ItemStack stack, int armorType, Entity entity) - { - return armorType == 1; - } + if (gasStack == null) { + list.add(LangUtils.localize("tooltip.noGas") + "."); + } else { + list.add( + LangUtils.localize("tooltip.stored") + " " + + gasStack.getGas().getLocalizedName() + ": " + gasStack.amount + ); + } - @Override - public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) - { - return "mekanism:render/NullArmor.png"; - } + list.add( + EnumColor.GREY + LangUtils.localize("tooltip.mode") + ": " + EnumColor.GREY + + getMode(itemstack).getName() + ); + } - @Override - @SideOnly(Side.CLIENT) - public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) - { - ModelCustomArmor model = ModelCustomArmor.INSTANCE; + @Override + public boolean isValidArmor(ItemStack stack, int armorType, Entity entity) { + return armorType == 1; + } - if(this == MekanismItems.Jetpack) - { - model.modelType = ArmorModel.JETPACK; - } - else if(this == MekanismItems.ArmoredJetpack) - { - model.modelType = ArmorModel.ARMOREDJETPACK; - } + @Override + public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { + return "mekanism:render/NullArmor.png"; + } - return model; - } + @Override + @SideOnly(Side.CLIENT) + public ModelBiped + getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) { + ModelCustomArmor model = ModelCustomArmor.INSTANCE; - public void incrementMode(ItemStack stack) - { - setMode(stack, getMode(stack).increment()); - } + if (this == MekanismItems.Jetpack) { + model.modelType = ArmorModel.JETPACK; + } else if (this == MekanismItems.ArmoredJetpack) { + model.modelType = ArmorModel.ARMOREDJETPACK; + } - public void useGas(ItemStack stack) - { - setGas(stack, new GasStack(getGas(stack).getGas(), getGas(stack).amount-1)); - } + return model; + } - @Override - public int getMaxGas(ItemStack itemstack) - { - return general.maxJetpackGas; - } + public void incrementMode(ItemStack stack) { + setMode(stack, getMode(stack).increment()); + } - @Override - public int getRate(ItemStack itemstack) - { - return TRANSFER_RATE; - } + public void useGas(ItemStack stack) { + setGas(stack, new GasStack(getGas(stack).getGas(), getGas(stack).amount - 1)); + } - @Override - public int addGas(ItemStack itemstack, GasStack stack) - { - if(getGas(itemstack) != null && getGas(itemstack).getGas() != stack.getGas()) - { - return 0; - } + @Override + public int getMaxGas(ItemStack itemstack) { + return general.maxJetpackGas; + } - if(stack.getGas() != GasRegistry.getGas("hydrogen")) - { - return 0; - } + @Override + public int getRate(ItemStack itemstack) { + return TRANSFER_RATE; + } - int toUse = Math.min(getMaxGas(itemstack)-getStored(itemstack), Math.min(getRate(itemstack), stack.amount)); - setGas(itemstack, new GasStack(stack.getGas(), getStored(itemstack)+toUse)); + @Override + public int addGas(ItemStack itemstack, GasStack stack) { + if (getGas(itemstack) != null && getGas(itemstack).getGas() != stack.getGas()) { + return 0; + } - return toUse; - } + if (stack.getGas() != GasRegistry.getGas("hydrogen")) { + return 0; + } - @Override - public GasStack removeGas(ItemStack itemstack, int amount) - { - return null; - } + int toUse = Math.min( + getMaxGas(itemstack) - getStored(itemstack), + Math.min(getRate(itemstack), stack.amount) + ); + setGas(itemstack, new GasStack(stack.getGas(), getStored(itemstack) + toUse)); - public int getStored(ItemStack itemstack) - { - return getGas(itemstack) != null ? getGas(itemstack).amount : 0; - } + return toUse; + } - @Override - public boolean canReceiveGas(ItemStack itemstack, Gas type) - { - return type == GasRegistry.getGas("hydrogen"); - } + @Override + public GasStack removeGas(ItemStack itemstack, int amount) { + return null; + } - @Override - public boolean canProvideGas(ItemStack itemstack, Gas type) - { - return false; - } + public int getStored(ItemStack itemstack) { + return getGas(itemstack) != null ? getGas(itemstack).amount : 0; + } - @Override - public GasStack getGas(ItemStack itemstack) - { - if(itemstack.stackTagCompound == null) - { - return null; - } + @Override + public boolean canReceiveGas(ItemStack itemstack, Gas type) { + return type == GasRegistry.getGas("hydrogen"); + } - return GasStack.readFromNBT(itemstack.stackTagCompound.getCompoundTag("stored")); - } + @Override + public boolean canProvideGas(ItemStack itemstack, Gas type) { + return false; + } - public JetpackMode getMode(ItemStack stack) - { - if(stack.stackTagCompound == null) - { - return JetpackMode.NORMAL; - } + @Override + public GasStack getGas(ItemStack itemstack) { + if (itemstack.stackTagCompound == null) { + return null; + } - return JetpackMode.values()[stack.stackTagCompound.getInteger("mode")]; - } + return GasStack.readFromNBT(itemstack.stackTagCompound.getCompoundTag("stored")); + } - public void setMode(ItemStack stack, JetpackMode mode) - { - if(stack.stackTagCompound == null) - { - stack.setTagCompound(new NBTTagCompound()); - } + public JetpackMode getMode(ItemStack stack) { + if (stack.stackTagCompound == null) { + return JetpackMode.NORMAL; + } - stack.stackTagCompound.setInteger("mode", mode.ordinal()); - } + return JetpackMode.values()[stack.stackTagCompound.getInteger("mode")]; + } - @Override - public void setGas(ItemStack itemstack, GasStack stack) - { - if(itemstack.stackTagCompound == null) - { - itemstack.setTagCompound(new NBTTagCompound()); - } + public void setMode(ItemStack stack, JetpackMode mode) { + if (stack.stackTagCompound == null) { + stack.setTagCompound(new NBTTagCompound()); + } - if(stack == null || stack.amount == 0) - { - itemstack.stackTagCompound.removeTag("stored"); - } - else { - int amount = Math.max(0, Math.min(stack.amount, getMaxGas(itemstack))); - GasStack gasStack = new GasStack(stack.getGas(), amount); + stack.stackTagCompound.setInteger("mode", mode.ordinal()); + } - itemstack.stackTagCompound.setTag("stored", gasStack.write(new NBTTagCompound())); - } - } + @Override + public void setGas(ItemStack itemstack, GasStack stack) { + if (itemstack.stackTagCompound == null) { + itemstack.setTagCompound(new NBTTagCompound()); + } - public ItemStack getEmptyItem() - { - ItemStack empty = new ItemStack(this); - setGas(empty, null); - - return empty; - } + if (stack == null || stack.amount == 0) { + itemstack.stackTagCompound.removeTag("stored"); + } else { + int amount = Math.max(0, Math.min(stack.amount, getMaxGas(itemstack))); + GasStack gasStack = new GasStack(stack.getGas(), amount); - @Override - public void getSubItems(Item item, CreativeTabs tabs, List list) - { - ItemStack empty = new ItemStack(this); - setGas(empty, null); - list.add(empty); + itemstack.stackTagCompound.setTag( + "stored", gasStack.write(new NBTTagCompound()) + ); + } + } - ItemStack filled = new ItemStack(this); - setGas(filled, new GasStack(GasRegistry.getGas("hydrogen"), ((IGasItem)filled.getItem()).getMaxGas(filled))); - list.add(filled); - } + public ItemStack getEmptyItem() { + ItemStack empty = new ItemStack(this); + setGas(empty, null); - public static enum JetpackMode - { - NORMAL("tooltip.jetpack.regular", EnumColor.DARK_GREEN), - HOVER("tooltip.jetpack.hover", EnumColor.DARK_AQUA), - DISABLED("tooltip.jetpack.disabled", EnumColor.DARK_RED); + return empty; + } - private String unlocalized; - private EnumColor color; + @Override + public void getSubItems(Item item, CreativeTabs tabs, List list) { + ItemStack empty = new ItemStack(this); + setGas(empty, null); + list.add(empty); - private JetpackMode(String s, EnumColor c) - { - unlocalized = s; - color = c; - } + ItemStack filled = new ItemStack(this); + setGas( + filled, + new GasStack( + GasRegistry.getGas("hydrogen"), + ((IGasItem) filled.getItem()).getMaxGas(filled) + ) + ); + list.add(filled); + } - public JetpackMode increment() - { - return ordinal() < values().length-1 ? values()[ordinal()+1] : values()[0]; - } + public static enum JetpackMode { + NORMAL("tooltip.jetpack.regular", EnumColor.DARK_GREEN), + HOVER("tooltip.jetpack.hover", EnumColor.DARK_AQUA), + DISABLED("tooltip.jetpack.disabled", EnumColor.DARK_RED); - public String getName() - { - return color + LangUtils.localize(unlocalized); - } - } + private String unlocalized; + private EnumColor color; - @Override - public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) - { - if(this == MekanismItems.Jetpack) - { - return new ArmorProperties(0, 0, 0); - } - else if(this == MekanismItems.ArmoredJetpack) - { - return new ArmorProperties(1, general.armoredJetpackDamageRatio, general.armoredJetpackDamageMax); - } + private JetpackMode(String s, EnumColor c) { + unlocalized = s; + color = c; + } - return new ArmorProperties(0, 0, 0); - } + public JetpackMode increment() { + return ordinal() < values().length - 1 ? values()[ordinal() + 1] + : values()[0]; + } - @Override - public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) - { - if(armor.getItem() == MekanismItems.Jetpack) - { - return 0; - } - else if(armor.getItem() == MekanismItems.ArmoredJetpack) - { - return 12; - } + public String getName() { + return color + LangUtils.localize(unlocalized); + } + } - return 0; - } + @Override + public ArmorProperties getProperties( + EntityLivingBase player, + ItemStack armor, + DamageSource source, + double damage, + int slot + ) { + if (this == MekanismItems.Jetpack) { + return new ArmorProperties(0, 0, 0); + } else if (this == MekanismItems.ArmoredJetpack) { + return new ArmorProperties( + 1, general.armoredJetpackDamageRatio, general.armoredJetpackDamageMax + ); + } - @Override - public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) {} + return new ArmorProperties(0, 0, 0); + } + + @Override + public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) { + if (armor.getItem() == MekanismItems.Jetpack) { + return 0; + } else if (armor.getItem() == MekanismItems.ArmoredJetpack) { + return 12; + } + + return 0; + } + + @Override + public void damageArmor( + EntityLivingBase entity, + ItemStack stack, + DamageSource source, + int damage, + int slot + ) {} } diff --git a/src/main/java/mekanism/common/item/ItemMekanism.java b/src/main/java/mekanism/common/item/ItemMekanism.java index b7156ebff..c983d9016 100644 --- a/src/main/java/mekanism/common/item/ItemMekanism.java +++ b/src/main/java/mekanism/common/item/ItemMekanism.java @@ -4,17 +4,16 @@ import mekanism.common.Mekanism; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.item.Item; -public class ItemMekanism extends Item -{ - public ItemMekanism() - { - super(); - setCreativeTab(Mekanism.tabMekanism); - } +public class ItemMekanism extends Item { + public ItemMekanism() { + super(); + setCreativeTab(Mekanism.tabMekanism); + } - @Override - public void registerIcons(IIconRegister register) - { - itemIcon = register.registerIcon("mekanism:" + getUnlocalizedName().replace("item.", "")); - } + @Override + public void registerIcons(IIconRegister register) { + itemIcon = register.registerIcon( + "mekanism:" + getUnlocalizedName().replace("item.", "") + ); + } } diff --git a/src/main/java/mekanism/common/item/ItemNetworkReader.java b/src/main/java/mekanism/common/item/ItemNetworkReader.java index f7e15b441..83e5aed64 100644 --- a/src/main/java/mekanism/common/item/ItemNetworkReader.java +++ b/src/main/java/mekanism/common/item/ItemNetworkReader.java @@ -18,103 +18,168 @@ import net.minecraft.util.ChatComponentText; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -public class ItemNetworkReader extends ItemEnergized -{ - public static double ENERGY_PER_USE = 400; +public class ItemNetworkReader extends ItemEnergized { + public static double ENERGY_PER_USE = 400; - public ItemNetworkReader() - { - super(60000); - } + public ItemNetworkReader() { + super(60000); + } - @Override - public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) - { - if(!world.isRemote) - { - TileEntity tileEntity = world.getTileEntity(x, y, z); - boolean drain = !player.capabilities.isCreativeMode; + @Override + public boolean onItemUseFirst( + ItemStack stack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int side, + float hitX, + float hitY, + float hitZ + ) { + if (!world.isRemote) { + TileEntity tileEntity = world.getTileEntity(x, y, z); + boolean drain = !player.capabilities.isCreativeMode; - if(getEnergy(stack) >= ENERGY_PER_USE) - { - if(tileEntity instanceof ITransmitterTile) - { - if(drain) setEnergy(stack, getEnergy(stack)-ENERGY_PER_USE); - - IGridTransmitter transmitter = ((ITransmitterTile)tileEntity).getTransmitter(); - - player.addChatMessage(new ChatComponentText(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " -------------")); - player.addChatMessage(new ChatComponentText(EnumColor.GREY + " *Transmitters: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetworkSize())); - player.addChatMessage(new ChatComponentText(EnumColor.GREY + " *Acceptors: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetworkAcceptorSize())); - player.addChatMessage(new ChatComponentText(EnumColor.GREY + " *Needed: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetworkNeeded())); - player.addChatMessage(new ChatComponentText(EnumColor.GREY + " *Buffer: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetworkBuffer())); - player.addChatMessage(new ChatComponentText(EnumColor.GREY + " *Throughput: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetworkFlow())); - player.addChatMessage(new ChatComponentText(EnumColor.GREY + " *Capacity: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetworkCapacity())); - if(transmitter instanceof IHeatTransfer) - player.addChatMessage(new ChatComponentText(EnumColor.GREY + " *Temperature: " + EnumColor.DARK_GREY + ((IHeatTransfer)transmitter).getTemp() + "K above ambient")); - player.addChatMessage(new ChatComponentText(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------")); - - return true; - } - else if(tileEntity instanceof IHeatTransfer) - { - if(drain) setEnergy(stack, getEnergy(stack)-ENERGY_PER_USE); + if (getEnergy(stack) >= ENERGY_PER_USE) { + if (tileEntity instanceof ITransmitterTile) { + if (drain) + setEnergy(stack, getEnergy(stack) - ENERGY_PER_USE); - player.addChatMessage(new ChatComponentText(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " -------------")); - player.addChatMessage(new ChatComponentText(EnumColor.GREY + " *Temperature: " + EnumColor.DARK_GREY + ((IHeatTransfer)tileEntity).getTemp() + "K above ambient")); - player.addChatMessage(new ChatComponentText(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------")); + IGridTransmitter transmitter + = ((ITransmitterTile) tileEntity).getTransmitter(); - return true; - } - else if(tileEntity != null) - { - if(drain) setEnergy(stack, getEnergy(stack)-ENERGY_PER_USE); - - Set iteratedNetworks = new HashSet<>(); - - for(ForgeDirection iterSide : ForgeDirection.VALID_DIRECTIONS) - { - Coord4D coord = Coord4D.get(tileEntity).getFromSide(iterSide); - - if(coord.getTileEntity(world) instanceof ITransmitterTile) - { - IGridTransmitter transmitter = ((ITransmitterTile)coord.getTileEntity(world)).getTransmitter(); - - if(transmitter.getTransmitterNetwork().possibleAcceptors.containsKey(coord.getFromSide(iterSide.getOpposite())) && !iteratedNetworks.contains(transmitter.getTransmitterNetwork())) - { - player.addChatMessage(new ChatComponentText(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[" + transmitter.getTransmissionType().getName() + "]" + EnumColor.GREY + " -------------")); - player.addChatMessage(new ChatComponentText(EnumColor.GREY + " *Connected sides: " + EnumColor.DARK_GREY + transmitter.getTransmitterNetwork().acceptorDirections.get(coord.getFromSide(iterSide.getOpposite())))); - player.addChatMessage(new ChatComponentText(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------")); - - iteratedNetworks.add(transmitter.getTransmitterNetwork()); - } - } - } - - return true; - } - } + player.addChatMessage(new ChatComponentText( + EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + + "[Mekanism]" + EnumColor.GREY + " -------------" + )); + player.addChatMessage(new ChatComponentText( + EnumColor.GREY + " *Transmitters: " + EnumColor.DARK_GREY + + transmitter.getTransmitterNetworkSize() + )); + player.addChatMessage(new ChatComponentText( + EnumColor.GREY + " *Acceptors: " + EnumColor.DARK_GREY + + transmitter.getTransmitterNetworkAcceptorSize() + )); + player.addChatMessage(new ChatComponentText( + EnumColor.GREY + " *Needed: " + EnumColor.DARK_GREY + + transmitter.getTransmitterNetworkNeeded() + )); + player.addChatMessage(new ChatComponentText( + EnumColor.GREY + " *Buffer: " + EnumColor.DARK_GREY + + transmitter.getTransmitterNetworkBuffer() + )); + player.addChatMessage(new ChatComponentText( + EnumColor.GREY + " *Throughput: " + EnumColor.DARK_GREY + + transmitter.getTransmitterNetworkFlow() + )); + player.addChatMessage(new ChatComponentText( + EnumColor.GREY + " *Capacity: " + EnumColor.DARK_GREY + + transmitter.getTransmitterNetworkCapacity() + )); + if (transmitter instanceof IHeatTransfer) + player.addChatMessage(new ChatComponentText( + EnumColor.GREY + " *Temperature: " + EnumColor.DARK_GREY + + ((IHeatTransfer) transmitter).getTemp() + "K above ambient" + )); + player.addChatMessage(new ChatComponentText( + EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + + "[=======]" + EnumColor.GREY + " -------------" + )); - if(player.isSneaking() && MekanismAPI.debug) - { - String[] strings = TransmitterNetworkRegistry.getInstance().toStrings(); - player.addChatMessage(new ChatComponentText(EnumColor.GREY + "---------- " + EnumColor.DARK_BLUE + "[Mekanism Debug]" + EnumColor.GREY + " ----------")); + return true; + } else if (tileEntity instanceof IHeatTransfer) { + if (drain) + setEnergy(stack, getEnergy(stack) - ENERGY_PER_USE); - for(String s : strings) - { - player.addChatMessage(new ChatComponentText(EnumColor.DARK_GREY + s)); - } + player.addChatMessage(new ChatComponentText( + EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + + "[Mekanism]" + EnumColor.GREY + " -------------" + )); + player.addChatMessage(new ChatComponentText( + EnumColor.GREY + " *Temperature: " + EnumColor.DARK_GREY + + ((IHeatTransfer) tileEntity).getTemp() + "K above ambient" + )); + player.addChatMessage(new ChatComponentText( + EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + + "[=======]" + EnumColor.GREY + " -------------" + )); - player.addChatMessage(new ChatComponentText(EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + " -------------")); - } - } + return true; + } else if (tileEntity != null) { + if (drain) + setEnergy(stack, getEnergy(stack) - ENERGY_PER_USE); - return false; - } + Set iteratedNetworks = new HashSet<>(); - @Override - public boolean canSend(ItemStack itemstack) - { - return false; - } + for (ForgeDirection iterSide : ForgeDirection.VALID_DIRECTIONS) { + Coord4D coord = Coord4D.get(tileEntity).getFromSide(iterSide); + + if (coord.getTileEntity(world) instanceof ITransmitterTile) { + IGridTransmitter transmitter + = ((ITransmitterTile) coord.getTileEntity(world)) + .getTransmitter(); + + if (transmitter.getTransmitterNetwork() + .possibleAcceptors.containsKey( + coord.getFromSide(iterSide.getOpposite()) + ) + && !iteratedNetworks.contains( + transmitter.getTransmitterNetwork() + )) { + player.addChatMessage(new ChatComponentText( + EnumColor.GREY + "------------- " + + EnumColor.DARK_BLUE + "[" + + transmitter.getTransmissionType().getName() + "]" + + EnumColor.GREY + " -------------" + )); + player.addChatMessage(new ChatComponentText( + EnumColor.GREY + + " *Connected sides: " + EnumColor.DARK_GREY + + transmitter.getTransmitterNetwork() + .acceptorDirections.get( + coord.getFromSide(iterSide.getOpposite()) + ) + )); + player.addChatMessage(new ChatComponentText( + EnumColor.GREY + "------------- " + + EnumColor.DARK_BLUE + "[=======]" + EnumColor.GREY + + " -------------" + )); + + iteratedNetworks.add(transmitter.getTransmitterNetwork()); + } + } + } + + return true; + } + } + + if (player.isSneaking() && MekanismAPI.debug) { + String[] strings = TransmitterNetworkRegistry.getInstance().toStrings(); + player.addChatMessage(new ChatComponentText( + EnumColor.GREY + "---------- " + EnumColor.DARK_BLUE + + "[Mekanism Debug]" + EnumColor.GREY + " ----------" + )); + + for (String s : strings) { + player.addChatMessage(new ChatComponentText(EnumColor.DARK_GREY + s)); + } + + player.addChatMessage(new ChatComponentText( + EnumColor.GREY + "------------- " + EnumColor.DARK_BLUE + "[=======]" + + EnumColor.GREY + " -------------" + )); + } + } + + return false; + } + + @Override + public boolean canSend(ItemStack itemstack) { + return false; + } } diff --git a/src/main/java/mekanism/common/item/ItemOtherDust.java b/src/main/java/mekanism/common/item/ItemOtherDust.java index cdb4aba21..ce283b663 100644 --- a/src/main/java/mekanism/common/item/ItemOtherDust.java +++ b/src/main/java/mekanism/common/item/ItemOtherDust.java @@ -8,57 +8,46 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -public class ItemOtherDust extends ItemMekanism -{ - public IIcon[] icons = new IIcon[256]; - - public static String[] subtypes = {"Diamond", "Steel", "null", - "Sulfur", "Lithium", "RefinedObsidian", - "Obsidian"}; - - public ItemOtherDust() - { - super(); - setHasSubtypes(true); - } - - @Override - public void registerIcons(IIconRegister register) - { - for(int i = 0; i < subtypes.length; i++) - { - if(i == 2) - { - continue; - } - - icons[i] = register.registerIcon("mekanism:" + subtypes[i] + "Dust"); - } - } +public class ItemOtherDust extends ItemMekanism { + public IIcon[] icons = new IIcon[256]; - @Override - public IIcon getIconFromDamage(int meta) - { - return icons[meta]; - } + public static String[] subtypes = { "Diamond", "Steel", "null", "Sulfur", + "Lithium", "RefinedObsidian", "Obsidian" }; - @Override - public void getSubItems(Item item, CreativeTabs tabs, List itemList) - { - for(int counter = 0; counter < subtypes.length; counter++) - { - if(counter == 2) - { - continue; - } - - itemList.add(new ItemStack(this, 1, counter)); - } - } + public ItemOtherDust() { + super(); + setHasSubtypes(true); + } - @Override - public String getUnlocalizedName(ItemStack item) - { - return "item." + subtypes[item.getItemDamage()].toLowerCase() + "Dust"; - } + @Override + public void registerIcons(IIconRegister register) { + for (int i = 0; i < subtypes.length; i++) { + if (i == 2) { + continue; + } + + icons[i] = register.registerIcon("mekanism:" + subtypes[i] + "Dust"); + } + } + + @Override + public IIcon getIconFromDamage(int meta) { + return icons[meta]; + } + + @Override + public void getSubItems(Item item, CreativeTabs tabs, List itemList) { + for (int counter = 0; counter < subtypes.length; counter++) { + if (counter == 2) { + continue; + } + + itemList.add(new ItemStack(this, 1, counter)); + } + } + + @Override + public String getUnlocalizedName(ItemStack item) { + return "item." + subtypes[item.getItemDamage()].toLowerCase() + "Dust"; + } } diff --git a/src/main/java/mekanism/common/item/ItemPortableTeleporter.java b/src/main/java/mekanism/common/item/ItemPortableTeleporter.java index 52b932cf2..8bc65e8a8 100644 --- a/src/main/java/mekanism/common/item/ItemPortableTeleporter.java +++ b/src/main/java/mekanism/common/item/ItemPortableTeleporter.java @@ -16,170 +16,159 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ChatComponentText; import net.minecraft.world.World; -public class ItemPortableTeleporter extends ItemEnergized implements IOwnerItem -{ - public ItemPortableTeleporter() - { - super(1000000); - } - - @Override - public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) - { - list.add(SecurityUtils.getOwnerDisplay(entityplayer.getCommandSenderName(), getOwner(itemstack))); - - if(getFrequency(itemstack) != null) - { - list.add(EnumColor.INDIGO + LangUtils.localize("gui.frequency") + ": " + EnumColor.GREY + getFrequency(itemstack)); +public class ItemPortableTeleporter extends ItemEnergized implements IOwnerItem { + public ItemPortableTeleporter() { + super(1000000); + } - String name = "trusted"; + @Override + public void addInformation( + ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag + ) { + list.add(SecurityUtils.getOwnerDisplay( + entityplayer.getCommandSenderName(), getOwner(itemstack) + )); - ISecurityTile.SecurityMode access= getAccess(itemstack); - if(access == ISecurityTile.SecurityMode.PUBLIC) { - name = "public"; - } else if(access == ISecurityTile.SecurityMode.PRIVATE) { - name = "private"; - } + if (getFrequency(itemstack) != null) { + list.add( + EnumColor.INDIGO + LangUtils.localize("gui.frequency") + ": " + + EnumColor.GREY + getFrequency(itemstack) + ); - list.add(EnumColor.INDIGO + LangUtils.localize("gui.mode") + ": " + EnumColor.GREY + LangUtils.localize("gui." + name)); - } - - super.addInformation(itemstack, entityplayer, list, flag); - } + String name = "trusted"; - @Override - public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) - { - if(!world.isRemote) - { - if(getOwner(itemstack) == null) - { - setOwner(itemstack, entityplayer.getCommandSenderName()); - entityplayer.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + LangUtils.localize("gui.nowOwn"))); - } - else { - if(SecurityUtils.canAccess(entityplayer, itemstack)) - { - entityplayer.openGui(Mekanism.instance, 14, world, 0, 0, 0); - } - else { - SecurityUtils.displayNoAccess(entityplayer); - } - } - } - - return itemstack; - } + ISecurityTile.SecurityMode access = getAccess(itemstack); + if (access == ISecurityTile.SecurityMode.PUBLIC) { + name = "public"; + } else if (access == ISecurityTile.SecurityMode.PRIVATE) { + name = "private"; + } - public static double calculateEnergyCost(Entity entity, Coord4D coords) - { - if(coords == null) - { - return 0; - } + list.add( + EnumColor.INDIGO + LangUtils.localize("gui.mode") + ": " + EnumColor.GREY + + LangUtils.localize("gui." + name) + ); + } - int neededEnergy = 1000; + super.addInformation(itemstack, entityplayer, list, flag); + } - if(entity.worldObj.provider.dimensionId != coords.dimensionId) - { - neededEnergy+=10000; - } + @Override + public ItemStack + onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { + if (!world.isRemote) { + if (getOwner(itemstack) == null) { + setOwner(itemstack, entityplayer.getCommandSenderName()); + entityplayer.addChatMessage(new ChatComponentText( + EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + + LangUtils.localize("gui.nowOwn") + )); + } else { + if (SecurityUtils.canAccess(entityplayer, itemstack)) { + entityplayer.openGui(Mekanism.instance, 14, world, 0, 0, 0); + } else { + SecurityUtils.displayNoAccess(entityplayer); + } + } + } - int distance = (int)entity.getDistance(coords.xCoord, coords.yCoord, coords.zCoord); + return itemstack; + } - neededEnergy+=(distance*10); + public static double calculateEnergyCost(Entity entity, Coord4D coords) { + if (coords == null) { + return 0; + } - return neededEnergy; - } + int neededEnergy = 1000; - @Override - public boolean canSend(ItemStack itemStack) - { - return false; - } - - @Override - public String getOwner(ItemStack stack) - { - if(stack.stackTagCompound != null && stack.stackTagCompound.hasKey("owner")) - { - return stack.stackTagCompound.getString("owner"); - } - - return null; - } + if (entity.worldObj.provider.dimensionId != coords.dimensionId) { + neededEnergy += 10000; + } - @Override - public void setOwner(ItemStack stack, String owner) - { - setFrequency(stack, null); - setAccess(stack, ISecurityTile.SecurityMode.PUBLIC); - - if(owner == null || owner.isEmpty()) - { - stack.stackTagCompound.removeTag("owner"); - return; - } - - stack.stackTagCompound.setString("owner", owner); - } - - @Override - public boolean hasOwner(ItemStack stack) - { - return true; - } - - public ISecurityTile.SecurityMode getAccess(ItemStack stack) - { - if(stack.stackTagCompound != null) - { - if(stack.stackTagCompound.hasKey("access")) { - return ISecurityTile.SecurityMode.values()[stack.stackTagCompound.getInteger("access")]; - } else { - boolean priv = stack.stackTagCompound.getBoolean("private"); + int distance + = (int) entity.getDistance(coords.xCoord, coords.yCoord, coords.zCoord); - if(priv) - return ISecurityTile.SecurityMode.PRIVATE; - } - } - - return ISecurityTile.SecurityMode.PUBLIC; - } + neededEnergy += (distance * 10); - public void setAccess(ItemStack stack, ISecurityTile.SecurityMode access) - { - if(stack.stackTagCompound == null) - { - stack.setTagCompound(new NBTTagCompound()); - } - - stack.stackTagCompound.setInteger("access", access.ordinal()); - } - - public String getFrequency(ItemStack stack) - { - if(stack.stackTagCompound != null && stack.stackTagCompound.hasKey("frequency")) - { - return stack.stackTagCompound.getString("frequency"); - } - - return null; - } + return neededEnergy; + } - public void setFrequency(ItemStack stack, String frequency) - { - if(stack.stackTagCompound == null) - { - stack.setTagCompound(new NBTTagCompound()); - } - - if(frequency == null || frequency.isEmpty()) - { - stack.stackTagCompound.removeTag("frequency"); - return; - } - - stack.stackTagCompound.setString("frequency", frequency); - } + @Override + public boolean canSend(ItemStack itemStack) { + return false; + } + + @Override + public String getOwner(ItemStack stack) { + if (stack.stackTagCompound != null && stack.stackTagCompound.hasKey("owner")) { + return stack.stackTagCompound.getString("owner"); + } + + return null; + } + + @Override + public void setOwner(ItemStack stack, String owner) { + setFrequency(stack, null); + setAccess(stack, ISecurityTile.SecurityMode.PUBLIC); + + if (owner == null || owner.isEmpty()) { + stack.stackTagCompound.removeTag("owner"); + return; + } + + stack.stackTagCompound.setString("owner", owner); + } + + @Override + public boolean hasOwner(ItemStack stack) { + return true; + } + + public ISecurityTile.SecurityMode getAccess(ItemStack stack) { + if (stack.stackTagCompound != null) { + if (stack.stackTagCompound.hasKey("access")) { + return ISecurityTile.SecurityMode.values( + )[stack.stackTagCompound.getInteger("access")]; + } else { + boolean priv = stack.stackTagCompound.getBoolean("private"); + + if (priv) + return ISecurityTile.SecurityMode.PRIVATE; + } + } + + return ISecurityTile.SecurityMode.PUBLIC; + } + + public void setAccess(ItemStack stack, ISecurityTile.SecurityMode access) { + if (stack.stackTagCompound == null) { + stack.setTagCompound(new NBTTagCompound()); + } + + stack.stackTagCompound.setInteger("access", access.ordinal()); + } + + public String getFrequency(ItemStack stack) { + if (stack.stackTagCompound != null + && stack.stackTagCompound.hasKey("frequency")) { + return stack.stackTagCompound.getString("frequency"); + } + + return null; + } + + public void setFrequency(ItemStack stack, String frequency) { + if (stack.stackTagCompound == null) { + stack.setTagCompound(new NBTTagCompound()); + } + + if (frequency == null || frequency.isEmpty()) { + stack.stackTagCompound.removeTag("frequency"); + return; + } + + stack.stackTagCompound.setString("frequency", frequency); + } } diff --git a/src/main/java/mekanism/common/item/ItemProxy.java b/src/main/java/mekanism/common/item/ItemProxy.java index 92eaf210d..4a7d373bf 100644 --- a/src/main/java/mekanism/common/item/ItemProxy.java +++ b/src/main/java/mekanism/common/item/ItemProxy.java @@ -8,82 +8,73 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.world.World; -public class ItemProxy extends Item -{ - public ItemProxy() - { - super(); - setMaxDamage(1); - } +public class ItemProxy extends Item { + public ItemProxy() { + super(); + setMaxDamage(1); + } - @Override - public ItemStack getContainerItem(ItemStack stack) - { - return getSavedItem(stack); - } + @Override + public ItemStack getContainerItem(ItemStack stack) { + return getSavedItem(stack); + } - @Override - public boolean doesContainerItemLeaveCraftingGrid(ItemStack stack) - { - return stack.stackTagCompound == null || !stack.stackTagCompound.getBoolean("hasStack"); - } + @Override + public boolean doesContainerItemLeaveCraftingGrid(ItemStack stack) { + return stack.stackTagCompound == null + || !stack.stackTagCompound.getBoolean("hasStack"); + } - @Override - public boolean hasContainerItem(ItemStack itemStack) - { - return getSavedItem(itemStack) != null; - } + @Override + public boolean hasContainerItem(ItemStack itemStack) { + return getSavedItem(itemStack) != null; + } - public void setSavedItem(ItemStack stack, ItemStack save) - { - if(stack.stackTagCompound == null) - { - stack.setTagCompound(new NBTTagCompound()); - } + public void setSavedItem(ItemStack stack, ItemStack save) { + if (stack.stackTagCompound == null) { + stack.setTagCompound(new NBTTagCompound()); + } - if(save == null) - { - stack.stackTagCompound.setBoolean("hasStack", false); - stack.stackTagCompound.removeTag("savedItem"); - } - else { - stack.stackTagCompound.setBoolean("hasStack", true); - stack.stackTagCompound.setTag("savedItem", save.writeToNBT(new NBTTagCompound())); - } - } + if (save == null) { + stack.stackTagCompound.setBoolean("hasStack", false); + stack.stackTagCompound.removeTag("savedItem"); + } else { + stack.stackTagCompound.setBoolean("hasStack", true); + stack.stackTagCompound.setTag( + "savedItem", save.writeToNBT(new NBTTagCompound()) + ); + } + } - public ItemStack getSavedItem(ItemStack stack) - { - if(stack.stackTagCompound == null) - { - return null; - } + public ItemStack getSavedItem(ItemStack stack) { + if (stack.stackTagCompound == null) { + return null; + } - if(stack.stackTagCompound.getBoolean("hasStack")) - { - return ItemStack.loadItemStackFromNBT(stack.stackTagCompound.getCompoundTag("savedItem")); - } + if (stack.stackTagCompound.getBoolean("hasStack")) { + return ItemStack.loadItemStackFromNBT( + stack.stackTagCompound.getCompoundTag("savedItem") + ); + } - return null; - } + return null; + } - @Override - public void registerIcons(IIconRegister register) {} + @Override + public void registerIcons(IIconRegister register) {} - @Override - public void onUpdate(ItemStack stacks, World world, Entity entity, int j, boolean flag) - { - if(entity instanceof EntityPlayer) - { - EntityPlayer player = (EntityPlayer)entity; - - for(int i = 0; i < player.inventory.mainInventory.length; i++) - { - if(player.inventory.mainInventory[i] != null && player.inventory.mainInventory[i].getItem() == this) - { - player.inventory.mainInventory[i] = null; - } - } - } - } + @Override + public void + onUpdate(ItemStack stacks, World world, Entity entity, int j, boolean flag) { + if (entity instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) entity; + + for (int i = 0; i < player.inventory.mainInventory.length; i++) { + if (player.inventory.mainInventory[i] != null + && player.inventory.mainInventory[i].getItem() == this) { + player.inventory.mainInventory[i] = null; + } + } + } + } } diff --git a/src/main/java/mekanism/common/item/ItemRobit.java b/src/main/java/mekanism/common/item/ItemRobit.java index 84bdbe9ec..caa2811d9 100644 --- a/src/main/java/mekanism/common/item/ItemRobit.java +++ b/src/main/java/mekanism/common/item/ItemRobit.java @@ -2,6 +2,8 @@ package mekanism.common.item; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.common.base.ISustainedInventory; @@ -15,121 +17,121 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class ItemRobit extends ItemEnergized implements ISustainedInventory -{ - public ItemRobit() - { - super(100000); - } +public class ItemRobit extends ItemEnergized implements ISustainedInventory { + public ItemRobit() { + super(100000); + } - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister register) {} + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister register) {} - @Override - @SideOnly(Side.CLIENT) - public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) - { - super.addInformation(itemstack, entityplayer, list, flag); + @Override + @SideOnly(Side.CLIENT) + public void addInformation( + ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag + ) { + super.addInformation(itemstack, entityplayer, list, flag); - list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.name") + ": " + EnumColor.GREY + getName(itemstack)); - list.add(EnumColor.AQUA + LangUtils.localize("tooltip.inventory") + ": " + EnumColor.GREY + (getInventory(itemstack) != null && getInventory(itemstack).tagCount() != 0)); - } + list.add( + EnumColor.INDIGO + LangUtils.localize("tooltip.name") + ": " + EnumColor.GREY + + getName(itemstack) + ); + list.add( + EnumColor.AQUA + LangUtils.localize("tooltip.inventory") + ": " + + EnumColor.GREY + + (getInventory(itemstack) != null && getInventory(itemstack).tagCount() != 0) + ); + } - @Override - public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int x, int y, int z, int side, float posX, float posY, float posZ) - { - TileEntity tileEntity = world.getTileEntity(x, y, z); + @Override + public boolean onItemUse( + ItemStack itemstack, + EntityPlayer entityplayer, + World world, + int x, + int y, + int z, + int side, + float posX, + float posY, + float posZ + ) { + TileEntity tileEntity = world.getTileEntity(x, y, z); - if(tileEntity instanceof TileEntityChargepad) - { - TileEntityChargepad chargepad = (TileEntityChargepad)tileEntity; - if(!chargepad.isActive) - { - if(!world.isRemote) - { - EntityRobit robit = new EntityRobit(world, x+0.5, y+0.1, z+0.5); + if (tileEntity instanceof TileEntityChargepad) { + TileEntityChargepad chargepad = (TileEntityChargepad) tileEntity; + if (!chargepad.isActive) { + if (!world.isRemote) { + EntityRobit robit = new EntityRobit(world, x + 0.5, y + 0.1, z + 0.5); - robit.setHome(Coord4D.get(chargepad)); - robit.setEnergy(getEnergy(itemstack)); - robit.setOwner(entityplayer.getCommandSenderName()); - robit.setInventory(getInventory(itemstack)); - robit.setName(getName(itemstack)); + robit.setHome(Coord4D.get(chargepad)); + robit.setEnergy(getEnergy(itemstack)); + robit.setOwner(entityplayer.getCommandSenderName()); + robit.setInventory(getInventory(itemstack)); + robit.setName(getName(itemstack)); - world.spawnEntityInWorld(robit); - } + world.spawnEntityInWorld(robit); + } - entityplayer.setCurrentItemOrArmor(0, null); + entityplayer.setCurrentItemOrArmor(0, null); - return true; - } - } + return true; + } + } - return false; - } + return false; + } - @Override - public boolean canSend(ItemStack itemStack) - { - return false; - } + @Override + public boolean canSend(ItemStack itemStack) { + return false; + } - public void setName(ItemStack itemstack, String name) - { - if(itemstack.stackTagCompound == null) - { - itemstack.setTagCompound(new NBTTagCompound()); - } + public void setName(ItemStack itemstack, String name) { + if (itemstack.stackTagCompound == null) { + itemstack.setTagCompound(new NBTTagCompound()); + } - itemstack.stackTagCompound.setString("name", name); - } + itemstack.stackTagCompound.setString("name", name); + } - public String getName(ItemStack itemstack) - { - if(itemstack.stackTagCompound == null) - { - return "Robit"; - } + public String getName(ItemStack itemstack) { + if (itemstack.stackTagCompound == null) { + return "Robit"; + } - String name = itemstack.stackTagCompound.getString("name"); + String name = itemstack.stackTagCompound.getString("name"); - return name.equals("") ? "Robit" : name; - } + return name.equals("") ? "Robit" : name; + } - @Override - public void setInventory(NBTTagList nbtTags, Object... data) - { - if(data[0] instanceof ItemStack) - { - ItemStack itemStack = (ItemStack)data[0]; + @Override + public void setInventory(NBTTagList nbtTags, Object... data) { + if (data[0] instanceof ItemStack) { + ItemStack itemStack = (ItemStack) data[0]; - if(itemStack.stackTagCompound == null) - { - itemStack.setTagCompound(new NBTTagCompound()); - } + if (itemStack.stackTagCompound == null) { + itemStack.setTagCompound(new NBTTagCompound()); + } - itemStack.stackTagCompound.setTag("Items", nbtTags); - } - } + itemStack.stackTagCompound.setTag("Items", nbtTags); + } + } - @Override - public NBTTagList getInventory(Object... data) - { - if(data[0] instanceof ItemStack) - { - ItemStack itemStack = (ItemStack)data[0]; + @Override + public NBTTagList getInventory(Object... data) { + if (data[0] instanceof ItemStack) { + ItemStack itemStack = (ItemStack) data[0]; - if(itemStack.stackTagCompound == null) - { - return null; - } + if (itemStack.stackTagCompound == null) { + return null; + } - return itemStack.stackTagCompound.getTagList("Items", 10); - } + return itemStack.stackTagCompound.getTagList("Items", 10); + } - return null; - } + return null; + } } diff --git a/src/main/java/mekanism/common/item/ItemScubaTank.java b/src/main/java/mekanism/common/item/ItemScubaTank.java index 7e8953fdd..ba55c575b 100644 --- a/src/main/java/mekanism/common/item/ItemScubaTank.java +++ b/src/main/java/mekanism/common/item/ItemScubaTank.java @@ -2,6 +2,8 @@ package mekanism.common.item; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.EnumColor; import mekanism.api.MekanismConfig.general; import mekanism.api.gas.Gas; @@ -23,226 +25,217 @@ import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.EnumHelper; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class ItemScubaTank extends ItemArmor implements IGasItem -{ - public int TRANSFER_RATE = 16; +public class ItemScubaTank extends ItemArmor implements IGasItem { + public int TRANSFER_RATE = 16; - public ItemScubaTank() - { - super(EnumHelper.addArmorMaterial("SCUBATANK", 0, new int[] {0, 0, 0, 0}, 0), 0, 1); - setCreativeTab(Mekanism.tabMekanism); - } + public ItemScubaTank() { + super( + EnumHelper.addArmorMaterial("SCUBATANK", 0, new int[] { 0, 0, 0, 0 }, 0), 0, 1 + ); + setCreativeTab(Mekanism.tabMekanism); + } - @Override - public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) - { - GasStack gasStack = getGas(itemstack); + @Override + public void addInformation( + ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag + ) { + GasStack gasStack = getGas(itemstack); - if(gasStack == null) - { - list.add(LangUtils.localize("tooltip.noGas") + "."); - } - else { - list.add(LangUtils.localize("tooltip.stored") + " " + gasStack.getGas().getLocalizedName() + ": " + gasStack.amount); - } + if (gasStack == null) { + list.add(LangUtils.localize("tooltip.noGas") + "."); + } else { + list.add( + LangUtils.localize("tooltip.stored") + " " + + gasStack.getGas().getLocalizedName() + ": " + gasStack.amount + ); + } - list.add(EnumColor.GREY + LangUtils.localize("tooltip.flowing") + ": " + (getFlowing(itemstack) ? EnumColor.DARK_GREEN : EnumColor.DARK_RED) + getFlowingStr(itemstack)); - } - - @Override - public boolean showDurabilityBar(ItemStack stack) - { - return true; - } - - @Override - public double getDurabilityForDisplay(ItemStack stack) - { - return 1D-((getGas(stack) != null ? (double)getGas(stack).amount : 0D)/(double)getMaxGas(stack)); - } + list.add( + EnumColor.GREY + LangUtils.localize("tooltip.flowing") + ": " + + (getFlowing(itemstack) ? EnumColor.DARK_GREEN : EnumColor.DARK_RED) + + getFlowingStr(itemstack) + ); + } - @Override - public boolean isValidArmor(ItemStack stack, int armorType, Entity entity) - { - return armorType == 1; - } + @Override + public boolean showDurabilityBar(ItemStack stack) { + return true; + } - @Override - public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) - { - return "mekanism:render/NullArmor.png"; - } + @Override + public double getDurabilityForDisplay(ItemStack stack) { + return 1D + - ((getGas(stack) != null ? (double) getGas(stack).amount : 0D) + / (double) getMaxGas(stack)); + } - @Override - @SideOnly(Side.CLIENT) - public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) - { - ModelCustomArmor model = ModelCustomArmor.INSTANCE; - model.modelType = ArmorModel.SCUBATANK; - return model; - } + @Override + public boolean isValidArmor(ItemStack stack, int armorType, Entity entity) { + return armorType == 1; + } - public void useGas(ItemStack itemstack) - { - setGas(itemstack, new GasStack(getGas(itemstack).getGas(), getGas(itemstack).amount-1)); - } - - public GasStack useGas(ItemStack itemstack, int amount) - { - if(getGas(itemstack) == null) - { - return null; - } + @Override + public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { + return "mekanism:render/NullArmor.png"; + } - Gas type = getGas(itemstack).getGas(); + @Override + @SideOnly(Side.CLIENT) + public ModelBiped + getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) { + ModelCustomArmor model = ModelCustomArmor.INSTANCE; + model.modelType = ArmorModel.SCUBATANK; + return model; + } - int gasToUse = Math.min(getStored(itemstack), Math.min(getRate(itemstack), amount)); - setGas(itemstack, new GasStack(type, getStored(itemstack)-gasToUse)); + public void useGas(ItemStack itemstack) { + setGas( + itemstack, + new GasStack(getGas(itemstack).getGas(), getGas(itemstack).amount - 1) + ); + } - return new GasStack(type, gasToUse); - } + public GasStack useGas(ItemStack itemstack, int amount) { + if (getGas(itemstack) == null) { + return null; + } - @Override - public int getMaxGas(ItemStack itemstack) - { - return general.maxScubaGas; - } + Gas type = getGas(itemstack).getGas(); - @Override - public int getRate(ItemStack itemstack) - { - return TRANSFER_RATE; - } + int gasToUse + = Math.min(getStored(itemstack), Math.min(getRate(itemstack), amount)); + setGas(itemstack, new GasStack(type, getStored(itemstack) - gasToUse)); - @Override - public int addGas(ItemStack itemstack, GasStack stack) - { - if(getGas(itemstack) != null && getGas(itemstack).getGas() != stack.getGas()) - { - return 0; - } + return new GasStack(type, gasToUse); + } - if(stack.getGas() != GasRegistry.getGas("oxygen")) - { - return 0; - } + @Override + public int getMaxGas(ItemStack itemstack) { + return general.maxScubaGas; + } - int toUse = Math.min(getMaxGas(itemstack)-getStored(itemstack), Math.min(getRate(itemstack), stack.amount)); - setGas(itemstack, new GasStack(stack.getGas(), getStored(itemstack)+toUse)); + @Override + public int getRate(ItemStack itemstack) { + return TRANSFER_RATE; + } - return toUse; - } + @Override + public int addGas(ItemStack itemstack, GasStack stack) { + if (getGas(itemstack) != null && getGas(itemstack).getGas() != stack.getGas()) { + return 0; + } - @Override - public GasStack removeGas(ItemStack itemstack, int amount) - { - return null; - } + if (stack.getGas() != GasRegistry.getGas("oxygen")) { + return 0; + } - public int getStored(ItemStack itemstack) - { - return getGas(itemstack) != null ? getGas(itemstack).amount : 0; - } + int toUse = Math.min( + getMaxGas(itemstack) - getStored(itemstack), + Math.min(getRate(itemstack), stack.amount) + ); + setGas(itemstack, new GasStack(stack.getGas(), getStored(itemstack) + toUse)); - public void toggleFlowing(ItemStack stack) - { - setFlowing(stack, !getFlowing(stack)); - } + return toUse; + } - public boolean getFlowing(ItemStack stack) - { - if(stack.stackTagCompound == null) - { - return false; - } + @Override + public GasStack removeGas(ItemStack itemstack, int amount) { + return null; + } - return stack.stackTagCompound.getBoolean("flowing"); - } - - public String getFlowingStr(ItemStack stack) - { - boolean flowing = getFlowing(stack); - - return LangUtils.localize("tooltip." + (flowing ? "yes" : "no")); - } + public int getStored(ItemStack itemstack) { + return getGas(itemstack) != null ? getGas(itemstack).amount : 0; + } - public void setFlowing(ItemStack stack, boolean flowing) - { - if(stack.stackTagCompound == null) - { - stack.setTagCompound(new NBTTagCompound()); - } + public void toggleFlowing(ItemStack stack) { + setFlowing(stack, !getFlowing(stack)); + } - stack.stackTagCompound.setBoolean("flowing", flowing); - } + public boolean getFlowing(ItemStack stack) { + if (stack.stackTagCompound == null) { + return false; + } - @Override - public boolean canReceiveGas(ItemStack itemstack, Gas type) - { - return type == GasRegistry.getGas("oxygen"); - } + return stack.stackTagCompound.getBoolean("flowing"); + } - @Override - public boolean canProvideGas(ItemStack itemstack, Gas type) - { - return false; - } + public String getFlowingStr(ItemStack stack) { + boolean flowing = getFlowing(stack); - @Override - public GasStack getGas(ItemStack itemstack) - { - if(itemstack.stackTagCompound == null) - { - return null; - } + return LangUtils.localize("tooltip." + (flowing ? "yes" : "no")); + } - return GasStack.readFromNBT(itemstack.stackTagCompound.getCompoundTag("stored")); - } + public void setFlowing(ItemStack stack, boolean flowing) { + if (stack.stackTagCompound == null) { + stack.setTagCompound(new NBTTagCompound()); + } - @Override - public void setGas(ItemStack itemstack, GasStack stack) - { - if(itemstack.stackTagCompound == null) - { - itemstack.setTagCompound(new NBTTagCompound()); - } + stack.stackTagCompound.setBoolean("flowing", flowing); + } - if(stack == null || stack.amount == 0) - { - itemstack.stackTagCompound.removeTag("stored"); - } - else { - int amount = Math.max(0, Math.min(stack.amount, getMaxGas(itemstack))); - GasStack gasStack = new GasStack(stack.getGas(), amount); + @Override + public boolean canReceiveGas(ItemStack itemstack, Gas type) { + return type == GasRegistry.getGas("oxygen"); + } - itemstack.stackTagCompound.setTag("stored", gasStack.write(new NBTTagCompound())); - } - } + @Override + public boolean canProvideGas(ItemStack itemstack, Gas type) { + return false; + } - public ItemStack getEmptyItem() - { - ItemStack empty = new ItemStack(this); - setGas(empty, null); - - return empty; - } + @Override + public GasStack getGas(ItemStack itemstack) { + if (itemstack.stackTagCompound == null) { + return null; + } - @Override - public void getSubItems(Item item, CreativeTabs tabs, List list) - { - ItemStack empty = new ItemStack(this); - setGas(empty, null); - list.add(empty); + return GasStack.readFromNBT(itemstack.stackTagCompound.getCompoundTag("stored")); + } - ItemStack filled = new ItemStack(this); - setGas(filled, new GasStack(GasRegistry.getGas("oxygen"), ((IGasItem)filled.getItem()).getMaxGas(filled))); - list.add(filled); - } + @Override + public void setGas(ItemStack itemstack, GasStack stack) { + if (itemstack.stackTagCompound == null) { + itemstack.setTagCompound(new NBTTagCompound()); + } - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister register) {} + if (stack == null || stack.amount == 0) { + itemstack.stackTagCompound.removeTag("stored"); + } else { + int amount = Math.max(0, Math.min(stack.amount, getMaxGas(itemstack))); + GasStack gasStack = new GasStack(stack.getGas(), amount); + + itemstack.stackTagCompound.setTag( + "stored", gasStack.write(new NBTTagCompound()) + ); + } + } + + public ItemStack getEmptyItem() { + ItemStack empty = new ItemStack(this); + setGas(empty, null); + + return empty; + } + + @Override + public void getSubItems(Item item, CreativeTabs tabs, List list) { + ItemStack empty = new ItemStack(this); + setGas(empty, null); + list.add(empty); + + ItemStack filled = new ItemStack(this); + setGas( + filled, + new GasStack( + GasRegistry.getGas("oxygen"), + ((IGasItem) filled.getItem()).getMaxGas(filled) + ) + ); + list.add(filled); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister register) {} } diff --git a/src/main/java/mekanism/common/item/ItemSeismicReader.java b/src/main/java/mekanism/common/item/ItemSeismicReader.java index 1292d7b4c..7fc531f6b 100644 --- a/src/main/java/mekanism/common/item/ItemSeismicReader.java +++ b/src/main/java/mekanism/common/item/ItemSeismicReader.java @@ -10,52 +10,57 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.ChatComponentText; import net.minecraft.world.World; -public class ItemSeismicReader extends ItemEnergized -{ - public static final double ENERGY_USAGE = 250; - - public ItemSeismicReader() - { - super(12000); - } - - @Override - public boolean canSend(ItemStack itemStack) - { - return false; - } - - @Override - public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) - { - Chunk3D chunk = new Chunk3D(entityplayer); - - if(getEnergy(itemstack) < ENERGY_USAGE && !entityplayer.capabilities.isCreativeMode) - { - if(!world.isRemote) - { - entityplayer.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.RED + LangUtils.localize("tooltip.seismicReader.needsEnergy"))); - } - - return itemstack; - } - else if(!MekanismUtils.isChunkVibrated(chunk)) - { - if(!world.isRemote) - { - entityplayer.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.RED + LangUtils.localize("tooltip.seismicReader.noVibrations"))); - } - - return itemstack; - } - - if(!entityplayer.capabilities.isCreativeMode) - { - setEnergy(itemstack, getEnergy(itemstack)-ENERGY_USAGE); - } - - entityplayer.openGui(Mekanism.instance, 38, world, (int)entityplayer.posX, (int)entityplayer.posY, (int)entityplayer.posZ); +public class ItemSeismicReader extends ItemEnergized { + public static final double ENERGY_USAGE = 250; - return itemstack; - } + public ItemSeismicReader() { + super(12000); + } + + @Override + public boolean canSend(ItemStack itemStack) { + return false; + } + + @Override + public ItemStack + onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) { + Chunk3D chunk = new Chunk3D(entityplayer); + + if (getEnergy(itemstack) < ENERGY_USAGE + && !entityplayer.capabilities.isCreativeMode) { + if (!world.isRemote) { + entityplayer.addChatMessage(new ChatComponentText( + EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.RED + + LangUtils.localize("tooltip.seismicReader.needsEnergy") + )); + } + + return itemstack; + } else if (!MekanismUtils.isChunkVibrated(chunk)) { + if (!world.isRemote) { + entityplayer.addChatMessage(new ChatComponentText( + EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.RED + + LangUtils.localize("tooltip.seismicReader.noVibrations") + )); + } + + return itemstack; + } + + if (!entityplayer.capabilities.isCreativeMode) { + setEnergy(itemstack, getEnergy(itemstack) - ENERGY_USAGE); + } + + entityplayer.openGui( + Mekanism.instance, + 38, + world, + (int) entityplayer.posX, + (int) entityplayer.posY, + (int) entityplayer.posZ + ); + + return itemstack; + } } diff --git a/src/main/java/mekanism/common/item/ItemShard.java b/src/main/java/mekanism/common/item/ItemShard.java index 71d379c33..745eecf3e 100644 --- a/src/main/java/mekanism/common/item/ItemShard.java +++ b/src/main/java/mekanism/common/item/ItemShard.java @@ -9,48 +9,43 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; -public class ItemShard extends ItemMekanism -{ - public IIcon[] icons = new IIcon[256]; +public class ItemShard extends ItemMekanism { + public IIcon[] icons = new IIcon[256]; - public ItemShard() - { - super(); - setHasSubtypes(true); - } + public ItemShard() { + super(); + setHasSubtypes(true); + } - @Override - public void registerIcons(IIconRegister register) - { - for(int i = 0; i < Resource.values().length; i++) - { - icons[i] = register.registerIcon("mekanism:" + Resource.values()[i].getName() + "Shard"); - } - } + @Override + public void registerIcons(IIconRegister register) { + for (int i = 0; i < Resource.values().length; i++) { + icons[i] = register.registerIcon( + "mekanism:" + Resource.values()[i].getName() + "Shard" + ); + } + } - @Override - public IIcon getIconFromDamage(int meta) - { - return icons[meta]; - } + @Override + public IIcon getIconFromDamage(int meta) { + return icons[meta]; + } - @Override - public void getSubItems(Item item, CreativeTabs tabs, List itemList) - { - for(int counter = 0; counter < Resource.values().length; counter++) - { - itemList.add(new ItemStack(item, 1, counter)); - } - } + @Override + public void getSubItems(Item item, CreativeTabs tabs, List itemList) { + for (int counter = 0; counter < Resource.values().length; counter++) { + itemList.add(new ItemStack(item, 1, counter)); + } + } - @Override - public String getUnlocalizedName(ItemStack item) - { - if(item.getItemDamage() <= Resource.values().length-1) - { - return "item." + Resource.values()[item.getItemDamage()].getName().toLowerCase() + "Shard"; - } - - return "Invalid"; - } + @Override + public String getUnlocalizedName(ItemStack item) { + if (item.getItemDamage() <= Resource.values().length - 1) { + return "item." + + Resource.values()[item.getItemDamage()].getName().toLowerCase() + + "Shard"; + } + + return "Invalid"; + } } diff --git a/src/main/java/mekanism/common/item/ItemStopwatch.java b/src/main/java/mekanism/common/item/ItemStopwatch.java index 5743ad4b0..d9e496fca 100644 --- a/src/main/java/mekanism/common/item/ItemStopwatch.java +++ b/src/main/java/mekanism/common/item/ItemStopwatch.java @@ -1,6 +1,5 @@ package mekanism.common.item; - import mekanism.common.Mekanism; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; @@ -9,31 +8,37 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class ItemStopwatch extends ItemMekanism { - public ItemStopwatch() { super(); setMaxStackSize(1); setMaxDamage(5000); } - + @Override - public boolean hasEffect(final ItemStack itemstack) { - return true; + public boolean hasEffect(final ItemStack itemstack) { + return true; } @Override - public void onUpdate(final ItemStack itemstack, final World world, final Entity entity, final int i, final boolean flag) { - if (itemstack.getItemDamage() > 0 && entity instanceof EntityLivingBase) { - itemstack.damageItem(-1, (EntityLivingBase) entity); - } + public void onUpdate( + final ItemStack itemstack, + final World world, + final Entity entity, + final int i, + final boolean flag + ) { + if (itemstack.getItemDamage() > 0 && entity instanceof EntityLivingBase) { + itemstack.damageItem(-1, (EntityLivingBase) entity); + } } @Override - public ItemStack onItemRightClick(final ItemStack itemstack, final World world, final EntityPlayer entityplayer) { + public ItemStack onItemRightClick( + final ItemStack itemstack, final World world, final EntityPlayer entityplayer + ) { if (itemstack.getItemDamage() == 0) { entityplayer.openGui(Mekanism.instance, 61, world, 0, 0, 0); } return itemstack; } - } diff --git a/src/main/java/mekanism/common/item/ItemTierInstaller.java b/src/main/java/mekanism/common/item/ItemTierInstaller.java index 065ec62ad..55ce6a78e 100644 --- a/src/main/java/mekanism/common/item/ItemTierInstaller.java +++ b/src/main/java/mekanism/common/item/ItemTierInstaller.java @@ -14,83 +14,82 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; -public class ItemTierInstaller extends ItemMekanism -{ - public IIcon[] icons = new IIcon[256]; - - public ItemTierInstaller() - { - super(); - setHasSubtypes(true); - } - - @Override - public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) - { - if(world.isRemote) - { - return false; - } - - TileEntity tile = world.getTileEntity(x, y, z); - BaseTier tier = BaseTier.values()[stack.getItemDamage()]; - - if(tile instanceof ITierUpgradeable) - { - if(tile instanceof TileEntityBasicBlock && ((TileEntityBasicBlock)tile).playersUsing.size() > 0) - { - return true; - } - - if(((ITierUpgradeable)tile).upgrade(tier)) - { - if(!player.capabilities.isCreativeMode) - { - stack.stackSize--; - } - - return true; - } - - return false; - } - - return false; - } - - @Override - public void registerIcons(IIconRegister register) - { - for(BaseTier tier : BaseTier.values()) - { - if(tier.isObtainable()) - { - icons[tier.ordinal()] = register.registerIcon("mekanism:" + tier.getName() + "TierInstaller"); - } - } - } - - @Override - public IIcon getIconFromDamage(int meta) - { - return icons[meta]; - } +public class ItemTierInstaller extends ItemMekanism { + public IIcon[] icons = new IIcon[256]; - @Override - public void getSubItems(Item item, CreativeTabs tabs, List itemList) - { - for(BaseTier tier : BaseTier.values()) - { - if(tier.isObtainable()) - { - itemList.add(new ItemStack(item, 1, tier.ordinal())); - } - } - } + public ItemTierInstaller() { + super(); + setHasSubtypes(true); + } - @Override - public String getUnlocalizedName(ItemStack item) - { - return "item." + BaseTier.values()[item.getItemDamage()].getName().toLowerCase() + "TierInstaller"; - } + @Override + public boolean onItemUseFirst( + ItemStack stack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int side, + float hitX, + float hitY, + float hitZ + ) { + if (world.isRemote) { + return false; + } + + TileEntity tile = world.getTileEntity(x, y, z); + BaseTier tier = BaseTier.values()[stack.getItemDamage()]; + + if (tile instanceof ITierUpgradeable) { + if (tile instanceof TileEntityBasicBlock + && ((TileEntityBasicBlock) tile).playersUsing.size() > 0) { + return true; + } + + if (((ITierUpgradeable) tile).upgrade(tier)) { + if (!player.capabilities.isCreativeMode) { + stack.stackSize--; + } + + return true; + } + + return false; + } + + return false; + } + + @Override + public void registerIcons(IIconRegister register) { + for (BaseTier tier : BaseTier.values()) { + if (tier.isObtainable()) { + icons[tier.ordinal()] = register.registerIcon( + "mekanism:" + tier.getName() + "TierInstaller" + ); + } + } + } + + @Override + public IIcon getIconFromDamage(int meta) { + return icons[meta]; + } + + @Override + public void getSubItems(Item item, CreativeTabs tabs, List itemList) { + for (BaseTier tier : BaseTier.values()) { + if (tier.isObtainable()) { + itemList.add(new ItemStack(item, 1, tier.ordinal())); + } + } + } + + @Override + public String getUnlocalizedName(ItemStack item) { + return "item." + BaseTier.values()[item.getItemDamage()].getName().toLowerCase() + + "TierInstaller"; + } } diff --git a/src/main/java/mekanism/common/item/ItemUpgrade.java b/src/main/java/mekanism/common/item/ItemUpgrade.java index 0f081d656..3e147906e 100644 --- a/src/main/java/mekanism/common/item/ItemUpgrade.java +++ b/src/main/java/mekanism/common/item/ItemUpgrade.java @@ -2,6 +2,8 @@ package mekanism.common.item; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.EnumColor; import mekanism.common.Upgrade; import mekanism.common.base.IUpgradeItem; @@ -13,72 +15,74 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; - import org.lwjgl.input.Keyboard; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; +public class ItemUpgrade extends ItemMekanism implements IUpgradeItem { + private Upgrade upgrade; -public class ItemUpgrade extends ItemMekanism implements IUpgradeItem -{ - private Upgrade upgrade; - - public ItemUpgrade(Upgrade type) - { - super(); - upgrade = type; - setMaxStackSize(type.getMax()); - } - - @Override - @SideOnly(Side.CLIENT) - public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) - { - if(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) - { - list.add(LangUtils.localize("tooltip.hold") + " " + EnumColor.AQUA + "shift" + EnumColor.GREY + " " + LangUtils.localize("tooltip.forDetails")); - } - else { - list.addAll(MekanismUtils.splitTooltip(getUpgradeType(itemstack).getDescription(), itemstack)); - } - } - - @Override - public Upgrade getUpgradeType(ItemStack stack) - { - return upgrade; - } - - @Override - public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) - { - if(world.isRemote) - { - return false; - } - - if(player.isSneaking()) - { - TileEntity tile = world.getTileEntity(x, y, z); - Upgrade type = getUpgradeType(stack); - - if(tile instanceof IUpgradeTile) - { - TileComponentUpgrade component = ((IUpgradeTile)tile).getComponent(); - - if(component.supports(type)) - { - if(component.getUpgrades(type) < type.getMax()) - { - component.addUpgrade(type); - stack.stackSize--; - } - } - - return true; - } - } - - return false; - } + public ItemUpgrade(Upgrade type) { + super(); + upgrade = type; + setMaxStackSize(type.getMax()); + } + + @Override + @SideOnly(Side.CLIENT) + public void addInformation( + ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag + ) { + if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + list.add( + LangUtils.localize("tooltip.hold") + " " + EnumColor.AQUA + "shift" + + EnumColor.GREY + " " + LangUtils.localize("tooltip.forDetails") + ); + } else { + list.addAll(MekanismUtils.splitTooltip( + getUpgradeType(itemstack).getDescription(), itemstack + )); + } + } + + @Override + public Upgrade getUpgradeType(ItemStack stack) { + return upgrade; + } + + @Override + public boolean onItemUseFirst( + ItemStack stack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int side, + float hitX, + float hitY, + float hitZ + ) { + if (world.isRemote) { + return false; + } + + if (player.isSneaking()) { + TileEntity tile = world.getTileEntity(x, y, z); + Upgrade type = getUpgradeType(stack); + + if (tile instanceof IUpgradeTile) { + TileComponentUpgrade component = ((IUpgradeTile) tile).getComponent(); + + if (component.supports(type)) { + if (component.getUpgrades(type) < type.getMax()) { + component.addUpgrade(type); + stack.stackSize--; + } + } + + return true; + } + } + + return false; + } } diff --git a/src/main/java/mekanism/common/item/ItemWalkieTalkie.java b/src/main/java/mekanism/common/item/ItemWalkieTalkie.java index 08110cd29..3019b21a0 100644 --- a/src/main/java/mekanism/common/item/ItemWalkieTalkie.java +++ b/src/main/java/mekanism/common/item/ItemWalkieTalkie.java @@ -11,102 +11,93 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.IIcon; import net.minecraft.world.World; -public class ItemWalkieTalkie extends ItemMekanism -{ - public IIcon[] icons = new IIcon[256]; +public class ItemWalkieTalkie extends ItemMekanism { + public IIcon[] icons = new IIcon[256]; - public ItemWalkieTalkie() - { - super(); - setMaxStackSize(1); - } + public ItemWalkieTalkie() { + super(); + setMaxStackSize(1); + } - @Override - public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) - { - super.addInformation(itemstack, entityplayer, list, flag); + @Override + public void addInformation( + ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag + ) { + super.addInformation(itemstack, entityplayer, list, flag); - list.add((getOn(itemstack) ? EnumColor.DARK_GREEN : EnumColor.DARK_RED) + LangUtils.localize("gui." + (getOn(itemstack) ? "on" : "off"))); - list.add(EnumColor.DARK_AQUA + LangUtils.localize("tooltip.channel") + ": " + EnumColor.GREY + getChannel(itemstack)); - } + list.add( + (getOn(itemstack) ? EnumColor.DARK_GREEN : EnumColor.DARK_RED) + + LangUtils.localize("gui." + (getOn(itemstack) ? "on" : "off")) + ); + list.add( + EnumColor.DARK_AQUA + LangUtils.localize("tooltip.channel") + ": " + + EnumColor.GREY + getChannel(itemstack) + ); + } - @Override - public IIcon getIconIndex(ItemStack itemStack) - { - if(!getOn(itemStack)) - { - return icons[0]; - } + @Override + public IIcon getIconIndex(ItemStack itemStack) { + if (!getOn(itemStack)) { + return icons[0]; + } - return icons[getChannel(itemStack)]; - } + return icons[getChannel(itemStack)]; + } - @Override - public void registerIcons(IIconRegister register) - { - icons[0] = register.registerIcon("mekanism:WalkieTalkieOff"); + @Override + public void registerIcons(IIconRegister register) { + icons[0] = register.registerIcon("mekanism:WalkieTalkieOff"); - for(int i = 1; i <= 9; i++) - { - icons[i] = register.registerIcon("mekanism:WalkieTalkie_ch" + i); - } - } + for (int i = 1; i <= 9; i++) { + icons[i] = register.registerIcon("mekanism:WalkieTalkie_ch" + i); + } + } - @Override - public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) - { - if(player.isSneaking()) - { - setOn(itemStack, !getOn(itemStack)); - } + @Override + public ItemStack + onItemRightClick(ItemStack itemStack, World world, EntityPlayer player) { + if (player.isSneaking()) { + setOn(itemStack, !getOn(itemStack)); + } - return itemStack; - } + return itemStack; + } - public void setOn(ItemStack itemStack, boolean on) - { - if(itemStack.stackTagCompound == null) - { - itemStack.setTagCompound(new NBTTagCompound()); - } + public void setOn(ItemStack itemStack, boolean on) { + if (itemStack.stackTagCompound == null) { + itemStack.setTagCompound(new NBTTagCompound()); + } - itemStack.stackTagCompound.setBoolean("on", on); - } + itemStack.stackTagCompound.setBoolean("on", on); + } - public boolean getOn(ItemStack itemStack) - { - if(itemStack.stackTagCompound == null) - { - return false; - } + public boolean getOn(ItemStack itemStack) { + if (itemStack.stackTagCompound == null) { + return false; + } - return itemStack.stackTagCompound.getBoolean("on"); - } + return itemStack.stackTagCompound.getBoolean("on"); + } - public void setChannel(ItemStack itemStack, int channel) - { - if(itemStack.stackTagCompound == null) - { - itemStack.setTagCompound(new NBTTagCompound()); - } + public void setChannel(ItemStack itemStack, int channel) { + if (itemStack.stackTagCompound == null) { + itemStack.setTagCompound(new NBTTagCompound()); + } - itemStack.stackTagCompound.setInteger("channel", channel); - } + itemStack.stackTagCompound.setInteger("channel", channel); + } - public int getChannel(ItemStack itemStack) - { - if(itemStack.stackTagCompound == null) - { - return 1; - } + public int getChannel(ItemStack itemStack) { + if (itemStack.stackTagCompound == null) { + return 1; + } - int channel = itemStack.stackTagCompound.getInteger("channel"); + int channel = itemStack.stackTagCompound.getInteger("channel"); - if(channel == 0) - { - setChannel(itemStack, 1); - } + if (channel == 0) { + setChannel(itemStack, 1); + } - return itemStack.stackTagCompound.getInteger("channel"); - } + return itemStack.stackTagCompound.getInteger("channel"); + } } diff --git a/src/main/java/mekanism/common/item/ItemWeatherOrb.java b/src/main/java/mekanism/common/item/ItemWeatherOrb.java index ed9242305..0a8618acd 100644 --- a/src/main/java/mekanism/common/item/ItemWeatherOrb.java +++ b/src/main/java/mekanism/common/item/ItemWeatherOrb.java @@ -8,7 +8,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.World; public class ItemWeatherOrb extends ItemMekanism { - public ItemWeatherOrb() { super(); this.setMaxStackSize(1); @@ -19,20 +18,27 @@ public class ItemWeatherOrb extends ItemMekanism { public boolean hasEffect(final ItemStack itemstack) { return true; } - + @Override - public ItemStack onItemRightClick(final ItemStack itemstack, final World world, final EntityPlayer entityplayer) { + public ItemStack onItemRightClick( + final ItemStack itemstack, final World world, final EntityPlayer entityplayer + ) { if (itemstack.getItemDamage() == 0) { entityplayer.openGui(Mekanism.instance, 62, world, 0, 0, 0); } return itemstack; } - + @Override - public void onUpdate(final ItemStack itemstack, final World world, final Entity entity, final int i, final boolean flag) { + public void onUpdate( + final ItemStack itemstack, + final World world, + final Entity entity, + final int i, + final boolean flag + ) { if (itemstack.getItemDamage() > 0 && entity instanceof EntityLivingBase) { itemstack.damageItem(-1, (EntityLivingBase) entity); } } - } diff --git a/src/main/java/mekanism/common/multiblock/IMultiblock.java b/src/main/java/mekanism/common/multiblock/IMultiblock.java index 97ec03128..c7be6a20c 100644 --- a/src/main/java/mekanism/common/multiblock/IMultiblock.java +++ b/src/main/java/mekanism/common/multiblock/IMultiblock.java @@ -2,11 +2,10 @@ package mekanism.common.multiblock; import net.minecraft.entity.player.EntityPlayer; -public interface IMultiblock> -{ - public T getSynchronizedData(); - - public boolean onActivate(EntityPlayer player); - - public void update(); +public interface IMultiblock> { + public T getSynchronizedData(); + + public boolean onActivate(EntityPlayer player); + + public void update(); } diff --git a/src/main/java/mekanism/common/multiblock/IStructuralMultiblock.java b/src/main/java/mekanism/common/multiblock/IStructuralMultiblock.java index 279a6daf6..803537c39 100644 --- a/src/main/java/mekanism/common/multiblock/IStructuralMultiblock.java +++ b/src/main/java/mekanism/common/multiblock/IStructuralMultiblock.java @@ -4,13 +4,12 @@ import mekanism.api.Coord4D; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; -public interface IStructuralMultiblock -{ - public boolean onActivate(EntityPlayer player); - - public boolean canInterface(TileEntity controller); - - public void setController(Coord4D coord); - - public void update(); +public interface IStructuralMultiblock { + public boolean onActivate(EntityPlayer player); + + public boolean canInterface(TileEntity controller); + + public void setController(Coord4D coord); + + public void update(); } diff --git a/src/main/java/mekanism/common/multiblock/MultiblockCache.java b/src/main/java/mekanism/common/multiblock/MultiblockCache.java index 09a636ba3..c1254a305 100644 --- a/src/main/java/mekanism/common/multiblock/MultiblockCache.java +++ b/src/main/java/mekanism/common/multiblock/MultiblockCache.java @@ -5,15 +5,14 @@ import java.util.HashSet; import mekanism.api.Coord4D; import net.minecraft.nbt.NBTTagCompound; -public abstract class MultiblockCache> -{ - public HashSet locations = new HashSet(); - - public abstract void apply(T data); - - public abstract void sync(T data); - - public abstract void load(NBTTagCompound nbtTags); - - public abstract void save(NBTTagCompound nbtTags); +public abstract class MultiblockCache> { + public HashSet locations = new HashSet(); + + public abstract void apply(T data); + + public abstract void sync(T data); + + public abstract void load(NBTTagCompound nbtTags); + + public abstract void save(NBTTagCompound nbtTags); } diff --git a/src/main/java/mekanism/common/multiblock/MultiblockManager.java b/src/main/java/mekanism/common/multiblock/MultiblockManager.java index b5c17b90d..957bfc86e 100644 --- a/src/main/java/mekanism/common/multiblock/MultiblockManager.java +++ b/src/main/java/mekanism/common/multiblock/MultiblockManager.java @@ -12,144 +12,129 @@ import mekanism.common.tile.TileEntityMultiblock; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -public class MultiblockManager> -{ - private static Set managers = new HashSet(); - - public String name; - - /** A map containing references to all multiblock inventory caches. */ - public Map> inventories = new HashMap>(); - - public MultiblockManager(String s) - { - name = s; - managers.add(this); - } - - /** - * Grabs an inventory from the world's caches, and removes all the world's references to it. - * @param world - world the cache is stored in - * @param id - inventory ID to pull - * @return correct multiblock inventory cache - */ - public MultiblockCache pullInventory(World world, String id) - { - MultiblockCache toReturn = inventories.get(id); - - for(Coord4D obj : inventories.get(id).locations) - { - TileEntityMultiblock tileEntity = (TileEntityMultiblock)obj.getTileEntity(world); +public class MultiblockManager> { + private static Set managers = new HashSet(); - if(tileEntity != null) - { - tileEntity.cachedData = tileEntity.getNewCache(); - tileEntity.cachedID = null; - } - } - - inventories.remove(id); + public String name; - return toReturn; - } + /** A map containing references to all multiblock inventory caches. */ + public Map> inventories + = new HashMap>(); - /** - * Grabs a unique inventory ID for a multiblock. - * @return unique inventory ID - */ - public String getUniqueInventoryID() - { - return UUID.randomUUID().toString(); - } - - public static void tick(World world) - { - for(MultiblockManager manager : managers) - { - manager.tickSelf(world); - } - } + public MultiblockManager(String s) { + name = s; + managers.add(this); + } - public void tickSelf(World world) - { - ArrayList idsToKill = new ArrayList(); - HashMap> tilesToKill = new HashMap>(); + /** + * Grabs an inventory from the world's caches, and removes all the world's references + * to it. + * @param world - world the cache is stored in + * @param id - inventory ID to pull + * @return correct multiblock inventory cache + */ + public MultiblockCache pullInventory(World world, String id) { + MultiblockCache toReturn = inventories.get(id); - for(Map.Entry> entry : inventories.entrySet()) - { - String inventoryID = entry.getKey(); + for (Coord4D obj : inventories.get(id).locations) { + TileEntityMultiblock tileEntity + = (TileEntityMultiblock) obj.getTileEntity(world); - for(Coord4D obj : entry.getValue().locations) - { - if(obj.dimensionId == world.provider.dimensionId && obj.exists(world)) - { - TileEntity tileEntity = obj.getTileEntity(world); + if (tileEntity != null) { + tileEntity.cachedData = tileEntity.getNewCache(); + tileEntity.cachedID = null; + } + } - if(!(tileEntity instanceof TileEntityMultiblock) || ((TileEntityMultiblock)tileEntity).getManager() != this || (getStructureId(((TileEntityMultiblock)tileEntity)) != null && getStructureId(((TileEntityMultiblock)tileEntity)) != inventoryID)) - { - if(!tilesToKill.containsKey(inventoryID)) - { - tilesToKill.put(inventoryID, new HashSet()); - } + inventories.remove(id); - tilesToKill.get(inventoryID).add(obj); - } - } - } + return toReturn; + } - if(entry.getValue().locations.isEmpty()) - { - idsToKill.add(inventoryID); - } - } + /** + * Grabs a unique inventory ID for a multiblock. + * @return unique inventory ID + */ + public String getUniqueInventoryID() { + return UUID.randomUUID().toString(); + } - for(Map.Entry> entry : tilesToKill.entrySet()) - { - for(Coord4D obj : entry.getValue()) - { - inventories.get(entry.getKey()).locations.remove(obj); - } - } + public static void tick(World world) { + for (MultiblockManager manager : managers) { + manager.tickSelf(world); + } + } - for(String inventoryID : idsToKill) - { - inventories.remove(inventoryID); - } - } - - public static String getStructureId(TileEntityMultiblock tile) - { - return tile.structure != null ? tile.getSynchronizedData().inventoryID : null; - } - - public static boolean areEqual(TileEntity tile1, TileEntity tile2) - { - if(!(tile1 instanceof TileEntityMultiblock) || !(tile2 instanceof TileEntityMultiblock)) - { - return false; - } - - return ((TileEntityMultiblock)tile1).getManager() == ((TileEntityMultiblock)tile2).getManager(); - } - - public void updateCache(TileEntityMultiblock tile) - { - if(!inventories.containsKey(tile.cachedID)) - { - tile.cachedData.locations.add(Coord4D.get(tile)); - inventories.put(tile.cachedID, tile.cachedData); + public void tickSelf(World world) { + ArrayList idsToKill = new ArrayList(); + HashMap> tilesToKill + = new HashMap>(); - return; - } + for (Map.Entry> entry : inventories.entrySet()) { + String inventoryID = entry.getKey(); - inventories.get(tile.cachedID).locations.add(Coord4D.get(tile)); - } - - public static void reset() - { - for(MultiblockManager manager : managers) - { - manager.inventories.clear(); - } - } + for (Coord4D obj : entry.getValue().locations) { + if (obj.dimensionId == world.provider.dimensionId && obj.exists(world)) { + TileEntity tileEntity = obj.getTileEntity(world); + + if (!(tileEntity instanceof TileEntityMultiblock) + || ((TileEntityMultiblock) tileEntity).getManager() != this + || (getStructureId(((TileEntityMultiblock) tileEntity)) != null + && getStructureId(((TileEntityMultiblock) tileEntity)) + != inventoryID)) { + if (!tilesToKill.containsKey(inventoryID)) { + tilesToKill.put(inventoryID, new HashSet()); + } + + tilesToKill.get(inventoryID).add(obj); + } + } + } + + if (entry.getValue().locations.isEmpty()) { + idsToKill.add(inventoryID); + } + } + + for (Map.Entry> entry : tilesToKill.entrySet()) { + for (Coord4D obj : entry.getValue()) { + inventories.get(entry.getKey()).locations.remove(obj); + } + } + + for (String inventoryID : idsToKill) { + inventories.remove(inventoryID); + } + } + + public static String getStructureId(TileEntityMultiblock tile) { + return tile.structure != null ? tile.getSynchronizedData().inventoryID : null; + } + + public static boolean areEqual(TileEntity tile1, TileEntity tile2) { + if (!(tile1 instanceof TileEntityMultiblock) + || !(tile2 instanceof TileEntityMultiblock)) { + return false; + } + + return ((TileEntityMultiblock) tile1).getManager() + == ((TileEntityMultiblock) tile2).getManager(); + } + + public void updateCache(TileEntityMultiblock tile) { + if (!inventories.containsKey(tile.cachedID)) { + tile.cachedData.locations.add(Coord4D.get(tile)); + inventories.put(tile.cachedID, tile.cachedData); + + return; + } + + inventories.get(tile.cachedID).locations.add(Coord4D.get(tile)); + } + + public static void reset() { + for (MultiblockManager manager : managers) { + manager.inventories.clear(); + } + } } diff --git a/src/main/java/mekanism/common/multiblock/SynchronizedData.java b/src/main/java/mekanism/common/multiblock/SynchronizedData.java index 17d6b3cb2..bf7e1ce80 100644 --- a/src/main/java/mekanism/common/multiblock/SynchronizedData.java +++ b/src/main/java/mekanism/common/multiblock/SynchronizedData.java @@ -6,75 +6,68 @@ import java.util.Set; import mekanism.api.Coord4D; import net.minecraft.item.ItemStack; -public abstract class SynchronizedData> -{ - public Set locations = new HashSet(); +public abstract class SynchronizedData> { + public Set locations = new HashSet(); - public int volLength; + public int volLength; - public int volWidth; + public int volWidth; - public int volHeight; + public int volHeight; - public int volume; - - public String inventoryID; - - public boolean didTick; + public int volume; - public boolean hasRenderer; + public String inventoryID; - public Coord4D renderLocation; + public boolean didTick; - public Coord4D minLocation; - public Coord4D maxLocation; - - public boolean destroyed; - - public Set internalLocations = new HashSet(); - - public ItemStack[] getInventory() - { - return null; - } - - @Override - public int hashCode() - { - int code = 1; - code = 31 * code + locations.hashCode(); - code = 31 * code + volLength; - code = 31 * code + volWidth; - code = 31 * code + volHeight; - code = 31 * code + volume; - return code; - } + public boolean hasRenderer; - @Override - public boolean equals(Object obj) - { - if(obj == null || obj.getClass() != getClass()) - { - return false; - } + public Coord4D renderLocation; - SynchronizedData data = (SynchronizedData)obj; + public Coord4D minLocation; + public Coord4D maxLocation; - if(!data.locations.equals(locations)) - { - return false; - } + public boolean destroyed; - if(data.volLength != volLength || data.volWidth != volWidth || data.volHeight != volHeight) - { - return false; - } + public Set internalLocations = new HashSet(); - if(data.volume != volume) - { - return false; - } + public ItemStack[] getInventory() { + return null; + } - return true; - } + @Override + public int hashCode() { + int code = 1; + code = 31 * code + locations.hashCode(); + code = 31 * code + volLength; + code = 31 * code + volWidth; + code = 31 * code + volHeight; + code = 31 * code + volume; + return code; + } + + @Override + public boolean equals(Object obj) { + if (obj == null || obj.getClass() != getClass()) { + return false; + } + + SynchronizedData data = (SynchronizedData) obj; + + if (!data.locations.equals(locations)) { + return false; + } + + if (data.volLength != volLength || data.volWidth != volWidth + || data.volHeight != volHeight) { + return false; + } + + if (data.volume != volume) { + return false; + } + + return true; + } } diff --git a/src/main/java/mekanism/common/multiblock/TileEntityInternalMultiblock.java b/src/main/java/mekanism/common/multiblock/TileEntityInternalMultiblock.java index 2c7ac19c0..19c74e1f2 100644 --- a/src/main/java/mekanism/common/multiblock/TileEntityInternalMultiblock.java +++ b/src/main/java/mekanism/common/multiblock/TileEntityInternalMultiblock.java @@ -1,61 +1,50 @@ package mekanism.common.multiblock; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import io.netty.buffer.ByteBuf; import mekanism.common.PacketHandler; import mekanism.common.tile.TileEntityBasicBlock; -public class TileEntityInternalMultiblock extends TileEntityBasicBlock -{ - public String multiblockUUID; +public class TileEntityInternalMultiblock extends TileEntityBasicBlock { + public String multiblockUUID; - @Override - public void onUpdate() {} - - @Override - public boolean canUpdate() - { - return false; - } - - @Override - public void handlePacketData(ByteBuf dataStream) - { - super.handlePacketData(dataStream); - - if(worldObj.isRemote) - { - if(dataStream.readBoolean()) - { - multiblockUUID = PacketHandler.readString(dataStream); - } - else { - multiblockUUID = null; - } - } - } + @Override + public void onUpdate() {} - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); - - if(multiblockUUID != null) - { - data.add(true); - data.add(multiblockUUID); - } - else { - data.add(false); - } - - return data; - } - - public void setMultiblock(String id) - { - multiblockUUID = id; - } + @Override + public boolean canUpdate() { + return false; + } + + @Override + public void handlePacketData(ByteBuf dataStream) { + super.handlePacketData(dataStream); + + if (worldObj.isRemote) { + if (dataStream.readBoolean()) { + multiblockUUID = PacketHandler.readString(dataStream); + } else { + multiblockUUID = null; + } + } + } + + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); + + if (multiblockUUID != null) { + data.add(true); + data.add(multiblockUUID); + } else { + data.add(false); + } + + return data; + } + + public void setMultiblock(String id) { + multiblockUUID = id; + } } diff --git a/src/main/java/mekanism/common/multiblock/UpdateProtocol.java b/src/main/java/mekanism/common/multiblock/UpdateProtocol.java index 474fa76e1..1174f97fa 100644 --- a/src/main/java/mekanism/common/multiblock/UpdateProtocol.java +++ b/src/main/java/mekanism/common/multiblock/UpdateProtocol.java @@ -12,615 +12,547 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -public abstract class UpdateProtocol> -{ - /** The multiblock nodes that have already been iterated over. */ - public Set iteratedNodes = new HashSet(); - - public Set innerNodes = new HashSet(); +public abstract class UpdateProtocol> { + /** The multiblock nodes that have already been iterated over. */ + public Set iteratedNodes = new HashSet(); - /** The structures found, all connected by some nodes to the pointer. */ - public T structureFound = null; + public Set innerNodes = new HashSet(); - /** The original block the calculation is getting run from. */ - public TileEntityMultiblock pointer; + /** The structures found, all connected by some nodes to the pointer. */ + public T structureFound = null; - public UpdateProtocol(TileEntityMultiblock tileEntity) - { - pointer = tileEntity; - } + /** The original block the calculation is getting run from. */ + public TileEntityMultiblock pointer; - /** - * Recursively loops through each node connected to the given TileEntity. - * @param tile - the TileEntity to loop over - */ - public void loopThrough(TileEntity tile) - { - World worldObj = tile.getWorldObj(); + public UpdateProtocol(TileEntityMultiblock tileEntity) { + pointer = tileEntity; + } - int origX = tile.xCoord, origY = tile.yCoord, origZ = tile.zCoord; + /** + * Recursively loops through each node connected to the given TileEntity. + * @param tile - the TileEntity to loop over + */ + public void loopThrough(TileEntity tile) { + World worldObj = tile.getWorldObj(); - boolean isCorner = true; - boolean isHollow = true; - boolean rightBlocks = true; - boolean rightFrame = true; + int origX = tile.xCoord, origY = tile.yCoord, origZ = tile.zCoord; - Set locations = new HashSet(); + boolean isCorner = true; + boolean isHollow = true; + boolean rightBlocks = true; + boolean rightFrame = true; - int xmin = 0, xmax = 0, ymin = 0, ymax = 0, zmin = 0, zmax = 0; + Set locations = new HashSet(); - int x = 0, y = 0, z = 0; + int xmin = 0, xmax = 0, ymin = 0, ymax = 0, zmin = 0, zmax = 0; - int volume = 0; + int x = 0, y = 0, z = 0; - if((isViableNode(origX + 1, origY, origZ) && isViableNode(origX - 1, origY, origZ)) || - (isViableNode(origX, origY + 1, origZ) && isViableNode(origX, origY - 1, origZ)) || - (isViableNode(origX, origY, origZ + 1) && isViableNode(origX, origY, origZ - 1))) - { - isCorner = false; - } + int volume = 0; - if(isCorner) - { - if(isViableNode(origX+1, origY, origZ)) - { - xmin = 0; + if ((isViableNode(origX + 1, origY, origZ) + && isViableNode(origX - 1, origY, origZ)) + || (isViableNode(origX, origY + 1, origZ) + && isViableNode(origX, origY - 1, origZ)) + || (isViableNode(origX, origY, origZ + 1) + && isViableNode(origX, origY, origZ - 1))) { + isCorner = false; + } - while(isViableNode(origX+x+1, origY, origZ)) - { - x++; - } + if (isCorner) { + if (isViableNode(origX + 1, origY, origZ)) { + xmin = 0; - xmax = x; - } - else { - xmax = 0; + while (isViableNode(origX + x + 1, origY, origZ)) { + x++; + } - while(isViableNode(origX+x-1, origY, origZ)) - { - x--; - } + xmax = x; + } else { + xmax = 0; - xmin = x; - } + while (isViableNode(origX + x - 1, origY, origZ)) { + x--; + } - if(isViableNode(origX, origY+1, origZ)) - { - ymin = 0; + xmin = x; + } - while(isViableNode(origX, origY+y+1, origZ)) - { - y++; - } + if (isViableNode(origX, origY + 1, origZ)) { + ymin = 0; - ymax = y; - } - else { - ymax = 0; + while (isViableNode(origX, origY + y + 1, origZ)) { + y++; + } - while(isViableNode(origX, origY+y-1 ,origZ)) - { - y--; - } + ymax = y; + } else { + ymax = 0; - ymin = y; - } + while (isViableNode(origX, origY + y - 1, origZ)) { + y--; + } - if(isViableNode(origX, origY, origZ+1)) - { - zmin = 0; + ymin = y; + } - while(isViableNode(origX, origY, origZ+z+1)) - { - z++; - } + if (isViableNode(origX, origY, origZ + 1)) { + zmin = 0; - zmax = z; - } - else { - zmax = 0; + while (isViableNode(origX, origY, origZ + z + 1)) { + z++; + } - while(isViableNode(origX, origY, origZ+z-1)) - { - z--; - } + zmax = z; + } else { + zmax = 0; - zmin = z; - } + while (isViableNode(origX, origY, origZ + z - 1)) { + z--; + } - for(x = xmin; x <= xmax; x++) - { - for(y = ymin; y <= ymax; y++) - { - for(z = zmin; z <= zmax; z++) - { - if(x == xmin || x == xmax || y == ymin || y == ymax || z == zmin || z == zmax) - { - if(!isViableNode(origX+x, origY+y, origZ+z)) - { - rightBlocks = false; - break; - } - else if(isFrame(Coord4D.get(tile).translate(x, y, z), origX+xmin, origX+xmax, origY+ymin, origY+ymax, origZ+zmin, origZ+zmax) && !isValidFrame(origX+x, origY+y, origZ+z)) - { - rightFrame = false; - break; - } - else { - locations.add(Coord4D.get(tile).translate(x, y, z)); - } - } - else { - if(!isValidInnerNode(origX+x, origY+y, origZ+z)) - { - isHollow = false; - break; - } - else { - if(!isAir(origX+x, origY+y, origZ+z)) - { - innerNodes.add(new Coord4D(origX+x, origY+y, origZ+z, pointer.getWorldObj().provider.dimensionId)); - } - } + zmin = z; + } - volume++; - } - } - - if(!isHollow || !rightBlocks || !rightFrame) - { - break; - } - } - - if(!isHollow || !rightBlocks || !rightFrame) - { - break; - } - } - } + for (x = xmin; x <= xmax; x++) { + for (y = ymin; y <= ymax; y++) { + for (z = zmin; z <= zmax; z++) { + if (x == xmin || x == xmax || y == ymin || y == ymax || z == zmin + || z == zmax) { + if (!isViableNode(origX + x, origY + y, origZ + z)) { + rightBlocks = false; + break; + } else if (isFrame(Coord4D.get(tile).translate(x, y, z), origX + xmin, origX + xmax, origY + ymin, origY + ymax, origZ + zmin, origZ + zmax) && !isValidFrame(origX + x, origY + y, origZ + z)) { + rightFrame = false; + break; + } else { + locations.add(Coord4D.get(tile).translate(x, y, z)); + } + } else { + if (!isValidInnerNode(origX + x, origY + y, origZ + z)) { + isHollow = false; + break; + } else { + if (!isAir(origX + x, origY + y, origZ + z)) { + innerNodes.add(new Coord4D( + origX + x, + origY + y, + origZ + z, + pointer.getWorldObj().provider.dimensionId + )); + } + } - volume += locations.size(); + volume++; + } + } - if(Math.abs(xmax-xmin)+1 <= 18 && Math.abs(ymax-ymin)+1 <= 18 && Math.abs(zmax-zmin)+1 <= 18) - { - if(rightBlocks && rightFrame && isHollow && isCorner) - { - T structure = getNewStructure(); - structure.locations = locations; - structure.volLength = Math.abs(xmax-xmin)+1; - structure.volHeight = Math.abs(ymax-ymin)+1; - structure.volWidth = Math.abs(zmax-zmin)+1; - structure.volume = structure.volLength*structure.volHeight*structure.volWidth; - structure.renderLocation = Coord4D.get(tile).translate(0, 1, 0); - structure.minLocation = Coord4D.get(tile).translate(xmin, ymin, zmin); - structure.maxLocation = Coord4D.get(tile).translate(xmax, ymax, zmax); - - if(structure.volLength >= 3 && structure.volHeight >= 3 && structure.volWidth >= 3) - { - onStructureCreated(structure, origX, origY, origZ, xmin, xmax, ymin, ymax, zmin, zmax); - - if(structure.locations.contains(Coord4D.get(pointer)) && isCorrectCorner(Coord4D.get(tile), origX+xmin, origY+ymin, origZ+zmin)) - { - if(canForm(structure)) - { - structureFound = structure; - return; - } - } - } - } - } + if (!isHollow || !rightBlocks || !rightFrame) { + break; + } + } - innerNodes.clear(); - iteratedNodes.add(tile); - - if(iteratedNodes.size() > 2048) - { - return; - } + if (!isHollow || !rightBlocks || !rightFrame) { + break; + } + } + } - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - Coord4D coord = Coord4D.get(tile).getFromSide(side); - TileEntity tileEntity = coord.getTileEntity(tile.getWorldObj()); + volume += locations.size(); - if(isViableNode(coord.xCoord, coord.yCoord, coord.zCoord)) - { - if(!iteratedNodes.contains(tileEntity)) - { - loopThrough(tileEntity); - } - } - } - } - - protected boolean canForm(T structure) - { - return true; - } + if (Math.abs(xmax - xmin) + 1 <= 18 && Math.abs(ymax - ymin) + 1 <= 18 + && Math.abs(zmax - zmin) + 1 <= 18) { + if (rightBlocks && rightFrame && isHollow && isCorner) { + T structure = getNewStructure(); + structure.locations = locations; + structure.volLength = Math.abs(xmax - xmin) + 1; + structure.volHeight = Math.abs(ymax - ymin) + 1; + structure.volWidth = Math.abs(zmax - zmin) + 1; + structure.volume + = structure.volLength * structure.volHeight * structure.volWidth; + structure.renderLocation = Coord4D.get(tile).translate(0, 1, 0); + structure.minLocation = Coord4D.get(tile).translate(xmin, ymin, zmin); + structure.maxLocation = Coord4D.get(tile).translate(xmax, ymax, zmax); - public ForgeDirection getSide(Coord4D obj, int xmin, int xmax, int ymin, int ymax, int zmin, int zmax) - { - if(obj.xCoord == xmin) - { - return ForgeDirection.WEST; - } - else if(obj.xCoord == xmax) - { - return ForgeDirection.EAST; - } - else if(obj.yCoord == ymin) - { - return ForgeDirection.DOWN; - } - else if(obj.yCoord == ymax) - { - return ForgeDirection.UP; - } - else if(obj.zCoord == zmin) - { - return ForgeDirection.NORTH; - } - else if(obj.zCoord == zmax) - { - return ForgeDirection.SOUTH; - } + if (structure.volLength >= 3 && structure.volHeight >= 3 + && structure.volWidth >= 3) { + onStructureCreated( + structure, origX, origY, origZ, xmin, xmax, ymin, ymax, zmin, zmax + ); - return ForgeDirection.UNKNOWN; - } + if (structure.locations.contains(Coord4D.get(pointer)) + && isCorrectCorner( + Coord4D.get(tile), origX + xmin, origY + ymin, origZ + zmin + )) { + if (canForm(structure)) { + structureFound = structure; + return; + } + } + } + } + } - /** - * Whether or not the block at the specified location is an air block. - * @param x - x coordinate - * @param y - y coordinate - * @param z - z coordinate - * @return - */ - protected boolean isAir(int x, int y, int z) - { - return pointer.getWorldObj().isAirBlock(x, y, z); - } - - protected boolean isValidInnerNode(int x, int y, int z) - { - return isAir(x, y, z); - } + innerNodes.clear(); + iteratedNodes.add(tile); - /** - * Whether or not the block at the specified location is a viable node for a multiblock structure. - * @param x - x coordinate - * @param y - y coordinate - * @param z - z coordinate - * @return - */ - public boolean isViableNode(int x, int y, int z) - { - TileEntity tile = pointer.getWorldObj().getTileEntity(x, y, z); - - if(tile instanceof IStructuralMultiblock) - { - if(((IStructuralMultiblock)tile).canInterface(pointer)) - { - return true; - } - } - - if(MultiblockManager.areEqual(tile, pointer)) - { - return true; - } + if (iteratedNodes.size() > 2048) { + return; + } - return false; - } + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + Coord4D coord = Coord4D.get(tile).getFromSide(side); + TileEntity tileEntity = coord.getTileEntity(tile.getWorldObj()); - /** - * If the block at the specified location is on the minimum of all angles of this multiblock structure, and the one to use for the - * actual calculation. - * @param obj - location to check - * @param xmin - minimum x value - * @param ymin - minimum y value - * @param zmin - minimum z value - * @return - */ - private boolean isCorrectCorner(Coord4D obj, int xmin, int ymin, int zmin) - { - if(obj.xCoord == xmin && obj.yCoord == ymin && obj.zCoord == zmin) - { - return true; - } + if (isViableNode(coord.xCoord, coord.yCoord, coord.zCoord)) { + if (!iteratedNodes.contains(tileEntity)) { + loopThrough(tileEntity); + } + } + } + } - return false; - } + protected boolean canForm(T structure) { + return true; + } - /** - * Whether or not the block at the specified location is considered a frame on the multiblock structure. - * @param obj - location to check - * @param xmin - minimum x value - * @param xmax - maximum x value - * @param ymin - minimum y value - * @param ymax - maximum y value - * @param zmin - minimum z value - * @param zmax - maximum z value - * @return - */ - private boolean isFrame(Coord4D obj, int xmin, int xmax, int ymin, int ymax, int zmin, int zmax) - { - if(obj.xCoord == xmin && obj.yCoord == ymin) - return true; - if(obj.xCoord == xmax && obj.yCoord == ymin) - return true; - if(obj.xCoord == xmin && obj.yCoord == ymax) - return true; - if(obj.xCoord == xmax && obj.yCoord == ymax) - return true; + public ForgeDirection + getSide(Coord4D obj, int xmin, int xmax, int ymin, int ymax, int zmin, int zmax) { + if (obj.xCoord == xmin) { + return ForgeDirection.WEST; + } else if (obj.xCoord == xmax) { + return ForgeDirection.EAST; + } else if (obj.yCoord == ymin) { + return ForgeDirection.DOWN; + } else if (obj.yCoord == ymax) { + return ForgeDirection.UP; + } else if (obj.zCoord == zmin) { + return ForgeDirection.NORTH; + } else if (obj.zCoord == zmax) { + return ForgeDirection.SOUTH; + } - if(obj.xCoord == xmin && obj.zCoord == zmin) - return true; - if(obj.xCoord == xmax && obj.zCoord == zmin) - return true; - if(obj.xCoord == xmin && obj.zCoord == zmax) - return true; - if(obj.xCoord == xmax && obj.zCoord == zmax) - return true; + return ForgeDirection.UNKNOWN; + } - if(obj.yCoord == ymin && obj.zCoord == zmin) - return true; - if(obj.yCoord == ymax && obj.zCoord == zmin) - return true; - if(obj.yCoord == ymin && obj.zCoord == zmax) - return true; - if(obj.yCoord == ymax && obj.zCoord == zmax) - return true; + /** + * Whether or not the block at the specified location is an air block. + * @param x - x coordinate + * @param y - y coordinate + * @param z - z coordinate + * @return + */ + protected boolean isAir(int x, int y, int z) { + return pointer.getWorldObj().isAirBlock(x, y, z); + } - return false; - } + protected boolean isValidInnerNode(int x, int y, int z) { + return isAir(x, y, z); + } - /** - * Whether or not the block at the specified location serves as a frame for a multiblock structure. - * @param x - x coordinate - * @param y - y coordinate - * @param z - z coordinate - * @return - */ - protected abstract boolean isValidFrame(int x, int y, int z); - - protected abstract MultiblockCache getNewCache(); - - protected abstract T getNewStructure(); - - protected abstract MultiblockManager getManager(); - - protected abstract void mergeCaches(List rejectedItems, MultiblockCache cache, MultiblockCache merge); - - protected void onFormed() - { - for(Coord4D coord : structureFound.internalLocations) - { - TileEntity tile = coord.getTileEntity(pointer.getWorldObj()); - - if(tile instanceof TileEntityInternalMultiblock) - { - ((TileEntityInternalMultiblock)tile).setMultiblock(structureFound.inventoryID); - } - } - } - - protected void onStructureCreated(T structure, int origX, int origY, int origZ, int xmin, int xmax, int ymin, int ymax, int zmin, int zmax) {} - - public void onStructureDestroyed(T structure) - { - for(Coord4D coord : structure.internalLocations) - { - TileEntity tile = coord.getTileEntity(pointer.getWorldObj()); - - if(tile instanceof TileEntityInternalMultiblock) - { - ((TileEntityInternalMultiblock)tile).setMultiblock(null); - } - } - } - - public void killInnerNode(Coord4D coord) - { - TileEntity tile = coord.getTileEntity(pointer.getWorldObj()); - - if(tile instanceof TileEntityInternalMultiblock) - { - ((TileEntityInternalMultiblock)tile).setMultiblock(null); - } - } + /** + * Whether or not the block at the specified location is a viable node for a + * multiblock structure. + * @param x - x coordinate + * @param y - y coordinate + * @param z - z coordinate + * @return + */ + public boolean isViableNode(int x, int y, int z) { + TileEntity tile = pointer.getWorldObj().getTileEntity(x, y, z); - /** - * Runs the protocol and updates all nodes that make a part of the multiblock. - */ - public void doUpdate() - { - loopThrough(pointer); + if (tile instanceof IStructuralMultiblock) { + if (((IStructuralMultiblock) tile).canInterface(pointer)) { + return true; + } + } - if(structureFound != null) - { - for(TileEntity tileEntity : iteratedNodes) - { - if(!structureFound.locations.contains(Coord4D.get(tileEntity))) - { - for(TileEntity tile : iteratedNodes) - { - if(tile instanceof TileEntityMultiblock) - { - ((TileEntityMultiblock)tile).structure = null; - } - else if(tile instanceof IStructuralMultiblock) - { - ((IStructuralMultiblock)tile).setController(null); - } - } - - for(Coord4D coord : innerNodes) - { - killInnerNode(coord); - } + if (MultiblockManager.areEqual(tile, pointer)) { + return true; + } - return; - } - } + return false; + } - List idsFound = new ArrayList(); - String idToUse = null; + /** + * If the block at the specified location is on the minimum of all angles of this + * multiblock structure, and the one to use for the actual calculation. + * @param obj - location to check + * @param xmin - minimum x value + * @param ymin - minimum y value + * @param zmin - minimum z value + * @return + */ + private boolean isCorrectCorner(Coord4D obj, int xmin, int ymin, int zmin) { + if (obj.xCoord == xmin && obj.yCoord == ymin && obj.zCoord == zmin) { + return true; + } - for(Coord4D obj : structureFound.locations) - { - TileEntity tileEntity = obj.getTileEntity(pointer.getWorldObj()); + return false; + } - if(tileEntity instanceof TileEntityMultiblock && ((TileEntityMultiblock)tileEntity).cachedID != null) - { - idsFound.add(((TileEntityMultiblock)tileEntity).cachedID); - } - } + /** + * Whether or not the block at the specified location is considered a frame on the + * multiblock structure. + * @param obj - location to check + * @param xmin - minimum x value + * @param xmax - maximum x value + * @param ymin - minimum y value + * @param ymax - maximum y value + * @param zmin - minimum z value + * @param zmax - maximum z value + * @return + */ + private boolean + isFrame(Coord4D obj, int xmin, int xmax, int ymin, int ymax, int zmin, int zmax) { + if (obj.xCoord == xmin && obj.yCoord == ymin) + return true; + if (obj.xCoord == xmax && obj.yCoord == ymin) + return true; + if (obj.xCoord == xmin && obj.yCoord == ymax) + return true; + if (obj.xCoord == xmax && obj.yCoord == ymax) + return true; - MultiblockCache cache = getNewCache(); - List rejectedItems = new ArrayList(); + if (obj.xCoord == xmin && obj.zCoord == zmin) + return true; + if (obj.xCoord == xmax && obj.zCoord == zmin) + return true; + if (obj.xCoord == xmin && obj.zCoord == zmax) + return true; + if (obj.xCoord == xmax && obj.zCoord == zmax) + return true; - if(!idsFound.isEmpty()) - { - for(String id : idsFound) - { - if(getManager().inventories.get(id) != null) - { - if(cache == null) - { - cache = getManager().pullInventory(pointer.getWorldObj(), id); - } - else { - mergeCaches(rejectedItems, cache, getManager().pullInventory(pointer.getWorldObj(), id)); - } - - idToUse = id; - } - } - } - else { - idToUse = getManager().getUniqueInventoryID(); - } - - //TODO someday: drop all items in rejectedItems - //TODO seriously this needs to happen soon - //TODO perhaps drop from pointer? + if (obj.yCoord == ymin && obj.zCoord == zmin) + return true; + if (obj.yCoord == ymax && obj.zCoord == zmin) + return true; + if (obj.yCoord == ymin && obj.zCoord == zmax) + return true; + if (obj.yCoord == ymax && obj.zCoord == zmax) + return true; - cache.apply((T)structureFound); - - structureFound.inventoryID = idToUse; - - onFormed(); - - List structures = new ArrayList(); - Coord4D toUse = null; + return false; + } - for(Coord4D obj : structureFound.locations) - { - TileEntity tileEntity = obj.getTileEntity(pointer.getWorldObj()); + /** + * Whether or not the block at the specified location serves as a frame for a + * multiblock structure. + * @param x - x coordinate + * @param y - y coordinate + * @param z - z coordinate + * @return + */ + protected abstract boolean isValidFrame(int x, int y, int z); - if(tileEntity instanceof TileEntityMultiblock) - { - ((TileEntityMultiblock)tileEntity).structure = structureFound; - - if(toUse == null) - { - toUse = obj.clone(); - } - } - else if(tileEntity instanceof IStructuralMultiblock) - { - structures.add((IStructuralMultiblock)tileEntity); - } - } - - //Remove all structural multiblocks from locations, set controllers - for(IStructuralMultiblock node : structures) - { - node.setController(toUse); - structureFound.locations.remove(Coord4D.get((TileEntity)node)); - } - } - else { - for(TileEntity tile : iteratedNodes) - { - if(tile instanceof TileEntityMultiblock) - { - TileEntityMultiblock tileEntity = (TileEntityMultiblock)tile; - - if(tileEntity.structure != null && !tileEntity.structure.destroyed) - { - onStructureDestroyed(tileEntity.structure); - tileEntity.structure.destroyed = true; - } - - tileEntity.structure = null; - } - else if(tile instanceof IStructuralMultiblock) - { - ((IStructuralMultiblock)tile).setController(null); - } - } - - for(Coord4D coord : innerNodes) - { - killInnerNode(coord); - } - } - } - - public class NodeCounter - { - public Set iterated = new HashSet(); - - public NodeChecker checker; - - public NodeCounter(NodeChecker c) - { - checker = c; - } - - public void loop(Coord4D pos) - { - iterated.add(pos); - - if(!checker.shouldContinue(iterated.size())) - { - return; - } - - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - Coord4D coord = pos.getFromSide(side); - - if(!iterated.contains(coord) && checker.isValid(coord)) - { - loop(coord); - } - } - } - - public int calculate(Coord4D coord) - { - if(!checker.isValid(coord)) - { - return 0; - } - - loop(coord); - - return iterated.size(); - } - } - - public static abstract class NodeChecker - { - public abstract boolean isValid(final Coord4D coord); - - public boolean shouldContinue(int iterated) - { - return true; - } - } + protected abstract MultiblockCache getNewCache(); + + protected abstract T getNewStructure(); + + protected abstract MultiblockManager getManager(); + + protected abstract void mergeCaches( + List rejectedItems, MultiblockCache cache, MultiblockCache merge + ); + + protected void onFormed() { + for (Coord4D coord : structureFound.internalLocations) { + TileEntity tile = coord.getTileEntity(pointer.getWorldObj()); + + if (tile instanceof TileEntityInternalMultiblock) { + ((TileEntityInternalMultiblock) tile) + .setMultiblock(structureFound.inventoryID); + } + } + } + + protected void onStructureCreated( + T structure, + int origX, + int origY, + int origZ, + int xmin, + int xmax, + int ymin, + int ymax, + int zmin, + int zmax + ) {} + + public void onStructureDestroyed(T structure) { + for (Coord4D coord : structure.internalLocations) { + TileEntity tile = coord.getTileEntity(pointer.getWorldObj()); + + if (tile instanceof TileEntityInternalMultiblock) { + ((TileEntityInternalMultiblock) tile).setMultiblock(null); + } + } + } + + public void killInnerNode(Coord4D coord) { + TileEntity tile = coord.getTileEntity(pointer.getWorldObj()); + + if (tile instanceof TileEntityInternalMultiblock) { + ((TileEntityInternalMultiblock) tile).setMultiblock(null); + } + } + + /** + * Runs the protocol and updates all nodes that make a part of the multiblock. + */ + public void doUpdate() { + loopThrough(pointer); + + if (structureFound != null) { + for (TileEntity tileEntity : iteratedNodes) { + if (!structureFound.locations.contains(Coord4D.get(tileEntity))) { + for (TileEntity tile : iteratedNodes) { + if (tile instanceof TileEntityMultiblock) { + ((TileEntityMultiblock) tile).structure = null; + } else if (tile instanceof IStructuralMultiblock) { + ((IStructuralMultiblock) tile).setController(null); + } + } + + for (Coord4D coord : innerNodes) { + killInnerNode(coord); + } + + return; + } + } + + List idsFound = new ArrayList(); + String idToUse = null; + + for (Coord4D obj : structureFound.locations) { + TileEntity tileEntity = obj.getTileEntity(pointer.getWorldObj()); + + if (tileEntity instanceof TileEntityMultiblock + && ((TileEntityMultiblock) tileEntity).cachedID != null) { + idsFound.add(((TileEntityMultiblock) tileEntity).cachedID); + } + } + + MultiblockCache cache = getNewCache(); + List rejectedItems = new ArrayList(); + + if (!idsFound.isEmpty()) { + for (String id : idsFound) { + if (getManager().inventories.get(id) != null) { + if (cache == null) { + cache = getManager().pullInventory(pointer.getWorldObj(), id); + } else { + mergeCaches( + rejectedItems, + cache, + getManager().pullInventory(pointer.getWorldObj(), id) + ); + } + + idToUse = id; + } + } + } else { + idToUse = getManager().getUniqueInventoryID(); + } + + //TODO someday: drop all items in rejectedItems + //TODO seriously this needs to happen soon + //TODO perhaps drop from pointer? + + cache.apply((T) structureFound); + + structureFound.inventoryID = idToUse; + + onFormed(); + + List structures + = new ArrayList(); + Coord4D toUse = null; + + for (Coord4D obj : structureFound.locations) { + TileEntity tileEntity = obj.getTileEntity(pointer.getWorldObj()); + + if (tileEntity instanceof TileEntityMultiblock) { + ((TileEntityMultiblock) tileEntity).structure = structureFound; + + if (toUse == null) { + toUse = obj.clone(); + } + } else if (tileEntity instanceof IStructuralMultiblock) { + structures.add((IStructuralMultiblock) tileEntity); + } + } + + //Remove all structural multiblocks from locations, set controllers + for (IStructuralMultiblock node : structures) { + node.setController(toUse); + structureFound.locations.remove(Coord4D.get((TileEntity) node)); + } + } else { + for (TileEntity tile : iteratedNodes) { + if (tile instanceof TileEntityMultiblock) { + TileEntityMultiblock tileEntity = (TileEntityMultiblock) tile; + + if (tileEntity.structure != null && !tileEntity.structure.destroyed) { + onStructureDestroyed(tileEntity.structure); + tileEntity.structure.destroyed = true; + } + + tileEntity.structure = null; + } else if (tile instanceof IStructuralMultiblock) { + ((IStructuralMultiblock) tile).setController(null); + } + } + + for (Coord4D coord : innerNodes) { + killInnerNode(coord); + } + } + } + + public class NodeCounter { + public Set iterated = new HashSet(); + + public NodeChecker checker; + + public NodeCounter(NodeChecker c) { + checker = c; + } + + public void loop(Coord4D pos) { + iterated.add(pos); + + if (!checker.shouldContinue(iterated.size())) { + return; + } + + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + Coord4D coord = pos.getFromSide(side); + + if (!iterated.contains(coord) && checker.isValid(coord)) { + loop(coord); + } + } + } + + public int calculate(Coord4D coord) { + if (!checker.isValid(coord)) { + return 0; + } + + loop(coord); + + return iterated.size(); + } + } + + public static abstract class NodeChecker { + public abstract boolean isValid(final Coord4D coord); + + public boolean shouldContinue(int iterated) { + return true; + } + } } diff --git a/src/main/java/mekanism/common/multipart/ItemGlowPanel.java b/src/main/java/mekanism/common/multipart/ItemGlowPanel.java index ac9f70a32..93eb1b67a 100644 --- a/src/main/java/mekanism/common/multipart/ItemGlowPanel.java +++ b/src/main/java/mekanism/common/multipart/ItemGlowPanel.java @@ -2,6 +2,14 @@ package mekanism.common.multipart; import java.util.List; +import codechicken.lib.vec.BlockCoord; +import codechicken.lib.vec.Vector3; +import codechicken.microblock.HollowMicroblock; +import codechicken.multipart.JItemMultiPart; +import codechicken.multipart.TMultiPart; +import codechicken.multipart.TileMultipart; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.EnumColor; import mekanism.common.Mekanism; import mekanism.common.util.LangUtils; @@ -13,119 +21,106 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.StatCollector; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import codechicken.lib.vec.BlockCoord; -import codechicken.lib.vec.Vector3; -import codechicken.microblock.HollowMicroblock; -import codechicken.multipart.JItemMultiPart; -import codechicken.multipart.TMultiPart; -import codechicken.multipart.TileMultipart; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class ItemGlowPanel extends JItemMultiPart -{ - public ItemGlowPanel() - { - super(); - setHasSubtypes(true); - setCreativeTab(Mekanism.tabMekanism); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister register) {} +public class ItemGlowPanel extends JItemMultiPart { + public ItemGlowPanel() { + super(); + setHasSubtypes(true); + setCreativeTab(Mekanism.tabMekanism); + } - @Override - public TMultiPart newPart(ItemStack item, EntityPlayer player, World world, BlockCoord pos, int side, Vector3 vHit) - { - EnumColor col = EnumColor.DYES[item.getItemDamage()]; - ForgeDirection orientation = getSideFromVector3(vHit.subtract(Vector3.center)); - - if(pos != null && orientation != null) - { - BlockCoord pos1 = pos.copy().inset(orientation.getOpposite().ordinal()); - - if(world.isSideSolid(pos1.x, pos1.y, pos1.z, orientation.getOpposite())) - { - return new PartGlowPanel(col, orientation); - } - - if(world.getTileEntity(pos.x, pos.y, pos.z) instanceof TileMultipart && ((TileMultipart) world.getTileEntity(pos.x, pos.y, pos.z)).partMap(orientation.ordinal()) instanceof HollowMicroblock) - { - return new PartGlowPanel(col, orientation); - } - } + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister register) {} - return null; - } + @Override + public TMultiPart newPart( + ItemStack item, + EntityPlayer player, + World world, + BlockCoord pos, + int side, + Vector3 vHit + ) { + EnumColor col = EnumColor.DYES[item.getItemDamage()]; + ForgeDirection orientation = getSideFromVector3(vHit.subtract(Vector3.center)); - public ForgeDirection getSideFromVector3(Vector3 vector) - { - if(Math.abs(vector.x) > Math.abs(vector.y) && Math.abs(vector.x) > Math.abs(vector.z)) - { - if((vector.x < 0.5 && vector.x > 0) || vector.x == -0.5) - { - return ForgeDirection.EAST; - } - - return ForgeDirection.WEST; - } + if (pos != null && orientation != null) { + BlockCoord pos1 = pos.copy().inset(orientation.getOpposite().ordinal()); + + if (world.isSideSolid(pos1.x, pos1.y, pos1.z, orientation.getOpposite())) { + return new PartGlowPanel(col, orientation); + } + + if (world.getTileEntity(pos.x, pos.y, pos.z) instanceof TileMultipart + && ((TileMultipart) world.getTileEntity(pos.x, pos.y, pos.z)) + .partMap(orientation.ordinal()) + instanceof HollowMicroblock) { + return new PartGlowPanel(col, orientation); + } + } + + return null; + } + + public ForgeDirection getSideFromVector3(Vector3 vector) { + if (Math.abs(vector.x) > Math.abs(vector.y) + && Math.abs(vector.x) > Math.abs(vector.z)) { + if ((vector.x < 0.5 && vector.x > 0) || vector.x == -0.5) { + return ForgeDirection.EAST; + } + + return ForgeDirection.WEST; + } else if(Math.abs(vector.y) > Math.abs(vector.x) && Math.abs(vector.y) > Math.abs(vector.z)) { - if((vector.y < 0.5 && vector.y > 0) || vector.y == -0.5) - { - return ForgeDirection.UP; - } - - return ForgeDirection.DOWN; - } + if ((vector.y < 0.5 && vector.y > 0) || vector.y == -0.5) { + return ForgeDirection.UP; + } + + return ForgeDirection.DOWN; + } else if(Math.abs(vector.z) > Math.abs(vector.x) && Math.abs(vector.z) > Math.abs(vector.y)) { - if((vector.z < 0.5 && vector.z > 0) || vector.z == -0.5) - { - return ForgeDirection.SOUTH; - } - - return ForgeDirection.NORTH; - } - - return null; - } + if ((vector.z < 0.5 && vector.z > 0) || vector.z == -0.5) { + return ForgeDirection.SOUTH; + } - @Override - public void getSubItems(Item item, CreativeTabs tab, List listToAddTo) - { - for(EnumColor color : EnumColor.DYES) - { - listToAddTo.add(new ItemStack(item, 1, color.getMetaValue())); - } - } + return ForgeDirection.NORTH; + } - @Override - public String getItemStackDisplayName(ItemStack stack) - { - EnumColor colour = EnumColor.DYES[stack.getItemDamage()]; - String colourName; + return null; + } - if(StatCollector.canTranslate(getUnlocalizedName(stack) + "." + colour.dyeName)) - { + @Override + public void getSubItems(Item item, CreativeTabs tab, List listToAddTo) { + for (EnumColor color : EnumColor.DYES) { + listToAddTo.add(new ItemStack(item, 1, color.getMetaValue())); + } + } + + @Override + public String getItemStackDisplayName(ItemStack stack) { + EnumColor colour = EnumColor.DYES[stack.getItemDamage()]; + String colourName; + + if (StatCollector.canTranslate( + getUnlocalizedName(stack) + "." + colour.dyeName + )) { return LangUtils.localize(getUnlocalizedName(stack) + "." + colour.dyeName); } - - if(colour == EnumColor.BLACK) - { - colourName = EnumColor.DARK_GREY + colour.getDyeName(); - } - else { - colourName = colour.getDyedName(); - } - return colourName + " " + super.getItemStackDisplayName(stack); - } + if (colour == EnumColor.BLACK) { + colourName = EnumColor.DARK_GREY + colour.getDyeName(); + } else { + colourName = colour.getDyedName(); + } - @Override - public boolean shouldRotateAroundWhenRendering() - { - return true; - } + return colourName + " " + super.getItemStackDisplayName(stack); + } + + @Override + public boolean shouldRotateAroundWhenRendering() { + return true; + } } diff --git a/src/main/java/mekanism/common/multipart/ItemPartTransmitter.java b/src/main/java/mekanism/common/multipart/ItemPartTransmitter.java index 42edc32c8..5a24ad6e2 100644 --- a/src/main/java/mekanism/common/multipart/ItemPartTransmitter.java +++ b/src/main/java/mekanism/common/multipart/ItemPartTransmitter.java @@ -3,6 +3,12 @@ package mekanism.common.multipart; import java.util.ArrayList; import java.util.List; +import codechicken.lib.vec.BlockCoord; +import codechicken.lib.vec.Vector3; +import codechicken.multipart.JItemMultiPart; +import codechicken.multipart.TMultiPart; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.transmitters.DynamicNetwork; @@ -24,163 +30,255 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import codechicken.lib.vec.BlockCoord; -import codechicken.lib.vec.Vector3; -import codechicken.multipart.JItemMultiPart; -import codechicken.multipart.TMultiPart; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class ItemPartTransmitter extends JItemMultiPart -{ - public ItemPartTransmitter() - { - super(); - setHasSubtypes(true); - setCreativeTab(Mekanism.tabMekanism); - } +public class ItemPartTransmitter extends JItemMultiPart { + public ItemPartTransmitter() { + super(); + setHasSubtypes(true); + setCreativeTab(Mekanism.tabMekanism); + } - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IIconRegister register) {} + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IIconRegister register) {} - @Override - public TMultiPart newPart(ItemStack stack, EntityPlayer player, World world, BlockCoord coord, int face, Vector3 vecHit) - { - TransmitterType type = TransmitterType.values()[stack.getItemDamage()]; + @Override + public TMultiPart newPart( + ItemStack stack, + EntityPlayer player, + World world, + BlockCoord coord, + int face, + Vector3 vecHit + ) { + TransmitterType type = TransmitterType.values()[stack.getItemDamage()]; - if(type.getTransmission() != TransmissionType.ITEM) - { - Coord4D obj = new Coord4D(coord.x, coord.y, coord.z, world.provider.dimensionId); + if (type.getTransmission() != TransmissionType.ITEM) { + Coord4D obj + = new Coord4D(coord.x, coord.y, coord.z, world.provider.dimensionId); - List networks = new ArrayList<>(); + List networks = new ArrayList<>(); - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - TileEntity tile = obj.getFromSide(side).getTileEntity(world); + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + TileEntity tile = obj.getFromSide(side).getTileEntity(world); - if(tile instanceof ITransmitterTile && TransmissionType.checkTransmissionType(((ITransmitterTile)tile).getTransmitter(), type.getTransmission())) - { - networks.add(((ITransmitterTile)tile).getTransmitter().getTransmitterNetwork()); - } - } - } + if (tile instanceof ITransmitterTile + && TransmissionType.checkTransmissionType( + ((ITransmitterTile) tile).getTransmitter(), type.getTransmission() + )) { + networks.add( + ((ITransmitterTile) tile).getTransmitter().getTransmitterNetwork() + ); + } + } + } - return PartTransmitter.getPartType(TransmitterType.values()[getDamage(stack)]); - } + return PartTransmitter.getPartType(TransmitterType.values()[getDamage(stack)]); + } - @Override - public int getMetadata(int damage) - { - return damage; - } + @Override + public int getMetadata(int damage) { + return damage; + } - @Override - @SideOnly(Side.CLIENT) - public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) - { - if(!MekKeyHandler.getIsKeyPressed(MekanismKeyHandler.sneakKey)) - { - TransmissionType transmission = TransmitterType.values()[itemstack.getItemDamage()].getTransmission(); - BaseTier tier = TransmitterType.values()[itemstack.getItemDamage()].getTier(); - - if(transmission == TransmissionType.ENERGY) - { - list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.capacity") + ": " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(Tier.CableTier.values()[itemstack.getItemDamage()].cableCapacity) + "/t"); - } - else if(transmission == TransmissionType.FLUID) - { - list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.capacity") + ": " + EnumColor.GREY + Tier.PipeTier.get(tier).pipeCapacity + "mB/t"); - list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.pumpRate") + ": " + EnumColor.GREY + Tier.PipeTier.get(tier).pipePullAmount + "mB/t"); - } - else if(transmission == TransmissionType.GAS) - { - list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.capacity") + ": " + EnumColor.GREY + Tier.TubeTier.get(tier).tubeCapacity + "mB/t"); - list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.pumpRate") + ": " + EnumColor.GREY + Tier.TubeTier.get(tier).tubePullAmount + "mB/t"); - } - else if(transmission == TransmissionType.ITEM) - { - list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.speed") + ": " + EnumColor.GREY + (Tier.TransporterTier.get(tier).speed/(100/20)) + " m/s"); - list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.pumpRate") + ": " + EnumColor.GREY + Tier.TransporterTier.get(tier).pullAmount*2 + "/s"); - } + @Override + @SideOnly(Side.CLIENT) + public void addInformation( + ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag + ) { + if (!MekKeyHandler.getIsKeyPressed(MekanismKeyHandler.sneakKey)) { + TransmissionType transmission + = TransmitterType.values()[itemstack.getItemDamage()].getTransmission(); + BaseTier tier = TransmitterType.values()[itemstack.getItemDamage()].getTier(); - list.add(LangUtils.localize("tooltip.hold") + " " + EnumColor.AQUA + GameSettings.getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode()) + EnumColor.GREY + " " + LangUtils.localize("tooltip.forDetails")); - } - else { - switch(itemstack.getItemDamage()) - { - case 0: case 1: case 2: case 3: - { - list.add(EnumColor.DARK_GREY + LangUtils.localize("tooltip.capableTrans") + ":"); - list.add("- " + EnumColor.PURPLE + "RF " + EnumColor.GREY + "(ThermalExpansion)"); - list.add("- " + EnumColor.PURPLE + "EU " + EnumColor.GREY + "(IndustrialCraft)"); - list.add("- " + EnumColor.PURPLE + "Joules " + EnumColor.GREY + "(Mekanism)"); - break; - } - case 4: case 5: case 6: case 7: - { - list.add(EnumColor.DARK_GREY + LangUtils.localize("tooltip.capableTrans") + ":"); - list.add("- " + EnumColor.PURPLE + LangUtils.localize("tooltip.fluids") + " " + EnumColor.GREY + "(MinecraftForge)"); - break; - } - case 8: case 9: case 10: case 11: - { - list.add(EnumColor.DARK_GREY + LangUtils.localize("tooltip.capableTrans") + ":"); - list.add("- " + EnumColor.PURPLE + LangUtils.localize("tooltip.gasses") + " (Mekanism)"); - break; - } - case 12: case 13: case 14: case 15: - { - list.add(EnumColor.DARK_GREY + LangUtils.localize("tooltip.capableTrans") + ":"); - list.add("- " + EnumColor.PURPLE + LangUtils.localize("tooltip.items") + " (" + LangUtils.localize("tooltip.universal") + ")"); - list.add("- " + EnumColor.PURPLE + LangUtils.localize("tooltip.blocks") + " (" + LangUtils.localize("tooltip.universal") + ")"); - break; - } - case 16: - { - list.add(EnumColor.DARK_GREY + LangUtils.localize("tooltip.capableTrans") + ":"); - list.add("- " + EnumColor.PURPLE + LangUtils.localize("tooltip.items") + " (" + LangUtils.localize("tooltip.universal") + ")"); - list.add("- " + EnumColor.PURPLE + LangUtils.localize("tooltip.blocks") + " (" + LangUtils.localize("tooltip.universal") + ")"); - list.add("- " + EnumColor.DARK_RED + LangUtils.localize("tooltip.restrictiveDesc")); - break; - } - case 17: - { - list.add(EnumColor.DARK_GREY + LangUtils.localize("tooltip.capableTrans") + ":"); - list.add("- " + EnumColor.PURPLE + LangUtils.localize("tooltip.items") + " (" + LangUtils.localize("tooltip.universal") + ")"); - list.add("- " + EnumColor.PURPLE + LangUtils.localize("tooltip.blocks") + " (" + LangUtils.localize("tooltip.universal") + ")"); - list.add("- " + EnumColor.DARK_RED + LangUtils.localize("tooltip.diversionDesc")); - break; - } - case 18: case 19: case 20: case 21: - { - list.add(EnumColor.DARK_GREY + LangUtils.localize("tooltip.capableTrans") + ":"); - list.add("- " + EnumColor.PURPLE + LangUtils.localize("tooltip.heat") + " (Mekanism)"); - break; - } - } - } - } + if (transmission == TransmissionType.ENERGY) { + list.add( + EnumColor.INDIGO + LangUtils.localize("tooltip.capacity") + ": " + + EnumColor.GREY + + MekanismUtils.getEnergyDisplay( + Tier.CableTier.values()[itemstack.getItemDamage()].cableCapacity + ) + + "/t" + ); + } else if (transmission == TransmissionType.FLUID) { + list.add( + EnumColor.INDIGO + LangUtils.localize("tooltip.capacity") + ": " + + EnumColor.GREY + Tier.PipeTier.get(tier).pipeCapacity + "mB/t" + ); + list.add( + EnumColor.INDIGO + LangUtils.localize("tooltip.pumpRate") + ": " + + EnumColor.GREY + Tier.PipeTier.get(tier).pipePullAmount + "mB/t" + ); + } else if (transmission == TransmissionType.GAS) { + list.add( + EnumColor.INDIGO + LangUtils.localize("tooltip.capacity") + ": " + + EnumColor.GREY + Tier.TubeTier.get(tier).tubeCapacity + "mB/t" + ); + list.add( + EnumColor.INDIGO + LangUtils.localize("tooltip.pumpRate") + ": " + + EnumColor.GREY + Tier.TubeTier.get(tier).tubePullAmount + "mB/t" + ); + } else if (transmission == TransmissionType.ITEM) { + list.add( + EnumColor.INDIGO + LangUtils.localize("tooltip.speed") + ": " + + EnumColor.GREY + (Tier.TransporterTier.get(tier).speed / (100 / 20)) + + " m/s" + ); + list.add( + EnumColor.INDIGO + LangUtils.localize("tooltip.pumpRate") + ": " + + EnumColor.GREY + Tier.TransporterTier.get(tier).pullAmount * 2 + + "/s" + ); + } - @Override - public void getSubItems(Item item, CreativeTabs tab, List listToAddTo) - { - for(TransmitterType type : TransmitterType.values()) - { - listToAddTo.add(new ItemStack(item, 1, type.ordinal())); - } - } + list.add( + LangUtils.localize("tooltip.hold") + " " + EnumColor.AQUA + + GameSettings.getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode( + )) + + EnumColor.GREY + " " + LangUtils.localize("tooltip.forDetails") + ); + } else { + switch (itemstack.getItemDamage()) { + case 0: + case 1: + case 2: + case 3: { + list.add( + EnumColor.DARK_GREY + LangUtils.localize("tooltip.capableTrans") + + ":" + ); + list.add( + "- " + EnumColor.PURPLE + "RF " + EnumColor.GREY + + "(ThermalExpansion)" + ); + list.add( + "- " + EnumColor.PURPLE + "EU " + EnumColor.GREY + + "(IndustrialCraft)" + ); + list.add( + "- " + EnumColor.PURPLE + "Joules " + EnumColor.GREY + + "(Mekanism)" + ); + break; + } + case 4: + case 5: + case 6: + case 7: { + list.add( + EnumColor.DARK_GREY + LangUtils.localize("tooltip.capableTrans") + + ":" + ); + list.add( + "- " + EnumColor.PURPLE + LangUtils.localize("tooltip.fluids") + + " " + EnumColor.GREY + "(MinecraftForge)" + ); + break; + } + case 8: + case 9: + case 10: + case 11: { + list.add( + EnumColor.DARK_GREY + LangUtils.localize("tooltip.capableTrans") + + ":" + ); + list.add( + "- " + EnumColor.PURPLE + LangUtils.localize("tooltip.gasses") + + " (Mekanism)" + ); + break; + } + case 12: + case 13: + case 14: + case 15: { + list.add( + EnumColor.DARK_GREY + LangUtils.localize("tooltip.capableTrans") + + ":" + ); + list.add( + "- " + EnumColor.PURPLE + LangUtils.localize("tooltip.items") + + " (" + LangUtils.localize("tooltip.universal") + ")" + ); + list.add( + "- " + EnumColor.PURPLE + LangUtils.localize("tooltip.blocks") + + " (" + LangUtils.localize("tooltip.universal") + ")" + ); + break; + } + case 16: { + list.add( + EnumColor.DARK_GREY + LangUtils.localize("tooltip.capableTrans") + + ":" + ); + list.add( + "- " + EnumColor.PURPLE + LangUtils.localize("tooltip.items") + + " (" + LangUtils.localize("tooltip.universal") + ")" + ); + list.add( + "- " + EnumColor.PURPLE + LangUtils.localize("tooltip.blocks") + + " (" + LangUtils.localize("tooltip.universal") + ")" + ); + list.add( + "- " + EnumColor.DARK_RED + + LangUtils.localize("tooltip.restrictiveDesc") + ); + break; + } + case 17: { + list.add( + EnumColor.DARK_GREY + LangUtils.localize("tooltip.capableTrans") + + ":" + ); + list.add( + "- " + EnumColor.PURPLE + LangUtils.localize("tooltip.items") + + " (" + LangUtils.localize("tooltip.universal") + ")" + ); + list.add( + "- " + EnumColor.PURPLE + LangUtils.localize("tooltip.blocks") + + " (" + LangUtils.localize("tooltip.universal") + ")" + ); + list.add( + "- " + EnumColor.DARK_RED + + LangUtils.localize("tooltip.diversionDesc") + ); + break; + } + case 18: + case 19: + case 20: + case 21: { + list.add( + EnumColor.DARK_GREY + LangUtils.localize("tooltip.capableTrans") + + ":" + ); + list.add( + "- " + EnumColor.PURPLE + LangUtils.localize("tooltip.heat") + + " (Mekanism)" + ); + break; + } + } + } + } - @Override - @SideOnly(Side.CLIENT) - public int getSpriteNumber() - { - return 0; - } + @Override + public void getSubItems(Item item, CreativeTabs tab, List listToAddTo) { + for (TransmitterType type : TransmitterType.values()) { + listToAddTo.add(new ItemStack(item, 1, type.ordinal())); + } + } - @Override - public String getUnlocalizedName(ItemStack stack) - { - return getUnlocalizedName() + "." + TransmitterType.values()[stack.getItemDamage()].getName(); - } + @Override + @SideOnly(Side.CLIENT) + public int getSpriteNumber() { + return 0; + } + + @Override + public String getUnlocalizedName(ItemStack stack) { + return getUnlocalizedName() + "." + + TransmitterType.values()[stack.getItemDamage()].getName(); + } } diff --git a/src/main/java/mekanism/common/multipart/MultipartMekanism.java b/src/main/java/mekanism/common/multipart/MultipartMekanism.java index 163c151df..f9e354c08 100644 --- a/src/main/java/mekanism/common/multipart/MultipartMekanism.java +++ b/src/main/java/mekanism/common/multipart/MultipartMekanism.java @@ -2,10 +2,7 @@ package mekanism.common.multipart; import static mekanism.common.block.BlockMachine.MachineBlock.MACHINE_BLOCK_1; import static mekanism.common.block.BlockMachine.MachineBlock.MACHINE_BLOCK_2; -import mekanism.common.MekanismBlocks; -import mekanism.common.Tier; -import mekanism.common.block.BlockMachine.MachineType; -import net.minecraft.item.ItemStack; + import codechicken.microblock.BlockMicroMaterial; import codechicken.microblock.MicroMaterialRegistry; import codechicken.multipart.MultiPartRegistry; @@ -13,176 +10,182 @@ import codechicken.multipart.MultiPartRegistry.IPartFactory; import codechicken.multipart.MultipartGenerator; import codechicken.multipart.TMultiPart; import cpw.mods.fml.common.event.FMLInterModComms; +import mekanism.common.MekanismBlocks; +import mekanism.common.Tier; +import mekanism.common.block.BlockMachine.MachineType; +import net.minecraft.item.ItemStack; -public class MultipartMekanism implements IPartFactory -{ - public MultipartMekanism() - { - init(); - } +public class MultipartMekanism implements IPartFactory { + public MultipartMekanism() { + init(); + } - public void init() - { - MultiPartRegistry.registerParts(this, new String[] {"mekanism:universal_cable_basic", - "mekanism:universal_cable_advanced", "mekanism:universal_cable_elite", - "mekanism:universal_cable_ultimate", "mekanism:mechanical_pipe", - "mekanism:mechanical_pipe_basic", "mekanism:mechanical_pipe_advanced", - "mekanism:mechanical_pipe_elite", "mekanism:mechanical_pipe_ultimate", - "mekanism:pressurized_tube_basic", "mekanism:pressurized_tube_advanced", - "mekanism:pressurized_tube_elite", "mekanism:pressurized_tube_ultimate", - "mekanism:logistical_transporter_basic", "mekanism:logistical_transporter_advanced", - "mekanism:logistical_transporter_elite", "mekanism:logistical_transporter_ultimate", - "mekanism:restrictive_transporter", "mekanism:diversion_transporter", - "mekanism:thermodynamic_conductor_basic", "mekanism:thermodynamic_conductor_advanced", - "mekanism:thermodynamic_conductor_elite", "mekanism:thermodynamic_conductor_ultimate", - "mekanism:glow_panel"}); + public void init() { + MultiPartRegistry.registerParts( + this, + new String[] { "mekanism:universal_cable_basic", + "mekanism:universal_cable_advanced", + "mekanism:universal_cable_elite", + "mekanism:universal_cable_ultimate", + "mekanism:mechanical_pipe", + "mekanism:mechanical_pipe_basic", + "mekanism:mechanical_pipe_advanced", + "mekanism:mechanical_pipe_elite", + "mekanism:mechanical_pipe_ultimate", + "mekanism:pressurized_tube_basic", + "mekanism:pressurized_tube_advanced", + "mekanism:pressurized_tube_elite", + "mekanism:pressurized_tube_ultimate", + "mekanism:logistical_transporter_basic", + "mekanism:logistical_transporter_advanced", + "mekanism:logistical_transporter_elite", + "mekanism:logistical_transporter_ultimate", + "mekanism:restrictive_transporter", + "mekanism:diversion_transporter", + "mekanism:thermodynamic_conductor_basic", + "mekanism:thermodynamic_conductor_advanced", + "mekanism:thermodynamic_conductor_elite", + "mekanism:thermodynamic_conductor_ultimate", + "mekanism:glow_panel" } + ); - MultipartGenerator.registerPassThroughInterface("mekanism.api.IConfigurable"); - MultipartGenerator.registerPassThroughInterface("mekanism.api.energy.IStrictEnergyAcceptor"); - MultipartGenerator.registerPassThroughInterface("mekanism.api.gas.IGasHandler"); - MultipartGenerator.registerPassThroughInterface("mekanism.api.IHeatTransfer"); - MultipartGenerator.registerPassThroughInterface("mekanism.api.transmitters.IBlockableConnection"); - MultipartGenerator.registerPassThroughInterface("mekanism.api.transmitters.ITransmitterTile"); - MultipartGenerator.registerPassThroughInterface("mekanism.api.IAlloyInteraction"); - MultipartGenerator.registerPassThroughInterface("mekanism.common.base.ITransporterTile"); - MultipartGenerator.registerPassThroughInterface("mekanism.common.base.ILogisticalTransporter"); - MultipartGenerator.registerPassThroughInterface("mekanism.common.base.ITileNetwork"); - MultipartGenerator.registerPassThroughInterface("cofh.api.energy.IEnergyHandler"); + MultipartGenerator.registerPassThroughInterface("mekanism.api.IConfigurable"); + MultipartGenerator.registerPassThroughInterface( + "mekanism.api.energy.IStrictEnergyAcceptor" + ); + MultipartGenerator.registerPassThroughInterface("mekanism.api.gas.IGasHandler"); + MultipartGenerator.registerPassThroughInterface("mekanism.api.IHeatTransfer"); + MultipartGenerator.registerPassThroughInterface( + "mekanism.api.transmitters.IBlockableConnection" + ); + MultipartGenerator.registerPassThroughInterface( + "mekanism.api.transmitters.ITransmitterTile" + ); + MultipartGenerator.registerPassThroughInterface("mekanism.api.IAlloyInteraction"); + MultipartGenerator.registerPassThroughInterface( + "mekanism.common.base.ITransporterTile" + ); + MultipartGenerator.registerPassThroughInterface( + "mekanism.common.base.ILogisticalTransporter" + ); + MultipartGenerator.registerPassThroughInterface( + "mekanism.common.base.ITileNetwork" + ); + MultipartGenerator.registerPassThroughInterface("cofh.api.energy.IEnergyHandler"); - registerMicroMaterials(); - } + registerMicroMaterials(); + } - @Override - public TMultiPart createPart(String name, boolean client) - { - if(name.equals("mekanism:universal_cable")) - { - return new PartUniversalCable(Tier.CableTier.BASIC); - } - else if(name.equals("mekanism:universal_cable_basic")) - { - return new PartUniversalCable(Tier.CableTier.BASIC); - } - else if(name.equals("mekanism:universal_cable_advanced")) - { - return new PartUniversalCable(Tier.CableTier.ADVANCED); - } - else if(name.equals("mekanism:universal_cable_elite")) - { - return new PartUniversalCable(Tier.CableTier.ELITE); - } - else if(name.equals("mekanism:universal_cable_ultimate")) - { - return new PartUniversalCable(Tier.CableTier.ULTIMATE); - } - else if(name.equals("mekanism:mechanical_pipe")) - { - return new PartMechanicalPipe(Tier.PipeTier.BASIC); - } - else if(name.equals("mekanism:mechanical_pipe_basic")) - { - return new PartMechanicalPipe(Tier.PipeTier.BASIC); - } - else if(name.equals("mekanism:mechanical_pipe_advanced")) - { - return new PartMechanicalPipe(Tier.PipeTier.ADVANCED); - } - else if(name.equals("mekanism:mechanical_pipe_elite")) - { - return new PartMechanicalPipe(Tier.PipeTier.ELITE); - } - else if(name.equals("mekanism:mechanical_pipe_ultimate")) - { - return new PartMechanicalPipe(Tier.PipeTier.ULTIMATE); - } - else if(name.equals("mekanism:pressurized_tube_basic") || name.equals("mekanism:pressurized_tube")) - { - return new PartPressurizedTube(Tier.TubeTier.BASIC); - } - else if(name.equals("mekanism:pressurized_tube_advanced")) - { - return new PartPressurizedTube(Tier.TubeTier.ADVANCED); - } - else if(name.equals("mekanism:pressurized_tube_elite")) - { - return new PartPressurizedTube(Tier.TubeTier.ELITE); - } - else if(name.equals("mekanism:pressurized_tube_ultimate")) - { - return new PartPressurizedTube(Tier.TubeTier.ULTIMATE); - } - else if(name.equals("mekanism:logistical_transporter_basic") || name.equals("mekanism:logistical_transporter")) - { - return new PartLogisticalTransporter(Tier.TransporterTier.BASIC); - } - else if(name.equals("mekanism:logistical_transporter_advanced")) - { - return new PartLogisticalTransporter(Tier.TransporterTier.ADVANCED); - } - else if(name.equals("mekanism:logistical_transporter_elite")) - { - return new PartLogisticalTransporter(Tier.TransporterTier.ELITE); - } - else if(name.equals("mekanism:logistical_transporter_ultimate")) - { - return new PartLogisticalTransporter(Tier.TransporterTier.ULTIMATE); - } - else if(name.equals("mekanism:restrictive_transporter")) - { - return new PartRestrictiveTransporter(); - } - else if(name.equals("mekanism:diversion_transporter")) - { - return new PartDiversionTransporter(); - } - else if(name.equals("mekanism:thermodynamic_conductor_basic")) - { - return new PartThermodynamicConductor(Tier.ConductorTier.BASIC); - } - else if(name.equals("mekanism:thermodynamic_conductor_advanced")) - { - return new PartThermodynamicConductor(Tier.ConductorTier.ADVANCED); - } - else if(name.equals("mekanism:thermodynamic_conductor_elite")) - { - return new PartThermodynamicConductor(Tier.ConductorTier.ELITE); - } - else if(name.equals("mekanism:thermodynamic_conductor_ultimate")) - { - return new PartThermodynamicConductor(Tier.ConductorTier.ULTIMATE); - } - else if(name.equals("mekanism:glow_panel")) - { - return new PartGlowPanel(); - } + @Override + public TMultiPart createPart(String name, boolean client) { + if (name.equals("mekanism:universal_cable")) { + return new PartUniversalCable(Tier.CableTier.BASIC); + } else if (name.equals("mekanism:universal_cable_basic")) { + return new PartUniversalCable(Tier.CableTier.BASIC); + } else if (name.equals("mekanism:universal_cable_advanced")) { + return new PartUniversalCable(Tier.CableTier.ADVANCED); + } else if (name.equals("mekanism:universal_cable_elite")) { + return new PartUniversalCable(Tier.CableTier.ELITE); + } else if (name.equals("mekanism:universal_cable_ultimate")) { + return new PartUniversalCable(Tier.CableTier.ULTIMATE); + } else if (name.equals("mekanism:mechanical_pipe")) { + return new PartMechanicalPipe(Tier.PipeTier.BASIC); + } else if (name.equals("mekanism:mechanical_pipe_basic")) { + return new PartMechanicalPipe(Tier.PipeTier.BASIC); + } else if (name.equals("mekanism:mechanical_pipe_advanced")) { + return new PartMechanicalPipe(Tier.PipeTier.ADVANCED); + } else if (name.equals("mekanism:mechanical_pipe_elite")) { + return new PartMechanicalPipe(Tier.PipeTier.ELITE); + } else if (name.equals("mekanism:mechanical_pipe_ultimate")) { + return new PartMechanicalPipe(Tier.PipeTier.ULTIMATE); + } else if (name.equals("mekanism:pressurized_tube_basic") || name.equals("mekanism:pressurized_tube")) { + return new PartPressurizedTube(Tier.TubeTier.BASIC); + } else if (name.equals("mekanism:pressurized_tube_advanced")) { + return new PartPressurizedTube(Tier.TubeTier.ADVANCED); + } else if (name.equals("mekanism:pressurized_tube_elite")) { + return new PartPressurizedTube(Tier.TubeTier.ELITE); + } else if (name.equals("mekanism:pressurized_tube_ultimate")) { + return new PartPressurizedTube(Tier.TubeTier.ULTIMATE); + } else if (name.equals("mekanism:logistical_transporter_basic") || name.equals("mekanism:logistical_transporter")) { + return new PartLogisticalTransporter(Tier.TransporterTier.BASIC); + } else if (name.equals("mekanism:logistical_transporter_advanced")) { + return new PartLogisticalTransporter(Tier.TransporterTier.ADVANCED); + } else if (name.equals("mekanism:logistical_transporter_elite")) { + return new PartLogisticalTransporter(Tier.TransporterTier.ELITE); + } else if (name.equals("mekanism:logistical_transporter_ultimate")) { + return new PartLogisticalTransporter(Tier.TransporterTier.ULTIMATE); + } else if (name.equals("mekanism:restrictive_transporter")) { + return new PartRestrictiveTransporter(); + } else if (name.equals("mekanism:diversion_transporter")) { + return new PartDiversionTransporter(); + } else if (name.equals("mekanism:thermodynamic_conductor_basic")) { + return new PartThermodynamicConductor(Tier.ConductorTier.BASIC); + } else if (name.equals("mekanism:thermodynamic_conductor_advanced")) { + return new PartThermodynamicConductor(Tier.ConductorTier.ADVANCED); + } else if (name.equals("mekanism:thermodynamic_conductor_elite")) { + return new PartThermodynamicConductor(Tier.ConductorTier.ELITE); + } else if (name.equals("mekanism:thermodynamic_conductor_ultimate")) { + return new PartThermodynamicConductor(Tier.ConductorTier.ULTIMATE); + } else if (name.equals("mekanism:glow_panel")) { + return new PartGlowPanel(); + } - return null; - } + return null; + } - public void registerMicroMaterials() - { - for(int i = 0; i < 16; i++) - { - MicroMaterialRegistry.registerMaterial(new PlasticMicroMaterial(MekanismBlocks.PlasticBlock, i), BlockMicroMaterial.materialKey(MekanismBlocks.PlasticBlock, i)); - MicroMaterialRegistry.registerMaterial(new PlasticMicroMaterial(MekanismBlocks.GlowPlasticBlock, i), BlockMicroMaterial.materialKey(MekanismBlocks.GlowPlasticBlock, i)); - MicroMaterialRegistry.registerMaterial(new PlasticMicroMaterial(MekanismBlocks.SlickPlasticBlock, i), BlockMicroMaterial.materialKey(MekanismBlocks.SlickPlasticBlock, i)); - MicroMaterialRegistry.registerMaterial(new PlasticMicroMaterial(MekanismBlocks.ReinforcedPlasticBlock, i), BlockMicroMaterial.materialKey(MekanismBlocks.ReinforcedPlasticBlock, i)); - MicroMaterialRegistry.registerMaterial(new PlasticMicroMaterial(MekanismBlocks.RoadPlasticBlock, i), BlockMicroMaterial.materialKey(MekanismBlocks.RoadPlasticBlock, i)); + public void registerMicroMaterials() { + for (int i = 0; i < 16; i++) { + MicroMaterialRegistry.registerMaterial( + new PlasticMicroMaterial(MekanismBlocks.PlasticBlock, i), + BlockMicroMaterial.materialKey(MekanismBlocks.PlasticBlock, i) + ); + MicroMaterialRegistry.registerMaterial( + new PlasticMicroMaterial(MekanismBlocks.GlowPlasticBlock, i), + BlockMicroMaterial.materialKey(MekanismBlocks.GlowPlasticBlock, i) + ); + MicroMaterialRegistry.registerMaterial( + new PlasticMicroMaterial(MekanismBlocks.SlickPlasticBlock, i), + BlockMicroMaterial.materialKey(MekanismBlocks.SlickPlasticBlock, i) + ); + MicroMaterialRegistry.registerMaterial( + new PlasticMicroMaterial(MekanismBlocks.ReinforcedPlasticBlock, i), + BlockMicroMaterial.materialKey(MekanismBlocks.ReinforcedPlasticBlock, i) + ); + MicroMaterialRegistry.registerMaterial( + new PlasticMicroMaterial(MekanismBlocks.RoadPlasticBlock, i), + BlockMicroMaterial.materialKey(MekanismBlocks.RoadPlasticBlock, i) + ); - FMLInterModComms.sendMessage("ForgeMicroblock", "microMaterial", new ItemStack(MekanismBlocks.BasicBlock, 1, i)); - - if(!MachineType.get(MACHINE_BLOCK_1, i).hasModel) - { - FMLInterModComms.sendMessage("ForgeMicroblock", "microMaterial", new ItemStack(MekanismBlocks.MachineBlock, 1, i)); - } - - if(!MachineType.get(MACHINE_BLOCK_2, i).hasModel) - { - FMLInterModComms.sendMessage("ForgeMicroblock", "microMaterial", new ItemStack(MekanismBlocks.MachineBlock2, 1, i)); - } - } - - FMLInterModComms.sendMessage("ForgeMicroblock", "microMaterial", new ItemStack(MekanismBlocks.BasicBlock2, 1, 0)); - FMLInterModComms.sendMessage("ForgeMicroblock", "microMaterial", new ItemStack(MekanismBlocks.CardboardBox)); - } + FMLInterModComms.sendMessage( + "ForgeMicroblock", + "microMaterial", + new ItemStack(MekanismBlocks.BasicBlock, 1, i) + ); + + if (!MachineType.get(MACHINE_BLOCK_1, i).hasModel) { + FMLInterModComms.sendMessage( + "ForgeMicroblock", + "microMaterial", + new ItemStack(MekanismBlocks.MachineBlock, 1, i) + ); + } + + if (!MachineType.get(MACHINE_BLOCK_2, i).hasModel) { + FMLInterModComms.sendMessage( + "ForgeMicroblock", + "microMaterial", + new ItemStack(MekanismBlocks.MachineBlock2, 1, i) + ); + } + } + + FMLInterModComms.sendMessage( + "ForgeMicroblock", + "microMaterial", + new ItemStack(MekanismBlocks.BasicBlock2, 1, 0) + ); + FMLInterModComms.sendMessage( + "ForgeMicroblock", "microMaterial", new ItemStack(MekanismBlocks.CardboardBox) + ); + } } diff --git a/src/main/java/mekanism/common/multipart/MultipartTransmitter.java b/src/main/java/mekanism/common/multipart/MultipartTransmitter.java index 970043090..390adaae8 100644 --- a/src/main/java/mekanism/common/multipart/MultipartTransmitter.java +++ b/src/main/java/mekanism/common/multipart/MultipartTransmitter.java @@ -12,131 +12,120 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -public class MultipartTransmitter> extends Transmitter -{ - public PartTransmitter containingPart; +public class MultipartTransmitter> + extends Transmitter { + public PartTransmitter containingPart; - public MultipartTransmitter(PartTransmitter multiPart) - { - setPart(multiPart); - } - - @Override - public int getCapacity() - { - return getPart().getCapacity(); - } - - @Override - public World world() - { - return getPart().world(); - } - - @Override - public Coord4D coord() - { - return new Coord4D(getPart().x(), getPart().y(), getPart().z(), getPart().world().provider.dimensionId); - } - - @Override - public Coord4D getAdjacentConnectableTransmitterCoord(ForgeDirection side) - { - Coord4D sideCoord = coord().getFromSide(side); - - TileEntity potentialTransmitterTile = sideCoord.getTileEntity(world()); - - if(!containingPart.canConnectMutual(side)) - { - return null; - } - - if(potentialTransmitterTile instanceof ITransmitterTile) - { - IGridTransmitter transmitter = ((ITransmitterTile)potentialTransmitterTile).getTransmitter(); - - if(TransmissionType.checkTransmissionType(transmitter, getTransmissionType()) && containingPart.isValidTransmitter(potentialTransmitterTile)) - { - return sideCoord; - } - } - - return null; - } - - @Override - public A getAcceptor(ForgeDirection side) - { - return getPart().getCachedAcceptor(side); - } - - @Override - public boolean isValid() - { - return getPart().tile() != null && !getPart().tile().isInvalid() && !getPart().unloaded && coord().exists(world()); - } - - @Override - public N createEmptyNetwork() - { - return getPart().createNewNetwork(); - } - - @Override - public N getExternalNetwork(Coord4D from) - { - TileEntity tile = from.getTileEntity(world()); - - if(tile instanceof ITransmitterTile) - { - IGridTransmitter transmitter = ((ITransmitterTile)tile).getTransmitter(); - - if(TransmissionType.checkTransmissionType(transmitter, getTransmissionType())); - { - return ((IGridTransmitter)transmitter).getTransmitterNetwork(); - } - } - - return null; - } - - @Override - public void takeShare() - { - containingPart.takeShare(); - } + public MultipartTransmitter(PartTransmitter multiPart) { + setPart(multiPart); + } @Override - public void updateShare() - { + public int getCapacity() { + return getPart().getCapacity(); + } + + @Override + public World world() { + return getPart().world(); + } + + @Override + public Coord4D coord() { + return new Coord4D( + getPart().x(), + getPart().y(), + getPart().z(), + getPart().world().provider.dimensionId + ); + } + + @Override + public Coord4D getAdjacentConnectableTransmitterCoord(ForgeDirection side) { + Coord4D sideCoord = coord().getFromSide(side); + + TileEntity potentialTransmitterTile = sideCoord.getTileEntity(world()); + + if (!containingPart.canConnectMutual(side)) { + return null; + } + + if (potentialTransmitterTile instanceof ITransmitterTile) { + IGridTransmitter transmitter + = ((ITransmitterTile) potentialTransmitterTile).getTransmitter(); + + if (TransmissionType.checkTransmissionType(transmitter, getTransmissionType()) + && containingPart.isValidTransmitter(potentialTransmitterTile)) { + return sideCoord; + } + } + + return null; + } + + @Override + public A getAcceptor(ForgeDirection side) { + return getPart().getCachedAcceptor(side); + } + + @Override + public boolean isValid() { + return getPart().tile() != null && !getPart().tile().isInvalid() + && !getPart().unloaded && coord().exists(world()); + } + + @Override + public N createEmptyNetwork() { + return getPart().createNewNetwork(); + } + + @Override + public N getExternalNetwork(Coord4D from) { + TileEntity tile = from.getTileEntity(world()); + + if (tile instanceof ITransmitterTile) { + IGridTransmitter transmitter = ((ITransmitterTile) tile).getTransmitter(); + + if (TransmissionType.checkTransmissionType( + transmitter, getTransmissionType() + )) + ; + { return ((IGridTransmitter) transmitter).getTransmitterNetwork(); } + } + + return null; + } + + @Override + public void takeShare() { + containingPart.takeShare(); + } + + @Override + public void updateShare() { containingPart.updateShare(); } - @Override - public Object getBuffer() - { - return getPart().getBuffer(); - } + @Override + public Object getBuffer() { + return getPart().getBuffer(); + } - @Override - public N mergeNetworks(Collection toMerge) - { - return getPart().createNetworkByMerging(toMerge); - } + @Override + public N mergeNetworks(Collection toMerge) { + return getPart().createNetworkByMerging(toMerge); + } - @Override - public TransmissionType getTransmissionType() - { - return getPart().getTransmissionType(); - } + @Override + public TransmissionType getTransmissionType() { + return getPart().getTransmissionType(); + } - public PartTransmitter getPart() - { - return containingPart; - } + public PartTransmitter getPart() { + return containingPart; + } - public void setPart(PartTransmitter containingPart) - { - this.containingPart = containingPart; - } + public void setPart(PartTransmitter containingPart) { + this.containingPart = containingPart; + } } diff --git a/src/main/java/mekanism/common/multipart/MultipartTransporter.java b/src/main/java/mekanism/common/multipart/MultipartTransporter.java index 7fefc6720..e7b9889ae 100644 --- a/src/main/java/mekanism/common/multipart/MultipartTransporter.java +++ b/src/main/java/mekanism/common/multipart/MultipartTransporter.java @@ -25,376 +25,373 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -public class MultipartTransporter extends MultipartTransmitter implements ILogisticalTransporter -{ - public HashList transit = new HashList<>(); +public class MultipartTransporter + extends MultipartTransmitter + implements ILogisticalTransporter { + public HashList transit = new HashList<>(); - public EnumColor color; + public EnumColor color; - public Set needsSync = new HashSet<>(); + public Set needsSync = new HashSet<>(); - public MultipartTransporter(PartLogisticalTransporter multiPart) - { - super(multiPart); - } + public MultipartTransporter(PartLogisticalTransporter multiPart) { + super(multiPart); + } - public void update() - { - if(world().isRemote) - { - for(TransporterStack stack : transit) - { - if(stack != null) - { - stack.progress = Math.min(100, stack.progress+getPart().tier.speed); - } - } - } - else { - if(getTransmitterNetwork() == null) - { - return; - } - - Set remove = new HashSet(); + public void update() { + if (world().isRemote) { + for (TransporterStack stack : transit) { + if (stack != null) { + stack.progress = Math.min(100, stack.progress + getPart().tier.speed); + } + } + } else { + if (getTransmitterNetwork() == null) { + return; + } - getPart().pullItems(); + Set remove = new HashSet(); - for(TransporterStack stack : transit) - { - if(!stack.initiatedPath) - { - if(stack.itemStack == null || !recalculate(stack, null)) - { - remove.add(stack); - continue; - } - } + getPart().pullItems(); - stack.progress += getPart().tier.speed; + for (TransporterStack stack : transit) { + if (!stack.initiatedPath) { + if (stack.itemStack == null || !recalculate(stack, null)) { + remove.add(stack); + continue; + } + } - if(stack.progress > 100) - { - Coord4D prevSet = null; + stack.progress += getPart().tier.speed; - if(stack.hasPath()) - { - int currentIndex = stack.getPath().indexOf(coord()); + if (stack.progress > 100) { + Coord4D prevSet = null; - if(currentIndex == 0) //Necessary for transition reasons, not sure why - { - remove.add(stack); - continue; - } + if (stack.hasPath()) { + int currentIndex = stack.getPath().indexOf(coord()); - Coord4D next = stack.getPath().get(currentIndex-1); + if (currentIndex + == 0) //Necessary for transition reasons, not sure why + { + remove.add(stack); + continue; + } - if(!stack.isFinal(this)) - { - if(next != null && stack.canInsertToTransporter(stack.getNext(this).getTileEntity(world()), ForgeDirection.getOrientation(stack.getSide(this)))) - { - ITransporterTile nextTile = (ITransporterTile)next.getTileEntity(world()); - nextTile.getTransmitter().entityEntering(stack, stack.progress%100); - remove.add(stack); + Coord4D next = stack.getPath().get(currentIndex - 1); - continue; - } - else if(next != null) - { - prevSet = next; - } - } - else { - if(stack.pathType != Path.NONE) - { - if(next != null && next.getTileEntity(world()) instanceof IInventory) - { - needsSync.add(stack); - IInventory inventory = (IInventory)next.getTileEntity(world()); + if (!stack.isFinal(this)) { + if (next != null + && stack.canInsertToTransporter( + stack.getNext(this).getTileEntity(world()), + ForgeDirection.getOrientation(stack.getSide(this)) + )) { + ITransporterTile nextTile + = (ITransporterTile) next.getTileEntity(world()); + nextTile.getTransmitter().entityEntering( + stack, stack.progress % 100 + ); + remove.add(stack); - if(inventory != null) - { - ItemStack rejected = InventoryUtils.putStackInInventory(inventory, stack.itemStack, stack.getSide(this), stack.pathType == Path.HOME); + continue; + } else if (next != null) { + prevSet = next; + } + } else { + if (stack.pathType != Path.NONE) { + if (next != null + && next.getTileEntity(world()) + instanceof IInventory) { + needsSync.add(stack); + IInventory inventory + = (IInventory) next.getTileEntity(world()); - if(rejected == null) - { - TransporterManager.remove(stack); - remove.add(stack); - continue; - } - else { - needsSync.add(stack); - stack.itemStack = rejected; + if (inventory != null) { + ItemStack rejected + = InventoryUtils.putStackInInventory( + inventory, + stack.itemStack, + stack.getSide(this), + stack.pathType == Path.HOME + ); - prevSet = next; - } - } - } - } - } - } + if (rejected == null) { + TransporterManager.remove(stack); + remove.add(stack); + continue; + } else { + needsSync.add(stack); + stack.itemStack = rejected; - if(!recalculate(stack, prevSet)) - { - remove.add(stack); - continue; - } - else { - if(prevSet != null) - { - stack.progress = 0; - } - else { - stack.progress = 50; - } - } - } - else if(stack.progress == 50) - { - if(stack.isFinal(this)) - { - if(stack.pathType == Path.DEST && (!checkSideForInsert(stack) || !InventoryUtils.canInsert(stack.getDest().getTileEntity(world()), stack.color, stack.itemStack, stack.getSide(this), false))) - { - if(!recalculate(stack, null)) - { - remove.add(stack); - continue; - } - } + prevSet = next; + } + } + } + } + } + } + + if (!recalculate(stack, prevSet)) { + remove.add(stack); + continue; + } else { + if (prevSet != null) { + stack.progress = 0; + } else { + stack.progress = 50; + } + } + } else if (stack.progress == 50) { + if (stack.isFinal(this)) { + if (stack.pathType == Path.DEST + && (!checkSideForInsert(stack) + || !InventoryUtils.canInsert( + stack.getDest().getTileEntity(world()), + stack.color, + stack.itemStack, + stack.getSide(this), + false + ))) { + if (!recalculate(stack, null)) { + remove.add(stack); + continue; + } + } else if(stack.pathType == Path.HOME && (!checkSideForInsert(stack) || !InventoryUtils.canInsert(stack.getDest().getTileEntity(world()), stack.color, stack.itemStack, stack.getSide(this), true))) { - if(!recalculate(stack, null)) - { - remove.add(stack); - continue; - } - } - else if(stack.pathType == Path.NONE) - { - if(!recalculate(stack, null)) - { - remove.add(stack); - continue; - } - } - } - else { - TileEntity next = stack.getNext(this).getTileEntity(world()); - boolean recalculate = false; + if (!recalculate(stack, null)) { + remove.add(stack); + continue; + } + } else if (stack.pathType == Path.NONE) { + if (!recalculate(stack, null)) { + remove.add(stack); + continue; + } + } + } else { + TileEntity next = stack.getNext(this).getTileEntity(world()); + boolean recalculate = false; - if(!stack.canInsertToTransporter(next, ForgeDirection.getOrientation(stack.getSide(this)))) - { - recalculate = true; - } + if (!stack.canInsertToTransporter( + next, ForgeDirection.getOrientation(stack.getSide(this)) + )) { + recalculate = true; + } - if(recalculate) - { - if(!recalculate(stack, null)) - { - remove.add(stack); - continue; - } - } - } - } - } + if (recalculate) { + if (!recalculate(stack, null)) { + remove.add(stack); + continue; + } + } + } + } + } - for(TransporterStack stack : remove) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(coord(), getPart().getSyncPacket(stack, true)), new Range4D(coord())); - transit.remove(stack); - MekanismUtils.saveChunk(getPart().tile()); - } + for (TransporterStack stack : remove) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage(coord(), getPart().getSyncPacket(stack, true)), + new Range4D(coord()) + ); + transit.remove(stack); + MekanismUtils.saveChunk(getPart().tile()); + } - for(TransporterStack stack : needsSync) - { - if(transit.contains(stack)) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(coord(), getPart().getSyncPacket(stack, false)), new Range4D(coord())); - } - } + for (TransporterStack stack : needsSync) { + if (transit.contains(stack)) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + coord(), getPart().getSyncPacket(stack, false) + ), + new Range4D(coord()) + ); + } + } - needsSync.clear(); - } - } + needsSync.clear(); + } + } - private boolean checkSideForInsert(TransporterStack stack) - { - ForgeDirection side = ForgeDirection.getOrientation(stack.getSide(this)); + private boolean checkSideForInsert(TransporterStack stack) { + ForgeDirection side = ForgeDirection.getOrientation(stack.getSide(this)); - return getPart().getConnectionType(side) == ConnectionType.NORMAL || getPart().getConnectionType(side) == ConnectionType.PUSH; - } + return getPart().getConnectionType(side) == ConnectionType.NORMAL + || getPart().getConnectionType(side) == ConnectionType.PUSH; + } - private boolean recalculate(TransporterStack stack, Coord4D from) - { - needsSync.add(stack); + private boolean recalculate(TransporterStack stack, Coord4D from) { + needsSync.add(stack); - if(stack.pathType != Path.NONE) - { - if(!TransporterManager.didEmit(stack.itemStack, stack.recalculatePath(this, 0))) - { - if(!stack.calculateIdle(this)) - { - TransporterUtils.drop(this, stack); - return false; - } - } - } - else { - if(!stack.calculateIdle(this)) - { - TransporterUtils.drop(this, stack); - return false; - } - } + if (stack.pathType != Path.NONE) { + if (!TransporterManager.didEmit( + stack.itemStack, stack.recalculatePath(this, 0) + )) { + if (!stack.calculateIdle(this)) { + TransporterUtils.drop(this, stack); + return false; + } + } + } else { + if (!stack.calculateIdle(this)) { + TransporterUtils.drop(this, stack); + return false; + } + } - if(from != null) - { - stack.originalLocation = from; - } + if (from != null) { + stack.originalLocation = from; + } - return true; - } + return true; + } - @Override - public ItemStack insert(Coord4D original, ItemStack itemStack, EnumColor color, boolean doEmit, int min) - { - return insert_do(original, itemStack, color, doEmit, min, false); - } + @Override + public ItemStack insert( + Coord4D original, ItemStack itemStack, EnumColor color, boolean doEmit, int min + ) { + return insert_do(original, itemStack, color, doEmit, min, false); + } - private ItemStack insert_do(Coord4D original, ItemStack itemStack, EnumColor color, boolean doEmit, int min, boolean force) - { - ForgeDirection from = coord().sideDifference(original).getOpposite(); + private ItemStack insert_do( + Coord4D original, + ItemStack itemStack, + EnumColor color, + boolean doEmit, + int min, + boolean force + ) { + ForgeDirection from = coord().sideDifference(original).getOpposite(); - TransporterStack stack = new TransporterStack(); - stack.itemStack = itemStack; - stack.originalLocation = original; - stack.homeLocation = original; - stack.color = color; + TransporterStack stack = new TransporterStack(); + stack.itemStack = itemStack; + stack.originalLocation = original; + stack.homeLocation = original; + stack.color = color; - if((force && !canReceiveFrom(original.getTileEntity(world()), from)) || !stack.canInsertToTransporter(this, from)) - { - return itemStack; - } + if ((force && !canReceiveFrom(original.getTileEntity(world()), from)) + || !stack.canInsertToTransporter(this, from)) { + return itemStack; + } - ItemStack rejected = stack.recalculatePath(this, min); + ItemStack rejected = stack.recalculatePath(this, min); - if(TransporterManager.didEmit(stack.itemStack, rejected)) - { - stack.itemStack = TransporterManager.getToUse(stack.itemStack, rejected); + if (TransporterManager.didEmit(stack.itemStack, rejected)) { + stack.itemStack = TransporterManager.getToUse(stack.itemStack, rejected); - if(doEmit) - { - transit.add(stack); - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(coord(), getPart().getSyncPacket(stack, false)), new Range4D(coord())); - MekanismUtils.saveChunk(getPart().tile()); - } + if (doEmit) { + transit.add(stack); + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage(coord(), getPart().getSyncPacket(stack, false)), + new Range4D(coord()) + ); + MekanismUtils.saveChunk(getPart().tile()); + } - return rejected; - } + return rejected; + } - return itemStack; - } + return itemStack; + } - @Override - public ItemStack insertRR(TileEntityLogisticalSorter outputter, ItemStack itemStack, EnumColor color, boolean doEmit, int min) - { - ForgeDirection from = coord().sideDifference(Coord4D.get(outputter)).getOpposite(); + @Override + public ItemStack insertRR( + TileEntityLogisticalSorter outputter, + ItemStack itemStack, + EnumColor color, + boolean doEmit, + int min + ) { + ForgeDirection from + = coord().sideDifference(Coord4D.get(outputter)).getOpposite(); - TransporterStack stack = new TransporterStack(); - stack.itemStack = itemStack; - stack.originalLocation = Coord4D.get(outputter); - stack.homeLocation = Coord4D.get(outputter); - stack.color = color; + TransporterStack stack = new TransporterStack(); + stack.itemStack = itemStack; + stack.originalLocation = Coord4D.get(outputter); + stack.homeLocation = Coord4D.get(outputter); + stack.color = color; - if(!canReceiveFrom(outputter, from) || !stack.canInsertToTransporter(this, from)) - { - return itemStack; - } + if (!canReceiveFrom(outputter, from) + || !stack.canInsertToTransporter(this, from)) { + return itemStack; + } - ItemStack rejected = stack.recalculateRRPath(outputter, this, min); + ItemStack rejected = stack.recalculateRRPath(outputter, this, min); - if(TransporterManager.didEmit(stack.itemStack, rejected)) - { - stack.itemStack = TransporterManager.getToUse(stack.itemStack, rejected); + if (TransporterManager.didEmit(stack.itemStack, rejected)) { + stack.itemStack = TransporterManager.getToUse(stack.itemStack, rejected); - if(doEmit) - { - transit.add(stack); - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(coord(), getPart().getSyncPacket(stack, false)), new Range4D(coord())); - MekanismUtils.saveChunk(getPart().tile()); - } + if (doEmit) { + transit.add(stack); + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage(coord(), getPart().getSyncPacket(stack, false)), + new Range4D(coord()) + ); + MekanismUtils.saveChunk(getPart().tile()); + } - return rejected; - } + return rejected; + } - return itemStack; - } + return itemStack; + } - @Override - public void entityEntering(TransporterStack stack, int progress) - { - stack.progress = progress; - transit.add(stack); - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(coord(), getPart().getSyncPacket(stack, false)), new Range4D(coord())); - MekanismUtils.saveChunk(getPart().tile()); - } + @Override + public void entityEntering(TransporterStack stack, int progress) { + stack.progress = progress; + transit.add(stack); + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage(coord(), getPart().getSyncPacket(stack, false)), + new Range4D(coord()) + ); + MekanismUtils.saveChunk(getPart().tile()); + } - @Override - public EnumColor getColor() - { - return color; - } + @Override + public EnumColor getColor() { + return color; + } - @Override - public void setColor(EnumColor c) - { - color = c; - } + @Override + public void setColor(EnumColor c) { + color = c; + } - @Override - public boolean canEmitTo(TileEntity tileEntity, ForgeDirection side) - { - if(!getPart().canConnect(side)) - { - return false; - } + @Override + public boolean canEmitTo(TileEntity tileEntity, ForgeDirection side) { + if (!getPart().canConnect(side)) { + return false; + } - return getPart().getConnectionType(side) == ConnectionType.NORMAL || getPart().getConnectionType(side) == ConnectionType.PUSH; - } + return getPart().getConnectionType(side) == ConnectionType.NORMAL + || getPart().getConnectionType(side) == ConnectionType.PUSH; + } - @Override - public boolean canReceiveFrom(TileEntity tileEntity, ForgeDirection side) - { - if(!getPart().canConnect(side)) - { - return false; - } + @Override + public boolean canReceiveFrom(TileEntity tileEntity, ForgeDirection side) { + if (!getPart().canConnect(side)) { + return false; + } - return getPart().getConnectionType(side) == ConnectionType.NORMAL; - } + return getPart().getConnectionType(side) == ConnectionType.NORMAL; + } - @Override - public double getCost() - { - return getPart().getCost(); - } + @Override + public double getCost() { + return getPart().getCost(); + } - @Override - public boolean canConnectMutual(ForgeDirection side) - { - return getPart().canConnectMutual(side); - } + @Override + public boolean canConnectMutual(ForgeDirection side) { + return getPart().canConnectMutual(side); + } - @Override - public boolean canConnect(ForgeDirection side) - { - return getPart().canConnect(side); - } + @Override + public boolean canConnect(ForgeDirection side) { + return getPart().canConnect(side); + } - @Override - public PartLogisticalTransporter getPart() - { - return (PartLogisticalTransporter)containingPart; - } + @Override + public PartLogisticalTransporter getPart() { + return (PartLogisticalTransporter) containingPart; + } } diff --git a/src/main/java/mekanism/common/multipart/PartDiversionTransporter.java b/src/main/java/mekanism/common/multipart/PartDiversionTransporter.java index d4d004ac5..55916a159 100644 --- a/src/main/java/mekanism/common/multipart/PartDiversionTransporter.java +++ b/src/main/java/mekanism/common/multipart/PartDiversionTransporter.java @@ -1,9 +1,8 @@ package mekanism.common.multipart; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.Range4D; @@ -17,154 +16,147 @@ import net.minecraft.util.ChatComponentText; import net.minecraft.util.IIcon; import net.minecraftforge.common.util.ForgeDirection; -public class PartDiversionTransporter extends PartLogisticalTransporter -{ - public int[] modes = {0, 0, 0, 0, 0, 0}; +public class PartDiversionTransporter extends PartLogisticalTransporter { + public int[] modes = { 0, 0, 0, 0, 0, 0 }; - @Override - public String getType() - { - return "mekanism:diversion_transporter"; - } + @Override + public String getType() { + return "mekanism:diversion_transporter"; + } - @Override - public TransmitterType getTransmitterType() - { - return TransmitterType.DIVERSION_TRANSPORTER; - } + @Override + public TransmitterType getTransmitterType() { + return TransmitterType.DIVERSION_TRANSPORTER; + } - @Override - public IIcon getCenterIcon(boolean opaque) - { - return transporterIcons.getCenterIcon(5); - } - - @Override - public IIcon getSideIcon(boolean opaque) - { - return transporterIcons.getSideIcon(opaque ? 14 : (getTransmitter().color != null ? 11 : 10)); - } - - @Override - public IIcon getSideIconRotated(boolean opaque) - { - return transporterIcons.getSideIcon(opaque ? 15 : (getTransmitter().color != null ? 13 : 12)); - } - - @Override - public boolean renderCenter() - { - return true; - } + @Override + public IIcon getCenterIcon(boolean opaque) { + return transporterIcons.getCenterIcon(5); + } - @Override - public void load(NBTTagCompound nbtTags) - { - super.load(nbtTags); + @Override + public IIcon getSideIcon(boolean opaque) { + return transporterIcons.getSideIcon( + opaque ? 14 : (getTransmitter().color != null ? 11 : 10) + ); + } - modes = nbtTags.getIntArray("modes"); - } + @Override + public IIcon getSideIconRotated(boolean opaque) { + return transporterIcons.getSideIcon( + opaque ? 15 : (getTransmitter().color != null ? 13 : 12) + ); + } - @Override - public void save(NBTTagCompound nbtTags) - { - super.save(nbtTags); + @Override + public boolean renderCenter() { + return true; + } - nbtTags.setIntArray("modes", modes); - } + @Override + public void load(NBTTagCompound nbtTags) { + super.load(nbtTags); - @Override - public void handlePacketData(ByteBuf dataStream) throws Exception - { - super.handlePacketData(dataStream); - - if(world().isRemote) - { - modes[0] = dataStream.readInt(); - modes[1] = dataStream.readInt(); - modes[2] = dataStream.readInt(); - modes[3] = dataStream.readInt(); - modes[4] = dataStream.readInt(); - modes[5] = dataStream.readInt(); - } - } + modes = nbtTags.getIntArray("modes"); + } - @Override - public ArrayList getNetworkedData(ArrayList data) - { - data = super.getNetworkedData(data); + @Override + public void save(NBTTagCompound nbtTags) { + super.save(nbtTags); - data.add(modes[0]); - data.add(modes[1]); - data.add(modes[2]); - data.add(modes[3]); - data.add(modes[4]); - data.add(modes[5]); + nbtTags.setIntArray("modes", modes); + } - return data; - } + @Override + public void handlePacketData(ByteBuf dataStream) throws Exception { + super.handlePacketData(dataStream); - @Override - public ArrayList getSyncPacket(TransporterStack stack, boolean kill) - { - ArrayList data = super.getSyncPacket(stack, kill); + if (world().isRemote) { + modes[0] = dataStream.readInt(); + modes[1] = dataStream.readInt(); + modes[2] = dataStream.readInt(); + modes[3] = dataStream.readInt(); + modes[4] = dataStream.readInt(); + modes[5] = dataStream.readInt(); + } + } - data.add(modes[0]); - data.add(modes[1]); - data.add(modes[2]); - data.add(modes[3]); - data.add(modes[4]); - data.add(modes[5]); + @Override + public ArrayList getNetworkedData(ArrayList data) { + data = super.getNetworkedData(data); - return data; - } + data.add(modes[0]); + data.add(modes[1]); + data.add(modes[2]); + data.add(modes[3]); + data.add(modes[4]); + data.add(modes[5]); - @Override - protected boolean onConfigure(EntityPlayer player, int part, int side) - { - int newMode = (modes[side] + 1) % 3; - String description = "ERROR"; + return data; + } - modes[side] = newMode; + @Override + public ArrayList getSyncPacket(TransporterStack stack, boolean kill) { + ArrayList data = super.getSyncPacket(stack, kill); - switch(newMode) - { - case 0: - description = LangUtils.localize("control.disabled.desc"); - break; - case 1: - description = LangUtils.localize("control.high.desc"); - break; - case 2: - description = LangUtils.localize("control.low.desc"); - break; - } + data.add(modes[0]); + data.add(modes[1]); + data.add(modes[2]); + data.add(modes[3]); + data.add(modes[4]); + data.add(modes[5]); - refreshConnections(); - tile().notifyPartChange(this); - notifyTileChange(); - player.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + LangUtils.localize("tooltip.configurator.toggleDiverter") + ": " + EnumColor.RED + description)); - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tile()), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(tile()))); + return data; + } - return true; - } + @Override + protected boolean onConfigure(EntityPlayer player, int part, int side) { + int newMode = (modes[side] + 1) % 3; + String description = "ERROR"; - @Override - public boolean canConnect(ForgeDirection side) - { - if(!super.canConnect(side)) - { - return false; - } + modes[side] = newMode; - int mode = modes[side.ordinal()]; - boolean redstone = world().isBlockIndirectlyGettingPowered(x(), y(), z()); + switch (newMode) { + case 0: + description = LangUtils.localize("control.disabled.desc"); + break; + case 1: + description = LangUtils.localize("control.high.desc"); + break; + case 2: + description = LangUtils.localize("control.low.desc"); + break; + } - if((mode == 2 && redstone == true) || (mode == 1 && redstone == false)) - { - return false; - } + refreshConnections(); + tile().notifyPartChange(this); + notifyTileChange(); + player.addChatMessage(new ChatComponentText( + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + + LangUtils.localize("tooltip.configurator.toggleDiverter") + ": " + + EnumColor.RED + description + )); + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage(Coord4D.get(tile()), getNetworkedData(new ArrayList())), + new Range4D(Coord4D.get(tile())) + ); - return true; - } + return true; + } + + @Override + public boolean canConnect(ForgeDirection side) { + if (!super.canConnect(side)) { + return false; + } + + int mode = modes[side.ordinal()]; + boolean redstone = world().isBlockIndirectlyGettingPowered(x(), y(), z()); + + if ((mode == 2 && redstone == true) || (mode == 1 && redstone == false)) { + return false; + } + + return true; + } } diff --git a/src/main/java/mekanism/common/multipart/PartGlowPanel.java b/src/main/java/mekanism/common/multipart/PartGlowPanel.java index a56821324..cf38bb289 100644 --- a/src/main/java/mekanism/common/multipart/PartGlowPanel.java +++ b/src/main/java/mekanism/common/multipart/PartGlowPanel.java @@ -2,16 +2,6 @@ package mekanism.common.multipart; import java.util.Collections; -import mekanism.api.Coord4D; -import mekanism.api.EnumColor; -import mekanism.client.render.RenderGlowPanel; -import mekanism.common.MekanismItems; -import net.minecraft.client.particle.EffectRenderer; -import net.minecraft.item.ItemStack; -import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.util.IIcon; -import net.minecraft.util.MovingObjectPosition; -import net.minecraftforge.common.util.ForgeDirection; import codechicken.lib.data.MCDataInput; import codechicken.lib.data.MCDataOutput; import codechicken.lib.vec.Cuboid6; @@ -28,184 +18,178 @@ import codechicken.multipart.TMultiPart; import codechicken.multipart.TileMultipart; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import mekanism.api.Coord4D; +import mekanism.api.EnumColor; +import mekanism.client.render.RenderGlowPanel; +import mekanism.common.MekanismItems; +import net.minecraft.client.particle.EffectRenderer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.IIcon; +import net.minecraft.util.MovingObjectPosition; +import net.minecraftforge.common.util.ForgeDirection; -public class PartGlowPanel extends JCuboidPart implements JNormalOcclusion, JIconHitEffects -{ - public EnumColor colour = EnumColor.WHITE; - public ForgeDirection side = ForgeDirection.DOWN; +public class PartGlowPanel + extends JCuboidPart implements JNormalOcclusion, JIconHitEffects { + public EnumColor colour = EnumColor.WHITE; + public ForgeDirection side = ForgeDirection.DOWN; - public static Cuboid6[] bounds = new Cuboid6[6]; + public static Cuboid6[] bounds = new Cuboid6[6]; - static - { - Cuboid6 cuboid = new Cuboid6(0.25, 0, 0.25, 0.75, 0.125, 0.75); - Translation fromOrigin = new Translation(Vector3.center); - Translation toOrigin = (Translation)fromOrigin.inverse(); - - for(int i = 0; i < 6; i++) - { - bounds[i] = cuboid.copy().apply(toOrigin).apply(Rotation.sideRotations[i]).apply(fromOrigin); - } - } + static { + Cuboid6 cuboid = new Cuboid6(0.25, 0, 0.25, 0.75, 0.125, 0.75); + Translation fromOrigin = new Translation(Vector3.center); + Translation toOrigin = (Translation) fromOrigin.inverse(); - public PartGlowPanel() - { - super(); - } + for (int i = 0; i < 6; i++) { + bounds[i] = cuboid.copy() + .apply(toOrigin) + .apply(Rotation.sideRotations[i]) + .apply(fromOrigin); + } + } - public PartGlowPanel(EnumColor colour, ForgeDirection side) - { - super(); - setColour(colour); - setOrientation(side); - } + public PartGlowPanel() { + super(); + } - @Override - public Cuboid6 getBounds() - { - return bounds[side.ordinal()]; - } + public PartGlowPanel(EnumColor colour, ForgeDirection side) { + super(); + setColour(colour); + setOrientation(side); + } - @Override - public String getType() - { - return "mekanism:glow_panel"; - } + @Override + public Cuboid6 getBounds() { + return bounds[side.ordinal()]; + } - public void setColour(EnumColor newColour) - { - colour = newColour; - } + @Override + public String getType() { + return "mekanism:glow_panel"; + } - public void setOrientation(ForgeDirection newSide) - { - side = newSide; - } - - @Override - public void onNeighborChanged() - { - if(!world().isRemote && !canStay()) - { - TileMultipart.dropItem(new ItemStack(MekanismItems.GlowPanel, 1, colour.getMetaValue()), world(), Vector3.fromTileEntityCenter(tile())); - tile().remPart(this); - } - } + public void setColour(EnumColor newColour) { + colour = newColour; + } - @Override - public void onPartChanged(TMultiPart other) - { - if(!world().isRemote && !canStay()) - { - TileMultipart.dropItem(new ItemStack(MekanismItems.GlowPanel, 1, colour.getMetaValue()), world(), Vector3.fromTileEntityCenter(tile())); - tile().remPart(this); - } - } + public void setOrientation(ForgeDirection newSide) { + side = newSide; + } - @Override - public void writeDesc(MCDataOutput data) - { - data.writeInt(side.ordinal()); - data.writeInt(colour.getMetaValue()); - } + @Override + public void onNeighborChanged() { + if (!world().isRemote && !canStay()) { + TileMultipart.dropItem( + new ItemStack(MekanismItems.GlowPanel, 1, colour.getMetaValue()), + world(), + Vector3.fromTileEntityCenter(tile()) + ); + tile().remPart(this); + } + } - @Override - public void readDesc(MCDataInput data) - { - side = ForgeDirection.getOrientation(data.readInt()); - colour = EnumColor.DYES[data.readInt()]; - } + @Override + public void onPartChanged(TMultiPart other) { + if (!world().isRemote && !canStay()) { + TileMultipart.dropItem( + new ItemStack(MekanismItems.GlowPanel, 1, colour.getMetaValue()), + world(), + Vector3.fromTileEntityCenter(tile()) + ); + tile().remPart(this); + } + } - @Override - public void save(NBTTagCompound nbt) - { - nbt.setInteger("side", side.ordinal()); - nbt.setInteger("colour", colour.getMetaValue()); - } + @Override + public void writeDesc(MCDataOutput data) { + data.writeInt(side.ordinal()); + data.writeInt(colour.getMetaValue()); + } - @Override - public void load(NBTTagCompound nbt) - { - side = ForgeDirection.getOrientation(nbt.getInteger("side")); - colour = EnumColor.DYES[nbt.getInteger("colour")]; - } + @Override + public void readDesc(MCDataInput data) { + side = ForgeDirection.getOrientation(data.readInt()); + colour = EnumColor.DYES[data.readInt()]; + } - @Override - @SideOnly(Side.CLIENT) - public boolean renderStatic(Vector3 pos, int pass) - { - if(pass == 0) - { - RenderGlowPanel.getInstance().renderStatic(this); - return true; - } - - return false; - } + @Override + public void save(NBTTagCompound nbt) { + nbt.setInteger("side", side.ordinal()); + nbt.setInteger("colour", colour.getMetaValue()); + } - @Override - public int getLightValue() - { - return 15; - } + @Override + public void load(NBTTagCompound nbt) { + side = ForgeDirection.getOrientation(nbt.getInteger("side")); + colour = EnumColor.DYES[nbt.getInteger("colour")]; + } - @Override - public Iterable getOcclusionBoxes() - { - return getCollisionBoxes(); - } + @Override + @SideOnly(Side.CLIENT) + public boolean renderStatic(Vector3 pos, int pass) { + if (pass == 0) { + RenderGlowPanel.getInstance().renderStatic(this); + return true; + } - @Override - public boolean occlusionTest(TMultiPart other) - { - return NormalOcclusionTest.apply(this, other); - } + return false; + } - @Override - public IIcon getBreakingIcon(Object subPart, int side) - { - return RenderGlowPanel.icon; - } + @Override + public int getLightValue() { + return 15; + } - @Override - public IIcon getBrokenIcon(int side) - { - return RenderGlowPanel.icon; - } + @Override + public Iterable getOcclusionBoxes() { + return getCollisionBoxes(); + } - @Override - public void addHitEffects(MovingObjectPosition hit, EffectRenderer effectRenderer) - { - IconHitEffects.addHitEffects(this, hit, effectRenderer); - } + @Override + public boolean occlusionTest(TMultiPart other) { + return NormalOcclusionTest.apply(this, other); + } - @Override - public void addDestroyEffects(MovingObjectPosition mop, EffectRenderer effectRenderer) - { - IconHitEffects.addDestroyEffects(this, effectRenderer, false); - } + @Override + public IIcon getBreakingIcon(Object subPart, int side) { + return RenderGlowPanel.icon; + } - @Override - public Iterable getDrops() - { - return Collections.singletonList(pickItem(null)); - } + @Override + public IIcon getBrokenIcon(int side) { + return RenderGlowPanel.icon; + } - @Override - public ItemStack pickItem(MovingObjectPosition hit) - { - return new ItemStack(MekanismItems.GlowPanel, 1, colour.getMetaValue()); - } + @Override + public void addHitEffects(MovingObjectPosition hit, EffectRenderer effectRenderer) { + IconHitEffects.addHitEffects(this, hit, effectRenderer); + } - @Override - public boolean doesTick() - { - return false; - } + @Override + public void + addDestroyEffects(MovingObjectPosition mop, EffectRenderer effectRenderer) { + IconHitEffects.addDestroyEffects(this, effectRenderer, false); + } - public boolean canStay() - { - Coord4D adj = Coord4D.get(tile()).getFromSide(side); - return world().isSideSolid(adj.xCoord, adj.yCoord, adj.zCoord, side.getOpposite()) || tile().partMap(side.ordinal()) instanceof HollowMicroblock; - } + @Override + public Iterable getDrops() { + return Collections.singletonList(pickItem(null)); + } + + @Override + public ItemStack pickItem(MovingObjectPosition hit) { + return new ItemStack(MekanismItems.GlowPanel, 1, colour.getMetaValue()); + } + + @Override + public boolean doesTick() { + return false; + } + + public boolean canStay() { + Coord4D adj = Coord4D.get(tile()).getFromSide(side); + return world().isSideSolid(adj.xCoord, adj.yCoord, adj.zCoord, side.getOpposite()) + || tile().partMap(side.ordinal()) instanceof HollowMicroblock; + } } diff --git a/src/main/java/mekanism/common/multipart/PartLogisticalTransporter.java b/src/main/java/mekanism/common/multipart/PartLogisticalTransporter.java index 19a4bce76..031132dec 100644 --- a/src/main/java/mekanism/common/multipart/PartLogisticalTransporter.java +++ b/src/main/java/mekanism/common/multipart/PartLogisticalTransporter.java @@ -1,10 +1,14 @@ package mekanism.common.multipart; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.Collection; +import codechicken.lib.data.MCDataInput; +import codechicken.lib.data.MCDataOutput; +import codechicken.lib.vec.Vector3; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.MekanismConfig.client; @@ -38,452 +42,443 @@ import net.minecraft.util.ChatComponentText; import net.minecraft.util.IIcon; import net.minecraftforge.common.util.Constants.NBT; import net.minecraftforge.common.util.ForgeDirection; -import codechicken.lib.data.MCDataInput; -import codechicken.lib.data.MCDataOutput; -import codechicken.lib.vec.Vector3; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class PartLogisticalTransporter extends PartTransmitter implements ITransporterTile -{ - public Tier.TransporterTier tier = Tier.TransporterTier.BASIC; +public class PartLogisticalTransporter + extends PartTransmitter implements ITransporterTile { + public Tier.TransporterTier tier = Tier.TransporterTier.BASIC; - public static TransmitterIcons transporterIcons = new TransmitterIcons(8, 16); + public static TransmitterIcons transporterIcons = new TransmitterIcons(8, 16); - public int pullDelay = 0; + public int pullDelay = 0; - public PartLogisticalTransporter(TransporterTier transporterTier) - { - this(); - tier = transporterTier; - } + public PartLogisticalTransporter(TransporterTier transporterTier) { + this(); + tier = transporterTier; + } - public PartLogisticalTransporter() - { - transmitterDelegate = new MultipartTransporter(this); - } + public PartLogisticalTransporter() { + transmitterDelegate = new MultipartTransporter(this); + } - @Override - public String getType() - { - return "mekanism:logistical_transporter_" + tier.name().toLowerCase(); - } + @Override + public String getType() { + return "mekanism:logistical_transporter_" + tier.name().toLowerCase(); + } - @Override - public TransmitterType getTransmitterType() - { - return tier.type; - } + @Override + public TransmitterType getTransmitterType() { + return tier.type; + } - @Override - public TransmissionType getTransmissionType() - { - return TransmissionType.ITEM; - } + @Override + public TransmissionType getTransmissionType() { + return TransmissionType.ITEM; + } - public static void registerIcons(IIconRegister register) - { - transporterIcons.registerCenterIcons(register, new String[] {"LogisticalTransporterBasic", "LogisticalTransporterAdvanced", "LogisticalTransporterElite", "LogisticalTransporterUltimate", "RestrictiveTransporter", - "DiversionTransporter", "LogisticalTransporterGlass", "LogisticalTransporterGlassColored"}); - transporterIcons.registerSideIcons(register, new String[] {"LogisticalTransporterVerticalBasic", "LogisticalTransporterVerticalAdvanced", "LogisticalTransporterVerticalElite", "LogisticalTransporterVerticalUltimate", - "LogisticalTransporterHorizontalBasic", "LogisticalTransporterHorizontalAdvanced", "LogisticalTransporterHorizontalElite", "LogisticalTransporterHorizontalUltimate", "RestrictiveTransporterVertical", - "RestrictiveTransporterHorizontal", "LogisticalTransporterVerticalGlass", "LogisticalTransporterVerticalGlassColored", "LogisticalTransporterHorizontalGlass", "LogisticalTransporterHorizontalGlassColored", - "DiversionTransporterVertical", "DiversionTransporterHorizontal"}); - } + public static void registerIcons(IIconRegister register) { + transporterIcons.registerCenterIcons( + register, + new String[] { "LogisticalTransporterBasic", + "LogisticalTransporterAdvanced", + "LogisticalTransporterElite", + "LogisticalTransporterUltimate", + "RestrictiveTransporter", + "DiversionTransporter", + "LogisticalTransporterGlass", + "LogisticalTransporterGlassColored" } + ); + transporterIcons.registerSideIcons( + register, + new String[] { "LogisticalTransporterVerticalBasic", + "LogisticalTransporterVerticalAdvanced", + "LogisticalTransporterVerticalElite", + "LogisticalTransporterVerticalUltimate", + "LogisticalTransporterHorizontalBasic", + "LogisticalTransporterHorizontalAdvanced", + "LogisticalTransporterHorizontalElite", + "LogisticalTransporterHorizontalUltimate", + "RestrictiveTransporterVertical", + "RestrictiveTransporterHorizontal", + "LogisticalTransporterVerticalGlass", + "LogisticalTransporterVerticalGlassColored", + "LogisticalTransporterHorizontalGlass", + "LogisticalTransporterHorizontalGlassColored", + "DiversionTransporterVertical", + "DiversionTransporterHorizontal" } + ); + } - @Override - @SideOnly(Side.CLIENT) - public void renderDynamic(Vector3 pos, float f, int pass) - { - if(pass == 0 && !client.opaqueTransmitters) - { - RenderPartTransmitter.getInstance().renderContents(this, f, pos); - } - } - - @Override - public void onWorldSeparate() - { - super.onWorldSeparate(); - - if(!world().isRemote) - { - PathfinderCache.onChanged(Coord4D.get(tile())); - } - } - - @Override - protected boolean isValidTransmitter(TileEntity tileEntity) - { - ILogisticalTransporter transporter = ((ITransporterTile)tileEntity).getTransmitter(); + @Override + @SideOnly(Side.CLIENT) + public void renderDynamic(Vector3 pos, float f, int pass) { + if (pass == 0 && !client.opaqueTransmitters) { + RenderPartTransmitter.getInstance().renderContents(this, f, pos); + } + } - if(getTransmitter().getColor() == null || transporter.getColor() == null || getTransmitter().getColor() == transporter.getColor()) - { - return super.isValidTransmitter(tileEntity); - } - - return false; - } + @Override + public void onWorldSeparate() { + super.onWorldSeparate(); - @Override - public IIcon getCenterIcon(boolean opaque) - { - return transporterIcons.getCenterIcon(opaque ? tier.ordinal() : (getTransmitter().color != null ? 7 : 6)); - } + if (!world().isRemote) { + PathfinderCache.onChanged(Coord4D.get(tile())); + } + } - @Override - public IIcon getSideIcon(boolean opaque) - { - return transporterIcons.getSideIcon(opaque ? tier.ordinal() : (getTransmitter().color != null ? 11 : 10)); - } + @Override + protected boolean isValidTransmitter(TileEntity tileEntity) { + ILogisticalTransporter transporter + = ((ITransporterTile) tileEntity).getTransmitter(); - @Override - public IIcon getSideIconRotated(boolean opaque) - { - return transporterIcons.getSideIcon(opaque ? 4+tier.ordinal() : (getTransmitter().color != null ? 13 : 12)); - } + if (getTransmitter().getColor() == null || transporter.getColor() == null + || getTransmitter().getColor() == transporter.getColor()) { + return super.isValidTransmitter(tileEntity); + } - @Override - public boolean isValidAcceptor(TileEntity tile, ForgeDirection side) - { - return TransporterUtils.isValidAcceptorOnSide(tile, side); - } - - @Override - public boolean handlesRedstone() - { - return false; - } + return false; + } - @Override - public void update() - { - super.update(); + @Override + public IIcon getCenterIcon(boolean opaque) { + return transporterIcons.getCenterIcon( + opaque ? tier.ordinal() : (getTransmitter().color != null ? 7 : 6) + ); + } - getTransmitter().update(); - } + @Override + public IIcon getSideIcon(boolean opaque) { + return transporterIcons.getSideIcon( + opaque ? tier.ordinal() : (getTransmitter().color != null ? 11 : 10) + ); + } - protected void pullItems() - { - if(pullDelay == 0) - { - boolean did = false; + @Override + public IIcon getSideIconRotated(boolean opaque) { + return transporterIcons.getSideIcon( + opaque ? 4 + tier.ordinal() : (getTransmitter().color != null ? 13 : 12) + ); + } - for(ForgeDirection side : getConnections(ConnectionType.PULL)) - { - TileEntity tile = Coord4D.get(tile()).getFromSide(side).getTileEntity(world()); + @Override + public boolean isValidAcceptor(TileEntity tile, ForgeDirection side) { + return TransporterUtils.isValidAcceptorOnSide(tile, side); + } - if(tile instanceof IInventory) - { - IInventory inv = (IInventory)tile; - InvStack stack = InventoryUtils.takeTopItem(inv, side.ordinal(), tier.pullAmount); + @Override + public boolean handlesRedstone() { + return false; + } - if(stack != null && stack.getStack() != null) - { - ItemStack rejects = TransporterUtils.insert(tile, getTransmitter(), stack.getStack(), getTransmitter().getColor(), true, 0); + @Override + public void update() { + super.update(); - if(TransporterManager.didEmit(stack.getStack(), rejects)) - { - did = true; - stack.use(TransporterManager.getToUse(stack.getStack(), rejects).stackSize); - } - } - } - } + getTransmitter().update(); + } - if(did) - { - pullDelay = 10; - } - } - else { - pullDelay--; - } - } + protected void pullItems() { + if (pullDelay == 0) { + boolean did = false; - @Override - public void onWorldJoin() - { - super.onWorldJoin(); + for (ForgeDirection side : getConnections(ConnectionType.PULL)) { + TileEntity tile + = Coord4D.get(tile()).getFromSide(side).getTileEntity(world()); - if(world().isRemote) - { - Mekanism.packetHandler.sendToServer(new DataRequestMessage(Coord4D.get(tile()))); - } - else { - PathfinderCache.onChanged(Coord4D.get(tile())); - } - } + if (tile instanceof IInventory) { + IInventory inv = (IInventory) tile; + InvStack stack = InventoryUtils.takeTopItem( + inv, side.ordinal(), tier.pullAmount + ); - @Override - public InventoryNetwork createNewNetwork() - { - return new InventoryNetwork(); - } + if (stack != null && stack.getStack() != null) { + ItemStack rejects = TransporterUtils.insert( + tile, + getTransmitter(), + stack.getStack(), + getTransmitter().getColor(), + true, + 0 + ); - @Override - public InventoryNetwork createNetworkByMerging(Collection networks) - { - return new InventoryNetwork(networks); - } + if (TransporterManager.didEmit(stack.getStack(), rejects)) { + did = true; + stack.use(TransporterManager + .getToUse(stack.getStack(), rejects) + .stackSize); + } + } + } + } - @Override - public void handlePacketData(ByteBuf dataStream) throws Exception - { - super.handlePacketData(dataStream); - - if(world().isRemote) - { - int type = dataStream.readInt(); - - if(type == 0) - { - int c = dataStream.readInt(); - - EnumColor prev = getTransmitter().getColor(); - - if(c != -1) - { - getTransmitter().setColor(TransporterUtils.colors.get(c)); - } - else { - getTransmitter().setColor(null); - } - - if(prev != getTransmitter().getColor()) - { - tile().markRender(); - } - - getTransmitter().transit.clear(); - - int amount = dataStream.readInt(); - - for(int i = 0; i < amount; i++) - { - getTransmitter().transit.add(TransporterStack.readFromPacket(dataStream)); - } - } - else if(type == 1) - { - boolean kill = dataStream.readBoolean(); - int index = dataStream.readInt(); - - if(kill) - { - getTransmitter().transit.remove(index); - } - else { - TransporterStack stack = TransporterStack.readFromPacket(dataStream); - - if(stack.progress == 0) - { - stack.progress = 5; - } - - getTransmitter().transit.replace(index, stack); - } - } - } - } + if (did) { + pullDelay = 10; + } + } else { + pullDelay--; + } + } - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); - - data.add(0); + @Override + public void onWorldJoin() { + super.onWorldJoin(); - if(getTransmitter().getColor() != null) - { - data.add(TransporterUtils.colors.indexOf(getTransmitter().getColor())); - } - else { - data.add(-1); - } + if (world().isRemote) { + Mekanism.packetHandler.sendToServer(new DataRequestMessage(Coord4D.get(tile()) + )); + } else { + PathfinderCache.onChanged(Coord4D.get(tile())); + } + } - data.add(getTransmitter().transit.size()); + @Override + public InventoryNetwork createNewNetwork() { + return new InventoryNetwork(); + } - for(TransporterStack stack : getTransmitter().transit) - { - stack.write(getTransmitter(), data); - } + @Override + public InventoryNetwork createNetworkByMerging(Collection networks + ) { + return new InventoryNetwork(networks); + } - return data; - } + @Override + public void handlePacketData(ByteBuf dataStream) throws Exception { + super.handlePacketData(dataStream); - public ArrayList getSyncPacket(TransporterStack stack, boolean kill) - { - ArrayList data = new ArrayList(); + if (world().isRemote) { + int type = dataStream.readInt(); - data.add(1); - data.add(kill); - data.add(getTransmitter().transit.indexOf(stack)); + if (type == 0) { + int c = dataStream.readInt(); - if(!kill) - { - stack.write(getTransmitter(), data); - } + EnumColor prev = getTransmitter().getColor(); - return data; - } + if (c != -1) { + getTransmitter().setColor(TransporterUtils.colors.get(c)); + } else { + getTransmitter().setColor(null); + } - @Override - public void load(NBTTagCompound nbtTags) - { - super.load(nbtTags); - - tier = TransporterTier.values()[nbtTags.getInteger("tier")]; + if (prev != getTransmitter().getColor()) { + tile().markRender(); + } - if(nbtTags.hasKey("color")) - { - getTransmitter().setColor(TransporterUtils.colors.get(nbtTags.getInteger("color"))); - } + getTransmitter().transit.clear(); - if(nbtTags.hasKey("stacks")) - { - NBTTagList tagList = nbtTags.getTagList("stacks", NBT.TAG_COMPOUND); + int amount = dataStream.readInt(); - for(int i = 0; i < tagList.tagCount(); i++) - { - TransporterStack stack = TransporterStack.readFromNBT(tagList.getCompoundTagAt(i)); + for (int i = 0; i < amount; i++) { + getTransmitter().transit.add( + TransporterStack.readFromPacket(dataStream) + ); + } + } else if (type == 1) { + boolean kill = dataStream.readBoolean(); + int index = dataStream.readInt(); - getTransmitter().transit.add(stack); - } - } - } + if (kill) { + getTransmitter().transit.remove(index); + } else { + TransporterStack stack = TransporterStack.readFromPacket(dataStream); - @Override - public void save(NBTTagCompound nbtTags) - { - super.save(nbtTags); - - nbtTags.setInteger("tier", tier.ordinal()); + if (stack.progress == 0) { + stack.progress = 5; + } - if(getTransmitter().getColor() != null) - { - nbtTags.setInteger("color", TransporterUtils.colors.indexOf(getTransmitter().getColor())); - } + getTransmitter().transit.replace(index, stack); + } + } + } + } - NBTTagList stacks = new NBTTagList(); + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); - for(TransporterStack stack : getTransmitter().transit) - { - NBTTagCompound tagCompound = new NBTTagCompound(); - stack.write(tagCompound); - stacks.appendTag(tagCompound); - } + data.add(0); - if(stacks.tagCount() != 0) - { - nbtTags.setTag("stacks", stacks); - } - } + if (getTransmitter().getColor() != null) { + data.add(TransporterUtils.colors.indexOf(getTransmitter().getColor())); + } else { + data.add(-1); + } - @Override - protected boolean onConfigure(EntityPlayer player, int part, int side) - { - TransporterUtils.incrementColor(getTransmitter()); - onPartChanged(this); - PathfinderCache.onChanged(Coord4D.get(tile())); - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tile()), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(tile()))); - player.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + LangUtils.localize("tooltip.configurator.toggleColor") + ": " + (getTransmitter().getColor() != null ? getTransmitter().getColor().getName() : EnumColor.BLACK + LangUtils.localize("gui.none")))); + data.add(getTransmitter().transit.size()); - return true; - } + for (TransporterStack stack : getTransmitter().transit) { + stack.write(getTransmitter(), data); + } - @Override - public boolean onRightClick(EntityPlayer player, int side) - { - super.onRightClick(player, side); - player.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + LangUtils.localize("tooltip.configurator.viewColor") + ": " + (getTransmitter().getColor() != null ? getTransmitter().getColor().getName() : "None"))); - return true; - } + return data; + } - @Override - public EnumColor getRenderColor(boolean post) - { - return post ? null : getTransmitter().getColor(); - } + public ArrayList getSyncPacket(TransporterStack stack, boolean kill) { + ArrayList data = new ArrayList(); - @Override - public boolean transparencyRender() - { - return true; - } + data.add(1); + data.add(kill); + data.add(getTransmitter().transit.indexOf(stack)); - @Override - public void onRemoved() - { - super.onRemoved(); + if (!kill) { + stack.write(getTransmitter(), data); + } - if(!world().isRemote) - { - for(TransporterStack stack : getTransmitter().transit) - { - TransporterUtils.drop(getTransmitter(), stack); - } - } - } + return data; + } - @Override - public int getCapacity() - { - return 0; - } + @Override + public void load(NBTTagCompound nbtTags) { + super.load(nbtTags); - @Override - public Object getBuffer() - { - return null; - } + tier = TransporterTier.values()[nbtTags.getInteger("tier")]; - @Override - public void takeShare() {} + if (nbtTags.hasKey("color")) { + getTransmitter().setColor( + TransporterUtils.colors.get(nbtTags.getInteger("color")) + ); + } + + if (nbtTags.hasKey("stacks")) { + NBTTagList tagList = nbtTags.getTagList("stacks", NBT.TAG_COMPOUND); + + for (int i = 0; i < tagList.tagCount(); i++) { + TransporterStack stack + = TransporterStack.readFromNBT(tagList.getCompoundTagAt(i)); + + getTransmitter().transit.add(stack); + } + } + } + + @Override + public void save(NBTTagCompound nbtTags) { + super.save(nbtTags); + + nbtTags.setInteger("tier", tier.ordinal()); + + if (getTransmitter().getColor() != null) { + nbtTags.setInteger( + "color", TransporterUtils.colors.indexOf(getTransmitter().getColor()) + ); + } + + NBTTagList stacks = new NBTTagList(); + + for (TransporterStack stack : getTransmitter().transit) { + NBTTagCompound tagCompound = new NBTTagCompound(); + stack.write(tagCompound); + stacks.appendTag(tagCompound); + } + + if (stacks.tagCount() != 0) { + nbtTags.setTag("stacks", stacks); + } + } + + @Override + protected boolean onConfigure(EntityPlayer player, int part, int side) { + TransporterUtils.incrementColor(getTransmitter()); + onPartChanged(this); + PathfinderCache.onChanged(Coord4D.get(tile())); + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage(Coord4D.get(tile()), getNetworkedData(new ArrayList())), + new Range4D(Coord4D.get(tile())) + ); + player.addChatMessage(new ChatComponentText( + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + + LangUtils.localize("tooltip.configurator.toggleColor") + ": " + + (getTransmitter().getColor() != null + ? getTransmitter().getColor().getName() + : EnumColor.BLACK + LangUtils.localize("gui.none")) + )); + + return true; + } + + @Override + public boolean onRightClick(EntityPlayer player, int side) { + super.onRightClick(player, side); + player.addChatMessage(new ChatComponentText( + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " " + + LangUtils.localize("tooltip.configurator.viewColor") + ": " + + (getTransmitter().getColor() != null ? getTransmitter().getColor().getName() + : "None") + )); + return true; + } + + @Override + public EnumColor getRenderColor(boolean post) { + return post ? null : getTransmitter().getColor(); + } + + @Override + public boolean transparencyRender() { + return true; + } + + @Override + public void onRemoved() { + super.onRemoved(); + + if (!world().isRemote) { + for (TransporterStack stack : getTransmitter().transit) { + TransporterUtils.drop(getTransmitter(), stack); + } + } + } + + @Override + public int getCapacity() { + return 0; + } + + @Override + public Object getBuffer() { + return null; + } + + @Override + public void takeShare() {} @Override public void updateShare() {} - @Override - public MultipartTransporter getTransmitter() - { - return (MultipartTransporter)transmitterDelegate; - } + @Override + public MultipartTransporter getTransmitter() { + return (MultipartTransporter) transmitterDelegate; + } - public double getCost() - { - return (double)TransporterTier.ULTIMATE.speed / (double)tier.speed; - } - - @Override - public boolean upgrade(int tierOrdinal) - { - if(tier.ordinal() < BaseTier.ULTIMATE.ordinal() && tierOrdinal == tier.ordinal()+1) - { - tier = TransporterTier.values()[tier.ordinal()+1]; - - markDirtyTransmitters(); - sendDesc = true; - - return true; - } - - return false; - } - - @Override - public void readDesc(MCDataInput packet) - { - tier = TransporterTier.values()[packet.readInt()]; - - super.readDesc(packet); - } + public double getCost() { + return (double) TransporterTier.ULTIMATE.speed / (double) tier.speed; + } - @Override - public void writeDesc(MCDataOutput packet) - { - packet.writeInt(tier.ordinal()); - - super.writeDesc(packet); - } + @Override + public boolean upgrade(int tierOrdinal) { + if (tier.ordinal() < BaseTier.ULTIMATE.ordinal() + && tierOrdinal == tier.ordinal() + 1) { + tier = TransporterTier.values()[tier.ordinal() + 1]; + + markDirtyTransmitters(); + sendDesc = true; + + return true; + } + + return false; + } + + @Override + public void readDesc(MCDataInput packet) { + tier = TransporterTier.values()[packet.readInt()]; + + super.readDesc(packet); + } + + @Override + public void writeDesc(MCDataOutput packet) { + packet.writeInt(tier.ordinal()); + + super.writeDesc(packet); + } } diff --git a/src/main/java/mekanism/common/multipart/PartMechanicalPipe.java b/src/main/java/mekanism/common/multipart/PartMechanicalPipe.java index 03b085718..439ddfe71 100644 --- a/src/main/java/mekanism/common/multipart/PartMechanicalPipe.java +++ b/src/main/java/mekanism/common/multipart/PartMechanicalPipe.java @@ -2,6 +2,11 @@ package mekanism.common.multipart; import java.util.Collection; +import codechicken.lib.data.MCDataInput; +import codechicken.lib.data.MCDataOutput; +import codechicken.lib.vec.Vector3; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.MekanismConfig.client; import mekanism.api.transmitters.TransmissionType; import mekanism.client.render.RenderPartTransmitter; @@ -22,331 +27,311 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; -import codechicken.lib.data.MCDataInput; -import codechicken.lib.data.MCDataOutput; -import codechicken.lib.vec.Vector3; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class PartMechanicalPipe extends PartTransmitter implements IFluidHandler -{ - public static TransmitterIcons pipeIcons = new TransmitterIcons(4, 8); +public class PartMechanicalPipe + extends PartTransmitter implements IFluidHandler { + public static TransmitterIcons pipeIcons = new TransmitterIcons(4, 8); - public float currentScale; + public float currentScale; - public FluidTank buffer = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME); + public FluidTank buffer = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME); - public FluidStack lastWrite; + public FluidStack lastWrite; - public Tier.PipeTier tier; + public Tier.PipeTier tier; - public PartMechanicalPipe(Tier.PipeTier pipeTier) - { - super(); - tier = pipeTier; - buffer.setCapacity(getCapacity()); - } - - @Override - public void update() - { - if(!world().isRemote) - { - updateShare(); - - IFluidHandler[] connectedAcceptors = PipeUtils.getConnectedAcceptors(tile()); - - for(ForgeDirection side : getConnections(ConnectionType.PULL)) - { - if(connectedAcceptors[side.ordinal()] != null) - { - IFluidHandler container = connectedAcceptors[side.ordinal()]; - - if(container != null) - { - FluidStack received = container.drain(side.getOpposite(), getPullAmount(), false); - - if(received != null && received.amount != 0) - { - container.drain(side.getOpposite(), takeFluid(received, true), true); - } - } - } - } - } - - super.update(); - } + public PartMechanicalPipe(Tier.PipeTier pipeTier) { + super(); + tier = pipeTier; + buffer.setCapacity(getCapacity()); + } @Override - public void updateShare() - { - if(getTransmitter().hasTransmitterNetwork() && getTransmitter().getTransmitterNetworkSize() > 0) - { + public void update() { + if (!world().isRemote) { + updateShare(); + + IFluidHandler[] connectedAcceptors = PipeUtils.getConnectedAcceptors(tile()); + + for (ForgeDirection side : getConnections(ConnectionType.PULL)) { + if (connectedAcceptors[side.ordinal()] != null) { + IFluidHandler container = connectedAcceptors[side.ordinal()]; + + if (container != null) { + FluidStack received + = container.drain(side.getOpposite(), getPullAmount(), false); + + if (received != null && received.amount != 0) { + container.drain( + side.getOpposite(), takeFluid(received, true), true + ); + } + } + } + } + } + + super.update(); + } + + @Override + public void updateShare() { + if (getTransmitter().hasTransmitterNetwork() + && getTransmitter().getTransmitterNetworkSize() > 0) { FluidStack last = getSaveShare(); - if((last != null && !(lastWrite != null && lastWrite.amount == last.amount && lastWrite.getFluid() == last.getFluid())) || (last == null && lastWrite != null)) - { + if ((last != null + && !( + lastWrite != null && lastWrite.amount == last.amount + && lastWrite.getFluid() == last.getFluid() + )) + || (last == null && lastWrite != null)) { lastWrite = last; MekanismUtils.saveChunk(tile()); } } } - private FluidStack getSaveShare() - { - if(getTransmitter().hasTransmitterNetwork() && getTransmitter().getTransmitterNetwork().buffer != null) - { - int remain = getTransmitter().getTransmitterNetwork().buffer.amount%getTransmitter().getTransmitterNetwork().transmitters.size(); - int toSave = getTransmitter().getTransmitterNetwork().buffer.amount/getTransmitter().getTransmitterNetwork().transmitters.size(); + private FluidStack getSaveShare() { + if (getTransmitter().hasTransmitterNetwork() + && getTransmitter().getTransmitterNetwork().buffer != null) { + int remain = getTransmitter().getTransmitterNetwork().buffer.amount + % getTransmitter().getTransmitterNetwork().transmitters.size(); + int toSave = getTransmitter().getTransmitterNetwork().buffer.amount + / getTransmitter().getTransmitterNetwork().transmitters.size(); - if(getTransmitter().getTransmitterNetwork().transmitters.iterator().next().equals(getTransmitter())) - { - toSave += remain; - } + if (getTransmitter() + .getTransmitterNetwork() + .transmitters.iterator() + .next() + .equals(getTransmitter())) { + toSave += remain; + } - return PipeUtils.copy(getTransmitter().getTransmitterNetwork().buffer, toSave); - } + return PipeUtils.copy( + getTransmitter().getTransmitterNetwork().buffer, toSave + ); + } - return null; - } + return null; + } - @Override - public void onChunkUnload() - { - if(!world().isRemote && getTransmitter().hasTransmitterNetwork()) - { - if(lastWrite != null && getTransmitter().getTransmitterNetwork().buffer != null) - { - getTransmitter().getTransmitterNetwork().buffer.amount -= lastWrite.amount; + @Override + public void onChunkUnload() { + if (!world().isRemote && getTransmitter().hasTransmitterNetwork()) { + if (lastWrite != null + && getTransmitter().getTransmitterNetwork().buffer != null) { + getTransmitter().getTransmitterNetwork().buffer.amount + -= lastWrite.amount; - if(getTransmitter().getTransmitterNetwork().buffer.amount <= 0) - { - getTransmitter().getTransmitterNetwork().buffer = null; - } - } - } + if (getTransmitter().getTransmitterNetwork().buffer.amount <= 0) { + getTransmitter().getTransmitterNetwork().buffer = null; + } + } + } - super.onChunkUnload(); - } + super.onChunkUnload(); + } - @Override - public void load(NBTTagCompound nbtTags) - { - super.load(nbtTags); - - tier = Tier.PipeTier.values()[nbtTags.getInteger("tier")]; - buffer.setCapacity(getCapacity()); + @Override + public void load(NBTTagCompound nbtTags) { + super.load(nbtTags); - if(nbtTags.hasKey("cacheFluid")) - { - buffer.setFluid(FluidStack.loadFluidStackFromNBT(nbtTags.getCompoundTag("cacheFluid"))); - } - else { + tier = Tier.PipeTier.values()[nbtTags.getInteger("tier")]; + buffer.setCapacity(getCapacity()); + + if (nbtTags.hasKey("cacheFluid")) { + buffer.setFluid( + FluidStack.loadFluidStackFromNBT(nbtTags.getCompoundTag("cacheFluid")) + ); + } else { buffer.setFluid(null); } - } + } - @Override - public void save(NBTTagCompound nbtTags) - { - super.save(nbtTags); + @Override + public void save(NBTTagCompound nbtTags) { + super.save(nbtTags); - if(lastWrite != null && lastWrite.amount > 0) - { - nbtTags.setTag("cacheFluid", lastWrite.writeToNBT(new NBTTagCompound())); - } - else { + if (lastWrite != null && lastWrite.amount > 0) { + nbtTags.setTag("cacheFluid", lastWrite.writeToNBT(new NBTTagCompound())); + } else { nbtTags.removeTag("cacheFluid"); } - nbtTags.setInteger("tier", tier.ordinal()); - } + nbtTags.setInteger("tier", tier.ordinal()); + } - @Override - public String getType() - { - return "mekanism:mechanical_pipe_" + tier.name().toLowerCase(); - } + @Override + public String getType() { + return "mekanism:mechanical_pipe_" + tier.name().toLowerCase(); + } - public static void registerIcons(IIconRegister register) - { - pipeIcons.registerCenterIcons(register, new String[] {"MechanicalPipeBasic", "MechanicalPipeAdvanced", "MechanicalPipeElite", "MechanicalPipeUltimate"}); - pipeIcons.registerSideIcons(register, new String[] {"MechanicalPipeVerticalBasic", "MechanicalPipeVerticalAdvanced", "MechanicalPipeVerticalElite", "MechanicalPipeVerticalUltimate", - "MechanicalPipeHorizontalBasic", "MechanicalPipeHorizontalAdvanced", "MechanicalPipeHorizontalElite", "MechanicalPipeHorizontalUltimate"}); - } + public static void registerIcons(IIconRegister register) { + pipeIcons.registerCenterIcons( + register, + new String[] { "MechanicalPipeBasic", + "MechanicalPipeAdvanced", + "MechanicalPipeElite", + "MechanicalPipeUltimate" } + ); + pipeIcons.registerSideIcons( + register, + new String[] { "MechanicalPipeVerticalBasic", + "MechanicalPipeVerticalAdvanced", + "MechanicalPipeVerticalElite", + "MechanicalPipeVerticalUltimate", + "MechanicalPipeHorizontalBasic", + "MechanicalPipeHorizontalAdvanced", + "MechanicalPipeHorizontalElite", + "MechanicalPipeHorizontalUltimate" } + ); + } - @Override - public IIcon getCenterIcon(boolean opaque) - { - return pipeIcons.getCenterIcon(tier.ordinal()); - } + @Override + public IIcon getCenterIcon(boolean opaque) { + return pipeIcons.getCenterIcon(tier.ordinal()); + } - @Override - public IIcon getSideIcon(boolean opaque) - { - return pipeIcons.getSideIcon(tier.ordinal()); - } + @Override + public IIcon getSideIcon(boolean opaque) { + return pipeIcons.getSideIcon(tier.ordinal()); + } - @Override - public IIcon getSideIconRotated(boolean opaque) - { - return pipeIcons.getSideIcon(4+tier.ordinal()); - } + @Override + public IIcon getSideIconRotated(boolean opaque) { + return pipeIcons.getSideIcon(4 + tier.ordinal()); + } - @Override - public TransmissionType getTransmissionType() - { - return TransmissionType.FLUID; - } + @Override + public TransmissionType getTransmissionType() { + return TransmissionType.FLUID; + } - @Override - public TransmitterType getTransmitterType() - { - return tier.type; - } + @Override + public TransmitterType getTransmitterType() { + return tier.type; + } - @Override - public boolean isValidAcceptor(TileEntity acceptor, ForgeDirection side) - { - return PipeUtils.isValidAcceptorOnSide(acceptor, side); - } + @Override + public boolean isValidAcceptor(TileEntity acceptor, ForgeDirection side) { + return PipeUtils.isValidAcceptorOnSide(acceptor, side); + } - @Override - public FluidNetwork createNewNetwork() - { - return new FluidNetwork(); - } + @Override + public FluidNetwork createNewNetwork() { + return new FluidNetwork(); + } - @Override - public FluidNetwork createNetworkByMerging(Collection networks) - { - return new FluidNetwork(networks); - } + @Override + public FluidNetwork createNetworkByMerging(Collection networks) { + return new FluidNetwork(networks); + } - @Override - @SideOnly(Side.CLIENT) - public void renderDynamic(Vector3 pos, float f, int pass) - { - if(pass == 0 && !client.opaqueTransmitters) - { - RenderPartTransmitter.getInstance().renderContents(this, pos); - } - } + @Override + @SideOnly(Side.CLIENT) + public void renderDynamic(Vector3 pos, float f, int pass) { + if (pass == 0 && !client.opaqueTransmitters) { + RenderPartTransmitter.getInstance().renderContents(this, pos); + } + } - @Override - public int getCapacity() - { - return tier.pipeCapacity; - } + @Override + public int getCapacity() { + return tier.pipeCapacity; + } - @Override - public FluidStack getBuffer() - { - return buffer == null ? null : buffer.getFluid(); - } + @Override + public FluidStack getBuffer() { + return buffer == null ? null : buffer.getFluid(); + } - @Override - public void takeShare() - { - if(getTransmitter().hasTransmitterNetwork() && getTransmitter().getTransmitterNetwork().buffer != null && lastWrite != null) - { - getTransmitter().getTransmitterNetwork().buffer.amount -= lastWrite.amount; - buffer.setFluid(lastWrite); - } - } + @Override + public void takeShare() { + if (getTransmitter().hasTransmitterNetwork() + && getTransmitter().getTransmitterNetwork().buffer != null + && lastWrite != null) { + getTransmitter().getTransmitterNetwork().buffer.amount -= lastWrite.amount; + buffer.setFluid(lastWrite); + } + } - @Override - public int fill(ForgeDirection from, FluidStack resource, boolean doFill) - { - if(getConnectionType(from) == ConnectionType.NORMAL) - { - return takeFluid(resource, doFill); - } + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { + if (getConnectionType(from) == ConnectionType.NORMAL) { + return takeFluid(resource, doFill); + } - return 0; - } + return 0; + } - @Override - public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) - { - return null; - } + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { + return null; + } - @Override - public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) - { - return null; - } + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + return null; + } - @Override - public boolean canFill(ForgeDirection from, Fluid fluid) - { - return getConnectionType(from) == ConnectionType.NORMAL; - } + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + return getConnectionType(from) == ConnectionType.NORMAL; + } - @Override - public boolean canDrain(ForgeDirection from, Fluid fluid) - { - return false; - } + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + return false; + } - @Override - public FluidTankInfo[] getTankInfo(ForgeDirection from) - { - if(getConnectionType(from) != ConnectionType.NONE) - { - return new FluidTankInfo[] {buffer.getInfo()}; - } + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection from) { + if (getConnectionType(from) != ConnectionType.NONE) { + return new FluidTankInfo[] { buffer.getInfo() }; + } - return new FluidTankInfo[0]; - } + return new FluidTankInfo[0]; + } - public int getPullAmount() - { - return tier.pipePullAmount; - } + public int getPullAmount() { + return tier.pipePullAmount; + } - public int takeFluid(FluidStack fluid, boolean doEmit) - { - if(getTransmitter().hasTransmitterNetwork()) - { - return getTransmitter().getTransmitterNetwork().emit(fluid, doEmit); - } - else { - return buffer.fill(fluid, doEmit); - } - } - - @Override - public boolean upgrade(int tierOrdinal) - { - if(tier.ordinal() < BaseTier.ULTIMATE.ordinal() && tierOrdinal == tier.ordinal()+1) - { - tier = PipeTier.values()[tier.ordinal()+1]; - - markDirtyTransmitters(); - sendDesc = true; - - return true; - } - - return false; - } - - @Override - public void readDesc(MCDataInput packet) - { - tier = PipeTier.values()[packet.readInt()]; - - super.readDesc(packet); - } + public int takeFluid(FluidStack fluid, boolean doEmit) { + if (getTransmitter().hasTransmitterNetwork()) { + return getTransmitter().getTransmitterNetwork().emit(fluid, doEmit); + } else { + return buffer.fill(fluid, doEmit); + } + } - @Override - public void writeDesc(MCDataOutput packet) - { - packet.writeInt(tier.ordinal()); - - super.writeDesc(packet); - } + @Override + public boolean upgrade(int tierOrdinal) { + if (tier.ordinal() < BaseTier.ULTIMATE.ordinal() + && tierOrdinal == tier.ordinal() + 1) { + tier = PipeTier.values()[tier.ordinal() + 1]; + + markDirtyTransmitters(); + sendDesc = true; + + return true; + } + + return false; + } + + @Override + public void readDesc(MCDataInput packet) { + tier = PipeTier.values()[packet.readInt()]; + + super.readDesc(packet); + } + + @Override + public void writeDesc(MCDataOutput packet) { + packet.writeInt(tier.ordinal()); + + super.writeDesc(packet); + } } diff --git a/src/main/java/mekanism/common/multipart/PartPressurizedTube.java b/src/main/java/mekanism/common/multipart/PartPressurizedTube.java index 1389b3a41..750d6db13 100644 --- a/src/main/java/mekanism/common/multipart/PartPressurizedTube.java +++ b/src/main/java/mekanism/common/multipart/PartPressurizedTube.java @@ -2,6 +2,11 @@ package mekanism.common.multipart; import java.util.Collection; +import codechicken.lib.data.MCDataInput; +import codechicken.lib.data.MCDataOutput; +import codechicken.lib.vec.Vector3; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.MekanismConfig.client; import mekanism.api.gas.Gas; import mekanism.api.gas.GasNetwork; @@ -20,340 +25,322 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraftforge.common.util.ForgeDirection; -import codechicken.lib.data.MCDataInput; -import codechicken.lib.data.MCDataOutput; -import codechicken.lib.vec.Vector3; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class PartPressurizedTube extends PartTransmitter implements IGasHandler -{ - public Tier.TubeTier tier = Tier.TubeTier.BASIC; - - public static TransmitterIcons tubeIcons = new TransmitterIcons(4, 8); +public class PartPressurizedTube + extends PartTransmitter implements IGasHandler { + public Tier.TubeTier tier = Tier.TubeTier.BASIC; - public float currentScale; + public static TransmitterIcons tubeIcons = new TransmitterIcons(4, 8); - public GasTank buffer = new GasTank(getCapacity()); + public float currentScale; - public GasStack lastWrite; - - public PartPressurizedTube(Tier.TubeTier tubeTier) - { - super(); - tier = tubeTier; - } + public GasTank buffer = new GasTank(getCapacity()); - @Override - public void update() - { - if(!world().isRemote) - { - updateShare(); + public GasStack lastWrite; - IGasHandler[] connectedAcceptors = GasTransmission.getConnectedAcceptors(tile()); - - for(ForgeDirection side : getConnections(ConnectionType.PULL)) - { - if(connectedAcceptors[side.ordinal()] != null) - { - IGasHandler container = connectedAcceptors[side.ordinal()]; - - if(container != null) - { - GasStack received = container.drawGas(side.getOpposite(), tier.tubePullAmount, false); - - if(received != null && received.amount != 0) - { - container.drawGas(side.getOpposite(), takeGas(received, true), true); - } - } - } - } - - } - else { - float targetScale = getTransmitter().hasTransmitterNetwork() ? getTransmitter().getTransmitterNetwork().gasScale : (float)buffer.getStored()/(float)buffer.getMaxGas(); - - if(Math.abs(currentScale - targetScale) > 0.01) - { - currentScale = (9 * currentScale + targetScale) / 10; - } - } - - super.update(); - } + public PartPressurizedTube(Tier.TubeTier tubeTier) { + super(); + tier = tubeTier; + } @Override - public void updateShare() - { - if(getTransmitter().hasTransmitterNetwork() && getTransmitter().getTransmitterNetworkSize() > 0) - { + public void update() { + if (!world().isRemote) { + updateShare(); + + IGasHandler[] connectedAcceptors + = GasTransmission.getConnectedAcceptors(tile()); + + for (ForgeDirection side : getConnections(ConnectionType.PULL)) { + if (connectedAcceptors[side.ordinal()] != null) { + IGasHandler container = connectedAcceptors[side.ordinal()]; + + if (container != null) { + GasStack received = container.drawGas( + side.getOpposite(), tier.tubePullAmount, false + ); + + if (received != null && received.amount != 0) { + container.drawGas( + side.getOpposite(), takeGas(received, true), true + ); + } + } + } + } + + } else { + float targetScale = getTransmitter().hasTransmitterNetwork() + ? getTransmitter().getTransmitterNetwork().gasScale + : (float) buffer.getStored() / (float) buffer.getMaxGas(); + + if (Math.abs(currentScale - targetScale) > 0.01) { + currentScale = (9 * currentScale + targetScale) / 10; + } + } + + super.update(); + } + + @Override + public void updateShare() { + if (getTransmitter().hasTransmitterNetwork() + && getTransmitter().getTransmitterNetworkSize() > 0) { GasStack last = getSaveShare(); - if((last != null && !(lastWrite != null && lastWrite.amount == last.amount && lastWrite.getGas() == last.getGas())) || (last == null && lastWrite != null)) - { + if ((last != null + && !( + lastWrite != null && lastWrite.amount == last.amount + && lastWrite.getGas() == last.getGas() + )) + || (last == null && lastWrite != null)) { lastWrite = last; MekanismUtils.saveChunk(tile()); } } } - private GasStack getSaveShare() - { - if(getTransmitter().hasTransmitterNetwork() && getTransmitter().getTransmitterNetwork().buffer != null) - { - int remain = getTransmitter().getTransmitterNetwork().buffer.amount%getTransmitter().getTransmitterNetwork().transmitters.size(); - int toSave = getTransmitter().getTransmitterNetwork().buffer.amount/getTransmitter().getTransmitterNetwork().transmitters.size(); + private GasStack getSaveShare() { + if (getTransmitter().hasTransmitterNetwork() + && getTransmitter().getTransmitterNetwork().buffer != null) { + int remain = getTransmitter().getTransmitterNetwork().buffer.amount + % getTransmitter().getTransmitterNetwork().transmitters.size(); + int toSave = getTransmitter().getTransmitterNetwork().buffer.amount + / getTransmitter().getTransmitterNetwork().transmitters.size(); - if(getTransmitter().getTransmitterNetwork().transmitters.iterator().next().equals(getTransmitter())) - { - toSave += remain; - } + if (getTransmitter() + .getTransmitterNetwork() + .transmitters.iterator() + .next() + .equals(getTransmitter())) { + toSave += remain; + } - return new GasStack(getTransmitter().getTransmitterNetwork().buffer.getGas(), toSave); - } + return new GasStack( + getTransmitter().getTransmitterNetwork().buffer.getGas(), toSave + ); + } - return null; - } + return null; + } - @Override - public void onChunkUnload() - { - if(!world().isRemote && getTransmitter().hasTransmitterNetwork()) - { - if(lastWrite != null && getTransmitter().getTransmitterNetwork().buffer != null) - { - getTransmitter().getTransmitterNetwork().buffer.amount -= lastWrite.amount; + @Override + public void onChunkUnload() { + if (!world().isRemote && getTransmitter().hasTransmitterNetwork()) { + if (lastWrite != null + && getTransmitter().getTransmitterNetwork().buffer != null) { + getTransmitter().getTransmitterNetwork().buffer.amount + -= lastWrite.amount; - if(getTransmitter().getTransmitterNetwork().buffer.amount <= 0) - { - getTransmitter().getTransmitterNetwork().buffer = null; - } - } - } + if (getTransmitter().getTransmitterNetwork().buffer.amount <= 0) { + getTransmitter().getTransmitterNetwork().buffer = null; + } + } + } - super.onChunkUnload(); - } + super.onChunkUnload(); + } - @Override - public void load(NBTTagCompound nbtTags) - { - super.load(nbtTags); - - tier = TubeTier.values()[nbtTags.getInteger("tier")]; - buffer.setMaxGas(getCapacity()); + @Override + public void load(NBTTagCompound nbtTags) { + super.load(nbtTags); - if(nbtTags.hasKey("cacheGas")) - { - buffer.setGas(GasStack.readFromNBT(nbtTags.getCompoundTag("cacheGas"))); - } - else { + tier = TubeTier.values()[nbtTags.getInteger("tier")]; + buffer.setMaxGas(getCapacity()); + + if (nbtTags.hasKey("cacheGas")) { + buffer.setGas(GasStack.readFromNBT(nbtTags.getCompoundTag("cacheGas"))); + } else { buffer.setGas(null); } - } + } - @Override - public void save(NBTTagCompound nbtTags) - { - super.save(nbtTags); + @Override + public void save(NBTTagCompound nbtTags) { + super.save(nbtTags); - if(lastWrite != null && lastWrite.amount > 0) - { + if (lastWrite != null && lastWrite.amount > 0) { nbtTags.setTag("cacheGas", lastWrite.write(new NBTTagCompound())); - } - else { + } else { nbtTags.removeTag("cacheGas"); - } + } nbtTags.setInteger("tier", tier.ordinal()); - } + } - @Override - public String getType() - { - return "mekanism:pressurized_tube_" + tier.name().toLowerCase(); - } + @Override + public String getType() { + return "mekanism:pressurized_tube_" + tier.name().toLowerCase(); + } - public static void registerIcons(IIconRegister register) - { - tubeIcons.registerCenterIcons(register, new String[] {"PressurizedTubeBasic", "PressurizedTubeAdvanced", "PressurizedTubeElite", "PressurizedTubeUltimate"}); - tubeIcons.registerSideIcons(register, new String[] {"PressurizedTubeVerticalBasic", "PressurizedTubeVerticalAdvanced", "PressurizedTubeVerticalElite", "PressurizedTubeVerticalUltimate", - "PressurizedTubeHorizontalBasic", "PressurizedTubeHorizontalAdvanced", "PressurizedTubeHorizontalElite", "PressurizedTubeHorizontalUltimate"}); - } + public static void registerIcons(IIconRegister register) { + tubeIcons.registerCenterIcons( + register, + new String[] { "PressurizedTubeBasic", + "PressurizedTubeAdvanced", + "PressurizedTubeElite", + "PressurizedTubeUltimate" } + ); + tubeIcons.registerSideIcons( + register, + new String[] { "PressurizedTubeVerticalBasic", + "PressurizedTubeVerticalAdvanced", + "PressurizedTubeVerticalElite", + "PressurizedTubeVerticalUltimate", + "PressurizedTubeHorizontalBasic", + "PressurizedTubeHorizontalAdvanced", + "PressurizedTubeHorizontalElite", + "PressurizedTubeHorizontalUltimate" } + ); + } - @Override - public IIcon getCenterIcon(boolean opaque) - { - return tubeIcons.getCenterIcon(tier.ordinal()); - } + @Override + public IIcon getCenterIcon(boolean opaque) { + return tubeIcons.getCenterIcon(tier.ordinal()); + } - @Override - public IIcon getSideIcon(boolean opaque) - { - return tubeIcons.getSideIcon(tier.ordinal()); - } + @Override + public IIcon getSideIcon(boolean opaque) { + return tubeIcons.getSideIcon(tier.ordinal()); + } - @Override - public IIcon getSideIconRotated(boolean opaque) - { - return tubeIcons.getSideIcon(4+tier.ordinal()); - } + @Override + public IIcon getSideIconRotated(boolean opaque) { + return tubeIcons.getSideIcon(4 + tier.ordinal()); + } - @Override - public TransmissionType getTransmissionType() - { - return TransmissionType.GAS; - } + @Override + public TransmissionType getTransmissionType() { + return TransmissionType.GAS; + } - @Override - public TransmitterType getTransmitterType() - { - return tier.type; - } + @Override + public TransmitterType getTransmitterType() { + return tier.type; + } - @Override - public boolean isValidAcceptor(TileEntity tile, ForgeDirection side) - { - return GasTransmission.canConnect(tile, side); - } + @Override + public boolean isValidAcceptor(TileEntity tile, ForgeDirection side) { + return GasTransmission.canConnect(tile, side); + } - @Override - public GasNetwork createNewNetwork() - { - return new GasNetwork(); - } + @Override + public GasNetwork createNewNetwork() { + return new GasNetwork(); + } - @Override - public GasNetwork createNetworkByMerging(Collection networks) - { - return new GasNetwork(networks); - } + @Override + public GasNetwork createNetworkByMerging(Collection networks) { + return new GasNetwork(networks); + } - @Override - @SideOnly(Side.CLIENT) - public void renderDynamic(Vector3 pos, float f, int pass) - { - if(pass == 0 && !client.opaqueTransmitters) - { - RenderPartTransmitter.getInstance().renderContents(this, pos); - } - } + @Override + @SideOnly(Side.CLIENT) + public void renderDynamic(Vector3 pos, float f, int pass) { + if (pass == 0 && !client.opaqueTransmitters) { + RenderPartTransmitter.getInstance().renderContents(this, pos); + } + } - @Override - public int getCapacity() - { - return tier.tubeCapacity; - } + @Override + public int getCapacity() { + return tier.tubeCapacity; + } - @Override - public GasStack getBuffer() - { - return buffer == null ? null : buffer.getGas(); - } + @Override + public GasStack getBuffer() { + return buffer == null ? null : buffer.getGas(); + } - @Override - public void takeShare() - { - if(getTransmitter().hasTransmitterNetwork() && getTransmitter().getTransmitterNetwork().buffer != null && lastWrite != null) - { + @Override + public void takeShare() { + if (getTransmitter().hasTransmitterNetwork() + && getTransmitter().getTransmitterNetwork().buffer != null + && lastWrite != null) { getTransmitter().getTransmitterNetwork().buffer.amount -= lastWrite.amount; buffer.setGas(lastWrite); } } - @Override - public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) - { - if(getConnectionType(side) == ConnectionType.NORMAL || getConnectionType(side) == ConnectionType.PULL) - { - return takeGas(stack, doTransfer); - } - - return 0; - } + @Override + public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) { + if (getConnectionType(side) == ConnectionType.NORMAL + || getConnectionType(side) == ConnectionType.PULL) { + return takeGas(stack, doTransfer); + } - @Override - public int receiveGas(ForgeDirection side, GasStack stack) - { - return receiveGas(side, stack, true); - } + return 0; + } - @Override - public GasStack drawGas(ForgeDirection side, int amount, boolean doTransfer) - { - return null; - } + @Override + public int receiveGas(ForgeDirection side, GasStack stack) { + return receiveGas(side, stack, true); + } - @Override - public GasStack drawGas(ForgeDirection side, int amount) - { - return drawGas(side, amount, true); - } + @Override + public GasStack drawGas(ForgeDirection side, int amount, boolean doTransfer) { + return null; + } - @Override - public boolean canReceiveGas(ForgeDirection side, Gas type) - { - return getConnectionType(side) == ConnectionType.NORMAL || getConnectionType(side) == ConnectionType.PULL; - } + @Override + public GasStack drawGas(ForgeDirection side, int amount) { + return drawGas(side, amount, true); + } - @Override - public boolean canDrawGas(ForgeDirection side, Gas type) - { - return false; - } + @Override + public boolean canReceiveGas(ForgeDirection side, Gas type) { + return getConnectionType(side) == ConnectionType.NORMAL + || getConnectionType(side) == ConnectionType.PULL; + } - public int takeGas(GasStack gasStack, boolean doEmit) - { - if(getTransmitter().hasTransmitterNetwork()) - { - return getTransmitter().getTransmitterNetwork().emit(gasStack, doEmit); - } - else { - return buffer.receive(gasStack, doEmit); - } - } + @Override + public boolean canDrawGas(ForgeDirection side, Gas type) { + return false; + } - @Override - public IGasHandler getCachedAcceptor(ForgeDirection side) - { - if(cachedAcceptors[side.ordinal()] instanceof IGasHandler) - { - return super.getCachedAcceptor(side); - } - - return null; - } - - @Override - public boolean upgrade(int tierOrdinal) - { - if(tier.ordinal() < BaseTier.ULTIMATE.ordinal() && tierOrdinal == tier.ordinal()+1) - { - tier = TubeTier.values()[tier.ordinal()+1]; - - markDirtyTransmitters(); - sendDesc = true; - - return true; - } - - return false; - } - - @Override - public void readDesc(MCDataInput packet) - { - tier = TubeTier.values()[packet.readInt()]; - - super.readDesc(packet); - } + public int takeGas(GasStack gasStack, boolean doEmit) { + if (getTransmitter().hasTransmitterNetwork()) { + return getTransmitter().getTransmitterNetwork().emit(gasStack, doEmit); + } else { + return buffer.receive(gasStack, doEmit); + } + } - @Override - public void writeDesc(MCDataOutput packet) - { - packet.writeInt(tier.ordinal()); - - super.writeDesc(packet); - } + @Override + public IGasHandler getCachedAcceptor(ForgeDirection side) { + if (cachedAcceptors[side.ordinal()] instanceof IGasHandler) { + return super.getCachedAcceptor(side); + } + + return null; + } + + @Override + public boolean upgrade(int tierOrdinal) { + if (tier.ordinal() < BaseTier.ULTIMATE.ordinal() + && tierOrdinal == tier.ordinal() + 1) { + tier = TubeTier.values()[tier.ordinal() + 1]; + + markDirtyTransmitters(); + sendDesc = true; + + return true; + } + + return false; + } + + @Override + public void readDesc(MCDataInput packet) { + tier = TubeTier.values()[packet.readInt()]; + + super.readDesc(packet); + } + + @Override + public void writeDesc(MCDataOutput packet) { + packet.writeInt(tier.ordinal()); + + super.writeDesc(packet); + } } diff --git a/src/main/java/mekanism/common/multipart/PartRestrictiveTransporter.java b/src/main/java/mekanism/common/multipart/PartRestrictiveTransporter.java index 266196094..805263719 100644 --- a/src/main/java/mekanism/common/multipart/PartRestrictiveTransporter.java +++ b/src/main/java/mekanism/common/multipart/PartRestrictiveTransporter.java @@ -3,53 +3,44 @@ package mekanism.common.multipart; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.IIcon; -public class PartRestrictiveTransporter extends PartLogisticalTransporter -{ - @Override - public String getType() - { - return "mekanism:restrictive_transporter"; - } +public class PartRestrictiveTransporter extends PartLogisticalTransporter { + @Override + public String getType() { + return "mekanism:restrictive_transporter"; + } - @Override - public TransmitterType getTransmitterType() - { - return TransmitterType.RESTRICTIVE_TRANSPORTER; - } + @Override + public TransmitterType getTransmitterType() { + return TransmitterType.RESTRICTIVE_TRANSPORTER; + } - @Override - public IIcon getCenterIcon(boolean opaque) - { - return transporterIcons.getCenterIcon(4); - } + @Override + public IIcon getCenterIcon(boolean opaque) { + return transporterIcons.getCenterIcon(4); + } - @Override - public IIcon getSideIcon(boolean opaque) - { - return transporterIcons.getSideIcon(8); - } + @Override + public IIcon getSideIcon(boolean opaque) { + return transporterIcons.getSideIcon(8); + } - @Override - public IIcon getSideIconRotated(boolean opaque) - { - return transporterIcons.getSideIcon(9); - } + @Override + public IIcon getSideIconRotated(boolean opaque) { + return transporterIcons.getSideIcon(9); + } - @Override - public double getCost() - { - return 1000; - } - - @Override - public boolean transparencyRender() - { - return false; - } - - @Override - protected boolean onConfigure(EntityPlayer player, int part, int side) - { - return false; - } + @Override + public double getCost() { + return 1000; + } + + @Override + public boolean transparencyRender() { + return false; + } + + @Override + protected boolean onConfigure(EntityPlayer player, int part, int side) { + return false; + } } diff --git a/src/main/java/mekanism/common/multipart/PartSidedPipe.java b/src/main/java/mekanism/common/multipart/PartSidedPipe.java index 70a98ee78..fd26369c7 100644 --- a/src/main/java/mekanism/common/multipart/PartSidedPipe.java +++ b/src/main/java/mekanism/common/multipart/PartSidedPipe.java @@ -1,7 +1,5 @@ package mekanism.common.multipart; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -9,6 +7,26 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import codechicken.lib.data.MCDataInput; +import codechicken.lib.data.MCDataOutput; +import codechicken.lib.raytracer.ExtendedMOP; +import codechicken.lib.raytracer.IndexedCuboid6; +import codechicken.lib.raytracer.RayTracer; +import codechicken.lib.render.CCModel; +import codechicken.lib.vec.Cuboid6; +import codechicken.lib.vec.Vector3; +import codechicken.microblock.ISidedHollowConnect; +import codechicken.multipart.INeighborTileChange; +import codechicken.multipart.IconHitEffects; +import codechicken.multipart.JIconHitEffects; +import codechicken.multipart.JNormalOcclusion; +import codechicken.multipart.NormalOcclusionTest; +import codechicken.multipart.PartMap; +import codechicken.multipart.TMultiPart; +import codechicken.multipart.TSlottedPart; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.IConfigurable; @@ -32,842 +50,751 @@ import net.minecraft.util.ChatComponentText; import net.minecraft.util.IIcon; import net.minecraft.util.MovingObjectPosition; import net.minecraftforge.common.util.ForgeDirection; -import codechicken.lib.data.MCDataInput; -import codechicken.lib.data.MCDataOutput; -import codechicken.lib.raytracer.ExtendedMOP; -import codechicken.lib.raytracer.IndexedCuboid6; -import codechicken.lib.raytracer.RayTracer; -import codechicken.lib.render.CCModel; -import codechicken.lib.vec.Cuboid6; -import codechicken.lib.vec.Vector3; -import codechicken.microblock.ISidedHollowConnect; -import codechicken.multipart.INeighborTileChange; -import codechicken.multipart.IconHitEffects; -import codechicken.multipart.JIconHitEffects; -import codechicken.multipart.JNormalOcclusion; -import codechicken.multipart.NormalOcclusionTest; -import codechicken.multipart.PartMap; -import codechicken.multipart.TMultiPart; -import codechicken.multipart.TSlottedPart; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public abstract class PartSidedPipe extends TMultiPart implements TSlottedPart, JNormalOcclusion, ISidedHollowConnect, JIconHitEffects, ITileNetwork, IBlockableConnection, IConfigurable, ITransmitter, INeighborTileChange -{ - public static IndexedCuboid6[] smallSides = new IndexedCuboid6[7]; - public static IndexedCuboid6[] largeSides = new IndexedCuboid6[7]; +public abstract class PartSidedPipe + extends TMultiPart implements TSlottedPart, JNormalOcclusion, ISidedHollowConnect, + JIconHitEffects, ITileNetwork, IBlockableConnection, + IConfigurable, ITransmitter, INeighborTileChange { + public static IndexedCuboid6[] smallSides = new IndexedCuboid6[7]; + public static IndexedCuboid6[] largeSides = new IndexedCuboid6[7]; - public int delayTicks; + public int delayTicks; - public ForgeDirection testingSide = null; + public ForgeDirection testingSide = null; - public byte currentAcceptorConnections = 0x00; - public byte currentTransmitterConnections = 0x00; + public byte currentAcceptorConnections = 0x00; + public byte currentTransmitterConnections = 0x00; - public boolean sendDesc = false; - public boolean redstonePowered = false; + public boolean sendDesc = false; + public boolean redstonePowered = false; - public boolean redstoneReactive = true; - - public boolean forceUpdate = false; + public boolean redstoneReactive = true; - public ConnectionType[] connectionTypes = {ConnectionType.NORMAL, ConnectionType.NORMAL, ConnectionType.NORMAL, ConnectionType.NORMAL, ConnectionType.NORMAL, ConnectionType.NORMAL}; - public TileEntity[] cachedAcceptors = new TileEntity[6]; + public boolean forceUpdate = false; - static - { - smallSides[0] = new IndexedCuboid6(0, new Cuboid6(0.3, 0.0, 0.3, 0.7, 0.3, 0.7)); - smallSides[1] = new IndexedCuboid6(1, new Cuboid6(0.3, 0.7, 0.3, 0.7, 1.0, 0.7)); - smallSides[2] = new IndexedCuboid6(2, new Cuboid6(0.3, 0.3, 0.0, 0.7, 0.7, 0.3)); - smallSides[3] = new IndexedCuboid6(3, new Cuboid6(0.3, 0.3, 0.7, 0.7, 0.7, 1.0)); - smallSides[4] = new IndexedCuboid6(4, new Cuboid6(0.0, 0.3, 0.3, 0.3, 0.7, 0.7)); - smallSides[5] = new IndexedCuboid6(5, new Cuboid6(0.7, 0.3, 0.3, 1.0, 0.7, 0.7)); - smallSides[6] = new IndexedCuboid6(6, new Cuboid6(0.3, 0.3, 0.3, 0.7, 0.7, 0.7)); + public ConnectionType[] connectionTypes + = { ConnectionType.NORMAL, ConnectionType.NORMAL, ConnectionType.NORMAL, + ConnectionType.NORMAL, ConnectionType.NORMAL, ConnectionType.NORMAL }; + public TileEntity[] cachedAcceptors = new TileEntity[6]; - largeSides[0] = new IndexedCuboid6(0, new Cuboid6(0.25, 0.0, 0.25, 0.75, 0.25, 0.75)); - largeSides[1] = new IndexedCuboid6(1, new Cuboid6(0.25, 0.75, 0.25, 0.75, 1.0, 0.75)); - largeSides[2] = new IndexedCuboid6(2, new Cuboid6(0.25, 0.25, 0.0, 0.75, 0.75, 0.25)); - largeSides[3] = new IndexedCuboid6(3, new Cuboid6(0.25, 0.25, 0.75, 0.75, 0.75, 1.0)); - largeSides[4] = new IndexedCuboid6(4, new Cuboid6(0.0, 0.25, 0.25, 0.25, 0.75, 0.75)); - largeSides[5] = new IndexedCuboid6(5, new Cuboid6(0.75, 0.25, 0.25, 1.0, 0.75, 0.75)); - largeSides[6] = new IndexedCuboid6(6, new Cuboid6(0.25, 0.25, 0.25, 0.75, 0.75, 0.75)); - } + static { + smallSides[0] = new IndexedCuboid6(0, new Cuboid6(0.3, 0.0, 0.3, 0.7, 0.3, 0.7)); + smallSides[1] = new IndexedCuboid6(1, new Cuboid6(0.3, 0.7, 0.3, 0.7, 1.0, 0.7)); + smallSides[2] = new IndexedCuboid6(2, new Cuboid6(0.3, 0.3, 0.0, 0.7, 0.7, 0.3)); + smallSides[3] = new IndexedCuboid6(3, new Cuboid6(0.3, 0.3, 0.7, 0.7, 0.7, 1.0)); + smallSides[4] = new IndexedCuboid6(4, new Cuboid6(0.0, 0.3, 0.3, 0.3, 0.7, 0.7)); + smallSides[5] = new IndexedCuboid6(5, new Cuboid6(0.7, 0.3, 0.3, 1.0, 0.7, 0.7)); + smallSides[6] = new IndexedCuboid6(6, new Cuboid6(0.3, 0.3, 0.3, 0.7, 0.7, 0.7)); - public static TMultiPart getPartType(TransmitterType type) - { - switch(type) - { - case UNIVERSAL_CABLE_BASIC: - return new PartUniversalCable(Tier.CableTier.BASIC); - case UNIVERSAL_CABLE_ADVANCED: - return new PartUniversalCable(Tier.CableTier.ADVANCED); - case UNIVERSAL_CABLE_ELITE: - return new PartUniversalCable(Tier.CableTier.ELITE); - case UNIVERSAL_CABLE_ULTIMATE: - return new PartUniversalCable(Tier.CableTier.ULTIMATE); - case MECHANICAL_PIPE_BASIC: - return new PartMechanicalPipe(Tier.PipeTier.BASIC); - case MECHANICAL_PIPE_ADVANCED: - return new PartMechanicalPipe(Tier.PipeTier.ADVANCED); - case MECHANICAL_PIPE_ELITE: - return new PartMechanicalPipe(Tier.PipeTier.ELITE); - case MECHANICAL_PIPE_ULTIMATE: - return new PartMechanicalPipe(Tier.PipeTier.ULTIMATE); - case PRESSURIZED_TUBE_BASIC: - return new PartPressurizedTube(Tier.TubeTier.BASIC); - case PRESSURIZED_TUBE_ADVANCED: - return new PartPressurizedTube(Tier.TubeTier.ADVANCED); - case PRESSURIZED_TUBE_ELITE: - return new PartPressurizedTube(Tier.TubeTier.ELITE); - case PRESSURIZED_TUBE_ULTIMATE: - return new PartPressurizedTube(Tier.TubeTier.ULTIMATE); - case LOGISTICAL_TRANSPORTER_BASIC: - return new PartLogisticalTransporter(Tier.TransporterTier.BASIC); - case LOGISTICAL_TRANSPORTER_ADVANCED: - return new PartLogisticalTransporter(Tier.TransporterTier.ADVANCED); - case LOGISTICAL_TRANSPORTER_ELITE: - return new PartLogisticalTransporter(Tier.TransporterTier.ELITE); - case LOGISTICAL_TRANSPORTER_ULTIMATE: - return new PartLogisticalTransporter(Tier.TransporterTier.ULTIMATE); - case RESTRICTIVE_TRANSPORTER: - return new PartRestrictiveTransporter(); - case DIVERSION_TRANSPORTER: - return new PartDiversionTransporter(); - case THERMODYNAMIC_CONDUCTOR_BASIC: - return new PartThermodynamicConductor(Tier.ConductorTier.BASIC); - case THERMODYNAMIC_CONDUCTOR_ADVANCED: - return new PartThermodynamicConductor(Tier.ConductorTier.ADVANCED); - case THERMODYNAMIC_CONDUCTOR_ELITE: - return new PartThermodynamicConductor(Tier.ConductorTier.ELITE); - case THERMODYNAMIC_CONDUCTOR_ULTIMATE: - return new PartThermodynamicConductor(Tier.ConductorTier.ULTIMATE); - default: - return null; - } - } + largeSides[0] + = new IndexedCuboid6(0, new Cuboid6(0.25, 0.0, 0.25, 0.75, 0.25, 0.75)); + largeSides[1] + = new IndexedCuboid6(1, new Cuboid6(0.25, 0.75, 0.25, 0.75, 1.0, 0.75)); + largeSides[2] + = new IndexedCuboid6(2, new Cuboid6(0.25, 0.25, 0.0, 0.75, 0.75, 0.25)); + largeSides[3] + = new IndexedCuboid6(3, new Cuboid6(0.25, 0.25, 0.75, 0.75, 0.75, 1.0)); + largeSides[4] + = new IndexedCuboid6(4, new Cuboid6(0.0, 0.25, 0.25, 0.25, 0.75, 0.75)); + largeSides[5] + = new IndexedCuboid6(5, new Cuboid6(0.75, 0.25, 0.25, 1.0, 0.75, 0.75)); + largeSides[6] + = new IndexedCuboid6(6, new Cuboid6(0.25, 0.25, 0.25, 0.75, 0.75, 0.75)); + } - public static boolean connectionMapContainsSide(byte connections, ForgeDirection side) - { - byte tester = (byte)(1 << side.ordinal()); - return (connections & tester) > 0; - } + public static TMultiPart getPartType(TransmitterType type) { + switch (type) { + case UNIVERSAL_CABLE_BASIC: + return new PartUniversalCable(Tier.CableTier.BASIC); + case UNIVERSAL_CABLE_ADVANCED: + return new PartUniversalCable(Tier.CableTier.ADVANCED); + case UNIVERSAL_CABLE_ELITE: + return new PartUniversalCable(Tier.CableTier.ELITE); + case UNIVERSAL_CABLE_ULTIMATE: + return new PartUniversalCable(Tier.CableTier.ULTIMATE); + case MECHANICAL_PIPE_BASIC: + return new PartMechanicalPipe(Tier.PipeTier.BASIC); + case MECHANICAL_PIPE_ADVANCED: + return new PartMechanicalPipe(Tier.PipeTier.ADVANCED); + case MECHANICAL_PIPE_ELITE: + return new PartMechanicalPipe(Tier.PipeTier.ELITE); + case MECHANICAL_PIPE_ULTIMATE: + return new PartMechanicalPipe(Tier.PipeTier.ULTIMATE); + case PRESSURIZED_TUBE_BASIC: + return new PartPressurizedTube(Tier.TubeTier.BASIC); + case PRESSURIZED_TUBE_ADVANCED: + return new PartPressurizedTube(Tier.TubeTier.ADVANCED); + case PRESSURIZED_TUBE_ELITE: + return new PartPressurizedTube(Tier.TubeTier.ELITE); + case PRESSURIZED_TUBE_ULTIMATE: + return new PartPressurizedTube(Tier.TubeTier.ULTIMATE); + case LOGISTICAL_TRANSPORTER_BASIC: + return new PartLogisticalTransporter(Tier.TransporterTier.BASIC); + case LOGISTICAL_TRANSPORTER_ADVANCED: + return new PartLogisticalTransporter(Tier.TransporterTier.ADVANCED); + case LOGISTICAL_TRANSPORTER_ELITE: + return new PartLogisticalTransporter(Tier.TransporterTier.ELITE); + case LOGISTICAL_TRANSPORTER_ULTIMATE: + return new PartLogisticalTransporter(Tier.TransporterTier.ULTIMATE); + case RESTRICTIVE_TRANSPORTER: + return new PartRestrictiveTransporter(); + case DIVERSION_TRANSPORTER: + return new PartDiversionTransporter(); + case THERMODYNAMIC_CONDUCTOR_BASIC: + return new PartThermodynamicConductor(Tier.ConductorTier.BASIC); + case THERMODYNAMIC_CONDUCTOR_ADVANCED: + return new PartThermodynamicConductor(Tier.ConductorTier.ADVANCED); + case THERMODYNAMIC_CONDUCTOR_ELITE: + return new PartThermodynamicConductor(Tier.ConductorTier.ELITE); + case THERMODYNAMIC_CONDUCTOR_ULTIMATE: + return new PartThermodynamicConductor(Tier.ConductorTier.ULTIMATE); + default: + return null; + } + } - public static byte setConnectionBit(byte connections, boolean toSet, ForgeDirection side) - { - return (byte)((connections & ~(byte)(1 << side.ordinal())) | (byte)((toSet?1:0) << side.ordinal())); - } + public static boolean + connectionMapContainsSide(byte connections, ForgeDirection side) { + byte tester = (byte) (1 << side.ordinal()); + return (connections & tester) > 0; + } - public abstract IIcon getCenterIcon(boolean opaque); + public static byte + setConnectionBit(byte connections, boolean toSet, ForgeDirection side) { + return (byte + ) ((connections & ~(byte) (1 << side.ordinal())) + | (byte) ((toSet ? 1 : 0) << side.ordinal())); + } - public abstract IIcon getSideIcon(boolean opaque); + public abstract IIcon getCenterIcon(boolean opaque); - public abstract IIcon getSideIconRotated(boolean opaque); + public abstract IIcon getSideIcon(boolean opaque); - @Override - public void update() - { - if(world().isRemote) - { - if(delayTicks == 5) - { - delayTicks = 6; /* don't refresh again */ - refreshConnections(); - } - else if(delayTicks < 5) - { - delayTicks++; - } - } + public abstract IIcon getSideIconRotated(boolean opaque); - if(!world().isRemote) - { - if(forceUpdate) - { - refreshConnections(); - forceUpdate = false; - } - - if(sendDesc) - { - sendDescUpdate(); - sendDesc = false; - } - } - } - - public boolean handlesRedstone() - { - return true; - } - - public boolean renderCenter() - { - return false; - } - - public boolean transparencyRender() - { - return false; - } + @Override + public void update() { + if (world().isRemote) { + if (delayTicks == 5) { + delayTicks = 6; /* don't refresh again */ + refreshConnections(); + } else if (delayTicks < 5) { + delayTicks++; + } + } - public IIcon getIconForSide(ForgeDirection side, boolean opaque) - { - ConnectionType type = getConnectionType(side); + if (!world().isRemote) { + if (forceUpdate) { + refreshConnections(); + forceUpdate = false; + } - if(type == ConnectionType.NONE) - { - if(client.oldTransmitterRender || renderCenter()) - { - return getCenterIcon(opaque); - } + if (sendDesc) { + sendDescUpdate(); + sendDesc = false; + } + } + } + + public boolean handlesRedstone() { + return true; + } + + public boolean renderCenter() { + return false; + } + + public boolean transparencyRender() { + return false; + } + + public IIcon getIconForSide(ForgeDirection side, boolean opaque) { + ConnectionType type = getConnectionType(side); + + if (type == ConnectionType.NONE) { + if (client.oldTransmitterRender || renderCenter()) { + return getCenterIcon(opaque); + } else if(getAllCurrentConnections() == 3 && side != ForgeDirection.DOWN && side != ForgeDirection.UP) { - return getSideIcon(opaque); - } + return getSideIcon(opaque); + } else if(getAllCurrentConnections() == 12 && (side == ForgeDirection.DOWN || side == ForgeDirection.UP)) { - return getSideIcon(opaque); - } + return getSideIcon(opaque); + } else if(getAllCurrentConnections() == 12 && (side == ForgeDirection.EAST || side == ForgeDirection.WEST)) { - return getSideIconRotated(opaque); - } + return getSideIconRotated(opaque); + } else if(getAllCurrentConnections() == 48 && side != ForgeDirection.EAST && side != ForgeDirection.WEST) { - return getSideIconRotated(opaque); - } - - return getCenterIcon(opaque); - } - else { - return getSideIcon(opaque); - } - } - - public byte getPossibleTransmitterConnections() - { - byte connections = 0x00; - - if(handlesRedstone() && redstoneReactive && redstonePowered) - { - return connections; - } - - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - if(canConnectMutual(side)) - { - TileEntity tileEntity = Coord4D.get(tile()).getFromSide(side).getTileEntity(world()); - - if(tileEntity instanceof ITransmitterTile && TransmissionType.checkTransmissionType(((ITransmitterTile)tileEntity).getTransmitter(), getTransmitterType().getTransmission()) && isValidTransmitter(tileEntity)) - { - connections |= 1 << side.ordinal(); - } - } - } - - return connections; - } - - public boolean getPossibleAcceptorConnection(ForgeDirection side) - { - if(handlesRedstone() && redstoneReactive && redstonePowered) - { - return false; - } - - if(canConnectMutual(side)) - { - TileEntity tileEntity = Coord4D.get(tile()).getFromSide(side).getTileEntity(world()); - - if(isValidAcceptor(tileEntity, side)) - { - if(cachedAcceptors[side.ordinal()] != tileEntity) - { - cachedAcceptors[side.ordinal()] = tileEntity; - markDirtyAcceptor(side); - } - - return true; - } - } - - if(cachedAcceptors[side.ordinal()] != null) - { - cachedAcceptors[side.ordinal()] = null; - markDirtyAcceptor(side); - } - - return false; - } - - public boolean getPossibleTransmitterConnection(ForgeDirection side) - { - if(handlesRedstone() && redstoneReactive && MekanismUtils.isGettingPowered(world(), Coord4D.get(tile()))) - { - return false; - } - - if(canConnectMutual(side)) - { - TileEntity tileEntity = Coord4D.get(tile()).getFromSide(side).getTileEntity(world()); - - if(tileEntity instanceof ITransmitterTile && TransmissionType.checkTransmissionType(((ITransmitterTile)tileEntity).getTransmitter(), getTransmitterType().getTransmission()) && isValidTransmitter(tileEntity)) - { - return true; - } - } - - return false; - } - - public byte getPossibleAcceptorConnections() - { - byte connections = 0x00; - - if(handlesRedstone() && redstoneReactive && redstonePowered) - { - return connections; - } - - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - if(canConnectMutual(side)) - { - Coord4D coord = Coord4D.get(tile()).getFromSide(side); - - if(!world().isRemote && !coord.exists(world())) - { - forceUpdate = true; - continue; - } - - TileEntity tileEntity = coord.getTileEntity(world()); - - if(isValidAcceptor(tileEntity, side)) - { - if(cachedAcceptors[side.ordinal()] != tileEntity) - { - cachedAcceptors[side.ordinal()] = tileEntity; - markDirtyAcceptor(side); - } - - connections |= 1 << side.ordinal(); - continue; - } - } - - if(cachedAcceptors[side.ordinal()] != null) - { - cachedAcceptors[side.ordinal()] = null; - markDirtyAcceptor(side); - } - } - - return connections; - } - - public byte getAllCurrentConnections() - { - return (byte)(currentTransmitterConnections | currentAcceptorConnections); - } - - protected boolean isValidTransmitter(TileEntity tileEntity) - { - return true; - } - - @Override - public boolean occlusionTest(TMultiPart other) - { - return NormalOcclusionTest.apply(this, other); - } - - @Override - public Iterable getSubParts() - { - Set subParts = new HashSet(); - - if(tile() != null) - { - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - int ord = side.ordinal(); - byte connections = getAllCurrentConnections(); - - if(connectionMapContainsSide(connections, side) || side == testingSide) - { - subParts.add(getTransmitterType().getSize() == Size.SMALL ? smallSides[ord] : largeSides[ord]); - } - } - } - - subParts.add(getTransmitterType().getSize() == Size.SMALL ? smallSides[6] : largeSides[6]); - - return subParts; - } - - public abstract TransmitterType getTransmitterType(); - - @Override - public Iterable getCollisionBoxes() - { - Set collisionBoxes = new HashSet(); - collisionBoxes.addAll((Collection)getSubParts()); - - return collisionBoxes; - } - - @Override - public Iterable getOcclusionBoxes() - { - return getCollisionBoxes(); - } - - @Override - public int getSlotMask() - { - return PartMap.CENTER.mask; - } - - @Override - public IIcon getBreakingIcon(Object subPart, int side) - { - return getCenterIcon(true); - } - - @Override - public IIcon getBrokenIcon(int side) - { - return getCenterIcon(true); - } - - @Override - public Cuboid6 getBounds() - { - return getTransmitterType().getSize() == Size.SMALL ? smallSides[6] : largeSides[6]; - } - - @Override - public int getHollowSize(int side) - { - ForgeDirection direction = ForgeDirection.getOrientation(side); - - if(connectionMapContainsSide(getAllCurrentConnections(), direction) || direction == testingSide) - { - return getTransmitterType().getSize().centerSize+1; - } - - return 0; - } - - @Override - @SideOnly(Side.CLIENT) - public boolean renderStatic(Vector3 pos, int pass) - { - if(pass == 0) - { - RenderPartTransmitter.getInstance().renderStatic(this, pass); - return true; - } - else if(pass == 1 && transparencyRender()) - { - RenderPartTransmitter.getInstance().renderStatic(this, pass); - return true; - } - - return false; - } - - @Override - public void addHitEffects(MovingObjectPosition hit, EffectRenderer effectRenderer) - { - IconHitEffects.addHitEffects(this, hit, effectRenderer); - } - - @Override - public void addDestroyEffects(MovingObjectPosition mop, EffectRenderer effectRenderer) - { - IconHitEffects.addDestroyEffects(this, effectRenderer, false); - } - - public abstract boolean isValidAcceptor(TileEntity tile, ForgeDirection side); - - @Override - public boolean canConnectMutual(ForgeDirection side) - { - if(!canConnect(side)) return false; - - TileEntity tile = Coord4D.get(tile()).getFromSide(side).getTileEntity(world()); - return (!(tile instanceof IBlockableConnection) || ((IBlockableConnection)tile).canConnect(side.getOpposite())); - } - - @Override - public boolean canConnect(ForgeDirection side) - { - if(handlesRedstone() && redstoneReactive && redstonePowered) - { - return false; - } - - testingSide = side; - boolean unblocked = tile().canReplacePart(this, this); - testingSide = null; - - return unblocked; - } - - @Override - public void readDesc(MCDataInput packet) - { - currentTransmitterConnections = packet.readByte(); - currentAcceptorConnections = packet.readByte(); - - for(int i = 0; i < 6; i++) - { - connectionTypes[i] = ConnectionType.values()[packet.readInt()]; - } - - if(tile() != null) - { - tile().internalPartChange(this); - tile().markRender(); - } - } - - @Override - public void writeDesc(MCDataOutput packet) - { - packet.writeByte(currentTransmitterConnections); - packet.writeByte(currentAcceptorConnections); - - for(int i = 0; i < 6; i++) - { - packet.writeInt(connectionTypes[i].ordinal()); - } - } - - @Override - public void load(NBTTagCompound nbtTags) - { - super.load(nbtTags); - - redstoneReactive = nbtTags.getBoolean("redstoneReactive"); - - for(int i = 0; i < 6; i++) - { - connectionTypes[i] = ConnectionType.values()[nbtTags.getInteger("connection" + i)]; - } - } - - @Override - public void save(NBTTagCompound nbtTags) - { - super.save(nbtTags); - - nbtTags.setBoolean("redstoneReactive", redstoneReactive); - - for(int i = 0; i < 6; i++) - { - nbtTags.setInteger("connection" + i, connectionTypes[i].ordinal()); - } - } - - @Override - public boolean activate(EntityPlayer player, MovingObjectPosition part, ItemStack item) - { - if(item == null) - { - return false; - } - - if(MekanismUtils.hasUsableWrench(player, x(), y(), z()) && player.isSneaking()) - { - if(!world().isRemote) - { - tile().dropItems(getDrops()); - tile().remPart(this); - } - - return true; - } - - return false; - } - - @Override - public Iterable getDrops() - { - return Collections.singletonList(pickItem(null)); - } - - @Override - public ItemStack pickItem(MovingObjectPosition hit) - { - return new ItemStack(MekanismItems.PartTransmitter, 1, getTransmitterType().ordinal()); - } - - @Override - public boolean doesTick() - { - return true; - } - - protected void onRefresh() {} - - public void refreshConnections() - { - if(redstoneReactive) - { - redstonePowered = MekanismUtils.isGettingPowered(world(), Coord4D.get(tile())); - } - else { - redstonePowered = false; - } - - if(!world().isRemote) - { - byte possibleTransmitters = getPossibleTransmitterConnections(); - byte possibleAcceptors = getPossibleAcceptorConnections(); - - if((possibleTransmitters | possibleAcceptors) != getAllCurrentConnections()) - { - sendDesc = true; - } - - currentTransmitterConnections = possibleTransmitters; - currentAcceptorConnections = possibleAcceptors; - } - } - - public void refreshConnections(ForgeDirection side) - { - if(redstoneReactive) - { - redstonePowered = MekanismUtils.isGettingPowered(world(), Coord4D.get(tile())); - } - else { - redstonePowered = false; - } - - boolean possibleTransmitter = getPossibleTransmitterConnection(side); - boolean possibleAcceptor = getPossibleAcceptorConnection(side); - - if(!world().isRemote) - { - if((possibleTransmitter || possibleAcceptor) != connectionMapContainsSide(getAllCurrentConnections(), side)) - { - sendDesc = true; - } - - currentTransmitterConnections = setConnectionBit(currentTransmitterConnections, possibleTransmitter, side); - currentAcceptorConnections = setConnectionBit(currentAcceptorConnections, possibleAcceptor, side); - } - } - - protected void onModeChange(ForgeDirection side) - { - markDirtyAcceptor(side); - } - - protected void markDirtyTransmitters() - { - notifyTileChange(); - } - - protected void markDirtyAcceptor(ForgeDirection side) {} - - @Override - public void onAdded() - { - super.onAdded(); - - refreshConnections(); - } - - @Override - public void onChunkLoad() - { - super.onChunkLoad(); - - refreshConnections(); - notifyTileChange(); - } - - @Override - public void onNeighborTileChanged(int side, boolean weak) - { - refreshConnections(ForgeDirection.getOrientation(side)); - } - - @Override - public void onNeighborChanged() - { - if(handlesRedstone()) - { - boolean prevPowered = redstonePowered; - refreshConnections(); - - if(prevPowered != redstonePowered) - { - markDirtyTransmitters(); - } - } - } - - @Override - public void onPartChanged(TMultiPart part) - { - super.onPartChanged(part); - - byte transmittersBefore = currentTransmitterConnections; - refreshConnections(); - - if(transmittersBefore != currentTransmitterConnections) - { - markDirtyTransmitters(); - } - } - - @Override - public void handlePacketData(ByteBuf dataStream) throws Exception {} - - @Override - public ArrayList getNetworkedData(ArrayList data) - { - return data; - } - - public ConnectionType getConnectionType(ForgeDirection side) - { - if(!connectionMapContainsSide(getAllCurrentConnections(), side)) - { - return ConnectionType.NONE; - } - else if(connectionMapContainsSide(currentTransmitterConnections, side)) - { - return ConnectionType.NORMAL; - } - - return connectionTypes[side.ordinal()]; - } - - public List getConnections(ConnectionType type) - { - List sides = new ArrayList(); - - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - if(getConnectionType(side) == type) - { - sides.add(side); - } - } - - return sides; - } - - public CCModel getModelForSide(ForgeDirection side, boolean internal) - { - String sideName = side.name().toLowerCase(); - String typeName = getConnectionType(side).name().toUpperCase(); - String name = sideName + typeName; - - if(internal) - { - return RenderPartTransmitter.contents_models.get(name); - } - else { - if(getTransmitterType().getSize() == Size.LARGE) - { - return RenderPartTransmitter.large_models.get(name); - } - else { - return RenderPartTransmitter.small_models.get(name); - } - } - } - - @Override - public boolean onSneakRightClick(EntityPlayer player, int side) - { - if(!world().isRemote) - { - ExtendedMOP hit = (ExtendedMOP)RayTracer.retraceBlock(world(), player, x(), y(), z()); - - if(hit == null) - { - return false; - } - else if(hit.subHit < 6) - { - connectionTypes[hit.subHit] = connectionTypes[hit.subHit].next(); - sendDesc = true; - - onModeChange(ForgeDirection.getOrientation(hit.subHit)); - player.addChatMessage(new ChatComponentText("Connection type changed to " + connectionTypes[hit.subHit].toString())); - - return true; - } - else { - return onConfigure(player, hit.subHit, side); - } - } - - return true; - } - - protected boolean onConfigure(EntityPlayer player, int part, int side) - { - return false; - } - - public EnumColor getRenderColor(boolean opaque) - { - return null; - } - - @Override - public boolean onRightClick(EntityPlayer player, int side) - { - if(!world().isRemote && handlesRedstone()) - { - redstoneReactive ^= true; - refreshConnections(); - notifyTileChange(); - - player.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Redstone sensitivity turned " + EnumColor.INDIGO + (redstoneReactive ? "on." : "off."))); - } - - return true; - } - - public static enum ConnectionType - { - NORMAL, - PUSH, - PULL, - NONE; - - public ConnectionType next() - { - if(ordinal() == values().length-1) - { - return NORMAL; - } - - return values()[ordinal()+1]; - } - } - - @Override - public boolean weakTileChanges() - { - return false; - } - - public void notifyTileChange() - { - MekanismUtils.notifyLoadedNeighborsOfTileChange(world(), Coord4D.get(tile())); - } + return getSideIconRotated(opaque); + } + + return getCenterIcon(opaque); + } else { + return getSideIcon(opaque); + } + } + + public byte getPossibleTransmitterConnections() { + byte connections = 0x00; + + if (handlesRedstone() && redstoneReactive && redstonePowered) { + return connections; + } + + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + if (canConnectMutual(side)) { + TileEntity tileEntity + = Coord4D.get(tile()).getFromSide(side).getTileEntity(world()); + + if (tileEntity instanceof ITransmitterTile + && TransmissionType.checkTransmissionType( + ((ITransmitterTile) tileEntity).getTransmitter(), + getTransmitterType().getTransmission() + ) + && isValidTransmitter(tileEntity)) { + connections |= 1 << side.ordinal(); + } + } + } + + return connections; + } + + public boolean getPossibleAcceptorConnection(ForgeDirection side) { + if (handlesRedstone() && redstoneReactive && redstonePowered) { + return false; + } + + if (canConnectMutual(side)) { + TileEntity tileEntity + = Coord4D.get(tile()).getFromSide(side).getTileEntity(world()); + + if (isValidAcceptor(tileEntity, side)) { + if (cachedAcceptors[side.ordinal()] != tileEntity) { + cachedAcceptors[side.ordinal()] = tileEntity; + markDirtyAcceptor(side); + } + + return true; + } + } + + if (cachedAcceptors[side.ordinal()] != null) { + cachedAcceptors[side.ordinal()] = null; + markDirtyAcceptor(side); + } + + return false; + } + + public boolean getPossibleTransmitterConnection(ForgeDirection side) { + if (handlesRedstone() && redstoneReactive + && MekanismUtils.isGettingPowered(world(), Coord4D.get(tile()))) { + return false; + } + + if (canConnectMutual(side)) { + TileEntity tileEntity + = Coord4D.get(tile()).getFromSide(side).getTileEntity(world()); + + if (tileEntity instanceof ITransmitterTile + && TransmissionType.checkTransmissionType( + ((ITransmitterTile) tileEntity).getTransmitter(), + getTransmitterType().getTransmission() + ) + && isValidTransmitter(tileEntity)) { + return true; + } + } + + return false; + } + + public byte getPossibleAcceptorConnections() { + byte connections = 0x00; + + if (handlesRedstone() && redstoneReactive && redstonePowered) { + return connections; + } + + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + if (canConnectMutual(side)) { + Coord4D coord = Coord4D.get(tile()).getFromSide(side); + + if (!world().isRemote && !coord.exists(world())) { + forceUpdate = true; + continue; + } + + TileEntity tileEntity = coord.getTileEntity(world()); + + if (isValidAcceptor(tileEntity, side)) { + if (cachedAcceptors[side.ordinal()] != tileEntity) { + cachedAcceptors[side.ordinal()] = tileEntity; + markDirtyAcceptor(side); + } + + connections |= 1 << side.ordinal(); + continue; + } + } + + if (cachedAcceptors[side.ordinal()] != null) { + cachedAcceptors[side.ordinal()] = null; + markDirtyAcceptor(side); + } + } + + return connections; + } + + public byte getAllCurrentConnections() { + return (byte) (currentTransmitterConnections | currentAcceptorConnections); + } + + protected boolean isValidTransmitter(TileEntity tileEntity) { + return true; + } + + @Override + public boolean occlusionTest(TMultiPart other) { + return NormalOcclusionTest.apply(this, other); + } + + @Override + public Iterable getSubParts() { + Set subParts = new HashSet(); + + if (tile() != null) { + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + int ord = side.ordinal(); + byte connections = getAllCurrentConnections(); + + if (connectionMapContainsSide(connections, side) || side == testingSide) { + subParts.add( + getTransmitterType().getSize() == Size.SMALL ? smallSides[ord] + : largeSides[ord] + ); + } + } + } + + subParts.add( + getTransmitterType().getSize() == Size.SMALL ? smallSides[6] : largeSides[6] + ); + + return subParts; + } + + public abstract TransmitterType getTransmitterType(); + + @Override + public Iterable getCollisionBoxes() { + Set collisionBoxes = new HashSet(); + collisionBoxes.addAll((Collection) getSubParts()); + + return collisionBoxes; + } + + @Override + public Iterable getOcclusionBoxes() { + return getCollisionBoxes(); + } + + @Override + public int getSlotMask() { + return PartMap.CENTER.mask; + } + + @Override + public IIcon getBreakingIcon(Object subPart, int side) { + return getCenterIcon(true); + } + + @Override + public IIcon getBrokenIcon(int side) { + return getCenterIcon(true); + } + + @Override + public Cuboid6 getBounds() { + return getTransmitterType().getSize() == Size.SMALL ? smallSides[6] + : largeSides[6]; + } + + @Override + public int getHollowSize(int side) { + ForgeDirection direction = ForgeDirection.getOrientation(side); + + if (connectionMapContainsSide(getAllCurrentConnections(), direction) + || direction == testingSide) { + return getTransmitterType().getSize().centerSize + 1; + } + + return 0; + } + + @Override + @SideOnly(Side.CLIENT) + public boolean renderStatic(Vector3 pos, int pass) { + if (pass == 0) { + RenderPartTransmitter.getInstance().renderStatic(this, pass); + return true; + } else if (pass == 1 && transparencyRender()) { + RenderPartTransmitter.getInstance().renderStatic(this, pass); + return true; + } + + return false; + } + + @Override + public void addHitEffects(MovingObjectPosition hit, EffectRenderer effectRenderer) { + IconHitEffects.addHitEffects(this, hit, effectRenderer); + } + + @Override + public void + addDestroyEffects(MovingObjectPosition mop, EffectRenderer effectRenderer) { + IconHitEffects.addDestroyEffects(this, effectRenderer, false); + } + + public abstract boolean isValidAcceptor(TileEntity tile, ForgeDirection side); + + @Override + public boolean canConnectMutual(ForgeDirection side) { + if (!canConnect(side)) + return false; + + TileEntity tile = Coord4D.get(tile()).getFromSide(side).getTileEntity(world()); + return ( + !(tile instanceof IBlockableConnection) + || ((IBlockableConnection) tile).canConnect(side.getOpposite()) + ); + } + + @Override + public boolean canConnect(ForgeDirection side) { + if (handlesRedstone() && redstoneReactive && redstonePowered) { + return false; + } + + testingSide = side; + boolean unblocked = tile().canReplacePart(this, this); + testingSide = null; + + return unblocked; + } + + @Override + public void readDesc(MCDataInput packet) { + currentTransmitterConnections = packet.readByte(); + currentAcceptorConnections = packet.readByte(); + + for (int i = 0; i < 6; i++) { + connectionTypes[i] = ConnectionType.values()[packet.readInt()]; + } + + if (tile() != null) { + tile().internalPartChange(this); + tile().markRender(); + } + } + + @Override + public void writeDesc(MCDataOutput packet) { + packet.writeByte(currentTransmitterConnections); + packet.writeByte(currentAcceptorConnections); + + for (int i = 0; i < 6; i++) { + packet.writeInt(connectionTypes[i].ordinal()); + } + } + + @Override + public void load(NBTTagCompound nbtTags) { + super.load(nbtTags); + + redstoneReactive = nbtTags.getBoolean("redstoneReactive"); + + for (int i = 0; i < 6; i++) { + connectionTypes[i] + = ConnectionType.values()[nbtTags.getInteger("connection" + i)]; + } + } + + @Override + public void save(NBTTagCompound nbtTags) { + super.save(nbtTags); + + nbtTags.setBoolean("redstoneReactive", redstoneReactive); + + for (int i = 0; i < 6; i++) { + nbtTags.setInteger("connection" + i, connectionTypes[i].ordinal()); + } + } + + @Override + public boolean + activate(EntityPlayer player, MovingObjectPosition part, ItemStack item) { + if (item == null) { + return false; + } + + if (MekanismUtils.hasUsableWrench(player, x(), y(), z()) && player.isSneaking()) { + if (!world().isRemote) { + tile().dropItems(getDrops()); + tile().remPart(this); + } + + return true; + } + + return false; + } + + @Override + public Iterable getDrops() { + return Collections.singletonList(pickItem(null)); + } + + @Override + public ItemStack pickItem(MovingObjectPosition hit) { + return new ItemStack( + MekanismItems.PartTransmitter, 1, getTransmitterType().ordinal() + ); + } + + @Override + public boolean doesTick() { + return true; + } + + protected void onRefresh() {} + + public void refreshConnections() { + if (redstoneReactive) { + redstonePowered + = MekanismUtils.isGettingPowered(world(), Coord4D.get(tile())); + } else { + redstonePowered = false; + } + + if (!world().isRemote) { + byte possibleTransmitters = getPossibleTransmitterConnections(); + byte possibleAcceptors = getPossibleAcceptorConnections(); + + if ((possibleTransmitters | possibleAcceptors) + != getAllCurrentConnections()) { + sendDesc = true; + } + + currentTransmitterConnections = possibleTransmitters; + currentAcceptorConnections = possibleAcceptors; + } + } + + public void refreshConnections(ForgeDirection side) { + if (redstoneReactive) { + redstonePowered + = MekanismUtils.isGettingPowered(world(), Coord4D.get(tile())); + } else { + redstonePowered = false; + } + + boolean possibleTransmitter = getPossibleTransmitterConnection(side); + boolean possibleAcceptor = getPossibleAcceptorConnection(side); + + if (!world().isRemote) { + if ((possibleTransmitter || possibleAcceptor) + != connectionMapContainsSide(getAllCurrentConnections(), side)) { + sendDesc = true; + } + + currentTransmitterConnections = setConnectionBit( + currentTransmitterConnections, possibleTransmitter, side + ); + currentAcceptorConnections + = setConnectionBit(currentAcceptorConnections, possibleAcceptor, side); + } + } + + protected void onModeChange(ForgeDirection side) { + markDirtyAcceptor(side); + } + + protected void markDirtyTransmitters() { + notifyTileChange(); + } + + protected void markDirtyAcceptor(ForgeDirection side) {} + + @Override + public void onAdded() { + super.onAdded(); + + refreshConnections(); + } + + @Override + public void onChunkLoad() { + super.onChunkLoad(); + + refreshConnections(); + notifyTileChange(); + } + + @Override + public void onNeighborTileChanged(int side, boolean weak) { + refreshConnections(ForgeDirection.getOrientation(side)); + } + + @Override + public void onNeighborChanged() { + if (handlesRedstone()) { + boolean prevPowered = redstonePowered; + refreshConnections(); + + if (prevPowered != redstonePowered) { + markDirtyTransmitters(); + } + } + } + + @Override + public void onPartChanged(TMultiPart part) { + super.onPartChanged(part); + + byte transmittersBefore = currentTransmitterConnections; + refreshConnections(); + + if (transmittersBefore != currentTransmitterConnections) { + markDirtyTransmitters(); + } + } + + @Override + public void handlePacketData(ByteBuf dataStream) throws Exception {} + + @Override + public ArrayList getNetworkedData(ArrayList data) { + return data; + } + + public ConnectionType getConnectionType(ForgeDirection side) { + if (!connectionMapContainsSide(getAllCurrentConnections(), side)) { + return ConnectionType.NONE; + } else if (connectionMapContainsSide(currentTransmitterConnections, side)) { + return ConnectionType.NORMAL; + } + + return connectionTypes[side.ordinal()]; + } + + public List getConnections(ConnectionType type) { + List sides = new ArrayList(); + + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + if (getConnectionType(side) == type) { + sides.add(side); + } + } + + return sides; + } + + public CCModel getModelForSide(ForgeDirection side, boolean internal) { + String sideName = side.name().toLowerCase(); + String typeName = getConnectionType(side).name().toUpperCase(); + String name = sideName + typeName; + + if (internal) { + return RenderPartTransmitter.contents_models.get(name); + } else { + if (getTransmitterType().getSize() == Size.LARGE) { + return RenderPartTransmitter.large_models.get(name); + } else { + return RenderPartTransmitter.small_models.get(name); + } + } + } + + @Override + public boolean onSneakRightClick(EntityPlayer player, int side) { + if (!world().isRemote) { + ExtendedMOP hit + = (ExtendedMOP) RayTracer.retraceBlock(world(), player, x(), y(), z()); + + if (hit == null) { + return false; + } else if (hit.subHit < 6) { + connectionTypes[hit.subHit] = connectionTypes[hit.subHit].next(); + sendDesc = true; + + onModeChange(ForgeDirection.getOrientation(hit.subHit)); + player.addChatMessage(new ChatComponentText( + "Connection type changed to " + connectionTypes[hit.subHit].toString() + )); + + return true; + } else { + return onConfigure(player, hit.subHit, side); + } + } + + return true; + } + + protected boolean onConfigure(EntityPlayer player, int part, int side) { + return false; + } + + public EnumColor getRenderColor(boolean opaque) { + return null; + } + + @Override + public boolean onRightClick(EntityPlayer player, int side) { + if (!world().isRemote && handlesRedstone()) { + redstoneReactive ^= true; + refreshConnections(); + notifyTileChange(); + + player.addChatMessage(new ChatComponentText( + EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + + " Redstone sensitivity turned " + EnumColor.INDIGO + + (redstoneReactive ? "on." : "off.") + )); + } + + return true; + } + + public static enum ConnectionType { + NORMAL, + PUSH, + PULL, + NONE; + + public ConnectionType next() { + if (ordinal() == values().length - 1) { + return NORMAL; + } + + return values()[ordinal() + 1]; + } + } + + @Override + public boolean weakTileChanges() { + return false; + } + + public void notifyTileChange() { + MekanismUtils.notifyLoadedNeighborsOfTileChange(world(), Coord4D.get(tile())); + } } diff --git a/src/main/java/mekanism/common/multipart/PartThermodynamicConductor.java b/src/main/java/mekanism/common/multipart/PartThermodynamicConductor.java index 592aa17a0..7493915f3 100644 --- a/src/main/java/mekanism/common/multipart/PartThermodynamicConductor.java +++ b/src/main/java/mekanism/common/multipart/PartThermodynamicConductor.java @@ -2,6 +2,12 @@ package mekanism.common.multipart; import java.util.Collection; +import codechicken.lib.colour.ColourRGBA; +import codechicken.lib.data.MCDataInput; +import codechicken.lib.data.MCDataOutput; +import codechicken.lib.vec.Vector3; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.IHeatTransfer; import mekanism.api.MekanismConfig.client; @@ -17,251 +23,225 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraftforge.common.util.ForgeDirection; -import codechicken.lib.colour.ColourRGBA; -import codechicken.lib.data.MCDataInput; -import codechicken.lib.data.MCDataOutput; -import codechicken.lib.vec.Vector3; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class PartThermodynamicConductor extends PartTransmitter implements IHeatTransfer -{ - public Tier.ConductorTier tier; - - public static TransmitterIcons conductorIcons = new TransmitterIcons(4, 8); +public class PartThermodynamicConductor + extends PartTransmitter implements IHeatTransfer { + public Tier.ConductorTier tier; - public double temperature = 0; - public double clientTemperature = 0; - public double heatToAbsorb = 0; + public static TransmitterIcons conductorIcons = new TransmitterIcons(4, 8); - public PartThermodynamicConductor(Tier.ConductorTier conductorTier) - { - super(); - tier = conductorTier; - } + public double temperature = 0; + public double clientTemperature = 0; + public double heatToAbsorb = 0; - @Override - public HeatNetwork createNewNetwork() - { - return new HeatNetwork(); - } + public PartThermodynamicConductor(Tier.ConductorTier conductorTier) { + super(); + tier = conductorTier; + } - @Override - public HeatNetwork createNetworkByMerging(Collection networks) - { - return new HeatNetwork(networks); - } + @Override + public HeatNetwork createNewNetwork() { + return new HeatNetwork(); + } - @Override - public int getCapacity() - { - return 0; - } + @Override + public HeatNetwork createNetworkByMerging(Collection networks) { + return new HeatNetwork(networks); + } - @Override - public Object getBuffer() - { - return null; - } + @Override + public int getCapacity() { + return 0; + } - @Override - public void takeShare() {} + @Override + public Object getBuffer() { + return null; + } + + @Override + public void takeShare() {} @Override public void updateShare() {} - public static void registerIcons(IIconRegister register) - { - conductorIcons.registerCenterIcons(register, new String[]{"ThermodynamicConductorBasic", "ThermodynamicConductorAdvanced", - "ThermodynamicConductorElite", "ThermodynamicConductorUltimate"}); - conductorIcons.registerSideIcons(register, new String[]{"ThermodynamicConductorVerticalBasic", "ThermodynamicConductorVerticalAdvanced", "ThermodynamicConductorVerticalElite", "ThermodynamicConductorVerticalUltimate", - "ThermodynamicConductorHorizontalBasic", "ThermodynamicConductorHorizontalAdvanced", "ThermodynamicConductorHorizontalElite", "ThermodynamicConductorHorizontalUltimate"}); - } + public static void registerIcons(IIconRegister register) { + conductorIcons.registerCenterIcons( + register, + new String[] { "ThermodynamicConductorBasic", + "ThermodynamicConductorAdvanced", + "ThermodynamicConductorElite", + "ThermodynamicConductorUltimate" } + ); + conductorIcons.registerSideIcons( + register, + new String[] { "ThermodynamicConductorVerticalBasic", + "ThermodynamicConductorVerticalAdvanced", + "ThermodynamicConductorVerticalElite", + "ThermodynamicConductorVerticalUltimate", + "ThermodynamicConductorHorizontalBasic", + "ThermodynamicConductorHorizontalAdvanced", + "ThermodynamicConductorHorizontalElite", + "ThermodynamicConductorHorizontalUltimate" } + ); + } - @Override - public IIcon getCenterIcon(boolean opaque) - { - return conductorIcons.getCenterIcon(tier.ordinal()); - } + @Override + public IIcon getCenterIcon(boolean opaque) { + return conductorIcons.getCenterIcon(tier.ordinal()); + } - @Override - public IIcon getSideIcon(boolean opaque) - { - return conductorIcons.getSideIcon(tier.ordinal()); - } + @Override + public IIcon getSideIcon(boolean opaque) { + return conductorIcons.getSideIcon(tier.ordinal()); + } - @Override - public IIcon getSideIconRotated(boolean opaque) - { - return conductorIcons.getSideIcon(4+tier.ordinal()); - } + @Override + public IIcon getSideIconRotated(boolean opaque) { + return conductorIcons.getSideIcon(4 + tier.ordinal()); + } - @Override - public TransmitterType getTransmitterType() - { - return tier.type; - } + @Override + public TransmitterType getTransmitterType() { + return tier.type; + } - @Override - public boolean isValidAcceptor(TileEntity tile, ForgeDirection side) - { - return tile instanceof IHeatTransfer && ((IHeatTransfer)tile).canConnectHeat(side.getOpposite()); - } + @Override + public boolean isValidAcceptor(TileEntity tile, ForgeDirection side) { + return tile instanceof IHeatTransfer + && ((IHeatTransfer) tile).canConnectHeat(side.getOpposite()); + } - @Override - public TransmissionType getTransmissionType() - { - return TransmissionType.HEAT; - } + @Override + public TransmissionType getTransmissionType() { + return TransmissionType.HEAT; + } - @Override - public String getType() - { - return "mekanism:thermodynamic_conductor_" + tier.name().toLowerCase(); - } + @Override + public String getType() { + return "mekanism:thermodynamic_conductor_" + tier.name().toLowerCase(); + } - @Override - @SideOnly(Side.CLIENT) - public void renderDynamic(Vector3 pos, float f, int pass) - { - if(pass == 0 && !client.opaqueTransmitters) - { - RenderPartTransmitter.getInstance().renderContents(this, pos); - } - } + @Override + @SideOnly(Side.CLIENT) + public void renderDynamic(Vector3 pos, float f, int pass) { + if (pass == 0 && !client.opaqueTransmitters) { + RenderPartTransmitter.getInstance().renderContents(this, pos); + } + } - @Override - public void load(NBTTagCompound nbtTags) - { - super.load(nbtTags); + @Override + public void load(NBTTagCompound nbtTags) { + super.load(nbtTags); - temperature = nbtTags.getDouble("temperature"); - } + temperature = nbtTags.getDouble("temperature"); + } - @Override - public void save(NBTTagCompound nbtTags) - { - super.save(nbtTags); + @Override + public void save(NBTTagCompound nbtTags) { + super.save(nbtTags); - nbtTags.setDouble("temperature", temperature); - } + nbtTags.setDouble("temperature", temperature); + } - public void sendTemp() - { - MCDataOutput packet = getWriteStream(); - packet.writeBoolean(true); - packet.writeDouble(temperature); - } + public void sendTemp() { + MCDataOutput packet = getWriteStream(); + packet.writeBoolean(true); + packet.writeDouble(temperature); + } - @Override - public void writeDesc(MCDataOutput packet) - { - packet.writeBoolean(false); - - super.writeDesc(packet); - - packet.writeInt(tier.ordinal()); - } + @Override + public void writeDesc(MCDataOutput packet) { + packet.writeBoolean(false); - @Override - public void readDesc(MCDataInput packet) - { - if(packet.readBoolean()) - { - temperature = packet.readDouble(); - } - else { - super.readDesc(packet); - - tier = ConductorTier.values()[packet.readInt()]; - } - } + super.writeDesc(packet); - public ColourRGBA getBaseColour() - { - return tier.baseColour; - } + packet.writeInt(tier.ordinal()); + } - @Override - public double getTemp() - { - return temperature; - } + @Override + public void readDesc(MCDataInput packet) { + if (packet.readBoolean()) { + temperature = packet.readDouble(); + } else { + super.readDesc(packet); - @Override - public double getInverseConductionCoefficient() - { - return tier.inverseConduction; - } + tier = ConductorTier.values()[packet.readInt()]; + } + } - @Override - public double getInsulationCoefficient(ForgeDirection side) - { - return tier.inverseConductionInsulation; - } + public ColourRGBA getBaseColour() { + return tier.baseColour; + } - @Override - public void transferHeatTo(double heat) - { - heatToAbsorb += heat; - } + @Override + public double getTemp() { + return temperature; + } - @Override - public double[] simulateHeat() - { - return HeatUtils.simulate(this); - } + @Override + public double getInverseConductionCoefficient() { + return tier.inverseConduction; + } - @Override - public double applyTemperatureChange() - { - temperature += tier.inverseHeatCapacity * heatToAbsorb; - heatToAbsorb = 0; - - if(Math.abs(temperature - clientTemperature) > (temperature / 100)) - { - clientTemperature = temperature; - sendTemp(); - } - - return temperature; - } + @Override + public double getInsulationCoefficient(ForgeDirection side) { + return tier.inverseConductionInsulation; + } - @Override - public boolean canConnectHeat(ForgeDirection side) - { - return true; - } + @Override + public void transferHeatTo(double heat) { + heatToAbsorb += heat; + } - @Override - public IHeatTransfer getAdjacent(ForgeDirection side) - { - if(connectionMapContainsSide(getAllCurrentConnections(), side)) - { - TileEntity adj = Coord4D.get(tile()).getFromSide(side).getTileEntity(world()); - - if(adj instanceof IHeatTransfer) - { - return (IHeatTransfer)adj; - } - } - - return null; - } - - @Override - public boolean upgrade(int tierOrdinal) - { - if(tier.ordinal() < BaseTier.ULTIMATE.ordinal() && tierOrdinal == tier.ordinal()+1) - { - tier = ConductorTier.values()[tier.ordinal()+1]; - - markDirtyTransmitters(); - sendDesc = true; - - return true; - } - - return false; - } + @Override + public double[] simulateHeat() { + return HeatUtils.simulate(this); + } + + @Override + public double applyTemperatureChange() { + temperature += tier.inverseHeatCapacity * heatToAbsorb; + heatToAbsorb = 0; + + if (Math.abs(temperature - clientTemperature) > (temperature / 100)) { + clientTemperature = temperature; + sendTemp(); + } + + return temperature; + } + + @Override + public boolean canConnectHeat(ForgeDirection side) { + return true; + } + + @Override + public IHeatTransfer getAdjacent(ForgeDirection side) { + if (connectionMapContainsSide(getAllCurrentConnections(), side)) { + TileEntity adj = Coord4D.get(tile()).getFromSide(side).getTileEntity(world()); + + if (adj instanceof IHeatTransfer) { + return (IHeatTransfer) adj; + } + } + + return null; + } + + @Override + public boolean upgrade(int tierOrdinal) { + if (tier.ordinal() < BaseTier.ULTIMATE.ordinal() + && tierOrdinal == tier.ordinal() + 1) { + tier = ConductorTier.values()[tier.ordinal() + 1]; + + markDirtyTransmitters(); + sendDesc = true; + + return true; + } + + return false; + } } diff --git a/src/main/java/mekanism/common/multipart/PartTransmitter.java b/src/main/java/mekanism/common/multipart/PartTransmitter.java index b3ce5c15a..f91fa0cd2 100644 --- a/src/main/java/mekanism/common/multipart/PartTransmitter.java +++ b/src/main/java/mekanism/common/multipart/PartTransmitter.java @@ -16,178 +16,162 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.ForgeDirection; -public abstract class PartTransmitter> extends PartSidedPipe implements ITransmitterTile, IAlloyInteraction -{ - public MultipartTransmitter transmitterDelegate; +public abstract class PartTransmitter> + extends PartSidedPipe implements ITransmitterTile, IAlloyInteraction { + public MultipartTransmitter transmitterDelegate; - public boolean unloaded = true; + public boolean unloaded = true; - public PartTransmitter() - { - transmitterDelegate = new MultipartTransmitter<>(this); - } + public PartTransmitter() { + transmitterDelegate = new MultipartTransmitter<>(this); + } - @Override - public MultipartTransmitter getTransmitter() - { - return transmitterDelegate; - } + @Override + public MultipartTransmitter getTransmitter() { + return transmitterDelegate; + } - @Override - public void onWorldJoin() - { - super.onWorldJoin(); - - if(!world().isRemote) - { - TransmitterNetworkRegistry.registerOrphanTransmitter(getTransmitter()); - } - else { - MinecraftForge.EVENT_BUS.post(new NetworkClientRequest(tile())); - } + @Override + public void onWorldJoin() { + super.onWorldJoin(); - unloaded = false; - } + if (!world().isRemote) { + TransmitterNetworkRegistry.registerOrphanTransmitter(getTransmitter()); + } else { + MinecraftForge.EVENT_BUS.post(new NetworkClientRequest(tile())); + } - public abstract N createNewNetwork(); + unloaded = false; + } - public abstract N createNetworkByMerging(Collection networks); + public abstract N createNewNetwork(); - @Override - public void onChunkUnload() - { - super.onChunkUnload(); + public abstract N createNetworkByMerging(Collection networks); - unloaded = true; - - if(!world().isRemote) - { - getTransmitter().takeShare(); - TransmitterNetworkRegistry.invalidateTransmitter(getTransmitter()); - } - else { - getTransmitter().setTransmitterNetwork(null); - } - } + @Override + public void onChunkUnload() { + super.onChunkUnload(); - @Override - public void preRemove() - { - if(!world().isRemote) - { - TransmitterNetworkRegistry.invalidateTransmitter(getTransmitter()); - } - else { - getTransmitter().setTransmitterNetwork(null); - } - - super.preRemove(); - } + unloaded = true; - @Override - public void markDirtyTransmitters() - { - super.markDirtyTransmitters(); - - if(getTransmitter().hasTransmitterNetwork()) - { - TransmitterNetworkRegistry.invalidateTransmitter(getTransmitter()); - } - } + if (!world().isRemote) { + getTransmitter().takeShare(); + TransmitterNetworkRegistry.invalidateTransmitter(getTransmitter()); + } else { + getTransmitter().setTransmitterNetwork(null); + } + } - @Override - public void markDirtyAcceptor(ForgeDirection side) - { - super.markDirtyAcceptor(side); - - if(getTransmitter().hasTransmitterNetwork()) - { - getTransmitter().getTransmitterNetwork().acceptorChanged(getTransmitter(), side); - } - } + @Override + public void preRemove() { + if (!world().isRemote) { + TransmitterNetworkRegistry.invalidateTransmitter(getTransmitter()); + } else { + getTransmitter().setTransmitterNetwork(null); + } - public A getCachedAcceptor(ForgeDirection side) - { - ConnectionType type = connectionTypes[side.ordinal()]; - - if(type == ConnectionType.PULL || type == ConnectionType.NONE) - { - return null; - } - - return connectionMapContainsSide(currentAcceptorConnections, side) ? (A)cachedAcceptors[side.ordinal()] : null; - } - - @Override - public void onAlloyInteraction(EntityPlayer player, int tierOrdinal) - { - if(getTransmitter().hasTransmitterNetwork()) - { - int upgraded = 0; - Object[] array = ((LinkedHashSet)getTransmitter().getTransmitterNetwork().transmitters.clone()).toArray(); - - Arrays.sort(array, new Comparator() { - @Override - public int compare(Object o1, Object o2) - { - if(o1 instanceof IGridTransmitter && o2 instanceof IGridTransmitter) - { - Coord4D thisCoord = Coord4D.get(tile()); - - Coord4D o1Coord = ((IGridTransmitter)o1).coord(); - Coord4D o2Coord = ((IGridTransmitter)o2).coord(); - - return o1Coord.distanceTo(thisCoord) > o2Coord.distanceTo(thisCoord) ? 1 : - (o1Coord.distanceTo(thisCoord) < o2Coord.distanceTo(thisCoord) ? -1 : 0); - } - - return 0; - } - }); - - for(Object iter : array) - { - if(iter instanceof MultipartTransmitter) - { - PartTransmitter t = ((MultipartTransmitter)iter).containingPart; - - if(t.upgrade(tierOrdinal)) - { - upgraded++; - - if(upgraded == 8) - { - break; - } - } - } - } - - if(upgraded > 0) - { - if(!player.capabilities.isCreativeMode) - { - player.getCurrentEquippedItem().stackSize--; - - if(player.getCurrentEquippedItem().stackSize == 0) - { - player.setCurrentItemOrArmor(0, null); - } - } - } - } - } - - public boolean upgrade(int tierOrdinal) - { - return false; - } + super.preRemove(); + } - public abstract int getCapacity(); + @Override + public void markDirtyTransmitters() { + super.markDirtyTransmitters(); - public abstract Object getBuffer(); + if (getTransmitter().hasTransmitterNetwork()) { + TransmitterNetworkRegistry.invalidateTransmitter(getTransmitter()); + } + } - public abstract void takeShare(); + @Override + public void markDirtyAcceptor(ForgeDirection side) { + super.markDirtyAcceptor(side); + + if (getTransmitter().hasTransmitterNetwork()) { + getTransmitter().getTransmitterNetwork().acceptorChanged( + getTransmitter(), side + ); + } + } + + public A getCachedAcceptor(ForgeDirection side) { + ConnectionType type = connectionTypes[side.ordinal()]; + + if (type == ConnectionType.PULL || type == ConnectionType.NONE) { + return null; + } + + return connectionMapContainsSide(currentAcceptorConnections, side) + ? (A) cachedAcceptors[side.ordinal()] + : null; + } + + @Override + public void onAlloyInteraction(EntityPlayer player, int tierOrdinal) { + if (getTransmitter().hasTransmitterNetwork()) { + int upgraded = 0; + Object[] array = ((LinkedHashSet) getTransmitter() + .getTransmitterNetwork() + .transmitters.clone()) + .toArray(); + + Arrays.sort(array, new Comparator() { + @Override + public int compare(Object o1, Object o2) { + if (o1 instanceof IGridTransmitter + && o2 instanceof IGridTransmitter) { + Coord4D thisCoord = Coord4D.get(tile()); + + Coord4D o1Coord = ((IGridTransmitter) o1).coord(); + Coord4D o2Coord = ((IGridTransmitter) o2).coord(); + + return o1Coord.distanceTo(thisCoord) + > o2Coord.distanceTo(thisCoord) + ? 1 + : (o1Coord.distanceTo(thisCoord) + < o2Coord.distanceTo(thisCoord) + ? -1 + : 0); + } + + return 0; + } + }); + + for (Object iter : array) { + if (iter instanceof MultipartTransmitter) { + PartTransmitter t = ((MultipartTransmitter) iter).containingPart; + + if (t.upgrade(tierOrdinal)) { + upgraded++; + + if (upgraded == 8) { + break; + } + } + } + } + + if (upgraded > 0) { + if (!player.capabilities.isCreativeMode) { + player.getCurrentEquippedItem().stackSize--; + + if (player.getCurrentEquippedItem().stackSize == 0) { + player.setCurrentItemOrArmor(0, null); + } + } + } + } + } + + public boolean upgrade(int tierOrdinal) { + return false; + } + + public abstract int getCapacity(); + + public abstract Object getBuffer(); + + public abstract void takeShare(); public abstract void updateShare(); } diff --git a/src/main/java/mekanism/common/multipart/PartUniversalCable.java b/src/main/java/mekanism/common/multipart/PartUniversalCable.java index 78846c352..76fce363a 100644 --- a/src/main/java/mekanism/common/multipart/PartUniversalCable.java +++ b/src/main/java/mekanism/common/multipart/PartUniversalCable.java @@ -1,10 +1,16 @@ package mekanism.common.multipart; -import ic2.api.energy.tile.IEnergySource; - import java.util.Collection; import java.util.List; +import codechicken.lib.data.MCDataInput; +import codechicken.lib.data.MCDataOutput; +import codechicken.lib.vec.Vector3; +import cofh.api.energy.IEnergyHandler; +import cofh.api.energy.IEnergyProvider; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ic2.api.energy.tile.IEnergySource; import mekanism.api.MekanismConfig.client; import mekanism.api.MekanismConfig.general; import mekanism.api.energy.EnergyStack; @@ -25,403 +31,381 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraftforge.common.util.ForgeDirection; -import codechicken.lib.data.MCDataInput; -import codechicken.lib.data.MCDataOutput; -import codechicken.lib.vec.Vector3; -import cofh.api.energy.IEnergyHandler; -import cofh.api.energy.IEnergyProvider; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class PartUniversalCable extends PartTransmitter implements IStrictEnergyAcceptor, IEnergyHandler -{ - public Tier.CableTier tier; +public class PartUniversalCable + extends PartTransmitter + implements IStrictEnergyAcceptor, IEnergyHandler { + public Tier.CableTier tier; - public static TransmitterIcons cableIcons = new TransmitterIcons(4, 8); + public static TransmitterIcons cableIcons = new TransmitterIcons(4, 8); - public double currentPower = 0; - public double lastWrite = 0; + public double currentPower = 0; + public double lastWrite = 0; - public EnergyStack buffer = new EnergyStack(0); + public EnergyStack buffer = new EnergyStack(0); - public PartUniversalCable(Tier.CableTier cableTier) - { - super(); - tier = cableTier; - } - - @Override - public void update() - { - if(world().isRemote) - { - double targetPower = getTransmitter().hasTransmitterNetwork() ? getTransmitter().getTransmitterNetwork().clientEnergyScale : 0; - - if(Math.abs(currentPower - targetPower) > 0.01) - { - currentPower = (9 * currentPower + targetPower) / 10; - } - } - else { - updateShare(); - - List sides = getConnections(ConnectionType.PULL); - - if(!sides.isEmpty()) - { - TileEntity[] connectedOutputters = CableUtils.getConnectedOutputters(tile()); - double canDraw = tier.cableCapacity/10F; - - for(ForgeDirection side : sides) - { - if(connectedOutputters[side.ordinal()] != null) - { - TileEntity outputter = connectedOutputters[side.ordinal()]; - - if(outputter instanceof ICableOutputter && outputter instanceof IStrictEnergyStorage) - { - if(((ICableOutputter)outputter).canOutputTo(side.getOpposite())) - { - double received = Math.min(((IStrictEnergyStorage)outputter).getEnergy(), canDraw); - double toDraw = received; - - if(received > 0) - { - toDraw -= takeEnergy(received, true); - } - - ((IStrictEnergyStorage)outputter).setEnergy(((IStrictEnergyStorage)outputter).getEnergy() - toDraw); - } - } - else if(MekanismUtils.useRF() && outputter instanceof IEnergyProvider) - { - double received = ((IEnergyProvider)outputter).extractEnergy(side.getOpposite(), (int)(canDraw*general.TO_TE), true) * general.FROM_TE; - double toDraw = received; - - if(received > 0) - { - toDraw -= takeEnergy(received, true); - } - - ((IEnergyProvider)outputter).extractEnergy(side.getOpposite(), (int)(toDraw*general.TO_TE), false); - } - else if(MekanismUtils.useIC2() && CableUtils.getIC2Tile(outputter) instanceof IEnergySource) - { - double received = Math.min(((IEnergySource)CableUtils.getIC2Tile(outputter)).getOfferedEnergy() * general.FROM_IC2, canDraw); - double toDraw = received; - - if(received > 0) - { - toDraw -= takeEnergy(received, true); - } - - ((IEnergySource)CableUtils.getIC2Tile(outputter)).drawEnergy(toDraw * general.TO_IC2); - } - } - } - } - } - - super.update(); - } + public PartUniversalCable(Tier.CableTier cableTier) { + super(); + tier = cableTier; + } @Override - public void updateShare() - { - if(getTransmitter().hasTransmitterNetwork() && getTransmitter().getTransmitterNetworkSize() > 0) - { + public void update() { + if (world().isRemote) { + double targetPower = getTransmitter().hasTransmitterNetwork() + ? getTransmitter().getTransmitterNetwork().clientEnergyScale + : 0; + + if (Math.abs(currentPower - targetPower) > 0.01) { + currentPower = (9 * currentPower + targetPower) / 10; + } + } else { + updateShare(); + + List sides = getConnections(ConnectionType.PULL); + + if (!sides.isEmpty()) { + TileEntity[] connectedOutputters + = CableUtils.getConnectedOutputters(tile()); + double canDraw = tier.cableCapacity / 10F; + + for (ForgeDirection side : sides) { + if (connectedOutputters[side.ordinal()] != null) { + TileEntity outputter = connectedOutputters[side.ordinal()]; + + if (outputter instanceof ICableOutputter + && outputter instanceof IStrictEnergyStorage) { + if (((ICableOutputter) outputter) + .canOutputTo(side.getOpposite())) { + double received = Math.min( + ((IStrictEnergyStorage) outputter).getEnergy(), + canDraw + ); + double toDraw = received; + + if (received > 0) { + toDraw -= takeEnergy(received, true); + } + + ((IStrictEnergyStorage) outputter) + .setEnergy( + ((IStrictEnergyStorage) outputter).getEnergy() + - toDraw + ); + } + } else if (MekanismUtils.useRF() && outputter instanceof IEnergyProvider) { + double received = ((IEnergyProvider) outputter) + .extractEnergy( + side.getOpposite(), + (int) (canDraw * general.TO_TE), + true + ) + * general.FROM_TE; + double toDraw = received; + + if (received > 0) { + toDraw -= takeEnergy(received, true); + } + + ((IEnergyProvider) outputter) + .extractEnergy( + side.getOpposite(), + (int) (toDraw * general.TO_TE), + false + ); + } else if (MekanismUtils.useIC2() && CableUtils.getIC2Tile(outputter) instanceof IEnergySource) { + double received = Math.min( + ((IEnergySource) CableUtils.getIC2Tile(outputter)) + .getOfferedEnergy() + * general.FROM_IC2, + canDraw + ); + double toDraw = received; + + if (received > 0) { + toDraw -= takeEnergy(received, true); + } + + ((IEnergySource) CableUtils.getIC2Tile(outputter)) + .drawEnergy(toDraw * general.TO_IC2); + } + } + } + } + } + + super.update(); + } + + @Override + public void updateShare() { + if (getTransmitter().hasTransmitterNetwork() + && getTransmitter().getTransmitterNetworkSize() > 0) { double last = getSaveShare(); - if(last != lastWrite) - { + if (last != lastWrite) { lastWrite = last; MekanismUtils.saveChunk(tile()); } } } - private double getSaveShare() - { - if(getTransmitter().hasTransmitterNetwork()) - { - return EnergyNetwork.round(getTransmitter().getTransmitterNetwork().buffer.amount * (1F / getTransmitter().getTransmitterNetwork().transmitters.size())); - } - else { - return buffer.amount; - } - } + private double getSaveShare() { + if (getTransmitter().hasTransmitterNetwork()) { + return EnergyNetwork.round( + getTransmitter().getTransmitterNetwork().buffer.amount + * (1F / getTransmitter().getTransmitterNetwork().transmitters.size()) + ); + } else { + return buffer.amount; + } + } - @Override - public TransmitterType getTransmitterType() - { - return tier.type; - } + @Override + public TransmitterType getTransmitterType() { + return tier.type; + } - @Override - public void load(NBTTagCompound nbtTags) - { - super.load(nbtTags); + @Override + public void load(NBTTagCompound nbtTags) { + super.load(nbtTags); - buffer.amount = nbtTags.getDouble("cacheEnergy"); - if(buffer.amount < 0) buffer.amount = 0; - tier = Tier.CableTier.values()[nbtTags.getInteger("tier")]; - } + buffer.amount = nbtTags.getDouble("cacheEnergy"); + if (buffer.amount < 0) + buffer.amount = 0; + tier = Tier.CableTier.values()[nbtTags.getInteger("tier")]; + } - @Override - public void save(NBTTagCompound nbtTags) - { - super.save(nbtTags); - - nbtTags.setDouble("cacheEnergy", lastWrite); - nbtTags.setInteger("tier", tier.ordinal()); - } + @Override + public void save(NBTTagCompound nbtTags) { + super.save(nbtTags); - @Override - public String getType() - { - return "mekanism:universal_cable_" + tier.name().toLowerCase(); - } + nbtTags.setDouble("cacheEnergy", lastWrite); + nbtTags.setInteger("tier", tier.ordinal()); + } - public static void registerIcons(IIconRegister register) - { - cableIcons.registerCenterIcons(register, new String[]{"UniversalCableBasic", "UniversalCableAdvanced", - "UniversalCableElite", "UniversalCableUltimate"}); - cableIcons.registerSideIcons(register, new String[]{"UniversalCableVerticalBasic", "UniversalCableVerticalAdvanced", "UniversalCableVerticalElite", "UniversalCableVerticalUltimate", - "UniversalCableHorizontalBasic", "UniversalCableHorizontalAdvanced", "UniversalCableHorizontalElite", "UniversalCableHorizontalUltimate"}); - } + @Override + public String getType() { + return "mekanism:universal_cable_" + tier.name().toLowerCase(); + } - @Override - public IIcon getCenterIcon(boolean opaque) - { - return cableIcons.getCenterIcon(tier.ordinal()); - } + public static void registerIcons(IIconRegister register) { + cableIcons.registerCenterIcons( + register, + new String[] { "UniversalCableBasic", + "UniversalCableAdvanced", + "UniversalCableElite", + "UniversalCableUltimate" } + ); + cableIcons.registerSideIcons( + register, + new String[] { "UniversalCableVerticalBasic", + "UniversalCableVerticalAdvanced", + "UniversalCableVerticalElite", + "UniversalCableVerticalUltimate", + "UniversalCableHorizontalBasic", + "UniversalCableHorizontalAdvanced", + "UniversalCableHorizontalElite", + "UniversalCableHorizontalUltimate" } + ); + } - @Override - public IIcon getSideIcon(boolean opaque) - { - return cableIcons.getSideIcon(tier.ordinal()); - } + @Override + public IIcon getCenterIcon(boolean opaque) { + return cableIcons.getCenterIcon(tier.ordinal()); + } - @Override - public IIcon getSideIconRotated(boolean opaque) - { - return cableIcons.getSideIcon(4+tier.ordinal()); - } + @Override + public IIcon getSideIcon(boolean opaque) { + return cableIcons.getSideIcon(tier.ordinal()); + } - @Override - public TransmissionType getTransmissionType() - { - return TransmissionType.ENERGY; - } + @Override + public IIcon getSideIconRotated(boolean opaque) { + return cableIcons.getSideIcon(4 + tier.ordinal()); + } - @Override - public EnergyNetwork createNetworkByMerging(Collection networks) - { - return new EnergyNetwork(networks); - } + @Override + public TransmissionType getTransmissionType() { + return TransmissionType.ENERGY; + } - @Override - public boolean isValidAcceptor(TileEntity acceptor, ForgeDirection side) - { - return CableUtils.isValidAcceptorOnSide(tile(), acceptor, side); - } + @Override + public EnergyNetwork createNetworkByMerging(Collection networks) { + return new EnergyNetwork(networks); + } - @Override - @SideOnly(Side.CLIENT) - public void renderDynamic(Vector3 pos, float frame, int pass) - { - if(pass == 0 && !client.opaqueTransmitters) - { - RenderPartTransmitter.getInstance().renderContents(this, pos); - } - } + @Override + public boolean isValidAcceptor(TileEntity acceptor, ForgeDirection side) { + return CableUtils.isValidAcceptorOnSide(tile(), acceptor, side); + } - @Override - public EnergyNetwork createNewNetwork() - { - return new EnergyNetwork(); - } + @Override + @SideOnly(Side.CLIENT) + public void renderDynamic(Vector3 pos, float frame, int pass) { + if (pass == 0 && !client.opaqueTransmitters) { + RenderPartTransmitter.getInstance().renderContents(this, pos); + } + } - @Override - public void onChunkUnload() - { - takeShare(); - super.onChunkUnload(); - } + @Override + public EnergyNetwork createNewNetwork() { + return new EnergyNetwork(); + } - @Override - public Object getBuffer() - { - return buffer; - } + @Override + public void onChunkUnload() { + takeShare(); + super.onChunkUnload(); + } - @Override - public void takeShare() - { - if(getTransmitter().hasTransmitterNetwork()) - { - getTransmitter().getTransmitterNetwork().buffer.amount -= lastWrite; - buffer.amount = lastWrite; - } - } + @Override + public Object getBuffer() { + return buffer; + } - @Override - public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) - { - if(canReceiveEnergy(from)) - { - return maxReceive - (int)Math.round(takeEnergy(maxReceive * general.FROM_TE, !simulate) * general.TO_TE); - } + @Override + public void takeShare() { + if (getTransmitter().hasTransmitterNetwork()) { + getTransmitter().getTransmitterNetwork().buffer.amount -= lastWrite; + buffer.amount = lastWrite; + } + } - return 0; - } + @Override + public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { + if (canReceiveEnergy(from)) { + return maxReceive + - (int) Math.round( + takeEnergy(maxReceive * general.FROM_TE, !simulate) * general.TO_TE + ); + } - @Override - public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) - { - return 0; - } + return 0; + } - @Override - public boolean canConnectEnergy(ForgeDirection from) - { - return canConnect(from); - } + @Override + public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) { + return 0; + } - @Override - public int getEnergyStored(ForgeDirection from) - { - return (int)Math.round(getEnergy() * general.TO_TE); - } + @Override + public boolean canConnectEnergy(ForgeDirection from) { + return canConnect(from); + } - @Override - public int getMaxEnergyStored(ForgeDirection from) - { - return (int)Math.round(getMaxEnergy() * general.TO_TE); - } + @Override + public int getEnergyStored(ForgeDirection from) { + return (int) Math.round(getEnergy() * general.TO_TE); + } - @Override - public int getCapacity() - { - return tier.cableCapacity; - } + @Override + public int getMaxEnergyStored(ForgeDirection from) { + return (int) Math.round(getMaxEnergy() * general.TO_TE); + } - @Override - public double transferEnergyToAcceptor(ForgeDirection side, double amount) - { - if(!canReceiveEnergy(side)) - { - return 0; - } + @Override + public int getCapacity() { + return tier.cableCapacity; + } - double toUse = Math.min(getMaxEnergy() - getEnergy(), amount); - setEnergy(getEnergy() + toUse); + @Override + public double transferEnergyToAcceptor(ForgeDirection side, double amount) { + if (!canReceiveEnergy(side)) { + return 0; + } - return toUse; - } + double toUse = Math.min(getMaxEnergy() - getEnergy(), amount); + setEnergy(getEnergy() + toUse); - @Override - public boolean canReceiveEnergy(ForgeDirection side) - { - return getConnectionType(side) == ConnectionType.NORMAL; - } + return toUse; + } - @Override - public double getMaxEnergy() - { - if(getTransmitter().hasTransmitterNetwork()) - { - return getTransmitter().getTransmitterNetwork().getCapacity(); - } - else { - return getCapacity(); - } - } + @Override + public boolean canReceiveEnergy(ForgeDirection side) { + return getConnectionType(side) == ConnectionType.NORMAL; + } - @Override - public double getEnergy() - { - if(getTransmitter().hasTransmitterNetwork()) - { - return getTransmitter().getTransmitterNetwork().buffer.amount; - } - else { - return buffer.amount; - } - } + @Override + public double getMaxEnergy() { + if (getTransmitter().hasTransmitterNetwork()) { + return getTransmitter().getTransmitterNetwork().getCapacity(); + } else { + return getCapacity(); + } + } - @Override - public void setEnergy(double energy) - { - if(getTransmitter().hasTransmitterNetwork()) - { - getTransmitter().getTransmitterNetwork().buffer.amount = energy; - } - else { - buffer.amount = energy; - } - } + @Override + public double getEnergy() { + if (getTransmitter().hasTransmitterNetwork()) { + return getTransmitter().getTransmitterNetwork().buffer.amount; + } else { + return buffer.amount; + } + } - public double takeEnergy(double energy, boolean doEmit) - { - if(getTransmitter().hasTransmitterNetwork()) - { - return getTransmitter().getTransmitterNetwork().emit(energy, doEmit); - } - else { - double used = Math.min(getCapacity() - buffer.amount, energy); - - if(doEmit) - { - buffer.amount += used; - } - - return energy - used; - } - } + @Override + public void setEnergy(double energy) { + if (getTransmitter().hasTransmitterNetwork()) { + getTransmitter().getTransmitterNetwork().buffer.amount = energy; + } else { + buffer.amount = energy; + } + } - @Override - public EnergyAcceptorWrapper getCachedAcceptor(ForgeDirection side) - { - ConnectionType type = connectionTypes[side.ordinal()]; + public double takeEnergy(double energy, boolean doEmit) { + if (getTransmitter().hasTransmitterNetwork()) { + return getTransmitter().getTransmitterNetwork().emit(energy, doEmit); + } else { + double used = Math.min(getCapacity() - buffer.amount, energy); - if(type == ConnectionType.PULL || type == ConnectionType.NONE) - { - return null; - } + if (doEmit) { + buffer.amount += used; + } - return connectionMapContainsSide(currentAcceptorConnections, side) ? EnergyAcceptorWrapper.get(cachedAcceptors[side.ordinal()]) : null; - } + return energy - used; + } + } - @Override - public boolean upgrade(int tierOrdinal) - { - if(tier.ordinal() < BaseTier.ULTIMATE.ordinal() && tierOrdinal == tier.ordinal()+1) - { - tier = CableTier.values()[tier.ordinal()+1]; - - markDirtyTransmitters(); - sendDesc = true; - - return true; - } - - return false; - } - - @Override - public void readDesc(MCDataInput packet) - { - tier = CableTier.values()[packet.readInt()]; - - super.readDesc(packet); - } + @Override + public EnergyAcceptorWrapper getCachedAcceptor(ForgeDirection side) { + ConnectionType type = connectionTypes[side.ordinal()]; - @Override - public void writeDesc(MCDataOutput packet) - { - packet.writeInt(tier.ordinal()); - - super.writeDesc(packet); - } + if (type == ConnectionType.PULL || type == ConnectionType.NONE) { + return null; + } + + return connectionMapContainsSide(currentAcceptorConnections, side) + ? EnergyAcceptorWrapper.get(cachedAcceptors[side.ordinal()]) + : null; + } + + @Override + public boolean upgrade(int tierOrdinal) { + if (tier.ordinal() < BaseTier.ULTIMATE.ordinal() + && tierOrdinal == tier.ordinal() + 1) { + tier = CableTier.values()[tier.ordinal() + 1]; + + markDirtyTransmitters(); + sendDesc = true; + + return true; + } + + return false; + } + + @Override + public void readDesc(MCDataInput packet) { + tier = CableTier.values()[packet.readInt()]; + + super.readDesc(packet); + } + + @Override + public void writeDesc(MCDataOutput packet) { + packet.writeInt(tier.ordinal()); + + super.writeDesc(packet); + } } diff --git a/src/main/java/mekanism/common/multipart/PlasticMicroMaterial.java b/src/main/java/mekanism/common/multipart/PlasticMicroMaterial.java index 70bf96d20..fe17ca48e 100644 --- a/src/main/java/mekanism/common/multipart/PlasticMicroMaterial.java +++ b/src/main/java/mekanism/common/multipart/PlasticMicroMaterial.java @@ -1,18 +1,15 @@ package mekanism.common.multipart; -import net.minecraft.block.Block; import codechicken.microblock.BlockMicroMaterial; +import net.minecraft.block.Block; -public class PlasticMicroMaterial extends BlockMicroMaterial -{ - public PlasticMicroMaterial(Block block, int meta) - { - super(block, meta); - } +public class PlasticMicroMaterial extends BlockMicroMaterial { + public PlasticMicroMaterial(Block block, int meta) { + super(block, meta); + } - @Override - public int getColour(int pass) - { - return block().getRenderColor(meta()) << 8 | 0xFF; - } + @Override + public int getColour(int pass) { + return block().getRenderColor(meta()) << 8 | 0xFF; + } } diff --git a/src/main/java/mekanism/common/multipart/TransmitterIcons.java b/src/main/java/mekanism/common/multipart/TransmitterIcons.java index e80c07d7a..9237756f5 100644 --- a/src/main/java/mekanism/common/multipart/TransmitterIcons.java +++ b/src/main/java/mekanism/common/multipart/TransmitterIcons.java @@ -4,48 +4,42 @@ import mekanism.api.MekanismConfig.client; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.util.IIcon; -public class TransmitterIcons -{ - private IIcon[] sideIcons; - private IIcon[] centerIcons; - - private IIcon[] sideIcons_opaque; - private IIcon[] centerIcons_opaque; +public class TransmitterIcons { + private IIcon[] sideIcons; + private IIcon[] centerIcons; - public TransmitterIcons(int numCentres, int numSides) - { - sideIcons = new IIcon[numSides]; - centerIcons = new IIcon[numCentres]; - - sideIcons_opaque = new IIcon[numSides]; - centerIcons_opaque = new IIcon[numCentres]; - } + private IIcon[] sideIcons_opaque; + private IIcon[] centerIcons_opaque; - public void registerCenterIcons(IIconRegister register, String[] filenames) - { - for(int i = 0; i < centerIcons.length; i++) - { - centerIcons[i] = register.registerIcon("mekanism:models/" + filenames[i]); - centerIcons_opaque[i] = register.registerIcon("mekanism:models/opaque/" + filenames[i]); - } - } + public TransmitterIcons(int numCentres, int numSides) { + sideIcons = new IIcon[numSides]; + centerIcons = new IIcon[numCentres]; - public void registerSideIcons(IIconRegister register, String[] filenames) - { - for(int i = 0; i < sideIcons.length; i++) - { - sideIcons[i] = register.registerIcon("mekanism:models/" + filenames[i]); - sideIcons_opaque[i] = register.registerIcon("mekanism:models/opaque/" + filenames[i]); - } - } + sideIcons_opaque = new IIcon[numSides]; + centerIcons_opaque = new IIcon[numCentres]; + } - public IIcon getSideIcon(int n) - { - return client.opaqueTransmitters ? sideIcons_opaque[n] : sideIcons[n]; - } + public void registerCenterIcons(IIconRegister register, String[] filenames) { + for (int i = 0; i < centerIcons.length; i++) { + centerIcons[i] = register.registerIcon("mekanism:models/" + filenames[i]); + centerIcons_opaque[i] + = register.registerIcon("mekanism:models/opaque/" + filenames[i]); + } + } - public IIcon getCenterIcon(int n) - { - return client.opaqueTransmitters ? centerIcons_opaque[n] : centerIcons[n]; - } + public void registerSideIcons(IIconRegister register, String[] filenames) { + for (int i = 0; i < sideIcons.length; i++) { + sideIcons[i] = register.registerIcon("mekanism:models/" + filenames[i]); + sideIcons_opaque[i] + = register.registerIcon("mekanism:models/opaque/" + filenames[i]); + } + } + + public IIcon getSideIcon(int n) { + return client.opaqueTransmitters ? sideIcons_opaque[n] : sideIcons[n]; + } + + public IIcon getCenterIcon(int n) { + return client.opaqueTransmitters ? centerIcons_opaque[n] : centerIcons[n]; + } } diff --git a/src/main/java/mekanism/common/multipart/TransmitterType.java b/src/main/java/mekanism/common/multipart/TransmitterType.java index ab01b58ea..3bc31e8ca 100644 --- a/src/main/java/mekanism/common/multipart/TransmitterType.java +++ b/src/main/java/mekanism/common/multipart/TransmitterType.java @@ -4,107 +4,308 @@ import mekanism.api.transmitters.TransmissionType; import mekanism.common.Tier.BaseTier; import net.minecraft.util.IIcon; -public enum TransmitterType -{ - UNIVERSAL_CABLE_BASIC("BasicUniversalCable", BaseTier.BASIC, Size.SMALL, TransmissionType.ENERGY, PartUniversalCable.cableIcons, false, 0, 0), - UNIVERSAL_CABLE_ADVANCED("AdvancedUniversalCable", BaseTier.ADVANCED, Size.SMALL, TransmissionType.ENERGY, PartUniversalCable.cableIcons, false, 1, 1), - UNIVERSAL_CABLE_ELITE("EliteUniversalCable", BaseTier.ELITE, Size.SMALL, TransmissionType.ENERGY, PartUniversalCable.cableIcons, false, 2, 2), - UNIVERSAL_CABLE_ULTIMATE("UltimateUniversalCable", BaseTier.ULTIMATE, Size.SMALL, TransmissionType.ENERGY, PartUniversalCable.cableIcons, false, 3, 3), - MECHANICAL_PIPE_BASIC("BasicMechanicalPipe", BaseTier.BASIC, Size.LARGE, TransmissionType.FLUID, PartMechanicalPipe.pipeIcons, false, 0, 0), - MECHANICAL_PIPE_ADVANCED("AdvancedMechanicalPipe", BaseTier.ADVANCED, Size.LARGE, TransmissionType.FLUID, PartMechanicalPipe.pipeIcons, false, 1, 1), - MECHANICAL_PIPE_ELITE("EliteMechanicalPipe", BaseTier.ELITE, Size.LARGE, TransmissionType.FLUID, PartMechanicalPipe.pipeIcons, false, 2, 2), - MECHANICAL_PIPE_ULTIMATE("UltimateMechanicalPipe", BaseTier.ULTIMATE, Size.LARGE, TransmissionType.FLUID, PartMechanicalPipe.pipeIcons, false, 3, 3), - PRESSURIZED_TUBE_BASIC("BasicPressurizedTube", BaseTier.BASIC, Size.SMALL, TransmissionType.GAS, PartPressurizedTube.tubeIcons, false, 0, 0), - PRESSURIZED_TUBE_ADVANCED("AdvancedPressurizedTube", BaseTier.ADVANCED, Size.SMALL, TransmissionType.GAS, PartPressurizedTube.tubeIcons, false, 1, 1), - PRESSURIZED_TUBE_ELITE("ElitePressurizedTube", BaseTier.ELITE, Size.SMALL, TransmissionType.GAS, PartPressurizedTube.tubeIcons, false, 2, 2), - PRESSURIZED_TUBE_ULTIMATE("UltimatePressurizedTube", BaseTier.ULTIMATE, Size.SMALL, TransmissionType.GAS, PartPressurizedTube.tubeIcons, false, 3, 3), - LOGISTICAL_TRANSPORTER_BASIC("BasicLogisticalTransporter", BaseTier.BASIC, Size.LARGE, TransmissionType.ITEM, PartLogisticalTransporter.transporterIcons, true, 0, 0, 6, 10), - LOGISTICAL_TRANSPORTER_ADVANCED("AdvancedLogisticalTransporter", BaseTier.ADVANCED, Size.LARGE, TransmissionType.ITEM, PartLogisticalTransporter.transporterIcons, true, 1, 1, 6, 10), - LOGISTICAL_TRANSPORTER_ELITE("EliteLogisticalTransporter", BaseTier.ELITE, Size.LARGE, TransmissionType.ITEM, PartLogisticalTransporter.transporterIcons, true, 2, 2, 6, 10), - LOGISTICAL_TRANSPORTER_ULTIMATE("UltimateLogisticalTransporter", BaseTier.ULTIMATE, Size.LARGE, TransmissionType.ITEM, PartLogisticalTransporter.transporterIcons, true, 3, 3, 6, 10), - RESTRICTIVE_TRANSPORTER("RestrictiveTransporter", BaseTier.BASIC, Size.LARGE, TransmissionType.ITEM, PartLogisticalTransporter.transporterIcons, false, 4, 8), - DIVERSION_TRANSPORTER("DiversionTransporter", BaseTier.BASIC, Size.LARGE, TransmissionType.ITEM, PartLogisticalTransporter.transporterIcons, true, 5, 14, 6, 10), - THERMODYNAMIC_CONDUCTOR_BASIC("BasicThermodynamicConductor", BaseTier.BASIC, Size.SMALL, TransmissionType.HEAT, PartThermodynamicConductor.conductorIcons, false, 0, 0), - THERMODYNAMIC_CONDUCTOR_ADVANCED("AdvancedThermodynamicConductor", BaseTier.ADVANCED, Size.SMALL, TransmissionType.HEAT, PartThermodynamicConductor.conductorIcons, false, 1, 1), - THERMODYNAMIC_CONDUCTOR_ELITE("EliteThermodynamicConductor", BaseTier.ELITE, Size.SMALL, TransmissionType.HEAT, PartThermodynamicConductor.conductorIcons, false, 2, 2), - THERMODYNAMIC_CONDUCTOR_ULTIMATE("UltimateThermodynamicConductor", BaseTier.ULTIMATE, Size.SMALL, TransmissionType.HEAT, PartThermodynamicConductor.conductorIcons, false, 3, 3); +public enum TransmitterType { + UNIVERSAL_CABLE_BASIC( + "BasicUniversalCable", + BaseTier.BASIC, + Size.SMALL, + TransmissionType.ENERGY, + PartUniversalCable.cableIcons, + false, + 0, + 0 + ), + UNIVERSAL_CABLE_ADVANCED( + "AdvancedUniversalCable", + BaseTier.ADVANCED, + Size.SMALL, + TransmissionType.ENERGY, + PartUniversalCable.cableIcons, + false, + 1, + 1 + ), + UNIVERSAL_CABLE_ELITE( + "EliteUniversalCable", + BaseTier.ELITE, + Size.SMALL, + TransmissionType.ENERGY, + PartUniversalCable.cableIcons, + false, + 2, + 2 + ), + UNIVERSAL_CABLE_ULTIMATE( + "UltimateUniversalCable", + BaseTier.ULTIMATE, + Size.SMALL, + TransmissionType.ENERGY, + PartUniversalCable.cableIcons, + false, + 3, + 3 + ), + MECHANICAL_PIPE_BASIC( + "BasicMechanicalPipe", + BaseTier.BASIC, + Size.LARGE, + TransmissionType.FLUID, + PartMechanicalPipe.pipeIcons, + false, + 0, + 0 + ), + MECHANICAL_PIPE_ADVANCED( + "AdvancedMechanicalPipe", + BaseTier.ADVANCED, + Size.LARGE, + TransmissionType.FLUID, + PartMechanicalPipe.pipeIcons, + false, + 1, + 1 + ), + MECHANICAL_PIPE_ELITE( + "EliteMechanicalPipe", + BaseTier.ELITE, + Size.LARGE, + TransmissionType.FLUID, + PartMechanicalPipe.pipeIcons, + false, + 2, + 2 + ), + MECHANICAL_PIPE_ULTIMATE( + "UltimateMechanicalPipe", + BaseTier.ULTIMATE, + Size.LARGE, + TransmissionType.FLUID, + PartMechanicalPipe.pipeIcons, + false, + 3, + 3 + ), + PRESSURIZED_TUBE_BASIC( + "BasicPressurizedTube", + BaseTier.BASIC, + Size.SMALL, + TransmissionType.GAS, + PartPressurizedTube.tubeIcons, + false, + 0, + 0 + ), + PRESSURIZED_TUBE_ADVANCED( + "AdvancedPressurizedTube", + BaseTier.ADVANCED, + Size.SMALL, + TransmissionType.GAS, + PartPressurizedTube.tubeIcons, + false, + 1, + 1 + ), + PRESSURIZED_TUBE_ELITE( + "ElitePressurizedTube", + BaseTier.ELITE, + Size.SMALL, + TransmissionType.GAS, + PartPressurizedTube.tubeIcons, + false, + 2, + 2 + ), + PRESSURIZED_TUBE_ULTIMATE( + "UltimatePressurizedTube", + BaseTier.ULTIMATE, + Size.SMALL, + TransmissionType.GAS, + PartPressurizedTube.tubeIcons, + false, + 3, + 3 + ), + LOGISTICAL_TRANSPORTER_BASIC( + "BasicLogisticalTransporter", + BaseTier.BASIC, + Size.LARGE, + TransmissionType.ITEM, + PartLogisticalTransporter.transporterIcons, + true, + 0, + 0, + 6, + 10 + ), + LOGISTICAL_TRANSPORTER_ADVANCED( + "AdvancedLogisticalTransporter", + BaseTier.ADVANCED, + Size.LARGE, + TransmissionType.ITEM, + PartLogisticalTransporter.transporterIcons, + true, + 1, + 1, + 6, + 10 + ), + LOGISTICAL_TRANSPORTER_ELITE( + "EliteLogisticalTransporter", + BaseTier.ELITE, + Size.LARGE, + TransmissionType.ITEM, + PartLogisticalTransporter.transporterIcons, + true, + 2, + 2, + 6, + 10 + ), + LOGISTICAL_TRANSPORTER_ULTIMATE( + "UltimateLogisticalTransporter", + BaseTier.ULTIMATE, + Size.LARGE, + TransmissionType.ITEM, + PartLogisticalTransporter.transporterIcons, + true, + 3, + 3, + 6, + 10 + ), + RESTRICTIVE_TRANSPORTER( + "RestrictiveTransporter", + BaseTier.BASIC, + Size.LARGE, + TransmissionType.ITEM, + PartLogisticalTransporter.transporterIcons, + false, + 4, + 8 + ), + DIVERSION_TRANSPORTER( + "DiversionTransporter", + BaseTier.BASIC, + Size.LARGE, + TransmissionType.ITEM, + PartLogisticalTransporter.transporterIcons, + true, + 5, + 14, + 6, + 10 + ), + THERMODYNAMIC_CONDUCTOR_BASIC( + "BasicThermodynamicConductor", + BaseTier.BASIC, + Size.SMALL, + TransmissionType.HEAT, + PartThermodynamicConductor.conductorIcons, + false, + 0, + 0 + ), + THERMODYNAMIC_CONDUCTOR_ADVANCED( + "AdvancedThermodynamicConductor", + BaseTier.ADVANCED, + Size.SMALL, + TransmissionType.HEAT, + PartThermodynamicConductor.conductorIcons, + false, + 1, + 1 + ), + THERMODYNAMIC_CONDUCTOR_ELITE( + "EliteThermodynamicConductor", + BaseTier.ELITE, + Size.SMALL, + TransmissionType.HEAT, + PartThermodynamicConductor.conductorIcons, + false, + 2, + 2 + ), + THERMODYNAMIC_CONDUCTOR_ULTIMATE( + "UltimateThermodynamicConductor", + BaseTier.ULTIMATE, + Size.SMALL, + TransmissionType.HEAT, + PartThermodynamicConductor.conductorIcons, + false, + 3, + 3 + ); - private String unlocalizedName; - private Size size; - private TransmissionType transmissionType; - private TransmitterIcons transmitterIcons; - private boolean transparencyRender; - private int[] indexes; - private BaseTier tier; + private String unlocalizedName; + private Size size; + private TransmissionType transmissionType; + private TransmitterIcons transmitterIcons; + private boolean transparencyRender; + private int[] indexes; + private BaseTier tier; - private TransmitterType(String name, BaseTier t, Size s, TransmissionType type, TransmitterIcons icons, boolean transparency, int... is) - { - unlocalizedName = name; - tier = t; - size = s; - transmissionType = type; - transmitterIcons = icons; - transparencyRender = transparency; - indexes = is; - } - - public BaseTier getTier() - { - return tier; - } + private TransmitterType( + String name, + BaseTier t, + Size s, + TransmissionType type, + TransmitterIcons icons, + boolean transparency, + int... is + ) { + unlocalizedName = name; + tier = t; + size = s; + transmissionType = type; + transmitterIcons = icons; + transparencyRender = transparency; + indexes = is; + } - public String getName() - { - return unlocalizedName; - } + public BaseTier getTier() { + return tier; + } - public Size getSize() - { - return size; - } - - public boolean hasTransparency() - { - return transparencyRender; - } + public String getName() { + return unlocalizedName; + } - public TransmissionType getTransmission() - { - return transmissionType; - } + public Size getSize() { + return size; + } - public IIcon getCenterIcon(boolean opaque) - { - if(!transparencyRender) - { - return transmitterIcons.getCenterIcon(indexes[0]); - } - else { - return transmitterIcons.getCenterIcon(opaque ? indexes[0] : indexes[2]); - } - } + public boolean hasTransparency() { + return transparencyRender; + } - public IIcon getSideIcon(boolean opaque) - { - if(!transparencyRender) - { - return transmitterIcons.getSideIcon(indexes[1]); - } - else { - return transmitterIcons.getSideIcon(opaque ? indexes[1] : indexes[3]); - } - } + public TransmissionType getTransmission() { + return transmissionType; + } - public static enum Size - { - SMALL(6), - LARGE(8); + public IIcon getCenterIcon(boolean opaque) { + if (!transparencyRender) { + return transmitterIcons.getCenterIcon(indexes[0]); + } else { + return transmitterIcons.getCenterIcon(opaque ? indexes[0] : indexes[2]); + } + } - public int centerSize; + public IIcon getSideIcon(boolean opaque) { + if (!transparencyRender) { + return transmitterIcons.getSideIcon(indexes[1]); + } else { + return transmitterIcons.getSideIcon(opaque ? indexes[1] : indexes[3]); + } + } - private Size(int size) - { - centerSize = size; - } - } + public static enum Size { + SMALL(6), + LARGE(8); + + public int centerSize; + + private Size(int size) { + centerSize = size; + } + } } diff --git a/src/main/java/mekanism/common/network/PacketBoxBlacklist.java b/src/main/java/mekanism/common/network/PacketBoxBlacklist.java index ecfb36de6..e4ca2b275 100644 --- a/src/main/java/mekanism/common/network/PacketBoxBlacklist.java +++ b/src/main/java/mekanism/common/network/PacketBoxBlacklist.java @@ -1,52 +1,51 @@ package mekanism.common.network; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; import mekanism.api.MekanismAPI; import mekanism.api.util.BlockInfo; import mekanism.common.Mekanism; import mekanism.common.network.PacketBoxBlacklist.BoxBlacklistMessage; import net.minecraft.block.Block; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -public class PacketBoxBlacklist implements IMessageHandler -{ - @Override - public IMessage onMessage(BoxBlacklistMessage message, MessageContext context) - { - return null; - } - - public static class BoxBlacklistMessage implements IMessage - { - public BoxBlacklistMessage() {} - - @Override - public void toBytes(ByteBuf dataStream) - { - dataStream.writeInt(MekanismAPI.getBoxIgnore().size()); - - for(BlockInfo info : MekanismAPI.getBoxIgnore()) - { - dataStream.writeInt(Block.getIdFromBlock(info.block)); - dataStream.writeInt(info.meta); - } - } - - @Override - public void fromBytes(ByteBuf dataStream) - { - MekanismAPI.getBoxIgnore().clear(); - - int amount = dataStream.readInt(); - - for(int i = 0; i < amount; i++) - { - MekanismAPI.addBoxBlacklist(Block.getBlockById(dataStream.readInt()), dataStream.readInt()); - } - - Mekanism.logger.info("Received Cardboard Box blacklist entries from server (" + amount + " total)"); - } - } +public class PacketBoxBlacklist + implements IMessageHandler { + @Override + public IMessage onMessage(BoxBlacklistMessage message, MessageContext context) { + return null; + } + + public static class BoxBlacklistMessage implements IMessage { + public BoxBlacklistMessage() {} + + @Override + public void toBytes(ByteBuf dataStream) { + dataStream.writeInt(MekanismAPI.getBoxIgnore().size()); + + for (BlockInfo info : MekanismAPI.getBoxIgnore()) { + dataStream.writeInt(Block.getIdFromBlock(info.block)); + dataStream.writeInt(info.meta); + } + } + + @Override + public void fromBytes(ByteBuf dataStream) { + MekanismAPI.getBoxIgnore().clear(); + + int amount = dataStream.readInt(); + + for (int i = 0; i < amount; i++) { + MekanismAPI.addBoxBlacklist( + Block.getBlockById(dataStream.readInt()), dataStream.readInt() + ); + } + + Mekanism.logger.info( + "Received Cardboard Box blacklist entries from server (" + amount + + " total)" + ); + } + } } diff --git a/src/main/java/mekanism/common/network/PacketChangeTime.java b/src/main/java/mekanism/common/network/PacketChangeTime.java index 686a4118c..fb5862bdb 100644 --- a/src/main/java/mekanism/common/network/PacketChangeTime.java +++ b/src/main/java/mekanism/common/network/PacketChangeTime.java @@ -11,10 +11,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; public class PacketChangeTime implements IMessageHandler { - - public static class ChangeTimeMessage implements IMessage { - public int time; public ChangeTimeMessage() {} @@ -32,7 +29,6 @@ public class PacketChangeTime implements IMessageHandler { - +public class PacketChangeWeather + implements IMessageHandler { public static enum WeatherType { CLEAR, HAZE, @@ -18,14 +18,13 @@ public class PacketChangeWeather implements IMessageHandler= WeatherType.values().length || ordinal < 0) return null; + if (ordinal >= WeatherType.values().length || ordinal < 0) + return null; return WeatherType.values()[ordinal]; } - } public static class ChangeWeatherMessage implements IMessage { - public WeatherType type; public ChangeWeatherMessage() {} @@ -43,7 +42,6 @@ public class PacketChangeWeather implements IMessageHandler -{ - @Override - public IMessage onMessage(ConfigSyncMessage message, MessageContext context) - { - return null; - } - - public static class ConfigSyncMessage implements IMessage - { - public ConfigSyncMessage() {} - - @Override - public void toBytes(ByteBuf dataStream) - { - dataStream.writeBoolean(general.controlCircuitOreDict); - dataStream.writeBoolean(general.logPackets); - dataStream.writeBoolean(general.dynamicTankEasterEgg); - dataStream.writeBoolean(general.voiceServerEnabled); - dataStream.writeBoolean(general.cardboardSpawners); - dataStream.writeBoolean(general.spawnBabySkeletons); - dataStream.writeInt(general.obsidianTNTDelay); - dataStream.writeInt(general.obsidianTNTBlastRadius); - dataStream.writeInt(general.UPDATE_DELAY); - dataStream.writeDouble(general.FROM_IC2); - dataStream.writeDouble(general.TO_IC2); - dataStream.writeDouble(general.FROM_TE); - dataStream.writeDouble(general.TO_TE); - dataStream.writeDouble(general.FROM_H2); - dataStream.writeInt(general.ETHENE_BURN_TIME); - dataStream.writeInt(general.METHANE_BURN_TIME); - dataStream.writeDouble(general.ENERGY_PER_REDSTONE); - dataStream.writeDouble(general.DISASSEMBLER_USAGE); - dataStream.writeInt(general.VOICE_PORT); - dataStream.writeInt(general.maxUpgradeMultiplier); - dataStream.writeInt(general.energyUnit.ordinal()); - dataStream.writeDouble(general.minerSilkMultiplier); - dataStream.writeBoolean(general.blacklistIC2); - dataStream.writeBoolean(general.blacklistRF); - dataStream.writeDouble(general.armoredJetpackDamageRatio); - dataStream.writeInt(general.armoredJetpackDamageMax); - dataStream.writeBoolean(general.aestheticWorldDamage); - dataStream.writeBoolean(general.opsBypassRestrictions); - dataStream.writeDouble(general.thermalEvaporationSpeed); - dataStream.writeInt(general.maxJetpackGas); - dataStream.writeInt(general.maxScubaGas); - dataStream.writeInt(general.maxFlamethrowerGas); - dataStream.writeInt(general.maxPumpRange); - dataStream.writeBoolean(general.pumpWaterSources); - dataStream.writeInt(general.maxPlenisherNodes); - dataStream.writeDouble(general.evaporationHeatDissipation); - dataStream.writeDouble(general.evaporationTempMultiplier); - dataStream.writeDouble(general.evaporationSolarMultiplier); - dataStream.writeDouble(general.evaporationMaxTemp); - dataStream.writeDouble(general.energyPerHeat); - dataStream.writeDouble(general.maxEnergyPerSteam); - dataStream.writeDouble(general.superheatingHeatTransfer); - dataStream.writeDouble(general.heatPerFuelTick); - dataStream.writeBoolean(general.allowTransmitterAlloyUpgrade); - dataStream.writeBoolean(general.allowProtection); - dataStream.writeBoolean(general.EnableQuartzCompat); - dataStream.writeBoolean(general.EnableDiamondCompat); - dataStream.writeBoolean(general.EnablePoorOresCompat); - dataStream.writeBoolean(general.OreDictOsmium); - dataStream.writeBoolean(general.OreDictPlatinum); - - for(MachineType type : MachineType.getValidMachines()) - { - dataStream.writeBoolean(machines.isEnabled(type.name)); - } - - dataStream.writeDouble(usage.enrichmentChamberUsage); - dataStream.writeDouble(usage.osmiumCompressorUsage); - dataStream.writeDouble(usage.combinerUsage); - dataStream.writeDouble(usage.crusherUsage); - dataStream.writeDouble(usage.factoryUsage); - dataStream.writeDouble(usage.metallurgicInfuserUsage); - dataStream.writeDouble(usage.purificationChamberUsage); - dataStream.writeDouble(usage.energizedSmelterUsage); - dataStream.writeDouble(usage.digitalMinerUsage); - dataStream.writeDouble(usage.electricPumpUsage); - dataStream.writeDouble(usage.rotaryCondensentratorUsage); - dataStream.writeDouble(usage.oxidationChamberUsage); - dataStream.writeDouble(usage.chemicalInfuserUsage); - dataStream.writeDouble(usage.chemicalInjectionChamberUsage); - dataStream.writeDouble(usage.precisionSawmillUsage); - dataStream.writeDouble(usage.chemicalDissolutionChamberUsage); - dataStream.writeDouble(usage.chemicalWasherUsage); - dataStream.writeDouble(usage.chemicalCrystallizerUsage); - dataStream.writeDouble(usage.seismicVibratorUsage); - dataStream.writeDouble(usage.fluidicPlenisherUsage); - dataStream.writeDouble(usage.gasCentrifugeUsage); - dataStream.writeDouble(usage.heavyWaterElectrolysisUsage); - dataStream.writeDouble(usage.formulaicAssemblicatorUsage); - - Tier.writeConfig(dataStream); - - try { - for(IModule module : Mekanism.modulesLoaded) - { - module.writeConfig(dataStream); - } - } catch(Exception e) { - e.printStackTrace(); - } - } - - @Override - public void fromBytes(ByteBuf dataStream) - { - general.controlCircuitOreDict = dataStream.readBoolean(); - general.logPackets = dataStream.readBoolean(); - general.dynamicTankEasterEgg = dataStream.readBoolean(); - general.voiceServerEnabled = dataStream.readBoolean(); - general.cardboardSpawners = dataStream.readBoolean(); - general.spawnBabySkeletons = dataStream.readBoolean(); - general.obsidianTNTDelay = dataStream.readInt(); - general.obsidianTNTBlastRadius = dataStream.readInt(); - general.UPDATE_DELAY = dataStream.readInt(); - general.FROM_IC2 = dataStream.readDouble(); - general.TO_IC2 = dataStream.readDouble(); - general.FROM_TE = dataStream.readDouble(); - general.TO_TE = dataStream.readDouble(); - general.FROM_H2 = dataStream.readDouble(); - general.ETHENE_BURN_TIME = dataStream.readInt(); - general.METHANE_BURN_TIME = dataStream.readInt(); - general.ENERGY_PER_REDSTONE = dataStream.readDouble(); - general.DISASSEMBLER_USAGE = dataStream.readDouble(); - general.VOICE_PORT = dataStream.readInt(); - general.maxUpgradeMultiplier = dataStream.readInt(); - general.energyUnit = EnergyType.values()[dataStream.readInt()]; - general.minerSilkMultiplier = dataStream.readDouble(); - general.blacklistIC2 = dataStream.readBoolean(); - general.blacklistRF = dataStream.readBoolean(); - general.armoredJetpackDamageRatio = dataStream.readDouble(); - general.armoredJetpackDamageMax = dataStream.readInt(); - general.aestheticWorldDamage = dataStream.readBoolean(); - general.opsBypassRestrictions = dataStream.readBoolean(); - general.thermalEvaporationSpeed = dataStream.readDouble(); - general.maxJetpackGas = dataStream.readInt(); - general.maxScubaGas = dataStream.readInt(); - general.maxFlamethrowerGas = dataStream.readInt(); - general.maxPumpRange = dataStream.readInt(); - general.pumpWaterSources = dataStream.readBoolean(); - general.maxPlenisherNodes = dataStream.readInt(); - general.evaporationHeatDissipation = dataStream.readDouble(); - general.evaporationTempMultiplier = dataStream.readDouble(); - general.evaporationSolarMultiplier = dataStream.readDouble(); - general.evaporationMaxTemp = dataStream.readDouble(); - general.energyPerHeat = dataStream.readDouble(); - general.maxEnergyPerSteam = dataStream.readDouble(); - general.superheatingHeatTransfer = dataStream.readDouble(); - general.heatPerFuelTick = dataStream.readDouble(); - general.allowTransmitterAlloyUpgrade = dataStream.readBoolean(); - general.allowProtection = dataStream.readBoolean(); - general.EnableQuartzCompat = dataStream.readBoolean(); - general.EnableDiamondCompat = dataStream.readBoolean(); - general.EnablePoorOresCompat = dataStream.readBoolean(); - general.OreDictOsmium = dataStream.readBoolean(); - general.OreDictPlatinum = dataStream.readBoolean(); - - for(MachineType type : MachineType.getValidMachines()) - { - machines.setEntry(type.name, dataStream.readBoolean()); - } - - usage.enrichmentChamberUsage = dataStream.readDouble(); - usage.osmiumCompressorUsage = dataStream.readDouble(); - usage.combinerUsage = dataStream.readDouble(); - usage.crusherUsage = dataStream.readDouble(); - usage.factoryUsage = dataStream.readDouble(); - usage.metallurgicInfuserUsage = dataStream.readDouble(); - usage.purificationChamberUsage = dataStream.readDouble(); - usage.energizedSmelterUsage = dataStream.readDouble(); - usage.digitalMinerUsage = dataStream.readDouble(); - usage.electricPumpUsage = dataStream.readDouble(); - usage.rotaryCondensentratorUsage = dataStream.readDouble(); - usage.oxidationChamberUsage = dataStream.readDouble(); - usage.chemicalInfuserUsage = dataStream.readDouble(); - usage.chemicalInjectionChamberUsage = dataStream.readDouble(); - usage.precisionSawmillUsage = dataStream.readDouble(); - usage.chemicalDissolutionChamberUsage = dataStream.readDouble(); - usage.chemicalWasherUsage = dataStream.readDouble(); - usage.chemicalCrystallizerUsage = dataStream.readDouble(); - usage.seismicVibratorUsage = dataStream.readDouble(); - usage.fluidicPlenisherUsage = dataStream.readDouble(); - usage.gasCentrifugeUsage = dataStream.readDouble(); - usage.heavyWaterElectrolysisUsage = dataStream.readDouble(); - usage.formulaicAssemblicatorUsage = dataStream.readDouble(); - - Tier.readConfig(dataStream); - - try { - for(IModule module : Mekanism.modulesLoaded) - { - module.readConfig(dataStream); - } - } catch(Exception e) { - e.printStackTrace(); - } - - Mekanism.proxy.onConfigSync(true); - } - } +public class PacketConfigSync implements IMessageHandler { + @Override + public IMessage onMessage(ConfigSyncMessage message, MessageContext context) { + return null; + } + + public static class ConfigSyncMessage implements IMessage { + public ConfigSyncMessage() {} + + @Override + public void toBytes(ByteBuf dataStream) { + dataStream.writeBoolean(general.controlCircuitOreDict); + dataStream.writeBoolean(general.logPackets); + dataStream.writeBoolean(general.dynamicTankEasterEgg); + dataStream.writeBoolean(general.voiceServerEnabled); + dataStream.writeBoolean(general.cardboardSpawners); + dataStream.writeBoolean(general.spawnBabySkeletons); + dataStream.writeInt(general.obsidianTNTDelay); + dataStream.writeInt(general.obsidianTNTBlastRadius); + dataStream.writeInt(general.UPDATE_DELAY); + dataStream.writeDouble(general.FROM_IC2); + dataStream.writeDouble(general.TO_IC2); + dataStream.writeDouble(general.FROM_TE); + dataStream.writeDouble(general.TO_TE); + dataStream.writeDouble(general.FROM_H2); + dataStream.writeInt(general.ETHENE_BURN_TIME); + dataStream.writeInt(general.METHANE_BURN_TIME); + dataStream.writeDouble(general.ENERGY_PER_REDSTONE); + dataStream.writeDouble(general.DISASSEMBLER_USAGE); + dataStream.writeInt(general.VOICE_PORT); + dataStream.writeInt(general.maxUpgradeMultiplier); + dataStream.writeInt(general.energyUnit.ordinal()); + dataStream.writeDouble(general.minerSilkMultiplier); + dataStream.writeBoolean(general.blacklistIC2); + dataStream.writeBoolean(general.blacklistRF); + dataStream.writeDouble(general.armoredJetpackDamageRatio); + dataStream.writeInt(general.armoredJetpackDamageMax); + dataStream.writeBoolean(general.aestheticWorldDamage); + dataStream.writeBoolean(general.opsBypassRestrictions); + dataStream.writeDouble(general.thermalEvaporationSpeed); + dataStream.writeInt(general.maxJetpackGas); + dataStream.writeInt(general.maxScubaGas); + dataStream.writeInt(general.maxFlamethrowerGas); + dataStream.writeInt(general.maxPumpRange); + dataStream.writeBoolean(general.pumpWaterSources); + dataStream.writeInt(general.maxPlenisherNodes); + dataStream.writeDouble(general.evaporationHeatDissipation); + dataStream.writeDouble(general.evaporationTempMultiplier); + dataStream.writeDouble(general.evaporationSolarMultiplier); + dataStream.writeDouble(general.evaporationMaxTemp); + dataStream.writeDouble(general.energyPerHeat); + dataStream.writeDouble(general.maxEnergyPerSteam); + dataStream.writeDouble(general.superheatingHeatTransfer); + dataStream.writeDouble(general.heatPerFuelTick); + dataStream.writeBoolean(general.allowTransmitterAlloyUpgrade); + dataStream.writeBoolean(general.allowProtection); + dataStream.writeBoolean(general.EnableQuartzCompat); + dataStream.writeBoolean(general.EnableDiamondCompat); + dataStream.writeBoolean(general.EnablePoorOresCompat); + dataStream.writeBoolean(general.OreDictOsmium); + dataStream.writeBoolean(general.OreDictPlatinum); + + for (MachineType type : MachineType.getValidMachines()) { + dataStream.writeBoolean(machines.isEnabled(type.name)); + } + + dataStream.writeDouble(usage.enrichmentChamberUsage); + dataStream.writeDouble(usage.osmiumCompressorUsage); + dataStream.writeDouble(usage.combinerUsage); + dataStream.writeDouble(usage.crusherUsage); + dataStream.writeDouble(usage.factoryUsage); + dataStream.writeDouble(usage.metallurgicInfuserUsage); + dataStream.writeDouble(usage.purificationChamberUsage); + dataStream.writeDouble(usage.energizedSmelterUsage); + dataStream.writeDouble(usage.digitalMinerUsage); + dataStream.writeDouble(usage.electricPumpUsage); + dataStream.writeDouble(usage.rotaryCondensentratorUsage); + dataStream.writeDouble(usage.oxidationChamberUsage); + dataStream.writeDouble(usage.chemicalInfuserUsage); + dataStream.writeDouble(usage.chemicalInjectionChamberUsage); + dataStream.writeDouble(usage.precisionSawmillUsage); + dataStream.writeDouble(usage.chemicalDissolutionChamberUsage); + dataStream.writeDouble(usage.chemicalWasherUsage); + dataStream.writeDouble(usage.chemicalCrystallizerUsage); + dataStream.writeDouble(usage.seismicVibratorUsage); + dataStream.writeDouble(usage.fluidicPlenisherUsage); + dataStream.writeDouble(usage.gasCentrifugeUsage); + dataStream.writeDouble(usage.heavyWaterElectrolysisUsage); + dataStream.writeDouble(usage.formulaicAssemblicatorUsage); + + Tier.writeConfig(dataStream); + + try { + for (IModule module : Mekanism.modulesLoaded) { + module.writeConfig(dataStream); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public void fromBytes(ByteBuf dataStream) { + general.controlCircuitOreDict = dataStream.readBoolean(); + general.logPackets = dataStream.readBoolean(); + general.dynamicTankEasterEgg = dataStream.readBoolean(); + general.voiceServerEnabled = dataStream.readBoolean(); + general.cardboardSpawners = dataStream.readBoolean(); + general.spawnBabySkeletons = dataStream.readBoolean(); + general.obsidianTNTDelay = dataStream.readInt(); + general.obsidianTNTBlastRadius = dataStream.readInt(); + general.UPDATE_DELAY = dataStream.readInt(); + general.FROM_IC2 = dataStream.readDouble(); + general.TO_IC2 = dataStream.readDouble(); + general.FROM_TE = dataStream.readDouble(); + general.TO_TE = dataStream.readDouble(); + general.FROM_H2 = dataStream.readDouble(); + general.ETHENE_BURN_TIME = dataStream.readInt(); + general.METHANE_BURN_TIME = dataStream.readInt(); + general.ENERGY_PER_REDSTONE = dataStream.readDouble(); + general.DISASSEMBLER_USAGE = dataStream.readDouble(); + general.VOICE_PORT = dataStream.readInt(); + general.maxUpgradeMultiplier = dataStream.readInt(); + general.energyUnit = EnergyType.values()[dataStream.readInt()]; + general.minerSilkMultiplier = dataStream.readDouble(); + general.blacklistIC2 = dataStream.readBoolean(); + general.blacklistRF = dataStream.readBoolean(); + general.armoredJetpackDamageRatio = dataStream.readDouble(); + general.armoredJetpackDamageMax = dataStream.readInt(); + general.aestheticWorldDamage = dataStream.readBoolean(); + general.opsBypassRestrictions = dataStream.readBoolean(); + general.thermalEvaporationSpeed = dataStream.readDouble(); + general.maxJetpackGas = dataStream.readInt(); + general.maxScubaGas = dataStream.readInt(); + general.maxFlamethrowerGas = dataStream.readInt(); + general.maxPumpRange = dataStream.readInt(); + general.pumpWaterSources = dataStream.readBoolean(); + general.maxPlenisherNodes = dataStream.readInt(); + general.evaporationHeatDissipation = dataStream.readDouble(); + general.evaporationTempMultiplier = dataStream.readDouble(); + general.evaporationSolarMultiplier = dataStream.readDouble(); + general.evaporationMaxTemp = dataStream.readDouble(); + general.energyPerHeat = dataStream.readDouble(); + general.maxEnergyPerSteam = dataStream.readDouble(); + general.superheatingHeatTransfer = dataStream.readDouble(); + general.heatPerFuelTick = dataStream.readDouble(); + general.allowTransmitterAlloyUpgrade = dataStream.readBoolean(); + general.allowProtection = dataStream.readBoolean(); + general.EnableQuartzCompat = dataStream.readBoolean(); + general.EnableDiamondCompat = dataStream.readBoolean(); + general.EnablePoorOresCompat = dataStream.readBoolean(); + general.OreDictOsmium = dataStream.readBoolean(); + general.OreDictPlatinum = dataStream.readBoolean(); + + for (MachineType type : MachineType.getValidMachines()) { + machines.setEntry(type.name, dataStream.readBoolean()); + } + + usage.enrichmentChamberUsage = dataStream.readDouble(); + usage.osmiumCompressorUsage = dataStream.readDouble(); + usage.combinerUsage = dataStream.readDouble(); + usage.crusherUsage = dataStream.readDouble(); + usage.factoryUsage = dataStream.readDouble(); + usage.metallurgicInfuserUsage = dataStream.readDouble(); + usage.purificationChamberUsage = dataStream.readDouble(); + usage.energizedSmelterUsage = dataStream.readDouble(); + usage.digitalMinerUsage = dataStream.readDouble(); + usage.electricPumpUsage = dataStream.readDouble(); + usage.rotaryCondensentratorUsage = dataStream.readDouble(); + usage.oxidationChamberUsage = dataStream.readDouble(); + usage.chemicalInfuserUsage = dataStream.readDouble(); + usage.chemicalInjectionChamberUsage = dataStream.readDouble(); + usage.precisionSawmillUsage = dataStream.readDouble(); + usage.chemicalDissolutionChamberUsage = dataStream.readDouble(); + usage.chemicalWasherUsage = dataStream.readDouble(); + usage.chemicalCrystallizerUsage = dataStream.readDouble(); + usage.seismicVibratorUsage = dataStream.readDouble(); + usage.fluidicPlenisherUsage = dataStream.readDouble(); + usage.gasCentrifugeUsage = dataStream.readDouble(); + usage.heavyWaterElectrolysisUsage = dataStream.readDouble(); + usage.formulaicAssemblicatorUsage = dataStream.readDouble(); + + Tier.readConfig(dataStream); + + try { + for (IModule module : Mekanism.modulesLoaded) { + module.readConfig(dataStream); + } + } catch (Exception e) { + e.printStackTrace(); + } + + Mekanism.proxy.onConfigSync(true); + } + } } diff --git a/src/main/java/mekanism/common/network/PacketConfigurationUpdate.java b/src/main/java/mekanism/common/network/PacketConfigurationUpdate.java index 04c0827d4..b884bf411 100644 --- a/src/main/java/mekanism/common/network/PacketConfigurationUpdate.java +++ b/src/main/java/mekanism/common/network/PacketConfigurationUpdate.java @@ -1,9 +1,11 @@ package mekanism.common.network; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.Range4D; import mekanism.api.transmitters.TransmissionType; @@ -20,199 +22,205 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -public class PacketConfigurationUpdate implements IMessageHandler -{ - @Override - public IMessage onMessage(ConfigurationUpdateMessage message, MessageContext context) - { - TileEntity tile = message.coord4D.getTileEntity(PacketHandler.getPlayer(context).worldObj); - - if(tile instanceof ISideConfiguration) - { - ISideConfiguration config = (ISideConfiguration)tile; +public class PacketConfigurationUpdate + implements IMessageHandler { + @Override + public IMessage + onMessage(ConfigurationUpdateMessage message, MessageContext context) { + TileEntity tile + = message.coord4D.getTileEntity(PacketHandler.getPlayer(context).worldObj); - if(message.packetType == ConfigurationPacket.EJECT) - { - config.getConfig().setEjecting(message.transmission, !config.getConfig().isEjecting(message.transmission)); - } - else if(message.packetType == ConfigurationPacket.SIDE_DATA) - { - if(message.clickType == 0) - { - MekanismUtils.incrementOutput((ISideConfiguration)tile, message.transmission, message.configIndex); - } - else if(message.clickType == 1) - { - MekanismUtils.decrementOutput((ISideConfiguration)tile, message.transmission, message.configIndex); - } - else if(message.clickType == 2) - { - ((ISideConfiguration)tile).getConfig().getConfig(message.transmission)[message.configIndex] = 0; - } + if (tile instanceof ISideConfiguration) { + ISideConfiguration config = (ISideConfiguration) tile; - tile.markDirty(); - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(message.coord4D, ((ITileNetwork)tile).getNetworkedData(new ArrayList())), new Range4D(message.coord4D)); - } - else if(message.packetType == ConfigurationPacket.EJECT_COLOR) - { - if(message.clickType == 0) - { - config.getEjector().setOutputColor(TransporterUtils.increment(config.getEjector().getOutputColor())); - } - else if(message.clickType == 1) - { - config.getEjector().setOutputColor(TransporterUtils.decrement(config.getEjector().getOutputColor())); - } - else if(message.clickType == 2) - { - config.getEjector().setOutputColor(null); - } - } - else if(message.packetType == ConfigurationPacket.INPUT_COLOR) - { - ForgeDirection side = ForgeDirection.getOrientation(message.inputSide); + if (message.packetType == ConfigurationPacket.EJECT) { + config.getConfig().setEjecting( + message.transmission, + !config.getConfig().isEjecting(message.transmission) + ); + } else if (message.packetType == ConfigurationPacket.SIDE_DATA) { + if (message.clickType == 0) { + MekanismUtils.incrementOutput( + (ISideConfiguration) tile, + message.transmission, + message.configIndex + ); + } else if (message.clickType == 1) { + MekanismUtils.decrementOutput( + (ISideConfiguration) tile, + message.transmission, + message.configIndex + ); + } else if (message.clickType == 2) { + ((ISideConfiguration) tile) + .getConfig() + .getConfig(message.transmission)[message.configIndex] + = 0; + } - if(message.clickType == 0) - { - config.getEjector().setInputColor(side, TransporterUtils.increment(config.getEjector().getInputColor(side))); - } - else if(message.clickType == 1) - { - config.getEjector().setInputColor(side, TransporterUtils.decrement(config.getEjector().getInputColor(side))); - } - else if(message.clickType == 2) - { - config.getEjector().setInputColor(side, null); - } - } - else if(message.packetType == ConfigurationPacket.STRICT_INPUT) - { - config.getEjector().setStrictInput(!config.getEjector().hasStrictInput()); - } + tile.markDirty(); + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + message.coord4D, + ((ITileNetwork) tile).getNetworkedData(new ArrayList()) + ), + new Range4D(message.coord4D) + ); + } else if (message.packetType == ConfigurationPacket.EJECT_COLOR) { + if (message.clickType == 0) { + config.getEjector().setOutputColor( + TransporterUtils.increment(config.getEjector().getOutputColor()) + ); + } else if (message.clickType == 1) { + config.getEjector().setOutputColor( + TransporterUtils.decrement(config.getEjector().getOutputColor()) + ); + } else if (message.clickType == 2) { + config.getEjector().setOutputColor(null); + } + } else if (message.packetType == ConfigurationPacket.INPUT_COLOR) { + ForgeDirection side = ForgeDirection.getOrientation(message.inputSide); - for(EntityPlayer p : ((TileEntityBasicBlock)config).playersUsing) - { - Mekanism.packetHandler.sendTo(new TileEntityMessage(message.coord4D, ((ITileNetwork)tile).getNetworkedData(new ArrayList())), (EntityPlayerMP)p); - } - } - - return null; - } - - public static class ConfigurationUpdateMessage implements IMessage - { - public Coord4D coord4D; - - public int configIndex; - - public int inputSide; - - public TransmissionType transmission; - - public int clickType; - - public ConfigurationPacket packetType; - - public ConfigurationUpdateMessage() {} - - public ConfigurationUpdateMessage(ConfigurationPacket type, Coord4D coord, int click, int extra, TransmissionType trans) - { - packetType = type; - - coord4D = coord; - - if(packetType == ConfigurationPacket.EJECT) - { - transmission = trans; - } - - if(packetType == ConfigurationPacket.EJECT_COLOR) - { - clickType = click; - } - - if(packetType == ConfigurationPacket.SIDE_DATA) - { - clickType = click; - configIndex = extra; - transmission = trans; - } - - if(packetType == ConfigurationPacket.INPUT_COLOR) - { - clickType = click; - inputSide = extra; - } - } - - @Override - public void toBytes(ByteBuf dataStream) - { - dataStream.writeInt(packetType.ordinal()); - - dataStream.writeInt(coord4D.xCoord); - dataStream.writeInt(coord4D.yCoord); - dataStream.writeInt(coord4D.zCoord); - - dataStream.writeInt(coord4D.dimensionId); - - if(packetType != ConfigurationPacket.EJECT && packetType != ConfigurationPacket.STRICT_INPUT) - { - dataStream.writeInt(clickType); - } - - if(packetType == ConfigurationPacket.EJECT) - { - dataStream.writeInt(transmission.ordinal()); - } - - if(packetType == ConfigurationPacket.SIDE_DATA) - { - dataStream.writeInt(configIndex); - dataStream.writeInt(transmission.ordinal()); - } - - if(packetType == ConfigurationPacket.INPUT_COLOR) - { - dataStream.writeInt(inputSide); - } - } - - @Override - public void fromBytes(ByteBuf dataStream) - { - packetType = ConfigurationPacket.values()[dataStream.readInt()]; - - coord4D = new Coord4D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt(), dataStream.readInt()); - - if(packetType == ConfigurationPacket.EJECT) - { - transmission = TransmissionType.values()[dataStream.readInt()]; - } - else if(packetType == ConfigurationPacket.SIDE_DATA) - { - clickType = dataStream.readInt(); - configIndex = dataStream.readInt(); - transmission = TransmissionType.values()[dataStream.readInt()]; - } - else if(packetType == ConfigurationPacket.EJECT_COLOR) - { - clickType = dataStream.readInt(); - } - else if(packetType == ConfigurationPacket.INPUT_COLOR) - { - clickType = dataStream.readInt(); - inputSide = dataStream.readInt(); - } - } - } - - public static enum ConfigurationPacket - { - EJECT, SIDE_DATA, EJECT_COLOR, INPUT_COLOR, STRICT_INPUT - } + if (message.clickType == 0) { + config.getEjector().setInputColor( + side, + TransporterUtils.increment(config.getEjector().getInputColor(side) + ) + ); + } else if (message.clickType == 1) { + config.getEjector().setInputColor( + side, + TransporterUtils.decrement(config.getEjector().getInputColor(side) + ) + ); + } else if (message.clickType == 2) { + config.getEjector().setInputColor(side, null); + } + } else if (message.packetType == ConfigurationPacket.STRICT_INPUT) { + config.getEjector().setStrictInput(!config.getEjector().hasStrictInput()); + } + + for (EntityPlayer p : ((TileEntityBasicBlock) config).playersUsing) { + Mekanism.packetHandler.sendTo( + new TileEntityMessage( + message.coord4D, + ((ITileNetwork) tile).getNetworkedData(new ArrayList()) + ), + (EntityPlayerMP) p + ); + } + } + + return null; + } + + public static class ConfigurationUpdateMessage implements IMessage { + public Coord4D coord4D; + + public int configIndex; + + public int inputSide; + + public TransmissionType transmission; + + public int clickType; + + public ConfigurationPacket packetType; + + public ConfigurationUpdateMessage() {} + + public ConfigurationUpdateMessage( + ConfigurationPacket type, + Coord4D coord, + int click, + int extra, + TransmissionType trans + ) { + packetType = type; + + coord4D = coord; + + if (packetType == ConfigurationPacket.EJECT) { + transmission = trans; + } + + if (packetType == ConfigurationPacket.EJECT_COLOR) { + clickType = click; + } + + if (packetType == ConfigurationPacket.SIDE_DATA) { + clickType = click; + configIndex = extra; + transmission = trans; + } + + if (packetType == ConfigurationPacket.INPUT_COLOR) { + clickType = click; + inputSide = extra; + } + } + + @Override + public void toBytes(ByteBuf dataStream) { + dataStream.writeInt(packetType.ordinal()); + + dataStream.writeInt(coord4D.xCoord); + dataStream.writeInt(coord4D.yCoord); + dataStream.writeInt(coord4D.zCoord); + + dataStream.writeInt(coord4D.dimensionId); + + if (packetType != ConfigurationPacket.EJECT + && packetType != ConfigurationPacket.STRICT_INPUT) { + dataStream.writeInt(clickType); + } + + if (packetType == ConfigurationPacket.EJECT) { + dataStream.writeInt(transmission.ordinal()); + } + + if (packetType == ConfigurationPacket.SIDE_DATA) { + dataStream.writeInt(configIndex); + dataStream.writeInt(transmission.ordinal()); + } + + if (packetType == ConfigurationPacket.INPUT_COLOR) { + dataStream.writeInt(inputSide); + } + } + + @Override + public void fromBytes(ByteBuf dataStream) { + packetType = ConfigurationPacket.values()[dataStream.readInt()]; + + coord4D = new Coord4D( + dataStream.readInt(), + dataStream.readInt(), + dataStream.readInt(), + dataStream.readInt() + ); + + if (packetType == ConfigurationPacket.EJECT) { + transmission = TransmissionType.values()[dataStream.readInt()]; + } else if (packetType == ConfigurationPacket.SIDE_DATA) { + clickType = dataStream.readInt(); + configIndex = dataStream.readInt(); + transmission = TransmissionType.values()[dataStream.readInt()]; + } else if (packetType == ConfigurationPacket.EJECT_COLOR) { + clickType = dataStream.readInt(); + } else if (packetType == ConfigurationPacket.INPUT_COLOR) { + clickType = dataStream.readInt(); + inputSide = dataStream.readInt(); + } + } + } + + public static enum ConfigurationPacket { + EJECT, + SIDE_DATA, + EJECT_COLOR, + INPUT_COLOR, + STRICT_INPUT + } } diff --git a/src/main/java/mekanism/common/network/PacketConfiguratorState.java b/src/main/java/mekanism/common/network/PacketConfiguratorState.java index 6f0bacd7f..efc6becf8 100644 --- a/src/main/java/mekanism/common/network/PacketConfiguratorState.java +++ b/src/main/java/mekanism/common/network/PacketConfiguratorState.java @@ -1,51 +1,45 @@ package mekanism.common.network; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; import mekanism.common.PacketHandler; import mekanism.common.item.ItemConfigurator; import mekanism.common.item.ItemConfigurator.ConfiguratorMode; import mekanism.common.network.PacketConfiguratorState.ConfiguratorStateMessage; import net.minecraft.item.ItemStack; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -public class PacketConfiguratorState implements IMessageHandler -{ - @Override - public IMessage onMessage(ConfiguratorStateMessage message, MessageContext context) - { - ItemStack itemstack = PacketHandler.getPlayer(context).getCurrentEquippedItem(); - - if(itemstack != null && itemstack.getItem() instanceof ItemConfigurator) - { - ((ItemConfigurator)itemstack.getItem()).setState(itemstack, message.state); - } - - return null; - } - - public static class ConfiguratorStateMessage implements IMessage - { - public ConfiguratorMode state; - - public ConfiguratorStateMessage() {} - - public ConfiguratorStateMessage(ConfiguratorMode s) - { - state = s; - } - - @Override - public void toBytes(ByteBuf dataStream) - { - dataStream.writeInt(state.ordinal()); - } - - @Override - public void fromBytes(ByteBuf dataStream) - { - state = ConfiguratorMode.values()[dataStream.readInt()]; - } - } +public class PacketConfiguratorState + implements IMessageHandler { + @Override + public IMessage onMessage(ConfiguratorStateMessage message, MessageContext context) { + ItemStack itemstack = PacketHandler.getPlayer(context).getCurrentEquippedItem(); + + if (itemstack != null && itemstack.getItem() instanceof ItemConfigurator) { + ((ItemConfigurator) itemstack.getItem()).setState(itemstack, message.state); + } + + return null; + } + + public static class ConfiguratorStateMessage implements IMessage { + public ConfiguratorMode state; + + public ConfiguratorStateMessage() {} + + public ConfiguratorStateMessage(ConfiguratorMode s) { + state = s; + } + + @Override + public void toBytes(ByteBuf dataStream) { + dataStream.writeInt(state.ordinal()); + } + + @Override + public void fromBytes(ByteBuf dataStream) { + state = ConfiguratorMode.values()[dataStream.readInt()]; + } + } } diff --git a/src/main/java/mekanism/common/network/PacketContainerEditMode.java b/src/main/java/mekanism/common/network/PacketContainerEditMode.java index 5e72dfed1..11ffec929 100644 --- a/src/main/java/mekanism/common/network/PacketContainerEditMode.java +++ b/src/main/java/mekanism/common/network/PacketContainerEditMode.java @@ -1,5 +1,8 @@ package mekanism.common.network; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.common.PacketHandler; @@ -8,55 +11,46 @@ import mekanism.common.network.PacketContainerEditMode.ContainerEditModeMessage; import mekanism.common.util.FluidContainerUtils.ContainerEditMode; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -public class PacketContainerEditMode implements IMessageHandler -{ - @Override - public IMessage onMessage(ContainerEditModeMessage message, MessageContext context) - { - EntityPlayer player = PacketHandler.getPlayer(context); - TileEntity tileEntity = message.coord4D.getTileEntity(player.worldObj); - - if(tileEntity instanceof IFluidContainerManager) - { - ((IFluidContainerManager)tileEntity).setContainerEditMode(message.value); - } - - return null; - } - - public static class ContainerEditModeMessage implements IMessage - { - public Coord4D coord4D; - public ContainerEditMode value; - - public ContainerEditModeMessage() {} - - public ContainerEditModeMessage(Coord4D coord, ContainerEditMode mode) - { - coord4D = coord; - value = mode; - } - - @Override - public void toBytes(ByteBuf dataStream) - { - dataStream.writeInt(coord4D.xCoord); - dataStream.writeInt(coord4D.yCoord); - dataStream.writeInt(coord4D.zCoord); - dataStream.writeInt(coord4D.dimensionId); - - dataStream.writeInt(value.ordinal()); - } - - @Override - public void fromBytes(ByteBuf dataStream) - { - coord4D = Coord4D.read(dataStream); - value = ContainerEditMode.values()[dataStream.readInt()]; - } - } +public class PacketContainerEditMode + implements IMessageHandler { + @Override + public IMessage onMessage(ContainerEditModeMessage message, MessageContext context) { + EntityPlayer player = PacketHandler.getPlayer(context); + TileEntity tileEntity = message.coord4D.getTileEntity(player.worldObj); + + if (tileEntity instanceof IFluidContainerManager) { + ((IFluidContainerManager) tileEntity).setContainerEditMode(message.value); + } + + return null; + } + + public static class ContainerEditModeMessage implements IMessage { + public Coord4D coord4D; + public ContainerEditMode value; + + public ContainerEditModeMessage() {} + + public ContainerEditModeMessage(Coord4D coord, ContainerEditMode mode) { + coord4D = coord; + value = mode; + } + + @Override + public void toBytes(ByteBuf dataStream) { + dataStream.writeInt(coord4D.xCoord); + dataStream.writeInt(coord4D.yCoord); + dataStream.writeInt(coord4D.zCoord); + dataStream.writeInt(coord4D.dimensionId); + + dataStream.writeInt(value.ordinal()); + } + + @Override + public void fromBytes(ByteBuf dataStream) { + coord4D = Coord4D.read(dataStream); + value = ContainerEditMode.values()[dataStream.readInt()]; + } + } } diff --git a/src/main/java/mekanism/common/network/PacketDataRequest.java b/src/main/java/mekanism/common/network/PacketDataRequest.java index 56ccffd28..50e8a9aa8 100644 --- a/src/main/java/mekanism/common/network/PacketDataRequest.java +++ b/src/main/java/mekanism/common/network/PacketDataRequest.java @@ -1,9 +1,12 @@ package mekanism.common.network; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.transmitters.IGridTransmitter; import mekanism.api.transmitters.ITransmitterTile; @@ -17,69 +20,70 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -public class PacketDataRequest implements IMessageHandler -{ - @Override - public IMessage onMessage(DataRequestMessage message, MessageContext context) - { - EntityPlayer player = PacketHandler.getPlayer(context); - World worldServer = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(message.coord4D.dimensionId); - - if(worldServer != null && message.coord4D.getTileEntity(worldServer) instanceof ITileNetwork) - { - TileEntity tileEntity = message.coord4D.getTileEntity(worldServer); +public class PacketDataRequest implements IMessageHandler { + @Override + public IMessage onMessage(DataRequestMessage message, MessageContext context) { + EntityPlayer player = PacketHandler.getPlayer(context); + World worldServer = FMLCommonHandler.instance() + .getMinecraftServerInstance() + .worldServerForDimension(message.coord4D.dimensionId); - if(tileEntity instanceof TileEntityMultiblock) - { - ((TileEntityMultiblock)tileEntity).sendStructure = true; - } + if (worldServer != null + && message.coord4D.getTileEntity(worldServer) instanceof ITileNetwork) { + TileEntity tileEntity = message.coord4D.getTileEntity(worldServer); - if(tileEntity instanceof ITransmitterTile) - { - IGridTransmitter transmitter = ((ITransmitterTile)tileEntity).getTransmitter(); + if (tileEntity instanceof TileEntityMultiblock) { + ((TileEntityMultiblock) tileEntity).sendStructure = true; + } - if(transmitter.hasTransmitterNetwork()) - { - transmitter.getTransmitterNetwork().addUpdate(player); - } - } + if (tileEntity instanceof ITransmitterTile) { + IGridTransmitter transmitter + = ((ITransmitterTile) tileEntity).getTransmitter(); - Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(tileEntity), ((ITileNetwork)tileEntity).getNetworkedData(new ArrayList())), (EntityPlayerMP)player); - } - - return null; - } - - public static class DataRequestMessage implements IMessage - { - public Coord4D coord4D; - - public DataRequestMessage() {} - - public DataRequestMessage(Coord4D coord) - { - coord4D = coord; - } - - @Override - public void toBytes(ByteBuf dataStream) - { - dataStream.writeInt(coord4D.xCoord); - dataStream.writeInt(coord4D.yCoord); - dataStream.writeInt(coord4D.zCoord); - - dataStream.writeInt(coord4D.dimensionId); - } - - @Override - public void fromBytes(ByteBuf dataStream) - { - coord4D = new Coord4D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt(), dataStream.readInt()); - } - } + if (transmitter.hasTransmitterNetwork()) { + transmitter.getTransmitterNetwork().addUpdate(player); + } + } + + Mekanism.packetHandler.sendTo( + new TileEntityMessage( + Coord4D.get(tileEntity), + ((ITileNetwork) tileEntity).getNetworkedData(new ArrayList()) + ), + (EntityPlayerMP) player + ); + } + + return null; + } + + public static class DataRequestMessage implements IMessage { + public Coord4D coord4D; + + public DataRequestMessage() {} + + public DataRequestMessage(Coord4D coord) { + coord4D = coord; + } + + @Override + public void toBytes(ByteBuf dataStream) { + dataStream.writeInt(coord4D.xCoord); + dataStream.writeInt(coord4D.yCoord); + dataStream.writeInt(coord4D.zCoord); + + dataStream.writeInt(coord4D.dimensionId); + } + + @Override + public void fromBytes(ByteBuf dataStream) { + coord4D = new Coord4D( + dataStream.readInt(), + dataStream.readInt(), + dataStream.readInt(), + dataStream.readInt() + ); + } + } } diff --git a/src/main/java/mekanism/common/network/PacketDigitalMinerGui.java b/src/main/java/mekanism/common/network/PacketDigitalMinerGui.java index e92801c02..5bc5ba854 100644 --- a/src/main/java/mekanism/common/network/PacketDigitalMinerGui.java +++ b/src/main/java/mekanism/common/network/PacketDigitalMinerGui.java @@ -1,9 +1,14 @@ package mekanism.common.network; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.client.gui.GuiDigitalMiner; import mekanism.client.gui.GuiDigitalMinerConfig; @@ -26,244 +31,292 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.inventory.Container; import net.minecraft.world.World; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class PacketDigitalMinerGui implements IMessageHandler -{ - @Override - public IMessage onMessage(DigitalMinerGuiMessage message, MessageContext context) - { - EntityPlayer player = PacketHandler.getPlayer(context); - - if(!player.worldObj.isRemote) - { - World worldServer = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(message.coord4D.dimensionId); +public class PacketDigitalMinerGui + implements IMessageHandler { + @Override + public IMessage onMessage(DigitalMinerGuiMessage message, MessageContext context) { + EntityPlayer player = PacketHandler.getPlayer(context); - if(worldServer != null && message.coord4D.getTileEntity(worldServer) instanceof TileEntityDigitalMiner) - { - DigitalMinerGuiMessage.openServerGui(message.packetType, message.guiType, worldServer, (EntityPlayerMP)player, message.coord4D, message.index); - } - } - else { - if(message.coord4D.getTileEntity(player.worldObj) instanceof TileEntityDigitalMiner) - { - try { - if(message.packetType == MinerGuiPacket.CLIENT) - { - FMLCommonHandler.instance().showGuiScreen(DigitalMinerGuiMessage.getGui(message.packetType, message.guiType, player, player.worldObj, message.coord4D.xCoord, message.coord4D.yCoord, message.coord4D.zCoord, -1)); - } - else if(message.packetType == MinerGuiPacket.CLIENT_INDEX) - { - FMLCommonHandler.instance().showGuiScreen(DigitalMinerGuiMessage.getGui(message.packetType, message.guiType, player, player.worldObj, message.coord4D.xCoord, message.coord4D.yCoord, message.coord4D.zCoord, message.index)); - } + if (!player.worldObj.isRemote) { + World worldServer = FMLCommonHandler.instance() + .getMinecraftServerInstance() + .worldServerForDimension(message.coord4D.dimensionId); - player.openContainer.windowId = message.windowId; - } catch(Exception e) { - e.printStackTrace(); - } - } - } - - return null; - } - - public static class DigitalMinerGuiMessage implements IMessage - { - public Coord4D coord4D; - - public MinerGuiPacket packetType; - - public int guiType; - - public int windowId = -1; - - public int index = -1; - - public DigitalMinerGuiMessage() {} - - public DigitalMinerGuiMessage(MinerGuiPacket type, Coord4D coord, int guiID, int extra, int extra2) - { - packetType = type; - - coord4D = coord; - guiType = guiID; - - if(packetType == MinerGuiPacket.CLIENT) - { - windowId = extra; - } - else if(packetType == MinerGuiPacket.SERVER_INDEX) - { - index = extra; - } - else if(packetType == MinerGuiPacket.CLIENT_INDEX) - { - windowId = extra; - index = extra2; - } - } - - public static void openServerGui(MinerGuiPacket t, int guiType, World world, EntityPlayerMP playerMP, Coord4D obj, int i) - { - Container container = null; - - playerMP.closeContainer(); - - if(guiType == 0) - { - container = new ContainerNull(playerMP, (TileEntityContainerBlock)obj.getTileEntity(world)); - } - else if(guiType == 4) - { - container = new ContainerDigitalMiner(playerMP.inventory, (TileEntityDigitalMiner)obj.getTileEntity(world)); - } - else if(guiType == 5) - { - container = new ContainerNull(playerMP, (TileEntityContainerBlock)obj.getTileEntity(world)); - } - else if(guiType == 1 || guiType == 2 || guiType == 3 || guiType == 6) - { - container = new ContainerFilter(playerMP.inventory, (TileEntityContainerBlock)obj.getTileEntity(world)); - } - - playerMP.getNextWindowId(); - int window = playerMP.currentWindowId; - - if(t == MinerGuiPacket.SERVER) - { - Mekanism.packetHandler.sendTo(new DigitalMinerGuiMessage(MinerGuiPacket.CLIENT, obj, guiType, window, 0), playerMP); - } - else if(t == MinerGuiPacket.SERVER_INDEX) - { - Mekanism.packetHandler.sendTo(new DigitalMinerGuiMessage(MinerGuiPacket.CLIENT_INDEX, obj, guiType, window, i), playerMP); - } - - playerMP.openContainer = container; - playerMP.openContainer.windowId = window; - playerMP.openContainer.addCraftingToCrafters(playerMP); - - if(guiType == 0) - { - TileEntityDigitalMiner tile = (TileEntityDigitalMiner)obj.getTileEntity(world); - - for(EntityPlayer player : tile.playersUsing) - { - Mekanism.packetHandler.sendTo(new TileEntityMessage(obj, tile.getFilterPacket(new ArrayList())), (EntityPlayerMP)player); - } - } - } - - @SideOnly(Side.CLIENT) - public static GuiScreen getGui(MinerGuiPacket packetType, int type, EntityPlayer player, World world, int x, int y, int z, int index) - { - if(type == 0) - { - return new GuiDigitalMinerConfig(player, (TileEntityDigitalMiner)world.getTileEntity(x, y, z)); - } - else if(type == 4) - { - return new GuiDigitalMiner(player.inventory, (TileEntityDigitalMiner)world.getTileEntity(x, y, z)); - } - else if(type == 5) - { - return new GuiMFilterSelect(player, (TileEntityDigitalMiner)world.getTileEntity(x, y, z)); - } - else { - if(packetType == MinerGuiPacket.CLIENT) - { - if(type == 1) - { - return new GuiMItemStackFilter(player, (TileEntityDigitalMiner)world.getTileEntity(x, y, z)); - } - else if(type == 2) - { - return new GuiMOreDictFilter(player, (TileEntityDigitalMiner)world.getTileEntity(x, y, z)); - } - else if(type == 3) - { - return new GuiMMaterialFilter(player, (TileEntityDigitalMiner)world.getTileEntity(x, y, z)); - } - else if(type == 6) - { - return new GuiMModIDFilter(player, (TileEntityDigitalMiner)world.getTileEntity(x, y, z)); - } - } - else if(packetType == MinerGuiPacket.CLIENT_INDEX) - { - if(type == 1) - { - return new GuiMItemStackFilter(player, (TileEntityDigitalMiner)world.getTileEntity(x, y, z), index); - } - else if(type == 2) - { - return new GuiMOreDictFilter(player, (TileEntityDigitalMiner)world.getTileEntity(x, y, z), index); - } - else if(type == 3) - { - return new GuiMMaterialFilter(player, (TileEntityDigitalMiner)world.getTileEntity(x, y, z), index); - } - else if(type == 6) - { - return new GuiMModIDFilter(player, (TileEntityDigitalMiner)world.getTileEntity(x, y, z), index); - } - } - } - - return null; - } - - @Override - public void toBytes(ByteBuf dataStream) - { - dataStream.writeInt(packetType.ordinal()); - - dataStream.writeInt(coord4D.xCoord); - dataStream.writeInt(coord4D.yCoord); - dataStream.writeInt(coord4D.zCoord); - - dataStream.writeInt(coord4D.dimensionId); - - dataStream.writeInt(guiType); - - if(packetType == MinerGuiPacket.CLIENT || packetType == MinerGuiPacket.CLIENT_INDEX) - { - dataStream.writeInt(windowId); - } - - if(packetType == MinerGuiPacket.SERVER_INDEX || packetType == MinerGuiPacket.CLIENT_INDEX) - { - dataStream.writeInt(index); - } - } - - @Override - public void fromBytes(ByteBuf dataStream) - { - packetType = MinerGuiPacket.values()[dataStream.readInt()]; - - coord4D = new Coord4D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt(), dataStream.readInt()); - - guiType = dataStream.readInt(); - - if(packetType == MinerGuiPacket.CLIENT || packetType == MinerGuiPacket.CLIENT_INDEX) - { - windowId = dataStream.readInt(); - } - - if(packetType == MinerGuiPacket.SERVER_INDEX || packetType == MinerGuiPacket.CLIENT_INDEX) - { - index = dataStream.readInt(); - } - } - } - - public static enum MinerGuiPacket - { - SERVER, CLIENT, SERVER_INDEX, CLIENT_INDEX - } + if (worldServer != null + && message.coord4D.getTileEntity(worldServer) + instanceof TileEntityDigitalMiner) { + DigitalMinerGuiMessage.openServerGui( + message.packetType, + message.guiType, + worldServer, + (EntityPlayerMP) player, + message.coord4D, + message.index + ); + } + } else { + if (message.coord4D.getTileEntity(player.worldObj) + instanceof TileEntityDigitalMiner) { + try { + if (message.packetType == MinerGuiPacket.CLIENT) { + FMLCommonHandler.instance().showGuiScreen( + DigitalMinerGuiMessage.getGui( + message.packetType, + message.guiType, + player, + player.worldObj, + message.coord4D.xCoord, + message.coord4D.yCoord, + message.coord4D.zCoord, + -1 + ) + ); + } else if (message.packetType == MinerGuiPacket.CLIENT_INDEX) { + FMLCommonHandler.instance().showGuiScreen( + DigitalMinerGuiMessage.getGui( + message.packetType, + message.guiType, + player, + player.worldObj, + message.coord4D.xCoord, + message.coord4D.yCoord, + message.coord4D.zCoord, + message.index + ) + ); + } + + player.openContainer.windowId = message.windowId; + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + return null; + } + + public static class DigitalMinerGuiMessage implements IMessage { + public Coord4D coord4D; + + public MinerGuiPacket packetType; + + public int guiType; + + public int windowId = -1; + + public int index = -1; + + public DigitalMinerGuiMessage() {} + + public DigitalMinerGuiMessage( + MinerGuiPacket type, Coord4D coord, int guiID, int extra, int extra2 + ) { + packetType = type; + + coord4D = coord; + guiType = guiID; + + if (packetType == MinerGuiPacket.CLIENT) { + windowId = extra; + } else if (packetType == MinerGuiPacket.SERVER_INDEX) { + index = extra; + } else if (packetType == MinerGuiPacket.CLIENT_INDEX) { + windowId = extra; + index = extra2; + } + } + + public static void openServerGui( + MinerGuiPacket t, + int guiType, + World world, + EntityPlayerMP playerMP, + Coord4D obj, + int i + ) { + Container container = null; + + playerMP.closeContainer(); + + if (guiType == 0) { + container = new ContainerNull( + playerMP, (TileEntityContainerBlock) obj.getTileEntity(world) + ); + } else if (guiType == 4) { + container = new ContainerDigitalMiner( + playerMP.inventory, (TileEntityDigitalMiner) obj.getTileEntity(world) + ); + } else if (guiType == 5) { + container = new ContainerNull( + playerMP, (TileEntityContainerBlock) obj.getTileEntity(world) + ); + } else if (guiType == 1 || guiType == 2 || guiType == 3 || guiType == 6) { + container = new ContainerFilter( + playerMP.inventory, + (TileEntityContainerBlock) obj.getTileEntity(world) + ); + } + + playerMP.getNextWindowId(); + int window = playerMP.currentWindowId; + + if (t == MinerGuiPacket.SERVER) { + Mekanism.packetHandler.sendTo( + new DigitalMinerGuiMessage( + MinerGuiPacket.CLIENT, obj, guiType, window, 0 + ), + playerMP + ); + } else if (t == MinerGuiPacket.SERVER_INDEX) { + Mekanism.packetHandler.sendTo( + new DigitalMinerGuiMessage( + MinerGuiPacket.CLIENT_INDEX, obj, guiType, window, i + ), + playerMP + ); + } + + playerMP.openContainer = container; + playerMP.openContainer.windowId = window; + playerMP.openContainer.addCraftingToCrafters(playerMP); + + if (guiType == 0) { + TileEntityDigitalMiner tile + = (TileEntityDigitalMiner) obj.getTileEntity(world); + + for (EntityPlayer player : tile.playersUsing) { + Mekanism.packetHandler.sendTo( + new TileEntityMessage(obj, tile.getFilterPacket(new ArrayList())), + (EntityPlayerMP) player + ); + } + } + } + + @SideOnly(Side.CLIENT) + public static GuiScreen getGui( + MinerGuiPacket packetType, + int type, + EntityPlayer player, + World world, + int x, + int y, + int z, + int index + ) { + if (type == 0) { + return new GuiDigitalMinerConfig( + player, (TileEntityDigitalMiner) world.getTileEntity(x, y, z) + ); + } else if (type == 4) { + return new GuiDigitalMiner( + player.inventory, + (TileEntityDigitalMiner) world.getTileEntity(x, y, z) + ); + } else if (type == 5) { + return new GuiMFilterSelect( + player, (TileEntityDigitalMiner) world.getTileEntity(x, y, z) + ); + } else { + if (packetType == MinerGuiPacket.CLIENT) { + if (type == 1) { + return new GuiMItemStackFilter( + player, (TileEntityDigitalMiner) world.getTileEntity(x, y, z) + ); + } else if (type == 2) { + return new GuiMOreDictFilter( + player, (TileEntityDigitalMiner) world.getTileEntity(x, y, z) + ); + } else if (type == 3) { + return new GuiMMaterialFilter( + player, (TileEntityDigitalMiner) world.getTileEntity(x, y, z) + ); + } else if (type == 6) { + return new GuiMModIDFilter( + player, (TileEntityDigitalMiner) world.getTileEntity(x, y, z) + ); + } + } else if (packetType == MinerGuiPacket.CLIENT_INDEX) { + if (type == 1) { + return new GuiMItemStackFilter( + player, + (TileEntityDigitalMiner) world.getTileEntity(x, y, z), + index + ); + } else if (type == 2) { + return new GuiMOreDictFilter( + player, + (TileEntityDigitalMiner) world.getTileEntity(x, y, z), + index + ); + } else if (type == 3) { + return new GuiMMaterialFilter( + player, + (TileEntityDigitalMiner) world.getTileEntity(x, y, z), + index + ); + } else if (type == 6) { + return new GuiMModIDFilter( + player, + (TileEntityDigitalMiner) world.getTileEntity(x, y, z), + index + ); + } + } + } + + return null; + } + + @Override + public void toBytes(ByteBuf dataStream) { + dataStream.writeInt(packetType.ordinal()); + + dataStream.writeInt(coord4D.xCoord); + dataStream.writeInt(coord4D.yCoord); + dataStream.writeInt(coord4D.zCoord); + + dataStream.writeInt(coord4D.dimensionId); + + dataStream.writeInt(guiType); + + if (packetType == MinerGuiPacket.CLIENT + || packetType == MinerGuiPacket.CLIENT_INDEX) { + dataStream.writeInt(windowId); + } + + if (packetType == MinerGuiPacket.SERVER_INDEX + || packetType == MinerGuiPacket.CLIENT_INDEX) { + dataStream.writeInt(index); + } + } + + @Override + public void fromBytes(ByteBuf dataStream) { + packetType = MinerGuiPacket.values()[dataStream.readInt()]; + + coord4D = new Coord4D( + dataStream.readInt(), + dataStream.readInt(), + dataStream.readInt(), + dataStream.readInt() + ); + + guiType = dataStream.readInt(); + + if (packetType == MinerGuiPacket.CLIENT + || packetType == MinerGuiPacket.CLIENT_INDEX) { + windowId = dataStream.readInt(); + } + + if (packetType == MinerGuiPacket.SERVER_INDEX + || packetType == MinerGuiPacket.CLIENT_INDEX) { + index = dataStream.readInt(); + } + } + } + + public static enum MinerGuiPacket { SERVER, CLIENT, SERVER_INDEX, CLIENT_INDEX } } diff --git a/src/main/java/mekanism/common/network/PacketDropperUse.java b/src/main/java/mekanism/common/network/PacketDropperUse.java index 48f9d0872..7281caa80 100644 --- a/src/main/java/mekanism/common/network/PacketDropperUse.java +++ b/src/main/java/mekanism/common/network/PacketDropperUse.java @@ -1,5 +1,8 @@ package mekanism.common.network; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.common.PacketHandler; @@ -7,69 +10,66 @@ import mekanism.common.base.ITankManager; import mekanism.common.base.ITankManager.DropperHandler; import mekanism.common.network.PacketDropperUse.DropperUseMessage; import net.minecraft.tileentity.TileEntity; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -public class PacketDropperUse implements IMessageHandler -{ - @Override - public IMessage onMessage(DropperUseMessage message, MessageContext context) - { - TileEntity tileEntity = message.coord4D.getTileEntity(PacketHandler.getPlayer(context).worldObj); - - if(tileEntity instanceof ITankManager) - { - try { - Object tank = ((ITankManager)tileEntity).getTanks()[message.tankId]; - - if(tank != null) - { - DropperHandler.useDropper(PacketHandler.getPlayer(context), tank, message.mouseButton); - } - } catch(Exception e) { - e.printStackTrace(); - } - } - - return null; - } - - public static class DropperUseMessage implements IMessage - { - public Coord4D coord4D; - - public int mouseButton; - public int tankId; - - public DropperUseMessage() {} - - public DropperUseMessage(Coord4D coord, int button, int id) - { - coord4D = coord; - mouseButton = button; - tankId = id; - } - - @Override - public void toBytes(ByteBuf dataStream) - { - dataStream.writeInt(coord4D.xCoord); - dataStream.writeInt(coord4D.yCoord); - dataStream.writeInt(coord4D.zCoord); - dataStream.writeInt(coord4D.dimensionId); - - dataStream.writeInt(mouseButton); - dataStream.writeInt(tankId); - } - - @Override - public void fromBytes(ByteBuf dataStream) - { - coord4D = new Coord4D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt(), dataStream.readInt()); - - mouseButton = dataStream.readInt(); - tankId = dataStream.readInt(); - } - } +public class PacketDropperUse implements IMessageHandler { + @Override + public IMessage onMessage(DropperUseMessage message, MessageContext context) { + TileEntity tileEntity + = message.coord4D.getTileEntity(PacketHandler.getPlayer(context).worldObj); + + if (tileEntity instanceof ITankManager) { + try { + Object tank = ((ITankManager) tileEntity).getTanks()[message.tankId]; + + if (tank != null) { + DropperHandler.useDropper( + PacketHandler.getPlayer(context), tank, message.mouseButton + ); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + return null; + } + + public static class DropperUseMessage implements IMessage { + public Coord4D coord4D; + + public int mouseButton; + public int tankId; + + public DropperUseMessage() {} + + public DropperUseMessage(Coord4D coord, int button, int id) { + coord4D = coord; + mouseButton = button; + tankId = id; + } + + @Override + public void toBytes(ByteBuf dataStream) { + dataStream.writeInt(coord4D.xCoord); + dataStream.writeInt(coord4D.yCoord); + dataStream.writeInt(coord4D.zCoord); + dataStream.writeInt(coord4D.dimensionId); + + dataStream.writeInt(mouseButton); + dataStream.writeInt(tankId); + } + + @Override + public void fromBytes(ByteBuf dataStream) { + coord4D = new Coord4D( + dataStream.readInt(), + dataStream.readInt(), + dataStream.readInt(), + dataStream.readInt() + ); + + mouseButton = dataStream.readInt(); + tankId = dataStream.readInt(); + } + } } diff --git a/src/main/java/mekanism/common/network/PacketEditFilter.java b/src/main/java/mekanism/common/network/PacketEditFilter.java index 23c12a26f..12ec4399b 100644 --- a/src/main/java/mekanism/common/network/PacketEditFilter.java +++ b/src/main/java/mekanism/common/network/PacketEditFilter.java @@ -1,9 +1,12 @@ package mekanism.common.network; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.common.Mekanism; import mekanism.common.PacketHandler; @@ -18,234 +21,216 @@ import mekanism.common.tile.TileEntityOredictionificator.OredictionificatorFilte import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.world.World; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -public class PacketEditFilter implements IMessageHandler -{ - @Override - public IMessage onMessage(EditFilterMessage message, MessageContext context) - { - World worldServer = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(message.coord4D.dimensionId); - - if(worldServer != null) - { - if(message.type == 0 && message.coord4D.getTileEntity(worldServer) instanceof TileEntityLogisticalSorter) - { - TileEntityLogisticalSorter sorter = (TileEntityLogisticalSorter) message.coord4D.getTileEntity(worldServer); +public class PacketEditFilter implements IMessageHandler { + @Override + public IMessage onMessage(EditFilterMessage message, MessageContext context) { + World worldServer = FMLCommonHandler.instance() + .getMinecraftServerInstance() + .worldServerForDimension(message.coord4D.dimensionId); - if(!sorter.filters.contains(message.tFilter)) - { - return null; - } + if (worldServer != null) { + if (message.type == 0 + && message.coord4D.getTileEntity(worldServer) + instanceof TileEntityLogisticalSorter) { + TileEntityLogisticalSorter sorter = (TileEntityLogisticalSorter + ) message.coord4D.getTileEntity(worldServer); - int index = sorter.filters.indexOf(message.tFilter); + if (!sorter.filters.contains(message.tFilter)) { + return null; + } - sorter.filters.remove(index); + int index = sorter.filters.indexOf(message.tFilter); - if(!message.delete) - { - sorter.filters.add(index, message.tEdited); - } + sorter.filters.remove(index); - for(EntityPlayer iterPlayer : sorter.playersUsing) - { - Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(sorter), sorter.getFilterPacket(new ArrayList())), (EntityPlayerMP)iterPlayer); - } - } - else if(message.type == 1 && message.coord4D.getTileEntity(worldServer) instanceof TileEntityDigitalMiner) - { - TileEntityDigitalMiner miner = (TileEntityDigitalMiner)message.coord4D.getTileEntity(worldServer); + if (!message.delete) { + sorter.filters.add(index, message.tEdited); + } - if(!miner.filters.contains(message.mFilter)) - { - return null; - } + for (EntityPlayer iterPlayer : sorter.playersUsing) { + Mekanism.packetHandler.sendTo( + new TileEntityMessage( + Coord4D.get(sorter), sorter.getFilterPacket(new ArrayList()) + ), + (EntityPlayerMP) iterPlayer + ); + } + } else if (message.type == 1 && message.coord4D.getTileEntity(worldServer) instanceof TileEntityDigitalMiner) { + TileEntityDigitalMiner miner + = (TileEntityDigitalMiner) message.coord4D.getTileEntity(worldServer); - int index = miner.filters.indexOf(message.mFilter); + if (!miner.filters.contains(message.mFilter)) { + return null; + } - miner.filters.remove(index); + int index = miner.filters.indexOf(message.mFilter); - if(!message.delete) - { - miner.filters.add(index, message.mEdited); - } + miner.filters.remove(index); - for(EntityPlayer iterPlayer : miner.playersUsing) - { - Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(miner), miner.getFilterPacket(new ArrayList())), (EntityPlayerMP)iterPlayer); - } - } - else if(message.type == 2 && message.coord4D.getTileEntity(worldServer) instanceof TileEntityOredictionificator) - { - TileEntityOredictionificator oredictionificator = (TileEntityOredictionificator)message.coord4D.getTileEntity(worldServer); + if (!message.delete) { + miner.filters.add(index, message.mEdited); + } - if(!oredictionificator.filters.contains(message.oFilter)) - { - return null; - } + for (EntityPlayer iterPlayer : miner.playersUsing) { + Mekanism.packetHandler.sendTo( + new TileEntityMessage( + Coord4D.get(miner), miner.getFilterPacket(new ArrayList()) + ), + (EntityPlayerMP) iterPlayer + ); + } + } else if (message.type == 2 && message.coord4D.getTileEntity(worldServer) instanceof TileEntityOredictionificator) { + TileEntityOredictionificator oredictionificator + = (TileEntityOredictionificator + ) message.coord4D.getTileEntity(worldServer); - int index = oredictionificator.filters.indexOf(message.oFilter); + if (!oredictionificator.filters.contains(message.oFilter)) { + return null; + } - oredictionificator.filters.remove(index); + int index = oredictionificator.filters.indexOf(message.oFilter); - if(!message.delete) - { - oredictionificator.filters.add(index, message.oEdited); - } + oredictionificator.filters.remove(index); - for(EntityPlayer iterPlayer : oredictionificator.playersUsing) - { - Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(oredictionificator), oredictionificator.getFilterPacket(new ArrayList())), (EntityPlayerMP)iterPlayer); - } - } - } - - return null; - } - - public static class EditFilterMessage implements IMessage - { - public Coord4D coord4D; - - public TransporterFilter tFilter; - public TransporterFilter tEdited; - - public MinerFilter mFilter; - public MinerFilter mEdited; - - public OredictionificatorFilter oFilter; - public OredictionificatorFilter oEdited; - - public byte type = -1; - - public boolean delete; - - public EditFilterMessage() {} - - public EditFilterMessage(Coord4D coord, boolean deletion, Object filter, Object edited) - { - coord4D = coord; - delete = deletion; - - if(filter instanceof TransporterFilter) - { - tFilter = (TransporterFilter)filter; - - if(!delete) - { - tEdited = (TransporterFilter)edited; - } - - type = 0; - } - else if(filter instanceof MinerFilter) - { - mFilter = (MinerFilter)filter; - - if(!delete) - { - mEdited = (MinerFilter)edited; - } - - type = 1; - } - else if(filter instanceof OredictionificatorFilter) - { - oFilter = (OredictionificatorFilter)filter; - - if(!delete) - { - oEdited = (OredictionificatorFilter)edited; - } - - type = 2; - } - } - - @Override - public void toBytes(ByteBuf dataStream) - { - dataStream.writeInt(coord4D.xCoord); - dataStream.writeInt(coord4D.yCoord); - dataStream.writeInt(coord4D.zCoord); - - dataStream.writeInt(coord4D.dimensionId); - - dataStream.writeByte(type); - - dataStream.writeBoolean(delete); - - ArrayList data = new ArrayList(); - - if(type == 0) - { - tFilter.write(data); - - if(!delete) - { - tEdited.write(data); - } - } - else if(type == 1) - { - mFilter.write(data); - - if(!delete) - { - mEdited.write(data); - } - } - else if(type == 2) - { - oFilter.write(data); - - if(!delete) - { - oEdited.write(data); - } - } - - PacketHandler.encode(data.toArray(), dataStream); - } - - @Override - public void fromBytes(ByteBuf dataStream) - { - coord4D = new Coord4D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt(), dataStream.readInt()); - - type = dataStream.readByte(); - delete = dataStream.readBoolean(); - - if(type == 0) - { - tFilter = TransporterFilter.readFromPacket(dataStream); - - if(!delete) - { - tEdited = TransporterFilter.readFromPacket(dataStream); - } - } - else if(type == 1) - { - mFilter = MinerFilter.readFromPacket(dataStream); - - if(!delete) - { - mEdited = MinerFilter.readFromPacket(dataStream); - } - } - else if(type == 2) - { - oFilter = OredictionificatorFilter.readFromPacket(dataStream); - - if(!delete) - { - oEdited = OredictionificatorFilter.readFromPacket(dataStream); - } - } - } - } + if (!message.delete) { + oredictionificator.filters.add(index, message.oEdited); + } + + for (EntityPlayer iterPlayer : oredictionificator.playersUsing) { + Mekanism.packetHandler.sendTo( + new TileEntityMessage( + Coord4D.get(oredictionificator), + oredictionificator.getFilterPacket(new ArrayList()) + ), + (EntityPlayerMP) iterPlayer + ); + } + } + } + + return null; + } + + public static class EditFilterMessage implements IMessage { + public Coord4D coord4D; + + public TransporterFilter tFilter; + public TransporterFilter tEdited; + + public MinerFilter mFilter; + public MinerFilter mEdited; + + public OredictionificatorFilter oFilter; + public OredictionificatorFilter oEdited; + + public byte type = -1; + + public boolean delete; + + public EditFilterMessage() {} + + public EditFilterMessage( + Coord4D coord, boolean deletion, Object filter, Object edited + ) { + coord4D = coord; + delete = deletion; + + if (filter instanceof TransporterFilter) { + tFilter = (TransporterFilter) filter; + + if (!delete) { + tEdited = (TransporterFilter) edited; + } + + type = 0; + } else if (filter instanceof MinerFilter) { + mFilter = (MinerFilter) filter; + + if (!delete) { + mEdited = (MinerFilter) edited; + } + + type = 1; + } else if (filter instanceof OredictionificatorFilter) { + oFilter = (OredictionificatorFilter) filter; + + if (!delete) { + oEdited = (OredictionificatorFilter) edited; + } + + type = 2; + } + } + + @Override + public void toBytes(ByteBuf dataStream) { + dataStream.writeInt(coord4D.xCoord); + dataStream.writeInt(coord4D.yCoord); + dataStream.writeInt(coord4D.zCoord); + + dataStream.writeInt(coord4D.dimensionId); + + dataStream.writeByte(type); + + dataStream.writeBoolean(delete); + + ArrayList data = new ArrayList(); + + if (type == 0) { + tFilter.write(data); + + if (!delete) { + tEdited.write(data); + } + } else if (type == 1) { + mFilter.write(data); + + if (!delete) { + mEdited.write(data); + } + } else if (type == 2) { + oFilter.write(data); + + if (!delete) { + oEdited.write(data); + } + } + + PacketHandler.encode(data.toArray(), dataStream); + } + + @Override + public void fromBytes(ByteBuf dataStream) { + coord4D = new Coord4D( + dataStream.readInt(), + dataStream.readInt(), + dataStream.readInt(), + dataStream.readInt() + ); + + type = dataStream.readByte(); + delete = dataStream.readBoolean(); + + if (type == 0) { + tFilter = TransporterFilter.readFromPacket(dataStream); + + if (!delete) { + tEdited = TransporterFilter.readFromPacket(dataStream); + } + } else if (type == 1) { + mFilter = MinerFilter.readFromPacket(dataStream); + + if (!delete) { + mEdited = MinerFilter.readFromPacket(dataStream); + } + } else if (type == 2) { + oFilter = OredictionificatorFilter.readFromPacket(dataStream); + + if (!delete) { + oEdited = OredictionificatorFilter.readFromPacket(dataStream); + } + } + } + } } diff --git a/src/main/java/mekanism/common/network/PacketElectricBowState.java b/src/main/java/mekanism/common/network/PacketElectricBowState.java index 1c9b05569..c4a11a552 100644 --- a/src/main/java/mekanism/common/network/PacketElectricBowState.java +++ b/src/main/java/mekanism/common/network/PacketElectricBowState.java @@ -1,50 +1,45 @@ package mekanism.common.network; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; import mekanism.common.PacketHandler; import mekanism.common.item.ItemElectricBow; import mekanism.common.network.PacketElectricBowState.ElectricBowStateMessage; import net.minecraft.item.ItemStack; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -public class PacketElectricBowState implements IMessageHandler -{ - @Override - public IMessage onMessage(ElectricBowStateMessage message, MessageContext context) - { - ItemStack itemstack = PacketHandler.getPlayer(context).getCurrentEquippedItem(); - - if(itemstack != null && itemstack.getItem() instanceof ItemElectricBow) - { - ((ItemElectricBow)itemstack.getItem()).setFireState(itemstack, message.fireMode); - } - - return null; - } - - public static class ElectricBowStateMessage implements IMessage - { - public boolean fireMode; - - public ElectricBowStateMessage() {} - - public ElectricBowStateMessage(boolean state) - { - fireMode = state; - } - - @Override - public void toBytes(ByteBuf dataStream) - { - dataStream.writeBoolean(fireMode); - } - - @Override - public void fromBytes(ByteBuf dataStream) - { - fireMode = dataStream.readBoolean(); - } - } +public class PacketElectricBowState + implements IMessageHandler { + @Override + public IMessage onMessage(ElectricBowStateMessage message, MessageContext context) { + ItemStack itemstack = PacketHandler.getPlayer(context).getCurrentEquippedItem(); + + if (itemstack != null && itemstack.getItem() instanceof ItemElectricBow) { + ((ItemElectricBow) itemstack.getItem()) + .setFireState(itemstack, message.fireMode); + } + + return null; + } + + public static class ElectricBowStateMessage implements IMessage { + public boolean fireMode; + + public ElectricBowStateMessage() {} + + public ElectricBowStateMessage(boolean state) { + fireMode = state; + } + + @Override + public void toBytes(ByteBuf dataStream) { + dataStream.writeBoolean(fireMode); + } + + @Override + public void fromBytes(ByteBuf dataStream) { + fireMode = dataStream.readBoolean(); + } + } } diff --git a/src/main/java/mekanism/common/network/PacketEntityMove.java b/src/main/java/mekanism/common/network/PacketEntityMove.java index e26435b01..2d8cc0e19 100644 --- a/src/main/java/mekanism/common/network/PacketEntityMove.java +++ b/src/main/java/mekanism/common/network/PacketEntityMove.java @@ -1,61 +1,62 @@ package mekanism.common.network; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; import mekanism.api.Pos3D; import mekanism.common.PacketHandler; import mekanism.common.network.PacketEntityMove.EntityMoveMessage; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -public class PacketEntityMove implements IMessageHandler -{ - @Override - public IMessage onMessage(EntityMoveMessage message, MessageContext context) - { - EntityPlayer player = PacketHandler.getPlayer(context); - Entity entity = player.worldObj.getEntityByID(message.entityId); - - if(entity != null) - { - entity.setLocationAndAngles(message.pos.xPos, message.pos.yPos, message.pos.zPos, entity.rotationYaw, entity.rotationPitch); - } - - return null; - } - - public static class EntityMoveMessage implements IMessage - { - public int entityId; - - public Pos3D pos; - - public EntityMoveMessage() {} - - public EntityMoveMessage(Entity e) - { - entityId = e.getEntityId(); - pos = new Pos3D(e); - } - - @Override - public void toBytes(ByteBuf dataStream) - { - dataStream.writeInt(entityId); - - dataStream.writeFloat((float)pos.xPos); - dataStream.writeFloat((float)pos.yPos); - dataStream.writeFloat((float)pos.zPos); - } - - @Override - public void fromBytes(ByteBuf dataStream) - { - entityId = dataStream.readInt(); - - pos = new Pos3D(dataStream.readFloat(), dataStream.readFloat(), dataStream.readFloat()); - } - } +public class PacketEntityMove implements IMessageHandler { + @Override + public IMessage onMessage(EntityMoveMessage message, MessageContext context) { + EntityPlayer player = PacketHandler.getPlayer(context); + Entity entity = player.worldObj.getEntityByID(message.entityId); + + if (entity != null) { + entity.setLocationAndAngles( + message.pos.xPos, + message.pos.yPos, + message.pos.zPos, + entity.rotationYaw, + entity.rotationPitch + ); + } + + return null; + } + + public static class EntityMoveMessage implements IMessage { + public int entityId; + + public Pos3D pos; + + public EntityMoveMessage() {} + + public EntityMoveMessage(Entity e) { + entityId = e.getEntityId(); + pos = new Pos3D(e); + } + + @Override + public void toBytes(ByteBuf dataStream) { + dataStream.writeInt(entityId); + + dataStream.writeFloat((float) pos.xPos); + dataStream.writeFloat((float) pos.yPos); + dataStream.writeFloat((float) pos.zPos); + } + + @Override + public void fromBytes(ByteBuf dataStream) { + entityId = dataStream.readInt(); + + pos = new Pos3D( + dataStream.readFloat(), dataStream.readFloat(), dataStream.readFloat() + ); + } + } } diff --git a/src/main/java/mekanism/common/network/PacketFlamethrowerData.java b/src/main/java/mekanism/common/network/PacketFlamethrowerData.java index efdbb09f8..e50bfcd77 100644 --- a/src/main/java/mekanism/common/network/PacketFlamethrowerData.java +++ b/src/main/java/mekanism/common/network/PacketFlamethrowerData.java @@ -1,5 +1,8 @@ package mekanism.common.network; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; import mekanism.common.Mekanism; import mekanism.common.PacketHandler; @@ -7,92 +10,80 @@ import mekanism.common.item.ItemFlamethrower; import mekanism.common.network.PacketFlamethrowerData.FlamethrowerDataMessage; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -public class PacketFlamethrowerData implements IMessageHandler -{ - @Override - public IMessage onMessage(FlamethrowerDataMessage message, MessageContext context) - { - EntityPlayer player = PacketHandler.getPlayer(context); +public class PacketFlamethrowerData + implements IMessageHandler { + @Override + public IMessage onMessage(FlamethrowerDataMessage message, MessageContext context) { + EntityPlayer player = PacketHandler.getPlayer(context); - if(message.packetType == FlamethrowerPacket.UPDATE) - { - if(message.value) - { + if (message.packetType == FlamethrowerPacket.UPDATE) { + if (message.value) { Mekanism.flamethrowerActive.add(message.username); - } - else { + } else { Mekanism.flamethrowerActive.remove(message.username); } - if(!player.worldObj.isRemote) - { - Mekanism.packetHandler.sendToDimension(new FlamethrowerDataMessage(FlamethrowerPacket.UPDATE, message.username, message.value), player.worldObj.provider.dimensionId); + if (!player.worldObj.isRemote) { + Mekanism.packetHandler.sendToDimension( + new FlamethrowerDataMessage( + FlamethrowerPacket.UPDATE, message.username, message.value + ), + player.worldObj.provider.dimensionId + ); } - } - else if(message.packetType == FlamethrowerPacket.MODE) - { + } else if (message.packetType == FlamethrowerPacket.MODE) { ItemStack stack = player.getCurrentEquippedItem(); - if(stack != null && stack.getItem() instanceof ItemFlamethrower) - { - ((ItemFlamethrower)stack.getItem()).incrementMode(stack); + if (stack != null && stack.getItem() instanceof ItemFlamethrower) { + ((ItemFlamethrower) stack.getItem()).incrementMode(stack); } } - - return null; - } - - public static class FlamethrowerDataMessage implements IMessage - { + + return null; + } + + public static class FlamethrowerDataMessage implements IMessage { public FlamethrowerPacket packetType; - public String username; - public boolean value; - - public FlamethrowerDataMessage() {} - - public FlamethrowerDataMessage(FlamethrowerPacket type, String name, boolean state) - { + public String username; + public boolean value; + + public FlamethrowerDataMessage() {} + + public FlamethrowerDataMessage( + FlamethrowerPacket type, String name, boolean state + ) { packetType = type; - if(type == FlamethrowerPacket.UPDATE) - { + if (type == FlamethrowerPacket.UPDATE) { username = name; value = state; } - } - - @Override - public void toBytes(ByteBuf dataStream) - { + } + + @Override + public void toBytes(ByteBuf dataStream) { dataStream.writeInt(packetType.ordinal()); - if(packetType == FlamethrowerPacket.UPDATE) - { + if (packetType == FlamethrowerPacket.UPDATE) { PacketHandler.writeString(dataStream, username); dataStream.writeBoolean(value); } - } - - @Override - public void fromBytes(ByteBuf dataStream) - { + } + + @Override + public void fromBytes(ByteBuf dataStream) { packetType = FlamethrowerPacket.values()[dataStream.readInt()]; - if(packetType == FlamethrowerPacket.UPDATE) - { + if (packetType == FlamethrowerPacket.UPDATE) { username = PacketHandler.readString(dataStream); value = dataStream.readBoolean(); } - } - } + } + } - public static enum FlamethrowerPacket - { + public static enum FlamethrowerPacket { UPDATE, MODE; } diff --git a/src/main/java/mekanism/common/network/PacketJetpackData.java b/src/main/java/mekanism/common/network/PacketJetpackData.java index dd22216b5..e57dc2ca9 100644 --- a/src/main/java/mekanism/common/network/PacketJetpackData.java +++ b/src/main/java/mekanism/common/network/PacketJetpackData.java @@ -1,5 +1,8 @@ package mekanism.common.network; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; import mekanism.common.Mekanism; import mekanism.common.PacketHandler; @@ -8,131 +11,103 @@ import mekanism.common.item.ItemJetpack.JetpackMode; import mekanism.common.network.PacketJetpackData.JetpackDataMessage; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -public class PacketJetpackData implements IMessageHandler -{ - @Override - public IMessage onMessage(JetpackDataMessage message, MessageContext context) - { - EntityPlayer player = PacketHandler.getPlayer(context); - - if(message.packetType == JetpackPacket.UPDATE) - { - if(message.value) - { - Mekanism.jetpackOn.add(message.username); - } - else { - Mekanism.jetpackOn.remove(message.username); - } +public class PacketJetpackData implements IMessageHandler { + @Override + public IMessage onMessage(JetpackDataMessage message, MessageContext context) { + EntityPlayer player = PacketHandler.getPlayer(context); - if(!player.worldObj.isRemote) - { - Mekanism.packetHandler.sendToDimension(new JetpackDataMessage(JetpackPacket.UPDATE, message.username, message.value), player.worldObj.provider.dimensionId); - } - } - else if(message.packetType == JetpackPacket.MODE) - { - ItemStack stack = player.getEquipmentInSlot(3); + if (message.packetType == JetpackPacket.UPDATE) { + if (message.value) { + Mekanism.jetpackOn.add(message.username); + } else { + Mekanism.jetpackOn.remove(message.username); + } - if(stack != null && stack.getItem() instanceof ItemJetpack) - { - if(!message.value) - { - ((ItemJetpack)stack.getItem()).incrementMode(stack); - } - else { - ((ItemJetpack)stack.getItem()).setMode(stack, JetpackMode.DISABLED); - } - } - } - - return null; - } - - public static class JetpackDataMessage implements IMessage - { - public JetpackPacket packetType; - - public String username; - public boolean value; - - public JetpackDataMessage() {} - - public JetpackDataMessage(JetpackPacket type, String name, boolean state) - { - packetType = type; - value = state; - - if(packetType == JetpackPacket.UPDATE) - { - username = name; - } - } - - @Override - public void toBytes(ByteBuf dataStream) - { - dataStream.writeInt(packetType.ordinal()); - - if(packetType == JetpackPacket.MODE) - { - dataStream.writeBoolean(value); - } - else if(packetType == JetpackPacket.UPDATE) - { - PacketHandler.writeString(dataStream, username); - dataStream.writeBoolean(value); - } - else if(packetType == JetpackPacket.FULL) - { - dataStream.writeInt(Mekanism.jetpackOn.size()); + if (!player.worldObj.isRemote) { + Mekanism.packetHandler.sendToDimension( + new JetpackDataMessage( + JetpackPacket.UPDATE, message.username, message.value + ), + player.worldObj.provider.dimensionId + ); + } + } else if (message.packetType == JetpackPacket.MODE) { + ItemStack stack = player.getEquipmentInSlot(3); - synchronized(Mekanism.jetpackOn) - { - for(String username : Mekanism.jetpackOn) - { - PacketHandler.writeString(dataStream, username); - } - } - } - } - - @Override - public void fromBytes(ByteBuf dataStream) - { - packetType = JetpackPacket.values()[dataStream.readInt()]; - - if(packetType == JetpackPacket.MODE) - { - value = dataStream.readBoolean(); - } - else if(packetType == JetpackPacket.UPDATE) - { - username = PacketHandler.readString(dataStream); - value = dataStream.readBoolean(); - } - else if(packetType == JetpackPacket.FULL) - { - Mekanism.jetpackOn.clear(); - - int amount = dataStream.readInt(); - - for(int i = 0; i < amount; i++) - { - Mekanism.jetpackOn.add(PacketHandler.readString(dataStream)); - } - } - } - } - - public static enum JetpackPacket - { - UPDATE, - FULL, - MODE; - } + if (stack != null && stack.getItem() instanceof ItemJetpack) { + if (!message.value) { + ((ItemJetpack) stack.getItem()).incrementMode(stack); + } else { + ((ItemJetpack) stack.getItem()).setMode(stack, JetpackMode.DISABLED); + } + } + } + + return null; + } + + public static class JetpackDataMessage implements IMessage { + public JetpackPacket packetType; + + public String username; + public boolean value; + + public JetpackDataMessage() {} + + public JetpackDataMessage(JetpackPacket type, String name, boolean state) { + packetType = type; + value = state; + + if (packetType == JetpackPacket.UPDATE) { + username = name; + } + } + + @Override + public void toBytes(ByteBuf dataStream) { + dataStream.writeInt(packetType.ordinal()); + + if (packetType == JetpackPacket.MODE) { + dataStream.writeBoolean(value); + } else if (packetType == JetpackPacket.UPDATE) { + PacketHandler.writeString(dataStream, username); + dataStream.writeBoolean(value); + } else if (packetType == JetpackPacket.FULL) { + dataStream.writeInt(Mekanism.jetpackOn.size()); + + synchronized (Mekanism.jetpackOn) { + for (String username : Mekanism.jetpackOn) { + PacketHandler.writeString(dataStream, username); + } + } + } + } + + @Override + public void fromBytes(ByteBuf dataStream) { + packetType = JetpackPacket.values()[dataStream.readInt()]; + + if (packetType == JetpackPacket.MODE) { + value = dataStream.readBoolean(); + } else if (packetType == JetpackPacket.UPDATE) { + username = PacketHandler.readString(dataStream); + value = dataStream.readBoolean(); + } else if (packetType == JetpackPacket.FULL) { + Mekanism.jetpackOn.clear(); + + int amount = dataStream.readInt(); + + for (int i = 0; i < amount; i++) { + Mekanism.jetpackOn.add(PacketHandler.readString(dataStream)); + } + } + } + } + + public static enum JetpackPacket { + UPDATE, + FULL, + MODE; + } } diff --git a/src/main/java/mekanism/common/network/PacketKey.java b/src/main/java/mekanism/common/network/PacketKey.java index 05fad0273..c6dabf860 100644 --- a/src/main/java/mekanism/common/network/PacketKey.java +++ b/src/main/java/mekanism/common/network/PacketKey.java @@ -1,54 +1,46 @@ package mekanism.common.network; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; import mekanism.common.Mekanism; import mekanism.common.PacketHandler; import mekanism.common.network.PacketKey.KeyMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -public class PacketKey implements IMessageHandler -{ - @Override - public IMessage onMessage(KeyMessage message, MessageContext context) - { - if(message.add) - { - Mekanism.keyMap.add(PacketHandler.getPlayer(context), message.key); - } - else { - Mekanism.keyMap.remove(PacketHandler.getPlayer(context), message.key); - } - - return null; - } - - public static class KeyMessage implements IMessage - { - public int key; - public boolean add; - - public KeyMessage() {} - - public KeyMessage(int k, boolean a) - { - key = k; - add = a; - } - - @Override - public void toBytes(ByteBuf dataStream) - { - dataStream.writeInt(key); - dataStream.writeBoolean(add); - } - - @Override - public void fromBytes(ByteBuf dataStream) - { - key = dataStream.readInt(); - add = dataStream.readBoolean(); - } - } +public class PacketKey implements IMessageHandler { + @Override + public IMessage onMessage(KeyMessage message, MessageContext context) { + if (message.add) { + Mekanism.keyMap.add(PacketHandler.getPlayer(context), message.key); + } else { + Mekanism.keyMap.remove(PacketHandler.getPlayer(context), message.key); + } + + return null; + } + + public static class KeyMessage implements IMessage { + public int key; + public boolean add; + + public KeyMessage() {} + + public KeyMessage(int k, boolean a) { + key = k; + add = a; + } + + @Override + public void toBytes(ByteBuf dataStream) { + dataStream.writeInt(key); + dataStream.writeBoolean(add); + } + + @Override + public void fromBytes(ByteBuf dataStream) { + key = dataStream.readInt(); + add = dataStream.readBoolean(); + } + } } diff --git a/src/main/java/mekanism/common/network/PacketLogisticalSorterGui.java b/src/main/java/mekanism/common/network/PacketLogisticalSorterGui.java index 5250048ee..18c1b4f24 100644 --- a/src/main/java/mekanism/common/network/PacketLogisticalSorterGui.java +++ b/src/main/java/mekanism/common/network/PacketLogisticalSorterGui.java @@ -1,5 +1,11 @@ package mekanism.common.network; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.client.gui.GuiLogisticalSorter; @@ -20,226 +26,277 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.inventory.Container; import net.minecraft.world.World; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class PacketLogisticalSorterGui implements IMessageHandler -{ - @Override - public IMessage onMessage(LogisticalSorterGuiMessage message, MessageContext context) - { - EntityPlayer player = PacketHandler.getPlayer(context); - - if(!player.worldObj.isRemote) - { - World worldServer = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(message.object3D.dimensionId); +public class PacketLogisticalSorterGui + implements IMessageHandler { + @Override + public IMessage + onMessage(LogisticalSorterGuiMessage message, MessageContext context) { + EntityPlayer player = PacketHandler.getPlayer(context); - if(worldServer != null && message.object3D.getTileEntity(worldServer) instanceof TileEntityLogisticalSorter) - { - LogisticalSorterGuiMessage.openServerGui(message.packetType, message.guiType, worldServer, (EntityPlayerMP)player, message.object3D, message.index); - } - } - else { - if(message.object3D.getTileEntity(player.worldObj) instanceof TileEntityLogisticalSorter) - { - try { - if(message.packetType == SorterGuiPacket.CLIENT) - { - FMLCommonHandler.instance().showGuiScreen(LogisticalSorterGuiMessage.getGui(message.packetType, message.guiType, player, player.worldObj, message.object3D.xCoord, message.object3D.yCoord, message.object3D.zCoord, -1)); - } - else if(message.packetType == SorterGuiPacket.CLIENT_INDEX) - { - FMLCommonHandler.instance().showGuiScreen(LogisticalSorterGuiMessage.getGui(message.packetType, message.guiType, player, player.worldObj, message.object3D.xCoord, message.object3D.yCoord, message.object3D.zCoord, message.index)); - } + if (!player.worldObj.isRemote) { + World worldServer + = FMLCommonHandler.instance() + .getMinecraftServerInstance() + .worldServerForDimension(message.object3D.dimensionId); - player.openContainer.windowId = message.windowId; - } catch(Exception e) { - e.printStackTrace(); - } - } - } - - return null; - } - - public static class LogisticalSorterGuiMessage implements IMessage - { - public Coord4D object3D; - - public SorterGuiPacket packetType; - - public int guiType; - - public int windowId = -1; - - public int index = -1; - - public LogisticalSorterGuiMessage() {} - - public LogisticalSorterGuiMessage(SorterGuiPacket type, Coord4D coord, int guiId, int extra, int extra2) - { - packetType = type; - - object3D = coord; - guiType = guiId; - - if(packetType == SorterGuiPacket.CLIENT) - { - windowId = extra; - } - else if(packetType == SorterGuiPacket.SERVER_INDEX) - { - index = extra; - } - else if(packetType == SorterGuiPacket.CLIENT_INDEX) - { - windowId = extra2; - index = extra2; - } - } - - public static void openServerGui(SorterGuiPacket t, int guiType, World world, EntityPlayerMP playerMP, Coord4D obj, int i) - { - Container container = null; - - playerMP.closeContainer(); - - if(guiType == 0) - { - container = new ContainerNull(playerMP, (TileEntityContainerBlock)obj.getTileEntity(world)); - } - else if(guiType == 4) - { - container = new ContainerNull(playerMP, (TileEntityContainerBlock)obj.getTileEntity(world)); - } - else if(guiType == 1 || guiType == 2 || guiType == 3 || guiType == 5) - { - container = new ContainerFilter(playerMP.inventory, (TileEntityContainerBlock)obj.getTileEntity(world)); - } - - playerMP.getNextWindowId(); - int window = playerMP.currentWindowId; - - if(t == SorterGuiPacket.SERVER) - { - Mekanism.packetHandler.sendTo(new LogisticalSorterGuiMessage(SorterGuiPacket.CLIENT, obj, guiType, window, 0), playerMP); - } - else if(t == SorterGuiPacket.SERVER_INDEX) - { - Mekanism.packetHandler.sendTo(new LogisticalSorterGuiMessage(SorterGuiPacket.CLIENT_INDEX, obj, guiType, window, i), playerMP); - } - - playerMP.openContainer = container; - playerMP.openContainer.windowId = window; - playerMP.openContainer.addCraftingToCrafters(playerMP); - } - - @SideOnly(Side.CLIENT) - public static GuiScreen getGui(SorterGuiPacket packetType, int type, EntityPlayer player, World world, int x, int y, int z, int index) - { - if(type == 0) - { - return new GuiLogisticalSorter(player, (TileEntityLogisticalSorter)world.getTileEntity(x, y, z)); - } - else if(type == 4) - { - return new GuiTFilterSelect(player, (TileEntityLogisticalSorter)world.getTileEntity(x, y, z)); - } - else { - if(packetType == SorterGuiPacket.CLIENT) - { - if(type == 1) - { - return new GuiTItemStackFilter(player, (TileEntityLogisticalSorter)world.getTileEntity(x, y, z)); - } - else if(type == 2) - { - return new GuiTOreDictFilter(player, (TileEntityLogisticalSorter)world.getTileEntity(x, y, z)); - } - else if(type == 3) - { - return new GuiTMaterialFilter(player, (TileEntityLogisticalSorter)world.getTileEntity(x, y, z)); - } - else if(type == 5) - { - return new GuiTModIDFilter(player, (TileEntityLogisticalSorter)world.getTileEntity(x, y, z)); - } - } - else if(packetType == SorterGuiPacket.CLIENT_INDEX) - { - if(type == 1) - { - return new GuiTItemStackFilter(player, (TileEntityLogisticalSorter)world.getTileEntity(x, y, z), index); - } - else if(type == 2) - { - return new GuiTOreDictFilter(player, (TileEntityLogisticalSorter)world.getTileEntity(x, y, z), index); - } - else if(type == 3) - { - return new GuiTMaterialFilter(player, (TileEntityLogisticalSorter)world.getTileEntity(x, y, z), index); - } - else if(type == 5) - { - return new GuiTModIDFilter(player, (TileEntityLogisticalSorter)world.getTileEntity(x, y, z), index); - } - } - } - - return null; - } - - @Override - public void toBytes(ByteBuf dataStream) - { - dataStream.writeInt(packetType.ordinal()); - - dataStream.writeInt(object3D.xCoord); - dataStream.writeInt(object3D.yCoord); - dataStream.writeInt(object3D.zCoord); - - dataStream.writeInt(object3D.dimensionId); - - dataStream.writeInt(guiType); - - if(packetType == SorterGuiPacket.CLIENT || packetType == SorterGuiPacket.CLIENT_INDEX) - { - dataStream.writeInt(windowId); - } - - if(packetType == SorterGuiPacket.SERVER_INDEX || packetType == SorterGuiPacket.CLIENT_INDEX) - { - dataStream.writeInt(index); - } - } - - @Override - public void fromBytes(ByteBuf dataStream) - { - packetType = SorterGuiPacket.values()[dataStream.readInt()]; - - object3D = new Coord4D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt(), dataStream.readInt()); - - guiType = dataStream.readInt(); - - if(packetType == SorterGuiPacket.CLIENT || packetType == SorterGuiPacket.CLIENT_INDEX) - { - windowId = dataStream.readInt(); - } - - if(packetType == SorterGuiPacket.SERVER_INDEX || packetType == SorterGuiPacket.CLIENT_INDEX) - { - index = dataStream.readInt(); - } - } - } - - public static enum SorterGuiPacket - { - SERVER, CLIENT, SERVER_INDEX, CLIENT_INDEX - } + if (worldServer != null + && message.object3D.getTileEntity(worldServer) + instanceof TileEntityLogisticalSorter) { + LogisticalSorterGuiMessage.openServerGui( + message.packetType, + message.guiType, + worldServer, + (EntityPlayerMP) player, + message.object3D, + message.index + ); + } + } else { + if (message.object3D.getTileEntity(player.worldObj) + instanceof TileEntityLogisticalSorter) { + try { + if (message.packetType == SorterGuiPacket.CLIENT) { + FMLCommonHandler.instance().showGuiScreen( + LogisticalSorterGuiMessage.getGui( + message.packetType, + message.guiType, + player, + player.worldObj, + message.object3D.xCoord, + message.object3D.yCoord, + message.object3D.zCoord, + -1 + ) + ); + } else if (message.packetType == SorterGuiPacket.CLIENT_INDEX) { + FMLCommonHandler.instance().showGuiScreen( + LogisticalSorterGuiMessage.getGui( + message.packetType, + message.guiType, + player, + player.worldObj, + message.object3D.xCoord, + message.object3D.yCoord, + message.object3D.zCoord, + message.index + ) + ); + } + + player.openContainer.windowId = message.windowId; + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + return null; + } + + public static class LogisticalSorterGuiMessage implements IMessage { + public Coord4D object3D; + + public SorterGuiPacket packetType; + + public int guiType; + + public int windowId = -1; + + public int index = -1; + + public LogisticalSorterGuiMessage() {} + + public LogisticalSorterGuiMessage( + SorterGuiPacket type, Coord4D coord, int guiId, int extra, int extra2 + ) { + packetType = type; + + object3D = coord; + guiType = guiId; + + if (packetType == SorterGuiPacket.CLIENT) { + windowId = extra; + } else if (packetType == SorterGuiPacket.SERVER_INDEX) { + index = extra; + } else if (packetType == SorterGuiPacket.CLIENT_INDEX) { + windowId = extra2; + index = extra2; + } + } + + public static void openServerGui( + SorterGuiPacket t, + int guiType, + World world, + EntityPlayerMP playerMP, + Coord4D obj, + int i + ) { + Container container = null; + + playerMP.closeContainer(); + + if (guiType == 0) { + container = new ContainerNull( + playerMP, (TileEntityContainerBlock) obj.getTileEntity(world) + ); + } else if (guiType == 4) { + container = new ContainerNull( + playerMP, (TileEntityContainerBlock) obj.getTileEntity(world) + ); + } else if (guiType == 1 || guiType == 2 || guiType == 3 || guiType == 5) { + container = new ContainerFilter( + playerMP.inventory, + (TileEntityContainerBlock) obj.getTileEntity(world) + ); + } + + playerMP.getNextWindowId(); + int window = playerMP.currentWindowId; + + if (t == SorterGuiPacket.SERVER) { + Mekanism.packetHandler.sendTo( + new LogisticalSorterGuiMessage( + SorterGuiPacket.CLIENT, obj, guiType, window, 0 + ), + playerMP + ); + } else if (t == SorterGuiPacket.SERVER_INDEX) { + Mekanism.packetHandler.sendTo( + new LogisticalSorterGuiMessage( + SorterGuiPacket.CLIENT_INDEX, obj, guiType, window, i + ), + playerMP + ); + } + + playerMP.openContainer = container; + playerMP.openContainer.windowId = window; + playerMP.openContainer.addCraftingToCrafters(playerMP); + } + + @SideOnly(Side.CLIENT) + public static GuiScreen getGui( + SorterGuiPacket packetType, + int type, + EntityPlayer player, + World world, + int x, + int y, + int z, + int index + ) { + if (type == 0) { + return new GuiLogisticalSorter( + player, (TileEntityLogisticalSorter) world.getTileEntity(x, y, z) + ); + } else if (type == 4) { + return new GuiTFilterSelect( + player, (TileEntityLogisticalSorter) world.getTileEntity(x, y, z) + ); + } else { + if (packetType == SorterGuiPacket.CLIENT) { + if (type == 1) { + return new GuiTItemStackFilter( + player, + (TileEntityLogisticalSorter) world.getTileEntity(x, y, z) + ); + } else if (type == 2) { + return new GuiTOreDictFilter( + player, + (TileEntityLogisticalSorter) world.getTileEntity(x, y, z) + ); + } else if (type == 3) { + return new GuiTMaterialFilter( + player, + (TileEntityLogisticalSorter) world.getTileEntity(x, y, z) + ); + } else if (type == 5) { + return new GuiTModIDFilter( + player, + (TileEntityLogisticalSorter) world.getTileEntity(x, y, z) + ); + } + } else if (packetType == SorterGuiPacket.CLIENT_INDEX) { + if (type == 1) { + return new GuiTItemStackFilter( + player, + (TileEntityLogisticalSorter) world.getTileEntity(x, y, z), + index + ); + } else if (type == 2) { + return new GuiTOreDictFilter( + player, + (TileEntityLogisticalSorter) world.getTileEntity(x, y, z), + index + ); + } else if (type == 3) { + return new GuiTMaterialFilter( + player, + (TileEntityLogisticalSorter) world.getTileEntity(x, y, z), + index + ); + } else if (type == 5) { + return new GuiTModIDFilter( + player, + (TileEntityLogisticalSorter) world.getTileEntity(x, y, z), + index + ); + } + } + } + + return null; + } + + @Override + public void toBytes(ByteBuf dataStream) { + dataStream.writeInt(packetType.ordinal()); + + dataStream.writeInt(object3D.xCoord); + dataStream.writeInt(object3D.yCoord); + dataStream.writeInt(object3D.zCoord); + + dataStream.writeInt(object3D.dimensionId); + + dataStream.writeInt(guiType); + + if (packetType == SorterGuiPacket.CLIENT + || packetType == SorterGuiPacket.CLIENT_INDEX) { + dataStream.writeInt(windowId); + } + + if (packetType == SorterGuiPacket.SERVER_INDEX + || packetType == SorterGuiPacket.CLIENT_INDEX) { + dataStream.writeInt(index); + } + } + + @Override + public void fromBytes(ByteBuf dataStream) { + packetType = SorterGuiPacket.values()[dataStream.readInt()]; + + object3D = new Coord4D( + dataStream.readInt(), + dataStream.readInt(), + dataStream.readInt(), + dataStream.readInt() + ); + + guiType = dataStream.readInt(); + + if (packetType == SorterGuiPacket.CLIENT + || packetType == SorterGuiPacket.CLIENT_INDEX) { + windowId = dataStream.readInt(); + } + + if (packetType == SorterGuiPacket.SERVER_INDEX + || packetType == SorterGuiPacket.CLIENT_INDEX) { + index = dataStream.readInt(); + } + } + } + + public static enum SorterGuiPacket { SERVER, CLIENT, SERVER_INDEX, CLIENT_INDEX } } diff --git a/src/main/java/mekanism/common/network/PacketNewFilter.java b/src/main/java/mekanism/common/network/PacketNewFilter.java index 42964cac9..58148da6d 100644 --- a/src/main/java/mekanism/common/network/PacketNewFilter.java +++ b/src/main/java/mekanism/common/network/PacketNewFilter.java @@ -1,9 +1,12 @@ package mekanism.common.network; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.common.Mekanism; import mekanism.common.PacketHandler; @@ -18,140 +21,135 @@ import mekanism.common.tile.TileEntityOredictionificator.OredictionificatorFilte import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.world.World; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -public class PacketNewFilter implements IMessageHandler -{ - @Override - public IMessage onMessage(NewFilterMessage message, MessageContext context) - { - World worldServer = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(message.coord4D.dimensionId); - - if(worldServer != null) - { - if(message.type == 0 && message.coord4D.getTileEntity(worldServer) instanceof TileEntityLogisticalSorter) - { - TileEntityLogisticalSorter sorter = (TileEntityLogisticalSorter)message.coord4D.getTileEntity(worldServer); +public class PacketNewFilter implements IMessageHandler { + @Override + public IMessage onMessage(NewFilterMessage message, MessageContext context) { + World worldServer = FMLCommonHandler.instance() + .getMinecraftServerInstance() + .worldServerForDimension(message.coord4D.dimensionId); - sorter.filters.add(message.tFilter); + if (worldServer != null) { + if (message.type == 0 + && message.coord4D.getTileEntity(worldServer) + instanceof TileEntityLogisticalSorter) { + TileEntityLogisticalSorter sorter = (TileEntityLogisticalSorter + ) message.coord4D.getTileEntity(worldServer); - for(EntityPlayer iterPlayer : sorter.playersUsing) - { - Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(sorter), sorter.getFilterPacket(new ArrayList())), (EntityPlayerMP)iterPlayer); - } - } - else if(message.type == 1 && message.coord4D.getTileEntity(worldServer) instanceof TileEntityDigitalMiner) - { - TileEntityDigitalMiner miner = (TileEntityDigitalMiner)message.coord4D.getTileEntity(worldServer); + sorter.filters.add(message.tFilter); - miner.filters.add(message.mFilter); + for (EntityPlayer iterPlayer : sorter.playersUsing) { + Mekanism.packetHandler.sendTo( + new TileEntityMessage( + Coord4D.get(sorter), sorter.getFilterPacket(new ArrayList()) + ), + (EntityPlayerMP) iterPlayer + ); + } + } else if (message.type == 1 && message.coord4D.getTileEntity(worldServer) instanceof TileEntityDigitalMiner) { + TileEntityDigitalMiner miner + = (TileEntityDigitalMiner) message.coord4D.getTileEntity(worldServer); - for(EntityPlayer iterPlayer : miner.playersUsing) - { - Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(miner), miner.getFilterPacket(new ArrayList())), (EntityPlayerMP)iterPlayer); - } - } - else if(message.type == 2 && message.coord4D.getTileEntity(worldServer) instanceof TileEntityOredictionificator) - { - TileEntityOredictionificator oredictionificator = (TileEntityOredictionificator)message.coord4D.getTileEntity(worldServer); - - oredictionificator.filters.add(message.oFilter); - - for(EntityPlayer iterPlayer : oredictionificator.playersUsing) - { - Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(oredictionificator), oredictionificator.getFilterPacket(new ArrayList())), (EntityPlayerMP)iterPlayer); - } - } - } - - return null; - } - - public static class NewFilterMessage implements IMessage - { - public Coord4D coord4D; + miner.filters.add(message.mFilter); - public TransporterFilter tFilter; + for (EntityPlayer iterPlayer : miner.playersUsing) { + Mekanism.packetHandler.sendTo( + new TileEntityMessage( + Coord4D.get(miner), miner.getFilterPacket(new ArrayList()) + ), + (EntityPlayerMP) iterPlayer + ); + } + } else if (message.type == 2 && message.coord4D.getTileEntity(worldServer) instanceof TileEntityOredictionificator) { + TileEntityOredictionificator oredictionificator + = (TileEntityOredictionificator + ) message.coord4D.getTileEntity(worldServer); - public MinerFilter mFilter; - - public OredictionificatorFilter oFilter; + oredictionificator.filters.add(message.oFilter); - public byte type = -1; - - public NewFilterMessage() {} - - public NewFilterMessage(Coord4D coord, Object filter) - { - coord4D = coord; - - if(filter instanceof TransporterFilter) - { - tFilter = (TransporterFilter)filter; - type = 0; - } - else if(filter instanceof MinerFilter) - { - mFilter = (MinerFilter)filter; - type = 1; - } - else if(filter instanceof OredictionificatorFilter) - { - oFilter = (OredictionificatorFilter)filter; - type = 2; - } - } - - @Override - public void toBytes(ByteBuf dataStream) - { - dataStream.writeInt(coord4D.xCoord); - dataStream.writeInt(coord4D.yCoord); - dataStream.writeInt(coord4D.zCoord); - - dataStream.writeInt(coord4D.dimensionId); - - dataStream.writeByte(type); - - ArrayList data = new ArrayList(); - - if(type == 0) - { - tFilter.write(data); - } - else if(type == 1) - { - mFilter.write(data); - } - else if(type == 2) - { - oFilter.write(data); - } - - PacketHandler.encode(data.toArray(), dataStream); - } - - @Override - public void fromBytes(ByteBuf dataStream) - { - coord4D = new Coord4D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt(), dataStream.readInt()); - type = dataStream.readByte(); - - if(type == 0) - { - tFilter = TransporterFilter.readFromPacket(dataStream); - } - else if(type == 1) - { - mFilter = MinerFilter.readFromPacket(dataStream); - } - else if(type == 2) - { - oFilter = OredictionificatorFilter.readFromPacket(dataStream); - } - } - } + for (EntityPlayer iterPlayer : oredictionificator.playersUsing) { + Mekanism.packetHandler.sendTo( + new TileEntityMessage( + Coord4D.get(oredictionificator), + oredictionificator.getFilterPacket(new ArrayList()) + ), + (EntityPlayerMP) iterPlayer + ); + } + } + } + + return null; + } + + public static class NewFilterMessage implements IMessage { + public Coord4D coord4D; + + public TransporterFilter tFilter; + + public MinerFilter mFilter; + + public OredictionificatorFilter oFilter; + + public byte type = -1; + + public NewFilterMessage() {} + + public NewFilterMessage(Coord4D coord, Object filter) { + coord4D = coord; + + if (filter instanceof TransporterFilter) { + tFilter = (TransporterFilter) filter; + type = 0; + } else if (filter instanceof MinerFilter) { + mFilter = (MinerFilter) filter; + type = 1; + } else if (filter instanceof OredictionificatorFilter) { + oFilter = (OredictionificatorFilter) filter; + type = 2; + } + } + + @Override + public void toBytes(ByteBuf dataStream) { + dataStream.writeInt(coord4D.xCoord); + dataStream.writeInt(coord4D.yCoord); + dataStream.writeInt(coord4D.zCoord); + + dataStream.writeInt(coord4D.dimensionId); + + dataStream.writeByte(type); + + ArrayList data = new ArrayList(); + + if (type == 0) { + tFilter.write(data); + } else if (type == 1) { + mFilter.write(data); + } else if (type == 2) { + oFilter.write(data); + } + + PacketHandler.encode(data.toArray(), dataStream); + } + + @Override + public void fromBytes(ByteBuf dataStream) { + coord4D = new Coord4D( + dataStream.readInt(), + dataStream.readInt(), + dataStream.readInt(), + dataStream.readInt() + ); + type = dataStream.readByte(); + + if (type == 0) { + tFilter = TransporterFilter.readFromPacket(dataStream); + } else if (type == 1) { + mFilter = MinerFilter.readFromPacket(dataStream); + } else if (type == 2) { + oFilter = OredictionificatorFilter.readFromPacket(dataStream); + } + } + } } diff --git a/src/main/java/mekanism/common/network/PacketOredictionificatorGui.java b/src/main/java/mekanism/common/network/PacketOredictionificatorGui.java index 391e8946e..f780d3831 100644 --- a/src/main/java/mekanism/common/network/PacketOredictionificatorGui.java +++ b/src/main/java/mekanism/common/network/PacketOredictionificatorGui.java @@ -1,9 +1,14 @@ package mekanism.common.network; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.client.gui.GuiOredictionificator; import mekanism.client.gui.GuiOredictionificatorFilter; @@ -20,204 +25,258 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.inventory.Container; import net.minecraft.world.World; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class PacketOredictionificatorGui implements IMessageHandler -{ - @Override - public IMessage onMessage(OredictionificatorGuiMessage message, MessageContext context) - { - EntityPlayer player = PacketHandler.getPlayer(context); - - if(!player.worldObj.isRemote) - { - World worldServer = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(message.coord4D.dimensionId); +public class PacketOredictionificatorGui + implements IMessageHandler { + @Override + public IMessage + onMessage(OredictionificatorGuiMessage message, MessageContext context) { + EntityPlayer player = PacketHandler.getPlayer(context); - if(worldServer != null && message.coord4D.getTileEntity(worldServer) instanceof TileEntityOredictionificator) - { - OredictionificatorGuiMessage.openServerGui(message.packetType, message.guiType, worldServer, (EntityPlayerMP)player, message.coord4D, message.index); - } - } - else { - if(message.coord4D.getTileEntity(player.worldObj) instanceof TileEntityOredictionificator) - { - try { - if(message.packetType == OredictionificatorGuiPacket.CLIENT) - { - FMLCommonHandler.instance().showGuiScreen(OredictionificatorGuiMessage.getGui(message.packetType, message.guiType, player, player.worldObj, message.coord4D.xCoord, message.coord4D.yCoord, message.coord4D.zCoord, -1)); - } - else if(message.packetType == OredictionificatorGuiPacket.CLIENT_INDEX) - { - FMLCommonHandler.instance().showGuiScreen(OredictionificatorGuiMessage.getGui(message.packetType, message.guiType, player, player.worldObj, message.coord4D.xCoord, message.coord4D.yCoord, message.coord4D.zCoord, message.index)); - } + if (!player.worldObj.isRemote) { + World worldServer = FMLCommonHandler.instance() + .getMinecraftServerInstance() + .worldServerForDimension(message.coord4D.dimensionId); - player.openContainer.windowId = message.windowId; - } catch(Exception e) { - e.printStackTrace(); - } - } - } - - return null; - } - - public static class OredictionificatorGuiMessage implements IMessage - { - public Coord4D coord4D; - - public OredictionificatorGuiPacket packetType; - - public int guiType; - - public int windowId = -1; - - public int index = -1; - - public OredictionificatorGuiMessage() {} - - public OredictionificatorGuiMessage(OredictionificatorGuiPacket type, Coord4D coord, int guiID, int extra, int extra2) - { - packetType = type; - - coord4D = coord; - guiType = guiID; - - if(packetType == OredictionificatorGuiPacket.CLIENT) - { - windowId = extra; - } - else if(packetType == OredictionificatorGuiPacket.SERVER_INDEX) - { - index = extra; - } - else if(packetType == OredictionificatorGuiPacket.CLIENT_INDEX) - { - windowId = extra; - index = extra2; - } - } - - public static void openServerGui(OredictionificatorGuiPacket t, int guiType, World world, EntityPlayerMP playerMP, Coord4D obj, int i) - { - Container container = null; - - playerMP.closeContainer(); - - if(guiType == 0) - { - container = new ContainerOredictionificator(playerMP.inventory, (TileEntityOredictionificator)obj.getTileEntity(world)); - } - else if(guiType == 1) - { - container = new ContainerFilter(playerMP.inventory, (TileEntityContainerBlock)obj.getTileEntity(world)); - } - - playerMP.getNextWindowId(); - int window = playerMP.currentWindowId; - - if(t == OredictionificatorGuiPacket.SERVER) - { - Mekanism.packetHandler.sendTo(new OredictionificatorGuiMessage(OredictionificatorGuiPacket.CLIENT, obj, guiType, window, 0), playerMP); - } - else if(t == OredictionificatorGuiPacket.SERVER_INDEX) - { - Mekanism.packetHandler.sendTo(new OredictionificatorGuiMessage(OredictionificatorGuiPacket.CLIENT_INDEX, obj, guiType, window, i), playerMP); - } - - playerMP.openContainer = container; - playerMP.openContainer.windowId = window; - playerMP.openContainer.addCraftingToCrafters(playerMP); - - if(guiType == 0) - { - TileEntityOredictionificator tile = (TileEntityOredictionificator)obj.getTileEntity(world); - - for(EntityPlayer player : tile.playersUsing) - { - Mekanism.packetHandler.sendTo(new TileEntityMessage(obj, tile.getFilterPacket(new ArrayList())), (EntityPlayerMP)player); - } - } - } - - @SideOnly(Side.CLIENT) - public static GuiScreen getGui(OredictionificatorGuiPacket packetType, int type, EntityPlayer player, World world, int x, int y, int z, int index) - { - if(type == 0) - { - return new GuiOredictionificator(player.inventory, (TileEntityOredictionificator)world.getTileEntity(x, y, z)); - } - else { - if(packetType == OredictionificatorGuiPacket.CLIENT) - { - if(type == 1) - { - return new GuiOredictionificatorFilter(player, (TileEntityOredictionificator)world.getTileEntity(x, y, z)); - } - } - else if(packetType == OredictionificatorGuiPacket.CLIENT_INDEX) - { - if(type == 1) - { - return new GuiOredictionificatorFilter(player, (TileEntityOredictionificator)world.getTileEntity(x, y, z), index); - } - } - } - - return null; - } - - @Override - public void toBytes(ByteBuf dataStream) - { - dataStream.writeInt(packetType.ordinal()); - - dataStream.writeInt(coord4D.xCoord); - dataStream.writeInt(coord4D.yCoord); - dataStream.writeInt(coord4D.zCoord); - - dataStream.writeInt(coord4D.dimensionId); - - dataStream.writeInt(guiType); - - if(packetType == OredictionificatorGuiPacket.CLIENT || packetType == OredictionificatorGuiPacket.CLIENT_INDEX) - { - dataStream.writeInt(windowId); - } - - if(packetType == OredictionificatorGuiPacket.SERVER_INDEX || packetType == OredictionificatorGuiPacket.CLIENT_INDEX) - { - dataStream.writeInt(index); - } - } - - @Override - public void fromBytes(ByteBuf dataStream) - { - packetType = OredictionificatorGuiPacket.values()[dataStream.readInt()]; - - coord4D = new Coord4D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt(), dataStream.readInt()); - - guiType = dataStream.readInt(); - - if(packetType == OredictionificatorGuiPacket.CLIENT || packetType == OredictionificatorGuiPacket.CLIENT_INDEX) - { - windowId = dataStream.readInt(); - } - - if(packetType == OredictionificatorGuiPacket.SERVER_INDEX || packetType == OredictionificatorGuiPacket.CLIENT_INDEX) - { - index = dataStream.readInt(); - } - } - } - - public static enum OredictionificatorGuiPacket - { - SERVER, CLIENT, SERVER_INDEX, CLIENT_INDEX - } + if (worldServer != null + && message.coord4D.getTileEntity(worldServer) + instanceof TileEntityOredictionificator) { + OredictionificatorGuiMessage.openServerGui( + message.packetType, + message.guiType, + worldServer, + (EntityPlayerMP) player, + message.coord4D, + message.index + ); + } + } else { + if (message.coord4D.getTileEntity(player.worldObj) + instanceof TileEntityOredictionificator) { + try { + if (message.packetType == OredictionificatorGuiPacket.CLIENT) { + FMLCommonHandler.instance().showGuiScreen( + OredictionificatorGuiMessage.getGui( + message.packetType, + message.guiType, + player, + player.worldObj, + message.coord4D.xCoord, + message.coord4D.yCoord, + message.coord4D.zCoord, + -1 + ) + ); + } else if (message.packetType == OredictionificatorGuiPacket.CLIENT_INDEX) { + FMLCommonHandler.instance().showGuiScreen( + OredictionificatorGuiMessage.getGui( + message.packetType, + message.guiType, + player, + player.worldObj, + message.coord4D.xCoord, + message.coord4D.yCoord, + message.coord4D.zCoord, + message.index + ) + ); + } + + player.openContainer.windowId = message.windowId; + } catch (Exception e) { + e.printStackTrace(); + } + } + } + + return null; + } + + public static class OredictionificatorGuiMessage implements IMessage { + public Coord4D coord4D; + + public OredictionificatorGuiPacket packetType; + + public int guiType; + + public int windowId = -1; + + public int index = -1; + + public OredictionificatorGuiMessage() {} + + public OredictionificatorGuiMessage( + OredictionificatorGuiPacket type, + Coord4D coord, + int guiID, + int extra, + int extra2 + ) { + packetType = type; + + coord4D = coord; + guiType = guiID; + + if (packetType == OredictionificatorGuiPacket.CLIENT) { + windowId = extra; + } else if (packetType == OredictionificatorGuiPacket.SERVER_INDEX) { + index = extra; + } else if (packetType == OredictionificatorGuiPacket.CLIENT_INDEX) { + windowId = extra; + index = extra2; + } + } + + public static void openServerGui( + OredictionificatorGuiPacket t, + int guiType, + World world, + EntityPlayerMP playerMP, + Coord4D obj, + int i + ) { + Container container = null; + + playerMP.closeContainer(); + + if (guiType == 0) { + container = new ContainerOredictionificator( + playerMP.inventory, + (TileEntityOredictionificator) obj.getTileEntity(world) + ); + } else if (guiType == 1) { + container = new ContainerFilter( + playerMP.inventory, + (TileEntityContainerBlock) obj.getTileEntity(world) + ); + } + + playerMP.getNextWindowId(); + int window = playerMP.currentWindowId; + + if (t == OredictionificatorGuiPacket.SERVER) { + Mekanism.packetHandler.sendTo( + new OredictionificatorGuiMessage( + OredictionificatorGuiPacket.CLIENT, obj, guiType, window, 0 + ), + playerMP + ); + } else if (t == OredictionificatorGuiPacket.SERVER_INDEX) { + Mekanism.packetHandler.sendTo( + new OredictionificatorGuiMessage( + OredictionificatorGuiPacket.CLIENT_INDEX, obj, guiType, window, i + ), + playerMP + ); + } + + playerMP.openContainer = container; + playerMP.openContainer.windowId = window; + playerMP.openContainer.addCraftingToCrafters(playerMP); + + if (guiType == 0) { + TileEntityOredictionificator tile + = (TileEntityOredictionificator) obj.getTileEntity(world); + + for (EntityPlayer player : tile.playersUsing) { + Mekanism.packetHandler.sendTo( + new TileEntityMessage(obj, tile.getFilterPacket(new ArrayList())), + (EntityPlayerMP) player + ); + } + } + } + + @SideOnly(Side.CLIENT) + public static GuiScreen getGui( + OredictionificatorGuiPacket packetType, + int type, + EntityPlayer player, + World world, + int x, + int y, + int z, + int index + ) { + if (type == 0) { + return new GuiOredictionificator( + player.inventory, + (TileEntityOredictionificator) world.getTileEntity(x, y, z) + ); + } else { + if (packetType == OredictionificatorGuiPacket.CLIENT) { + if (type == 1) { + return new GuiOredictionificatorFilter( + player, + (TileEntityOredictionificator) world.getTileEntity(x, y, z) + ); + } + } else if (packetType == OredictionificatorGuiPacket.CLIENT_INDEX) { + if (type == 1) { + return new GuiOredictionificatorFilter( + player, + (TileEntityOredictionificator) world.getTileEntity(x, y, z), + index + ); + } + } + } + + return null; + } + + @Override + public void toBytes(ByteBuf dataStream) { + dataStream.writeInt(packetType.ordinal()); + + dataStream.writeInt(coord4D.xCoord); + dataStream.writeInt(coord4D.yCoord); + dataStream.writeInt(coord4D.zCoord); + + dataStream.writeInt(coord4D.dimensionId); + + dataStream.writeInt(guiType); + + if (packetType == OredictionificatorGuiPacket.CLIENT + || packetType == OredictionificatorGuiPacket.CLIENT_INDEX) { + dataStream.writeInt(windowId); + } + + if (packetType == OredictionificatorGuiPacket.SERVER_INDEX + || packetType == OredictionificatorGuiPacket.CLIENT_INDEX) { + dataStream.writeInt(index); + } + } + + @Override + public void fromBytes(ByteBuf dataStream) { + packetType = OredictionificatorGuiPacket.values()[dataStream.readInt()]; + + coord4D = new Coord4D( + dataStream.readInt(), + dataStream.readInt(), + dataStream.readInt(), + dataStream.readInt() + ); + + guiType = dataStream.readInt(); + + if (packetType == OredictionificatorGuiPacket.CLIENT + || packetType == OredictionificatorGuiPacket.CLIENT_INDEX) { + windowId = dataStream.readInt(); + } + + if (packetType == OredictionificatorGuiPacket.SERVER_INDEX + || packetType == OredictionificatorGuiPacket.CLIENT_INDEX) { + index = dataStream.readInt(); + } + } + } + + public static enum OredictionificatorGuiPacket { + SERVER, + CLIENT, + SERVER_INDEX, + CLIENT_INDEX + } } diff --git a/src/main/java/mekanism/common/network/PacketPersonalChest.java b/src/main/java/mekanism/common/network/PacketPersonalChest.java index e75b01862..4a6699156 100644 --- a/src/main/java/mekanism/common/network/PacketPersonalChest.java +++ b/src/main/java/mekanism/common/network/PacketPersonalChest.java @@ -1,5 +1,8 @@ package mekanism.common.network; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.common.Mekanism; @@ -12,166 +15,157 @@ import mekanism.common.util.MekanismUtils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -public class PacketPersonalChest implements IMessageHandler -{ - @Override - public IMessage onMessage(PersonalChestMessage message, MessageContext context) - { - EntityPlayer player = PacketHandler.getPlayer(context); - - if(message.packetType == PersonalChestPacketType.SERVER_OPEN) - { - try { - if(message.isBlock) - { - TileEntityPersonalChest tileEntity = (TileEntityPersonalChest)message.coord4D.getTileEntity(player.worldObj); - MekanismUtils.openPersonalChestGui((EntityPlayerMP)player, tileEntity, null, true); - } - else { - ItemStack stack = player.getCurrentEquippedItem(); +public class PacketPersonalChest + implements IMessageHandler { + @Override + public IMessage onMessage(PersonalChestMessage message, MessageContext context) { + EntityPlayer player = PacketHandler.getPlayer(context); - if(MachineType.get(stack) == MachineType.PERSONAL_CHEST) - { - InventoryPersonalChest inventory = new InventoryPersonalChest(player); - MekanismUtils.openPersonalChestGui((EntityPlayerMP)player, null, inventory, false); - } - } - } catch(Exception e) { - Mekanism.logger.error("Error while handling electric chest open packet."); - e.printStackTrace(); - } - } - else if(message.packetType == PersonalChestPacketType.CLIENT_OPEN) - { - try { - int x = message.coord4D != null ? message.coord4D.xCoord : 0; - int y = message.coord4D != null ? message.coord4D.yCoord : 0; - int z = message.coord4D != null ? message.coord4D.zCoord : 0; + if (message.packetType == PersonalChestPacketType.SERVER_OPEN) { + try { + if (message.isBlock) { + TileEntityPersonalChest tileEntity = (TileEntityPersonalChest + ) message.coord4D.getTileEntity(player.worldObj); + MekanismUtils.openPersonalChestGui( + (EntityPlayerMP) player, tileEntity, null, true + ); + } else { + ItemStack stack = player.getCurrentEquippedItem(); - Mekanism.proxy.openPersonalChest(player, message.guiType, message.windowId, message.isBlock, x, y, z); - } catch(Exception e) { - Mekanism.logger.error("Error while handling electric chest open packet."); - e.printStackTrace(); - } - } - - return null; - } - - public static class PersonalChestMessage implements IMessage - { - public PersonalChestPacketType packetType; - - public boolean isBlock; - - public int guiType; - public int windowId; - - public Coord4D coord4D; - - public PersonalChestMessage() {} - - //This is a really messy implementation... - public PersonalChestMessage(PersonalChestPacketType type, boolean b1, int i1, int i2, Coord4D c1) - { - packetType = type; - - switch(packetType) - { - case CLIENT_OPEN: - guiType = i1; - windowId = i2; - isBlock = b1; - - if(isBlock) - { - coord4D = c1; - } - - break; - case SERVER_OPEN: - isBlock = b1; - - if(isBlock) - { - coord4D = c1; - } - - break; - } - } - - @Override - public void toBytes(ByteBuf dataStream) - { - dataStream.writeInt(packetType.ordinal()); - - switch(packetType) - { - case CLIENT_OPEN: - dataStream.writeInt(guiType); - dataStream.writeInt(windowId); - dataStream.writeBoolean(isBlock); - - if(isBlock) - { - dataStream.writeInt(coord4D.xCoord); - dataStream.writeInt(coord4D.yCoord); - dataStream.writeInt(coord4D.zCoord); - dataStream.writeInt(coord4D.dimensionId); - } - - break; - case SERVER_OPEN: - dataStream.writeBoolean(isBlock); - - if(isBlock) - { - dataStream.writeInt(coord4D.xCoord); - dataStream.writeInt(coord4D.yCoord); - dataStream.writeInt(coord4D.zCoord); - dataStream.writeInt(coord4D.dimensionId); - } - - break; - } - } - - @Override - public void fromBytes(ByteBuf dataStream) - { - packetType = PersonalChestPacketType.values()[dataStream.readInt()]; - - if(packetType == PersonalChestPacketType.SERVER_OPEN) - { - isBlock = dataStream.readBoolean(); + if (MachineType.get(stack) == MachineType.PERSONAL_CHEST) { + InventoryPersonalChest inventory + = new InventoryPersonalChest(player); + MekanismUtils.openPersonalChestGui( + (EntityPlayerMP) player, null, inventory, false + ); + } + } + } catch (Exception e) { + Mekanism.logger.error("Error while handling electric chest open packet."); + e.printStackTrace(); + } + } else if (message.packetType == PersonalChestPacketType.CLIENT_OPEN) { + try { + int x = message.coord4D != null ? message.coord4D.xCoord : 0; + int y = message.coord4D != null ? message.coord4D.yCoord : 0; + int z = message.coord4D != null ? message.coord4D.zCoord : 0; - if(isBlock) - { - coord4D = new Coord4D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt(), dataStream.readInt()); - } - } - else if(packetType == PersonalChestPacketType.CLIENT_OPEN) - { - guiType = dataStream.readInt(); - windowId = dataStream.readInt(); - isBlock = dataStream.readBoolean(); + Mekanism.proxy.openPersonalChest( + player, message.guiType, message.windowId, message.isBlock, x, y, z + ); + } catch (Exception e) { + Mekanism.logger.error("Error while handling electric chest open packet."); + e.printStackTrace(); + } + } - if(isBlock) - { - coord4D = new Coord4D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt(), dataStream.readInt()); - } - } - } - } - - public static enum PersonalChestPacketType - { - CLIENT_OPEN, - SERVER_OPEN - } + return null; + } + + public static class PersonalChestMessage implements IMessage { + public PersonalChestPacketType packetType; + + public boolean isBlock; + + public int guiType; + public int windowId; + + public Coord4D coord4D; + + public PersonalChestMessage() {} + + //This is a really messy implementation... + public PersonalChestMessage( + PersonalChestPacketType type, boolean b1, int i1, int i2, Coord4D c1 + ) { + packetType = type; + + switch (packetType) { + case CLIENT_OPEN: + guiType = i1; + windowId = i2; + isBlock = b1; + + if (isBlock) { + coord4D = c1; + } + + break; + case SERVER_OPEN: + isBlock = b1; + + if (isBlock) { + coord4D = c1; + } + + break; + } + } + + @Override + public void toBytes(ByteBuf dataStream) { + dataStream.writeInt(packetType.ordinal()); + + switch (packetType) { + case CLIENT_OPEN: + dataStream.writeInt(guiType); + dataStream.writeInt(windowId); + dataStream.writeBoolean(isBlock); + + if (isBlock) { + dataStream.writeInt(coord4D.xCoord); + dataStream.writeInt(coord4D.yCoord); + dataStream.writeInt(coord4D.zCoord); + dataStream.writeInt(coord4D.dimensionId); + } + + break; + case SERVER_OPEN: + dataStream.writeBoolean(isBlock); + + if (isBlock) { + dataStream.writeInt(coord4D.xCoord); + dataStream.writeInt(coord4D.yCoord); + dataStream.writeInt(coord4D.zCoord); + dataStream.writeInt(coord4D.dimensionId); + } + + break; + } + } + + @Override + public void fromBytes(ByteBuf dataStream) { + packetType = PersonalChestPacketType.values()[dataStream.readInt()]; + + if (packetType == PersonalChestPacketType.SERVER_OPEN) { + isBlock = dataStream.readBoolean(); + + if (isBlock) { + coord4D = new Coord4D( + dataStream.readInt(), + dataStream.readInt(), + dataStream.readInt(), + dataStream.readInt() + ); + } + } else if (packetType == PersonalChestPacketType.CLIENT_OPEN) { + guiType = dataStream.readInt(); + windowId = dataStream.readInt(); + isBlock = dataStream.readBoolean(); + + if (isBlock) { + coord4D = new Coord4D( + dataStream.readInt(), + dataStream.readInt(), + dataStream.readInt(), + dataStream.readInt() + ); + } + } + } + } + + public static enum PersonalChestPacketType { CLIENT_OPEN, SERVER_OPEN } } diff --git a/src/main/java/mekanism/common/network/PacketPortableTankState.java b/src/main/java/mekanism/common/network/PacketPortableTankState.java index c04a30158..e13644254 100644 --- a/src/main/java/mekanism/common/network/PacketPortableTankState.java +++ b/src/main/java/mekanism/common/network/PacketPortableTankState.java @@ -1,50 +1,45 @@ package mekanism.common.network; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; import mekanism.common.PacketHandler; import mekanism.common.item.ItemBlockMachine; import mekanism.common.network.PacketPortableTankState.PortableTankStateMessage; import net.minecraft.item.ItemStack; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -public class PacketPortableTankState implements IMessageHandler -{ - @Override - public IMessage onMessage(PortableTankStateMessage message, MessageContext context) - { - ItemStack itemstack = PacketHandler.getPlayer(context).getCurrentEquippedItem(); - - if(itemstack != null && itemstack.getItem() instanceof ItemBlockMachine) - { - ((ItemBlockMachine)itemstack.getItem()).setBucketMode(itemstack, message.bucketMode); - } - - return null; - } - - public static class PortableTankStateMessage implements IMessage - { - public boolean bucketMode; - - public PortableTankStateMessage() {} - - public PortableTankStateMessage(boolean state) - { - bucketMode = state; - } - - @Override - public void toBytes(ByteBuf dataStream) - { - dataStream.writeBoolean(bucketMode); - } - - @Override - public void fromBytes(ByteBuf dataStream) - { - bucketMode = dataStream.readBoolean(); - } - } +public class PacketPortableTankState + implements IMessageHandler { + @Override + public IMessage onMessage(PortableTankStateMessage message, MessageContext context) { + ItemStack itemstack = PacketHandler.getPlayer(context).getCurrentEquippedItem(); + + if (itemstack != null && itemstack.getItem() instanceof ItemBlockMachine) { + ((ItemBlockMachine) itemstack.getItem()) + .setBucketMode(itemstack, message.bucketMode); + } + + return null; + } + + public static class PortableTankStateMessage implements IMessage { + public boolean bucketMode; + + public PortableTankStateMessage() {} + + public PortableTankStateMessage(boolean state) { + bucketMode = state; + } + + @Override + public void toBytes(ByteBuf dataStream) { + dataStream.writeBoolean(bucketMode); + } + + @Override + public void fromBytes(ByteBuf dataStream) { + bucketMode = dataStream.readBoolean(); + } + } } \ No newline at end of file diff --git a/src/main/java/mekanism/common/network/PacketPortableTeleporter.java b/src/main/java/mekanism/common/network/PacketPortableTeleporter.java index 3b7330303..c5e68cf67 100644 --- a/src/main/java/mekanism/common/network/PacketPortableTeleporter.java +++ b/src/main/java/mekanism/common/network/PacketPortableTeleporter.java @@ -1,12 +1,15 @@ package mekanism.common.network; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.Range4D; import mekanism.common.Mekanism; @@ -26,12 +29,9 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.network.NetHandlerPlayServer; import net.minecraft.world.World; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -public class PacketPortableTeleporter implements IMessageHandler { +public class PacketPortableTeleporter + implements IMessageHandler { @Override public IMessage onMessage(PortableTeleporterMessage message, MessageContext context) { EntityPlayer player = PacketHandler.getPlayer(context); @@ -49,7 +49,9 @@ public class PacketPortableTeleporter implements IMessageHandler publicFreqs = new ArrayList(); - for (Frequency f : getManager(ISecurityTile.SecurityMode.PUBLIC, null, world).getFrequencies()) { + for (Frequency f : getManager(ISecurityTile.SecurityMode.PUBLIC, null, world) + .getFrequencies()) { publicFreqs.add(f); } List privateFreqs = new ArrayList(); - for (Frequency f : getManager(ISecurityTile.SecurityMode.PRIVATE, player.getCommandSenderName(), world).getFrequencies()) { + for (Frequency f : + getManager( + ISecurityTile.SecurityMode.PRIVATE, player.getCommandSenderName(), world + ) + .getFrequencies()) { privateFreqs.add(f); } @@ -147,20 +191,29 @@ public class PacketPortableTeleporter implements IMessageHandler privateCache = new ArrayList(); public List protectedCache = new ArrayList(); - public PortableTeleporterMessage() { - } + public PortableTeleporterMessage() {} - public PortableTeleporterMessage(PortableTeleporterPacketType type, Frequency freq) { + public PortableTeleporterMessage( + PortableTeleporterPacketType type, Frequency freq + ) { packetType = type; if (type == PortableTeleporterPacketType.DATA_REQUEST) { @@ -260,7 +323,13 @@ public class PacketPortableTeleporter implements IMessageHandler publicFreqs, List privateFreqs, List protectedFreqs) { + public PortableTeleporterMessage( + Frequency freq, + byte b, + List publicFreqs, + List privateFreqs, + List protectedFreqs + ) { packetType = PortableTeleporterPacketType.DATA_RESPONSE; frequency = freq; @@ -332,11 +401,15 @@ public class PacketPortableTeleporter implements IMessageHandler -{ - @Override - public IMessage onMessage(PortalFXMessage message, MessageContext context) - { - EntityPlayer player = PacketHandler.getPlayer(context); - - Random random = new Random(); +public class PacketPortalFX implements IMessageHandler { + @Override + public IMessage onMessage(PortalFXMessage message, MessageContext context) { + EntityPlayer player = PacketHandler.getPlayer(context); - for(int i = 0; i < 50; i++) - { - player.worldObj.spawnParticle("portal", message.coord4D.xCoord + random.nextFloat(), message.coord4D.yCoord + random.nextFloat(), message.coord4D.zCoord + random.nextFloat(), 0.0F, 0.0F, 0.0F); - player.worldObj.spawnParticle("portal", message.coord4D.xCoord + random.nextFloat(), message.coord4D.yCoord + 1 + random.nextFloat(), message.coord4D.zCoord + random.nextFloat(), 0.0F, 0.0F, 0.0F); - } - - return null; - } - - public static class PortalFXMessage implements IMessage - { - public Coord4D coord4D; - - public PortalFXMessage() {} - - public PortalFXMessage(Coord4D coord) - { - coord4D = coord; - } - - @Override - public void toBytes(ByteBuf dataStream) - { - dataStream.writeInt(coord4D.xCoord); - dataStream.writeInt(coord4D.yCoord); - dataStream.writeInt(coord4D.zCoord); - dataStream.writeInt(coord4D.dimensionId); - } - - @Override - public void fromBytes(ByteBuf dataStream) - { - coord4D = new Coord4D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt(), dataStream.readInt()); - } - } + Random random = new Random(); + + for (int i = 0; i < 50; i++) { + player.worldObj.spawnParticle( + "portal", + message.coord4D.xCoord + random.nextFloat(), + message.coord4D.yCoord + random.nextFloat(), + message.coord4D.zCoord + random.nextFloat(), + 0.0F, + 0.0F, + 0.0F + ); + player.worldObj.spawnParticle( + "portal", + message.coord4D.xCoord + random.nextFloat(), + message.coord4D.yCoord + 1 + random.nextFloat(), + message.coord4D.zCoord + random.nextFloat(), + 0.0F, + 0.0F, + 0.0F + ); + } + + return null; + } + + public static class PortalFXMessage implements IMessage { + public Coord4D coord4D; + + public PortalFXMessage() {} + + public PortalFXMessage(Coord4D coord) { + coord4D = coord; + } + + @Override + public void toBytes(ByteBuf dataStream) { + dataStream.writeInt(coord4D.xCoord); + dataStream.writeInt(coord4D.yCoord); + dataStream.writeInt(coord4D.zCoord); + dataStream.writeInt(coord4D.dimensionId); + } + + @Override + public void fromBytes(ByteBuf dataStream) { + coord4D = new Coord4D( + dataStream.readInt(), + dataStream.readInt(), + dataStream.readInt(), + dataStream.readInt() + ); + } + } } diff --git a/src/main/java/mekanism/common/network/PacketRedstoneControl.java b/src/main/java/mekanism/common/network/PacketRedstoneControl.java index 358bafb58..408e47ab8 100644 --- a/src/main/java/mekanism/common/network/PacketRedstoneControl.java +++ b/src/main/java/mekanism/common/network/PacketRedstoneControl.java @@ -1,5 +1,8 @@ package mekanism.common.network; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.common.PacketHandler; @@ -8,55 +11,46 @@ import mekanism.common.base.IRedstoneControl.RedstoneControl; import mekanism.common.network.PacketRedstoneControl.RedstoneControlMessage; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -public class PacketRedstoneControl implements IMessageHandler -{ - @Override - public IMessage onMessage(RedstoneControlMessage message, MessageContext context) - { - EntityPlayer player = PacketHandler.getPlayer(context); - TileEntity tileEntity = message.coord4D.getTileEntity(player.worldObj); - - if(tileEntity instanceof IRedstoneControl) - { - ((IRedstoneControl)tileEntity).setControlType(message.value); - } - - return null; - } - - public static class RedstoneControlMessage implements IMessage - { - public Coord4D coord4D; - public RedstoneControl value; - - public RedstoneControlMessage() {} - - public RedstoneControlMessage(Coord4D coord, RedstoneControl control) - { - coord4D = coord; - value = control; - } - - @Override - public void toBytes(ByteBuf dataStream) - { - dataStream.writeInt(coord4D.xCoord); - dataStream.writeInt(coord4D.yCoord); - dataStream.writeInt(coord4D.zCoord); - dataStream.writeInt(coord4D.dimensionId); - - dataStream.writeInt(value.ordinal()); - } - - @Override - public void fromBytes(ByteBuf dataStream) - { - coord4D = Coord4D.read(dataStream); - value = RedstoneControl.values()[dataStream.readInt()]; - } - } +public class PacketRedstoneControl + implements IMessageHandler { + @Override + public IMessage onMessage(RedstoneControlMessage message, MessageContext context) { + EntityPlayer player = PacketHandler.getPlayer(context); + TileEntity tileEntity = message.coord4D.getTileEntity(player.worldObj); + + if (tileEntity instanceof IRedstoneControl) { + ((IRedstoneControl) tileEntity).setControlType(message.value); + } + + return null; + } + + public static class RedstoneControlMessage implements IMessage { + public Coord4D coord4D; + public RedstoneControl value; + + public RedstoneControlMessage() {} + + public RedstoneControlMessage(Coord4D coord, RedstoneControl control) { + coord4D = coord; + value = control; + } + + @Override + public void toBytes(ByteBuf dataStream) { + dataStream.writeInt(coord4D.xCoord); + dataStream.writeInt(coord4D.yCoord); + dataStream.writeInt(coord4D.zCoord); + dataStream.writeInt(coord4D.dimensionId); + + dataStream.writeInt(value.ordinal()); + } + + @Override + public void fromBytes(ByteBuf dataStream) { + coord4D = Coord4D.read(dataStream); + value = RedstoneControl.values()[dataStream.readInt()]; + } + } } diff --git a/src/main/java/mekanism/common/network/PacketRemoveUpgrade.java b/src/main/java/mekanism/common/network/PacketRemoveUpgrade.java index ce9181960..9c978ad8f 100644 --- a/src/main/java/mekanism/common/network/PacketRemoveUpgrade.java +++ b/src/main/java/mekanism/common/network/PacketRemoveUpgrade.java @@ -1,5 +1,8 @@ package mekanism.common.network; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.common.PacketHandler; @@ -9,66 +12,61 @@ import mekanism.common.network.PacketRemoveUpgrade.RemoveUpgradeMessage; import mekanism.common.tile.TileEntityBasicBlock; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -public class PacketRemoveUpgrade implements IMessageHandler -{ - @Override - public IMessage onMessage(RemoveUpgradeMessage message, MessageContext context) - { - EntityPlayer player = PacketHandler.getPlayer(context); - TileEntity tileEntity = message.coord4D.getTileEntity(player.worldObj); - - if(tileEntity instanceof IUpgradeTile && tileEntity instanceof TileEntityBasicBlock) - { - IUpgradeTile upgradeTile = (IUpgradeTile)tileEntity; - Upgrade upgrade = Upgrade.values()[message.upgradeType]; +public class PacketRemoveUpgrade + implements IMessageHandler { + @Override + public IMessage onMessage(RemoveUpgradeMessage message, MessageContext context) { + EntityPlayer player = PacketHandler.getPlayer(context); + TileEntity tileEntity = message.coord4D.getTileEntity(player.worldObj); - if(upgradeTile.getComponent().getUpgrades(upgrade) > 0) - { - if(player.inventory.addItemStackToInventory(upgrade.getStack())) - { - upgradeTile.getComponent().removeUpgrade(upgrade); - } - } - } - - return null; - } - - public static class RemoveUpgradeMessage implements IMessage - { - public Coord4D coord4D; - - public int upgradeType; - - public RemoveUpgradeMessage() {} - - public RemoveUpgradeMessage(Coord4D coord, int type) - { - coord4D = coord; - upgradeType = type; - } - - @Override - public void toBytes(ByteBuf dataStream) - { - dataStream.writeInt(coord4D.xCoord); - dataStream.writeInt(coord4D.yCoord); - dataStream.writeInt(coord4D.zCoord); - dataStream.writeInt(coord4D.dimensionId); - - dataStream.writeInt(upgradeType); - } - - @Override - public void fromBytes(ByteBuf dataStream) - { - coord4D = new Coord4D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt(), dataStream.readInt()); - - upgradeType = dataStream.readInt(); - } - } + if (tileEntity instanceof IUpgradeTile + && tileEntity instanceof TileEntityBasicBlock) { + IUpgradeTile upgradeTile = (IUpgradeTile) tileEntity; + Upgrade upgrade = Upgrade.values()[message.upgradeType]; + + if (upgradeTile.getComponent().getUpgrades(upgrade) > 0) { + if (player.inventory.addItemStackToInventory(upgrade.getStack())) { + upgradeTile.getComponent().removeUpgrade(upgrade); + } + } + } + + return null; + } + + public static class RemoveUpgradeMessage implements IMessage { + public Coord4D coord4D; + + public int upgradeType; + + public RemoveUpgradeMessage() {} + + public RemoveUpgradeMessage(Coord4D coord, int type) { + coord4D = coord; + upgradeType = type; + } + + @Override + public void toBytes(ByteBuf dataStream) { + dataStream.writeInt(coord4D.xCoord); + dataStream.writeInt(coord4D.yCoord); + dataStream.writeInt(coord4D.zCoord); + dataStream.writeInt(coord4D.dimensionId); + + dataStream.writeInt(upgradeType); + } + + @Override + public void fromBytes(ByteBuf dataStream) { + coord4D = new Coord4D( + dataStream.readInt(), + dataStream.readInt(), + dataStream.readInt(), + dataStream.readInt() + ); + + upgradeType = dataStream.readInt(); + } + } } diff --git a/src/main/java/mekanism/common/network/PacketRobit.java b/src/main/java/mekanism/common/network/PacketRobit.java index bf5069455..8f6acfc05 100644 --- a/src/main/java/mekanism/common/network/PacketRobit.java +++ b/src/main/java/mekanism/common/network/PacketRobit.java @@ -1,185 +1,159 @@ package mekanism.common.network; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; import mekanism.common.Mekanism; import mekanism.common.PacketHandler; import mekanism.common.entity.EntityRobit; import mekanism.common.network.PacketRobit.RobitMessage; import net.minecraft.entity.player.EntityPlayer; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -public class PacketRobit implements IMessageHandler -{ - @Override - public IMessage onMessage(RobitMessage message, MessageContext context) - { - EntityPlayer player = PacketHandler.getPlayer(context); - - if(message.activeType == RobitPacketType.GUI) - { - if(message.guiType == 0) - { - player.openGui(Mekanism.instance, 21, player.worldObj, message.entityId, 0, 0); - } - else if(message.guiType == 1) - { - player.openGui(Mekanism.instance, 22, player.worldObj, message.entityId, 0, 0); - } - else if(message.guiType == 2) - { - player.openGui(Mekanism.instance, 23, player.worldObj, message.entityId, 0, 0); - } - else if(message.guiType == 3) - { - player.openGui(Mekanism.instance, 24, player.worldObj, message.entityId, 0, 0); - } - else if(message.guiType == 4) - { - player.openGui(Mekanism.instance, 25, player.worldObj, message.entityId, 0, 0); - } - } - else if(message.activeType == RobitPacketType.FOLLOW) - { - EntityRobit robit = (EntityRobit)player.worldObj.getEntityByID(message.entityId); +public class PacketRobit implements IMessageHandler { + @Override + public IMessage onMessage(RobitMessage message, MessageContext context) { + EntityPlayer player = PacketHandler.getPlayer(context); - if(robit != null) - { - robit.setFollowing(!robit.getFollowing()); - } - } - else if(message.activeType == RobitPacketType.NAME) - { - EntityRobit robit = (EntityRobit)player.worldObj.getEntityByID(message.entityId); + if (message.activeType == RobitPacketType.GUI) { + if (message.guiType == 0) { + player.openGui( + Mekanism.instance, 21, player.worldObj, message.entityId, 0, 0 + ); + } else if (message.guiType == 1) { + player.openGui( + Mekanism.instance, 22, player.worldObj, message.entityId, 0, 0 + ); + } else if (message.guiType == 2) { + player.openGui( + Mekanism.instance, 23, player.worldObj, message.entityId, 0, 0 + ); + } else if (message.guiType == 3) { + player.openGui( + Mekanism.instance, 24, player.worldObj, message.entityId, 0, 0 + ); + } else if (message.guiType == 4) { + player.openGui( + Mekanism.instance, 25, player.worldObj, message.entityId, 0, 0 + ); + } + } else if (message.activeType == RobitPacketType.FOLLOW) { + EntityRobit robit + = (EntityRobit) player.worldObj.getEntityByID(message.entityId); - if(robit != null) - { - robit.setName(message.name); - } - } - else if(message.activeType == RobitPacketType.GO_HOME) - { - EntityRobit robit = (EntityRobit)player.worldObj.getEntityByID(message.entityId); + if (robit != null) { + robit.setFollowing(!robit.getFollowing()); + } + } else if (message.activeType == RobitPacketType.NAME) { + EntityRobit robit + = (EntityRobit) player.worldObj.getEntityByID(message.entityId); - if(robit != null) - { - robit.goHome(); - } - } - else if(message.activeType == RobitPacketType.DROP_PICKUP) - { - EntityRobit robit = (EntityRobit)player.worldObj.getEntityByID(message.entityId); + if (robit != null) { + robit.setName(message.name); + } + } else if (message.activeType == RobitPacketType.GO_HOME) { + EntityRobit robit + = (EntityRobit) player.worldObj.getEntityByID(message.entityId); - if(robit != null) - { - robit.setDropPickup(!robit.getDropPickup()); - } - } - - return null; - } - - public static class RobitMessage implements IMessage - { - public RobitPacketType activeType; - - public int guiType; - public int entityId; - - public String name; - - public RobitMessage() {} - - public RobitMessage(RobitPacketType type, int i1, int i2, String s) - { - activeType = type; - - switch(activeType) - { - case GUI: - guiType = i1; - entityId = i2; - break; - case FOLLOW: - entityId = i1; - break; - case NAME: - name = s; - entityId = i1; - break; - case GO_HOME: - entityId = i1; - break; - case DROP_PICKUP: - entityId = i1; - break; - } - } - - @Override - public void toBytes(ByteBuf dataStream) - { - dataStream.writeInt(activeType.ordinal()); - - switch(activeType) - { - case GUI: - dataStream.writeInt(guiType); - dataStream.writeInt(entityId); - break; - case FOLLOW: - dataStream.writeInt(entityId); - break; - case NAME: - PacketHandler.writeString(dataStream, name); - dataStream.writeInt(entityId); - break; - case GO_HOME: - dataStream.writeInt(entityId); - break; - case DROP_PICKUP: - dataStream.writeInt(entityId); - break; - } - } - - @Override - public void fromBytes(ByteBuf dataStream) - { - activeType = RobitPacketType.values()[dataStream.readInt()]; - - if(activeType == RobitPacketType.GUI) - { - guiType = dataStream.readInt(); - entityId = dataStream.readInt(); - } - else if(activeType == RobitPacketType.FOLLOW) - { - entityId = dataStream.readInt(); - } - else if(activeType == RobitPacketType.NAME) - { - name = PacketHandler.readString(dataStream); - entityId = dataStream.readInt(); - } - else if(activeType == RobitPacketType.GO_HOME) - { - entityId = dataStream.readInt(); - } - else if(activeType == RobitPacketType.DROP_PICKUP) - { - entityId = dataStream.readInt(); - } - } - } - - public static enum RobitPacketType - { - GUI, - FOLLOW, - NAME, - GO_HOME, - DROP_PICKUP; - } + if (robit != null) { + robit.goHome(); + } + } else if (message.activeType == RobitPacketType.DROP_PICKUP) { + EntityRobit robit + = (EntityRobit) player.worldObj.getEntityByID(message.entityId); + + if (robit != null) { + robit.setDropPickup(!robit.getDropPickup()); + } + } + + return null; + } + + public static class RobitMessage implements IMessage { + public RobitPacketType activeType; + + public int guiType; + public int entityId; + + public String name; + + public RobitMessage() {} + + public RobitMessage(RobitPacketType type, int i1, int i2, String s) { + activeType = type; + + switch (activeType) { + case GUI: + guiType = i1; + entityId = i2; + break; + case FOLLOW: + entityId = i1; + break; + case NAME: + name = s; + entityId = i1; + break; + case GO_HOME: + entityId = i1; + break; + case DROP_PICKUP: + entityId = i1; + break; + } + } + + @Override + public void toBytes(ByteBuf dataStream) { + dataStream.writeInt(activeType.ordinal()); + + switch (activeType) { + case GUI: + dataStream.writeInt(guiType); + dataStream.writeInt(entityId); + break; + case FOLLOW: + dataStream.writeInt(entityId); + break; + case NAME: + PacketHandler.writeString(dataStream, name); + dataStream.writeInt(entityId); + break; + case GO_HOME: + dataStream.writeInt(entityId); + break; + case DROP_PICKUP: + dataStream.writeInt(entityId); + break; + } + } + + @Override + public void fromBytes(ByteBuf dataStream) { + activeType = RobitPacketType.values()[dataStream.readInt()]; + + if (activeType == RobitPacketType.GUI) { + guiType = dataStream.readInt(); + entityId = dataStream.readInt(); + } else if (activeType == RobitPacketType.FOLLOW) { + entityId = dataStream.readInt(); + } else if (activeType == RobitPacketType.NAME) { + name = PacketHandler.readString(dataStream); + entityId = dataStream.readInt(); + } else if (activeType == RobitPacketType.GO_HOME) { + entityId = dataStream.readInt(); + } else if (activeType == RobitPacketType.DROP_PICKUP) { + entityId = dataStream.readInt(); + } + } + } + + public static enum RobitPacketType { + GUI, + FOLLOW, + NAME, + GO_HOME, + DROP_PICKUP; + } } diff --git a/src/main/java/mekanism/common/network/PacketScubaTankData.java b/src/main/java/mekanism/common/network/PacketScubaTankData.java index cf888990b..e6c4eb3be 100644 --- a/src/main/java/mekanism/common/network/PacketScubaTankData.java +++ b/src/main/java/mekanism/common/network/PacketScubaTankData.java @@ -1,5 +1,8 @@ package mekanism.common.network; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; import mekanism.common.Mekanism; import mekanism.common.PacketHandler; @@ -7,117 +10,96 @@ import mekanism.common.item.ItemScubaTank; import mekanism.common.network.PacketScubaTankData.ScubaTankDataMessage; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -public class PacketScubaTankData implements IMessageHandler -{ - @Override - public IMessage onMessage(ScubaTankDataMessage message, MessageContext context) - { - EntityPlayer player = PacketHandler.getPlayer(context); - - if(message.packetType == ScubaTankPacket.UPDATE) - { - if(message.value) - { - Mekanism.gasmaskOn.add(message.username); - } - else { - Mekanism.gasmaskOn.remove(message.username); - } +public class PacketScubaTankData + implements IMessageHandler { + @Override + public IMessage onMessage(ScubaTankDataMessage message, MessageContext context) { + EntityPlayer player = PacketHandler.getPlayer(context); - if(!player.worldObj.isRemote) - { - Mekanism.packetHandler.sendToDimension(new ScubaTankDataMessage(ScubaTankPacket.UPDATE, message.username, message.value), player.worldObj.provider.dimensionId); - } - } - else if(message.packetType == ScubaTankPacket.MODE) - { - ItemStack stack = player.getEquipmentInSlot(3); + if (message.packetType == ScubaTankPacket.UPDATE) { + if (message.value) { + Mekanism.gasmaskOn.add(message.username); + } else { + Mekanism.gasmaskOn.remove(message.username); + } - if(stack != null && stack.getItem() instanceof ItemScubaTank) - { - ((ItemScubaTank)stack.getItem()).toggleFlowing(stack); - } - } - - return null; - } - - public static class ScubaTankDataMessage implements IMessage - { - public ScubaTankPacket packetType; - - public String username; - public boolean value; - - public ScubaTankDataMessage() {} - - public ScubaTankDataMessage(ScubaTankPacket type, String name, boolean state) - { - packetType = type; - - if(packetType == ScubaTankPacket.UPDATE) - { - username = name; - value = state; - } - } - - @Override - public void toBytes(ByteBuf dataStream) - { - dataStream.writeInt(packetType.ordinal()); - - if(packetType == ScubaTankPacket.UPDATE) - { - PacketHandler.writeString(dataStream, username); - dataStream.writeBoolean(value); - } - else if(packetType == ScubaTankPacket.FULL) - { - dataStream.writeInt(Mekanism.gasmaskOn.size()); + if (!player.worldObj.isRemote) { + Mekanism.packetHandler.sendToDimension( + new ScubaTankDataMessage( + ScubaTankPacket.UPDATE, message.username, message.value + ), + player.worldObj.provider.dimensionId + ); + } + } else if (message.packetType == ScubaTankPacket.MODE) { + ItemStack stack = player.getEquipmentInSlot(3); - synchronized(Mekanism.gasmaskOn) - { - for (String name : Mekanism.gasmaskOn) - { - PacketHandler.writeString(dataStream, name); - } - } - } - } - - @Override - public void fromBytes(ByteBuf dataStream) - { - packetType = ScubaTankPacket.values()[dataStream.readInt()]; - - if(packetType == ScubaTankPacket.FULL) - { - Mekanism.gasmaskOn.clear(); - - int amount = dataStream.readInt(); - - for(int i = 0; i < amount; i++) - { - Mekanism.gasmaskOn.add(PacketHandler.readString(dataStream)); - } - } - else if(packetType == ScubaTankPacket.UPDATE) - { - username = PacketHandler.readString(dataStream); - value = dataStream.readBoolean(); - } - } - } - - public static enum ScubaTankPacket - { - UPDATE, - FULL, - MODE; - } + if (stack != null && stack.getItem() instanceof ItemScubaTank) { + ((ItemScubaTank) stack.getItem()).toggleFlowing(stack); + } + } + + return null; + } + + public static class ScubaTankDataMessage implements IMessage { + public ScubaTankPacket packetType; + + public String username; + public boolean value; + + public ScubaTankDataMessage() {} + + public ScubaTankDataMessage(ScubaTankPacket type, String name, boolean state) { + packetType = type; + + if (packetType == ScubaTankPacket.UPDATE) { + username = name; + value = state; + } + } + + @Override + public void toBytes(ByteBuf dataStream) { + dataStream.writeInt(packetType.ordinal()); + + if (packetType == ScubaTankPacket.UPDATE) { + PacketHandler.writeString(dataStream, username); + dataStream.writeBoolean(value); + } else if (packetType == ScubaTankPacket.FULL) { + dataStream.writeInt(Mekanism.gasmaskOn.size()); + + synchronized (Mekanism.gasmaskOn) { + for (String name : Mekanism.gasmaskOn) { + PacketHandler.writeString(dataStream, name); + } + } + } + } + + @Override + public void fromBytes(ByteBuf dataStream) { + packetType = ScubaTankPacket.values()[dataStream.readInt()]; + + if (packetType == ScubaTankPacket.FULL) { + Mekanism.gasmaskOn.clear(); + + int amount = dataStream.readInt(); + + for (int i = 0; i < amount; i++) { + Mekanism.gasmaskOn.add(PacketHandler.readString(dataStream)); + } + } else if (packetType == ScubaTankPacket.UPDATE) { + username = PacketHandler.readString(dataStream); + value = dataStream.readBoolean(); + } + } + } + + public static enum ScubaTankPacket { + UPDATE, + FULL, + MODE; + } } diff --git a/src/main/java/mekanism/common/network/PacketSecurityMode.java b/src/main/java/mekanism/common/network/PacketSecurityMode.java index 0e86dfe89..ed2c8bbad 100644 --- a/src/main/java/mekanism/common/network/PacketSecurityMode.java +++ b/src/main/java/mekanism/common/network/PacketSecurityMode.java @@ -1,5 +1,8 @@ package mekanism.common.network; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.common.PacketHandler; @@ -10,99 +13,79 @@ import mekanism.common.security.ISecurityTile.SecurityMode; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -public class PacketSecurityMode implements IMessageHandler -{ - @Override - public IMessage onMessage(SecurityModeMessage message, MessageContext context) - { - EntityPlayer player = PacketHandler.getPlayer(context); - - if(message.packetType == SecurityPacketType.BLOCK) - { - TileEntity tileEntity = message.coord4D.getTileEntity(player.worldObj); - - if(tileEntity instanceof ISecurityTile) - { - String owner = ((ISecurityTile)tileEntity).getSecurity().getOwner(); - - if(owner != null && player.getCommandSenderName().equals(owner)) - { - ((ISecurityTile)tileEntity).getSecurity().setMode(message.value); - } - } - } - else { - ItemStack stack = player.getCurrentEquippedItem(); - - if(stack.getItem() instanceof ISecurityItem) - { - ((ISecurityItem)stack.getItem()).setSecurity(stack, message.value); - } - } - - return null; - } - - public static class SecurityModeMessage implements IMessage - { - public SecurityPacketType packetType; - public Coord4D coord4D; - public SecurityMode value; - - public SecurityModeMessage() {} - - public SecurityModeMessage(Coord4D coord, SecurityMode control) - { - packetType = SecurityPacketType.BLOCK; - - coord4D = coord; - value = control; - } - - public SecurityModeMessage(SecurityMode control) - { - packetType = SecurityPacketType.ITEM; - - value = control; - } - - @Override - public void toBytes(ByteBuf dataStream) - { - dataStream.writeInt(packetType.ordinal()); - - if(packetType == SecurityPacketType.BLOCK) - { - dataStream.writeInt(coord4D.xCoord); - dataStream.writeInt(coord4D.yCoord); - dataStream.writeInt(coord4D.zCoord); - dataStream.writeInt(coord4D.dimensionId); - } - - dataStream.writeInt(value.ordinal()); - } - - @Override - public void fromBytes(ByteBuf dataStream) - { - packetType = SecurityPacketType.values()[dataStream.readInt()]; - - if(packetType == SecurityPacketType.BLOCK) - { - coord4D = Coord4D.read(dataStream); - } - - value = SecurityMode.values()[dataStream.readInt()]; - } - } - - public static enum SecurityPacketType - { - BLOCK, - ITEM - } +public class PacketSecurityMode + implements IMessageHandler { + @Override + public IMessage onMessage(SecurityModeMessage message, MessageContext context) { + EntityPlayer player = PacketHandler.getPlayer(context); + + if (message.packetType == SecurityPacketType.BLOCK) { + TileEntity tileEntity = message.coord4D.getTileEntity(player.worldObj); + + if (tileEntity instanceof ISecurityTile) { + String owner = ((ISecurityTile) tileEntity).getSecurity().getOwner(); + + if (owner != null && player.getCommandSenderName().equals(owner)) { + ((ISecurityTile) tileEntity).getSecurity().setMode(message.value); + } + } + } else { + ItemStack stack = player.getCurrentEquippedItem(); + + if (stack.getItem() instanceof ISecurityItem) { + ((ISecurityItem) stack.getItem()).setSecurity(stack, message.value); + } + } + + return null; + } + + public static class SecurityModeMessage implements IMessage { + public SecurityPacketType packetType; + public Coord4D coord4D; + public SecurityMode value; + + public SecurityModeMessage() {} + + public SecurityModeMessage(Coord4D coord, SecurityMode control) { + packetType = SecurityPacketType.BLOCK; + + coord4D = coord; + value = control; + } + + public SecurityModeMessage(SecurityMode control) { + packetType = SecurityPacketType.ITEM; + + value = control; + } + + @Override + public void toBytes(ByteBuf dataStream) { + dataStream.writeInt(packetType.ordinal()); + + if (packetType == SecurityPacketType.BLOCK) { + dataStream.writeInt(coord4D.xCoord); + dataStream.writeInt(coord4D.yCoord); + dataStream.writeInt(coord4D.zCoord); + dataStream.writeInt(coord4D.dimensionId); + } + + dataStream.writeInt(value.ordinal()); + } + + @Override + public void fromBytes(ByteBuf dataStream) { + packetType = SecurityPacketType.values()[dataStream.readInt()]; + + if (packetType == SecurityPacketType.BLOCK) { + coord4D = Coord4D.read(dataStream); + } + + value = SecurityMode.values()[dataStream.readInt()]; + } + } + + public static enum SecurityPacketType { BLOCK, ITEM } } diff --git a/src/main/java/mekanism/common/network/PacketSecurityUpdate.java b/src/main/java/mekanism/common/network/PacketSecurityUpdate.java index 60be51188..fc7925b2e 100644 --- a/src/main/java/mekanism/common/network/PacketSecurityUpdate.java +++ b/src/main/java/mekanism/common/network/PacketSecurityUpdate.java @@ -1,10 +1,12 @@ package mekanism.common.network; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.List; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import io.netty.buffer.ByteBuf; import mekanism.client.MekanismClient; import mekanism.common.Mekanism; import mekanism.common.PacketHandler; @@ -12,105 +14,89 @@ import mekanism.common.frequency.Frequency; import mekanism.common.network.PacketSecurityUpdate.SecurityUpdateMessage; import mekanism.common.security.SecurityData; import mekanism.common.security.SecurityFrequency; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -public class PacketSecurityUpdate implements IMessageHandler -{ - @Override - public IMessage onMessage(SecurityUpdateMessage message, MessageContext context) - { - if(message.packetType == SecurityPacket.UPDATE) - { - MekanismClient.clientSecurityMap.put(message.playerUsername, message.securityData); - } - - return null; - } - - public static class SecurityUpdateMessage implements IMessage - { - public SecurityPacket packetType; - - public String playerUsername; - public SecurityData securityData; - - public SecurityUpdateMessage() {} - - public SecurityUpdateMessage(SecurityPacket type, String username, SecurityData data) - { - packetType = type; - - if(packetType == SecurityPacket.UPDATE) - { - playerUsername = username; - securityData = data; - } - } - - @Override - public void toBytes(ByteBuf dataStream) - { - dataStream.writeInt(packetType.ordinal()); - - if(packetType == SecurityPacket.UPDATE) - { - PacketHandler.writeString(dataStream, playerUsername); - securityData.write(dataStream); - } - else if(packetType == SecurityPacket.FULL) - { - List frequencies = new ArrayList(); - - for(Frequency frequency : Mekanism.securityFrequencies.getFrequencies()) - { - if(frequency instanceof SecurityFrequency) - { - frequencies.add((SecurityFrequency)frequency); - } - } - - dataStream.writeInt(frequencies.size()); - - for(SecurityFrequency frequency : frequencies) - { - PacketHandler.writeString(dataStream, frequency.owner); - new SecurityData(frequency).write(dataStream); - } - } - } - - @Override - public void fromBytes(ByteBuf dataStream) - { - packetType = SecurityPacket.values()[dataStream.readInt()]; - - if(packetType == SecurityPacket.UPDATE) - { - playerUsername = PacketHandler.readString(dataStream); - securityData = SecurityData.read(dataStream); - } - else if(packetType == SecurityPacket.FULL) - { - MekanismClient.clientSecurityMap.clear(); - - int amount = dataStream.readInt(); - - for(int i = 0; i < amount; i++) - { - String owner = PacketHandler.readString(dataStream); - SecurityData data = SecurityData.read(dataStream); - - MekanismClient.clientSecurityMap.put(owner, data); - } - } - } - } - - public static enum SecurityPacket - { - UPDATE, - FULL; - } +public class PacketSecurityUpdate + implements IMessageHandler { + @Override + public IMessage onMessage(SecurityUpdateMessage message, MessageContext context) { + if (message.packetType == SecurityPacket.UPDATE) { + MekanismClient.clientSecurityMap.put( + message.playerUsername, message.securityData + ); + } + + return null; + } + + public static class SecurityUpdateMessage implements IMessage { + public SecurityPacket packetType; + + public String playerUsername; + public SecurityData securityData; + + public SecurityUpdateMessage() {} + + public SecurityUpdateMessage( + SecurityPacket type, String username, SecurityData data + ) { + packetType = type; + + if (packetType == SecurityPacket.UPDATE) { + playerUsername = username; + securityData = data; + } + } + + @Override + public void toBytes(ByteBuf dataStream) { + dataStream.writeInt(packetType.ordinal()); + + if (packetType == SecurityPacket.UPDATE) { + PacketHandler.writeString(dataStream, playerUsername); + securityData.write(dataStream); + } else if (packetType == SecurityPacket.FULL) { + List frequencies = new ArrayList(); + + for (Frequency frequency : + Mekanism.securityFrequencies.getFrequencies()) { + if (frequency instanceof SecurityFrequency) { + frequencies.add((SecurityFrequency) frequency); + } + } + + dataStream.writeInt(frequencies.size()); + + for (SecurityFrequency frequency : frequencies) { + PacketHandler.writeString(dataStream, frequency.owner); + new SecurityData(frequency).write(dataStream); + } + } + } + + @Override + public void fromBytes(ByteBuf dataStream) { + packetType = SecurityPacket.values()[dataStream.readInt()]; + + if (packetType == SecurityPacket.UPDATE) { + playerUsername = PacketHandler.readString(dataStream); + securityData = SecurityData.read(dataStream); + } else if (packetType == SecurityPacket.FULL) { + MekanismClient.clientSecurityMap.clear(); + + int amount = dataStream.readInt(); + + for (int i = 0; i < amount; i++) { + String owner = PacketHandler.readString(dataStream); + SecurityData data = SecurityData.read(dataStream); + + MekanismClient.clientSecurityMap.put(owner, data); + } + } + } + } + + public static enum SecurityPacket { + UPDATE, + FULL; + } } diff --git a/src/main/java/mekanism/common/network/PacketSimpleGui.java b/src/main/java/mekanism/common/network/PacketSimpleGui.java index 4d8902f6b..17a420a56 100644 --- a/src/main/java/mekanism/common/network/PacketSimpleGui.java +++ b/src/main/java/mekanism/common/network/PacketSimpleGui.java @@ -1,10 +1,15 @@ package mekanism.common.network; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.List; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.common.Mekanism; import mekanism.common.PacketHandler; @@ -15,111 +20,122 @@ import net.minecraft.client.gui.GuiScreen; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.world.World; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class PacketSimpleGui implements IMessageHandler -{ - public static List handlers = new ArrayList(); - - @Override - public IMessage onMessage(SimpleGuiMessage message, MessageContext context) - { - EntityPlayer player = PacketHandler.getPlayer(context); - - if(!player.worldObj.isRemote) - { - World worldServer = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(message.coord4D.dimensionId); +public class PacketSimpleGui implements IMessageHandler { + public static List handlers = new ArrayList(); - if(worldServer != null && message.coord4D.getTileEntity(worldServer) instanceof TileEntityBasicBlock) - { - if(message.guiId == -1) - { - return null; - } + @Override + public IMessage onMessage(SimpleGuiMessage message, MessageContext context) { + EntityPlayer player = PacketHandler.getPlayer(context); - SimpleGuiMessage.openServerGui(message.guiHandler, message.guiId, (EntityPlayerMP)player, player.worldObj, message.coord4D); - } - } - else { - FMLCommonHandler.instance().showGuiScreen(SimpleGuiMessage.getGui(message.guiHandler, message.guiId, player, player.worldObj, message.coord4D)); - player.openContainer.windowId = message.windowId; - } - - return null; - } - - public static class SimpleGuiMessage implements IMessage - { - public Coord4D coord4D; - - public int guiHandler; - - public int guiId; - - public int windowId; - - public SimpleGuiMessage() {} - - public SimpleGuiMessage(Coord4D coord, int handler, int gui) - { - coord4D = coord; - guiHandler = handler; - guiId = gui; - } - - public SimpleGuiMessage(Coord4D coord, int handler, int gui, int id) - { - this(coord, handler, gui); - windowId = id; - } - - public static void openServerGui(int handler, int id, EntityPlayerMP playerMP, World world, Coord4D obj) - { - playerMP.closeContainer(); - playerMP.getNextWindowId(); - - int window = playerMP.currentWindowId; - - Mekanism.packetHandler.sendTo(new SimpleGuiMessage(obj, handler, id, window), playerMP); - - playerMP.openContainer = handlers.get(handler).getServerGui(id, playerMP, world, obj.xCoord, obj.yCoord, obj.zCoord); - playerMP.openContainer.windowId = window; - playerMP.openContainer.addCraftingToCrafters(playerMP); - } - - @SideOnly(Side.CLIENT) - public static GuiScreen getGui(int handler, int id, EntityPlayer player, World world, Coord4D obj) - { - return (GuiScreen)handlers.get(handler).getClientGui(id, player, world, obj.xCoord, obj.yCoord, obj.zCoord); - } - - @Override - public void toBytes(ByteBuf dataStream) - { - dataStream.writeInt(coord4D.xCoord); - dataStream.writeInt(coord4D.yCoord); - dataStream.writeInt(coord4D.zCoord); - - dataStream.writeInt(coord4D.dimensionId); - - dataStream.writeInt(guiHandler); - dataStream.writeInt(guiId); - dataStream.writeInt(windowId); - } - - @Override - public void fromBytes(ByteBuf dataStream) - { - coord4D = new Coord4D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt(), dataStream.readInt()); - - guiHandler = dataStream.readInt(); - guiId = dataStream.readInt(); - windowId = dataStream.readInt(); - } - } + if (!player.worldObj.isRemote) { + World worldServer = FMLCommonHandler.instance() + .getMinecraftServerInstance() + .worldServerForDimension(message.coord4D.dimensionId); + + if (worldServer != null + && message.coord4D.getTileEntity(worldServer) + instanceof TileEntityBasicBlock) { + if (message.guiId == -1) { + return null; + } + + SimpleGuiMessage.openServerGui( + message.guiHandler, + message.guiId, + (EntityPlayerMP) player, + player.worldObj, + message.coord4D + ); + } + } else { + FMLCommonHandler.instance().showGuiScreen(SimpleGuiMessage.getGui( + message.guiHandler, + message.guiId, + player, + player.worldObj, + message.coord4D + )); + player.openContainer.windowId = message.windowId; + } + + return null; + } + + public static class SimpleGuiMessage implements IMessage { + public Coord4D coord4D; + + public int guiHandler; + + public int guiId; + + public int windowId; + + public SimpleGuiMessage() {} + + public SimpleGuiMessage(Coord4D coord, int handler, int gui) { + coord4D = coord; + guiHandler = handler; + guiId = gui; + } + + public SimpleGuiMessage(Coord4D coord, int handler, int gui, int id) { + this(coord, handler, gui); + windowId = id; + } + + public static void openServerGui( + int handler, int id, EntityPlayerMP playerMP, World world, Coord4D obj + ) { + playerMP.closeContainer(); + playerMP.getNextWindowId(); + + int window = playerMP.currentWindowId; + + Mekanism.packetHandler.sendTo( + new SimpleGuiMessage(obj, handler, id, window), playerMP + ); + + playerMP.openContainer = handlers.get(handler).getServerGui( + id, playerMP, world, obj.xCoord, obj.yCoord, obj.zCoord + ); + playerMP.openContainer.windowId = window; + playerMP.openContainer.addCraftingToCrafters(playerMP); + } + + @SideOnly(Side.CLIENT) + public static GuiScreen + getGui(int handler, int id, EntityPlayer player, World world, Coord4D obj) { + return (GuiScreen) handlers.get(handler).getClientGui( + id, player, world, obj.xCoord, obj.yCoord, obj.zCoord + ); + } + + @Override + public void toBytes(ByteBuf dataStream) { + dataStream.writeInt(coord4D.xCoord); + dataStream.writeInt(coord4D.yCoord); + dataStream.writeInt(coord4D.zCoord); + + dataStream.writeInt(coord4D.dimensionId); + + dataStream.writeInt(guiHandler); + dataStream.writeInt(guiId); + dataStream.writeInt(windowId); + } + + @Override + public void fromBytes(ByteBuf dataStream) { + coord4D = new Coord4D( + dataStream.readInt(), + dataStream.readInt(), + dataStream.readInt(), + dataStream.readInt() + ); + + guiHandler = dataStream.readInt(); + guiId = dataStream.readInt(); + windowId = dataStream.readInt(); + } + } } diff --git a/src/main/java/mekanism/common/network/PacketTileEntity.java b/src/main/java/mekanism/common/network/PacketTileEntity.java index ea7597acf..ed4310748 100644 --- a/src/main/java/mekanism/common/network/PacketTileEntity.java +++ b/src/main/java/mekanism/common/network/PacketTileEntity.java @@ -1,9 +1,12 @@ package mekanism.common.network; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.common.PacketHandler; import mekanism.common.base.ITileNetwork; @@ -11,73 +14,71 @@ import mekanism.common.network.PacketTileEntity.TileEntityMessage; import net.minecraft.server.MinecraftServer; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -public class PacketTileEntity implements IMessageHandler -{ - @Override - public IMessage onMessage(TileEntityMessage message, MessageContext context) - { - TileEntity tileEntity = message.coord4D.getTileEntity(PacketHandler.getPlayer(context).worldObj); - - if(tileEntity instanceof ITileNetwork) - { - try { - ((ITileNetwork)tileEntity).handlePacketData(message.storedBuffer); - } catch(Exception e) { - e.printStackTrace(); - } - - message.storedBuffer.release(); - } - - return null; - } - - public static class TileEntityMessage implements IMessage - { - public Coord4D coord4D; - - public ArrayList parameters; - - public ByteBuf storedBuffer = null; - - public TileEntityMessage() {} - - public TileEntityMessage(Coord4D coord, ArrayList params) - { - coord4D = coord; - parameters = params; - } - - @Override - public void toBytes(ByteBuf dataStream) - { - dataStream.writeInt(coord4D.xCoord); - dataStream.writeInt(coord4D.yCoord); - dataStream.writeInt(coord4D.zCoord); - dataStream.writeInt(coord4D.dimensionId); - - MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); - - if(server != null) - { - World world = server.worldServerForDimension(coord4D.dimensionId); - PacketHandler.log("Sending TileEntity packet from coordinate " + coord4D + " (" + coord4D.getTileEntity(world) + ")"); - } - - PacketHandler.encode(new Object[] {parameters}, dataStream); - } - - @Override - public void fromBytes(ByteBuf dataStream) - { - coord4D = new Coord4D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt(), dataStream.readInt()); - - storedBuffer = dataStream.copy(); - } - } +public class PacketTileEntity implements IMessageHandler { + @Override + public IMessage onMessage(TileEntityMessage message, MessageContext context) { + TileEntity tileEntity + = message.coord4D.getTileEntity(PacketHandler.getPlayer(context).worldObj); + + if (tileEntity instanceof ITileNetwork) { + try { + ((ITileNetwork) tileEntity).handlePacketData(message.storedBuffer); + } catch (Exception e) { + e.printStackTrace(); + } + + message.storedBuffer.release(); + } + + return null; + } + + public static class TileEntityMessage implements IMessage { + public Coord4D coord4D; + + public ArrayList parameters; + + public ByteBuf storedBuffer = null; + + public TileEntityMessage() {} + + public TileEntityMessage(Coord4D coord, ArrayList params) { + coord4D = coord; + parameters = params; + } + + @Override + public void toBytes(ByteBuf dataStream) { + dataStream.writeInt(coord4D.xCoord); + dataStream.writeInt(coord4D.yCoord); + dataStream.writeInt(coord4D.zCoord); + dataStream.writeInt(coord4D.dimensionId); + + MinecraftServer server + = FMLCommonHandler.instance().getMinecraftServerInstance(); + + if (server != null) { + World world = server.worldServerForDimension(coord4D.dimensionId); + PacketHandler.log( + "Sending TileEntity packet from coordinate " + coord4D + " (" + + coord4D.getTileEntity(world) + ")" + ); + } + + PacketHandler.encode(new Object[] { parameters }, dataStream); + } + + @Override + public void fromBytes(ByteBuf dataStream) { + coord4D = new Coord4D( + dataStream.readInt(), + dataStream.readInt(), + dataStream.readInt(), + dataStream.readInt() + ); + + storedBuffer = dataStream.copy(); + } + } } diff --git a/src/main/java/mekanism/common/network/PacketTransmitterUpdate.java b/src/main/java/mekanism/common/network/PacketTransmitterUpdate.java index 3cd83857b..8ab1450ef 100644 --- a/src/main/java/mekanism/common/network/PacketTransmitterUpdate.java +++ b/src/main/java/mekanism/common/network/PacketTransmitterUpdate.java @@ -1,10 +1,12 @@ package mekanism.common.network; -import io.netty.buffer.ByteBuf; - import java.util.Collection; import java.util.HashSet; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.MekanismConfig.client; import mekanism.api.gas.Gas; @@ -27,256 +29,244 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidHandler; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -public class PacketTransmitterUpdate implements IMessageHandler -{ - @Override - public IMessage onMessage(TransmitterUpdateMessage message, MessageContext context) - { - EntityPlayer player = PacketHandler.getPlayer(context); - - if(message.packetType == PacketType.UPDATE) - { - TileEntity tileEntity = message.coord4D.getTileEntity(player.worldObj); +public class PacketTransmitterUpdate + implements IMessageHandler { + @Override + public IMessage onMessage(TransmitterUpdateMessage message, MessageContext context) { + EntityPlayer player = PacketHandler.getPlayer(context); - if(tileEntity instanceof ITransmitterTile) - { - IGridTransmitter transmitter = ((ITransmitterTile)tileEntity).getTransmitter(); - DynamicNetwork network = transmitter.hasTransmitterNetwork() && !message.newNetwork ? transmitter.getTransmitterNetwork() : transmitter.createEmptyNetwork(); - network.register(); - transmitter.setTransmitterNetwork(network); - - for(Coord4D coord : message.transmitterCoords) - { - TileEntity tile = coord.getTileEntity(player.worldObj); + if (message.packetType == PacketType.UPDATE) { + TileEntity tileEntity = message.coord4D.getTileEntity(player.worldObj); - if(tile instanceof ITransmitterTile) - { - ((ITransmitterTile)tile).getTransmitter().setTransmitterNetwork(network); - } - } - - network.updateCapacity(); - } - } - - if(client.opaqueTransmitters) - { - return null; - } - - if(message.packetType == PacketType.ENERGY) - { - TileEntity tileEntity = message.coord4D.getTileEntity(player.worldObj); + if (tileEntity instanceof ITransmitterTile) { + IGridTransmitter transmitter + = ((ITransmitterTile) tileEntity).getTransmitter(); + DynamicNetwork network + = transmitter.hasTransmitterNetwork() && !message.newNetwork + ? transmitter.getTransmitterNetwork() + : transmitter.createEmptyNetwork(); + network.register(); + transmitter.setTransmitterNetwork(network); - if(tileEntity instanceof ITransmitterTile) - { - IGridTransmitter transmitter = ((ITransmitterTile)tileEntity).getTransmitter(); - - if(transmitter.hasTransmitterNetwork() && transmitter.getTransmissionType() == TransmissionType.ENERGY) - { - ((IGridTransmitter)transmitter).getTransmitterNetwork().clientEnergyScale = message.power; - } - } - } - else if(message.packetType == PacketType.GAS) - { - TileEntity tileEntity = message.coord4D.getTileEntity(player.worldObj); + for (Coord4D coord : message.transmitterCoords) { + TileEntity tile = coord.getTileEntity(player.worldObj); - if(tileEntity instanceof ITransmitterTile) - { - IGridTransmitter transmitter = ((ITransmitterTile)tileEntity).getTransmitter(); - - if(transmitter.hasTransmitterNetwork() && transmitter.getTransmissionType() == TransmissionType.GAS) - { - GasNetwork net = ((IGridTransmitter)transmitter).getTransmitterNetwork(); + if (tile instanceof ITransmitterTile) { + ((ITransmitterTile) tile) + .getTransmitter() + .setTransmitterNetwork(network); + } + } - if(message.gasType != null) - { - net.refGas = message.gasType; - } + network.updateCapacity(); + } + } - net.buffer = message.gasStack; - net.didTransfer = message.didGasTransfer; - } - } - } - else if(message.packetType == PacketType.FLUID) - { - TileEntity tileEntity = message.coord4D.getTileEntity(player.worldObj); + if (client.opaqueTransmitters) { + return null; + } - if(tileEntity instanceof ITransmitterTile) - { - IGridTransmitter transmitter = ((ITransmitterTile)tileEntity).getTransmitter(); - - if(transmitter.hasTransmitterNetwork() && ((ITransmitterTile)tileEntity).getTransmitter().getTransmissionType() == TransmissionType.FLUID) - { - FluidNetwork net = ((IGridTransmitter)transmitter).getTransmitterNetwork(); + if (message.packetType == PacketType.ENERGY) { + TileEntity tileEntity = message.coord4D.getTileEntity(player.worldObj); - if(message.fluidType != null) - { - net.refFluid = message.fluidType; - } + if (tileEntity instanceof ITransmitterTile) { + IGridTransmitter transmitter + = ((ITransmitterTile) tileEntity).getTransmitter(); - net.buffer = message.fluidStack; - net.didTransfer = message.didFluidTransfer; - } - } - } - - return null; - } - - public static class TransmitterUpdateMessage implements IMessage - { - public PacketType packetType; - - public Coord4D coord4D; - - public double power; - - public GasStack gasStack; - public Gas gasType; - public boolean didGasTransfer; - - public FluidStack fluidStack; - public Fluid fluidType; - public float fluidScale; - public boolean didFluidTransfer; + if (transmitter.hasTransmitterNetwork() + && transmitter.getTransmissionType() == TransmissionType.ENERGY) { + ((IGridTransmitter) transmitter) + .getTransmitterNetwork() + .clientEnergyScale + = message.power; + } + } + } else if (message.packetType == PacketType.GAS) { + TileEntity tileEntity = message.coord4D.getTileEntity(player.worldObj); - public int amount; + if (tileEntity instanceof ITransmitterTile) { + IGridTransmitter transmitter + = ((ITransmitterTile) tileEntity).getTransmitter(); - public boolean newNetwork; - public Collection transmittersAdded; - public Collection transmitterCoords; - - public TransmitterUpdateMessage() {} - - public TransmitterUpdateMessage(PacketType type, Coord4D coord, Object... data) - { - packetType = type; - coord4D = coord; - - switch(packetType) - { - case UPDATE: - newNetwork = (Boolean)data[0]; - transmittersAdded = (Collection)data[1]; - break; - case ENERGY: - power = (Double)data[0]; - break; - case GAS: - gasStack = (GasStack)data[0]; - didGasTransfer = (Boolean)data[1]; - break; - case FLUID: - fluidStack = (FluidStack)data[0]; - didFluidTransfer = (Boolean)data[1]; - break; - default: - break; - } - } - - @Override - public void toBytes(ByteBuf dataStream) - { - dataStream.writeInt(packetType.ordinal()); - - dataStream.writeInt(coord4D.xCoord); - dataStream.writeInt(coord4D.yCoord); - dataStream.writeInt(coord4D.zCoord); - dataStream.writeInt(coord4D.dimensionId); - - PacketHandler.log("Sending '" + packetType + "' update message from coordinate " + coord4D); - - switch(packetType) - { - case UPDATE: - dataStream.writeBoolean(newNetwork); - dataStream.writeInt(transmittersAdded.size()); - - for(IGridTransmitter transmitter : transmittersAdded) - { - transmitter.coord().write(dataStream); - } - - break; - case ENERGY: - dataStream.writeDouble(power); - break; - case GAS: - dataStream.writeInt(gasStack != null ? gasStack.getGas().getID() : -1); - dataStream.writeInt(gasStack != null ? gasStack.amount : 0); - dataStream.writeBoolean(didGasTransfer); - break; - case FLUID: - dataStream.writeInt(fluidStack != null ? fluidStack.getFluid().getID() : -1); - dataStream.writeInt(fluidStack != null ? fluidStack.amount : 0); - dataStream.writeBoolean(didFluidTransfer); - break; - default: - break; - } - } - - @Override - public void fromBytes(ByteBuf dataStream) - { - packetType = PacketType.values()[dataStream.readInt()]; - - coord4D = new Coord4D(dataStream.readInt(), dataStream.readInt(), dataStream.readInt(), dataStream.readInt()); + if (transmitter.hasTransmitterNetwork() + && transmitter.getTransmissionType() == TransmissionType.GAS) { + GasNetwork net + = ((IGridTransmitter) transmitter) + .getTransmitterNetwork(); - if(packetType == PacketType.UPDATE) - { - newNetwork = dataStream.readBoolean(); - transmitterCoords = new HashSet<>(); - int numTransmitters = dataStream.readInt(); + if (message.gasType != null) { + net.refGas = message.gasType; + } - for(int i = 0; i < numTransmitters; i++) - { - transmitterCoords.add(Coord4D.read(dataStream)); - } - } - else if(packetType == PacketType.ENERGY) - { - power = dataStream.readDouble(); - } - else if(packetType == PacketType.GAS) - { - gasType = GasRegistry.getGas(dataStream.readInt()); - amount = dataStream.readInt(); - didGasTransfer = dataStream.readBoolean(); - - if(gasType != null) - { - gasStack = new GasStack(gasType, amount); - } - } - else if(packetType == PacketType.FLUID) - { - int type = dataStream.readInt(); - fluidType = type != -1 ? FluidRegistry.getFluid(type) : null; - amount = dataStream.readInt(); - didFluidTransfer = dataStream.readBoolean(); + net.buffer = message.gasStack; + net.didTransfer = message.didGasTransfer; + } + } + } else if (message.packetType == PacketType.FLUID) { + TileEntity tileEntity = message.coord4D.getTileEntity(player.worldObj); - if(fluidType != null) - { - fluidStack = new FluidStack(fluidType, amount); - } - } - } - } - - public static enum PacketType - { - UPDATE, - ENERGY, - GAS, - FLUID - } + if (tileEntity instanceof ITransmitterTile) { + IGridTransmitter transmitter + = ((ITransmitterTile) tileEntity).getTransmitter(); + + if (transmitter.hasTransmitterNetwork() + && ((ITransmitterTile) tileEntity) + .getTransmitter() + .getTransmissionType() + == TransmissionType.FLUID) { + FluidNetwork net + = ((IGridTransmitter) transmitter) + .getTransmitterNetwork(); + + if (message.fluidType != null) { + net.refFluid = message.fluidType; + } + + net.buffer = message.fluidStack; + net.didTransfer = message.didFluidTransfer; + } + } + } + + return null; + } + + public static class TransmitterUpdateMessage implements IMessage { + public PacketType packetType; + + public Coord4D coord4D; + + public double power; + + public GasStack gasStack; + public Gas gasType; + public boolean didGasTransfer; + + public FluidStack fluidStack; + public Fluid fluidType; + public float fluidScale; + public boolean didFluidTransfer; + + public int amount; + + public boolean newNetwork; + public Collection transmittersAdded; + public Collection transmitterCoords; + + public TransmitterUpdateMessage() {} + + public TransmitterUpdateMessage(PacketType type, Coord4D coord, Object... data) { + packetType = type; + coord4D = coord; + + switch (packetType) { + case UPDATE: + newNetwork = (Boolean) data[0]; + transmittersAdded = (Collection) data[1]; + break; + case ENERGY: + power = (Double) data[0]; + break; + case GAS: + gasStack = (GasStack) data[0]; + didGasTransfer = (Boolean) data[1]; + break; + case FLUID: + fluidStack = (FluidStack) data[0]; + didFluidTransfer = (Boolean) data[1]; + break; + default: + break; + } + } + + @Override + public void toBytes(ByteBuf dataStream) { + dataStream.writeInt(packetType.ordinal()); + + dataStream.writeInt(coord4D.xCoord); + dataStream.writeInt(coord4D.yCoord); + dataStream.writeInt(coord4D.zCoord); + dataStream.writeInt(coord4D.dimensionId); + + PacketHandler.log( + "Sending '" + packetType + "' update message from coordinate " + coord4D + ); + + switch (packetType) { + case UPDATE: + dataStream.writeBoolean(newNetwork); + dataStream.writeInt(transmittersAdded.size()); + + for (IGridTransmitter transmitter : transmittersAdded) { + transmitter.coord().write(dataStream); + } + + break; + case ENERGY: + dataStream.writeDouble(power); + break; + case GAS: + dataStream.writeInt( + gasStack != null ? gasStack.getGas().getID() : -1 + ); + dataStream.writeInt(gasStack != null ? gasStack.amount : 0); + dataStream.writeBoolean(didGasTransfer); + break; + case FLUID: + dataStream.writeInt( + fluidStack != null ? fluidStack.getFluid().getID() : -1 + ); + dataStream.writeInt(fluidStack != null ? fluidStack.amount : 0); + dataStream.writeBoolean(didFluidTransfer); + break; + default: + break; + } + } + + @Override + public void fromBytes(ByteBuf dataStream) { + packetType = PacketType.values()[dataStream.readInt()]; + + coord4D = new Coord4D( + dataStream.readInt(), + dataStream.readInt(), + dataStream.readInt(), + dataStream.readInt() + ); + + if (packetType == PacketType.UPDATE) { + newNetwork = dataStream.readBoolean(); + transmitterCoords = new HashSet<>(); + int numTransmitters = dataStream.readInt(); + + for (int i = 0; i < numTransmitters; i++) { + transmitterCoords.add(Coord4D.read(dataStream)); + } + } else if (packetType == PacketType.ENERGY) { + power = dataStream.readDouble(); + } else if (packetType == PacketType.GAS) { + gasType = GasRegistry.getGas(dataStream.readInt()); + amount = dataStream.readInt(); + didGasTransfer = dataStream.readBoolean(); + + if (gasType != null) { + gasStack = new GasStack(gasType, amount); + } + } else if (packetType == PacketType.FLUID) { + int type = dataStream.readInt(); + fluidType = type != -1 ? FluidRegistry.getFluid(type) : null; + amount = dataStream.readInt(); + didFluidTransfer = dataStream.readBoolean(); + + if (fluidType != null) { + fluidStack = new FluidStack(fluidType, amount); + } + } + } + } + + public static enum PacketType { UPDATE, ENERGY, GAS, FLUID } } \ No newline at end of file diff --git a/src/main/java/mekanism/common/network/PacketWalkieTalkieState.java b/src/main/java/mekanism/common/network/PacketWalkieTalkieState.java index 561ce8b72..8b93bfc48 100644 --- a/src/main/java/mekanism/common/network/PacketWalkieTalkieState.java +++ b/src/main/java/mekanism/common/network/PacketWalkieTalkieState.java @@ -1,50 +1,45 @@ package mekanism.common.network; +import cpw.mods.fml.common.network.simpleimpl.IMessage; +import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; +import cpw.mods.fml.common.network.simpleimpl.MessageContext; import io.netty.buffer.ByteBuf; import mekanism.common.PacketHandler; import mekanism.common.item.ItemWalkieTalkie; import mekanism.common.network.PacketWalkieTalkieState.WalkieTalkieStateMessage; import net.minecraft.item.ItemStack; -import cpw.mods.fml.common.network.simpleimpl.IMessage; -import cpw.mods.fml.common.network.simpleimpl.IMessageHandler; -import cpw.mods.fml.common.network.simpleimpl.MessageContext; -public class PacketWalkieTalkieState implements IMessageHandler -{ - @Override - public IMessage onMessage(WalkieTalkieStateMessage message, MessageContext context) - { - ItemStack itemstack = PacketHandler.getPlayer(context).getCurrentEquippedItem(); - - if(itemstack != null && itemstack.getItem() instanceof ItemWalkieTalkie) - { - ((ItemWalkieTalkie)itemstack.getItem()).setChannel(itemstack, message.channel); - } - - return null; - } - - public static class WalkieTalkieStateMessage implements IMessage - { - public int channel; - - public WalkieTalkieStateMessage() {} - - public WalkieTalkieStateMessage(int chan) - { - channel = chan; - } - - @Override - public void toBytes(ByteBuf dataStream) - { - dataStream.writeInt(channel); - } - - @Override - public void fromBytes(ByteBuf dataStream) - { - channel = dataStream.readInt(); - } - } +public class PacketWalkieTalkieState + implements IMessageHandler { + @Override + public IMessage onMessage(WalkieTalkieStateMessage message, MessageContext context) { + ItemStack itemstack = PacketHandler.getPlayer(context).getCurrentEquippedItem(); + + if (itemstack != null && itemstack.getItem() instanceof ItemWalkieTalkie) { + ((ItemWalkieTalkie) itemstack.getItem()) + .setChannel(itemstack, message.channel); + } + + return null; + } + + public static class WalkieTalkieStateMessage implements IMessage { + public int channel; + + public WalkieTalkieStateMessage() {} + + public WalkieTalkieStateMessage(int chan) { + channel = chan; + } + + @Override + public void toBytes(ByteBuf dataStream) { + dataStream.writeInt(channel); + } + + @Override + public void fromBytes(ByteBuf dataStream) { + channel = dataStream.readInt(); + } + } } diff --git a/src/main/java/mekanism/common/recipe/BinRecipe.java b/src/main/java/mekanism/common/recipe/BinRecipe.java index 08cf6969d..7f585f2db 100644 --- a/src/main/java/mekanism/common/recipe/BinRecipe.java +++ b/src/main/java/mekanism/common/recipe/BinRecipe.java @@ -1,5 +1,8 @@ package mekanism.common.recipe; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent; import mekanism.common.MekanismItems; import mekanism.common.block.BlockBasic.BasicType; import mekanism.common.inventory.InventoryBin; @@ -9,171 +12,143 @@ import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.IRecipe; import net.minecraft.world.World; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent; -public class BinRecipe implements IRecipe -{ - private static boolean registered; - - public BinRecipe() - { - if(!registered) - { - FMLCommonHandler.instance().bus().register(this); - registered = true; - } - } +public class BinRecipe implements IRecipe { + private static boolean registered; - @Override - public boolean matches(InventoryCrafting inv, World world) - { - return getCraftingResult(inv) != null; - } + public BinRecipe() { + if (!registered) { + FMLCommonHandler.instance().bus().register(this); + registered = true; + } + } - private boolean isBin(ItemStack itemStack) - { - if(itemStack == null) - { - return false; - } + @Override + public boolean matches(InventoryCrafting inv, World world) { + return getCraftingResult(inv) != null; + } - return BasicType.get(itemStack) == BasicType.BIN && itemStack.stackSize <= 1; - } + private boolean isBin(ItemStack itemStack) { + if (itemStack == null) { + return false; + } - @Override - public ItemStack getCraftingResult(InventoryCrafting inv) - { - return getResult(inv); - } + return BasicType.get(itemStack) == BasicType.BIN && itemStack.stackSize <= 1; + } - public ItemStack getResult(IInventory inv) - { - ItemStack bin = null; + @Override + public ItemStack getCraftingResult(InventoryCrafting inv) { + return getResult(inv); + } - for(int i = 0; i < inv.getSizeInventory(); i++) - { - ItemStack stack = inv.getStackInSlot(i); + public ItemStack getResult(IInventory inv) { + ItemStack bin = null; - if(isBin(stack)) - { - if(bin != null) - { - return null; - } + for (int i = 0; i < inv.getSizeInventory(); i++) { + ItemStack stack = inv.getStackInSlot(i); - bin = stack.copy(); - } - } + if (isBin(stack)) { + if (bin != null) { + return null; + } - if(bin == null || bin.stackSize > 1) - { - return null; - } + bin = stack.copy(); + } + } - ItemStack addStack = null; + if (bin == null || bin.stackSize > 1) { + return null; + } - for(int i = 0; i < 9; i++) - { - ItemStack stack = inv.getStackInSlot(i); + ItemStack addStack = null; - if(stack != null && !isBin(stack)) - { - if(addStack != null) - { - return null; - } + for (int i = 0; i < 9; i++) { + ItemStack stack = inv.getStackInSlot(i); - addStack = stack.copy(); - } - } + if (stack != null && !isBin(stack)) { + if (addStack != null) { + return null; + } - InventoryBin binInv = new InventoryBin(bin); + addStack = stack.copy(); + } + } - if(addStack != null) - { - if(binInv.getItemType() != null && !binInv.getItemType().isItemEqual(addStack)) - { - return null; - } + InventoryBin binInv = new InventoryBin(bin); - binInv.add(addStack); - - return bin; - } - else { - return binInv.removeStack(); - } - } + if (addStack != null) { + if (binInv.getItemType() != null + && !binInv.getItemType().isItemEqual(addStack)) { + return null; + } - @Override - public int getRecipeSize() - { - return 0; - } + binInv.add(addStack); - @Override - public ItemStack getRecipeOutput() - { - return null; - } + return bin; + } else { + return binInv.removeStack(); + } + } - @SubscribeEvent - public void onCrafting(ItemCraftedEvent event) - { - if(getResult(event.craftMatrix) != null) - { - if(!isBin(event.crafting)) - { - for(int i = 0; i < event.craftMatrix.getSizeInventory(); i++) - { - if(isBin(event.craftMatrix.getStackInSlot(i))) - { - ItemStack bin = event.craftMatrix.getStackInSlot(i); - InventoryBin inv = new InventoryBin(bin.copy()); + @Override + public int getRecipeSize() { + return 0; + } - int size = inv.getItemCount(); + @Override + public ItemStack getRecipeOutput() { + return null; + } - ItemStack testRemove = inv.removeStack(); + @SubscribeEvent + public void onCrafting(ItemCraftedEvent event) { + if (getResult(event.craftMatrix) != null) { + if (!isBin(event.crafting)) { + for (int i = 0; i < event.craftMatrix.getSizeInventory(); i++) { + if (isBin(event.craftMatrix.getStackInSlot(i))) { + ItemStack bin = event.craftMatrix.getStackInSlot(i); + InventoryBin inv = new InventoryBin(bin.copy()); - bin.stackTagCompound.setInteger("newCount", size-(testRemove != null ? testRemove.stackSize : 0)); - } - } - } - else { - int bin = -1; - int other = -1; + int size = inv.getItemCount(); - for(int i = 0; i < event.craftMatrix.getSizeInventory(); i++) - { - if(isBin(event.craftMatrix.getStackInSlot(i))) - { - bin = i; - } + ItemStack testRemove = inv.removeStack(); + + bin.stackTagCompound.setInteger( + "newCount", + size - (testRemove != null ? testRemove.stackSize : 0) + ); + } + } + } else { + int bin = -1; + int other = -1; + + for (int i = 0; i < event.craftMatrix.getSizeInventory(); i++) { + if (isBin(event.craftMatrix.getStackInSlot(i))) { + bin = i; + } else if(!isBin(event.craftMatrix.getStackInSlot(i)) && event.craftMatrix.getStackInSlot(i) != null) { - other = i; - } - } + other = i; + } + } - ItemStack binStack = event.craftMatrix.getStackInSlot(bin); - ItemStack otherStack = event.craftMatrix.getStackInSlot(other); + ItemStack binStack = event.craftMatrix.getStackInSlot(bin); + ItemStack otherStack = event.craftMatrix.getStackInSlot(other); - ItemStack testRemain = new InventoryBin(binStack.copy()).add(otherStack.copy()); + ItemStack testRemain + = new InventoryBin(binStack.copy()).add(otherStack.copy()); - if(testRemain != null && testRemain.stackSize > 0) - { - ItemStack proxy = new ItemStack(MekanismItems.ItemProxy); - ((ItemProxy)proxy.getItem()).setSavedItem(proxy, testRemain.copy()); - event.craftMatrix.setInventorySlotContents(other, proxy); - } - else { - event.craftMatrix.setInventorySlotContents(other, null); - } + if (testRemain != null && testRemain.stackSize > 0) { + ItemStack proxy = new ItemStack(MekanismItems.ItemProxy); + ((ItemProxy) proxy.getItem()).setSavedItem(proxy, testRemain.copy()); + event.craftMatrix.setInventorySlotContents(other, proxy); + } else { + event.craftMatrix.setInventorySlotContents(other, null); + } - event.craftMatrix.setInventorySlotContents(bin, null); - } - } - } + event.craftMatrix.setInventorySlotContents(bin, null); + } + } + } } diff --git a/src/main/java/mekanism/common/recipe/ElementizerRecipeHandler.java b/src/main/java/mekanism/common/recipe/ElementizerRecipeHandler.java index 43ab0b0a3..d0332da57 100644 --- a/src/main/java/mekanism/common/recipe/ElementizerRecipeHandler.java +++ b/src/main/java/mekanism/common/recipe/ElementizerRecipeHandler.java @@ -11,12 +11,12 @@ import net.minecraft.init.Items; import net.minecraft.item.ItemStack; public class ElementizerRecipeHandler { - public static List outputItems = new ArrayList<>(); public static List fuelItems = new ArrayList<>(); public static ItemStack getRandomMagicItem() { - int range = outputItems.size() + MekanismConfig.general.elementizerFailChanceMultiplier; + int range + = outputItems.size() + MekanismConfig.general.elementizerFailChanceMultiplier; int index = 0; if (range > 0) { final Random rand = new Random(); @@ -54,5 +54,4 @@ public class ElementizerRecipeHandler { outputItems.add(new ItemStack(MekanismItems.Stopwatch)); outputItems.add(new ItemStack(MekanismItems.WeatherOrb)); } - } diff --git a/src/main/java/mekanism/common/recipe/RecipeHandler.java b/src/main/java/mekanism/common/recipe/RecipeHandler.java index 9c2165592..0a93d8265 100644 --- a/src/main/java/mekanism/common/recipe/RecipeHandler.java +++ b/src/main/java/mekanism/common/recipe/RecipeHandler.java @@ -55,640 +55,703 @@ import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidStack; /** - * Class used to handle machine recipes. This is used for both adding and fetching recipes. + * Class used to handle machine recipes. This is used for both adding and fetching + * recipes. * @author AidanBrady, unpairedbracket * */ -public final class RecipeHandler -{ - public static void addRecipe(Recipe recipeMap, MachineRecipe recipe) - { - recipeMap.put(recipe); - } - - public static void removeRecipe(Recipe recipeMap, MachineRecipe recipe) - { - recipeMap.remove(recipe); - } - - /** - * Add an Enrichment Chamber recipe. - * @param input - input ItemStack - * @param output - output ItemStack - */ - public static void addEnrichmentChamberRecipe(ItemStack input, ItemStack output) - { - addRecipe(Recipe.ENRICHMENT_CHAMBER, new EnrichmentRecipe(input, output)); - } - - /** - * Add an Osmium Compressor recipe. - * @param input - input ItemStack - * @param output - output ItemStack - */ - public static void addOsmiumCompressorRecipe(ItemStack input, ItemStack output) - { - addRecipe(Recipe.OSMIUM_COMPRESSOR, new OsmiumCompressorRecipe(input, output)); - } - - /** - * Add a Combiner recipe. - * @param input - input ItemStack - * @param output - output ItemStack - */ - public static void addCombinerRecipe(ItemStack input, ItemStack output) - { - addRecipe(Recipe.COMBINER, new CombinerRecipe(input, output)); - } - - /** - * Add a Crusher recipe. - * @param input - input ItemStack - * @param output - output ItemStack - */ - public static void addCrusherRecipe(ItemStack input, ItemStack output) - { - addRecipe(Recipe.CRUSHER, new CrusherRecipe(input, output)); - } - - /** - * Add a Purification Chamber recipe. - * @param input - input ItemStack - * @param output - output ItemStack - */ - public static void addPurificationChamberRecipe(ItemStack input, ItemStack output) - { - addRecipe(Recipe.PURIFICATION_CHAMBER, new PurificationRecipe(input, output)); - } - - /** - * Add a Metallurgic Infuser recipe. - * @param infuse - which Infuse to use - * @param amount - how much of the Infuse to use - * @param input - input ItemStack - * @param output - output ItemStack - */ - public static void addMetallurgicInfuserRecipe(InfuseType infuse, int amount, ItemStack input, ItemStack output) - { - addRecipe(Recipe.METALLURGIC_INFUSER, new MetallurgicInfuserRecipe(new InfusionInput(infuse, amount, input), output)); - } - - /** - * Add a Chemical Infuser recipe. - * @param leftInput - left GasStack to input - * @param rightInput - right GasStack to input - * @param output - output GasStack - */ - public static void addChemicalInfuserRecipe(GasStack leftInput, GasStack rightInput, GasStack output) - { - addRecipe(Recipe.CHEMICAL_INFUSER, new ChemicalInfuserRecipe(leftInput, rightInput, output)); - } - - /** - * Add a Chemical Oxidizer recipe. - * @param input - input ItemStack - * @param output - output GasStack - */ - public static void addChemicalOxidizerRecipe(ItemStack input, GasStack output) - { - addRecipe(Recipe.CHEMICAL_OXIDIZER, new OxidationRecipe(input, output)); - } - - /** - * Add a Chemical Injection Chamber recipe. - * @param input - input ItemStack - * @param output - output ItemStack - */ - public static void addChemicalInjectionChamberRecipe(ItemStack input, String gasName, ItemStack output) - { - addRecipe(Recipe.CHEMICAL_INJECTION_CHAMBER, new InjectionRecipe(input, gasName, output)); - } - - /** - * Add an Electrolytic Separator recipe. - * @param fluid - FluidStack to electrolyze - * @param leftOutput - left gas to produce when the fluid is electrolyzed - * @param rightOutput - right gas to produce when the fluid is electrolyzed - */ - public static void addElectrolyticSeparatorRecipe(FluidStack fluid, double energy, GasStack leftOutput, GasStack rightOutput) - { - addRecipe(Recipe.ELECTROLYTIC_SEPARATOR, new SeparatorRecipe(fluid, energy, leftOutput, rightOutput)); - } - - /** - * Add a Precision Sawmill recipe. - * @param input - input ItemStack - * @param primaryOutput - guaranteed output - * @param secondaryOutput - possible extra output - * @param chance - probability of obtaining extra output - */ - public static void addPrecisionSawmillRecipe(ItemStack input, ItemStack primaryOutput, ItemStack secondaryOutput, double chance) - { - addRecipe(Recipe.PRECISION_SAWMILL, new SawmillRecipe(input, primaryOutput, secondaryOutput, chance)); - } - - /** - * Add a Precision Sawmill recipe with no chance output - * @param input - input ItemStack - * @param primaryOutput - guaranteed output - */ - public static void addPrecisionSawmillRecipe(ItemStack input, ItemStack primaryOutput) - { - addRecipe(Recipe.PRECISION_SAWMILL, new SawmillRecipe(input, primaryOutput)); - } - - /** - * Add a Chemical Dissolution Chamber recipe. - * @param input - input ItemStack - * @param output - output GasStack - */ - public static void addChemicalDissolutionChamberRecipe(ItemStack input, GasStack output) - { - addRecipe(Recipe.CHEMICAL_DISSOLUTION_CHAMBER, new DissolutionRecipe(input, output)); - } - - /** - * Add a Chemical Washer recipe. - * @param input - input GasStack - * @param output - output GasStack - */ - public static void addChemicalWasherRecipe(GasStack input, GasStack output) - { - addRecipe(Recipe.CHEMICAL_WASHER, new WasherRecipe(input, output)); - } - - /** - * Add a Chemical Crystallizer recipe. - * @param input - input GasStack - * @param output - output ItemStack - */ - public static void addChemicalCrystallizerRecipe(GasStack input, ItemStack output) - { - addRecipe(Recipe.CHEMICAL_CRYSTALLIZER, new CrystallizerRecipe(input, output)); - } - - /** - * Add a Pressurized Reaction Chamber recipe. - * @param inputSolid - input ItemStack - * @param inputFluid - input FluidStack - * @param inputGas - input GasStack - * @param outputSolid - output ItemStack - * @param outputGas - output GasStack - * @param extraEnergy - extra energy needed by the recipe - * @param ticks - amount of ticks it takes for this recipe to complete - */ - public static void addPRCRecipe(ItemStack inputSolid, FluidStack inputFluid, GasStack inputGas, ItemStack outputSolid, GasStack outputGas, double extraEnergy, int ticks) - { - addRecipe(Recipe.PRESSURIZED_REACTION_CHAMBER, new PressurizedRecipe(inputSolid, inputFluid, inputGas, outputSolid, outputGas, extraEnergy, ticks)); - } - - public static void addThermalEvaporationRecipe(FluidStack inputFluid, FluidStack outputFluid) - { - addRecipe(Recipe.THERMAL_EVAPORATION_PLANT, new ThermalEvaporationRecipe(inputFluid, outputFluid)); - } - - public static void addSolarNeutronRecipe(GasStack inputGas, GasStack outputGas) - { - addRecipe(Recipe.SOLAR_NEUTRON_ACTIVATOR, new SolarNeutronRecipe(inputGas, outputGas)); - } - - public static void addAmbientGas(int dimensionID, String ambientGasName) - { - addRecipe(Recipe.AMBIENT_ACCUMULATOR, new AmbientGasRecipe(dimensionID, ambientGasName)); - } - - /** - * Gets the Metallurgic Infuser Recipe for the InfusionInput in the parameters. - * @param input - input Infusion - * @return MetallurgicInfuserRecipe - */ - public static MetallurgicInfuserRecipe getMetallurgicInfuserRecipe(InfusionInput input) - { - if(input.isValid()) - { - HashMap recipes = Recipe.METALLURGIC_INFUSER.get(); - - MetallurgicInfuserRecipe recipe = recipes.get(input); - return recipe == null ? null : recipe.copy(); - } - - return null; - } - - /** - * Gets the Chemical Infuser Recipe of the ChemicalPairInput in the parameters. - * @param input - the pair of gases to infuse - * @return ChemicalInfuserRecipe - */ - public static ChemicalInfuserRecipe getChemicalInfuserRecipe(ChemicalPairInput input) - { - if(input.isValid()) - { - HashMap recipes = Recipe.CHEMICAL_INFUSER.get(); - - ChemicalInfuserRecipe recipe = recipes.get(input); - return recipe == null ? null : recipe.copy(); - } - - return null; - } - - /** - * Gets the Chemical Crystallizer Recipe for the defined Gas input. - * @param input - GasInput - * @return CrystallizerRecipe - */ - public static CrystallizerRecipe getChemicalCrystallizerRecipe(GasInput input) - { - if(input.isValid()) - { - HashMap recipes = Recipe.CHEMICAL_CRYSTALLIZER.get(); - - CrystallizerRecipe recipe = recipes.get(input); - return recipe == null ? null : recipe.copy(); - } - - return null; - } - - /** - * Gets the Chemical Washer Recipe for the defined Gas input. - * @param input - GasInput - * @return WasherRecipe - */ - public static WasherRecipe getChemicalWasherRecipe(GasInput input) - { - if(input.isValid()) - { - HashMap recipes = Recipe.CHEMICAL_WASHER.get(); - - WasherRecipe recipe = recipes.get(input); - return recipe == null ? null : recipe.copy(); - } - - return null; - } - - /** - * Gets the Chemical Dissolution Chamber of the ItemStackInput in the parameters - * @param input - ItemStackInput - * @return DissolutionRecipe - */ - public static DissolutionRecipe getDissolutionRecipe(ItemStackInput input) - { - if(input.isValid()) - { - HashMap recipes = Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get(); - - DissolutionRecipe recipe = getRecipeTryWildcard(input, recipes); - return recipe == null ? null : recipe.copy(); - } - - return null; - } - - /** - * Gets the Chemical Oxidizer Recipe for the ItemStackInput in the parameters. - * @param input - ItemStackInput - * @return OxidationRecipe - */ - public static OxidationRecipe getOxidizerRecipe(ItemStackInput input) - { - if(input.isValid()) - { - HashMap recipes = Recipe.CHEMICAL_OXIDIZER.get(); - - OxidationRecipe recipe = getRecipeTryWildcard(input, recipes); - return recipe == null ? null : recipe.copy(); - } - - return null; - } - - /** - * Gets the ChanceMachineRecipe of the ItemStackInput in the parameters, using the map in the parameters. - * @param input - ItemStackInput - * @param recipes - Map of recipes - * @return ChanceRecipe - */ - public static > RECIPE getChanceRecipe(ItemStackInput input, Map recipes) - { - if(input.isValid()) - { - RECIPE recipe = getRecipeTryWildcard(input, recipes); - return recipe == null ? null : recipe.copy(); - } - - return null; - } - - /** - * Gets the BasicMachineRecipe of the ItemStackInput in the parameters, using the map in the parameters. - * @param input - ItemStackInput - * @param recipes - Map of recipes - * @return BasicMachineRecipe - */ - public static > RECIPE getRecipe(ItemStackInput input, Map recipes) - { - if(input.isValid()) - { - RECIPE recipe = getRecipeTryWildcard(input, recipes); - return recipe == null ? null : recipe.copy(); - } - - return null; - } - /** - * Gets the AdvancedMachineRecipe of the AdvancedInput in the parameters, using the map in the paramaters. - * @param input - AdvancedInput - * @param recipes - Map of recipes - * @return AdvancedMachineRecipe - */ - public static > RECIPE getRecipe(AdvancedMachineInput input, Map recipes) - { - if(input.isValid()) - { - RECIPE recipe = recipes.get(input); - return recipe == null ? null : recipe.copy(); - } - - return null; - } - - /** - * Get the Electrolytic Separator Recipe corresponding to electrolysing a given fluid. - * @param input - the FluidInput to electrolyse fluid from - * @return SeparatorRecipe - */ - public static SeparatorRecipe getElectrolyticSeparatorRecipe(FluidInput input) - { - if(input.isValid()) - { - HashMap recipes = Recipe.ELECTROLYTIC_SEPARATOR.get(); - - SeparatorRecipe recipe = recipes.get(input); - return recipe == null ? null : recipe.copy(); - } - - return null; - } - - public static ThermalEvaporationRecipe getThermalEvaporationRecipe(FluidInput input) - { - if(input.isValid()) - { - HashMap recipes = Recipe.THERMAL_EVAPORATION_PLANT.get(); - - ThermalEvaporationRecipe recipe = recipes.get(input); - return recipe == null ? null : recipe.copy(); - } - - return null; - } - - public static SolarNeutronRecipe getSolarNeutronRecipe(GasInput input) - { - if(input.isValid()) - { - HashMap recipes = Recipe.SOLAR_NEUTRON_ACTIVATOR.get(); - - SolarNeutronRecipe recipe = recipes.get(input); - return recipe == null ? null : recipe.copy(); - } - - return null; - } - - public static PressurizedRecipe getPRCRecipe(PressurizedInput input) - { - if(input.isValid()) - { - HashMap recipes = Recipe.PRESSURIZED_REACTION_CHAMBER.get(); - - PressurizedRecipe recipe = recipes.get(input); - return recipe == null ? null : recipe.copy(); - } - - return null; - } - - public static AmbientGasRecipe getDimensionGas(IntegerInput input) - { - HashMap recipes = Recipe.AMBIENT_ACCUMULATOR.get(); - AmbientGasRecipe recipe = recipes.get(input); - - return recipe == null ? null : recipe.copy(); - } - - /** - * Gets the whether the input ItemStack is in a recipe - * @param itemstack - input ItemStack - * @param recipes - Map of recipes - * @return whether the item can be used in a recipe - */ - public static > boolean isInRecipe(ItemStack itemstack, Map recipes) - { - if(itemstack != null) - { - for(RECIPE recipe : recipes.values()) - { - ItemStackInput required = recipe.getInput(); - - if(required.useItemStackFromInventory(new ItemStack[]{itemstack}, 0, false)) - { - return true; - } - } - } - - return false; - } - - public static boolean isInPressurizedRecipe(ItemStack stack) - { - if(stack != null) - { - for(PressurizedInput key : (Set)Recipe.PRESSURIZED_REACTION_CHAMBER.get().keySet()) - { - if(key.containsType(stack)) - { - return true; - } - } - } - - return false; - } - - public static > RECIPE getRecipeTryWildcard(ItemStack stack, Map recipes) - { - return getRecipeTryWildcard(new ItemStackInput(stack), recipes); - } - - public static > RECIPE getRecipeTryWildcard(ItemStackInput input, Map recipes) - { - RECIPE recipe = recipes.get(input); - - if(recipe == null) - { - recipe = recipes.get(input.wildCopy()); - } - - return recipe; - } - - public static enum Recipe - { - ENERGIZED_SMELTER(MachineType.ENERGIZED_SMELTER.name, ItemStackInput.class, ItemStackOutput.class, SmeltingRecipe.class), - ENRICHMENT_CHAMBER(MachineType.ENRICHMENT_CHAMBER.name, ItemStackInput.class, ItemStackOutput.class, EnrichmentRecipe.class), - OSMIUM_COMPRESSOR(MachineType.OSMIUM_COMPRESSOR.name, AdvancedMachineInput.class, ItemStackOutput.class, OsmiumCompressorRecipe.class), - COMBINER(MachineType.COMBINER.name, AdvancedMachineInput.class, ItemStackOutput.class, CombinerRecipe.class), - CRUSHER(MachineType.CRUSHER.name, ItemStackInput.class, ItemStackOutput.class, CrusherRecipe.class), - PURIFICATION_CHAMBER(MachineType.PURIFICATION_CHAMBER.name, AdvancedMachineInput.class, ItemStackOutput.class, PurificationRecipe.class), - METALLURGIC_INFUSER(MachineType.METALLURGIC_INFUSER.name, InfusionInput.class, ItemStackOutput.class, MetallurgicInfuserRecipe.class), - CHEMICAL_INFUSER(MachineType.CHEMICAL_INFUSER.name, ChemicalPairInput.class, GasOutput.class, ChemicalInfuserRecipe.class), - CHEMICAL_OXIDIZER(MachineType.CHEMICAL_OXIDIZER.name, ItemStackInput.class, GasOutput.class, OxidationRecipe.class), - CHEMICAL_INJECTION_CHAMBER(MachineType.CHEMICAL_INJECTION_CHAMBER.name, AdvancedMachineInput.class, ItemStackOutput.class, InjectionRecipe.class), - ELECTROLYTIC_SEPARATOR(MachineType.ELECTROLYTIC_SEPARATOR.name, FluidInput.class, ChemicalPairOutput.class, SeparatorRecipe.class), - PRECISION_SAWMILL(MachineType.PRECISION_SAWMILL.name, ItemStackInput.class, ChanceOutput.class, SawmillRecipe.class), - CHEMICAL_DISSOLUTION_CHAMBER(MachineType.CHEMICAL_DISSOLUTION_CHAMBER.name, ItemStackInput.class, GasOutput.class, DissolutionRecipe.class), - CHEMICAL_WASHER(MachineType.CHEMICAL_WASHER.name, GasInput.class, GasOutput.class, WasherRecipe.class), - CHEMICAL_CRYSTALLIZER(MachineType.CHEMICAL_CRYSTALLIZER.name, GasInput.class, ItemStackOutput.class, CrystallizerRecipe.class), - PRESSURIZED_REACTION_CHAMBER(MachineType.PRESSURIZED_REACTION_CHAMBER.name, PressurizedInput.class, PressurizedOutput.class, PressurizedRecipe.class), - AMBIENT_ACCUMULATOR(MachineType.AMBIENT_ACCUMULATOR.name, IntegerInput.class, GasOutput.class, AmbientGasRecipe.class), - THERMAL_EVAPORATION_PLANT("ThermalEvaporationPlant", FluidInput.class, FluidOutput.class, ThermalEvaporationRecipe.class), - SOLAR_NEUTRON_ACTIVATOR(MachineType.SOLAR_NEUTRON_ACTIVATOR.name, GasInput.class, GasOutput.class, SolarNeutronRecipe.class); - - private HashMap recipes; - private String recipeName; - - private Class inputClass; - private Class outputClass; - private Class recipeClass; - - private , OUTPUT extends MachineOutput, RECIPE extends MachineRecipe> Recipe(String name, Class input, Class output, Class recipe) - { - recipeName = name; - - inputClass = input; - outputClass = output; - recipeClass = recipe; - - recipes = new HashMap(); - } - - public > void put(RECIPE recipe) - { - recipes.put(recipe.getInput(), recipe); - } - - public > void remove(RECIPE recipe) - { - recipes.remove(recipe.getInput()); - } - - public String getRecipeName() - { - return recipeName; - } - - public INPUT createInput(NBTTagCompound nbtTags) - { - try { - MachineInput input = inputClass.newInstance(); - input.load(nbtTags); - - return (INPUT)input; - } catch(Exception e) { - return null; - } - } - - public RECIPE createRecipe(INPUT input, NBTTagCompound nbtTags) - { - try { - MachineOutput output = outputClass.newInstance(); - output.load(nbtTags); - - Constructor construct = recipeClass.getDeclaredConstructor(inputClass, outputClass); - return (RECIPE)construct.newInstance(input, output); - } catch(Exception e) { - return null; - } - } - - public boolean containsRecipe(ItemStack input) - { - for(Object obj : get().entrySet()) - { - if(obj instanceof Map.Entry) - { - Map.Entry entry = (Map.Entry)obj; - - if(entry.getKey() instanceof ItemStackInput) - { - ItemStack stack = ((ItemStackInput)entry.getKey()).ingredient; - - if(StackUtils.equalsWildcard(stack, input)) - { - return true; - } - } - else if(entry.getKey() instanceof FluidInput) - { - if(((FluidInput)entry.getKey()).ingredient.isFluidEqual(input)) - { - return true; - } - } - else if(entry.getKey() instanceof AdvancedMachineInput) - { - ItemStack stack = ((AdvancedMachineInput)entry.getKey()).itemStack; - - if(StackUtils.equalsWildcard(stack, input)) - { - return true; - } - } - } - } - - return false; - } - - public boolean containsRecipe(Fluid input) - { - for(Object obj : get().entrySet()) - { - if(obj instanceof Map.Entry) - { - Map.Entry entry = (Map.Entry)obj; - - if(entry.getKey() instanceof FluidInput) - { - if(((FluidInput)entry.getKey()).ingredient.getFluid() == input) - { - return true; - } - } - } - } - - return false; - } - - public boolean containsRecipe(Gas input) - { - for(Object obj : get().entrySet()) - { - if(obj instanceof Map.Entry) - { - Map.Entry entry = (Map.Entry)obj; - - if(entry.getKey() instanceof GasInput) - { - if(((GasInput)entry.getKey()).ingredient.getGas() == input) - { +public final class RecipeHandler { + public static void addRecipe(Recipe recipeMap, MachineRecipe recipe) { + recipeMap.put(recipe); + } + + public static void removeRecipe(Recipe recipeMap, MachineRecipe recipe) { + recipeMap.remove(recipe); + } + + /** + * Add an Enrichment Chamber recipe. + * @param input - input ItemStack + * @param output - output ItemStack + */ + public static void addEnrichmentChamberRecipe(ItemStack input, ItemStack output) { + addRecipe(Recipe.ENRICHMENT_CHAMBER, new EnrichmentRecipe(input, output)); + } + + /** + * Add an Osmium Compressor recipe. + * @param input - input ItemStack + * @param output - output ItemStack + */ + public static void addOsmiumCompressorRecipe(ItemStack input, ItemStack output) { + addRecipe(Recipe.OSMIUM_COMPRESSOR, new OsmiumCompressorRecipe(input, output)); + } + + /** + * Add a Combiner recipe. + * @param input - input ItemStack + * @param output - output ItemStack + */ + public static void addCombinerRecipe(ItemStack input, ItemStack output) { + addRecipe(Recipe.COMBINER, new CombinerRecipe(input, output)); + } + + /** + * Add a Crusher recipe. + * @param input - input ItemStack + * @param output - output ItemStack + */ + public static void addCrusherRecipe(ItemStack input, ItemStack output) { + addRecipe(Recipe.CRUSHER, new CrusherRecipe(input, output)); + } + + /** + * Add a Purification Chamber recipe. + * @param input - input ItemStack + * @param output - output ItemStack + */ + public static void addPurificationChamberRecipe(ItemStack input, ItemStack output) { + addRecipe(Recipe.PURIFICATION_CHAMBER, new PurificationRecipe(input, output)); + } + + /** + * Add a Metallurgic Infuser recipe. + * @param infuse - which Infuse to use + * @param amount - how much of the Infuse to use + * @param input - input ItemStack + * @param output - output ItemStack + */ + public static void addMetallurgicInfuserRecipe( + InfuseType infuse, int amount, ItemStack input, ItemStack output + ) { + addRecipe( + Recipe.METALLURGIC_INFUSER, + new MetallurgicInfuserRecipe(new InfusionInput(infuse, amount, input), output) + ); + } + + /** + * Add a Chemical Infuser recipe. + * @param leftInput - left GasStack to input + * @param rightInput - right GasStack to input + * @param output - output GasStack + */ + public static void + addChemicalInfuserRecipe(GasStack leftInput, GasStack rightInput, GasStack output) { + addRecipe( + Recipe.CHEMICAL_INFUSER, + new ChemicalInfuserRecipe(leftInput, rightInput, output) + ); + } + + /** + * Add a Chemical Oxidizer recipe. + * @param input - input ItemStack + * @param output - output GasStack + */ + public static void addChemicalOxidizerRecipe(ItemStack input, GasStack output) { + addRecipe(Recipe.CHEMICAL_OXIDIZER, new OxidationRecipe(input, output)); + } + + /** + * Add a Chemical Injection Chamber recipe. + * @param input - input ItemStack + * @param output - output ItemStack + */ + public static void + addChemicalInjectionChamberRecipe(ItemStack input, String gasName, ItemStack output) { + addRecipe( + Recipe.CHEMICAL_INJECTION_CHAMBER, new InjectionRecipe(input, gasName, output) + ); + } + + /** + * Add an Electrolytic Separator recipe. + * @param fluid - FluidStack to electrolyze + * @param leftOutput - left gas to produce when the fluid is electrolyzed + * @param rightOutput - right gas to produce when the fluid is electrolyzed + */ + public static void addElectrolyticSeparatorRecipe( + FluidStack fluid, double energy, GasStack leftOutput, GasStack rightOutput + ) { + addRecipe( + Recipe.ELECTROLYTIC_SEPARATOR, + new SeparatorRecipe(fluid, energy, leftOutput, rightOutput) + ); + } + + /** + * Add a Precision Sawmill recipe. + * @param input - input ItemStack + * @param primaryOutput - guaranteed output + * @param secondaryOutput - possible extra output + * @param chance - probability of obtaining extra output + */ + public static void addPrecisionSawmillRecipe( + ItemStack input, ItemStack primaryOutput, ItemStack secondaryOutput, double chance + ) { + addRecipe( + Recipe.PRECISION_SAWMILL, + new SawmillRecipe(input, primaryOutput, secondaryOutput, chance) + ); + } + + /** + * Add a Precision Sawmill recipe with no chance output + * @param input - input ItemStack + * @param primaryOutput - guaranteed output + */ + public static void + addPrecisionSawmillRecipe(ItemStack input, ItemStack primaryOutput) { + addRecipe(Recipe.PRECISION_SAWMILL, new SawmillRecipe(input, primaryOutput)); + } + + /** + * Add a Chemical Dissolution Chamber recipe. + * @param input - input ItemStack + * @param output - output GasStack + */ + public static void + addChemicalDissolutionChamberRecipe(ItemStack input, GasStack output) { + addRecipe( + Recipe.CHEMICAL_DISSOLUTION_CHAMBER, new DissolutionRecipe(input, output) + ); + } + + /** + * Add a Chemical Washer recipe. + * @param input - input GasStack + * @param output - output GasStack + */ + public static void addChemicalWasherRecipe(GasStack input, GasStack output) { + addRecipe(Recipe.CHEMICAL_WASHER, new WasherRecipe(input, output)); + } + + /** + * Add a Chemical Crystallizer recipe. + * @param input - input GasStack + * @param output - output ItemStack + */ + public static void addChemicalCrystallizerRecipe(GasStack input, ItemStack output) { + addRecipe(Recipe.CHEMICAL_CRYSTALLIZER, new CrystallizerRecipe(input, output)); + } + + /** + * Add a Pressurized Reaction Chamber recipe. + * @param inputSolid - input ItemStack + * @param inputFluid - input FluidStack + * @param inputGas - input GasStack + * @param outputSolid - output ItemStack + * @param outputGas - output GasStack + * @param extraEnergy - extra energy needed by the recipe + * @param ticks - amount of ticks it takes for this recipe to complete + */ + public static void addPRCRecipe( + ItemStack inputSolid, + FluidStack inputFluid, + GasStack inputGas, + ItemStack outputSolid, + GasStack outputGas, + double extraEnergy, + int ticks + ) { + addRecipe( + Recipe.PRESSURIZED_REACTION_CHAMBER, + new PressurizedRecipe( + inputSolid, + inputFluid, + inputGas, + outputSolid, + outputGas, + extraEnergy, + ticks + ) + ); + } + + public static void + addThermalEvaporationRecipe(FluidStack inputFluid, FluidStack outputFluid) { + addRecipe( + Recipe.THERMAL_EVAPORATION_PLANT, + new ThermalEvaporationRecipe(inputFluid, outputFluid) + ); + } + + public static void addSolarNeutronRecipe(GasStack inputGas, GasStack outputGas) { + addRecipe( + Recipe.SOLAR_NEUTRON_ACTIVATOR, new SolarNeutronRecipe(inputGas, outputGas) + ); + } + + public static void addAmbientGas(int dimensionID, String ambientGasName) { + addRecipe( + Recipe.AMBIENT_ACCUMULATOR, new AmbientGasRecipe(dimensionID, ambientGasName) + ); + } + + /** + * Gets the Metallurgic Infuser Recipe for the InfusionInput in the parameters. + * @param input - input Infusion + * @return MetallurgicInfuserRecipe + */ + public static MetallurgicInfuserRecipe getMetallurgicInfuserRecipe(InfusionInput input + ) { + if (input.isValid()) { + HashMap recipes + = Recipe.METALLURGIC_INFUSER.get(); + + MetallurgicInfuserRecipe recipe = recipes.get(input); + return recipe == null ? null : recipe.copy(); + } + + return null; + } + + /** + * Gets the Chemical Infuser Recipe of the ChemicalPairInput in the parameters. + * @param input - the pair of gases to infuse + * @return ChemicalInfuserRecipe + */ + public static ChemicalInfuserRecipe getChemicalInfuserRecipe(ChemicalPairInput input + ) { + if (input.isValid()) { + HashMap recipes + = Recipe.CHEMICAL_INFUSER.get(); + + ChemicalInfuserRecipe recipe = recipes.get(input); + return recipe == null ? null : recipe.copy(); + } + + return null; + } + + /** + * Gets the Chemical Crystallizer Recipe for the defined Gas input. + * @param input - GasInput + * @return CrystallizerRecipe + */ + public static CrystallizerRecipe getChemicalCrystallizerRecipe(GasInput input) { + if (input.isValid()) { + HashMap recipes + = Recipe.CHEMICAL_CRYSTALLIZER.get(); + + CrystallizerRecipe recipe = recipes.get(input); + return recipe == null ? null : recipe.copy(); + } + + return null; + } + + /** + * Gets the Chemical Washer Recipe for the defined Gas input. + * @param input - GasInput + * @return WasherRecipe + */ + public static WasherRecipe getChemicalWasherRecipe(GasInput input) { + if (input.isValid()) { + HashMap recipes = Recipe.CHEMICAL_WASHER.get(); + + WasherRecipe recipe = recipes.get(input); + return recipe == null ? null : recipe.copy(); + } + + return null; + } + + /** + * Gets the Chemical Dissolution Chamber of the ItemStackInput in the parameters + * @param input - ItemStackInput + * @return DissolutionRecipe + */ + public static DissolutionRecipe getDissolutionRecipe(ItemStackInput input) { + if (input.isValid()) { + HashMap recipes + = Recipe.CHEMICAL_DISSOLUTION_CHAMBER.get(); + + DissolutionRecipe recipe = getRecipeTryWildcard(input, recipes); + return recipe == null ? null : recipe.copy(); + } + + return null; + } + + /** + * Gets the Chemical Oxidizer Recipe for the ItemStackInput in the parameters. + * @param input - ItemStackInput + * @return OxidationRecipe + */ + public static OxidationRecipe getOxidizerRecipe(ItemStackInput input) { + if (input.isValid()) { + HashMap recipes + = Recipe.CHEMICAL_OXIDIZER.get(); + + OxidationRecipe recipe = getRecipeTryWildcard(input, recipes); + return recipe == null ? null : recipe.copy(); + } + + return null; + } + + /** + * Gets the ChanceMachineRecipe of the ItemStackInput in the parameters, using the map + * in the parameters. + * @param input - ItemStackInput + * @param recipes - Map of recipes + * @return ChanceRecipe + */ + public static > RECIPE + getChanceRecipe(ItemStackInput input, Map recipes) { + if (input.isValid()) { + RECIPE recipe = getRecipeTryWildcard(input, recipes); + return recipe == null ? null : recipe.copy(); + } + + return null; + } + + /** + * Gets the BasicMachineRecipe of the ItemStackInput in the parameters, using the map + * in the parameters. + * @param input - ItemStackInput + * @param recipes - Map of recipes + * @return BasicMachineRecipe + */ + public static > + RECIPE getRecipe(ItemStackInput input, Map recipes) { + if (input.isValid()) { + RECIPE recipe = getRecipeTryWildcard(input, recipes); + return recipe == null ? null : recipe.copy(); + } + + return null; + } + + /** + * Gets the AdvancedMachineRecipe of the AdvancedInput in the parameters, using the + * map in the paramaters. + * @param input - AdvancedInput + * @param recipes - Map of recipes + * @return AdvancedMachineRecipe + */ + public static > RECIPE + getRecipe(AdvancedMachineInput input, Map recipes) { + if (input.isValid()) { + RECIPE recipe = recipes.get(input); + return recipe == null ? null : recipe.copy(); + } + + return null; + } + + /** + * Get the Electrolytic Separator Recipe corresponding to electrolysing a given fluid. + * @param input - the FluidInput to electrolyse fluid from + * @return SeparatorRecipe + */ + public static SeparatorRecipe getElectrolyticSeparatorRecipe(FluidInput input) { + if (input.isValid()) { + HashMap recipes + = Recipe.ELECTROLYTIC_SEPARATOR.get(); + + SeparatorRecipe recipe = recipes.get(input); + return recipe == null ? null : recipe.copy(); + } + + return null; + } + + public static ThermalEvaporationRecipe getThermalEvaporationRecipe(FluidInput input) { + if (input.isValid()) { + HashMap recipes + = Recipe.THERMAL_EVAPORATION_PLANT.get(); + + ThermalEvaporationRecipe recipe = recipes.get(input); + return recipe == null ? null : recipe.copy(); + } + + return null; + } + + public static SolarNeutronRecipe getSolarNeutronRecipe(GasInput input) { + if (input.isValid()) { + HashMap recipes + = Recipe.SOLAR_NEUTRON_ACTIVATOR.get(); + + SolarNeutronRecipe recipe = recipes.get(input); + return recipe == null ? null : recipe.copy(); + } + + return null; + } + + public static PressurizedRecipe getPRCRecipe(PressurizedInput input) { + if (input.isValid()) { + HashMap recipes + = Recipe.PRESSURIZED_REACTION_CHAMBER.get(); + + PressurizedRecipe recipe = recipes.get(input); + return recipe == null ? null : recipe.copy(); + } + + return null; + } + + public static AmbientGasRecipe getDimensionGas(IntegerInput input) { + HashMap recipes + = Recipe.AMBIENT_ACCUMULATOR.get(); + AmbientGasRecipe recipe = recipes.get(input); + + return recipe == null ? null : recipe.copy(); + } + + /** + * Gets the whether the input ItemStack is in a recipe + * @param itemstack - input ItemStack + * @param recipes - Map of recipes + * @return whether the item can be used in a recipe + */ + public static > + boolean isInRecipe(ItemStack itemstack, Map recipes) { + if (itemstack != null) { + for (RECIPE recipe : recipes.values()) { + ItemStackInput required = recipe.getInput(); + + if (required.useItemStackFromInventory( + new ItemStack[] { itemstack }, 0, false + )) { + return true; + } + } + } + + return false; + } + + public static boolean isInPressurizedRecipe(ItemStack stack) { + if (stack != null) { + for (PressurizedInput key : + (Set) Recipe.PRESSURIZED_REACTION_CHAMBER.get().keySet( + )) { + if (key.containsType(stack)) { + return true; + } + } + } + + return false; + } + + public static > RECIPE + getRecipeTryWildcard(ItemStack stack, Map recipes) { + return getRecipeTryWildcard(new ItemStackInput(stack), recipes); + } + + public static > RECIPE + getRecipeTryWildcard(ItemStackInput input, Map recipes) { + RECIPE recipe = recipes.get(input); + + if (recipe == null) { + recipe = recipes.get(input.wildCopy()); + } + + return recipe; + } + + public static enum Recipe { + ENERGIZED_SMELTER( + MachineType.ENERGIZED_SMELTER.name, + ItemStackInput.class, + ItemStackOutput.class, + SmeltingRecipe.class + ), + ENRICHMENT_CHAMBER( + MachineType.ENRICHMENT_CHAMBER.name, + ItemStackInput.class, + ItemStackOutput.class, + EnrichmentRecipe.class + ), + OSMIUM_COMPRESSOR( + MachineType.OSMIUM_COMPRESSOR.name, + AdvancedMachineInput.class, + ItemStackOutput.class, + OsmiumCompressorRecipe.class + ), + COMBINER( + MachineType.COMBINER.name, + AdvancedMachineInput.class, + ItemStackOutput.class, + CombinerRecipe.class + ), + CRUSHER( + MachineType.CRUSHER.name, + ItemStackInput.class, + ItemStackOutput.class, + CrusherRecipe.class + ), + PURIFICATION_CHAMBER( + MachineType.PURIFICATION_CHAMBER.name, + AdvancedMachineInput.class, + ItemStackOutput.class, + PurificationRecipe.class + ), + METALLURGIC_INFUSER( + MachineType.METALLURGIC_INFUSER.name, + InfusionInput.class, + ItemStackOutput.class, + MetallurgicInfuserRecipe.class + ), + CHEMICAL_INFUSER( + MachineType.CHEMICAL_INFUSER.name, + ChemicalPairInput.class, + GasOutput.class, + ChemicalInfuserRecipe.class + ), + CHEMICAL_OXIDIZER( + MachineType.CHEMICAL_OXIDIZER.name, + ItemStackInput.class, + GasOutput.class, + OxidationRecipe.class + ), + CHEMICAL_INJECTION_CHAMBER( + MachineType.CHEMICAL_INJECTION_CHAMBER.name, + AdvancedMachineInput.class, + ItemStackOutput.class, + InjectionRecipe.class + ), + ELECTROLYTIC_SEPARATOR( + MachineType.ELECTROLYTIC_SEPARATOR.name, + FluidInput.class, + ChemicalPairOutput.class, + SeparatorRecipe.class + ), + PRECISION_SAWMILL( + MachineType.PRECISION_SAWMILL.name, + ItemStackInput.class, + ChanceOutput.class, + SawmillRecipe.class + ), + CHEMICAL_DISSOLUTION_CHAMBER( + MachineType.CHEMICAL_DISSOLUTION_CHAMBER.name, + ItemStackInput.class, + GasOutput.class, + DissolutionRecipe.class + ), + CHEMICAL_WASHER( + MachineType.CHEMICAL_WASHER.name, + GasInput.class, + GasOutput.class, + WasherRecipe.class + ), + CHEMICAL_CRYSTALLIZER( + MachineType.CHEMICAL_CRYSTALLIZER.name, + GasInput.class, + ItemStackOutput.class, + CrystallizerRecipe.class + ), + PRESSURIZED_REACTION_CHAMBER( + MachineType.PRESSURIZED_REACTION_CHAMBER.name, + PressurizedInput.class, + PressurizedOutput.class, + PressurizedRecipe.class + ), + AMBIENT_ACCUMULATOR( + MachineType.AMBIENT_ACCUMULATOR.name, + IntegerInput.class, + GasOutput.class, + AmbientGasRecipe.class + ), + THERMAL_EVAPORATION_PLANT( + "ThermalEvaporationPlant", + FluidInput.class, + FluidOutput.class, + ThermalEvaporationRecipe.class + ), + SOLAR_NEUTRON_ACTIVATOR( + MachineType.SOLAR_NEUTRON_ACTIVATOR.name, + GasInput.class, + GasOutput.class, + SolarNeutronRecipe.class + ); + + private HashMap recipes; + private String recipeName; + + private Class inputClass; + private Class outputClass; + private Class recipeClass; + + private , OUTPUT + extends MachineOutput, RECIPE + extends MachineRecipe> + Recipe( + String name, Class input, Class output, Class recipe + ) { + recipeName = name; + + inputClass = input; + outputClass = output; + recipeClass = recipe; + + recipes = new HashMap(); + } + + public > void put(RECIPE recipe) { + recipes.put(recipe.getInput(), recipe); + } + + public > void remove(RECIPE recipe) { + recipes.remove(recipe.getInput()); + } + + public String getRecipeName() { + return recipeName; + } + + public INPUT createInput(NBTTagCompound nbtTags) { + try { + MachineInput input = inputClass.newInstance(); + input.load(nbtTags); + + return (INPUT) input; + } catch (Exception e) { + return null; + } + } + + public RECIPE createRecipe(INPUT input, NBTTagCompound nbtTags) { + try { + MachineOutput output = outputClass.newInstance(); + output.load(nbtTags); + + Constructor construct + = recipeClass.getDeclaredConstructor(inputClass, outputClass); + return (RECIPE) construct.newInstance(input, output); + } catch (Exception e) { + return null; + } + } + + public boolean containsRecipe(ItemStack input) { + for (Object obj : get().entrySet()) { + if (obj instanceof Map.Entry) { + Map.Entry entry = (Map.Entry) obj; + + if (entry.getKey() instanceof ItemStackInput) { + ItemStack stack = ((ItemStackInput) entry.getKey()).ingredient; + + if (StackUtils.equalsWildcard(stack, input)) { + return true; + } + } else if (entry.getKey() instanceof FluidInput) { + if (((FluidInput) entry.getKey()) + .ingredient.isFluidEqual(input)) { + return true; + } + } else if (entry.getKey() instanceof AdvancedMachineInput) { + ItemStack stack + = ((AdvancedMachineInput) entry.getKey()).itemStack; + + if (StackUtils.equalsWildcard(stack, input)) { return true; } } @@ -698,9 +761,41 @@ public final class RecipeHandler return false; } - public HashMap get() - { - return recipes; - } - } + public boolean containsRecipe(Fluid input) { + for (Object obj : get().entrySet()) { + if (obj instanceof Map.Entry) { + Map.Entry entry = (Map.Entry) obj; + + if (entry.getKey() instanceof FluidInput) { + if (((FluidInput) entry.getKey()).ingredient.getFluid() + == input) { + return true; + } + } + } + } + + return false; + } + + public boolean containsRecipe(Gas input) { + for (Object obj : get().entrySet()) { + if (obj instanceof Map.Entry) { + Map.Entry entry = (Map.Entry) obj; + + if (entry.getKey() instanceof GasInput) { + if (((GasInput) entry.getKey()).ingredient.getGas() == input) { + return true; + } + } + } + } + + return false; + } + + public HashMap get() { + return recipes; + } + } } diff --git a/src/main/java/mekanism/common/recipe/ShapedMekanismRecipe.java b/src/main/java/mekanism/common/recipe/ShapedMekanismRecipe.java index 5e8c6a975..55e622000 100644 --- a/src/main/java/mekanism/common/recipe/ShapedMekanismRecipe.java +++ b/src/main/java/mekanism/common/recipe/ShapedMekanismRecipe.java @@ -17,282 +17,239 @@ import net.minecraftforge.common.util.Constants.NBT; import net.minecraftforge.oredict.OreDictionary; /** - * Code originally from Eloraam and her work on the Ore Dictionary. Cleaned up and modified to work well with energized items. + * Code originally from Eloraam and her work on the Ore Dictionary. Cleaned up and + * modified to work well with energized items. * @author Eloraam, aidancbrady * */ -public class ShapedMekanismRecipe implements IRecipe -{ - private static final int MAX_CRAFT_GRID_WIDTH = 3; - private static final int MAX_CRAFT_GRID_HEIGHT = 3; +public class ShapedMekanismRecipe implements IRecipe { + private static final int MAX_CRAFT_GRID_WIDTH = 3; + private static final int MAX_CRAFT_GRID_HEIGHT = 3; - private ItemStack output = null; - private Object[] input = null; + private ItemStack output = null; + private Object[] input = null; - public int width = 0; - public int height = 0; + public int width = 0; + public int height = 0; - private boolean mirrored = true; - - public ShapedMekanismRecipe(ItemStack result, Object... recipe) - { - output = result.copy(); + private boolean mirrored = true; - String shape = ""; - int idx = 0; + public ShapedMekanismRecipe(ItemStack result, Object... recipe) { + output = result.copy(); - if(recipe[idx] instanceof Boolean) - { - mirrored = (Boolean)recipe[idx]; + String shape = ""; + int idx = 0; - if(recipe[idx+1] instanceof Object[]) - { - recipe = (Object[])recipe[idx+1]; - } - else { - idx = 1; - } - } + if (recipe[idx] instanceof Boolean) { + mirrored = (Boolean) recipe[idx]; - if(recipe[idx] instanceof String[]) - { - String[] parts = ((String[])recipe[idx++]); + if (recipe[idx + 1] instanceof Object[]) { + recipe = (Object[]) recipe[idx + 1]; + } else { + idx = 1; + } + } - for(String s : parts) - { - width = s.length(); - shape += s; - } + if (recipe[idx] instanceof String[]) { + String[] parts = ((String[]) recipe[idx++]); - height = parts.length; - } - else { - while(recipe[idx] instanceof String) - { - String s = (String)recipe[idx++]; - shape += s; - width = s.length(); - height++; - } - } + for (String s : parts) { + width = s.length(); + shape += s; + } - if(width * height != shape.length()) - { - String ret = "Invalid shaped Mekanism recipe: "; + height = parts.length; + } else { + while (recipe[idx] instanceof String) { + String s = (String) recipe[idx++]; + shape += s; + width = s.length(); + height++; + } + } - for(Object tmp : recipe) - { - ret += tmp + ", "; - } + if (width * height != shape.length()) { + String ret = "Invalid shaped Mekanism recipe: "; - ret += output; + for (Object tmp : recipe) { + ret += tmp + ", "; + } - throw new RuntimeException(ret); - } + ret += output; - HashMap itemMap = new HashMap(); + throw new RuntimeException(ret); + } - for(; idx < recipe.length; idx += 2) - { - Character chr = (Character)recipe[idx]; - Object in = recipe[idx + 1]; + HashMap itemMap = new HashMap(); - if(in instanceof ItemStack) - { - itemMap.put(chr, ((ItemStack)in).copy()); - } - else if(in instanceof Item) - { - itemMap.put(chr, new ItemStack((Item)in)); - } - else if(in instanceof Block) - { - itemMap.put(chr, new ItemStack((Block)in, 1, OreDictionary.WILDCARD_VALUE)); - } - else if(in instanceof String) - { - itemMap.put(chr, OreDictionary.getOres((String)in)); - } - else { - String ret = "Invalid shaped Mekanism recipe: "; + for (; idx < recipe.length; idx += 2) { + Character chr = (Character) recipe[idx]; + Object in = recipe[idx + 1]; - for(Object tmp : recipe) - { - ret += tmp + ", "; - } + if (in instanceof ItemStack) { + itemMap.put(chr, ((ItemStack) in).copy()); + } else if (in instanceof Item) { + itemMap.put(chr, new ItemStack((Item) in)); + } else if (in instanceof Block) { + itemMap.put( + chr, new ItemStack((Block) in, 1, OreDictionary.WILDCARD_VALUE) + ); + } else if (in instanceof String) { + itemMap.put(chr, OreDictionary.getOres((String) in)); + } else { + String ret = "Invalid shaped Mekanism recipe: "; - ret += output; - throw new RuntimeException(ret); - } - } + for (Object tmp : recipe) { + ret += tmp + ", "; + } - input = new Object[width * height]; - int x = 0; + ret += output; + throw new RuntimeException(ret); + } + } - for(char chr : shape.toCharArray()) - { - input[x++] = itemMap.get(chr); - } - } + input = new Object[width * height]; + int x = 0; - @Override - public ItemStack getCraftingResult(InventoryCrafting inv) - { - return RecipeUtils.getCraftingResult(inv, output.copy()); - } + for (char chr : shape.toCharArray()) { + input[x++] = itemMap.get(chr); + } + } - @Override - public int getRecipeSize() - { - return input.length; - } + @Override + public ItemStack getCraftingResult(InventoryCrafting inv) { + return RecipeUtils.getCraftingResult(inv, output.copy()); + } - @Override - public ItemStack getRecipeOutput() - { - return output; - } + @Override + public int getRecipeSize() { + return input.length; + } - @Override - public boolean matches(InventoryCrafting inv, World world) - { - for(int x = 0; x <= MAX_CRAFT_GRID_WIDTH - width; x++) - { - for(int y = 0; y <= MAX_CRAFT_GRID_HEIGHT - height; ++y) - { - if(checkMatch(inv, x, y, true)) - { - return true; - } + @Override + public ItemStack getRecipeOutput() { + return output; + } - if(mirrored && checkMatch(inv, x, y, false)) - { - return true; - } - } - } + @Override + public boolean matches(InventoryCrafting inv, World world) { + for (int x = 0; x <= MAX_CRAFT_GRID_WIDTH - width; x++) { + for (int y = 0; y <= MAX_CRAFT_GRID_HEIGHT - height; ++y) { + if (checkMatch(inv, x, y, true)) { + return true; + } - return false; - } + if (mirrored && checkMatch(inv, x, y, false)) { + return true; + } + } + } - private boolean checkMatch(InventoryCrafting inv, int startX, int startY, boolean mirror) - { - for(int x = 0; x < MAX_CRAFT_GRID_WIDTH; x++) - { - for(int y = 0; y < MAX_CRAFT_GRID_HEIGHT; y++) - { - int subX = x - startX; - int subY = y - startY; - Object target = null; + return false; + } - if(subX >= 0 && subY >= 0 && subX < width && subY < height) - { - if(mirror) - { - target = input[width - subX - 1 + subY * width]; - } - else { - target = input[subX + subY * width]; - } - } + private boolean + checkMatch(InventoryCrafting inv, int startX, int startY, boolean mirror) { + for (int x = 0; x < MAX_CRAFT_GRID_WIDTH; x++) { + for (int y = 0; y < MAX_CRAFT_GRID_HEIGHT; y++) { + int subX = x - startX; + int subY = y - startY; + Object target = null; - ItemStack slot = inv.getStackInRowAndColumn(x, y); + if (subX >= 0 && subY >= 0 && subX < width && subY < height) { + if (mirror) { + target = input[width - subX - 1 + subY * width]; + } else { + target = input[subX + subY * width]; + } + } - if(target instanceof ItemStack) - { - if(!RecipeUtils.areItemsEqualForCrafting((ItemStack)target, slot)) - { - return false; - } - } - else if(target instanceof ArrayList) - { - boolean matched = false; + ItemStack slot = inv.getStackInRowAndColumn(x, y); - for(ItemStack item : (ArrayList)target) - { - matched = matched || RecipeUtils.areItemsEqualForCrafting(item, slot); - } + if (target instanceof ItemStack) { + if (!RecipeUtils.areItemsEqualForCrafting((ItemStack) target, slot)) { + return false; + } + } else if (target instanceof ArrayList) { + boolean matched = false; - if(!matched) - { - return false; - } - } - else if(target == null && slot != null) - { - return false; - } - } - } + for (ItemStack item : (ArrayList) target) { + matched + = matched || RecipeUtils.areItemsEqualForCrafting(item, slot); + } - return true; - } + if (!matched) { + return false; + } + } else if (target == null && slot != null) { + return false; + } + } + } - public ShapedMekanismRecipe setMirrored(boolean mirror) - { - mirrored = mirror; - return this; - } + return true; + } - public Object[] getInput() - { - return input; - } - - public static ShapedMekanismRecipe create(NBTTagCompound nbtTags) - { - if(!nbtTags.hasKey("result") || !nbtTags.hasKey("input")) - { - Mekanism.logger.error("[Mekanism] Shaped recipe parse error: missing input or result compound tag."); - return null; - } - - ItemStack result = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("result")); - NBTTagList list = nbtTags.getTagList("input", NBT.TAG_COMPOUND); - - if(result == null || list.tagCount() == 0) - { - Mekanism.logger.error("[Mekanism] Shaped recipe parse error: invalid result stack or input data list."); - return null; - } - - Object[] ret = new Object[list.tagCount()]; - - for(int i = 0; i < list.tagCount(); i++) - { - NBTTagCompound compound = list.getCompoundTagAt(i); - - if(compound.hasKey("oredict")) - { - ret[i] = compound.getString("oredict"); - } - else if(compound.hasKey("pattern")) - { - ret[i] = compound.getString("pattern"); - } - else if(compound.hasKey("character")) - { - String s = compound.getString("character"); - - if(s.length() > 1) - { - Mekanism.logger.error("[Mekanism] Shaped recipe parse error: invalid pattern character data."); - return null; - } - - ret[i] = compound.getString("character").toCharArray()[0]; - } - else if(compound.hasKey("itemstack")) - { - ret[i] = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("itemstack")); - } - else { - Mekanism.logger.error("[Mekanism] Shaped recipe parse error: invalid input tag data key."); - return null; - } - } - - return new ShapedMekanismRecipe(result, ret); - } + public ShapedMekanismRecipe setMirrored(boolean mirror) { + mirrored = mirror; + return this; + } + + public Object[] getInput() { + return input; + } + + public static ShapedMekanismRecipe create(NBTTagCompound nbtTags) { + if (!nbtTags.hasKey("result") || !nbtTags.hasKey("input")) { + Mekanism.logger.error( + "[Mekanism] Shaped recipe parse error: missing input or result compound tag." + ); + return null; + } + + ItemStack result + = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("result")); + NBTTagList list = nbtTags.getTagList("input", NBT.TAG_COMPOUND); + + if (result == null || list.tagCount() == 0) { + Mekanism.logger.error( + "[Mekanism] Shaped recipe parse error: invalid result stack or input data list." + ); + return null; + } + + Object[] ret = new Object[list.tagCount()]; + + for (int i = 0; i < list.tagCount(); i++) { + NBTTagCompound compound = list.getCompoundTagAt(i); + + if (compound.hasKey("oredict")) { + ret[i] = compound.getString("oredict"); + } else if (compound.hasKey("pattern")) { + ret[i] = compound.getString("pattern"); + } else if (compound.hasKey("character")) { + String s = compound.getString("character"); + + if (s.length() > 1) { + Mekanism.logger.error( + "[Mekanism] Shaped recipe parse error: invalid pattern character data." + ); + return null; + } + + ret[i] = compound.getString("character").toCharArray()[0]; + } else if (compound.hasKey("itemstack")) { + ret[i] + = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("itemstack") + ); + } else { + Mekanism.logger.error( + "[Mekanism] Shaped recipe parse error: invalid input tag data key." + ); + return null; + } + } + + return new ShapedMekanismRecipe(result, ret); + } } diff --git a/src/main/java/mekanism/common/recipe/ShapelessMekanismRecipe.java b/src/main/java/mekanism/common/recipe/ShapelessMekanismRecipe.java index 3ce9a0fe9..d772b8ad5 100644 --- a/src/main/java/mekanism/common/recipe/ShapelessMekanismRecipe.java +++ b/src/main/java/mekanism/common/recipe/ShapelessMekanismRecipe.java @@ -16,44 +16,37 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.Constants.NBT; import net.minecraftforge.oredict.OreDictionary; -public class ShapelessMekanismRecipe implements IRecipe -{ +public class ShapelessMekanismRecipe implements IRecipe { private ItemStack output = null; private ArrayList input = new ArrayList(); - public ShapelessMekanismRecipe(Block result, Object... recipe){ this(new ItemStack(result), recipe); } - public ShapelessMekanismRecipe(Item result, Object... recipe){ this(new ItemStack(result), recipe); } + public ShapelessMekanismRecipe(Block result, Object... recipe) { + this(new ItemStack(result), recipe); + } - public ShapelessMekanismRecipe(ItemStack result, Object... recipe) - { + public ShapelessMekanismRecipe(Item result, Object... recipe) { + this(new ItemStack(result), recipe); + } + + public ShapelessMekanismRecipe(ItemStack result, Object... recipe) { output = result.copy(); - - for(Object obj : recipe) - { - if(obj instanceof ItemStack) - { - input.add(((ItemStack)obj).copy()); - } - else if(obj instanceof Item) - { - input.add(new ItemStack((Item)obj)); - } - else if(obj instanceof Block) - { - input.add(new ItemStack((Block)obj)); - } - else if(obj instanceof String) - { - input.add(OreDictionary.getOres((String)obj)); - } - else { + + for (Object obj : recipe) { + if (obj instanceof ItemStack) { + input.add(((ItemStack) obj).copy()); + } else if (obj instanceof Item) { + input.add(new ItemStack((Item) obj)); + } else if (obj instanceof Block) { + input.add(new ItemStack((Block) obj)); + } else if (obj instanceof String) { + input.add(OreDictionary.getOres((String) obj)); + } else { String ret = "Invalid shapeless Mekanism recipe: "; - - for(Object tmp : recipe) - { + + for (Object tmp : recipe) { ret += tmp + ", "; } - + ret += output; throw new RuntimeException(ret); } @@ -61,69 +54,60 @@ public class ShapelessMekanismRecipe implements IRecipe } @Override - public int getRecipeSize() - { - return input.size(); + public int getRecipeSize() { + return input.size(); } @Override - public ItemStack getRecipeOutput() - { - return output; + public ItemStack getRecipeOutput() { + return output; } @Override - public ItemStack getCraftingResult(InventoryCrafting inv) - { - return RecipeUtils.getCraftingResult(inv, output.copy()); + public ItemStack getCraftingResult(InventoryCrafting inv) { + return RecipeUtils.getCraftingResult(inv, output.copy()); } @SuppressWarnings("unchecked") @Override - public boolean matches(InventoryCrafting inv, World world) - { + public boolean matches(InventoryCrafting inv, World world) { ArrayList required = new ArrayList(input); - for(int x = 0; x < inv.getSizeInventory(); x++) - { + for (int x = 0; x < inv.getSizeInventory(); x++) { ItemStack slot = inv.getStackInSlot(x); - if(slot != null) - { + if (slot != null) { boolean inRecipe = false; Iterator req = required.iterator(); - while(req.hasNext()) - { + while (req.hasNext()) { boolean match = false; Object next = req.next(); - if(next instanceof ItemStack) - { - match = RecipeUtils.areItemsEqualForCrafting((ItemStack)next, slot); - } - else if(next instanceof ArrayList) - { - Iterator itr = ((ArrayList)next).iterator(); - - while(itr.hasNext() && !match) - { - match = RecipeUtils.areItemsEqualForCrafting(itr.next(), slot); + if (next instanceof ItemStack) { + match = RecipeUtils.areItemsEqualForCrafting( + (ItemStack) next, slot + ); + } else if (next instanceof ArrayList) { + Iterator itr + = ((ArrayList) next).iterator(); + + while (itr.hasNext() && !match) { + match + = RecipeUtils.areItemsEqualForCrafting(itr.next(), slot); } } - if(match) - { + if (match) { inRecipe = true; required.remove(next); - + break; } } - if(!inRecipe) - { + if (!inRecipe) { return false; } } @@ -132,48 +116,48 @@ public class ShapelessMekanismRecipe implements IRecipe return required.isEmpty(); } - public ArrayList getInput() - { + public ArrayList getInput() { return input; } - - public static ShapelessMekanismRecipe create(NBTTagCompound nbtTags) - { - if(!nbtTags.hasKey("result") || !nbtTags.hasKey("input")) - { - Mekanism.logger.error("[Mekanism] Shapeless recipe parse error: missing input or result compound tag."); - return null; - } - - ItemStack result = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("result")); - NBTTagList list = nbtTags.getTagList("input", NBT.TAG_COMPOUND); - - if(result == null || list.tagCount() == 0) - { - Mekanism.logger.error("[Mekanism] Shapeless recipe parse error: invalid result stack or input data list."); - return null; - } - - Object[] ret = new Object[list.tagCount()]; - - for(int i = 0; i < list.tagCount(); i++) - { - NBTTagCompound compound = list.getCompoundTagAt(i); - - if(compound.hasKey("oredict")) - { - ret[i] = compound.getString("oredict"); - } - else if(compound.hasKey("itemstack")) - { - ret[i] = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("itemstack")); - } - else { - Mekanism.logger.error("[Mekanism] Shapeless recipe parse error: invalid input tag data key."); - return null; - } - } - - return new ShapelessMekanismRecipe(result, ret); + + public static ShapelessMekanismRecipe create(NBTTagCompound nbtTags) { + if (!nbtTags.hasKey("result") || !nbtTags.hasKey("input")) { + Mekanism.logger.error( + "[Mekanism] Shapeless recipe parse error: missing input or result compound tag." + ); + return null; + } + + ItemStack result + = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("result")); + NBTTagList list = nbtTags.getTagList("input", NBT.TAG_COMPOUND); + + if (result == null || list.tagCount() == 0) { + Mekanism.logger.error( + "[Mekanism] Shapeless recipe parse error: invalid result stack or input data list." + ); + return null; + } + + Object[] ret = new Object[list.tagCount()]; + + for (int i = 0; i < list.tagCount(); i++) { + NBTTagCompound compound = list.getCompoundTagAt(i); + + if (compound.hasKey("oredict")) { + ret[i] = compound.getString("oredict"); + } else if (compound.hasKey("itemstack")) { + ret[i] + = ItemStack.loadItemStackFromNBT(compound.getCompoundTag("itemstack") + ); + } else { + Mekanism.logger.error( + "[Mekanism] Shapeless recipe parse error: invalid input tag data key." + ); + return null; + } + } + + return new ShapelessMekanismRecipe(result, ret); } } diff --git a/src/main/java/mekanism/common/recipe/inputs/AdvancedMachineInput.java b/src/main/java/mekanism/common/recipe/inputs/AdvancedMachineInput.java index 0cba3c79a..c24ac05f5 100644 --- a/src/main/java/mekanism/common/recipe/inputs/AdvancedMachineInput.java +++ b/src/main/java/mekanism/common/recipe/inputs/AdvancedMachineInput.java @@ -6,89 +6,76 @@ import mekanism.api.util.StackUtils; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -public class AdvancedMachineInput extends MachineInput -{ - public ItemStack itemStack; +public class AdvancedMachineInput extends MachineInput { + public ItemStack itemStack; - public Gas gasType; + public Gas gasType; - public AdvancedMachineInput(ItemStack item, Gas gas) - { - itemStack = item; - gasType = gas; - } - - public AdvancedMachineInput() {} - - @Override - public void load(NBTTagCompound nbtTags) - { - itemStack = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("input")); - gasType = Gas.readFromNBT(nbtTags.getCompoundTag("gasType")); - } + public AdvancedMachineInput(ItemStack item, Gas gas) { + itemStack = item; + gasType = gas; + } - @Override - public AdvancedMachineInput copy() - { - return new AdvancedMachineInput(itemStack.copy(), gasType); - } + public AdvancedMachineInput() {} - @Override - public boolean isValid() - { - return itemStack != null && gasType != null; - } + @Override + public void load(NBTTagCompound nbtTags) { + itemStack = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("input")); + gasType = Gas.readFromNBT(nbtTags.getCompoundTag("gasType")); + } - public boolean useItem(ItemStack[] inventory, int index, boolean deplete) - { - if(inputContains(inventory[index], itemStack)) - { - if(deplete) - { - inventory[index] = StackUtils.subtract(inventory[index], itemStack); - } - - return true; - } - - return false; - } + @Override + public AdvancedMachineInput copy() { + return new AdvancedMachineInput(itemStack.copy(), gasType); + } - public boolean useSecondary(GasTank gasTank, int amountToUse, boolean deplete) - { - if(gasTank.getGasType() == gasType && gasTank.getStored() >= amountToUse) - { - gasTank.draw(amountToUse, deplete); - return true; - } - - return false; - } + @Override + public boolean isValid() { + return itemStack != null && gasType != null; + } - public boolean matches(AdvancedMachineInput input) - { - return StackUtils.equalsWildcard(itemStack, input.itemStack) && input.itemStack.stackSize >= itemStack.stackSize; - } + public boolean useItem(ItemStack[] inventory, int index, boolean deplete) { + if (inputContains(inventory[index], itemStack)) { + if (deplete) { + inventory[index] = StackUtils.subtract(inventory[index], itemStack); + } - @Override - public int hashIngredients() - { - return StackUtils.hashItemStack(itemStack) << 8 | gasType.getID(); - } + return true; + } - @Override - public boolean testEquality(AdvancedMachineInput other) - { - if(!isValid()) - { - return !other.isValid(); - } - return StackUtils.equalsWildcardWithNBT(itemStack, other.itemStack) && gasType.getID() == other.gasType.getID(); - } + return false; + } - @Override - public boolean isInstance(Object other) - { - return other instanceof AdvancedMachineInput; - } + public boolean useSecondary(GasTank gasTank, int amountToUse, boolean deplete) { + if (gasTank.getGasType() == gasType && gasTank.getStored() >= amountToUse) { + gasTank.draw(amountToUse, deplete); + return true; + } + + return false; + } + + public boolean matches(AdvancedMachineInput input) { + return StackUtils.equalsWildcard(itemStack, input.itemStack) + && input.itemStack.stackSize >= itemStack.stackSize; + } + + @Override + public int hashIngredients() { + return StackUtils.hashItemStack(itemStack) << 8 | gasType.getID(); + } + + @Override + public boolean testEquality(AdvancedMachineInput other) { + if (!isValid()) { + return !other.isValid(); + } + return StackUtils.equalsWildcardWithNBT(itemStack, other.itemStack) + && gasType.getID() == other.gasType.getID(); + } + + @Override + public boolean isInstance(Object other) { + return other instanceof AdvancedMachineInput; + } } diff --git a/src/main/java/mekanism/common/recipe/inputs/ChemicalPairInput.java b/src/main/java/mekanism/common/recipe/inputs/ChemicalPairInput.java index 7be009fdf..37e2953fe 100644 --- a/src/main/java/mekanism/common/recipe/inputs/ChemicalPairInput.java +++ b/src/main/java/mekanism/common/recipe/inputs/ChemicalPairInput.java @@ -9,172 +9,156 @@ import net.minecraft.nbt.NBTTagCompound; * @author aidancbrady * */ -public class ChemicalPairInput extends MachineInput -{ - /** The left gas of this chemical input */ - public GasStack leftGas; +public class ChemicalPairInput extends MachineInput { + /** The left gas of this chemical input */ + public GasStack leftGas; - /** The right gas of this chemical input */ - public GasStack rightGas; + /** 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 ChemicalPairInput(GasStack left, GasStack right) - { - leftGas = left; - rightGas = right; - } - - @Override - public void load(NBTTagCompound nbtTags) - { - leftGas = GasStack.readFromNBT(nbtTags.getCompoundTag("leftInput")); - rightGas = GasStack.readFromNBT(nbtTags.getCompoundTag("rightInput")); - } - - public ChemicalPairInput() {} + /** + * Creates a chemical input with two defined gasses. + * @param left - left gas + * @param right - right gas + */ + public ChemicalPairInput(GasStack left, GasStack right) { + leftGas = left; + rightGas = right; + } - public boolean useGas(GasTank leftTank, GasTank rightTank, boolean deplete, int scale) - { - int leftAmount = leftGas.amount * scale; - int rightAmount = rightGas.amount * scale; - - if(leftTank.canDraw(leftGas.getGas()) && rightTank.canDraw(rightGas.getGas())) - { - if(leftTank.getStored() >= leftAmount && rightTank.getStored() >= rightAmount) - { - leftTank.draw(leftAmount, deplete); - rightTank.draw(rightAmount, deplete); - - return true; - } - } - else if(leftTank.canDraw(rightGas.getGas()) && rightTank.canDraw(leftGas.getGas())) - { - if(leftTank.getStored() >= rightAmount && rightTank.getStored() >= leftAmount) - { - leftTank.draw(rightAmount, deplete); - rightTank.draw(leftAmount, deplete); - - return true; - } - } - - return false; - } + @Override + public void load(NBTTagCompound nbtTags) { + leftGas = GasStack.readFromNBT(nbtTags.getCompoundTag("leftInput")); + rightGas = GasStack.readFromNBT(nbtTags.getCompoundTag("rightInput")); + } - /** - * If this is a valid ChemicalPair - * @return - */ - @Override - public boolean isValid() - { - return leftGas != null && rightGas != null; - } + public ChemicalPairInput() {} - /** - * 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(ChemicalPairInput input) - { - return meets(input) || meets(input.swap()); - } + public boolean + useGas(GasTank leftTank, GasTank rightTank, boolean deplete, int scale) { + int leftAmount = leftGas.amount * scale; + int rightAmount = rightGas.amount * scale; - /** - * Swaps the right gas and left gas of this input. - * @return a swapped ChemicalInput - */ - public ChemicalPairInput swap() - { - return new ChemicalPairInput(rightGas, leftGas); - } + if (leftTank.canDraw(leftGas.getGas()) && rightTank.canDraw(rightGas.getGas())) { + if (leftTank.getStored() >= leftAmount + && rightTank.getStored() >= rightAmount) { + leftTank.draw(leftAmount, deplete); + rightTank.draw(rightAmount, deplete); - /** - * 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 ChemicalPairInput(leftTank.getGas(), rightTank.getGas()))) - { - leftTank.draw(leftGas.amount, true); - rightTank.draw(rightGas.amount, true); - } - else if(meets(new ChemicalPairInput(rightTank.getGas(), leftTank.getGas()))) - { - leftTank.draw(rightGas.amount, true); - rightTank.draw(leftGas.amount, true); - } - } + return true; + } + } else if (leftTank.canDraw(rightGas.getGas()) && rightTank.canDraw(leftGas.getGas())) { + if (leftTank.getStored() >= rightAmount + && rightTank.getStored() >= leftAmount) { + leftTank.draw(rightAmount, deplete); + rightTank.draw(leftAmount, deplete); - /** - * 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 true; + } + } - return stack.isGasEqual(leftGas) || stack.isGasEqual(rightGas); - } + return false; + } - /** - * Actual implementation of meetsInput(), performs the checks. - * @param input - input to check - * @return if the input meets this input's requirements - */ - private boolean meets(ChemicalPairInput input) - { - if(input == null || !input.isValid()) - { - return false; - } + /** + * If this is a valid ChemicalPair + * @return + */ + @Override + public boolean isValid() { + return leftGas != null && rightGas != null; + } - if(input.leftGas.getGas() != leftGas.getGas() || input.rightGas.getGas() != rightGas.getGas()) - { - return false; - } + /** + * 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(ChemicalPairInput input) { + return meets(input) || meets(input.swap()); + } - return input.leftGas.amount >= leftGas.amount && input.rightGas.amount >= rightGas.amount; - } + /** + * Swaps the right gas and left gas of this input. + * @return a swapped ChemicalInput + */ + public ChemicalPairInput swap() { + return new ChemicalPairInput(rightGas, leftGas); + } - @Override - public ChemicalPairInput copy() - { - return new ChemicalPairInput(leftGas.copy(), rightGas.copy()); - } + /** + * 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 ChemicalPairInput(leftTank.getGas(), rightTank.getGas()))) { + leftTank.draw(leftGas.amount, true); + rightTank.draw(rightGas.amount, true); + } else if (meets(new ChemicalPairInput(rightTank.getGas(), leftTank.getGas()))) { + leftTank.draw(rightGas.amount, true); + rightTank.draw(leftGas.amount, true); + } + } - @Override - public int hashIngredients() - { - return (leftGas.hashCode() << 8 | rightGas.hashCode()) + (rightGas.hashCode() << 8 | leftGas.hashCode()); - } + /** + * 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; + } - @Override - public boolean testEquality(ChemicalPairInput other) - { - if(!isValid()) - { - return !other.isValid(); - } - return (other.leftGas.hashCode() == leftGas.hashCode() && other.rightGas.hashCode() == rightGas.hashCode()) - || (other.leftGas.hashCode() == rightGas.hashCode() && other.rightGas.hashCode() == leftGas.hashCode()); - } + return stack.isGasEqual(leftGas) || stack.isGasEqual(rightGas); + } - @Override - public boolean isInstance(Object other) - { - return other instanceof ChemicalPairInput; - } + /** + * Actual implementation of meetsInput(), performs the checks. + * @param input - input to check + * @return if the input meets this input's requirements + */ + private boolean meets(ChemicalPairInput 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; + } + + @Override + public ChemicalPairInput copy() { + return new ChemicalPairInput(leftGas.copy(), rightGas.copy()); + } + + @Override + public int hashIngredients() { + return (leftGas.hashCode() << 8 | rightGas.hashCode()) + + (rightGas.hashCode() << 8 | leftGas.hashCode()); + } + + @Override + public boolean testEquality(ChemicalPairInput other) { + if (!isValid()) { + return !other.isValid(); + } + return (other.leftGas.hashCode() == leftGas.hashCode() + && other.rightGas.hashCode() == rightGas.hashCode()) + || (other.leftGas.hashCode() == rightGas.hashCode() + && other.rightGas.hashCode() == leftGas.hashCode()); + } + + @Override + public boolean isInstance(Object other) { + return other instanceof ChemicalPairInput; + } } diff --git a/src/main/java/mekanism/common/recipe/inputs/FluidInput.java b/src/main/java/mekanism/common/recipe/inputs/FluidInput.java index 90deeef43..e30cd75ff 100644 --- a/src/main/java/mekanism/common/recipe/inputs/FluidInput.java +++ b/src/main/java/mekanism/common/recipe/inputs/FluidInput.java @@ -4,65 +4,55 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; -public class FluidInput extends MachineInput -{ - public FluidStack ingredient; +public class FluidInput extends MachineInput { + public FluidStack ingredient; - public FluidInput(FluidStack stack) - { - ingredient = stack; - } - - public FluidInput() {} - - @Override - public void load(NBTTagCompound nbtTags) - { - ingredient = FluidStack.loadFluidStackFromNBT(nbtTags.getCompoundTag("input")); - } + public FluidInput(FluidStack stack) { + ingredient = stack; + } - @Override - public FluidInput copy() - { - return new FluidInput(ingredient.copy()); - } + public FluidInput() {} - @Override - public boolean isValid() - { - return ingredient != null; - } + @Override + public void load(NBTTagCompound nbtTags) { + ingredient = FluidStack.loadFluidStackFromNBT(nbtTags.getCompoundTag("input")); + } - public boolean useFluid(FluidTank fluidTank, boolean deplete, int scale) - { - if(fluidTank.getFluid() != null && fluidTank.getFluid().containsFluid(ingredient)) - { - fluidTank.drain(ingredient.amount*scale, deplete); - return true; - } - - return false; - } + @Override + public FluidInput copy() { + return new FluidInput(ingredient.copy()); + } - @Override - public int hashIngredients() - { - return ingredient.getFluid() != null ? ingredient.getFluid().hashCode() : 0; - } + @Override + public boolean isValid() { + return ingredient != null; + } - @Override - public boolean testEquality(FluidInput other) - { - if(!isValid()) - { - return !other.isValid(); - } - return ingredient.equals(other.ingredient); - } + public boolean useFluid(FluidTank fluidTank, boolean deplete, int scale) { + if (fluidTank.getFluid() != null + && fluidTank.getFluid().containsFluid(ingredient)) { + fluidTank.drain(ingredient.amount * scale, deplete); + return true; + } - @Override - public boolean isInstance(Object other) - { - return other instanceof FluidInput; - } + return false; + } + + @Override + public int hashIngredients() { + return ingredient.getFluid() != null ? ingredient.getFluid().hashCode() : 0; + } + + @Override + public boolean testEquality(FluidInput other) { + if (!isValid()) { + return !other.isValid(); + } + return ingredient.equals(other.ingredient); + } + + @Override + public boolean isInstance(Object other) { + return other instanceof FluidInput; + } } diff --git a/src/main/java/mekanism/common/recipe/inputs/GasInput.java b/src/main/java/mekanism/common/recipe/inputs/GasInput.java index 963da0973..38232d533 100644 --- a/src/main/java/mekanism/common/recipe/inputs/GasInput.java +++ b/src/main/java/mekanism/common/recipe/inputs/GasInput.java @@ -4,67 +4,57 @@ import mekanism.api.gas.GasStack; import mekanism.api.gas.GasTank; import net.minecraft.nbt.NBTTagCompound; -public class GasInput extends MachineInput -{ - public GasStack ingredient; +public class GasInput extends MachineInput { + public GasStack ingredient; - public GasInput(GasStack stack) - { - ingredient = stack; - } - - public GasInput() {} - - @Override - public void load(NBTTagCompound nbtTags) - { - ingredient = GasStack.readFromNBT(nbtTags.getCompoundTag("input")); - } + public GasInput(GasStack stack) { + ingredient = stack; + } - @Override - public GasInput copy() - { - return new GasInput(ingredient.copy()); - } + public GasInput() {} - @Override - public boolean isValid() - { - return ingredient != null; - } + @Override + public void load(NBTTagCompound nbtTags) { + ingredient = GasStack.readFromNBT(nbtTags.getCompoundTag("input")); + } - public boolean useGas(GasTank gasTank, boolean deplete, int scale) - { - if(gasTank.getGasType() == ingredient.getGas() && gasTank.getStored() >= ingredient.amount*scale) - { - gasTank.draw(ingredient.amount*scale, deplete); - - return true; - } - - return false; - } + @Override + public GasInput copy() { + return new GasInput(ingredient.copy()); + } - @Override - public int hashIngredients() - { - return ingredient.hashCode(); - } + @Override + public boolean isValid() { + return ingredient != null; + } - @Override - public boolean testEquality(GasInput other) - { - if(!isValid()) - { - return !other.isValid(); - } - - return other.ingredient.hashCode() == ingredient.hashCode(); - } + public boolean useGas(GasTank gasTank, boolean deplete, int scale) { + if (gasTank.getGasType() == ingredient.getGas() + && gasTank.getStored() >= ingredient.amount * scale) { + gasTank.draw(ingredient.amount * scale, deplete); - @Override - public boolean isInstance(Object other) - { - return other instanceof GasInput; - } + return true; + } + + return false; + } + + @Override + public int hashIngredients() { + return ingredient.hashCode(); + } + + @Override + public boolean testEquality(GasInput other) { + if (!isValid()) { + return !other.isValid(); + } + + return other.ingredient.hashCode() == ingredient.hashCode(); + } + + @Override + public boolean isInstance(Object other) { + return other instanceof GasInput; + } } diff --git a/src/main/java/mekanism/common/recipe/inputs/InfusionInput.java b/src/main/java/mekanism/common/recipe/inputs/InfusionInput.java index 840443291..23a01108b 100644 --- a/src/main/java/mekanism/common/recipe/inputs/InfusionInput.java +++ b/src/main/java/mekanism/common/recipe/inputs/InfusionInput.java @@ -8,88 +8,80 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; /** - * An infusion input, containing the type of and amount of infuse the operation requires, as well as the input 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 extends MachineInput -{ - public InfuseStorage infuse; +public class InfusionInput extends MachineInput { + public InfuseStorage infuse; - /** The input ItemStack */ - public ItemStack inputStack; + /** The input ItemStack */ + public ItemStack inputStack; - public InfusionInput(InfuseStorage storage, ItemStack itemStack) - { - infuse = new InfuseStorage(storage.type, storage.amount); - inputStack = itemStack; - } + public InfusionInput(InfuseStorage storage, ItemStack itemStack) { + infuse = new InfuseStorage(storage.type, storage.amount); + inputStack = itemStack; + } - public InfusionInput(InfuseType infusionType, int required, ItemStack itemStack) - { - infuse = new InfuseStorage(infusionType, required); - inputStack = itemStack; - } - - @Override - public void load(NBTTagCompound nbtTags) - { - inputStack = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("input")); - InfuseType type = InfuseRegistry.get(nbtTags.getString("infuseType")); - int amount = nbtTags.getInteger("infuseAmount"); - infuse = new InfuseStorage(type, amount); - } - - public InfusionInput() {} + public InfusionInput(InfuseType infusionType, int required, ItemStack itemStack) { + infuse = new InfuseStorage(infusionType, required); + inputStack = itemStack; + } - @Override - public InfusionInput copy() - { - return new InfusionInput(infuse.type, infuse.amount, inputStack.copy()); - } + @Override + public void load(NBTTagCompound nbtTags) { + inputStack = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("input")); + InfuseType type = InfuseRegistry.get(nbtTags.getString("infuseType")); + int amount = nbtTags.getInteger("infuseAmount"); + infuse = new InfuseStorage(type, amount); + } - @Override - public boolean isValid() - { - return infuse.type != null && inputStack != null; - } + public InfusionInput() {} - public boolean use(ItemStack[] inventory, int index, InfuseStorage infuseStorage, boolean deplete) - { - if(inputContains(inventory[index], inputStack) && infuseStorage.contains(infuse)) - { - if(deplete) - { - inventory[index] = StackUtils.subtract(inventory[index], inputStack); - infuseStorage.subtract(infuse); - } - - return true; - } - - return false; - } + @Override + public InfusionInput copy() { + return new InfusionInput(infuse.type, infuse.amount, inputStack.copy()); + } - @Override - public int hashIngredients() - { - return infuse.type.unlocalizedName.hashCode() << 8 | StackUtils.hashItemStack(inputStack); - } + @Override + public boolean isValid() { + return infuse.type != null && inputStack != null; + } - @Override - public boolean testEquality(InfusionInput other) - { - if(!isValid()) - { - return !other.isValid(); - } - - return infuse.type == other.infuse.type && StackUtils.equalsWildcardWithNBT(inputStack, other.inputStack); - } + public boolean + use(ItemStack[] inventory, int index, InfuseStorage infuseStorage, boolean deplete) { + if (inputContains(inventory[index], inputStack) + && infuseStorage.contains(infuse)) { + if (deplete) { + inventory[index] = StackUtils.subtract(inventory[index], inputStack); + infuseStorage.subtract(infuse); + } - @Override - public boolean isInstance(Object other) - { - return other instanceof InfusionInput; - } + return true; + } + + return false; + } + + @Override + public int hashIngredients() { + return infuse.type.unlocalizedName.hashCode() << 8 + | StackUtils.hashItemStack(inputStack); + } + + @Override + public boolean testEquality(InfusionInput other) { + if (!isValid()) { + return !other.isValid(); + } + + return infuse.type == other.infuse.type + && StackUtils.equalsWildcardWithNBT(inputStack, other.inputStack); + } + + @Override + public boolean isInstance(Object other) { + return other instanceof InfusionInput; + } } diff --git a/src/main/java/mekanism/common/recipe/inputs/IntegerInput.java b/src/main/java/mekanism/common/recipe/inputs/IntegerInput.java index 0469481e8..e3d6f6533 100644 --- a/src/main/java/mekanism/common/recipe/inputs/IntegerInput.java +++ b/src/main/java/mekanism/common/recipe/inputs/IntegerInput.java @@ -2,50 +2,42 @@ package mekanism.common.recipe.inputs; import net.minecraft.nbt.NBTTagCompound; -public class IntegerInput extends MachineInput -{ - public int ingredient; +public class IntegerInput extends MachineInput { + public int ingredient; - public IntegerInput(int integer) - { - ingredient = integer; - } - - public IntegerInput() {} - - @Override - public void load(NBTTagCompound nbtTags) - { - ingredient = nbtTags.getInteger("input"); - } + public IntegerInput(int integer) { + ingredient = integer; + } - @Override - public IntegerInput copy() - { - return new IntegerInput(ingredient); - } + public IntegerInput() {} - @Override - public boolean isValid() - { - return true; - } + @Override + public void load(NBTTagCompound nbtTags) { + ingredient = nbtTags.getInteger("input"); + } - @Override - public int hashIngredients() - { - return ingredient; - } + @Override + public IntegerInput copy() { + return new IntegerInput(ingredient); + } - @Override - public boolean testEquality(IntegerInput other) - { - return ingredient == other.ingredient; - } + @Override + public boolean isValid() { + return true; + } - @Override - public boolean isInstance(Object other) - { - return other instanceof IntegerInput; - } + @Override + public int hashIngredients() { + return ingredient; + } + + @Override + public boolean testEquality(IntegerInput other) { + return ingredient == other.ingredient; + } + + @Override + public boolean isInstance(Object other) { + return other instanceof IntegerInput; + } } diff --git a/src/main/java/mekanism/common/recipe/inputs/ItemStackInput.java b/src/main/java/mekanism/common/recipe/inputs/ItemStackInput.java index 76d0a8b7f..da0fd1efa 100644 --- a/src/main/java/mekanism/common/recipe/inputs/ItemStackInput.java +++ b/src/main/java/mekanism/common/recipe/inputs/ItemStackInput.java @@ -5,70 +5,61 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.oredict.OreDictionary; -public class ItemStackInput extends MachineInput -{ - public ItemStack ingredient; +public class ItemStackInput extends MachineInput { + public ItemStack ingredient; - public ItemStackInput(ItemStack stack) - { - ingredient = stack; - } - - public ItemStackInput() {} - - @Override - public void load(NBTTagCompound nbtTags) - { - ingredient = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("input")); - } + public ItemStackInput(ItemStack stack) { + ingredient = stack; + } - @Override - public ItemStackInput copy() - { - return new ItemStackInput(ingredient.copy()); - } + public ItemStackInput() {} - @Override - public boolean isValid() - { - return ingredient != null; - } + @Override + public void load(NBTTagCompound nbtTags) { + ingredient = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("input")); + } - public ItemStackInput wildCopy() - { - return new ItemStackInput(new ItemStack(ingredient.getItem(), ingredient.stackSize, OreDictionary.WILDCARD_VALUE)); - } + @Override + public ItemStackInput copy() { + return new ItemStackInput(ingredient.copy()); + } - public boolean useItemStackFromInventory(ItemStack[] inventory, int index, boolean deplete) - { - if(inputContains(inventory[index], ingredient)) - { - if(deplete) - { - inventory[index] = StackUtils.subtract(inventory[index], ingredient); - } - - return true; - } - - return false; - } + @Override + public boolean isValid() { + return ingredient != null; + } - @Override - public int hashIngredients() - { - return StackUtils.hashItemStack(ingredient); - } + public ItemStackInput wildCopy() { + return new ItemStackInput(new ItemStack( + ingredient.getItem(), ingredient.stackSize, OreDictionary.WILDCARD_VALUE + )); + } - @Override - public boolean testEquality(ItemStackInput other) - { - return StackUtils.equalsWildcardWithNBT(ingredient, other.ingredient); - } + public boolean + useItemStackFromInventory(ItemStack[] inventory, int index, boolean deplete) { + if (inputContains(inventory[index], ingredient)) { + if (deplete) { + inventory[index] = StackUtils.subtract(inventory[index], ingredient); + } - @Override - public boolean isInstance(Object other) - { - return other instanceof ItemStackInput; - } + return true; + } + + return false; + } + + @Override + public int hashIngredients() { + return StackUtils.hashItemStack(ingredient); + } + + @Override + public boolean testEquality(ItemStackInput other) { + return StackUtils.equalsWildcardWithNBT(ingredient, other.ingredient); + } + + @Override + public boolean isInstance(Object other) { + return other instanceof ItemStackInput; + } } diff --git a/src/main/java/mekanism/common/recipe/inputs/MachineInput.java b/src/main/java/mekanism/common/recipe/inputs/MachineInput.java index 7340c5888..337174691 100644 --- a/src/main/java/mekanism/common/recipe/inputs/MachineInput.java +++ b/src/main/java/mekanism/common/recipe/inputs/MachineInput.java @@ -5,57 +5,51 @@ import mekanism.common.util.MekanismUtils; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -public abstract class MachineInput> -{ - public abstract boolean isValid(); +public abstract class MachineInput> { + public abstract boolean isValid(); - public abstract INPUT copy(); + public abstract INPUT copy(); - public abstract int hashIngredients(); - - public abstract void load(NBTTagCompound nbtTags); + public abstract int hashIngredients(); - /** - * Test equality to another input. - * This should return true if the input matches this one, - * IGNORING AMOUNTS. - * Allows usage of HashMap optimisation to get recipes. - * @param other - * @return - */ - public abstract boolean testEquality(INPUT other); - - public static boolean inputContains(ItemStack container, ItemStack contained) - { - if(container != null && container.stackSize >= contained.stackSize) - { - if(MekanismUtils.getOreDictName(container).contains("treeSapling")) - { - return StackUtils.equalsWildcard(contained, container); - } - - return StackUtils.equalsWildcardWithNBT(contained, container) && container.stackSize >= contained.stackSize; - } - - return false; - } + public abstract void load(NBTTagCompound nbtTags); - @Override - public int hashCode() - { - return hashIngredients(); - } + /** + * Test equality to another input. + * This should return true if the input matches this one, + * IGNORING AMOUNTS. + * Allows usage of HashMap optimisation to get recipes. + * @param other + * @return + */ + public abstract boolean testEquality(INPUT other); - @Override - public boolean equals(Object other) - { - if(isInstance(other)) - { - return testEquality((INPUT)other); - } - - return false; - } + public static boolean inputContains(ItemStack container, ItemStack contained) { + if (container != null && container.stackSize >= contained.stackSize) { + if (MekanismUtils.getOreDictName(container).contains("treeSapling")) { + return StackUtils.equalsWildcard(contained, container); + } - public abstract boolean isInstance(Object other); + return StackUtils.equalsWildcardWithNBT(contained, container) + && container.stackSize >= contained.stackSize; + } + + return false; + } + + @Override + public int hashCode() { + return hashIngredients(); + } + + @Override + public boolean equals(Object other) { + if (isInstance(other)) { + return testEquality((INPUT) other); + } + + return false; + } + + public abstract boolean isInstance(Object other); } diff --git a/src/main/java/mekanism/common/recipe/inputs/PressurizedInput.java b/src/main/java/mekanism/common/recipe/inputs/PressurizedInput.java index 2fc3e919e..60d422dfb 100644 --- a/src/main/java/mekanism/common/recipe/inputs/PressurizedInput.java +++ b/src/main/java/mekanism/common/recipe/inputs/PressurizedInput.java @@ -11,154 +11,148 @@ import net.minecraftforge.fluids.FluidTank; /** * An input of a gas, a fluid and an item for the pressurized reaction chamber */ -public class PressurizedInput extends MachineInput -{ - private ItemStack theSolid; - private FluidStack theFluid; - private GasStack theGas; +public class PressurizedInput extends MachineInput { + private ItemStack theSolid; + private FluidStack theFluid; + private GasStack theGas; - public PressurizedInput(ItemStack solid, FluidStack fluid, GasStack gas) - { - theSolid = solid; - theFluid = fluid; - theGas = gas; - } - - public PressurizedInput() {} - - @Override - public void load(NBTTagCompound nbtTags) - { - theSolid = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("itemInput")); - theFluid = FluidStack.loadFluidStackFromNBT(nbtTags.getCompoundTag("fluidInput")); - theGas = GasStack.readFromNBT(nbtTags.getCompoundTag("gasInput")); - } + public PressurizedInput(ItemStack solid, FluidStack fluid, GasStack gas) { + theSolid = solid; + theFluid = fluid; + theGas = gas; + } - /** - * If this is a valid PressurizedReactants - */ - @Override - public boolean isValid() - { - return theSolid != null && theFluid != null && theGas != null; - } + public PressurizedInput() {} - public boolean use(ItemStack[] inventory, int index, FluidTank fluidTank, GasTank gasTank, boolean deplete) - { - if(meets(new PressurizedInput(inventory[index], fluidTank.getFluid(), gasTank.getGas()))) - { - if(deplete) - { - inventory[index] = StackUtils.subtract(inventory[index], theSolid); - fluidTank.drain(theFluid.amount, true); - gasTank.draw(theGas.amount, true); - } - return true; - } - return false; - } + @Override + public void load(NBTTagCompound nbtTags) { + theSolid = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("itemInput")); + theFluid = FluidStack.loadFluidStackFromNBT(nbtTags.getCompoundTag("fluidInput")); + theGas = GasStack.readFromNBT(nbtTags.getCompoundTag("gasInput")); + } - /** - * 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; - } + /** + * If this is a valid PressurizedReactants + */ + @Override + public boolean isValid() { + return theSolid != null && theFluid != null && theGas != null; + } - return StackUtils.equalsWildcard(stack, theSolid); - } + public boolean + use(ItemStack[] inventory, + int index, + FluidTank fluidTank, + GasTank gasTank, + boolean deplete) { + if (meets(new PressurizedInput( + inventory[index], fluidTank.getFluid(), gasTank.getGas() + ))) { + if (deplete) { + inventory[index] = StackUtils.subtract(inventory[index], theSolid); + fluidTank.drain(theFluid.amount, true); + gasTank.draw(theGas.amount, true); + } + return true; + } + return false; + } - /** - * 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; - } + /** + * 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 stack.isFluidEqual(theFluid); - } + return StackUtils.equalsWildcard(stack, theSolid); + } - /** - * 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; - } + /** + * 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.isGasEqual(theGas); - } + return stack.isFluidEqual(theFluid); + } - /** - * Actual implementation of meetsInput(), performs the checks. - * @param input - input to check - * @return if the input meets this input's requirements - */ - public boolean meets(PressurizedInput input) - { - if(input == null || !input.isValid()) - { - return false; - } + /** + * 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; + } - if(!(StackUtils.equalsWildcard(input.theSolid, theSolid) && input.theFluid.isFluidEqual(theFluid) && input.theGas.isGasEqual(theGas))) - { - return false; - } + return stack.isGasEqual(theGas); + } - return input.theSolid.stackSize >= theSolid.stackSize && input.theFluid.amount >= theFluid.amount && input.theGas.amount >= theGas.amount; - } + /** + * Actual implementation of meetsInput(), performs the checks. + * @param input - input to check + * @return if the input meets this input's requirements + */ + public boolean meets(PressurizedInput input) { + if (input == null || !input.isValid()) { + return false; + } - @Override - public PressurizedInput copy() - { - return new PressurizedInput(theSolid.copy(), theFluid.copy(), theGas.copy()); - } - - public ItemStack getSolid() - { - return theSolid; - } - - public FluidStack getFluid() - { - return theFluid; - } - - public GasStack getGas() - { - return theGas; - } + if (!(StackUtils.equalsWildcard(input.theSolid, theSolid) + && input.theFluid.isFluidEqual(theFluid) + && input.theGas.isGasEqual(theGas))) { + return false; + } - @Override - public int hashIngredients() - { - return StackUtils.hashItemStack(theSolid) << 16 | (theFluid.getFluid() != null ? theFluid.getFluid().hashCode() : 0) << 8 | theGas.hashCode(); - } + return input.theSolid.stackSize >= theSolid.stackSize + && input.theFluid.amount >= theFluid.amount + && input.theGas.amount >= theGas.amount; + } - @Override - public boolean testEquality(PressurizedInput other) - { - return other.containsType(theSolid) && other.containsType(theFluid) && other.containsType(theGas); - } + @Override + public PressurizedInput copy() { + return new PressurizedInput(theSolid.copy(), theFluid.copy(), theGas.copy()); + } - @Override - public boolean isInstance(Object other) - { - return other instanceof PressurizedInput; - } + public ItemStack getSolid() { + return theSolid; + } + + public FluidStack getFluid() { + return theFluid; + } + + public GasStack getGas() { + return theGas; + } + + @Override + public int hashIngredients() { + return StackUtils.hashItemStack(theSolid) << 16 + | (theFluid.getFluid() != null ? theFluid.getFluid().hashCode() : 0) << 8 + | theGas.hashCode(); + } + + @Override + public boolean testEquality(PressurizedInput other) { + return other.containsType(theSolid) && other.containsType(theFluid) + && other.containsType(theGas); + } + + @Override + public boolean isInstance(Object other) { + return other instanceof PressurizedInput; + } } diff --git a/src/main/java/mekanism/common/recipe/machines/AdvancedMachineRecipe.java b/src/main/java/mekanism/common/recipe/machines/AdvancedMachineRecipe.java index 06ca6782e..8506bed62 100644 --- a/src/main/java/mekanism/common/recipe/machines/AdvancedMachineRecipe.java +++ b/src/main/java/mekanism/common/recipe/machines/AdvancedMachineRecipe.java @@ -7,34 +7,45 @@ import mekanism.common.recipe.inputs.AdvancedMachineInput; import mekanism.common.recipe.outputs.ItemStackOutput; import net.minecraft.item.ItemStack; -public abstract class AdvancedMachineRecipe> extends MachineRecipe -{ - public AdvancedMachineRecipe(AdvancedMachineInput input, ItemStackOutput output) - { - super(input, output); - } +public abstract class AdvancedMachineRecipe> + extends MachineRecipe { + public AdvancedMachineRecipe(AdvancedMachineInput input, ItemStackOutput output) { + super(input, output); + } - public AdvancedMachineRecipe(ItemStack input, String gasName, ItemStack output) - { - this(new AdvancedMachineInput(input, GasRegistry.getGas(gasName)), new ItemStackOutput(output)); - } + public AdvancedMachineRecipe(ItemStack input, String gasName, ItemStack output) { + this( + new AdvancedMachineInput(input, GasRegistry.getGas(gasName)), + new ItemStackOutput(output) + ); + } - public AdvancedMachineRecipe(ItemStack input, Gas gas, ItemStack output) - { - this(new AdvancedMachineInput(input, gas), new ItemStackOutput(output)); - } + public AdvancedMachineRecipe(ItemStack input, Gas gas, ItemStack output) { + this(new AdvancedMachineInput(input, gas), new ItemStackOutput(output)); + } - public boolean canOperate(ItemStack[] inventory, int inputIndex, int outputIndex, GasTank gasTank, int amount) - { - return getInput().useItem(inventory, inputIndex, false) && getInput().useSecondary(gasTank, amount, false) && getOutput().applyOutputs(inventory, outputIndex, false); - } + public boolean canOperate( + ItemStack[] inventory, + int inputIndex, + int outputIndex, + GasTank gasTank, + int amount + ) { + return getInput().useItem(inventory, inputIndex, false) + && getInput().useSecondary(gasTank, amount, false) + && getOutput().applyOutputs(inventory, outputIndex, false); + } - public void operate(ItemStack[] inventory, int inputIndex, int outputIndex, GasTank gasTank, int needed) - { - if(getInput().useItem(inventory, inputIndex, true) && getInput().useSecondary(gasTank, needed, true)) - { - getOutput().applyOutputs(inventory, outputIndex, true); - } - - } + public void operate( + ItemStack[] inventory, + int inputIndex, + int outputIndex, + GasTank gasTank, + int needed + ) { + if (getInput().useItem(inventory, inputIndex, true) + && getInput().useSecondary(gasTank, needed, true)) { + getOutput().applyOutputs(inventory, outputIndex, true); + } + } } diff --git a/src/main/java/mekanism/common/recipe/machines/AmbientGasRecipe.java b/src/main/java/mekanism/common/recipe/machines/AmbientGasRecipe.java index 53d0dabfd..922e52757 100644 --- a/src/main/java/mekanism/common/recipe/machines/AmbientGasRecipe.java +++ b/src/main/java/mekanism/common/recipe/machines/AmbientGasRecipe.java @@ -5,20 +5,20 @@ import mekanism.api.gas.GasStack; import mekanism.common.recipe.inputs.IntegerInput; import mekanism.common.recipe.outputs.GasOutput; -public class AmbientGasRecipe extends MachineRecipe -{ - public AmbientGasRecipe(IntegerInput input, GasOutput output) - { - super(input, output); - } +public class AmbientGasRecipe + extends MachineRecipe { + public AmbientGasRecipe(IntegerInput input, GasOutput output) { + super(input, output); + } - public AmbientGasRecipe(int input, String output) - { - this(new IntegerInput(input), new GasOutput(new GasStack(GasRegistry.getGas(output), 1))); - } + public AmbientGasRecipe(int input, String output) { + this( + new IntegerInput(input), + new GasOutput(new GasStack(GasRegistry.getGas(output), 1)) + ); + } - public AmbientGasRecipe copy() - { - return new AmbientGasRecipe(getInput().copy(), getOutput().copy()); - } + public AmbientGasRecipe copy() { + return new AmbientGasRecipe(getInput().copy(), getOutput().copy()); + } } diff --git a/src/main/java/mekanism/common/recipe/machines/BasicMachineRecipe.java b/src/main/java/mekanism/common/recipe/machines/BasicMachineRecipe.java index e2f628edb..e01bdd2f5 100644 --- a/src/main/java/mekanism/common/recipe/machines/BasicMachineRecipe.java +++ b/src/main/java/mekanism/common/recipe/machines/BasicMachineRecipe.java @@ -4,28 +4,24 @@ import mekanism.common.recipe.inputs.ItemStackInput; import mekanism.common.recipe.outputs.ItemStackOutput; import net.minecraft.item.ItemStack; -public abstract class BasicMachineRecipe> extends MachineRecipe -{ - public BasicMachineRecipe(ItemStackInput input, ItemStackOutput output) - { - super(input, output); - } +public abstract class BasicMachineRecipe> + extends MachineRecipe { + public BasicMachineRecipe(ItemStackInput input, ItemStackOutput output) { + super(input, output); + } - public BasicMachineRecipe(ItemStack input, ItemStack output) - { - this(new ItemStackInput(input), new ItemStackOutput(output)); - } + public BasicMachineRecipe(ItemStack input, ItemStack output) { + this(new ItemStackInput(input), new ItemStackOutput(output)); + } - public boolean canOperate(ItemStack[] inventory, int inputIndex, int outputIndex) - { - return getInput().useItemStackFromInventory(inventory, inputIndex, false) && getOutput().applyOutputs(inventory, outputIndex, false); - } + public boolean canOperate(ItemStack[] inventory, int inputIndex, int outputIndex) { + return getInput().useItemStackFromInventory(inventory, inputIndex, false) + && getOutput().applyOutputs(inventory, outputIndex, false); + } - public void operate(ItemStack[] inventory, int inputIndex, int outputIndex) - { - if(getInput().useItemStackFromInventory(inventory, inputIndex, true)) - { - getOutput().applyOutputs(inventory, outputIndex, true); - } - } + public void operate(ItemStack[] inventory, int inputIndex, int outputIndex) { + if (getInput().useItemStackFromInventory(inventory, inputIndex, true)) { + getOutput().applyOutputs(inventory, outputIndex, true); + } + } } diff --git a/src/main/java/mekanism/common/recipe/machines/ChanceMachineRecipe.java b/src/main/java/mekanism/common/recipe/machines/ChanceMachineRecipe.java index 159a2d1ab..e5279713a 100644 --- a/src/main/java/mekanism/common/recipe/machines/ChanceMachineRecipe.java +++ b/src/main/java/mekanism/common/recipe/machines/ChanceMachineRecipe.java @@ -4,23 +4,22 @@ import mekanism.common.recipe.inputs.ItemStackInput; import mekanism.common.recipe.outputs.ChanceOutput; import net.minecraft.item.ItemStack; -public abstract class ChanceMachineRecipe> extends MachineRecipe -{ - public ChanceMachineRecipe(ItemStackInput input, ChanceOutput output) - { - super(input, output); - } +public abstract class ChanceMachineRecipe> + extends MachineRecipe { + public ChanceMachineRecipe(ItemStackInput input, ChanceOutput output) { + super(input, output); + } - public boolean canOperate(ItemStack[] inventory, int inputIndex, int primaryIndex, int secondaryIndex) - { - return getInput().useItemStackFromInventory(inventory, inputIndex, false) && getOutput().applyOutputs(inventory, primaryIndex, secondaryIndex, false); - } + public boolean canOperate( + ItemStack[] inventory, int inputIndex, int primaryIndex, int secondaryIndex + ) { + return getInput().useItemStackFromInventory(inventory, inputIndex, false) + && getOutput().applyOutputs(inventory, primaryIndex, secondaryIndex, false); + } - public void operate(ItemStack[] inventory) - { - if(getInput().useItemStackFromInventory(inventory, 0, true)) - { - getOutput().applyOutputs(inventory, 2, 4, true); - } - } + public void operate(ItemStack[] inventory) { + if (getInput().useItemStackFromInventory(inventory, 0, true)) { + getOutput().applyOutputs(inventory, 2, 4, true); + } + } } diff --git a/src/main/java/mekanism/common/recipe/machines/ChemicalInfuserRecipe.java b/src/main/java/mekanism/common/recipe/machines/ChemicalInfuserRecipe.java index 436d151dd..e1beea44f 100644 --- a/src/main/java/mekanism/common/recipe/machines/ChemicalInfuserRecipe.java +++ b/src/main/java/mekanism/common/recipe/machines/ChemicalInfuserRecipe.java @@ -5,34 +5,32 @@ import mekanism.api.gas.GasTank; import mekanism.common.recipe.inputs.ChemicalPairInput; import mekanism.common.recipe.outputs.GasOutput; -public class ChemicalInfuserRecipe extends MachineRecipe -{ - public ChemicalInfuserRecipe(ChemicalPairInput input, GasOutput output) - { - super(input, output); - } +public class ChemicalInfuserRecipe + extends MachineRecipe { + public ChemicalInfuserRecipe(ChemicalPairInput input, GasOutput output) { + super(input, output); + } - public ChemicalInfuserRecipe(GasStack leftInput, GasStack rightInput, GasStack output) - { - this(new ChemicalPairInput(leftInput, rightInput), new GasOutput(output)); - } + public ChemicalInfuserRecipe( + GasStack leftInput, GasStack rightInput, GasStack output + ) { + this(new ChemicalPairInput(leftInput, rightInput), new GasOutput(output)); + } - @Override - public ChemicalInfuserRecipe copy() - { - return new ChemicalInfuserRecipe(getInput().copy(), getOutput().copy()); - } + @Override + public ChemicalInfuserRecipe copy() { + return new ChemicalInfuserRecipe(getInput().copy(), getOutput().copy()); + } - public boolean canOperate(GasTank leftTank, GasTank rightTank, GasTank outputTank) - { - return getInput().useGas(leftTank, rightTank, false, 1) && getOutput().applyOutputs(outputTank, false, 1); - } + public boolean canOperate(GasTank leftTank, GasTank rightTank, GasTank outputTank) { + return getInput().useGas(leftTank, rightTank, false, 1) + && getOutput().applyOutputs(outputTank, false, 1); + } - public void operate(GasTank leftInput, GasTank rightInput, GasTank outputTank, int scale) - { - if(getInput().useGas(leftInput, rightInput, true, scale)) - { - getOutput().applyOutputs(outputTank, true, scale); - } - } + public void + operate(GasTank leftInput, GasTank rightInput, GasTank outputTank, int scale) { + if (getInput().useGas(leftInput, rightInput, true, scale)) { + getOutput().applyOutputs(outputTank, true, scale); + } + } } diff --git a/src/main/java/mekanism/common/recipe/machines/CombinerRecipe.java b/src/main/java/mekanism/common/recipe/machines/CombinerRecipe.java index 2f889fa0c..f74c60249 100644 --- a/src/main/java/mekanism/common/recipe/machines/CombinerRecipe.java +++ b/src/main/java/mekanism/common/recipe/machines/CombinerRecipe.java @@ -4,21 +4,17 @@ import mekanism.common.recipe.inputs.AdvancedMachineInput; import mekanism.common.recipe.outputs.ItemStackOutput; import net.minecraft.item.ItemStack; -public class CombinerRecipe extends AdvancedMachineRecipe -{ - public CombinerRecipe(AdvancedMachineInput input, ItemStackOutput output) - { - super(input, output); - } +public class CombinerRecipe extends AdvancedMachineRecipe { + public CombinerRecipe(AdvancedMachineInput input, ItemStackOutput output) { + super(input, output); + } - public CombinerRecipe(ItemStack input, ItemStack output) - { - super(input, "liquidStone", output); - } + public CombinerRecipe(ItemStack input, ItemStack output) { + super(input, "liquidStone", output); + } - @Override - public CombinerRecipe copy() - { - return new CombinerRecipe(getInput().copy(), getOutput().copy()); - } + @Override + public CombinerRecipe copy() { + return new CombinerRecipe(getInput().copy(), getOutput().copy()); + } } diff --git a/src/main/java/mekanism/common/recipe/machines/CrusherRecipe.java b/src/main/java/mekanism/common/recipe/machines/CrusherRecipe.java index c40937eb3..89469476d 100644 --- a/src/main/java/mekanism/common/recipe/machines/CrusherRecipe.java +++ b/src/main/java/mekanism/common/recipe/machines/CrusherRecipe.java @@ -4,21 +4,17 @@ import mekanism.common.recipe.inputs.ItemStackInput; import mekanism.common.recipe.outputs.ItemStackOutput; import net.minecraft.item.ItemStack; -public class CrusherRecipe extends BasicMachineRecipe -{ - public CrusherRecipe(ItemStackInput input, ItemStackOutput output) - { - super(input, output); - } +public class CrusherRecipe extends BasicMachineRecipe { + public CrusherRecipe(ItemStackInput input, ItemStackOutput output) { + super(input, output); + } - public CrusherRecipe(ItemStack input, ItemStack output) - { - super(input, output); - } + public CrusherRecipe(ItemStack input, ItemStack output) { + super(input, output); + } - @Override - public CrusherRecipe copy() - { - return new CrusherRecipe(getInput().copy(), getOutput().copy()); - } + @Override + public CrusherRecipe copy() { + return new CrusherRecipe(getInput().copy(), getOutput().copy()); + } } diff --git a/src/main/java/mekanism/common/recipe/machines/CrystallizerRecipe.java b/src/main/java/mekanism/common/recipe/machines/CrystallizerRecipe.java index 5122ca0c3..f41615830 100644 --- a/src/main/java/mekanism/common/recipe/machines/CrystallizerRecipe.java +++ b/src/main/java/mekanism/common/recipe/machines/CrystallizerRecipe.java @@ -6,34 +6,29 @@ import mekanism.common.recipe.inputs.GasInput; import mekanism.common.recipe.outputs.ItemStackOutput; import net.minecraft.item.ItemStack; -public class CrystallizerRecipe extends MachineRecipe -{ - public CrystallizerRecipe(GasInput input, ItemStackOutput output) - { - super(input, output); - } +public class CrystallizerRecipe + extends MachineRecipe { + public CrystallizerRecipe(GasInput input, ItemStackOutput output) { + super(input, output); + } - public CrystallizerRecipe(GasStack input, ItemStack output) - { - this(new GasInput(input), new ItemStackOutput(output)); - } + public CrystallizerRecipe(GasStack input, ItemStack output) { + this(new GasInput(input), new ItemStackOutput(output)); + } - public boolean canOperate(GasTank gasTank, ItemStack[] inventory) - { - return getInput().useGas(gasTank, false, 1) && getOutput().applyOutputs(inventory, 1, false); - } + public boolean canOperate(GasTank gasTank, ItemStack[] inventory) { + return getInput().useGas(gasTank, false, 1) + && getOutput().applyOutputs(inventory, 1, false); + } - public void operate(GasTank inputTank, ItemStack[] inventory) - { - if(getInput().useGas(inputTank, true, 1)) - { - getOutput().applyOutputs(inventory, 1, true); - } - } + public void operate(GasTank inputTank, ItemStack[] inventory) { + if (getInput().useGas(inputTank, true, 1)) { + getOutput().applyOutputs(inventory, 1, true); + } + } - @Override - public CrystallizerRecipe copy() - { - return new CrystallizerRecipe(getInput().copy(), getOutput().copy()); - } + @Override + public CrystallizerRecipe copy() { + return new CrystallizerRecipe(getInput().copy(), getOutput().copy()); + } } diff --git a/src/main/java/mekanism/common/recipe/machines/DissolutionRecipe.java b/src/main/java/mekanism/common/recipe/machines/DissolutionRecipe.java index 9d36ac30d..2b722fb51 100644 --- a/src/main/java/mekanism/common/recipe/machines/DissolutionRecipe.java +++ b/src/main/java/mekanism/common/recipe/machines/DissolutionRecipe.java @@ -6,34 +6,29 @@ import mekanism.common.recipe.inputs.ItemStackInput; import mekanism.common.recipe.outputs.GasOutput; import net.minecraft.item.ItemStack; -public class DissolutionRecipe extends MachineRecipe -{ - public DissolutionRecipe(ItemStackInput input, GasOutput output) - { - super(input, output); - } +public class DissolutionRecipe + extends MachineRecipe { + public DissolutionRecipe(ItemStackInput input, GasOutput output) { + super(input, output); + } - public DissolutionRecipe(ItemStack input, GasStack output) - { - this(new ItemStackInput(input), new GasOutput(output)); - } + public DissolutionRecipe(ItemStack input, GasStack output) { + this(new ItemStackInput(input), new GasOutput(output)); + } - public boolean canOperate(ItemStack[] inventory, GasTank outputTank) - { - return getInput().useItemStackFromInventory(inventory, 1, false) && getOutput().applyOutputs(outputTank, false, 1); - } + public boolean canOperate(ItemStack[] inventory, GasTank outputTank) { + return getInput().useItemStackFromInventory(inventory, 1, false) + && getOutput().applyOutputs(outputTank, false, 1); + } - public void operate(ItemStack[] inventory, GasTank outputTank) - { - if(getInput().useItemStackFromInventory(inventory, 1, true)) - { - getOutput().applyOutputs(outputTank, true, 1); - } - } + public void operate(ItemStack[] inventory, GasTank outputTank) { + if (getInput().useItemStackFromInventory(inventory, 1, true)) { + getOutput().applyOutputs(outputTank, true, 1); + } + } - @Override - public DissolutionRecipe copy() - { - return new DissolutionRecipe(getInput().copy(), getOutput().copy()); - } + @Override + public DissolutionRecipe copy() { + return new DissolutionRecipe(getInput().copy(), getOutput().copy()); + } } diff --git a/src/main/java/mekanism/common/recipe/machines/EnrichmentRecipe.java b/src/main/java/mekanism/common/recipe/machines/EnrichmentRecipe.java index a54df895d..464cccc42 100644 --- a/src/main/java/mekanism/common/recipe/machines/EnrichmentRecipe.java +++ b/src/main/java/mekanism/common/recipe/machines/EnrichmentRecipe.java @@ -4,21 +4,17 @@ import mekanism.common.recipe.inputs.ItemStackInput; import mekanism.common.recipe.outputs.ItemStackOutput; import net.minecraft.item.ItemStack; -public class EnrichmentRecipe extends BasicMachineRecipe -{ - public EnrichmentRecipe(ItemStackInput input, ItemStackOutput output) - { - super(input, output); - } +public class EnrichmentRecipe extends BasicMachineRecipe { + public EnrichmentRecipe(ItemStackInput input, ItemStackOutput output) { + super(input, output); + } - public EnrichmentRecipe(ItemStack input, ItemStack output) - { - super(input, output); - } + public EnrichmentRecipe(ItemStack input, ItemStack output) { + super(input, output); + } - @Override - public EnrichmentRecipe copy() - { - return new EnrichmentRecipe(getInput().copy(), getOutput().copy()); - } + @Override + public EnrichmentRecipe copy() { + return new EnrichmentRecipe(getInput().copy(), getOutput().copy()); + } } diff --git a/src/main/java/mekanism/common/recipe/machines/GasCentrifugeRecipe.java b/src/main/java/mekanism/common/recipe/machines/GasCentrifugeRecipe.java index f56525d71..c53e9df10 100644 --- a/src/main/java/mekanism/common/recipe/machines/GasCentrifugeRecipe.java +++ b/src/main/java/mekanism/common/recipe/machines/GasCentrifugeRecipe.java @@ -5,34 +5,29 @@ import mekanism.api.gas.GasTank; import mekanism.common.recipe.inputs.GasInput; import mekanism.common.recipe.outputs.GasOutput; -public class GasCentrifugeRecipe extends MachineRecipe -{ - public GasCentrifugeRecipe(GasStack input, GasStack output) - { - super(new GasInput(input), new GasOutput(output)); - } +public class GasCentrifugeRecipe + extends MachineRecipe { + public GasCentrifugeRecipe(GasStack input, GasStack output) { + super(new GasInput(input), new GasOutput(output)); + } - public GasCentrifugeRecipe(GasInput input, GasOutput output) - { - super(input, output); - } + public GasCentrifugeRecipe(GasInput input, GasOutput output) { + super(input, output); + } - @Override - public GasCentrifugeRecipe copy() - { - return new GasCentrifugeRecipe(getInput(), getOutput()); - } + @Override + public GasCentrifugeRecipe copy() { + return new GasCentrifugeRecipe(getInput(), getOutput()); + } - public boolean canOperate(GasTank inputTank, GasTank outputTank) - { - return getInput().useGas(inputTank, false, 1) && getOutput().applyOutputs(outputTank, false, 1); - } + public boolean canOperate(GasTank inputTank, GasTank outputTank) { + return getInput().useGas(inputTank, false, 1) + && getOutput().applyOutputs(outputTank, false, 1); + } - public void operate(GasTank inputTank, GasTank outputTank) - { - if(getInput().useGas(inputTank, true, 1)) - { - getOutput().applyOutputs(outputTank, true, 1); - } - } + public void operate(GasTank inputTank, GasTank outputTank) { + if (getInput().useGas(inputTank, true, 1)) { + getOutput().applyOutputs(outputTank, true, 1); + } + } } diff --git a/src/main/java/mekanism/common/recipe/machines/InjectionRecipe.java b/src/main/java/mekanism/common/recipe/machines/InjectionRecipe.java index 80c5c22b6..7d38003eb 100644 --- a/src/main/java/mekanism/common/recipe/machines/InjectionRecipe.java +++ b/src/main/java/mekanism/common/recipe/machines/InjectionRecipe.java @@ -4,21 +4,17 @@ import mekanism.common.recipe.inputs.AdvancedMachineInput; import mekanism.common.recipe.outputs.ItemStackOutput; import net.minecraft.item.ItemStack; -public class InjectionRecipe extends AdvancedMachineRecipe -{ - public InjectionRecipe(AdvancedMachineInput input, ItemStackOutput output) - { - super(input, output); - } +public class InjectionRecipe extends AdvancedMachineRecipe { + public InjectionRecipe(AdvancedMachineInput input, ItemStackOutput output) { + super(input, output); + } - public InjectionRecipe(ItemStack input, String gasName, ItemStack output) - { - super(input, gasName, output); - } + public InjectionRecipe(ItemStack input, String gasName, ItemStack output) { + super(input, gasName, output); + } - @Override - public InjectionRecipe copy() - { - return new InjectionRecipe(getInput().copy(), getOutput().copy()); - } + @Override + public InjectionRecipe copy() { + return new InjectionRecipe(getInput().copy(), getOutput().copy()); + } } diff --git a/src/main/java/mekanism/common/recipe/machines/MachineRecipe.java b/src/main/java/mekanism/common/recipe/machines/MachineRecipe.java index 4f7be3f15..dc7402107 100644 --- a/src/main/java/mekanism/common/recipe/machines/MachineRecipe.java +++ b/src/main/java/mekanism/common/recipe/machines/MachineRecipe.java @@ -3,26 +3,24 @@ package mekanism.common.recipe.machines; import mekanism.common.recipe.inputs.MachineInput; import mekanism.common.recipe.outputs.MachineOutput; -public abstract class MachineRecipe> -{ - public INPUT recipeInput; - public OUTPUT recipeOutput; +public abstract class MachineRecipe> { + public INPUT recipeInput; + public OUTPUT recipeOutput; - public MachineRecipe(INPUT input, OUTPUT output) - { - recipeInput = input; - recipeOutput = output; - } + public MachineRecipe(INPUT input, OUTPUT output) { + recipeInput = input; + recipeOutput = output; + } - public INPUT getInput() - { - return recipeInput; - } + public INPUT getInput() { + return recipeInput; + } - public OUTPUT getOutput() - { - return recipeOutput; - } + public OUTPUT getOutput() { + return recipeOutput; + } - public abstract RECIPE copy(); + public abstract RECIPE copy(); } diff --git a/src/main/java/mekanism/common/recipe/machines/MetallurgicInfuserRecipe.java b/src/main/java/mekanism/common/recipe/machines/MetallurgicInfuserRecipe.java index a13d69fab..f804b1142 100644 --- a/src/main/java/mekanism/common/recipe/machines/MetallurgicInfuserRecipe.java +++ b/src/main/java/mekanism/common/recipe/machines/MetallurgicInfuserRecipe.java @@ -5,34 +5,33 @@ import mekanism.common.recipe.inputs.InfusionInput; import mekanism.common.recipe.outputs.ItemStackOutput; import net.minecraft.item.ItemStack; -public class MetallurgicInfuserRecipe extends MachineRecipe -{ - public MetallurgicInfuserRecipe(InfusionInput input, ItemStackOutput output) - { - super(input, output); - } +public class MetallurgicInfuserRecipe + extends MachineRecipe { + public MetallurgicInfuserRecipe(InfusionInput input, ItemStackOutput output) { + super(input, output); + } - public MetallurgicInfuserRecipe(InfusionInput input, ItemStack output) - { - this(input, new ItemStackOutput(output)); - } + public MetallurgicInfuserRecipe(InfusionInput input, ItemStack output) { + this(input, new ItemStackOutput(output)); + } - public boolean canOperate(ItemStack[] inventory, int inputIndex, int outputIndex, InfuseStorage infuse) - { - return getInput().use(inventory, inputIndex, infuse, false) && getOutput().applyOutputs(inventory, outputIndex, false); - } + public boolean canOperate( + ItemStack[] inventory, int inputIndex, int outputIndex, InfuseStorage infuse + ) { + return getInput().use(inventory, inputIndex, infuse, false) + && getOutput().applyOutputs(inventory, outputIndex, false); + } - @Override - public MetallurgicInfuserRecipe copy() - { - return new MetallurgicInfuserRecipe(getInput(), getOutput()); - } + @Override + public MetallurgicInfuserRecipe copy() { + return new MetallurgicInfuserRecipe(getInput(), getOutput()); + } - public void output(ItemStack[] inventory, int inputIndex, int outputIndex, InfuseStorage infuseStored) - { - if(getInput().use(inventory, inputIndex, infuseStored, true)) - { - getOutput().applyOutputs(inventory, outputIndex, true); - } - } + public void output( + ItemStack[] inventory, int inputIndex, int outputIndex, InfuseStorage infuseStored + ) { + if (getInput().use(inventory, inputIndex, infuseStored, true)) { + getOutput().applyOutputs(inventory, outputIndex, true); + } + } } diff --git a/src/main/java/mekanism/common/recipe/machines/OsmiumCompressorRecipe.java b/src/main/java/mekanism/common/recipe/machines/OsmiumCompressorRecipe.java index 1c8a4b6d7..a687d4310 100644 --- a/src/main/java/mekanism/common/recipe/machines/OsmiumCompressorRecipe.java +++ b/src/main/java/mekanism/common/recipe/machines/OsmiumCompressorRecipe.java @@ -4,21 +4,18 @@ import mekanism.common.recipe.inputs.AdvancedMachineInput; import mekanism.common.recipe.outputs.ItemStackOutput; import net.minecraft.item.ItemStack; -public class OsmiumCompressorRecipe extends AdvancedMachineRecipe -{ - public OsmiumCompressorRecipe(AdvancedMachineInput input, ItemStackOutput output) - { - super(input, output); - } +public class OsmiumCompressorRecipe + extends AdvancedMachineRecipe { + public OsmiumCompressorRecipe(AdvancedMachineInput input, ItemStackOutput output) { + super(input, output); + } - public OsmiumCompressorRecipe(ItemStack input, ItemStack output) - { - super(input, "liquidOsmium", output); - } + public OsmiumCompressorRecipe(ItemStack input, ItemStack output) { + super(input, "liquidOsmium", output); + } - @Override - public OsmiumCompressorRecipe copy() - { - return new OsmiumCompressorRecipe(getInput().copy(), getOutput().copy()); - } + @Override + public OsmiumCompressorRecipe copy() { + return new OsmiumCompressorRecipe(getInput().copy(), getOutput().copy()); + } } diff --git a/src/main/java/mekanism/common/recipe/machines/OxidationRecipe.java b/src/main/java/mekanism/common/recipe/machines/OxidationRecipe.java index 636592260..2968116f1 100644 --- a/src/main/java/mekanism/common/recipe/machines/OxidationRecipe.java +++ b/src/main/java/mekanism/common/recipe/machines/OxidationRecipe.java @@ -6,34 +6,29 @@ import mekanism.common.recipe.inputs.ItemStackInput; import mekanism.common.recipe.outputs.GasOutput; import net.minecraft.item.ItemStack; -public class OxidationRecipe extends MachineRecipe -{ - public OxidationRecipe(ItemStackInput input, GasOutput output) - { - super(input, output); - } +public class OxidationRecipe + extends MachineRecipe { + public OxidationRecipe(ItemStackInput input, GasOutput output) { + super(input, output); + } - public OxidationRecipe(ItemStack input, GasStack output) - { - this(new ItemStackInput(input), new GasOutput(output)); - } + public OxidationRecipe(ItemStack input, GasStack output) { + this(new ItemStackInput(input), new GasOutput(output)); + } - @Override - public OxidationRecipe copy() - { - return new OxidationRecipe(getInput().copy(), getOutput().copy()); - } + @Override + public OxidationRecipe copy() { + return new OxidationRecipe(getInput().copy(), getOutput().copy()); + } - public boolean canOperate(ItemStack[] inventory, GasTank outputTank) - { - return getInput().useItemStackFromInventory(inventory, 0, false) && getOutput().applyOutputs(outputTank, false, 1); - } + public boolean canOperate(ItemStack[] inventory, GasTank outputTank) { + return getInput().useItemStackFromInventory(inventory, 0, false) + && getOutput().applyOutputs(outputTank, false, 1); + } - public void operate(ItemStack[] inventory, GasTank outputTank) - { - if(getInput().useItemStackFromInventory(inventory, 0, true)) - { - getOutput().applyOutputs(outputTank, true, 1); - } - } + public void operate(ItemStack[] inventory, GasTank outputTank) { + if (getInput().useItemStackFromInventory(inventory, 0, true)) { + getOutput().applyOutputs(outputTank, true, 1); + } + } } diff --git a/src/main/java/mekanism/common/recipe/machines/PressurizedRecipe.java b/src/main/java/mekanism/common/recipe/machines/PressurizedRecipe.java index 0ff2e97cc..707522bc4 100644 --- a/src/main/java/mekanism/common/recipe/machines/PressurizedRecipe.java +++ b/src/main/java/mekanism/common/recipe/machines/PressurizedRecipe.java @@ -8,41 +8,66 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; -public class PressurizedRecipe extends MachineRecipe -{ - public double extraEnergy; +public class PressurizedRecipe + extends MachineRecipe { + public double extraEnergy; - public int ticks; + public int ticks; - public PressurizedRecipe(ItemStack inputSolid, FluidStack inputFluid, GasStack inputGas, ItemStack outputSolid, GasStack outputGas, double energy, int duration) - { - this(new PressurizedInput(inputSolid, inputFluid, inputGas), new PressurizedOutput(outputSolid, outputGas), energy, duration); - } + public PressurizedRecipe( + ItemStack inputSolid, + FluidStack inputFluid, + GasStack inputGas, + ItemStack outputSolid, + GasStack outputGas, + double energy, + int duration + ) { + this( + new PressurizedInput(inputSolid, inputFluid, inputGas), + new PressurizedOutput(outputSolid, outputGas), + energy, + duration + ); + } - public PressurizedRecipe(PressurizedInput pressurizedInput, PressurizedOutput pressurizedProducts, double energy, int duration) - { - super(pressurizedInput, pressurizedProducts); + public PressurizedRecipe( + PressurizedInput pressurizedInput, + PressurizedOutput pressurizedProducts, + double energy, + int duration + ) { + super(pressurizedInput, pressurizedProducts); - extraEnergy = energy; - ticks = duration; - } + extraEnergy = energy; + ticks = duration; + } - @Override - public PressurizedRecipe copy() - { - return new PressurizedRecipe(getInput().copy(), getOutput().copy(), extraEnergy, ticks); - } + @Override + public PressurizedRecipe copy() { + return new PressurizedRecipe( + getInput().copy(), getOutput().copy(), extraEnergy, ticks + ); + } - public boolean canOperate(ItemStack[] inventory, FluidTank inputFluidTank, GasTank inputGasTank, GasTank outputGasTank) - { - return getInput().use(inventory, 0, inputFluidTank, inputGasTank, false) && getOutput().applyOutputs(inventory, 2, outputGasTank, false); - } + public boolean canOperate( + ItemStack[] inventory, + FluidTank inputFluidTank, + GasTank inputGasTank, + GasTank outputGasTank + ) { + return getInput().use(inventory, 0, inputFluidTank, inputGasTank, false) + && getOutput().applyOutputs(inventory, 2, outputGasTank, false); + } - public void operate(ItemStack[] inventory, FluidTank inputFluidTank, GasTank inputGasTank, GasTank outputGasTank) - { - if(getInput().use(inventory, 0, inputFluidTank, inputGasTank, true)) - { - getOutput().applyOutputs(inventory, 2, outputGasTank, true); - } - } + public void operate( + ItemStack[] inventory, + FluidTank inputFluidTank, + GasTank inputGasTank, + GasTank outputGasTank + ) { + if (getInput().use(inventory, 0, inputFluidTank, inputGasTank, true)) { + getOutput().applyOutputs(inventory, 2, outputGasTank, true); + } + } } diff --git a/src/main/java/mekanism/common/recipe/machines/PurificationRecipe.java b/src/main/java/mekanism/common/recipe/machines/PurificationRecipe.java index d7859e08d..789550008 100644 --- a/src/main/java/mekanism/common/recipe/machines/PurificationRecipe.java +++ b/src/main/java/mekanism/common/recipe/machines/PurificationRecipe.java @@ -4,21 +4,17 @@ import mekanism.common.recipe.inputs.AdvancedMachineInput; import mekanism.common.recipe.outputs.ItemStackOutput; import net.minecraft.item.ItemStack; -public class PurificationRecipe extends AdvancedMachineRecipe -{ - public PurificationRecipe(AdvancedMachineInput input, ItemStackOutput output) - { - super(input, output); - } +public class PurificationRecipe extends AdvancedMachineRecipe { + public PurificationRecipe(AdvancedMachineInput input, ItemStackOutput output) { + super(input, output); + } - public PurificationRecipe(ItemStack input, ItemStack output) - { - super(input, "oxygen", output); - } + public PurificationRecipe(ItemStack input, ItemStack output) { + super(input, "oxygen", output); + } - @Override - public PurificationRecipe copy() - { - return new PurificationRecipe(getInput().copy(), getOutput().copy()); - } + @Override + public PurificationRecipe copy() { + return new PurificationRecipe(getInput().copy(), getOutput().copy()); + } } diff --git a/src/main/java/mekanism/common/recipe/machines/SawmillRecipe.java b/src/main/java/mekanism/common/recipe/machines/SawmillRecipe.java index ca7817bff..2841df973 100644 --- a/src/main/java/mekanism/common/recipe/machines/SawmillRecipe.java +++ b/src/main/java/mekanism/common/recipe/machines/SawmillRecipe.java @@ -4,26 +4,26 @@ import mekanism.common.recipe.inputs.ItemStackInput; import mekanism.common.recipe.outputs.ChanceOutput; import net.minecraft.item.ItemStack; -public class SawmillRecipe extends ChanceMachineRecipe -{ - public SawmillRecipe(ItemStackInput input, ChanceOutput output) - { - super(input, output); - } +public class SawmillRecipe extends ChanceMachineRecipe { + public SawmillRecipe(ItemStackInput input, ChanceOutput output) { + super(input, output); + } - public SawmillRecipe(ItemStack input, ItemStack primaryOutput, ItemStack secondaryOutput, double chance) - { - this(new ItemStackInput(input), new ChanceOutput(primaryOutput, secondaryOutput, chance)); - } + public SawmillRecipe( + ItemStack input, ItemStack primaryOutput, ItemStack secondaryOutput, double chance + ) { + this( + new ItemStackInput(input), + new ChanceOutput(primaryOutput, secondaryOutput, chance) + ); + } - public SawmillRecipe(ItemStack input, ItemStack primaryOutput) - { - this(new ItemStackInput(input), new ChanceOutput(primaryOutput)); - } + public SawmillRecipe(ItemStack input, ItemStack primaryOutput) { + this(new ItemStackInput(input), new ChanceOutput(primaryOutput)); + } - @Override - public SawmillRecipe copy() - { - return new SawmillRecipe(getInput().copy(), getOutput().copy()); - } + @Override + public SawmillRecipe copy() { + return new SawmillRecipe(getInput().copy(), getOutput().copy()); + } } diff --git a/src/main/java/mekanism/common/recipe/machines/SeparatorRecipe.java b/src/main/java/mekanism/common/recipe/machines/SeparatorRecipe.java index 1719d31c1..87e41b26d 100644 --- a/src/main/java/mekanism/common/recipe/machines/SeparatorRecipe.java +++ b/src/main/java/mekanism/common/recipe/machines/SeparatorRecipe.java @@ -7,37 +7,35 @@ import mekanism.common.recipe.outputs.ChemicalPairOutput; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; -public class SeparatorRecipe extends MachineRecipe -{ - public double energyUsage; +public class SeparatorRecipe + extends MachineRecipe { + public double energyUsage; - public SeparatorRecipe(FluidInput input, double energy, ChemicalPairOutput output) - { - super(input, output); - energyUsage = energy; - } + public SeparatorRecipe(FluidInput input, double energy, ChemicalPairOutput output) { + super(input, output); + energyUsage = energy; + } - public SeparatorRecipe(FluidStack input, double energy, GasStack left, GasStack right) - { - this(new FluidInput(input), energy, new ChemicalPairOutput(left, right)); - } + public SeparatorRecipe( + FluidStack input, double energy, GasStack left, GasStack right + ) { + this(new FluidInput(input), energy, new ChemicalPairOutput(left, right)); + } - @Override - public SeparatorRecipe copy() - { - return new SeparatorRecipe(getInput().copy(), energyUsage, getOutput().copy()); - } + @Override + public SeparatorRecipe copy() { + return new SeparatorRecipe(getInput().copy(), energyUsage, getOutput().copy()); + } - public boolean canOperate(FluidTank fluidTank, GasTank leftTank, GasTank rightTank) - { - return getInput().useFluid(fluidTank, false, 1) && getOutput().applyOutputs(leftTank, rightTank, false, 1); - } + public boolean canOperate(FluidTank fluidTank, GasTank leftTank, GasTank rightTank) { + return getInput().useFluid(fluidTank, false, 1) + && getOutput().applyOutputs(leftTank, rightTank, false, 1); + } - public void operate(FluidTank fluidTank, GasTank leftTank, GasTank rightTank, int scale) - { - if(getInput().useFluid(fluidTank, true, scale)) - { - getOutput().applyOutputs(leftTank, rightTank, true, scale); - } - } + public void + operate(FluidTank fluidTank, GasTank leftTank, GasTank rightTank, int scale) { + if (getInput().useFluid(fluidTank, true, scale)) { + getOutput().applyOutputs(leftTank, rightTank, true, scale); + } + } } diff --git a/src/main/java/mekanism/common/recipe/machines/SmeltingRecipe.java b/src/main/java/mekanism/common/recipe/machines/SmeltingRecipe.java index 77e650956..17150669f 100644 --- a/src/main/java/mekanism/common/recipe/machines/SmeltingRecipe.java +++ b/src/main/java/mekanism/common/recipe/machines/SmeltingRecipe.java @@ -4,21 +4,17 @@ import mekanism.common.recipe.inputs.ItemStackInput; import mekanism.common.recipe.outputs.ItemStackOutput; import net.minecraft.item.ItemStack; -public class SmeltingRecipe extends BasicMachineRecipe -{ - public SmeltingRecipe(ItemStackInput input, ItemStackOutput output) - { - super(input, output); - } +public class SmeltingRecipe extends BasicMachineRecipe { + public SmeltingRecipe(ItemStackInput input, ItemStackOutput output) { + super(input, output); + } - public SmeltingRecipe(ItemStack input, ItemStack output) - { - super(input, output); - } + public SmeltingRecipe(ItemStack input, ItemStack output) { + super(input, output); + } - @Override - public SmeltingRecipe copy() - { - return new SmeltingRecipe(getInput().copy(), getOutput().copy()); - } + @Override + public SmeltingRecipe copy() { + return new SmeltingRecipe(getInput().copy(), getOutput().copy()); + } } diff --git a/src/main/java/mekanism/common/recipe/machines/SolarNeutronRecipe.java b/src/main/java/mekanism/common/recipe/machines/SolarNeutronRecipe.java index 7e22fd958..a108bb132 100644 --- a/src/main/java/mekanism/common/recipe/machines/SolarNeutronRecipe.java +++ b/src/main/java/mekanism/common/recipe/machines/SolarNeutronRecipe.java @@ -5,34 +5,29 @@ import mekanism.api.gas.GasTank; import mekanism.common.recipe.inputs.GasInput; import mekanism.common.recipe.outputs.GasOutput; -public class SolarNeutronRecipe extends MachineRecipe -{ - public SolarNeutronRecipe(GasStack input, GasStack output) - { - super(new GasInput(input), new GasOutput(output)); - } +public class SolarNeutronRecipe + extends MachineRecipe { + public SolarNeutronRecipe(GasStack input, GasStack output) { + super(new GasInput(input), new GasOutput(output)); + } - public SolarNeutronRecipe(GasInput input, GasOutput output) - { - super(input, output); - } + public SolarNeutronRecipe(GasInput input, GasOutput output) { + super(input, output); + } - @Override - public SolarNeutronRecipe copy() - { - return new SolarNeutronRecipe(getInput(), getOutput()); - } + @Override + public SolarNeutronRecipe copy() { + return new SolarNeutronRecipe(getInput(), getOutput()); + } - public boolean canOperate(GasTank inputTank, GasTank outputTank) - { - return getInput().useGas(inputTank, false, 1) && getOutput().applyOutputs(outputTank, false, 1); - } + public boolean canOperate(GasTank inputTank, GasTank outputTank) { + return getInput().useGas(inputTank, false, 1) + && getOutput().applyOutputs(outputTank, false, 1); + } - public void operate(GasTank inputTank, GasTank outputTank, int scale) - { - if(getInput().useGas(inputTank, true, scale)) - { - getOutput().applyOutputs(outputTank, true, scale); - } - } + public void operate(GasTank inputTank, GasTank outputTank, int scale) { + if (getInput().useGas(inputTank, true, scale)) { + getOutput().applyOutputs(outputTank, true, scale); + } + } } diff --git a/src/main/java/mekanism/common/recipe/machines/TheoreticalElementizerRecipe.java b/src/main/java/mekanism/common/recipe/machines/TheoreticalElementizerRecipe.java index 4b84a277d..fdd33c511 100644 --- a/src/main/java/mekanism/common/recipe/machines/TheoreticalElementizerRecipe.java +++ b/src/main/java/mekanism/common/recipe/machines/TheoreticalElementizerRecipe.java @@ -3,17 +3,18 @@ package mekanism.common.recipe.machines; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; -public class TheoreticalElementizerRecipe extends AdvancedMachineRecipe { - - +public class TheoreticalElementizerRecipe + extends AdvancedMachineRecipe { public TheoreticalElementizerRecipe(ItemStack output) { - - super(new ItemStack(Blocks.fire).setStackDisplayName("Destroys any item"), "elementizerFuel", output); + super( + new ItemStack(Blocks.fire).setStackDisplayName("Destroys any item"), + "elementizerFuel", + output + ); } @Override public TheoreticalElementizerRecipe copy() { return new TheoreticalElementizerRecipe(getOutput().output.copy()); } - } diff --git a/src/main/java/mekanism/common/recipe/machines/ThermalEvaporationRecipe.java b/src/main/java/mekanism/common/recipe/machines/ThermalEvaporationRecipe.java index 05c822029..da6c1ad12 100644 --- a/src/main/java/mekanism/common/recipe/machines/ThermalEvaporationRecipe.java +++ b/src/main/java/mekanism/common/recipe/machines/ThermalEvaporationRecipe.java @@ -5,34 +5,29 @@ import mekanism.common.recipe.outputs.FluidOutput; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; -public class ThermalEvaporationRecipe extends MachineRecipe -{ - public ThermalEvaporationRecipe(FluidStack input, FluidStack output) - { - super(new FluidInput(input), new FluidOutput(output)); - } +public class ThermalEvaporationRecipe + extends MachineRecipe { + public ThermalEvaporationRecipe(FluidStack input, FluidStack output) { + super(new FluidInput(input), new FluidOutput(output)); + } - public ThermalEvaporationRecipe(FluidInput input, FluidOutput output) - { - super(input, output); - } + public ThermalEvaporationRecipe(FluidInput input, FluidOutput output) { + super(input, output); + } - @Override - public ThermalEvaporationRecipe copy() - { - return new ThermalEvaporationRecipe(getInput(), getOutput()); - } + @Override + public ThermalEvaporationRecipe copy() { + return new ThermalEvaporationRecipe(getInput(), getOutput()); + } - public boolean canOperate(FluidTank inputTank, FluidTank outputTank) - { - return getInput().useFluid(inputTank, false, 1) && getOutput().applyOutputs(outputTank, false); - } + public boolean canOperate(FluidTank inputTank, FluidTank outputTank) { + return getInput().useFluid(inputTank, false, 1) + && getOutput().applyOutputs(outputTank, false); + } - public void operate(FluidTank inputTank, FluidTank outputTank) - { - if(getInput().useFluid(inputTank, true, 1)) - { - getOutput().applyOutputs(outputTank, true); - } - } + public void operate(FluidTank inputTank, FluidTank outputTank) { + if (getInput().useFluid(inputTank, true, 1)) { + getOutput().applyOutputs(outputTank, true); + } + } } diff --git a/src/main/java/mekanism/common/recipe/machines/WasherRecipe.java b/src/main/java/mekanism/common/recipe/machines/WasherRecipe.java index e7a28a4f6..55ba3d6e1 100644 --- a/src/main/java/mekanism/common/recipe/machines/WasherRecipe.java +++ b/src/main/java/mekanism/common/recipe/machines/WasherRecipe.java @@ -10,36 +10,36 @@ import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; -public class WasherRecipe extends MachineRecipe -{ - public FluidInput waterInput = new FluidInput(new FluidStack(FluidRegistry.WATER, TileEntityChemicalWasher.WATER_USAGE)); +public class WasherRecipe extends MachineRecipe { + public FluidInput waterInput = new FluidInput( + new FluidStack(FluidRegistry.WATER, TileEntityChemicalWasher.WATER_USAGE) + ); - public WasherRecipe(GasInput input, GasOutput output) - { - super(input, output); - } + public WasherRecipe(GasInput input, GasOutput output) { + super(input, output); + } - public WasherRecipe(GasStack input, GasStack output) - { - this(new GasInput(input), new GasOutput(output)); - } + public WasherRecipe(GasStack input, GasStack output) { + this(new GasInput(input), new GasOutput(output)); + } - @Override - public WasherRecipe copy() - { - return new WasherRecipe(getInput().copy(), getOutput().copy()); - } + @Override + public WasherRecipe copy() { + return new WasherRecipe(getInput().copy(), getOutput().copy()); + } - public boolean canOperate(GasTank inputTank, FluidTank fluidTank, GasTank outputTank) - { - return getInput().useGas(inputTank, false, 1) && waterInput.useFluid(fluidTank, false, 1) && getOutput().applyOutputs(outputTank, false, 1); - } + public boolean + canOperate(GasTank inputTank, FluidTank fluidTank, GasTank outputTank) { + return getInput().useGas(inputTank, false, 1) + && waterInput.useFluid(fluidTank, false, 1) + && getOutput().applyOutputs(outputTank, false, 1); + } - public void operate(GasTank inputTank, FluidTank fluidTank, GasTank outputTank, int scale) - { - if(getInput().useGas(inputTank, true, scale) && waterInput.useFluid(fluidTank, true, scale)) - { - getOutput().applyOutputs(outputTank, true, scale); - } - } + public void + operate(GasTank inputTank, FluidTank fluidTank, GasTank outputTank, int scale) { + if (getInput().useGas(inputTank, true, scale) + && waterInput.useFluid(fluidTank, true, scale)) { + getOutput().applyOutputs(outputTank, true, scale); + } + } } diff --git a/src/main/java/mekanism/common/recipe/outputs/ChanceOutput.java b/src/main/java/mekanism/common/recipe/outputs/ChanceOutput.java index 6ec02d1f4..4e1408e10 100644 --- a/src/main/java/mekanism/common/recipe/outputs/ChanceOutput.java +++ b/src/main/java/mekanism/common/recipe/outputs/ChanceOutput.java @@ -6,107 +6,96 @@ import mekanism.api.util.StackUtils; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -public class ChanceOutput extends MachineOutput -{ - private static Random rand = new Random(); +public class ChanceOutput extends MachineOutput { + private static Random rand = new Random(); - public ItemStack primaryOutput; + public ItemStack primaryOutput; - public ItemStack secondaryOutput; + public ItemStack secondaryOutput; - public double secondaryChance; + public double secondaryChance; - public ChanceOutput(ItemStack primary, ItemStack secondary, double chance) - { - primaryOutput = primary; - secondaryOutput = secondary; - secondaryChance = chance; - } - - public ChanceOutput() {} - - @Override - public void load(NBTTagCompound nbtTags) - { - primaryOutput = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("primaryOutput")); - secondaryOutput = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("secondaryOutput")); - secondaryChance = nbtTags.getDouble("secondaryChance"); - } + public ChanceOutput(ItemStack primary, ItemStack secondary, double chance) { + primaryOutput = primary; + secondaryOutput = secondary; + secondaryChance = chance; + } - public ChanceOutput(ItemStack primary) - { - primaryOutput = primary; - } + public ChanceOutput() {} - public boolean checkSecondary() - { - return rand.nextDouble() <= secondaryChance; - } + @Override + public void load(NBTTagCompound nbtTags) { + primaryOutput + = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("primaryOutput")); + secondaryOutput + = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("secondaryOutput")); + secondaryChance = nbtTags.getDouble("secondaryChance"); + } - public boolean hasPrimary() - { - return primaryOutput != null; - } + public ChanceOutput(ItemStack primary) { + primaryOutput = primary; + } - public boolean hasSecondary() - { - return secondaryOutput != null; - } + public boolean checkSecondary() { + return rand.nextDouble() <= secondaryChance; + } - public boolean applyOutputs(ItemStack[] inventory, int primaryIndex, int secondaryIndex, boolean doEmit) - { - if(hasPrimary()) - { - if(inventory[primaryIndex] == null) - { - if(doEmit) - { - inventory[primaryIndex] = primaryOutput.copy(); - } - } + public boolean hasPrimary() { + return primaryOutput != null; + } + + public boolean hasSecondary() { + return secondaryOutput != null; + } + + public boolean applyOutputs( + ItemStack[] inventory, int primaryIndex, int secondaryIndex, boolean doEmit + ) { + if (hasPrimary()) { + if (inventory[primaryIndex] == null) { + if (doEmit) { + inventory[primaryIndex] = primaryOutput.copy(); + } + } else if(inventory[primaryIndex].isItemEqual(primaryOutput) && inventory[primaryIndex].stackSize + primaryOutput.stackSize <= inventory[primaryIndex].getMaxStackSize()) { - if(doEmit) - { - inventory[primaryIndex].stackSize += primaryOutput.stackSize; - } - } - else { - return false; - } - } - - if(hasSecondary() && (!doEmit || checkSecondary())) - { - if(inventory[secondaryIndex] == null) - { - if(doEmit) - { - inventory[secondaryIndex] = secondaryOutput.copy(); - } - - return true; - } + if (doEmit) { + inventory[primaryIndex].stackSize += primaryOutput.stackSize; + } + } else { + return false; + } + } + + if (hasSecondary() && (!doEmit || checkSecondary())) { + if (inventory[secondaryIndex] == null) { + if (doEmit) { + inventory[secondaryIndex] = secondaryOutput.copy(); + } + + return true; + } else if(inventory[secondaryIndex].isItemEqual(secondaryOutput) && inventory[secondaryIndex].stackSize + primaryOutput.stackSize <= inventory[secondaryIndex].getMaxStackSize()) { - if(doEmit) - { - inventory[secondaryIndex].stackSize += secondaryOutput.stackSize; - } - - return true; - } - else { - return false; - } - } + if (doEmit) { + inventory[secondaryIndex].stackSize += secondaryOutput.stackSize; + } - return true; - } + return true; + } else { + return false; + } + } - @Override - public ChanceOutput copy() - { - return new ChanceOutput(StackUtils.copy(primaryOutput), StackUtils.copy(secondaryOutput), secondaryChance); - } + return true; + } + + @Override + public ChanceOutput copy() { + return new ChanceOutput( + StackUtils.copy(primaryOutput), + StackUtils.copy(secondaryOutput), + secondaryChance + ); + } } diff --git a/src/main/java/mekanism/common/recipe/outputs/ChemicalPairOutput.java b/src/main/java/mekanism/common/recipe/outputs/ChemicalPairOutput.java index a5e621e86..9541bdbec 100644 --- a/src/main/java/mekanism/common/recipe/outputs/ChemicalPairOutput.java +++ b/src/main/java/mekanism/common/recipe/outputs/ChemicalPairOutput.java @@ -9,145 +9,139 @@ import net.minecraft.nbt.NBTTagCompound; * @author aidancbrady * */ -public class ChemicalPairOutput extends MachineOutput -{ - /** The left gas of this chemical input */ - public GasStack leftGas; +public class ChemicalPairOutput extends MachineOutput { + /** The left gas of this chemical input */ + public GasStack leftGas; - /** The right gas of this chemical input */ - public GasStack rightGas; + /** 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 ChemicalPairOutput(GasStack left, GasStack right) - { - leftGas = left; - rightGas = right; - } - - public ChemicalPairOutput() {} - - @Override - public void load(NBTTagCompound nbtTags) - { - leftGas = GasStack.readFromNBT(nbtTags.getCompoundTag("leftOutput")); - rightGas = GasStack.readFromNBT(nbtTags.getCompoundTag("rightOutput")); - } + /** + * Creates a chemical input with two defined gasses. + * @param left - left gas + * @param right - right gas + */ + public ChemicalPairOutput(GasStack left, GasStack right) { + leftGas = left; + rightGas = right; + } - /** - * If this is a valid ChemicalPair - * @return - */ - public boolean isValid() - { - return leftGas != null && rightGas != null; - } + public ChemicalPairOutput() {} - /** - * 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(ChemicalPairOutput input) - { - return meets(input) || meets(input.swap()); - } + @Override + public void load(NBTTagCompound nbtTags) { + leftGas = GasStack.readFromNBT(nbtTags.getCompoundTag("leftOutput")); + rightGas = GasStack.readFromNBT(nbtTags.getCompoundTag("rightOutput")); + } - /** - * Swaps the right gas and left gas of this input. - * @return a swapped ChemicalInput - */ - public ChemicalPairOutput swap() - { - return new ChemicalPairOutput(rightGas, leftGas); - } + /** + * If this is a valid ChemicalPair + * @return + */ + public boolean isValid() { + return leftGas != null && rightGas != null; + } - public boolean applyOutputs(GasTank leftTank, GasTank rightTank, boolean doEmit, int scale) - { - if(leftTank.canReceive(leftGas.getGas()) && rightTank.canReceive(rightGas.getGas())) - { - if(leftTank.getNeeded() >= leftGas.amount*scale && rightTank.getNeeded() >= rightGas.amount*scale) - { - leftTank.receive(leftGas.copy().withAmount(leftGas.amount*scale), doEmit); - rightTank.receive(rightGas.copy().withAmount(rightGas.amount*scale), doEmit); - - return true; - } - } - else if(leftTank.canReceive(rightGas.getGas()) && rightTank.canReceive(leftGas.getGas())) - { - if(leftTank.getNeeded() >= rightGas.amount*scale && rightTank.getNeeded() >= leftGas.amount*scale) - { - leftTank.receive(rightGas.copy().withAmount(rightGas.amount*scale), doEmit); - rightTank.receive(leftGas.copy().withAmount(leftGas.amount*scale), doEmit); - - return true; - } - } - - return false; - } + /** + * 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(ChemicalPairOutput input) { + return meets(input) || meets(input.swap()); + } - /** - * 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 ChemicalPairOutput(leftTank.getGas(), rightTank.getGas()))) - { - leftTank.draw(leftGas.amount, true); - rightTank.draw(rightGas.amount, true); - } - else if(meets(new ChemicalPairOutput(rightTank.getGas(), leftTank.getGas()))) - { - leftTank.draw(rightGas.amount, true); - rightTank.draw(leftGas.amount, true); - } - } + /** + * Swaps the right gas and left gas of this input. + * @return a swapped ChemicalInput + */ + public ChemicalPairOutput swap() { + return new ChemicalPairOutput(rightGas, leftGas); + } - /** - * 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; - } + public boolean + applyOutputs(GasTank leftTank, GasTank rightTank, boolean doEmit, int scale) { + if (leftTank.canReceive(leftGas.getGas()) + && rightTank.canReceive(rightGas.getGas())) { + if (leftTank.getNeeded() >= leftGas.amount * scale + && rightTank.getNeeded() >= rightGas.amount * scale) { + leftTank.receive( + leftGas.copy().withAmount(leftGas.amount * scale), doEmit + ); + rightTank.receive( + rightGas.copy().withAmount(rightGas.amount * scale), doEmit + ); - return stack.isGasEqual(leftGas) || stack.isGasEqual(rightGas); - } + return true; + } + } else if (leftTank.canReceive(rightGas.getGas()) && rightTank.canReceive(leftGas.getGas())) { + if (leftTank.getNeeded() >= rightGas.amount * scale + && rightTank.getNeeded() >= leftGas.amount * scale) { + leftTank.receive( + rightGas.copy().withAmount(rightGas.amount * scale), doEmit + ); + rightTank.receive( + leftGas.copy().withAmount(leftGas.amount * scale), doEmit + ); - /** - * Actual implementation of meetsInput(), performs the checks. - * @param input - input to check - * @return if the input meets this input's requirements - */ - private boolean meets(ChemicalPairOutput input) - { - if(input == null || !input.isValid()) - { - return false; - } + return true; + } + } - if(input.leftGas.getGas() != leftGas.getGas() || input.rightGas.getGas() != rightGas.getGas()) - { - return false; - } + return false; + } - return input.leftGas.amount >= leftGas.amount && input.rightGas.amount >= rightGas.amount; - } + /** + * 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 ChemicalPairOutput(leftTank.getGas(), rightTank.getGas()))) { + leftTank.draw(leftGas.amount, true); + rightTank.draw(rightGas.amount, true); + } else if (meets(new ChemicalPairOutput(rightTank.getGas(), leftTank.getGas()))) { + leftTank.draw(rightGas.amount, true); + rightTank.draw(leftGas.amount, true); + } + } - @Override - public ChemicalPairOutput copy() - { - return new ChemicalPairOutput(leftGas.copy(), rightGas.copy()); - } + /** + * 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(ChemicalPairOutput 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; + } + + @Override + public ChemicalPairOutput copy() { + return new ChemicalPairOutput(leftGas.copy(), rightGas.copy()); + } } diff --git a/src/main/java/mekanism/common/recipe/outputs/FluidOutput.java b/src/main/java/mekanism/common/recipe/outputs/FluidOutput.java index 59255dae6..0858f3bed 100644 --- a/src/main/java/mekanism/common/recipe/outputs/FluidOutput.java +++ b/src/main/java/mekanism/common/recipe/outputs/FluidOutput.java @@ -4,38 +4,32 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; -public class FluidOutput extends MachineOutput -{ - public FluidStack output; +public class FluidOutput extends MachineOutput { + public FluidStack output; - public FluidOutput(FluidStack stack) - { - output = stack; - } - - public FluidOutput() {} - - @Override - public void load(NBTTagCompound nbtTags) - { - output = FluidStack.loadFluidStackFromNBT(nbtTags.getCompoundTag("output")); - } + public FluidOutput(FluidStack stack) { + output = stack; + } - @Override - public FluidOutput copy() - { - return new FluidOutput(output.copy()); - } + public FluidOutput() {} - public boolean applyOutputs(FluidTank fluidTank, boolean doEmit) - { - if(fluidTank.fill(output, false) > 0) - { - fluidTank.fill(output, doEmit); - - return true; - } - - return false; - } + @Override + public void load(NBTTagCompound nbtTags) { + output = FluidStack.loadFluidStackFromNBT(nbtTags.getCompoundTag("output")); + } + + @Override + public FluidOutput copy() { + return new FluidOutput(output.copy()); + } + + public boolean applyOutputs(FluidTank fluidTank, boolean doEmit) { + if (fluidTank.fill(output, false) > 0) { + fluidTank.fill(output, doEmit); + + return true; + } + + return false; + } } diff --git a/src/main/java/mekanism/common/recipe/outputs/GasOutput.java b/src/main/java/mekanism/common/recipe/outputs/GasOutput.java index 7d35459e3..8e3513796 100644 --- a/src/main/java/mekanism/common/recipe/outputs/GasOutput.java +++ b/src/main/java/mekanism/common/recipe/outputs/GasOutput.java @@ -4,38 +4,33 @@ import mekanism.api.gas.GasStack; import mekanism.api.gas.GasTank; import net.minecraft.nbt.NBTTagCompound; -public class GasOutput extends MachineOutput -{ - public GasStack output; +public class GasOutput extends MachineOutput { + public GasStack output; - public GasOutput(GasStack stack) - { - output = stack; - } - - public GasOutput() {} - - @Override - public void load(NBTTagCompound nbtTags) - { - output = GasStack.readFromNBT(nbtTags.getCompoundTag("output")); - } + public GasOutput(GasStack stack) { + output = stack; + } - @Override - public GasOutput copy() - { - return new GasOutput(output.copy()); - } + public GasOutput() {} - public boolean applyOutputs(GasTank gasTank, boolean doEmit, int scale) - { - if(gasTank.canReceive(output.getGas()) && gasTank.getNeeded() >= output.amount*scale) - { - gasTank.receive(output.copy().withAmount(output.amount*scale), doEmit); - - return true; - } - - return false; - } + @Override + public void load(NBTTagCompound nbtTags) { + output = GasStack.readFromNBT(nbtTags.getCompoundTag("output")); + } + + @Override + public GasOutput copy() { + return new GasOutput(output.copy()); + } + + public boolean applyOutputs(GasTank gasTank, boolean doEmit, int scale) { + if (gasTank.canReceive(output.getGas()) + && gasTank.getNeeded() >= output.amount * scale) { + gasTank.receive(output.copy().withAmount(output.amount * scale), doEmit); + + return true; + } + + return false; + } } diff --git a/src/main/java/mekanism/common/recipe/outputs/ItemStackOutput.java b/src/main/java/mekanism/common/recipe/outputs/ItemStackOutput.java index 7ee952f81..4fcbdde85 100644 --- a/src/main/java/mekanism/common/recipe/outputs/ItemStackOutput.java +++ b/src/main/java/mekanism/common/recipe/outputs/ItemStackOutput.java @@ -3,49 +3,41 @@ package mekanism.common.recipe.outputs; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -public class ItemStackOutput extends MachineOutput -{ - public ItemStack output; +public class ItemStackOutput extends MachineOutput { + public ItemStack output; - public ItemStackOutput(ItemStack stack) - { - output = stack; - } - - public ItemStackOutput() {} - - @Override - public void load(NBTTagCompound nbtTags) - { - output = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("output")); - } + public ItemStackOutput(ItemStack stack) { + output = stack; + } - public boolean applyOutputs(ItemStack[] inventory, int index, boolean doEmit) - { - if(inventory[index] == null) - { - if(doEmit) - { - inventory[index] = output.copy(); - } - - return true; - } + public ItemStackOutput() {} + + @Override + public void load(NBTTagCompound nbtTags) { + output = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("output")); + } + + public boolean applyOutputs(ItemStack[] inventory, int index, boolean doEmit) { + if (inventory[index] == null) { + if (doEmit) { + inventory[index] = output.copy(); + } + + return true; + } else if(inventory[index].isItemEqual(output) && inventory[index].stackSize + output.stackSize <= inventory[index].getMaxStackSize()) { - if(doEmit) - { - inventory[index].stackSize += output.stackSize; - } - - return true; - } - return false; - } + if (doEmit) { + inventory[index].stackSize += output.stackSize; + } - @Override - public ItemStackOutput copy() - { - return new ItemStackOutput(output.copy()); - } + return true; + } + return false; + } + + @Override + public ItemStackOutput copy() { + return new ItemStackOutput(output.copy()); + } } diff --git a/src/main/java/mekanism/common/recipe/outputs/MachineOutput.java b/src/main/java/mekanism/common/recipe/outputs/MachineOutput.java index d27a61cdc..7b6a1746f 100644 --- a/src/main/java/mekanism/common/recipe/outputs/MachineOutput.java +++ b/src/main/java/mekanism/common/recipe/outputs/MachineOutput.java @@ -2,9 +2,8 @@ package mekanism.common.recipe.outputs; import net.minecraft.nbt.NBTTagCompound; -public abstract class MachineOutput> -{ - public abstract OUTPUT copy(); - - public abstract void load(NBTTagCompound nbtTags); +public abstract class MachineOutput> { + public abstract OUTPUT copy(); + + public abstract void load(NBTTagCompound nbtTags); } diff --git a/src/main/java/mekanism/common/recipe/outputs/PressurizedOutput.java b/src/main/java/mekanism/common/recipe/outputs/PressurizedOutput.java index 5692be99a..b4e262ed8 100644 --- a/src/main/java/mekanism/common/recipe/outputs/PressurizedOutput.java +++ b/src/main/java/mekanism/common/recipe/outputs/PressurizedOutput.java @@ -5,80 +5,69 @@ import mekanism.api.gas.GasTank; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -public class PressurizedOutput extends MachineOutput -{ - private ItemStack itemOutput; - private GasStack gasOutput; +public class PressurizedOutput extends MachineOutput { + private ItemStack itemOutput; + private GasStack gasOutput; - public PressurizedOutput(ItemStack item, GasStack gas) - { - itemOutput = item; - gasOutput = gas; - } - - public PressurizedOutput() {} - - @Override - public void load(NBTTagCompound nbtTags) - { - itemOutput = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("itemOutput")); - gasOutput = GasStack.readFromNBT(nbtTags.getCompoundTag("gasOutput")); - } + public PressurizedOutput(ItemStack item, GasStack gas) { + itemOutput = item; + gasOutput = gas; + } - public boolean canFillTank(GasTank tank) - { - return tank.canReceive(gasOutput.getGas()) && tank.getNeeded() >= gasOutput.amount; - } + public PressurizedOutput() {} - public boolean canAddProducts(ItemStack[] inventory, int index) - { - return inventory[index] == null || (inventory[index].isItemEqual(itemOutput) && inventory[index].stackSize + itemOutput.stackSize <= inventory[index].getMaxStackSize()); - } + @Override + public void load(NBTTagCompound nbtTags) { + itemOutput = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("itemOutput")); + gasOutput = GasStack.readFromNBT(nbtTags.getCompoundTag("gasOutput")); + } - public void fillTank(GasTank tank) - { - tank.receive(gasOutput, true); - } + public boolean canFillTank(GasTank tank) { + return tank.canReceive(gasOutput.getGas()) + && tank.getNeeded() >= gasOutput.amount; + } - 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 boolean canAddProducts(ItemStack[] inventory, int index) { + return inventory[index] == null + || (inventory[index].isItemEqual(itemOutput) + && inventory[index].stackSize + itemOutput.stackSize + <= inventory[index].getMaxStackSize()); + } - public boolean applyOutputs(ItemStack[] inventory, int index, GasTank tank, boolean doEmit) - { - if(canFillTank(tank) && canAddProducts(inventory, index)) - { - if(doEmit) - { - fillTank(tank); - addProducts(inventory, index); - } - return true; - } - return false; - } + public void fillTank(GasTank tank) { + tank.receive(gasOutput, true); + } - public ItemStack getItemOutput() - { - return itemOutput; - } + 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 GasStack getGasOutput() - { - return gasOutput; - } + public boolean + applyOutputs(ItemStack[] inventory, int index, GasTank tank, boolean doEmit) { + if (canFillTank(tank) && canAddProducts(inventory, index)) { + if (doEmit) { + fillTank(tank); + addProducts(inventory, index); + } + return true; + } + return false; + } - @Override - public PressurizedOutput copy() - { - return new PressurizedOutput(itemOutput.copy(), gasOutput.copy()); - } + public ItemStack getItemOutput() { + return itemOutput; + } + + public GasStack getGasOutput() { + return gasOutput; + } + + @Override + public PressurizedOutput copy() { + return new PressurizedOutput(itemOutput.copy(), gasOutput.copy()); + } } diff --git a/src/main/java/mekanism/common/security/IOwnerItem.java b/src/main/java/mekanism/common/security/IOwnerItem.java index 7dd4afb11..a93cb1e44 100644 --- a/src/main/java/mekanism/common/security/IOwnerItem.java +++ b/src/main/java/mekanism/common/security/IOwnerItem.java @@ -2,11 +2,10 @@ package mekanism.common.security; import net.minecraft.item.ItemStack; -public interface IOwnerItem -{ - public String getOwner(ItemStack stack); - - public void setOwner(ItemStack stack, String owner); - - public boolean hasOwner(ItemStack stack); +public interface IOwnerItem { + public String getOwner(ItemStack stack); + + public void setOwner(ItemStack stack, String owner); + + public boolean hasOwner(ItemStack stack); } diff --git a/src/main/java/mekanism/common/security/ISecurityItem.java b/src/main/java/mekanism/common/security/ISecurityItem.java index d7bdde3d6..6f6f3b85e 100644 --- a/src/main/java/mekanism/common/security/ISecurityItem.java +++ b/src/main/java/mekanism/common/security/ISecurityItem.java @@ -3,11 +3,10 @@ package mekanism.common.security; import mekanism.common.security.ISecurityTile.SecurityMode; import net.minecraft.item.ItemStack; -public interface ISecurityItem extends IOwnerItem -{ - public SecurityMode getSecurity(ItemStack stack); - - public void setSecurity(ItemStack stack, SecurityMode mode); - - public boolean hasSecurity(ItemStack stack); +public interface ISecurityItem extends IOwnerItem { + public SecurityMode getSecurity(ItemStack stack); + + public void setSecurity(ItemStack stack, SecurityMode mode); + + public boolean hasSecurity(ItemStack stack); } diff --git a/src/main/java/mekanism/common/security/ISecurityTile.java b/src/main/java/mekanism/common/security/ISecurityTile.java index 3cbfb4e67..f4ec9653a 100644 --- a/src/main/java/mekanism/common/security/ISecurityTile.java +++ b/src/main/java/mekanism/common/security/ISecurityTile.java @@ -4,28 +4,24 @@ import mekanism.api.EnumColor; import mekanism.common.tile.component.TileComponentSecurity; import mekanism.common.util.LangUtils; -public interface ISecurityTile -{ - public TileComponentSecurity getSecurity(); - - public enum SecurityMode - { - PUBLIC("security.public", EnumColor.BRIGHT_GREEN), - PRIVATE("security.private", EnumColor.RED), - TRUSTED("security.trusted", EnumColor.ORANGE); - - private String display; - private EnumColor color; +public interface ISecurityTile { + public TileComponentSecurity getSecurity(); - public String getDisplay() - { - return color + LangUtils.localize(display); - } + public enum SecurityMode { + PUBLIC("security.public", EnumColor.BRIGHT_GREEN), + PRIVATE("security.private", EnumColor.RED), + TRUSTED("security.trusted", EnumColor.ORANGE); - private SecurityMode(String s, EnumColor c) - { - display = s; - color = c; - } - } + private String display; + private EnumColor color; + + public String getDisplay() { + return color + LangUtils.localize(display); + } + + private SecurityMode(String s, EnumColor c) { + display = s; + color = c; + } + } } diff --git a/src/main/java/mekanism/common/security/SecurityData.java b/src/main/java/mekanism/common/security/SecurityData.java index 89a0a4ff5..d3a85dc4a 100644 --- a/src/main/java/mekanism/common/security/SecurityData.java +++ b/src/main/java/mekanism/common/security/SecurityData.java @@ -3,32 +3,28 @@ package mekanism.common.security; import io.netty.buffer.ByteBuf; import mekanism.common.security.ISecurityTile.SecurityMode; -public class SecurityData -{ - public SecurityMode mode = SecurityMode.PUBLIC; - public boolean override; - - public SecurityData() {} - - public SecurityData(SecurityFrequency frequency) - { - mode = frequency.securityMode; - override = frequency.override; - } - - public void write(ByteBuf dataStream) - { - dataStream.writeInt(mode.ordinal()); - dataStream.writeBoolean(override); - } - - public static SecurityData read(ByteBuf dataStream) - { - SecurityData data = new SecurityData(); - - data.mode = SecurityMode.values()[dataStream.readInt()]; - data.override = dataStream.readBoolean(); - - return data; - } +public class SecurityData { + public SecurityMode mode = SecurityMode.PUBLIC; + public boolean override; + + public SecurityData() {} + + public SecurityData(SecurityFrequency frequency) { + mode = frequency.securityMode; + override = frequency.override; + } + + public void write(ByteBuf dataStream) { + dataStream.writeInt(mode.ordinal()); + dataStream.writeBoolean(override); + } + + public static SecurityData read(ByteBuf dataStream) { + SecurityData data = new SecurityData(); + + data.mode = SecurityMode.values()[dataStream.readInt()]; + data.override = dataStream.readBoolean(); + + return data; + } } diff --git a/src/main/java/mekanism/common/security/SecurityFrequency.java b/src/main/java/mekanism/common/security/SecurityFrequency.java index 33506de51..e567e0272 100644 --- a/src/main/java/mekanism/common/security/SecurityFrequency.java +++ b/src/main/java/mekanism/common/security/SecurityFrequency.java @@ -1,9 +1,8 @@ package mekanism.common.security; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import io.netty.buffer.ByteBuf; import mekanism.common.HashList; import mekanism.common.PacketHandler; import mekanism.common.frequency.Frequency; @@ -13,110 +12,96 @@ import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagString; import net.minecraftforge.common.util.Constants.NBT; -public class SecurityFrequency extends Frequency -{ - public static final String SECURITY = "Security"; - - public boolean override; - - public HashList trusted; - - public SecurityMode securityMode; - - public SecurityFrequency(String o) - { - super("Security", o); - - trusted = new HashList(); - securityMode = SecurityMode.PUBLIC; - } - - public SecurityFrequency(NBTTagCompound nbtTags) - { - super(nbtTags); - } - - public SecurityFrequency(ByteBuf dataStream) - { - super(dataStream); - } - - @Override - public void write(NBTTagCompound nbtTags) - { - super.write(nbtTags); - - nbtTags.setBoolean("override", override); - nbtTags.setInteger("securityMode", securityMode.ordinal()); - - if(!trusted.isEmpty()) - { - NBTTagList trustedList = new NBTTagList(); - - for(String s : trusted) - { - trustedList.appendTag(new NBTTagString(s)); - } - - nbtTags.setTag("trusted", trustedList); - } - } +public class SecurityFrequency extends Frequency { + public static final String SECURITY = "Security"; - @Override - protected void read(NBTTagCompound nbtTags) - { - super.read(nbtTags); - - trusted = new HashList(); - securityMode = SecurityMode.PUBLIC; - - override = nbtTags.getBoolean("override"); - securityMode = SecurityMode.values()[nbtTags.getInteger("securityMode")]; - - if(nbtTags.hasKey("trusted")) - { - NBTTagList trustedList = nbtTags.getTagList("trusted", NBT.TAG_STRING); - - for(int i = 0; i < trustedList.tagCount(); i++) - { - trusted.add(trustedList.getStringTagAt(i)); - } - } - } + public boolean override; - @Override - public void write(ArrayList data) - { - super.write(data); - - data.add(override); - data.add(securityMode.ordinal()); - - data.add(trusted.size()); - - for(String s : trusted) - { - data.add(s); - } - } + public HashList trusted; - @Override - protected void read(ByteBuf dataStream) - { - super.read(dataStream); - - trusted = new HashList(); - securityMode = SecurityMode.PUBLIC; - - override = dataStream.readBoolean(); - securityMode = SecurityMode.values()[dataStream.readInt()]; - - trusted.clear(); - int size = dataStream.readInt(); - - for(int i = 0; i < size; i++) - { - trusted.add(PacketHandler.readString(dataStream)); - } - } + public SecurityMode securityMode; + + public SecurityFrequency(String o) { + super("Security", o); + + trusted = new HashList(); + securityMode = SecurityMode.PUBLIC; + } + + public SecurityFrequency(NBTTagCompound nbtTags) { + super(nbtTags); + } + + public SecurityFrequency(ByteBuf dataStream) { + super(dataStream); + } + + @Override + public void write(NBTTagCompound nbtTags) { + super.write(nbtTags); + + nbtTags.setBoolean("override", override); + nbtTags.setInteger("securityMode", securityMode.ordinal()); + + if (!trusted.isEmpty()) { + NBTTagList trustedList = new NBTTagList(); + + for (String s : trusted) { + trustedList.appendTag(new NBTTagString(s)); + } + + nbtTags.setTag("trusted", trustedList); + } + } + + @Override + protected void read(NBTTagCompound nbtTags) { + super.read(nbtTags); + + trusted = new HashList(); + securityMode = SecurityMode.PUBLIC; + + override = nbtTags.getBoolean("override"); + securityMode = SecurityMode.values()[nbtTags.getInteger("securityMode")]; + + if (nbtTags.hasKey("trusted")) { + NBTTagList trustedList = nbtTags.getTagList("trusted", NBT.TAG_STRING); + + for (int i = 0; i < trustedList.tagCount(); i++) { + trusted.add(trustedList.getStringTagAt(i)); + } + } + } + + @Override + public void write(ArrayList data) { + super.write(data); + + data.add(override); + data.add(securityMode.ordinal()); + + data.add(trusted.size()); + + for (String s : trusted) { + data.add(s); + } + } + + @Override + protected void read(ByteBuf dataStream) { + super.read(dataStream); + + trusted = new HashList(); + securityMode = SecurityMode.PUBLIC; + + override = dataStream.readBoolean(); + securityMode = SecurityMode.values()[dataStream.readInt()]; + + trusted.clear(); + int size = dataStream.readInt(); + + for (int i = 0; i < size; i++) { + trusted.add(PacketHandler.readString(dataStream)); + } + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityAdvancedBoundingBlock.java b/src/main/java/mekanism/common/tile/TileEntityAdvancedBoundingBlock.java index 11494c7f4..c76fbac07 100644 --- a/src/main/java/mekanism/common/tile/TileEntityAdvancedBoundingBlock.java +++ b/src/main/java/mekanism/common/tile/TileEntityAdvancedBoundingBlock.java @@ -1,5 +1,9 @@ package mekanism.common.tile; +import cofh.api.energy.IEnergyHandler; +import cpw.mods.fml.common.Optional.Interface; +import cpw.mods.fml.common.Optional.InterfaceList; +import cpw.mods.fml.common.Optional.Method; import ic2.api.energy.tile.IEnergySink; import mekanism.api.Coord4D; import mekanism.api.IConfigCardAccess.ISpecialConfigData; @@ -13,426 +17,351 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -import cofh.api.energy.IEnergyHandler; -import cpw.mods.fml.common.Optional.Interface; -import cpw.mods.fml.common.Optional.InterfaceList; -import cpw.mods.fml.common.Optional.Method; - -@InterfaceList({ - @Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2") -}) -public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock implements ISidedInventory, IEnergySink, IStrictEnergyAcceptor, IEnergyHandler, IComputerIntegration, ISpecialConfigData -{ - @Override - public int getSizeInventory() - { - if(getInv() == null) - { - return 0; - } - - return getInv().getSizeInventory(); - } - - @Override - public ItemStack getStackInSlot(int i) - { - if(getInv() == null) - { - return null; - } - - return getInv().getStackInSlot(i); - } - - @Override - public ItemStack decrStackSize(int i, int j) - { - if(getInv() == null) - { - return null; - } - - return getInv().decrStackSize(i, j); - } - - @Override - public ItemStack getStackInSlotOnClosing(int i) - { - if(getInv() == null) - { - return null; - } - - return getInv().getStackInSlotOnClosing(i); - } - - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) - { - if(getInv() == null) - { - return; - } - - getInv().setInventorySlotContents(i, itemstack); - } - - @Override - public String getInventoryName() - { - if(getInv() == null) - { - return "null"; - } - - return getInv().getInventoryName(); - } - - @Override - public boolean hasCustomInventoryName() - { - if(getInv() == null) - { - return false; - } - - return getInv().hasCustomInventoryName(); - } - - @Override - public int getInventoryStackLimit() - { - if(getInv() == null) - { - return 0; - } - - return getInv().getInventoryStackLimit(); - } - - @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) - { - if(getInv() == null) - { - return false; - } - - return getInv().isUseableByPlayer(entityplayer); - } - - @Override - public void openInventory() - { - if(getInv() == null) - { - return; - } - - getInv().openInventory(); - } - - @Override - public void closeInventory() - { - if(getInv() == null) - { - return; - } - - getInv().closeInventory(); - } - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) - { - if(getInv() == null) - { - return false; - } - - return getInv().canBoundInsert(Coord4D.get(this), i, itemstack); - } - - @Override - public int[] getAccessibleSlotsFromSide(int slotID) - { - if(getInv() == null) - { - return InventoryUtils.EMPTY; - } - - return getInv().getBoundSlots(Coord4D.get(this), slotID); - } - - @Override - public boolean canInsertItem(int i, ItemStack itemstack, int j) - { - return isItemValidForSlot(i, itemstack); - } - - @Override - public boolean canExtractItem(int i, ItemStack itemstack, int j) - { - if(getInv() == null) - { - return false; - } - - return getInv().canBoundExtract(Coord4D.get(this), i, itemstack, j); - } - - @Override - @Method(modid = "IC2") - public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) - { - if(getInv() == null) - { - return false; - } - - return getInv().acceptsEnergyFrom(emitter, direction); - } - - @Override - public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) - { - if(getInv() == null || !canReceiveEnergy(from)) - { - return 0; - } - - return getInv().receiveEnergy(from, maxReceive, simulate); - } - - @Override - public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) - { - if(getInv() == null) - { - return 0; - } - - return getInv().extractEnergy(from, maxExtract, simulate); - } - - @Override - public boolean canConnectEnergy(ForgeDirection from) - { - if(getInv() == null) - { - return false; - } - - return canReceiveEnergy(from); - } - - @Override - public int getEnergyStored(ForgeDirection from) - { - if(getInv() == null) - { - return 0; - } - - return getInv().getEnergyStored(from); - } - - @Override - public int getMaxEnergyStored(ForgeDirection from) - { - if(getInv() == null) - { - return 0; - } - - return getInv().getMaxEnergyStored(from); - } - - @Override - public double getEnergy() - { - if(getInv() == null) - { - return 0; - } - - return getInv().getEnergy(); - } - - @Override - public void setEnergy(double energy) - { - if(getInv() == null) - { - return; - } - - getInv().setEnergy(energy); - } - - @Override - public double getMaxEnergy() - { - if(getInv() == null) - { - return 0; - } - - return getInv().getMaxEnergy(); - } - - @Override - public double transferEnergyToAcceptor(ForgeDirection side, double amount) - { - if(getInv() == null || !canReceiveEnergy(side)) - { - return 0; - } - - return getInv().transferEnergyToAcceptor(side, amount); - } - - @Override - public boolean canReceiveEnergy(ForgeDirection side) - { - if(getInv() == null) - { - return false; - } - - return getInv().canBoundReceiveEnergy(Coord4D.get(this), side); - } - - @Override - @Method(modid = "IC2") - public double getDemandedEnergy() - { - if(getInv() == null) - { - return 0; - } - - return getInv().getDemandedEnergy(); - } - - @Override - @Method(modid = "IC2") - public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage) - { - if(getInv() == null || !canReceiveEnergy(directionFrom)) - { - return amount; - } - - return getInv().injectEnergy(directionFrom, amount, voltage); - } - - @Override - @Method(modid = "IC2") - public int getSinkTier() - { - if(getInv() == null) - { - return 0; - } - - return getInv().getSinkTier(); - } - - public IAdvancedBoundingBlock getInv() - { - if(!receivedCoords) - { - return null; - } - - TileEntity tile = new Coord4D(mainX, mainY, mainZ, worldObj.provider.dimensionId).getTileEntity(worldObj); - - if(!(tile instanceof IAdvancedBoundingBlock)) - { - worldObj.setBlockToAir(xCoord, yCoord, zCoord); - return null; - } - - return (IAdvancedBoundingBlock)new Coord4D(mainX, mainY, mainZ, worldObj.provider.dimensionId).getTileEntity(worldObj); - } - - @Override - public void onPower() - { - super.onPower(); - - if(getInv() != null) - { - getInv().onPower(); - } - } - - @Override - public void onNoPower() - { - super.onNoPower(); - - if(getInv() != null) - { - getInv().onNoPower(); - } - } - - @Override - public String[] getMethods() - { - if(getInv() == null) - { - return new String[] {}; - } - - return getInv().getMethods(); - } - - @Override - public Object[] invoke(int method, Object[] arguments) throws Exception - { - if(getInv() == null) - { - return new Object[] {}; - } - - return getInv().invoke(method, arguments); - } - - @Override - public NBTTagCompound getConfigurationData(NBTTagCompound nbtTags) - { - if(getInv() == null) - { - return new NBTTagCompound(); - } - - return getInv().getConfigurationData(nbtTags); - } - - @Override - public void setConfigurationData(NBTTagCompound nbtTags) - { - if(getInv() == null) - { - return; - } - - getInv().setConfigurationData(nbtTags); - } - - @Override - public String getDataType() - { - if(getInv() == null) - { - return "null"; - } - - return getInv().getDataType(); - } + +@InterfaceList({ @Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2") }) +public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock + implements ISidedInventory, IEnergySink, IStrictEnergyAcceptor, IEnergyHandler, + IComputerIntegration, ISpecialConfigData { + @Override + public int getSizeInventory() { + if (getInv() == null) { + return 0; + } + + return getInv().getSizeInventory(); + } + + @Override + public ItemStack getStackInSlot(int i) { + if (getInv() == null) { + return null; + } + + return getInv().getStackInSlot(i); + } + + @Override + public ItemStack decrStackSize(int i, int j) { + if (getInv() == null) { + return null; + } + + return getInv().decrStackSize(i, j); + } + + @Override + public ItemStack getStackInSlotOnClosing(int i) { + if (getInv() == null) { + return null; + } + + return getInv().getStackInSlotOnClosing(i); + } + + @Override + public void setInventorySlotContents(int i, ItemStack itemstack) { + if (getInv() == null) { + return; + } + + getInv().setInventorySlotContents(i, itemstack); + } + + @Override + public String getInventoryName() { + if (getInv() == null) { + return "null"; + } + + return getInv().getInventoryName(); + } + + @Override + public boolean hasCustomInventoryName() { + if (getInv() == null) { + return false; + } + + return getInv().hasCustomInventoryName(); + } + + @Override + public int getInventoryStackLimit() { + if (getInv() == null) { + return 0; + } + + return getInv().getInventoryStackLimit(); + } + + @Override + public boolean isUseableByPlayer(EntityPlayer entityplayer) { + if (getInv() == null) { + return false; + } + + return getInv().isUseableByPlayer(entityplayer); + } + + @Override + public void openInventory() { + if (getInv() == null) { + return; + } + + getInv().openInventory(); + } + + @Override + public void closeInventory() { + if (getInv() == null) { + return; + } + + getInv().closeInventory(); + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + if (getInv() == null) { + return false; + } + + return getInv().canBoundInsert(Coord4D.get(this), i, itemstack); + } + + @Override + public int[] getAccessibleSlotsFromSide(int slotID) { + if (getInv() == null) { + return InventoryUtils.EMPTY; + } + + return getInv().getBoundSlots(Coord4D.get(this), slotID); + } + + @Override + public boolean canInsertItem(int i, ItemStack itemstack, int j) { + return isItemValidForSlot(i, itemstack); + } + + @Override + public boolean canExtractItem(int i, ItemStack itemstack, int j) { + if (getInv() == null) { + return false; + } + + return getInv().canBoundExtract(Coord4D.get(this), i, itemstack, j); + } + + @Override + @Method(modid = "IC2") + public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) { + if (getInv() == null) { + return false; + } + + return getInv().acceptsEnergyFrom(emitter, direction); + } + + @Override + public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { + if (getInv() == null || !canReceiveEnergy(from)) { + return 0; + } + + return getInv().receiveEnergy(from, maxReceive, simulate); + } + + @Override + public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) { + if (getInv() == null) { + return 0; + } + + return getInv().extractEnergy(from, maxExtract, simulate); + } + + @Override + public boolean canConnectEnergy(ForgeDirection from) { + if (getInv() == null) { + return false; + } + + return canReceiveEnergy(from); + } + + @Override + public int getEnergyStored(ForgeDirection from) { + if (getInv() == null) { + return 0; + } + + return getInv().getEnergyStored(from); + } + + @Override + public int getMaxEnergyStored(ForgeDirection from) { + if (getInv() == null) { + return 0; + } + + return getInv().getMaxEnergyStored(from); + } + + @Override + public double getEnergy() { + if (getInv() == null) { + return 0; + } + + return getInv().getEnergy(); + } + + @Override + public void setEnergy(double energy) { + if (getInv() == null) { + return; + } + + getInv().setEnergy(energy); + } + + @Override + public double getMaxEnergy() { + if (getInv() == null) { + return 0; + } + + return getInv().getMaxEnergy(); + } + + @Override + public double transferEnergyToAcceptor(ForgeDirection side, double amount) { + if (getInv() == null || !canReceiveEnergy(side)) { + return 0; + } + + return getInv().transferEnergyToAcceptor(side, amount); + } + + @Override + public boolean canReceiveEnergy(ForgeDirection side) { + if (getInv() == null) { + return false; + } + + return getInv().canBoundReceiveEnergy(Coord4D.get(this), side); + } + + @Override + @Method(modid = "IC2") + public double getDemandedEnergy() { + if (getInv() == null) { + return 0; + } + + return getInv().getDemandedEnergy(); + } + + @Override + @Method(modid = "IC2") + public double + injectEnergy(ForgeDirection directionFrom, double amount, double voltage) { + if (getInv() == null || !canReceiveEnergy(directionFrom)) { + return amount; + } + + return getInv().injectEnergy(directionFrom, amount, voltage); + } + + @Override + @Method(modid = "IC2") + public int getSinkTier() { + if (getInv() == null) { + return 0; + } + + return getInv().getSinkTier(); + } + + public IAdvancedBoundingBlock getInv() { + if (!receivedCoords) { + return null; + } + + TileEntity tile = new Coord4D(mainX, mainY, mainZ, worldObj.provider.dimensionId) + .getTileEntity(worldObj); + + if (!(tile instanceof IAdvancedBoundingBlock)) { + worldObj.setBlockToAir(xCoord, yCoord, zCoord); + return null; + } + + return (IAdvancedBoundingBlock + ) new Coord4D(mainX, mainY, mainZ, worldObj.provider.dimensionId) + .getTileEntity(worldObj); + } + + @Override + public void onPower() { + super.onPower(); + + if (getInv() != null) { + getInv().onPower(); + } + } + + @Override + public void onNoPower() { + super.onNoPower(); + + if (getInv() != null) { + getInv().onNoPower(); + } + } + + @Override + public String[] getMethods() { + if (getInv() == null) { + return new String[] {}; + } + + return getInv().getMethods(); + } + + @Override + public Object[] invoke(int method, Object[] arguments) throws Exception { + if (getInv() == null) { + return new Object[] {}; + } + + return getInv().invoke(method, arguments); + } + + @Override + public NBTTagCompound getConfigurationData(NBTTagCompound nbtTags) { + if (getInv() == null) { + return new NBTTagCompound(); + } + + return getInv().getConfigurationData(nbtTags); + } + + @Override + public void setConfigurationData(NBTTagCompound nbtTags) { + if (getInv() == null) { + return; + } + + getInv().setConfigurationData(nbtTags); + } + + @Override + public String getDataType() { + if (getInv() == null) { + return "null"; + } + + return getInv().getDataType(); + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityAdvancedElectricMachine.java b/src/main/java/mekanism/common/tile/TileEntityAdvancedElectricMachine.java index 1f816b444..120f7ba93 100644 --- a/src/main/java/mekanism/common/tile/TileEntityAdvancedElectricMachine.java +++ b/src/main/java/mekanism/common/tile/TileEntityAdvancedElectricMachine.java @@ -1,9 +1,8 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import io.netty.buffer.ByteBuf; import mekanism.api.EnumColor; import mekanism.api.gas.Gas; import mekanism.api.gas.GasStack; @@ -35,457 +34,472 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; -public abstract class TileEntityAdvancedElectricMachine> extends TileEntityBasicMachine implements IGasHandler, ITubeConnection, ITierUpgradeable -{ - /** How much secondary energy (fuel) this machine uses per tick, not including upgrades. */ - public int BASE_SECONDARY_ENERGY_PER_TICK; - - /** How much secondary energy this machine uses per tick, including upgrades. */ - public double secondaryEnergyPerTick; - - public int secondaryEnergyThisTick; - - public static int MAX_GAS = 210; - - public int maxGas; - public GasTank gasTank; - public Gas prevGas; - - public TileEntityAdvancedElectricMachine(String soundPath, String name, double perTick, int secondaryPerTick, int ticksRequired, double maxEnergy) { - this(soundPath, name, perTick, secondaryPerTick, ticksRequired, maxEnergy, MAX_GAS); - } - - /** - * Advanced Electric Machine -- a machine like this has a total of 4 slots. Input slot (0), fuel slot (1), output slot (2), - * energy slot (3), and the upgrade slot (4). The machine will not run if it does not have enough electricity, or if it doesn't have enough - * fuel ticks. - * - * @param soundPath - location of the sound effect - * @param name - full name of this machine - * @param perTick - how much energy this machine uses per tick. - * @param secondaryPerTick - how much secondary energy (fuel) this machine uses per tick. - * @param ticksRequired - how many ticks it takes to smelt an item. - * @param maxEnergy - maximum amount of energy this machine can hold. - */ - public TileEntityAdvancedElectricMachine(String soundPath, String name, double perTick, int secondaryPerTick, int ticksRequired, double maxEnergy, int maxGas) - { - super(soundPath, name, MekanismUtils.getResource(ResourceType.GUI, "GuiAdvancedMachine.png"), perTick, ticksRequired, maxEnergy); - - configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY); - - configComponent.addOutput(TransmissionType.ITEM, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY)); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Input", EnumColor.DARK_RED, new int[] {0})); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Output", EnumColor.DARK_BLUE, new int[] {2})); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Energy", EnumColor.DARK_GREEN, new int[] {3})); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Extra", EnumColor.PURPLE, new int[] {1})); - - configComponent.setConfig(TransmissionType.ITEM, new byte[] {4, 1, 0, 3, 0, 2}); - configComponent.setInputConfig(TransmissionType.ENERGY); - - this.maxGas = maxGas; - gasTank = new GasTank(maxGas); - - inventory = new ItemStack[5]; - - BASE_SECONDARY_ENERGY_PER_TICK = secondaryPerTick; - secondaryEnergyPerTick = secondaryPerTick; - - upgradeComponent = upgradeableSecondaryEfficiency() ? new TileComponentAdvancedUpgrade(this, 4) : new TileComponentUpgrade(this, 4); - upgradeComponent.setSupported(Upgrade.MUFFLING); - - ejectorComponent = new TileComponentEjector(this); - ejectorComponent.setOutputData(TransmissionType.ITEM, configComponent.getOutputs(TransmissionType.ITEM).get(2)); - } - - @Override - public boolean upgrade(BaseTier upgradeTier) - { - if(upgradeTier != BaseTier.BASIC) - { - return false; - } - - worldObj.setBlockToAir(xCoord, yCoord, zCoord); - worldObj.setBlock(xCoord, yCoord, zCoord, MekanismBlocks.MachineBlock, 5, 3); - - TileEntityFactory factory = (TileEntityFactory)worldObj.getTileEntity(xCoord, yCoord, zCoord); - RecipeType type = RecipeType.getFromMachine(getBlockType(), getBlockMetadata()); - - //Basic - factory.facing = facing; - factory.clientFacing = clientFacing; - factory.ticker = ticker; - factory.redstone = redstone; - factory.redstoneLastTick = redstoneLastTick; - factory.doAutoSync = doAutoSync; - - //Electric - factory.electricityStored = electricityStored; - - //Noisy - factory.soundURL = soundURL; - - //Machine - factory.progress[0] = operatingTicks; - factory.updateDelay = updateDelay; - factory.isActive = isActive; - factory.clientActive = clientActive; - factory.controlType = controlType; - factory.prevEnergy = prevEnergy; - factory.upgradeComponent.readFrom(upgradeComponent); - factory.upgradeComponent.setUpgradeSlot(0); - factory.ejectorComponent.readFrom(ejectorComponent); - factory.ejectorComponent.setOutputData(TransmissionType.ITEM, factory.configComponent.getOutputs(TransmissionType.ITEM).get(2)); - factory.recipeType = type; - factory.upgradeComponent.setSupported(Upgrade.GAS, type.fuelEnergyUpgrades()); - factory.securityComponent.readFrom(securityComponent); - - for(TransmissionType transmission : configComponent.transmissions) - { - factory.configComponent.setConfig(transmission, configComponent.getConfig(transmission)); - factory.configComponent.setEjecting(transmission, configComponent.isEjecting(transmission)); - } - - //Advanced Machine - factory.gasTank.setGas(gasTank.getGas()); - - factory.inventory[5] = inventory[0]; - factory.inventory[4] = inventory[1]; - factory.inventory[5+3] = inventory[2]; - factory.inventory[1] = inventory[3]; - factory.inventory[0] = inventory[4]; - - for(Upgrade upgrade : factory.upgradeComponent.getSupportedTypes()) - { - factory.recalculateUpgradables(upgrade); - } - - factory.upgraded = true; - factory.markDirty(); - - return true; - } - - /** - * Gets the amount of ticks the declared itemstack can fuel this machine. - * @param itemstack - itemstack to check with - * @return fuel ticks - */ - public abstract GasStack getItemGas(ItemStack itemstack); - - public abstract boolean isValidGas(Gas gas); - - @Override - public void onUpdate() - { - super.onUpdate(); - - if(!worldObj.isRemote) - { - ChargeUtils.discharge(3, this); - - handleSecondaryFuel(); - - boolean inactive = false; - - RECIPE recipe = getRecipe(); - - secondaryEnergyThisTick = useStatisticalMechanics() ? StatUtils.inversePoisson(secondaryEnergyPerTick) : (int)Math.ceil(secondaryEnergyPerTick); - - if(canOperate(recipe) && MekanismUtils.canFunction(this) && getEnergy() >= energyPerTick && gasTank.getStored() >= secondaryEnergyThisTick) - { - setActive(true); - - operatingTicks++; - - if(operatingTicks >= ticksRequired) - { - operate(recipe); - - operatingTicks = 0; - } - - gasTank.draw(secondaryEnergyThisTick, true); - electricityStored -= energyPerTick; - } - else { - inactive = true; - setActive(false); - } - - if(inactive && getRecipe() == null) - { - operatingTicks = 0; - } - - prevEnergy = getEnergy(); - - if(!(gasTank.getGasType() == null || gasTank.getStored() == 0)) - { - prevGas = gasTank.getGasType(); - } - } - } - - public void handleSecondaryFuel() - { - if(inventory[1] != null && gasTank.getNeeded() > 0) - { - GasStack stack = getItemGas(inventory[1]); - int gasNeeded = gasTank.getNeeded(); - - if(stack != null && gasTank.canReceive(stack.getGas()) && gasNeeded >= stack.amount) - { - gasTank.receive(stack, true); - - inventory[1].stackSize--; - - if(inventory[1].stackSize == 0) - { - inventory[1] = null; - } - } - } - } - - public boolean upgradeableSecondaryEfficiency() - { - return false; - } - - public boolean useStatisticalMechanics() - { - return false; - } - - @Override - public boolean isItemValidForSlot(int slotID, ItemStack itemstack) - { - if(slotID == 2) - { - return false; - } - else if(slotID == 4) - { - return itemstack.getItem() == MekanismItems.SpeedUpgrade || itemstack.getItem() == MekanismItems.EnergyUpgrade; - } - else if(slotID == 0) - { - for(AdvancedMachineInput input : getRecipes().keySet()) - { - if(input.itemStack.isItemEqual(itemstack)) - { - return true; - } - } - } - else if(slotID == 3) - { - return ChargeUtils.canBeDischarged(itemstack); - } - else if(slotID == 1) - { - return getItemGas(itemstack) != null; - } - - return false; - } - - @Override - public AdvancedMachineInput getInput() - { - return new AdvancedMachineInput(inventory[0], prevGas); - } - - @Override - public RECIPE getRecipe() - { - AdvancedMachineInput input = getInput(); - - if(cachedRecipe == null || !input.testEquality(cachedRecipe.getInput())) - { - cachedRecipe = RecipeHandler.getRecipe(input, getRecipes()); - } - - return cachedRecipe; - } - - @Override - public void operate(RECIPE recipe) - { - recipe.operate(inventory, 0, 2, gasTank, secondaryEnergyThisTick); - - markDirty(); - ejectorComponent.outputItems(); - } - - @Override - public boolean canOperate(RECIPE recipe) - { - return recipe != null && recipe.canOperate(inventory, 0, 2, gasTank, secondaryEnergyThisTick); - } - - @Override - public void handlePacketData(ByteBuf dataStream) - { - super.handlePacketData(dataStream); - - if(worldObj.isRemote) - { - if(dataStream.readBoolean()) - { - gasTank.setGas(new GasStack(dataStream.readInt(), dataStream.readInt())); - } - else { - gasTank.setGas(null); - } - } - } - - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); - - if(gasTank.getGas() != null) - { - data.add(true); - data.add(gasTank.getGas().getGas().getID()); - data.add(gasTank.getStored()); - } - else { - data.add(false); - } - - return data; - } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - gasTank.read(nbtTags.getCompoundTag("gasTank")); - gasTank.setMaxGas(maxGas); - } - - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - nbtTags.setTag("gasTank", gasTank.write(new NBTTagCompound())); - } - - /** - * Gets the scaled secondary energy level for the GUI. - * @param i - multiplier - * @return scaled secondary energy - */ - public int getScaledGasLevel(int i) - { - return gasTank.getStored()*i / gasTank.getMaxGas(); - } - - @Override - public boolean canExtractItem(int slotID, ItemStack itemstack, int side) - { - if(slotID == 3) - { - return ChargeUtils.canBeOutputted(itemstack, false); - } - else if(slotID == 2) - { - return true; - } - - return false; - } - - @Override - public boolean canTubeConnect(ForgeDirection side) - { - return false; - } - - @Override - public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) - { - return 0; - } - - @Override - public int receiveGas(ForgeDirection side, GasStack stack) - { - return receiveGas(side, stack, true); - } - - @Override - public GasStack drawGas(ForgeDirection side, int amount, boolean doTransfer) - { - return null; - } - - @Override - public GasStack drawGas(ForgeDirection side, int amount) - { - return drawGas(side, amount, true); - } - - @Override - public boolean canReceiveGas(ForgeDirection side, Gas type) - { - return false; - } - - @Override - public boolean canDrawGas(ForgeDirection side, Gas type) - { - return false; - } - - @Override - public void recalculateUpgradables(Upgrade upgrade) - { - super.recalculateUpgradables(upgrade); - - if(upgrade == Upgrade.SPEED || (upgradeableSecondaryEfficiency() && upgrade == Upgrade.GAS)) - { - secondaryEnergyPerTick = MekanismUtils.getSecondaryEnergyPerTickMean(this, BASE_SECONDARY_ENERGY_PER_TICK); - } - } - - private static final String[] methods = new String[] {"getEnergy", "getSecondaryStored", "getProgress", "isActive", "facing", "canOperate", "getMaxEnergy", "getEnergyNeeded"}; - - @Override - public String[] getMethods() - { - return methods; - } - - @Override - public Object[] invoke(int method, Object[] arguments) throws Exception - { - switch(method) - { - case 0: - return new Object[] {getEnergy()}; - case 1: - return new Object[] {gasTank.getStored()}; - case 2: - return new Object[] {operatingTicks}; - case 3: - return new Object[] {isActive}; - case 4: - return new Object[] {facing}; - case 5: - return new Object[] {canOperate(RecipeHandler.getRecipe(getInput(), getRecipes()))}; - case 6: - return new Object[] {maxEnergy}; - case 7: - return new Object[] {maxEnergy-getEnergy()}; - default: - throw new NoSuchMethodException(); - } - } +public abstract class TileEntityAdvancedElectricMachine< + RECIPE extends AdvancedMachineRecipe> + extends TileEntityBasicMachine + implements IGasHandler, ITubeConnection, ITierUpgradeable { + /** + * How much secondary energy (fuel) this machine uses per tick, not including + * upgrades. + */ + public int BASE_SECONDARY_ENERGY_PER_TICK; + + /** How much secondary energy this machine uses per tick, including upgrades. */ + public double secondaryEnergyPerTick; + + public int secondaryEnergyThisTick; + + public static int MAX_GAS = 210; + + public int maxGas; + public GasTank gasTank; + public Gas prevGas; + + public TileEntityAdvancedElectricMachine( + String soundPath, + String name, + double perTick, + int secondaryPerTick, + int ticksRequired, + double maxEnergy + ) { + this( + soundPath, name, perTick, secondaryPerTick, ticksRequired, maxEnergy, MAX_GAS + ); + } + + /** + * Advanced Electric Machine -- a machine like this has a total of 4 slots. Input slot + * (0), fuel slot (1), output slot (2), energy slot (3), and the upgrade slot (4). The + * machine will not run if it does not have enough electricity, or if it doesn't have + * enough fuel ticks. + * + * @param soundPath - location of the sound effect + * @param name - full name of this machine + * @param perTick - how much energy this machine uses per tick. + * @param secondaryPerTick - how much secondary energy (fuel) this machine uses per + * tick. + * @param ticksRequired - how many ticks it takes to smelt an item. + * @param maxEnergy - maximum amount of energy this machine can hold. + */ + public TileEntityAdvancedElectricMachine( + String soundPath, + String name, + double perTick, + int secondaryPerTick, + int ticksRequired, + double maxEnergy, + int maxGas + ) { + super( + soundPath, + name, + MekanismUtils.getResource(ResourceType.GUI, "GuiAdvancedMachine.png"), + perTick, + ticksRequired, + maxEnergy + ); + + configComponent = new TileComponentConfig( + this, TransmissionType.ITEM, TransmissionType.ENERGY + ); + + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY) + ); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("Input", EnumColor.DARK_RED, new int[] { 0 }) + ); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("Output", EnumColor.DARK_BLUE, new int[] { 2 }) + ); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("Energy", EnumColor.DARK_GREEN, new int[] { 3 }) + ); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("Extra", EnumColor.PURPLE, new int[] { 1 }) + ); + + configComponent.setConfig(TransmissionType.ITEM, new byte[] { 4, 1, 0, 3, 0, 2 }); + configComponent.setInputConfig(TransmissionType.ENERGY); + + this.maxGas = maxGas; + gasTank = new GasTank(maxGas); + + inventory = new ItemStack[5]; + + BASE_SECONDARY_ENERGY_PER_TICK = secondaryPerTick; + secondaryEnergyPerTick = secondaryPerTick; + + upgradeComponent = upgradeableSecondaryEfficiency() + ? new TileComponentAdvancedUpgrade(this, 4) + : new TileComponentUpgrade(this, 4); + upgradeComponent.setSupported(Upgrade.MUFFLING); + + ejectorComponent = new TileComponentEjector(this); + ejectorComponent.setOutputData( + TransmissionType.ITEM, + configComponent.getOutputs(TransmissionType.ITEM).get(2) + ); + } + + @Override + public boolean upgrade(BaseTier upgradeTier) { + if (upgradeTier != BaseTier.BASIC) { + return false; + } + + worldObj.setBlockToAir(xCoord, yCoord, zCoord); + worldObj.setBlock(xCoord, yCoord, zCoord, MekanismBlocks.MachineBlock, 5, 3); + + TileEntityFactory factory + = (TileEntityFactory) worldObj.getTileEntity(xCoord, yCoord, zCoord); + RecipeType type = RecipeType.getFromMachine(getBlockType(), getBlockMetadata()); + + //Basic + factory.facing = facing; + factory.clientFacing = clientFacing; + factory.ticker = ticker; + factory.redstone = redstone; + factory.redstoneLastTick = redstoneLastTick; + factory.doAutoSync = doAutoSync; + + //Electric + factory.electricityStored = electricityStored; + + //Noisy + factory.soundURL = soundURL; + + //Machine + factory.progress[0] = operatingTicks; + factory.updateDelay = updateDelay; + factory.isActive = isActive; + factory.clientActive = clientActive; + factory.controlType = controlType; + factory.prevEnergy = prevEnergy; + factory.upgradeComponent.readFrom(upgradeComponent); + factory.upgradeComponent.setUpgradeSlot(0); + factory.ejectorComponent.readFrom(ejectorComponent); + factory.ejectorComponent.setOutputData( + TransmissionType.ITEM, + factory.configComponent.getOutputs(TransmissionType.ITEM).get(2) + ); + factory.recipeType = type; + factory.upgradeComponent.setSupported(Upgrade.GAS, type.fuelEnergyUpgrades()); + factory.securityComponent.readFrom(securityComponent); + + for (TransmissionType transmission : configComponent.transmissions) { + factory.configComponent.setConfig( + transmission, configComponent.getConfig(transmission) + ); + factory.configComponent.setEjecting( + transmission, configComponent.isEjecting(transmission) + ); + } + + //Advanced Machine + factory.gasTank.setGas(gasTank.getGas()); + + factory.inventory[5] = inventory[0]; + factory.inventory[4] = inventory[1]; + factory.inventory[5 + 3] = inventory[2]; + factory.inventory[1] = inventory[3]; + factory.inventory[0] = inventory[4]; + + for (Upgrade upgrade : factory.upgradeComponent.getSupportedTypes()) { + factory.recalculateUpgradables(upgrade); + } + + factory.upgraded = true; + factory.markDirty(); + + return true; + } + + /** + * Gets the amount of ticks the declared itemstack can fuel this machine. + * @param itemstack - itemstack to check with + * @return fuel ticks + */ + public abstract GasStack getItemGas(ItemStack itemstack); + + public abstract boolean isValidGas(Gas gas); + + @Override + public void onUpdate() { + super.onUpdate(); + + if (!worldObj.isRemote) { + ChargeUtils.discharge(3, this); + + handleSecondaryFuel(); + + boolean inactive = false; + + RECIPE recipe = getRecipe(); + + secondaryEnergyThisTick = useStatisticalMechanics() + ? StatUtils.inversePoisson(secondaryEnergyPerTick) + : (int) Math.ceil(secondaryEnergyPerTick); + + if (canOperate(recipe) && MekanismUtils.canFunction(this) + && getEnergy() >= energyPerTick + && gasTank.getStored() >= secondaryEnergyThisTick) { + setActive(true); + + operatingTicks++; + + if (operatingTicks >= ticksRequired) { + operate(recipe); + + operatingTicks = 0; + } + + gasTank.draw(secondaryEnergyThisTick, true); + electricityStored -= energyPerTick; + } else { + inactive = true; + setActive(false); + } + + if (inactive && getRecipe() == null) { + operatingTicks = 0; + } + + prevEnergy = getEnergy(); + + if (!(gasTank.getGasType() == null || gasTank.getStored() == 0)) { + prevGas = gasTank.getGasType(); + } + } + } + + public void handleSecondaryFuel() { + if (inventory[1] != null && gasTank.getNeeded() > 0) { + GasStack stack = getItemGas(inventory[1]); + int gasNeeded = gasTank.getNeeded(); + + if (stack != null && gasTank.canReceive(stack.getGas()) + && gasNeeded >= stack.amount) { + gasTank.receive(stack, true); + + inventory[1].stackSize--; + + if (inventory[1].stackSize == 0) { + inventory[1] = null; + } + } + } + } + + public boolean upgradeableSecondaryEfficiency() { + return false; + } + + public boolean useStatisticalMechanics() { + return false; + } + + @Override + public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { + if (slotID == 2) { + return false; + } else if (slotID == 4) { + return itemstack.getItem() == MekanismItems.SpeedUpgrade + || itemstack.getItem() == MekanismItems.EnergyUpgrade; + } else if (slotID == 0) { + for (AdvancedMachineInput input : getRecipes().keySet()) { + if (input.itemStack.isItemEqual(itemstack)) { + return true; + } + } + } else if (slotID == 3) { + return ChargeUtils.canBeDischarged(itemstack); + } else if (slotID == 1) { + return getItemGas(itemstack) != null; + } + + return false; + } + + @Override + public AdvancedMachineInput getInput() { + return new AdvancedMachineInput(inventory[0], prevGas); + } + + @Override + public RECIPE getRecipe() { + AdvancedMachineInput input = getInput(); + + if (cachedRecipe == null || !input.testEquality(cachedRecipe.getInput())) { + cachedRecipe = RecipeHandler.getRecipe(input, getRecipes()); + } + + return cachedRecipe; + } + + @Override + public void operate(RECIPE recipe) { + recipe.operate(inventory, 0, 2, gasTank, secondaryEnergyThisTick); + + markDirty(); + ejectorComponent.outputItems(); + } + + @Override + public boolean canOperate(RECIPE recipe) { + return recipe != null + && recipe.canOperate(inventory, 0, 2, gasTank, secondaryEnergyThisTick); + } + + @Override + public void handlePacketData(ByteBuf dataStream) { + super.handlePacketData(dataStream); + + if (worldObj.isRemote) { + if (dataStream.readBoolean()) { + gasTank.setGas(new GasStack(dataStream.readInt(), dataStream.readInt())); + } else { + gasTank.setGas(null); + } + } + } + + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); + + if (gasTank.getGas() != null) { + data.add(true); + data.add(gasTank.getGas().getGas().getID()); + data.add(gasTank.getStored()); + } else { + data.add(false); + } + + return data; + } + + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); + + gasTank.read(nbtTags.getCompoundTag("gasTank")); + gasTank.setMaxGas(maxGas); + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); + + nbtTags.setTag("gasTank", gasTank.write(new NBTTagCompound())); + } + + /** + * Gets the scaled secondary energy level for the GUI. + * @param i - multiplier + * @return scaled secondary energy + */ + public int getScaledGasLevel(int i) { + return gasTank.getStored() * i / gasTank.getMaxGas(); + } + + @Override + public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { + if (slotID == 3) { + return ChargeUtils.canBeOutputted(itemstack, false); + } else if (slotID == 2) { + return true; + } + + return false; + } + + @Override + public boolean canTubeConnect(ForgeDirection side) { + return false; + } + + @Override + public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) { + return 0; + } + + @Override + public int receiveGas(ForgeDirection side, GasStack stack) { + return receiveGas(side, stack, true); + } + + @Override + public GasStack drawGas(ForgeDirection side, int amount, boolean doTransfer) { + return null; + } + + @Override + public GasStack drawGas(ForgeDirection side, int amount) { + return drawGas(side, amount, true); + } + + @Override + public boolean canReceiveGas(ForgeDirection side, Gas type) { + return false; + } + + @Override + public boolean canDrawGas(ForgeDirection side, Gas type) { + return false; + } + + @Override + public void recalculateUpgradables(Upgrade upgrade) { + super.recalculateUpgradables(upgrade); + + if (upgrade == Upgrade.SPEED + || (upgradeableSecondaryEfficiency() && upgrade == Upgrade.GAS)) { + secondaryEnergyPerTick = MekanismUtils.getSecondaryEnergyPerTickMean( + this, BASE_SECONDARY_ENERGY_PER_TICK + ); + } + } + + private static final String[] methods = new String[] { + "getEnergy", "getSecondaryStored", "getProgress", "isActive", + "facing", "canOperate", "getMaxEnergy", "getEnergyNeeded" + }; + + @Override + public String[] getMethods() { + return methods; + } + + @Override + public Object[] invoke(int method, Object[] arguments) throws Exception { + switch (method) { + case 0: + return new Object[] { getEnergy() }; + case 1: + return new Object[] { gasTank.getStored() }; + case 2: + return new Object[] { operatingTicks }; + case 3: + return new Object[] { isActive }; + case 4: + return new Object[] { facing }; + case 5: + return new Object[] { + canOperate(RecipeHandler.getRecipe(getInput(), getRecipes())) + }; + case 6: + return new Object[] { maxEnergy }; + case 7: + return new Object[] { maxEnergy - getEnergy() }; + default: + throw new NoSuchMethodException(); + } + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityAdvancedFactory.java b/src/main/java/mekanism/common/tile/TileEntityAdvancedFactory.java index fe5b0ee39..bbb751885 100644 --- a/src/main/java/mekanism/common/tile/TileEntityAdvancedFactory.java +++ b/src/main/java/mekanism/common/tile/TileEntityAdvancedFactory.java @@ -3,40 +3,63 @@ package mekanism.common.tile; import mekanism.api.EnumColor; import mekanism.api.transmitters.TransmissionType; import mekanism.common.SideData; -import mekanism.common.Upgrade; import mekanism.common.Tier.FactoryTier; +import mekanism.common.Upgrade; import mekanism.common.block.BlockMachine.MachineType; import mekanism.common.tile.component.TileComponentConfig; import mekanism.common.tile.component.TileComponentEjector; import mekanism.common.tile.component.TileComponentUpgrade; import mekanism.common.util.InventoryUtils; -public class TileEntityAdvancedFactory extends TileEntityFactory -{ - public TileEntityAdvancedFactory() - { - super(FactoryTier.ADVANCED, MachineType.ADVANCED_FACTORY); +public class TileEntityAdvancedFactory extends TileEntityFactory { + public TileEntityAdvancedFactory() { + super(FactoryTier.ADVANCED, MachineType.ADVANCED_FACTORY); - configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY, TransmissionType.GAS); - - configComponent.addOutput(TransmissionType.ITEM, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY)); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Input", EnumColor.DARK_RED, new int[] {5, 6, 7, 8, 9})); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Output", EnumColor.DARK_BLUE, new int[] {10, 11, 12, 13, 14})); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Energy", EnumColor.DARK_GREEN, new int[] {1})); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Extra", EnumColor.PURPLE, new int[] {4})); - configComponent.setConfig(TransmissionType.ITEM, new byte[] {4, 0, 0, 3, 1, 2}); - - configComponent.addOutput(TransmissionType.GAS, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY)); - configComponent.addOutput(TransmissionType.GAS, new SideData("Gas", EnumColor.DARK_RED, new int[] {0})); - configComponent.fillConfig(TransmissionType.GAS, 1); - configComponent.setCanEject(TransmissionType.GAS, false); - - configComponent.setInputConfig(TransmissionType.ENERGY); + configComponent = new TileComponentConfig( + this, TransmissionType.ITEM, TransmissionType.ENERGY, TransmissionType.GAS + ); - upgradeComponent = new TileComponentUpgrade(this, 0); - upgradeComponent.setSupported(Upgrade.MUFFLING); - - ejectorComponent = new TileComponentEjector(this); - ejectorComponent.setOutputData(TransmissionType.ITEM, configComponent.getOutputs(TransmissionType.ITEM).get(2)); - } + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY) + ); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("Input", EnumColor.DARK_RED, new int[] { 5, 6, 7, 8, 9 }) + ); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("Output", EnumColor.DARK_BLUE, new int[] { 10, 11, 12, 13, 14 }) + ); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("Energy", EnumColor.DARK_GREEN, new int[] { 1 }) + ); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("Extra", EnumColor.PURPLE, new int[] { 4 }) + ); + configComponent.setConfig(TransmissionType.ITEM, new byte[] { 4, 0, 0, 3, 1, 2 }); + + configComponent.addOutput( + TransmissionType.GAS, + new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY) + ); + configComponent.addOutput( + TransmissionType.GAS, new SideData("Gas", EnumColor.DARK_RED, new int[] { 0 }) + ); + configComponent.fillConfig(TransmissionType.GAS, 1); + configComponent.setCanEject(TransmissionType.GAS, false); + + configComponent.setInputConfig(TransmissionType.ENERGY); + + upgradeComponent = new TileComponentUpgrade(this, 0); + upgradeComponent.setSupported(Upgrade.MUFFLING); + + ejectorComponent = new TileComponentEjector(this); + ejectorComponent.setOutputData( + TransmissionType.ITEM, + configComponent.getOutputs(TransmissionType.ITEM).get(2) + ); + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityAmbientAccumulator.java b/src/main/java/mekanism/common/tile/TileEntityAmbientAccumulator.java index 19df868d7..2cdc263a1 100644 --- a/src/main/java/mekanism/common/tile/TileEntityAmbientAccumulator.java +++ b/src/main/java/mekanism/common/tile/TileEntityAmbientAccumulator.java @@ -1,10 +1,9 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.Random; +import io.netty.buffer.ByteBuf; import mekanism.api.gas.Gas; import mekanism.api.gas.GasStack; import mekanism.api.gas.GasTank; @@ -16,112 +15,95 @@ import mekanism.common.recipe.machines.AmbientGasRecipe; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityAmbientAccumulator extends TileEntityContainerBlock implements IGasHandler, ITubeConnection -{ - public GasTank collectedGas = new GasTank(1000); +public class TileEntityAmbientAccumulator + extends TileEntityContainerBlock implements IGasHandler, ITubeConnection { + public GasTank collectedGas = new GasTank(1000); - public int cachedDimensionId = 0; - public AmbientGasRecipe cachedRecipe; + public int cachedDimensionId = 0; + public AmbientGasRecipe cachedRecipe; - public static Random gasRand = new Random(); + public static Random gasRand = new Random(); - public TileEntityAmbientAccumulator() - { - super("AmbientAccumulator"); - inventory = new ItemStack[0]; - } + public TileEntityAmbientAccumulator() { + super("AmbientAccumulator"); + inventory = new ItemStack[0]; + } - @Override - public void onUpdate() - { - if(!worldObj.isRemote) - { - if(cachedRecipe == null || worldObj.provider.dimensionId != cachedDimensionId) - { - cachedDimensionId = worldObj.provider.dimensionId; - cachedRecipe = RecipeHandler.getDimensionGas(new IntegerInput(cachedDimensionId)); - } + @Override + public void onUpdate() { + if (!worldObj.isRemote) { + if (cachedRecipe == null + || worldObj.provider.dimensionId != cachedDimensionId) { + cachedDimensionId = worldObj.provider.dimensionId; + cachedRecipe + = RecipeHandler.getDimensionGas(new IntegerInput(cachedDimensionId)); + } - if(cachedRecipe != null && gasRand.nextDouble() < 0.05 && cachedRecipe.getOutput().applyOutputs(collectedGas, false, 1)) - { - cachedRecipe.getOutput().applyOutputs(collectedGas, true, 1); - } - } - } + if (cachedRecipe != null && gasRand.nextDouble() < 0.05 + && cachedRecipe.getOutput().applyOutputs(collectedGas, false, 1)) { + cachedRecipe.getOutput().applyOutputs(collectedGas, true, 1); + } + } + } + @Override + public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) { + return 0; + } - @Override - public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) - { - return 0; - } + @Override + public int receiveGas(ForgeDirection side, GasStack stack) { + return receiveGas(side, stack, true); + } - @Override - public int receiveGas(ForgeDirection side, GasStack stack) - { - return receiveGas(side, stack, true); - } + @Override + public GasStack drawGas(ForgeDirection side, int amount, boolean doTransfer) { + return collectedGas.draw(amount, doTransfer); + } - @Override - public GasStack drawGas(ForgeDirection side, int amount, boolean doTransfer) - { - return collectedGas.draw(amount, doTransfer); - } + @Override + public GasStack drawGas(ForgeDirection side, int amount) { + return drawGas(side, amount, true); + } - @Override - public GasStack drawGas(ForgeDirection side, int amount) - { - return drawGas(side, amount, true); - } + @Override + public boolean canReceiveGas(ForgeDirection side, Gas type) { + return false; + } - @Override - public boolean canReceiveGas(ForgeDirection side, Gas type) - { - return false; - } + @Override + public boolean canDrawGas(ForgeDirection side, Gas type) { + return type == collectedGas.getGasType(); + } - @Override - public boolean canDrawGas(ForgeDirection side, Gas type) - { - return type == collectedGas.getGasType(); - } + @Override + public boolean canTubeConnect(ForgeDirection side) { + return true; + } - @Override - public boolean canTubeConnect(ForgeDirection side) - { - return true; - } + @Override + public ArrayList getNetworkedData(ArrayList data) { + if (collectedGas.getGasType() != null) { + data.add(collectedGas.getGasType().getID()); + data.add(collectedGas.getStored()); + } else { + data.add(-1); + data.add(0); + } - @Override - public ArrayList getNetworkedData(ArrayList data) - { - if(collectedGas.getGasType() != null) - { - data.add(collectedGas.getGasType().getID()); - data.add(collectedGas.getStored()); - } - else { - data.add(-1); - data.add(0); - } - - return data; - } + return data; + } - @Override - public void handlePacketData(ByteBuf data) - { - if(worldObj.isRemote) - { - int gasID = data.readInt(); - - if(gasID < 0) - { - collectedGas.setGas(null); - } - else { - collectedGas.setGas(new GasStack(gasID, data.readInt())); - } - } - } + @Override + public void handlePacketData(ByteBuf data) { + if (worldObj.isRemote) { + int gasID = data.readInt(); + + if (gasID < 0) { + collectedGas.setGas(null); + } else { + collectedGas.setGas(new GasStack(gasID, data.readInt())); + } + } + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityBasicBlock.java b/src/main/java/mekanism/common/tile/TileEntityBasicBlock.java index 4bf01c918..fc9b2934b 100644 --- a/src/main/java/mekanism/common/tile/TileEntityBasicBlock.java +++ b/src/main/java/mekanism/common/tile/TileEntityBasicBlock.java @@ -1,12 +1,13 @@ package mekanism.common.tile; -import ic2.api.tile.IWrenchable; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.HashSet; import java.util.List; +import cpw.mods.fml.common.Optional.Interface; +import cpw.mods.fml.common.Optional.Method; +import ic2.api.tile.IWrenchable; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.MekanismConfig.general; import mekanism.api.Range4D; @@ -28,284 +29,264 @@ import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -import cpw.mods.fml.common.Optional.Interface; -import cpw.mods.fml.common.Optional.Method; @Interface(iface = "ic2.api.tile.IWrenchable", modid = "IC2") -public abstract class TileEntityBasicBlock extends TileEntity implements IWrenchable, ITileNetwork, IChunkLoadHandler, IFrequencyHandler -{ - /** The direction this block is facing. */ - public int facing; +public abstract class TileEntityBasicBlock extends TileEntity + implements IWrenchable, ITileNetwork, IChunkLoadHandler, IFrequencyHandler { + /** The direction this block is facing. */ + public int facing; - public int clientFacing; + public int clientFacing; - /** The players currently using this block. */ - public HashSet playersUsing = new HashSet(); + /** The players currently using this block. */ + public HashSet playersUsing = new HashSet(); - /** A timer used to send packets to clients. */ - public int ticker; + /** A timer used to send packets to clients. */ + public int ticker; - public boolean redstone = false; - public boolean redstoneLastTick = false; + public boolean redstone = false; + public boolean redstoneLastTick = false; - public boolean doAutoSync = true; + public boolean doAutoSync = true; - public List components = new ArrayList(); + public List components = new ArrayList(); - @Override - public void updateEntity() - { - if(!worldObj.isRemote && general.destroyDisabledBlocks) - { - MachineType type = MachineType.get(getBlockType(), getBlockMetadata()); - - if(type != null && !type.isEnabled()) - { - Mekanism.logger.info("[Mekanism] Destroying machine of type '" + type.name + "' at coords " + Coord4D.get(this) + " as according to config."); - worldObj.setBlockToAir(xCoord, yCoord, zCoord); - return; - } - } - - for(ITileComponent component : components) - { - component.tick(); - } + @Override + public void updateEntity() { + if (!worldObj.isRemote && general.destroyDisabledBlocks) { + MachineType type = MachineType.get(getBlockType(), getBlockMetadata()); - onUpdate(); + if (type != null && !type.isEnabled()) { + Mekanism.logger.info( + "[Mekanism] Destroying machine of type '" + type.name + "' at coords " + + Coord4D.get(this) + " as according to config." + ); + worldObj.setBlockToAir(xCoord, yCoord, zCoord); + return; + } + } - if(!worldObj.isRemote) - { - if(doAutoSync && playersUsing.size() > 0) - { - for(EntityPlayer player : playersUsing) - { - Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), (EntityPlayerMP)player); - } - } - } + for (ITileComponent component : components) { + component.tick(); + } - ticker++; - redstoneLastTick = redstone; - } - - @Override - public void onChunkLoad() - { - markDirty(); - } + onUpdate(); - public void open(EntityPlayer player) - { - playersUsing.add(player); - } + if (!worldObj.isRemote) { + if (doAutoSync && playersUsing.size() > 0) { + for (EntityPlayer player : playersUsing) { + Mekanism.packetHandler.sendTo( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + (EntityPlayerMP) player + ); + } + } + } - public void close(EntityPlayer player) - { - playersUsing.remove(player); - } + ticker++; + redstoneLastTick = redstone; + } - @Override - public void handlePacketData(ByteBuf dataStream) - { - if(worldObj.isRemote) - { - facing = dataStream.readInt(); - redstone = dataStream.readBoolean(); - - if(clientFacing != facing) - { - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord)); - clientFacing = facing; - } - - for(ITileComponent component : components) - { - component.read(dataStream); - } - } - } + @Override + public void onChunkLoad() { + markDirty(); + } - @Override - public ArrayList getNetworkedData(ArrayList data) - { - data.add(facing); - data.add(redstone); + public void open(EntityPlayer player) { + playersUsing.add(player); + } - for(ITileComponent component : components) - { - component.write(data); - } + public void close(EntityPlayer player) { + playersUsing.remove(player); + } - return data; - } - - @Override - public void invalidate() - { - super.invalidate(); - - for(ITileComponent component : components) - { - component.invalidate(); - } - } + @Override + public void handlePacketData(ByteBuf dataStream) { + if (worldObj.isRemote) { + facing = dataStream.readInt(); + redstone = dataStream.readBoolean(); - @Override - public void validate() - { - super.validate(); + if (clientFacing != facing) { + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + worldObj.notifyBlocksOfNeighborChange( + xCoord, yCoord, zCoord, worldObj.getBlock(xCoord, yCoord, zCoord) + ); + clientFacing = facing; + } - if(worldObj.isRemote) - { - Mekanism.packetHandler.sendToServer(new DataRequestMessage(Coord4D.get(this))); - } - } + for (ITileComponent component : components) { + component.read(dataStream); + } + } + } - /** - * Update call for machines. Use instead of updateEntity -- it's called every tick. - */ - public abstract void onUpdate(); + @Override + public ArrayList getNetworkedData(ArrayList data) { + data.add(facing); + data.add(redstone); - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); + for (ITileComponent component : components) { + component.write(data); + } - facing = nbtTags.getInteger("facing"); - redstone = nbtTags.getBoolean("redstone"); + return data; + } - for(ITileComponent component : components) - { - component.read(nbtTags); - } - } + @Override + public void invalidate() { + super.invalidate(); - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); + for (ITileComponent component : components) { + component.invalidate(); + } + } - nbtTags.setInteger("facing", facing); - nbtTags.setBoolean("redstone", redstone); + @Override + public void validate() { + super.validate(); - for(ITileComponent component : components) - { - component.write(nbtTags); - } - } + if (worldObj.isRemote) { + Mekanism.packetHandler.sendToServer(new DataRequestMessage(Coord4D.get(this)) + ); + } + } - @Override - @Method(modid = "IC2") - public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) - { - return true; - } + /** + * Update call for machines. Use instead of updateEntity -- it's called every tick. + */ + public abstract void onUpdate(); - @Override - @Method(modid = "IC2") - public short getFacing() - { - return (short)facing; - } + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); - @Override - public void setFacing(short direction) - { - if(canSetFacing(direction)) - { - facing = direction; - } + facing = nbtTags.getInteger("facing"); + redstone = nbtTags.getBoolean("redstone"); - if(!(facing == clientFacing || worldObj.isRemote)) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - markDirty(); - clientFacing = facing; - } - } + for (ITileComponent component : components) { + component.read(nbtTags); + } + } - /** - * Whether or not this block's orientation can be changed to a specific direction. True by default. - * @param facing - facing to check - * @return if the block's orientation can be changed - */ - public boolean canSetFacing(int facing) - { - return true; - } + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); - @Override - @Method(modid = "IC2") - public boolean wrenchCanRemove(EntityPlayer entityPlayer) - { - return true; - } + nbtTags.setInteger("facing", facing); + nbtTags.setBoolean("redstone", redstone); - @Override - @Method(modid = "IC2") - public float getWrenchDropRate() - { - return 1.0F; - } + for (ITileComponent component : components) { + component.write(nbtTags); + } + } - @Override - @Method(modid = "IC2") - public ItemStack getWrenchDrop(EntityPlayer entityPlayer) - { - return getBlockType().getPickBlock(null, worldObj, xCoord, yCoord, zCoord, entityPlayer); - } + @Override + @Method(modid = "IC2") + public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) { + return true; + } - public boolean isPowered() - { - return redstone; - } + @Override + @Method(modid = "IC2") + public short getFacing() { + return (short) facing; + } - public boolean wasPowered() - { - return redstoneLastTick; - } - - public void onPowerChange() {} + @Override + public void setFacing(short direction) { + if (canSetFacing(direction)) { + facing = direction; + } - public void onNeighborChange(Block block) - { - if(!worldObj.isRemote) - { - updatePower(); - } - } - - private void updatePower() - { - boolean power = worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord); + if (!(facing == clientFacing || worldObj.isRemote)) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + markDirty(); + clientFacing = facing; + } + } - if(redstone != power) - { - redstone = power; - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - - onPowerChange(); - } - } - - /** - * Called when block is placed in world - */ - public void onAdded() - { - updatePower(); - } - - @Override - public Frequency getFrequency(FrequencyManager manager) - { - if(manager == Mekanism.securityFrequencies && this instanceof ISecurityTile) - { - return ((ISecurityTile)this).getSecurity().getFrequency(); - } - - return null; - } + /** + * Whether or not this block's orientation can be changed to a specific direction. + * True by default. + * @param facing - facing to check + * @return if the block's orientation can be changed + */ + public boolean canSetFacing(int facing) { + return true; + } + + @Override + @Method(modid = "IC2") + public boolean wrenchCanRemove(EntityPlayer entityPlayer) { + return true; + } + + @Override + @Method(modid = "IC2") + public float getWrenchDropRate() { + return 1.0F; + } + + @Override + @Method(modid = "IC2") + public ItemStack getWrenchDrop(EntityPlayer entityPlayer) { + return getBlockType().getPickBlock( + null, worldObj, xCoord, yCoord, zCoord, entityPlayer + ); + } + + public boolean isPowered() { + return redstone; + } + + public boolean wasPowered() { + return redstoneLastTick; + } + + public void onPowerChange() {} + + public void onNeighborChange(Block block) { + if (!worldObj.isRemote) { + updatePower(); + } + } + + private void updatePower() { + boolean power = worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord); + + if (redstone != power) { + redstone = power; + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + + onPowerChange(); + } + } + + /** + * Called when block is placed in world + */ + public void onAdded() { + updatePower(); + } + + @Override + public Frequency getFrequency(FrequencyManager manager) { + if (manager == Mekanism.securityFrequencies && this instanceof ISecurityTile) { + return ((ISecurityTile) this).getSecurity().getFrequency(); + } + + return null; + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityBasicMachine.java b/src/main/java/mekanism/common/tile/TileEntityBasicMachine.java index eed0677f0..70dceef0c 100644 --- a/src/main/java/mekanism/common/tile/TileEntityBasicMachine.java +++ b/src/main/java/mekanism/common/tile/TileEntityBasicMachine.java @@ -1,10 +1,9 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.EnumSet; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.IConfigCardAccess; import mekanism.api.MekanismConfig.general; @@ -31,280 +30,275 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ResourceLocation; import net.minecraftforge.common.util.ForgeDirection; -public abstract class TileEntityBasicMachine, OUTPUT extends MachineOutput, RECIPE extends MachineRecipe> extends TileEntityNoisyElectricBlock implements IElectricMachine, IComputerIntegration, ISideConfiguration, IUpgradeTile, IRedstoneControl, IConfigCardAccess, ISecurityTile -{ - /** How much energy this machine uses per tick, un-upgraded. */ - public double BASE_ENERGY_PER_TICK; +public abstract class TileEntityBasicMachine< + INPUT extends MachineInput, OUTPUT extends MachineOutput, RECIPE + extends MachineRecipe> extends TileEntityNoisyElectricBlock + implements IElectricMachine, IComputerIntegration, + ISideConfiguration, IUpgradeTile, IRedstoneControl, IConfigCardAccess, + ISecurityTile { + /** How much energy this machine uses per tick, un-upgraded. */ + public double BASE_ENERGY_PER_TICK; - /** How much energy this machine uses per tick including upgrades */ - public double energyPerTick; + /** How much energy this machine uses per tick including upgrades */ + public double energyPerTick; - /** How many ticks this machine has operated for. */ - public int operatingTicks = 0; + /** How many ticks this machine has operated for. */ + public int operatingTicks = 0; - /** Un-upgraded ticks required to operate -- or smelt an item. */ - public int BASE_TICKS_REQUIRED; + /** Un-upgraded ticks required to operate -- or smelt an item. */ + public int BASE_TICKS_REQUIRED; - /** Ticks required including upgrades */ - public int ticksRequired; + /** Ticks required including upgrades */ + public int ticksRequired; - /** How many ticks must pass until this block's active state can sync with the client. */ - public int updateDelay; + /** + * How many ticks must pass until this block's active state can sync with the client. + */ + public int updateDelay; - /** Whether or not this block is in it's active state. */ - public boolean isActive; + /** Whether or not this block is in it's active state. */ + public boolean isActive; - /** The client's current active state. */ - public boolean clientActive; + /** The client's current active state. */ + public boolean clientActive; - /** The GUI texture path for this machine. */ - public ResourceLocation guiLocation; + /** The GUI texture path for this machine. */ + public ResourceLocation guiLocation; - /** This machine's current RedstoneControl type. */ - public RedstoneControl controlType = RedstoneControl.DISABLED; + /** This machine's current RedstoneControl type. */ + public RedstoneControl controlType = RedstoneControl.DISABLED; - /** This machine's previous amount of energy. */ - public double prevEnergy; + /** This machine's previous amount of energy. */ + public double prevEnergy; - public RECIPE cachedRecipe = null; + public RECIPE cachedRecipe = null; - public TileComponentUpgrade upgradeComponent; - public TileComponentEjector ejectorComponent; - public TileComponentConfig configComponent; - public TileComponentSecurity securityComponent; + public TileComponentUpgrade upgradeComponent; + public TileComponentEjector ejectorComponent; + public TileComponentConfig configComponent; + public TileComponentSecurity securityComponent; - /** - * The foundation of all machines - a simple tile entity with a facing, active state, initialized state, sound effect, and animated texture. - * @param soundPath - location of the sound effect - * @param name - full name of this machine - * @param location - GUI texture path of this machine - * @param perTick - the energy this machine consumes every tick in it's active state - * @param baseTicksRequired - how many ticks it takes to run a cycle - * @param maxEnergy - how much energy this machine can store - */ - public TileEntityBasicMachine(String soundPath, String name, ResourceLocation location, double perTick, int baseTicksRequired, double maxEnergy) - { - super("machine." + soundPath, name, maxEnergy); - - BASE_ENERGY_PER_TICK = perTick; - energyPerTick = perTick; - BASE_TICKS_REQUIRED = baseTicksRequired; - ticksRequired = baseTicksRequired; - guiLocation = location; - isActive = false; - - securityComponent = new TileComponentSecurity(this); - } + /** + * The foundation of all machines - a simple tile entity with a facing, active state, + * initialized state, sound effect, and animated texture. + * @param soundPath - location of the sound effect + * @param name - full name of this machine + * @param location - GUI texture path of this machine + * @param perTick - the energy this machine consumes every tick in it's active state + * @param baseTicksRequired - how many ticks it takes to run a cycle + * @param maxEnergy - how much energy this machine can store + */ + public TileEntityBasicMachine( + String soundPath, + String name, + ResourceLocation location, + double perTick, + int baseTicksRequired, + double maxEnergy + ) { + super("machine." + soundPath, name, maxEnergy); - @Override - public void onUpdate() - { - super.onUpdate(); + BASE_ENERGY_PER_TICK = perTick; + energyPerTick = perTick; + BASE_TICKS_REQUIRED = baseTicksRequired; + ticksRequired = baseTicksRequired; + guiLocation = location; + isActive = false; - if(worldObj.isRemote && updateDelay > 0) - { - updateDelay--; + securityComponent = new TileComponentSecurity(this); + } - if(updateDelay == 0 && clientActive != isActive) - { - isActive = clientActive; - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } + @Override + public void onUpdate() { + super.onUpdate(); - if(!worldObj.isRemote) - { - if(updateDelay > 0) - { - updateDelay--; + if (worldObj.isRemote && updateDelay > 0) { + updateDelay--; - if(updateDelay == 0 && clientActive != isActive) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - } - } - } - } - - @Override - public EnumSet getConsumingSides() - { - return configComponent.getSidesForData(TransmissionType.ENERGY, facing, 1); - } + if (updateDelay == 0 && clientActive != isActive) { + isActive = clientActive; + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); + if (!worldObj.isRemote) { + if (updateDelay > 0) { + updateDelay--; - operatingTicks = nbtTags.getInteger("operatingTicks"); - clientActive = isActive = nbtTags.getBoolean("isActive"); - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - } + if (updateDelay == 0 && clientActive != isActive) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + } + } + } + } - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); + @Override + public EnumSet getConsumingSides() { + return configComponent.getSidesForData(TransmissionType.ENERGY, facing, 1); + } - nbtTags.setInteger("operatingTicks", operatingTicks); - nbtTags.setBoolean("isActive", isActive); - nbtTags.setInteger("controlType", controlType.ordinal()); - } + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); - @Override - public void handlePacketData(ByteBuf dataStream) - { - super.handlePacketData(dataStream); + operatingTicks = nbtTags.getInteger("operatingTicks"); + clientActive = isActive = nbtTags.getBoolean("isActive"); + controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + } - if(worldObj.isRemote) - { - operatingTicks = dataStream.readInt(); - clientActive = dataStream.readBoolean(); - ticksRequired = dataStream.readInt(); - controlType = RedstoneControl.values()[dataStream.readInt()]; - - if(updateDelay == 0 && clientActive != isActive) - { - updateDelay = general.UPDATE_DELAY; - isActive = clientActive; - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } - } + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); + nbtTags.setInteger("operatingTicks", operatingTicks); + nbtTags.setBoolean("isActive", isActive); + nbtTags.setInteger("controlType", controlType.ordinal()); + } - data.add(operatingTicks); - data.add(isActive); - data.add(ticksRequired); - data.add(controlType.ordinal()); + @Override + public void handlePacketData(ByteBuf dataStream) { + super.handlePacketData(dataStream); - return data; - } + if (worldObj.isRemote) { + operatingTicks = dataStream.readInt(); + clientActive = dataStream.readBoolean(); + ticksRequired = dataStream.readInt(); + controlType = RedstoneControl.values()[dataStream.readInt()]; - /** - * Gets the scaled progress level for the GUI. - * @return - */ - public double getScaledProgress() - { - return ((double)operatingTicks) / ((double)ticksRequired); - } + if (updateDelay == 0 && clientActive != isActive) { + updateDelay = general.UPDATE_DELAY; + isActive = clientActive; + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } + } - @Override - public boolean getActive() - { - return isActive; - } + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); - @Override - public void setActive(boolean active) - { - isActive = active; + data.add(operatingTicks); + data.add(isActive); + data.add(ticksRequired); + data.add(controlType.ordinal()); - if(clientActive != active && updateDelay == 0) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); + return data; + } - updateDelay = 10; - clientActive = active; - } - } + /** + * Gets the scaled progress level for the GUI. + * @return + */ + public double getScaledProgress() { + return ((double) operatingTicks) / ((double) ticksRequired); + } - @Override - public void recalculateUpgradables(Upgrade upgrade) - { - super.recalculateUpgradables(upgrade); + @Override + public boolean getActive() { + return isActive; + } - switch(upgrade) - { - case SPEED: - ticksRequired = MekanismUtils.getTicks(this, BASE_TICKS_REQUIRED); - energyPerTick = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK); - break; - case ENERGY: - energyPerTick = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK); - maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY); - break; - default: - break; - } - } + @Override + public void setActive(boolean active) { + isActive = active; - @Override - public boolean canSetFacing(int facing) - { - return facing != 0 && facing != 1; - } + if (clientActive != active && updateDelay == 0) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); - @Override - public int[] getAccessibleSlotsFromSide(int side) - { - return configComponent.getOutput(TransmissionType.ITEM, side, facing).availableSlots; - } + updateDelay = 10; + clientActive = active; + } + } - @Override - public TileComponentConfig getConfig() - { - return configComponent; - } + @Override + public void recalculateUpgradables(Upgrade upgrade) { + super.recalculateUpgradables(upgrade); - @Override - public int getOrientation() - { - return facing; - } + switch (upgrade) { + case SPEED: + ticksRequired = MekanismUtils.getTicks(this, BASE_TICKS_REQUIRED); + energyPerTick + = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK); + break; + case ENERGY: + energyPerTick + = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK); + maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY); + break; + default: + break; + } + } - @Override - public boolean renderUpdate() - { - return true; - } + @Override + public boolean canSetFacing(int facing) { + return facing != 0 && facing != 1; + } - @Override - public boolean lightUpdate() - { - return true; - } + @Override + public int[] getAccessibleSlotsFromSide(int side) { + return configComponent.getOutput(TransmissionType.ITEM, side, facing) + .availableSlots; + } - @Override - public RedstoneControl getControlType() - { - return controlType; - } + @Override + public TileComponentConfig getConfig() { + return configComponent; + } - @Override - public void setControlType(RedstoneControl type) - { - controlType = type; - MekanismUtils.saveChunk(this); - } + @Override + public int getOrientation() { + return facing; + } - @Override - public boolean canPulse() - { - return false; - } + @Override + public boolean renderUpdate() { + return true; + } - @Override - public TileComponentUpgrade getComponent() - { - return upgradeComponent; - } + @Override + public boolean lightUpdate() { + return true; + } - @Override - public TileComponentEjector getEjector() - { - return ejectorComponent; - } - - @Override - public TileComponentSecurity getSecurity() - { - return securityComponent; - } + @Override + public RedstoneControl getControlType() { + return controlType; + } + + @Override + public void setControlType(RedstoneControl type) { + controlType = type; + MekanismUtils.saveChunk(this); + } + + @Override + public boolean canPulse() { + return false; + } + + @Override + public TileComponentUpgrade getComponent() { + return upgradeComponent; + } + + @Override + public TileComponentEjector getEjector() { + return ejectorComponent; + } + + @Override + public TileComponentSecurity getSecurity() { + return securityComponent; + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityBin.java b/src/main/java/mekanism/common/tile/TileEntityBin.java index 8f9f54f33..107c3f6a6 100644 --- a/src/main/java/mekanism/common/tile/TileEntityBin.java +++ b/src/main/java/mekanism/common/tile/TileEntityBin.java @@ -1,9 +1,9 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import cpw.mods.fml.common.Optional.Interface; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.IConfigurable; import mekanism.api.Range4D; @@ -31,574 +31,518 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; import powercrystals.minefactoryreloaded.api.IDeepStorageUnit; -import cpw.mods.fml.common.Optional.Interface; - -@Interface(iface = "powercrystals.minefactoryreloaded.api.IDeepStorageUnit", modid = "MineFactoryReloaded") -public class TileEntityBin extends TileEntityBasicBlock implements ISidedInventory, IActiveState, IDeepStorageUnit, IConfigurable, ITierUpgradeable -{ - public boolean isActive; - - public boolean clientActive; - - public final int MAX_DELAY = 10; - - public int addTicks = 0; - - public int delayTicks; - - public int cacheCount; - - public BinTier tier = BinTier.BASIC; - - public ItemStack itemType; - - public ItemStack topStack; - public ItemStack bottomStack; - - public int prevCount; - - public int clientAmount; - - @Override - public boolean upgrade(BaseTier upgradeTier) - { - if(upgradeTier.ordinal() != tier.ordinal()+1) - { - return false; - } - - tier = BinTier.values()[upgradeTier.ordinal()]; - - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - markDirty(); - - return true; - } - - public void sortStacks() - { - if(getItemCount() == 0 || itemType == null) - { - itemType = null; - topStack = null; - bottomStack = null; - cacheCount = 0; - - return; - } - - int count = getItemCount(); - int remain = tier.storage-count; - - if(remain >= itemType.getMaxStackSize()) - { - topStack = null; - } - else { - topStack = itemType.copy(); - topStack.stackSize = itemType.getMaxStackSize()-remain; - } - - count -= StackUtils.getSize(topStack); - - bottomStack = itemType.copy(); - bottomStack.stackSize = Math.min(itemType.getMaxStackSize(), count); - - count -= StackUtils.getSize(bottomStack); - - cacheCount = count; - } - - public boolean isValid(ItemStack stack) - { - if(stack == null || stack.stackSize <= 0) - { - return false; - } - - if(stack.getItem() instanceof ItemBlockBasic && stack.getItemDamage() == 6) - { - return false; - } - - if(itemType == null) - { - return true; - } - - if(!stack.isItemEqual(itemType) || !ItemStack.areItemStackTagsEqual(stack, itemType)) - { - return false; - } - - return true; - } - - public ItemStack add(ItemStack stack) - { - if(isValid(stack) && getItemCount() != tier.storage) - { - if(itemType == null) - { - setItemType(stack); - } - - if(getItemCount() + stack.stackSize <= tier.storage) - { - setItemCount(getItemCount() + stack.stackSize); - return null; - } - else { - ItemStack rejects = itemType.copy(); - rejects.stackSize = (getItemCount()+stack.stackSize) - tier.storage; - - setItemCount(tier.storage); - - return rejects; - } - } - - return stack; - } - - public ItemStack removeStack() - { - if(getItemCount() == 0) - { - return null; - } - - return remove(bottomStack.stackSize); - } - - public ItemStack remove(int amount) - { - if(getItemCount() == 0) - { - return null; - } - - ItemStack ret = itemType.copy(); - ret.stackSize = Math.min(Math.min(amount, itemType.getMaxStackSize()), getItemCount()); - - setItemCount(getItemCount() - ret.stackSize); - - return ret; - } - - public int getItemCount() - { - return StackUtils.getSize(bottomStack) + cacheCount + StackUtils.getSize(topStack); - } - - @Override - public void onUpdate() - { - if(!worldObj.isRemote) - { - addTicks = Math.max(0, addTicks-1); - delayTicks = Math.max(0, delayTicks-1); - - sortStacks(); - - if(getItemCount() != prevCount) - { - markDirty(); - MekanismUtils.saveChunk(this); - } - - if(delayTicks == 0) - { - if(bottomStack != null && isActive) - { - TileEntity tile = Coord4D.get(this).getFromSide(ForgeDirection.getOrientation(0)).getTileEntity(worldObj); - - if(tile instanceof ITransporterTile) - { - ILogisticalTransporter transporter = ((ITransporterTile)tile).getTransmitter(); - - ItemStack rejects = TransporterUtils.insert(this, transporter, bottomStack, null, true, 0); - - if(TransporterManager.didEmit(bottomStack, rejects)) - { - setInventorySlotContents(0, rejects); - } - } - else if(tile instanceof IInventory) - { - setInventorySlotContents(0, InventoryUtils.putStackInInventory((IInventory)tile, bottomStack, 0, false)); - } - - delayTicks = 10; - } - } - else { - delayTicks--; - } - } - } - - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - nbtTags.setBoolean("isActive", isActive); - nbtTags.setInteger("itemCount", cacheCount); - nbtTags.setInteger("tier", tier.ordinal()); - - if(bottomStack != null) - { - nbtTags.setTag("bottomStack", bottomStack.writeToNBT(new NBTTagCompound())); - } - - if(topStack != null) - { - nbtTags.setTag("topStack", topStack.writeToNBT(new NBTTagCompound())); - } - - if(getItemCount() > 0) - { - nbtTags.setTag("itemType", itemType.writeToNBT(new NBTTagCompound())); - } - } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - isActive = nbtTags.getBoolean("isActive"); - cacheCount = nbtTags.getInteger("itemCount"); - tier = BinTier.values()[nbtTags.getInteger("tier")]; - - bottomStack = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("bottomStack")); - topStack = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("topStack")); - - if(getItemCount() > 0) - { - itemType = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("itemType")); - } - } - - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); - - data.add(isActive); - data.add(getItemCount()); - data.add(tier.ordinal()); - - if(getItemCount() > 0) - { - data.add(itemType); - } - - return data; - } - - @Override - public void handlePacketData(ByteBuf dataStream) - { - super.handlePacketData(dataStream); - - if(worldObj.isRemote) - { - isActive = dataStream.readBoolean(); - clientAmount = dataStream.readInt(); - tier = BinTier.values()[dataStream.readInt()]; - - if(clientAmount > 0) - { - itemType = PacketHandler.readStack(dataStream); - } - else { - itemType = null; - } - - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } - - @Override - public ItemStack getStackInSlot(int slotID) - { - if(slotID == 1) - { - return topStack; - } - else { - return bottomStack; - } - } - - @Override - public ItemStack decrStackSize(int slotID, int amount) - { - if(slotID == 1) - { - return null; - } - else if(slotID == 0) - { - int toRemove = Math.min(getItemCount(), amount); - - if(toRemove > 0) - { - ItemStack ret = itemType.copy(); - ret.stackSize = toRemove; - - setItemCount(getItemCount()-toRemove); - - return ret; - } - } - - return null; - } - - @Override - public ItemStack getStackInSlotOnClosing(int slotID) - { - return getStackInSlot(slotID); - } - - @Override - public int getSizeInventory() - { - return 2; - } - - @Override - public void setInventorySlotContents(int i, ItemStack itemstack) - { - if(i == 0) - { - if(getItemCount() == 0) - { - return; - } - - if(itemstack == null) - { - setItemCount(getItemCount() - bottomStack.stackSize); - } - else { - setItemCount(getItemCount() - (bottomStack.stackSize-itemstack.stackSize)); - } - } - else if(i == 1) - { - if(itemstack == null) - { - topStack = null; - } - else { - if(isValid(itemstack) && itemstack.stackSize > StackUtils.getSize(topStack)) - { - add(StackUtils.size(itemstack, itemstack.stackSize-StackUtils.getSize(topStack))); - } - } - } - } - - @Override - public void markDirty() - { - super.markDirty(); - - if(!worldObj.isRemote) - { - MekanismUtils.saveChunk(this); - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - prevCount = getItemCount(); - sortStacks(); - } - } - - public void setItemType(ItemStack stack) - { - if(stack == null) - { - itemType = null; - cacheCount = 0; - topStack = null; - bottomStack = null; - return; - } - - ItemStack ret = stack.copy(); - ret.stackSize = 1; - itemType = ret; - } - - public void setItemCount(int count) - { - cacheCount = Math.max(0, count); - topStack = null; - bottomStack = null; - - if(count == 0) - { - setItemType(null); - } - - markDirty(); - } - - @Override - public String getInventoryName() - { - return LangUtils.localize(getBlockType().getUnlocalizedName() + ".Bin" + tier.getBaseTier().getName() + ".name"); - } - - @Override - public boolean hasCustomInventoryName() - { - return true; - } - - @Override - public int getInventoryStackLimit() - { - return 64; - } - - @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) - { - return true; - } - - @Override - public void openInventory() {} - - @Override - public void closeInventory() {} - - @Override - public boolean isItemValidForSlot(int i, ItemStack itemstack) - { - return i == 1 ? isValid(itemstack) : false; - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) - { - if(side == 1) - { - return new int[] {1}; - } - else if(side == 0) - { - return new int[] {0}; - } - - return InventoryUtils.EMPTY; - } - - @Override - public boolean canInsertItem(int i, ItemStack itemstack, int j) - { - return isItemValidForSlot(i, itemstack); - } - - @Override - public boolean canExtractItem(int i, ItemStack itemstack, int j) - { - return i == 0 ? isValid(itemstack) : false; - } - - @Override - public boolean canSetFacing(int facing) - { - return facing != 0 && facing != 1; - } - - @Override - public void setActive(boolean active) - { - isActive = active; - - if(clientActive != active) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - - clientActive = active; - } - } - - @Override - public boolean getActive() - { - return isActive; - } - - @Override - public boolean renderUpdate() - { - return true; - } - - @Override - public boolean lightUpdate() - { - return true; - } - - @Override - public ItemStack getStoredItemType() - { - if(itemType == null) - { - return null; - } - - return MekanismUtils.size(itemType, getItemCount()); - } - - @Override - public void setStoredItemCount(int amount) - { - if(amount == 0) - { - setStoredItemType(null, 0); - } - - setItemCount(amount); - } - - @Override - public void setStoredItemType(ItemStack type, int amount) - { - itemType = type; - cacheCount = amount; - - topStack = null; - bottomStack = null; - - markDirty(); - } - - @Override - public int getMaxStoredCount() - { - return tier.storage; - } - - @Override - public boolean onSneakRightClick(EntityPlayer player, int side) - { - setActive(!getActive()); - worldObj.playSoundEffect(xCoord, yCoord, zCoord, "random.click", 0.3F, 1); - - return true; - } - - @Override - public boolean onRightClick(EntityPlayer player, int side) - { - return false; - } + +@Interface( + iface = "powercrystals.minefactoryreloaded.api.IDeepStorageUnit", + modid = "MineFactoryReloaded" +) +public class TileEntityBin extends TileEntityBasicBlock + implements ISidedInventory, IActiveState, IDeepStorageUnit, IConfigurable, + ITierUpgradeable { + public boolean isActive; + + public boolean clientActive; + + public final int MAX_DELAY = 10; + + public int addTicks = 0; + + public int delayTicks; + + public int cacheCount; + + public BinTier tier = BinTier.BASIC; + + public ItemStack itemType; + + public ItemStack topStack; + public ItemStack bottomStack; + + public int prevCount; + + public int clientAmount; + + @Override + public boolean upgrade(BaseTier upgradeTier) { + if (upgradeTier.ordinal() != tier.ordinal() + 1) { + return false; + } + + tier = BinTier.values()[upgradeTier.ordinal()]; + + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), + new Range4D(Coord4D.get(this)) + ); + markDirty(); + + return true; + } + + public void sortStacks() { + if (getItemCount() == 0 || itemType == null) { + itemType = null; + topStack = null; + bottomStack = null; + cacheCount = 0; + + return; + } + + int count = getItemCount(); + int remain = tier.storage - count; + + if (remain >= itemType.getMaxStackSize()) { + topStack = null; + } else { + topStack = itemType.copy(); + topStack.stackSize = itemType.getMaxStackSize() - remain; + } + + count -= StackUtils.getSize(topStack); + + bottomStack = itemType.copy(); + bottomStack.stackSize = Math.min(itemType.getMaxStackSize(), count); + + count -= StackUtils.getSize(bottomStack); + + cacheCount = count; + } + + public boolean isValid(ItemStack stack) { + if (stack == null || stack.stackSize <= 0) { + return false; + } + + if (stack.getItem() instanceof ItemBlockBasic && stack.getItemDamage() == 6) { + return false; + } + + if (itemType == null) { + return true; + } + + if (!stack.isItemEqual(itemType) + || !ItemStack.areItemStackTagsEqual(stack, itemType)) { + return false; + } + + return true; + } + + public ItemStack add(ItemStack stack) { + if (isValid(stack) && getItemCount() != tier.storage) { + if (itemType == null) { + setItemType(stack); + } + + if (getItemCount() + stack.stackSize <= tier.storage) { + setItemCount(getItemCount() + stack.stackSize); + return null; + } else { + ItemStack rejects = itemType.copy(); + rejects.stackSize = (getItemCount() + stack.stackSize) - tier.storage; + + setItemCount(tier.storage); + + return rejects; + } + } + + return stack; + } + + public ItemStack removeStack() { + if (getItemCount() == 0) { + return null; + } + + return remove(bottomStack.stackSize); + } + + public ItemStack remove(int amount) { + if (getItemCount() == 0) { + return null; + } + + ItemStack ret = itemType.copy(); + ret.stackSize + = Math.min(Math.min(amount, itemType.getMaxStackSize()), getItemCount()); + + setItemCount(getItemCount() - ret.stackSize); + + return ret; + } + + public int getItemCount() { + return StackUtils.getSize(bottomStack) + cacheCount + + StackUtils.getSize(topStack); + } + + @Override + public void onUpdate() { + if (!worldObj.isRemote) { + addTicks = Math.max(0, addTicks - 1); + delayTicks = Math.max(0, delayTicks - 1); + + sortStacks(); + + if (getItemCount() != prevCount) { + markDirty(); + MekanismUtils.saveChunk(this); + } + + if (delayTicks == 0) { + if (bottomStack != null && isActive) { + TileEntity tile = Coord4D.get(this) + .getFromSide(ForgeDirection.getOrientation(0)) + .getTileEntity(worldObj); + + if (tile instanceof ITransporterTile) { + ILogisticalTransporter transporter + = ((ITransporterTile) tile).getTransmitter(); + + ItemStack rejects = TransporterUtils.insert( + this, transporter, bottomStack, null, true, 0 + ); + + if (TransporterManager.didEmit(bottomStack, rejects)) { + setInventorySlotContents(0, rejects); + } + } else if (tile instanceof IInventory) { + setInventorySlotContents( + 0, + InventoryUtils.putStackInInventory( + (IInventory) tile, bottomStack, 0, false + ) + ); + } + + delayTicks = 10; + } + } else { + delayTicks--; + } + } + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); + + nbtTags.setBoolean("isActive", isActive); + nbtTags.setInteger("itemCount", cacheCount); + nbtTags.setInteger("tier", tier.ordinal()); + + if (bottomStack != null) { + nbtTags.setTag("bottomStack", bottomStack.writeToNBT(new NBTTagCompound())); + } + + if (topStack != null) { + nbtTags.setTag("topStack", topStack.writeToNBT(new NBTTagCompound())); + } + + if (getItemCount() > 0) { + nbtTags.setTag("itemType", itemType.writeToNBT(new NBTTagCompound())); + } + } + + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); + + isActive = nbtTags.getBoolean("isActive"); + cacheCount = nbtTags.getInteger("itemCount"); + tier = BinTier.values()[nbtTags.getInteger("tier")]; + + bottomStack + = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("bottomStack")); + topStack = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("topStack")); + + if (getItemCount() > 0) { + itemType = ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("itemType")); + } + } + + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); + + data.add(isActive); + data.add(getItemCount()); + data.add(tier.ordinal()); + + if (getItemCount() > 0) { + data.add(itemType); + } + + return data; + } + + @Override + public void handlePacketData(ByteBuf dataStream) { + super.handlePacketData(dataStream); + + if (worldObj.isRemote) { + isActive = dataStream.readBoolean(); + clientAmount = dataStream.readInt(); + tier = BinTier.values()[dataStream.readInt()]; + + if (clientAmount > 0) { + itemType = PacketHandler.readStack(dataStream); + } else { + itemType = null; + } + + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } + + @Override + public ItemStack getStackInSlot(int slotID) { + if (slotID == 1) { + return topStack; + } else { + return bottomStack; + } + } + + @Override + public ItemStack decrStackSize(int slotID, int amount) { + if (slotID == 1) { + return null; + } else if (slotID == 0) { + int toRemove = Math.min(getItemCount(), amount); + + if (toRemove > 0) { + ItemStack ret = itemType.copy(); + ret.stackSize = toRemove; + + setItemCount(getItemCount() - toRemove); + + return ret; + } + } + + return null; + } + + @Override + public ItemStack getStackInSlotOnClosing(int slotID) { + return getStackInSlot(slotID); + } + + @Override + public int getSizeInventory() { + return 2; + } + + @Override + public void setInventorySlotContents(int i, ItemStack itemstack) { + if (i == 0) { + if (getItemCount() == 0) { + return; + } + + if (itemstack == null) { + setItemCount(getItemCount() - bottomStack.stackSize); + } else { + setItemCount( + getItemCount() - (bottomStack.stackSize - itemstack.stackSize) + ); + } + } else if (i == 1) { + if (itemstack == null) { + topStack = null; + } else { + if (isValid(itemstack) + && itemstack.stackSize > StackUtils.getSize(topStack)) { + add(StackUtils.size( + itemstack, itemstack.stackSize - StackUtils.getSize(topStack) + )); + } + } + } + } + + @Override + public void markDirty() { + super.markDirty(); + + if (!worldObj.isRemote) { + MekanismUtils.saveChunk(this); + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + prevCount = getItemCount(); + sortStacks(); + } + } + + public void setItemType(ItemStack stack) { + if (stack == null) { + itemType = null; + cacheCount = 0; + topStack = null; + bottomStack = null; + return; + } + + ItemStack ret = stack.copy(); + ret.stackSize = 1; + itemType = ret; + } + + public void setItemCount(int count) { + cacheCount = Math.max(0, count); + topStack = null; + bottomStack = null; + + if (count == 0) { + setItemType(null); + } + + markDirty(); + } + + @Override + public String getInventoryName() { + return LangUtils.localize( + getBlockType().getUnlocalizedName() + ".Bin" + tier.getBaseTier().getName() + + ".name" + ); + } + + @Override + public boolean hasCustomInventoryName() { + return true; + } + + @Override + public int getInventoryStackLimit() { + return 64; + } + + @Override + public boolean isUseableByPlayer(EntityPlayer entityplayer) { + return true; + } + + @Override + public void openInventory() {} + + @Override + public void closeInventory() {} + + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) { + return i == 1 ? isValid(itemstack) : false; + } + + @Override + public int[] getAccessibleSlotsFromSide(int side) { + if (side == 1) { + return new int[] { 1 }; + } else if (side == 0) { + return new int[] { 0 }; + } + + return InventoryUtils.EMPTY; + } + + @Override + public boolean canInsertItem(int i, ItemStack itemstack, int j) { + return isItemValidForSlot(i, itemstack); + } + + @Override + public boolean canExtractItem(int i, ItemStack itemstack, int j) { + return i == 0 ? isValid(itemstack) : false; + } + + @Override + public boolean canSetFacing(int facing) { + return facing != 0 && facing != 1; + } + + @Override + public void setActive(boolean active) { + isActive = active; + + if (clientActive != active) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + + clientActive = active; + } + } + + @Override + public boolean getActive() { + return isActive; + } + + @Override + public boolean renderUpdate() { + return true; + } + + @Override + public boolean lightUpdate() { + return true; + } + + @Override + public ItemStack getStoredItemType() { + if (itemType == null) { + return null; + } + + return MekanismUtils.size(itemType, getItemCount()); + } + + @Override + public void setStoredItemCount(int amount) { + if (amount == 0) { + setStoredItemType(null, 0); + } + + setItemCount(amount); + } + + @Override + public void setStoredItemType(ItemStack type, int amount) { + itemType = type; + cacheCount = amount; + + topStack = null; + bottomStack = null; + + markDirty(); + } + + @Override + public int getMaxStoredCount() { + return tier.storage; + } + + @Override + public boolean onSneakRightClick(EntityPlayer player, int side) { + setActive(!getActive()); + worldObj.playSoundEffect(xCoord, yCoord, zCoord, "random.click", 0.3F, 1); + + return true; + } + + @Override + public boolean onRightClick(EntityPlayer player, int side) { + return false; + } } \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityBoilerCasing.java b/src/main/java/mekanism/common/tile/TileEntityBoilerCasing.java index c529bc49d..a460ca224 100644 --- a/src/main/java/mekanism/common/tile/TileEntityBoilerCasing.java +++ b/src/main/java/mekanism/common/tile/TileEntityBoilerCasing.java @@ -1,11 +1,10 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.HashSet; import java.util.Set; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.IHeatTransfer; import mekanism.api.Range4D; @@ -24,390 +23,367 @@ import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; -public class TileEntityBoilerCasing extends TileEntityMultiblock implements IHeatTransfer -{ - /** A client-sided set of valves on this tank's structure that are currently active, used on the client for rendering fluids. */ - public Set valveViewing = new HashSet(); +public class TileEntityBoilerCasing + extends TileEntityMultiblock implements IHeatTransfer { + /** + * A client-sided set of valves on this tank's structure that are currently active, + * used on the client for rendering fluids. + */ + public Set valveViewing = new HashSet(); - /** The capacity this tank has on the client-side. */ - public int clientWaterCapacity; - public int clientSteamCapacity; + /** The capacity this tank has on the client-side. */ + public int clientWaterCapacity; + public int clientSteamCapacity; - public float prevWaterScale; + public float prevWaterScale; - public TileEntityBoilerCasing() - { - this("BoilerCasing"); - } + public TileEntityBoilerCasing() { + this("BoilerCasing"); + } - public TileEntityBoilerCasing(String name) - { - super(name); - inventory = new ItemStack[2]; - } + public TileEntityBoilerCasing(String name) { + super(name); + inventory = new ItemStack[2]; + } - @Override - public void onUpdate() - { - super.onUpdate(); + @Override + public void onUpdate() { + super.onUpdate(); - if(worldObj.isRemote) - { - if(structure != null && clientHasStructure && isRendering) - { - float targetScale = (float)(structure.waterStored != null ? structure.waterStored.amount : 0)/clientWaterCapacity; + if (worldObj.isRemote) { + if (structure != null && clientHasStructure && isRendering) { + float targetScale + = (float + ) (structure.waterStored != null ? structure.waterStored.amount : 0) + / clientWaterCapacity; - if(Math.abs(prevWaterScale - targetScale) > 0.01) - { - prevWaterScale = (9*prevWaterScale + targetScale)/10; - } - } + if (Math.abs(prevWaterScale - targetScale) > 0.01) { + prevWaterScale = (9 * prevWaterScale + targetScale) / 10; + } + } - if(!clientHasStructure || !isRendering) - { - for(ValveData data : valveViewing) - { - TileEntityBoilerCasing tileEntity = (TileEntityBoilerCasing)data.location.getTileEntity(worldObj); + if (!clientHasStructure || !isRendering) { + for (ValveData data : valveViewing) { + TileEntityBoilerCasing tileEntity + = (TileEntityBoilerCasing) data.location.getTileEntity(worldObj); - if(tileEntity != null) - { - tileEntity.clientHasStructure = false; - } - } + if (tileEntity != null) { + tileEntity.clientHasStructure = false; + } + } - valveViewing.clear(); - } - } + valveViewing.clear(); + } + } - if(!worldObj.isRemote) - { - if(structure != null) - { - if(structure.waterStored != null && structure.waterStored.amount <= 0) - { - structure.waterStored = null; - markDirty(); - } - - if(structure.steamStored != null && structure.steamStored.amount <= 0) - { - structure.steamStored = null; - markDirty(); - } - - if(isRendering) - { - boolean needsValveUpdate = false; - - for(ValveData data : structure.valves) - { - if(data.activeTicks > 0) - { - data.activeTicks--; - } - - if(data.activeTicks > 0 != data.prevActive) - { - needsValveUpdate = true; - } - - data.prevActive = data.activeTicks > 0; - } - - boolean needsHotUpdate = false; - boolean newHot = structure.temperature >= SynchronizedBoilerData.BASE_BOIL_TEMP-0.01F; - - if(newHot != structure.clientHot) - { - needsHotUpdate = true; - structure.clientHot = newHot; - } - - double[] d = structure.simulateHeat(); - structure.applyTemperatureChange(); - structure.lastEnvironmentLoss = d[1]; - - if(structure.temperature >= SynchronizedBoilerData.BASE_BOIL_TEMP && structure.waterStored != null) - { - int steamAmount = structure.steamStored != null ? structure.steamStored.amount : 0; - double heatAvailable = structure.getHeatAvailable(); - - structure.lastMaxBoil = (int)Math.floor(heatAvailable / SynchronizedBoilerData.getHeatEnthalpy()); - - int amountToBoil = Math.min(structure.lastMaxBoil, structure.waterStored.amount); - amountToBoil = Math.min(amountToBoil, (structure.steamVolume*BoilerUpdateProtocol.STEAM_PER_TANK)-steamAmount); - structure.waterStored.amount -= amountToBoil; - - if(structure.steamStored == null) - { - structure.steamStored = new FluidStack(FluidRegistry.getFluid("steam"), amountToBoil); - } - else { - structure.steamStored.amount += amountToBoil; - } - - structure.temperature -= (amountToBoil*SynchronizedBoilerData.getHeatEnthalpy())/structure.locations.size(); - structure.lastBoilRate = amountToBoil; - } - else { - structure.lastBoilRate = 0; - structure.lastMaxBoil = 0; - } - - if(needsValveUpdate || structure.needsRenderUpdate() || needsHotUpdate) - { - sendPacketToRenderer(); - } - - structure.prevWater = structure.waterStored != null ? structure.waterStored.copy() : null; - structure.prevSteam = structure.steamStored != null ? structure.steamStored.copy() : null; - - MekanismUtils.saveChunk(this); - } - } - } - } - - @Override - public boolean onActivate(EntityPlayer player) - { - if(!player.isSneaking() && structure != null) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - player.openGui(Mekanism.instance, 54, worldObj, xCoord, yCoord, zCoord); - - return true; - } - - return false; - } + if (!worldObj.isRemote) { + if (structure != null) { + if (structure.waterStored != null && structure.waterStored.amount <= 0) { + structure.waterStored = null; + markDirty(); + } - @Override - protected SynchronizedBoilerData getNewStructure() - { - return new SynchronizedBoilerData(); - } - - @Override - public BoilerCache getNewCache() - { - return new BoilerCache(); - } + if (structure.steamStored != null && structure.steamStored.amount <= 0) { + structure.steamStored = null; + markDirty(); + } - @Override - protected BoilerUpdateProtocol getProtocol() - { - return new BoilerUpdateProtocol(this); - } + if (isRendering) { + boolean needsValveUpdate = false; - @Override - public MultiblockManager getManager() - { - return Mekanism.boilerManager; - } + for (ValveData data : structure.valves) { + if (data.activeTicks > 0) { + data.activeTicks--; + } - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); + if (data.activeTicks > 0 != data.prevActive) { + needsValveUpdate = true; + } - if(structure != null) - { - data.add(structure.waterVolume*BoilerUpdateProtocol.WATER_PER_TANK); - data.add(structure.steamVolume*BoilerUpdateProtocol.STEAM_PER_TANK); - data.add(structure.lastEnvironmentLoss); - data.add(structure.lastBoilRate); - data.add(structure.superheatingElements); - data.add(structure.temperature); - data.add(structure.lastMaxBoil); + data.prevActive = data.activeTicks > 0; + } - if(structure.waterStored != null) - { - data.add(1); - data.add(structure.waterStored.getFluidID()); - data.add(structure.waterStored.amount); - } - else { - data.add(0); - } + boolean needsHotUpdate = false; + boolean newHot = structure.temperature + >= SynchronizedBoilerData.BASE_BOIL_TEMP - 0.01F; - if(structure.steamStored != null) - { - data.add(1); - data.add(structure.steamStored.getFluidID()); - data.add(structure.steamStored.amount); - } - else { - data.add(0); - } + if (newHot != structure.clientHot) { + needsHotUpdate = true; + structure.clientHot = newHot; + } - structure.upperRenderLocation.write(data); - - if(isRendering) - { - data.add(structure.clientHot); - - Set toSend = new HashSet(); + double[] d = structure.simulateHeat(); + structure.applyTemperatureChange(); + structure.lastEnvironmentLoss = d[1]; - for(ValveData valveData : structure.valves) - { - if(valveData.activeTicks > 0) - { - toSend.add(valveData); - } - } - - data.add(toSend.size()); - - for(ValveData valveData : toSend) - { - valveData.location.write(data); - data.add(valveData.side.ordinal()); - } - } - } + if (structure.temperature >= SynchronizedBoilerData.BASE_BOIL_TEMP + && structure.waterStored != null) { + int steamAmount = structure.steamStored != null + ? structure.steamStored.amount + : 0; + double heatAvailable = structure.getHeatAvailable(); - return data; - } + structure.lastMaxBoil = (int) Math.floor( + heatAvailable / SynchronizedBoilerData.getHeatEnthalpy() + ); - @Override - public void handlePacketData(ByteBuf dataStream) - { - super.handlePacketData(dataStream); + int amountToBoil = Math.min( + structure.lastMaxBoil, structure.waterStored.amount + ); + amountToBoil = Math.min( + amountToBoil, + (structure.steamVolume * BoilerUpdateProtocol.STEAM_PER_TANK) + - steamAmount + ); + structure.waterStored.amount -= amountToBoil; - if(worldObj.isRemote) - { - if(clientHasStructure) - { - clientWaterCapacity = dataStream.readInt(); - clientSteamCapacity = dataStream.readInt(); - structure.lastEnvironmentLoss = dataStream.readDouble(); - structure.lastBoilRate = dataStream.readInt(); - structure.superheatingElements = dataStream.readInt(); - structure.temperature = dataStream.readDouble(); - structure.lastMaxBoil = dataStream.readInt(); - - if(dataStream.readInt() == 1) - { - structure.waterStored = new FluidStack(FluidRegistry.getFluid(dataStream.readInt()), dataStream.readInt()); - } - else { - structure.waterStored = null; - } - - if(dataStream.readInt() == 1) - { - structure.steamStored = new FluidStack(FluidRegistry.getFluid(dataStream.readInt()), dataStream.readInt()); - } - else { - structure.steamStored = null; - } - - structure.upperRenderLocation = Coord4D.read(dataStream); - - if(isRendering) - { - structure.clientHot = dataStream.readBoolean(); - SynchronizedBoilerData.clientHotMap.put(structure.inventoryID, structure.clientHot); - - int size = dataStream.readInt(); - - valveViewing.clear(); - - for(int i = 0; i < size; i++) - { - ValveData data = new ValveData(); - data.location = Coord4D.read(dataStream); - data.side = ForgeDirection.getOrientation(dataStream.readInt()); - - valveViewing.add(data); - - TileEntityBoilerCasing tileEntity = (TileEntityBoilerCasing)data.location.getTileEntity(worldObj); - - if(tileEntity != null) - { - tileEntity.clientHasStructure = true; - } - } - } - } - } - } + if (structure.steamStored == null) { + structure.steamStored = new FluidStack( + FluidRegistry.getFluid("steam"), amountToBoil + ); + } else { + structure.steamStored.amount += amountToBoil; + } - public int getScaledWaterLevel(int i) - { - if(clientWaterCapacity == 0 || structure.waterStored == null) - { - return 0; - } + structure.temperature + -= (amountToBoil * SynchronizedBoilerData.getHeatEnthalpy()) + / structure.locations.size(); + structure.lastBoilRate = amountToBoil; + } else { + structure.lastBoilRate = 0; + structure.lastMaxBoil = 0; + } - return structure.waterStored.amount*i / clientWaterCapacity; - } + if (needsValveUpdate || structure.needsRenderUpdate() + || needsHotUpdate) { + sendPacketToRenderer(); + } - public int getScaledSteamLevel(int i) - { - if(clientSteamCapacity == 0 || structure.steamStored == null) - { - return 0; - } + structure.prevWater = structure.waterStored != null + ? structure.waterStored.copy() + : null; + structure.prevSteam = structure.steamStored != null + ? structure.steamStored.copy() + : null; - return structure.steamStored.amount*i / clientSteamCapacity; - } + MekanismUtils.saveChunk(this); + } + } + } + } - @Override - public double getTemp() - { - return 0; - } + @Override + public boolean onActivate(EntityPlayer player) { + if (!player.isSneaking() && structure != null) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + player.openGui(Mekanism.instance, 54, worldObj, xCoord, yCoord, zCoord); - @Override - public double getInverseConductionCoefficient() - { - return SynchronizedBoilerData.CASING_INVERSE_CONDUCTION_COEFFICIENT; - } + return true; + } - @Override - public double getInsulationCoefficient(ForgeDirection side) - { - return SynchronizedBoilerData.CASING_INSULATION_COEFFICIENT; - } + return false; + } - @Override - public void transferHeatTo(double heat) - { - if(structure != null) - { - structure.heatToAbsorb += heat; - } - } + @Override + protected SynchronizedBoilerData getNewStructure() { + return new SynchronizedBoilerData(); + } - @Override - public double[] simulateHeat() - { - return new double[] {0, 0}; - } + @Override + public BoilerCache getNewCache() { + return new BoilerCache(); + } - @Override - public double applyTemperatureChange() - { - return 0; - } + @Override + protected BoilerUpdateProtocol getProtocol() { + return new BoilerUpdateProtocol(this); + } - @Override - public boolean canConnectHeat(ForgeDirection side) - { - return structure != null; - } + @Override + public MultiblockManager getManager() { + return Mekanism.boilerManager; + } - @Override - public IHeatTransfer getAdjacent(ForgeDirection side) - { - return null; - } - - @Override - public String getInventoryName() - { - return LangUtils.localize("gui.thermoelectricBoiler"); - } + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); + + if (structure != null) { + data.add(structure.waterVolume * BoilerUpdateProtocol.WATER_PER_TANK); + data.add(structure.steamVolume * BoilerUpdateProtocol.STEAM_PER_TANK); + data.add(structure.lastEnvironmentLoss); + data.add(structure.lastBoilRate); + data.add(structure.superheatingElements); + data.add(structure.temperature); + data.add(structure.lastMaxBoil); + + if (structure.waterStored != null) { + data.add(1); + data.add(structure.waterStored.getFluidID()); + data.add(structure.waterStored.amount); + } else { + data.add(0); + } + + if (structure.steamStored != null) { + data.add(1); + data.add(structure.steamStored.getFluidID()); + data.add(structure.steamStored.amount); + } else { + data.add(0); + } + + structure.upperRenderLocation.write(data); + + if (isRendering) { + data.add(structure.clientHot); + + Set toSend = new HashSet(); + + for (ValveData valveData : structure.valves) { + if (valveData.activeTicks > 0) { + toSend.add(valveData); + } + } + + data.add(toSend.size()); + + for (ValveData valveData : toSend) { + valveData.location.write(data); + data.add(valveData.side.ordinal()); + } + } + } + + return data; + } + + @Override + public void handlePacketData(ByteBuf dataStream) { + super.handlePacketData(dataStream); + + if (worldObj.isRemote) { + if (clientHasStructure) { + clientWaterCapacity = dataStream.readInt(); + clientSteamCapacity = dataStream.readInt(); + structure.lastEnvironmentLoss = dataStream.readDouble(); + structure.lastBoilRate = dataStream.readInt(); + structure.superheatingElements = dataStream.readInt(); + structure.temperature = dataStream.readDouble(); + structure.lastMaxBoil = dataStream.readInt(); + + if (dataStream.readInt() == 1) { + structure.waterStored = new FluidStack( + FluidRegistry.getFluid(dataStream.readInt()), dataStream.readInt() + ); + } else { + structure.waterStored = null; + } + + if (dataStream.readInt() == 1) { + structure.steamStored = new FluidStack( + FluidRegistry.getFluid(dataStream.readInt()), dataStream.readInt() + ); + } else { + structure.steamStored = null; + } + + structure.upperRenderLocation = Coord4D.read(dataStream); + + if (isRendering) { + structure.clientHot = dataStream.readBoolean(); + SynchronizedBoilerData.clientHotMap.put( + structure.inventoryID, structure.clientHot + ); + + int size = dataStream.readInt(); + + valveViewing.clear(); + + for (int i = 0; i < size; i++) { + ValveData data = new ValveData(); + data.location = Coord4D.read(dataStream); + data.side = ForgeDirection.getOrientation(dataStream.readInt()); + + valveViewing.add(data); + + TileEntityBoilerCasing tileEntity = (TileEntityBoilerCasing + ) data.location.getTileEntity(worldObj); + + if (tileEntity != null) { + tileEntity.clientHasStructure = true; + } + } + } + } + } + } + + public int getScaledWaterLevel(int i) { + if (clientWaterCapacity == 0 || structure.waterStored == null) { + return 0; + } + + return structure.waterStored.amount * i / clientWaterCapacity; + } + + public int getScaledSteamLevel(int i) { + if (clientSteamCapacity == 0 || structure.steamStored == null) { + return 0; + } + + return structure.steamStored.amount * i / clientSteamCapacity; + } + + @Override + public double getTemp() { + return 0; + } + + @Override + public double getInverseConductionCoefficient() { + return SynchronizedBoilerData.CASING_INVERSE_CONDUCTION_COEFFICIENT; + } + + @Override + public double getInsulationCoefficient(ForgeDirection side) { + return SynchronizedBoilerData.CASING_INSULATION_COEFFICIENT; + } + + @Override + public void transferHeatTo(double heat) { + if (structure != null) { + structure.heatToAbsorb += heat; + } + } + + @Override + public double[] simulateHeat() { + return new double[] { 0, 0 }; + } + + @Override + public double applyTemperatureChange() { + return 0; + } + + @Override + public boolean canConnectHeat(ForgeDirection side) { + return structure != null; + } + + @Override + public IHeatTransfer getAdjacent(ForgeDirection side) { + return null; + } + + @Override + public String getInventoryName() { + return LangUtils.localize("gui.thermoelectricBoiler"); + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityBoilerValve.java b/src/main/java/mekanism/common/tile/TileEntityBoilerValve.java index 0ab2b12b0..eee183179 100644 --- a/src/main/java/mekanism/common/tile/TileEntityBoilerValve.java +++ b/src/main/java/mekanism/common/tile/TileEntityBoilerValve.java @@ -12,127 +12,124 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; -public class TileEntityBoilerValve extends TileEntityBoilerCasing implements IFluidHandler -{ - public BoilerTank waterTank; - public BoilerTank steamTank; +public class TileEntityBoilerValve + extends TileEntityBoilerCasing implements IFluidHandler { + public BoilerTank waterTank; + public BoilerTank steamTank; - public TileEntityBoilerValve() - { - super("BoilerValve"); - - waterTank = new BoilerWaterTank(this); - steamTank = new BoilerSteamTank(this); - } - - @Override - public void onUpdate() - { - super.onUpdate(); - - if(!worldObj.isRemote) - { - if(structure != null && structure.upperRenderLocation != null && yCoord >= structure.upperRenderLocation.yCoord-1) - { - if(structure.steamStored != null && structure.steamStored.amount > 0) - { - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - TileEntity tile = Coord4D.get(this).getFromSide(side).getTileEntity(worldObj); - - if(tile instanceof IFluidHandler && !(tile instanceof TileEntityBoilerValve)) - { - if(((IFluidHandler)tile).canFill(side.getOpposite(), structure.steamStored.getFluid())) - { - structure.steamStored.amount -= ((IFluidHandler)tile).fill(side.getOpposite(), structure.steamStored, true); - - if(structure.steamStored.amount <= 0) - { - structure.steamStored = null; - } - } - } - } - } - } - } - } + public TileEntityBoilerValve() { + super("BoilerValve"); - @Override - public FluidTankInfo[] getTankInfo(ForgeDirection from) - { - if((!worldObj.isRemote && structure != null) || (worldObj.isRemote && clientHasStructure)) - { - if(structure.upperRenderLocation != null && yCoord >= structure.upperRenderLocation.yCoord-1) - { - return new FluidTankInfo[] {steamTank.getInfo()}; - } - else { - return new FluidTankInfo[] {waterTank.getInfo()}; - } - } - - return PipeUtils.EMPTY; - } + waterTank = new BoilerWaterTank(this); + steamTank = new BoilerSteamTank(this); + } - @Override - public int fill(ForgeDirection from, FluidStack resource, boolean doFill) - { - if(structure != null && structure.upperRenderLocation != null && yCoord < structure.upperRenderLocation.yCoord-1) - { - return waterTank.fill(resource, doFill); - } - - return 0; - } + @Override + public void onUpdate() { + super.onUpdate(); - @Override - public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) - { - if(structure != null && structure.upperRenderLocation != null && yCoord >= structure.upperRenderLocation.yCoord-1) - { - if(structure.steamStored != null) - { - if(resource.getFluid() == structure.steamStored.getFluid()) - { - return steamTank.drain(resource.amount, doDrain); - } - } - } + if (!worldObj.isRemote) { + if (structure != null && structure.upperRenderLocation != null + && yCoord >= structure.upperRenderLocation.yCoord - 1) { + if (structure.steamStored != null && structure.steamStored.amount > 0) { + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + TileEntity tile + = Coord4D.get(this).getFromSide(side).getTileEntity(worldObj); - return null; - } + if (tile instanceof IFluidHandler + && !(tile instanceof TileEntityBoilerValve)) { + if (((IFluidHandler) tile) + .canFill( + side.getOpposite(), + structure.steamStored.getFluid() + )) { + structure.steamStored.amount + -= ((IFluidHandler) tile) + .fill( + side.getOpposite(), + structure.steamStored, + true + ); - @Override - public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) - { - if(structure != null && structure.upperRenderLocation != null && yCoord >= structure.upperRenderLocation.yCoord-1) - { - return steamTank.drain(maxDrain, doDrain); - } + if (structure.steamStored.amount <= 0) { + structure.steamStored = null; + } + } + } + } + } + } + } + } - return null; - } + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection from) { + if ((!worldObj.isRemote && structure != null) + || (worldObj.isRemote && clientHasStructure)) { + if (structure.upperRenderLocation != null + && yCoord >= structure.upperRenderLocation.yCoord - 1) { + return new FluidTankInfo[] { steamTank.getInfo() }; + } else { + return new FluidTankInfo[] { waterTank.getInfo() }; + } + } - @Override - public boolean canFill(ForgeDirection from, Fluid fluid) - { - if((!worldObj.isRemote && structure != null) || (worldObj.isRemote && clientHasStructure)) - { - return structure.upperRenderLocation != null && yCoord < structure.upperRenderLocation.yCoord-1; - } - - return false; - } + return PipeUtils.EMPTY; + } - @Override - public boolean canDrain(ForgeDirection from, Fluid fluid) - { - if((!worldObj.isRemote && structure != null) || (worldObj.isRemote && clientHasStructure)) - { - return structure.upperRenderLocation != null && yCoord >= structure.upperRenderLocation.yCoord-1; - } - - return false; - } + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { + if (structure != null && structure.upperRenderLocation != null + && yCoord < structure.upperRenderLocation.yCoord - 1) { + return waterTank.fill(resource, doFill); + } + + return 0; + } + + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + if (structure != null && structure.upperRenderLocation != null + && yCoord >= structure.upperRenderLocation.yCoord - 1) { + if (structure.steamStored != null) { + if (resource.getFluid() == structure.steamStored.getFluid()) { + return steamTank.drain(resource.amount, doDrain); + } + } + } + + return null; + } + + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { + if (structure != null && structure.upperRenderLocation != null + && yCoord >= structure.upperRenderLocation.yCoord - 1) { + return steamTank.drain(maxDrain, doDrain); + } + + return null; + } + + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + if ((!worldObj.isRemote && structure != null) + || (worldObj.isRemote && clientHasStructure)) { + return structure.upperRenderLocation != null + && yCoord < structure.upperRenderLocation.yCoord - 1; + } + + return false; + } + + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + if ((!worldObj.isRemote && structure != null) + || (worldObj.isRemote && clientHasStructure)) { + return structure.upperRenderLocation != null + && yCoord >= structure.upperRenderLocation.yCoord - 1; + } + + return false; + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityBoundingBlock.java b/src/main/java/mekanism/common/tile/TileEntityBoundingBlock.java index 7a7185a7e..6e44244e5 100644 --- a/src/main/java/mekanism/common/tile/TileEntityBoundingBlock.java +++ b/src/main/java/mekanism/common/tile/TileEntityBoundingBlock.java @@ -1,9 +1,8 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.Range4D; import mekanism.common.Mekanism; @@ -14,121 +13,118 @@ import net.minecraft.block.Block; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -public class TileEntityBoundingBlock extends TileEntity implements ITileNetwork -{ - public int mainX; - public int mainY; - public int mainZ; - - public boolean receivedCoords; +public class TileEntityBoundingBlock extends TileEntity implements ITileNetwork { + public int mainX; + public int mainY; + public int mainZ; - public boolean prevPower; + public boolean receivedCoords; - public void setMainLocation(int x, int y, int z) - { - receivedCoords = true; - - if(!worldObj.isRemote) - { - mainX = x; - mainY = y; - mainZ = z; + public boolean prevPower; - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - } - } + public void setMainLocation(int x, int y, int z) { + receivedCoords = true; - @Override - public void validate() - { - super.validate(); + if (!worldObj.isRemote) { + mainX = x; + mainY = y; + mainZ = z; - if(worldObj.isRemote) - { - Mekanism.packetHandler.sendToServer(new DataRequestMessage(Coord4D.get(this))); - } - } + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + } + } - @Override - public boolean canUpdate() - { - return false; - } + @Override + public void validate() { + super.validate(); - public void onNeighborChange(Block block) - { - TileEntity tile = worldObj.getTileEntity(mainX, mainY, mainZ); + if (worldObj.isRemote) { + Mekanism.packetHandler.sendToServer(new DataRequestMessage(Coord4D.get(this)) + ); + } + } - if(tile instanceof TileEntityBasicBlock) - { - TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)tile; + @Override + public boolean canUpdate() { + return false; + } - boolean power = worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord); + public void onNeighborChange(Block block) { + TileEntity tile = worldObj.getTileEntity(mainX, mainY, mainZ); - if(prevPower != power) - { - if(power) - { - onPower(); - } - else { - onNoPower(); - } + if (tile instanceof TileEntityBasicBlock) { + TileEntityBasicBlock tileEntity = (TileEntityBasicBlock) tile; - prevPower = power; - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tileEntity), tileEntity.getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - } - } - } + boolean power + = worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord); - public void onPower() {} + if (prevPower != power) { + if (power) { + onPower(); + } else { + onNoPower(); + } - public void onNoPower() {} + prevPower = power; + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(tileEntity), + tileEntity.getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + } + } + } - @Override - public void handlePacketData(ByteBuf dataStream) - { - if(worldObj.isRemote) - { - mainX = dataStream.readInt(); - mainY = dataStream.readInt(); - mainZ = dataStream.readInt(); - prevPower = dataStream.readBoolean(); - } - } + public void onPower() {} - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); + public void onNoPower() {} - mainX = nbtTags.getInteger("mainX"); - mainY = nbtTags.getInteger("mainY"); - mainZ = nbtTags.getInteger("mainZ"); - prevPower = nbtTags.getBoolean("prevPower"); - receivedCoords = nbtTags.getBoolean("receivedCoords"); - } + @Override + public void handlePacketData(ByteBuf dataStream) { + if (worldObj.isRemote) { + mainX = dataStream.readInt(); + mainY = dataStream.readInt(); + mainZ = dataStream.readInt(); + prevPower = dataStream.readBoolean(); + } + } - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); - nbtTags.setInteger("mainX", mainX); - nbtTags.setInteger("mainY", mainY); - nbtTags.setInteger("mainZ", mainZ); - nbtTags.setBoolean("prevPower", prevPower); - nbtTags.setBoolean("receivedCoords", receivedCoords); - } + mainX = nbtTags.getInteger("mainX"); + mainY = nbtTags.getInteger("mainY"); + mainZ = nbtTags.getInteger("mainZ"); + prevPower = nbtTags.getBoolean("prevPower"); + receivedCoords = nbtTags.getBoolean("receivedCoords"); + } - @Override - public ArrayList getNetworkedData(ArrayList data) - { - data.add(mainX); - data.add(mainY); - data.add(mainZ); - data.add(prevPower); + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); - return data; - } + nbtTags.setInteger("mainX", mainX); + nbtTags.setInteger("mainY", mainY); + nbtTags.setInteger("mainZ", mainZ); + nbtTags.setBoolean("prevPower", prevPower); + nbtTags.setBoolean("receivedCoords", receivedCoords); + } + + @Override + public ArrayList getNetworkedData(ArrayList data) { + data.add(mainX); + data.add(mainY); + data.add(mainZ); + data.add(prevPower); + + return data; + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityCardboardBox.java b/src/main/java/mekanism/common/tile/TileEntityCardboardBox.java index 768da48de..7e1a6a843 100644 --- a/src/main/java/mekanism/common/tile/TileEntityCardboardBox.java +++ b/src/main/java/mekanism/common/tile/TileEntityCardboardBox.java @@ -4,35 +4,29 @@ import mekanism.common.block.BlockCardboardBox.BlockData; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; -public class TileEntityCardboardBox extends TileEntity -{ - public BlockData storedData; +public class TileEntityCardboardBox extends TileEntity { + public BlockData storedData; - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); - if(nbtTags.hasKey("storedData")) - { - storedData = BlockData.read(nbtTags.getCompoundTag("storedData")); - } - } + if (nbtTags.hasKey("storedData")) { + storedData = BlockData.read(nbtTags.getCompoundTag("storedData")); + } + } - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); - if(storedData != null) - { - nbtTags.setTag("storedData", storedData.write(new NBTTagCompound())); - } - } + if (storedData != null) { + nbtTags.setTag("storedData", storedData.write(new NBTTagCompound())); + } + } - @Override - public boolean canUpdate() - { - return false; - } + @Override + public boolean canUpdate() { + return false; + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityChanceMachine.java b/src/main/java/mekanism/common/tile/TileEntityChanceMachine.java index 11b4b87ef..c3c233ef4 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChanceMachine.java +++ b/src/main/java/mekanism/common/tile/TileEntityChanceMachine.java @@ -20,177 +20,177 @@ import mekanism.common.util.MekanismUtils; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; -public abstract class TileEntityChanceMachine> extends TileEntityBasicMachine -{ - public TileEntityChanceMachine(String soundPath, String name, ResourceLocation location, double perTick, int ticksRequired, double maxEnergy) - { - super(soundPath, name, location, perTick, ticksRequired, maxEnergy); +public abstract class TileEntityChanceMachine> + extends TileEntityBasicMachine { + public TileEntityChanceMachine( + String soundPath, + String name, + ResourceLocation location, + double perTick, + int ticksRequired, + double maxEnergy + ) { + super(soundPath, name, location, perTick, ticksRequired, maxEnergy); - configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY); - - configComponent.addOutput(TransmissionType.ITEM, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY)); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Input", EnumColor.DARK_RED, new int[] {0})); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Energy", EnumColor.DARK_GREEN, new int[] {1})); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Output", EnumColor.DARK_BLUE, new int[] {2, 4})); + configComponent = new TileComponentConfig( + this, TransmissionType.ITEM, TransmissionType.ENERGY + ); - configComponent.setConfig(TransmissionType.ITEM, new byte[] {2, 1, 0, 0, 0, 3}); - configComponent.setInputConfig(TransmissionType.ENERGY); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY) + ); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("Input", EnumColor.DARK_RED, new int[] { 0 }) + ); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("Energy", EnumColor.DARK_GREEN, new int[] { 1 }) + ); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("Output", EnumColor.DARK_BLUE, new int[] { 2, 4 }) + ); - inventory = new ItemStack[5]; + configComponent.setConfig(TransmissionType.ITEM, new byte[] { 2, 1, 0, 0, 0, 3 }); + configComponent.setInputConfig(TransmissionType.ENERGY); - upgradeComponent = new TileComponentUpgrade(this, 3); - upgradeComponent.setSupported(Upgrade.MUFFLING); - - ejectorComponent = new TileComponentEjector(this); - ejectorComponent.setOutputData(TransmissionType.ITEM, configComponent.getOutputs(TransmissionType.ITEM).get(3)); - } + inventory = new ItemStack[5]; - @Override - public void onUpdate() - { - super.onUpdate(); + upgradeComponent = new TileComponentUpgrade(this, 3); + upgradeComponent.setSupported(Upgrade.MUFFLING); - if(!worldObj.isRemote) - { - ChargeUtils.discharge(1, this); + ejectorComponent = new TileComponentEjector(this); + ejectorComponent.setOutputData( + TransmissionType.ITEM, + configComponent.getOutputs(TransmissionType.ITEM).get(3) + ); + } - RECIPE recipe = getRecipe(); + @Override + public void onUpdate() { + super.onUpdate(); - if(canOperate(recipe) && MekanismUtils.canFunction(this) && getEnergy() >= energyPerTick) - { - setActive(true); + if (!worldObj.isRemote) { + ChargeUtils.discharge(1, this); - electricityStored -= energyPerTick; + RECIPE recipe = getRecipe(); - if((operatingTicks+1) < ticksRequired) - { - operatingTicks++; - } - else { - operate(recipe); + if (canOperate(recipe) && MekanismUtils.canFunction(this) + && getEnergy() >= energyPerTick) { + setActive(true); - operatingTicks = 0; - } - } - else { - if(prevEnergy >= getEnergy()) - { - setActive(false); - } - } + electricityStored -= energyPerTick; - if(!canOperate(recipe)) - { - operatingTicks = 0; - } + if ((operatingTicks + 1) < ticksRequired) { + operatingTicks++; + } else { + operate(recipe); - prevEnergy = getEnergy(); - } - } + operatingTicks = 0; + } + } else { + if (prevEnergy >= getEnergy()) { + setActive(false); + } + } - @Override - public boolean isItemValidForSlot(int slotID, ItemStack itemstack) - { - if(slotID == 3) - { - return itemstack.getItem() == MekanismItems.SpeedUpgrade || itemstack.getItem() == MekanismItems.EnergyUpgrade; - } - else if(slotID == 0) - { - return RecipeHandler.isInRecipe(itemstack, getRecipes()); - } - else if(slotID == 1) - { - return ChargeUtils.canBeDischarged(itemstack); - } + if (!canOperate(recipe)) { + operatingTicks = 0; + } - return false; - } + prevEnergy = getEnergy(); + } + } - @Override - public ItemStackInput getInput() - { - return new ItemStackInput(inventory[0]); - } + @Override + public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { + if (slotID == 3) { + return itemstack.getItem() == MekanismItems.SpeedUpgrade + || itemstack.getItem() == MekanismItems.EnergyUpgrade; + } else if (slotID == 0) { + return RecipeHandler.isInRecipe(itemstack, getRecipes()); + } else if (slotID == 1) { + return ChargeUtils.canBeDischarged(itemstack); + } - @Override - public void operate(RECIPE recipe) - { - recipe.operate(inventory); + return false; + } - markDirty(); - ejectorComponent.outputItems(); - } + @Override + public ItemStackInput getInput() { + return new ItemStackInput(inventory[0]); + } - @Override - public boolean canOperate(RECIPE recipe) - { - return recipe != null && recipe.canOperate(inventory, 0, 2, 4); - } + @Override + public void operate(RECIPE recipe) { + recipe.operate(inventory); - @Override - public boolean canExtractItem(int slotID, ItemStack itemstack, int side) - { - if(slotID == 1) - { - return ChargeUtils.canBeOutputted(itemstack, false); - } - else if(slotID == 2 || slotID == 4) - { - return true; - } + markDirty(); + ejectorComponent.outputItems(); + } - return false; - } + @Override + public boolean canOperate(RECIPE recipe) { + return recipe != null && recipe.canOperate(inventory, 0, 2, 4); + } - @Override - public RECIPE getRecipe() - { - ItemStackInput input = getInput(); - - if(cachedRecipe == null || !input.testEquality(cachedRecipe.getInput())) - { - cachedRecipe = RecipeHandler.getChanceRecipe(input, getRecipes()); - } - - return cachedRecipe; - } + @Override + public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { + if (slotID == 1) { + return ChargeUtils.canBeOutputted(itemstack, false); + } else if (slotID == 2 || slotID == 4) { + return true; + } - @Override - public Map getRecipes() - { - return null; - } + return false; + } - private static final String[] methods = new String[] {"getEnergy", "getProgress", "isActive", "facing", "canOperate", "getMaxEnergy", "getEnergyNeeded"}; + @Override + public RECIPE getRecipe() { + ItemStackInput input = getInput(); - @Override - public String[] getMethods() - { - return methods; - } + if (cachedRecipe == null || !input.testEquality(cachedRecipe.getInput())) { + cachedRecipe = RecipeHandler.getChanceRecipe(input, getRecipes()); + } - @Override - public Object[] invoke(int method, Object[] arguments) throws Exception - { - switch(method) - { - case 0: - return new Object[] {getEnergy()}; - case 1: - return new Object[] {operatingTicks}; - case 2: - return new Object[] {isActive}; - case 3: - return new Object[] {facing}; - case 4: - return new Object[] {canOperate(getRecipe())}; - case 5: - return new Object[] {getMaxEnergy()}; - case 6: - return new Object[] {getMaxEnergy()-getEnergy()}; - default: - throw new NoSuchMethodException(); - } - } + return cachedRecipe; + } + + @Override + public Map getRecipes() { + return null; + } + + private static final String[] methods + = new String[] { "getEnergy", "getProgress", "isActive", "facing", + "canOperate", "getMaxEnergy", "getEnergyNeeded" }; + + @Override + public String[] getMethods() { + return methods; + } + + @Override + public Object[] invoke(int method, Object[] arguments) throws Exception { + switch (method) { + case 0: + return new Object[] { getEnergy() }; + case 1: + return new Object[] { operatingTicks }; + case 2: + return new Object[] { isActive }; + case 3: + return new Object[] { facing }; + case 4: + return new Object[] { canOperate(getRecipe()) }; + case 5: + return new Object[] { getMaxEnergy() }; + case 6: + return new Object[] { getMaxEnergy() - getEnergy() }; + default: + throw new NoSuchMethodException(); + } + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityChargepad.java b/src/main/java/mekanism/common/tile/TileEntityChargepad.java index 6decdfb25..fa9d8dc8d 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChargepad.java +++ b/src/main/java/mekanism/common/tile/TileEntityChargepad.java @@ -1,14 +1,16 @@ package mekanism.common.tile; -import ic2.api.item.ElectricItem; -import ic2.api.item.IElectricItem; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.EnumSet; import java.util.List; import java.util.Random; +import cofh.api.energy.IEnergyContainerItem; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ic2.api.item.ElectricItem; +import ic2.api.item.IElectricItem; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.MekanismConfig.general; import mekanism.api.Range4D; @@ -25,202 +27,204 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; import net.minecraftforge.common.util.ForgeDirection; -import cofh.api.energy.IEnergyContainerItem; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class TileEntityChargepad extends TileEntityNoisyElectricBlock -{ - public boolean isActive; +public class TileEntityChargepad extends TileEntityNoisyElectricBlock { + public boolean isActive; - public boolean prevActive; + public boolean prevActive; - public Random random = new Random(); + public Random random = new Random(); - public TileEntityChargepad() - { - super("machine.chargepad", "Chargepad", MachineType.CHARGEPAD.baseEnergy); - inventory = new ItemStack[0]; - } + public TileEntityChargepad() { + super("machine.chargepad", "Chargepad", MachineType.CHARGEPAD.baseEnergy); + inventory = new ItemStack[0]; + } - @Override - public void onUpdate() - { - super.onUpdate(); + @Override + public void onUpdate() { + super.onUpdate(); - if(!worldObj.isRemote) - { - isActive = false; - List entities = worldObj.getEntitiesWithinAABB(EntityLivingBase.class, AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 0.2, zCoord + 1)); + if (!worldObj.isRemote) { + isActive = false; + List entities = worldObj.getEntitiesWithinAABB( + EntityLivingBase.class, + AxisAlignedBB.getBoundingBox( + xCoord, yCoord, zCoord, xCoord + 1, yCoord + 0.2, zCoord + 1 + ) + ); - for(EntityLivingBase entity : entities) - { - if(entity instanceof EntityPlayer || entity instanceof EntityRobit) - { - isActive = true; - } + for (EntityLivingBase entity : entities) { + if (entity instanceof EntityPlayer || entity instanceof EntityRobit) { + isActive = true; + } - if(getEnergy() > 0) - { - if(entity instanceof EntityRobit) - { - EntityRobit robit = (EntityRobit) entity; + if (getEnergy() > 0) { + if (entity instanceof EntityRobit) { + EntityRobit robit = (EntityRobit) entity; - double canGive = Math.min(getEnergy(), 1000); - double toGive = Math.min(robit.MAX_ELECTRICITY - robit.getEnergy(), canGive); + double canGive = Math.min(getEnergy(), 1000); + double toGive = Math.min( + robit.MAX_ELECTRICITY - robit.getEnergy(), canGive + ); - robit.setEnergy(robit.getEnergy() + toGive); - setEnergy(getEnergy() - toGive); - } - else if(entity instanceof EntityPlayer) - { - EntityPlayer player = (EntityPlayer) entity; + robit.setEnergy(robit.getEnergy() + toGive); + setEnergy(getEnergy() - toGive); + } else if (entity instanceof EntityPlayer) { + EntityPlayer player = (EntityPlayer) entity; - double prevEnergy = getEnergy(); + double prevEnergy = getEnergy(); - for(ItemStack itemstack : player.inventory.armorInventory) - { - chargeItemStack(itemstack); + for (ItemStack itemstack : player.inventory.armorInventory) { + chargeItemStack(itemstack); - if(prevEnergy != getEnergy()) - { - break; - } - } + if (prevEnergy != getEnergy()) { + break; + } + } - for(ItemStack itemstack : player.inventory.mainInventory) - { - chargeItemStack(itemstack); + for (ItemStack itemstack : player.inventory.mainInventory) { + chargeItemStack(itemstack); - if(prevEnergy != getEnergy()) - { - break; - } - } - } - } - } + if (prevEnergy != getEnergy()) { + break; + } + } + } + } + } - if(prevActive != isActive) - { - worldObj.playSoundEffect(xCoord + 0.5, yCoord + 0.1, zCoord + 0.5, "random.click", 0.3F, isActive ? 0.6F : 0.5F); - setActive(isActive); - } - } - else if(isActive) - { - worldObj.spawnParticle("reddust", xCoord+random.nextDouble(), yCoord+0.15, zCoord+random.nextDouble(), 0, 0, 0); - } - } + if (prevActive != isActive) { + worldObj.playSoundEffect( + xCoord + 0.5, + yCoord + 0.1, + zCoord + 0.5, + "random.click", + 0.3F, + isActive ? 0.6F : 0.5F + ); + setActive(isActive); + } + } else if (isActive) { + worldObj.spawnParticle( + "reddust", + xCoord + random.nextDouble(), + yCoord + 0.15, + zCoord + random.nextDouble(), + 0, + 0, + 0 + ); + } + } - public void chargeItemStack(ItemStack itemstack) - { - if(itemstack != null) - { - if(itemstack.getItem() instanceof IEnergizedItem) - { - setEnergy(getEnergy() - EnergizedItemManager.charge(itemstack, getEnergy())); - } - else if(MekanismUtils.useIC2() && itemstack.getItem() instanceof IElectricItem) - { - double sent = ElectricItem.manager.charge(itemstack, (int)(getEnergy()*general.TO_IC2), 4, true, false)*general.FROM_IC2; - setEnergy(getEnergy() - sent); - } - else if(MekanismUtils.useRF() && itemstack.getItem() instanceof IEnergyContainerItem) - { - IEnergyContainerItem item = (IEnergyContainerItem)itemstack.getItem(); + public void chargeItemStack(ItemStack itemstack) { + if (itemstack != null) { + if (itemstack.getItem() instanceof IEnergizedItem) { + setEnergy( + getEnergy() - EnergizedItemManager.charge(itemstack, getEnergy()) + ); + } else if (MekanismUtils.useIC2() && itemstack.getItem() instanceof IElectricItem) { + double sent + = ElectricItem.manager.charge( + itemstack, (int) (getEnergy() * general.TO_IC2), 4, true, false + ) + * general.FROM_IC2; + setEnergy(getEnergy() - sent); + } else if (MekanismUtils.useRF() && itemstack.getItem() instanceof IEnergyContainerItem) { + IEnergyContainerItem item = (IEnergyContainerItem) itemstack.getItem(); - int itemEnergy = (int)Math.round(Math.min(Math.sqrt(item.getMaxEnergyStored(itemstack)), item.getMaxEnergyStored(itemstack) - item.getEnergyStored(itemstack))); - int toTransfer = (int)Math.round(Math.min(itemEnergy, (getEnergy()*general.TO_TE))); + int itemEnergy = (int) Math.round(Math.min( + Math.sqrt(item.getMaxEnergyStored(itemstack)), + item.getMaxEnergyStored(itemstack) - item.getEnergyStored(itemstack) + )); + int toTransfer = (int + ) Math.round(Math.min(itemEnergy, (getEnergy() * general.TO_TE))); - setEnergy(getEnergy() - (item.receiveEnergy(itemstack, toTransfer, false)*general.FROM_TE)); - } - } - } + setEnergy( + getEnergy() + - (item.receiveEnergy(itemstack, toTransfer, false) * general.FROM_TE) + ); + } + } + } - @Override - public EnumSet getConsumingSides() - { - return EnumSet.of(ForgeDirection.DOWN, ForgeDirection.getOrientation(facing).getOpposite()); - } + @Override + public EnumSet getConsumingSides() { + return EnumSet.of( + ForgeDirection.DOWN, ForgeDirection.getOrientation(facing).getOpposite() + ); + } - @Override - public boolean getActive() - { - return isActive; - } + @Override + public boolean getActive() { + return isActive; + } - @Override - public void setActive(boolean active) - { - isActive = active; + @Override + public void setActive(boolean active) { + isActive = active; - if(prevActive != active) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - } + if (prevActive != active) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + } - prevActive = active; - } + prevActive = active; + } - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); - isActive = nbtTags.getBoolean("isActive"); - } + isActive = nbtTags.getBoolean("isActive"); + } - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); - nbtTags.setBoolean("isActive", isActive); - } + nbtTags.setBoolean("isActive", isActive); + } - @Override - public void handlePacketData(ByteBuf dataStream) - { - super.handlePacketData(dataStream); - - if(worldObj.isRemote) - { - isActive = dataStream.readBoolean(); - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } + @Override + public void handlePacketData(ByteBuf dataStream) { + super.handlePacketData(dataStream); - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); - data.add(isActive); - return data; - } + if (worldObj.isRemote) { + isActive = dataStream.readBoolean(); + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } - @Override - public boolean canSetFacing(int side) - { - return side != 0 && side != 1; - } + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); + data.add(isActive); + return data; + } - @Override - @SideOnly(Side.CLIENT) - public float getVolume() - { - return 0.4F*super.getVolume(); - } + @Override + public boolean canSetFacing(int side) { + return side != 0 && side != 1; + } - @Override - public boolean renderUpdate() - { - return false; - } + @Override + @SideOnly(Side.CLIENT) + public float getVolume() { + return 0.4F * super.getVolume(); + } - @Override - public boolean lightUpdate() - { - return true; - } + @Override + public boolean renderUpdate() { + return false; + } + + @Override + public boolean lightUpdate() { + return true; + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalCrystallizer.java b/src/main/java/mekanism/common/tile/TileEntityChemicalCrystallizer.java index f9461f754..8d8ba6d08 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalCrystallizer.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalCrystallizer.java @@ -1,9 +1,8 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.IConfigCardAccess; @@ -43,462 +42,455 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock implements IGasHandler, ITubeConnection, IRedstoneControl, ISideConfiguration, IUpgradeTile, ISustainedData, ITankManager, IConfigCardAccess, ISecurityTile -{ - public static final int MAX_GAS = 10000; - - public GasTank inputTank = new GasTank(MAX_GAS); - - public int updateDelay; - - public int operatingTicks; - - public int BASE_TICKS_REQUIRED = 200; - - public int ticksRequired = 200; - - public boolean isActive; - - public boolean clientActive; - - public double prevEnergy; - - public float spinSpeed; - - public float spin; - - public final double BASE_ENERGY_USAGE = usage.chemicalCrystallizerUsage; - - public double energyUsage = usage.chemicalCrystallizerUsage; - - public CrystallizerRecipe cachedRecipe; - - /** This machine's current RedstoneControl type. */ - public RedstoneControl controlType = RedstoneControl.DISABLED; - - public TileComponentUpgrade upgradeComponent; - public TileComponentEjector ejectorComponent; - public TileComponentConfig configComponent; - public TileComponentSecurity securityComponent; - - public TileEntityChemicalCrystallizer() - { - super("machine.crystallizer", "ChemicalCrystallizer", MachineType.CHEMICAL_CRYSTALLIZER.baseEnergy); - - configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY, TransmissionType.GAS); - - configComponent.addOutput(TransmissionType.ITEM, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY)); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Gas", EnumColor.PURPLE, new int[] {0})); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Output", EnumColor.DARK_BLUE, new int[] {1})); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Energy", EnumColor.DARK_GREEN, new int[] {2})); - configComponent.setConfig(TransmissionType.ITEM, new byte[] {0, 3, 0, 0, 1, 2}); - - configComponent.addOutput(TransmissionType.GAS, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY)); - configComponent.addOutput(TransmissionType.GAS, new SideData("Gas", EnumColor.YELLOW, new int[] {0})); - configComponent.setConfig(TransmissionType.GAS, new byte[] {-1, -1, -1, -1, 1, -1}); - configComponent.setCanEject(TransmissionType.GAS, false); - - configComponent.setInputConfig(TransmissionType.ENERGY); - - inventory = new ItemStack[4]; - - upgradeComponent = new TileComponentUpgrade(this, 3); - upgradeComponent.setSupported(Upgrade.MUFFLING); - - ejectorComponent = new TileComponentEjector(this); - ejectorComponent.setOutputData(TransmissionType.ITEM, configComponent.getOutputs(TransmissionType.ITEM).get(2)); - - securityComponent = new TileComponentSecurity(this); - } - - @Override - public void onUpdate() - { - super.onUpdate(); - - if(worldObj.isRemote && updateDelay > 0) - { - updateDelay--; - - if(updateDelay == 0 && clientActive != isActive) - { - isActive = clientActive; - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } - - if(!worldObj.isRemote) - { - if(updateDelay > 0) - { - updateDelay--; - - if(updateDelay == 0 && clientActive != isActive) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - } - } - - ChargeUtils.discharge(2, this); - - if(inventory[0] != null && (inputTank.getGas() == null || inputTank.getStored() < inputTank.getMaxGas())) - { - inputTank.receive(GasTransmission.removeGas(inventory[0], inputTank.getGasType(), inputTank.getNeeded()), true); - } - - CrystallizerRecipe recipe = getRecipe(); - - if(canOperate(recipe) && MekanismUtils.canFunction(this) && getEnergy() >= energyUsage) - { - setActive(true); - - setEnergy(getEnergy() - energyUsage); - - if((operatingTicks+1) < ticksRequired) - { - operatingTicks++; - } - else { - operate(recipe); - operatingTicks = 0; - } - } - else { - if(prevEnergy >= getEnergy()) - { - setActive(false); - } - } - - if(!canOperate(recipe)) - { - operatingTicks = 0; - } - - prevEnergy = getEnergy(); - } - } - - public GasInput getInput() - { - return new GasInput(inputTank.getGas()); - } - - public CrystallizerRecipe getRecipe() - { - GasInput input = getInput(); - - if(cachedRecipe == null || !input.testEquality(cachedRecipe.getInput())) - { - cachedRecipe = RecipeHandler.getChemicalCrystallizerRecipe(getInput()); - } - - return cachedRecipe; - } - - public boolean canOperate(CrystallizerRecipe recipe) - { - return recipe != null && recipe.canOperate(inputTank, inventory); - } - - public void operate(CrystallizerRecipe recipe) - { - recipe.operate(inputTank, inventory); - - markDirty(); - ejectorComponent.outputItems(); - } - - @Override - public void handlePacketData(ByteBuf dataStream) - { - super.handlePacketData(dataStream); - - if(worldObj.isRemote) - { - isActive = dataStream.readBoolean(); - operatingTicks = dataStream.readInt(); - controlType = RedstoneControl.values()[dataStream.readInt()]; - - if(dataStream.readBoolean()) - { - inputTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt())); - } - else { - inputTank.setGas(null); - } - - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } - - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); - - data.add(isActive); - data.add(operatingTicks); - data.add(controlType.ordinal()); - - if(inputTank.getGas() != null) - { - data.add(true); - data.add(inputTank.getGas().getGas().getID()); - data.add(inputTank.getStored()); - } - else { - data.add(false); - } - - return data; - } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - isActive = nbtTags.getBoolean("isActive"); - operatingTicks = nbtTags.getInteger("operatingTicks"); - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - - inputTank.read(nbtTags.getCompoundTag("rightTank")); - } - - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - nbtTags.setBoolean("isActive", isActive); - nbtTags.setInteger("operatingTicks", operatingTicks); - nbtTags.setInteger("controlType", controlType.ordinal()); - - nbtTags.setTag("rightTank", inputTank.write(new NBTTagCompound())); - - nbtTags.setBoolean("sideDataStored", true); - } - - @Override - public boolean canSetFacing(int i) - { - return i != 0 && i != 1; - } - - public double getScaledProgress() - { - return ((double)operatingTicks) / (double)ticksRequired; - } - - @Override - public void setActive(boolean active) - { - isActive = active; - - if(clientActive != active && updateDelay == 0) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - - updateDelay = 10; - clientActive = active; - } - } - - @Override - public boolean getActive() - { - return isActive; - } - - @Override - public boolean renderUpdate() - { - return false; - } - - @Override - public boolean lightUpdate() - { - return true; - } - - @Override - public boolean canTubeConnect(ForgeDirection side) - { - return configComponent.getOutput(TransmissionType.GAS, side.ordinal(), facing).hasSlot(0); - } - - @Override - public boolean canReceiveGas(ForgeDirection side, Gas type) - { - return configComponent.getOutput(TransmissionType.GAS, side.ordinal(), facing).hasSlot(0) && inputTank.canReceive(type) && - RecipeHandler.Recipe.CHEMICAL_CRYSTALLIZER.containsRecipe(type); - } - - @Override - public RedstoneControl getControlType() - { - return controlType; - } - - @Override - public void setControlType(RedstoneControl type) - { - controlType = type; - MekanismUtils.saveChunk(this); - } - - @Override - public boolean canPulse() - { - return false; - } - - @Override - public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) - { - if(canReceiveGas(side, stack.getGas())) - { - return inputTank.receive(stack, doTransfer); - } - - return 0; - } - - @Override - public int receiveGas(ForgeDirection side, GasStack stack) - { - return receiveGas(side, stack, true); - } - - @Override - public GasStack drawGas(ForgeDirection side, int amount, boolean doTransfer) - { - return null; - } - - @Override - public GasStack drawGas(ForgeDirection side, int amount) - { - return drawGas(side, amount, true); - } - - @Override - public boolean canDrawGas(ForgeDirection side, Gas type) - { - return false; - } - - @Override - public boolean isItemValidForSlot(int slotID, ItemStack itemstack) - { - if(slotID == 0) - { - return itemstack != null && itemstack.getItem() instanceof IGasItem && ((IGasItem)itemstack.getItem()).getGas(itemstack) != null && - RecipeHandler.Recipe.CHEMICAL_CRYSTALLIZER.containsRecipe(((IGasItem)itemstack.getItem()).getGas(itemstack).getGas()); - } - else if(slotID == 2) - { - return ChargeUtils.canBeDischarged(itemstack); - } - - return false; - } - - @Override - public boolean canExtractItem(int slotID, ItemStack itemstack, int side) - { - if(slotID == 0) - { - return itemstack != null && itemstack.getItem() instanceof IGasItem && ((IGasItem)itemstack.getItem()).getGas(itemstack) == null; - } - else if(slotID == 1) - { - return true; - } - else if(slotID == 2) - { - return ChargeUtils.canBeOutputted(itemstack, false); - } - - return false; - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) - { - return configComponent.getOutput(TransmissionType.ITEM, side, facing).availableSlots; - } - - @Override - public TileComponentConfig getConfig() - { - return configComponent; - } - - @Override - public int getOrientation() - { - return facing; - } - - @Override - public TileComponentEjector getEjector() - { - return ejectorComponent; - } - - @Override - public TileComponentUpgrade getComponent() - { - return upgradeComponent; - } - - @Override - public void writeSustainedData(ItemStack itemStack) - { - if(inputTank.getGas() != null) - { - itemStack.stackTagCompound.setTag("inputTank", inputTank.getGas().write(new NBTTagCompound())); - } - } - - @Override - public void readSustainedData(ItemStack itemStack) - { - inputTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("inputTank"))); - } - - @Override - public void recalculateUpgradables(Upgrade upgrade) - { - super.recalculateUpgradables(upgrade); - - switch(upgrade) - { - case SPEED: - ticksRequired = MekanismUtils.getTicks(this, BASE_TICKS_REQUIRED); - energyUsage = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_USAGE); - break; - case ENERGY: - energyUsage = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_USAGE); - maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY); - break; - default: - break; - } - } - - @Override - public Object[] getTanks() - { - return new Object[] {inputTank}; - } - - @Override - public TileComponentSecurity getSecurity() - { - return securityComponent; - } +public class TileEntityChemicalCrystallizer extends TileEntityNoisyElectricBlock + implements IGasHandler, ITubeConnection, IRedstoneControl, ISideConfiguration, + IUpgradeTile, ISustainedData, ITankManager, IConfigCardAccess, + ISecurityTile { + public static final int MAX_GAS = 10000; + + public GasTank inputTank = new GasTank(MAX_GAS); + + public int updateDelay; + + public int operatingTicks; + + public int BASE_TICKS_REQUIRED = 200; + + public int ticksRequired = 200; + + public boolean isActive; + + public boolean clientActive; + + public double prevEnergy; + + public float spinSpeed; + + public float spin; + + public final double BASE_ENERGY_USAGE = usage.chemicalCrystallizerUsage; + + public double energyUsage = usage.chemicalCrystallizerUsage; + + public CrystallizerRecipe cachedRecipe; + + /** This machine's current RedstoneControl type. */ + public RedstoneControl controlType = RedstoneControl.DISABLED; + + public TileComponentUpgrade upgradeComponent; + public TileComponentEjector ejectorComponent; + public TileComponentConfig configComponent; + public TileComponentSecurity securityComponent; + + public TileEntityChemicalCrystallizer() { + super( + "machine.crystallizer", + "ChemicalCrystallizer", + MachineType.CHEMICAL_CRYSTALLIZER.baseEnergy + ); + + configComponent = new TileComponentConfig( + this, TransmissionType.ITEM, TransmissionType.ENERGY, TransmissionType.GAS + ); + + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY) + ); + configComponent.addOutput( + TransmissionType.ITEM, new SideData("Gas", EnumColor.PURPLE, new int[] { 0 }) + ); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("Output", EnumColor.DARK_BLUE, new int[] { 1 }) + ); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("Energy", EnumColor.DARK_GREEN, new int[] { 2 }) + ); + configComponent.setConfig(TransmissionType.ITEM, new byte[] { 0, 3, 0, 0, 1, 2 }); + + configComponent.addOutput( + TransmissionType.GAS, + new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY) + ); + configComponent.addOutput( + TransmissionType.GAS, new SideData("Gas", EnumColor.YELLOW, new int[] { 0 }) + ); + configComponent.setConfig( + TransmissionType.GAS, new byte[] { -1, -1, -1, -1, 1, -1 } + ); + configComponent.setCanEject(TransmissionType.GAS, false); + + configComponent.setInputConfig(TransmissionType.ENERGY); + + inventory = new ItemStack[4]; + + upgradeComponent = new TileComponentUpgrade(this, 3); + upgradeComponent.setSupported(Upgrade.MUFFLING); + + ejectorComponent = new TileComponentEjector(this); + ejectorComponent.setOutputData( + TransmissionType.ITEM, + configComponent.getOutputs(TransmissionType.ITEM).get(2) + ); + + securityComponent = new TileComponentSecurity(this); + } + + @Override + public void onUpdate() { + super.onUpdate(); + + if (worldObj.isRemote && updateDelay > 0) { + updateDelay--; + + if (updateDelay == 0 && clientActive != isActive) { + isActive = clientActive; + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } + + if (!worldObj.isRemote) { + if (updateDelay > 0) { + updateDelay--; + + if (updateDelay == 0 && clientActive != isActive) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + } + } + + ChargeUtils.discharge(2, this); + + if (inventory[0] != null + && (inputTank.getGas() == null + || inputTank.getStored() < inputTank.getMaxGas())) { + inputTank.receive( + GasTransmission.removeGas( + inventory[0], inputTank.getGasType(), inputTank.getNeeded() + ), + true + ); + } + + CrystallizerRecipe recipe = getRecipe(); + + if (canOperate(recipe) && MekanismUtils.canFunction(this) + && getEnergy() >= energyUsage) { + setActive(true); + + setEnergy(getEnergy() - energyUsage); + + if ((operatingTicks + 1) < ticksRequired) { + operatingTicks++; + } else { + operate(recipe); + operatingTicks = 0; + } + } else { + if (prevEnergy >= getEnergy()) { + setActive(false); + } + } + + if (!canOperate(recipe)) { + operatingTicks = 0; + } + + prevEnergy = getEnergy(); + } + } + + public GasInput getInput() { + return new GasInput(inputTank.getGas()); + } + + public CrystallizerRecipe getRecipe() { + GasInput input = getInput(); + + if (cachedRecipe == null || !input.testEquality(cachedRecipe.getInput())) { + cachedRecipe = RecipeHandler.getChemicalCrystallizerRecipe(getInput()); + } + + return cachedRecipe; + } + + public boolean canOperate(CrystallizerRecipe recipe) { + return recipe != null && recipe.canOperate(inputTank, inventory); + } + + public void operate(CrystallizerRecipe recipe) { + recipe.operate(inputTank, inventory); + + markDirty(); + ejectorComponent.outputItems(); + } + + @Override + public void handlePacketData(ByteBuf dataStream) { + super.handlePacketData(dataStream); + + if (worldObj.isRemote) { + isActive = dataStream.readBoolean(); + operatingTicks = dataStream.readInt(); + controlType = RedstoneControl.values()[dataStream.readInt()]; + + if (dataStream.readBoolean()) { + inputTank.setGas(new GasStack( + GasRegistry.getGas(dataStream.readInt()), dataStream.readInt() + )); + } else { + inputTank.setGas(null); + } + + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } + + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); + + data.add(isActive); + data.add(operatingTicks); + data.add(controlType.ordinal()); + + if (inputTank.getGas() != null) { + data.add(true); + data.add(inputTank.getGas().getGas().getID()); + data.add(inputTank.getStored()); + } else { + data.add(false); + } + + return data; + } + + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); + + isActive = nbtTags.getBoolean("isActive"); + operatingTicks = nbtTags.getInteger("operatingTicks"); + controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + + inputTank.read(nbtTags.getCompoundTag("rightTank")); + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); + + nbtTags.setBoolean("isActive", isActive); + nbtTags.setInteger("operatingTicks", operatingTicks); + nbtTags.setInteger("controlType", controlType.ordinal()); + + nbtTags.setTag("rightTank", inputTank.write(new NBTTagCompound())); + + nbtTags.setBoolean("sideDataStored", true); + } + + @Override + public boolean canSetFacing(int i) { + return i != 0 && i != 1; + } + + public double getScaledProgress() { + return ((double) operatingTicks) / (double) ticksRequired; + } + + @Override + public void setActive(boolean active) { + isActive = active; + + if (clientActive != active && updateDelay == 0) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + + updateDelay = 10; + clientActive = active; + } + } + + @Override + public boolean getActive() { + return isActive; + } + + @Override + public boolean renderUpdate() { + return false; + } + + @Override + public boolean lightUpdate() { + return true; + } + + @Override + public boolean canTubeConnect(ForgeDirection side) { + return configComponent.getOutput(TransmissionType.GAS, side.ordinal(), facing) + .hasSlot(0); + } + + @Override + public boolean canReceiveGas(ForgeDirection side, Gas type) { + return configComponent.getOutput(TransmissionType.GAS, side.ordinal(), facing) + .hasSlot(0) + && inputTank.canReceive(type) + && RecipeHandler.Recipe.CHEMICAL_CRYSTALLIZER.containsRecipe(type); + } + + @Override + public RedstoneControl getControlType() { + return controlType; + } + + @Override + public void setControlType(RedstoneControl type) { + controlType = type; + MekanismUtils.saveChunk(this); + } + + @Override + public boolean canPulse() { + return false; + } + + @Override + public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) { + if (canReceiveGas(side, stack.getGas())) { + return inputTank.receive(stack, doTransfer); + } + + return 0; + } + + @Override + public int receiveGas(ForgeDirection side, GasStack stack) { + return receiveGas(side, stack, true); + } + + @Override + public GasStack drawGas(ForgeDirection side, int amount, boolean doTransfer) { + return null; + } + + @Override + public GasStack drawGas(ForgeDirection side, int amount) { + return drawGas(side, amount, true); + } + + @Override + public boolean canDrawGas(ForgeDirection side, Gas type) { + return false; + } + + @Override + public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { + if (slotID == 0) { + return itemstack != null && itemstack.getItem() instanceof IGasItem + && ((IGasItem) itemstack.getItem()).getGas(itemstack) != null + && RecipeHandler.Recipe.CHEMICAL_CRYSTALLIZER.containsRecipe( + ((IGasItem) itemstack.getItem()).getGas(itemstack).getGas() + ); + } else if (slotID == 2) { + return ChargeUtils.canBeDischarged(itemstack); + } + + return false; + } + + @Override + public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { + if (slotID == 0) { + return itemstack != null && itemstack.getItem() instanceof IGasItem + && ((IGasItem) itemstack.getItem()).getGas(itemstack) == null; + } else if (slotID == 1) { + return true; + } else if (slotID == 2) { + return ChargeUtils.canBeOutputted(itemstack, false); + } + + return false; + } + + @Override + public int[] getAccessibleSlotsFromSide(int side) { + return configComponent.getOutput(TransmissionType.ITEM, side, facing) + .availableSlots; + } + + @Override + public TileComponentConfig getConfig() { + return configComponent; + } + + @Override + public int getOrientation() { + return facing; + } + + @Override + public TileComponentEjector getEjector() { + return ejectorComponent; + } + + @Override + public TileComponentUpgrade getComponent() { + return upgradeComponent; + } + + @Override + public void writeSustainedData(ItemStack itemStack) { + if (inputTank.getGas() != null) { + itemStack.stackTagCompound.setTag( + "inputTank", inputTank.getGas().write(new NBTTagCompound()) + ); + } + } + + @Override + public void readSustainedData(ItemStack itemStack) { + inputTank.setGas( + GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("inputTank")) + ); + } + + @Override + public void recalculateUpgradables(Upgrade upgrade) { + super.recalculateUpgradables(upgrade); + + switch (upgrade) { + case SPEED: + ticksRequired = MekanismUtils.getTicks(this, BASE_TICKS_REQUIRED); + energyUsage = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_USAGE); + break; + case ENERGY: + energyUsage = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_USAGE); + maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY); + break; + default: + break; + } + } + + @Override + public Object[] getTanks() { + return new Object[] { inputTank }; + } + + @Override + public TileComponentSecurity getSecurity() { + return securityComponent; + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalDissolutionChamber.java b/src/main/java/mekanism/common/tile/TileEntityChemicalDissolutionChamber.java index 79ad26d82..8a3a487b4 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalDissolutionChamber.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalDissolutionChamber.java @@ -1,9 +1,8 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.MekanismConfig.usage; import mekanism.api.Range4D; @@ -39,480 +38,468 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityChemicalDissolutionChamber extends TileEntityNoisyElectricBlock implements ITubeConnection, IRedstoneControl, IGasHandler, IUpgradeTile, ISustainedData, ITankManager, ISecurityTile -{ - public GasTank injectTank = new GasTank(MAX_GAS); - public GasTank outputTank = new GasTank(MAX_GAS); +public class TileEntityChemicalDissolutionChamber extends TileEntityNoisyElectricBlock + implements ITubeConnection, IRedstoneControl, IGasHandler, IUpgradeTile, + ISustainedData, ITankManager, ISecurityTile { + public GasTank injectTank = new GasTank(MAX_GAS); + public GasTank outputTank = new GasTank(MAX_GAS); - public static final int MAX_GAS = 10000; + public static final int MAX_GAS = 10000; - public static final int BASE_INJECT_USAGE = 1; + public static final int BASE_INJECT_USAGE = 1; - public double injectUsage = 1; + public double injectUsage = 1; - public int injectUsageThisTick; + public int injectUsageThisTick; - public int updateDelay; + public int updateDelay; - public int gasOutput = 256; + public int gasOutput = 256; - public boolean isActive; + public boolean isActive; - public boolean clientActive; + public boolean clientActive; - public double prevEnergy; + public double prevEnergy; - public int operatingTicks = 0; + public int operatingTicks = 0; - public int BASE_TICKS_REQUIRED = 100; + public int BASE_TICKS_REQUIRED = 100; - public int ticksRequired = 100; + public int ticksRequired = 100; - public final double BASE_ENERGY_USAGE = usage.chemicalDissolutionChamberUsage; + public final double BASE_ENERGY_USAGE = usage.chemicalDissolutionChamberUsage; - public double energyUsage = usage.chemicalDissolutionChamberUsage; + public double energyUsage = usage.chemicalDissolutionChamberUsage; - public DissolutionRecipe cachedRecipe; - - public TileComponentUpgrade upgradeComponent = new TileComponentAdvancedUpgrade(this, 4); - public TileComponentSecurity securityComponent = new TileComponentSecurity(this); - - public RedstoneControl controlType = RedstoneControl.DISABLED; - - public TileEntityChemicalDissolutionChamber() - { - super("machine.dissolution", "ChemicalDissolutionChamber", MachineType.CHEMICAL_DISSOLUTION_CHAMBER.baseEnergy); - - inventory = new ItemStack[5]; - upgradeComponent.setSupported(Upgrade.MUFFLING); - } - - @Override - public void onUpdate() - { - if(worldObj.isRemote && updateDelay > 0) - { - updateDelay--; - - if(updateDelay == 0 && clientActive != isActive) - { - isActive = clientActive; - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } - - if(!worldObj.isRemote) - { - if(updateDelay > 0) - { - updateDelay--; - - if(updateDelay == 0 && clientActive != isActive) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - } - } - - ChargeUtils.discharge(3, this); - - if(inventory[0] != null && injectTank.getNeeded() > 0) - { - injectTank.receive(GasTransmission.removeGas(inventory[0], GasRegistry.getGas("sulfuricAcid"), injectTank.getNeeded()), true); - } - - if(inventory[2] != null && outputTank.getGas() != null) - { - outputTank.draw(GasTransmission.addGas(inventory[2], outputTank.getGas()), true); - } - - boolean changed = false; - - DissolutionRecipe recipe = getRecipe(); - - injectUsageThisTick = Math.max(1, StatUtils.inversePoisson(injectUsage)); - - if(canOperate(recipe) && getEnergy() >= energyUsage && injectTank.getStored() >= injectUsageThisTick && MekanismUtils.canFunction(this)) - { - setActive(true); - setEnergy(getEnergy() - energyUsage); - minorOperate(); - - if((operatingTicks+1) < ticksRequired) - { - operatingTicks++; - } - else { - operate(recipe); - operatingTicks = 0; - } - } - else { - if(prevEnergy >= getEnergy()) - { - changed = true; - setActive(false); - } - } - - if(changed && !canOperate(recipe)) - { - operatingTicks = 0; - } - - prevEnergy = getEnergy(); - - if(outputTank.getGas() != null) - { - GasStack toSend = new GasStack(outputTank.getGas().getGas(), Math.min(outputTank.getStored(), gasOutput)); - - TileEntity tileEntity = Coord4D.get(this).getFromSide(MekanismUtils.getRight(facing)).getTileEntity(worldObj); - - if(tileEntity instanceof IGasHandler) - { - if(((IGasHandler)tileEntity).canReceiveGas(MekanismUtils.getRight(facing).getOpposite(), outputTank.getGas().getGas())) - { - outputTank.draw(((IGasHandler)tileEntity).receiveGas(MekanismUtils.getRight(facing).getOpposite(), toSend, true), true); - } - } - } - } - } - - @Override - public boolean isItemValidForSlot(int slotID, ItemStack itemstack) - { - if(slotID == 1) - { - return RecipeHandler.getDissolutionRecipe(new ItemStackInput(itemstack)) != null; - } - else if(slotID == 3) - { - return ChargeUtils.canBeDischarged(itemstack); - } - - return false; - } - - @Override - public boolean canExtractItem(int slotID, ItemStack itemstack, int side) - { - if(slotID == 2) - { - return itemstack != null && itemstack.getItem() instanceof IGasItem && ((IGasItem)itemstack.getItem()).canProvideGas(itemstack, null); - } - - return false; - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) - { - if(side == MekanismUtils.getLeft(facing).ordinal() || side == 1) - { - return new int[] {1}; - } - else if(side == 0) - { - return new int[] {0}; - } - else if(side == MekanismUtils.getRight(facing).ordinal()) - { - return new int[] {2}; - } - - return InventoryUtils.EMPTY; - } - - public double getScaledProgress() - { - return ((double)operatingTicks) / ((double)ticksRequired); - } - - public DissolutionRecipe getRecipe() - { - ItemStackInput input = getInput(); - - if(cachedRecipe == null || !input.testEquality(cachedRecipe.getInput())) - { - cachedRecipe = RecipeHandler.getDissolutionRecipe(getInput()); - } - - return cachedRecipe; - } - - public ItemStackInput getInput() - { - return new ItemStackInput(inventory[1]); - } - - public boolean canOperate(DissolutionRecipe recipe) - { - return recipe != null && recipe.canOperate(inventory, outputTank); - } - - public void operate(DissolutionRecipe recipe) - { - recipe.operate(inventory, outputTank); - - markDirty(); - } - - public void minorOperate() - { - injectTank.draw(injectUsageThisTick, true); - } - - @Override - public void handlePacketData(ByteBuf dataStream) - { - super.handlePacketData(dataStream); - - if(worldObj.isRemote) - { - isActive = dataStream.readBoolean(); - controlType = RedstoneControl.values()[dataStream.readInt()]; - operatingTicks = dataStream.readInt(); - - if(dataStream.readBoolean()) - { - injectTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt())); - } - else { - injectTank.setGas(null); - } - - if(dataStream.readBoolean()) - { - outputTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt())); - } - else { - outputTank.setGas(null); - } - - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } - - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); - - data.add(isActive); - data.add(controlType.ordinal()); - data.add(operatingTicks); - - if(injectTank.getGas() != null) - { - data.add(true); - data.add(injectTank.getGas().getGas().getID()); - data.add(injectTank.getStored()); - } - else { - data.add(false); - } - - if(outputTank.getGas() != null) - { - data.add(true); - data.add(outputTank.getGas().getGas().getID()); - data.add(outputTank.getStored()); - } - else { - data.add(false); - } - - return data; - } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - isActive = nbtTags.getBoolean("isActive"); - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - operatingTicks = nbtTags.getInteger("operatingTicks"); - injectTank.read(nbtTags.getCompoundTag("injectTank")); - outputTank.read(nbtTags.getCompoundTag("gasTank")); - } - - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - nbtTags.setBoolean("isActive", isActive); - nbtTags.setInteger("controlType", controlType.ordinal()); - nbtTags.setInteger("operatingTicks", operatingTicks); - nbtTags.setTag("injectTank", injectTank.write(new NBTTagCompound())); - nbtTags.setTag("gasTank", outputTank.write(new NBTTagCompound())); - } - - @Override - public boolean canSetFacing(int i) - { - return i != 0 && i != 1; - } - - @Override - public void setActive(boolean active) - { - isActive = active; - - if(clientActive != active && updateDelay == 0) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - - updateDelay = 10; - clientActive = active; - } - } - - @Override - public boolean getActive() - { - return isActive; - } - - @Override - public boolean renderUpdate() - { - return false; - } - - @Override - public boolean lightUpdate() - { - return true; - } - - @Override - public boolean canTubeConnect(ForgeDirection side) - { - return side == MekanismUtils.getLeft(facing) || side == MekanismUtils.getRight(facing); - } - - @Override - public RedstoneControl getControlType() - { - return controlType; - } - - @Override - public void setControlType(RedstoneControl type) - { - controlType = type; - MekanismUtils.saveChunk(this); - } - - @Override - public boolean canPulse() - { - return false; - } - - @Override - public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) - { - if(canReceiveGas(side, stack.getGas())) - { - return injectTank.receive(stack, doTransfer); - } - - return 0; - } - - @Override - public int receiveGas(ForgeDirection side, GasStack stack) - { - return receiveGas(side, stack, true); - } - - @Override - public GasStack drawGas(ForgeDirection side, int amount, boolean doTransfer) - { - return null; - } - - @Override - public GasStack drawGas(ForgeDirection side, int amount) - { - return drawGas(side, amount, true); - } - - @Override - public boolean canReceiveGas(ForgeDirection side, Gas type) - { - return side == MekanismUtils.getLeft(facing) && type == GasRegistry.getGas("sulfuricAcid"); - } - - @Override - public boolean canDrawGas(ForgeDirection side, Gas type) - { - return false; - } - - @Override - public TileComponentUpgrade getComponent() - { - return upgradeComponent; - } - - @Override - public void writeSustainedData(ItemStack itemStack) - { - if(injectTank.getGas() != null) - { - itemStack.stackTagCompound.setTag("injectTank", injectTank.getGas().write(new NBTTagCompound())); - } - - if(outputTank.getGas() != null) - { - itemStack.stackTagCompound.setTag("outputTank", outputTank.getGas().write(new NBTTagCompound())); - } - } - - @Override - public void readSustainedData(ItemStack itemStack) - { - injectTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("injectTank"))); - outputTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("outputTank"))); - } - - @Override - public void recalculateUpgradables(Upgrade upgrade) - { - super.recalculateUpgradables(upgrade); - - switch(upgrade) - { - case GAS: - injectUsage = MekanismUtils.getSecondaryEnergyPerTickMean(this, BASE_INJECT_USAGE); - break; - case SPEED: - ticksRequired = MekanismUtils.getTicks(this, BASE_TICKS_REQUIRED); - energyUsage = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_USAGE); - injectUsage = MekanismUtils.getSecondaryEnergyPerTickMean(this, BASE_INJECT_USAGE); - break; - case ENERGY: - energyUsage = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_USAGE); - maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY); - break; - default: - break; - } - } - - @Override - public Object[] getTanks() - { - return new Object[] {injectTank, outputTank}; - } - - @Override - public TileComponentSecurity getSecurity() - { - return securityComponent; - } + public DissolutionRecipe cachedRecipe; + + public TileComponentUpgrade upgradeComponent + = new TileComponentAdvancedUpgrade(this, 4); + public TileComponentSecurity securityComponent = new TileComponentSecurity(this); + + public RedstoneControl controlType = RedstoneControl.DISABLED; + + public TileEntityChemicalDissolutionChamber() { + super( + "machine.dissolution", + "ChemicalDissolutionChamber", + MachineType.CHEMICAL_DISSOLUTION_CHAMBER.baseEnergy + ); + + inventory = new ItemStack[5]; + upgradeComponent.setSupported(Upgrade.MUFFLING); + } + + @Override + public void onUpdate() { + if (worldObj.isRemote && updateDelay > 0) { + updateDelay--; + + if (updateDelay == 0 && clientActive != isActive) { + isActive = clientActive; + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } + + if (!worldObj.isRemote) { + if (updateDelay > 0) { + updateDelay--; + + if (updateDelay == 0 && clientActive != isActive) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + } + } + + ChargeUtils.discharge(3, this); + + if (inventory[0] != null && injectTank.getNeeded() > 0) { + injectTank.receive( + GasTransmission.removeGas( + inventory[0], + GasRegistry.getGas("sulfuricAcid"), + injectTank.getNeeded() + ), + true + ); + } + + if (inventory[2] != null && outputTank.getGas() != null) { + outputTank.draw( + GasTransmission.addGas(inventory[2], outputTank.getGas()), true + ); + } + + boolean changed = false; + + DissolutionRecipe recipe = getRecipe(); + + injectUsageThisTick = Math.max(1, StatUtils.inversePoisson(injectUsage)); + + if (canOperate(recipe) && getEnergy() >= energyUsage + && injectTank.getStored() >= injectUsageThisTick + && MekanismUtils.canFunction(this)) { + setActive(true); + setEnergy(getEnergy() - energyUsage); + minorOperate(); + + if ((operatingTicks + 1) < ticksRequired) { + operatingTicks++; + } else { + operate(recipe); + operatingTicks = 0; + } + } else { + if (prevEnergy >= getEnergy()) { + changed = true; + setActive(false); + } + } + + if (changed && !canOperate(recipe)) { + operatingTicks = 0; + } + + prevEnergy = getEnergy(); + + if (outputTank.getGas() != null) { + GasStack toSend = new GasStack( + outputTank.getGas().getGas(), + Math.min(outputTank.getStored(), gasOutput) + ); + + TileEntity tileEntity = Coord4D.get(this) + .getFromSide(MekanismUtils.getRight(facing)) + .getTileEntity(worldObj); + + if (tileEntity instanceof IGasHandler) { + if (((IGasHandler) tileEntity) + .canReceiveGas( + MekanismUtils.getRight(facing).getOpposite(), + outputTank.getGas().getGas() + )) { + outputTank.draw( + ((IGasHandler) tileEntity) + .receiveGas( + MekanismUtils.getRight(facing).getOpposite(), + toSend, + true + ), + true + ); + } + } + } + } + } + + @Override + public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { + if (slotID == 1) { + return RecipeHandler.getDissolutionRecipe(new ItemStackInput(itemstack)) + != null; + } else if (slotID == 3) { + return ChargeUtils.canBeDischarged(itemstack); + } + + return false; + } + + @Override + public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { + if (slotID == 2) { + return itemstack != null && itemstack.getItem() instanceof IGasItem + && ((IGasItem) itemstack.getItem()).canProvideGas(itemstack, null); + } + + return false; + } + + @Override + public int[] getAccessibleSlotsFromSide(int side) { + if (side == MekanismUtils.getLeft(facing).ordinal() || side == 1) { + return new int[] { 1 }; + } else if (side == 0) { + return new int[] { 0 }; + } else if (side == MekanismUtils.getRight(facing).ordinal()) { + return new int[] { 2 }; + } + + return InventoryUtils.EMPTY; + } + + public double getScaledProgress() { + return ((double) operatingTicks) / ((double) ticksRequired); + } + + public DissolutionRecipe getRecipe() { + ItemStackInput input = getInput(); + + if (cachedRecipe == null || !input.testEquality(cachedRecipe.getInput())) { + cachedRecipe = RecipeHandler.getDissolutionRecipe(getInput()); + } + + return cachedRecipe; + } + + public ItemStackInput getInput() { + return new ItemStackInput(inventory[1]); + } + + public boolean canOperate(DissolutionRecipe recipe) { + return recipe != null && recipe.canOperate(inventory, outputTank); + } + + public void operate(DissolutionRecipe recipe) { + recipe.operate(inventory, outputTank); + + markDirty(); + } + + public void minorOperate() { + injectTank.draw(injectUsageThisTick, true); + } + + @Override + public void handlePacketData(ByteBuf dataStream) { + super.handlePacketData(dataStream); + + if (worldObj.isRemote) { + isActive = dataStream.readBoolean(); + controlType = RedstoneControl.values()[dataStream.readInt()]; + operatingTicks = dataStream.readInt(); + + if (dataStream.readBoolean()) { + injectTank.setGas(new GasStack( + GasRegistry.getGas(dataStream.readInt()), dataStream.readInt() + )); + } else { + injectTank.setGas(null); + } + + if (dataStream.readBoolean()) { + outputTank.setGas(new GasStack( + GasRegistry.getGas(dataStream.readInt()), dataStream.readInt() + )); + } else { + outputTank.setGas(null); + } + + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } + + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); + + data.add(isActive); + data.add(controlType.ordinal()); + data.add(operatingTicks); + + if (injectTank.getGas() != null) { + data.add(true); + data.add(injectTank.getGas().getGas().getID()); + data.add(injectTank.getStored()); + } else { + data.add(false); + } + + if (outputTank.getGas() != null) { + data.add(true); + data.add(outputTank.getGas().getGas().getID()); + data.add(outputTank.getStored()); + } else { + data.add(false); + } + + return data; + } + + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); + + isActive = nbtTags.getBoolean("isActive"); + controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + operatingTicks = nbtTags.getInteger("operatingTicks"); + injectTank.read(nbtTags.getCompoundTag("injectTank")); + outputTank.read(nbtTags.getCompoundTag("gasTank")); + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); + + nbtTags.setBoolean("isActive", isActive); + nbtTags.setInteger("controlType", controlType.ordinal()); + nbtTags.setInteger("operatingTicks", operatingTicks); + nbtTags.setTag("injectTank", injectTank.write(new NBTTagCompound())); + nbtTags.setTag("gasTank", outputTank.write(new NBTTagCompound())); + } + + @Override + public boolean canSetFacing(int i) { + return i != 0 && i != 1; + } + + @Override + public void setActive(boolean active) { + isActive = active; + + if (clientActive != active && updateDelay == 0) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + + updateDelay = 10; + clientActive = active; + } + } + + @Override + public boolean getActive() { + return isActive; + } + + @Override + public boolean renderUpdate() { + return false; + } + + @Override + public boolean lightUpdate() { + return true; + } + + @Override + public boolean canTubeConnect(ForgeDirection side) { + return side == MekanismUtils.getLeft(facing) + || side == MekanismUtils.getRight(facing); + } + + @Override + public RedstoneControl getControlType() { + return controlType; + } + + @Override + public void setControlType(RedstoneControl type) { + controlType = type; + MekanismUtils.saveChunk(this); + } + + @Override + public boolean canPulse() { + return false; + } + + @Override + public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) { + if (canReceiveGas(side, stack.getGas())) { + return injectTank.receive(stack, doTransfer); + } + + return 0; + } + + @Override + public int receiveGas(ForgeDirection side, GasStack stack) { + return receiveGas(side, stack, true); + } + + @Override + public GasStack drawGas(ForgeDirection side, int amount, boolean doTransfer) { + return null; + } + + @Override + public GasStack drawGas(ForgeDirection side, int amount) { + return drawGas(side, amount, true); + } + + @Override + public boolean canReceiveGas(ForgeDirection side, Gas type) { + return side == MekanismUtils.getLeft(facing) + && type == GasRegistry.getGas("sulfuricAcid"); + } + + @Override + public boolean canDrawGas(ForgeDirection side, Gas type) { + return false; + } + + @Override + public TileComponentUpgrade getComponent() { + return upgradeComponent; + } + + @Override + public void writeSustainedData(ItemStack itemStack) { + if (injectTank.getGas() != null) { + itemStack.stackTagCompound.setTag( + "injectTank", injectTank.getGas().write(new NBTTagCompound()) + ); + } + + if (outputTank.getGas() != null) { + itemStack.stackTagCompound.setTag( + "outputTank", outputTank.getGas().write(new NBTTagCompound()) + ); + } + } + + @Override + public void readSustainedData(ItemStack itemStack) { + injectTank.setGas( + GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("injectTank")) + ); + outputTank.setGas( + GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("outputTank")) + ); + } + + @Override + public void recalculateUpgradables(Upgrade upgrade) { + super.recalculateUpgradables(upgrade); + + switch (upgrade) { + case GAS: + injectUsage = MekanismUtils.getSecondaryEnergyPerTickMean( + this, BASE_INJECT_USAGE + ); + break; + case SPEED: + ticksRequired = MekanismUtils.getTicks(this, BASE_TICKS_REQUIRED); + energyUsage = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_USAGE); + injectUsage = MekanismUtils.getSecondaryEnergyPerTickMean( + this, BASE_INJECT_USAGE + ); + break; + case ENERGY: + energyUsage = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_USAGE); + maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY); + break; + default: + break; + } + } + + @Override + public Object[] getTanks() { + return new Object[] { injectTank, outputTank }; + } + + @Override + public TileComponentSecurity getSecurity() { + return securityComponent; + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalInfuser.java b/src/main/java/mekanism/common/tile/TileEntityChemicalInfuser.java index e7d38e96a..fb48bf2b2 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalInfuser.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalInfuser.java @@ -1,10 +1,9 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.List; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.MekanismConfig.usage; import mekanism.api.Range4D; @@ -39,532 +38,530 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock implements IGasHandler, ITubeConnection, IRedstoneControl, ISustainedData, IUpgradeTile, IUpgradeInfoHandler, ITankManager, ISecurityTile -{ - public GasTank leftTank = new GasTank(MAX_GAS); - public GasTank rightTank = new GasTank(MAX_GAS); - public GasTank centerTank = new GasTank(MAX_GAS); - - public static final int MAX_GAS = 10000; - - public int updateDelay; - - public int gasOutput = 256; - - public boolean isActive; - - public boolean clientActive; - - public double prevEnergy; - - public final double BASE_ENERGY_USAGE = usage.chemicalInfuserUsage; - - public double energyPerTick = BASE_ENERGY_USAGE; - - public ChemicalInfuserRecipe cachedRecipe; - - public double clientEnergyUsed; - - public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, 4); - public TileComponentSecurity securityComponent = new TileComponentSecurity(this); - - /** This machine's current RedstoneControl type. */ - public RedstoneControl controlType = RedstoneControl.DISABLED; - - public TileEntityChemicalInfuser() - { - super("machine.cheminfuser", "ChemicalInfuser", MachineType.CHEMICAL_INFUSER.baseEnergy); - - inventory = new ItemStack[5]; - upgradeComponent.setSupported(Upgrade.MUFFLING); - } - - @Override - public void onUpdate() - { - super.onUpdate(); - - if(worldObj.isRemote && updateDelay > 0) - { - updateDelay--; - - if(updateDelay == 0 && clientActive != isActive) - { - isActive = clientActive; - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } - - if(!worldObj.isRemote) - { - if(updateDelay > 0) - { - updateDelay--; - - if(updateDelay == 0 && clientActive != isActive) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - } - } - - ChargeUtils.discharge(3, this); - - if(inventory[0] != null && (leftTank.getGas() == null || leftTank.getStored() < leftTank.getMaxGas())) - { - leftTank.receive(GasTransmission.removeGas(inventory[0], leftTank.getGasType(), leftTank.getNeeded()), true); - } - - if(inventory[1] != null && (rightTank.getGas() == null || rightTank.getStored() < rightTank.getMaxGas())) - { - rightTank.receive(GasTransmission.removeGas(inventory[1], rightTank.getGasType(), rightTank.getNeeded()), true); - } - - if(inventory[2] != null && centerTank.getGas() != null) - { - centerTank.draw(GasTransmission.addGas(inventory[2], centerTank.getGas()), true); - } - - ChemicalInfuserRecipe recipe = getRecipe(); - - if(canOperate(recipe) && getEnergy() >= energyPerTick && MekanismUtils.canFunction(this)) - { - setActive(true); - - int operations = operate(recipe); - double prev = getEnergy(); - - setEnergy(getEnergy() - energyPerTick*operations); - clientEnergyUsed = prev-getEnergy(); - } - else { - if(prevEnergy >= getEnergy()) - { - setActive(false); - } - } - - if(centerTank.getGas() != null) - { - GasStack toSend = new GasStack(centerTank.getGas().getGas(), Math.min(centerTank.getStored(), gasOutput)); - - TileEntity tileEntity = Coord4D.get(this).getFromSide(ForgeDirection.getOrientation(facing)).getTileEntity(worldObj); - - if(tileEntity instanceof IGasHandler) - { - if(((IGasHandler)tileEntity).canReceiveGas(ForgeDirection.getOrientation(facing).getOpposite(), centerTank.getGas().getGas())) - { - centerTank.draw(((IGasHandler)tileEntity).receiveGas(ForgeDirection.getOrientation(facing).getOpposite(), toSend, true), true); - } - } - } - - prevEnergy = getEnergy(); - } - } - - public int getUpgradedUsage(ChemicalInfuserRecipe recipe) - { - int possibleProcess = (int)Math.pow(2, upgradeComponent.getUpgrades(Upgrade.SPEED)); - - if(leftTank.getGasType() == recipe.recipeInput.leftGas.getGas()) - { - possibleProcess = Math.min(leftTank.getStored()/recipe.recipeInput.leftGas.amount, possibleProcess); - possibleProcess = Math.min(rightTank.getStored()/recipe.recipeInput.rightGas.amount, possibleProcess); - } - else { - possibleProcess = Math.min(leftTank.getStored()/recipe.recipeInput.rightGas.amount, possibleProcess); - possibleProcess = Math.min(rightTank.getStored()/recipe.recipeInput.leftGas.amount, possibleProcess); - } - - possibleProcess = Math.min(centerTank.getNeeded()/recipe.recipeOutput.output.amount, possibleProcess); - possibleProcess = Math.min((int)(getEnergy()/energyPerTick), possibleProcess); - - return possibleProcess; - } - - public ChemicalPairInput getInput() - { - return new ChemicalPairInput(leftTank.getGas(), rightTank.getGas()); - } - - public ChemicalInfuserRecipe getRecipe() - { - ChemicalPairInput input = getInput(); - - if(cachedRecipe == null || !input.testEquality(cachedRecipe.getInput())) - { - cachedRecipe = RecipeHandler.getChemicalInfuserRecipe(getInput()); - } - - return cachedRecipe; - } - - public boolean canOperate(ChemicalInfuserRecipe recipe) - { - return recipe != null && recipe.canOperate(leftTank, rightTank, centerTank); - } - - public int operate(ChemicalInfuserRecipe recipe) - { - int operations = getUpgradedUsage(recipe); - - recipe.operate(leftTank, rightTank, centerTank, operations); - - markDirty(); - - return operations; - } - - @Override - public void handlePacketData(ByteBuf dataStream) - { - super.handlePacketData(dataStream); - - if(worldObj.isRemote) - { - isActive = dataStream.readBoolean(); - controlType = RedstoneControl.values()[dataStream.readInt()]; - clientEnergyUsed = dataStream.readDouble(); - - if(dataStream.readBoolean()) - { - leftTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt())); - } - else { - leftTank.setGas(null); - } - - if(dataStream.readBoolean()) - { - rightTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt())); - } - else { - rightTank.setGas(null); - } - - if(dataStream.readBoolean()) - { - centerTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt())); - } - else { - centerTank.setGas(null); - } - - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } - - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); - - data.add(isActive); - data.add(controlType.ordinal()); - data.add(clientEnergyUsed); - - if(leftTank.getGas() != null) - { - data.add(true); - data.add(leftTank.getGas().getGas().getID()); - data.add(leftTank.getStored()); - } - else { - data.add(false); - } - - if(rightTank.getGas() != null) - { - data.add(true); - data.add(rightTank.getGas().getGas().getID()); - data.add(rightTank.getStored()); - } - else { - data.add(false); - } - - if(centerTank.getGas() != null) - { - data.add(true); - data.add(centerTank.getGas().getGas().getID()); - data.add(centerTank.getStored()); - } - else { - data.add(false); - } - - return data; - } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - isActive = nbtTags.getBoolean("isActive"); - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - - leftTank.read(nbtTags.getCompoundTag("leftTank")); - rightTank.read(nbtTags.getCompoundTag("rightTank")); - centerTank.read(nbtTags.getCompoundTag("centerTank")); - } - - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - nbtTags.setBoolean("isActive", isActive); - nbtTags.setInteger("controlType", controlType.ordinal()); - - nbtTags.setTag("leftTank", leftTank.write(new NBTTagCompound())); - nbtTags.setTag("rightTank", rightTank.write(new NBTTagCompound())); - nbtTags.setTag("centerTank", centerTank.write(new NBTTagCompound())); - } - - @Override - public boolean canSetFacing(int i) - { - return i != 0 && i != 1; - } - - public GasTank getTank(ForgeDirection side) - { - if(side == MekanismUtils.getLeft(facing)) - { - return leftTank; - } - else if(side == MekanismUtils.getRight(facing)) - { - return rightTank; - } - else if(side == ForgeDirection.getOrientation(facing)) - { - return centerTank; - } - - return null; - } - - @Override - public void setActive(boolean active) - { - isActive = active; - - if(clientActive != active && updateDelay == 0) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - - updateDelay = 10; - clientActive = active; - } - } - - @Override - public boolean getActive() - { - return isActive; - } - - @Override - public boolean renderUpdate() - { - return false; - } - - @Override - public boolean lightUpdate() - { - return true; - } - - @Override - public boolean canTubeConnect(ForgeDirection side) - { - return side == MekanismUtils.getLeft(facing) || side == MekanismUtils.getRight(facing) || side == ForgeDirection.getOrientation(facing); - } - - @Override - public boolean canReceiveGas(ForgeDirection side, Gas type) - { - return getTank(side) != null && getTank(side) != centerTank ? getTank(side).canReceive(type) : false; - } - - @Override - public RedstoneControl getControlType() - { - return controlType; - } - - @Override - public void setControlType(RedstoneControl type) - { - controlType = type; - MekanismUtils.saveChunk(this); - } - - @Override - public boolean canPulse() - { - return false; - } - - @Override - public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) - { - if(canReceiveGas(side, stack != null ? stack.getGas() : null)) - { - return getTank(side).receive(stack, doTransfer); - } - - return 0; - } - - @Override - public int receiveGas(ForgeDirection side, GasStack stack) - { - return receiveGas(side, stack, true); - } - - @Override - public GasStack drawGas(ForgeDirection side, int amount, boolean doTransfer) - { - if(canDrawGas(side, null)) - { - return getTank(side).draw(amount, doTransfer); - } - - return null; - } - - @Override - public GasStack drawGas(ForgeDirection side, int amount) - { - return drawGas(side, amount, true); - } - - @Override - public boolean canDrawGas(ForgeDirection side, Gas type) - { - return getTank(side) != null && getTank(side) == centerTank ? getTank(side).canDraw(type) : false; - } - - @Override - public boolean isItemValidForSlot(int slotID, ItemStack itemstack) - { - if(slotID == 3) - { - return ChargeUtils.canBeDischarged(itemstack); - } - - return false; - } - - @Override - public boolean canExtractItem(int slotID, ItemStack itemstack, int side) - { - if(slotID == 0 || slotID == 2) - { - return itemstack != null && itemstack.getItem() instanceof IGasItem && ((IGasItem)itemstack.getItem()).canReceiveGas(itemstack, null); - } - else if(slotID == 1) - { - return itemstack != null && itemstack.getItem() instanceof IGasItem && ((IGasItem)itemstack.getItem()).canProvideGas(itemstack, null); - } - else if(slotID == 3) - { - return ChargeUtils.canBeOutputted(itemstack, false); - } - - return false; - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) - { - if(side == MekanismUtils.getLeft(facing).ordinal()) - { - return new int[] {0}; - } - else if(side == facing) - { - return new int[] {1}; - } - else if(side == MekanismUtils.getRight(facing).ordinal()) - { - return new int[] {2}; - } - else if(side == 0 || side == 1) - { - return new int[3]; - } - - return InventoryUtils.EMPTY; - } - - @Override - public void writeSustainedData(ItemStack itemStack) - { - if(leftTank.getGas() != null) - { - itemStack.stackTagCompound.setTag("leftTank", leftTank.getGas().write(new NBTTagCompound())); - } - - if(rightTank.getGas() != null) - { - itemStack.stackTagCompound.setTag("rightTank", rightTank.getGas().write(new NBTTagCompound())); - } - - if(centerTank.getGas() != null) - { - itemStack.stackTagCompound.setTag("centerTank", centerTank.getGas().write(new NBTTagCompound())); - } - } - - @Override - public void readSustainedData(ItemStack itemStack) - { - leftTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("leftTank"))); - rightTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("rightTank"))); - centerTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("centerTank"))); - } - - @Override - public TileComponentUpgrade getComponent() - { - return upgradeComponent; - } - - @Override - public void recalculateUpgradables(Upgrade upgrade) - { - super.recalculateUpgradables(upgrade); - - switch(upgrade) - { - case ENERGY: - maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY); - energyPerTick = MekanismUtils.getBaseEnergyPerTick(this, BASE_ENERGY_USAGE); - default: - break; - } - } - - @Override - public List getInfo(Upgrade upgrade) - { - return upgrade == Upgrade.SPEED ? upgrade.getExpScaledInfo(this) : upgrade.getMultScaledInfo(this); - } - - @Override - public Object[] getTanks() - { - return new Object[] {leftTank, rightTank, centerTank}; - } - - @Override - public TileComponentSecurity getSecurity() - { - return securityComponent; - } +public class TileEntityChemicalInfuser extends TileEntityNoisyElectricBlock + implements IGasHandler, ITubeConnection, IRedstoneControl, ISustainedData, + IUpgradeTile, IUpgradeInfoHandler, ITankManager, ISecurityTile { + public GasTank leftTank = new GasTank(MAX_GAS); + public GasTank rightTank = new GasTank(MAX_GAS); + public GasTank centerTank = new GasTank(MAX_GAS); + + public static final int MAX_GAS = 10000; + + public int updateDelay; + + public int gasOutput = 256; + + public boolean isActive; + + public boolean clientActive; + + public double prevEnergy; + + public final double BASE_ENERGY_USAGE = usage.chemicalInfuserUsage; + + public double energyPerTick = BASE_ENERGY_USAGE; + + public ChemicalInfuserRecipe cachedRecipe; + + public double clientEnergyUsed; + + public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, 4); + public TileComponentSecurity securityComponent = new TileComponentSecurity(this); + + /** This machine's current RedstoneControl type. */ + public RedstoneControl controlType = RedstoneControl.DISABLED; + + public TileEntityChemicalInfuser() { + super( + "machine.cheminfuser", + "ChemicalInfuser", + MachineType.CHEMICAL_INFUSER.baseEnergy + ); + + inventory = new ItemStack[5]; + upgradeComponent.setSupported(Upgrade.MUFFLING); + } + + @Override + public void onUpdate() { + super.onUpdate(); + + if (worldObj.isRemote && updateDelay > 0) { + updateDelay--; + + if (updateDelay == 0 && clientActive != isActive) { + isActive = clientActive; + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } + + if (!worldObj.isRemote) { + if (updateDelay > 0) { + updateDelay--; + + if (updateDelay == 0 && clientActive != isActive) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + } + } + + ChargeUtils.discharge(3, this); + + if (inventory[0] != null + && (leftTank.getGas() == null + || leftTank.getStored() < leftTank.getMaxGas())) { + leftTank.receive( + GasTransmission.removeGas( + inventory[0], leftTank.getGasType(), leftTank.getNeeded() + ), + true + ); + } + + if (inventory[1] != null + && (rightTank.getGas() == null + || rightTank.getStored() < rightTank.getMaxGas())) { + rightTank.receive( + GasTransmission.removeGas( + inventory[1], rightTank.getGasType(), rightTank.getNeeded() + ), + true + ); + } + + if (inventory[2] != null && centerTank.getGas() != null) { + centerTank.draw( + GasTransmission.addGas(inventory[2], centerTank.getGas()), true + ); + } + + ChemicalInfuserRecipe recipe = getRecipe(); + + if (canOperate(recipe) && getEnergy() >= energyPerTick + && MekanismUtils.canFunction(this)) { + setActive(true); + + int operations = operate(recipe); + double prev = getEnergy(); + + setEnergy(getEnergy() - energyPerTick * operations); + clientEnergyUsed = prev - getEnergy(); + } else { + if (prevEnergy >= getEnergy()) { + setActive(false); + } + } + + if (centerTank.getGas() != null) { + GasStack toSend = new GasStack( + centerTank.getGas().getGas(), + Math.min(centerTank.getStored(), gasOutput) + ); + + TileEntity tileEntity + = Coord4D.get(this) + .getFromSide(ForgeDirection.getOrientation(facing)) + .getTileEntity(worldObj); + + if (tileEntity instanceof IGasHandler) { + if (((IGasHandler) tileEntity) + .canReceiveGas( + ForgeDirection.getOrientation(facing).getOpposite(), + centerTank.getGas().getGas() + )) { + centerTank.draw( + ((IGasHandler) tileEntity) + .receiveGas( + ForgeDirection.getOrientation(facing).getOpposite(), + toSend, + true + ), + true + ); + } + } + } + + prevEnergy = getEnergy(); + } + } + + public int getUpgradedUsage(ChemicalInfuserRecipe recipe) { + int possibleProcess + = (int) Math.pow(2, upgradeComponent.getUpgrades(Upgrade.SPEED)); + + if (leftTank.getGasType() == recipe.recipeInput.leftGas.getGas()) { + possibleProcess = Math.min( + leftTank.getStored() / recipe.recipeInput.leftGas.amount, possibleProcess + ); + possibleProcess = Math.min( + rightTank.getStored() / recipe.recipeInput.rightGas.amount, + possibleProcess + ); + } else { + possibleProcess = Math.min( + leftTank.getStored() / recipe.recipeInput.rightGas.amount, possibleProcess + ); + possibleProcess = Math.min( + rightTank.getStored() / recipe.recipeInput.leftGas.amount, possibleProcess + ); + } + + possibleProcess = Math.min( + centerTank.getNeeded() / recipe.recipeOutput.output.amount, possibleProcess + ); + possibleProcess = Math.min((int) (getEnergy() / energyPerTick), possibleProcess); + + return possibleProcess; + } + + public ChemicalPairInput getInput() { + return new ChemicalPairInput(leftTank.getGas(), rightTank.getGas()); + } + + public ChemicalInfuserRecipe getRecipe() { + ChemicalPairInput input = getInput(); + + if (cachedRecipe == null || !input.testEquality(cachedRecipe.getInput())) { + cachedRecipe = RecipeHandler.getChemicalInfuserRecipe(getInput()); + } + + return cachedRecipe; + } + + public boolean canOperate(ChemicalInfuserRecipe recipe) { + return recipe != null && recipe.canOperate(leftTank, rightTank, centerTank); + } + + public int operate(ChemicalInfuserRecipe recipe) { + int operations = getUpgradedUsage(recipe); + + recipe.operate(leftTank, rightTank, centerTank, operations); + + markDirty(); + + return operations; + } + + @Override + public void handlePacketData(ByteBuf dataStream) { + super.handlePacketData(dataStream); + + if (worldObj.isRemote) { + isActive = dataStream.readBoolean(); + controlType = RedstoneControl.values()[dataStream.readInt()]; + clientEnergyUsed = dataStream.readDouble(); + + if (dataStream.readBoolean()) { + leftTank.setGas(new GasStack( + GasRegistry.getGas(dataStream.readInt()), dataStream.readInt() + )); + } else { + leftTank.setGas(null); + } + + if (dataStream.readBoolean()) { + rightTank.setGas(new GasStack( + GasRegistry.getGas(dataStream.readInt()), dataStream.readInt() + )); + } else { + rightTank.setGas(null); + } + + if (dataStream.readBoolean()) { + centerTank.setGas(new GasStack( + GasRegistry.getGas(dataStream.readInt()), dataStream.readInt() + )); + } else { + centerTank.setGas(null); + } + + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } + + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); + + data.add(isActive); + data.add(controlType.ordinal()); + data.add(clientEnergyUsed); + + if (leftTank.getGas() != null) { + data.add(true); + data.add(leftTank.getGas().getGas().getID()); + data.add(leftTank.getStored()); + } else { + data.add(false); + } + + if (rightTank.getGas() != null) { + data.add(true); + data.add(rightTank.getGas().getGas().getID()); + data.add(rightTank.getStored()); + } else { + data.add(false); + } + + if (centerTank.getGas() != null) { + data.add(true); + data.add(centerTank.getGas().getGas().getID()); + data.add(centerTank.getStored()); + } else { + data.add(false); + } + + return data; + } + + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); + + isActive = nbtTags.getBoolean("isActive"); + controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + + leftTank.read(nbtTags.getCompoundTag("leftTank")); + rightTank.read(nbtTags.getCompoundTag("rightTank")); + centerTank.read(nbtTags.getCompoundTag("centerTank")); + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); + + nbtTags.setBoolean("isActive", isActive); + nbtTags.setInteger("controlType", controlType.ordinal()); + + nbtTags.setTag("leftTank", leftTank.write(new NBTTagCompound())); + nbtTags.setTag("rightTank", rightTank.write(new NBTTagCompound())); + nbtTags.setTag("centerTank", centerTank.write(new NBTTagCompound())); + } + + @Override + public boolean canSetFacing(int i) { + return i != 0 && i != 1; + } + + public GasTank getTank(ForgeDirection side) { + if (side == MekanismUtils.getLeft(facing)) { + return leftTank; + } else if (side == MekanismUtils.getRight(facing)) { + return rightTank; + } else if (side == ForgeDirection.getOrientation(facing)) { + return centerTank; + } + + return null; + } + + @Override + public void setActive(boolean active) { + isActive = active; + + if (clientActive != active && updateDelay == 0) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + + updateDelay = 10; + clientActive = active; + } + } + + @Override + public boolean getActive() { + return isActive; + } + + @Override + public boolean renderUpdate() { + return false; + } + + @Override + public boolean lightUpdate() { + return true; + } + + @Override + public boolean canTubeConnect(ForgeDirection side) { + return side == MekanismUtils.getLeft(facing) + || side == MekanismUtils.getRight(facing) + || side == ForgeDirection.getOrientation(facing); + } + + @Override + public boolean canReceiveGas(ForgeDirection side, Gas type) { + return getTank(side) != null && getTank(side) != centerTank + ? getTank(side).canReceive(type) + : false; + } + + @Override + public RedstoneControl getControlType() { + return controlType; + } + + @Override + public void setControlType(RedstoneControl type) { + controlType = type; + MekanismUtils.saveChunk(this); + } + + @Override + public boolean canPulse() { + return false; + } + + @Override + public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) { + if (canReceiveGas(side, stack != null ? stack.getGas() : null)) { + return getTank(side).receive(stack, doTransfer); + } + + return 0; + } + + @Override + public int receiveGas(ForgeDirection side, GasStack stack) { + return receiveGas(side, stack, true); + } + + @Override + public GasStack drawGas(ForgeDirection side, int amount, boolean doTransfer) { + if (canDrawGas(side, null)) { + return getTank(side).draw(amount, doTransfer); + } + + return null; + } + + @Override + public GasStack drawGas(ForgeDirection side, int amount) { + return drawGas(side, amount, true); + } + + @Override + public boolean canDrawGas(ForgeDirection side, Gas type) { + return getTank(side) != null && getTank(side) == centerTank + ? getTank(side).canDraw(type) + : false; + } + + @Override + public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { + if (slotID == 3) { + return ChargeUtils.canBeDischarged(itemstack); + } + + return false; + } + + @Override + public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { + if (slotID == 0 || slotID == 2) { + return itemstack != null && itemstack.getItem() instanceof IGasItem + && ((IGasItem) itemstack.getItem()).canReceiveGas(itemstack, null); + } else if (slotID == 1) { + return itemstack != null && itemstack.getItem() instanceof IGasItem + && ((IGasItem) itemstack.getItem()).canProvideGas(itemstack, null); + } else if (slotID == 3) { + return ChargeUtils.canBeOutputted(itemstack, false); + } + + return false; + } + + @Override + public int[] getAccessibleSlotsFromSide(int side) { + if (side == MekanismUtils.getLeft(facing).ordinal()) { + return new int[] { 0 }; + } else if (side == facing) { + return new int[] { 1 }; + } else if (side == MekanismUtils.getRight(facing).ordinal()) { + return new int[] { 2 }; + } else if (side == 0 || side == 1) { + return new int[3]; + } + + return InventoryUtils.EMPTY; + } + + @Override + public void writeSustainedData(ItemStack itemStack) { + if (leftTank.getGas() != null) { + itemStack.stackTagCompound.setTag( + "leftTank", leftTank.getGas().write(new NBTTagCompound()) + ); + } + + if (rightTank.getGas() != null) { + itemStack.stackTagCompound.setTag( + "rightTank", rightTank.getGas().write(new NBTTagCompound()) + ); + } + + if (centerTank.getGas() != null) { + itemStack.stackTagCompound.setTag( + "centerTank", centerTank.getGas().write(new NBTTagCompound()) + ); + } + } + + @Override + public void readSustainedData(ItemStack itemStack) { + leftTank.setGas( + GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("leftTank")) + ); + rightTank.setGas( + GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("rightTank")) + ); + centerTank.setGas( + GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("centerTank")) + ); + } + + @Override + public TileComponentUpgrade getComponent() { + return upgradeComponent; + } + + @Override + public void recalculateUpgradables(Upgrade upgrade) { + super.recalculateUpgradables(upgrade); + + switch (upgrade) { + case ENERGY: + maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY); + energyPerTick + = MekanismUtils.getBaseEnergyPerTick(this, BASE_ENERGY_USAGE); + default: + break; + } + } + + @Override + public List getInfo(Upgrade upgrade) { + return upgrade == Upgrade.SPEED ? upgrade.getExpScaledInfo(this) + : upgrade.getMultScaledInfo(this); + } + + @Override + public Object[] getTanks() { + return new Object[] { leftTank, rightTank, centerTank }; + } + + @Override + public TileComponentSecurity getSecurity() { + return securityComponent; + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalInjectionChamber.java b/src/main/java/mekanism/common/tile/TileEntityChemicalInjectionChamber.java index 2013c7a01..4b6174349 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalInjectionChamber.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalInjectionChamber.java @@ -21,98 +21,107 @@ import net.minecraft.block.Block; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityChemicalInjectionChamber extends TileEntityAdvancedElectricMachine -{ - public TileEntityChemicalInjectionChamber() - { - super("injection", "ChemicalInjectionChamber", usage.chemicalInjectionChamberUsage, 1, 200, MachineType.CHEMICAL_INJECTION_CHAMBER.baseEnergy); - - configComponent.addSupported(TransmissionType.GAS); - configComponent.addOutput(TransmissionType.GAS, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY)); - configComponent.addOutput(TransmissionType.GAS, new SideData("Gas", EnumColor.DARK_RED, new int[] {0})); - configComponent.fillConfig(TransmissionType.GAS, 1); - configComponent.setCanEject(TransmissionType.GAS, false); - } +public class TileEntityChemicalInjectionChamber + extends TileEntityAdvancedElectricMachine { + public TileEntityChemicalInjectionChamber() { + super( + "injection", + "ChemicalInjectionChamber", + usage.chemicalInjectionChamberUsage, + 1, + 200, + MachineType.CHEMICAL_INJECTION_CHAMBER.baseEnergy + ); - @Override - public Map getRecipes() - { - return Recipe.CHEMICAL_INJECTION_CHAMBER.get(); - } + configComponent.addSupported(TransmissionType.GAS); + configComponent.addOutput( + TransmissionType.GAS, + new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY) + ); + configComponent.addOutput( + TransmissionType.GAS, new SideData("Gas", EnumColor.DARK_RED, new int[] { 0 }) + ); + configComponent.fillConfig(TransmissionType.GAS, 1); + configComponent.setCanEject(TransmissionType.GAS, false); + } - @Override - public GasStack getItemGas(ItemStack itemstack) - { - if(MekanismUtils.getOreDictName(itemstack).contains("dustSulfur")) return new GasStack(GasRegistry.getGas("sulfuricAcid"), 2); - if(MekanismUtils.getOreDictName(itemstack).contains("dustSalt")) return new GasStack(GasRegistry.getGas("hydrogenChloride"), 2); - if(Block.getBlockFromItem(itemstack.getItem()) == MekanismBlocks.GasTank && ((IGasItem)itemstack.getItem()).getGas(itemstack) != null && - isValidGas(((IGasItem)itemstack.getItem()).getGas(itemstack).getGas())) return new GasStack(GasRegistry.getGas("sulfuricAcid"), 1); + @Override + public Map getRecipes() { + return Recipe.CHEMICAL_INJECTION_CHAMBER.get(); + } - return null; - } + @Override + public GasStack getItemGas(ItemStack itemstack) { + if (MekanismUtils.getOreDictName(itemstack).contains("dustSulfur")) + return new GasStack(GasRegistry.getGas("sulfuricAcid"), 2); + if (MekanismUtils.getOreDictName(itemstack).contains("dustSalt")) + return new GasStack(GasRegistry.getGas("hydrogenChloride"), 2); + if (Block.getBlockFromItem(itemstack.getItem()) == MekanismBlocks.GasTank + && ((IGasItem) itemstack.getItem()).getGas(itemstack) != null + && isValidGas(((IGasItem) itemstack.getItem()).getGas(itemstack).getGas())) + return new GasStack(GasRegistry.getGas("sulfuricAcid"), 1); - @Override - public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) - { - if(canReceiveGas(side, stack.getGas())) - { - return gasTank.receive(stack, doTransfer); - } + return null; + } - return 0; - } + @Override + public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) { + if (canReceiveGas(side, stack.getGas())) { + return gasTank.receive(stack, doTransfer); + } - @Override - public boolean canReceiveGas(ForgeDirection side, Gas type) - { - if(configComponent.getOutput(TransmissionType.GAS, side.ordinal(), facing).hasSlot(0)) - { - return isValidGas(type); - } - - return false; - } + return 0; + } - @Override - public void handleSecondaryFuel() - { - if(inventory[1] != null && gasTank.getNeeded() > 0 && inventory[1].getItem() instanceof IGasItem) - { - GasStack gas = ((IGasItem)inventory[1].getItem()).getGas(inventory[1]); + @Override + public boolean canReceiveGas(ForgeDirection side, Gas type) { + if (configComponent.getOutput(TransmissionType.GAS, side.ordinal(), facing) + .hasSlot(0)) { + return isValidGas(type); + } - if(gas != null && isValidGas(gas.getGas())) - { - GasStack removed = GasTransmission.removeGas(inventory[1], gasTank.getGasType(), gasTank.getNeeded()); - gasTank.receive(removed, true); - } + return false; + } - return; - } + @Override + public void handleSecondaryFuel() { + if (inventory[1] != null && gasTank.getNeeded() > 0 + && inventory[1].getItem() instanceof IGasItem) { + GasStack gas = ((IGasItem) inventory[1].getItem()).getGas(inventory[1]); - super.handleSecondaryFuel(); - } + if (gas != null && isValidGas(gas.getGas())) { + GasStack removed = GasTransmission.removeGas( + inventory[1], gasTank.getGasType(), gasTank.getNeeded() + ); + gasTank.receive(removed, true); + } - @Override - public boolean canTubeConnect(ForgeDirection side) - { - return configComponent.getOutput(TransmissionType.GAS, side.ordinal(), facing).hasSlot(0); - } + return; + } - @Override - public boolean isValidGas(Gas gas) - { - return gas == GasRegistry.getGas("sulfuricAcid") || gas == GasRegistry.getGas("water") || gas == GasRegistry.getGas("hydrogenChloride"); - } + super.handleSecondaryFuel(); + } - @Override - public boolean upgradeableSecondaryEfficiency() - { - return true; - } + @Override + public boolean canTubeConnect(ForgeDirection side) { + return configComponent.getOutput(TransmissionType.GAS, side.ordinal(), facing) + .hasSlot(0); + } - @Override - public boolean useStatisticalMechanics() - { - return true; - } + @Override + public boolean isValidGas(Gas gas) { + return gas == GasRegistry.getGas("sulfuricAcid") + || gas == GasRegistry.getGas("water") + || gas == GasRegistry.getGas("hydrogenChloride"); + } + + @Override + public boolean upgradeableSecondaryEfficiency() { + return true; + } + + @Override + public boolean useStatisticalMechanics() { + return true; + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalOxidizer.java b/src/main/java/mekanism/common/tile/TileEntityChemicalOxidizer.java index 1d436973f..97ec814a5 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalOxidizer.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalOxidizer.java @@ -1,9 +1,8 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.MekanismConfig.usage; import mekanism.api.Range4D; @@ -36,382 +35,362 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityChemicalOxidizer extends TileEntityNoisyElectricBlock implements ITubeConnection, IRedstoneControl, IUpgradeTile, ISustainedData, ITankManager, ISecurityTile -{ - public GasTank gasTank = new GasTank(MAX_GAS); +public class TileEntityChemicalOxidizer extends TileEntityNoisyElectricBlock + implements ITubeConnection, IRedstoneControl, IUpgradeTile, ISustainedData, + ITankManager, ISecurityTile { + public GasTank gasTank = new GasTank(MAX_GAS); - public static final int MAX_GAS = 10000; + public static final int MAX_GAS = 10000; - public int updateDelay; + public int updateDelay; - public int gasOutput = 256; + public int gasOutput = 256; - public boolean isActive; + public boolean isActive; - public boolean clientActive; + public boolean clientActive; - public double prevEnergy; + public double prevEnergy; - public int operatingTicks = 0; + public int operatingTicks = 0; - public int BASE_TICKS_REQUIRED = 100; + public int BASE_TICKS_REQUIRED = 100; - public int ticksRequired = BASE_TICKS_REQUIRED; + public int ticksRequired = BASE_TICKS_REQUIRED; - public final double BASE_ENERGY_USAGE = usage.rotaryCondensentratorUsage; + public final double BASE_ENERGY_USAGE = usage.rotaryCondensentratorUsage; - public double energyUsage = BASE_ENERGY_USAGE; + public double energyUsage = BASE_ENERGY_USAGE; - public OxidationRecipe cachedRecipe; + public OxidationRecipe cachedRecipe; - public RedstoneControl controlType = RedstoneControl.DISABLED; - - public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, 3); - public TileComponentSecurity securityComponent = new TileComponentSecurity(this); + public RedstoneControl controlType = RedstoneControl.DISABLED; - public TileEntityChemicalOxidizer() - { - super("machine.oxidizer", "ChemicalOxidizer", MachineType.CHEMICAL_OXIDIZER.baseEnergy); - - inventory = new ItemStack[4]; - upgradeComponent.setSupported(Upgrade.MUFFLING); - } + public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, 3); + public TileComponentSecurity securityComponent = new TileComponentSecurity(this); - @Override - public void onUpdate() - { - super.onUpdate(); - - if(worldObj.isRemote && updateDelay > 0) - { - updateDelay--; + public TileEntityChemicalOxidizer() { + super( + "machine.oxidizer", + "ChemicalOxidizer", + MachineType.CHEMICAL_OXIDIZER.baseEnergy + ); - if(updateDelay == 0 && clientActive != isActive) - { - isActive = clientActive; - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } + inventory = new ItemStack[4]; + upgradeComponent.setSupported(Upgrade.MUFFLING); + } - if(!worldObj.isRemote) - { - if(updateDelay > 0) - { - updateDelay--; + @Override + public void onUpdate() { + super.onUpdate(); - if(updateDelay == 0 && clientActive != isActive) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - } - } + if (worldObj.isRemote && updateDelay > 0) { + updateDelay--; - ChargeUtils.discharge(1, this); + if (updateDelay == 0 && clientActive != isActive) { + isActive = clientActive; + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } - if(inventory[2] != null && gasTank.getGas() != null) - { - gasTank.draw(GasTransmission.addGas(inventory[2], gasTank.getGas()), true); - } - - OxidationRecipe recipe = getRecipe(); + if (!worldObj.isRemote) { + if (updateDelay > 0) { + updateDelay--; - if(canOperate(recipe) && getEnergy() >= energyUsage && MekanismUtils.canFunction(this)) - { - setActive(true); - setEnergy(getEnergy() - energyUsage); + if (updateDelay == 0 && clientActive != isActive) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + } + } - if(operatingTicks < ticksRequired) - { - operatingTicks++; - } - else { - operate(recipe); + ChargeUtils.discharge(1, this); - operatingTicks = 0; - markDirty(); - } - } - else { - if(prevEnergy >= getEnergy()) - { - setActive(false); - } - } + if (inventory[2] != null && gasTank.getGas() != null) { + gasTank.draw( + GasTransmission.addGas(inventory[2], gasTank.getGas()), true + ); + } - prevEnergy = getEnergy(); + OxidationRecipe recipe = getRecipe(); - if(gasTank.getGas() != null) - { - GasStack toSend = new GasStack(gasTank.getGas().getGas(), Math.min(gasTank.getStored(), gasOutput)); + if (canOperate(recipe) && getEnergy() >= energyUsage + && MekanismUtils.canFunction(this)) { + setActive(true); + setEnergy(getEnergy() - energyUsage); - TileEntity tileEntity = Coord4D.get(this).getFromSide(MekanismUtils.getRight(facing)).getTileEntity(worldObj); + if (operatingTicks < ticksRequired) { + operatingTicks++; + } else { + operate(recipe); - if(tileEntity instanceof IGasHandler) - { - if(((IGasHandler)tileEntity).canReceiveGas(MekanismUtils.getRight(facing).getOpposite(), gasTank.getGas().getGas())) - { - gasTank.draw(((IGasHandler)tileEntity).receiveGas(MekanismUtils.getRight(facing).getOpposite(), toSend, true), true); - } - } - } - } - } + operatingTicks = 0; + markDirty(); + } + } else { + if (prevEnergy >= getEnergy()) { + setActive(false); + } + } - @Override - public boolean isItemValidForSlot(int slotID, ItemStack itemstack) - { - if(slotID == 0) - { - return RecipeHandler.getOxidizerRecipe(new ItemStackInput(itemstack)) != null; - } - else if(slotID == 1) - { - return ChargeUtils.canBeDischarged(itemstack); - } + prevEnergy = getEnergy(); - return false; - } + if (gasTank.getGas() != null) { + GasStack toSend = new GasStack( + gasTank.getGas().getGas(), Math.min(gasTank.getStored(), gasOutput) + ); - @Override - public boolean canExtractItem(int slotID, ItemStack itemstack, int side) - { - if(slotID == 2) - { - return itemstack != null && itemstack.getItem() instanceof IGasItem && ((IGasItem)itemstack.getItem()).canProvideGas(itemstack, null); - } + TileEntity tileEntity = Coord4D.get(this) + .getFromSide(MekanismUtils.getRight(facing)) + .getTileEntity(worldObj); - return false; - } + if (tileEntity instanceof IGasHandler) { + if (((IGasHandler) tileEntity) + .canReceiveGas( + MekanismUtils.getRight(facing).getOpposite(), + gasTank.getGas().getGas() + )) { + gasTank.draw( + ((IGasHandler) tileEntity) + .receiveGas( + MekanismUtils.getRight(facing).getOpposite(), + toSend, + true + ), + true + ); + } + } + } + } + } - @Override - public int[] getAccessibleSlotsFromSide(int side) - { - if(side == MekanismUtils.getLeft(facing).ordinal()) - { - return new int[] {0}; - } - else if(side == 0 || side == 1) - { - return new int[] {1}; - } - else if(side == MekanismUtils.getRight(facing).ordinal()) - { - return new int[] {2}; - } + @Override + public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { + if (slotID == 0) { + return RecipeHandler.getOxidizerRecipe(new ItemStackInput(itemstack)) != null; + } else if (slotID == 1) { + return ChargeUtils.canBeDischarged(itemstack); + } - return InventoryUtils.EMPTY; - } + return false; + } - public double getScaledProgress() - { - return ((double)operatingTicks) / ((double)ticksRequired); - } + @Override + public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { + if (slotID == 2) { + return itemstack != null && itemstack.getItem() instanceof IGasItem + && ((IGasItem) itemstack.getItem()).canProvideGas(itemstack, null); + } - public OxidationRecipe getRecipe() - { - ItemStackInput input = getInput(); - - if(cachedRecipe == null || !input.testEquality(cachedRecipe.getInput())) - { - cachedRecipe = RecipeHandler.getOxidizerRecipe(getInput()); - } - - return cachedRecipe; - } + return false; + } - public ItemStackInput getInput() - { - return new ItemStackInput(inventory[0]); - } + @Override + public int[] getAccessibleSlotsFromSide(int side) { + if (side == MekanismUtils.getLeft(facing).ordinal()) { + return new int[] { 0 }; + } else if (side == 0 || side == 1) { + return new int[] { 1 }; + } else if (side == MekanismUtils.getRight(facing).ordinal()) { + return new int[] { 2 }; + } - public boolean canOperate(OxidationRecipe recipe) - { - return recipe != null && recipe.canOperate(inventory, gasTank); - } + return InventoryUtils.EMPTY; + } - public void operate(OxidationRecipe recipe) - { - recipe.operate(inventory, gasTank); + public double getScaledProgress() { + return ((double) operatingTicks) / ((double) ticksRequired); + } - markDirty(); - } + public OxidationRecipe getRecipe() { + ItemStackInput input = getInput(); - @Override - public void handlePacketData(ByteBuf dataStream) - { - super.handlePacketData(dataStream); + if (cachedRecipe == null || !input.testEquality(cachedRecipe.getInput())) { + cachedRecipe = RecipeHandler.getOxidizerRecipe(getInput()); + } - if(worldObj.isRemote) - { - isActive = dataStream.readBoolean(); - controlType = RedstoneControl.values()[dataStream.readInt()]; - operatingTicks = dataStream.readInt(); - - if(dataStream.readBoolean()) - { - gasTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt())); - } - else { - gasTank.setGas(null); - } - - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } + return cachedRecipe; + } - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); + public ItemStackInput getInput() { + return new ItemStackInput(inventory[0]); + } - data.add(isActive); - data.add(controlType.ordinal()); - data.add(operatingTicks); + public boolean canOperate(OxidationRecipe recipe) { + return recipe != null && recipe.canOperate(inventory, gasTank); + } - if(gasTank.getGas() != null) - { - data.add(true); - data.add(gasTank.getGas().getGas().getID()); - data.add(gasTank.getStored()); - } - else { - data.add(false); - } + public void operate(OxidationRecipe recipe) { + recipe.operate(inventory, gasTank); - return data; - } + markDirty(); + } - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); + @Override + public void handlePacketData(ByteBuf dataStream) { + super.handlePacketData(dataStream); - isActive = nbtTags.getBoolean("isActive"); - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - operatingTicks = nbtTags.getInteger("operatingTicks"); - gasTank.read(nbtTags.getCompoundTag("gasTank")); - } + if (worldObj.isRemote) { + isActive = dataStream.readBoolean(); + controlType = RedstoneControl.values()[dataStream.readInt()]; + operatingTicks = dataStream.readInt(); - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); + if (dataStream.readBoolean()) { + gasTank.setGas(new GasStack( + GasRegistry.getGas(dataStream.readInt()), dataStream.readInt() + )); + } else { + gasTank.setGas(null); + } - nbtTags.setBoolean("isActive", isActive); - nbtTags.setInteger("controlType", controlType.ordinal()); - nbtTags.setInteger("operatingTicks", operatingTicks); - nbtTags.setTag("gasTank", gasTank.write(new NBTTagCompound())); - } + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } - @Override - public boolean canSetFacing(int i) - { - return i != 0 && i != 1; - } - - @Override - public void setActive(boolean active) - { - isActive = active; + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); - if(clientActive != active && updateDelay == 0) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); + data.add(isActive); + data.add(controlType.ordinal()); + data.add(operatingTicks); - updateDelay = 10; - clientActive = active; - } - } + if (gasTank.getGas() != null) { + data.add(true); + data.add(gasTank.getGas().getGas().getID()); + data.add(gasTank.getStored()); + } else { + data.add(false); + } - @Override - public boolean getActive() - { - return isActive; - } + return data; + } - @Override - public boolean renderUpdate() - { - return false; - } + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); - @Override - public boolean lightUpdate() - { - return true; - } + isActive = nbtTags.getBoolean("isActive"); + controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + operatingTicks = nbtTags.getInteger("operatingTicks"); + gasTank.read(nbtTags.getCompoundTag("gasTank")); + } - @Override - public boolean canTubeConnect(ForgeDirection side) - { - return side == MekanismUtils.getRight(facing); - } + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); - @Override - public RedstoneControl getControlType() - { - return controlType; - } + nbtTags.setBoolean("isActive", isActive); + nbtTags.setInteger("controlType", controlType.ordinal()); + nbtTags.setInteger("operatingTicks", operatingTicks); + nbtTags.setTag("gasTank", gasTank.write(new NBTTagCompound())); + } - @Override - public void setControlType(RedstoneControl type) - { - controlType = type; - MekanismUtils.saveChunk(this); - } + @Override + public boolean canSetFacing(int i) { + return i != 0 && i != 1; + } - @Override - public boolean canPulse() - { - return false; - } + @Override + public void setActive(boolean active) { + isActive = active; - @Override - public TileComponentUpgrade getComponent() - { - return upgradeComponent; - } + if (clientActive != active && updateDelay == 0) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); - @Override - public void writeSustainedData(ItemStack itemStack) - { - if(gasTank.getGas() != null) - { - itemStack.stackTagCompound.setTag("gasTank", gasTank.getGas().write(new NBTTagCompound())); - } - } + updateDelay = 10; + clientActive = active; + } + } - @Override - public void readSustainedData(ItemStack itemStack) - { - gasTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("gasTank"))); - } + @Override + public boolean getActive() { + return isActive; + } - @Override - public void recalculateUpgradables(Upgrade upgrade) - { - super.recalculateUpgradables(upgrade); + @Override + public boolean renderUpdate() { + return false; + } - switch(upgrade) - { - case SPEED: - ticksRequired = MekanismUtils.getTicks(this, BASE_TICKS_REQUIRED); - case ENERGY: - energyUsage = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_USAGE); - maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY); - default: - break; - } - } - - @Override - public Object[] getTanks() - { - return new Object[] {gasTank}; - } - - @Override - public TileComponentSecurity getSecurity() - { - return securityComponent; - } + @Override + public boolean lightUpdate() { + return true; + } + + @Override + public boolean canTubeConnect(ForgeDirection side) { + return side == MekanismUtils.getRight(facing); + } + + @Override + public RedstoneControl getControlType() { + return controlType; + } + + @Override + public void setControlType(RedstoneControl type) { + controlType = type; + MekanismUtils.saveChunk(this); + } + + @Override + public boolean canPulse() { + return false; + } + + @Override + public TileComponentUpgrade getComponent() { + return upgradeComponent; + } + + @Override + public void writeSustainedData(ItemStack itemStack) { + if (gasTank.getGas() != null) { + itemStack.stackTagCompound.setTag( + "gasTank", gasTank.getGas().write(new NBTTagCompound()) + ); + } + } + + @Override + public void readSustainedData(ItemStack itemStack) { + gasTank.setGas( + GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("gasTank")) + ); + } + + @Override + public void recalculateUpgradables(Upgrade upgrade) { + super.recalculateUpgradables(upgrade); + + switch (upgrade) { + case SPEED: + ticksRequired = MekanismUtils.getTicks(this, BASE_TICKS_REQUIRED); + case ENERGY: + energyUsage = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_USAGE); + maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY); + default: + break; + } + } + + @Override + public Object[] getTanks() { + return new Object[] { gasTank }; + } + + @Override + public TileComponentSecurity getSecurity() { + return securityComponent; + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityChemicalWasher.java b/src/main/java/mekanism/common/tile/TileEntityChemicalWasher.java index dcadafcc8..c3688ea26 100644 --- a/src/main/java/mekanism/common/tile/TileEntityChemicalWasher.java +++ b/src/main/java/mekanism/common/tile/TileEntityChemicalWasher.java @@ -1,10 +1,9 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.List; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.MekanismConfig.usage; import mekanism.api.Range4D; @@ -50,571 +49,536 @@ import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidContainerItem; import net.minecraftforge.fluids.IFluidHandler; -public class TileEntityChemicalWasher extends TileEntityNoisyElectricBlock implements IGasHandler, ITubeConnection, IRedstoneControl, IFluidHandler, IUpgradeTile, ISustainedData, IUpgradeInfoHandler, ITankManager, ISecurityTile -{ - public FluidTank fluidTank = new FluidTank(MAX_FLUID); - public GasTank inputTank = new GasTank(MAX_GAS); - public GasTank outputTank = new GasTank(MAX_GAS); +public class TileEntityChemicalWasher extends TileEntityNoisyElectricBlock + implements IGasHandler, ITubeConnection, IRedstoneControl, IFluidHandler, + IUpgradeTile, ISustainedData, IUpgradeInfoHandler, ITankManager, + ISecurityTile { + public FluidTank fluidTank = new FluidTank(MAX_FLUID); + public GasTank inputTank = new GasTank(MAX_GAS); + public GasTank outputTank = new GasTank(MAX_GAS); - public static final int MAX_GAS = 10000; - public static final int MAX_FLUID = 10000; + public static final int MAX_GAS = 10000; + public static final int MAX_FLUID = 10000; - public static int WATER_USAGE = 5; + public static int WATER_USAGE = 5; - public int updateDelay; + public int updateDelay; - public int gasOutput = 256; + public int gasOutput = 256; - public boolean isActive; + public boolean isActive; - public boolean clientActive; + public boolean clientActive; - public double prevEnergy; + public double prevEnergy; - public final double BASE_ENERGY_USAGE = usage.chemicalWasherUsage; - - public double energyPerTick = BASE_ENERGY_USAGE; + public final double BASE_ENERGY_USAGE = usage.chemicalWasherUsage; - public WasherRecipe cachedRecipe; - - public double clientEnergyUsed; - - public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, 4); - public TileComponentSecurity securityComponent = new TileComponentSecurity(this); + public double energyPerTick = BASE_ENERGY_USAGE; - /** This machine's current RedstoneControl type. */ - public RedstoneControl controlType = RedstoneControl.DISABLED; + public WasherRecipe cachedRecipe; - public TileEntityChemicalWasher() - { - super("machine.washer", "ChemicalWasher", MachineType.CHEMICAL_WASHER.baseEnergy); - - inventory = new ItemStack[5]; - upgradeComponent.setSupported(Upgrade.MUFFLING); - } + public double clientEnergyUsed; - @Override - public void onUpdate() - { - super.onUpdate(); - - if(worldObj.isRemote && updateDelay > 0) - { - updateDelay--; + public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, 4); + public TileComponentSecurity securityComponent = new TileComponentSecurity(this); - if(updateDelay == 0 && clientActive != isActive) - { - isActive = clientActive; - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } + /** This machine's current RedstoneControl type. */ + public RedstoneControl controlType = RedstoneControl.DISABLED; - if(!worldObj.isRemote) - { - if(updateDelay > 0) - { - updateDelay--; + public TileEntityChemicalWasher() { + super("machine.washer", "ChemicalWasher", MachineType.CHEMICAL_WASHER.baseEnergy); - if(updateDelay == 0 && clientActive != isActive) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - } - } + inventory = new ItemStack[5]; + upgradeComponent.setSupported(Upgrade.MUFFLING); + } - ChargeUtils.discharge(3, this); - manageBuckets(); + @Override + public void onUpdate() { + super.onUpdate(); - if(inventory[2] != null && outputTank.getGas() != null) - { - outputTank.draw(GasTransmission.addGas(inventory[2], outputTank.getGas()), true); - } - - WasherRecipe recipe = getRecipe(); + if (worldObj.isRemote && updateDelay > 0) { + updateDelay--; - if(canOperate(recipe) && getEnergy() >= energyPerTick && MekanismUtils.canFunction(this)) - { - setActive(true); + if (updateDelay == 0 && clientActive != isActive) { + isActive = clientActive; + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } - int operations = operate(recipe); - double prev = getEnergy(); + if (!worldObj.isRemote) { + if (updateDelay > 0) { + updateDelay--; - setEnergy(getEnergy() - energyPerTick*operations); - clientEnergyUsed = prev-getEnergy(); - } - else { - if(prevEnergy >= getEnergy()) - { - setActive(false); - } - } + if (updateDelay == 0 && clientActive != isActive) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + } + } - if(outputTank.getGas() != null) - { - GasStack toSend = new GasStack(outputTank.getGas().getGas(), Math.min(outputTank.getStored(), gasOutput)); + ChargeUtils.discharge(3, this); + manageBuckets(); - TileEntity tileEntity = Coord4D.get(this).getFromSide(MekanismUtils.getRight(facing)).getTileEntity(worldObj); + if (inventory[2] != null && outputTank.getGas() != null) { + outputTank.draw( + GasTransmission.addGas(inventory[2], outputTank.getGas()), true + ); + } - if(tileEntity instanceof IGasHandler) - { - if(((IGasHandler)tileEntity).canReceiveGas(MekanismUtils.getRight(facing).getOpposite(), outputTank.getGas().getGas())) - { - outputTank.draw(((IGasHandler)tileEntity).receiveGas(MekanismUtils.getRight(facing).getOpposite(), toSend, true), true); - } - } - } + WasherRecipe recipe = getRecipe(); - prevEnergy = getEnergy(); - } - } + if (canOperate(recipe) && getEnergy() >= energyPerTick + && MekanismUtils.canFunction(this)) { + setActive(true); - public WasherRecipe getRecipe() - { - GasInput input = getInput(); - - if(cachedRecipe == null || !input.testEquality(cachedRecipe.getInput())) - { - cachedRecipe = RecipeHandler.getChemicalWasherRecipe(getInput()); - } - - return cachedRecipe; - } + int operations = operate(recipe); + double prev = getEnergy(); - public GasInput getInput() - { - return new GasInput(inputTank.getGas()); - } + setEnergy(getEnergy() - energyPerTick * operations); + clientEnergyUsed = prev - getEnergy(); + } else { + if (prevEnergy >= getEnergy()) { + setActive(false); + } + } - public boolean canOperate(WasherRecipe recipe) - { - return recipe != null && recipe.canOperate(inputTank, fluidTank, outputTank); - } + if (outputTank.getGas() != null) { + GasStack toSend = new GasStack( + outputTank.getGas().getGas(), + Math.min(outputTank.getStored(), gasOutput) + ); - public int operate(WasherRecipe recipe) - { - int operations = getUpgradedUsage(); - - recipe.operate(inputTank, fluidTank, outputTank, operations); - - return operations; - } + TileEntity tileEntity = Coord4D.get(this) + .getFromSide(MekanismUtils.getRight(facing)) + .getTileEntity(worldObj); - private void manageBuckets() - { - if(inventory[0] != null) - { - if(inventory[0].getItem() instanceof IFluidContainerItem) - { - FluidContainerUtils.handleContainerItemEmpty(this, fluidTank, 0, 1, FluidChecker.check(FluidRegistry.WATER)); - } - else if(FluidContainerRegistry.isFilledContainer(inventory[0])) - { - FluidContainerUtils.handleRegistryItemEmpty(this, fluidTank, 0, 1, FluidChecker.check(FluidRegistry.WATER)); - } - } - } - - public int getUpgradedUsage() - { - int possibleProcess = (int)Math.pow(2, upgradeComponent.getUpgrades(Upgrade.SPEED)); - possibleProcess = Math.min(Math.min(inputTank.getStored(), outputTank.getNeeded()), possibleProcess); - possibleProcess = Math.min((int)(getEnergy()/energyPerTick), possibleProcess); - - return Math.min(fluidTank.getFluidAmount()/WATER_USAGE, possibleProcess); - } - - @Override - public void handlePacketData(ByteBuf dataStream) - { - super.handlePacketData(dataStream); + if (tileEntity instanceof IGasHandler) { + if (((IGasHandler) tileEntity) + .canReceiveGas( + MekanismUtils.getRight(facing).getOpposite(), + outputTank.getGas().getGas() + )) { + outputTank.draw( + ((IGasHandler) tileEntity) + .receiveGas( + MekanismUtils.getRight(facing).getOpposite(), + toSend, + true + ), + true + ); + } + } + } - if(worldObj.isRemote) - { - isActive = dataStream.readBoolean(); - controlType = RedstoneControl.values()[dataStream.readInt()]; - clientEnergyUsed = dataStream.readDouble(); - - if(dataStream.readBoolean()) - { - fluidTank.setFluid(new FluidStack(FluidRegistry.getFluid(dataStream.readInt()), dataStream.readInt())); - } - else { - fluidTank.setFluid(null); - } - - if(dataStream.readBoolean()) - { - inputTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt())); - } - else { - inputTank.setGas(null); - } - - if(dataStream.readBoolean()) - { - outputTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt())); - } - else { - outputTank.setGas(null); - } - - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } + prevEnergy = getEnergy(); + } + } - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); + public WasherRecipe getRecipe() { + GasInput input = getInput(); - data.add(isActive); - data.add(controlType.ordinal()); - data.add(clientEnergyUsed); + if (cachedRecipe == null || !input.testEquality(cachedRecipe.getInput())) { + cachedRecipe = RecipeHandler.getChemicalWasherRecipe(getInput()); + } - if(fluidTank.getFluid() != null) - { - data.add(true); - data.add(fluidTank.getFluid().getFluid().getID()); - data.add(fluidTank.getFluidAmount()); - } - else { - data.add(false); - } + return cachedRecipe; + } - if(inputTank.getGas() != null) - { - data.add(true); - data.add(inputTank.getGas().getGas().getID()); - data.add(inputTank.getStored()); - } - else { - data.add(false); - } + public GasInput getInput() { + return new GasInput(inputTank.getGas()); + } - if(outputTank.getGas() != null) - { - data.add(true); - data.add(outputTank.getGas().getGas().getID()); - data.add(outputTank.getStored()); - } - else { - data.add(false); - } + public boolean canOperate(WasherRecipe recipe) { + return recipe != null && recipe.canOperate(inputTank, fluidTank, outputTank); + } - return data; - } + public int operate(WasherRecipe recipe) { + int operations = getUpgradedUsage(); - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); + recipe.operate(inputTank, fluidTank, outputTank, operations); - isActive = nbtTags.getBoolean("isActive"); - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + return operations; + } - fluidTank.readFromNBT(nbtTags.getCompoundTag("leftTank")); - inputTank.read(nbtTags.getCompoundTag("rightTank")); - outputTank.read(nbtTags.getCompoundTag("centerTank")); - } + private void manageBuckets() { + if (inventory[0] != null) { + if (inventory[0].getItem() instanceof IFluidContainerItem) { + FluidContainerUtils.handleContainerItemEmpty( + this, fluidTank, 0, 1, FluidChecker.check(FluidRegistry.WATER) + ); + } else if (FluidContainerRegistry.isFilledContainer(inventory[0])) { + FluidContainerUtils.handleRegistryItemEmpty( + this, fluidTank, 0, 1, FluidChecker.check(FluidRegistry.WATER) + ); + } + } + } - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); + public int getUpgradedUsage() { + int possibleProcess + = (int) Math.pow(2, upgradeComponent.getUpgrades(Upgrade.SPEED)); + possibleProcess = Math.min( + Math.min(inputTank.getStored(), outputTank.getNeeded()), possibleProcess + ); + possibleProcess = Math.min((int) (getEnergy() / energyPerTick), possibleProcess); - nbtTags.setBoolean("isActive", isActive); - nbtTags.setInteger("controlType", controlType.ordinal()); + return Math.min(fluidTank.getFluidAmount() / WATER_USAGE, possibleProcess); + } - nbtTags.setTag("leftTank", fluidTank.writeToNBT(new NBTTagCompound())); - nbtTags.setTag("rightTank", inputTank.write(new NBTTagCompound())); - nbtTags.setTag("centerTank", outputTank.write(new NBTTagCompound())); - } + @Override + public void handlePacketData(ByteBuf dataStream) { + super.handlePacketData(dataStream); - @Override - public boolean canSetFacing(int i) - { - return i != 0 && i != 1; - } + if (worldObj.isRemote) { + isActive = dataStream.readBoolean(); + controlType = RedstoneControl.values()[dataStream.readInt()]; + clientEnergyUsed = dataStream.readDouble(); - public GasTank getTank(ForgeDirection side) - { - if(side == MekanismUtils.getLeft(facing)) - { - return inputTank; - } - else if(side == MekanismUtils.getRight(facing)) - { - return outputTank; - } + if (dataStream.readBoolean()) { + fluidTank.setFluid(new FluidStack( + FluidRegistry.getFluid(dataStream.readInt()), dataStream.readInt() + )); + } else { + fluidTank.setFluid(null); + } - return null; - } + if (dataStream.readBoolean()) { + inputTank.setGas(new GasStack( + GasRegistry.getGas(dataStream.readInt()), dataStream.readInt() + )); + } else { + inputTank.setGas(null); + } - @Override - public void setActive(boolean active) - { - isActive = active; + if (dataStream.readBoolean()) { + outputTank.setGas(new GasStack( + GasRegistry.getGas(dataStream.readInt()), dataStream.readInt() + )); + } else { + outputTank.setGas(null); + } - if(clientActive != active && updateDelay == 0) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } - updateDelay = 10; - clientActive = active; - } - } + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); - @Override - public boolean getActive() - { - return isActive; - } + data.add(isActive); + data.add(controlType.ordinal()); + data.add(clientEnergyUsed); - @Override - public boolean renderUpdate() - { - return false; - } + if (fluidTank.getFluid() != null) { + data.add(true); + data.add(fluidTank.getFluid().getFluid().getID()); + data.add(fluidTank.getFluidAmount()); + } else { + data.add(false); + } - @Override - public boolean lightUpdate() - { - return true; - } + if (inputTank.getGas() != null) { + data.add(true); + data.add(inputTank.getGas().getGas().getID()); + data.add(inputTank.getStored()); + } else { + data.add(false); + } - @Override - public boolean canTubeConnect(ForgeDirection side) - { - return getTank(side) != null; - } + if (outputTank.getGas() != null) { + data.add(true); + data.add(outputTank.getGas().getGas().getID()); + data.add(outputTank.getStored()); + } else { + data.add(false); + } - @Override - public boolean canReceiveGas(ForgeDirection side, Gas type) - { - if(getTank(side) == inputTank) - { - return getTank(side).canReceive(type) && RecipeHandler.Recipe.CHEMICAL_WASHER.containsRecipe(type); + return data; + } + + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); + + isActive = nbtTags.getBoolean("isActive"); + controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + + fluidTank.readFromNBT(nbtTags.getCompoundTag("leftTank")); + inputTank.read(nbtTags.getCompoundTag("rightTank")); + outputTank.read(nbtTags.getCompoundTag("centerTank")); + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); + + nbtTags.setBoolean("isActive", isActive); + nbtTags.setInteger("controlType", controlType.ordinal()); + + nbtTags.setTag("leftTank", fluidTank.writeToNBT(new NBTTagCompound())); + nbtTags.setTag("rightTank", inputTank.write(new NBTTagCompound())); + nbtTags.setTag("centerTank", outputTank.write(new NBTTagCompound())); + } + + @Override + public boolean canSetFacing(int i) { + return i != 0 && i != 1; + } + + public GasTank getTank(ForgeDirection side) { + if (side == MekanismUtils.getLeft(facing)) { + return inputTank; + } else if (side == MekanismUtils.getRight(facing)) { + return outputTank; + } + + return null; + } + + @Override + public void setActive(boolean active) { + isActive = active; + + if (clientActive != active && updateDelay == 0) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + + updateDelay = 10; + clientActive = active; + } + } + + @Override + public boolean getActive() { + return isActive; + } + + @Override + public boolean renderUpdate() { + return false; + } + + @Override + public boolean lightUpdate() { + return true; + } + + @Override + public boolean canTubeConnect(ForgeDirection side) { + return getTank(side) != null; + } + + @Override + public boolean canReceiveGas(ForgeDirection side, Gas type) { + if (getTank(side) == inputTank) { + return getTank(side).canReceive(type) + && RecipeHandler.Recipe.CHEMICAL_WASHER.containsRecipe(type); } return false; - } + } - @Override - public RedstoneControl getControlType() - { - return controlType; - } + @Override + public RedstoneControl getControlType() { + return controlType; + } - @Override - public void setControlType(RedstoneControl type) - { - controlType = type; - MekanismUtils.saveChunk(this); - } + @Override + public void setControlType(RedstoneControl type) { + controlType = type; + MekanismUtils.saveChunk(this); + } - @Override - public boolean canPulse() - { - return false; - } + @Override + public boolean canPulse() { + return false; + } - @Override - public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) - { - if(canReceiveGas(side, stack != null ? stack.getGas() : null)) - { - return getTank(side).receive(stack, doTransfer); - } + @Override + public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) { + if (canReceiveGas(side, stack != null ? stack.getGas() : null)) { + return getTank(side).receive(stack, doTransfer); + } - return 0; - } + return 0; + } - @Override - public int receiveGas(ForgeDirection side, GasStack stack) - { - return receiveGas(side, stack, true); - } + @Override + public int receiveGas(ForgeDirection side, GasStack stack) { + return receiveGas(side, stack, true); + } - @Override - public GasStack drawGas(ForgeDirection side, int amount, boolean doTransfer) - { - if(canDrawGas(side, null)) - { - return getTank(side).draw(amount, doTransfer); - } + @Override + public GasStack drawGas(ForgeDirection side, int amount, boolean doTransfer) { + if (canDrawGas(side, null)) { + return getTank(side).draw(amount, doTransfer); + } - return null; - } + return null; + } - @Override - public GasStack drawGas(ForgeDirection side, int amount) - { - return drawGas(side, amount, true); - } + @Override + public GasStack drawGas(ForgeDirection side, int amount) { + return drawGas(side, amount, true); + } - @Override - public boolean canDrawGas(ForgeDirection side, Gas type) - { - return getTank(side) == outputTank ? getTank(side).canDraw(type) : false; - } + @Override + public boolean canDrawGas(ForgeDirection side, Gas type) { + return getTank(side) == outputTank ? getTank(side).canDraw(type) : false; + } - @Override - public boolean isItemValidForSlot(int slotID, ItemStack itemstack) - { - if(slotID == 0) - { - return FluidContainerRegistry.getFluidForFilledItem(itemstack) != null && FluidContainerRegistry.getFluidForFilledItem(itemstack).getFluid() == FluidRegistry.WATER; - } - else if(slotID == 2) - { - return ChargeUtils.canBeDischarged(itemstack); - } + @Override + public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { + if (slotID == 0) { + return FluidContainerRegistry.getFluidForFilledItem(itemstack) != null + && FluidContainerRegistry.getFluidForFilledItem(itemstack).getFluid() + == FluidRegistry.WATER; + } else if (slotID == 2) { + return ChargeUtils.canBeDischarged(itemstack); + } - return false; - } + return false; + } - @Override - public boolean canExtractItem(int slotID, ItemStack itemstack, int side) - { - if(slotID == 1) - { - return itemstack != null && itemstack.getItem() instanceof IGasItem && ((IGasItem)itemstack.getItem()).canProvideGas(itemstack, null); - } - else if(slotID == 2) - { - return ChargeUtils.canBeOutputted(itemstack, false); - } + @Override + public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { + if (slotID == 1) { + return itemstack != null && itemstack.getItem() instanceof IGasItem + && ((IGasItem) itemstack.getItem()).canProvideGas(itemstack, null); + } else if (slotID == 2) { + return ChargeUtils.canBeOutputted(itemstack, false); + } - return false; - } + return false; + } - @Override - public int[] getAccessibleSlotsFromSide(int side) - { - if(side == MekanismUtils.getLeft(facing).ordinal()) - { - return new int[] {0}; - } - else if(side == MekanismUtils.getRight(facing).ordinal()) - { - return new int[] {1}; - } - else if(side == 0 || side == 1) - { - return new int[2]; - } + @Override + public int[] getAccessibleSlotsFromSide(int side) { + if (side == MekanismUtils.getLeft(facing).ordinal()) { + return new int[] { 0 }; + } else if (side == MekanismUtils.getRight(facing).ordinal()) { + return new int[] { 1 }; + } else if (side == 0 || side == 1) { + return new int[2]; + } - return InventoryUtils.EMPTY; - } + return InventoryUtils.EMPTY; + } - @Override - public int fill(ForgeDirection from, FluidStack resource, boolean doFill) - { - if(canFill(from, resource.getFluid())) - { - return fluidTank.fill(resource, doFill); - } + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { + if (canFill(from, resource.getFluid())) { + return fluidTank.fill(resource, doFill); + } - return 0; - } + return 0; + } - @Override - public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) - { - return null; - } + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + return null; + } - @Override - public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) - { - return null; - } + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { + return null; + } - @Override - public boolean canFill(ForgeDirection from, Fluid fluid) - { - return from == ForgeDirection.UP && fluid == FluidRegistry.WATER; - } + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + return from == ForgeDirection.UP && fluid == FluidRegistry.WATER; + } - @Override - public boolean canDrain(ForgeDirection from, Fluid fluid) - { - return false; - } + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + return false; + } - @Override - public FluidTankInfo[] getTankInfo(ForgeDirection from) - { - if(from == ForgeDirection.UP) - { - return new FluidTankInfo[] {fluidTank.getInfo()}; - } + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection from) { + if (from == ForgeDirection.UP) { + return new FluidTankInfo[] { fluidTank.getInfo() }; + } - return PipeUtils.EMPTY; - } + return PipeUtils.EMPTY; + } - @Override - public void writeSustainedData(ItemStack itemStack) - { - if(fluidTank.getFluid() != null) - { - itemStack.stackTagCompound.setTag("fluidTank", fluidTank.getFluid().writeToNBT(new NBTTagCompound())); - } - - if(inputTank.getGas() != null) - { - itemStack.stackTagCompound.setTag("inputTank", inputTank.getGas().write(new NBTTagCompound())); - } - - if(outputTank.getGas() != null) - { - itemStack.stackTagCompound.setTag("outputTank", outputTank.getGas().write(new NBTTagCompound())); - } - } + @Override + public void writeSustainedData(ItemStack itemStack) { + if (fluidTank.getFluid() != null) { + itemStack.stackTagCompound.setTag( + "fluidTank", fluidTank.getFluid().writeToNBT(new NBTTagCompound()) + ); + } - @Override - public void readSustainedData(ItemStack itemStack) - { - fluidTank.setFluid(FluidStack.loadFluidStackFromNBT(itemStack.stackTagCompound.getCompoundTag("fluidTank"))); - inputTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("inputTank"))); - outputTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("outputTank"))); - } + if (inputTank.getGas() != null) { + itemStack.stackTagCompound.setTag( + "inputTank", inputTank.getGas().write(new NBTTagCompound()) + ); + } - @Override - public TileComponentUpgrade getComponent() - { - return upgradeComponent; - } - - @Override - public void recalculateUpgradables(Upgrade upgrade) - { - super.recalculateUpgradables(upgrade); + if (outputTank.getGas() != null) { + itemStack.stackTagCompound.setTag( + "outputTank", outputTank.getGas().write(new NBTTagCompound()) + ); + } + } - switch(upgrade) - { - case ENERGY: - maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY); - energyPerTick = MekanismUtils.getBaseEnergyPerTick(this, BASE_ENERGY_USAGE); - default: - break; - } - } - - @Override - public List getInfo(Upgrade upgrade) - { - return upgrade == Upgrade.SPEED ? upgrade.getExpScaledInfo(this) : upgrade.getMultScaledInfo(this); - } + @Override + public void readSustainedData(ItemStack itemStack) { + fluidTank.setFluid(FluidStack.loadFluidStackFromNBT( + itemStack.stackTagCompound.getCompoundTag("fluidTank") + )); + inputTank.setGas( + GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("inputTank")) + ); + outputTank.setGas( + GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("outputTank")) + ); + } - @Override - public Object[] getTanks() - { - return new Object[] {fluidTank, inputTank, outputTank}; - } - - @Override - public TileComponentSecurity getSecurity() - { - return securityComponent; - } + @Override + public TileComponentUpgrade getComponent() { + return upgradeComponent; + } + + @Override + public void recalculateUpgradables(Upgrade upgrade) { + super.recalculateUpgradables(upgrade); + + switch (upgrade) { + case ENERGY: + maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY); + energyPerTick + = MekanismUtils.getBaseEnergyPerTick(this, BASE_ENERGY_USAGE); + default: + break; + } + } + + @Override + public List getInfo(Upgrade upgrade) { + return upgrade == Upgrade.SPEED ? upgrade.getExpScaledInfo(this) + : upgrade.getMultScaledInfo(this); + } + + @Override + public Object[] getTanks() { + return new Object[] { fluidTank, inputTank, outputTank }; + } + + @Override + public TileComponentSecurity getSecurity() { + return securityComponent; + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityCombiner.java b/src/main/java/mekanism/common/tile/TileEntityCombiner.java index 0f462d632..bf84d5577 100644 --- a/src/main/java/mekanism/common/tile/TileEntityCombiner.java +++ b/src/main/java/mekanism/common/tile/TileEntityCombiner.java @@ -14,33 +14,36 @@ import net.minecraft.init.Blocks; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; -public class TileEntityCombiner extends TileEntityAdvancedElectricMachine -{ - public TileEntityCombiner() - { - super("combiner", "Combiner", usage.combinerUsage, 1, 200, MachineType.COMBINER.baseEnergy); - } +public class TileEntityCombiner + extends TileEntityAdvancedElectricMachine { + public TileEntityCombiner() { + super( + "combiner", + "Combiner", + usage.combinerUsage, + 1, + 200, + MachineType.COMBINER.baseEnergy + ); + } - @Override - public Map getRecipes() - { - return Recipe.COMBINER.get(); - } + @Override + public Map getRecipes() { + return Recipe.COMBINER.get(); + } - @Override - public GasStack getItemGas(ItemStack itemstack) - { - if(itemstack.getItem() instanceof ItemBlock && Block.getBlockFromItem(itemstack.getItem()) == Blocks.cobblestone) - { - return new GasStack(GasRegistry.getGas("liquidStone"), 200); - } + @Override + public GasStack getItemGas(ItemStack itemstack) { + if (itemstack.getItem() instanceof ItemBlock + && Block.getBlockFromItem(itemstack.getItem()) == Blocks.cobblestone) { + return new GasStack(GasRegistry.getGas("liquidStone"), 200); + } - return null; - } + return null; + } - @Override - public boolean isValidGas(Gas gas) - { - return false; - } + @Override + public boolean isValidGas(Gas gas) { + return false; + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityContainerBlock.java b/src/main/java/mekanism/common/tile/TileEntityContainerBlock.java index 7cc33fd44..f45e42605 100644 --- a/src/main/java/mekanism/common/tile/TileEntityContainerBlock.java +++ b/src/main/java/mekanism/common/tile/TileEntityContainerBlock.java @@ -11,240 +11,205 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraftforge.common.util.Constants.NBT; -public abstract class TileEntityContainerBlock extends TileEntityBasicBlock implements ISidedInventory, ISustainedInventory -{ - /** The inventory slot itemstacks used by this block. */ - public ItemStack[] inventory; +public abstract class TileEntityContainerBlock + extends TileEntityBasicBlock implements ISidedInventory, ISustainedInventory { + /** The inventory slot itemstacks used by this block. */ + public ItemStack[] inventory; - /** The full name of this machine. */ - public String fullName; + /** The full name of this machine. */ + public String fullName; - /** - * A simple tile entity with a container and facing state. - * @param name - full name of this tile entity - */ - public TileEntityContainerBlock(String name) - { - fullName = name; - } + /** + * A simple tile entity with a container and facing state. + * @param name - full name of this tile entity + */ + public TileEntityContainerBlock(String name) { + fullName = name; + } - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); - if(handleInventory()) - { - NBTTagList tagList = nbtTags.getTagList("Items", NBT.TAG_COMPOUND); - inventory = new ItemStack[getSizeInventory()]; + if (handleInventory()) { + NBTTagList tagList = nbtTags.getTagList("Items", NBT.TAG_COMPOUND); + inventory = new ItemStack[getSizeInventory()]; - for(int tagCount = 0; tagCount < tagList.tagCount(); tagCount++) - { - NBTTagCompound tagCompound = tagList.getCompoundTagAt(tagCount); - byte slotID = tagCompound.getByte("Slot"); + for (int tagCount = 0; tagCount < tagList.tagCount(); tagCount++) { + NBTTagCompound tagCompound = tagList.getCompoundTagAt(tagCount); + byte slotID = tagCompound.getByte("Slot"); - if(slotID >= 0 && slotID < getSizeInventory()) - { - setInventorySlotContents(slotID, ItemStack.loadItemStackFromNBT(tagCompound)); - } - } - } - } + if (slotID >= 0 && slotID < getSizeInventory()) { + setInventorySlotContents( + slotID, ItemStack.loadItemStackFromNBT(tagCompound) + ); + } + } + } + } - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); - if(handleInventory()) - { - NBTTagList tagList = new NBTTagList(); + if (handleInventory()) { + NBTTagList tagList = new NBTTagList(); - for(int slotCount = 0; slotCount < getSizeInventory(); slotCount++) - { - if(getStackInSlot(slotCount) != null) - { - NBTTagCompound tagCompound = new NBTTagCompound(); - tagCompound.setByte("Slot", (byte)slotCount); - getStackInSlot(slotCount).writeToNBT(tagCompound); - tagList.appendTag(tagCompound); - } - } + for (int slotCount = 0; slotCount < getSizeInventory(); slotCount++) { + if (getStackInSlot(slotCount) != null) { + NBTTagCompound tagCompound = new NBTTagCompound(); + tagCompound.setByte("Slot", (byte) slotCount); + getStackInSlot(slotCount).writeToNBT(tagCompound); + tagList.appendTag(tagCompound); + } + } - nbtTags.setTag("Items", tagList); - } - } + nbtTags.setTag("Items", tagList); + } + } - @Override - public int getSizeInventory() - { - return inventory != null ? inventory.length : 0; - } + @Override + public int getSizeInventory() { + return inventory != null ? inventory.length : 0; + } - @Override - public ItemStack getStackInSlot(int slotID) - { - return inventory != null ? inventory[slotID] : null; - } + @Override + public ItemStack getStackInSlot(int slotID) { + return inventory != null ? inventory[slotID] : null; + } - @Override - public ItemStack decrStackSize(int slotID, int amount) - { - if(getStackInSlot(slotID) != null) - { - ItemStack tempStack; + @Override + public ItemStack decrStackSize(int slotID, int amount) { + if (getStackInSlot(slotID) != null) { + ItemStack tempStack; - if(getStackInSlot(slotID).stackSize <= amount) - { - tempStack = getStackInSlot(slotID); - setInventorySlotContents(slotID, null); - return tempStack; - } - else { - tempStack = getStackInSlot(slotID).splitStack(amount); + if (getStackInSlot(slotID).stackSize <= amount) { + tempStack = getStackInSlot(slotID); + setInventorySlotContents(slotID, null); + return tempStack; + } else { + tempStack = getStackInSlot(slotID).splitStack(amount); - if(getStackInSlot(slotID).stackSize == 0) - { - setInventorySlotContents(slotID, null); - } + if (getStackInSlot(slotID).stackSize == 0) { + setInventorySlotContents(slotID, null); + } - return tempStack; - } - } - else { - return null; - } - } + return tempStack; + } + } else { + return null; + } + } - @Override - public ItemStack getStackInSlotOnClosing(int slotID) - { - if(getStackInSlot(slotID) != null) - { - ItemStack tempStack = getStackInSlot(slotID); - setInventorySlotContents(slotID, null); - return tempStack; - } - else { - return null; - } - } + @Override + public ItemStack getStackInSlotOnClosing(int slotID) { + if (getStackInSlot(slotID) != null) { + ItemStack tempStack = getStackInSlot(slotID); + setInventorySlotContents(slotID, null); + return tempStack; + } else { + return null; + } + } - @Override - public void setInventorySlotContents(int slotID, ItemStack itemstack) - { - inventory[slotID] = itemstack; + @Override + public void setInventorySlotContents(int slotID, ItemStack itemstack) { + inventory[slotID] = itemstack; - if(itemstack != null && itemstack.stackSize > getInventoryStackLimit()) - { - itemstack.stackSize = getInventoryStackLimit(); - } - - markDirty(); - } + if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { + itemstack.stackSize = getInventoryStackLimit(); + } - @Override - public boolean isUseableByPlayer(EntityPlayer entityplayer) - { - return !isInvalid(); - } + markDirty(); + } - @Override - public String getInventoryName() - { - return LangUtils.localize(getBlockType().getUnlocalizedName() + "." + fullName + ".name"); - } + @Override + public boolean isUseableByPlayer(EntityPlayer entityplayer) { + return !isInvalid(); + } - @Override - public int getInventoryStackLimit() - { - return 64; - } + @Override + public String getInventoryName() { + return LangUtils.localize( + getBlockType().getUnlocalizedName() + "." + fullName + ".name" + ); + } - @Override - public void openInventory() {} + @Override + public int getInventoryStackLimit() { + return 64; + } - @Override - public void closeInventory() {} + @Override + public void openInventory() {} - @Override - public boolean hasCustomInventoryName() - { - return true; - } + @Override + public void closeInventory() {} - @Override - public boolean isItemValidForSlot(int slotID, ItemStack itemstack) - { - return true; - } + @Override + public boolean hasCustomInventoryName() { + return true; + } - @Override - public boolean canInsertItem(int slotID, ItemStack itemstack, int side) - { - return isItemValidForSlot(slotID, itemstack); - } + @Override + public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { + return true; + } - @Override - public int[] getAccessibleSlotsFromSide(int side) - { - return InventoryUtils.EMPTY; - } + @Override + public boolean canInsertItem(int slotID, ItemStack itemstack, int side) { + return isItemValidForSlot(slotID, itemstack); + } - @Override - public boolean canExtractItem(int slotID, ItemStack itemstack, int side) - { - return true; - } + @Override + public int[] getAccessibleSlotsFromSide(int side) { + return InventoryUtils.EMPTY; + } - @Override - public void setInventory(NBTTagList nbtTags, Object... data) - { - if(nbtTags == null || nbtTags.tagCount() == 0 || !handleInventory()) - { - return; - } + @Override + public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { + return true; + } - inventory = new ItemStack[getSizeInventory()]; + @Override + public void setInventory(NBTTagList nbtTags, Object... data) { + if (nbtTags == null || nbtTags.tagCount() == 0 || !handleInventory()) { + return; + } - for(int slots = 0; slots < nbtTags.tagCount(); slots++) - { - NBTTagCompound tagCompound = (NBTTagCompound)nbtTags.getCompoundTagAt(slots); - byte slotID = tagCompound.getByte("Slot"); + inventory = new ItemStack[getSizeInventory()]; - if(slotID >= 0 && slotID < inventory.length) - { - inventory[slotID] = ItemStack.loadItemStackFromNBT(tagCompound); - } - } - } + for (int slots = 0; slots < nbtTags.tagCount(); slots++) { + NBTTagCompound tagCompound = (NBTTagCompound) nbtTags.getCompoundTagAt(slots); + byte slotID = tagCompound.getByte("Slot"); - @Override - public NBTTagList getInventory(Object... data) - { - NBTTagList tagList = new NBTTagList(); + if (slotID >= 0 && slotID < inventory.length) { + inventory[slotID] = ItemStack.loadItemStackFromNBT(tagCompound); + } + } + } - if(handleInventory()) - { - for(int slots = 0; slots < inventory.length; slots++) - { - if(inventory[slots] != null) - { - NBTTagCompound tagCompound = new NBTTagCompound(); - tagCompound.setByte("Slot", (byte)slots); - inventory[slots].writeToNBT(tagCompound); - tagList.appendTag(tagCompound); - } - } - } + @Override + public NBTTagList getInventory(Object... data) { + NBTTagList tagList = new NBTTagList(); - return tagList; - } + if (handleInventory()) { + for (int slots = 0; slots < inventory.length; slots++) { + if (inventory[slots] != null) { + NBTTagCompound tagCompound = new NBTTagCompound(); + tagCompound.setByte("Slot", (byte) slots); + inventory[slots].writeToNBT(tagCompound); + tagList.appendTag(tagCompound); + } + } + } - public boolean handleInventory() - { - return true; - } + return tagList; + } - public void recalculateUpgradables(Upgrade upgradeType) {} + public boolean handleInventory() { + return true; + } + + public void recalculateUpgradables(Upgrade upgradeType) {} } diff --git a/src/main/java/mekanism/common/tile/TileEntityCrusher.java b/src/main/java/mekanism/common/tile/TileEntityCrusher.java index d23629ba6..3a6e570c6 100644 --- a/src/main/java/mekanism/common/tile/TileEntityCrusher.java +++ b/src/main/java/mekanism/common/tile/TileEntityCrusher.java @@ -2,30 +2,28 @@ package mekanism.common.tile; import java.util.Map; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.MekanismConfig.usage; import mekanism.common.block.BlockMachine.MachineType; import mekanism.common.recipe.RecipeHandler.Recipe; import mekanism.common.recipe.machines.CrusherRecipe; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class TileEntityCrusher extends TileEntityElectricMachine -{ - public TileEntityCrusher() - { - super("crusher", "Crusher", usage.crusherUsage, 200, MachineType.CRUSHER.baseEnergy); - } +public class TileEntityCrusher extends TileEntityElectricMachine { + public TileEntityCrusher() { + super( + "crusher", "Crusher", usage.crusherUsage, 200, MachineType.CRUSHER.baseEnergy + ); + } - @Override - public Map getRecipes() - { - return Recipe.CRUSHER.get(); - } + @Override + public Map getRecipes() { + return Recipe.CRUSHER.get(); + } - @Override - @SideOnly(Side.CLIENT) - public float getVolume() - { - return 0.5F*super.getVolume(); - } + @Override + @SideOnly(Side.CLIENT) + public float getVolume() { + return 0.5F * super.getVolume(); + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityDigitalMiner.java b/src/main/java/mekanism/common/tile/TileEntityDigitalMiner.java index 25c7e744f..180a74aff 100644 --- a/src/main/java/mekanism/common/tile/TileEntityDigitalMiner.java +++ b/src/main/java/mekanism/common/tile/TileEntityDigitalMiner.java @@ -1,7 +1,5 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.BitSet; import java.util.EnumSet; @@ -12,6 +10,9 @@ import java.util.List; import java.util.Map; import java.util.Set; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; import mekanism.api.Chunk3D; import mekanism.api.Coord4D; import mekanism.api.MekanismConfig.usage; @@ -58,1476 +59,1329 @@ import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.Constants.NBT; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.event.world.BlockEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class TileEntityDigitalMiner extends TileEntityElectricBlock implements IUpgradeTile, IRedstoneControl, IActiveState, ISustainedData, IAdvancedBoundingBlock -{ - public static int[] EJECT_INV; +public class TileEntityDigitalMiner extends TileEntityElectricBlock + implements IUpgradeTile, IRedstoneControl, IActiveState, ISustainedData, + IAdvancedBoundingBlock { + public static int[] EJECT_INV; - public Map oresToMine = new HashMap(); - public Map replaceMap = new HashMap(); + public Map oresToMine = new HashMap(); + public Map replaceMap = new HashMap(); - public HashList filters = new HashList(); + public HashList filters = new HashList(); - public ThreadMinerSearch searcher = new ThreadMinerSearch(this); + public ThreadMinerSearch searcher = new ThreadMinerSearch(this); - public final double BASE_ENERGY_USAGE = usage.digitalMinerUsage; + public final double BASE_ENERGY_USAGE = usage.digitalMinerUsage; - public double energyUsage = usage.digitalMinerUsage; + public double energyUsage = usage.digitalMinerUsage; - public int radius; + public int radius; - public boolean inverse; + public boolean inverse; - public int minY = 0; - public int maxY = 60; + public int minY = 0; + public int maxY = 60; - public boolean doEject = false; - public boolean doPull = false; - - public ItemStack missingStack = null; - - public int BASE_DELAY = 80; - - public int delay; - - public int delayLength = BASE_DELAY; - - public int clientToMine; - - public boolean isActive; - public boolean clientActive; - - public boolean silkTouch; - - public boolean running; - - public double prevEnergy; - - public int delayTicks; - - public boolean initCalc = false; - - public int numPowering; - - public boolean clientRendering = false; - - /** This machine's current RedstoneControl type. */ - public RedstoneControl controlType = RedstoneControl.DISABLED; - - public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, 28); - public TileComponentSecurity securityComponent = new TileComponentSecurity(this); - - public TileEntityDigitalMiner() - { - super("DigitalMiner", MachineType.DIGITAL_MINER.baseEnergy); - inventory = new ItemStack[29]; - radius = 10; - } - - @Override - public void onUpdate() - { - super.onUpdate(); - - if(getActive()) - { - for(EntityPlayer player : (HashSet)playersUsing.clone()) - { - if(player.openContainer instanceof ContainerNull || player.openContainer instanceof ContainerFilter) - { - player.closeScreen(); - } - } - } - - if(!worldObj.isRemote) - { - if(!initCalc) - { - if(searcher.state == State.FINISHED) - { - boolean prevRunning = running; - - reset(); - start(); - - running = prevRunning; - } - - initCalc = true; - } - - ChargeUtils.discharge(27, this); - - if(MekanismUtils.canFunction(this) && running && getEnergy() >= getPerTick() && searcher.state == State.FINISHED && oresToMine.size() > 0) - { - setActive(true); - - if(delay > 0) - { - delay--; - } - - setEnergy(getEnergy()-getPerTick()); - - if(delay == 0) - { - Set toRemove = new HashSet(); - boolean did = false; - - for(Chunk3D chunk : oresToMine.keySet()) - { - BitSet set = oresToMine.get(chunk); - int next = 0; - - while(true) - { - int index = set.nextSetBit(next); - Coord4D coord = getCoordFromIndex(index); - - if(index == -1) - { - toRemove.add(chunk); - break; - } - - if(!coord.exists(worldObj)) - { - set.clear(index); - - if(set.cardinality() == 0) - { - toRemove.add(chunk); - } - - next = index + 1; - continue; - } - - Block block = coord.getBlock(worldObj); - int meta = coord.getMetadata(worldObj); - - if(block == null || coord.isAirBlock(worldObj)) - { - set.clear(index); - - if(set.cardinality() == 0) - { - toRemove.add(chunk); - } - - next = index + 1; - continue; - } - - boolean hasFilter = false; - - for(MinerFilter filter : filters) - { - if(filter.canFilter(new ItemStack(block, 1, meta))) - { - hasFilter = true; - break; - } - } - - if(inverse ? hasFilter : !hasFilter) - { - set.clear(index); - - if(set.cardinality() == 0) - { - toRemove.add(chunk); - break; - } - - next = index + 1; - continue; - } - - List drops = MinerUtils.getDrops(worldObj, coord, silkTouch); - - if(canInsert(drops) && setReplace(coord, index)) - { - did = true; - add(drops); - set.clear(index); - - if(set.cardinality() == 0) - { - toRemove.add(chunk); - } - - worldObj.playAuxSFXAtEntity(null, 2001, coord.xCoord, coord.yCoord, coord.zCoord, Block.getIdFromBlock(block) + (meta << 12)); - - missingStack = null; - } - - break; - } - - if(did) - { - break; - } - } - - for(Chunk3D chunk : toRemove) - { - oresToMine.remove(chunk); - } - - delay = getDelay(); - } - } - else { - if(prevEnergy >= getEnergy()) - { - setActive(false); - } - } - - if(doEject && delayTicks == 0 && getTopEject(false, null) != null && getEjectInv() != null && getEjectTile() != null) - { - if(getEjectInv() instanceof IInventory) - { - ItemStack remains = InventoryUtils.putStackInInventory((IInventory)getEjectInv(), getTopEject(false, null), ForgeDirection.getOrientation(facing).getOpposite().ordinal(), false); - - getTopEject(true, remains); - } - else if(getEjectInv() instanceof ITransporterTile) - { - ItemStack rejected = TransporterUtils.insert(getEjectTile(), ((ITransporterTile)getEjectInv()).getTransmitter(), getTopEject(false, null), null, true, 0); - - if(TransporterManager.didEmit(getTopEject(false, null), rejected)) - { - getTopEject(true, rejected); - } - } - - delayTicks = 10; - } - else if(delayTicks > 0) - { - delayTicks--; - } - - if(playersUsing.size() > 0) - { - for(EntityPlayer player : playersUsing) - { - Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(this), getSmallPacket(new ArrayList())), (EntityPlayerMP)player); - } - } - - prevEnergy = getEnergy(); - } - } - - public double getPerTick() - { - double ret = energyUsage; - - if(silkTouch) - { - ret *= 6F; - } - - int baseRad = Math.max(radius-10, 0); - ret *= (1 + ((float)baseRad/22F)); - - int baseHeight = Math.max((maxY-minY)-60, 0); - ret *= (1 + ((float)baseHeight/195F)); - - return ret; - } - - public int getDelay() - { - return delayLength; - } - - /* - * returns false if unsuccessful - */ - public boolean setReplace(Coord4D obj, int index) - { - Block block = obj.getBlock(worldObj); - int meta = obj.getMetadata(worldObj); - - EntityPlayer dummy = Mekanism.proxy.getDummyPlayer((WorldServer)worldObj, xCoord, yCoord, zCoord).get(); - BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(obj.xCoord, obj.yCoord, obj.zCoord, worldObj, block, meta, dummy); - MinecraftForge.EVENT_BUS.post(event); - - if(!event.isCanceled()) - { - ItemStack stack = getReplace(index); - - if(stack != null) - { - worldObj.setBlock(obj.xCoord, obj.yCoord, obj.zCoord, Block.getBlockFromItem(stack.getItem()), stack.getItemDamage(), 3); - - if(obj.getBlock(worldObj) != null && !obj.getBlock(worldObj).canBlockStay(worldObj, obj.xCoord, obj.yCoord, obj.zCoord)) - { - obj.getBlock(worldObj).dropBlockAsItem(worldObj, obj.xCoord, obj.yCoord, obj.zCoord, obj.getMetadata(worldObj), 1); - worldObj.setBlockToAir(obj.xCoord, obj.yCoord, obj.zCoord); - } - - return true; - } - else { - MinerFilter filter = replaceMap.get(index); - - if(filter == null || (filter.replaceStack == null || !filter.requireStack)) - { - worldObj.setBlockToAir(obj.xCoord, obj.yCoord, obj.zCoord); - - return true; - } - - missingStack = filter.replaceStack; - - return false; - } - } - - return false; - } - - public ItemStack getReplace(int index) - { - MinerFilter filter = replaceMap.get(index); - - if(filter == null || filter.replaceStack == null) - { - return null; - } - - for(int i = 0; i < 27; i++) - { - if(inventory[i] != null && inventory[i].isItemEqual(filter.replaceStack)) - { - inventory[i].stackSize--; - - if(inventory[i].stackSize == 0) - { - inventory[i] = null; - } - - return MekanismUtils.size(filter.replaceStack, 1); - } - } - - if(doPull && getPullInv() instanceof IInventory) - { - InvStack stack = InventoryUtils.takeDefinedItem((IInventory)getPullInv(), 1, filter.replaceStack.copy(), 1, 1); - - if(stack != null) - { - stack.use(); - return MekanismUtils.size(filter.replaceStack, 1); - } - } - - return null; - } - - public ItemStack[] copy(ItemStack[] stacks) - { - ItemStack[] toReturn = new ItemStack[stacks.length]; - - for(int i = 0; i < stacks.length; i++) - { - toReturn[i] = stacks[i] != null ? stacks[i].copy() : null; - } - - return toReturn; - } - - public ItemStack getTopEject(boolean remove, ItemStack reject) - { - for(int i = 27-1; i >= 0; i--) - { - ItemStack stack = inventory[i]; - - if(stack != null) - { - if(isReplaceStack(stack)) - { - continue; - } - - if(remove) - { - inventory[i] = reject; - } - - return stack; - } - } - - return null; - } - - public boolean canInsert(List stacks) - { - if(stacks.isEmpty()) - { - return true; - } - - ItemStack[] testInv = copy(inventory); - - int added = 0; - - stacks: - for(ItemStack stack : stacks) - { - if(stack == null || stack.getItem() == null) - { - continue; - } - - for(int i = 0; i < 27; i++) - { - if(testInv[i] != null && testInv[i].getItem() == null) - { - testInv[i] = null; - } - - if(testInv[i] == null) - { - testInv[i] = stack; - added++; - - continue stacks; - } + public boolean doEject = false; + public boolean doPull = false; + + public ItemStack missingStack = null; + + public int BASE_DELAY = 80; + + public int delay; + + public int delayLength = BASE_DELAY; + + public int clientToMine; + + public boolean isActive; + public boolean clientActive; + + public boolean silkTouch; + + public boolean running; + + public double prevEnergy; + + public int delayTicks; + + public boolean initCalc = false; + + public int numPowering; + + public boolean clientRendering = false; + + /** This machine's current RedstoneControl type. */ + public RedstoneControl controlType = RedstoneControl.DISABLED; + + public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, 28); + public TileComponentSecurity securityComponent = new TileComponentSecurity(this); + + public TileEntityDigitalMiner() { + super("DigitalMiner", MachineType.DIGITAL_MINER.baseEnergy); + inventory = new ItemStack[29]; + radius = 10; + } + + @Override + public void onUpdate() { + super.onUpdate(); + + if (getActive()) { + for (EntityPlayer player : (HashSet) playersUsing.clone()) { + if (player.openContainer instanceof ContainerNull + || player.openContainer instanceof ContainerFilter) { + player.closeScreen(); + } + } + } + + if (!worldObj.isRemote) { + if (!initCalc) { + if (searcher.state == State.FINISHED) { + boolean prevRunning = running; + + reset(); + start(); + + running = prevRunning; + } + + initCalc = true; + } + + ChargeUtils.discharge(27, this); + + if (MekanismUtils.canFunction(this) && running && getEnergy() >= getPerTick() + && searcher.state == State.FINISHED && oresToMine.size() > 0) { + setActive(true); + + if (delay > 0) { + delay--; + } + + setEnergy(getEnergy() - getPerTick()); + + if (delay == 0) { + Set toRemove = new HashSet(); + boolean did = false; + + for (Chunk3D chunk : oresToMine.keySet()) { + BitSet set = oresToMine.get(chunk); + int next = 0; + + while (true) { + int index = set.nextSetBit(next); + Coord4D coord = getCoordFromIndex(index); + + if (index == -1) { + toRemove.add(chunk); + break; + } + + if (!coord.exists(worldObj)) { + set.clear(index); + + if (set.cardinality() == 0) { + toRemove.add(chunk); + } + + next = index + 1; + continue; + } + + Block block = coord.getBlock(worldObj); + int meta = coord.getMetadata(worldObj); + + if (block == null || coord.isAirBlock(worldObj)) { + set.clear(index); + + if (set.cardinality() == 0) { + toRemove.add(chunk); + } + + next = index + 1; + continue; + } + + boolean hasFilter = false; + + for (MinerFilter filter : filters) { + if (filter.canFilter(new ItemStack(block, 1, meta))) { + hasFilter = true; + break; + } + } + + if (inverse ? hasFilter : !hasFilter) { + set.clear(index); + + if (set.cardinality() == 0) { + toRemove.add(chunk); + break; + } + + next = index + 1; + continue; + } + + List drops + = MinerUtils.getDrops(worldObj, coord, silkTouch); + + if (canInsert(drops) && setReplace(coord, index)) { + did = true; + add(drops); + set.clear(index); + + if (set.cardinality() == 0) { + toRemove.add(chunk); + } + + worldObj.playAuxSFXAtEntity( + null, + 2001, + coord.xCoord, + coord.yCoord, + coord.zCoord, + Block.getIdFromBlock(block) + (meta << 12) + ); + + missingStack = null; + } + + break; + } + + if (did) { + break; + } + } + + for (Chunk3D chunk : toRemove) { + oresToMine.remove(chunk); + } + + delay = getDelay(); + } + } else { + if (prevEnergy >= getEnergy()) { + setActive(false); + } + } + + if (doEject && delayTicks == 0 && getTopEject(false, null) != null + && getEjectInv() != null && getEjectTile() != null) { + if (getEjectInv() instanceof IInventory) { + ItemStack remains = InventoryUtils.putStackInInventory( + (IInventory) getEjectInv(), + getTopEject(false, null), + ForgeDirection.getOrientation(facing).getOpposite().ordinal(), + false + ); + + getTopEject(true, remains); + } else if (getEjectInv() instanceof ITransporterTile) { + ItemStack rejected = TransporterUtils.insert( + getEjectTile(), + ((ITransporterTile) getEjectInv()).getTransmitter(), + getTopEject(false, null), + null, + true, + 0 + ); + + if (TransporterManager.didEmit(getTopEject(false, null), rejected)) { + getTopEject(true, rejected); + } + } + + delayTicks = 10; + } else if (delayTicks > 0) { + delayTicks--; + } + + if (playersUsing.size() > 0) { + for (EntityPlayer player : playersUsing) { + Mekanism.packetHandler.sendTo( + new TileEntityMessage( + Coord4D.get(this), getSmallPacket(new ArrayList()) + ), + (EntityPlayerMP) player + ); + } + } + + prevEnergy = getEnergy(); + } + } + + public double getPerTick() { + double ret = energyUsage; + + if (silkTouch) { + ret *= 6F; + } + + int baseRad = Math.max(radius - 10, 0); + ret *= (1 + ((float) baseRad / 22F)); + + int baseHeight = Math.max((maxY - minY) - 60, 0); + ret *= (1 + ((float) baseHeight / 195F)); + + return ret; + } + + public int getDelay() { + return delayLength; + } + + /* + * returns false if unsuccessful + */ + public boolean setReplace(Coord4D obj, int index) { + Block block = obj.getBlock(worldObj); + int meta = obj.getMetadata(worldObj); + + EntityPlayer dummy + = Mekanism.proxy + .getDummyPlayer((WorldServer) worldObj, xCoord, yCoord, zCoord) + .get(); + BlockEvent.BreakEvent event = new BlockEvent.BreakEvent( + obj.xCoord, obj.yCoord, obj.zCoord, worldObj, block, meta, dummy + ); + MinecraftForge.EVENT_BUS.post(event); + + if (!event.isCanceled()) { + ItemStack stack = getReplace(index); + + if (stack != null) { + worldObj.setBlock( + obj.xCoord, + obj.yCoord, + obj.zCoord, + Block.getBlockFromItem(stack.getItem()), + stack.getItemDamage(), + 3 + ); + + if (obj.getBlock(worldObj) != null + && !obj.getBlock(worldObj).canBlockStay( + worldObj, obj.xCoord, obj.yCoord, obj.zCoord + )) { + obj.getBlock(worldObj).dropBlockAsItem( + worldObj, + obj.xCoord, + obj.yCoord, + obj.zCoord, + obj.getMetadata(worldObj), + 1 + ); + worldObj.setBlockToAir(obj.xCoord, obj.yCoord, obj.zCoord); + } + + return true; + } else { + MinerFilter filter = replaceMap.get(index); + + if (filter == null + || (filter.replaceStack == null || !filter.requireStack)) { + worldObj.setBlockToAir(obj.xCoord, obj.yCoord, obj.zCoord); + + return true; + } + + missingStack = filter.replaceStack; + + return false; + } + } + + return false; + } + + public ItemStack getReplace(int index) { + MinerFilter filter = replaceMap.get(index); + + if (filter == null || filter.replaceStack == null) { + return null; + } + + for (int i = 0; i < 27; i++) { + if (inventory[i] != null && inventory[i].isItemEqual(filter.replaceStack)) { + inventory[i].stackSize--; + + if (inventory[i].stackSize == 0) { + inventory[i] = null; + } + + return MekanismUtils.size(filter.replaceStack, 1); + } + } + + if (doPull && getPullInv() instanceof IInventory) { + InvStack stack = InventoryUtils.takeDefinedItem( + (IInventory) getPullInv(), 1, filter.replaceStack.copy(), 1, 1 + ); + + if (stack != null) { + stack.use(); + return MekanismUtils.size(filter.replaceStack, 1); + } + } + + return null; + } + + public ItemStack[] copy(ItemStack[] stacks) { + ItemStack[] toReturn = new ItemStack[stacks.length]; + + for (int i = 0; i < stacks.length; i++) { + toReturn[i] = stacks[i] != null ? stacks[i].copy() : null; + } + + return toReturn; + } + + public ItemStack getTopEject(boolean remove, ItemStack reject) { + for (int i = 27 - 1; i >= 0; i--) { + ItemStack stack = inventory[i]; + + if (stack != null) { + if (isReplaceStack(stack)) { + continue; + } + + if (remove) { + inventory[i] = reject; + } + + return stack; + } + } + + return null; + } + + public boolean canInsert(List stacks) { + if (stacks.isEmpty()) { + return true; + } + + ItemStack[] testInv = copy(inventory); + + int added = 0; + + stacks: + for (ItemStack stack : stacks) { + if (stack == null || stack.getItem() == null) { + continue; + } + + for (int i = 0; i < 27; i++) { + if (testInv[i] != null && testInv[i].getItem() == null) { + testInv[i] = null; + } + + if (testInv[i] == null) { + testInv[i] = stack; + added++; + + continue stacks; + } else if(testInv[i].isItemEqual(stack) && testInv[i].stackSize+stack.stackSize <= stack.getMaxStackSize()) { - testInv[i].stackSize += stack.stackSize; - added++; + testInv[i].stackSize += stack.stackSize; + added++; - continue stacks; - } - } - } + continue stacks; + } + } + } - if(added == stacks.size()) - { - return true; - } + if (added == stacks.size()) { + return true; + } - return false; - } + return false; + } - public TileEntity getPullInv() - { - return Coord4D.get(this).translate(0, 2, 0).getTileEntity(worldObj); - } + public TileEntity getPullInv() { + return Coord4D.get(this).translate(0, 2, 0).getTileEntity(worldObj); + } - public TileEntity getEjectInv() - { - ForgeDirection side = ForgeDirection.getOrientation(facing).getOpposite(); + public TileEntity getEjectInv() { + ForgeDirection side = ForgeDirection.getOrientation(facing).getOpposite(); - return new Coord4D(xCoord+(side.offsetX*2), yCoord+1, zCoord+(side.offsetZ*2), worldObj.provider.dimensionId).getTileEntity(worldObj); - } + return new Coord4D( + xCoord + (side.offsetX * 2), + yCoord + 1, + zCoord + (side.offsetZ * 2), + worldObj.provider.dimensionId + ) + .getTileEntity(worldObj); + } - public void add(List stacks) - { - if(stacks.isEmpty()) - { - return; - } + public void add(List stacks) { + if (stacks.isEmpty()) { + return; + } - stacks: - for(ItemStack stack : stacks) - { - for(int i = 0; i < 27; i++) - { - if(inventory[i] == null) - { - inventory[i] = stack; + stacks: + for (ItemStack stack : stacks) { + for (int i = 0; i < 27; i++) { + if (inventory[i] == null) { + inventory[i] = stack; - continue stacks; - } + continue stacks; + } else if(inventory[i].isItemEqual(stack) && inventory[i].stackSize+stack.stackSize <= stack.getMaxStackSize()) { - inventory[i].stackSize += stack.stackSize; - - continue stacks; - } - } - } - } - - public void start() - { - if(searcher.state == State.IDLE) - { - searcher.start(); - } - - running = true; - - MekanismUtils.saveChunk(this); - } - - public void stop() - { - if(searcher.state == State.SEARCHING) - { - searcher.interrupt(); - reset(); - - return; - } - else if(searcher.state == State.FINISHED) - { - running = false; - } - - MekanismUtils.saveChunk(this); - } - - public void reset() - { - searcher = new ThreadMinerSearch(this); - running = false; - oresToMine.clear(); - replaceMap.clear(); - missingStack = null; - setActive(false); - - MekanismUtils.saveChunk(this); - } - - public boolean isReplaceStack(ItemStack stack) - { - for(MinerFilter filter : filters) - { - if(filter.replaceStack != null && filter.replaceStack.isItemEqual(stack)) - { - return true; - } - } - - return false; - } - - public int getSize() - { - int size = 0; - - for(Chunk3D chunk : oresToMine.keySet()) - { - size += oresToMine.get(chunk).cardinality(); - } - - return size; - } - - @Override - public void openInventory() - { - super.openInventory(); - - if(!worldObj.isRemote) - { - for(EntityPlayer player : playersUsing) - { - Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), (EntityPlayerMP)player); - } - } - } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - radius = nbtTags.getInteger("radius"); - minY = nbtTags.getInteger("minY"); - maxY = nbtTags.getInteger("maxY"); - doEject = nbtTags.getBoolean("doEject"); - doPull = nbtTags.getBoolean("doPull"); - isActive = nbtTags.getBoolean("isActive"); - running = nbtTags.getBoolean("running"); - delay = nbtTags.getInteger("delay"); - silkTouch = nbtTags.getBoolean("silkTouch"); - numPowering = nbtTags.getInteger("numPowering"); - searcher.state = State.values()[nbtTags.getInteger("state")]; - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - inverse = nbtTags.getBoolean("inverse"); - - if(nbtTags.hasKey("filters")) - { - NBTTagList tagList = nbtTags.getTagList("filters", NBT.TAG_COMPOUND); - - for(int i = 0; i < tagList.tagCount(); i++) - { - filters.add(MinerFilter.readFromNBT((NBTTagCompound)tagList.getCompoundTagAt(i))); - } - } - } - - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - if(searcher.state == State.SEARCHING) - { - reset(); - } - - nbtTags.setInteger("radius", radius); - nbtTags.setInteger("minY", minY); - nbtTags.setInteger("maxY", maxY); - nbtTags.setBoolean("doEject", doEject); - nbtTags.setBoolean("doPull", doPull); - nbtTags.setBoolean("isActive", isActive); - nbtTags.setBoolean("running", running); - nbtTags.setInteger("delay", delay); - nbtTags.setBoolean("silkTouch", silkTouch); - nbtTags.setInteger("numPowering", numPowering); - nbtTags.setInteger("state", searcher.state.ordinal()); - nbtTags.setInteger("controlType", controlType.ordinal()); - nbtTags.setBoolean("inverse", inverse); - - NBTTagList filterTags = new NBTTagList(); - - for(MinerFilter filter : filters) - { - filterTags.appendTag(filter.write(new NBTTagCompound())); - } - - if(filterTags.tagCount() != 0) - { - nbtTags.setTag("filters", filterTags); - } - } - - @Override - public void handlePacketData(ByteBuf dataStream) - { - if(!worldObj.isRemote) - { - int type = dataStream.readInt(); - - if(type == 0) - { - doEject = !doEject; - } - else if(type == 1) - { - doPull = !doPull; - } - else if(type == 2) - { - //Unneeded at the moment - } - else if(type == 3) - { - start(); - } - else if(type == 4) - { - stop(); - } - else if(type == 5) - { - reset(); - } - else if(type == 6) - { - radius = dataStream.readInt(); - } - else if(type == 7) - { - minY = dataStream.readInt(); - } - else if(type == 8) - { - maxY = dataStream.readInt(); - } - else if(type == 9) - { - silkTouch = !silkTouch; - } - else if(type == 10) - { - inverse = !inverse; - } - else if(type == 11) - { - // Move filter up - int filterIndex = dataStream.readInt(); - filters.swap( filterIndex, filterIndex - 1 ); - openInventory(); - } - else if(type == 12) - { - // Move filter down - int filterIndex = dataStream.readInt(); - filters.swap( filterIndex, filterIndex + 1 ); - openInventory(); - } - - MekanismUtils.saveChunk(this); - - for(EntityPlayer player : playersUsing) - { - Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(this), getGenericPacket(new ArrayList())), (EntityPlayerMP)player); - } - - return; - } - - super.handlePacketData(dataStream); - - if(worldObj.isRemote) - { - int type = dataStream.readInt(); - - if(type == 0) - { - radius = dataStream.readInt(); - minY = dataStream.readInt(); - maxY = dataStream.readInt(); - doEject = dataStream.readBoolean(); - doPull = dataStream.readBoolean(); - clientActive = dataStream.readBoolean(); - running = dataStream.readBoolean(); - silkTouch = dataStream.readBoolean(); - numPowering = dataStream.readInt(); - searcher.state = State.values()[dataStream.readInt()]; - clientToMine = dataStream.readInt(); - controlType = RedstoneControl.values()[dataStream.readInt()]; - inverse = dataStream.readBoolean(); - - if(dataStream.readBoolean()) - { - missingStack = new ItemStack(Item.getItemById(dataStream.readInt()), 1, dataStream.readInt()); - } - else { - missingStack = null; - } - - filters.clear(); - - int amount = dataStream.readInt(); - - for(int i = 0; i < amount; i++) - { - filters.add(MinerFilter.readFromPacket(dataStream)); - } - } - else if(type == 1) - { - radius = dataStream.readInt(); - minY = dataStream.readInt(); - maxY = dataStream.readInt(); - doEject = dataStream.readBoolean(); - doPull = dataStream.readBoolean(); - clientActive = dataStream.readBoolean(); - running = dataStream.readBoolean(); - silkTouch = dataStream.readBoolean(); - numPowering = dataStream.readInt(); - searcher.state = State.values()[dataStream.readInt()]; - clientToMine = dataStream.readInt(); - controlType = RedstoneControl.values()[dataStream.readInt()]; - inverse = dataStream.readBoolean(); - - if(dataStream.readBoolean()) - { - missingStack = new ItemStack(Item.getItemById(dataStream.readInt()), 1, dataStream.readInt()); - } - else { - missingStack = null; - } - } - else if(type == 2) - { - filters.clear(); - - int amount = dataStream.readInt(); - - for(int i = 0; i < amount; i++) - { - filters.add(MinerFilter.readFromPacket(dataStream)); - } - } - else if(type == 3) - { - clientActive = dataStream.readBoolean(); - running = dataStream.readBoolean(); - clientToMine = dataStream.readInt(); - - if(dataStream.readBoolean()) - { - missingStack = new ItemStack(Item.getItemById(dataStream.readInt()), 1, dataStream.readInt()); - } - else { - missingStack = null; - } - } - - if(clientActive != isActive) - { - isActive = clientActive; - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } - } - - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); - - data.add(0); - - data.add(radius); - data.add(minY); - data.add(maxY); - data.add(doEject); - data.add(doPull); - data.add(isActive); - data.add(running); - data.add(silkTouch); - data.add(numPowering); - data.add(searcher.state.ordinal()); - - if(searcher.state == State.SEARCHING) - { - data.add(searcher.found); - } - else { - data.add(getSize()); - } - - data.add(controlType.ordinal()); - data.add(inverse); - - if(missingStack != null) - { - data.add(true); - data.add(MekanismUtils.getID(missingStack)); - data.add(missingStack.getItemDamage()); - } - else { - data.add(false); - } - - data.add(filters.size()); - - for(MinerFilter filter : filters) - { - filter.write(data); - } - - return data; - } - - public ArrayList getSmallPacket(ArrayList data) - { - super.getNetworkedData(data); - - data.add(3); - - data.add(isActive); - data.add(running); - - if(searcher.state == State.SEARCHING) - { - data.add(searcher.found); - } - else { - data.add(getSize()); - } - - if(missingStack != null) - { - data.add(true); - data.add(MekanismUtils.getID(missingStack)); - data.add(missingStack.getItemDamage()); - } - else { - data.add(false); - } - - return data; - } - - public ArrayList getGenericPacket(ArrayList data) - { - super.getNetworkedData(data); - - data.add(1); - - data.add(radius); - data.add(minY); - data.add(maxY); - data.add(doEject); - data.add(doPull); - data.add(isActive); - data.add(running); - data.add(silkTouch); - data.add(numPowering); - data.add(searcher.state.ordinal()); - - if(searcher.state == State.SEARCHING) - { - data.add(searcher.found); - } - else { - data.add(getSize()); - } - - data.add(controlType.ordinal()); - data.add(inverse); - - if(missingStack != null) - { - data.add(true); - data.add(MekanismUtils.getID(missingStack)); - data.add(missingStack.getItemDamage()); - } - else { - data.add(false); - } - - return data; - } - - public ArrayList getFilterPacket(ArrayList data) - { - super.getNetworkedData(data); - - data.add(2); - - data.add(filters.size()); - - for(MinerFilter filter : filters) - { - filter.write(data); - } - - return data; - } - - public int getTotalSize() - { - return getDiameter()*getDiameter()*(maxY-minY+1); - } - - public int getDiameter() - { - return (radius*2)+1; - } - - public Coord4D getStartingCoord() - { - return new Coord4D(xCoord-radius, minY, zCoord-radius, worldObj.provider.dimensionId); - } - - public Coord4D getCoordFromIndex(int index) - { - int diameter = getDiameter(); - Coord4D start = getStartingCoord(); - - int x = start.xCoord+index%diameter; - int z = start.zCoord+(index/diameter)%diameter; - int y = start.yCoord+(index/diameter/diameter); - - return new Coord4D(x, y, z, worldObj.provider.dimensionId); - } - - @Override - public boolean isPowered() - { - return redstone || numPowering > 0; - } - - @Override - public boolean canPulse() - { - return false; - } - - @Override - public RedstoneControl getControlType() - { - return controlType; - } - - @Override - public void setControlType(RedstoneControl type) - { - controlType = type; - MekanismUtils.saveChunk(this); - } - - @Override - public TileComponentUpgrade getComponent() - { - return upgradeComponent; - } - - @Override - public void setActive(boolean active) - { - isActive = active; - - if(clientActive != active) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - - clientActive = active; - } - } - - @Override - public boolean getActive() - { - return isActive; - } - - @Override - public boolean renderUpdate() - { - return false; - } - - @Override - public boolean lightUpdate() - { - return false; - } - - @Override - @SideOnly(Side.CLIENT) - public AxisAlignedBB getRenderBoundingBox() - { - return INFINITE_EXTENT_AABB; - } - - @Override - public void onPlace() - { - for(int x = xCoord-1; x <= xCoord+1; x++) - { - for(int y = yCoord; y <= yCoord+1; y++) - { - for(int z = zCoord-1; z <= zCoord+1; z++) - { - if(x == xCoord && y == yCoord && z == zCoord) - { - continue; - } - - MekanismUtils.makeAdvancedBoundingBlock(worldObj, new Coord4D(x, y, z, worldObj.provider.dimensionId), Coord4D.get(this)); - worldObj.func_147453_f(x, y, z, getBlockType()); - } - } - } - } - - @Override - public boolean canSetFacing(int side) - { - return side != 0 && side != 1; - } - - @Override - public void onBreak() - { - for(int x = xCoord-1; x <= xCoord+1; x++) - { - for(int y = yCoord; y <= yCoord+1; y++) - { - for(int z = zCoord-1; z <= zCoord+1; z++) - { - worldObj.setBlockToAir(x, y, z); - } - } - } - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) - { - return InventoryUtils.EMPTY; - } - - public TileEntity getEjectTile() - { - ForgeDirection side = ForgeDirection.getOrientation(facing).getOpposite(); - return new Coord4D(xCoord+side.offsetX, yCoord+1, zCoord+side.offsetZ, worldObj.provider.dimensionId).getTileEntity(worldObj); - } - - @Override - public int[] getBoundSlots(Coord4D location, int side) - { - ForgeDirection dir = ForgeDirection.getOrientation(facing).getOpposite(); - - Coord4D eject = Coord4D.get(this).translate(dir.offsetX, 1, dir.offsetZ); - Coord4D pull = Coord4D.get(this).translate(0, 1, 0); - - if((location.equals(eject) && side == dir.ordinal()) || (location.equals(pull) && side == 1)) - { - if(EJECT_INV == null) - { - EJECT_INV = new int[27]; - - for(int i = 0; i < EJECT_INV.length; i++) - { - EJECT_INV[i] = i; - } - } - - return EJECT_INV; - } - - return InventoryUtils.EMPTY; - } - - @Override - public boolean canBoundInsert(Coord4D location, int i, ItemStack itemstack) - { - ForgeDirection side = ForgeDirection.getOrientation(facing).getOpposite(); - - Coord4D eject = Coord4D.get(this).translate(side.offsetX, 1, side.offsetZ); - Coord4D pull = Coord4D.get(this).translate(0, 1, 0); - - if(location.equals(eject)) - { - return false; - } - else if(location.equals(pull)) - { - if(itemstack != null && isReplaceStack(itemstack)) - { - return true; - } - } - - return false; - } - - @Override - public boolean canBoundExtract(Coord4D location, int i, ItemStack itemstack, int j) - { - ForgeDirection side = ForgeDirection.getOrientation(facing).getOpposite(); - - Coord4D eject = new Coord4D(xCoord+side.offsetX, yCoord+1, zCoord+side.offsetZ, worldObj.provider.dimensionId); - Coord4D pull = new Coord4D(xCoord, yCoord+1, zCoord, worldObj.provider.dimensionId); - - if(location.equals(eject)) - { - if(itemstack != null && isReplaceStack(itemstack)) - { - return false; - } - - return true; - } - else if(location.equals(pull)) - { - return false; - } - - return false; - } - - @Override - public void onPower() - { - numPowering++; - } - - @Override - public void onNoPower() - { - numPowering--; - } - - public String[] methods = {"setRadius", "setMin", "setMax", "addFilter", "removeFilter", "addOreFilter", "removeOreFilter", "reset", "start", "stop", "getToMine"}; - - @Override - public String[] getMethods() - { - return methods; - } - - @Override - public Object[] invoke(int method, Object[] arguments) throws Exception - { - if(arguments.length > 0) - { - int num = 0; - - if(arguments[0] instanceof Double) - { - num = ((Double)arguments[0]).intValue(); - } - else if(arguments[0] instanceof String && (method != 5 && method != 6)) - { - num = Integer.parseInt((String)arguments[0]); - } - - if(num != 0) - { - if(method == 0) - { - radius = num; - } - else if(method == 1) - { - minY = num; - } - else if(method == 2) - { - maxY = num; - } - else if(method == 3) - { - int meta = 0; - - if(arguments.length > 1) - { - if(arguments[1] instanceof Double) - { - meta = ((Double)arguments[1]).intValue(); - } - else if(arguments[1] instanceof String) - { - meta = Integer.parseInt((String)arguments[1]); - } - } - - filters.add(new MItemStackFilter(new ItemStack(Item.getItemById(num), 1, meta))); - } - else if(method == 4) - { - Iterator iter = filters.iterator(); - - while(iter.hasNext()) - { - MinerFilter filter = iter.next(); - - if(filter instanceof MItemStackFilter) - { - if(MekanismUtils.getID(((MItemStackFilter)filter).itemType) == num) - { - iter.remove(); - } - } - } - } - else if(method == 5) - { - String ore = (String)arguments[0]; - MOreDictFilter filter = new MOreDictFilter(); - - filter.oreDictName = ore; - filters.add(filter); - } - else if(method == 6) - { - String ore = (String)arguments[0]; - Iterator iter = filters.iterator(); - - while(iter.hasNext()) - { - MinerFilter filter = iter.next(); - - if(filter instanceof MOreDictFilter) - { - if(((MOreDictFilter)filter).oreDictName == ore) - { - iter.remove(); - } - } - } - } - } - else if(method == 7) - { - reset(); - } - else if(method == 8) - { - start(); - } - else if(method == 9) - { - stop(); - } - else if(method == 10) - { - return new Object[] {searcher != null ? searcher.found : 0}; - } - } - - for(EntityPlayer player : playersUsing) - { - Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(this), getGenericPacket(new ArrayList())), (EntityPlayerMP)player); - } - - return null; - } - - @Override - public NBTTagCompound getConfigurationData(NBTTagCompound nbtTags) - { - nbtTags.setInteger("radius", radius); - nbtTags.setInteger("minY", minY); - nbtTags.setInteger("maxY", maxY); - nbtTags.setBoolean("doEject", doEject); - nbtTags.setBoolean("doPull", doPull); - nbtTags.setBoolean("silkTouch", silkTouch); - nbtTags.setBoolean("inverse", inverse); - - NBTTagList filterTags = new NBTTagList(); - - for(MinerFilter filter : filters) - { - filterTags.appendTag(filter.write(new NBTTagCompound())); - } - - if(filterTags.tagCount() != 0) - { - nbtTags.setTag("filters", filterTags); - } - - return nbtTags; - } - - @Override - public void setConfigurationData(NBTTagCompound nbtTags) - { - radius = nbtTags.getInteger("radius"); - minY = nbtTags.getInteger("minY"); - maxY = nbtTags.getInteger("maxY"); - doEject = nbtTags.getBoolean("doEject"); - doPull = nbtTags.getBoolean("doPull"); - silkTouch = nbtTags.getBoolean("silkTouch"); - inverse = nbtTags.getBoolean("inverse"); - - if(nbtTags.hasKey("filters")) - { - NBTTagList tagList = nbtTags.getTagList("filters", NBT.TAG_COMPOUND); - - for(int i = 0; i < tagList.tagCount(); i++) - { - filters.add(MinerFilter.readFromNBT((NBTTagCompound)tagList.getCompoundTagAt(i))); - } - } - } - - @Override - public String getDataType() - { - return getBlockType().getUnlocalizedName() + "." + fullName + ".name"; - } - - public void writeSustainedData(ItemStack itemStack) - { - itemStack.stackTagCompound.setBoolean("hasMinerConfig", true); - - itemStack.stackTagCompound.setInteger("radius", radius); - itemStack.stackTagCompound.setInteger("minY", minY); - itemStack.stackTagCompound.setInteger("maxY", maxY); - itemStack.stackTagCompound.setBoolean("doEject", doEject); - itemStack.stackTagCompound.setBoolean("doPull", doPull); - itemStack.stackTagCompound.setBoolean("silkTouch", silkTouch); - itemStack.stackTagCompound.setBoolean("inverse", inverse); - - NBTTagList filterTags = new NBTTagList(); - - for(MinerFilter filter : filters) - { - filterTags.appendTag(filter.write(new NBTTagCompound())); - } - - if(filterTags.tagCount() != 0) - { - itemStack.stackTagCompound.setTag("filters", filterTags); - } - } - - @Override - public void readSustainedData(ItemStack itemStack) - { - if(itemStack.stackTagCompound.hasKey("hasMinerConfig")) - { - radius = itemStack.stackTagCompound.getInteger("radius"); - minY = itemStack.stackTagCompound.getInteger("minY"); - maxY = itemStack.stackTagCompound.getInteger("maxY"); - doEject = itemStack.stackTagCompound.getBoolean("doEject"); - doPull = itemStack.stackTagCompound.getBoolean("doPull"); - silkTouch = itemStack.stackTagCompound.getBoolean("silkTouch"); - inverse = itemStack.stackTagCompound.getBoolean("inverse"); - - if(itemStack.stackTagCompound.hasKey("filters")) - { - NBTTagList tagList = itemStack.stackTagCompound.getTagList("filters", NBT.TAG_COMPOUND); - - for(int i = 0; i < tagList.tagCount(); i++) - { - filters.add(MinerFilter.readFromNBT((NBTTagCompound)tagList.getCompoundTagAt(i))); - } - } - } - } - - @Override - public void recalculateUpgradables(Upgrade upgrade) - { - super.recalculateUpgradables(upgrade); - - switch(upgrade) - { - case SPEED: - delayLength = MekanismUtils.getTicks(this, BASE_DELAY); - case ENERGY: - energyUsage = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_USAGE); - maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY); - default: - break; - } - } - - @Override - public boolean canBoundReceiveEnergy(Coord4D coord, ForgeDirection side) - { - ForgeDirection left = MekanismUtils.getLeft(facing); - ForgeDirection right = MekanismUtils.getRight(facing); - - if(coord.equals(Coord4D.get(this).getFromSide(left))) - { - return side == left; - } - else if(coord.equals(Coord4D.get(this).getFromSide(right))) - { - return side == right; - } - - return false; - } - - @Override - public EnumSet getConsumingSides() - { - return EnumSet.of(MekanismUtils.getLeft(facing), MekanismUtils.getRight(facing), ForgeDirection.DOWN); - } - - @Override - public TileComponentSecurity getSecurity() - { - return securityComponent; - } + inventory[i].stackSize += stack.stackSize; + + continue stacks; + } + } + } + } + + public void start() { + if (searcher.state == State.IDLE) { + searcher.start(); + } + + running = true; + + MekanismUtils.saveChunk(this); + } + + public void stop() { + if (searcher.state == State.SEARCHING) { + searcher.interrupt(); + reset(); + + return; + } else if (searcher.state == State.FINISHED) { + running = false; + } + + MekanismUtils.saveChunk(this); + } + + public void reset() { + searcher = new ThreadMinerSearch(this); + running = false; + oresToMine.clear(); + replaceMap.clear(); + missingStack = null; + setActive(false); + + MekanismUtils.saveChunk(this); + } + + public boolean isReplaceStack(ItemStack stack) { + for (MinerFilter filter : filters) { + if (filter.replaceStack != null && filter.replaceStack.isItemEqual(stack)) { + return true; + } + } + + return false; + } + + public int getSize() { + int size = 0; + + for (Chunk3D chunk : oresToMine.keySet()) { + size += oresToMine.get(chunk).cardinality(); + } + + return size; + } + + @Override + public void openInventory() { + super.openInventory(); + + if (!worldObj.isRemote) { + for (EntityPlayer player : playersUsing) { + Mekanism.packetHandler.sendTo( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + (EntityPlayerMP) player + ); + } + } + } + + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); + + radius = nbtTags.getInteger("radius"); + minY = nbtTags.getInteger("minY"); + maxY = nbtTags.getInteger("maxY"); + doEject = nbtTags.getBoolean("doEject"); + doPull = nbtTags.getBoolean("doPull"); + isActive = nbtTags.getBoolean("isActive"); + running = nbtTags.getBoolean("running"); + delay = nbtTags.getInteger("delay"); + silkTouch = nbtTags.getBoolean("silkTouch"); + numPowering = nbtTags.getInteger("numPowering"); + searcher.state = State.values()[nbtTags.getInteger("state")]; + controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + inverse = nbtTags.getBoolean("inverse"); + + if (nbtTags.hasKey("filters")) { + NBTTagList tagList = nbtTags.getTagList("filters", NBT.TAG_COMPOUND); + + for (int i = 0; i < tagList.tagCount(); i++) { + filters.add(MinerFilter.readFromNBT((NBTTagCompound + ) tagList.getCompoundTagAt(i))); + } + } + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); + + if (searcher.state == State.SEARCHING) { + reset(); + } + + nbtTags.setInteger("radius", radius); + nbtTags.setInteger("minY", minY); + nbtTags.setInteger("maxY", maxY); + nbtTags.setBoolean("doEject", doEject); + nbtTags.setBoolean("doPull", doPull); + nbtTags.setBoolean("isActive", isActive); + nbtTags.setBoolean("running", running); + nbtTags.setInteger("delay", delay); + nbtTags.setBoolean("silkTouch", silkTouch); + nbtTags.setInteger("numPowering", numPowering); + nbtTags.setInteger("state", searcher.state.ordinal()); + nbtTags.setInteger("controlType", controlType.ordinal()); + nbtTags.setBoolean("inverse", inverse); + + NBTTagList filterTags = new NBTTagList(); + + for (MinerFilter filter : filters) { + filterTags.appendTag(filter.write(new NBTTagCompound())); + } + + if (filterTags.tagCount() != 0) { + nbtTags.setTag("filters", filterTags); + } + } + + @Override + public void handlePacketData(ByteBuf dataStream) { + if (!worldObj.isRemote) { + int type = dataStream.readInt(); + + if (type == 0) { + doEject = !doEject; + } else if (type == 1) { + doPull = !doPull; + } else if (type == 2) { + //Unneeded at the moment + } else if (type == 3) { + start(); + } else if (type == 4) { + stop(); + } else if (type == 5) { + reset(); + } else if (type == 6) { + radius = dataStream.readInt(); + } else if (type == 7) { + minY = dataStream.readInt(); + } else if (type == 8) { + maxY = dataStream.readInt(); + } else if (type == 9) { + silkTouch = !silkTouch; + } else if (type == 10) { + inverse = !inverse; + } else if (type == 11) { + // Move filter up + int filterIndex = dataStream.readInt(); + filters.swap(filterIndex, filterIndex - 1); + openInventory(); + } else if (type == 12) { + // Move filter down + int filterIndex = dataStream.readInt(); + filters.swap(filterIndex, filterIndex + 1); + openInventory(); + } + + MekanismUtils.saveChunk(this); + + for (EntityPlayer player : playersUsing) { + Mekanism.packetHandler.sendTo( + new TileEntityMessage( + Coord4D.get(this), getGenericPacket(new ArrayList()) + ), + (EntityPlayerMP) player + ); + } + + return; + } + + super.handlePacketData(dataStream); + + if (worldObj.isRemote) { + int type = dataStream.readInt(); + + if (type == 0) { + radius = dataStream.readInt(); + minY = dataStream.readInt(); + maxY = dataStream.readInt(); + doEject = dataStream.readBoolean(); + doPull = dataStream.readBoolean(); + clientActive = dataStream.readBoolean(); + running = dataStream.readBoolean(); + silkTouch = dataStream.readBoolean(); + numPowering = dataStream.readInt(); + searcher.state = State.values()[dataStream.readInt()]; + clientToMine = dataStream.readInt(); + controlType = RedstoneControl.values()[dataStream.readInt()]; + inverse = dataStream.readBoolean(); + + if (dataStream.readBoolean()) { + missingStack = new ItemStack( + Item.getItemById(dataStream.readInt()), 1, dataStream.readInt() + ); + } else { + missingStack = null; + } + + filters.clear(); + + int amount = dataStream.readInt(); + + for (int i = 0; i < amount; i++) { + filters.add(MinerFilter.readFromPacket(dataStream)); + } + } else if (type == 1) { + radius = dataStream.readInt(); + minY = dataStream.readInt(); + maxY = dataStream.readInt(); + doEject = dataStream.readBoolean(); + doPull = dataStream.readBoolean(); + clientActive = dataStream.readBoolean(); + running = dataStream.readBoolean(); + silkTouch = dataStream.readBoolean(); + numPowering = dataStream.readInt(); + searcher.state = State.values()[dataStream.readInt()]; + clientToMine = dataStream.readInt(); + controlType = RedstoneControl.values()[dataStream.readInt()]; + inverse = dataStream.readBoolean(); + + if (dataStream.readBoolean()) { + missingStack = new ItemStack( + Item.getItemById(dataStream.readInt()), 1, dataStream.readInt() + ); + } else { + missingStack = null; + } + } else if (type == 2) { + filters.clear(); + + int amount = dataStream.readInt(); + + for (int i = 0; i < amount; i++) { + filters.add(MinerFilter.readFromPacket(dataStream)); + } + } else if (type == 3) { + clientActive = dataStream.readBoolean(); + running = dataStream.readBoolean(); + clientToMine = dataStream.readInt(); + + if (dataStream.readBoolean()) { + missingStack = new ItemStack( + Item.getItemById(dataStream.readInt()), 1, dataStream.readInt() + ); + } else { + missingStack = null; + } + } + + if (clientActive != isActive) { + isActive = clientActive; + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } + } + + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); + + data.add(0); + + data.add(radius); + data.add(minY); + data.add(maxY); + data.add(doEject); + data.add(doPull); + data.add(isActive); + data.add(running); + data.add(silkTouch); + data.add(numPowering); + data.add(searcher.state.ordinal()); + + if (searcher.state == State.SEARCHING) { + data.add(searcher.found); + } else { + data.add(getSize()); + } + + data.add(controlType.ordinal()); + data.add(inverse); + + if (missingStack != null) { + data.add(true); + data.add(MekanismUtils.getID(missingStack)); + data.add(missingStack.getItemDamage()); + } else { + data.add(false); + } + + data.add(filters.size()); + + for (MinerFilter filter : filters) { + filter.write(data); + } + + return data; + } + + public ArrayList getSmallPacket(ArrayList data) { + super.getNetworkedData(data); + + data.add(3); + + data.add(isActive); + data.add(running); + + if (searcher.state == State.SEARCHING) { + data.add(searcher.found); + } else { + data.add(getSize()); + } + + if (missingStack != null) { + data.add(true); + data.add(MekanismUtils.getID(missingStack)); + data.add(missingStack.getItemDamage()); + } else { + data.add(false); + } + + return data; + } + + public ArrayList getGenericPacket(ArrayList data) { + super.getNetworkedData(data); + + data.add(1); + + data.add(radius); + data.add(minY); + data.add(maxY); + data.add(doEject); + data.add(doPull); + data.add(isActive); + data.add(running); + data.add(silkTouch); + data.add(numPowering); + data.add(searcher.state.ordinal()); + + if (searcher.state == State.SEARCHING) { + data.add(searcher.found); + } else { + data.add(getSize()); + } + + data.add(controlType.ordinal()); + data.add(inverse); + + if (missingStack != null) { + data.add(true); + data.add(MekanismUtils.getID(missingStack)); + data.add(missingStack.getItemDamage()); + } else { + data.add(false); + } + + return data; + } + + public ArrayList getFilterPacket(ArrayList data) { + super.getNetworkedData(data); + + data.add(2); + + data.add(filters.size()); + + for (MinerFilter filter : filters) { + filter.write(data); + } + + return data; + } + + public int getTotalSize() { + return getDiameter() * getDiameter() * (maxY - minY + 1); + } + + public int getDiameter() { + return (radius * 2) + 1; + } + + public Coord4D getStartingCoord() { + return new Coord4D( + xCoord - radius, minY, zCoord - radius, worldObj.provider.dimensionId + ); + } + + public Coord4D getCoordFromIndex(int index) { + int diameter = getDiameter(); + Coord4D start = getStartingCoord(); + + int x = start.xCoord + index % diameter; + int z = start.zCoord + (index / diameter) % diameter; + int y = start.yCoord + (index / diameter / diameter); + + return new Coord4D(x, y, z, worldObj.provider.dimensionId); + } + + @Override + public boolean isPowered() { + return redstone || numPowering > 0; + } + + @Override + public boolean canPulse() { + return false; + } + + @Override + public RedstoneControl getControlType() { + return controlType; + } + + @Override + public void setControlType(RedstoneControl type) { + controlType = type; + MekanismUtils.saveChunk(this); + } + + @Override + public TileComponentUpgrade getComponent() { + return upgradeComponent; + } + + @Override + public void setActive(boolean active) { + isActive = active; + + if (clientActive != active) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + + clientActive = active; + } + } + + @Override + public boolean getActive() { + return isActive; + } + + @Override + public boolean renderUpdate() { + return false; + } + + @Override + public boolean lightUpdate() { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public AxisAlignedBB getRenderBoundingBox() { + return INFINITE_EXTENT_AABB; + } + + @Override + public void onPlace() { + for (int x = xCoord - 1; x <= xCoord + 1; x++) { + for (int y = yCoord; y <= yCoord + 1; y++) { + for (int z = zCoord - 1; z <= zCoord + 1; z++) { + if (x == xCoord && y == yCoord && z == zCoord) { + continue; + } + + MekanismUtils.makeAdvancedBoundingBlock( + worldObj, + new Coord4D(x, y, z, worldObj.provider.dimensionId), + Coord4D.get(this) + ); + worldObj.func_147453_f(x, y, z, getBlockType()); + } + } + } + } + + @Override + public boolean canSetFacing(int side) { + return side != 0 && side != 1; + } + + @Override + public void onBreak() { + for (int x = xCoord - 1; x <= xCoord + 1; x++) { + for (int y = yCoord; y <= yCoord + 1; y++) { + for (int z = zCoord - 1; z <= zCoord + 1; z++) { + worldObj.setBlockToAir(x, y, z); + } + } + } + } + + @Override + public int[] getAccessibleSlotsFromSide(int side) { + return InventoryUtils.EMPTY; + } + + public TileEntity getEjectTile() { + ForgeDirection side = ForgeDirection.getOrientation(facing).getOpposite(); + return new Coord4D( + xCoord + side.offsetX, + yCoord + 1, + zCoord + side.offsetZ, + worldObj.provider.dimensionId + ) + .getTileEntity(worldObj); + } + + @Override + public int[] getBoundSlots(Coord4D location, int side) { + ForgeDirection dir = ForgeDirection.getOrientation(facing).getOpposite(); + + Coord4D eject = Coord4D.get(this).translate(dir.offsetX, 1, dir.offsetZ); + Coord4D pull = Coord4D.get(this).translate(0, 1, 0); + + if ((location.equals(eject) && side == dir.ordinal()) + || (location.equals(pull) && side == 1)) { + if (EJECT_INV == null) { + EJECT_INV = new int[27]; + + for (int i = 0; i < EJECT_INV.length; i++) { + EJECT_INV[i] = i; + } + } + + return EJECT_INV; + } + + return InventoryUtils.EMPTY; + } + + @Override + public boolean canBoundInsert(Coord4D location, int i, ItemStack itemstack) { + ForgeDirection side = ForgeDirection.getOrientation(facing).getOpposite(); + + Coord4D eject = Coord4D.get(this).translate(side.offsetX, 1, side.offsetZ); + Coord4D pull = Coord4D.get(this).translate(0, 1, 0); + + if (location.equals(eject)) { + return false; + } else if (location.equals(pull)) { + if (itemstack != null && isReplaceStack(itemstack)) { + return true; + } + } + + return false; + } + + @Override + public boolean canBoundExtract(Coord4D location, int i, ItemStack itemstack, int j) { + ForgeDirection side = ForgeDirection.getOrientation(facing).getOpposite(); + + Coord4D eject = new Coord4D( + xCoord + side.offsetX, + yCoord + 1, + zCoord + side.offsetZ, + worldObj.provider.dimensionId + ); + Coord4D pull + = new Coord4D(xCoord, yCoord + 1, zCoord, worldObj.provider.dimensionId); + + if (location.equals(eject)) { + if (itemstack != null && isReplaceStack(itemstack)) { + return false; + } + + return true; + } else if (location.equals(pull)) { + return false; + } + + return false; + } + + @Override + public void onPower() { + numPowering++; + } + + @Override + public void onNoPower() { + numPowering--; + } + + public String[] methods + = { "setRadius", "setMin", "setMax", "addFilter", + "removeFilter", "addOreFilter", "removeOreFilter", "reset", + "start", "stop", "getToMine" }; + + @Override + public String[] getMethods() { + return methods; + } + + @Override + public Object[] invoke(int method, Object[] arguments) throws Exception { + if (arguments.length > 0) { + int num = 0; + + if (arguments[0] instanceof Double) { + num = ((Double) arguments[0]).intValue(); + } else if (arguments[0] instanceof String && (method != 5 && method != 6)) { + num = Integer.parseInt((String) arguments[0]); + } + + if (num != 0) { + if (method == 0) { + radius = num; + } else if (method == 1) { + minY = num; + } else if (method == 2) { + maxY = num; + } else if (method == 3) { + int meta = 0; + + if (arguments.length > 1) { + if (arguments[1] instanceof Double) { + meta = ((Double) arguments[1]).intValue(); + } else if (arguments[1] instanceof String) { + meta = Integer.parseInt((String) arguments[1]); + } + } + + filters.add(new MItemStackFilter( + new ItemStack(Item.getItemById(num), 1, meta) + )); + } else if (method == 4) { + Iterator iter = filters.iterator(); + + while (iter.hasNext()) { + MinerFilter filter = iter.next(); + + if (filter instanceof MItemStackFilter) { + if (MekanismUtils.getID(((MItemStackFilter) filter).itemType) + == num) { + iter.remove(); + } + } + } + } else if (method == 5) { + String ore = (String) arguments[0]; + MOreDictFilter filter = new MOreDictFilter(); + + filter.oreDictName = ore; + filters.add(filter); + } else if (method == 6) { + String ore = (String) arguments[0]; + Iterator iter = filters.iterator(); + + while (iter.hasNext()) { + MinerFilter filter = iter.next(); + + if (filter instanceof MOreDictFilter) { + if (((MOreDictFilter) filter).oreDictName == ore) { + iter.remove(); + } + } + } + } + } else if (method == 7) { + reset(); + } else if (method == 8) { + start(); + } else if (method == 9) { + stop(); + } else if (method == 10) { + return new Object[] { searcher != null ? searcher.found : 0 }; + } + } + + for (EntityPlayer player : playersUsing) { + Mekanism.packetHandler.sendTo( + new TileEntityMessage( + Coord4D.get(this), getGenericPacket(new ArrayList()) + ), + (EntityPlayerMP) player + ); + } + + return null; + } + + @Override + public NBTTagCompound getConfigurationData(NBTTagCompound nbtTags) { + nbtTags.setInteger("radius", radius); + nbtTags.setInteger("minY", minY); + nbtTags.setInteger("maxY", maxY); + nbtTags.setBoolean("doEject", doEject); + nbtTags.setBoolean("doPull", doPull); + nbtTags.setBoolean("silkTouch", silkTouch); + nbtTags.setBoolean("inverse", inverse); + + NBTTagList filterTags = new NBTTagList(); + + for (MinerFilter filter : filters) { + filterTags.appendTag(filter.write(new NBTTagCompound())); + } + + if (filterTags.tagCount() != 0) { + nbtTags.setTag("filters", filterTags); + } + + return nbtTags; + } + + @Override + public void setConfigurationData(NBTTagCompound nbtTags) { + radius = nbtTags.getInteger("radius"); + minY = nbtTags.getInteger("minY"); + maxY = nbtTags.getInteger("maxY"); + doEject = nbtTags.getBoolean("doEject"); + doPull = nbtTags.getBoolean("doPull"); + silkTouch = nbtTags.getBoolean("silkTouch"); + inverse = nbtTags.getBoolean("inverse"); + + if (nbtTags.hasKey("filters")) { + NBTTagList tagList = nbtTags.getTagList("filters", NBT.TAG_COMPOUND); + + for (int i = 0; i < tagList.tagCount(); i++) { + filters.add(MinerFilter.readFromNBT((NBTTagCompound + ) tagList.getCompoundTagAt(i))); + } + } + } + + @Override + public String getDataType() { + return getBlockType().getUnlocalizedName() + "." + fullName + ".name"; + } + + public void writeSustainedData(ItemStack itemStack) { + itemStack.stackTagCompound.setBoolean("hasMinerConfig", true); + + itemStack.stackTagCompound.setInteger("radius", radius); + itemStack.stackTagCompound.setInteger("minY", minY); + itemStack.stackTagCompound.setInteger("maxY", maxY); + itemStack.stackTagCompound.setBoolean("doEject", doEject); + itemStack.stackTagCompound.setBoolean("doPull", doPull); + itemStack.stackTagCompound.setBoolean("silkTouch", silkTouch); + itemStack.stackTagCompound.setBoolean("inverse", inverse); + + NBTTagList filterTags = new NBTTagList(); + + for (MinerFilter filter : filters) { + filterTags.appendTag(filter.write(new NBTTagCompound())); + } + + if (filterTags.tagCount() != 0) { + itemStack.stackTagCompound.setTag("filters", filterTags); + } + } + + @Override + public void readSustainedData(ItemStack itemStack) { + if (itemStack.stackTagCompound.hasKey("hasMinerConfig")) { + radius = itemStack.stackTagCompound.getInteger("radius"); + minY = itemStack.stackTagCompound.getInteger("minY"); + maxY = itemStack.stackTagCompound.getInteger("maxY"); + doEject = itemStack.stackTagCompound.getBoolean("doEject"); + doPull = itemStack.stackTagCompound.getBoolean("doPull"); + silkTouch = itemStack.stackTagCompound.getBoolean("silkTouch"); + inverse = itemStack.stackTagCompound.getBoolean("inverse"); + + if (itemStack.stackTagCompound.hasKey("filters")) { + NBTTagList tagList + = itemStack.stackTagCompound.getTagList("filters", NBT.TAG_COMPOUND); + + for (int i = 0; i < tagList.tagCount(); i++) { + filters.add(MinerFilter.readFromNBT((NBTTagCompound + ) tagList.getCompoundTagAt(i))); + } + } + } + } + + @Override + public void recalculateUpgradables(Upgrade upgrade) { + super.recalculateUpgradables(upgrade); + + switch (upgrade) { + case SPEED: + delayLength = MekanismUtils.getTicks(this, BASE_DELAY); + case ENERGY: + energyUsage = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_USAGE); + maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY); + default: + break; + } + } + + @Override + public boolean canBoundReceiveEnergy(Coord4D coord, ForgeDirection side) { + ForgeDirection left = MekanismUtils.getLeft(facing); + ForgeDirection right = MekanismUtils.getRight(facing); + + if (coord.equals(Coord4D.get(this).getFromSide(left))) { + return side == left; + } else if (coord.equals(Coord4D.get(this).getFromSide(right))) { + return side == right; + } + + return false; + } + + @Override + public EnumSet getConsumingSides() { + return EnumSet.of( + MekanismUtils.getLeft(facing), + MekanismUtils.getRight(facing), + ForgeDirection.DOWN + ); + } + + @Override + public TileComponentSecurity getSecurity() { + return securityComponent; + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityDynamicTank.java b/src/main/java/mekanism/common/tile/TileEntityDynamicTank.java index 3ec314a60..7fbc679d3 100644 --- a/src/main/java/mekanism/common/tile/TileEntityDynamicTank.java +++ b/src/main/java/mekanism/common/tile/TileEntityDynamicTank.java @@ -1,11 +1,10 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.HashSet; import java.util.Set; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.Range4D; import mekanism.common.Mekanism; @@ -27,299 +26,289 @@ import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidContainerItem; -public class TileEntityDynamicTank extends TileEntityMultiblock implements IFluidContainerManager -{ - /** A client-sided set of valves on this tank's structure that are currently active, used on the client for rendering fluids. */ - public Set valveViewing = new HashSet(); +public class TileEntityDynamicTank + extends TileEntityMultiblock implements IFluidContainerManager { + /** + * A client-sided set of valves on this tank's structure that are currently active, + * used on the client for rendering fluids. + */ + public Set valveViewing = new HashSet(); - /** The capacity this tank has on the client-side. */ - public int clientCapacity; + /** The capacity this tank has on the client-side. */ + public int clientCapacity; - public float prevScale; + public float prevScale; - public TileEntityDynamicTank() - { - super("DynamicTank"); - } + public TileEntityDynamicTank() { + super("DynamicTank"); + } - public TileEntityDynamicTank(String name) - { - super(name); - inventory = new ItemStack[2]; - } + public TileEntityDynamicTank(String name) { + super(name); + inventory = new ItemStack[2]; + } - @Override - public void onUpdate() - { - super.onUpdate(); - - if(worldObj.isRemote) - { - if(structure != null && clientHasStructure && isRendering) - { - float targetScale = (float)(structure.fluidStored != null ? structure.fluidStored.amount : 0)/clientCapacity; - - if(Math.abs(prevScale - targetScale) > 0.01) - { - prevScale = (9*prevScale + targetScale)/10; - } - } + @Override + public void onUpdate() { + super.onUpdate(); - if(!clientHasStructure || !isRendering) - { - for(ValveData data : valveViewing) - { - TileEntityDynamicTank tileEntity = (TileEntityDynamicTank)data.location.getTileEntity(worldObj); + if (worldObj.isRemote) { + if (structure != null && clientHasStructure && isRendering) { + float targetScale + = (float + ) (structure.fluidStored != null ? structure.fluidStored.amount : 0) + / clientCapacity; - if(tileEntity != null) - { - tileEntity.clientHasStructure = false; - } - } + if (Math.abs(prevScale - targetScale) > 0.01) { + prevScale = (9 * prevScale + targetScale) / 10; + } + } - valveViewing.clear(); - } - } + if (!clientHasStructure || !isRendering) { + for (ValveData data : valveViewing) { + TileEntityDynamicTank tileEntity + = (TileEntityDynamicTank) data.location.getTileEntity(worldObj); - if(!worldObj.isRemote) - { - if(structure != null) - { - if(structure.fluidStored != null && structure.fluidStored.amount <= 0) - { - structure.fluidStored = null; - markDirty(); - } - - if(isRendering) - { - boolean needsValveUpdate = false; - - for(ValveData data : structure.valves) - { - if(data.activeTicks > 0) - { - data.activeTicks--; - } - - if(data.activeTicks > 0 != data.prevActive) - { - needsValveUpdate = true; - } - - data.prevActive = data.activeTicks > 0; - } - - if(needsValveUpdate || structure.needsRenderUpdate()) - { - sendPacketToRenderer(); - } - - structure.prevFluid = structure.prevFluid != null ? structure.fluidStored.copy() : null; - - manageInventory(); - } - } - } - } + if (tileEntity != null) { + tileEntity.clientHasStructure = false; + } + } - public void manageInventory() - { - int needed = (structure.volume*TankUpdateProtocol.FLUID_PER_TANK)-(structure.fluidStored != null ? structure.fluidStored.amount : 0); + valveViewing.clear(); + } + } - if(structure.inventory[0] != null) - { - if(structure.inventory[0].getItem() instanceof IFluidContainerItem) - { - if(structure.editMode == ContainerEditMode.FILL && structure.fluidStored != null) - { - structure.fluidStored = FluidContainerUtils.handleContainerItemFill(this, structure.inventory, structure.fluidStored, 0, 1); - } - else if(structure.editMode == ContainerEditMode.EMPTY) - { - structure.fluidStored = FluidContainerUtils.handleContainerItemEmpty(this, structure.inventory, structure.fluidStored, needed, 0, 1, null); - } - } + if (!worldObj.isRemote) { + if (structure != null) { + if (structure.fluidStored != null && structure.fluidStored.amount <= 0) { + structure.fluidStored = null; + markDirty(); + } + + if (isRendering) { + boolean needsValveUpdate = false; + + for (ValveData data : structure.valves) { + if (data.activeTicks > 0) { + data.activeTicks--; + } + + if (data.activeTicks > 0 != data.prevActive) { + needsValveUpdate = true; + } + + data.prevActive = data.activeTicks > 0; + } + + if (needsValveUpdate || structure.needsRenderUpdate()) { + sendPacketToRenderer(); + } + + structure.prevFluid = structure.prevFluid != null + ? structure.fluidStored.copy() + : null; + + manageInventory(); + } + } + } + } + + public void manageInventory() { + int needed = (structure.volume * TankUpdateProtocol.FLUID_PER_TANK) + - (structure.fluidStored != null ? structure.fluidStored.amount : 0); + + if (structure.inventory[0] != null) { + if (structure.inventory[0].getItem() instanceof IFluidContainerItem) { + if (structure.editMode == ContainerEditMode.FILL + && structure.fluidStored != null) { + structure.fluidStored = FluidContainerUtils.handleContainerItemFill( + this, structure.inventory, structure.fluidStored, 0, 1 + ); + } else if (structure.editMode == ContainerEditMode.EMPTY) { + structure.fluidStored = FluidContainerUtils.handleContainerItemEmpty( + this, + structure.inventory, + structure.fluidStored, + needed, + 0, + 1, + null + ); + } + } else if(FluidContainerRegistry.isEmptyContainer(structure.inventory[0]) && (structure.editMode == ContainerEditMode.BOTH || structure.editMode == ContainerEditMode.FILL)) { - structure.fluidStored = FluidContainerUtils.handleRegistryItemFill(this, structure.inventory, structure.fluidStored, 0, 1); - - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - } + structure.fluidStored = FluidContainerUtils.handleRegistryItemFill( + this, structure.inventory, structure.fluidStored, 0, 1 + ); + + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + } else if(FluidContainerRegistry.isFilledContainer(structure.inventory[0]) && (structure.editMode == ContainerEditMode.BOTH || structure.editMode == ContainerEditMode.EMPTY)) { - structure.fluidStored = FluidContainerUtils.handleRegistryItemEmpty(this, structure.inventory, structure.fluidStored, needed, 0, 1, null); - - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - } - } - } - - @Override - public boolean onActivate(EntityPlayer player) - { - if(!player.isSneaking() && structure != null) - { - if(!BlockBasic.manageInventory(player, this)) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - player.openGui(Mekanism.instance, 18, worldObj, xCoord, yCoord, zCoord); - } - else { - player.inventory.markDirty(); - sendPacketToRenderer(); - } + structure.fluidStored = FluidContainerUtils.handleRegistryItemEmpty( + this, structure.inventory, structure.fluidStored, needed, 0, 1, null + ); - return true; - } - - return false; - } - - @Override - protected SynchronizedTankData getNewStructure() - { - return new SynchronizedTankData(); - } - - @Override - public TankCache getNewCache() - { - return new TankCache(); - } - - @Override - protected TankUpdateProtocol getProtocol() - { - return new TankUpdateProtocol(this); - } - - @Override - public MultiblockManager getManager() - { - return Mekanism.tankManager; - } + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + } + } + } - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); - - if(structure != null) - { - data.add(structure.volume*TankUpdateProtocol.FLUID_PER_TANK); - data.add(structure.editMode.ordinal()); - - if(structure.fluidStored != null) - { - data.add(1); - data.add(structure.fluidStored.getFluidID()); - data.add(structure.fluidStored.amount); - } - else { - data.add(0); - } - - if(isRendering) - { - Set toSend = new HashSet(); + @Override + public boolean onActivate(EntityPlayer player) { + if (!player.isSneaking() && structure != null) { + if (!BlockBasic.manageInventory(player, this)) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + player.openGui(Mekanism.instance, 18, worldObj, xCoord, yCoord, zCoord); + } else { + player.inventory.markDirty(); + sendPacketToRenderer(); + } - for(ValveData valveData : structure.valves) - { - if(valveData.activeTicks > 0) - { - toSend.add(valveData); - } - } - - data.add(toSend.size()); - - for(ValveData valveData : toSend) - { - valveData.location.write(data); - data.add(valveData.side.ordinal()); - } - } - } + return true; + } - return data; - } + return false; + } - @Override - public void handlePacketData(ByteBuf dataStream) - { - super.handlePacketData(dataStream); - - if(worldObj.isRemote) - { - if(clientHasStructure) - { - clientCapacity = dataStream.readInt(); - structure.editMode = ContainerEditMode.values()[dataStream.readInt()]; - - if(dataStream.readInt() == 1) - { - structure.fluidStored = new FluidStack(FluidRegistry.getFluid(dataStream.readInt()), dataStream.readInt()); - } - else { - structure.fluidStored = null; - } - - if(isRendering) - { - int size = dataStream.readInt(); - - valveViewing.clear(); - - for(int i = 0; i < size; i++) - { - ValveData data = new ValveData(); - data.location = Coord4D.read(dataStream); - data.side = ForgeDirection.getOrientation(dataStream.readInt()); - - valveViewing.add(data); - - TileEntityDynamicTank tileEntity = (TileEntityDynamicTank)data.location.getTileEntity(worldObj); - - if(tileEntity != null) - { - tileEntity.clientHasStructure = true; - } - } - } - } - } - } + @Override + protected SynchronizedTankData getNewStructure() { + return new SynchronizedTankData(); + } - public int getScaledFluidLevel(long i) - { - if(clientCapacity == 0 || structure.fluidStored == null) - { - return 0; - } + @Override + public TankCache getNewCache() { + return new TankCache(); + } - return (int)(structure.fluidStored.amount*i / clientCapacity); - } + @Override + protected TankUpdateProtocol getProtocol() { + return new TankUpdateProtocol(this); + } - @Override - public ContainerEditMode getContainerEditMode() - { - if(structure != null) - { - return structure.editMode; - } - - return ContainerEditMode.BOTH; - } + @Override + public MultiblockManager getManager() { + return Mekanism.tankManager; + } - @Override - public void setContainerEditMode(ContainerEditMode mode) - { - if(structure == null) - { - return; - } - - structure.editMode = mode; - } + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); + + if (structure != null) { + data.add(structure.volume * TankUpdateProtocol.FLUID_PER_TANK); + data.add(structure.editMode.ordinal()); + + if (structure.fluidStored != null) { + data.add(1); + data.add(structure.fluidStored.getFluidID()); + data.add(structure.fluidStored.amount); + } else { + data.add(0); + } + + if (isRendering) { + Set toSend = new HashSet(); + + for (ValveData valveData : structure.valves) { + if (valveData.activeTicks > 0) { + toSend.add(valveData); + } + } + + data.add(toSend.size()); + + for (ValveData valveData : toSend) { + valveData.location.write(data); + data.add(valveData.side.ordinal()); + } + } + } + + return data; + } + + @Override + public void handlePacketData(ByteBuf dataStream) { + super.handlePacketData(dataStream); + + if (worldObj.isRemote) { + if (clientHasStructure) { + clientCapacity = dataStream.readInt(); + structure.editMode = ContainerEditMode.values()[dataStream.readInt()]; + + if (dataStream.readInt() == 1) { + structure.fluidStored = new FluidStack( + FluidRegistry.getFluid(dataStream.readInt()), dataStream.readInt() + ); + } else { + structure.fluidStored = null; + } + + if (isRendering) { + int size = dataStream.readInt(); + + valveViewing.clear(); + + for (int i = 0; i < size; i++) { + ValveData data = new ValveData(); + data.location = Coord4D.read(dataStream); + data.side = ForgeDirection.getOrientation(dataStream.readInt()); + + valveViewing.add(data); + + TileEntityDynamicTank tileEntity = (TileEntityDynamicTank + ) data.location.getTileEntity(worldObj); + + if (tileEntity != null) { + tileEntity.clientHasStructure = true; + } + } + } + } + } + } + + public int getScaledFluidLevel(long i) { + if (clientCapacity == 0 || structure.fluidStored == null) { + return 0; + } + + return (int) (structure.fluidStored.amount * i / clientCapacity); + } + + @Override + public ContainerEditMode getContainerEditMode() { + if (structure != null) { + return structure.editMode; + } + + return ContainerEditMode.BOTH; + } + + @Override + public void setContainerEditMode(ContainerEditMode mode) { + if (structure == null) { + return; + } + + structure.editMode = mode; + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityDynamicValve.java b/src/main/java/mekanism/common/tile/TileEntityDynamicValve.java index 5fb134cd2..7550912bb 100644 --- a/src/main/java/mekanism/common/tile/TileEntityDynamicValve.java +++ b/src/main/java/mekanism/common/tile/TileEntityDynamicValve.java @@ -9,68 +9,66 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; -public class TileEntityDynamicValve extends TileEntityDynamicTank implements IFluidHandler -{ - public DynamicFluidTank fluidTank; +public class TileEntityDynamicValve + extends TileEntityDynamicTank implements IFluidHandler { + public DynamicFluidTank fluidTank; - public TileEntityDynamicValve() - { - super("Dynamic Valve"); - fluidTank = new DynamicFluidTank(this); - } + public TileEntityDynamicValve() { + super("Dynamic Valve"); + fluidTank = new DynamicFluidTank(this); + } - @Override - public FluidTankInfo[] getTankInfo(ForgeDirection from) - { - return ((!worldObj.isRemote && structure != null) || (worldObj.isRemote && clientHasStructure)) ? new FluidTankInfo[] {fluidTank.getInfo()} : PipeUtils.EMPTY; - } + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection from) { + return ((!worldObj.isRemote && structure != null) + || (worldObj.isRemote && clientHasStructure)) + ? new FluidTankInfo[] { fluidTank.getInfo() } + : PipeUtils.EMPTY; + } - @Override - public int fill(ForgeDirection from, FluidStack resource, boolean doFill) - { - return fluidTank.fill(resource, doFill); - } + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { + return fluidTank.fill(resource, doFill); + } - @Override - public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) - { - if(structure != null && structure.fluidStored != null) - { - if(resource.getFluid() == structure.fluidStored.getFluid()) - { - return fluidTank.drain(resource.amount, doDrain); - } - } + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + if (structure != null && structure.fluidStored != null) { + if (resource.getFluid() == structure.fluidStored.getFluid()) { + return fluidTank.drain(resource.amount, doDrain); + } + } - return null; - } + return null; + } - @Override - public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) - { - if(structure != null) - { - return fluidTank.drain(maxDrain, doDrain); - } + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { + if (structure != null) { + return fluidTank.drain(maxDrain, doDrain); + } - return null; - } + return null; + } - @Override - public boolean canFill(ForgeDirection from, Fluid fluid) - { - return ((!worldObj.isRemote && structure != null) || (worldObj.isRemote && clientHasStructure)); - } + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + return ( + (!worldObj.isRemote && structure != null) + || (worldObj.isRemote && clientHasStructure) + ); + } - @Override - public boolean canDrain(ForgeDirection from, Fluid fluid) - { - return ((!worldObj.isRemote && structure != null) || (worldObj.isRemote && clientHasStructure)); - } - - @Override - public String getInventoryName() - { - return LangUtils.localize("gui.dynamicTank"); - } + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + return ( + (!worldObj.isRemote && structure != null) + || (worldObj.isRemote && clientHasStructure) + ); + } + + @Override + public String getInventoryName() { + return LangUtils.localize("gui.dynamicTank"); + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityElectricBlock.java b/src/main/java/mekanism/common/tile/TileEntityElectricBlock.java index 0498528ba..87f1e2582 100644 --- a/src/main/java/mekanism/common/tile/TileEntityElectricBlock.java +++ b/src/main/java/mekanism/common/tile/TileEntityElectricBlock.java @@ -1,15 +1,15 @@ package mekanism.common.tile; +import java.util.ArrayList; +import java.util.EnumSet; + +import cpw.mods.fml.common.Optional.Method; import ic2.api.energy.EnergyNet; import ic2.api.energy.event.EnergyTileLoadEvent; import ic2.api.energy.event.EnergyTileUnloadEvent; import ic2.api.energy.tile.IEnergyConductor; import ic2.api.energy.tile.IEnergyTile; import io.netty.buffer.ByteBuf; - -import java.util.ArrayList; -import java.util.EnumSet; - import mekanism.api.Coord4D; import mekanism.api.MekanismConfig.general; import mekanism.api.transmitters.ITransmitterTile; @@ -19,384 +19,334 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.ForgeDirection; -import cpw.mods.fml.common.Optional.Method; -public abstract class TileEntityElectricBlock extends TileEntityContainerBlock implements IEnergyWrapper -{ - /** How much energy is stored in this block. */ - public double electricityStored; +public abstract class TileEntityElectricBlock + extends TileEntityContainerBlock implements IEnergyWrapper { + /** How much energy is stored in this block. */ + public double electricityStored; - /** Maximum amount of energy this machine can hold. */ - public double BASE_MAX_ENERGY; + /** Maximum amount of energy this machine can hold. */ + public double BASE_MAX_ENERGY; - /** Actual maximum energy storage, including upgrades */ - public double maxEnergy; + /** Actual maximum energy storage, including upgrades */ + public double maxEnergy; - /** Is this registered with IC2 */ - public boolean ic2Registered = false; + /** Is this registered with IC2 */ + public boolean ic2Registered = false; - /** - * The base of all blocks that deal with electricity. It has a facing state, initialized state, - * and a current amount of stored energy. - * @param name - full name of this block - * @param baseMaxEnergy - how much energy this block can store - */ - public TileEntityElectricBlock(String name, double baseMaxEnergy) - { - super(name); - BASE_MAX_ENERGY = baseMaxEnergy; - maxEnergy = BASE_MAX_ENERGY; - } + /** + * The base of all blocks that deal with electricity. It has a facing state, + * initialized state, and a current amount of stored energy. + * @param name - full name of this block + * @param baseMaxEnergy - how much energy this block can store + */ + public TileEntityElectricBlock(String name, double baseMaxEnergy) { + super(name); + BASE_MAX_ENERGY = baseMaxEnergy; + maxEnergy = BASE_MAX_ENERGY; + } - @Method(modid = "IC2") - public void register() - { - if(!worldObj.isRemote) - { - TileEntity registered = EnergyNet.instance.getTileEntity(worldObj, xCoord, yCoord, zCoord); - - if(registered != this) - { - if(registered instanceof IEnergyTile) - { - MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergyTile)registered)); - } - else if(registered == null) - { - MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); - ic2Registered = true; - } - } - } - } + @Method(modid = "IC2") + public void register() { + if (!worldObj.isRemote) { + TileEntity registered + = EnergyNet.instance.getTileEntity(worldObj, xCoord, yCoord, zCoord); - @Method(modid = "IC2") - public void deregister() - { - if(!worldObj.isRemote) - { - TileEntity registered = EnergyNet.instance.getTileEntity(worldObj, xCoord, yCoord, zCoord); - - if(registered instanceof IEnergyTile) - { - MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergyTile)registered)); - } - } - } + if (registered != this) { + if (registered instanceof IEnergyTile) { + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergyTile + ) registered)); + } else if (registered == null) { + MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); + ic2Registered = true; + } + } + } + } - @Override - public void onUpdate() - { - if(!ic2Registered && MekanismUtils.useIC2()) - { - register(); - } - } + @Method(modid = "IC2") + public void deregister() { + if (!worldObj.isRemote) { + TileEntity registered + = EnergyNet.instance.getTileEntity(worldObj, xCoord, yCoord, zCoord); - @Override - public EnumSet getOutputtingSides() - { - return EnumSet.noneOf(ForgeDirection.class); - } + if (registered instanceof IEnergyTile) { + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergyTile + ) registered)); + } + } + } - @Override - public EnumSet getConsumingSides() - { - return EnumSet.allOf(ForgeDirection.class); - } + @Override + public void onUpdate() { + if (!ic2Registered && MekanismUtils.useIC2()) { + register(); + } + } - @Override - public double getMaxOutput() - { - return 0; - } + @Override + public EnumSet getOutputtingSides() { + return EnumSet.noneOf(ForgeDirection.class); + } - @Override - public double getEnergy() - { - return electricityStored; - } + @Override + public EnumSet getConsumingSides() { + return EnumSet.allOf(ForgeDirection.class); + } - @Override - public void setEnergy(double energy) - { - electricityStored = Math.max(Math.min(energy, getMaxEnergy()), 0); - MekanismUtils.saveChunk(this); - } + @Override + public double getMaxOutput() { + return 0; + } - @Override - public double getMaxEnergy() - { - return maxEnergy; - } + @Override + public double getEnergy() { + return electricityStored; + } - @Override - public void handlePacketData(ByteBuf dataStream) - { - super.handlePacketData(dataStream); - - if(worldObj.isRemote) - { - setEnergy(dataStream.readDouble()); - } - } + @Override + public void setEnergy(double energy) { + electricityStored = Math.max(Math.min(energy, getMaxEnergy()), 0); + MekanismUtils.saveChunk(this); + } - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); - - data.add(getEnergy()); - - return data; - } - - @Override - public void onAdded() - { - super.onAdded(); - - if(MekanismUtils.useIC2()) - { - register(); - } - } + @Override + public double getMaxEnergy() { + return maxEnergy; + } - @Override - public void onChunkUnload() - { - if(MekanismUtils.useIC2()) - { - deregister(); - } - super.onChunkUnload(); - } + @Override + public void handlePacketData(ByteBuf dataStream) { + super.handlePacketData(dataStream); - @Override - public void invalidate() - { - super.invalidate(); - if(MekanismUtils.useIC2()) - { - deregister(); - } - } + if (worldObj.isRemote) { + setEnergy(dataStream.readDouble()); + } + } - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); - electricityStored = nbtTags.getDouble("electricityStored"); - } + data.add(getEnergy()); - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); + return data; + } - nbtTags.setDouble("electricityStored", getEnergy()); - } + @Override + public void onAdded() { + super.onAdded(); - /** - * Gets the scaled energy level for the GUI. - * @param i - multiplier - * @return scaled energy - */ - public int getScaledEnergyLevel(int i) - { - return (int)(getEnergy()*i / getMaxEnergy()); - } + if (MekanismUtils.useIC2()) { + register(); + } + } - @Override - public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) - { - if(getConsumingSides().contains(from)) - { - double toAdd = (int)Math.min(getMaxEnergy()-getEnergy(), maxReceive*general.FROM_TE); + @Override + public void onChunkUnload() { + if (MekanismUtils.useIC2()) { + deregister(); + } + super.onChunkUnload(); + } - if(!simulate) - { - setEnergy(getEnergy() + toAdd); - } + @Override + public void invalidate() { + super.invalidate(); + if (MekanismUtils.useIC2()) { + deregister(); + } + } - return (int)Math.round(toAdd*general.TO_TE); - } + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); - return 0; - } + electricityStored = nbtTags.getDouble("electricityStored"); + } - @Override - public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) - { - if(getOutputtingSides().contains(from)) - { - double toSend = Math.min(getEnergy(), Math.min(getMaxOutput(), maxExtract*general.FROM_TE)); + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); - if(!simulate) - { - setEnergy(getEnergy() - toSend); - } + nbtTags.setDouble("electricityStored", getEnergy()); + } - return (int)Math.round(toSend*general.TO_TE); - } + /** + * Gets the scaled energy level for the GUI. + * @param i - multiplier + * @return scaled energy + */ + public int getScaledEnergyLevel(int i) { + return (int) (getEnergy() * i / getMaxEnergy()); + } - return 0; - } + @Override + public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { + if (getConsumingSides().contains(from)) { + double toAdd = (int + ) Math.min(getMaxEnergy() - getEnergy(), maxReceive * general.FROM_TE); - @Override - public boolean canConnectEnergy(ForgeDirection from) - { - return getConsumingSides().contains(from) || getOutputtingSides().contains(from); - } + if (!simulate) { + setEnergy(getEnergy() + toAdd); + } - @Override - public int getEnergyStored(ForgeDirection from) - { - return (int)Math.round(getEnergy()*general.TO_TE); - } + return (int) Math.round(toAdd * general.TO_TE); + } - @Override - public int getMaxEnergyStored(ForgeDirection from) - { - return (int)Math.round(getMaxEnergy()*general.TO_TE); - } + return 0; + } - @Override - @Method(modid = "IC2") - public int getSinkTier() - { - return 4; - } + @Override + public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) { + if (getOutputtingSides().contains(from)) { + double toSend = Math.min( + getEnergy(), Math.min(getMaxOutput(), maxExtract * general.FROM_TE) + ); - @Override - @Method(modid = "IC2") - public int getSourceTier() - { - return 1; - } + if (!simulate) { + setEnergy(getEnergy() - toSend); + } - @Override - @Method(modid = "IC2") - public void setStored(int energy) - { - setEnergy(energy*general.FROM_IC2); - } + return (int) Math.round(toSend * general.TO_TE); + } - @Override - @Method(modid = "IC2") - public int addEnergy(int amount) - { - setEnergy(getEnergy() + amount*general.FROM_IC2); - return (int)Math.round(getEnergy()*general.TO_IC2); - } + return 0; + } - @Override - @Method(modid = "IC2") - public boolean isTeleporterCompatible(ForgeDirection side) - { - return getOutputtingSides().contains(side); - } + @Override + public boolean canConnectEnergy(ForgeDirection from) { + return getConsumingSides().contains(from) || getOutputtingSides().contains(from); + } - @Override - public boolean canOutputTo(ForgeDirection side) - { - return getOutputtingSides().contains(side); - } + @Override + public int getEnergyStored(ForgeDirection from) { + return (int) Math.round(getEnergy() * general.TO_TE); + } - @Override - @Method(modid = "IC2") - public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) - { - return getConsumingSides().contains(direction); - } + @Override + public int getMaxEnergyStored(ForgeDirection from) { + return (int) Math.round(getMaxEnergy() * general.TO_TE); + } - @Override - @Method(modid = "IC2") - public boolean emitsEnergyTo(TileEntity receiver, ForgeDirection direction) - { - return getOutputtingSides().contains(direction) && receiver instanceof IEnergyConductor; - } + @Override + @Method(modid = "IC2") + public int getSinkTier() { + return 4; + } - @Override - @Method(modid = "IC2") - public int getStored() - { - return (int)Math.round(getEnergy()*general.TO_IC2); - } + @Override + @Method(modid = "IC2") + public int getSourceTier() { + return 1; + } - @Override - @Method(modid = "IC2") - public int getCapacity() - { - return (int)Math.round(getMaxEnergy()*general.TO_IC2); - } + @Override + @Method(modid = "IC2") + public void setStored(int energy) { + setEnergy(energy * general.FROM_IC2); + } - @Override - @Method(modid = "IC2") - public int getOutput() - { - return (int)Math.round(getMaxOutput()*general.TO_IC2); - } + @Override + @Method(modid = "IC2") + public int addEnergy(int amount) { + setEnergy(getEnergy() + amount * general.FROM_IC2); + return (int) Math.round(getEnergy() * general.TO_IC2); + } - @Override - @Method(modid = "IC2") - public double getDemandedEnergy() - { - return (getMaxEnergy() - getEnergy())*general.TO_IC2; - } + @Override + @Method(modid = "IC2") + public boolean isTeleporterCompatible(ForgeDirection side) { + return getOutputtingSides().contains(side); + } - @Override - @Method(modid = "IC2") - public double getOfferedEnergy() - { - return Math.min(getEnergy(), getMaxOutput())*general.TO_IC2; - } + @Override + public boolean canOutputTo(ForgeDirection side) { + return getOutputtingSides().contains(side); + } - @Override - public boolean canReceiveEnergy(ForgeDirection side) - { - return getConsumingSides().contains(side); - } + @Override + @Method(modid = "IC2") + public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) { + return getConsumingSides().contains(direction); + } - @Override - @Method(modid = "IC2") - public double getOutputEnergyUnitsPerTick() - { - return getMaxOutput()*general.TO_IC2; - } + @Override + @Method(modid = "IC2") + public boolean emitsEnergyTo(TileEntity receiver, ForgeDirection direction) { + return getOutputtingSides().contains(direction) + && receiver instanceof IEnergyConductor; + } - @Override - @Method(modid = "IC2") - public double injectEnergy(ForgeDirection direction, double amount, double voltage) - { - if(Coord4D.get(this).getFromSide(direction).getTileEntity(worldObj) instanceof ITransmitterTile) - { - return amount; - } + @Override + @Method(modid = "IC2") + public int getStored() { + return (int) Math.round(getEnergy() * general.TO_IC2); + } - return amount-transferEnergyToAcceptor(direction, amount*general.FROM_IC2)*general.TO_IC2; - } + @Override + @Method(modid = "IC2") + public int getCapacity() { + return (int) Math.round(getMaxEnergy() * general.TO_IC2); + } - @Override - @Method(modid = "IC2") - public void drawEnergy(double amount) - { - setEnergy(Math.max(getEnergy() - (amount*general.FROM_IC2), 0)); - } + @Override + @Method(modid = "IC2") + public int getOutput() { + return (int) Math.round(getMaxOutput() * general.TO_IC2); + } - @Override - public double transferEnergyToAcceptor(ForgeDirection side, double amount) - { - if(!(getConsumingSides().contains(side) || side == ForgeDirection.UNKNOWN)) - { - return 0; - } + @Override + @Method(modid = "IC2") + public double getDemandedEnergy() { + return (getMaxEnergy() - getEnergy()) * general.TO_IC2; + } - double toUse = Math.min(getMaxEnergy()-getEnergy(), amount); - setEnergy(getEnergy() + toUse); + @Override + @Method(modid = "IC2") + public double getOfferedEnergy() { + return Math.min(getEnergy(), getMaxOutput()) * general.TO_IC2; + } - return toUse; - } + @Override + public boolean canReceiveEnergy(ForgeDirection side) { + return getConsumingSides().contains(side); + } + @Override + @Method(modid = "IC2") + public double getOutputEnergyUnitsPerTick() { + return getMaxOutput() * general.TO_IC2; + } + + @Override + @Method(modid = "IC2") + public double injectEnergy(ForgeDirection direction, double amount, double voltage) { + if (Coord4D.get(this).getFromSide(direction).getTileEntity(worldObj) + instanceof ITransmitterTile) { + return amount; + } + + return amount + - transferEnergyToAcceptor(direction, amount * general.FROM_IC2) + * general.TO_IC2; + } + + @Override + @Method(modid = "IC2") + public void drawEnergy(double amount) { + setEnergy(Math.max(getEnergy() - (amount * general.FROM_IC2), 0)); + } + + @Override + public double transferEnergyToAcceptor(ForgeDirection side, double amount) { + if (!(getConsumingSides().contains(side) || side == ForgeDirection.UNKNOWN)) { + return 0; + } + + double toUse = Math.min(getMaxEnergy() - getEnergy(), amount); + setEnergy(getEnergy() + toUse); + + return toUse; + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityElectricMachine.java b/src/main/java/mekanism/common/tile/TileEntityElectricMachine.java index 8574fc099..80a0e6195 100644 --- a/src/main/java/mekanism/common/tile/TileEntityElectricMachine.java +++ b/src/main/java/mekanism/common/tile/TileEntityElectricMachine.java @@ -7,8 +7,8 @@ import mekanism.common.MekanismItems; import mekanism.common.SideData; import mekanism.common.Tier.BaseTier; import mekanism.common.Upgrade; -import mekanism.common.base.ITierUpgradeable; import mekanism.common.base.IFactory.RecipeType; +import mekanism.common.base.ITierUpgradeable; import mekanism.common.recipe.RecipeHandler; import mekanism.common.recipe.inputs.ItemStackInput; import mekanism.common.recipe.machines.BasicMachineRecipe; @@ -22,250 +22,256 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.item.ItemStack; -public abstract class TileEntityElectricMachine> extends TileEntityBasicMachine implements ITierUpgradeable -{ - /** - * A simple electrical machine. This has 3 slots - the input slot (0), the energy slot (1), - * output slot (2), and the upgrade slot (3). It will not run if it does not have enough energy. - * - * @param soundPath - location of the sound effect - * @param name - full name of this machine - * @param perTick - energy used per tick. - * @param ticksRequired - ticks required to operate -- or smelt an item. - * @param maxEnergy - maximum energy this machine can hold. - */ - public TileEntityElectricMachine(String soundPath, String name, double perTick, int ticksRequired, double maxEnergy) - { - super(soundPath, name, MekanismUtils.getResource(ResourceType.GUI, "GuiBasicMachine.png"), perTick, ticksRequired, maxEnergy); +public abstract class TileEntityElectricMachine> + extends TileEntityBasicMachine + implements ITierUpgradeable { + /** + * A simple electrical machine. This has 3 slots - the input slot (0), the energy slot + * (1), output slot (2), and the upgrade slot (3). It will not run if it does not have + * enough energy. + * + * @param soundPath - location of the sound effect + * @param name - full name of this machine + * @param perTick - energy used per tick. + * @param ticksRequired - ticks required to operate -- or smelt an item. + * @param maxEnergy - maximum energy this machine can hold. + */ + public TileEntityElectricMachine( + String soundPath, String name, double perTick, int ticksRequired, double maxEnergy + ) { + super( + soundPath, + name, + MekanismUtils.getResource(ResourceType.GUI, "GuiBasicMachine.png"), + perTick, + ticksRequired, + maxEnergy + ); - configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY); - - configComponent.addOutput(TransmissionType.ITEM, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY)); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Input", EnumColor.DARK_RED, new int[] {0})); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Output", EnumColor.DARK_BLUE, new int[] {2})); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Energy", EnumColor.DARK_GREEN, new int[] {1})); + configComponent = new TileComponentConfig( + this, TransmissionType.ITEM, TransmissionType.ENERGY + ); - configComponent.setConfig(TransmissionType.ITEM, new byte[] {3, 1, 0, 0, 0, 2}); - configComponent.setInputConfig(TransmissionType.ENERGY); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY) + ); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("Input", EnumColor.DARK_RED, new int[] { 0 }) + ); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("Output", EnumColor.DARK_BLUE, new int[] { 2 }) + ); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("Energy", EnumColor.DARK_GREEN, new int[] { 1 }) + ); - inventory = new ItemStack[4]; + configComponent.setConfig(TransmissionType.ITEM, new byte[] { 3, 1, 0, 0, 0, 2 }); + configComponent.setInputConfig(TransmissionType.ENERGY); - upgradeComponent = new TileComponentUpgrade(this, 3); - upgradeComponent.setSupported(Upgrade.MUFFLING); - - ejectorComponent = new TileComponentEjector(this); - ejectorComponent.setOutputData(TransmissionType.ITEM, configComponent.getOutputs(TransmissionType.ITEM).get(2)); - } - - @Override - public boolean upgrade(BaseTier upgradeTier) - { - if(upgradeTier != BaseTier.BASIC) - { - return false; - } - - worldObj.setBlockToAir(xCoord, yCoord, zCoord); - worldObj.setBlock(xCoord, yCoord, zCoord, MekanismBlocks.MachineBlock, 5, 3); - - TileEntityFactory factory = (TileEntityFactory)worldObj.getTileEntity(xCoord, yCoord, zCoord); - RecipeType type = RecipeType.getFromMachine(getBlockType(), getBlockMetadata()); - - //Basic - factory.facing = facing; - factory.clientFacing = clientFacing; - factory.ticker = ticker; - factory.redstone = redstone; - factory.redstoneLastTick = redstoneLastTick; - factory.doAutoSync = doAutoSync; - - //Electric - factory.electricityStored = electricityStored; - - //Noisy - factory.soundURL = soundURL; - - //Machine - factory.progress[0] = operatingTicks; - factory.clientActive = clientActive; - factory.isActive = isActive; - factory.updateDelay = updateDelay; - factory.controlType = controlType; - factory.prevEnergy = prevEnergy; - factory.upgradeComponent.readFrom(upgradeComponent); - factory.upgradeComponent.setUpgradeSlot(0); - factory.ejectorComponent.readFrom(ejectorComponent); - factory.ejectorComponent.setOutputData(TransmissionType.ITEM, factory.configComponent.getOutputs(TransmissionType.ITEM).get(2)); - factory.recipeType = type; - factory.upgradeComponent.setSupported(Upgrade.GAS, type.fuelEnergyUpgrades()); - factory.securityComponent.readFrom(securityComponent); - - for(TransmissionType transmission : configComponent.transmissions) - { - factory.configComponent.setConfig(transmission, configComponent.getConfig(transmission)); - factory.configComponent.setEjecting(transmission, configComponent.isEjecting(transmission)); - } + inventory = new ItemStack[4]; - factory.inventory[5] = inventory[0]; - factory.inventory[1] = inventory[1]; - factory.inventory[5+3] = inventory[2]; - factory.inventory[0] = inventory[3]; - - for(Upgrade upgrade : factory.upgradeComponent.getSupportedTypes()) - { - factory.recalculateUpgradables(upgrade); - } - - factory.upgraded = true; - factory.markDirty(); - - return true; - } + upgradeComponent = new TileComponentUpgrade(this, 3); + upgradeComponent.setSupported(Upgrade.MUFFLING); - @Override - public void onUpdate() - { - super.onUpdate(); + ejectorComponent = new TileComponentEjector(this); + ejectorComponent.setOutputData( + TransmissionType.ITEM, + configComponent.getOutputs(TransmissionType.ITEM).get(2) + ); + } - if(!worldObj.isRemote) - { - ChargeUtils.discharge(1, this); + @Override + public boolean upgrade(BaseTier upgradeTier) { + if (upgradeTier != BaseTier.BASIC) { + return false; + } - RECIPE recipe = getRecipe(); + worldObj.setBlockToAir(xCoord, yCoord, zCoord); + worldObj.setBlock(xCoord, yCoord, zCoord, MekanismBlocks.MachineBlock, 5, 3); - if(canOperate(recipe) && MekanismUtils.canFunction(this) && getEnergy() >= energyPerTick) - { - setActive(true); - electricityStored -= energyPerTick; + TileEntityFactory factory + = (TileEntityFactory) worldObj.getTileEntity(xCoord, yCoord, zCoord); + RecipeType type = RecipeType.getFromMachine(getBlockType(), getBlockMetadata()); - if((operatingTicks+1) < ticksRequired) - { - operatingTicks++; - } - else if((operatingTicks+1) >= ticksRequired) - { - operate(recipe); + //Basic + factory.facing = facing; + factory.clientFacing = clientFacing; + factory.ticker = ticker; + factory.redstone = redstone; + factory.redstoneLastTick = redstoneLastTick; + factory.doAutoSync = doAutoSync; - operatingTicks = 0; - } - } - else { - if(prevEnergy >= getEnergy()) - { - setActive(false); - } - } + //Electric + factory.electricityStored = electricityStored; - if(!canOperate(recipe)) - { - operatingTicks = 0; - } + //Noisy + factory.soundURL = soundURL; - prevEnergy = getEnergy(); - } - } + //Machine + factory.progress[0] = operatingTicks; + factory.clientActive = clientActive; + factory.isActive = isActive; + factory.updateDelay = updateDelay; + factory.controlType = controlType; + factory.prevEnergy = prevEnergy; + factory.upgradeComponent.readFrom(upgradeComponent); + factory.upgradeComponent.setUpgradeSlot(0); + factory.ejectorComponent.readFrom(ejectorComponent); + factory.ejectorComponent.setOutputData( + TransmissionType.ITEM, + factory.configComponent.getOutputs(TransmissionType.ITEM).get(2) + ); + factory.recipeType = type; + factory.upgradeComponent.setSupported(Upgrade.GAS, type.fuelEnergyUpgrades()); + factory.securityComponent.readFrom(securityComponent); - @Override - public boolean isItemValidForSlot(int slotID, ItemStack itemstack) - { - if(slotID == 2) - { - return false; - } - else if(slotID == 3) - { - return itemstack.getItem() == MekanismItems.SpeedUpgrade || itemstack.getItem() == MekanismItems.EnergyUpgrade; - } - else if(slotID == 0) - { - return RecipeHandler.isInRecipe(itemstack, getRecipes()); - } - else if(slotID == 1) - { - return ChargeUtils.canBeDischarged(itemstack); - } + for (TransmissionType transmission : configComponent.transmissions) { + factory.configComponent.setConfig( + transmission, configComponent.getConfig(transmission) + ); + factory.configComponent.setEjecting( + transmission, configComponent.isEjecting(transmission) + ); + } - return false; - } + factory.inventory[5] = inventory[0]; + factory.inventory[1] = inventory[1]; + factory.inventory[5 + 3] = inventory[2]; + factory.inventory[0] = inventory[3]; - @Override - public ItemStackInput getInput() - { - return new ItemStackInput(inventory[0]); - } + for (Upgrade upgrade : factory.upgradeComponent.getSupportedTypes()) { + factory.recalculateUpgradables(upgrade); + } - @Override - public RECIPE getRecipe() - { - ItemStackInput input = getInput(); - - if(cachedRecipe == null || !input.testEquality(cachedRecipe.getInput())) - { - cachedRecipe = RecipeHandler.getRecipe(input, getRecipes()); - } - - return cachedRecipe; - } + factory.upgraded = true; + factory.markDirty(); - @Override - public void operate(RECIPE recipe) - { - recipe.operate(inventory, 0, 2); + return true; + } - markDirty(); - ejectorComponent.outputItems(); - } + @Override + public void onUpdate() { + super.onUpdate(); - @Override - public boolean canOperate(RECIPE recipe) - { - return recipe != null && recipe.canOperate(inventory, 0, 2); - } + if (!worldObj.isRemote) { + ChargeUtils.discharge(1, this); - @Override - public boolean canExtractItem(int slotID, ItemStack itemstack, int side) - { - if(slotID == 1) - { - return ChargeUtils.canBeOutputted(itemstack, false); - } - else if(slotID == 2) - { - return true; - } + RECIPE recipe = getRecipe(); - return false; - } + if (canOperate(recipe) && MekanismUtils.canFunction(this) + && getEnergy() >= energyPerTick) { + setActive(true); + electricityStored -= energyPerTick; - private static final String[] methods = new String[] {"getEnergy", "getProgress", "isActive", "facing", "canOperate", "getMaxEnergy", "getEnergyNeeded"}; + if ((operatingTicks + 1) < ticksRequired) { + operatingTicks++; + } else if ((operatingTicks + 1) >= ticksRequired) { + operate(recipe); - @Override - public String[] getMethods() - { - return methods; - } + operatingTicks = 0; + } + } else { + if (prevEnergy >= getEnergy()) { + setActive(false); + } + } - @Override - public Object[] invoke(int method, Object[] arguments) throws Exception - { - switch(method) - { - case 0: - return new Object[] {getEnergy()}; - case 1: - return new Object[] {operatingTicks}; - case 2: - return new Object[] {isActive}; - case 3: - return new Object[] {facing}; - case 4: - return new Object[] {canOperate(getRecipe())}; - case 5: - return new Object[] {getMaxEnergy()}; - case 6: - return new Object[] {getMaxEnergy()-getEnergy()}; - default: - throw new NoSuchMethodException(); - } - } + if (!canOperate(recipe)) { + operatingTicks = 0; + } + + prevEnergy = getEnergy(); + } + } + + @Override + public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { + if (slotID == 2) { + return false; + } else if (slotID == 3) { + return itemstack.getItem() == MekanismItems.SpeedUpgrade + || itemstack.getItem() == MekanismItems.EnergyUpgrade; + } else if (slotID == 0) { + return RecipeHandler.isInRecipe(itemstack, getRecipes()); + } else if (slotID == 1) { + return ChargeUtils.canBeDischarged(itemstack); + } + + return false; + } + + @Override + public ItemStackInput getInput() { + return new ItemStackInput(inventory[0]); + } + + @Override + public RECIPE getRecipe() { + ItemStackInput input = getInput(); + + if (cachedRecipe == null || !input.testEquality(cachedRecipe.getInput())) { + cachedRecipe = RecipeHandler.getRecipe(input, getRecipes()); + } + + return cachedRecipe; + } + + @Override + public void operate(RECIPE recipe) { + recipe.operate(inventory, 0, 2); + + markDirty(); + ejectorComponent.outputItems(); + } + + @Override + public boolean canOperate(RECIPE recipe) { + return recipe != null && recipe.canOperate(inventory, 0, 2); + } + + @Override + public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { + if (slotID == 1) { + return ChargeUtils.canBeOutputted(itemstack, false); + } else if (slotID == 2) { + return true; + } + + return false; + } + + private static final String[] methods + = new String[] { "getEnergy", "getProgress", "isActive", "facing", + "canOperate", "getMaxEnergy", "getEnergyNeeded" }; + + @Override + public String[] getMethods() { + return methods; + } + + @Override + public Object[] invoke(int method, Object[] arguments) throws Exception { + switch (method) { + case 0: + return new Object[] { getEnergy() }; + case 1: + return new Object[] { operatingTicks }; + case 2: + return new Object[] { isActive }; + case 3: + return new Object[] { facing }; + case 4: + return new Object[] { canOperate(getRecipe()) }; + case 5: + return new Object[] { getMaxEnergy() }; + case 6: + return new Object[] { getMaxEnergy() - getEnergy() }; + default: + throw new NoSuchMethodException(); + } + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityElectricPump.java b/src/main/java/mekanism/common/tile/TileEntityElectricPump.java index d2e78a603..52f89ec4a 100644 --- a/src/main/java/mekanism/common/tile/TileEntityElectricPump.java +++ b/src/main/java/mekanism/common/tile/TileEntityElectricPump.java @@ -1,7 +1,5 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -10,6 +8,7 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.IConfigurable; @@ -47,557 +46,516 @@ import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidContainerItem; import net.minecraftforge.fluids.IFluidHandler; -public class TileEntityElectricPump extends TileEntityElectricBlock implements IFluidHandler, ISustainedTank, IConfigurable, IRedstoneControl, IUpgradeTile, ITankManager, IComputerIntegration, ISecurityTile -{ - /** This pump's tank */ - public FluidTank fluidTank = new FluidTank(10000); - - /** The type of fluid this pump is pumping */ - public Fluid activeType; - - public boolean suckedLastOperation; - - /** How much energy this machine consumes per-tick. */ - public double BASE_ENERGY_PER_TICK = usage.electricPumpUsage; - - public double energyPerTick = BASE_ENERGY_PER_TICK; - - /** How many ticks it takes to run an operation. */ - public int BASE_TICKS_REQUIRED = 20; - - public int ticksRequired = BASE_TICKS_REQUIRED; - - /** How many ticks this machine has been operating for. */ - public int operatingTicks; - - /** The nodes that have full sources near them or in them */ - public Set recurringNodes = new HashSet(); - - /** This machine's current RedstoneControl type. */ - public RedstoneControl controlType = RedstoneControl.DISABLED; - - public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, 3); - public TileComponentSecurity securityComponent = new TileComponentSecurity(this); - - public TileEntityElectricPump() - { - super("ElectricPump", 10000); - inventory = new ItemStack[4]; - - upgradeComponent.setSupported(Upgrade.FILTER); - } - - @Override - public void onUpdate() - { - if(!worldObj.isRemote) - { - ChargeUtils.discharge(2, this); - - if(inventory[0] != null && fluidTank.getFluid() != null) - { - if(inventory[0].getItem() instanceof IFluidContainerItem) - { - FluidContainerUtils.handleContainerItemFill(this, fluidTank, 0, 1); - } - else if(FluidContainerRegistry.isEmptyContainer(inventory[0])) - { - FluidContainerUtils.handleRegistryItemFill(this, fluidTank, 0, 1); - } - } - } - - if(!worldObj.isRemote) - { - if(MekanismUtils.canFunction(this) && getEnergy() >= energyPerTick) - { - if(suckedLastOperation) - { - setEnergy(getEnergy() - energyPerTick); - } - - if((operatingTicks + 1) < ticksRequired) - { - operatingTicks++; - } - else { - if(fluidTank.getFluid() == null || fluidTank.getFluid().amount + FluidContainerRegistry.BUCKET_VOLUME <= fluidTank.getCapacity()) - { - if(!suck(true)) - { - suckedLastOperation = false; - reset(); - } - else { - suckedLastOperation = true; - } - } - else { - suckedLastOperation = false; - } - - operatingTicks = 0; - } - } - else { - suckedLastOperation = false; - } - } - - super.onUpdate(); - - if(!worldObj.isRemote && fluidTank.getFluid() != null) - { - TileEntity tileEntity = Coord4D.get(this).getFromSide(ForgeDirection.UP).getTileEntity(worldObj); - - if(tileEntity instanceof IFluidHandler) - { - FluidStack toDrain = new FluidStack(fluidTank.getFluid(), Math.min(256*(upgradeComponent.getUpgrades(Upgrade.SPEED)+1), fluidTank.getFluidAmount())); - fluidTank.drain(((IFluidHandler)tileEntity).fill(ForgeDirection.DOWN, toDrain, true), true); - } - } - } - - public boolean hasFilter() - { - return upgradeComponent.getInstalledTypes().contains(Upgrade.FILTER); - } - - public boolean suck(boolean take) - { - List tempPumpList = Arrays.asList(recurringNodes.toArray(new Coord4D[recurringNodes.size()])); - Collections.shuffle(tempPumpList); - - //First see if there are any fluid blocks touching the pump - if so, sucks and adds the location to the recurring list - for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) - { - Coord4D wrapper = Coord4D.get(this).getFromSide(orientation); - FluidStack fluid = MekanismUtils.getFluid(worldObj, wrapper, hasFilter()); - - if(fluid != null && (activeType == null || fluid.getFluid() == activeType) && (fluidTank.getFluid() == null || fluidTank.getFluid().isFluidEqual(fluid))) - { - if(take) - { - activeType = fluid.getFluid(); - recurringNodes.add(wrapper.clone()); - fluidTank.fill(fluid, true); - - if(shouldTake(fluid, wrapper)) - { - worldObj.setBlock(wrapper.xCoord, wrapper.yCoord, wrapper.zCoord, Blocks.air, 0, 3); - } - } - - return true; - } - } - - //Finally, go over the recurring list of nodes and see if there is a fluid block available to suck - if not, will iterate around the recurring block, attempt to suck, - //and then add the adjacent block to the recurring list - for(Coord4D wrapper : tempPumpList) - { - FluidStack fluid = MekanismUtils.getFluid(worldObj, wrapper, hasFilter()); - - if(fluid != null && (activeType == null || fluid.getFluid() == activeType) && (fluidTank.getFluid() == null || fluidTank.getFluid().isFluidEqual(fluid))) - { - if(take) - { - activeType = fluid.getFluid(); - fluidTank.fill(fluid, true); - - if(shouldTake(fluid, wrapper)) - { - worldObj.setBlock(wrapper.xCoord, wrapper.yCoord, wrapper.zCoord, Blocks.air, 0, 3); - } - } - - return true; - } - - //Add all the blocks surrounding this recurring node to the recurring node list - for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) - { - Coord4D side = wrapper.getFromSide(orientation); - - if(Coord4D.get(this).distanceTo(side) <= general.maxPumpRange) - { - fluid = MekanismUtils.getFluid(worldObj, side, hasFilter()); - - if(fluid != null && (activeType == null || fluid.getFluid() == activeType) && (fluidTank.getFluid() == null || fluidTank.getFluid().isFluidEqual(fluid))) - { - if(take) - { - activeType = fluid.getFluid(); - recurringNodes.add(side); - fluidTank.fill(fluid, true); - - if(shouldTake(fluid, side)) - { - worldObj.setBlock(side.xCoord, side.yCoord, side.zCoord, Blocks.air, 0, 3); - } - } - - return true; - } - } - } - - recurringNodes.remove(wrapper); - } - - return false; - } - - public void reset() - { - activeType = null; - recurringNodes.clear(); - } - - private boolean shouldTake(FluidStack fluid, Coord4D coord) - { - if(fluid.getFluid() == FluidRegistry.WATER || fluid.getFluid() == FluidRegistry.getFluid("heavywater")) - { - return general.pumpWaterSources; - } - - return true; - } - - @Override - public void handlePacketData(ByteBuf dataStream) - { - super.handlePacketData(dataStream); - - if(worldObj.isRemote) - { - if(dataStream.readInt() == 1) - { - fluidTank.setFluid(new FluidStack(FluidRegistry.getFluid(dataStream.readInt()), dataStream.readInt())); - } - else { - fluidTank.setFluid(null); - } - - controlType = RedstoneControl.values()[dataStream.readInt()]; - - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } - - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); - - if(fluidTank.getFluid() != null) - { - data.add(1); - data.add(fluidTank.getFluid().getFluidID()); - data.add(fluidTank.getFluid().amount); - } - else { - data.add(0); - } - - data.add(controlType.ordinal()); - - return data; - } - - public int getScaledFluidLevel(int i) - { - return fluidTank.getFluid() != null ? fluidTank.getFluid().amount*i / 10000 : 0; - } - - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - nbtTags.setInteger("operatingTicks", operatingTicks); - nbtTags.setBoolean("suckedLastOperation", suckedLastOperation); - - if(activeType != null) - { - nbtTags.setString("activeType", FluidRegistry.getFluidName(activeType)); - } - - if(fluidTank.getFluid() != null) - { - nbtTags.setTag("fluidTank", fluidTank.writeToNBT(new NBTTagCompound())); - } - - nbtTags.setInteger("controlType", controlType.ordinal()); - - NBTTagList recurringList = new NBTTagList(); - - for(Coord4D wrapper : recurringNodes) - { - NBTTagCompound tagCompound = new NBTTagCompound(); - wrapper.write(tagCompound); - recurringList.appendTag(tagCompound); - } - - if(recurringList.tagCount() != 0) - { - nbtTags.setTag("recurringNodes", recurringList); - } - } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - operatingTicks = nbtTags.getInteger("operatingTicks"); - suckedLastOperation = nbtTags.getBoolean("suckedLastOperation"); - - if(nbtTags.hasKey("activeType")) - { - activeType = FluidRegistry.getFluid(nbtTags.getString("activeType")); - } - - if(nbtTags.hasKey("fluidTank")) - { - fluidTank.readFromNBT(nbtTags.getCompoundTag("fluidTank")); - } - - if(nbtTags.hasKey("controlType")) - { - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - } - - if(nbtTags.hasKey("recurringNodes")) - { - NBTTagList tagList = nbtTags.getTagList("recurringNodes", NBT.TAG_COMPOUND); - - for(int i = 0; i < tagList.tagCount(); i++) - { - recurringNodes.add(Coord4D.read((NBTTagCompound)tagList.getCompoundTagAt(i))); - } - } - } - - @Override - public boolean isItemValidForSlot(int slotID, ItemStack itemstack) - { - if(slotID == 1) - { - return false; - } - else if(slotID == 0) - { - return FluidContainerRegistry.isEmptyContainer(itemstack); - } - else if(slotID == 2) - { - return ChargeUtils.canBeDischarged(itemstack); - } - - return true; - } - - @Override - public boolean canExtractItem(int slotID, ItemStack itemstack, int side) - { - if(slotID == 2) - { - return ChargeUtils.canBeOutputted(itemstack, false); - } - else if(slotID == 1) - { - return true; - } - - return false; - } - - @Override - public EnumSet getConsumingSides() - { - return EnumSet.of(ForgeDirection.getOrientation(facing).getOpposite()); - } - - @Override - public boolean canSetFacing(int side) - { - return side != 0 && side != 1; - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) - { - if(side == 1) - { - return new int[] {0}; - } - else if(side == 0) - { - return new int[] {1}; - } - else { - return new int[] {2}; - } - } - - @Override - public FluidTankInfo[] getTankInfo(ForgeDirection direction) - { - if(direction == ForgeDirection.getOrientation(1)) - { - return new FluidTankInfo[] {fluidTank.getInfo()}; - } - - return PipeUtils.EMPTY; - } - - @Override - public void setFluidStack(FluidStack fluidStack, Object... data) - { - fluidTank.setFluid(fluidStack); - } - - @Override - public FluidStack getFluidStack(Object... data) - { - return fluidTank.getFluid(); - } - - @Override - public boolean hasTank(Object... data) - { - return true; - } - - @Override - public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) - { - if(fluidTank.getFluid() != null && fluidTank.getFluid().getFluid() == resource.getFluid() && from == ForgeDirection.getOrientation(1)) - { - return drain(from, resource.amount, doDrain); - } - - return null; - } - - @Override - public int fill(ForgeDirection from, FluidStack resource, boolean doFill) - { - return 0; - } - - @Override - public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) - { - if(from == ForgeDirection.getOrientation(1)) - { - return fluidTank.drain(maxDrain, doDrain); - } - - return null; - } - - @Override - public boolean canFill(ForgeDirection from, Fluid fluid) - { - return false; - } - - @Override - public boolean canDrain(ForgeDirection from, Fluid fluid) - { - return from == ForgeDirection.getOrientation(1); - } - - @Override - public boolean onSneakRightClick(EntityPlayer player, int side) - { - reset(); - - player.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + LangUtils.localize("tooltip.configurator.pumpReset"))); - - return true; - } - - @Override - public boolean onRightClick(EntityPlayer player, int side) - { - return false; - } - - @Override - public RedstoneControl getControlType() - { - return controlType; - } - - @Override - public void setControlType(RedstoneControl type) - { - controlType = type; - MekanismUtils.saveChunk(this); - } - - @Override - public boolean canPulse() - { - return true; - } - - @Override - public TileComponentUpgrade getComponent() - { - return upgradeComponent; - } - - @Override - public Object[] getTanks() - { - return new Object[] {fluidTank}; - } - - private static final String[] methods = new String[] {"reset"}; - - @Override - public String[] getMethods() - { - return methods; - } - - @Override - public Object[] invoke(int method, Object[] arguments) throws Exception - { - switch(method) - { - case 0: - reset(); - return new Object[] {"Pump calculation reset."}; - default: - throw new NoSuchMethodException(); - } - } - - @Override - public TileComponentSecurity getSecurity() - { - return securityComponent; - } - - @Override - public void recalculateUpgradables(Upgrade upgrade) - { - super.recalculateUpgradables(upgrade); - - switch(upgrade) - { - case SPEED: - ticksRequired = MekanismUtils.getTicks(this, BASE_TICKS_REQUIRED); - case ENERGY: - energyPerTick = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK); - maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY); - default: - break; - } - } +public class TileEntityElectricPump extends TileEntityElectricBlock + implements IFluidHandler, ISustainedTank, IConfigurable, IRedstoneControl, + IUpgradeTile, ITankManager, IComputerIntegration, ISecurityTile { + /** This pump's tank */ + public FluidTank fluidTank = new FluidTank(10000); + + /** The type of fluid this pump is pumping */ + public Fluid activeType; + + public boolean suckedLastOperation; + + /** How much energy this machine consumes per-tick. */ + public double BASE_ENERGY_PER_TICK = usage.electricPumpUsage; + + public double energyPerTick = BASE_ENERGY_PER_TICK; + + /** How many ticks it takes to run an operation. */ + public int BASE_TICKS_REQUIRED = 20; + + public int ticksRequired = BASE_TICKS_REQUIRED; + + /** How many ticks this machine has been operating for. */ + public int operatingTicks; + + /** The nodes that have full sources near them or in them */ + public Set recurringNodes = new HashSet(); + + /** This machine's current RedstoneControl type. */ + public RedstoneControl controlType = RedstoneControl.DISABLED; + + public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, 3); + public TileComponentSecurity securityComponent = new TileComponentSecurity(this); + + public TileEntityElectricPump() { + super("ElectricPump", 10000); + inventory = new ItemStack[4]; + + upgradeComponent.setSupported(Upgrade.FILTER); + } + + @Override + public void onUpdate() { + if (!worldObj.isRemote) { + ChargeUtils.discharge(2, this); + + if (inventory[0] != null && fluidTank.getFluid() != null) { + if (inventory[0].getItem() instanceof IFluidContainerItem) { + FluidContainerUtils.handleContainerItemFill(this, fluidTank, 0, 1); + } else if (FluidContainerRegistry.isEmptyContainer(inventory[0])) { + FluidContainerUtils.handleRegistryItemFill(this, fluidTank, 0, 1); + } + } + } + + if (!worldObj.isRemote) { + if (MekanismUtils.canFunction(this) && getEnergy() >= energyPerTick) { + if (suckedLastOperation) { + setEnergy(getEnergy() - energyPerTick); + } + + if ((operatingTicks + 1) < ticksRequired) { + operatingTicks++; + } else { + if (fluidTank.getFluid() == null + || fluidTank.getFluid().amount + + FluidContainerRegistry.BUCKET_VOLUME + <= fluidTank.getCapacity()) { + if (!suck(true)) { + suckedLastOperation = false; + reset(); + } else { + suckedLastOperation = true; + } + } else { + suckedLastOperation = false; + } + + operatingTicks = 0; + } + } else { + suckedLastOperation = false; + } + } + + super.onUpdate(); + + if (!worldObj.isRemote && fluidTank.getFluid() != null) { + TileEntity tileEntity = Coord4D.get(this) + .getFromSide(ForgeDirection.UP) + .getTileEntity(worldObj); + + if (tileEntity instanceof IFluidHandler) { + FluidStack toDrain = new FluidStack( + fluidTank.getFluid(), + Math.min( + 256 * (upgradeComponent.getUpgrades(Upgrade.SPEED) + 1), + fluidTank.getFluidAmount() + ) + ); + fluidTank.drain( + ((IFluidHandler) tileEntity).fill(ForgeDirection.DOWN, toDrain, true), + true + ); + } + } + } + + public boolean hasFilter() { + return upgradeComponent.getInstalledTypes().contains(Upgrade.FILTER); + } + + public boolean suck(boolean take) { + List tempPumpList + = Arrays.asList(recurringNodes.toArray(new Coord4D[recurringNodes.size()])); + Collections.shuffle(tempPumpList); + + //First see if there are any fluid blocks touching the pump - if so, sucks and + //adds the location to the recurring list + for (ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) { + Coord4D wrapper = Coord4D.get(this).getFromSide(orientation); + FluidStack fluid = MekanismUtils.getFluid(worldObj, wrapper, hasFilter()); + + if (fluid != null && (activeType == null || fluid.getFluid() == activeType) + && (fluidTank.getFluid() == null + || fluidTank.getFluid().isFluidEqual(fluid))) { + if (take) { + activeType = fluid.getFluid(); + recurringNodes.add(wrapper.clone()); + fluidTank.fill(fluid, true); + + if (shouldTake(fluid, wrapper)) { + worldObj.setBlock( + wrapper.xCoord, + wrapper.yCoord, + wrapper.zCoord, + Blocks.air, + 0, + 3 + ); + } + } + + return true; + } + } + + //Finally, go over the recurring list of nodes and see if there is a fluid block + //available to suck - if not, will iterate around the recurring block, attempt to + //suck, and then add the adjacent block to the recurring list + for (Coord4D wrapper : tempPumpList) { + FluidStack fluid = MekanismUtils.getFluid(worldObj, wrapper, hasFilter()); + + if (fluid != null && (activeType == null || fluid.getFluid() == activeType) + && (fluidTank.getFluid() == null + || fluidTank.getFluid().isFluidEqual(fluid))) { + if (take) { + activeType = fluid.getFluid(); + fluidTank.fill(fluid, true); + + if (shouldTake(fluid, wrapper)) { + worldObj.setBlock( + wrapper.xCoord, + wrapper.yCoord, + wrapper.zCoord, + Blocks.air, + 0, + 3 + ); + } + } + + return true; + } + + //Add all the blocks surrounding this recurring node to the recurring node + //list + for (ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) { + Coord4D side = wrapper.getFromSide(orientation); + + if (Coord4D.get(this).distanceTo(side) <= general.maxPumpRange) { + fluid = MekanismUtils.getFluid(worldObj, side, hasFilter()); + + if (fluid != null + && (activeType == null || fluid.getFluid() == activeType) + && (fluidTank.getFluid() == null + || fluidTank.getFluid().isFluidEqual(fluid))) { + if (take) { + activeType = fluid.getFluid(); + recurringNodes.add(side); + fluidTank.fill(fluid, true); + + if (shouldTake(fluid, side)) { + worldObj.setBlock( + side.xCoord, + side.yCoord, + side.zCoord, + Blocks.air, + 0, + 3 + ); + } + } + + return true; + } + } + } + + recurringNodes.remove(wrapper); + } + + return false; + } + + public void reset() { + activeType = null; + recurringNodes.clear(); + } + + private boolean shouldTake(FluidStack fluid, Coord4D coord) { + if (fluid.getFluid() == FluidRegistry.WATER + || fluid.getFluid() == FluidRegistry.getFluid("heavywater")) { + return general.pumpWaterSources; + } + + return true; + } + + @Override + public void handlePacketData(ByteBuf dataStream) { + super.handlePacketData(dataStream); + + if (worldObj.isRemote) { + if (dataStream.readInt() == 1) { + fluidTank.setFluid(new FluidStack( + FluidRegistry.getFluid(dataStream.readInt()), dataStream.readInt() + )); + } else { + fluidTank.setFluid(null); + } + + controlType = RedstoneControl.values()[dataStream.readInt()]; + + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } + + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); + + if (fluidTank.getFluid() != null) { + data.add(1); + data.add(fluidTank.getFluid().getFluidID()); + data.add(fluidTank.getFluid().amount); + } else { + data.add(0); + } + + data.add(controlType.ordinal()); + + return data; + } + + public int getScaledFluidLevel(int i) { + return fluidTank.getFluid() != null ? fluidTank.getFluid().amount * i / 10000 : 0; + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); + + nbtTags.setInteger("operatingTicks", operatingTicks); + nbtTags.setBoolean("suckedLastOperation", suckedLastOperation); + + if (activeType != null) { + nbtTags.setString("activeType", FluidRegistry.getFluidName(activeType)); + } + + if (fluidTank.getFluid() != null) { + nbtTags.setTag("fluidTank", fluidTank.writeToNBT(new NBTTagCompound())); + } + + nbtTags.setInteger("controlType", controlType.ordinal()); + + NBTTagList recurringList = new NBTTagList(); + + for (Coord4D wrapper : recurringNodes) { + NBTTagCompound tagCompound = new NBTTagCompound(); + wrapper.write(tagCompound); + recurringList.appendTag(tagCompound); + } + + if (recurringList.tagCount() != 0) { + nbtTags.setTag("recurringNodes", recurringList); + } + } + + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); + + operatingTicks = nbtTags.getInteger("operatingTicks"); + suckedLastOperation = nbtTags.getBoolean("suckedLastOperation"); + + if (nbtTags.hasKey("activeType")) { + activeType = FluidRegistry.getFluid(nbtTags.getString("activeType")); + } + + if (nbtTags.hasKey("fluidTank")) { + fluidTank.readFromNBT(nbtTags.getCompoundTag("fluidTank")); + } + + if (nbtTags.hasKey("controlType")) { + controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + } + + if (nbtTags.hasKey("recurringNodes")) { + NBTTagList tagList = nbtTags.getTagList("recurringNodes", NBT.TAG_COMPOUND); + + for (int i = 0; i < tagList.tagCount(); i++) { + recurringNodes.add(Coord4D.read((NBTTagCompound + ) tagList.getCompoundTagAt(i))); + } + } + } + + @Override + public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { + if (slotID == 1) { + return false; + } else if (slotID == 0) { + return FluidContainerRegistry.isEmptyContainer(itemstack); + } else if (slotID == 2) { + return ChargeUtils.canBeDischarged(itemstack); + } + + return true; + } + + @Override + public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { + if (slotID == 2) { + return ChargeUtils.canBeOutputted(itemstack, false); + } else if (slotID == 1) { + return true; + } + + return false; + } + + @Override + public EnumSet getConsumingSides() { + return EnumSet.of(ForgeDirection.getOrientation(facing).getOpposite()); + } + + @Override + public boolean canSetFacing(int side) { + return side != 0 && side != 1; + } + + @Override + public int[] getAccessibleSlotsFromSide(int side) { + if (side == 1) { + return new int[] { 0 }; + } else if (side == 0) { + return new int[] { 1 }; + } else { + return new int[] { 2 }; + } + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection direction) { + if (direction == ForgeDirection.getOrientation(1)) { + return new FluidTankInfo[] { fluidTank.getInfo() }; + } + + return PipeUtils.EMPTY; + } + + @Override + public void setFluidStack(FluidStack fluidStack, Object... data) { + fluidTank.setFluid(fluidStack); + } + + @Override + public FluidStack getFluidStack(Object... data) { + return fluidTank.getFluid(); + } + + @Override + public boolean hasTank(Object... data) { + return true; + } + + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + if (fluidTank.getFluid() != null + && fluidTank.getFluid().getFluid() == resource.getFluid() + && from == ForgeDirection.getOrientation(1)) { + return drain(from, resource.amount, doDrain); + } + + return null; + } + + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { + return 0; + } + + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { + if (from == ForgeDirection.getOrientation(1)) { + return fluidTank.drain(maxDrain, doDrain); + } + + return null; + } + + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + return false; + } + + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + return from == ForgeDirection.getOrientation(1); + } + + @Override + public boolean onSneakRightClick(EntityPlayer player, int side) { + reset(); + + player.addChatMessage(new ChatComponentText( + EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + + LangUtils.localize("tooltip.configurator.pumpReset") + )); + + return true; + } + + @Override + public boolean onRightClick(EntityPlayer player, int side) { + return false; + } + + @Override + public RedstoneControl getControlType() { + return controlType; + } + + @Override + public void setControlType(RedstoneControl type) { + controlType = type; + MekanismUtils.saveChunk(this); + } + + @Override + public boolean canPulse() { + return true; + } + + @Override + public TileComponentUpgrade getComponent() { + return upgradeComponent; + } + + @Override + public Object[] getTanks() { + return new Object[] { fluidTank }; + } + + private static final String[] methods = new String[] { "reset" }; + + @Override + public String[] getMethods() { + return methods; + } + + @Override + public Object[] invoke(int method, Object[] arguments) throws Exception { + switch (method) { + case 0: + reset(); + return new Object[] { "Pump calculation reset." }; + default: + throw new NoSuchMethodException(); + } + } + + @Override + public TileComponentSecurity getSecurity() { + return securityComponent; + } + + @Override + public void recalculateUpgradables(Upgrade upgrade) { + super.recalculateUpgradables(upgrade); + + switch (upgrade) { + case SPEED: + ticksRequired = MekanismUtils.getTicks(this, BASE_TICKS_REQUIRED); + case ENERGY: + energyPerTick + = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK); + maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY); + default: + break; + } + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityElectrolyticSeparator.java b/src/main/java/mekanism/common/tile/TileEntityElectrolyticSeparator.java index 2b46fbfa8..a743d3475 100644 --- a/src/main/java/mekanism/common/tile/TileEntityElectrolyticSeparator.java +++ b/src/main/java/mekanism/common/tile/TileEntityElectrolyticSeparator.java @@ -1,10 +1,9 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.List; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.MekanismConfig; import mekanism.api.Range4D; @@ -53,679 +52,685 @@ import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidContainerItem; import net.minecraftforge.fluids.IFluidHandler; -public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock implements IFluidHandler, IComputerIntegration, ITubeConnection, ISustainedData, IGasHandler, IUpgradeTile, IUpgradeInfoHandler, ITankManager, IRedstoneControl, IActiveState, ISecurityTile -{ - /** This separator's water slot. */ - public FluidTank fluidTank = new FluidTank(24000); +public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock + implements IFluidHandler, IComputerIntegration, ITubeConnection, ISustainedData, + IGasHandler, IUpgradeTile, IUpgradeInfoHandler, ITankManager, + IRedstoneControl, IActiveState, ISecurityTile { + /** This separator's water slot. */ + public FluidTank fluidTank = new FluidTank(24000); - /** The maximum amount of gas this block can store. */ - public int MAX_GAS = 2400; + /** The maximum amount of gas this block can store. */ + public int MAX_GAS = 2400; - /** The amount of oxygen this block is storing. */ - public GasTank leftTank = new GasTank(MAX_GAS); + /** The amount of oxygen this block is storing. */ + public GasTank leftTank = new GasTank(MAX_GAS); - /** The amount of hydrogen this block is storing. */ - public GasTank rightTank = new GasTank(MAX_GAS); + /** The amount of hydrogen this block is storing. */ + public GasTank rightTank = new GasTank(MAX_GAS); - /** How fast this block can output gas. */ - public int output = 512; + /** How fast this block can output gas. */ + public int output = 512; - /** The type of gas this block is outputting. */ - public GasMode dumpLeft = GasMode.IDLE; + /** The type of gas this block is outputting. */ + public GasMode dumpLeft = GasMode.IDLE; - /** Type type of gas this block is dumping. */ - public GasMode dumpRight = GasMode.IDLE; - - public double BASE_ENERGY_USAGE; - - public double energyPerTick; + /** Type type of gas this block is dumping. */ + public GasMode dumpRight = GasMode.IDLE; + + public double BASE_ENERGY_USAGE; + + public double energyPerTick; public int updateDelay; - public boolean isActive = false; + public boolean isActive = false; public boolean clientActive = false; public double prevEnergy; - public SeparatorRecipe cachedRecipe; - - public double clientEnergyUsed; - - public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, 4); - public TileComponentSecurity securityComponent = new TileComponentSecurity(this); + public SeparatorRecipe cachedRecipe; + + public double clientEnergyUsed; + + public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, 4); + public TileComponentSecurity securityComponent = new TileComponentSecurity(this); /** This machine's current RedstoneControl type. */ public RedstoneControl controlType = RedstoneControl.DISABLED; - public TileEntityElectrolyticSeparator() - { - super("ElectrolyticSeparator", MachineType.ELECTROLYTIC_SEPARATOR.baseEnergy); - inventory = new ItemStack[5]; - } + public TileEntityElectrolyticSeparator() { + super("ElectrolyticSeparator", MachineType.ELECTROLYTIC_SEPARATOR.baseEnergy); + inventory = new ItemStack[5]; + } - @Override - public void onUpdate() - { - super.onUpdate(); + @Override + public void onUpdate() { + super.onUpdate(); - if(worldObj.isRemote && updateDelay > 0) - { + if (worldObj.isRemote && updateDelay > 0) { updateDelay--; - if(updateDelay == 0 && clientActive != isActive) - { + if (updateDelay == 0 && clientActive != isActive) { isActive = clientActive; MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); } } - if(!worldObj.isRemote) - { - if(updateDelay > 0) - { + if (!worldObj.isRemote) { + if (updateDelay > 0) { updateDelay--; - if(updateDelay == 0 && clientActive != isActive) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); + if (updateDelay == 0 && clientActive != isActive) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); } } - ChargeUtils.discharge(3, this); - - if(inventory[0] != null) - { - if(RecipeHandler.Recipe.ELECTROLYTIC_SEPARATOR.containsRecipe(inventory[0])) - { - if(inventory[0].getItem() instanceof IFluidContainerItem) - { - fluidTank.fill(FluidContainerUtils.extractFluid(fluidTank, inventory[0]), true); - } - else { - FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(inventory[0]); - - if(fluid != null && (fluidTank.getFluid() == null || fluid.isFluidEqual(fluidTank.getFluid()) && fluidTank.getFluid().amount+fluid.amount <= fluidTank.getCapacity())) - { - fluidTank.fill(fluid, true); - - if(inventory[0].getItem().hasContainerItem(inventory[0])) - { - inventory[0] = inventory[0].getItem().getContainerItem(inventory[0]); - } - else { - inventory[0].stackSize--; - } - - if(inventory[0].stackSize == 0) - { - inventory[0] = null; - } - } - } - } - } + ChargeUtils.discharge(3, this); - if(inventory[1] != null && leftTank.getStored() > 0) - { - leftTank.draw(GasTransmission.addGas(inventory[1], leftTank.getGas()), true); - MekanismUtils.saveChunk(this); - } + if (inventory[0] != null) { + if (RecipeHandler.Recipe.ELECTROLYTIC_SEPARATOR.containsRecipe( + inventory[0] + )) { + if (inventory[0].getItem() instanceof IFluidContainerItem) { + fluidTank.fill( + FluidContainerUtils.extractFluid(fluidTank, inventory[0]), + true + ); + } else { + FluidStack fluid + = FluidContainerRegistry.getFluidForFilledItem(inventory[0]); - if(inventory[2] != null && rightTank.getStored() > 0) - { - rightTank.draw(GasTransmission.addGas(inventory[2], rightTank.getGas()), true); - MekanismUtils.saveChunk(this); - } - - SeparatorRecipe recipe = getRecipe(); + if (fluid != null + && (fluidTank.getFluid() == null + || fluid.isFluidEqual(fluidTank.getFluid()) + && fluidTank.getFluid().amount + fluid.amount + <= fluidTank.getCapacity())) { + fluidTank.fill(fluid, true); - if(canOperate(recipe) && getEnergy() >= energyPerTick && MekanismUtils.canFunction(this)) - { + if (inventory[0].getItem().hasContainerItem(inventory[0])) { + inventory[0] + = inventory[0].getItem().getContainerItem(inventory[0] + ); + } else { + inventory[0].stackSize--; + } + + if (inventory[0].stackSize == 0) { + inventory[0] = null; + } + } + } + } + } + + if (inventory[1] != null && leftTank.getStored() > 0) { + leftTank.draw( + GasTransmission.addGas(inventory[1], leftTank.getGas()), true + ); + MekanismUtils.saveChunk(this); + } + + if (inventory[2] != null && rightTank.getStored() > 0) { + rightTank.draw( + GasTransmission.addGas(inventory[2], rightTank.getGas()), true + ); + MekanismUtils.saveChunk(this); + } + + SeparatorRecipe recipe = getRecipe(); + + if (canOperate(recipe) && getEnergy() >= energyPerTick + && MekanismUtils.canFunction(this)) { setActive(true); - boolean update = BASE_ENERGY_USAGE != recipe.energyUsage; - - BASE_ENERGY_USAGE = recipe.energyUsage; - - if(update) - { - recalculateUpgradables(Upgrade.ENERGY); - } - - int operations = operate(recipe); - double prev = getEnergy(); - - setEnergy(getEnergy() - energyPerTick*operations); - clientEnergyUsed = prev-getEnergy(); - } - else { - if(prevEnergy >= getEnergy()) - { + boolean update = BASE_ENERGY_USAGE != recipe.energyUsage; + + BASE_ENERGY_USAGE = recipe.energyUsage; + + if (update) { + recalculateUpgradables(Upgrade.ENERGY); + } + + int operations = operate(recipe); + double prev = getEnergy(); + + setEnergy(getEnergy() - energyPerTick * operations); + clientEnergyUsed = prev - getEnergy(); + } else { + if (prevEnergy >= getEnergy()) { setActive(false); } - } - - int dumpAmount = 8*(int)Math.pow(2, upgradeComponent.getUpgrades(Upgrade.SPEED)); + } - if(leftTank.getGas() != null) - { - if(dumpLeft != GasMode.DUMPING) - { - GasStack toSend = new GasStack(leftTank.getGas().getGas(), Math.min(leftTank.getStored(), output)); + int dumpAmount + = 8 * (int) Math.pow(2, upgradeComponent.getUpgrades(Upgrade.SPEED)); - TileEntity tileEntity = Coord4D.get(this).getFromSide(MekanismUtils.getLeft(facing)).getTileEntity(worldObj); + if (leftTank.getGas() != null) { + if (dumpLeft != GasMode.DUMPING) { + GasStack toSend = new GasStack( + leftTank.getGas().getGas(), Math.min(leftTank.getStored(), output) + ); - if(tileEntity instanceof IGasHandler) - { - if(((IGasHandler)tileEntity).canReceiveGas(MekanismUtils.getLeft(facing).getOpposite(), leftTank.getGas().getGas())) - { - leftTank.draw(((IGasHandler)tileEntity).receiveGas(MekanismUtils.getLeft(facing).getOpposite(), toSend, true), true); - } - } - } - else if(dumpLeft == GasMode.DUMPING) - { - leftTank.draw(dumpAmount, true); - } - - if(dumpLeft == GasMode.DUMPING_EXCESS && leftTank.getNeeded() < output) - { - leftTank.draw(output-leftTank.getNeeded(), true); - } - } + TileEntity tileEntity + = Coord4D.get(this) + .getFromSide(MekanismUtils.getLeft(facing)) + .getTileEntity(worldObj); - if(rightTank.getGas() != null) - { - if(dumpRight != GasMode.DUMPING) - { - GasStack toSend = new GasStack(rightTank.getGas().getGas(), Math.min(rightTank.getStored(), output)); + if (tileEntity instanceof IGasHandler) { + if (((IGasHandler) tileEntity) + .canReceiveGas( + MekanismUtils.getLeft(facing).getOpposite(), + leftTank.getGas().getGas() + )) { + leftTank.draw( + ((IGasHandler) tileEntity) + .receiveGas( + MekanismUtils.getLeft(facing).getOpposite(), + toSend, + true + ), + true + ); + } + } + } else if (dumpLeft == GasMode.DUMPING) { + leftTank.draw(dumpAmount, true); + } - TileEntity tileEntity = Coord4D.get(this).getFromSide(MekanismUtils.getRight(facing)).getTileEntity(worldObj); + if (dumpLeft == GasMode.DUMPING_EXCESS && leftTank.getNeeded() < output) { + leftTank.draw(output - leftTank.getNeeded(), true); + } + } - if(tileEntity instanceof IGasHandler) - { - if(((IGasHandler)tileEntity).canReceiveGas(MekanismUtils.getRight(facing).getOpposite(), rightTank.getGas().getGas())) - { - rightTank.draw(((IGasHandler)tileEntity).receiveGas(MekanismUtils.getRight(facing).getOpposite(), toSend, true), true); - } - } - } - else if(dumpRight == GasMode.DUMPING) - { - rightTank.draw(dumpAmount, true); - } - - if(dumpRight == GasMode.DUMPING_EXCESS && rightTank.getNeeded() < output) - { - rightTank.draw(output-rightTank.getNeeded(), true); - } - } + if (rightTank.getGas() != null) { + if (dumpRight != GasMode.DUMPING) { + GasStack toSend = new GasStack( + rightTank.getGas().getGas(), + Math.min(rightTank.getStored(), output) + ); + + TileEntity tileEntity + = Coord4D.get(this) + .getFromSide(MekanismUtils.getRight(facing)) + .getTileEntity(worldObj); + + if (tileEntity instanceof IGasHandler) { + if (((IGasHandler) tileEntity) + .canReceiveGas( + MekanismUtils.getRight(facing).getOpposite(), + rightTank.getGas().getGas() + )) { + rightTank.draw( + ((IGasHandler) tileEntity) + .receiveGas( + MekanismUtils.getRight(facing).getOpposite(), + toSend, + true + ), + true + ); + } + } + } else if (dumpRight == GasMode.DUMPING) { + rightTank.draw(dumpAmount, true); + } + + if (dumpRight == GasMode.DUMPING_EXCESS + && rightTank.getNeeded() < output) { + rightTank.draw(output - rightTank.getNeeded(), true); + } + } prevEnergy = getEnergy(); - } - } - - public int getUpgradedUsage(SeparatorRecipe recipe) - { - int possibleProcess = 0; - - if(leftTank.getGasType() == recipe.recipeOutput.leftGas.getGas()) - { - possibleProcess = leftTank.getNeeded()/recipe.recipeOutput.leftGas.amount; - possibleProcess = Math.min(rightTank.getNeeded()/recipe.recipeOutput.rightGas.amount, possibleProcess); - } - else { - possibleProcess = leftTank.getNeeded()/recipe.recipeOutput.rightGas.amount; - possibleProcess = Math.min(rightTank.getNeeded()/recipe.recipeOutput.leftGas.amount, possibleProcess); - } - - possibleProcess = Math.min((int)Math.pow(2, upgradeComponent.getUpgrades(Upgrade.SPEED)), possibleProcess); - possibleProcess = Math.min((int)(getEnergy()/energyPerTick), possibleProcess); - - return Math.min(fluidTank.getFluidAmount()/recipe.recipeInput.ingredient.amount, possibleProcess); - } + } + } - public SeparatorRecipe getRecipe() - { - FluidInput input = getInput(); - - if(cachedRecipe == null || !input.testEquality(cachedRecipe.getInput())) - { - cachedRecipe = RecipeHandler.getElectrolyticSeparatorRecipe(getInput()); - } - - return cachedRecipe; - } + public int getUpgradedUsage(SeparatorRecipe recipe) { + int possibleProcess = 0; - public FluidInput getInput() - { - return new FluidInput(fluidTank.getFluid()); - } + if (leftTank.getGasType() == recipe.recipeOutput.leftGas.getGas()) { + possibleProcess = leftTank.getNeeded() / recipe.recipeOutput.leftGas.amount; + possibleProcess = Math.min( + rightTank.getNeeded() / recipe.recipeOutput.rightGas.amount, + possibleProcess + ); + } else { + possibleProcess = leftTank.getNeeded() / recipe.recipeOutput.rightGas.amount; + possibleProcess = Math.min( + rightTank.getNeeded() / recipe.recipeOutput.leftGas.amount, + possibleProcess + ); + } - public boolean canOperate(SeparatorRecipe recipe) - { - return recipe != null && recipe.canOperate(fluidTank, leftTank, rightTank); - } + possibleProcess = Math.min( + (int) Math.pow(2, upgradeComponent.getUpgrades(Upgrade.SPEED)), + possibleProcess + ); + possibleProcess = Math.min((int) (getEnergy() / energyPerTick), possibleProcess); - public int operate(SeparatorRecipe recipe) - { - int operations = getUpgradedUsage(recipe); - - recipe.operate(fluidTank, leftTank, rightTank, operations); - - return operations; - } + return Math.min( + fluidTank.getFluidAmount() / recipe.recipeInput.ingredient.amount, + possibleProcess + ); + } - public boolean canFill(ChemicalPairOutput gases) - { - return (leftTank.canReceive(gases.leftGas.getGas()) && leftTank.getNeeded() >= gases.leftGas.amount - && rightTank.canReceive(gases.rightGas.getGas()) && rightTank.getNeeded() >= gases.rightGas.amount); - } + public SeparatorRecipe getRecipe() { + FluidInput input = getInput(); - @Override - public boolean canExtractItem(int slotID, ItemStack itemstack, int side) - { - if(slotID == 3) - { - return ChargeUtils.canBeOutputted(itemstack, false); - } - else if(slotID == 0) - { - return FluidContainerRegistry.isEmptyContainer(itemstack); - } - else if(slotID == 1 || slotID == 2) - { - return itemstack.getItem() instanceof IGasItem && ((IGasItem)itemstack.getItem()).getGas(itemstack) != null && - ((IGasItem)itemstack.getItem()).getGas(itemstack).amount == ((IGasItem)itemstack.getItem()).getMaxGas(itemstack); - } + if (cachedRecipe == null || !input.testEquality(cachedRecipe.getInput())) { + cachedRecipe = RecipeHandler.getElectrolyticSeparatorRecipe(getInput()); + } - return false; - } + return cachedRecipe; + } - @Override - public boolean isItemValidForSlot(int slotID, ItemStack itemstack) - { - if(slotID == 0) - { - return Recipe.ELECTROLYTIC_SEPARATOR.containsRecipe(itemstack); - } - else if(slotID == 1) - { - return itemstack.getItem() instanceof IGasItem && (((IGasItem)itemstack.getItem()).getGas(itemstack) == null || ((IGasItem)itemstack.getItem()).getGas(itemstack).getGas() == GasRegistry.getGas("hydrogen")); - } - else if(slotID == 2) - { - return itemstack.getItem() instanceof IGasItem && (((IGasItem)itemstack.getItem()).getGas(itemstack) == null || ((IGasItem)itemstack.getItem()).getGas(itemstack).getGas() == GasRegistry.getGas("oxygen")); - } - else if(slotID == 3) - { - return ChargeUtils.canBeDischarged(itemstack); - } + public FluidInput getInput() { + return new FluidInput(fluidTank.getFluid()); + } - return true; - } + public boolean canOperate(SeparatorRecipe recipe) { + return recipe != null && recipe.canOperate(fluidTank, leftTank, rightTank); + } - @Override - public int[] getAccessibleSlotsFromSide(int side) - { - if(ForgeDirection.getOrientation(side) == MekanismUtils.getRight(facing)) - { - return new int[] {3}; - } + public int operate(SeparatorRecipe recipe) { + int operations = getUpgradedUsage(recipe); + + recipe.operate(fluidTank, leftTank, rightTank, operations); + + return operations; + } + + public boolean canFill(ChemicalPairOutput gases) { + return ( + leftTank.canReceive(gases.leftGas.getGas()) + && leftTank.getNeeded() >= gases.leftGas.amount + && rightTank.canReceive(gases.rightGas.getGas()) + && rightTank.getNeeded() >= gases.rightGas.amount + ); + } + + @Override + public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { + if (slotID == 3) { + return ChargeUtils.canBeOutputted(itemstack, false); + } else if (slotID == 0) { + return FluidContainerRegistry.isEmptyContainer(itemstack); + } else if (slotID == 1 || slotID == 2) { + return itemstack.getItem() instanceof IGasItem + && ((IGasItem) itemstack.getItem()).getGas(itemstack) != null + && ((IGasItem) itemstack.getItem()).getGas(itemstack).amount + == ((IGasItem) itemstack.getItem()).getMaxGas(itemstack); + } + + return false; + } + + @Override + public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { + if (slotID == 0) { + return Recipe.ELECTROLYTIC_SEPARATOR.containsRecipe(itemstack); + } else if (slotID == 1) { + return itemstack.getItem() instanceof IGasItem + && (((IGasItem) itemstack.getItem()).getGas(itemstack) == null + || ((IGasItem) itemstack.getItem()).getGas(itemstack).getGas() + == GasRegistry.getGas("hydrogen")); + } else if (slotID == 2) { + return itemstack.getItem() instanceof IGasItem + && (((IGasItem) itemstack.getItem()).getGas(itemstack) == null + || ((IGasItem) itemstack.getItem()).getGas(itemstack).getGas() + == GasRegistry.getGas("oxygen")); + } else if (slotID == 3) { + return ChargeUtils.canBeDischarged(itemstack); + } + + return true; + } + + @Override + public int[] getAccessibleSlotsFromSide(int side) { + if (ForgeDirection.getOrientation(side) == MekanismUtils.getRight(facing)) { + return new int[] { 3 }; + } else if(side == facing || ForgeDirection.getOrientation(side) == ForgeDirection.getOrientation(facing).getOpposite()) { - return new int[] {1, 2}; - } + return new int[] { 1, 2 }; + } - return InventoryUtils.EMPTY; - } + return InventoryUtils.EMPTY; + } - @Override - public void handlePacketData(ByteBuf dataStream) - { - if(!worldObj.isRemote) - { - byte type = dataStream.readByte(); + @Override + public void handlePacketData(ByteBuf dataStream) { + if (!worldObj.isRemote) { + byte type = dataStream.readByte(); - if(type == 0) - { - dumpLeft = GasMode.values()[dumpLeft.ordinal() == GasMode.values().length-1 ? 0 : dumpLeft.ordinal()+1]; - } - else if(type == 1) - { - dumpRight = GasMode.values()[dumpRight.ordinal() == GasMode.values().length-1 ? 0 : dumpRight.ordinal()+1]; - } + if (type == 0) { + dumpLeft = GasMode.values( + )[dumpLeft.ordinal() == GasMode.values().length - 1 + ? 0 + : dumpLeft.ordinal() + 1]; + } else if (type == 1) { + dumpRight = GasMode.values( + )[dumpRight.ordinal() == GasMode.values().length - 1 + ? 0 + : dumpRight.ordinal() + 1]; + } - return; - } + return; + } - super.handlePacketData(dataStream); - - if(worldObj.isRemote) - { - if(dataStream.readBoolean()) - { - fluidTank.setFluid(new FluidStack(FluidRegistry.getFluid(dataStream.readInt()), dataStream.readInt())); - } - else { - fluidTank.setFluid(null); - } - - if(dataStream.readBoolean()) - { - leftTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt())); - } - else { - leftTank.setGas(null); - } - - if(dataStream.readBoolean()) - { - rightTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt())); - } - else { - rightTank.setGas(null); - } - - controlType = RedstoneControl.values()[dataStream.readInt()]; - dumpLeft = GasMode.values()[dataStream.readInt()]; - dumpRight = GasMode.values()[dataStream.readInt()]; - clientActive = dataStream.readBoolean(); - clientEnergyUsed = dataStream.readDouble(); - - if(updateDelay == 0 && clientActive != isActive) - { - updateDelay = MekanismConfig.general.UPDATE_DELAY; - isActive = clientActive; - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } - } + super.handlePacketData(dataStream); - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); + if (worldObj.isRemote) { + if (dataStream.readBoolean()) { + fluidTank.setFluid(new FluidStack( + FluidRegistry.getFluid(dataStream.readInt()), dataStream.readInt() + )); + } else { + fluidTank.setFluid(null); + } - if(fluidTank.getFluid() != null) - { - data.add(true); - data.add(fluidTank.getFluid().getFluid().getID()); - data.add(fluidTank.getFluidAmount()); - } - else { - data.add(false); - } + if (dataStream.readBoolean()) { + leftTank.setGas(new GasStack( + GasRegistry.getGas(dataStream.readInt()), dataStream.readInt() + )); + } else { + leftTank.setGas(null); + } - if(leftTank.getGas() != null) - { - data.add(true); - data.add(leftTank.getGas().getGas().getID()); - data.add(leftTank.getStored()); - } - else { - data.add(false); - } + if (dataStream.readBoolean()) { + rightTank.setGas(new GasStack( + GasRegistry.getGas(dataStream.readInt()), dataStream.readInt() + )); + } else { + rightTank.setGas(null); + } - if(rightTank.getGas() != null) - { - data.add(true); - data.add(rightTank.getGas().getGas().getID()); - data.add(rightTank.getStored()); - } - else { - data.add(false); - } + controlType = RedstoneControl.values()[dataStream.readInt()]; + dumpLeft = GasMode.values()[dataStream.readInt()]; + dumpRight = GasMode.values()[dataStream.readInt()]; + clientActive = dataStream.readBoolean(); + clientEnergyUsed = dataStream.readDouble(); + + if (updateDelay == 0 && clientActive != isActive) { + updateDelay = MekanismConfig.general.UPDATE_DELAY; + isActive = clientActive; + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } + } + + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); + + if (fluidTank.getFluid() != null) { + data.add(true); + data.add(fluidTank.getFluid().getFluid().getID()); + data.add(fluidTank.getFluidAmount()); + } else { + data.add(false); + } + + if (leftTank.getGas() != null) { + data.add(true); + data.add(leftTank.getGas().getGas().getID()); + data.add(leftTank.getStored()); + } else { + data.add(false); + } + + if (rightTank.getGas() != null) { + data.add(true); + data.add(rightTank.getGas().getGas().getID()); + data.add(rightTank.getStored()); + } else { + data.add(false); + } data.add(controlType.ordinal()); - data.add(dumpLeft.ordinal()); - data.add(dumpRight.ordinal()); - data.add(isActive); - data.add(clientEnergyUsed); + data.add(dumpLeft.ordinal()); + data.add(dumpRight.ordinal()); + data.add(isActive); + data.add(clientEnergyUsed); - return data; - } - - @Override - public boolean canSetFacing(int side) - { - return side != 0 && side != 1; - } + return data; + } - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); + @Override + public boolean canSetFacing(int side) { + return side != 0 && side != 1; + } - if(nbtTags.hasKey("fluidTank")) - { - fluidTank.readFromNBT(nbtTags.getCompoundTag("fluidTank")); - } + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); + + if (nbtTags.hasKey("fluidTank")) { + fluidTank.readFromNBT(nbtTags.getCompoundTag("fluidTank")); + } isActive = nbtTags.getBoolean("isActive"); controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - leftTank.read(nbtTags.getCompoundTag("leftTank")); - rightTank.read(nbtTags.getCompoundTag("rightTank")); + leftTank.read(nbtTags.getCompoundTag("leftTank")); + rightTank.read(nbtTags.getCompoundTag("rightTank")); - dumpLeft = GasMode.values()[nbtTags.getInteger("dumpLeft")]; - dumpRight = GasMode.values()[nbtTags.getInteger("dumpRight")]; - } + dumpLeft = GasMode.values()[nbtTags.getInteger("dumpLeft")]; + dumpRight = GasMode.values()[nbtTags.getInteger("dumpRight")]; + } - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); - if(fluidTank.getFluid() != null) - { - nbtTags.setTag("fluidTank", fluidTank.writeToNBT(new NBTTagCompound())); - } + if (fluidTank.getFluid() != null) { + nbtTags.setTag("fluidTank", fluidTank.writeToNBT(new NBTTagCompound())); + } nbtTags.setBoolean("isActive", isActive); nbtTags.setInteger("controlType", controlType.ordinal()); - nbtTags.setTag("leftTank", leftTank.write(new NBTTagCompound())); - nbtTags.setTag("rightTank", rightTank.write(new NBTTagCompound())); + nbtTags.setTag("leftTank", leftTank.write(new NBTTagCompound())); + nbtTags.setTag("rightTank", rightTank.write(new NBTTagCompound())); - nbtTags.setInteger("dumpLeft", dumpLeft.ordinal()); - nbtTags.setInteger("dumpRight", dumpRight.ordinal()); - } + nbtTags.setInteger("dumpLeft", dumpLeft.ordinal()); + nbtTags.setInteger("dumpRight", dumpRight.ordinal()); + } - private static final String[] methods = new String[] {"getEnergy", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getWater", "getWaterNeeded", "getHydrogen", "getHydrogenNeeded", "getOxygen", "getOxygenNeeded"}; - - @Override - public String[] getMethods() - { - return methods; - } - - @Override - public Object[] invoke(int method, Object[] arguments) throws Exception - { - switch(method) - { - case 0: - return new Object[] {electricityStored}; - case 1: - return new Object[] {output}; - case 2: - return new Object[] {BASE_MAX_ENERGY}; - case 3: - return new Object[] {(BASE_MAX_ENERGY -electricityStored)}; - case 4: - return new Object[] {fluidTank.getFluid() != null ? fluidTank.getFluid().amount : 0}; - case 5: - return new Object[] {fluidTank.getFluid() != null ? (fluidTank.getCapacity()- fluidTank.getFluid().amount) : 0}; - case 6: - return new Object[] {leftTank.getStored()}; - case 7: - return new Object[] {leftTank.getNeeded()}; - case 8: - return new Object[] {rightTank.getStored()}; - case 9: - return new Object[] {rightTank.getNeeded()}; - default: - throw new NoSuchMethodException(); - } - } - - @Override - public boolean canTubeConnect(ForgeDirection side) - { - return side == MekanismUtils.getLeft(facing) || side == MekanismUtils.getRight(facing); - } - - @Override - public void writeSustainedData(ItemStack itemStack) - { - if(fluidTank.getFluid() != null) - { - itemStack.stackTagCompound.setTag("fluidTank", fluidTank.getFluid().writeToNBT(new NBTTagCompound())); - } - - if(leftTank.getGas() != null) - { - itemStack.stackTagCompound.setTag("leftTank", leftTank.getGas().write(new NBTTagCompound())); - } - - if(rightTank.getGas() != null) - { - itemStack.stackTagCompound.setTag("rightTank", rightTank.getGas().write(new NBTTagCompound())); - } - } - - @Override - public void readSustainedData(ItemStack itemStack) - { - fluidTank.setFluid(FluidStack.loadFluidStackFromNBT(itemStack.stackTagCompound.getCompoundTag("fluidTank"))); - leftTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("leftTank"))); - rightTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("rightTank"))); - } - - @Override - public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) - { - return null; - } - - @Override - public boolean canFill(ForgeDirection from, Fluid fluid) - { - return Recipe.ELECTROLYTIC_SEPARATOR.containsRecipe(fluid); - } - - @Override - public boolean canDrain(ForgeDirection from, Fluid fluid) - { - return false; - } - - @Override - public int fill(ForgeDirection from, FluidStack resource, boolean doFill) - { - if(Recipe.ELECTROLYTIC_SEPARATOR.containsRecipe(resource.getFluid())) - { - return fluidTank.fill(resource, doFill); - } - - return 0; - } - - @Override - public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) - { - return null; - } - - @Override - public FluidTankInfo[] getTankInfo(ForgeDirection from) - { - return new FluidTankInfo[] {fluidTank.getInfo()}; - } - - @Override - public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) - { - return 0; - } - - @Override - public int receiveGas(ForgeDirection side, GasStack stack) - { - return receiveGas(side, stack, true); - } - - @Override - public GasStack drawGas(ForgeDirection side, int amount, boolean doTransfer) - { - if(side == MekanismUtils.getLeft(facing)) - { - return leftTank.draw(amount, doTransfer); - } - else if(side == MekanismUtils.getRight(facing)) - { - return rightTank.draw(amount, doTransfer); - } - - return null; - } - - @Override - public GasStack drawGas(ForgeDirection side, int amount) - { - return drawGas(side, amount, true); - } - - @Override - public boolean canReceiveGas(ForgeDirection side, Gas type) - { - return false; - } - - @Override - public boolean canDrawGas(ForgeDirection side, Gas type) - { - if(side == MekanismUtils.getLeft(facing)) - { - return leftTank.getGas() != null && leftTank.getGas().getGas() == type; - } - else if(side == MekanismUtils.getRight(facing)) - { - return rightTank.getGas() != null && rightTank.getGas().getGas() == type; - } - - return false; - } + private static final String[] methods + = new String[] { "getEnergy", "getOutput", "getMaxEnergy", + "getEnergyNeeded", "getWater", "getWaterNeeded", + "getHydrogen", "getHydrogenNeeded", "getOxygen", + "getOxygenNeeded" }; @Override - public RedstoneControl getControlType() - { + public String[] getMethods() { + return methods; + } + + @Override + public Object[] invoke(int method, Object[] arguments) throws Exception { + switch (method) { + case 0: + return new Object[] { electricityStored }; + case 1: + return new Object[] { output }; + case 2: + return new Object[] { BASE_MAX_ENERGY }; + case 3: + return new Object[] { (BASE_MAX_ENERGY - electricityStored) }; + case 4: + return new Object[] { fluidTank.getFluid() != null + ? fluidTank.getFluid().amount + : 0 }; + case 5: + return new Object[] { fluidTank.getFluid() != null + ? (fluidTank.getCapacity() + - fluidTank.getFluid().amount) + : 0 }; + case 6: + return new Object[] { leftTank.getStored() }; + case 7: + return new Object[] { leftTank.getNeeded() }; + case 8: + return new Object[] { rightTank.getStored() }; + case 9: + return new Object[] { rightTank.getNeeded() }; + default: + throw new NoSuchMethodException(); + } + } + + @Override + public boolean canTubeConnect(ForgeDirection side) { + return side == MekanismUtils.getLeft(facing) + || side == MekanismUtils.getRight(facing); + } + + @Override + public void writeSustainedData(ItemStack itemStack) { + if (fluidTank.getFluid() != null) { + itemStack.stackTagCompound.setTag( + "fluidTank", fluidTank.getFluid().writeToNBT(new NBTTagCompound()) + ); + } + + if (leftTank.getGas() != null) { + itemStack.stackTagCompound.setTag( + "leftTank", leftTank.getGas().write(new NBTTagCompound()) + ); + } + + if (rightTank.getGas() != null) { + itemStack.stackTagCompound.setTag( + "rightTank", rightTank.getGas().write(new NBTTagCompound()) + ); + } + } + + @Override + public void readSustainedData(ItemStack itemStack) { + fluidTank.setFluid(FluidStack.loadFluidStackFromNBT( + itemStack.stackTagCompound.getCompoundTag("fluidTank") + )); + leftTank.setGas( + GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("leftTank")) + ); + rightTank.setGas( + GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("rightTank")) + ); + } + + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + return null; + } + + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + return Recipe.ELECTROLYTIC_SEPARATOR.containsRecipe(fluid); + } + + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + return false; + } + + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { + if (Recipe.ELECTROLYTIC_SEPARATOR.containsRecipe(resource.getFluid())) { + return fluidTank.fill(resource, doFill); + } + + return 0; + } + + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { + return null; + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection from) { + return new FluidTankInfo[] { fluidTank.getInfo() }; + } + + @Override + public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) { + return 0; + } + + @Override + public int receiveGas(ForgeDirection side, GasStack stack) { + return receiveGas(side, stack, true); + } + + @Override + public GasStack drawGas(ForgeDirection side, int amount, boolean doTransfer) { + if (side == MekanismUtils.getLeft(facing)) { + return leftTank.draw(amount, doTransfer); + } else if (side == MekanismUtils.getRight(facing)) { + return rightTank.draw(amount, doTransfer); + } + + return null; + } + + @Override + public GasStack drawGas(ForgeDirection side, int amount) { + return drawGas(side, amount, true); + } + + @Override + public boolean canReceiveGas(ForgeDirection side, Gas type) { + return false; + } + + @Override + public boolean canDrawGas(ForgeDirection side, Gas type) { + if (side == MekanismUtils.getLeft(facing)) { + return leftTank.getGas() != null && leftTank.getGas().getGas() == type; + } else if (side == MekanismUtils.getRight(facing)) { + return rightTank.getGas() != null && rightTank.getGas().getGas() == type; + } + + return false; + } + + @Override + public RedstoneControl getControlType() { return controlType; } @Override - public void setControlType(RedstoneControl type) - { + public void setControlType(RedstoneControl type) { controlType = type; MekanismUtils.saveChunk(this); } @Override - public boolean canPulse() - { + public boolean canPulse() { return false; } @Override - public void setActive(boolean active) - { + public void setActive(boolean active) { isActive = active; - if(clientActive != active && updateDelay == 0) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); + if (clientActive != active && updateDelay == 0) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); updateDelay = 10; clientActive = active; @@ -733,59 +738,51 @@ public class TileEntityElectrolyticSeparator extends TileEntityElectricBlock imp } @Override - public boolean getActive() - { + public boolean getActive() { return isActive; } @Override - public boolean renderUpdate() - { + public boolean renderUpdate() { return false; } @Override - public boolean lightUpdate() - { + public boolean lightUpdate() { return true; } - - @Override - public TileComponentUpgrade getComponent() - { - return upgradeComponent; - } - - @Override - public TileComponentSecurity getSecurity() - { - return securityComponent; - } - - @Override - public void recalculateUpgradables(Upgrade upgrade) - { - super.recalculateUpgradables(upgrade); - switch(upgrade) - { - case ENERGY: - maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY); - energyPerTick = BASE_ENERGY_USAGE; //Don't scale energy usage. - default: - break; - } - } - - @Override - public List getInfo(Upgrade upgrade) - { - return upgrade == Upgrade.SPEED ? upgrade.getExpScaledInfo(this) : upgrade.getMultScaledInfo(this); - } - - @Override - public Object[] getTanks() - { - return new Object[] {fluidTank, leftTank, rightTank}; - } + @Override + public TileComponentUpgrade getComponent() { + return upgradeComponent; + } + + @Override + public TileComponentSecurity getSecurity() { + return securityComponent; + } + + @Override + public void recalculateUpgradables(Upgrade upgrade) { + super.recalculateUpgradables(upgrade); + + switch (upgrade) { + case ENERGY: + maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY); + energyPerTick = BASE_ENERGY_USAGE; //Don't scale energy usage. + default: + break; + } + } + + @Override + public List getInfo(Upgrade upgrade) { + return upgrade == Upgrade.SPEED ? upgrade.getExpScaledInfo(this) + : upgrade.getMultScaledInfo(this); + } + + @Override + public Object[] getTanks() { + return new Object[] { fluidTank, leftTank, rightTank }; + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityEliteFactory.java b/src/main/java/mekanism/common/tile/TileEntityEliteFactory.java index 25acd9bea..c9dc49007 100644 --- a/src/main/java/mekanism/common/tile/TileEntityEliteFactory.java +++ b/src/main/java/mekanism/common/tile/TileEntityEliteFactory.java @@ -3,40 +3,65 @@ package mekanism.common.tile; import mekanism.api.EnumColor; import mekanism.api.transmitters.TransmissionType; import mekanism.common.SideData; -import mekanism.common.Upgrade; import mekanism.common.Tier.FactoryTier; +import mekanism.common.Upgrade; import mekanism.common.block.BlockMachine.MachineType; import mekanism.common.tile.component.TileComponentConfig; import mekanism.common.tile.component.TileComponentEjector; import mekanism.common.tile.component.TileComponentUpgrade; import mekanism.common.util.InventoryUtils; -public class TileEntityEliteFactory extends TileEntityFactory -{ - public TileEntityEliteFactory() - { - super(FactoryTier.ELITE, MachineType.ELITE_FACTORY); +public class TileEntityEliteFactory extends TileEntityFactory { + public TileEntityEliteFactory() { + super(FactoryTier.ELITE, MachineType.ELITE_FACTORY); - configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY, TransmissionType.GAS); - - configComponent.addOutput(TransmissionType.ITEM, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY)); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Input", EnumColor.DARK_RED, new int[] {5, 6, 7, 8, 9, 10, 11})); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Output", EnumColor.DARK_BLUE, new int[] {12, 13, 14, 15, 16, 17, 18})); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Energy", EnumColor.DARK_GREEN, new int[] {1})); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Extra", EnumColor.PURPLE, new int[] {4})); - configComponent.setConfig(TransmissionType.ITEM, new byte[] {4, 0, 0, 3, 1, 2}); - - configComponent.addOutput(TransmissionType.GAS, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY)); - configComponent.addOutput(TransmissionType.GAS, new SideData("Gas", EnumColor.DARK_RED, new int[] {0})); - configComponent.fillConfig(TransmissionType.GAS, 1); - configComponent.setCanEject(TransmissionType.GAS, false); - - configComponent.setInputConfig(TransmissionType.ENERGY); + configComponent = new TileComponentConfig( + this, TransmissionType.ITEM, TransmissionType.ENERGY, TransmissionType.GAS + ); - upgradeComponent = new TileComponentUpgrade(this, 0); - upgradeComponent.setSupported(Upgrade.MUFFLING); - - ejectorComponent = new TileComponentEjector(this); - ejectorComponent.setOutputData(TransmissionType.ITEM, configComponent.getOutputs(TransmissionType.ITEM).get(2)); - } + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY) + ); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("Input", EnumColor.DARK_RED, new int[] { 5, 6, 7, 8, 9, 10, 11 }) + ); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData( + "Output", EnumColor.DARK_BLUE, new int[] { 12, 13, 14, 15, 16, 17, 18 } + ) + ); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("Energy", EnumColor.DARK_GREEN, new int[] { 1 }) + ); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("Extra", EnumColor.PURPLE, new int[] { 4 }) + ); + configComponent.setConfig(TransmissionType.ITEM, new byte[] { 4, 0, 0, 3, 1, 2 }); + + configComponent.addOutput( + TransmissionType.GAS, + new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY) + ); + configComponent.addOutput( + TransmissionType.GAS, new SideData("Gas", EnumColor.DARK_RED, new int[] { 0 }) + ); + configComponent.fillConfig(TransmissionType.GAS, 1); + configComponent.setCanEject(TransmissionType.GAS, false); + + configComponent.setInputConfig(TransmissionType.ENERGY); + + upgradeComponent = new TileComponentUpgrade(this, 0); + upgradeComponent.setSupported(Upgrade.MUFFLING); + + ejectorComponent = new TileComponentEjector(this); + ejectorComponent.setOutputData( + TransmissionType.ITEM, + configComponent.getOutputs(TransmissionType.ITEM).get(2) + ); + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityEnergizedSmelter.java b/src/main/java/mekanism/common/tile/TileEntityEnergizedSmelter.java index 90e4c6468..fb3d349e9 100644 --- a/src/main/java/mekanism/common/tile/TileEntityEnergizedSmelter.java +++ b/src/main/java/mekanism/common/tile/TileEntityEnergizedSmelter.java @@ -8,16 +8,20 @@ import mekanism.common.recipe.RecipeHandler.Recipe; import mekanism.common.recipe.inputs.ItemStackInput; import mekanism.common.recipe.machines.SmeltingRecipe; -public class TileEntityEnergizedSmelter extends TileEntityElectricMachine -{ - public TileEntityEnergizedSmelter() - { - super("smelter", "EnergizedSmelter", usage.energizedSmelterUsage, 200, MachineType.ENERGIZED_SMELTER.baseEnergy); - } +public class TileEntityEnergizedSmelter + extends TileEntityElectricMachine { + public TileEntityEnergizedSmelter() { + super( + "smelter", + "EnergizedSmelter", + usage.energizedSmelterUsage, + 200, + MachineType.ENERGIZED_SMELTER.baseEnergy + ); + } - @Override - public Map getRecipes() - { - return Recipe.ENERGIZED_SMELTER.get(); - } + @Override + public Map getRecipes() { + return Recipe.ENERGIZED_SMELTER.get(); + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityEnergyCube.java b/src/main/java/mekanism/common/tile/TileEntityEnergyCube.java index c9410096c..1928fcd43 100644 --- a/src/main/java/mekanism/common/tile/TileEntityEnergyCube.java +++ b/src/main/java/mekanism/common/tile/TileEntityEnergyCube.java @@ -1,10 +1,9 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.EnumSet; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.Range4D; @@ -32,303 +31,287 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.MathHelper; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityEnergyCube extends TileEntityElectricBlock implements IComputerIntegration, IRedstoneControl, ISideConfiguration, ISecurityTile, ITierUpgradeable -{ - /** This Energy Cube's tier. */ - public EnergyCubeTier tier = EnergyCubeTier.BASIC; +public class TileEntityEnergyCube extends TileEntityElectricBlock + implements IComputerIntegration, IRedstoneControl, ISideConfiguration, ISecurityTile, + ITierUpgradeable { + /** This Energy Cube's tier. */ + public EnergyCubeTier tier = EnergyCubeTier.BASIC; - /** The redstone level this Energy Cube is outputting at. */ - public int currentRedstoneLevel; + /** The redstone level this Energy Cube is outputting at. */ + public int currentRedstoneLevel; - /** This machine's current RedstoneControl type. */ - public RedstoneControl controlType; + /** This machine's current RedstoneControl type. */ + public RedstoneControl controlType; - public int prevScale; - - public TileComponentEjector ejectorComponent; - public TileComponentConfig configComponent; - public TileComponentSecurity securityComponent; + public int prevScale; - /** - * A block used to store and transfer electricity. - */ - public TileEntityEnergyCube() - { - super("EnergyCube", 0); - - configComponent = new TileComponentConfig(this, TransmissionType.ENERGY, TransmissionType.ITEM); - - configComponent.addOutput(TransmissionType.ITEM, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY)); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Charge", EnumColor.DARK_BLUE, new int[] {0})); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Discharge", EnumColor.DARK_RED, new int[] {1})); - - configComponent.setConfig(TransmissionType.ITEM, new byte[] {0, 0, 0, 0, 2, 1}); - configComponent.setCanEject(TransmissionType.ITEM, false); - configComponent.setIOConfig(TransmissionType.ENERGY); - configComponent.setEjecting(TransmissionType.ENERGY, true); + public TileComponentEjector ejectorComponent; + public TileComponentConfig configComponent; + public TileComponentSecurity securityComponent; - inventory = new ItemStack[2]; - controlType = RedstoneControl.DISABLED; - - ejectorComponent = new TileComponentEjector(this); - - securityComponent = new TileComponentSecurity(this); - } + /** + * A block used to store and transfer electricity. + */ + public TileEntityEnergyCube() { + super("EnergyCube", 0); - @Override - public void onUpdate() - { - super.onUpdate(); + configComponent = new TileComponentConfig( + this, TransmissionType.ENERGY, TransmissionType.ITEM + ); - if(!worldObj.isRemote) - { - ChargeUtils.charge(0, this); - ChargeUtils.discharge(1, this); - - if(MekanismUtils.canFunction(this) && configComponent.isEjecting(TransmissionType.ENERGY)) - { - CableUtils.emit(this); - } - - int newScale = getScaledEnergyLevel(20); - - if(newScale != prevScale) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - } - - prevScale = newScale; - } - } - - @Override - public boolean upgrade(BaseTier upgradeTier) - { - if(upgradeTier.ordinal() != tier.ordinal()+1) - { - return false; - } - - tier = EnergyCubeTier.values()[upgradeTier.ordinal()]; - - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - markDirty(); - - return true; - } + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY) + ); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("Charge", EnumColor.DARK_BLUE, new int[] { 0 }) + ); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("Discharge", EnumColor.DARK_RED, new int[] { 1 }) + ); - @Override - public String getInventoryName() - { - return LangUtils.localize("tile.EnergyCube" + tier.getBaseTier().getName() + ".name"); - } + configComponent.setConfig(TransmissionType.ITEM, new byte[] { 0, 0, 0, 0, 2, 1 }); + configComponent.setCanEject(TransmissionType.ITEM, false); + configComponent.setIOConfig(TransmissionType.ENERGY); + configComponent.setEjecting(TransmissionType.ENERGY, true); - @Override - public double getMaxOutput() - { - if(tier == EnergyCubeTier.CREATIVE) - { - return Integer.MAX_VALUE; - } - - return tier.output; - } + inventory = new ItemStack[2]; + controlType = RedstoneControl.DISABLED; - @Override - public boolean isItemValidForSlot(int slotID, ItemStack itemstack) - { - if(slotID == 0) - { - return ChargeUtils.canBeCharged(itemstack); - } - else if(slotID == 1) - { - return ChargeUtils.canBeDischarged(itemstack); - } + ejectorComponent = new TileComponentEjector(this); - return true; - } + securityComponent = new TileComponentSecurity(this); + } - @Override - public EnumSet getConsumingSides() - { - return configComponent.getSidesForData(TransmissionType.ENERGY, facing, 1); - } + @Override + public void onUpdate() { + super.onUpdate(); - @Override - public EnumSet getOutputtingSides() - { - return configComponent.getSidesForData(TransmissionType.ENERGY, facing, 2); - } + if (!worldObj.isRemote) { + ChargeUtils.charge(0, this); + ChargeUtils.discharge(1, this); - @Override - public boolean canSetFacing(int side) - { - return true; - } + if (MekanismUtils.canFunction(this) + && configComponent.isEjecting(TransmissionType.ENERGY)) { + CableUtils.emit(this); + } - @Override - public double getMaxEnergy() - { - return tier.maxEnergy; - } + int newScale = getScaledEnergyLevel(20); - @Override - public int[] getAccessibleSlotsFromSide(int side) - { - return configComponent.getOutput(TransmissionType.ITEM, side, facing).availableSlots; - } + if (newScale != prevScale) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + } - @Override - public boolean canExtractItem(int slotID, ItemStack itemstack, int side) - { - if(slotID == 1) - { - return ChargeUtils.canBeOutputted(itemstack, false); - } - else if(slotID == 0) - { - return ChargeUtils.canBeOutputted(itemstack, true); - } + prevScale = newScale; + } + } - return false; - } + @Override + public boolean upgrade(BaseTier upgradeTier) { + if (upgradeTier.ordinal() != tier.ordinal() + 1) { + return false; + } - private static final String[] methods = new String[] {"getEnergy", "getOutput", "getMaxEnergy", "getEnergyNeeded"}; + tier = EnergyCubeTier.values()[upgradeTier.ordinal()]; - @Override - public String[] getMethods() - { - return methods; - } + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), + new Range4D(Coord4D.get(this)) + ); + markDirty(); - @Override - public Object[] invoke(int method, Object[] arguments) throws Exception - { - switch(method) - { - case 0: - return new Object[] {getEnergy()}; - case 1: - return new Object[] {tier.output}; - case 2: - return new Object[] {getMaxEnergy()}; - case 3: - return new Object[] {(getMaxEnergy()-getEnergy())}; - default: - throw new NoSuchMethodException(); - } - } + return true; + } - @Override - public void handlePacketData(ByteBuf dataStream) - { - if(worldObj.isRemote) - { - tier = EnergyCubeTier.values()[dataStream.readInt()]; - - super.handlePacketData(dataStream); - - controlType = RedstoneControl.values()[dataStream.readInt()]; - - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } + @Override + public String getInventoryName() { + return LangUtils.localize( + "tile.EnergyCube" + tier.getBaseTier().getName() + ".name" + ); + } - @Override - public ArrayList getNetworkedData(ArrayList data) - { - data.add(tier.ordinal()); + @Override + public double getMaxOutput() { + if (tier == EnergyCubeTier.CREATIVE) { + return Integer.MAX_VALUE; + } - super.getNetworkedData(data); + return tier.output; + } - data.add(controlType.ordinal()); + @Override + public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { + if (slotID == 0) { + return ChargeUtils.canBeCharged(itemstack); + } else if (slotID == 1) { + return ChargeUtils.canBeDischarged(itemstack); + } - return data; - } + return true; + } - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); + @Override + public EnumSet getConsumingSides() { + return configComponent.getSidesForData(TransmissionType.ENERGY, facing, 1); + } - tier = EnergyCubeTier.getFromName(nbtTags.getString("tier")); - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - } + @Override + public EnumSet getOutputtingSides() { + return configComponent.getSidesForData(TransmissionType.ENERGY, facing, 2); + } - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); + @Override + public boolean canSetFacing(int side) { + return true; + } - nbtTags.setString("tier", tier.getBaseTier().getName()); - nbtTags.setInteger("controlType", controlType.ordinal()); - } + @Override + public double getMaxEnergy() { + return tier.maxEnergy; + } - @Override - public void setEnergy(double energy) - { - if(tier == EnergyCubeTier.CREATIVE && energy != Double.MAX_VALUE) - { - return; - } - - super.setEnergy(energy); + @Override + public int[] getAccessibleSlotsFromSide(int side) { + return configComponent.getOutput(TransmissionType.ITEM, side, facing) + .availableSlots; + } - int newRedstoneLevel = getRedstoneLevel(); + @Override + public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { + if (slotID == 1) { + return ChargeUtils.canBeOutputted(itemstack, false); + } else if (slotID == 0) { + return ChargeUtils.canBeOutputted(itemstack, true); + } - if(newRedstoneLevel != currentRedstoneLevel) - { - markDirty(); - currentRedstoneLevel = newRedstoneLevel; - } - } + return false; + } - public int getRedstoneLevel() - { - double fractionFull = getEnergy()/getMaxEnergy(); - return MathHelper.floor_float((float)(fractionFull * 14.0F)) + (fractionFull > 0 ? 1 : 0); - } + private static final String[] methods + = new String[] { "getEnergy", "getOutput", "getMaxEnergy", "getEnergyNeeded" }; - @Override - public RedstoneControl getControlType() - { - return controlType; - } + @Override + public String[] getMethods() { + return methods; + } - @Override - public void setControlType(RedstoneControl type) - { - controlType = type; - } + @Override + public Object[] invoke(int method, Object[] arguments) throws Exception { + switch (method) { + case 0: + return new Object[] { getEnergy() }; + case 1: + return new Object[] { tier.output }; + case 2: + return new Object[] { getMaxEnergy() }; + case 3: + return new Object[] { (getMaxEnergy() - getEnergy()) }; + default: + throw new NoSuchMethodException(); + } + } - @Override - public boolean canPulse() - { - return false; - } + @Override + public void handlePacketData(ByteBuf dataStream) { + if (worldObj.isRemote) { + tier = EnergyCubeTier.values()[dataStream.readInt()]; - @Override - public TileComponentEjector getEjector() - { - return ejectorComponent; - } - - @Override - public TileComponentConfig getConfig() - { - return configComponent; - } - - @Override - public int getOrientation() - { - return facing; - } - - @Override - public TileComponentSecurity getSecurity() - { - return securityComponent; - } + super.handlePacketData(dataStream); + + controlType = RedstoneControl.values()[dataStream.readInt()]; + + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } + + @Override + public ArrayList getNetworkedData(ArrayList data) { + data.add(tier.ordinal()); + + super.getNetworkedData(data); + + data.add(controlType.ordinal()); + + return data; + } + + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); + + tier = EnergyCubeTier.getFromName(nbtTags.getString("tier")); + controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); + + nbtTags.setString("tier", tier.getBaseTier().getName()); + nbtTags.setInteger("controlType", controlType.ordinal()); + } + + @Override + public void setEnergy(double energy) { + if (tier == EnergyCubeTier.CREATIVE && energy != Double.MAX_VALUE) { + return; + } + + super.setEnergy(energy); + + int newRedstoneLevel = getRedstoneLevel(); + + if (newRedstoneLevel != currentRedstoneLevel) { + markDirty(); + currentRedstoneLevel = newRedstoneLevel; + } + } + + public int getRedstoneLevel() { + double fractionFull = getEnergy() / getMaxEnergy(); + return MathHelper.floor_float((float) (fractionFull * 14.0F)) + + (fractionFull > 0 ? 1 : 0); + } + + @Override + public RedstoneControl getControlType() { + return controlType; + } + + @Override + public void setControlType(RedstoneControl type) { + controlType = type; + } + + @Override + public boolean canPulse() { + return false; + } + + @Override + public TileComponentEjector getEjector() { + return ejectorComponent; + } + + @Override + public TileComponentConfig getConfig() { + return configComponent; + } + + @Override + public int getOrientation() { + return facing; + } + + @Override + public TileComponentSecurity getSecurity() { + return securityComponent; + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityEnrichmentChamber.java b/src/main/java/mekanism/common/tile/TileEntityEnrichmentChamber.java index 3c6c95a42..b96c74807 100644 --- a/src/main/java/mekanism/common/tile/TileEntityEnrichmentChamber.java +++ b/src/main/java/mekanism/common/tile/TileEntityEnrichmentChamber.java @@ -2,30 +2,33 @@ package mekanism.common.tile; import java.util.Map; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.MekanismConfig.usage; import mekanism.common.block.BlockMachine.MachineType; import mekanism.common.recipe.RecipeHandler.Recipe; import mekanism.common.recipe.machines.EnrichmentRecipe; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class TileEntityEnrichmentChamber extends TileEntityElectricMachine -{ - public TileEntityEnrichmentChamber() - { - super("enrichment", "EnrichmentChamber", usage.enrichmentChamberUsage, 200, MachineType.ENRICHMENT_CHAMBER.baseEnergy); - } +public class TileEntityEnrichmentChamber + extends TileEntityElectricMachine { + public TileEntityEnrichmentChamber() { + super( + "enrichment", + "EnrichmentChamber", + usage.enrichmentChamberUsage, + 200, + MachineType.ENRICHMENT_CHAMBER.baseEnergy + ); + } - @Override - public Map getRecipes() - { - return Recipe.ENRICHMENT_CHAMBER.get(); - } + @Override + public Map getRecipes() { + return Recipe.ENRICHMENT_CHAMBER.get(); + } - @Override - @SideOnly(Side.CLIENT) - public float getVolume() - { - return 0.3F*super.getVolume(); - } + @Override + @SideOnly(Side.CLIENT) + public float getVolume() { + return 0.3F * super.getVolume(); + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityFactory.java b/src/main/java/mekanism/common/tile/TileEntityFactory.java index 0c9dca5ad..918c3e087 100644 --- a/src/main/java/mekanism/common/tile/TileEntityFactory.java +++ b/src/main/java/mekanism/common/tile/TileEntityFactory.java @@ -1,11 +1,12 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.EnumSet; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.IConfigCardAccess.ISpecialConfigData; @@ -62,1152 +63,1080 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.StatCollector; import net.minecraftforge.common.util.ForgeDirection; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -public class TileEntityFactory extends TileEntityNoisyElectricBlock implements IComputerIntegration, ISideConfiguration, IUpgradeTile, IRedstoneControl, IGasHandler, ITubeConnection, ISpecialConfigData, ISecurityTile, ITierUpgradeable -{ - /** This Factory's tier. */ - public FactoryTier tier; - - /** An int[] used to track all current operations' progress. */ - public int[] progress; - - public int BASE_MAX_INFUSE = 1000; - - public int maxInfuse = BASE_MAX_INFUSE; - - /** How many ticks it takes, by default, to run an operation. */ - public int BASE_TICKS_REQUIRED = 200; - - /** How many ticks it takes, with upgrades, to run an operation */ - public int ticksRequired = 200; - - /** How much energy each operation consumes per tick, without upgrades. */ - public double BASE_ENERGY_PER_TICK = usage.factoryUsage; - - /** How much energy each operation consumes per tick. */ - public double energyPerTick = usage.factoryUsage; - - /** How much secondary energy each operation consumes per tick */ - public double secondaryEnergyPerTick = 0; - - public int secondaryEnergyThisTick; - - /** How long it takes this factory to switch recipe types. */ - public int RECIPE_TICKS_REQUIRED = 40; - - /** How many recipe ticks have progressed. */ - public int recipeTicks; - - /** The client's current active state. */ - public boolean clientActive; - - /** This machine's active state. */ - public boolean isActive; - - /** How many ticks must pass until this block's active state can sync with the client. */ - public int updateDelay; - - /** This machine's recipe type. */ - public RecipeType recipeType = RecipeType.SMELTING; - - /** The amount of infuse this machine has stored. */ - public InfuseStorage infuseStored = new InfuseStorage(); - - /** This machine's previous amount of energy. */ - public double prevEnergy; - - public GasTank gasTank; - - public boolean sorting; - - public boolean upgraded; - - public double lastUsage; - - @SideOnly(Side.CLIENT) - public SoundWrapper[] sounds; - - /** This machine's current RedstoneControl type. */ - public RedstoneControl controlType = RedstoneControl.DISABLED; - - public TileComponentUpgrade upgradeComponent; - public TileComponentEjector ejectorComponent; - public TileComponentConfig configComponent; - public TileComponentSecurity securityComponent = new TileComponentSecurity(this); - - public TileEntityFactory() - { - this(FactoryTier.BASIC, MachineType.BASIC_FACTORY); - - configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY, TransmissionType.GAS); - - configComponent.addOutput(TransmissionType.ITEM, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY)); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Input", EnumColor.DARK_RED, new int[] {5, 6, 7})); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Output", EnumColor.DARK_BLUE, new int[] {8, 9, 10})); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Energy", EnumColor.DARK_GREEN, new int[] {1})); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Extra", EnumColor.PURPLE, new int[] {4})); - - configComponent.setConfig(TransmissionType.ITEM, new byte[] {4, 0, 0, 3, 1, 2}); - - configComponent.addOutput(TransmissionType.GAS, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY)); - configComponent.addOutput(TransmissionType.GAS, new SideData("Gas", EnumColor.DARK_RED, new int[] {0})); - configComponent.fillConfig(TransmissionType.GAS, 1); - configComponent.setCanEject(TransmissionType.GAS, false); - - configComponent.setInputConfig(TransmissionType.ENERGY); - - upgradeComponent = new TileComponentUpgrade(this, 0); - upgradeComponent.setSupported(Upgrade.MUFFLING); - - ejectorComponent = new TileComponentEjector(this); - ejectorComponent.setOutputData(TransmissionType.ITEM, configComponent.getOutputs(TransmissionType.ITEM).get(2)); - } - - public TileEntityFactory(FactoryTier type, MachineType machine) - { - super("null", machine.name, machine.baseEnergy); - - tier = type; - inventory = new ItemStack[5+type.processes*2]; - progress = new int[type.processes]; - isActive = false; - - gasTank = new GasTank(TileEntityAdvancedElectricMachine.MAX_GAS*tier.processes); - maxInfuse = BASE_MAX_INFUSE*tier.processes; - } - - @Override - public boolean upgrade(BaseTier upgradeTier) - { - if(upgradeTier.ordinal() != tier.ordinal()+1 || tier == FactoryTier.ELITE) - { - return false; - } - - worldObj.setBlockToAir(xCoord, yCoord, zCoord); - worldObj.setBlock(xCoord, yCoord, zCoord, MekanismBlocks.MachineBlock, 5+tier.ordinal()+1, 3); - - TileEntityFactory factory = (TileEntityFactory)worldObj.getTileEntity(xCoord, yCoord, zCoord); - - //Basic - factory.facing = facing; - factory.clientFacing = clientFacing; - factory.ticker = ticker; - factory.redstone = redstone; - factory.redstoneLastTick = redstoneLastTick; - factory.doAutoSync = doAutoSync; - - //Electric - factory.electricityStored = electricityStored; - - //Noisy - factory.soundURL = soundURL; - - //Factory - - for(int i = 0; i < tier.processes; i++) - { - factory.progress[i] = progress[i]; - } - - factory.recipeTicks = recipeTicks; - factory.clientActive = clientActive; - factory.isActive = isActive; - factory.updateDelay = updateDelay; - factory.prevEnergy = prevEnergy; - factory.gasTank.setGas(gasTank.getGas()); - factory.sorting = sorting; - factory.controlType = controlType; - factory.upgradeComponent.readFrom(upgradeComponent); - factory.ejectorComponent.readFrom(ejectorComponent); - factory.configComponent.readFrom(configComponent); - factory.ejectorComponent.setOutputData(TransmissionType.ITEM, factory.configComponent.getOutputs(TransmissionType.ITEM).get(2)); - factory.recipeType = recipeType; - factory.upgradeComponent.setSupported(Upgrade.GAS, recipeType.fuelEnergyUpgrades()); - factory.securityComponent.readFrom(securityComponent); - - for(int i = 0; i < tier.processes+5; i++) - { - factory.inventory[i] = inventory[i]; - } - - for(int i = 0; i < tier.processes; i++) - { - int output = getOutputSlot(i); - - if(inventory[output] != null) - { - int newOutput = 5+factory.tier.processes+i; - - factory.inventory[newOutput] = inventory[output]; - } - } - - for(Upgrade upgrade : factory.upgradeComponent.getSupportedTypes()) - { - factory.recalculateUpgradables(upgrade); - } - - factory.upgraded = true; - - factory.markDirty(); - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(factory), factory.getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(factory))); - - return true; - } - - @Override - public void onUpdate() - { - super.onUpdate(); - - if(worldObj.isRemote && updateDelay > 0) - { - updateDelay--; - - if(updateDelay == 0 && clientActive != isActive) - { - isActive = clientActive; - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } - - if(!worldObj.isRemote) - { - if(ticker == 1) - { - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType()); - } - - if(updateDelay > 0) - { - updateDelay--; - - if(updateDelay == 0 && clientActive != isActive) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - } - } - - ChargeUtils.discharge(1, this); - - handleSecondaryFuel(); - sortInventory(); - - if(inventory[2] != null && inventory[3] == null) - { - RecipeType toSet = null; - - for(RecipeType type : RecipeType.values()) - { - if(inventory[2].isItemEqual(type.getStack())) - { - toSet = type; - break; - } - } - - if(toSet != null && recipeType != toSet) - { - if(recipeTicks < RECIPE_TICKS_REQUIRED) - { - recipeTicks++; - } - else { - recipeTicks = 0; - - ItemStack returnStack = getMachineStack(); - - if(returnStack.stackTagCompound == null) - { - returnStack.setTagCompound(new NBTTagCompound()); - } - - upgradeComponent.write(returnStack.stackTagCompound); - upgradeComponent.setSupported(Upgrade.GAS, toSet.fuelEnergyUpgrades()); - upgradeComponent.read(inventory[2].stackTagCompound); - - inventory[2] = null; - inventory[3] = returnStack; - - recipeType = toSet; - gasTank.setGas(null); - - secondaryEnergyPerTick = getSecondaryEnergyPerTick(recipeType); - - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType()); - - MekanismUtils.saveChunk(this); - } - } - else { - recipeTicks = 0; - } - } - else { - recipeTicks = 0; - } - - double prev = getEnergy(); - - secondaryEnergyThisTick = recipeType.fuelEnergyUpgrades() ? StatUtils.inversePoisson(secondaryEnergyPerTick) : (int)Math.ceil(secondaryEnergyPerTick); - - for(int process = 0; process < tier.processes; process++) - { - if(MekanismUtils.canFunction(this) && canOperate(getInputSlot(process), getOutputSlot(process)) && getEnergy() >= energyPerTick && gasTank.getStored() >= secondaryEnergyThisTick) - { - if((progress[process]+1) < ticksRequired) - { - progress[process]++; - gasTank.draw(secondaryEnergyThisTick, true); - electricityStored -= energyPerTick; - } - else if((progress[process]+1) >= ticksRequired) - { - operate(getInputSlot(process), getOutputSlot(process)); - - progress[process] = 0; - gasTank.draw(secondaryEnergyThisTick, true); - electricityStored -= energyPerTick; - } - } - - if(!canOperate(getInputSlot(process), getOutputSlot(process))) - { - if(!(recipeType.usesFuel() && recipeType.hasRecipe(inventory[getInputSlot(process)]))) - { - progress[process] = 0; - } - } - } - - boolean hasOperation = false; - - for(int i = 0; i < tier.processes; i++) - { - if(canOperate(getInputSlot(i), getOutputSlot(i))) - { - hasOperation = true; - break; - } - } - - if(MekanismUtils.canFunction(this) && hasOperation && getEnergy() >= energyPerTick && gasTank.getStored() >= secondaryEnergyThisTick) - { - setActive(true); - } - else { - if(prevEnergy >= getEnergy()) - { - setActive(false); - } - } - - if(infuseStored.amount <= 0) - { - infuseStored.amount = 0; - infuseStored.type = null; - } - - lastUsage = prev-getEnergy(); - prevEnergy = getEnergy(); - } - } - - @Override - public EnumSet getConsumingSides() - { - return configComponent.getSidesForData(TransmissionType.ENERGY, facing, 1); - } - - public void sortInventory() - { - if(sorting) - { - boolean didOp = false; - - int[] inputSlots = null; - - List invStacks = new ArrayList(); - - if(tier == FactoryTier.BASIC) - { - inputSlots = new int[] {5, 6, 7}; - } - else if(tier == FactoryTier.ADVANCED) - { - inputSlots = new int[] {5, 6, 7, 8, 9}; - } - else if(tier == FactoryTier.ELITE) - { - inputSlots = new int[] {5, 6, 7, 8, 9, 10, 11}; - } - - for(int id : inputSlots) - { - InvID item = InvID.get(id, inventory); - if(item.stack != null && item.stack.hasTagCompound()) - { - return; //Don't sort items with NBT data (dupe fix) - } - invStacks.add(item); - } - - for(InvID invID1 : invStacks) - { - for(InvID invID2 : invStacks) - { - if(invID1.ID == invID2.ID || StackUtils.diffIgnoreNull(invID1.stack, invID2.stack) || Math.abs(invID1.size()-invID2.size()) < 2) continue; - - List evened = StackUtils.even(inventory[invID1.ID], inventory[invID2.ID]); - inventory[invID1.ID] = evened.get(0); - inventory[invID2.ID] = evened.get(1); - - didOp = true; - break; - } - - if(didOp) - { - markDirty(); - break; - } - } - } - } - - public static class InvID - { - public ItemStack stack; - public int ID; - - public InvID(ItemStack s, int i) - { - stack = s; - ID = i; - } - - public int size() - { - return stack != null ? stack.stackSize : 0; - } - - public Item item() - { - return stack != null ? stack.getItem() : null; - } - - public static InvID get(int id, ItemStack[] inv) - { - return new InvID(inv[id], id); - } - } - - public double getSecondaryEnergyPerTick(RecipeType type) - { - return MekanismUtils.getSecondaryEnergyPerTickMean(this, type.getSecondaryEnergyPerTick()); - } - - public void handleSecondaryFuel() - { - if(inventory[4] != null) - { - if(recipeType.usesFuel() && gasTank.getNeeded() > 0) - { - if(inventory[4].getItem() instanceof IGasItem) - { - GasStack gas = ((IGasItem)inventory[4].getItem()).getGas(inventory[4]); - - if(gas != null && recipeType.isValidGas(gas.getGas())) - { - GasStack removed = GasTransmission.removeGas(inventory[4], gasTank.getGasType(), gasTank.getNeeded()); - gasTank.receive(removed, true); - } - - return; - } - - GasStack stack = recipeType.getItemGas(inventory[4]); - int gasNeeded = gasTank.getNeeded(); - - if(stack != null && stack.amount <= gasNeeded) - { - gasTank.receive(stack, true); - - inventory[4].stackSize--; - - if(inventory[4].stackSize == 0) - { - inventory[4] = null; - } - } - } - else if(recipeType == RecipeType.INFUSING) - { - if(InfuseRegistry.getObject(inventory[4]) != null) - { - InfuseObject infuse = InfuseRegistry.getObject(inventory[4]); - - if(infuseStored.type == null || infuseStored.type == infuse.type) - { - if(infuseStored.amount + infuse.stored <= maxInfuse) - { - infuseStored.amount += infuse.stored; - infuseStored.type = infuse.type; - inventory[4].stackSize--; - - if(inventory[4].stackSize <= 0) - { - inventory[4] = null; - } - } - } - } - } - } - } - - public ItemStack getMachineStack() - { - return recipeType.getStack(); - } - - @Override - public boolean canExtractItem(int slotID, ItemStack itemstack, int side) - { - if(slotID == 1) - { - return ChargeUtils.canBeOutputted(itemstack, false); - } - else if(tier == FactoryTier.BASIC && slotID >= 8 && slotID <= 10) - { - return true; - } - else if(tier == FactoryTier.ADVANCED && slotID >= 10 && slotID <= 14) - { - return true; - } - else if(tier == FactoryTier.ELITE && slotID >= 12 && slotID <= 18) - { - return true; - } - - return false; - } - - @Override - public boolean isItemValidForSlot(int slotID, ItemStack itemstack) - { - if(tier == FactoryTier.BASIC) - { - if(slotID >= 8 && slotID <= 10) - { - return false; - } - else if(slotID >= 5 && slotID <= 7) - { - return recipeType.getAnyRecipe(itemstack, gasTank.getGasType(), infuseStored) != null; - } - } - else if(tier == FactoryTier.ADVANCED) - { - if(slotID >= 10 && slotID <= 14) - { - return false; - } - else if(slotID >= 5 && slotID <= 9) - { - return recipeType.getAnyRecipe(itemstack, gasTank.getGasType(), infuseStored) != null; - } - } - else if(tier == FactoryTier.ELITE) - { - if(slotID >= 12 && slotID <= 18) - { - return false; - } - else if(slotID >= 5 && slotID <= 11) - { - return recipeType.getAnyRecipe(itemstack, gasTank.getGasType(), infuseStored) != null; - } - } - - if(slotID == 0) - { - return itemstack.getItem() == MekanismItems.SpeedUpgrade || itemstack.getItem() == MekanismItems.EnergyUpgrade; - } - else if(slotID == 1) - { - return ChargeUtils.canBeDischarged(itemstack); - } - else if(slotID == 4) - { - if(recipeType.usesFuel()) - { - return recipeType.getItemGas(itemstack) != null; - } - else if(recipeType == RecipeType.INFUSING) - { - return InfuseRegistry.getObject(itemstack) != null && (infuseStored.type == null || infuseStored.type == InfuseRegistry.getObject(itemstack).type); - } - } - - return false; - } - - public int getScaledProgress(int i, int process) - { - return progress[process]*i / ticksRequired; - } - - public int getScaledInfuseLevel(int i) - { - return infuseStored.amount * i / maxInfuse; - } - - public int getScaledGasLevel(int i) - { - return gasTank.getStored()*i / gasTank.getMaxGas(); - } - - public int getScaledRecipeProgress(int i) - { - return recipeTicks*i / RECIPE_TICKS_REQUIRED; - } - - public boolean canOperate(int inputSlot, int outputSlot) - { - if(inventory[inputSlot] == null) - { - return false; - } - - if(recipeType.usesFuel()) - { - AdvancedMachineRecipe recipe = recipeType.getRecipe(inventory[inputSlot], gasTank.getGasType()); - - if(recipe == null) - { - return false; - } - - return recipe.canOperate(inventory, inputSlot, outputSlot, gasTank, secondaryEnergyThisTick); - } - - if(recipeType == RecipeType.INFUSING) - { - InfusionInput input = new InfusionInput(infuseStored, inventory[inputSlot]); - MetallurgicInfuserRecipe recipe = RecipeHandler.getMetallurgicInfuserRecipe(input); - - if(recipe == null) - { - return false; - } - - return recipe.canOperate(inventory, inputSlot, outputSlot, infuseStored); - } - - BasicMachineRecipe recipe = recipeType.getRecipe(inventory[inputSlot]); - - if(recipe == null) - { - return false; - } - - return recipe.canOperate(inventory, inputSlot, outputSlot); - } - - public void operate(int inputSlot, int outputSlot) - { - if(!canOperate(inputSlot, outputSlot)) - { - return; - } - - if(recipeType.usesFuel()) - { - AdvancedMachineRecipe recipe = recipeType.getRecipe(inventory[inputSlot], gasTank.getGasType()); - - recipe.operate(inventory, inputSlot, outputSlot, gasTank, secondaryEnergyThisTick); - } - else if(recipeType == RecipeType.INFUSING) - { - InfusionInput input = new InfusionInput(infuseStored, inventory[inputSlot]); - MetallurgicInfuserRecipe recipe = RecipeHandler.getMetallurgicInfuserRecipe(input); - - recipe.output(inventory, inputSlot, outputSlot, infuseStored); - } - else { - BasicMachineRecipe recipe = recipeType.getRecipe(inventory[inputSlot]); - - recipe.operate(inventory, inputSlot, outputSlot); - } - - markDirty(); - ejectorComponent.outputItems(); - } - - @Override - public void handlePacketData(ByteBuf dataStream) - { - if(!worldObj.isRemote) - { - int type = dataStream.readInt(); - - if(type == 0) - { - sorting = !sorting; - } - else if(type == 1) - { - gasTank.setGas(null); - infuseStored.amount = 0; - infuseStored.type = null; - } - - return; - } - - super.handlePacketData(dataStream); - - if(worldObj.isRemote) - { - clientActive = dataStream.readBoolean(); - RecipeType oldRecipe = recipeType; - recipeType = RecipeType.values()[dataStream.readInt()]; - upgradeComponent.setSupported(Upgrade.GAS, recipeType.fuelEnergyUpgrades()); - - if(recipeType != oldRecipe) - { - secondaryEnergyPerTick = getSecondaryEnergyPerTick(recipeType); - } - - recipeTicks = dataStream.readInt(); - controlType = RedstoneControl.values()[dataStream.readInt()]; - sorting = dataStream.readBoolean(); - upgraded = dataStream.readBoolean(); - lastUsage = dataStream.readDouble(); - infuseStored.amount = dataStream.readInt(); - infuseStored.type = InfuseRegistry.get(PacketHandler.readString(dataStream)); - - for(int i = 0; i < tier.processes; i++) - { - progress[i] = dataStream.readInt(); - } - - if(dataStream.readBoolean()) - { - gasTank.setGas(new GasStack(dataStream.readInt(), dataStream.readInt())); - } - else { - gasTank.setGas(null); - } - - if(updateDelay == 0 && clientActive != isActive) - { - updateDelay = general.UPDATE_DELAY; - isActive = clientActive; - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - - if(upgraded) - { - markDirty(); - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - upgraded = false; - } - } - } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - clientActive = isActive = nbtTags.getBoolean("isActive"); - RecipeType oldRecipe = recipeType; - recipeType = RecipeType.values()[nbtTags.getInteger("recipeType")]; - upgradeComponent.setSupported(Upgrade.GAS, recipeType.fuelEnergyUpgrades()); - - if(recipeType != oldRecipe) - { - secondaryEnergyPerTick = getSecondaryEnergyPerTick(recipeType); - } - - recipeTicks = nbtTags.getInteger("recipeTicks"); - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - sorting = nbtTags.getBoolean("sorting"); - infuseStored.amount = nbtTags.getInteger("infuseStored"); - infuseStored.type = InfuseRegistry.get(nbtTags.getString("type")); - - for(int i = 0; i < tier.processes; i++) - { - progress[i] = nbtTags.getInteger("progress" + i); - } - - gasTank.read(nbtTags.getCompoundTag("gasTank")); - } - - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - nbtTags.setBoolean("isActive", isActive); - nbtTags.setInteger("recipeType", recipeType.ordinal()); - nbtTags.setInteger("recipeTicks", recipeTicks); - nbtTags.setInteger("controlType", controlType.ordinal()); - nbtTags.setBoolean("sorting", sorting); - nbtTags.setInteger("infuseStored", infuseStored.amount); - - if(infuseStored.type != null) - { - nbtTags.setString("type", infuseStored.type.name); - } - else { - nbtTags.setString("type", "null"); - } - - for(int i = 0; i < tier.processes; i++) - { - nbtTags.setInteger("progress" + i, progress[i]); - } - - nbtTags.setTag("gasTank", gasTank.write(new NBTTagCompound())); - } - - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); - - data.add(isActive); - data.add(recipeType.ordinal()); - data.add(recipeTicks); - data.add(controlType.ordinal()); - data.add(sorting); - data.add(upgraded); - data.add(lastUsage); - data.add(infuseStored.amount); - - if(infuseStored.type != null) - { - data.add(infuseStored.type.name); - } - else { - data.add("null"); - } - - data.add(progress); - - if(gasTank.getGas() != null) - { - data.add(true); - data.add(gasTank.getGas().getGas().getID()); - data.add(gasTank.getStored()); - } - else { - data.add(false); - } - - upgraded = false; - - return data; - } - - public int getInputSlot(int operation) - { - return 5+operation; - } - - public int getOutputSlot(int operation) - { - return 5+tier.processes+operation; - } - - @Override - public String getInventoryName() - { - if(StatCollector.canTranslate("tile." + tier.getBaseTier().getName() + recipeType.getUnlocalizedName() + "Factory")) - { - return LangUtils.localize("tile." + tier.getBaseTier().getName() + recipeType.getUnlocalizedName() + "Factory"); - } - - return tier.getBaseTier().getLocalizedName() + " " + recipeType.getLocalizedName() + " " + super.getInventoryName(); - } - - private static final String[] methods = new String[] {"getEnergy", "getProgress", "facing", "canOperate", "getMaxEnergy", "getEnergyNeeded"}; - - @Override - public String[] getMethods() - { - return methods; - } - - @Override - public Object[] invoke(int method, Object[] arguments) throws Exception - { - switch(method) - { - case 0: - return new Object[] {electricityStored}; - case 1: - if(arguments[0] == null) - { - return new Object[] {"Please provide a target operation."}; - } - - if(!(arguments[0] instanceof Double) && !(arguments[0] instanceof Integer)) - { - return new Object[] {"Invalid characters."}; - } - - if((Integer)arguments[0] < 0 || (Integer)arguments[0] > progress.length) - { - return new Object[] {"No such operation found."}; - } - - return new Object[] {progress[(Integer)arguments[0]]}; - case 2: - return new Object[] {facing}; - case 3: - if(arguments[0] == null) - { - return new Object[] {"Please provide a target operation."}; - } - - if(!(arguments[0] instanceof Double) && !(arguments[0] instanceof Integer)) - { - return new Object[] {"Invalid characters."}; - } - - if((Integer)arguments[0] < 0 || (Integer)arguments[0] > progress.length) - { - return new Object[] {"No such operation found."}; - } - - return new Object[] {canOperate(getInputSlot((Integer)arguments[0]), getOutputSlot((Integer)arguments[0]))}; - case 4: - return new Object[] {getMaxEnergy()}; - case 5: - return new Object[] {getMaxEnergy()-getEnergy()}; - default: - throw new NoSuchMethodException(); - } - } - - @Override - public void setActive(boolean active) - { - isActive = active; - - if(clientActive != active && updateDelay == 0) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - - updateDelay = 10; - clientActive = active; - } - } - - @Override - public boolean getActive() - { - return isActive; - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) - { - return configComponent.getOutput(TransmissionType.ITEM, side, facing).availableSlots; - } - - @Override - public boolean canSetFacing(int side) - { - return side != 0 && side != 1; - } - - @Override - public TileComponentConfig getConfig() - { - return configComponent; - } - - @Override - public int getOrientation() - { - return facing; - } - - @Override - @SideOnly(Side.CLIENT) - public SoundWrapper getSound() - { - return sounds[recipeType.ordinal()]; - } - - @Override - @SideOnly(Side.CLIENT) - public void initSounds() - { - sounds = new SoundWrapper[RecipeType.values().length]; - - for(RecipeType type : RecipeType.values()) - { - sounds[type.ordinal()] = new SoundWrapper(this, this, HolidayManager.filterSound(type.getSound())); - } - } - - @Override - public boolean renderUpdate() - { - return true; - } - - @Override - public boolean lightUpdate() - { - return true; - } - - @Override - public RedstoneControl getControlType() - { - return controlType; - } - - @Override - public void setControlType(RedstoneControl type) - { - controlType = type; - MekanismUtils.saveChunk(this); - } - - @Override - public boolean canPulse() - { - return false; - } - - @Override - public TileComponentUpgrade getComponent() - { - return upgradeComponent; - } - - @Override - public TileComponentEjector getEjector() - { - return ejectorComponent; - } - - @Override - public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) - { - if(canReceiveGas(side, stack.getGas())) - { - return gasTank.receive(stack, doTransfer); - } - - return 0; - } - - @Override - public int receiveGas(ForgeDirection side, GasStack stack) - { - return receiveGas(side, stack, true); - } - - @Override - public boolean canReceiveGas(ForgeDirection side, Gas type) - { - if(configComponent.getOutput(TransmissionType.GAS, side.ordinal(), facing).hasSlot(0)) - { - return recipeType.canReceiveGas(side, type); - } - - return false; - } - - @Override - public boolean canTubeConnect(ForgeDirection side) - { - if(recipeType.canTubeConnect(side)) - { - return configComponent.getOutput(TransmissionType.GAS, side.ordinal(), facing).hasSlot(0); - } - - return false; - } - - @Override - public GasStack drawGas(ForgeDirection side, int amount, boolean doTransfer) - { - return null; - } - - @Override - public GasStack drawGas(ForgeDirection side, int amount) - { - return drawGas(side, amount, true); - } - - @Override - public boolean canDrawGas(ForgeDirection side, Gas type) - { - return false; - } - - @Override - public void recalculateUpgradables(Upgrade upgrade) - { - super.recalculateUpgradables(upgrade); - - switch(upgrade) - { - case GAS: - secondaryEnergyPerTick = getSecondaryEnergyPerTick(recipeType); - break; - case SPEED: - ticksRequired = MekanismUtils.getTicks(this, BASE_TICKS_REQUIRED); - energyPerTick = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK); - secondaryEnergyPerTick = getSecondaryEnergyPerTick(recipeType); - break; - case ENERGY: - energyPerTick = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK); - maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY); - break; - default: - break; - } - } - - @Override - public NBTTagCompound getConfigurationData(NBTTagCompound nbtTags) - { - nbtTags.setBoolean("sorting", sorting); - - return nbtTags; - } - - @Override - public void setConfigurationData(NBTTagCompound nbtTags) - { - sorting = nbtTags.getBoolean("sorting"); - } - - @Override - public String getDataType() - { - return tier.getBaseTier().getLocalizedName() + " " + recipeType.getLocalizedName() + " " + super.getInventoryName(); - } - - @Override - public TileComponentSecurity getSecurity() - { - return securityComponent; - } + +public class TileEntityFactory extends TileEntityNoisyElectricBlock + implements IComputerIntegration, ISideConfiguration, IUpgradeTile, IRedstoneControl, + IGasHandler, ITubeConnection, ISpecialConfigData, ISecurityTile, + ITierUpgradeable { + /** This Factory's tier. */ + public FactoryTier tier; + + /** An int[] used to track all current operations' progress. */ + public int[] progress; + + public int BASE_MAX_INFUSE = 1000; + + public int maxInfuse = BASE_MAX_INFUSE; + + /** How many ticks it takes, by default, to run an operation. */ + public int BASE_TICKS_REQUIRED = 200; + + /** How many ticks it takes, with upgrades, to run an operation */ + public int ticksRequired = 200; + + /** How much energy each operation consumes per tick, without upgrades. */ + public double BASE_ENERGY_PER_TICK = usage.factoryUsage; + + /** How much energy each operation consumes per tick. */ + public double energyPerTick = usage.factoryUsage; + + /** How much secondary energy each operation consumes per tick */ + public double secondaryEnergyPerTick = 0; + + public int secondaryEnergyThisTick; + + /** How long it takes this factory to switch recipe types. */ + public int RECIPE_TICKS_REQUIRED = 40; + + /** How many recipe ticks have progressed. */ + public int recipeTicks; + + /** The client's current active state. */ + public boolean clientActive; + + /** This machine's active state. */ + public boolean isActive; + + /** + * How many ticks must pass until this block's active state can sync with the client. + */ + public int updateDelay; + + /** This machine's recipe type. */ + public RecipeType recipeType = RecipeType.SMELTING; + + /** The amount of infuse this machine has stored. */ + public InfuseStorage infuseStored = new InfuseStorage(); + + /** This machine's previous amount of energy. */ + public double prevEnergy; + + public GasTank gasTank; + + public boolean sorting; + + public boolean upgraded; + + public double lastUsage; + + @SideOnly(Side.CLIENT) + public SoundWrapper[] sounds; + + /** This machine's current RedstoneControl type. */ + public RedstoneControl controlType = RedstoneControl.DISABLED; + + public TileComponentUpgrade upgradeComponent; + public TileComponentEjector ejectorComponent; + public TileComponentConfig configComponent; + public TileComponentSecurity securityComponent = new TileComponentSecurity(this); + + public TileEntityFactory() { + this(FactoryTier.BASIC, MachineType.BASIC_FACTORY); + + configComponent = new TileComponentConfig( + this, TransmissionType.ITEM, TransmissionType.ENERGY, TransmissionType.GAS + ); + + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY) + ); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("Input", EnumColor.DARK_RED, new int[] { 5, 6, 7 }) + ); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("Output", EnumColor.DARK_BLUE, new int[] { 8, 9, 10 }) + ); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("Energy", EnumColor.DARK_GREEN, new int[] { 1 }) + ); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("Extra", EnumColor.PURPLE, new int[] { 4 }) + ); + + configComponent.setConfig(TransmissionType.ITEM, new byte[] { 4, 0, 0, 3, 1, 2 }); + + configComponent.addOutput( + TransmissionType.GAS, + new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY) + ); + configComponent.addOutput( + TransmissionType.GAS, new SideData("Gas", EnumColor.DARK_RED, new int[] { 0 }) + ); + configComponent.fillConfig(TransmissionType.GAS, 1); + configComponent.setCanEject(TransmissionType.GAS, false); + + configComponent.setInputConfig(TransmissionType.ENERGY); + + upgradeComponent = new TileComponentUpgrade(this, 0); + upgradeComponent.setSupported(Upgrade.MUFFLING); + + ejectorComponent = new TileComponentEjector(this); + ejectorComponent.setOutputData( + TransmissionType.ITEM, + configComponent.getOutputs(TransmissionType.ITEM).get(2) + ); + } + + public TileEntityFactory(FactoryTier type, MachineType machine) { + super("null", machine.name, machine.baseEnergy); + + tier = type; + inventory = new ItemStack[5 + type.processes * 2]; + progress = new int[type.processes]; + isActive = false; + + gasTank = new GasTank(TileEntityAdvancedElectricMachine.MAX_GAS * tier.processes); + maxInfuse = BASE_MAX_INFUSE * tier.processes; + } + + @Override + public boolean upgrade(BaseTier upgradeTier) { + if (upgradeTier.ordinal() != tier.ordinal() + 1 || tier == FactoryTier.ELITE) { + return false; + } + + worldObj.setBlockToAir(xCoord, yCoord, zCoord); + worldObj.setBlock( + xCoord, yCoord, zCoord, MekanismBlocks.MachineBlock, 5 + tier.ordinal() + 1, 3 + ); + + TileEntityFactory factory + = (TileEntityFactory) worldObj.getTileEntity(xCoord, yCoord, zCoord); + + //Basic + factory.facing = facing; + factory.clientFacing = clientFacing; + factory.ticker = ticker; + factory.redstone = redstone; + factory.redstoneLastTick = redstoneLastTick; + factory.doAutoSync = doAutoSync; + + //Electric + factory.electricityStored = electricityStored; + + //Noisy + factory.soundURL = soundURL; + + //Factory + + for (int i = 0; i < tier.processes; i++) { + factory.progress[i] = progress[i]; + } + + factory.recipeTicks = recipeTicks; + factory.clientActive = clientActive; + factory.isActive = isActive; + factory.updateDelay = updateDelay; + factory.prevEnergy = prevEnergy; + factory.gasTank.setGas(gasTank.getGas()); + factory.sorting = sorting; + factory.controlType = controlType; + factory.upgradeComponent.readFrom(upgradeComponent); + factory.ejectorComponent.readFrom(ejectorComponent); + factory.configComponent.readFrom(configComponent); + factory.ejectorComponent.setOutputData( + TransmissionType.ITEM, + factory.configComponent.getOutputs(TransmissionType.ITEM).get(2) + ); + factory.recipeType = recipeType; + factory.upgradeComponent.setSupported( + Upgrade.GAS, recipeType.fuelEnergyUpgrades() + ); + factory.securityComponent.readFrom(securityComponent); + + for (int i = 0; i < tier.processes + 5; i++) { + factory.inventory[i] = inventory[i]; + } + + for (int i = 0; i < tier.processes; i++) { + int output = getOutputSlot(i); + + if (inventory[output] != null) { + int newOutput = 5 + factory.tier.processes + i; + + factory.inventory[newOutput] = inventory[output]; + } + } + + for (Upgrade upgrade : factory.upgradeComponent.getSupportedTypes()) { + factory.recalculateUpgradables(upgrade); + } + + factory.upgraded = true; + + factory.markDirty(); + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(factory), factory.getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(factory)) + ); + + return true; + } + + @Override + public void onUpdate() { + super.onUpdate(); + + if (worldObj.isRemote && updateDelay > 0) { + updateDelay--; + + if (updateDelay == 0 && clientActive != isActive) { + isActive = clientActive; + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } + + if (!worldObj.isRemote) { + if (ticker == 1) { + worldObj.notifyBlocksOfNeighborChange( + xCoord, yCoord, zCoord, getBlockType() + ); + } + + if (updateDelay > 0) { + updateDelay--; + + if (updateDelay == 0 && clientActive != isActive) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + } + } + + ChargeUtils.discharge(1, this); + + handleSecondaryFuel(); + sortInventory(); + + if (inventory[2] != null && inventory[3] == null) { + RecipeType toSet = null; + + for (RecipeType type : RecipeType.values()) { + if (inventory[2].isItemEqual(type.getStack())) { + toSet = type; + break; + } + } + + if (toSet != null && recipeType != toSet) { + if (recipeTicks < RECIPE_TICKS_REQUIRED) { + recipeTicks++; + } else { + recipeTicks = 0; + + ItemStack returnStack = getMachineStack(); + + if (returnStack.stackTagCompound == null) { + returnStack.setTagCompound(new NBTTagCompound()); + } + + upgradeComponent.write(returnStack.stackTagCompound); + upgradeComponent.setSupported( + Upgrade.GAS, toSet.fuelEnergyUpgrades() + ); + upgradeComponent.read(inventory[2].stackTagCompound); + + inventory[2] = null; + inventory[3] = returnStack; + + recipeType = toSet; + gasTank.setGas(null); + + secondaryEnergyPerTick = getSecondaryEnergyPerTick(recipeType); + + worldObj.notifyBlocksOfNeighborChange( + xCoord, yCoord, zCoord, getBlockType() + ); + + MekanismUtils.saveChunk(this); + } + } else { + recipeTicks = 0; + } + } else { + recipeTicks = 0; + } + + double prev = getEnergy(); + + secondaryEnergyThisTick = recipeType.fuelEnergyUpgrades() + ? StatUtils.inversePoisson(secondaryEnergyPerTick) + : (int) Math.ceil(secondaryEnergyPerTick); + + for (int process = 0; process < tier.processes; process++) { + if (MekanismUtils.canFunction(this) + && canOperate(getInputSlot(process), getOutputSlot(process)) + && getEnergy() >= energyPerTick + && gasTank.getStored() >= secondaryEnergyThisTick) { + if ((progress[process] + 1) < ticksRequired) { + progress[process]++; + gasTank.draw(secondaryEnergyThisTick, true); + electricityStored -= energyPerTick; + } else if ((progress[process] + 1) >= ticksRequired) { + operate(getInputSlot(process), getOutputSlot(process)); + + progress[process] = 0; + gasTank.draw(secondaryEnergyThisTick, true); + electricityStored -= energyPerTick; + } + } + + if (!canOperate(getInputSlot(process), getOutputSlot(process))) { + if (!(recipeType.usesFuel() + && recipeType.hasRecipe(inventory[getInputSlot(process)]))) { + progress[process] = 0; + } + } + } + + boolean hasOperation = false; + + for (int i = 0; i < tier.processes; i++) { + if (canOperate(getInputSlot(i), getOutputSlot(i))) { + hasOperation = true; + break; + } + } + + if (MekanismUtils.canFunction(this) && hasOperation + && getEnergy() >= energyPerTick + && gasTank.getStored() >= secondaryEnergyThisTick) { + setActive(true); + } else { + if (prevEnergy >= getEnergy()) { + setActive(false); + } + } + + if (infuseStored.amount <= 0) { + infuseStored.amount = 0; + infuseStored.type = null; + } + + lastUsage = prev - getEnergy(); + prevEnergy = getEnergy(); + } + } + + @Override + public EnumSet getConsumingSides() { + return configComponent.getSidesForData(TransmissionType.ENERGY, facing, 1); + } + + public void sortInventory() { + if (sorting) { + boolean didOp = false; + + int[] inputSlots = null; + + List invStacks = new ArrayList(); + + if (tier == FactoryTier.BASIC) { + inputSlots = new int[] { 5, 6, 7 }; + } else if (tier == FactoryTier.ADVANCED) { + inputSlots = new int[] { 5, 6, 7, 8, 9 }; + } else if (tier == FactoryTier.ELITE) { + inputSlots = new int[] { 5, 6, 7, 8, 9, 10, 11 }; + } + + for (int id : inputSlots) { + InvID item = InvID.get(id, inventory); + if (item.stack != null && item.stack.hasTagCompound()) { + return; //Don't sort items with NBT data (dupe fix) + } + invStacks.add(item); + } + + for (InvID invID1 : invStacks) { + for (InvID invID2 : invStacks) { + if (invID1.ID == invID2.ID + || StackUtils.diffIgnoreNull(invID1.stack, invID2.stack) + || Math.abs(invID1.size() - invID2.size()) < 2) + continue; + + List evened + = StackUtils.even(inventory[invID1.ID], inventory[invID2.ID]); + inventory[invID1.ID] = evened.get(0); + inventory[invID2.ID] = evened.get(1); + + didOp = true; + break; + } + + if (didOp) { + markDirty(); + break; + } + } + } + } + + public static class InvID { + public ItemStack stack; + public int ID; + + public InvID(ItemStack s, int i) { + stack = s; + ID = i; + } + + public int size() { + return stack != null ? stack.stackSize : 0; + } + + public Item item() { + return stack != null ? stack.getItem() : null; + } + + public static InvID get(int id, ItemStack[] inv) { + return new InvID(inv[id], id); + } + } + + public double getSecondaryEnergyPerTick(RecipeType type) { + return MekanismUtils.getSecondaryEnergyPerTickMean( + this, type.getSecondaryEnergyPerTick() + ); + } + + public void handleSecondaryFuel() { + if (inventory[4] != null) { + if (recipeType.usesFuel() && gasTank.getNeeded() > 0) { + if (inventory[4].getItem() instanceof IGasItem) { + GasStack gas + = ((IGasItem) inventory[4].getItem()).getGas(inventory[4]); + + if (gas != null && recipeType.isValidGas(gas.getGas())) { + GasStack removed = GasTransmission.removeGas( + inventory[4], gasTank.getGasType(), gasTank.getNeeded() + ); + gasTank.receive(removed, true); + } + + return; + } + + GasStack stack = recipeType.getItemGas(inventory[4]); + int gasNeeded = gasTank.getNeeded(); + + if (stack != null && stack.amount <= gasNeeded) { + gasTank.receive(stack, true); + + inventory[4].stackSize--; + + if (inventory[4].stackSize == 0) { + inventory[4] = null; + } + } + } else if (recipeType == RecipeType.INFUSING) { + if (InfuseRegistry.getObject(inventory[4]) != null) { + InfuseObject infuse = InfuseRegistry.getObject(inventory[4]); + + if (infuseStored.type == null || infuseStored.type == infuse.type) { + if (infuseStored.amount + infuse.stored <= maxInfuse) { + infuseStored.amount += infuse.stored; + infuseStored.type = infuse.type; + inventory[4].stackSize--; + + if (inventory[4].stackSize <= 0) { + inventory[4] = null; + } + } + } + } + } + } + } + + public ItemStack getMachineStack() { + return recipeType.getStack(); + } + + @Override + public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { + if (slotID == 1) { + return ChargeUtils.canBeOutputted(itemstack, false); + } else if (tier == FactoryTier.BASIC && slotID >= 8 && slotID <= 10) { + return true; + } else if (tier == FactoryTier.ADVANCED && slotID >= 10 && slotID <= 14) { + return true; + } else if (tier == FactoryTier.ELITE && slotID >= 12 && slotID <= 18) { + return true; + } + + return false; + } + + @Override + public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { + if (tier == FactoryTier.BASIC) { + if (slotID >= 8 && slotID <= 10) { + return false; + } else if (slotID >= 5 && slotID <= 7) { + return recipeType.getAnyRecipe( + itemstack, gasTank.getGasType(), infuseStored + ) + != null; + } + } else if (tier == FactoryTier.ADVANCED) { + if (slotID >= 10 && slotID <= 14) { + return false; + } else if (slotID >= 5 && slotID <= 9) { + return recipeType.getAnyRecipe( + itemstack, gasTank.getGasType(), infuseStored + ) + != null; + } + } else if (tier == FactoryTier.ELITE) { + if (slotID >= 12 && slotID <= 18) { + return false; + } else if (slotID >= 5 && slotID <= 11) { + return recipeType.getAnyRecipe( + itemstack, gasTank.getGasType(), infuseStored + ) + != null; + } + } + + if (slotID == 0) { + return itemstack.getItem() == MekanismItems.SpeedUpgrade + || itemstack.getItem() == MekanismItems.EnergyUpgrade; + } else if (slotID == 1) { + return ChargeUtils.canBeDischarged(itemstack); + } else if (slotID == 4) { + if (recipeType.usesFuel()) { + return recipeType.getItemGas(itemstack) != null; + } else if (recipeType == RecipeType.INFUSING) { + return InfuseRegistry.getObject(itemstack) != null + && (infuseStored.type == null + || infuseStored.type == InfuseRegistry.getObject(itemstack).type); + } + } + + return false; + } + + public int getScaledProgress(int i, int process) { + return progress[process] * i / ticksRequired; + } + + public int getScaledInfuseLevel(int i) { + return infuseStored.amount * i / maxInfuse; + } + + public int getScaledGasLevel(int i) { + return gasTank.getStored() * i / gasTank.getMaxGas(); + } + + public int getScaledRecipeProgress(int i) { + return recipeTicks * i / RECIPE_TICKS_REQUIRED; + } + + public boolean canOperate(int inputSlot, int outputSlot) { + if (inventory[inputSlot] == null) { + return false; + } + + if (recipeType.usesFuel()) { + AdvancedMachineRecipe recipe + = recipeType.getRecipe(inventory[inputSlot], gasTank.getGasType()); + + if (recipe == null) { + return false; + } + + return recipe.canOperate( + inventory, inputSlot, outputSlot, gasTank, secondaryEnergyThisTick + ); + } + + if (recipeType == RecipeType.INFUSING) { + InfusionInput input = new InfusionInput(infuseStored, inventory[inputSlot]); + MetallurgicInfuserRecipe recipe + = RecipeHandler.getMetallurgicInfuserRecipe(input); + + if (recipe == null) { + return false; + } + + return recipe.canOperate(inventory, inputSlot, outputSlot, infuseStored); + } + + BasicMachineRecipe recipe = recipeType.getRecipe(inventory[inputSlot]); + + if (recipe == null) { + return false; + } + + return recipe.canOperate(inventory, inputSlot, outputSlot); + } + + public void operate(int inputSlot, int outputSlot) { + if (!canOperate(inputSlot, outputSlot)) { + return; + } + + if (recipeType.usesFuel()) { + AdvancedMachineRecipe recipe + = recipeType.getRecipe(inventory[inputSlot], gasTank.getGasType()); + + recipe.operate( + inventory, inputSlot, outputSlot, gasTank, secondaryEnergyThisTick + ); + } else if (recipeType == RecipeType.INFUSING) { + InfusionInput input = new InfusionInput(infuseStored, inventory[inputSlot]); + MetallurgicInfuserRecipe recipe + = RecipeHandler.getMetallurgicInfuserRecipe(input); + + recipe.output(inventory, inputSlot, outputSlot, infuseStored); + } else { + BasicMachineRecipe recipe = recipeType.getRecipe(inventory[inputSlot]); + + recipe.operate(inventory, inputSlot, outputSlot); + } + + markDirty(); + ejectorComponent.outputItems(); + } + + @Override + public void handlePacketData(ByteBuf dataStream) { + if (!worldObj.isRemote) { + int type = dataStream.readInt(); + + if (type == 0) { + sorting = !sorting; + } else if (type == 1) { + gasTank.setGas(null); + infuseStored.amount = 0; + infuseStored.type = null; + } + + return; + } + + super.handlePacketData(dataStream); + + if (worldObj.isRemote) { + clientActive = dataStream.readBoolean(); + RecipeType oldRecipe = recipeType; + recipeType = RecipeType.values()[dataStream.readInt()]; + upgradeComponent.setSupported(Upgrade.GAS, recipeType.fuelEnergyUpgrades()); + + if (recipeType != oldRecipe) { + secondaryEnergyPerTick = getSecondaryEnergyPerTick(recipeType); + } + + recipeTicks = dataStream.readInt(); + controlType = RedstoneControl.values()[dataStream.readInt()]; + sorting = dataStream.readBoolean(); + upgraded = dataStream.readBoolean(); + lastUsage = dataStream.readDouble(); + infuseStored.amount = dataStream.readInt(); + infuseStored.type = InfuseRegistry.get(PacketHandler.readString(dataStream)); + + for (int i = 0; i < tier.processes; i++) { + progress[i] = dataStream.readInt(); + } + + if (dataStream.readBoolean()) { + gasTank.setGas(new GasStack(dataStream.readInt(), dataStream.readInt())); + } else { + gasTank.setGas(null); + } + + if (updateDelay == 0 && clientActive != isActive) { + updateDelay = general.UPDATE_DELAY; + isActive = clientActive; + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + + if (upgraded) { + markDirty(); + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + upgraded = false; + } + } + } + + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); + + clientActive = isActive = nbtTags.getBoolean("isActive"); + RecipeType oldRecipe = recipeType; + recipeType = RecipeType.values()[nbtTags.getInteger("recipeType")]; + upgradeComponent.setSupported(Upgrade.GAS, recipeType.fuelEnergyUpgrades()); + + if (recipeType != oldRecipe) { + secondaryEnergyPerTick = getSecondaryEnergyPerTick(recipeType); + } + + recipeTicks = nbtTags.getInteger("recipeTicks"); + controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + sorting = nbtTags.getBoolean("sorting"); + infuseStored.amount = nbtTags.getInteger("infuseStored"); + infuseStored.type = InfuseRegistry.get(nbtTags.getString("type")); + + for (int i = 0; i < tier.processes; i++) { + progress[i] = nbtTags.getInteger("progress" + i); + } + + gasTank.read(nbtTags.getCompoundTag("gasTank")); + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); + + nbtTags.setBoolean("isActive", isActive); + nbtTags.setInteger("recipeType", recipeType.ordinal()); + nbtTags.setInteger("recipeTicks", recipeTicks); + nbtTags.setInteger("controlType", controlType.ordinal()); + nbtTags.setBoolean("sorting", sorting); + nbtTags.setInteger("infuseStored", infuseStored.amount); + + if (infuseStored.type != null) { + nbtTags.setString("type", infuseStored.type.name); + } else { + nbtTags.setString("type", "null"); + } + + for (int i = 0; i < tier.processes; i++) { + nbtTags.setInteger("progress" + i, progress[i]); + } + + nbtTags.setTag("gasTank", gasTank.write(new NBTTagCompound())); + } + + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); + + data.add(isActive); + data.add(recipeType.ordinal()); + data.add(recipeTicks); + data.add(controlType.ordinal()); + data.add(sorting); + data.add(upgraded); + data.add(lastUsage); + data.add(infuseStored.amount); + + if (infuseStored.type != null) { + data.add(infuseStored.type.name); + } else { + data.add("null"); + } + + data.add(progress); + + if (gasTank.getGas() != null) { + data.add(true); + data.add(gasTank.getGas().getGas().getID()); + data.add(gasTank.getStored()); + } else { + data.add(false); + } + + upgraded = false; + + return data; + } + + public int getInputSlot(int operation) { + return 5 + operation; + } + + public int getOutputSlot(int operation) { + return 5 + tier.processes + operation; + } + + @Override + public String getInventoryName() { + if (StatCollector.canTranslate( + "tile." + tier.getBaseTier().getName() + recipeType.getUnlocalizedName() + + "Factory" + )) { + return LangUtils.localize( + "tile." + tier.getBaseTier().getName() + recipeType.getUnlocalizedName() + + "Factory" + ); + } + + return tier.getBaseTier().getLocalizedName() + " " + recipeType.getLocalizedName() + + " " + super.getInventoryName(); + } + + private static final String[] methods + = new String[] { "getEnergy", "getProgress", "facing", + "canOperate", "getMaxEnergy", "getEnergyNeeded" }; + + @Override + public String[] getMethods() { + return methods; + } + + @Override + public Object[] invoke(int method, Object[] arguments) throws Exception { + switch (method) { + case 0: + return new Object[] { electricityStored }; + case 1: + if (arguments[0] == null) { + return new Object[] { "Please provide a target operation." }; + } + + if (!(arguments[0] instanceof Double) + && !(arguments[0] instanceof Integer)) { + return new Object[] { "Invalid characters." }; + } + + if ((Integer) arguments[0] < 0 + || (Integer) arguments[0] > progress.length) { + return new Object[] { "No such operation found." }; + } + + return new Object[] { progress[(Integer) arguments[0]] }; + case 2: + return new Object[] { facing }; + case 3: + if (arguments[0] == null) { + return new Object[] { "Please provide a target operation." }; + } + + if (!(arguments[0] instanceof Double) + && !(arguments[0] instanceof Integer)) { + return new Object[] { "Invalid characters." }; + } + + if ((Integer) arguments[0] < 0 + || (Integer) arguments[0] > progress.length) { + return new Object[] { "No such operation found." }; + } + + return new Object[] { canOperate( + getInputSlot((Integer) arguments[0]), + getOutputSlot((Integer) arguments[0]) + ) }; + case 4: + return new Object[] { getMaxEnergy() }; + case 5: + return new Object[] { getMaxEnergy() - getEnergy() }; + default: + throw new NoSuchMethodException(); + } + } + + @Override + public void setActive(boolean active) { + isActive = active; + + if (clientActive != active && updateDelay == 0) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + + updateDelay = 10; + clientActive = active; + } + } + + @Override + public boolean getActive() { + return isActive; + } + + @Override + public int[] getAccessibleSlotsFromSide(int side) { + return configComponent.getOutput(TransmissionType.ITEM, side, facing) + .availableSlots; + } + + @Override + public boolean canSetFacing(int side) { + return side != 0 && side != 1; + } + + @Override + public TileComponentConfig getConfig() { + return configComponent; + } + + @Override + public int getOrientation() { + return facing; + } + + @Override + @SideOnly(Side.CLIENT) + public SoundWrapper getSound() { + return sounds[recipeType.ordinal()]; + } + + @Override + @SideOnly(Side.CLIENT) + public void initSounds() { + sounds = new SoundWrapper[RecipeType.values().length]; + + for (RecipeType type : RecipeType.values()) { + sounds[type.ordinal()] = new SoundWrapper( + this, this, HolidayManager.filterSound(type.getSound()) + ); + } + } + + @Override + public boolean renderUpdate() { + return true; + } + + @Override + public boolean lightUpdate() { + return true; + } + + @Override + public RedstoneControl getControlType() { + return controlType; + } + + @Override + public void setControlType(RedstoneControl type) { + controlType = type; + MekanismUtils.saveChunk(this); + } + + @Override + public boolean canPulse() { + return false; + } + + @Override + public TileComponentUpgrade getComponent() { + return upgradeComponent; + } + + @Override + public TileComponentEjector getEjector() { + return ejectorComponent; + } + + @Override + public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) { + if (canReceiveGas(side, stack.getGas())) { + return gasTank.receive(stack, doTransfer); + } + + return 0; + } + + @Override + public int receiveGas(ForgeDirection side, GasStack stack) { + return receiveGas(side, stack, true); + } + + @Override + public boolean canReceiveGas(ForgeDirection side, Gas type) { + if (configComponent.getOutput(TransmissionType.GAS, side.ordinal(), facing) + .hasSlot(0)) { + return recipeType.canReceiveGas(side, type); + } + + return false; + } + + @Override + public boolean canTubeConnect(ForgeDirection side) { + if (recipeType.canTubeConnect(side)) { + return configComponent.getOutput(TransmissionType.GAS, side.ordinal(), facing) + .hasSlot(0); + } + + return false; + } + + @Override + public GasStack drawGas(ForgeDirection side, int amount, boolean doTransfer) { + return null; + } + + @Override + public GasStack drawGas(ForgeDirection side, int amount) { + return drawGas(side, amount, true); + } + + @Override + public boolean canDrawGas(ForgeDirection side, Gas type) { + return false; + } + + @Override + public void recalculateUpgradables(Upgrade upgrade) { + super.recalculateUpgradables(upgrade); + + switch (upgrade) { + case GAS: + secondaryEnergyPerTick = getSecondaryEnergyPerTick(recipeType); + break; + case SPEED: + ticksRequired = MekanismUtils.getTicks(this, BASE_TICKS_REQUIRED); + energyPerTick + = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK); + secondaryEnergyPerTick = getSecondaryEnergyPerTick(recipeType); + break; + case ENERGY: + energyPerTick + = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK); + maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY); + break; + default: + break; + } + } + + @Override + public NBTTagCompound getConfigurationData(NBTTagCompound nbtTags) { + nbtTags.setBoolean("sorting", sorting); + + return nbtTags; + } + + @Override + public void setConfigurationData(NBTTagCompound nbtTags) { + sorting = nbtTags.getBoolean("sorting"); + } + + @Override + public String getDataType() { + return tier.getBaseTier().getLocalizedName() + " " + recipeType.getLocalizedName() + + " " + super.getInventoryName(); + } + + @Override + public TileComponentSecurity getSecurity() { + return securityComponent; + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityFluidTank.java b/src/main/java/mekanism/common/tile/TileEntityFluidTank.java index e2041be89..069c01b92 100644 --- a/src/main/java/mekanism/common/tile/TileEntityFluidTank.java +++ b/src/main/java/mekanism/common/tile/TileEntityFluidTank.java @@ -1,9 +1,8 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.IConfigurable; import mekanism.api.MekanismConfig.general; @@ -40,589 +39,543 @@ import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidContainerItem; import net.minecraftforge.fluids.IFluidHandler; -public class TileEntityFluidTank extends TileEntityContainerBlock implements IActiveState, IConfigurable, IFluidHandler, ISustainedTank, IFluidContainerManager, ITankManager, ISecurityTile, ITierUpgradeable -{ - public boolean isActive; +public class TileEntityFluidTank extends TileEntityContainerBlock + implements IActiveState, IConfigurable, IFluidHandler, ISustainedTank, + IFluidContainerManager, ITankManager, ISecurityTile, ITierUpgradeable { + public boolean isActive; - public boolean clientActive; - - public FluidTank fluidTank; - - public ContainerEditMode editMode = ContainerEditMode.BOTH; - - public FluidTankTier tier = FluidTankTier.BASIC; - - public int updateDelay; - - public int prevAmount; - - public int valve; - public Fluid valveFluid; - - public float prevScale; - - public boolean needsPacket; - - public int currentRedstoneLevel; - - public TileComponentSecurity securityComponent = new TileComponentSecurity(this); - - public TileEntityFluidTank() - { - super("FluidTank"); - - fluidTank = new FluidTank(tier.storage); - inventory = new ItemStack[2]; - } - - @Override - public boolean upgrade(BaseTier upgradeTier) - { - if(upgradeTier.ordinal() != tier.ordinal()+1) - { - return false; - } - - tier = FluidTankTier.values()[upgradeTier.ordinal()]; - fluidTank.setCapacity(tier.storage); - - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - markDirty(); - - return true; - } - - @Override - public boolean canSetFacing(int facing) - { - return false; - } + public boolean clientActive; - @Override - public void onUpdate() - { - if(worldObj.isRemote) - { - if(updateDelay > 0) - { - updateDelay--; + public FluidTank fluidTank; - if(updateDelay == 0 && clientActive != isActive) - { - isActive = clientActive; - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } - - float targetScale = (float)(fluidTank.getFluid() != null ? fluidTank.getFluid().amount : 0)/fluidTank.getCapacity(); + public ContainerEditMode editMode = ContainerEditMode.BOTH; - if(Math.abs(prevScale - targetScale) > 0.01) - { - prevScale = (9*prevScale + targetScale)/10; - } - } - else { - if(updateDelay > 0) - { - updateDelay--; + public FluidTankTier tier = FluidTankTier.BASIC; - if(updateDelay == 0 && clientActive != isActive) - { - needsPacket = true; - } - } - - if(valve > 0) - { - valve--; - - if(valve == 0) - { - valveFluid = null; - needsPacket = true; - } - } - - if(fluidTank.getFluidAmount() != prevAmount) - { - MekanismUtils.saveChunk(this); - needsPacket = true; - } - - prevAmount = fluidTank.getFluidAmount(); - - if(inventory[0] != null) - { - manageInventory(); - } - - if(isActive) - { - activeEmit(); - } - - int newRedstoneLevel = getRedstoneLevel(); + public int updateDelay; - if(newRedstoneLevel != currentRedstoneLevel) - { - markDirty(); - currentRedstoneLevel = newRedstoneLevel; - } - - if(needsPacket) - { - Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this).getTargetPoint(50)); - } - - needsPacket = false; - } - } - - @Override - public String getInventoryName() - { - return LangUtils.localize("tile.FluidTank" + tier.getBaseTier().getName() + ".name"); - } - - private void activeEmit() - { - if(fluidTank.getFluid() != null) - { - TileEntity tileEntity = Coord4D.get(this).getFromSide(ForgeDirection.DOWN).getTileEntity(worldObj); + public int prevAmount; - if(tileEntity instanceof IFluidHandler) - { - FluidStack toDrain = new FluidStack(fluidTank.getFluid(), Math.min(tier.output, fluidTank.getFluidAmount())); - fluidTank.drain(((IFluidHandler)tileEntity).fill(ForgeDirection.UP, toDrain, true), true); - } - } - } - - private void manageInventory() - { - if(inventory[0] != null) - { - if(inventory[0].getItem() instanceof IFluidContainerItem) - { - if(editMode == ContainerEditMode.FILL && fluidTank.getFluidAmount() > 0) - { - FluidContainerUtils.handleContainerItemFill(this, fluidTank, 0, 1); - } - else if(editMode == ContainerEditMode.EMPTY) - { - FluidStack ret = FluidContainerUtils.handleContainerItemEmpty(this, inventory, fluidTank.getFluid(), getCurrentNeeded(), 0, 1, null); - - if(ret != null) - { - fluidTank.setFluid(PipeUtils.copy(ret, Math.min(fluidTank.getCapacity(), ret.amount))); - - int rejects = Math.max(0, ret.amount - fluidTank.getCapacity()); - - if(rejects > 0) - { - pushUp(PipeUtils.copy(ret, rejects), true); - } - } - } - } + public int valve; + public Fluid valveFluid; + + public float prevScale; + + public boolean needsPacket; + + public int currentRedstoneLevel; + + public TileComponentSecurity securityComponent = new TileComponentSecurity(this); + + public TileEntityFluidTank() { + super("FluidTank"); + + fluidTank = new FluidTank(tier.storage); + inventory = new ItemStack[2]; + } + + @Override + public boolean upgrade(BaseTier upgradeTier) { + if (upgradeTier.ordinal() != tier.ordinal() + 1) { + return false; + } + + tier = FluidTankTier.values()[upgradeTier.ordinal()]; + fluidTank.setCapacity(tier.storage); + + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), + new Range4D(Coord4D.get(this)) + ); + markDirty(); + + return true; + } + + @Override + public boolean canSetFacing(int facing) { + return false; + } + + @Override + public void onUpdate() { + if (worldObj.isRemote) { + if (updateDelay > 0) { + updateDelay--; + + if (updateDelay == 0 && clientActive != isActive) { + isActive = clientActive; + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } + + float targetScale + = (float) (fluidTank.getFluid() != null ? fluidTank.getFluid().amount : 0) + / fluidTank.getCapacity(); + + if (Math.abs(prevScale - targetScale) > 0.01) { + prevScale = (9 * prevScale + targetScale) / 10; + } + } else { + if (updateDelay > 0) { + updateDelay--; + + if (updateDelay == 0 && clientActive != isActive) { + needsPacket = true; + } + } + + if (valve > 0) { + valve--; + + if (valve == 0) { + valveFluid = null; + needsPacket = true; + } + } + + if (fluidTank.getFluidAmount() != prevAmount) { + MekanismUtils.saveChunk(this); + needsPacket = true; + } + + prevAmount = fluidTank.getFluidAmount(); + + if (inventory[0] != null) { + manageInventory(); + } + + if (isActive) { + activeEmit(); + } + + int newRedstoneLevel = getRedstoneLevel(); + + if (newRedstoneLevel != currentRedstoneLevel) { + markDirty(); + currentRedstoneLevel = newRedstoneLevel; + } + + if (needsPacket) { + Mekanism.packetHandler.sendToAllAround( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + Coord4D.get(this).getTargetPoint(50) + ); + } + + needsPacket = false; + } + } + + @Override + public String getInventoryName() { + return LangUtils.localize( + "tile.FluidTank" + tier.getBaseTier().getName() + ".name" + ); + } + + private void activeEmit() { + if (fluidTank.getFluid() != null) { + TileEntity tileEntity = Coord4D.get(this) + .getFromSide(ForgeDirection.DOWN) + .getTileEntity(worldObj); + + if (tileEntity instanceof IFluidHandler) { + FluidStack toDrain = new FluidStack( + fluidTank.getFluid(), + Math.min(tier.output, fluidTank.getFluidAmount()) + ); + fluidTank.drain( + ((IFluidHandler) tileEntity).fill(ForgeDirection.UP, toDrain, true), + true + ); + } + } + } + + private void manageInventory() { + if (inventory[0] != null) { + if (inventory[0].getItem() instanceof IFluidContainerItem) { + if (editMode == ContainerEditMode.FILL + && fluidTank.getFluidAmount() > 0) { + FluidContainerUtils.handleContainerItemFill(this, fluidTank, 0, 1); + } else if (editMode == ContainerEditMode.EMPTY) { + FluidStack ret = FluidContainerUtils.handleContainerItemEmpty( + this, + inventory, + fluidTank.getFluid(), + getCurrentNeeded(), + 0, + 1, + null + ); + + if (ret != null) { + fluidTank.setFluid(PipeUtils.copy( + ret, Math.min(fluidTank.getCapacity(), ret.amount) + )); + + int rejects = Math.max(0, ret.amount - fluidTank.getCapacity()); + + if (rejects > 0) { + pushUp(PipeUtils.copy(ret, rejects), true); + } + } + } + } else if(FluidContainerRegistry.isEmptyContainer(inventory[0]) && (editMode == ContainerEditMode.BOTH || editMode == ContainerEditMode.FILL)) { - FluidContainerUtils.handleRegistryItemFill(this, fluidTank, 0, 1); - } + FluidContainerUtils.handleRegistryItemFill(this, fluidTank, 0, 1); + } else if(FluidContainerRegistry.isFilledContainer(inventory[0]) && (editMode == ContainerEditMode.BOTH || editMode == ContainerEditMode.EMPTY)) { - FluidStack ret = FluidContainerUtils.handleRegistryItemEmpty(this, inventory, fluidTank.getFluid(), getCurrentNeeded(), 0, 1, null); - - if(ret != null) - { - fluidTank.setFluid(PipeUtils.copy(ret, Math.min(fluidTank.getCapacity(), ret.amount))); - - int rejects = Math.max(0, ret.amount - fluidTank.getCapacity()); - - if(rejects > 0) - { - pushUp(PipeUtils.copy(ret, rejects), true); - } - } - } - } - } - - public int pushUp(FluidStack fluid, boolean doFill) - { - Coord4D up = Coord4D.get(this).getFromSide(ForgeDirection.UP); - - if(up.getTileEntity(worldObj) instanceof TileEntityFluidTank) - { - IFluidHandler handler = (IFluidHandler)up.getTileEntity(worldObj); - - if(handler.canFill(ForgeDirection.DOWN, fluid.getFluid())) - { - return handler.fill(ForgeDirection.DOWN, fluid, doFill); - } - } - - return 0; - } - - @Override - public boolean canExtractItem(int slotID, ItemStack itemstack, int side) - { - return slotID == 1; - } + FluidStack ret = FluidContainerUtils.handleRegistryItemEmpty( + this, inventory, fluidTank.getFluid(), getCurrentNeeded(), 0, 1, null + ); - @Override - public boolean isItemValidForSlot(int slotID, ItemStack itemstack) - { - if(slotID == 0) - { - if(itemstack.getItem() instanceof IFluidContainerItem) - { - return true; - } - else if(FluidContainerRegistry.isFilledContainer(itemstack)) - { - FluidStack stack = FluidContainerRegistry.getFluidForFilledItem(itemstack); - - if(fluidTank.getFluid() == null || fluidTank.getFluid().isFluidEqual(stack)) - { - return editMode == ContainerEditMode.EMPTY || editMode == ContainerEditMode.BOTH; - } - } - else if(FluidContainerRegistry.isEmptyContainer(itemstack)) - { - return editMode == ContainerEditMode.FILL || editMode == ContainerEditMode.BOTH; - } - } + if (ret != null) { + fluidTank.setFluid( + PipeUtils.copy(ret, Math.min(fluidTank.getCapacity(), ret.amount)) + ); - return false; - } + int rejects = Math.max(0, ret.amount - fluidTank.getCapacity()); - @Override - public int[] getAccessibleSlotsFromSide(int side) - { - if(side == 0) - { - return new int[] {1}; - } - else if(side == 1) - { - return new int[] {0}; - } - - return InventoryUtils.EMPTY; - } + if (rejects > 0) { + pushUp(PipeUtils.copy(ret, rejects), true); + } + } + } + } + } - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); + public int pushUp(FluidStack fluid, boolean doFill) { + Coord4D up = Coord4D.get(this).getFromSide(ForgeDirection.UP); - nbtTags.setInteger("tier", tier.ordinal()); - nbtTags.setBoolean("isActive", isActive); - nbtTags.setInteger("editMode", editMode.ordinal()); - - if(fluidTank.getFluid() != null) - { - nbtTags.setTag("fluidTank", fluidTank.writeToNBT(new NBTTagCompound())); - } - } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); + if (up.getTileEntity(worldObj) instanceof TileEntityFluidTank) { + IFluidHandler handler = (IFluidHandler) up.getTileEntity(worldObj); - tier = FluidTankTier.values()[nbtTags.getInteger("tier")]; - clientActive = isActive = nbtTags.getBoolean("isActive"); - editMode = ContainerEditMode.values()[nbtTags.getInteger("editMode")]; - - if(nbtTags.hasKey("fluidTank")) - { - fluidTank.setCapacity(tier.storage); - fluidTank.readFromNBT(nbtTags.getCompoundTag("fluidTank")); - } - } - - @Override - public void handlePacketData(ByteBuf dataStream) - { - super.handlePacketData(dataStream); + if (handler.canFill(ForgeDirection.DOWN, fluid.getFluid())) { + return handler.fill(ForgeDirection.DOWN, fluid, doFill); + } + } - if(worldObj.isRemote) - { - tier = FluidTankTier.values()[dataStream.readInt()]; - fluidTank.setCapacity(tier.storage); - - clientActive = dataStream.readBoolean(); - valve = dataStream.readInt(); - editMode = ContainerEditMode.values()[dataStream.readInt()]; - - if(valve > 0) - { - valveFluid = FluidRegistry.getFluid(dataStream.readInt()); - } - else { - valveFluid = null; - } - - if(dataStream.readInt() == 1) - { - fluidTank.setFluid(new FluidStack(FluidRegistry.getFluid(dataStream.readInt()), dataStream.readInt())); - } - else { - fluidTank.setFluid(null); - } - - if(updateDelay == 0 && clientActive != isActive) - { - updateDelay = general.UPDATE_DELAY; - isActive = clientActive; - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } - } - - public int getRedstoneLevel() - { - double fractionFull = (float)fluidTank.getFluidAmount()/(float)fluidTank.getCapacity(); - return MathHelper.floor_float((float)(fractionFull * 14.0F)) + (fractionFull > 0 ? 1 : 0); - } - - public int getCurrentNeeded() - { - int needed = fluidTank.getCapacity()-fluidTank.getFluidAmount(); - - Coord4D top = Coord4D.get(this).getFromSide(ForgeDirection.UP); - TileEntity topTile = top.getTileEntity(worldObj); - - if(topTile instanceof TileEntityFluidTank) - { - TileEntityFluidTank topTank = (TileEntityFluidTank)topTile; - - if(fluidTank.getFluid() != null && topTank.fluidTank.getFluid() != null) - { - if(fluidTank.getFluid().getFluid() != topTank.fluidTank.getFluid().getFluid()) - { - return needed; - } - } - - needed += topTank.getCurrentNeeded(); - } - - return needed; - } - - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); + return 0; + } - data.add(tier.ordinal()); - data.add(isActive); - data.add(valve); - data.add(editMode.ordinal()); - - if(valve > 0) - { - data.add(valveFluid.getID()); - } - - if(fluidTank.getFluid() != null) - { - data.add(1); - data.add(fluidTank.getFluid().getFluidID()); - data.add(fluidTank.getFluid().amount); - } - else { - data.add(0); - } - - return data; - } - - @Override - public void setActive(boolean active) - { - isActive = active; + @Override + public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { + return slotID == 1; + } - if(clientActive != active && updateDelay == 0) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); + @Override + public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { + if (slotID == 0) { + if (itemstack.getItem() instanceof IFluidContainerItem) { + return true; + } else if (FluidContainerRegistry.isFilledContainer(itemstack)) { + FluidStack stack + = FluidContainerRegistry.getFluidForFilledItem(itemstack); - updateDelay = 10; - clientActive = active; - } - } + if (fluidTank.getFluid() == null + || fluidTank.getFluid().isFluidEqual(stack)) { + return editMode == ContainerEditMode.EMPTY + || editMode == ContainerEditMode.BOTH; + } + } else if (FluidContainerRegistry.isEmptyContainer(itemstack)) { + return editMode == ContainerEditMode.FILL + || editMode == ContainerEditMode.BOTH; + } + } - @Override - public boolean getActive() - { - return isActive; - } - - @Override - public boolean renderUpdate() - { - return false; - } + return false; + } - @Override - public boolean lightUpdate() - { - return true; - } - - @Override - public boolean onSneakRightClick(EntityPlayer player, int side) - { - if(!worldObj.isRemote) - { - setActive(!getActive()); - worldObj.playSoundEffect(xCoord, yCoord, zCoord, "random.click", 0.3F, 1); - } - - return true; - } + @Override + public int[] getAccessibleSlotsFromSide(int side) { + if (side == 0) { + return new int[] { 1 }; + } else if (side == 1) { + return new int[] { 0 }; + } - @Override - public boolean onRightClick(EntityPlayer player, int side) - { - return false; - } + return InventoryUtils.EMPTY; + } - @Override - public int fill(ForgeDirection from, FluidStack resource, boolean doFill) - { - if(resource != null && canFill(from, resource.getFluid())) - { - int filled = fluidTank.fill(resource, doFill); - - if(filled < resource.amount && !isActive) - { - filled += pushUp(PipeUtils.copy(resource, resource.amount-filled), doFill); - } - - if(filled > 0 && from == ForgeDirection.UP) - { - if(valve == 0) - { - needsPacket = true; - } - - valve = 20; - valveFluid = resource.getFluid(); - } - - return filled; - } - - return 0; - } + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); - @Override - public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) - { - if(resource != null && canDrain(from, resource.getFluid())) - { - return fluidTank.drain(resource.amount, doDrain); - } - - return null; - } + nbtTags.setInteger("tier", tier.ordinal()); + nbtTags.setBoolean("isActive", isActive); + nbtTags.setInteger("editMode", editMode.ordinal()); - @Override - public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) - { - if(canDrain(from, null)) - { - return fluidTank.drain(maxDrain, doDrain); - } - - return null; - } + if (fluidTank.getFluid() != null) { + nbtTags.setTag("fluidTank", fluidTank.writeToNBT(new NBTTagCompound())); + } + } - @Override - public boolean canFill(ForgeDirection from, Fluid fluid) - { - if(from == ForgeDirection.DOWN) - { - TileEntity tile = Coord4D.get(this).getFromSide(ForgeDirection.DOWN).getTileEntity(worldObj); - - if(isActive && !(tile instanceof TileEntityFluidTank)) - { - return false; - } - } - - return fluidTank.getFluid() == null || fluidTank.getFluid().getFluid() == fluid; - } + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); - @Override - public boolean canDrain(ForgeDirection from, Fluid fluid) - { - if(fluidTank != null) - { - if(fluid == null || fluidTank.getFluid() != null && fluidTank.getFluid().getFluid() == fluid) - { - if(isActive) - { - return from != ForgeDirection.DOWN; - } - - return true; - } - } - - return false; - } + tier = FluidTankTier.values()[nbtTags.getInteger("tier")]; + clientActive = isActive = nbtTags.getBoolean("isActive"); + editMode = ContainerEditMode.values()[nbtTags.getInteger("editMode")]; - @Override - public FluidTankInfo[] getTankInfo(ForgeDirection from) - { - return new FluidTankInfo[] {fluidTank.getInfo()}; - } - - @Override - public void setFluidStack(FluidStack fluidStack, Object... data) - { - fluidTank.setFluid(fluidStack); - } + if (nbtTags.hasKey("fluidTank")) { + fluidTank.setCapacity(tier.storage); + fluidTank.readFromNBT(nbtTags.getCompoundTag("fluidTank")); + } + } - @Override - public FluidStack getFluidStack(Object... data) - { - return fluidTank.getFluid(); - } + @Override + public void handlePacketData(ByteBuf dataStream) { + super.handlePacketData(dataStream); - @Override - public boolean hasTank(Object... data) - { - return true; - } + if (worldObj.isRemote) { + tier = FluidTankTier.values()[dataStream.readInt()]; + fluidTank.setCapacity(tier.storage); - @Override - public ContainerEditMode getContainerEditMode() - { - return editMode; - } + clientActive = dataStream.readBoolean(); + valve = dataStream.readInt(); + editMode = ContainerEditMode.values()[dataStream.readInt()]; - @Override - public void setContainerEditMode(ContainerEditMode mode) - { - editMode = mode; - } - - @Override - public Object[] getTanks() - { - return new Object[] {fluidTank}; - } - - @Override - public TileComponentSecurity getSecurity() - { - return securityComponent; - } + if (valve > 0) { + valveFluid = FluidRegistry.getFluid(dataStream.readInt()); + } else { + valveFluid = null; + } + + if (dataStream.readInt() == 1) { + fluidTank.setFluid(new FluidStack( + FluidRegistry.getFluid(dataStream.readInt()), dataStream.readInt() + )); + } else { + fluidTank.setFluid(null); + } + + if (updateDelay == 0 && clientActive != isActive) { + updateDelay = general.UPDATE_DELAY; + isActive = clientActive; + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } + } + + public int getRedstoneLevel() { + double fractionFull + = (float) fluidTank.getFluidAmount() / (float) fluidTank.getCapacity(); + return MathHelper.floor_float((float) (fractionFull * 14.0F)) + + (fractionFull > 0 ? 1 : 0); + } + + public int getCurrentNeeded() { + int needed = fluidTank.getCapacity() - fluidTank.getFluidAmount(); + + Coord4D top = Coord4D.get(this).getFromSide(ForgeDirection.UP); + TileEntity topTile = top.getTileEntity(worldObj); + + if (topTile instanceof TileEntityFluidTank) { + TileEntityFluidTank topTank = (TileEntityFluidTank) topTile; + + if (fluidTank.getFluid() != null && topTank.fluidTank.getFluid() != null) { + if (fluidTank.getFluid().getFluid() + != topTank.fluidTank.getFluid().getFluid()) { + return needed; + } + } + + needed += topTank.getCurrentNeeded(); + } + + return needed; + } + + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); + + data.add(tier.ordinal()); + data.add(isActive); + data.add(valve); + data.add(editMode.ordinal()); + + if (valve > 0) { + data.add(valveFluid.getID()); + } + + if (fluidTank.getFluid() != null) { + data.add(1); + data.add(fluidTank.getFluid().getFluidID()); + data.add(fluidTank.getFluid().amount); + } else { + data.add(0); + } + + return data; + } + + @Override + public void setActive(boolean active) { + isActive = active; + + if (clientActive != active && updateDelay == 0) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + + updateDelay = 10; + clientActive = active; + } + } + + @Override + public boolean getActive() { + return isActive; + } + + @Override + public boolean renderUpdate() { + return false; + } + + @Override + public boolean lightUpdate() { + return true; + } + + @Override + public boolean onSneakRightClick(EntityPlayer player, int side) { + if (!worldObj.isRemote) { + setActive(!getActive()); + worldObj.playSoundEffect(xCoord, yCoord, zCoord, "random.click", 0.3F, 1); + } + + return true; + } + + @Override + public boolean onRightClick(EntityPlayer player, int side) { + return false; + } + + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { + if (resource != null && canFill(from, resource.getFluid())) { + int filled = fluidTank.fill(resource, doFill); + + if (filled < resource.amount && !isActive) { + filled + += pushUp(PipeUtils.copy(resource, resource.amount - filled), doFill); + } + + if (filled > 0 && from == ForgeDirection.UP) { + if (valve == 0) { + needsPacket = true; + } + + valve = 20; + valveFluid = resource.getFluid(); + } + + return filled; + } + + return 0; + } + + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + if (resource != null && canDrain(from, resource.getFluid())) { + return fluidTank.drain(resource.amount, doDrain); + } + + return null; + } + + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { + if (canDrain(from, null)) { + return fluidTank.drain(maxDrain, doDrain); + } + + return null; + } + + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + if (from == ForgeDirection.DOWN) { + TileEntity tile = Coord4D.get(this) + .getFromSide(ForgeDirection.DOWN) + .getTileEntity(worldObj); + + if (isActive && !(tile instanceof TileEntityFluidTank)) { + return false; + } + } + + return fluidTank.getFluid() == null || fluidTank.getFluid().getFluid() == fluid; + } + + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + if (fluidTank != null) { + if (fluid == null + || fluidTank.getFluid() != null + && fluidTank.getFluid().getFluid() == fluid) { + if (isActive) { + return from != ForgeDirection.DOWN; + } + + return true; + } + } + + return false; + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection from) { + return new FluidTankInfo[] { fluidTank.getInfo() }; + } + + @Override + public void setFluidStack(FluidStack fluidStack, Object... data) { + fluidTank.setFluid(fluidStack); + } + + @Override + public FluidStack getFluidStack(Object... data) { + return fluidTank.getFluid(); + } + + @Override + public boolean hasTank(Object... data) { + return true; + } + + @Override + public ContainerEditMode getContainerEditMode() { + return editMode; + } + + @Override + public void setContainerEditMode(ContainerEditMode mode) { + editMode = mode; + } + + @Override + public Object[] getTanks() { + return new Object[] { fluidTank }; + } + + @Override + public TileComponentSecurity getSecurity() { + return securityComponent; + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityFluidicPlenisher.java b/src/main/java/mekanism/common/tile/TileEntityFluidicPlenisher.java index 7d6247973..06fadfbd5 100644 --- a/src/main/java/mekanism/common/tile/TileEntityFluidicPlenisher.java +++ b/src/main/java/mekanism/common/tile/TileEntityFluidicPlenisher.java @@ -1,12 +1,11 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.EnumSet; import java.util.HashSet; import java.util.Set; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.IConfigurable; @@ -42,531 +41,485 @@ import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidContainerItem; import net.minecraftforge.fluids.IFluidHandler; -public class TileEntityFluidicPlenisher extends TileEntityElectricBlock implements IComputerIntegration, IConfigurable, IFluidHandler, ISustainedTank, IUpgradeTile, IRedstoneControl, ISecurityTile -{ - public Set activeNodes = new HashSet(); - public Set usedNodes = new HashSet(); - - public boolean finishedCalc = false; - - public FluidTank fluidTank = new FluidTank(10000); - - /** How much energy this machine consumes per-tick. */ - public double BASE_ENERGY_PER_TICK = usage.fluidicPlenisherUsage; +public class TileEntityFluidicPlenisher extends TileEntityElectricBlock + implements IComputerIntegration, IConfigurable, IFluidHandler, ISustainedTank, + IUpgradeTile, IRedstoneControl, ISecurityTile { + public Set activeNodes = new HashSet(); + public Set usedNodes = new HashSet(); - public double energyPerTick = BASE_ENERGY_PER_TICK; + public boolean finishedCalc = false; - /** How many ticks it takes to run an operation. */ - public int BASE_TICKS_REQUIRED = 20; + public FluidTank fluidTank = new FluidTank(10000); - public int ticksRequired = BASE_TICKS_REQUIRED; - - /** How many ticks this machine has been operating for. */ - public int operatingTicks; - - public RedstoneControl controlType = RedstoneControl.DISABLED; - - private static EnumSet dirs = EnumSet.complementOf(EnumSet.of(ForgeDirection.UP, ForgeDirection.UNKNOWN)); - - public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, 3); - public TileComponentSecurity securityComponent = new TileComponentSecurity(this); - - public TileEntityFluidicPlenisher() - { - super("FluidicPlenisher", MachineType.FLUIDIC_PLENISHER.baseEnergy); - inventory = new ItemStack[4]; - } - - @Override - public void onUpdate() - { - if(!worldObj.isRemote) - { - ChargeUtils.discharge(2, this); - - if(inventory[0] != null) - { - if(inventory[0].getItem() instanceof IFluidContainerItem) - { - FluidContainerUtils.handleContainerItemEmpty(this, fluidTank, 0, 1, new FluidChecker() { - @Override - public boolean isValid(Fluid f) - { - return f.canBePlacedInWorld(); - } - }); - } - else if(FluidContainerRegistry.isFilledContainer(inventory[0])) - { - FluidContainerUtils.handleRegistryItemEmpty(this, fluidTank, 0, 1, new FluidChecker() { - @Override - public boolean isValid(Fluid f) - { - return f.canBePlacedInWorld(); - } - }); - } - } - - if(MekanismUtils.canFunction(this) && getEnergy() >= energyPerTick && fluidTank.getFluid() != null && fluidTank.getFluid().getFluid().canBePlacedInWorld()) - { - if(!finishedCalc) - { - setEnergy(getEnergy() - energyPerTick); - } - - if((operatingTicks + 1) < ticksRequired) - { - operatingTicks++; - } - else { - if(!finishedCalc) - { - doPlenish(); - } - else { - Coord4D below = Coord4D.get(this).getFromSide(ForgeDirection.DOWN); - - if(canReplace(below, false, false) && fluidTank.getFluidAmount() >= FluidContainerRegistry.BUCKET_VOLUME) - { - if(fluidTank.getFluid().getFluid().canBePlacedInWorld()) - { - worldObj.setBlock(below.xCoord, below.yCoord, below.zCoord, MekanismUtils.getFlowingBlock(fluidTank.getFluid().getFluid()), 0, 3); - - setEnergy(getEnergy() - energyPerTick); - fluidTank.drain(FluidContainerRegistry.BUCKET_VOLUME, true); - } - } - } - - operatingTicks = 0; - } - } - } - } - - private void doPlenish() - { - if(usedNodes.size() >= general.maxPlenisherNodes) - { - finishedCalc = true; - return; - } - - if(activeNodes.isEmpty()) - { - if(usedNodes.isEmpty()) - { - Coord4D below = Coord4D.get(this).getFromSide(ForgeDirection.DOWN); - - if(!canReplace(below, true, true)) - { - finishedCalc = true; - return; - } + /** How much energy this machine consumes per-tick. */ + public double BASE_ENERGY_PER_TICK = usage.fluidicPlenisherUsage; - activeNodes.add(below); - } - else { - finishedCalc = true; - return; - } - } - - Set toRemove = new HashSet(); - - for(Coord4D coord : activeNodes) - { - if(coord.exists(worldObj)) - { - if(canReplace(coord, true, false)) - { - worldObj.setBlock(coord.xCoord, coord.yCoord, coord.zCoord, MekanismUtils.getFlowingBlock(fluidTank.getFluid().getFluid()), 0, 3); + public double energyPerTick = BASE_ENERGY_PER_TICK; - fluidTank.drain(FluidContainerRegistry.BUCKET_VOLUME, true); - } - - for(ForgeDirection dir : dirs) - { - Coord4D sideCoord = coord.getFromSide(dir); - - if(sideCoord.exists(worldObj) && canReplace(sideCoord, true, true)) - { - activeNodes.add(sideCoord); - } - } - - toRemove.add(coord); - break; - } - else { - toRemove.add(coord); - } - } - - for(Coord4D coord : toRemove) - { - activeNodes.remove(coord); - usedNodes.add(coord); - } - } - - public boolean canReplace(Coord4D coord, boolean checkNodes, boolean isPathfinding) - { - if(checkNodes && usedNodes.contains(coord)) - { - return false; - } - - if(coord.isAirBlock(worldObj) || MekanismUtils.isDeadFluid(worldObj, coord)) - { - return true; - } - - if(MekanismUtils.isFluid(worldObj, coord)) - { - return isPathfinding; - } - - return coord.getBlock(worldObj).isReplaceable(worldObj, coord.xCoord, coord.yCoord, coord.zCoord); - } - - @Override - public void handlePacketData(ByteBuf dataStream) - { - super.handlePacketData(dataStream); - - if(worldObj.isRemote) - { - finishedCalc = dataStream.readBoolean(); - controlType = RedstoneControl.values()[dataStream.readInt()]; - - if(dataStream.readInt() == 1) - { - fluidTank.setFluid(new FluidStack(dataStream.readInt(), dataStream.readInt())); - } - else { - fluidTank.setFluid(null); - } - - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } + /** How many ticks it takes to run an operation. */ + public int BASE_TICKS_REQUIRED = 20; - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); - - data.add(finishedCalc); - data.add(controlType.ordinal()); + public int ticksRequired = BASE_TICKS_REQUIRED; - if(fluidTank.getFluid() != null) - { - data.add(1); - data.add(fluidTank.getFluid().getFluidID()); - data.add(fluidTank.getFluid().amount); - } - else { - data.add(0); - } + /** How many ticks this machine has been operating for. */ + public int operatingTicks; - return data; - } + public RedstoneControl controlType = RedstoneControl.DISABLED; - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - nbtTags.setInteger("operatingTicks", operatingTicks); - nbtTags.setBoolean("finishedCalc", finishedCalc); - nbtTags.setInteger("controlType", controlType.ordinal()); + private static EnumSet dirs + = EnumSet.complementOf(EnumSet.of(ForgeDirection.UP, ForgeDirection.UNKNOWN)); - if(fluidTank.getFluid() != null) - { - nbtTags.setTag("fluidTank", fluidTank.writeToNBT(new NBTTagCompound())); - } - - NBTTagList activeList = new NBTTagList(); + public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, 3); + public TileComponentSecurity securityComponent = new TileComponentSecurity(this); - for(Coord4D wrapper : activeNodes) - { - NBTTagCompound tagCompound = new NBTTagCompound(); - wrapper.write(tagCompound); - activeList.appendTag(tagCompound); - } + public TileEntityFluidicPlenisher() { + super("FluidicPlenisher", MachineType.FLUIDIC_PLENISHER.baseEnergy); + inventory = new ItemStack[4]; + } - if(activeList.tagCount() != 0) - { - nbtTags.setTag("activeNodes", activeList); - } + @Override + public void onUpdate() { + if (!worldObj.isRemote) { + ChargeUtils.discharge(2, this); - NBTTagList usedList = new NBTTagList(); + if (inventory[0] != null) { + if (inventory[0].getItem() instanceof IFluidContainerItem) { + FluidContainerUtils.handleContainerItemEmpty( + this, + fluidTank, + 0, + 1, + new FluidChecker() { + @Override + public boolean isValid(Fluid f) { + return f.canBePlacedInWorld(); + } + } + ); + } else if (FluidContainerRegistry.isFilledContainer(inventory[0])) { + FluidContainerUtils.handleRegistryItemEmpty( + this, + fluidTank, + 0, + 1, + new FluidChecker() { + @Override + public boolean isValid(Fluid f) { + return f.canBePlacedInWorld(); + } + } + ); + } + } - for(Coord4D obj : usedNodes) - { - activeList.appendTag(obj.write(new NBTTagCompound())); - } + if (MekanismUtils.canFunction(this) && getEnergy() >= energyPerTick + && fluidTank.getFluid() != null + && fluidTank.getFluid().getFluid().canBePlacedInWorld()) { + if (!finishedCalc) { + setEnergy(getEnergy() - energyPerTick); + } - if(activeList.tagCount() != 0) - { - nbtTags.setTag("usedNodes", usedList); - } - } + if ((operatingTicks + 1) < ticksRequired) { + operatingTicks++; + } else { + if (!finishedCalc) { + doPlenish(); + } else { + Coord4D below + = Coord4D.get(this).getFromSide(ForgeDirection.DOWN); - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - operatingTicks = nbtTags.getInteger("operatingTicks"); - finishedCalc = nbtTags.getBoolean("finishedCalc"); - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + if (canReplace(below, false, false) + && fluidTank.getFluidAmount() + >= FluidContainerRegistry.BUCKET_VOLUME) { + if (fluidTank.getFluid().getFluid().canBePlacedInWorld()) { + worldObj.setBlock( + below.xCoord, + below.yCoord, + below.zCoord, + MekanismUtils.getFlowingBlock( + fluidTank.getFluid().getFluid() + ), + 0, + 3 + ); - if(nbtTags.hasKey("fluidTank")) - { - fluidTank.readFromNBT(nbtTags.getCompoundTag("fluidTank")); - } - - if(nbtTags.hasKey("activeNodes")) - { - NBTTagList tagList = nbtTags.getTagList("activeNodes", NBT.TAG_COMPOUND); + setEnergy(getEnergy() - energyPerTick); + fluidTank.drain( + FluidContainerRegistry.BUCKET_VOLUME, true + ); + } + } + } - for(int i = 0; i < tagList.tagCount(); i++) - { - activeNodes.add(Coord4D.read((NBTTagCompound)tagList.getCompoundTagAt(i))); - } - } + operatingTicks = 0; + } + } + } + } - if(nbtTags.hasKey("usedNodes")) - { - NBTTagList tagList = nbtTags.getTagList("usedNodes", NBT.TAG_COMPOUND); + private void doPlenish() { + if (usedNodes.size() >= general.maxPlenisherNodes) { + finishedCalc = true; + return; + } - for(int i = 0; i < tagList.tagCount(); i++) - { - usedNodes.add(Coord4D.read((NBTTagCompound)tagList.getCompoundTagAt(i))); - } - } - } + if (activeNodes.isEmpty()) { + if (usedNodes.isEmpty()) { + Coord4D below = Coord4D.get(this).getFromSide(ForgeDirection.DOWN); - @Override - public boolean isItemValidForSlot(int slotID, ItemStack itemstack) - { - if(slotID == 1) - { - return false; - } - else if(slotID == 0) - { - return FluidContainerRegistry.isFilledContainer(itemstack); - } - else if(slotID == 2) - { - return ChargeUtils.canBeDischarged(itemstack); - } + if (!canReplace(below, true, true)) { + finishedCalc = true; + return; + } - return false; - } + activeNodes.add(below); + } else { + finishedCalc = true; + return; + } + } - @Override - public boolean canExtractItem(int slotID, ItemStack itemstack, int side) - { - if(slotID == 2) - { - return ChargeUtils.canBeOutputted(itemstack, false); - } - else if(slotID == 1) - { - return true; - } + Set toRemove = new HashSet(); - return false; - } + for (Coord4D coord : activeNodes) { + if (coord.exists(worldObj)) { + if (canReplace(coord, true, false)) { + worldObj.setBlock( + coord.xCoord, + coord.yCoord, + coord.zCoord, + MekanismUtils.getFlowingBlock(fluidTank.getFluid().getFluid()), + 0, + 3 + ); - @Override - public EnumSet getConsumingSides() - { - return EnumSet.of(ForgeDirection.getOrientation(facing).getOpposite()); - } + fluidTank.drain(FluidContainerRegistry.BUCKET_VOLUME, true); + } - @Override - public boolean canSetFacing(int side) - { - return side != 0 && side != 1; - } + for (ForgeDirection dir : dirs) { + Coord4D sideCoord = coord.getFromSide(dir); - @Override - public int[] getAccessibleSlotsFromSide(int side) - { - if(side == 1) - { - return new int[] {0}; - } - else if(side == 0) - { - return new int[] {1}; - } - else { - return new int[] {2}; - } - } + if (sideCoord.exists(worldObj) && canReplace(sideCoord, true, true)) { + activeNodes.add(sideCoord); + } + } - @Override - public FluidTankInfo[] getTankInfo(ForgeDirection direction) - { - if(direction == ForgeDirection.UP) - { - return new FluidTankInfo[] {fluidTank.getInfo()}; - } + toRemove.add(coord); + break; + } else { + toRemove.add(coord); + } + } - return PipeUtils.EMPTY; - } + for (Coord4D coord : toRemove) { + activeNodes.remove(coord); + usedNodes.add(coord); + } + } - @Override - public void setFluidStack(FluidStack fluidStack, Object... data) - { - fluidTank.setFluid(fluidStack); - } + public boolean canReplace(Coord4D coord, boolean checkNodes, boolean isPathfinding) { + if (checkNodes && usedNodes.contains(coord)) { + return false; + } - @Override - public FluidStack getFluidStack(Object... data) - { - return fluidTank.getFluid(); - } + if (coord.isAirBlock(worldObj) || MekanismUtils.isDeadFluid(worldObj, coord)) { + return true; + } - @Override - public boolean hasTank(Object... data) - { - return true; - } + if (MekanismUtils.isFluid(worldObj, coord)) { + return isPathfinding; + } - @Override - public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) - { - if(fluidTank.getFluid() != null && fluidTank.getFluid().getFluid() == resource.getFluid() && from == ForgeDirection.UP) - { - return drain(from, resource.amount, doDrain); - } + return coord.getBlock(worldObj).isReplaceable( + worldObj, coord.xCoord, coord.yCoord, coord.zCoord + ); + } - return null; - } + @Override + public void handlePacketData(ByteBuf dataStream) { + super.handlePacketData(dataStream); - @Override - public int fill(ForgeDirection from, FluidStack resource, boolean doFill) - { - if(from == ForgeDirection.UP && resource.getFluid().canBePlacedInWorld()) - { - return fluidTank.fill(resource, true); - } - - return 0; - } + if (worldObj.isRemote) { + finishedCalc = dataStream.readBoolean(); + controlType = RedstoneControl.values()[dataStream.readInt()]; - @Override - public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) - { - return null; - } + if (dataStream.readInt() == 1) { + fluidTank.setFluid( + new FluidStack(dataStream.readInt(), dataStream.readInt()) + ); + } else { + fluidTank.setFluid(null); + } - @Override - public boolean canFill(ForgeDirection from, Fluid fluid) - { - return from == ForgeDirection.UP && fluid.canBePlacedInWorld(); - } + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } - @Override - public boolean canDrain(ForgeDirection from, Fluid fluid) - { - return false; - } - - @Override - public boolean onSneakRightClick(EntityPlayer player, int side) - { - activeNodes.clear(); - usedNodes.clear(); - finishedCalc = false; - - player.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + LangUtils.localize("tooltip.configurator.plenisherReset"))); + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); - return true; - } + data.add(finishedCalc); + data.add(controlType.ordinal()); - @Override - public boolean onRightClick(EntityPlayer player, int side) - { - return false; - } + if (fluidTank.getFluid() != null) { + data.add(1); + data.add(fluidTank.getFluid().getFluidID()); + data.add(fluidTank.getFluid().amount); + } else { + data.add(0); + } - private static final String[] methods = new String[] {"reset"}; + return data; + } - @Override - public String[] getMethods() - { - return methods; - } + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); - @Override - public Object[] invoke(int method, Object[] arguments) throws Exception - { - switch(method) - { + nbtTags.setInteger("operatingTicks", operatingTicks); + nbtTags.setBoolean("finishedCalc", finishedCalc); + nbtTags.setInteger("controlType", controlType.ordinal()); + + if (fluidTank.getFluid() != null) { + nbtTags.setTag("fluidTank", fluidTank.writeToNBT(new NBTTagCompound())); + } + + NBTTagList activeList = new NBTTagList(); + + for (Coord4D wrapper : activeNodes) { + NBTTagCompound tagCompound = new NBTTagCompound(); + wrapper.write(tagCompound); + activeList.appendTag(tagCompound); + } + + if (activeList.tagCount() != 0) { + nbtTags.setTag("activeNodes", activeList); + } + + NBTTagList usedList = new NBTTagList(); + + for (Coord4D obj : usedNodes) { + activeList.appendTag(obj.write(new NBTTagCompound())); + } + + if (activeList.tagCount() != 0) { + nbtTags.setTag("usedNodes", usedList); + } + } + + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); + + operatingTicks = nbtTags.getInteger("operatingTicks"); + finishedCalc = nbtTags.getBoolean("finishedCalc"); + controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + + if (nbtTags.hasKey("fluidTank")) { + fluidTank.readFromNBT(nbtTags.getCompoundTag("fluidTank")); + } + + if (nbtTags.hasKey("activeNodes")) { + NBTTagList tagList = nbtTags.getTagList("activeNodes", NBT.TAG_COMPOUND); + + for (int i = 0; i < tagList.tagCount(); i++) { + activeNodes.add(Coord4D.read((NBTTagCompound) tagList.getCompoundTagAt(i)) + ); + } + } + + if (nbtTags.hasKey("usedNodes")) { + NBTTagList tagList = nbtTags.getTagList("usedNodes", NBT.TAG_COMPOUND); + + for (int i = 0; i < tagList.tagCount(); i++) { + usedNodes.add(Coord4D.read((NBTTagCompound) tagList.getCompoundTagAt(i))); + } + } + } + + @Override + public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { + if (slotID == 1) { + return false; + } else if (slotID == 0) { + return FluidContainerRegistry.isFilledContainer(itemstack); + } else if (slotID == 2) { + return ChargeUtils.canBeDischarged(itemstack); + } + + return false; + } + + @Override + public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { + if (slotID == 2) { + return ChargeUtils.canBeOutputted(itemstack, false); + } else if (slotID == 1) { + return true; + } + + return false; + } + + @Override + public EnumSet getConsumingSides() { + return EnumSet.of(ForgeDirection.getOrientation(facing).getOpposite()); + } + + @Override + public boolean canSetFacing(int side) { + return side != 0 && side != 1; + } + + @Override + public int[] getAccessibleSlotsFromSide(int side) { + if (side == 1) { + return new int[] { 0 }; + } else if (side == 0) { + return new int[] { 1 }; + } else { + return new int[] { 2 }; + } + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection direction) { + if (direction == ForgeDirection.UP) { + return new FluidTankInfo[] { fluidTank.getInfo() }; + } + + return PipeUtils.EMPTY; + } + + @Override + public void setFluidStack(FluidStack fluidStack, Object... data) { + fluidTank.setFluid(fluidStack); + } + + @Override + public FluidStack getFluidStack(Object... data) { + return fluidTank.getFluid(); + } + + @Override + public boolean hasTank(Object... data) { + return true; + } + + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + if (fluidTank.getFluid() != null + && fluidTank.getFluid().getFluid() == resource.getFluid() + && from == ForgeDirection.UP) { + return drain(from, resource.amount, doDrain); + } + + return null; + } + + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { + if (from == ForgeDirection.UP && resource.getFluid().canBePlacedInWorld()) { + return fluidTank.fill(resource, true); + } + + return 0; + } + + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { + return null; + } + + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + return from == ForgeDirection.UP && fluid.canBePlacedInWorld(); + } + + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + return false; + } + + @Override + public boolean onSneakRightClick(EntityPlayer player, int side) { + activeNodes.clear(); + usedNodes.clear(); + finishedCalc = false; + + player.addChatMessage(new ChatComponentText( + EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + + LangUtils.localize("tooltip.configurator.plenisherReset") + )); + + return true; + } + + @Override + public boolean onRightClick(EntityPlayer player, int side) { + return false; + } + + private static final String[] methods = new String[] { "reset" }; + + @Override + public String[] getMethods() { + return methods; + } + + @Override + public Object[] invoke(int method, Object[] arguments) throws Exception { + switch (method) { case 0: activeNodes.clear(); usedNodes.clear(); finishedCalc = false; - return new Object[]{"Plenisher calculation reset."}; + return new Object[] { "Plenisher calculation reset." }; default: throw new NoSuchMethodException(); } } - - @Override - public TileComponentUpgrade getComponent() - { - return upgradeComponent; - } - - @Override - public void recalculateUpgradables(Upgrade upgrade) - { - super.recalculateUpgradables(upgrade); - switch(upgrade) - { - case SPEED: - ticksRequired = MekanismUtils.getTicks(this, BASE_TICKS_REQUIRED); - case ENERGY: - energyPerTick = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK); - maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY); - default: - break; - } - } - - @Override - public RedstoneControl getControlType() - { - return controlType; - } + @Override + public TileComponentUpgrade getComponent() { + return upgradeComponent; + } - @Override - public void setControlType(RedstoneControl type) - { - controlType = type; - } + @Override + public void recalculateUpgradables(Upgrade upgrade) { + super.recalculateUpgradables(upgrade); - @Override - public boolean canPulse() - { - return false; - } - - @Override - public TileComponentSecurity getSecurity() - { - return securityComponent; - } + switch (upgrade) { + case SPEED: + ticksRequired = MekanismUtils.getTicks(this, BASE_TICKS_REQUIRED); + case ENERGY: + energyPerTick + = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK); + maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY); + default: + break; + } + } + + @Override + public RedstoneControl getControlType() { + return controlType; + } + + @Override + public void setControlType(RedstoneControl type) { + controlType = type; + } + + @Override + public boolean canPulse() { + return false; + } + + @Override + public TileComponentSecurity getSecurity() { + return securityComponent; + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityFormulaicAssemblicator.java b/src/main/java/mekanism/common/tile/TileEntityFormulaicAssemblicator.java index b8d3d8875..795d9eaac 100644 --- a/src/main/java/mekanism/common/tile/TileEntityFormulaicAssemblicator.java +++ b/src/main/java/mekanism/common/tile/TileEntityFormulaicAssemblicator.java @@ -1,9 +1,8 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import io.netty.buffer.ByteBuf; import mekanism.api.EnumColor; import mekanism.api.IConfigCardAccess; import mekanism.api.MekanismConfig.usage; @@ -30,712 +29,623 @@ import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock implements ISideConfiguration, IUpgradeTile, IRedstoneControl, IConfigCardAccess, ISecurityTile -{ - public InventoryCrafting dummyInv = MekanismUtils.getDummyCraftingInv(); - - public double BASE_ENERGY_PER_TICK = usage.metallurgicInfuserUsage; +public class TileEntityFormulaicAssemblicator extends TileEntityElectricBlock + implements ISideConfiguration, IUpgradeTile, IRedstoneControl, IConfigCardAccess, + ISecurityTile { + public InventoryCrafting dummyInv = MekanismUtils.getDummyCraftingInv(); - public double energyPerTick = BASE_ENERGY_PER_TICK; + public double BASE_ENERGY_PER_TICK = usage.metallurgicInfuserUsage; - public int BASE_TICKS_REQUIRED = 40; + public double energyPerTick = BASE_ENERGY_PER_TICK; - public int ticksRequired = BASE_TICKS_REQUIRED; - - public int operatingTicks; - - public boolean autoMode = false; - - public boolean isRecipe = false; - - public int pulseOperations; - - public RecipeFormula formula; - - public RedstoneControl controlType = RedstoneControl.DISABLED; - - public TileComponentUpgrade upgradeComponent; - public TileComponentEjector ejectorComponent; - public TileComponentConfig configComponent; - public TileComponentSecurity securityComponent; - - public ItemStack lastFormulaStack; - public boolean needsFormulaUpdate = false; - - public TileEntityFormulaicAssemblicator() - { - super("FormulaicAssemblicator", MachineType.FORMULAIC_ASSEMBLICATOR.baseEnergy); - - configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY); - - configComponent.addOutput(TransmissionType.ITEM, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY)); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Input", EnumColor.DARK_RED, - new int[] {3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20})); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Output", EnumColor.DARK_BLUE, new int[] {21, 22, 23, 24, 25, 26})); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Energy", EnumColor.DARK_GREEN, new int[] {1})); - - configComponent.setConfig(TransmissionType.ITEM, new byte[] {0, 0, 0, 3, 1, 2}); - configComponent.setInputConfig(TransmissionType.ENERGY); - - inventory = new ItemStack[36]; - - upgradeComponent = new TileComponentUpgrade(this, 0); - - ejectorComponent = new TileComponentEjector(this); - ejectorComponent.setOutputData(TransmissionType.ITEM, configComponent.getOutputs(TransmissionType.ITEM).get(2)); - - securityComponent = new TileComponentSecurity(this); - } - - @Override - public void onUpdate() - { - super.onUpdate(); - - if(!worldObj.isRemote) - { - ChargeUtils.discharge(1, this); - - if(controlType != RedstoneControl.PULSE) - { - pulseOperations = 0; - } - else if(MekanismUtils.canFunction(this)) - { - pulseOperations++; - } - - RecipeFormula prev = formula; - - if(inventory[2] != null && inventory[2].getItem() instanceof ItemCraftingFormula) - { - ItemCraftingFormula item = (ItemCraftingFormula)inventory[2].getItem(); - - if(formula == null || lastFormulaStack != inventory[2]) - { - loadFormula(); - } - } - else { - formula = null; - } - - if(prev != formula) - { - needsFormulaUpdate = true; - } - - lastFormulaStack = inventory[2]; - - if(autoMode && formula == null) - { - toggleAutoMode(); - } - - if(autoMode && formula != null && ((controlType == RedstoneControl.PULSE && pulseOperations > 0) || MekanismUtils.canFunction(this))) - { - boolean canOperate = true; - - if(!isRecipe) - { - canOperate = moveItemsToGrid(); - } - - if(canOperate) - { - isRecipe = true; - - if(operatingTicks >= ticksRequired) - { - if(doSingleCraft()) - { - operatingTicks = 0; - - if(pulseOperations > 0) - { - pulseOperations--; - } - - ejectorComponent.outputItems(); - } - } - else { - if(getEnergy() >= energyPerTick) - { - operatingTicks++; - setEnergy(getEnergy() - energyPerTick); - } - } - } - else { - operatingTicks = 0; - } - } - else { - operatingTicks = 0; - } - } - } - - public void loadFormula() - { - ItemCraftingFormula item = (ItemCraftingFormula)inventory[2].getItem(); - - if(item.getInventory(inventory[2]) != null && !item.isInvalid(inventory[2])) - { - RecipeFormula itemFormula = new RecipeFormula(worldObj, item.getInventory(inventory[2])); - - if(itemFormula.isValidFormula(worldObj)) - { - if(formula != null && !formula.isFormulaEqual(worldObj, itemFormula)) - { - formula = itemFormula; - operatingTicks = 0; - } - else if(formula == null) - { - formula = itemFormula; - } - } - else { - formula = null; - item.setInvalid(inventory[2], true); - } - } - else { - formula = null; - } - } - - @Override - public void markDirty() - { - super.markDirty(); - - if(worldObj != null && !worldObj.isRemote) - { - if(formula == null) - { - for(int i = 0; i < 9; i++) - { - dummyInv.setInventorySlotContents(i, inventory[27+i]); - } - - isRecipe = MekanismUtils.findMatchingRecipe(dummyInv, worldObj) != null; - } - else { - isRecipe = formula.matches(worldObj, inventory, 27); - } - } - } - - private boolean doSingleCraft() - { - for(int i = 0; i < 9; i++) - { - dummyInv.setInventorySlotContents(i, inventory[27+i]); - } - - ItemStack output = MekanismUtils.findMatchingRecipe(dummyInv, worldObj); - - if(output != null && tryMoveToOutput(output, false)) - { - tryMoveToOutput(output, true); - - for(int i = 27; i <= 35; i++) - { - if(inventory[i] != null) - { - ItemStack stack = inventory[i]; - - inventory[i].stackSize--; - - if(inventory[i].stackSize == 0) - { - inventory[i] = null; - } - - if(stack.stackSize == 0 && stack.getItem().hasContainerItem(stack)) - { - ItemStack container = stack.getItem().getContainerItem(stack); + public int BASE_TICKS_REQUIRED = 40; - if(container != null && container.isItemStackDamageable() && container.getItemDamage() > container.getMaxDamage()) - { - container = null; - } + public int ticksRequired = BASE_TICKS_REQUIRED; - if(container != null && !stack.getItem().doesContainerItemLeaveCraftingGrid(stack)) - { - if(!stack.getItem().doesContainerItemLeaveCraftingGrid(stack)) - { - inventory[i] = container.copy(); - } - else { - boolean move = tryMoveToOutput(container.copy(), false); - - if(move) - { - tryMoveToOutput(container.copy(), true); - } - - inventory[i] = move ? null : container.copy(); - } - } - } - } - } - - if(formula != null) - { - moveItemsToGrid(); - } - - markDirty(); - - return true; - } - - return false; - } - - private boolean craftSingle() - { - if(formula != null) - { - boolean canOperate = true; - - if(!formula.matches(worldObj, inventory, 27)) - { - canOperate = moveItemsToGrid(); - } - - if(canOperate) - { - return doSingleCraft(); - } - } - else { - return doSingleCraft(); - } - - return false; - } - - private boolean moveItemsToGrid() - { - boolean ret = true; - - for(int i = 27; i <= 35; i++) - { - if(formula.isIngredientInPos(worldObj, inventory[i], i-27)) - { - continue; - } - - if(inventory[i] != null) - { - inventory[i] = tryMoveToInput(inventory[i]); - markDirty(); - - if(inventory[i] != null) - { - ret = false; - } - } - else { - boolean found = false; - - for(int j = 3; j <= 20; j++) - { - if(inventory[j] != null && formula.isIngredientInPos(worldObj, inventory[j], i-27)) - { - inventory[i] = StackUtils.size(inventory[j], 1); - inventory[j].stackSize--; - - if(inventory[j].stackSize == 0) - { - inventory[j] = null; - } - - markDirty(); - found = true; - - break; - } - } - - if(!found) - { - ret = false; - } - } - } - - return ret; - } - - private void craftAll() - { - while(craftSingle()); - } - - private void moveItemsToInput(boolean forcePush) - { - for(int i = 27; i <= 35; i++) - { - if(inventory[i] != null && (forcePush || (formula != null && !formula.isIngredientInPos(worldObj, inventory[i], i-27)))) - { - inventory[i] = tryMoveToInput(inventory[i]); - } - } - - markDirty(); - } - - private void toggleAutoMode() - { - if(autoMode) - { - operatingTicks = 0; - autoMode = false; - } - else if(formula != null) - { - moveItemsToInput(false); - autoMode = true; - } - - markDirty(); - } - - private ItemStack tryMoveToInput(ItemStack stack) - { - stack = stack.copy(); - - for(int i = 3; i <= 20; i++) - { - if(inventory[i] == null) - { - inventory[i] = stack; - - return null; - } + public int operatingTicks; + + public boolean autoMode = false; + + public boolean isRecipe = false; + + public int pulseOperations; + + public RecipeFormula formula; + + public RedstoneControl controlType = RedstoneControl.DISABLED; + + public TileComponentUpgrade upgradeComponent; + public TileComponentEjector ejectorComponent; + public TileComponentConfig configComponent; + public TileComponentSecurity securityComponent; + + public ItemStack lastFormulaStack; + public boolean needsFormulaUpdate = false; + + public TileEntityFormulaicAssemblicator() { + super("FormulaicAssemblicator", MachineType.FORMULAIC_ASSEMBLICATOR.baseEnergy); + + configComponent = new TileComponentConfig( + this, TransmissionType.ITEM, TransmissionType.ENERGY + ); + + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY) + ); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData( + "Input", + EnumColor.DARK_RED, + new int[] { + 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 } + ) + ); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData( + "Output", EnumColor.DARK_BLUE, new int[] { 21, 22, 23, 24, 25, 26 } + ) + ); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("Energy", EnumColor.DARK_GREEN, new int[] { 1 }) + ); + + configComponent.setConfig(TransmissionType.ITEM, new byte[] { 0, 0, 0, 3, 1, 2 }); + configComponent.setInputConfig(TransmissionType.ENERGY); + + inventory = new ItemStack[36]; + + upgradeComponent = new TileComponentUpgrade(this, 0); + + ejectorComponent = new TileComponentEjector(this); + ejectorComponent.setOutputData( + TransmissionType.ITEM, + configComponent.getOutputs(TransmissionType.ITEM).get(2) + ); + + securityComponent = new TileComponentSecurity(this); + } + + @Override + public void onUpdate() { + super.onUpdate(); + + if (!worldObj.isRemote) { + ChargeUtils.discharge(1, this); + + if (controlType != RedstoneControl.PULSE) { + pulseOperations = 0; + } else if (MekanismUtils.canFunction(this)) { + pulseOperations++; + } + + RecipeFormula prev = formula; + + if (inventory[2] != null + && inventory[2].getItem() instanceof ItemCraftingFormula) { + ItemCraftingFormula item = (ItemCraftingFormula) inventory[2].getItem(); + + if (formula == null || lastFormulaStack != inventory[2]) { + loadFormula(); + } + } else { + formula = null; + } + + if (prev != formula) { + needsFormulaUpdate = true; + } + + lastFormulaStack = inventory[2]; + + if (autoMode && formula == null) { + toggleAutoMode(); + } + + if (autoMode && formula != null + && ((controlType == RedstoneControl.PULSE && pulseOperations > 0) + || MekanismUtils.canFunction(this))) { + boolean canOperate = true; + + if (!isRecipe) { + canOperate = moveItemsToGrid(); + } + + if (canOperate) { + isRecipe = true; + + if (operatingTicks >= ticksRequired) { + if (doSingleCraft()) { + operatingTicks = 0; + + if (pulseOperations > 0) { + pulseOperations--; + } + + ejectorComponent.outputItems(); + } + } else { + if (getEnergy() >= energyPerTick) { + operatingTicks++; + setEnergy(getEnergy() - energyPerTick); + } + } + } else { + operatingTicks = 0; + } + } else { + operatingTicks = 0; + } + } + } + + public void loadFormula() { + ItemCraftingFormula item = (ItemCraftingFormula) inventory[2].getItem(); + + if (item.getInventory(inventory[2]) != null && !item.isInvalid(inventory[2])) { + RecipeFormula itemFormula + = new RecipeFormula(worldObj, item.getInventory(inventory[2])); + + if (itemFormula.isValidFormula(worldObj)) { + if (formula != null && !formula.isFormulaEqual(worldObj, itemFormula)) { + formula = itemFormula; + operatingTicks = 0; + } else if (formula == null) { + formula = itemFormula; + } + } else { + formula = null; + item.setInvalid(inventory[2], true); + } + } else { + formula = null; + } + } + + @Override + public void markDirty() { + super.markDirty(); + + if (worldObj != null && !worldObj.isRemote) { + if (formula == null) { + for (int i = 0; i < 9; i++) { + dummyInv.setInventorySlotContents(i, inventory[27 + i]); + } + + isRecipe = MekanismUtils.findMatchingRecipe(dummyInv, worldObj) != null; + } else { + isRecipe = formula.matches(worldObj, inventory, 27); + } + } + } + + private boolean doSingleCraft() { + for (int i = 0; i < 9; i++) { + dummyInv.setInventorySlotContents(i, inventory[27 + i]); + } + + ItemStack output = MekanismUtils.findMatchingRecipe(dummyInv, worldObj); + + if (output != null && tryMoveToOutput(output, false)) { + tryMoveToOutput(output, true); + + for (int i = 27; i <= 35; i++) { + if (inventory[i] != null) { + ItemStack stack = inventory[i]; + + inventory[i].stackSize--; + + if (inventory[i].stackSize == 0) { + inventory[i] = null; + } + + if (stack.stackSize == 0 && stack.getItem().hasContainerItem(stack)) { + ItemStack container = stack.getItem().getContainerItem(stack); + + if (container != null && container.isItemStackDamageable() + && container.getItemDamage() > container.getMaxDamage()) { + container = null; + } + + if (container != null + && !stack.getItem().doesContainerItemLeaveCraftingGrid(stack + )) { + if (!stack.getItem().doesContainerItemLeaveCraftingGrid(stack + )) { + inventory[i] = container.copy(); + } else { + boolean move = tryMoveToOutput(container.copy(), false); + + if (move) { + tryMoveToOutput(container.copy(), true); + } + + inventory[i] = move ? null : container.copy(); + } + } + } + } + } + + if (formula != null) { + moveItemsToGrid(); + } + + markDirty(); + + return true; + } + + return false; + } + + private boolean craftSingle() { + if (formula != null) { + boolean canOperate = true; + + if (!formula.matches(worldObj, inventory, 27)) { + canOperate = moveItemsToGrid(); + } + + if (canOperate) { + return doSingleCraft(); + } + } else { + return doSingleCraft(); + } + + return false; + } + + private boolean moveItemsToGrid() { + boolean ret = true; + + for (int i = 27; i <= 35; i++) { + if (formula.isIngredientInPos(worldObj, inventory[i], i - 27)) { + continue; + } + + if (inventory[i] != null) { + inventory[i] = tryMoveToInput(inventory[i]); + markDirty(); + + if (inventory[i] != null) { + ret = false; + } + } else { + boolean found = false; + + for (int j = 3; j <= 20; j++) { + if (inventory[j] != null + && formula.isIngredientInPos(worldObj, inventory[j], i - 27)) { + inventory[i] = StackUtils.size(inventory[j], 1); + inventory[j].stackSize--; + + if (inventory[j].stackSize == 0) { + inventory[j] = null; + } + + markDirty(); + found = true; + + break; + } + } + + if (!found) { + ret = false; + } + } + } + + return ret; + } + + private void craftAll() { + while (craftSingle()) + ; + } + + private void moveItemsToInput(boolean forcePush) { + for (int i = 27; i <= 35; i++) { + if (inventory[i] != null + && (forcePush + || (formula != null + && !formula.isIngredientInPos(worldObj, inventory[i], i - 27)))) { + inventory[i] = tryMoveToInput(inventory[i]); + } + } + + markDirty(); + } + + private void toggleAutoMode() { + if (autoMode) { + operatingTicks = 0; + autoMode = false; + } else if (formula != null) { + moveItemsToInput(false); + autoMode = true; + } + + markDirty(); + } + + private ItemStack tryMoveToInput(ItemStack stack) { + stack = stack.copy(); + + for (int i = 3; i <= 20; i++) { + if (inventory[i] == null) { + inventory[i] = stack; + + return null; + } else if(InventoryUtils.areItemsStackable(stack, inventory[i]) && inventory[i].stackSize < inventory[i].getMaxStackSize()) { - int toUse = Math.min(stack.stackSize, inventory[i].getMaxStackSize()-inventory[i].stackSize); - - inventory[i].stackSize += toUse; - stack.stackSize -= toUse; - - if(stack.stackSize == 0) - { - return null; - } - } - } - - return stack; - } - - private boolean tryMoveToOutput(ItemStack stack, boolean doMove) - { - stack = stack.copy(); - - for(int i = 21; i <= 26; i++) - { - if(inventory[i] == null) - { - if(doMove) - { - inventory[i] = stack; - } - - return true; - } + int toUse = Math.min( + stack.stackSize, + inventory[i].getMaxStackSize() - inventory[i].stackSize + ); + + inventory[i].stackSize += toUse; + stack.stackSize -= toUse; + + if (stack.stackSize == 0) { + return null; + } + } + } + + return stack; + } + + private boolean tryMoveToOutput(ItemStack stack, boolean doMove) { + stack = stack.copy(); + + for (int i = 21; i <= 26; i++) { + if (inventory[i] == null) { + if (doMove) { + inventory[i] = stack; + } + + return true; + } else if(InventoryUtils.areItemsStackable(stack, inventory[i]) && inventory[i].stackSize < inventory[i].getMaxStackSize()) { - int toUse = Math.min(stack.stackSize, inventory[i].getMaxStackSize()-inventory[i].stackSize); - - if(doMove) - { - inventory[i].stackSize += toUse; - } - - stack.stackSize -= toUse; - - if(stack.stackSize == 0) - { - return true; - } - } - } - - return false; - } - - private void encodeFormula() - { - if(inventory[2] != null && inventory[2].getItem() instanceof ItemCraftingFormula) - { - ItemCraftingFormula item = (ItemCraftingFormula)inventory[2].getItem(); - - if(item.getInventory(inventory[2]) == null) - { - RecipeFormula formula = new RecipeFormula(worldObj, inventory, 27); - - if(formula.isValidFormula(worldObj)) - { - item.setInventory(inventory[2], formula.input); - } - } - } - } - - @Override - public boolean canSetFacing(int side) - { - return side != 0 && side != 1; - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) - { - return configComponent.getOutput(TransmissionType.ITEM, side, facing).availableSlots; - } - - @Override - public boolean canExtractItem(int slotID, ItemStack itemstack, int side) - { - if(slotID == 1) - { - return ChargeUtils.canBeOutputted(itemstack, false); - } - else if(slotID >= 21 && slotID <= 26) - { - return true; - } + int toUse = Math.min( + stack.stackSize, + inventory[i].getMaxStackSize() - inventory[i].stackSize + ); - return false; - } + if (doMove) { + inventory[i].stackSize += toUse; + } - @Override - public boolean isItemValidForSlot(int slotID, ItemStack itemstack) - { - if(slotID >= 3 && slotID <= 20) - { - if(formula == null) - { - return true; - } - else { - return formula.isIngredient(worldObj, itemstack); - } - } - else if(slotID == 1) - { - return ChargeUtils.canBeDischarged(itemstack); - } + stack.stackSize -= toUse; - return false; - } + if (stack.stackSize == 0) { + return true; + } + } + } - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - autoMode = nbtTags.getBoolean("autoMode"); - operatingTicks = nbtTags.getInteger("operatingTicks"); - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - pulseOperations = nbtTags.getInteger("pulseOperations"); - } + return false; + } - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); + private void encodeFormula() { + if (inventory[2] != null + && inventory[2].getItem() instanceof ItemCraftingFormula) { + ItemCraftingFormula item = (ItemCraftingFormula) inventory[2].getItem(); - nbtTags.setBoolean("autoMode", autoMode); - nbtTags.setInteger("operatingTicks", operatingTicks); - nbtTags.setInteger("controlType", controlType.ordinal()); - nbtTags.setInteger("pulseOperations", pulseOperations); - } - - @Override - public void handlePacketData(ByteBuf dataStream) - { - if(!worldObj.isRemote) - { - int type = dataStream.readInt(); - - if(type == 0) - { - toggleAutoMode(); - } - else if(type == 1) - { - encodeFormula(); - } - else if(type == 2) - { - craftSingle(); - } - else if(type == 3) - { - craftAll(); - } - else if(type == 4) - { - if(formula != null) - { - moveItemsToGrid(); - } - else { - moveItemsToInput(true); - } - } - - return; - } - - super.handlePacketData(dataStream); - - if(worldObj.isRemote) - { - autoMode = dataStream.readBoolean(); - operatingTicks = dataStream.readInt(); - controlType = RedstoneControl.values()[dataStream.readInt()]; - isRecipe = dataStream.readBoolean(); - - if(dataStream.readBoolean()) - { - if(dataStream.readBoolean()) - { - ItemStack[] inv = new ItemStack[9]; - - for(int i = 0; i < 9; i++) - { - if(dataStream.readBoolean()) - { - inv[i] = PacketHandler.readStack(dataStream); - } - } - - formula = new RecipeFormula(worldObj, inv); - } - else { - formula = null; - } - } - } - } + if (item.getInventory(inventory[2]) == null) { + RecipeFormula formula = new RecipeFormula(worldObj, inventory, 27); - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); - - data.add(autoMode); - data.add(operatingTicks); - data.add(controlType.ordinal()); - data.add(isRecipe); - - if(needsFormulaUpdate) - { - data.add(true); - - if(formula != null) - { - data.add(true); - - for(int i = 0; i < 9; i++) - { - if(formula.input[i] != null) - { - data.add(true); - data.add(formula.input[i]); - } - else { - data.add(false); - } - } - } - else { - data.add(false); - } - } - else { - data.add(false); - } - - needsFormulaUpdate = false; - - return data; - } - - @Override - public RedstoneControl getControlType() - { - return controlType; - } + if (formula.isValidFormula(worldObj)) { + item.setInventory(inventory[2], formula.input); + } + } + } + } - @Override - public void setControlType(RedstoneControl type) - { - controlType = type; - MekanismUtils.saveChunk(this); - } + @Override + public boolean canSetFacing(int side) { + return side != 0 && side != 1; + } - @Override - public boolean canPulse() - { - return true; - } - - @Override - public TileComponentConfig getConfig() - { - return configComponent; - } + @Override + public int[] getAccessibleSlotsFromSide(int side) { + return configComponent.getOutput(TransmissionType.ITEM, side, facing) + .availableSlots; + } - @Override - public int getOrientation() - { - return facing; - } - - @Override - public TileComponentUpgrade getComponent() - { - return upgradeComponent; - } - - @Override - public TileComponentEjector getEjector() - { - return ejectorComponent; - } - - @Override - public TileComponentSecurity getSecurity() - { - return securityComponent; - } - - @Override - public void recalculateUpgradables(Upgrade upgrade) - { - super.recalculateUpgradables(upgrade); + @Override + public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { + if (slotID == 1) { + return ChargeUtils.canBeOutputted(itemstack, false); + } else if (slotID >= 21 && slotID <= 26) { + return true; + } - switch(upgrade) - { - case SPEED: - ticksRequired = MekanismUtils.getTicks(this, BASE_TICKS_REQUIRED); - case ENERGY: - energyPerTick = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK); - maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY); - default: - break; - } - } + return false; + } + + @Override + public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { + if (slotID >= 3 && slotID <= 20) { + if (formula == null) { + return true; + } else { + return formula.isIngredient(worldObj, itemstack); + } + } else if (slotID == 1) { + return ChargeUtils.canBeDischarged(itemstack); + } + + return false; + } + + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); + + autoMode = nbtTags.getBoolean("autoMode"); + operatingTicks = nbtTags.getInteger("operatingTicks"); + controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + pulseOperations = nbtTags.getInteger("pulseOperations"); + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); + + nbtTags.setBoolean("autoMode", autoMode); + nbtTags.setInteger("operatingTicks", operatingTicks); + nbtTags.setInteger("controlType", controlType.ordinal()); + nbtTags.setInteger("pulseOperations", pulseOperations); + } + + @Override + public void handlePacketData(ByteBuf dataStream) { + if (!worldObj.isRemote) { + int type = dataStream.readInt(); + + if (type == 0) { + toggleAutoMode(); + } else if (type == 1) { + encodeFormula(); + } else if (type == 2) { + craftSingle(); + } else if (type == 3) { + craftAll(); + } else if (type == 4) { + if (formula != null) { + moveItemsToGrid(); + } else { + moveItemsToInput(true); + } + } + + return; + } + + super.handlePacketData(dataStream); + + if (worldObj.isRemote) { + autoMode = dataStream.readBoolean(); + operatingTicks = dataStream.readInt(); + controlType = RedstoneControl.values()[dataStream.readInt()]; + isRecipe = dataStream.readBoolean(); + + if (dataStream.readBoolean()) { + if (dataStream.readBoolean()) { + ItemStack[] inv = new ItemStack[9]; + + for (int i = 0; i < 9; i++) { + if (dataStream.readBoolean()) { + inv[i] = PacketHandler.readStack(dataStream); + } + } + + formula = new RecipeFormula(worldObj, inv); + } else { + formula = null; + } + } + } + } + + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); + + data.add(autoMode); + data.add(operatingTicks); + data.add(controlType.ordinal()); + data.add(isRecipe); + + if (needsFormulaUpdate) { + data.add(true); + + if (formula != null) { + data.add(true); + + for (int i = 0; i < 9; i++) { + if (formula.input[i] != null) { + data.add(true); + data.add(formula.input[i]); + } else { + data.add(false); + } + } + } else { + data.add(false); + } + } else { + data.add(false); + } + + needsFormulaUpdate = false; + + return data; + } + + @Override + public RedstoneControl getControlType() { + return controlType; + } + + @Override + public void setControlType(RedstoneControl type) { + controlType = type; + MekanismUtils.saveChunk(this); + } + + @Override + public boolean canPulse() { + return true; + } + + @Override + public TileComponentConfig getConfig() { + return configComponent; + } + + @Override + public int getOrientation() { + return facing; + } + + @Override + public TileComponentUpgrade getComponent() { + return upgradeComponent; + } + + @Override + public TileComponentEjector getEjector() { + return ejectorComponent; + } + + @Override + public TileComponentSecurity getSecurity() { + return securityComponent; + } + + @Override + public void recalculateUpgradables(Upgrade upgrade) { + super.recalculateUpgradables(upgrade); + + switch (upgrade) { + case SPEED: + ticksRequired = MekanismUtils.getTicks(this, BASE_TICKS_REQUIRED); + case ENERGY: + energyPerTick + = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK); + maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY); + default: + break; + } + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityFuelwoodHeater.java b/src/main/java/mekanism/common/tile/TileEntityFuelwoodHeater.java index 11976c0b4..38350a166 100644 --- a/src/main/java/mekanism/common/tile/TileEntityFuelwoodHeater.java +++ b/src/main/java/mekanism/common/tile/TileEntityFuelwoodHeater.java @@ -1,9 +1,8 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.IHeatTransfer; import mekanism.api.MekanismConfig.general; @@ -21,264 +20,242 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityFurnace; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityFuelwoodHeater extends TileEntityContainerBlock implements IHeatTransfer, ISecurityTile, IActiveState -{ - public double temperature; - public double heatToAbsorb = 0; - - public int burnTime; - public int maxBurnTime; - - /** Whether or not this machine is in it's active state. */ - public boolean isActive; +public class TileEntityFuelwoodHeater extends TileEntityContainerBlock + implements IHeatTransfer, ISecurityTile, IActiveState { + public double temperature; + public double heatToAbsorb = 0; - /** The client's current active state. */ - public boolean clientActive; - - /** How many ticks must pass until this block's active state can sync with the client. */ - public int updateDelay; - - public double lastEnvironmentLoss; - - public TileComponentSecurity securityComponent = new TileComponentSecurity(this); - - public TileEntityFuelwoodHeater() - { - super("FuelwoodHeater"); - inventory = new ItemStack[1]; - } - - @Override - public void onUpdate() - { - if(worldObj.isRemote && updateDelay > 0) - { - updateDelay--; + public int burnTime; + public int maxBurnTime; - if(updateDelay == 0 && clientActive != isActive) - { - isActive = clientActive; - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } - - if(!worldObj.isRemote) - { - if(updateDelay > 0) - { - updateDelay--; + /** Whether or not this machine is in it's active state. */ + public boolean isActive; - if(updateDelay == 0 && clientActive != isActive) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - } - } - - boolean burning = false; - - if(burnTime > 0) - { - burnTime--; - burning = true; - } - else { - if(inventory[0] != null) - { - maxBurnTime = burnTime = TileEntityFurnace.getItemBurnTime(inventory[0])/2; - - if(burnTime > 0) - { - inventory[0].stackSize--; - - if(inventory[0].stackSize == 0) - { - inventory[0] = inventory[0].getItem().getContainerItem(inventory[0]); - } - - burning = true; - } - } - } - - if(burning) - { - heatToAbsorb += general.heatPerFuelTick; - } - - double[] loss = simulateHeat(); - applyTemperatureChange(); - - lastEnvironmentLoss = loss[1]; - - setActive(burning); - } - } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); + /** The client's current active state. */ + public boolean clientActive; - temperature = nbtTags.getDouble("temperature"); - clientActive = isActive = nbtTags.getBoolean("isActive"); - burnTime = nbtTags.getInteger("burnTime"); - maxBurnTime = nbtTags.getInteger("maxBurnTime"); - } + /** + * How many ticks must pass until this block's active state can sync with the client. + */ + public int updateDelay; - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); + public double lastEnvironmentLoss; - nbtTags.setDouble("temperature", temperature); - nbtTags.setBoolean("isActive", isActive); - nbtTags.setInteger("burnTime", burnTime); - nbtTags.setInteger("maxBurnTime", maxBurnTime); - } - - @Override - public void handlePacketData(ByteBuf dataStream) - { - super.handlePacketData(dataStream); - - if(worldObj.isRemote) - { - temperature = dataStream.readDouble(); - clientActive = dataStream.readBoolean(); - burnTime = dataStream.readInt(); - maxBurnTime = dataStream.readInt(); - - lastEnvironmentLoss = dataStream.readDouble(); - - if(updateDelay == 0 && clientActive != isActive) - { - updateDelay = general.UPDATE_DELAY; - isActive = clientActive; - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } - } + public TileComponentSecurity securityComponent = new TileComponentSecurity(this); - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); - - data.add(temperature); - data.add(isActive); - data.add(burnTime); - data.add(maxBurnTime); - - data.add(lastEnvironmentLoss); - - return data; - } - - @Override - public boolean canSetFacing(int side) - { - return side != 0 && side != 1; - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) - { - return new int[] {0}; - } - - @Override - public void setActive(boolean active) - { - isActive = active; + public TileEntityFuelwoodHeater() { + super("FuelwoodHeater"); + inventory = new ItemStack[1]; + } - if(clientActive != active && updateDelay == 0) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); + @Override + public void onUpdate() { + if (worldObj.isRemote && updateDelay > 0) { + updateDelay--; - updateDelay = 10; - clientActive = active; - } - } - - @Override - public boolean getActive() - { - return isActive; - } - - @Override - public boolean renderUpdate() - { - return false; - } + if (updateDelay == 0 && clientActive != isActive) { + isActive = clientActive; + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } - @Override - public boolean lightUpdate() - { - return true; - } - - @Override - public double getTemp() - { - return temperature; - } + if (!worldObj.isRemote) { + if (updateDelay > 0) { + updateDelay--; - @Override - public double getInverseConductionCoefficient() - { - return 5; - } + if (updateDelay == 0 && clientActive != isActive) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + } + } - @Override - public double getInsulationCoefficient(ForgeDirection side) - { - return 1000; - } + boolean burning = false; - @Override - public void transferHeatTo(double heat) - { - heatToAbsorb += heat; - } + if (burnTime > 0) { + burnTime--; + burning = true; + } else { + if (inventory[0] != null) { + maxBurnTime = burnTime + = TileEntityFurnace.getItemBurnTime(inventory[0]) / 2; - @Override - public double[] simulateHeat() - { - return HeatUtils.simulate(this); - } + if (burnTime > 0) { + inventory[0].stackSize--; - @Override - public double applyTemperatureChange() - { - temperature += heatToAbsorb; - heatToAbsorb = 0; - - return temperature; - } + if (inventory[0].stackSize == 0) { + inventory[0] + = inventory[0].getItem().getContainerItem(inventory[0]); + } - @Override - public boolean canConnectHeat(ForgeDirection side) - { - return true; - } + burning = true; + } + } + } - @Override - public IHeatTransfer getAdjacent(ForgeDirection side) - { - TileEntity adj = Coord4D.get(this).getFromSide(side).getTileEntity(worldObj); - - if(adj instanceof IHeatTransfer) - { - return (IHeatTransfer)adj; - } - - return null; - } - - @Override - public TileComponentSecurity getSecurity() - { - return securityComponent; - } + if (burning) { + heatToAbsorb += general.heatPerFuelTick; + } + + double[] loss = simulateHeat(); + applyTemperatureChange(); + + lastEnvironmentLoss = loss[1]; + + setActive(burning); + } + } + + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); + + temperature = nbtTags.getDouble("temperature"); + clientActive = isActive = nbtTags.getBoolean("isActive"); + burnTime = nbtTags.getInteger("burnTime"); + maxBurnTime = nbtTags.getInteger("maxBurnTime"); + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); + + nbtTags.setDouble("temperature", temperature); + nbtTags.setBoolean("isActive", isActive); + nbtTags.setInteger("burnTime", burnTime); + nbtTags.setInteger("maxBurnTime", maxBurnTime); + } + + @Override + public void handlePacketData(ByteBuf dataStream) { + super.handlePacketData(dataStream); + + if (worldObj.isRemote) { + temperature = dataStream.readDouble(); + clientActive = dataStream.readBoolean(); + burnTime = dataStream.readInt(); + maxBurnTime = dataStream.readInt(); + + lastEnvironmentLoss = dataStream.readDouble(); + + if (updateDelay == 0 && clientActive != isActive) { + updateDelay = general.UPDATE_DELAY; + isActive = clientActive; + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } + } + + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); + + data.add(temperature); + data.add(isActive); + data.add(burnTime); + data.add(maxBurnTime); + + data.add(lastEnvironmentLoss); + + return data; + } + + @Override + public boolean canSetFacing(int side) { + return side != 0 && side != 1; + } + + @Override + public int[] getAccessibleSlotsFromSide(int side) { + return new int[] { 0 }; + } + + @Override + public void setActive(boolean active) { + isActive = active; + + if (clientActive != active && updateDelay == 0) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + + updateDelay = 10; + clientActive = active; + } + } + + @Override + public boolean getActive() { + return isActive; + } + + @Override + public boolean renderUpdate() { + return false; + } + + @Override + public boolean lightUpdate() { + return true; + } + + @Override + public double getTemp() { + return temperature; + } + + @Override + public double getInverseConductionCoefficient() { + return 5; + } + + @Override + public double getInsulationCoefficient(ForgeDirection side) { + return 1000; + } + + @Override + public void transferHeatTo(double heat) { + heatToAbsorb += heat; + } + + @Override + public double[] simulateHeat() { + return HeatUtils.simulate(this); + } + + @Override + public double applyTemperatureChange() { + temperature += heatToAbsorb; + heatToAbsorb = 0; + + return temperature; + } + + @Override + public boolean canConnectHeat(ForgeDirection side) { + return true; + } + + @Override + public IHeatTransfer getAdjacent(ForgeDirection side) { + TileEntity adj = Coord4D.get(this).getFromSide(side).getTileEntity(worldObj); + + if (adj instanceof IHeatTransfer) { + return (IHeatTransfer) adj; + } + + return null; + } + + @Override + public TileComponentSecurity getSecurity() { + return securityComponent; + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityGasTank.java b/src/main/java/mekanism/common/tile/TileEntityGasTank.java index 02cf24199..c9eb56263 100644 --- a/src/main/java/mekanism/common/tile/TileEntityGasTank.java +++ b/src/main/java/mekanism/common/tile/TileEntityGasTank.java @@ -1,9 +1,8 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.Range4D; @@ -38,358 +37,362 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.MathHelper; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityGasTank extends TileEntityContainerBlock implements IGasHandler, ITubeConnection, IRedstoneControl, ISideConfiguration, ISecurityTile, ITierUpgradeable -{ - public enum GasMode - { - IDLE, - DUMPING_EXCESS, - DUMPING - } +public class TileEntityGasTank extends TileEntityContainerBlock + implements IGasHandler, ITubeConnection, IRedstoneControl, ISideConfiguration, + ISecurityTile, ITierUpgradeable { + public enum GasMode { IDLE, DUMPING_EXCESS, DUMPING } - /** The type of gas stored in this tank. */ - public GasTank gasTank; - - public GasTankTier tier = GasTankTier.BASIC; + /** The type of gas stored in this tank. */ + public GasTank gasTank; - public GasMode dumping; + public GasTankTier tier = GasTankTier.BASIC; - public int currentGasAmount; - - public int currentRedstoneLevel; + public GasMode dumping; - /** This machine's current RedstoneControl type. */ - public RedstoneControl controlType; - - public TileComponentEjector ejectorComponent; - public TileComponentConfig configComponent; - public TileComponentSecurity securityComponent; + public int currentGasAmount; - public TileEntityGasTank() - { - super("GasTank"); - - configComponent = new TileComponentConfig(this, TransmissionType.GAS, TransmissionType.ITEM); - - configComponent.addOutput(TransmissionType.ITEM, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY)); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Fill", EnumColor.DARK_BLUE, new int[] {0})); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Empty", EnumColor.DARK_RED, new int[] {1})); - - configComponent.setConfig(TransmissionType.ITEM, new byte[] {2, 1, 0, 0, 0, 0}); - configComponent.setCanEject(TransmissionType.ITEM, false); - configComponent.setIOConfig(TransmissionType.GAS); - configComponent.setEjecting(TransmissionType.GAS, true); - - gasTank = new GasTank(tier.storage); - inventory = new ItemStack[2]; - dumping = GasMode.IDLE; - controlType = RedstoneControl.DISABLED; - - ejectorComponent = new TileComponentEjector(this); - - securityComponent = new TileComponentSecurity(this); - } + public int currentRedstoneLevel; - @Override - public void onUpdate() - { - if(!worldObj.isRemote) - { - if(inventory[0] != null && gasTank.getGas() != null) - { - gasTank.draw(GasTransmission.addGas(inventory[0], gasTank.getGas()), true); - } - - if(inventory[1] != null && (gasTank.getGas() == null || gasTank.getGas().amount < gasTank.getMaxGas())) - { - gasTank.receive(GasTransmission.removeGas(inventory[1], gasTank.getGasType(), gasTank.getNeeded()), true); - } - - if(gasTank.getGas() != null && MekanismUtils.canFunction(this) && dumping != GasMode.DUMPING) - { - if(configComponent.isEjecting(TransmissionType.GAS)) - { - GasStack toSend = new GasStack(gasTank.getGas().getGas(), Math.min(gasTank.getStored(), tier.output)); - gasTank.draw(GasTransmission.emit(toSend, this, configComponent.getSidesForData(TransmissionType.GAS, facing, 2)), true); - } - } - - if(dumping == GasMode.DUMPING) - { - gasTank.draw(tier.storage/400, true); - } - - if(dumping == GasMode.DUMPING_EXCESS && gasTank.getNeeded() < tier.output) - { - gasTank.draw(tier.output-gasTank.getNeeded(), true); - } - - int newGasAmount = gasTank.getStored(); - - if(newGasAmount != currentGasAmount) - { - MekanismUtils.saveChunk(this); - } - - currentGasAmount = newGasAmount; - - int newRedstoneLevel = getRedstoneLevel(); + /** This machine's current RedstoneControl type. */ + public RedstoneControl controlType; - if(newRedstoneLevel != currentRedstoneLevel) - { - markDirty(); - currentRedstoneLevel = newRedstoneLevel; - } - } - } - - @Override - public boolean upgrade(BaseTier upgradeTier) - { - if(upgradeTier.ordinal() != tier.ordinal()+1) - { - return false; - } - - tier = GasTankTier.values()[upgradeTier.ordinal()]; - gasTank.setMaxGas(tier.storage); - - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - markDirty(); - - return true; - } - - @Override - public String getInventoryName() - { - return LangUtils.localize("tile.GasTank" + tier.getBaseTier().getName() + ".name"); - } + public TileComponentEjector ejectorComponent; + public TileComponentConfig configComponent; + public TileComponentSecurity securityComponent; - @Override - public boolean canExtractItem(int slotID, ItemStack itemstack, int side) - { - if(slotID == 1) - { - return (itemstack.getItem() instanceof IGasItem && ((IGasItem)itemstack.getItem()).getGas(itemstack) == null); - } - else if(slotID == 0) - { - return (itemstack.getItem() instanceof IGasItem && ((IGasItem)itemstack.getItem()).getGas(itemstack) != null && - ((IGasItem)itemstack.getItem()).getGas(itemstack).amount == ((IGasItem)itemstack.getItem()).getMaxGas(itemstack)); - } + public TileEntityGasTank() { + super("GasTank"); - return false; - } + configComponent + = new TileComponentConfig(this, TransmissionType.GAS, TransmissionType.ITEM); - @Override - public boolean isItemValidForSlot(int slotID, ItemStack itemstack) - { - if(slotID == 0) - { - return itemstack.getItem() instanceof IGasItem && (gasTank.getGas() == null || ((IGasItem)itemstack.getItem()).canReceiveGas(itemstack, gasTank.getGas().getGas())); - } - else if(slotID == 1) - { - return itemstack.getItem() instanceof IGasItem && (gasTank.getGas() == null || ((IGasItem)itemstack.getItem()).canProvideGas(itemstack, gasTank.getGas().getGas())); - } + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY) + ); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("Fill", EnumColor.DARK_BLUE, new int[] { 0 }) + ); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("Empty", EnumColor.DARK_RED, new int[] { 1 }) + ); - return false; - } + configComponent.setConfig(TransmissionType.ITEM, new byte[] { 2, 1, 0, 0, 0, 0 }); + configComponent.setCanEject(TransmissionType.ITEM, false); + configComponent.setIOConfig(TransmissionType.GAS); + configComponent.setEjecting(TransmissionType.GAS, true); - @Override - public int[] getAccessibleSlotsFromSide(int side) - { - return configComponent.getOutput(TransmissionType.ITEM, side, facing).availableSlots; - } + gasTank = new GasTank(tier.storage); + inventory = new ItemStack[2]; + dumping = GasMode.IDLE; + controlType = RedstoneControl.DISABLED; - @Override - public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) - { - return gasTank.receive(stack, doTransfer); - } + ejectorComponent = new TileComponentEjector(this); - @Override - public int receiveGas(ForgeDirection side, GasStack stack) - { - return receiveGas(side, stack, true); - } + securityComponent = new TileComponentSecurity(this); + } - @Override - public GasStack drawGas(ForgeDirection side, int amount, boolean doTransfer) - { - return null; - } + @Override + public void onUpdate() { + if (!worldObj.isRemote) { + if (inventory[0] != null && gasTank.getGas() != null) { + gasTank.draw( + GasTransmission.addGas(inventory[0], gasTank.getGas()), true + ); + } - @Override - public GasStack drawGas(ForgeDirection side, int amount) - { - return drawGas(side, amount, true); - } + if (inventory[1] != null + && (gasTank.getGas() == null + || gasTank.getGas().amount < gasTank.getMaxGas())) { + gasTank.receive( + GasTransmission.removeGas( + inventory[1], gasTank.getGasType(), gasTank.getNeeded() + ), + true + ); + } - @Override - public boolean canDrawGas(ForgeDirection side, Gas type) - { - return gasTank.canDraw(type); - } + if (gasTank.getGas() != null && MekanismUtils.canFunction(this) + && dumping != GasMode.DUMPING) { + if (configComponent.isEjecting(TransmissionType.GAS)) { + GasStack toSend = new GasStack( + gasTank.getGas().getGas(), + Math.min(gasTank.getStored(), tier.output) + ); + gasTank.draw( + GasTransmission.emit( + toSend, + this, + configComponent.getSidesForData( + TransmissionType.GAS, facing, 2 + ) + ), + true + ); + } + } - @Override - public boolean canReceiveGas(ForgeDirection side, Gas type) - { - if(configComponent.getSidesForData(TransmissionType.GAS, facing, 1).contains(side)) - { - return gasTank.canReceive(type); - } + if (dumping == GasMode.DUMPING) { + gasTank.draw(tier.storage / 400, true); + } - return false; - } + if (dumping == GasMode.DUMPING_EXCESS && gasTank.getNeeded() < tier.output) { + gasTank.draw(tier.output - gasTank.getNeeded(), true); + } - @Override - public void handlePacketData(ByteBuf dataStream) - { - if(!worldObj.isRemote) - { - int type = dataStream.readInt(); + int newGasAmount = gasTank.getStored(); - if(type == 0) - { - int index = (dumping.ordinal() + 1)%dumping.values().length; - dumping = GasMode.values()[index]; - } + if (newGasAmount != currentGasAmount) { + MekanismUtils.saveChunk(this); + } - for(EntityPlayer player : playersUsing) - { - Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), (EntityPlayerMP)player); - } + currentGasAmount = newGasAmount; - return; - } + int newRedstoneLevel = getRedstoneLevel(); - super.handlePacketData(dataStream); - - if(worldObj.isRemote) - { - tier = GasTankTier.values()[dataStream.readInt()]; - gasTank.setMaxGas(tier.storage); - - if(dataStream.readBoolean()) - { - gasTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt())); - } - else { - gasTank.setGas(null); - } - - dumping = GasMode.values()[dataStream.readInt()]; - controlType = RedstoneControl.values()[dataStream.readInt()]; - - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } + if (newRedstoneLevel != currentRedstoneLevel) { + markDirty(); + currentRedstoneLevel = newRedstoneLevel; + } + } + } - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); + @Override + public boolean upgrade(BaseTier upgradeTier) { + if (upgradeTier.ordinal() != tier.ordinal() + 1) { + return false; + } - tier = GasTankTier.values()[nbtTags.getInteger("tier")]; - gasTank.read(nbtTags.getCompoundTag("gasTank")); - dumping = GasMode.values()[nbtTags.getInteger("dumping")]; - - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - } + tier = GasTankTier.values()[upgradeTier.ordinal()]; + gasTank.setMaxGas(tier.storage); - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), + new Range4D(Coord4D.get(this)) + ); + markDirty(); - nbtTags.setInteger("tier", tier.ordinal()); - nbtTags.setTag("gasTank", gasTank.write(new NBTTagCompound())); - nbtTags.setInteger("dumping", dumping.ordinal()); - nbtTags.setInteger("controlType", controlType.ordinal()); - } + return true; + } - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); - - data.add(tier.ordinal()); + @Override + public String getInventoryName() { + return LangUtils.localize( + "tile.GasTank" + tier.getBaseTier().getName() + ".name" + ); + } - if(gasTank.getGas() != null) - { - data.add(true); - data.add(gasTank.getGas().getGas().getID()); - data.add(gasTank.getStored()); - } - else { - data.add(false); - } + @Override + public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { + if (slotID == 1) { + return ( + itemstack.getItem() instanceof IGasItem + && ((IGasItem) itemstack.getItem()).getGas(itemstack) == null + ); + } else if (slotID == 0) { + return ( + itemstack.getItem() instanceof IGasItem + && ((IGasItem) itemstack.getItem()).getGas(itemstack) != null + && ((IGasItem) itemstack.getItem()).getGas(itemstack).amount + == ((IGasItem) itemstack.getItem()).getMaxGas(itemstack) + ); + } - data.add(dumping.ordinal()); - data.add(controlType.ordinal()); + return false; + } - return data; - } + @Override + public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { + if (slotID == 0) { + return itemstack.getItem() instanceof IGasItem + && (gasTank.getGas() == null + || ((IGasItem) itemstack.getItem()) + .canReceiveGas(itemstack, gasTank.getGas().getGas())); + } else if (slotID == 1) { + return itemstack.getItem() instanceof IGasItem + && (gasTank.getGas() == null + || ((IGasItem) itemstack.getItem()) + .canProvideGas(itemstack, gasTank.getGas().getGas())); + } - @Override - public boolean canSetFacing(int side) - { - return side != 0 && side != 1; - } + return false; + } - @Override - public boolean canTubeConnect(ForgeDirection side) - { - return true; - } + @Override + public int[] getAccessibleSlotsFromSide(int side) { + return configComponent.getOutput(TransmissionType.ITEM, side, facing) + .availableSlots; + } - public int getRedstoneLevel() - { - double fractionFull = (float)gasTank.getStored()/(float)gasTank.getMaxGas(); - return MathHelper.floor_float((float)(fractionFull * 14.0F)) + (fractionFull > 0 ? 1 : 0); - } - - @Override - public RedstoneControl getControlType() - { - return controlType; - } + @Override + public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) { + return gasTank.receive(stack, doTransfer); + } - @Override - public void setControlType(RedstoneControl type) - { - controlType = type; - } + @Override + public int receiveGas(ForgeDirection side, GasStack stack) { + return receiveGas(side, stack, true); + } - @Override - public boolean canPulse() - { - return false; - } + @Override + public GasStack drawGas(ForgeDirection side, int amount, boolean doTransfer) { + return null; + } - @Override - public TileComponentEjector getEjector() - { - return ejectorComponent; - } - - @Override - public TileComponentConfig getConfig() - { - return configComponent; - } - - @Override - public int getOrientation() - { - return facing; - } - - @Override - public TileComponentSecurity getSecurity() - { - return securityComponent; - } + @Override + public GasStack drawGas(ForgeDirection side, int amount) { + return drawGas(side, amount, true); + } + + @Override + public boolean canDrawGas(ForgeDirection side, Gas type) { + return gasTank.canDraw(type); + } + + @Override + public boolean canReceiveGas(ForgeDirection side, Gas type) { + if (configComponent.getSidesForData(TransmissionType.GAS, facing, 1) + .contains(side)) { + return gasTank.canReceive(type); + } + + return false; + } + + @Override + public void handlePacketData(ByteBuf dataStream) { + if (!worldObj.isRemote) { + int type = dataStream.readInt(); + + if (type == 0) { + int index = (dumping.ordinal() + 1) % dumping.values().length; + dumping = GasMode.values()[index]; + } + + for (EntityPlayer player : playersUsing) { + Mekanism.packetHandler.sendTo( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + (EntityPlayerMP) player + ); + } + + return; + } + + super.handlePacketData(dataStream); + + if (worldObj.isRemote) { + tier = GasTankTier.values()[dataStream.readInt()]; + gasTank.setMaxGas(tier.storage); + + if (dataStream.readBoolean()) { + gasTank.setGas(new GasStack( + GasRegistry.getGas(dataStream.readInt()), dataStream.readInt() + )); + } else { + gasTank.setGas(null); + } + + dumping = GasMode.values()[dataStream.readInt()]; + controlType = RedstoneControl.values()[dataStream.readInt()]; + + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } + + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); + + tier = GasTankTier.values()[nbtTags.getInteger("tier")]; + gasTank.read(nbtTags.getCompoundTag("gasTank")); + dumping = GasMode.values()[nbtTags.getInteger("dumping")]; + + controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); + + nbtTags.setInteger("tier", tier.ordinal()); + nbtTags.setTag("gasTank", gasTank.write(new NBTTagCompound())); + nbtTags.setInteger("dumping", dumping.ordinal()); + nbtTags.setInteger("controlType", controlType.ordinal()); + } + + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); + + data.add(tier.ordinal()); + + if (gasTank.getGas() != null) { + data.add(true); + data.add(gasTank.getGas().getGas().getID()); + data.add(gasTank.getStored()); + } else { + data.add(false); + } + + data.add(dumping.ordinal()); + data.add(controlType.ordinal()); + + return data; + } + + @Override + public boolean canSetFacing(int side) { + return side != 0 && side != 1; + } + + @Override + public boolean canTubeConnect(ForgeDirection side) { + return true; + } + + public int getRedstoneLevel() { + double fractionFull = (float) gasTank.getStored() / (float) gasTank.getMaxGas(); + return MathHelper.floor_float((float) (fractionFull * 14.0F)) + + (fractionFull > 0 ? 1 : 0); + } + + @Override + public RedstoneControl getControlType() { + return controlType; + } + + @Override + public void setControlType(RedstoneControl type) { + controlType = type; + } + + @Override + public boolean canPulse() { + return false; + } + + @Override + public TileComponentEjector getEjector() { + return ejectorComponent; + } + + @Override + public TileComponentConfig getConfig() { + return configComponent; + } + + @Override + public int getOrientation() { + return facing; + } + + @Override + public TileComponentSecurity getSecurity() { + return securityComponent; + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityInductionCasing.java b/src/main/java/mekanism/common/tile/TileEntityInductionCasing.java index b7bc904b4..ac03147b0 100644 --- a/src/main/java/mekanism/common/tile/TileEntityInductionCasing.java +++ b/src/main/java/mekanism/common/tile/TileEntityInductionCasing.java @@ -1,9 +1,8 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.Range4D; import mekanism.api.energy.IStrictEnergyStorage; @@ -20,199 +19,179 @@ import mekanism.common.util.MekanismUtils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -public class TileEntityInductionCasing extends TileEntityMultiblock implements IStrictEnergyStorage, IComputerIntegration -{ - public int clientCells; - public int clientProviders; - - public TileEntityInductionCasing() - { - this("InductionCasing"); - } - - public TileEntityInductionCasing(String name) - { - super(name); - inventory = new ItemStack[2]; - } - - @Override - public void onUpdate() - { - super.onUpdate(); - - if(!worldObj.isRemote) - { - if(structure != null && isRendering) - { - structure.lastInput = structure.transferCap-structure.remainingInput; - structure.remainingInput = structure.transferCap; - - structure.lastOutput = structure.transferCap-structure.remainingOutput; - structure.remainingOutput = structure.transferCap; - - ChargeUtils.charge(0, this); - ChargeUtils.discharge(1, this); - } - } - } - - @Override - public boolean onActivate(EntityPlayer player) - { - if(!player.isSneaking() && structure != null) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - player.openGui(Mekanism.instance, 49, worldObj, xCoord, yCoord, zCoord); - - return true; - } - - return false; - } - - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); - - if(structure != null) - { - data.add(structure.getEnergy(worldObj)); - data.add(structure.storageCap); - data.add(structure.transferCap); - data.add(structure.lastInput); - data.add(structure.lastOutput); - - data.add(structure.volWidth); - data.add(structure.volHeight); - data.add(structure.volLength); - - data.add(structure.cells.size()); - data.add(structure.providers.size()); - } - - return data; - } +public class TileEntityInductionCasing + extends TileEntityMultiblock + implements IStrictEnergyStorage, IComputerIntegration { + public int clientCells; + public int clientProviders; - @Override - public void handlePacketData(ByteBuf dataStream) - { - super.handlePacketData(dataStream); - - if(worldObj.isRemote) - { - if(clientHasStructure) - { - structure.clientEnergy = dataStream.readDouble(); - structure.storageCap = dataStream.readDouble(); - structure.transferCap = dataStream.readDouble(); - structure.lastInput = dataStream.readDouble(); - structure.lastOutput = dataStream.readDouble(); - - structure.volWidth = dataStream.readInt(); - structure.volHeight = dataStream.readInt(); - structure.volLength = dataStream.readInt(); - - clientCells = dataStream.readInt(); - clientProviders = dataStream.readInt(); - } - } - } + public TileEntityInductionCasing() { + this("InductionCasing"); + } - @Override - protected SynchronizedMatrixData getNewStructure() - { - return new SynchronizedMatrixData(); - } - - @Override - public MatrixCache getNewCache() - { - return new MatrixCache(); - } + public TileEntityInductionCasing(String name) { + super(name); + inventory = new ItemStack[2]; + } - @Override - protected MatrixUpdateProtocol getProtocol() - { - return new MatrixUpdateProtocol(this); - } + @Override + public void onUpdate() { + super.onUpdate(); - @Override - public MultiblockManager getManager() - { - return Mekanism.matrixManager; - } - - @Override - public String getInventoryName() - { - return LangUtils.localize("gui.inductionMatrix"); - } - - public int getScaledEnergyLevel(int i) - { - return (int)(getEnergy()*i / getMaxEnergy()); - } + if (!worldObj.isRemote) { + if (structure != null && isRendering) { + structure.lastInput = structure.transferCap - structure.remainingInput; + structure.remainingInput = structure.transferCap; - @Override - public double getEnergy() - { - if(!worldObj.isRemote) - { - return structure != null ? structure.getEnergy(worldObj) : 0; - } - else { - return structure != null ? structure.clientEnergy : 0; - } - } + structure.lastOutput = structure.transferCap - structure.remainingOutput; + structure.remainingOutput = structure.transferCap; - @Override - public void setEnergy(double energy) - { - if(structure != null) - { - structure.setEnergy(worldObj, Math.max(Math.min(energy, getMaxEnergy()), 0)); - MekanismUtils.saveChunk(this); - } - } + ChargeUtils.charge(0, this); + ChargeUtils.discharge(1, this); + } + } + } - @Override - public double getMaxEnergy() - { - return structure != null ? structure.storageCap : 0; - } + @Override + public boolean onActivate(EntityPlayer player) { + if (!player.isSneaking() && structure != null) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + player.openGui(Mekanism.instance, 49, worldObj, xCoord, yCoord, zCoord); - public static final String[] methods = new String[] {"getEnergy", "getMaxEnergy", "getInput", "getOutput", "getTransferCap"}; + return true; + } - @Override - public String[] getMethods() - { - return methods; - } + return false; + } - @Override - public Object[] invoke(int method, Object[] arguments) throws Exception - { - if(structure == null) - { - return new Object[] {"Unformed."}; - } + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); - switch(method) - { - case 0: - return new Object[] {getEnergy()}; - case 1: - return new Object[] {getMaxEnergy()}; - case 2: - return new Object[] {structure.lastInput}; - case 3: - return new Object[] {structure.lastOutput}; - case 4: - return new Object[] {structure.transferCap}; - default: - return new Object[] {"Unknown command."}; - } - } + if (structure != null) { + data.add(structure.getEnergy(worldObj)); + data.add(structure.storageCap); + data.add(structure.transferCap); + data.add(structure.lastInput); + data.add(structure.lastOutput); + + data.add(structure.volWidth); + data.add(structure.volHeight); + data.add(structure.volLength); + + data.add(structure.cells.size()); + data.add(structure.providers.size()); + } + + return data; + } + + @Override + public void handlePacketData(ByteBuf dataStream) { + super.handlePacketData(dataStream); + + if (worldObj.isRemote) { + if (clientHasStructure) { + structure.clientEnergy = dataStream.readDouble(); + structure.storageCap = dataStream.readDouble(); + structure.transferCap = dataStream.readDouble(); + structure.lastInput = dataStream.readDouble(); + structure.lastOutput = dataStream.readDouble(); + + structure.volWidth = dataStream.readInt(); + structure.volHeight = dataStream.readInt(); + structure.volLength = dataStream.readInt(); + + clientCells = dataStream.readInt(); + clientProviders = dataStream.readInt(); + } + } + } + + @Override + protected SynchronizedMatrixData getNewStructure() { + return new SynchronizedMatrixData(); + } + + @Override + public MatrixCache getNewCache() { + return new MatrixCache(); + } + + @Override + protected MatrixUpdateProtocol getProtocol() { + return new MatrixUpdateProtocol(this); + } + + @Override + public MultiblockManager getManager() { + return Mekanism.matrixManager; + } + + @Override + public String getInventoryName() { + return LangUtils.localize("gui.inductionMatrix"); + } + + public int getScaledEnergyLevel(int i) { + return (int) (getEnergy() * i / getMaxEnergy()); + } + + @Override + public double getEnergy() { + if (!worldObj.isRemote) { + return structure != null ? structure.getEnergy(worldObj) : 0; + } else { + return structure != null ? structure.clientEnergy : 0; + } + } + + @Override + public void setEnergy(double energy) { + if (structure != null) { + structure.setEnergy(worldObj, Math.max(Math.min(energy, getMaxEnergy()), 0)); + MekanismUtils.saveChunk(this); + } + } + + @Override + public double getMaxEnergy() { + return structure != null ? structure.storageCap : 0; + } + + public static final String[] methods = new String[] { + "getEnergy", "getMaxEnergy", "getInput", "getOutput", "getTransferCap" + }; + + @Override + public String[] getMethods() { + return methods; + } + + @Override + public Object[] invoke(int method, Object[] arguments) throws Exception { + if (structure == null) { + return new Object[] { "Unformed." }; + } + + switch (method) { + case 0: + return new Object[] { getEnergy() }; + case 1: + return new Object[] { getMaxEnergy() }; + case 2: + return new Object[] { structure.lastInput }; + case 3: + return new Object[] { structure.lastOutput }; + case 4: + return new Object[] { structure.transferCap }; + default: + return new Object[] { "Unknown command." }; + } + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityInductionCell.java b/src/main/java/mekanism/common/tile/TileEntityInductionCell.java index 5b8599a9e..670200924 100644 --- a/src/main/java/mekanism/common/tile/TileEntityInductionCell.java +++ b/src/main/java/mekanism/common/tile/TileEntityInductionCell.java @@ -1,95 +1,87 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import io.netty.buffer.ByteBuf; import mekanism.api.energy.IStrictEnergyStorage; import mekanism.common.Tier.InductionCellTier; import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import net.minecraft.nbt.NBTTagCompound; -public class TileEntityInductionCell extends TileEntityBasicBlock implements IStrictEnergyStorage -{ - public InductionCellTier tier = InductionCellTier.BASIC; - - public double electricityStored; - - @Override - public void onUpdate() {} - - @Override - public boolean canUpdate() - { - return false; - } - - public String getInventoryName() - { - return LangUtils.localize(getBlockType().getUnlocalizedName() + ".InductionCell" + tier.getBaseTier().getName() + ".name"); - } - - @Override - public void handlePacketData(ByteBuf dataStream) - { - if(worldObj.isRemote) - { - tier = InductionCellTier.values()[dataStream.readInt()]; - - super.handlePacketData(dataStream); - - electricityStored = dataStream.readDouble(); - - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } +public class TileEntityInductionCell + extends TileEntityBasicBlock implements IStrictEnergyStorage { + public InductionCellTier tier = InductionCellTier.BASIC; - @Override - public ArrayList getNetworkedData(ArrayList data) - { - data.add(tier.ordinal()); + public double electricityStored; - super.getNetworkedData(data); - - data.add(electricityStored); + @Override + public void onUpdate() {} - return data; - } + @Override + public boolean canUpdate() { + return false; + } - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); + public String getInventoryName() { + return LangUtils.localize( + getBlockType().getUnlocalizedName() + ".InductionCell" + + tier.getBaseTier().getName() + ".name" + ); + } - tier = InductionCellTier.values()[nbtTags.getInteger("tier")]; - electricityStored = nbtTags.getDouble("electricityStored"); - } + @Override + public void handlePacketData(ByteBuf dataStream) { + if (worldObj.isRemote) { + tier = InductionCellTier.values()[dataStream.readInt()]; - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); + super.handlePacketData(dataStream); - nbtTags.setInteger("tier", tier.ordinal()); - nbtTags.setDouble("electricityStored", electricityStored); - } + electricityStored = dataStream.readDouble(); - @Override - public double getEnergy() - { - return electricityStored; - } + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } - @Override - public void setEnergy(double energy) - { - electricityStored = Math.min(energy, getMaxEnergy()); - } + @Override + public ArrayList getNetworkedData(ArrayList data) { + data.add(tier.ordinal()); - @Override - public double getMaxEnergy() - { - return tier.maxEnergy; - } + super.getNetworkedData(data); + + data.add(electricityStored); + + return data; + } + + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); + + tier = InductionCellTier.values()[nbtTags.getInteger("tier")]; + electricityStored = nbtTags.getDouble("electricityStored"); + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); + + nbtTags.setInteger("tier", tier.ordinal()); + nbtTags.setDouble("electricityStored", electricityStored); + } + + @Override + public double getEnergy() { + return electricityStored; + } + + @Override + public void setEnergy(double energy) { + electricityStored = Math.min(energy, getMaxEnergy()); + } + + @Override + public double getMaxEnergy() { + return tier.maxEnergy; + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityInductionPort.java b/src/main/java/mekanism/common/tile/TileEntityInductionPort.java index 252f98ce5..a20485c1c 100644 --- a/src/main/java/mekanism/common/tile/TileEntityInductionPort.java +++ b/src/main/java/mekanism/common/tile/TileEntityInductionPort.java @@ -1,15 +1,17 @@ package mekanism.common.tile; +import java.util.ArrayList; +import java.util.EnumSet; + +import cpw.mods.fml.common.Optional.Interface; +import cpw.mods.fml.common.Optional.InterfaceList; +import cpw.mods.fml.common.Optional.Method; import ic2.api.energy.EnergyNet; import ic2.api.energy.event.EnergyTileLoadEvent; import ic2.api.energy.event.EnergyTileUnloadEvent; import ic2.api.energy.tile.IEnergyConductor; import ic2.api.energy.tile.IEnergyTile; import io.netty.buffer.ByteBuf; - -import java.util.ArrayList; -import java.util.EnumSet; - import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.IConfigurable; @@ -30,448 +32,400 @@ import net.minecraft.util.ChatComponentText; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.ForgeDirection; import universalelectricity.core.electricity.ElectricityPack; -import cpw.mods.fml.common.Optional.Interface; -import cpw.mods.fml.common.Optional.InterfaceList; -import cpw.mods.fml.common.Optional.Method; @InterfaceList({ - @Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2"), - @Interface(iface = "ic2.api.energy.tile.IEnergySource", modid = "IC2"), - @Interface(iface = "ic2.api.tile.IEnergyStorage", modid = "IC2") + @Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2") + , @Interface(iface = "ic2.api.energy.tile.IEnergySource", modid = "IC2"), + @Interface(iface = "ic2.api.tile.IEnergyStorage", modid = "IC2") }) -public class TileEntityInductionPort extends TileEntityInductionCasing implements IEnergyWrapper, IConfigurable, IActiveState -{ - public boolean ic2Registered = false; - - /** false = input, true = output */ - public boolean mode; - - public TileEntityInductionPort() - { - super("InductionPort"); - } - - @Override - public void onUpdate() - { - super.onUpdate(); - - if(!ic2Registered && MekanismUtils.useIC2()) - { - register(); - } - - if(!worldObj.isRemote) - { - if(structure != null && mode == true) - { - double prev = getEnergy(); - CableUtils.emit(this); - structure.remainingOutput -= (prev-getEnergy()); - } - } - } - - @Override - public EnumSet getOutputtingSides() - { - if(structure != null && mode == true) - { - EnumSet set = EnumSet.allOf(ForgeDirection.class); - set.remove(ForgeDirection.UNKNOWN); - - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - if(structure.locations.contains(Coord4D.get(this).getFromSide(side))) - { - set.remove(side); - } - } - - return set; - } - - return EnumSet.noneOf(ForgeDirection.class); - } - - @Override - public EnumSet getConsumingSides() - { - if(structure != null && mode == false) - { - EnumSet set = EnumSet.allOf(ForgeDirection.class); - set.remove(ForgeDirection.UNKNOWN); - return set; - } - - return EnumSet.noneOf(ForgeDirection.class); - } - - @Method(modid = "IC2") - public void register() - { - if(!worldObj.isRemote) - { - TileEntity registered = EnergyNet.instance.getTileEntity(worldObj, xCoord, yCoord, zCoord); - - if(registered != this) - { - if(registered instanceof IEnergyTile) - { - MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergyTile)registered)); - } - else if(registered == null) - { - MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); - ic2Registered = true; - } - } - } - } - - @Method(modid = "IC2") - public void deregister() - { - if(!worldObj.isRemote) - { - TileEntity registered = EnergyNet.instance.getTileEntity(worldObj, xCoord, yCoord, zCoord); - - if(registered instanceof IEnergyTile) - { - MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergyTile)registered)); - } - } - } - - @Override - public double getMaxOutput() - { - return structure != null ? structure.remainingOutput : 0; - } - - private double getMaxInput() - { - return structure != null ? structure.remainingInput : 0; - } - - @Override - public void handlePacketData(ByteBuf dataStream) - { - super.handlePacketData(dataStream); - - if(worldObj.isRemote) - { - mode = dataStream.readBoolean(); - - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } - - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); - - data.add(mode); - - return data; - } - - @Override - public void onAdded() - { - super.onAdded(); - - if(MekanismUtils.useIC2()) - { - register(); - } - } - - @Override - public void onChunkUnload() - { - if(MekanismUtils.useIC2()) - { - deregister(); - } - - super.onChunkUnload(); - } - - @Override - public void invalidate() - { - super.invalidate(); - - if(MekanismUtils.useIC2()) - { - deregister(); - } - } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - mode = nbtTags.getBoolean("mode"); - } - - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - nbtTags.setBoolean("mode", mode); - } - - @Override - public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) - { - if(getConsumingSides().contains(from)) - { - double toAdd = (int)Math.min(Math.min(getMaxInput(), getMaxEnergy()-getEnergy()), maxReceive* general.FROM_TE); - - if(!simulate) - { - setEnergy(getEnergy() + toAdd); - structure.remainingInput -= toAdd; - } - - return (int)Math.round(toAdd*general.TO_TE); - } - - return 0; - } - - @Override - public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) - { - if(getOutputtingSides().contains(from)) - { - double toSend = Math.min(getEnergy(), Math.min(getMaxOutput(), maxExtract*general.FROM_TE)); - - if(!simulate) - { - setEnergy(getEnergy() - toSend); - structure.remainingOutput -= toSend; - } - - return (int)Math.round(toSend*general.TO_TE); - } - - return 0; - } - - @Override - public boolean canConnectEnergy(ForgeDirection from) - { - return structure != null; - } - - @Override - public int getEnergyStored(ForgeDirection from) - { - return (int)Math.round(getEnergy()*general.TO_TE); - } - - @Override - public int getMaxEnergyStored(ForgeDirection from) - { - return (int)Math.round(getMaxEnergy()*general.TO_TE); - } - - @Override - @Method(modid = "IC2") - public int getSinkTier() - { - return 4; - } - - @Override - @Method(modid = "IC2") - public int getSourceTier() - { - return 4; - } - - @Override - @Method(modid = "IC2") - public void setStored(int energy) - { - setEnergy(energy*general.FROM_IC2); - } - - @Override - @Method(modid = "IC2") - public int addEnergy(int amount) - { - double toUse = Math.min(Math.min(getMaxInput(), getMaxEnergy()-getEnergy()), amount*general.FROM_IC2); - setEnergy(getEnergy() + toUse); - structure.remainingInput -= toUse; - return (int)Math.round(getEnergy()*general.TO_IC2); - } - - @Override - @Method(modid = "IC2") - public boolean isTeleporterCompatible(ForgeDirection side) - { - return canOutputTo(side); - } - - @Override - public boolean canOutputTo(ForgeDirection side) - { - return getOutputtingSides().contains(side); - } - - @Override - @Method(modid = "IC2") - public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) - { - return false; - //return getConsumingSides().contains(direction); - } - - @Override - @Method(modid = "IC2") - public boolean emitsEnergyTo(TileEntity receiver, ForgeDirection direction) - { - return getOutputtingSides().contains(direction) && receiver instanceof IEnergyConductor; - } - - @Override - @Method(modid = "IC2") - public int getStored() - { - return (int)Math.round(getEnergy()*general.TO_IC2); - } - - @Override - @Method(modid = "IC2") - public int getCapacity() - { - return (int)Math.round(getMaxEnergy()*general.TO_IC2); - } - - @Override - @Method(modid = "IC2") - public int getOutput() - { - return (int)Math.round(getMaxOutput()*general.TO_IC2); - } - - @Override - @Method(modid = "IC2") - public double getDemandedEnergy() - { - return (getMaxEnergy() - getEnergy())*general.TO_IC2; - } - - @Override - @Method(modid = "IC2") - public double getOfferedEnergy() - { - return Math.min(getEnergy(), getMaxOutput())*general.TO_IC2; - } - - @Override - public boolean canReceiveEnergy(ForgeDirection side) - { - return getConsumingSides().contains(side); - } - - @Override - @Method(modid = "IC2") - public double getOutputEnergyUnitsPerTick() - { - return getMaxOutput()*general.TO_IC2; - } - - @Override - @Method(modid = "IC2") - public double injectEnergy(ForgeDirection direction, double amount, double voltage) - { - if(Coord4D.get(this).getFromSide(direction).getTileEntity(worldObj) instanceof ITransmitterTile) - { - return amount; - } - - return amount-transferEnergyToAcceptor(direction, amount*general.FROM_IC2)*general.TO_IC2; - } - - @Override - @Method(modid = "IC2") - public void drawEnergy(double amount) - { - if(structure != null) - { - double toDraw = Math.min(amount*general.FROM_IC2, getMaxOutput()); - setEnergy(Math.max(getEnergy() - toDraw, 0)); - structure.remainingOutput -= toDraw; - } - } - - @Override - public double transferEnergyToAcceptor(ForgeDirection side, double amount) - { - if(!getConsumingSides().contains(side)) - { - return 0; - } - - double toUse = Math.min(Math.min(getMaxInput(), getMaxEnergy()-getEnergy()), amount); - setEnergy(getEnergy() + toUse); - structure.remainingInput -= toUse; - - return toUse; - } - - @Override - public boolean onSneakRightClick(EntityPlayer player, int side) - { - if(!worldObj.isRemote) - { - mode = !mode; - String modeText = " " + (mode ? EnumColor.DARK_RED : EnumColor.DARK_GREEN) + LangUtils.transOutputInput(mode) + "."; - player.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + LangUtils.localize("tooltip.configurator.inductionPortMode") + modeText)); - - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - markDirty(); - } - - return true; - } - - @Override - public boolean onRightClick(EntityPlayer player, int side) - { - return false; - } - - @Override - public boolean getActive() - { - return mode; - } - - @Override - public void setActive(boolean active) - { - mode = active; - } - - @Override - public boolean renderUpdate() - { - return true; - } - - @Override - public boolean lightUpdate() - { - return false; - } - +public class TileEntityInductionPort extends TileEntityInductionCasing + implements IEnergyWrapper, IConfigurable, IActiveState { + public boolean ic2Registered = false; + + /** false = input, true = output */ + public boolean mode; + + public TileEntityInductionPort() { + super("InductionPort"); + } + + @Override + public void onUpdate() { + super.onUpdate(); + + if (!ic2Registered && MekanismUtils.useIC2()) { + register(); + } + + if (!worldObj.isRemote) { + if (structure != null && mode == true) { + double prev = getEnergy(); + CableUtils.emit(this); + structure.remainingOutput -= (prev - getEnergy()); + } + } + } + + @Override + public EnumSet getOutputtingSides() { + if (structure != null && mode == true) { + EnumSet set = EnumSet.allOf(ForgeDirection.class); + set.remove(ForgeDirection.UNKNOWN); + + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + if (structure.locations.contains(Coord4D.get(this).getFromSide(side))) { + set.remove(side); + } + } + + return set; + } + + return EnumSet.noneOf(ForgeDirection.class); + } + + @Override + public EnumSet getConsumingSides() { + if (structure != null && mode == false) { + EnumSet set = EnumSet.allOf(ForgeDirection.class); + set.remove(ForgeDirection.UNKNOWN); + return set; + } + + return EnumSet.noneOf(ForgeDirection.class); + } + + @Method(modid = "IC2") + public void register() { + if (!worldObj.isRemote) { + TileEntity registered + = EnergyNet.instance.getTileEntity(worldObj, xCoord, yCoord, zCoord); + + if (registered != this) { + if (registered instanceof IEnergyTile) { + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergyTile + ) registered)); + } else if (registered == null) { + MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); + ic2Registered = true; + } + } + } + } + + @Method(modid = "IC2") + public void deregister() { + if (!worldObj.isRemote) { + TileEntity registered + = EnergyNet.instance.getTileEntity(worldObj, xCoord, yCoord, zCoord); + + if (registered instanceof IEnergyTile) { + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergyTile + ) registered)); + } + } + } + + @Override + public double getMaxOutput() { + return structure != null ? structure.remainingOutput : 0; + } + + private double getMaxInput() { + return structure != null ? structure.remainingInput : 0; + } + + @Override + public void handlePacketData(ByteBuf dataStream) { + super.handlePacketData(dataStream); + + if (worldObj.isRemote) { + mode = dataStream.readBoolean(); + + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } + + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); + + data.add(mode); + + return data; + } + + @Override + public void onAdded() { + super.onAdded(); + + if (MekanismUtils.useIC2()) { + register(); + } + } + + @Override + public void onChunkUnload() { + if (MekanismUtils.useIC2()) { + deregister(); + } + + super.onChunkUnload(); + } + + @Override + public void invalidate() { + super.invalidate(); + + if (MekanismUtils.useIC2()) { + deregister(); + } + } + + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); + + mode = nbtTags.getBoolean("mode"); + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); + + nbtTags.setBoolean("mode", mode); + } + + @Override + public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { + if (getConsumingSides().contains(from)) { + double toAdd = (int) Math.min( + Math.min(getMaxInput(), getMaxEnergy() - getEnergy()), + maxReceive * general.FROM_TE + ); + + if (!simulate) { + setEnergy(getEnergy() + toAdd); + structure.remainingInput -= toAdd; + } + + return (int) Math.round(toAdd * general.TO_TE); + } + + return 0; + } + + @Override + public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) { + if (getOutputtingSides().contains(from)) { + double toSend = Math.min( + getEnergy(), Math.min(getMaxOutput(), maxExtract * general.FROM_TE) + ); + + if (!simulate) { + setEnergy(getEnergy() - toSend); + structure.remainingOutput -= toSend; + } + + return (int) Math.round(toSend * general.TO_TE); + } + + return 0; + } + + @Override + public boolean canConnectEnergy(ForgeDirection from) { + return structure != null; + } + + @Override + public int getEnergyStored(ForgeDirection from) { + return (int) Math.round(getEnergy() * general.TO_TE); + } + + @Override + public int getMaxEnergyStored(ForgeDirection from) { + return (int) Math.round(getMaxEnergy() * general.TO_TE); + } + + @Override + @Method(modid = "IC2") + public int getSinkTier() { + return 4; + } + + @Override + @Method(modid = "IC2") + public int getSourceTier() { + return 4; + } + + @Override + @Method(modid = "IC2") + public void setStored(int energy) { + setEnergy(energy * general.FROM_IC2); + } + + @Override + @Method(modid = "IC2") + public int addEnergy(int amount) { + double toUse = Math.min( + Math.min(getMaxInput(), getMaxEnergy() - getEnergy()), + amount * general.FROM_IC2 + ); + setEnergy(getEnergy() + toUse); + structure.remainingInput -= toUse; + return (int) Math.round(getEnergy() * general.TO_IC2); + } + + @Override + @Method(modid = "IC2") + public boolean isTeleporterCompatible(ForgeDirection side) { + return canOutputTo(side); + } + + @Override + public boolean canOutputTo(ForgeDirection side) { + return getOutputtingSides().contains(side); + } + + @Override + @Method(modid = "IC2") + public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) { + return false; + //return getConsumingSides().contains(direction); + } + + @Override + @Method(modid = "IC2") + public boolean emitsEnergyTo(TileEntity receiver, ForgeDirection direction) { + return getOutputtingSides().contains(direction) + && receiver instanceof IEnergyConductor; + } + + @Override + @Method(modid = "IC2") + public int getStored() { + return (int) Math.round(getEnergy() * general.TO_IC2); + } + + @Override + @Method(modid = "IC2") + public int getCapacity() { + return (int) Math.round(getMaxEnergy() * general.TO_IC2); + } + + @Override + @Method(modid = "IC2") + public int getOutput() { + return (int) Math.round(getMaxOutput() * general.TO_IC2); + } + + @Override + @Method(modid = "IC2") + public double getDemandedEnergy() { + return (getMaxEnergy() - getEnergy()) * general.TO_IC2; + } + + @Override + @Method(modid = "IC2") + public double getOfferedEnergy() { + return Math.min(getEnergy(), getMaxOutput()) * general.TO_IC2; + } + + @Override + public boolean canReceiveEnergy(ForgeDirection side) { + return getConsumingSides().contains(side); + } + + @Override + @Method(modid = "IC2") + public double getOutputEnergyUnitsPerTick() { + return getMaxOutput() * general.TO_IC2; + } + + @Override + @Method(modid = "IC2") + public double injectEnergy(ForgeDirection direction, double amount, double voltage) { + if (Coord4D.get(this).getFromSide(direction).getTileEntity(worldObj) + instanceof ITransmitterTile) { + return amount; + } + + return amount + - transferEnergyToAcceptor(direction, amount * general.FROM_IC2) + * general.TO_IC2; + } + + @Override + @Method(modid = "IC2") + public void drawEnergy(double amount) { + if (structure != null) { + double toDraw = Math.min(amount * general.FROM_IC2, getMaxOutput()); + setEnergy(Math.max(getEnergy() - toDraw, 0)); + structure.remainingOutput -= toDraw; + } + } + + @Override + public double transferEnergyToAcceptor(ForgeDirection side, double amount) { + if (!getConsumingSides().contains(side)) { + return 0; + } + + double toUse + = Math.min(Math.min(getMaxInput(), getMaxEnergy() - getEnergy()), amount); + setEnergy(getEnergy() + toUse); + structure.remainingInput -= toUse; + + return toUse; + } + + @Override + public boolean onSneakRightClick(EntityPlayer player, int side) { + if (!worldObj.isRemote) { + mode = !mode; + String modeText = " " + (mode ? EnumColor.DARK_RED : EnumColor.DARK_GREEN) + + LangUtils.transOutputInput(mode) + "."; + player.addChatMessage(new ChatComponentText( + EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + + LangUtils.localize("tooltip.configurator.inductionPortMode") + modeText + )); + + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + markDirty(); + } + + return true; + } + + @Override + public boolean onRightClick(EntityPlayer player, int side) { + return false; + } + + @Override + public boolean getActive() { + return mode; + } + + @Override + public void setActive(boolean active) { + mode = active; + } + + @Override + public boolean renderUpdate() { + return true; + } + + @Override + public boolean lightUpdate() { + return false; + } } \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityInductionProvider.java b/src/main/java/mekanism/common/tile/TileEntityInductionProvider.java index 4deefe128..0acf073cf 100644 --- a/src/main/java/mekanism/common/tile/TileEntityInductionProvider.java +++ b/src/main/java/mekanism/common/tile/TileEntityInductionProvider.java @@ -1,68 +1,62 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import io.netty.buffer.ByteBuf; import mekanism.common.Tier.InductionProviderTier; import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; import net.minecraft.nbt.NBTTagCompound; -public class TileEntityInductionProvider extends TileEntityBasicBlock -{ - public InductionProviderTier tier = InductionProviderTier.BASIC; - - @Override - public void onUpdate() {} - - @Override - public boolean canUpdate() - { - return false; - } - - public String getInventoryName() - { - return LangUtils.localize(getBlockType().getUnlocalizedName() + ".InductionProvider" + tier.getBaseTier().getName() + ".name"); - } - - @Override - public void handlePacketData(ByteBuf dataStream) - { - if(worldObj.isRemote) - { - tier = InductionProviderTier.values()[dataStream.readInt()]; - - super.handlePacketData(dataStream); - - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } +public class TileEntityInductionProvider extends TileEntityBasicBlock { + public InductionProviderTier tier = InductionProviderTier.BASIC; - @Override - public ArrayList getNetworkedData(ArrayList data) - { - data.add(tier.ordinal()); + @Override + public void onUpdate() {} - super.getNetworkedData(data); + @Override + public boolean canUpdate() { + return false; + } - return data; - } + public String getInventoryName() { + return LangUtils.localize( + getBlockType().getUnlocalizedName() + ".InductionProvider" + + tier.getBaseTier().getName() + ".name" + ); + } - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); + @Override + public void handlePacketData(ByteBuf dataStream) { + if (worldObj.isRemote) { + tier = InductionProviderTier.values()[dataStream.readInt()]; - tier = InductionProviderTier.values()[nbtTags.getInteger("tier")]; - } + super.handlePacketData(dataStream); - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } - nbtTags.setInteger("tier", tier.ordinal()); - } + @Override + public ArrayList getNetworkedData(ArrayList data) { + data.add(tier.ordinal()); + + super.getNetworkedData(data); + + return data; + } + + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); + + tier = InductionProviderTier.values()[nbtTags.getInteger("tier")]; + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); + + nbtTags.setInteger("tier", tier.ordinal()); + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityLaser.java b/src/main/java/mekanism/common/tile/TileEntityLaser.java index 52f44b84c..f719f9344 100644 --- a/src/main/java/mekanism/common/tile/TileEntityLaser.java +++ b/src/main/java/mekanism/common/tile/TileEntityLaser.java @@ -1,10 +1,9 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.EnumSet; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.MekanismConfig.general; import mekanism.api.MekanismConfig.usage; @@ -23,170 +22,180 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MovingObjectPosition; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityLaser extends TileEntityNoisyElectricBlock implements IActiveState -{ - public Coord4D digging; - public double diggingProgress; - - public boolean isActive; +public class TileEntityLaser + extends TileEntityNoisyElectricBlock implements IActiveState { + public Coord4D digging; + public double diggingProgress; - public boolean clientActive; + public boolean isActive; - public TileEntityLaser() - { - super("machine.laser", "Laser", 2*usage.laserUsage); - inventory = new ItemStack[0]; - } + public boolean clientActive; - @Override - public void onUpdate() - { - super.onUpdate(); + public TileEntityLaser() { + super("machine.laser", "Laser", 2 * usage.laserUsage); + inventory = new ItemStack[0]; + } - if(worldObj.isRemote) - { - if(isActive) - { - MovingObjectPosition mop = LaserManager.fireLaserClient(this, ForgeDirection.getOrientation(facing), usage.laserUsage, worldObj); - Coord4D hitCoord = mop == null ? null : new Coord4D(mop.blockX, mop.blockY, mop.blockZ, worldObj.provider.dimensionId); + @Override + public void onUpdate() { + super.onUpdate(); - if(hitCoord == null || !hitCoord.equals(digging)) - { - digging = hitCoord; - diggingProgress = 0; - } + if (worldObj.isRemote) { + if (isActive) { + MovingObjectPosition mop = LaserManager.fireLaserClient( + this, + ForgeDirection.getOrientation(facing), + usage.laserUsage, + worldObj + ); + Coord4D hitCoord = mop == null + ? null + : new Coord4D( + mop.blockX, mop.blockY, mop.blockZ, worldObj.provider.dimensionId + ); - if(hitCoord != null) - { - Block blockHit = hitCoord.getBlock(worldObj); - TileEntity tileHit = hitCoord.getTileEntity(worldObj); - float hardness = blockHit.getBlockHardness(worldObj, hitCoord.xCoord, hitCoord.yCoord, hitCoord.zCoord); + if (hitCoord == null || !hitCoord.equals(digging)) { + digging = hitCoord; + diggingProgress = 0; + } - if(!(hardness < 0 || (tileHit instanceof ILaserReceptor && !((ILaserReceptor)tileHit).canLasersDig()))) - { - diggingProgress += usage.laserUsage; + if (hitCoord != null) { + Block blockHit = hitCoord.getBlock(worldObj); + TileEntity tileHit = hitCoord.getTileEntity(worldObj); + float hardness = blockHit.getBlockHardness( + worldObj, hitCoord.xCoord, hitCoord.yCoord, hitCoord.zCoord + ); - if(diggingProgress < hardness*general.laserEnergyNeededPerHardness) - { - Mekanism.proxy.addHitEffects(hitCoord, mop); - } - } - } - } - } - else { - if(getEnergy() >= usage.laserUsage) - { - setActive(true); - - LaserInfo info = LaserManager.fireLaser(this, ForgeDirection.getOrientation(facing), usage.laserUsage, worldObj); - Coord4D hitCoord = info.movingPos == null ? null : new Coord4D(info.movingPos.blockX, info.movingPos.blockY, info.movingPos.blockZ, worldObj.provider.dimensionId); + if (!(hardness < 0 + || (tileHit instanceof ILaserReceptor + && !((ILaserReceptor) tileHit).canLasersDig()))) { + diggingProgress += usage.laserUsage; - if(hitCoord == null || !hitCoord.equals(digging)) - { - digging = hitCoord; - diggingProgress = 0; - } + if (diggingProgress + < hardness * general.laserEnergyNeededPerHardness) { + Mekanism.proxy.addHitEffects(hitCoord, mop); + } + } + } + } + } else { + if (getEnergy() >= usage.laserUsage) { + setActive(true); - if(hitCoord != null) - { - Block blockHit = hitCoord.getBlock(worldObj); - TileEntity tileHit = hitCoord.getTileEntity(worldObj); - float hardness = blockHit.getBlockHardness(worldObj, hitCoord.xCoord, hitCoord.yCoord, hitCoord.zCoord); - - if(!(hardness < 0 || (tileHit instanceof ILaserReceptor && !((ILaserReceptor)tileHit).canLasersDig()))) - { - diggingProgress += usage.laserUsage; + LaserInfo info = LaserManager.fireLaser( + this, + ForgeDirection.getOrientation(facing), + usage.laserUsage, + worldObj + ); + Coord4D hitCoord = info.movingPos == null + ? null + : new Coord4D( + info.movingPos.blockX, + info.movingPos.blockY, + info.movingPos.blockZ, + worldObj.provider.dimensionId + ); - if(diggingProgress >= hardness*general.laserEnergyNeededPerHardness) - { - LaserManager.breakBlock(hitCoord, true, worldObj); - diggingProgress = 0; - } - } - } + if (hitCoord == null || !hitCoord.equals(digging)) { + digging = hitCoord; + diggingProgress = 0; + } - setEnergy(getEnergy() - usage.laserUsage); - } - else { - setActive(false); - diggingProgress = 0; - } - } - } - - @Override - public EnumSet getConsumingSides() - { - return EnumSet.of(ForgeDirection.getOrientation(facing).getOpposite()); - } - - @Override - public void setActive(boolean active) - { - isActive = active; + if (hitCoord != null) { + Block blockHit = hitCoord.getBlock(worldObj); + TileEntity tileHit = hitCoord.getTileEntity(worldObj); + float hardness = blockHit.getBlockHardness( + worldObj, hitCoord.xCoord, hitCoord.yCoord, hitCoord.zCoord + ); - if(clientActive != active) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - clientActive = active; - } - } + if (!(hardness < 0 + || (tileHit instanceof ILaserReceptor + && !((ILaserReceptor) tileHit).canLasersDig()))) { + diggingProgress += usage.laserUsage; - @Override - public boolean getActive() - { - return isActive; - } + if (diggingProgress + >= hardness * general.laserEnergyNeededPerHardness) { + LaserManager.breakBlock(hitCoord, true, worldObj); + diggingProgress = 0; + } + } + } - @Override - public boolean renderUpdate() - { - return false; - } + setEnergy(getEnergy() - usage.laserUsage); + } else { + setActive(false); + diggingProgress = 0; + } + } + } - @Override - public boolean lightUpdate() - { - return false; - } + @Override + public EnumSet getConsumingSides() { + return EnumSet.of(ForgeDirection.getOrientation(facing).getOpposite()); + } - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); + @Override + public void setActive(boolean active) { + isActive = active; - data.add(isActive); + if (clientActive != active) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + clientActive = active; + } + } - return data; - } + @Override + public boolean getActive() { + return isActive; + } - @Override - public void handlePacketData(ByteBuf dataStream) - { - super.handlePacketData(dataStream); + @Override + public boolean renderUpdate() { + return false; + } - if(worldObj.isRemote) - { - isActive = dataStream.readBoolean(); - - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); + @Override + public boolean lightUpdate() { + return false; + } - isActive = nbtTags.getBoolean("isActive"); - } + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); + data.add(isActive); - nbtTags.setBoolean("isActive", isActive); - } + return data; + } + + @Override + public void handlePacketData(ByteBuf dataStream) { + super.handlePacketData(dataStream); + + if (worldObj.isRemote) { + isActive = dataStream.readBoolean(); + + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } + + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); + + isActive = nbtTags.getBoolean("isActive"); + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); + + nbtTags.setBoolean("isActive", isActive); + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityLaserAmplifier.java b/src/main/java/mekanism/common/tile/TileEntityLaserAmplifier.java index 41123b1e1..2e6528bf9 100644 --- a/src/main/java/mekanism/common/tile/TileEntityLaserAmplifier.java +++ b/src/main/java/mekanism/common/tile/TileEntityLaserAmplifier.java @@ -1,9 +1,8 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.MekanismConfig.general; import mekanism.api.energy.ICableOutputter; @@ -27,361 +26,358 @@ import net.minecraft.util.MathHelper; import net.minecraft.util.MovingObjectPosition; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityLaserAmplifier extends TileEntityContainerBlock implements ILaserReceptor, IRedstoneControl, ICableOutputter, IStrictEnergyStorage, IComputerIntegration, ISecurityTile -{ - public static final double MAX_ENERGY = 5E9; - public double collectedEnergy = 0; - public double lastFired = 0; +public class TileEntityLaserAmplifier extends TileEntityContainerBlock + implements ILaserReceptor, IRedstoneControl, ICableOutputter, IStrictEnergyStorage, + IComputerIntegration, ISecurityTile { + public static final double MAX_ENERGY = 5E9; + public double collectedEnergy = 0; + public double lastFired = 0; - public double minThreshold = 0; - public double maxThreshold = 5E9; - public int ticks = 0; - public int time = 0; + public double minThreshold = 0; + public double maxThreshold = 5E9; + public int ticks = 0; + public int time = 0; - public RedstoneControl controlType = RedstoneControl.DISABLED; + public RedstoneControl controlType = RedstoneControl.DISABLED; - public boolean on = false; + public boolean on = false; - public Coord4D digging; - public double diggingProgress; - - public boolean emittingRedstone; - public int currentRedstoneLevel; - - public RedstoneOutput outputMode = RedstoneOutput.OFF; - - public TileComponentSecurity securityComponent = new TileComponentSecurity(this); + public Coord4D digging; + public double diggingProgress; - public TileEntityLaserAmplifier() - { - super("LaserAmplifier"); - inventory = new ItemStack[0]; - } + public boolean emittingRedstone; + public int currentRedstoneLevel; - @Override - public void receiveLaserEnergy(double energy, ForgeDirection side) - { - setEnergy(getEnergy() + energy); - } + public RedstoneOutput outputMode = RedstoneOutput.OFF; - @Override - public boolean canLasersDig() - { - return false; - } + public TileComponentSecurity securityComponent = new TileComponentSecurity(this); - @Override - public void onUpdate() - { - if(worldObj.isRemote) - { - if(on) - { - MovingObjectPosition mop = LaserManager.fireLaserClient(this, ForgeDirection.getOrientation(facing), lastFired, worldObj); - Coord4D hitCoord = mop == null ? null : new Coord4D(mop.blockX, mop.blockY, mop.blockZ, worldObj.provider.dimensionId); + public TileEntityLaserAmplifier() { + super("LaserAmplifier"); + inventory = new ItemStack[0]; + } - if(hitCoord == null || !hitCoord.equals(digging)) - { - digging = hitCoord; - diggingProgress = 0; - } + @Override + public void receiveLaserEnergy(double energy, ForgeDirection side) { + setEnergy(getEnergy() + energy); + } - if(hitCoord != null) - { - Block blockHit = hitCoord.getBlock(worldObj); - TileEntity tileHit = hitCoord.getTileEntity(worldObj); - float hardness = blockHit.getBlockHardness(worldObj, hitCoord.xCoord, hitCoord.yCoord, hitCoord.zCoord); + @Override + public boolean canLasersDig() { + return false; + } - if(!(hardness < 0 || (tileHit instanceof ILaserReceptor && !((ILaserReceptor)tileHit).canLasersDig()))) - { - diggingProgress += lastFired; - - if(diggingProgress < hardness*general.laserEnergyNeededPerHardness) - { - Mekanism.proxy.addHitEffects(hitCoord, mop); - } - } - } + @Override + public void onUpdate() { + if (worldObj.isRemote) { + if (on) { + MovingObjectPosition mop = LaserManager.fireLaserClient( + this, ForgeDirection.getOrientation(facing), lastFired, worldObj + ); + Coord4D hitCoord = mop == null + ? null + : new Coord4D( + mop.blockX, mop.blockY, mop.blockZ, worldObj.provider.dimensionId + ); - } - } - else { - boolean prevRedstone = emittingRedstone; - - emittingRedstone = false; - - if(ticks < time) - { - ticks++; - } - else { - ticks = 0; - } + if (hitCoord == null || !hitCoord.equals(digging)) { + digging = hitCoord; + diggingProgress = 0; + } - if(toFire() > 0) - { - double firing = toFire(); + if (hitCoord != null) { + Block blockHit = hitCoord.getBlock(worldObj); + TileEntity tileHit = hitCoord.getTileEntity(worldObj); + float hardness = blockHit.getBlockHardness( + worldObj, hitCoord.xCoord, hitCoord.yCoord, hitCoord.zCoord + ); - if(!on || firing != lastFired) - { - on = true; - lastFired = firing; - Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this).getTargetPoint(50D)); - } + if (!(hardness < 0 + || (tileHit instanceof ILaserReceptor + && !((ILaserReceptor) tileHit).canLasersDig()))) { + diggingProgress += lastFired; - LaserInfo info = LaserManager.fireLaser(this, ForgeDirection.getOrientation(facing), firing, worldObj); - Coord4D hitCoord = info.movingPos == null ? null : new Coord4D(info.movingPos.blockX, info.movingPos.blockY, info.movingPos.blockZ, worldObj.provider.dimensionId); + if (diggingProgress + < hardness * general.laserEnergyNeededPerHardness) { + Mekanism.proxy.addHitEffects(hitCoord, mop); + } + } + } + } + } else { + boolean prevRedstone = emittingRedstone; - if(hitCoord == null || !hitCoord.equals(digging)) - { - digging = hitCoord; - diggingProgress = 0; - } + emittingRedstone = false; - if(hitCoord != null) - { - Block blockHit = hitCoord.getBlock(worldObj); - TileEntity tileHit = hitCoord.getTileEntity(worldObj); - float hardness = blockHit.getBlockHardness(worldObj, hitCoord.xCoord, hitCoord.yCoord, hitCoord.zCoord); - - if(!(hardness < 0 || (tileHit instanceof ILaserReceptor && !((ILaserReceptor)tileHit).canLasersDig()))) - { - diggingProgress += firing; + if (ticks < time) { + ticks++; + } else { + ticks = 0; + } - if(diggingProgress >= hardness*general.laserEnergyNeededPerHardness) - { - LaserManager.breakBlock(hitCoord, true, worldObj); - diggingProgress = 0; - } - } - } - - emittingRedstone = info.foundEntity; + if (toFire() > 0) { + double firing = toFire(); - setEnergy(getEnergy() - firing); - } - else if(on) - { - on = false; - diggingProgress = 0; - Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this).getTargetPoint(50D)); - } - - if(outputMode != RedstoneOutput.ENTITY_DETECTION) - { - emittingRedstone = false; - } - - int newRedstoneLevel = getRedstoneLevel(); + if (!on || firing != lastFired) { + on = true; + lastFired = firing; + Mekanism.packetHandler.sendToAllAround( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + Coord4D.get(this).getTargetPoint(50D) + ); + } - if(newRedstoneLevel != currentRedstoneLevel) - { - markDirty(); - currentRedstoneLevel = newRedstoneLevel; - } - - if(emittingRedstone != prevRedstone) - { - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType()); - } - } - } + LaserInfo info = LaserManager.fireLaser( + this, ForgeDirection.getOrientation(facing), firing, worldObj + ); + Coord4D hitCoord = info.movingPos == null + ? null + : new Coord4D( + info.movingPos.blockX, + info.movingPos.blockY, + info.movingPos.blockZ, + worldObj.provider.dimensionId + ); - @Override - public void setEnergy(double energy) - { - collectedEnergy = Math.max(0, Math.min(energy, MAX_ENERGY)); - } + if (hitCoord == null || !hitCoord.equals(digging)) { + digging = hitCoord; + diggingProgress = 0; + } - @Override - public double getEnergy() - { - return collectedEnergy; - } + if (hitCoord != null) { + Block blockHit = hitCoord.getBlock(worldObj); + TileEntity tileHit = hitCoord.getTileEntity(worldObj); + float hardness = blockHit.getBlockHardness( + worldObj, hitCoord.xCoord, hitCoord.yCoord, hitCoord.zCoord + ); - public boolean shouldFire() - { - return collectedEnergy >= minThreshold && ticks >= time && MekanismUtils.canFunction(this); - } + if (!(hardness < 0 + || (tileHit instanceof ILaserReceptor + && !((ILaserReceptor) tileHit).canLasersDig()))) { + diggingProgress += firing; - public double toFire() - { - return shouldFire() ? Math.min(collectedEnergy, maxThreshold) : 0; - } - - public int getRedstoneLevel() - { - if(outputMode != RedstoneOutput.ENERGY_CONTENTS) - { - return 0; - } - - double fractionFull = getEnergy()/getMaxEnergy(); - return MathHelper.floor_float((float)(fractionFull * 14.0F)) + (fractionFull > 0 ? 1 : 0); - } + if (diggingProgress + >= hardness * general.laserEnergyNeededPerHardness) { + LaserManager.breakBlock(hitCoord, true, worldObj); + diggingProgress = 0; + } + } + } - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); + emittingRedstone = info.foundEntity; - data.add(on); - data.add(minThreshold); - data.add(maxThreshold); - data.add(time); - data.add(collectedEnergy); - data.add(lastFired); - data.add(controlType.ordinal()); - data.add(emittingRedstone); - data.add(outputMode.ordinal()); + setEnergy(getEnergy() - firing); + } else if (on) { + on = false; + diggingProgress = 0; + Mekanism.packetHandler.sendToAllAround( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + Coord4D.get(this).getTargetPoint(50D) + ); + } - return data; - } + if (outputMode != RedstoneOutput.ENTITY_DETECTION) { + emittingRedstone = false; + } - @Override - public void handlePacketData(ByteBuf dataStream) - { - if(!worldObj.isRemote) - { - switch(dataStream.readInt()) - { - case 0: - minThreshold = Math.min(MAX_ENERGY, MekanismUtils.convertToJoules(dataStream.readDouble())); - break; - case 1: - maxThreshold = Math.min(MAX_ENERGY, MekanismUtils.convertToJoules(dataStream.readDouble())); - break; - case 2: - time = dataStream.readInt(); - break; - case 3: - outputMode = RedstoneOutput.values()[outputMode.ordinal() == RedstoneOutput.values().length-1 ? 0 : outputMode.ordinal()+1]; - break; - } - - return; - } - - super.handlePacketData(dataStream); - - if(worldObj.isRemote) - { - on = dataStream.readBoolean(); - minThreshold = dataStream.readDouble(); - maxThreshold = dataStream.readDouble(); - time = dataStream.readInt(); - collectedEnergy = dataStream.readDouble(); - lastFired = dataStream.readDouble(); - controlType = RedstoneControl.values()[dataStream.readInt()]; - emittingRedstone = dataStream.readBoolean(); - outputMode = RedstoneOutput.values()[dataStream.readInt()]; - } - } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); + int newRedstoneLevel = getRedstoneLevel(); - on = nbtTags.getBoolean("on"); - minThreshold = nbtTags.getDouble("minThreshold"); - maxThreshold = nbtTags.getDouble("maxThreshold"); - time = nbtTags.getInteger("time"); - collectedEnergy = nbtTags.getDouble("collectedEnergy"); - lastFired = nbtTags.getDouble("lastFired"); - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - outputMode = RedstoneOutput.values()[nbtTags.getInteger("outputMode")]; - } + if (newRedstoneLevel != currentRedstoneLevel) { + markDirty(); + currentRedstoneLevel = newRedstoneLevel; + } - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); + if (emittingRedstone != prevRedstone) { + worldObj.notifyBlocksOfNeighborChange( + xCoord, yCoord, zCoord, getBlockType() + ); + } + } + } - nbtTags.setBoolean("on", on); - nbtTags.setDouble("minThreshold", minThreshold); - nbtTags.setDouble("maxThreshold", maxThreshold); - nbtTags.setInteger("time", time); - nbtTags.setDouble("collectedEnergy", collectedEnergy); - nbtTags.setDouble("lastFired", lastFired); - nbtTags.setInteger("controlType", controlType.ordinal()); - nbtTags.setInteger("outputMode", outputMode.ordinal()); - } + @Override + public void setEnergy(double energy) { + collectedEnergy = Math.max(0, Math.min(energy, MAX_ENERGY)); + } - @Override - public RedstoneControl getControlType() - { - return controlType; - } + @Override + public double getEnergy() { + return collectedEnergy; + } - @Override - public void setControlType(RedstoneControl type) - { - controlType = type; - } + public boolean shouldFire() { + return collectedEnergy >= minThreshold && ticks >= time + && MekanismUtils.canFunction(this); + } - @Override - public boolean canPulse() - { - return true; - } + public double toFire() { + return shouldFire() ? Math.min(collectedEnergy, maxThreshold) : 0; + } - @Override - public boolean canOutputTo(ForgeDirection side) - { - return true; - } + public int getRedstoneLevel() { + if (outputMode != RedstoneOutput.ENERGY_CONTENTS) { + return 0; + } - @Override - public double getMaxEnergy() - { - return MAX_ENERGY; - } + double fractionFull = getEnergy() / getMaxEnergy(); + return MathHelper.floor_float((float) (fractionFull * 14.0F)) + + (fractionFull > 0 ? 1 : 0); + } - private static final String[] methods = new String[] {"getEnergy", "getMaxEnergy"}; + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); - @Override - public String[] getMethods() - { - return methods; - } + data.add(on); + data.add(minThreshold); + data.add(maxThreshold); + data.add(time); + data.add(collectedEnergy); + data.add(lastFired); + data.add(controlType.ordinal()); + data.add(emittingRedstone); + data.add(outputMode.ordinal()); - @Override - public Object[] invoke(int method, Object[] arguments) throws Exception - { - switch(method) - { - case 0: - return new Object[] {getEnergy()}; - case 1: - return new Object[] {getMaxEnergy()}; - default: - throw new NoSuchMethodException(); - } - } - - @Override - public TileComponentSecurity getSecurity() - { - return securityComponent; - } - - public static enum RedstoneOutput - { - OFF("off"), - ENTITY_DETECTION("entityDetection"), - ENERGY_CONTENTS("energyContents"); - - private String unlocalizedName; - - private RedstoneOutput(String name) - { - unlocalizedName = name; - } - - public String getName() - { - return LangUtils.localize("gui." + unlocalizedName); - } - } + return data; + } + + @Override + public void handlePacketData(ByteBuf dataStream) { + if (!worldObj.isRemote) { + switch (dataStream.readInt()) { + case 0: + minThreshold = Math.min( + MAX_ENERGY, MekanismUtils.convertToJoules(dataStream.readDouble()) + ); + break; + case 1: + maxThreshold = Math.min( + MAX_ENERGY, MekanismUtils.convertToJoules(dataStream.readDouble()) + ); + break; + case 2: + time = dataStream.readInt(); + break; + case 3: + outputMode = RedstoneOutput.values( + )[outputMode.ordinal() == RedstoneOutput.values().length - 1 + ? 0 + : outputMode.ordinal() + 1]; + break; + } + + return; + } + + super.handlePacketData(dataStream); + + if (worldObj.isRemote) { + on = dataStream.readBoolean(); + minThreshold = dataStream.readDouble(); + maxThreshold = dataStream.readDouble(); + time = dataStream.readInt(); + collectedEnergy = dataStream.readDouble(); + lastFired = dataStream.readDouble(); + controlType = RedstoneControl.values()[dataStream.readInt()]; + emittingRedstone = dataStream.readBoolean(); + outputMode = RedstoneOutput.values()[dataStream.readInt()]; + } + } + + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); + + on = nbtTags.getBoolean("on"); + minThreshold = nbtTags.getDouble("minThreshold"); + maxThreshold = nbtTags.getDouble("maxThreshold"); + time = nbtTags.getInteger("time"); + collectedEnergy = nbtTags.getDouble("collectedEnergy"); + lastFired = nbtTags.getDouble("lastFired"); + controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + outputMode = RedstoneOutput.values()[nbtTags.getInteger("outputMode")]; + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); + + nbtTags.setBoolean("on", on); + nbtTags.setDouble("minThreshold", minThreshold); + nbtTags.setDouble("maxThreshold", maxThreshold); + nbtTags.setInteger("time", time); + nbtTags.setDouble("collectedEnergy", collectedEnergy); + nbtTags.setDouble("lastFired", lastFired); + nbtTags.setInteger("controlType", controlType.ordinal()); + nbtTags.setInteger("outputMode", outputMode.ordinal()); + } + + @Override + public RedstoneControl getControlType() { + return controlType; + } + + @Override + public void setControlType(RedstoneControl type) { + controlType = type; + } + + @Override + public boolean canPulse() { + return true; + } + + @Override + public boolean canOutputTo(ForgeDirection side) { + return true; + } + + @Override + public double getMaxEnergy() { + return MAX_ENERGY; + } + + private static final String[] methods = new String[] { "getEnergy", "getMaxEnergy" }; + + @Override + public String[] getMethods() { + return methods; + } + + @Override + public Object[] invoke(int method, Object[] arguments) throws Exception { + switch (method) { + case 0: + return new Object[] { getEnergy() }; + case 1: + return new Object[] { getMaxEnergy() }; + default: + throw new NoSuchMethodException(); + } + } + + @Override + public TileComponentSecurity getSecurity() { + return securityComponent; + } + + public static enum RedstoneOutput { + OFF("off"), + ENTITY_DETECTION("entityDetection"), + ENERGY_CONTENTS("energyContents"); + + private String unlocalizedName; + + private RedstoneOutput(String name) { + unlocalizedName = name; + } + + public String getName() { + return LangUtils.localize("gui." + unlocalizedName); + } + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityLaserTractorBeam.java b/src/main/java/mekanism/common/tile/TileEntityLaserTractorBeam.java index 04c49ee59..e87338118 100644 --- a/src/main/java/mekanism/common/tile/TileEntityLaserTractorBeam.java +++ b/src/main/java/mekanism/common/tile/TileEntityLaserTractorBeam.java @@ -1,10 +1,9 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.List; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.MekanismConfig.general; import mekanism.api.lasers.ILaserReceptor; @@ -23,206 +22,214 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MovingObjectPosition; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityLaserTractorBeam extends TileEntityContainerBlock implements ILaserReceptor, ISecurityTile -{ - public static final double MAX_ENERGY = 5E9; - public double collectedEnergy = 0; - public double lastFired = 0; +public class TileEntityLaserTractorBeam + extends TileEntityContainerBlock implements ILaserReceptor, ISecurityTile { + public static final double MAX_ENERGY = 5E9; + public double collectedEnergy = 0; + public double lastFired = 0; - public boolean on = false; + public boolean on = false; - public Coord4D digging; - public double diggingProgress; + public Coord4D digging; + public double diggingProgress; - public static int[] availableSlotIDs = InventoryUtils.getIntRange(0, 26); - - public TileComponentSecurity securityComponent = new TileComponentSecurity(this); + public static int[] availableSlotIDs = InventoryUtils.getIntRange(0, 26); - public TileEntityLaserTractorBeam() - { - super("LaserTractorBeam"); - inventory = new ItemStack[27]; - } + public TileComponentSecurity securityComponent = new TileComponentSecurity(this); - @Override - public void receiveLaserEnergy(double energy, ForgeDirection side) - { - setEnergy(getEnergy() + energy); - } + public TileEntityLaserTractorBeam() { + super("LaserTractorBeam"); + inventory = new ItemStack[27]; + } - @Override - public boolean canLasersDig() - { - return false; - } + @Override + public void receiveLaserEnergy(double energy, ForgeDirection side) { + setEnergy(getEnergy() + energy); + } - @Override - public void onUpdate() - { - if(worldObj.isRemote) - { - if(on) - { - MovingObjectPosition mop = LaserManager.fireLaserClient(this, ForgeDirection.getOrientation(facing), lastFired, worldObj); - Coord4D hitCoord = mop == null ? null : new Coord4D(mop.blockX, mop.blockY, mop.blockZ, worldObj.provider.dimensionId); + @Override + public boolean canLasersDig() { + return false; + } - if(hitCoord == null || !hitCoord.equals(digging)) - { - digging = hitCoord; - diggingProgress = 0; - } + @Override + public void onUpdate() { + if (worldObj.isRemote) { + if (on) { + MovingObjectPosition mop = LaserManager.fireLaserClient( + this, ForgeDirection.getOrientation(facing), lastFired, worldObj + ); + Coord4D hitCoord = mop == null + ? null + : new Coord4D( + mop.blockX, mop.blockY, mop.blockZ, worldObj.provider.dimensionId + ); - if(hitCoord != null) - { - Block blockHit = hitCoord.getBlock(worldObj); - TileEntity tileHit = hitCoord.getTileEntity(worldObj); - float hardness = blockHit.getBlockHardness(worldObj, hitCoord.xCoord, hitCoord.yCoord, hitCoord.zCoord); - if(!(hardness < 0 || (tileHit instanceof ILaserReceptor && !((ILaserReceptor)tileHit).canLasersDig()))) - { - diggingProgress += lastFired; + if (hitCoord == null || !hitCoord.equals(digging)) { + digging = hitCoord; + diggingProgress = 0; + } - if(diggingProgress < hardness * general.laserEnergyNeededPerHardness) - { - Mekanism.proxy.addHitEffects(hitCoord, mop); - } - } - } + if (hitCoord != null) { + Block blockHit = hitCoord.getBlock(worldObj); + TileEntity tileHit = hitCoord.getTileEntity(worldObj); + float hardness = blockHit.getBlockHardness( + worldObj, hitCoord.xCoord, hitCoord.yCoord, hitCoord.zCoord + ); + if (!(hardness < 0 + || (tileHit instanceof ILaserReceptor + && !((ILaserReceptor) tileHit).canLasersDig()))) { + diggingProgress += lastFired; - } - } - else { - if(collectedEnergy > 0) - { - double firing = collectedEnergy; + if (diggingProgress + < hardness * general.laserEnergyNeededPerHardness) { + Mekanism.proxy.addHitEffects(hitCoord, mop); + } + } + } + } + } else { + if (collectedEnergy > 0) { + double firing = collectedEnergy; - if(!on || firing != lastFired) - { - on = true; - lastFired = firing; - Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this).getTargetPoint(50D)); - } + if (!on || firing != lastFired) { + on = true; + lastFired = firing; + Mekanism.packetHandler.sendToAllAround( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + Coord4D.get(this).getTargetPoint(50D) + ); + } - LaserInfo info = LaserManager.fireLaser(this, ForgeDirection.getOrientation(facing), firing, worldObj); - Coord4D hitCoord = info.movingPos == null ? null : new Coord4D(info.movingPos.blockX, info.movingPos.blockY, info.movingPos.blockZ, worldObj.provider.dimensionId); + LaserInfo info = LaserManager.fireLaser( + this, ForgeDirection.getOrientation(facing), firing, worldObj + ); + Coord4D hitCoord = info.movingPos == null + ? null + : new Coord4D( + info.movingPos.blockX, + info.movingPos.blockY, + info.movingPos.blockZ, + worldObj.provider.dimensionId + ); - if(hitCoord == null || !hitCoord.equals(digging)) - { - digging = hitCoord; - diggingProgress = 0; - } + if (hitCoord == null || !hitCoord.equals(digging)) { + digging = hitCoord; + diggingProgress = 0; + } - if(hitCoord != null) - { - Block blockHit = hitCoord.getBlock(worldObj); - TileEntity tileHit = hitCoord.getTileEntity(worldObj); - float hardness = blockHit.getBlockHardness(worldObj, hitCoord.xCoord, hitCoord.yCoord, hitCoord.zCoord); - if(!(hardness < 0 || (tileHit instanceof ILaserReceptor && !((ILaserReceptor)tileHit).canLasersDig()))) - { - diggingProgress += firing; + if (hitCoord != null) { + Block blockHit = hitCoord.getBlock(worldObj); + TileEntity tileHit = hitCoord.getTileEntity(worldObj); + float hardness = blockHit.getBlockHardness( + worldObj, hitCoord.xCoord, hitCoord.yCoord, hitCoord.zCoord + ); + if (!(hardness < 0 + || (tileHit instanceof ILaserReceptor + && !((ILaserReceptor) tileHit).canLasersDig()))) { + diggingProgress += firing; - if(diggingProgress >= hardness * general.laserEnergyNeededPerHardness) - { - List drops = LaserManager.breakBlock(hitCoord, false, worldObj); - if(drops != null) receiveDrops(drops); - diggingProgress = 0; - } - } - } + if (diggingProgress + >= hardness * general.laserEnergyNeededPerHardness) { + List drops + = LaserManager.breakBlock(hitCoord, false, worldObj); + if (drops != null) + receiveDrops(drops); + diggingProgress = 0; + } + } + } - setEnergy(getEnergy() - firing); - } - else if(on) - { - on = false; - diggingProgress = 0; - Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this).getTargetPoint(50D)); - } - } - } + setEnergy(getEnergy() - firing); + } else if (on) { + on = false; + diggingProgress = 0; + Mekanism.packetHandler.sendToAllAround( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + Coord4D.get(this).getTargetPoint(50D) + ); + } + } + } - public void setEnergy(double energy) - { - collectedEnergy = Math.max(0, Math.min(energy, MAX_ENERGY)); - } + public void setEnergy(double energy) { + collectedEnergy = Math.max(0, Math.min(energy, MAX_ENERGY)); + } - public double getEnergy() - { - return collectedEnergy; - } + public double getEnergy() { + return collectedEnergy; + } - public void receiveDrops(List drops) - { - outer: - for(ItemStack drop : drops) - { - for(int i = 0; i < inventory.length; i++) - { - if(inventory[i] == null) - { - inventory[i] = drop; - continue outer; - } - ItemStack slot = inventory[i]; - if(StackUtils.equalsWildcardWithNBT(slot, drop)) - { - int change = Math.min(drop.stackSize, slot.getMaxStackSize() - slot.stackSize); - slot.stackSize += change; - drop.stackSize -= change; - if(drop.stackSize <= 0) continue outer; - } - } - dropItem(drop); - } - } + public void receiveDrops(List drops) { + outer: + for (ItemStack drop : drops) { + for (int i = 0; i < inventory.length; i++) { + if (inventory[i] == null) { + inventory[i] = drop; + continue outer; + } + ItemStack slot = inventory[i]; + if (StackUtils.equalsWildcardWithNBT(slot, drop)) { + int change = Math.min( + drop.stackSize, slot.getMaxStackSize() - slot.stackSize + ); + slot.stackSize += change; + drop.stackSize -= change; + if (drop.stackSize <= 0) + continue outer; + } + } + dropItem(drop); + } + } - public void dropItem(ItemStack stack) - { - EntityItem item = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1, zCoord + 0.5, stack); - item.motionX = worldObj.rand.nextGaussian() * 0.05; - item.motionY = worldObj.rand.nextGaussian() * 0.05 + 0.2; - item.motionZ = worldObj.rand.nextGaussian() * 0.05; - item.delayBeforeCanPickup = 10; - worldObj.spawnEntityInWorld(item); - } + public void dropItem(ItemStack stack) { + EntityItem item + = new EntityItem(worldObj, xCoord + 0.5, yCoord + 1, zCoord + 0.5, stack); + item.motionX = worldObj.rand.nextGaussian() * 0.05; + item.motionY = worldObj.rand.nextGaussian() * 0.05 + 0.2; + item.motionZ = worldObj.rand.nextGaussian() * 0.05; + item.delayBeforeCanPickup = 10; + worldObj.spawnEntityInWorld(item); + } - public boolean canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_) - { - return false; - } + public boolean + canInsertItem(int p_102007_1_, ItemStack p_102007_2_, int p_102007_3_) { + return false; + } - public int[] getAccessibleSlotsFromSide(int p_94128_1_) - { - return availableSlotIDs; - } + public int[] getAccessibleSlotsFromSide(int p_94128_1_) { + return availableSlotIDs; + } - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); - data.add(on); - data.add(collectedEnergy); - data.add(lastFired); + data.add(on); + data.add(collectedEnergy); + data.add(lastFired); - return data; - } + return data; + } - @Override - public void handlePacketData(ByteBuf dataStream) - { - super.handlePacketData(dataStream); - - if(worldObj.isRemote) - { - on = dataStream.readBoolean(); - collectedEnergy = dataStream.readDouble(); - lastFired = dataStream.readDouble(); - } - } - - @Override - public TileComponentSecurity getSecurity() - { - return securityComponent; - } + @Override + public void handlePacketData(ByteBuf dataStream) { + super.handlePacketData(dataStream); + + if (worldObj.isRemote) { + on = dataStream.readBoolean(); + collectedEnergy = dataStream.readDouble(); + lastFired = dataStream.readDouble(); + } + } + + @Override + public TileComponentSecurity getSecurity() { + return securityComponent; + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityLogisticalSorter.java b/src/main/java/mekanism/common/tile/TileEntityLogisticalSorter.java index ffc377dd9..f6aaa7909 100644 --- a/src/main/java/mekanism/common/tile/TileEntityLogisticalSorter.java +++ b/src/main/java/mekanism/common/tile/TileEntityLogisticalSorter.java @@ -1,10 +1,9 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.EnumSet; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.IConfigCardAccess.ISpecialConfigData; @@ -40,679 +39,640 @@ import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.Constants.NBT; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityLogisticalSorter extends TileEntityElectricBlock implements IRedstoneControl, IActiveState, ISpecialConfigData, ISustainedData, ISecurityTile -{ - public HashList filters = new HashList(); +public class TileEntityLogisticalSorter extends TileEntityElectricBlock + implements IRedstoneControl, IActiveState, ISpecialConfigData, ISustainedData, + ISecurityTile { + public HashList filters = new HashList(); - public RedstoneControl controlType = RedstoneControl.DISABLED; + public RedstoneControl controlType = RedstoneControl.DISABLED; - public EnumColor color; - - public boolean autoEject; - - public boolean roundRobin; - - public int rrIndex = 0; - - public final int MAX_DELAY = 10; - - public int delayTicks; - - public boolean isActive; - - public boolean clientActive; - - public final double ENERGY_PER_ITEM = 5; - - public TileComponentSecurity securityComponent = new TileComponentSecurity(this); - - public TileEntityLogisticalSorter() - { - super("LogisticalSorter", MachineType.LOGISTICAL_SORTER.baseEnergy); - inventory = new ItemStack[1]; - doAutoSync = false; - } - - @Override - public void onUpdate() - { - super.onUpdate(); - - if(!worldObj.isRemote) - { - delayTicks = Math.max(0, delayTicks-1); - - if(delayTicks == 6) - { - setActive(false); - } - - if(MekanismUtils.canFunction(this) && delayTicks == 0) - { - TileEntity back = Coord4D.get(this).getFromSide(ForgeDirection.getOrientation(facing).getOpposite()).getTileEntity(worldObj); - TileEntity front = Coord4D.get(this).getFromSide(ForgeDirection.getOrientation(facing)).getTileEntity(worldObj); - - if(back instanceof IInventory && (front instanceof ITransporterTile || front instanceof IInventory)) - { - IInventory inventory = InventoryUtils.checkChestInv((IInventory)back); - - boolean sentItems = false; - int min = 0; - - outer: - for(TransporterFilter filter : filters) - { - inner: - for(StackSearcher search = new StackSearcher(inventory, ForgeDirection.getOrientation(facing).getOpposite()); search.i >= 0;) - { - InvStack invStack = filter.getStackFromInventory(search); - - if(invStack == null || invStack.getStack() == null) - { - break inner; - } - - if(filter.canFilter(invStack.getStack())) - { - if(filter instanceof TItemStackFilter) - { - TItemStackFilter itemFilter = (TItemStackFilter)filter; - - if(itemFilter.sizeMode) - { - min = itemFilter.min; - } - } - - ItemStack used = emitItemToTransporter(front, invStack, filter.color, min); - - if(used != null) - { - invStack.use(used.stackSize); - inventory.markDirty(); - setActive(true); - sentItems = true; - - break outer; - } - } - - } - } - - if(!sentItems && autoEject) - { - InvStack invStack = InventoryUtils.takeTopStack(inventory, ForgeDirection.getOrientation(facing).getOpposite().ordinal(), new FirstFinder()); - - if(invStack != null && invStack.getStack() != null) - { - ItemStack used = emitItemToTransporter(front, invStack, color, 0); - - if(used != null) - { - invStack.use(used.stackSize); - inventory.markDirty(); - setActive(true); - } - } - } - - delayTicks = 10; - } - } - - if(playersUsing.size() > 0) - { - for(EntityPlayer player : playersUsing) - { - Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(this), getGenericPacket(new ArrayList())), (EntityPlayerMP)player); - } - } - } - } - - /* - * Returns used - */ - public ItemStack emitItemToTransporter(TileEntity front, InvStack inInventory, EnumColor filterColor, int min) - { - ItemStack used = null; - - if(front instanceof ITransporterTile) - { - ILogisticalTransporter transporter = ((ITransporterTile)front).getTransmitter(); - - if(!roundRobin) - { - ItemStack rejects = TransporterUtils.insert(this, transporter, inInventory.getStack(), filterColor, true, min); - - if(TransporterManager.didEmit(inInventory.getStack(), rejects)) - { - used = TransporterManager.getToUse(inInventory.getStack(), rejects); - } - } - else { - ItemStack rejects = TransporterUtils.insertRR(this, transporter, inInventory.getStack(), filterColor, true, min); - - if(TransporterManager.didEmit(inInventory.getStack(), rejects)) - { - used = TransporterManager.getToUse(inInventory.getStack(), rejects); - } - } - } - else if(front instanceof IInventory) - { - ItemStack rejects = InventoryUtils.putStackInInventory((IInventory)front, inInventory.getStack(), facing, false); - - if(TransporterManager.didEmit(inInventory.getStack(), rejects)) - { - used = TransporterManager.getToUse(inInventory.getStack(), rejects); - } - } - - return used; - } - - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - nbtTags.setInteger("controlType", controlType.ordinal()); - - if(color != null) - { - nbtTags.setInteger("color", TransporterUtils.colors.indexOf(color)); - } - - nbtTags.setBoolean("autoEject", autoEject); - nbtTags.setBoolean("roundRobin", roundRobin); - - nbtTags.setInteger("rrIndex", rrIndex); - - NBTTagList filterTags = new NBTTagList(); - - for(TransporterFilter filter : filters) - { - NBTTagCompound tagCompound = new NBTTagCompound(); - filter.write(tagCompound); - filterTags.appendTag(tagCompound); - } - - if(filterTags.tagCount() != 0) - { - nbtTags.setTag("filters", filterTags); - } - } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - - if(nbtTags.hasKey("color")) - { - color = TransporterUtils.colors.get(nbtTags.getInteger("color")); - } - - autoEject = nbtTags.getBoolean("autoEject"); - roundRobin = nbtTags.getBoolean("roundRobin"); - - rrIndex = nbtTags.getInteger("rrIndex"); - - if(nbtTags.hasKey("filters")) - { - NBTTagList tagList = nbtTags.getTagList("filters", NBT.TAG_COMPOUND); - - for(int i = 0; i < tagList.tagCount(); i++) - { - filters.add(TransporterFilter.readFromNBT((NBTTagCompound)tagList.getCompoundTagAt(i))); - } - } - } - - @Override - public void handlePacketData(ByteBuf dataStream) - { - if(!worldObj.isRemote) - { - int type = dataStream.readInt(); - - if(type == 0) - { - int clickType = dataStream.readInt(); - - if(clickType == 0) - { - color = TransporterUtils.increment(color); - } - else if(clickType == 1) - { - color = TransporterUtils.decrement(color); - } - else if(clickType == 2) - { - color = null; - } - } - else if(type == 1) - { - autoEject = !autoEject; - } - else if(type == 2) - { - roundRobin = !roundRobin; - rrIndex = 0; - } - else if(type == 3) - { - // Move filter up - int filterIndex = dataStream.readInt(); - filters.swap( filterIndex, filterIndex - 1 ); - openInventory(); - } - else if(type == 4) - { - // Move filter down - int filterIndex = dataStream.readInt(); - filters.swap( filterIndex, filterIndex + 1 ); - openInventory(); - } - - return; - } - - super.handlePacketData(dataStream); - - if(worldObj.isRemote) - { - int type = dataStream.readInt(); - - if(type == 0) - { - isActive = dataStream.readBoolean(); - controlType = RedstoneControl.values()[dataStream.readInt()]; - - int c = dataStream.readInt(); - - if(c != -1) - { - color = TransporterUtils.colors.get(c); - } - else { - color = null; - } - - autoEject = dataStream.readBoolean(); - roundRobin = dataStream.readBoolean(); - - filters.clear(); - - int amount = dataStream.readInt(); - - for(int i = 0; i < amount; i++) - { - filters.add(TransporterFilter.readFromPacket(dataStream)); - } - - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - else if(type == 1) - { - isActive = dataStream.readBoolean(); - controlType = RedstoneControl.values()[dataStream.readInt()]; - - int c = dataStream.readInt(); - - if(c != -1) - { - color = TransporterUtils.colors.get(c); - } - else { - color = null; - } - - autoEject = dataStream.readBoolean(); - roundRobin = dataStream.readBoolean(); - - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - else if(type == 2) - { - filters.clear(); - - int amount = dataStream.readInt(); - - for(int i = 0; i < amount; i++) - { - filters.add(TransporterFilter.readFromPacket(dataStream)); - } - } - } - } - - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); - - data.add(0); - - data.add(isActive); - data.add(controlType.ordinal()); - - if(color != null) - { - data.add(TransporterUtils.colors.indexOf(color)); - } - else { - data.add(-1); - } - - data.add(autoEject); - data.add(roundRobin); - - data.add(filters.size()); - - for(TransporterFilter filter : filters) - { - filter.write(data); - } - - return data; - } - - public ArrayList getGenericPacket(ArrayList data) - { - super.getNetworkedData(data); - - data.add(1); - - data.add(isActive); - data.add(controlType.ordinal()); - - if(color != null) - { - data.add(TransporterUtils.colors.indexOf(color)); - } - else { - data.add(-1); - } - - data.add(autoEject); - data.add(roundRobin); - - return data; - - } - - public ArrayList getFilterPacket(ArrayList data) - { - super.getNetworkedData(data); - - data.add(2); - - data.add(filters.size()); - - for(TransporterFilter filter : filters) - { - filter.write(data); - } - - return data; - } - - public boolean canSendHome(ItemStack stack) - { - TileEntity back = Coord4D.get(this).getFromSide(ForgeDirection.getOrientation(facing).getOpposite()).getTileEntity(worldObj); - - if(back instanceof IInventory) - { - return InventoryUtils.canInsert(back, null, stack, ForgeDirection.getOrientation(facing).getOpposite().ordinal(), true); - } - - return false; - } - - public boolean hasInventory() - { - return Coord4D.get(this).getFromSide(ForgeDirection.getOrientation(facing).getOpposite()).getTileEntity(worldObj) instanceof IInventory; - } - - public ItemStack sendHome(ItemStack stack) - { - TileEntity back = Coord4D.get(this).getFromSide(ForgeDirection.getOrientation(facing).getOpposite()).getTileEntity(worldObj); - - if(back instanceof IInventory) - { - return InventoryUtils.putStackInInventory((IInventory)back, stack, ForgeDirection.getOrientation(facing).getOpposite().ordinal(), true); - } - - return stack; - } - - @Override - public boolean canExtractItem(int slotID, ItemStack itemstack, int side) - { - return false; - } - - @Override - public boolean isItemValidForSlot(int slotID, ItemStack itemstack) - { - return false; - } - - @Override - public int getInventoryStackLimit() - { - return 1; - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) - { - if(side == ForgeDirection.getOrientation(facing).ordinal() || side == ForgeDirection.getOrientation(facing).getOpposite().ordinal()) - { - return new int[] {0}; - } - - return InventoryUtils.EMPTY; - } - - @Override - public void openInventory() - { - if(!worldObj.isRemote) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getFilterPacket(new ArrayList())), new Range4D(Coord4D.get(this))); - } - } - - @Override - public RedstoneControl getControlType() - { - return controlType; - } - - @Override - public void setControlType(RedstoneControl type) - { - controlType = type; - } - - @Override - public boolean canPulse() - { - return true; - } - - @Override - public void setActive(boolean active) - { - isActive = active; - - if(clientActive != active) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - - if(active && client.enableMachineSounds) - { - worldObj.playSoundEffect(xCoord, yCoord, zCoord, "mekanism:etc.Click", 0.3F, 1); - } - - clientActive = active; - } - } - - @Override - public boolean getActive() - { - return isActive; - } - - @Override - public boolean renderUpdate() - { - return true; - } - - @Override - public boolean lightUpdate() - { - return false; - } - - @Override - public EnumSet getConsumingSides() - { - return EnumSet.noneOf(ForgeDirection.class); - } - - @Override - public boolean canSetFacing(int facing) - { - return true; - } - - @Override - public TileComponentSecurity getSecurity() - { - return securityComponent; - } - - @Override - public NBTTagCompound getConfigurationData(NBTTagCompound nbtTags) - { - if(color != null) - { - nbtTags.setInteger("color", TransporterUtils.colors.indexOf(color)); - } - - nbtTags.setBoolean("autoEject", autoEject); - nbtTags.setBoolean("roundRobin", roundRobin); - - nbtTags.setInteger("rrIndex", rrIndex); - - NBTTagList filterTags = new NBTTagList(); - - for(TransporterFilter filter : filters) - { - NBTTagCompound tagCompound = new NBTTagCompound(); - filter.write(tagCompound); - filterTags.appendTag(tagCompound); - } - - if(filterTags.tagCount() != 0) - { - nbtTags.setTag("filters", filterTags); - } - - return nbtTags; - } - - @Override - public void setConfigurationData(NBTTagCompound nbtTags) - { - if(nbtTags.hasKey("color")) - { - color = TransporterUtils.colors.get(nbtTags.getInteger("color")); - } - - autoEject = nbtTags.getBoolean("autoEject"); - roundRobin = nbtTags.getBoolean("roundRobin"); - - rrIndex = nbtTags.getInteger("rrIndex"); - - if(nbtTags.hasKey("filters")) - { - NBTTagList tagList = nbtTags.getTagList("filters", NBT.TAG_COMPOUND); - - for(int i = 0; i < tagList.tagCount(); i++) - { - filters.add(TransporterFilter.readFromNBT((NBTTagCompound)tagList.getCompoundTagAt(i))); - } - } - } - - @Override - public String getDataType() - { - return getBlockType().getUnlocalizedName() + "." + fullName + ".name"; - } - - @Override - public void writeSustainedData(ItemStack itemStack) - { - itemStack.stackTagCompound.setBoolean("hasSorterConfig", true); - - if(color != null) - { - itemStack.stackTagCompound.setInteger("color", TransporterUtils.colors.indexOf(color)); - } - - itemStack.stackTagCompound.setBoolean("autoEject", autoEject); - itemStack.stackTagCompound.setBoolean("roundRobin", roundRobin); - - NBTTagList filterTags = new NBTTagList(); - - for(TransporterFilter filter : filters) - { - NBTTagCompound tagCompound = new NBTTagCompound(); - filter.write(tagCompound); - filterTags.appendTag(tagCompound); - } - - if(filterTags.tagCount() != 0) - { - itemStack.stackTagCompound.setTag("filters", filterTags); - } - } - - @Override - public void readSustainedData(ItemStack itemStack) - { - if(itemStack.stackTagCompound.hasKey("hasSorterConfig")) - { - if(itemStack.stackTagCompound.hasKey("color")) - { - color = TransporterUtils.colors.get(itemStack.stackTagCompound.getInteger("color")); - } - - autoEject = itemStack.stackTagCompound.getBoolean("autoEject"); - roundRobin = itemStack.stackTagCompound.getBoolean("roundRobin"); - - if(itemStack.stackTagCompound.hasKey("filters")) - { - NBTTagList tagList = itemStack.stackTagCompound.getTagList("filters", NBT.TAG_COMPOUND); - - for(int i = 0; i < tagList.tagCount(); i++) - { - filters.add(TransporterFilter.readFromNBT((NBTTagCompound)tagList.getCompoundTagAt(i))); - } - } - } - } + public EnumColor color; + + public boolean autoEject; + + public boolean roundRobin; + + public int rrIndex = 0; + + public final int MAX_DELAY = 10; + + public int delayTicks; + + public boolean isActive; + + public boolean clientActive; + + public final double ENERGY_PER_ITEM = 5; + + public TileComponentSecurity securityComponent = new TileComponentSecurity(this); + + public TileEntityLogisticalSorter() { + super("LogisticalSorter", MachineType.LOGISTICAL_SORTER.baseEnergy); + inventory = new ItemStack[1]; + doAutoSync = false; + } + + @Override + public void onUpdate() { + super.onUpdate(); + + if (!worldObj.isRemote) { + delayTicks = Math.max(0, delayTicks - 1); + + if (delayTicks == 6) { + setActive(false); + } + + if (MekanismUtils.canFunction(this) && delayTicks == 0) { + TileEntity back + = Coord4D.get(this) + .getFromSide(ForgeDirection.getOrientation(facing).getOpposite() + ) + .getTileEntity(worldObj); + TileEntity front = Coord4D.get(this) + .getFromSide(ForgeDirection.getOrientation(facing)) + .getTileEntity(worldObj); + + if (back instanceof IInventory + && (front instanceof ITransporterTile || front instanceof IInventory + )) { + IInventory inventory + = InventoryUtils.checkChestInv((IInventory) back); + + boolean sentItems = false; + int min = 0; + + outer: + for (TransporterFilter filter : filters) { + inner: + for (StackSearcher search = new StackSearcher( + inventory, + ForgeDirection.getOrientation(facing).getOpposite() + ); + search.i >= 0;) { + InvStack invStack = filter.getStackFromInventory(search); + + if (invStack == null || invStack.getStack() == null) { + break inner; + } + + if (filter.canFilter(invStack.getStack())) { + if (filter instanceof TItemStackFilter) { + TItemStackFilter itemFilter + = (TItemStackFilter) filter; + + if (itemFilter.sizeMode) { + min = itemFilter.min; + } + } + + ItemStack used = emitItemToTransporter( + front, invStack, filter.color, min + ); + + if (used != null) { + invStack.use(used.stackSize); + inventory.markDirty(); + setActive(true); + sentItems = true; + + break outer; + } + } + } + } + + if (!sentItems && autoEject) { + InvStack invStack = InventoryUtils.takeTopStack( + inventory, + ForgeDirection.getOrientation(facing).getOpposite().ordinal(), + new FirstFinder() + ); + + if (invStack != null && invStack.getStack() != null) { + ItemStack used + = emitItemToTransporter(front, invStack, color, 0); + + if (used != null) { + invStack.use(used.stackSize); + inventory.markDirty(); + setActive(true); + } + } + } + + delayTicks = 10; + } + } + + if (playersUsing.size() > 0) { + for (EntityPlayer player : playersUsing) { + Mekanism.packetHandler.sendTo( + new TileEntityMessage( + Coord4D.get(this), getGenericPacket(new ArrayList()) + ), + (EntityPlayerMP) player + ); + } + } + } + } + + /* + * Returns used + */ + public ItemStack emitItemToTransporter( + TileEntity front, InvStack inInventory, EnumColor filterColor, int min + ) { + ItemStack used = null; + + if (front instanceof ITransporterTile) { + ILogisticalTransporter transporter + = ((ITransporterTile) front).getTransmitter(); + + if (!roundRobin) { + ItemStack rejects = TransporterUtils.insert( + this, transporter, inInventory.getStack(), filterColor, true, min + ); + + if (TransporterManager.didEmit(inInventory.getStack(), rejects)) { + used = TransporterManager.getToUse(inInventory.getStack(), rejects); + } + } else { + ItemStack rejects = TransporterUtils.insertRR( + this, transporter, inInventory.getStack(), filterColor, true, min + ); + + if (TransporterManager.didEmit(inInventory.getStack(), rejects)) { + used = TransporterManager.getToUse(inInventory.getStack(), rejects); + } + } + } else if (front instanceof IInventory) { + ItemStack rejects = InventoryUtils.putStackInInventory( + (IInventory) front, inInventory.getStack(), facing, false + ); + + if (TransporterManager.didEmit(inInventory.getStack(), rejects)) { + used = TransporterManager.getToUse(inInventory.getStack(), rejects); + } + } + + return used; + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); + + nbtTags.setInteger("controlType", controlType.ordinal()); + + if (color != null) { + nbtTags.setInteger("color", TransporterUtils.colors.indexOf(color)); + } + + nbtTags.setBoolean("autoEject", autoEject); + nbtTags.setBoolean("roundRobin", roundRobin); + + nbtTags.setInteger("rrIndex", rrIndex); + + NBTTagList filterTags = new NBTTagList(); + + for (TransporterFilter filter : filters) { + NBTTagCompound tagCompound = new NBTTagCompound(); + filter.write(tagCompound); + filterTags.appendTag(tagCompound); + } + + if (filterTags.tagCount() != 0) { + nbtTags.setTag("filters", filterTags); + } + } + + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); + + controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + + if (nbtTags.hasKey("color")) { + color = TransporterUtils.colors.get(nbtTags.getInteger("color")); + } + + autoEject = nbtTags.getBoolean("autoEject"); + roundRobin = nbtTags.getBoolean("roundRobin"); + + rrIndex = nbtTags.getInteger("rrIndex"); + + if (nbtTags.hasKey("filters")) { + NBTTagList tagList = nbtTags.getTagList("filters", NBT.TAG_COMPOUND); + + for (int i = 0; i < tagList.tagCount(); i++) { + filters.add(TransporterFilter.readFromNBT((NBTTagCompound + ) tagList.getCompoundTagAt(i))); + } + } + } + + @Override + public void handlePacketData(ByteBuf dataStream) { + if (!worldObj.isRemote) { + int type = dataStream.readInt(); + + if (type == 0) { + int clickType = dataStream.readInt(); + + if (clickType == 0) { + color = TransporterUtils.increment(color); + } else if (clickType == 1) { + color = TransporterUtils.decrement(color); + } else if (clickType == 2) { + color = null; + } + } else if (type == 1) { + autoEject = !autoEject; + } else if (type == 2) { + roundRobin = !roundRobin; + rrIndex = 0; + } else if (type == 3) { + // Move filter up + int filterIndex = dataStream.readInt(); + filters.swap(filterIndex, filterIndex - 1); + openInventory(); + } else if (type == 4) { + // Move filter down + int filterIndex = dataStream.readInt(); + filters.swap(filterIndex, filterIndex + 1); + openInventory(); + } + + return; + } + + super.handlePacketData(dataStream); + + if (worldObj.isRemote) { + int type = dataStream.readInt(); + + if (type == 0) { + isActive = dataStream.readBoolean(); + controlType = RedstoneControl.values()[dataStream.readInt()]; + + int c = dataStream.readInt(); + + if (c != -1) { + color = TransporterUtils.colors.get(c); + } else { + color = null; + } + + autoEject = dataStream.readBoolean(); + roundRobin = dataStream.readBoolean(); + + filters.clear(); + + int amount = dataStream.readInt(); + + for (int i = 0; i < amount; i++) { + filters.add(TransporterFilter.readFromPacket(dataStream)); + } + + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } else if (type == 1) { + isActive = dataStream.readBoolean(); + controlType = RedstoneControl.values()[dataStream.readInt()]; + + int c = dataStream.readInt(); + + if (c != -1) { + color = TransporterUtils.colors.get(c); + } else { + color = null; + } + + autoEject = dataStream.readBoolean(); + roundRobin = dataStream.readBoolean(); + + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } else if (type == 2) { + filters.clear(); + + int amount = dataStream.readInt(); + + for (int i = 0; i < amount; i++) { + filters.add(TransporterFilter.readFromPacket(dataStream)); + } + } + } + } + + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); + + data.add(0); + + data.add(isActive); + data.add(controlType.ordinal()); + + if (color != null) { + data.add(TransporterUtils.colors.indexOf(color)); + } else { + data.add(-1); + } + + data.add(autoEject); + data.add(roundRobin); + + data.add(filters.size()); + + for (TransporterFilter filter : filters) { + filter.write(data); + } + + return data; + } + + public ArrayList getGenericPacket(ArrayList data) { + super.getNetworkedData(data); + + data.add(1); + + data.add(isActive); + data.add(controlType.ordinal()); + + if (color != null) { + data.add(TransporterUtils.colors.indexOf(color)); + } else { + data.add(-1); + } + + data.add(autoEject); + data.add(roundRobin); + + return data; + } + + public ArrayList getFilterPacket(ArrayList data) { + super.getNetworkedData(data); + + data.add(2); + + data.add(filters.size()); + + for (TransporterFilter filter : filters) { + filter.write(data); + } + + return data; + } + + public boolean canSendHome(ItemStack stack) { + TileEntity back + = Coord4D.get(this) + .getFromSide(ForgeDirection.getOrientation(facing).getOpposite()) + .getTileEntity(worldObj); + + if (back instanceof IInventory) { + return InventoryUtils.canInsert( + back, + null, + stack, + ForgeDirection.getOrientation(facing).getOpposite().ordinal(), + true + ); + } + + return false; + } + + public boolean hasInventory() { + return Coord4D.get(this) + .getFromSide(ForgeDirection.getOrientation(facing).getOpposite()) + .getTileEntity(worldObj) + instanceof IInventory; + } + + public ItemStack sendHome(ItemStack stack) { + TileEntity back + = Coord4D.get(this) + .getFromSide(ForgeDirection.getOrientation(facing).getOpposite()) + .getTileEntity(worldObj); + + if (back instanceof IInventory) { + return InventoryUtils.putStackInInventory( + (IInventory) back, + stack, + ForgeDirection.getOrientation(facing).getOpposite().ordinal(), + true + ); + } + + return stack; + } + + @Override + public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { + return false; + } + + @Override + public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { + return false; + } + + @Override + public int getInventoryStackLimit() { + return 1; + } + + @Override + public int[] getAccessibleSlotsFromSide(int side) { + if (side == ForgeDirection.getOrientation(facing).ordinal() + || side == ForgeDirection.getOrientation(facing).getOpposite().ordinal()) { + return new int[] { 0 }; + } + + return InventoryUtils.EMPTY; + } + + @Override + public void openInventory() { + if (!worldObj.isRemote) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getFilterPacket(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + } + } + + @Override + public RedstoneControl getControlType() { + return controlType; + } + + @Override + public void setControlType(RedstoneControl type) { + controlType = type; + } + + @Override + public boolean canPulse() { + return true; + } + + @Override + public void setActive(boolean active) { + isActive = active; + + if (clientActive != active) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + + if (active && client.enableMachineSounds) { + worldObj.playSoundEffect( + xCoord, yCoord, zCoord, "mekanism:etc.Click", 0.3F, 1 + ); + } + + clientActive = active; + } + } + + @Override + public boolean getActive() { + return isActive; + } + + @Override + public boolean renderUpdate() { + return true; + } + + @Override + public boolean lightUpdate() { + return false; + } + + @Override + public EnumSet getConsumingSides() { + return EnumSet.noneOf(ForgeDirection.class); + } + + @Override + public boolean canSetFacing(int facing) { + return true; + } + + @Override + public TileComponentSecurity getSecurity() { + return securityComponent; + } + + @Override + public NBTTagCompound getConfigurationData(NBTTagCompound nbtTags) { + if (color != null) { + nbtTags.setInteger("color", TransporterUtils.colors.indexOf(color)); + } + + nbtTags.setBoolean("autoEject", autoEject); + nbtTags.setBoolean("roundRobin", roundRobin); + + nbtTags.setInteger("rrIndex", rrIndex); + + NBTTagList filterTags = new NBTTagList(); + + for (TransporterFilter filter : filters) { + NBTTagCompound tagCompound = new NBTTagCompound(); + filter.write(tagCompound); + filterTags.appendTag(tagCompound); + } + + if (filterTags.tagCount() != 0) { + nbtTags.setTag("filters", filterTags); + } + + return nbtTags; + } + + @Override + public void setConfigurationData(NBTTagCompound nbtTags) { + if (nbtTags.hasKey("color")) { + color = TransporterUtils.colors.get(nbtTags.getInteger("color")); + } + + autoEject = nbtTags.getBoolean("autoEject"); + roundRobin = nbtTags.getBoolean("roundRobin"); + + rrIndex = nbtTags.getInteger("rrIndex"); + + if (nbtTags.hasKey("filters")) { + NBTTagList tagList = nbtTags.getTagList("filters", NBT.TAG_COMPOUND); + + for (int i = 0; i < tagList.tagCount(); i++) { + filters.add(TransporterFilter.readFromNBT((NBTTagCompound + ) tagList.getCompoundTagAt(i))); + } + } + } + + @Override + public String getDataType() { + return getBlockType().getUnlocalizedName() + "." + fullName + ".name"; + } + + @Override + public void writeSustainedData(ItemStack itemStack) { + itemStack.stackTagCompound.setBoolean("hasSorterConfig", true); + + if (color != null) { + itemStack.stackTagCompound.setInteger( + "color", TransporterUtils.colors.indexOf(color) + ); + } + + itemStack.stackTagCompound.setBoolean("autoEject", autoEject); + itemStack.stackTagCompound.setBoolean("roundRobin", roundRobin); + + NBTTagList filterTags = new NBTTagList(); + + for (TransporterFilter filter : filters) { + NBTTagCompound tagCompound = new NBTTagCompound(); + filter.write(tagCompound); + filterTags.appendTag(tagCompound); + } + + if (filterTags.tagCount() != 0) { + itemStack.stackTagCompound.setTag("filters", filterTags); + } + } + + @Override + public void readSustainedData(ItemStack itemStack) { + if (itemStack.stackTagCompound.hasKey("hasSorterConfig")) { + if (itemStack.stackTagCompound.hasKey("color")) { + color = TransporterUtils.colors.get( + itemStack.stackTagCompound.getInteger("color") + ); + } + + autoEject = itemStack.stackTagCompound.getBoolean("autoEject"); + roundRobin = itemStack.stackTagCompound.getBoolean("roundRobin"); + + if (itemStack.stackTagCompound.hasKey("filters")) { + NBTTagList tagList + = itemStack.stackTagCompound.getTagList("filters", NBT.TAG_COMPOUND); + + for (int i = 0; i < tagList.tagCount(); i++) { + filters.add(TransporterFilter.readFromNBT((NBTTagCompound + ) tagList.getCompoundTagAt(i))); + } + } + } + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityMetallurgicInfuser.java b/src/main/java/mekanism/common/tile/TileEntityMetallurgicInfuser.java index 301051e64..bb422409e 100644 --- a/src/main/java/mekanism/common/tile/TileEntityMetallurgicInfuser.java +++ b/src/main/java/mekanism/common/tile/TileEntityMetallurgicInfuser.java @@ -1,9 +1,8 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.IConfigCardAccess; @@ -44,543 +43,523 @@ import mekanism.common.util.MekanismUtils; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock implements IComputerIntegration, ISideConfiguration, IUpgradeTile, IRedstoneControl, IConfigCardAccess, ISecurityTile, ITierUpgradeable -{ - /** The maxiumum amount of infuse this machine can store. */ - public int MAX_INFUSE = 1000; - - /** How much energy this machine consumes per-tick. */ - public double BASE_ENERGY_PER_TICK = usage.metallurgicInfuserUsage; - - public double energyPerTick = BASE_ENERGY_PER_TICK; - - /** How many ticks it takes to run an operation. */ - public int BASE_TICKS_REQUIRED = 200; - - public int ticksRequired = BASE_TICKS_REQUIRED; - - /** The amount of infuse this machine has stored. */ - public InfuseStorage infuseStored = new InfuseStorage(); - - /** How many ticks this machine has been operating for. */ - public int operatingTicks; - - /** Whether or not this machine is in it's active state. */ - public boolean isActive; - - /** The client's current active state. */ - public boolean clientActive; - - /** How many ticks must pass until this block's active state can sync with the client. */ - public int updateDelay; - - /** This machine's previous amount of energy. */ - public double prevEnergy; - - /** This machine's current RedstoneControl type. */ - public RedstoneControl controlType = RedstoneControl.DISABLED; - - public TileComponentUpgrade upgradeComponent; - public TileComponentEjector ejectorComponent; - public TileComponentConfig configComponent; - public TileComponentSecurity securityComponent; - - public TileEntityMetallurgicInfuser() - { - super("machine.metalinfuser", "MetallurgicInfuser", MachineType.METALLURGIC_INFUSER.baseEnergy); - - configComponent = new TileComponentConfig(this, TransmissionType.ITEM); - - configComponent.addOutput(TransmissionType.ITEM, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY)); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Input", EnumColor.DARK_RED, new int[] {2})); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Output", EnumColor.DARK_BLUE, new int[] {3})); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Energy", EnumColor.DARK_GREEN, new int[] {4})); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Infuse", EnumColor.PURPLE, new int[] {1})); - - configComponent.setConfig(TransmissionType.ITEM, new byte[] {4, 0, 0, 3, 1, 2}); - - inventory = new ItemStack[5]; - - upgradeComponent = new TileComponentUpgrade(this, 0); - upgradeComponent.setSupported(Upgrade.MUFFLING); - - ejectorComponent = new TileComponentEjector(this); - ejectorComponent.setOutputData(TransmissionType.ITEM, configComponent.getOutputs(TransmissionType.ITEM).get(2)); - - securityComponent = new TileComponentSecurity(this); - } - - @Override - public void onUpdate() - { - super.onUpdate(); - - if(worldObj.isRemote && updateDelay > 0) - { - updateDelay--; - - if(updateDelay == 0 && clientActive != isActive) - { - isActive = clientActive; - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } - - if(!worldObj.isRemote) - { - if(updateDelay > 0) - { - updateDelay--; - - if(updateDelay == 0 && clientActive != isActive) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - } - } - - ChargeUtils.discharge(4, this); - - if(inventory[1] != null) - { - if(InfuseRegistry.getObject(inventory[1]) != null) - { - InfuseObject infuse = InfuseRegistry.getObject(inventory[1]); - - if(infuseStored.type == null || infuseStored.type == infuse.type) - { - if(infuseStored.amount + infuse.stored <= MAX_INFUSE) - { - infuseStored.amount += infuse.stored; - infuseStored.type = infuse.type; - inventory[1].stackSize--; - - if(inventory[1].stackSize <= 0) - { - inventory[1] = null; - } - } - } - } - } - - MetallurgicInfuserRecipe recipe = RecipeHandler.getMetallurgicInfuserRecipe(getInput()); - - if(canOperate(recipe) && MekanismUtils.canFunction(this) && getEnergy() >= energyPerTick) - { - setActive(true); - setEnergy(getEnergy() - energyPerTick); - - if((operatingTicks + 1) < ticksRequired) - { - operatingTicks++; - } - else { - operate(recipe); - operatingTicks = 0; - } - } - else { - if(prevEnergy >= getEnergy()) - { - setActive(false); - } - } - - if(!canOperate(recipe)) - { - operatingTicks = 0; - } - - if(infuseStored.amount <= 0) - { - infuseStored.amount = 0; - infuseStored.type = null; - } - - prevEnergy = getEnergy(); - } - } - - @Override - public boolean upgrade(BaseTier upgradeTier) - { - if(upgradeTier != BaseTier.BASIC) - { - return false; - } - - worldObj.setBlockToAir(xCoord, yCoord, zCoord); - worldObj.setBlock(xCoord, yCoord, zCoord, MekanismBlocks.MachineBlock, 5, 3); - - TileEntityFactory factory = (TileEntityFactory)worldObj.getTileEntity(xCoord, yCoord, zCoord); - RecipeType type = RecipeType.INFUSING; - - //Basic - factory.facing = facing; - factory.clientFacing = clientFacing; - factory.ticker = ticker; - factory.redstone = redstone; - factory.redstoneLastTick = redstoneLastTick; - factory.doAutoSync = doAutoSync; - - //Electric - factory.electricityStored = electricityStored; - - //Noisy - factory.soundURL = soundURL; - - //Machine - factory.progress[0] = operatingTicks; - factory.clientActive = clientActive; - factory.isActive = isActive; - factory.updateDelay = updateDelay; - factory.controlType = controlType; - factory.prevEnergy = prevEnergy; - factory.upgradeComponent.readFrom(upgradeComponent); - factory.upgradeComponent.setUpgradeSlot(0); - factory.ejectorComponent.readFrom(ejectorComponent); - factory.ejectorComponent.setOutputData(TransmissionType.ITEM, factory.configComponent.getOutputs(TransmissionType.ITEM).get(2)); - factory.recipeType = type; - factory.upgradeComponent.setSupported(Upgrade.GAS, type.fuelEnergyUpgrades()); - factory.securityComponent.readFrom(securityComponent); - - for(TransmissionType transmission : configComponent.transmissions) - { - factory.configComponent.setConfig(transmission, configComponent.getConfig(transmission)); - factory.configComponent.setEjecting(transmission, configComponent.isEjecting(transmission)); - } - - //Infuser - factory.infuseStored.amount = infuseStored.amount; - factory.infuseStored.type = infuseStored.type; - - factory.inventory[5] = inventory[2]; - factory.inventory[1] = inventory[4]; - factory.inventory[5+3] = inventory[3]; - factory.inventory[0] = inventory[0]; - factory.inventory[4] = inventory[1]; - - for(Upgrade upgrade : factory.upgradeComponent.getSupportedTypes()) - { - factory.recalculateUpgradables(upgrade); - } - - factory.upgraded = true; - factory.markDirty(); - - return true; - } - - @Override - public boolean canExtractItem(int slotID, ItemStack itemstack, int side) - { - if(slotID == 4) - { - return ChargeUtils.canBeOutputted(itemstack, false); - } - else if(slotID == 3) - { - return true; - } - - return false; - } - - @Override - public boolean isItemValidForSlot(int slotID, ItemStack itemstack) - { - if(slotID == 3) - { - return false; - } - else if(slotID == 1) - { - return InfuseRegistry.getObject(itemstack) != null && (infuseStored.type == null || infuseStored.type == InfuseRegistry.getObject(itemstack).type); - } - else if(slotID == 0) - { - return itemstack.getItem() == MekanismItems.SpeedUpgrade || itemstack.getItem() == MekanismItems.EnergyUpgrade; - } - else if(slotID == 2) - { - if(infuseStored.type != null) - { - if(RecipeHandler.getMetallurgicInfuserRecipe(new InfusionInput(infuseStored, itemstack)) != null) - { - return true; - } - } - else { - for(Object obj : Recipe.METALLURGIC_INFUSER.get().keySet()) - { - InfusionInput input = (InfusionInput)obj; - - if(input.inputStack.isItemEqual(itemstack)) - { - return true; - } - } - } - } - else if(slotID == 4) - { - return ChargeUtils.canBeDischarged(itemstack); - } - - return false; - } - - public InfusionInput getInput() - { - return new InfusionInput(infuseStored, inventory[2]); - } - - public void operate(MetallurgicInfuserRecipe recipe) - { - recipe.output(inventory, 2, 3, infuseStored); - - markDirty(); - ejectorComponent.outputItems(); - } - - public boolean canOperate(MetallurgicInfuserRecipe recipe) - { - return recipe != null && recipe.canOperate(inventory, 2, 3, infuseStored); - } - - public int getScaledInfuseLevel(int i) - { - return infuseStored.amount * i / MAX_INFUSE; - } - - public double getScaledProgress() - { - return ((double)operatingTicks) / ((double)ticksRequired); - } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - clientActive = isActive = nbtTags.getBoolean("isActive"); - operatingTicks = nbtTags.getInteger("operatingTicks"); - infuseStored.amount = nbtTags.getInteger("infuseStored"); - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - infuseStored.type = InfuseRegistry.get(nbtTags.getString("type")); - } - - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - nbtTags.setBoolean("isActive", isActive); - nbtTags.setInteger("operatingTicks", operatingTicks); - nbtTags.setInteger("infuseStored", infuseStored.amount); - nbtTags.setInteger("controlType", controlType.ordinal()); - - if(infuseStored.type != null) - { - nbtTags.setString("type", infuseStored.type.name); - } - else { - nbtTags.setString("type", "null"); - } - - nbtTags.setBoolean("sideDataStored", true); - } - - @Override - public void handlePacketData(ByteBuf dataStream) - { - if(!worldObj.isRemote) - { - infuseStored.amount = dataStream.readInt(); - return; - } - - super.handlePacketData(dataStream); - - if(worldObj.isRemote) - { - clientActive = dataStream.readBoolean(); - operatingTicks = dataStream.readInt(); - infuseStored.amount = dataStream.readInt(); - controlType = RedstoneControl.values()[dataStream.readInt()]; - infuseStored.type = InfuseRegistry.get(PacketHandler.readString(dataStream)); - - if(updateDelay == 0 && clientActive != isActive) - { - updateDelay = general.UPDATE_DELAY; - isActive = clientActive; - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } - } - - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); - - data.add(isActive); - data.add(operatingTicks); - data.add(infuseStored.amount); - data.add(controlType.ordinal()); - - if(infuseStored.type != null) - { - data.add(infuseStored.type.name); - } - else { - data.add("null"); - } - - return data; - } - - private static final String[] methods = new String[] {"getEnergy", "getProgress", "facing", "canOperate", "getMaxEnergy", "getEnergyNeeded", "getInfuse", "getInfuseNeeded"}; - - @Override - public String[] getMethods() - { - return methods; - } - - @Override - public Object[] invoke(int method, Object[] arguments) throws Exception - { - switch(method) - { - case 0: - return new Object[] {getEnergy()}; - case 1: - return new Object[] {operatingTicks}; - case 2: - return new Object[] {facing}; - case 3: - return new Object[] {canOperate(RecipeHandler.getMetallurgicInfuserRecipe(getInput()))}; - case 4: - return new Object[] {getMaxEnergy()}; - case 5: - return new Object[] {getMaxEnergy()-getEnergy()}; - case 6: - return new Object[] {infuseStored}; - case 7: - return new Object[] {MAX_INFUSE-infuseStored.amount}; - default: - throw new NoSuchMethodException(); - } - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) - { - return configComponent.getOutput(TransmissionType.ITEM, side, facing).availableSlots; - } - - @Override - public boolean canSetFacing(int side) - { - return side != 0 && side != 1; - } - - @Override - public void setActive(boolean active) - { - isActive = active; - - if(clientActive != active && updateDelay == 0) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - - updateDelay = 10; - clientActive = active; - } - } - - @Override - public boolean getActive() - { - return isActive; - } - - @Override - public TileComponentConfig getConfig() - { - return configComponent; - } - - @Override - public int getOrientation() - { - return facing; - } - - @Override - public boolean renderUpdate() - { - return false; - } - - @Override - public boolean lightUpdate() - { - return true; - } - - @Override - public RedstoneControl getControlType() - { - return controlType; - } - - @Override - public void setControlType(RedstoneControl type) - { - controlType = type; - MekanismUtils.saveChunk(this); - } - - @Override - public boolean canPulse() - { - return false; - } - - @Override - public TileComponentUpgrade getComponent() - { - return upgradeComponent; - } - - @Override - public TileComponentEjector getEjector() - { - return ejectorComponent; - } - - @Override - public TileComponentSecurity getSecurity() - { - return securityComponent; - } - - @Override - public void recalculateUpgradables(Upgrade upgrade) - { - super.recalculateUpgradables(upgrade); - - switch(upgrade) - { - case SPEED: - ticksRequired = MekanismUtils.getTicks(this, BASE_TICKS_REQUIRED); - case ENERGY: - energyPerTick = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK); - maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY); - default: - break; - } - } +public class TileEntityMetallurgicInfuser extends TileEntityNoisyElectricBlock + implements IComputerIntegration, ISideConfiguration, IUpgradeTile, IRedstoneControl, + IConfigCardAccess, ISecurityTile, ITierUpgradeable { + /** The maxiumum amount of infuse this machine can store. */ + public int MAX_INFUSE = 1000; + + /** How much energy this machine consumes per-tick. */ + public double BASE_ENERGY_PER_TICK = usage.metallurgicInfuserUsage; + + public double energyPerTick = BASE_ENERGY_PER_TICK; + + /** How many ticks it takes to run an operation. */ + public int BASE_TICKS_REQUIRED = 200; + + public int ticksRequired = BASE_TICKS_REQUIRED; + + /** The amount of infuse this machine has stored. */ + public InfuseStorage infuseStored = new InfuseStorage(); + + /** How many ticks this machine has been operating for. */ + public int operatingTicks; + + /** Whether or not this machine is in it's active state. */ + public boolean isActive; + + /** The client's current active state. */ + public boolean clientActive; + + /** + * How many ticks must pass until this block's active state can sync with the client. + */ + public int updateDelay; + + /** This machine's previous amount of energy. */ + public double prevEnergy; + + /** This machine's current RedstoneControl type. */ + public RedstoneControl controlType = RedstoneControl.DISABLED; + + public TileComponentUpgrade upgradeComponent; + public TileComponentEjector ejectorComponent; + public TileComponentConfig configComponent; + public TileComponentSecurity securityComponent; + + public TileEntityMetallurgicInfuser() { + super( + "machine.metalinfuser", + "MetallurgicInfuser", + MachineType.METALLURGIC_INFUSER.baseEnergy + ); + + configComponent = new TileComponentConfig(this, TransmissionType.ITEM); + + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY) + ); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("Input", EnumColor.DARK_RED, new int[] { 2 }) + ); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("Output", EnumColor.DARK_BLUE, new int[] { 3 }) + ); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("Energy", EnumColor.DARK_GREEN, new int[] { 4 }) + ); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("Infuse", EnumColor.PURPLE, new int[] { 1 }) + ); + + configComponent.setConfig(TransmissionType.ITEM, new byte[] { 4, 0, 0, 3, 1, 2 }); + + inventory = new ItemStack[5]; + + upgradeComponent = new TileComponentUpgrade(this, 0); + upgradeComponent.setSupported(Upgrade.MUFFLING); + + ejectorComponent = new TileComponentEjector(this); + ejectorComponent.setOutputData( + TransmissionType.ITEM, + configComponent.getOutputs(TransmissionType.ITEM).get(2) + ); + + securityComponent = new TileComponentSecurity(this); + } + + @Override + public void onUpdate() { + super.onUpdate(); + + if (worldObj.isRemote && updateDelay > 0) { + updateDelay--; + + if (updateDelay == 0 && clientActive != isActive) { + isActive = clientActive; + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } + + if (!worldObj.isRemote) { + if (updateDelay > 0) { + updateDelay--; + + if (updateDelay == 0 && clientActive != isActive) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + } + } + + ChargeUtils.discharge(4, this); + + if (inventory[1] != null) { + if (InfuseRegistry.getObject(inventory[1]) != null) { + InfuseObject infuse = InfuseRegistry.getObject(inventory[1]); + + if (infuseStored.type == null || infuseStored.type == infuse.type) { + if (infuseStored.amount + infuse.stored <= MAX_INFUSE) { + infuseStored.amount += infuse.stored; + infuseStored.type = infuse.type; + inventory[1].stackSize--; + + if (inventory[1].stackSize <= 0) { + inventory[1] = null; + } + } + } + } + } + + MetallurgicInfuserRecipe recipe + = RecipeHandler.getMetallurgicInfuserRecipe(getInput()); + + if (canOperate(recipe) && MekanismUtils.canFunction(this) + && getEnergy() >= energyPerTick) { + setActive(true); + setEnergy(getEnergy() - energyPerTick); + + if ((operatingTicks + 1) < ticksRequired) { + operatingTicks++; + } else { + operate(recipe); + operatingTicks = 0; + } + } else { + if (prevEnergy >= getEnergy()) { + setActive(false); + } + } + + if (!canOperate(recipe)) { + operatingTicks = 0; + } + + if (infuseStored.amount <= 0) { + infuseStored.amount = 0; + infuseStored.type = null; + } + + prevEnergy = getEnergy(); + } + } + + @Override + public boolean upgrade(BaseTier upgradeTier) { + if (upgradeTier != BaseTier.BASIC) { + return false; + } + + worldObj.setBlockToAir(xCoord, yCoord, zCoord); + worldObj.setBlock(xCoord, yCoord, zCoord, MekanismBlocks.MachineBlock, 5, 3); + + TileEntityFactory factory + = (TileEntityFactory) worldObj.getTileEntity(xCoord, yCoord, zCoord); + RecipeType type = RecipeType.INFUSING; + + //Basic + factory.facing = facing; + factory.clientFacing = clientFacing; + factory.ticker = ticker; + factory.redstone = redstone; + factory.redstoneLastTick = redstoneLastTick; + factory.doAutoSync = doAutoSync; + + //Electric + factory.electricityStored = electricityStored; + + //Noisy + factory.soundURL = soundURL; + + //Machine + factory.progress[0] = operatingTicks; + factory.clientActive = clientActive; + factory.isActive = isActive; + factory.updateDelay = updateDelay; + factory.controlType = controlType; + factory.prevEnergy = prevEnergy; + factory.upgradeComponent.readFrom(upgradeComponent); + factory.upgradeComponent.setUpgradeSlot(0); + factory.ejectorComponent.readFrom(ejectorComponent); + factory.ejectorComponent.setOutputData( + TransmissionType.ITEM, + factory.configComponent.getOutputs(TransmissionType.ITEM).get(2) + ); + factory.recipeType = type; + factory.upgradeComponent.setSupported(Upgrade.GAS, type.fuelEnergyUpgrades()); + factory.securityComponent.readFrom(securityComponent); + + for (TransmissionType transmission : configComponent.transmissions) { + factory.configComponent.setConfig( + transmission, configComponent.getConfig(transmission) + ); + factory.configComponent.setEjecting( + transmission, configComponent.isEjecting(transmission) + ); + } + + //Infuser + factory.infuseStored.amount = infuseStored.amount; + factory.infuseStored.type = infuseStored.type; + + factory.inventory[5] = inventory[2]; + factory.inventory[1] = inventory[4]; + factory.inventory[5 + 3] = inventory[3]; + factory.inventory[0] = inventory[0]; + factory.inventory[4] = inventory[1]; + + for (Upgrade upgrade : factory.upgradeComponent.getSupportedTypes()) { + factory.recalculateUpgradables(upgrade); + } + + factory.upgraded = true; + factory.markDirty(); + + return true; + } + + @Override + public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { + if (slotID == 4) { + return ChargeUtils.canBeOutputted(itemstack, false); + } else if (slotID == 3) { + return true; + } + + return false; + } + + @Override + public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { + if (slotID == 3) { + return false; + } else if (slotID == 1) { + return InfuseRegistry.getObject(itemstack) != null + && (infuseStored.type == null + || infuseStored.type == InfuseRegistry.getObject(itemstack).type); + } else if (slotID == 0) { + return itemstack.getItem() == MekanismItems.SpeedUpgrade + || itemstack.getItem() == MekanismItems.EnergyUpgrade; + } else if (slotID == 2) { + if (infuseStored.type != null) { + if (RecipeHandler.getMetallurgicInfuserRecipe( + new InfusionInput(infuseStored, itemstack) + ) + != null) { + return true; + } + } else { + for (Object obj : Recipe.METALLURGIC_INFUSER.get().keySet()) { + InfusionInput input = (InfusionInput) obj; + + if (input.inputStack.isItemEqual(itemstack)) { + return true; + } + } + } + } else if (slotID == 4) { + return ChargeUtils.canBeDischarged(itemstack); + } + + return false; + } + + public InfusionInput getInput() { + return new InfusionInput(infuseStored, inventory[2]); + } + + public void operate(MetallurgicInfuserRecipe recipe) { + recipe.output(inventory, 2, 3, infuseStored); + + markDirty(); + ejectorComponent.outputItems(); + } + + public boolean canOperate(MetallurgicInfuserRecipe recipe) { + return recipe != null && recipe.canOperate(inventory, 2, 3, infuseStored); + } + + public int getScaledInfuseLevel(int i) { + return infuseStored.amount * i / MAX_INFUSE; + } + + public double getScaledProgress() { + return ((double) operatingTicks) / ((double) ticksRequired); + } + + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); + + clientActive = isActive = nbtTags.getBoolean("isActive"); + operatingTicks = nbtTags.getInteger("operatingTicks"); + infuseStored.amount = nbtTags.getInteger("infuseStored"); + controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + infuseStored.type = InfuseRegistry.get(nbtTags.getString("type")); + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); + + nbtTags.setBoolean("isActive", isActive); + nbtTags.setInteger("operatingTicks", operatingTicks); + nbtTags.setInteger("infuseStored", infuseStored.amount); + nbtTags.setInteger("controlType", controlType.ordinal()); + + if (infuseStored.type != null) { + nbtTags.setString("type", infuseStored.type.name); + } else { + nbtTags.setString("type", "null"); + } + + nbtTags.setBoolean("sideDataStored", true); + } + + @Override + public void handlePacketData(ByteBuf dataStream) { + if (!worldObj.isRemote) { + infuseStored.amount = dataStream.readInt(); + return; + } + + super.handlePacketData(dataStream); + + if (worldObj.isRemote) { + clientActive = dataStream.readBoolean(); + operatingTicks = dataStream.readInt(); + infuseStored.amount = dataStream.readInt(); + controlType = RedstoneControl.values()[dataStream.readInt()]; + infuseStored.type = InfuseRegistry.get(PacketHandler.readString(dataStream)); + + if (updateDelay == 0 && clientActive != isActive) { + updateDelay = general.UPDATE_DELAY; + isActive = clientActive; + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } + } + + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); + + data.add(isActive); + data.add(operatingTicks); + data.add(infuseStored.amount); + data.add(controlType.ordinal()); + + if (infuseStored.type != null) { + data.add(infuseStored.type.name); + } else { + data.add("null"); + } + + return data; + } + + private static final String[] methods = new String[] { + "getEnergy", "getProgress", "facing", "canOperate", + "getMaxEnergy", "getEnergyNeeded", "getInfuse", "getInfuseNeeded" + }; + + @Override + public String[] getMethods() { + return methods; + } + + @Override + public Object[] invoke(int method, Object[] arguments) throws Exception { + switch (method) { + case 0: + return new Object[] { getEnergy() }; + case 1: + return new Object[] { operatingTicks }; + case 2: + return new Object[] { facing }; + case 3: + return new Object[] { + canOperate(RecipeHandler.getMetallurgicInfuserRecipe(getInput())) + }; + case 4: + return new Object[] { getMaxEnergy() }; + case 5: + return new Object[] { getMaxEnergy() - getEnergy() }; + case 6: + return new Object[] { infuseStored }; + case 7: + return new Object[] { MAX_INFUSE - infuseStored.amount }; + default: + throw new NoSuchMethodException(); + } + } + + @Override + public int[] getAccessibleSlotsFromSide(int side) { + return configComponent.getOutput(TransmissionType.ITEM, side, facing) + .availableSlots; + } + + @Override + public boolean canSetFacing(int side) { + return side != 0 && side != 1; + } + + @Override + public void setActive(boolean active) { + isActive = active; + + if (clientActive != active && updateDelay == 0) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + + updateDelay = 10; + clientActive = active; + } + } + + @Override + public boolean getActive() { + return isActive; + } + + @Override + public TileComponentConfig getConfig() { + return configComponent; + } + + @Override + public int getOrientation() { + return facing; + } + + @Override + public boolean renderUpdate() { + return false; + } + + @Override + public boolean lightUpdate() { + return true; + } + + @Override + public RedstoneControl getControlType() { + return controlType; + } + + @Override + public void setControlType(RedstoneControl type) { + controlType = type; + MekanismUtils.saveChunk(this); + } + + @Override + public boolean canPulse() { + return false; + } + + @Override + public TileComponentUpgrade getComponent() { + return upgradeComponent; + } + + @Override + public TileComponentEjector getEjector() { + return ejectorComponent; + } + + @Override + public TileComponentSecurity getSecurity() { + return securityComponent; + } + + @Override + public void recalculateUpgradables(Upgrade upgrade) { + super.recalculateUpgradables(upgrade); + + switch (upgrade) { + case SPEED: + ticksRequired = MekanismUtils.getTicks(this, BASE_TICKS_REQUIRED); + case ENERGY: + energyPerTick + = MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK); + maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY); + default: + break; + } + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityMultiblock.java b/src/main/java/mekanism/common/tile/TileEntityMultiblock.java index 746a7f589..98cab7bce 100644 --- a/src/main/java/mekanism/common/tile/TileEntityMultiblock.java +++ b/src/main/java/mekanism/common/tile/TileEntityMultiblock.java @@ -1,9 +1,10 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.Range4D; import mekanism.common.Mekanism; @@ -19,289 +20,269 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; import net.minecraftforge.common.util.ForgeDirection; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public abstract class TileEntityMultiblock> extends TileEntityContainerBlock implements IMultiblock -{ - /** The multiblock data for this structure. */ - public T structure; - - /** Whether or not to send this multiblock's structure in the next update packet. */ - public boolean sendStructure; +public abstract class TileEntityMultiblock> + extends TileEntityContainerBlock implements IMultiblock { + /** The multiblock data for this structure. */ + public T structure; - /** This multiblock's previous "has structure" state. */ - public boolean prevStructure; + /** Whether or not to send this multiblock's structure in the next update packet. */ + public boolean sendStructure; - /** Whether or not this multiblock has it's structure, for the client side mechanics. */ - public boolean clientHasStructure; - - /** Whether or not this multiblock segment is rendering the structure. */ - public boolean isRendering; - - /** This multiblock segment's cached data */ - public MultiblockCache cachedData = getNewCache(); - - /** This multiblock segment's cached inventory ID */ - public String cachedID = null; - - public TileEntityMultiblock(String name) - { - super(name); - } - - @Override - public void onUpdate() - { - if(worldObj.isRemote) - { - if(structure == null) - { - structure = getNewStructure(); - } + /** This multiblock's previous "has structure" state. */ + public boolean prevStructure; - if(structure != null && clientHasStructure && isRendering) - { - if(!prevStructure) - { - Mekanism.proxy.doMultiblockSparkle(this); - } - } + /** + * Whether or not this multiblock has it's structure, for the client side mechanics. + */ + public boolean clientHasStructure; - prevStructure = clientHasStructure; - } + /** Whether or not this multiblock segment is rendering the structure. */ + public boolean isRendering; - if(playersUsing.size() > 0 && ((worldObj.isRemote && !clientHasStructure) || (!worldObj.isRemote && structure == null))) - { - for(EntityPlayer player : playersUsing) - { - player.closeScreen(); - } - } + /** This multiblock segment's cached data */ + public MultiblockCache cachedData = getNewCache(); - if(!worldObj.isRemote) - { - if(structure == null) - { - isRendering = false; - - if(cachedID != null) - { - getManager().updateCache(this); - } - } + /** This multiblock segment's cached inventory ID */ + public String cachedID = null; - if(structure == null && ticker == 5) - { - update(); - } + public TileEntityMultiblock(String name) { + super(name); + } - if(prevStructure != (structure != null)) - { - if(structure != null && !getSynchronizedData().hasRenderer) - { - getSynchronizedData().hasRenderer = true; - isRendering = true; - sendStructure = true; - } + @Override + public void onUpdate() { + if (worldObj.isRemote) { + if (structure == null) { + structure = getNewStructure(); + } - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - Coord4D obj = Coord4D.get(this).getFromSide(side); + if (structure != null && clientHasStructure && isRendering) { + if (!prevStructure) { + Mekanism.proxy.doMultiblockSparkle(this); + } + } - if(!obj.isAirBlock(worldObj) && (obj.getTileEntity(worldObj) == null || obj.getTileEntity(worldObj).getClass() != getClass())) - { - obj.getBlock(worldObj).onNeighborChange(worldObj, obj.xCoord, obj.yCoord, obj.zCoord, xCoord, yCoord, zCoord); - } - } + prevStructure = clientHasStructure; + } - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - } + if (playersUsing.size() > 0 + && ((worldObj.isRemote && !clientHasStructure) + || (!worldObj.isRemote && structure == null))) { + for (EntityPlayer player : playersUsing) { + player.closeScreen(); + } + } - prevStructure = structure != null; + if (!worldObj.isRemote) { + if (structure == null) { + isRendering = false; - if(structure != null) - { - getSynchronizedData().didTick = false; + if (cachedID != null) { + getManager().updateCache(this); + } + } - if(getSynchronizedData().inventoryID != null) - { - cachedData.sync(getSynchronizedData()); - cachedID = getSynchronizedData().inventoryID; - getManager().updateCache(this); - } - } - } - } - - @Override - public void update() - { - if(!worldObj.isRemote && (structure == null || !getSynchronizedData().didTick)) - { - getProtocol().doUpdate(); + if (structure == null && ticker == 5) { + update(); + } - if(structure != null) - { - getSynchronizedData().didTick = true; - } - } - } - - public void sendPacketToRenderer() - { - if(structure != null) - { - for(Coord4D obj : getSynchronizedData().locations) - { - TileEntityMultiblock tileEntity = (TileEntityMultiblock)obj.getTileEntity(worldObj); + if (prevStructure != (structure != null)) { + if (structure != null && !getSynchronizedData().hasRenderer) { + getSynchronizedData().hasRenderer = true; + isRendering = true; + sendStructure = true; + } - if(tileEntity != null && tileEntity.isRendering) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tileEntity), tileEntity.getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(tileEntity))); - } - } - } - } - - protected abstract T getNewStructure(); - - public abstract MultiblockCache getNewCache(); - - protected abstract UpdateProtocol getProtocol(); - - public abstract MultiblockManager getManager(); - - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + Coord4D obj = Coord4D.get(this).getFromSide(side); - data.add(isRendering); - data.add(structure != null); + if (!obj.isAirBlock(worldObj) + && (obj.getTileEntity(worldObj) == null + || obj.getTileEntity(worldObj).getClass() != getClass())) { + obj.getBlock(worldObj).onNeighborChange( + worldObj, + obj.xCoord, + obj.yCoord, + obj.zCoord, + xCoord, + yCoord, + zCoord + ); + } + } - if(structure != null && isRendering) - { - if(sendStructure) - { - sendStructure = false; + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + } - data.add(true); + prevStructure = structure != null; - data.add(getSynchronizedData().volHeight); - data.add(getSynchronizedData().volWidth); - data.add(getSynchronizedData().volLength); + if (structure != null) { + getSynchronizedData().didTick = false; - getSynchronizedData().renderLocation.write(data); - data.add(getSynchronizedData().inventoryID); - } - else { - data.add(false); - } - } + if (getSynchronizedData().inventoryID != null) { + cachedData.sync(getSynchronizedData()); + cachedID = getSynchronizedData().inventoryID; + getManager().updateCache(this); + } + } + } + } - return data; - } + @Override + public void update() { + if (!worldObj.isRemote && (structure == null || !getSynchronizedData().didTick)) { + getProtocol().doUpdate(); - @Override - public void handlePacketData(ByteBuf dataStream) - { - super.handlePacketData(dataStream); + if (structure != null) { + getSynchronizedData().didTick = true; + } + } + } - if(worldObj.isRemote) - { - if(structure == null) - { - structure = getNewStructure(); - } - - isRendering = dataStream.readBoolean(); - clientHasStructure = dataStream.readBoolean(); - - if(clientHasStructure && isRendering) - { - if(dataStream.readBoolean()) - { - getSynchronizedData().volHeight = dataStream.readInt(); - getSynchronizedData().volWidth = dataStream.readInt(); - getSynchronizedData().volLength = dataStream.readInt(); - - getSynchronizedData().renderLocation = Coord4D.read(dataStream); - getSynchronizedData().inventoryID = PacketHandler.readString(dataStream); - } - } - } - } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); + public void sendPacketToRenderer() { + if (structure != null) { + for (Coord4D obj : getSynchronizedData().locations) { + TileEntityMultiblock tileEntity + = (TileEntityMultiblock) obj.getTileEntity(worldObj); - if(structure == null) - { - if(nbtTags.hasKey("cachedID")) - { - cachedID = nbtTags.getString("cachedID"); - cachedData.load(nbtTags); - } - } - } + if (tileEntity != null && tileEntity.isRendering) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(tileEntity), + tileEntity.getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(tileEntity)) + ); + } + } + } + } - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); + protected abstract T getNewStructure(); - if(cachedID != null) - { - nbtTags.setString("cachedID", cachedID); - cachedData.save(nbtTags); - } - } - - @Override - public ItemStack getStackInSlot(int slotID) - { - return structure != null && getSynchronizedData().getInventory() != null ? getSynchronizedData().getInventory()[slotID] : null; - } + public abstract MultiblockCache getNewCache(); - @Override - public void setInventorySlotContents(int slotID, ItemStack itemstack) - { - if(structure != null && getSynchronizedData().getInventory() != null) - { - getSynchronizedData().getInventory()[slotID] = itemstack; + protected abstract UpdateProtocol getProtocol(); - if(itemstack != null && itemstack.stackSize > getInventoryStackLimit()) - { - itemstack.stackSize = getInventoryStackLimit(); - } - } - } - - @Override - public boolean onActivate(EntityPlayer player) - { - return false; - } - - @Override - @SideOnly(Side.CLIENT) - public AxisAlignedBB getRenderBoundingBox() - { - return INFINITE_EXTENT_AABB; - } - - @Override - public boolean handleInventory() - { - return false; - } + public abstract MultiblockManager getManager(); - @Override - public T getSynchronizedData() - { - return structure; - } + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); + + data.add(isRendering); + data.add(structure != null); + + if (structure != null && isRendering) { + if (sendStructure) { + sendStructure = false; + + data.add(true); + + data.add(getSynchronizedData().volHeight); + data.add(getSynchronizedData().volWidth); + data.add(getSynchronizedData().volLength); + + getSynchronizedData().renderLocation.write(data); + data.add(getSynchronizedData().inventoryID); + } else { + data.add(false); + } + } + + return data; + } + + @Override + public void handlePacketData(ByteBuf dataStream) { + super.handlePacketData(dataStream); + + if (worldObj.isRemote) { + if (structure == null) { + structure = getNewStructure(); + } + + isRendering = dataStream.readBoolean(); + clientHasStructure = dataStream.readBoolean(); + + if (clientHasStructure && isRendering) { + if (dataStream.readBoolean()) { + getSynchronizedData().volHeight = dataStream.readInt(); + getSynchronizedData().volWidth = dataStream.readInt(); + getSynchronizedData().volLength = dataStream.readInt(); + + getSynchronizedData().renderLocation = Coord4D.read(dataStream); + getSynchronizedData().inventoryID + = PacketHandler.readString(dataStream); + } + } + } + } + + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); + + if (structure == null) { + if (nbtTags.hasKey("cachedID")) { + cachedID = nbtTags.getString("cachedID"); + cachedData.load(nbtTags); + } + } + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); + + if (cachedID != null) { + nbtTags.setString("cachedID", cachedID); + cachedData.save(nbtTags); + } + } + + @Override + public ItemStack getStackInSlot(int slotID) { + return structure != null && getSynchronizedData().getInventory() != null + ? getSynchronizedData().getInventory()[slotID] + : null; + } + + @Override + public void setInventorySlotContents(int slotID, ItemStack itemstack) { + if (structure != null && getSynchronizedData().getInventory() != null) { + getSynchronizedData().getInventory()[slotID] = itemstack; + + if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { + itemstack.stackSize = getInventoryStackLimit(); + } + } + } + + @Override + public boolean onActivate(EntityPlayer player) { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public AxisAlignedBB getRenderBoundingBox() { + return INFINITE_EXTENT_AABB; + } + + @Override + public boolean handleInventory() { + return false; + } + + @Override + public T getSynchronizedData() { + return structure; + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityNoisyElectricBlock.java b/src/main/java/mekanism/common/tile/TileEntityNoisyElectricBlock.java index 25a713ba2..b5de0e085 100644 --- a/src/main/java/mekanism/common/tile/TileEntityNoisyElectricBlock.java +++ b/src/main/java/mekanism/common/tile/TileEntityNoisyElectricBlock.java @@ -1,5 +1,7 @@ package mekanism.common.tile; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.MekanismConfig.client; import mekanism.api.Pos3D; import mekanism.client.HolidayManager; @@ -11,141 +13,131 @@ import mekanism.common.base.IUpgradeTile; import mekanism.common.base.SoundWrapper; import net.minecraft.client.audio.ISound.AttenuationType; import net.minecraft.util.ResourceLocation; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public abstract class TileEntityNoisyElectricBlock extends TileEntityElectricBlock implements IHasSound, ISoundSource, IActiveState -{ - /** The ResourceLocation of the machine's sound */ - public ResourceLocation soundURL; +public abstract class TileEntityNoisyElectricBlock + extends TileEntityElectricBlock implements IHasSound, ISoundSource, IActiveState { + /** The ResourceLocation of the machine's sound */ + public ResourceLocation soundURL; - /** The bundled URL of this machine's sound effect */ - @SideOnly(Side.CLIENT) - public SoundWrapper sound; - - /** The path of this machine's sound */ - public String soundPath; + /** The bundled URL of this machine's sound effect */ + @SideOnly(Side.CLIENT) + public SoundWrapper sound; - /** - * The base of all blocks that deal with electricity and make noise. - * - * @param sound - the sound path of this block - * @param name - full name of this block - * @param maxEnergy - how much energy this block can store - */ - public TileEntityNoisyElectricBlock(String sound, String name, double maxEnergy) - { - super(name, maxEnergy); - - soundPath = sound; - } + /** The path of this machine's sound */ + public String soundPath; - @Override - @SideOnly(Side.CLIENT) - public SoundWrapper getSound() - { - return sound; - } + /** + * The base of all blocks that deal with electricity and make noise. + * + * @param sound - the sound path of this block + * @param name - full name of this block + * @param maxEnergy - how much energy this block can store + */ + public TileEntityNoisyElectricBlock(String sound, String name, double maxEnergy) { + super(name, maxEnergy); - @Override - @SideOnly(Side.CLIENT) - public boolean shouldPlaySound() - { - return getActive() && !isInvalid(); - } + soundPath = sound; + } - @Override - @SideOnly(Side.CLIENT) - public ResourceLocation getSoundLocation() - { - return soundURL; - } + @Override + @SideOnly(Side.CLIENT) + public SoundWrapper getSound() { + return sound; + } - @Override - @SideOnly(Side.CLIENT) - public float getVolume() - { - if(this instanceof IUpgradeTile && ((IUpgradeTile)this).getComponent().supports(Upgrade.MUFFLING)) - { - return Math.max(0.001F, 1F - (float)((IUpgradeTile)this).getComponent().getUpgrades(Upgrade.MUFFLING)/(float)Upgrade.MUFFLING.getMax()); - } - - return 1F; - } + @Override + @SideOnly(Side.CLIENT) + public boolean shouldPlaySound() { + return getActive() && !isInvalid(); + } - @Override - @SideOnly(Side.CLIENT) - public float getPitch() - { - return 1F; - } + @Override + @SideOnly(Side.CLIENT) + public ResourceLocation getSoundLocation() { + return soundURL; + } - @Override - @SideOnly(Side.CLIENT) - public Pos3D getSoundPosition() - { - return new Pos3D(xCoord+0.5, yCoord+0.5, zCoord+0.5); - } + @Override + @SideOnly(Side.CLIENT) + public float getVolume() { + if (this instanceof IUpgradeTile + && ((IUpgradeTile) this).getComponent().supports(Upgrade.MUFFLING)) { + return Math.max( + 0.001F, + 1F + - (float) ((IUpgradeTile) this) + .getComponent() + .getUpgrades(Upgrade.MUFFLING) + / (float) Upgrade.MUFFLING.getMax() + ); + } - @Override - @SideOnly(Side.CLIENT) - public boolean shouldRepeat() - { - return true; - } + return 1F; + } - @Override - @SideOnly(Side.CLIENT) - public int getRepeatDelay() - { - return 0; - } + @Override + @SideOnly(Side.CLIENT) + public float getPitch() { + return 1F; + } - @Override - @SideOnly(Side.CLIENT) - public AttenuationType getAttenuation() - { - return AttenuationType.LINEAR; - } + @Override + @SideOnly(Side.CLIENT) + public Pos3D getSoundPosition() { + return new Pos3D(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); + } - @Override - public void validate() - { - super.validate(); + @Override + @SideOnly(Side.CLIENT) + public boolean shouldRepeat() { + return true; + } - if(worldObj.isRemote) - { - try { - soundURL = HolidayManager.filterSound(new ResourceLocation("mekanism", "tile." + soundPath)); - initSounds(); - } catch(Throwable t) {} - } - } + @Override + @SideOnly(Side.CLIENT) + public int getRepeatDelay() { + return 0; + } - @SideOnly(Side.CLIENT) - public void initSounds() - { - sound = new SoundWrapper(this, this); - } + @Override + @SideOnly(Side.CLIENT) + public AttenuationType getAttenuation() { + return AttenuationType.LINEAR; + } - @Override - public void onUpdate() - { - super.onUpdate(); - - if(worldObj.isRemote) - { - updateSound(); - } - } + @Override + public void validate() { + super.validate(); - @SideOnly(Side.CLIENT) - public void updateSound() - { - if(shouldPlaySound() && getSound().canRestart() && client.enableMachineSounds) - { - getSound().reset(); - getSound().play(); - } - } + if (worldObj.isRemote) { + try { + soundURL = HolidayManager.filterSound( + new ResourceLocation("mekanism", "tile." + soundPath) + ); + initSounds(); + } catch (Throwable t) {} + } + } + + @SideOnly(Side.CLIENT) + public void initSounds() { + sound = new SoundWrapper(this, this); + } + + @Override + public void onUpdate() { + super.onUpdate(); + + if (worldObj.isRemote) { + updateSound(); + } + } + + @SideOnly(Side.CLIENT) + public void updateSound() { + if (shouldPlaySound() && getSound().canRestart() && client.enableMachineSounds) { + getSound().reset(); + getSound().play(); + } + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityObsidianTNT.java b/src/main/java/mekanism/common/tile/TileEntityObsidianTNT.java index c78e0a6ae..53505b7ca 100644 --- a/src/main/java/mekanism/common/tile/TileEntityObsidianTNT.java +++ b/src/main/java/mekanism/common/tile/TileEntityObsidianTNT.java @@ -3,11 +3,9 @@ package mekanism.common.tile; import net.minecraft.tileentity.TileEntity; //For a TESR -public class TileEntityObsidianTNT extends TileEntity -{ - @Override - public boolean canUpdate() - { - return false; - } +public class TileEntityObsidianTNT extends TileEntity { + @Override + public boolean canUpdate() { + return false; + } } \ No newline at end of file diff --git a/src/main/java/mekanism/common/tile/TileEntityOredictionificator.java b/src/main/java/mekanism/common/tile/TileEntityOredictionificator.java index 1ada0b539..68c8cca54 100644 --- a/src/main/java/mekanism/common/tile/TileEntityOredictionificator.java +++ b/src/main/java/mekanism/common/tile/TileEntityOredictionificator.java @@ -1,11 +1,10 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.IConfigCardAccess.ISpecialConfigData; import mekanism.api.Range4D; @@ -29,469 +28,408 @@ import net.minecraft.nbt.NBTTagList; import net.minecraftforge.common.util.Constants.NBT; import net.minecraftforge.oredict.OreDictionary; -public class TileEntityOredictionificator extends TileEntityContainerBlock implements IRedstoneControl, ISpecialConfigData, ISustainedData, ISecurityTile -{ - public static final int MAX_LENGTH = 24; - - public HashList filters = new HashList(); - - public static List possibleFilters = Arrays.asList("ingot", "ore", "dust", "nugget"); - - public RedstoneControl controlType = RedstoneControl.DISABLED; - - public boolean didProcess; - - public TileComponentSecurity securityComponent = new TileComponentSecurity(this); - - public TileEntityOredictionificator() - { - super(MachineType.OREDICTIONIFICATOR.name); - - inventory = new ItemStack[2]; - doAutoSync = false; - } +public class TileEntityOredictionificator extends TileEntityContainerBlock + implements IRedstoneControl, ISpecialConfigData, ISustainedData, ISecurityTile { + public static final int MAX_LENGTH = 24; - @Override - public void onUpdate() - { - if(!worldObj.isRemote) - { - if(playersUsing.size() > 0) - { - for(EntityPlayer player : playersUsing) - { - Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(this), getGenericPacket(new ArrayList())), (EntityPlayerMP)player); - } - } - - didProcess = false; - - if(MekanismUtils.canFunction(this) && inventory[0] != null && getValidName(inventory[0]) != null) - { - ItemStack result = getResult(inventory[0]); - - if(result != null) - { - if(inventory[1] == null) - { - inventory[0].stackSize--; - - if(inventory[0].stackSize <= 0) - { - inventory[0] = null; - } - - inventory[1] = result; - didProcess = true; - } + public HashList filters + = new HashList(); + + public static List possibleFilters + = Arrays.asList("ingot", "ore", "dust", "nugget"); + + public RedstoneControl controlType = RedstoneControl.DISABLED; + + public boolean didProcess; + + public TileComponentSecurity securityComponent = new TileComponentSecurity(this); + + public TileEntityOredictionificator() { + super(MachineType.OREDICTIONIFICATOR.name); + + inventory = new ItemStack[2]; + doAutoSync = false; + } + + @Override + public void onUpdate() { + if (!worldObj.isRemote) { + if (playersUsing.size() > 0) { + for (EntityPlayer player : playersUsing) { + Mekanism.packetHandler.sendTo( + new TileEntityMessage( + Coord4D.get(this), getGenericPacket(new ArrayList()) + ), + (EntityPlayerMP) player + ); + } + } + + didProcess = false; + + if (MekanismUtils.canFunction(this) && inventory[0] != null + && getValidName(inventory[0]) != null) { + ItemStack result = getResult(inventory[0]); + + if (result != null) { + if (inventory[1] == null) { + inventory[0].stackSize--; + + if (inventory[0].stackSize <= 0) { + inventory[0] = null; + } + + inventory[1] = result; + didProcess = true; + } else if(inventory[1].isItemEqual(result) && inventory[1].stackSize < inventory[1].getMaxStackSize()) { - inventory[0].stackSize--; - - if(inventory[0].stackSize <= 0) - { - inventory[0] = null; - } - - inventory[1].stackSize++; - didProcess = true; - } - - markDirty(); - } - } - } - } - - public String getValidName(ItemStack stack) - { - List def = OreDictCache.getOreDictName(stack); - - for(String s : def) - { - for(String pre : possibleFilters) - { - if(s.startsWith(pre)) - { - return s; - } - } - } - - return null; - } - - public ItemStack getResult(ItemStack stack) - { - String s = getValidName(stack); - - if(s == null) - { - return null; - } - - List ores = OreDictionary.getOres(s); - - for(OredictionificatorFilter filter : filters) - { - if(filter.filter.equals(s)) - { - if(ores.size()-1 >= filter.index) - { - return MekanismUtils.size(ores.get(filter.index), 1); - } - else { - return null; - } - } - } - - return null; - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) - { - if(side == MekanismUtils.getLeft(facing).ordinal()) - { - return new int[] {0}; - } - else if(side == MekanismUtils.getRight(facing).ordinal()) - { - return new int[] {1}; - } - else { - return InventoryUtils.EMPTY; - } - } + inventory[0].stackSize--; - @Override - public boolean canExtractItem(int slotID, ItemStack itemstack, int side) - { - return slotID == 1; - } + if (inventory[0].stackSize <= 0) { + inventory[0] = null; + } - @Override - public boolean isItemValidForSlot(int slotID, ItemStack itemstack) - { - if(slotID == 0) - { - return getResult(itemstack) != null; - } + inventory[1].stackSize++; + didProcess = true; + } - return false; - } - - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); + markDirty(); + } + } + } + } - nbtTags.setInteger("controlType", controlType.ordinal()); + public String getValidName(ItemStack stack) { + List def = OreDictCache.getOreDictName(stack); - NBTTagList filterTags = new NBTTagList(); + for (String s : def) { + for (String pre : possibleFilters) { + if (s.startsWith(pre)) { + return s; + } + } + } - for(OredictionificatorFilter filter : filters) - { - NBTTagCompound tagCompound = new NBTTagCompound(); - filter.write(tagCompound); - filterTags.appendTag(tagCompound); - } + return null; + } - if(filterTags.tagCount() != 0) - { - nbtTags.setTag("filters", filterTags); - } - } + public ItemStack getResult(ItemStack stack) { + String s = getValidName(stack); - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); + if (s == null) { + return null; + } - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + List ores = OreDictionary.getOres(s); - if(nbtTags.hasKey("filters")) - { - NBTTagList tagList = nbtTags.getTagList("filters", NBT.TAG_COMPOUND); + for (OredictionificatorFilter filter : filters) { + if (filter.filter.equals(s)) { + if (ores.size() - 1 >= filter.index) { + return MekanismUtils.size(ores.get(filter.index), 1); + } else { + return null; + } + } + } - for(int i = 0; i < tagList.tagCount(); i++) - { - filters.add(OredictionificatorFilter.readFromNBT((NBTTagCompound)tagList.getCompoundTagAt(i))); - } - } - } - - @Override - public void handlePacketData(ByteBuf dataStream) - { - super.handlePacketData(dataStream); + return null; + } - if(worldObj.isRemote) - { - int type = dataStream.readInt(); - - if(type == 0) - { - controlType = RedstoneControl.values()[dataStream.readInt()]; - didProcess = dataStream.readBoolean(); - - filters.clear(); - - int amount = dataStream.readInt(); - - for(int i = 0; i < amount; i++) - { - filters.add(OredictionificatorFilter.readFromPacket(dataStream)); - } - } - else if(type == 1) - { - controlType = RedstoneControl.values()[dataStream.readInt()]; - didProcess = dataStream.readBoolean(); - } - else if(type == 2) - { - filters.clear(); - - int amount = dataStream.readInt(); - - for(int i = 0; i < amount; i++) - { - filters.add(OredictionificatorFilter.readFromPacket(dataStream)); - } - } - } - } - - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); + @Override + public int[] getAccessibleSlotsFromSide(int side) { + if (side == MekanismUtils.getLeft(facing).ordinal()) { + return new int[] { 0 }; + } else if (side == MekanismUtils.getRight(facing).ordinal()) { + return new int[] { 1 }; + } else { + return InventoryUtils.EMPTY; + } + } - data.add(0); + @Override + public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { + return slotID == 1; + } - data.add(controlType.ordinal()); - data.add(didProcess); + @Override + public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { + if (slotID == 0) { + return getResult(itemstack) != null; + } - data.add(filters.size()); + return false; + } - for(OredictionificatorFilter filter : filters) - { - filter.write(data); - } + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); - return data; - } + nbtTags.setInteger("controlType", controlType.ordinal()); - public ArrayList getGenericPacket(ArrayList data) - { - super.getNetworkedData(data); + NBTTagList filterTags = new NBTTagList(); - data.add(1); + for (OredictionificatorFilter filter : filters) { + NBTTagCompound tagCompound = new NBTTagCompound(); + filter.write(tagCompound); + filterTags.appendTag(tagCompound); + } - data.add(controlType.ordinal()); - data.add(didProcess); + if (filterTags.tagCount() != 0) { + nbtTags.setTag("filters", filterTags); + } + } - return data; + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); - } + controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - public ArrayList getFilterPacket(ArrayList data) - { - super.getNetworkedData(data); + if (nbtTags.hasKey("filters")) { + NBTTagList tagList = nbtTags.getTagList("filters", NBT.TAG_COMPOUND); - data.add(2); + for (int i = 0; i < tagList.tagCount(); i++) { + filters.add(OredictionificatorFilter.readFromNBT((NBTTagCompound + ) tagList.getCompoundTagAt(i))); + } + } + } - data.add(filters.size()); + @Override + public void handlePacketData(ByteBuf dataStream) { + super.handlePacketData(dataStream); - for(OredictionificatorFilter filter : filters) - { - filter.write(data); - } + if (worldObj.isRemote) { + int type = dataStream.readInt(); - return data; - } - - @Override - public void openInventory() - { - if(!worldObj.isRemote) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getFilterPacket(new ArrayList())), new Range4D(Coord4D.get(this))); - } - } - - @Override - public NBTTagCompound getConfigurationData(NBTTagCompound nbtTags) - { - NBTTagList filterTags = new NBTTagList(); + if (type == 0) { + controlType = RedstoneControl.values()[dataStream.readInt()]; + didProcess = dataStream.readBoolean(); - for(OredictionificatorFilter filter : filters) - { - NBTTagCompound tagCompound = new NBTTagCompound(); - filter.write(tagCompound); - filterTags.appendTag(tagCompound); - } + filters.clear(); - if(filterTags.tagCount() != 0) - { - nbtTags.setTag("filters", filterTags); - } - - return nbtTags; - } + int amount = dataStream.readInt(); - @Override - public void setConfigurationData(NBTTagCompound nbtTags) - { - if(nbtTags.hasKey("filters")) - { - NBTTagList tagList = nbtTags.getTagList("filters", NBT.TAG_COMPOUND); + for (int i = 0; i < amount; i++) { + filters.add(OredictionificatorFilter.readFromPacket(dataStream)); + } + } else if (type == 1) { + controlType = RedstoneControl.values()[dataStream.readInt()]; + didProcess = dataStream.readBoolean(); + } else if (type == 2) { + filters.clear(); - for(int i = 0; i < tagList.tagCount(); i++) - { - filters.add(OredictionificatorFilter.readFromNBT((NBTTagCompound)tagList.getCompoundTagAt(i))); - } - } - } + int amount = dataStream.readInt(); - @Override - public String getDataType() - { - return getBlockType().getUnlocalizedName() + "." + fullName + ".name"; - } + for (int i = 0; i < amount; i++) { + filters.add(OredictionificatorFilter.readFromPacket(dataStream)); + } + } + } + } - @Override - public void writeSustainedData(ItemStack itemStack) - { - itemStack.stackTagCompound.setBoolean("hasOredictionificatorConfig", true); + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); - NBTTagList filterTags = new NBTTagList(); + data.add(0); - for(OredictionificatorFilter filter : filters) - { - NBTTagCompound tagCompound = new NBTTagCompound(); - filter.write(tagCompound); - filterTags.appendTag(tagCompound); - } + data.add(controlType.ordinal()); + data.add(didProcess); - if(filterTags.tagCount() != 0) - { - itemStack.stackTagCompound.setTag("filters", filterTags); - } - } + data.add(filters.size()); - @Override - public void readSustainedData(ItemStack itemStack) - { - if(itemStack.stackTagCompound.hasKey("hasOredictionificatorConfig")) - { - if(itemStack.stackTagCompound.hasKey("filters")) - { - NBTTagList tagList = itemStack.stackTagCompound.getTagList("filters", NBT.TAG_COMPOUND); + for (OredictionificatorFilter filter : filters) { + filter.write(data); + } - for(int i = 0; i < tagList.tagCount(); i++) - { - filters.add(OredictionificatorFilter.readFromNBT((NBTTagCompound)tagList.getCompoundTagAt(i))); - } - } - } - } - - @Override - public RedstoneControl getControlType() - { - return controlType; - } + return data; + } - @Override - public void setControlType(RedstoneControl type) - { - controlType = type; - } + public ArrayList getGenericPacket(ArrayList data) { + super.getNetworkedData(data); - @Override - public boolean canPulse() - { - return true; - } - - @Override - public TileComponentSecurity getSecurity() - { - return securityComponent; - } - - public static class OredictionificatorFilter - { - public String filter; - public int index; - - public void write(NBTTagCompound nbtTags) - { - nbtTags.setString("filter", filter); - nbtTags.setInteger("index", index); - } + data.add(1); - protected void read(NBTTagCompound nbtTags) - { - filter = nbtTags.getString("filter"); - index = nbtTags.getInteger("index"); - } + data.add(controlType.ordinal()); + data.add(didProcess); - public void write(ArrayList data) - { - data.add(filter); - data.add(index); - } + return data; + } - protected void read(ByteBuf dataStream) - { - filter = PacketHandler.readString(dataStream); - index = dataStream.readInt(); - } + public ArrayList getFilterPacket(ArrayList data) { + super.getNetworkedData(data); - public static OredictionificatorFilter readFromNBT(NBTTagCompound nbtTags) - { - OredictionificatorFilter filter = new OredictionificatorFilter(); + data.add(2); - filter.read(nbtTags); + data.add(filters.size()); - return filter; - } + for (OredictionificatorFilter filter : filters) { + filter.write(data); + } - public static OredictionificatorFilter readFromPacket(ByteBuf dataStream) - { - OredictionificatorFilter filter = new OredictionificatorFilter(); + return data; + } - filter.read(dataStream); + @Override + public void openInventory() { + if (!worldObj.isRemote) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getFilterPacket(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + } + } - return filter; - } - - @Override - public OredictionificatorFilter clone() - { - OredictionificatorFilter newFilter = new OredictionificatorFilter(); - newFilter.filter = filter; - newFilter.index = index; + @Override + public NBTTagCompound getConfigurationData(NBTTagCompound nbtTags) { + NBTTagList filterTags = new NBTTagList(); - return newFilter; - } + for (OredictionificatorFilter filter : filters) { + NBTTagCompound tagCompound = new NBTTagCompound(); + filter.write(tagCompound); + filterTags.appendTag(tagCompound); + } - @Override - public int hashCode() - { - int code = 1; - code = 31 * code + filter.hashCode(); - return code; - } + if (filterTags.tagCount() != 0) { + nbtTags.setTag("filters", filterTags); + } - @Override - public boolean equals(Object obj) - { - return obj instanceof OredictionificatorFilter && ((OredictionificatorFilter)obj).filter.equals(filter); - } - } + return nbtTags; + } + + @Override + public void setConfigurationData(NBTTagCompound nbtTags) { + if (nbtTags.hasKey("filters")) { + NBTTagList tagList = nbtTags.getTagList("filters", NBT.TAG_COMPOUND); + + for (int i = 0; i < tagList.tagCount(); i++) { + filters.add(OredictionificatorFilter.readFromNBT((NBTTagCompound + ) tagList.getCompoundTagAt(i))); + } + } + } + + @Override + public String getDataType() { + return getBlockType().getUnlocalizedName() + "." + fullName + ".name"; + } + + @Override + public void writeSustainedData(ItemStack itemStack) { + itemStack.stackTagCompound.setBoolean("hasOredictionificatorConfig", true); + + NBTTagList filterTags = new NBTTagList(); + + for (OredictionificatorFilter filter : filters) { + NBTTagCompound tagCompound = new NBTTagCompound(); + filter.write(tagCompound); + filterTags.appendTag(tagCompound); + } + + if (filterTags.tagCount() != 0) { + itemStack.stackTagCompound.setTag("filters", filterTags); + } + } + + @Override + public void readSustainedData(ItemStack itemStack) { + if (itemStack.stackTagCompound.hasKey("hasOredictionificatorConfig")) { + if (itemStack.stackTagCompound.hasKey("filters")) { + NBTTagList tagList + = itemStack.stackTagCompound.getTagList("filters", NBT.TAG_COMPOUND); + + for (int i = 0; i < tagList.tagCount(); i++) { + filters.add(OredictionificatorFilter.readFromNBT((NBTTagCompound + ) tagList.getCompoundTagAt(i))); + } + } + } + } + + @Override + public RedstoneControl getControlType() { + return controlType; + } + + @Override + public void setControlType(RedstoneControl type) { + controlType = type; + } + + @Override + public boolean canPulse() { + return true; + } + + @Override + public TileComponentSecurity getSecurity() { + return securityComponent; + } + + public static class OredictionificatorFilter { + public String filter; + public int index; + + public void write(NBTTagCompound nbtTags) { + nbtTags.setString("filter", filter); + nbtTags.setInteger("index", index); + } + + protected void read(NBTTagCompound nbtTags) { + filter = nbtTags.getString("filter"); + index = nbtTags.getInteger("index"); + } + + public void write(ArrayList data) { + data.add(filter); + data.add(index); + } + + protected void read(ByteBuf dataStream) { + filter = PacketHandler.readString(dataStream); + index = dataStream.readInt(); + } + + public static OredictionificatorFilter readFromNBT(NBTTagCompound nbtTags) { + OredictionificatorFilter filter = new OredictionificatorFilter(); + + filter.read(nbtTags); + + return filter; + } + + public static OredictionificatorFilter readFromPacket(ByteBuf dataStream) { + OredictionificatorFilter filter = new OredictionificatorFilter(); + + filter.read(dataStream); + + return filter; + } + + @Override + public OredictionificatorFilter clone() { + OredictionificatorFilter newFilter = new OredictionificatorFilter(); + newFilter.filter = filter; + newFilter.index = index; + + return newFilter; + } + + @Override + public int hashCode() { + int code = 1; + code = 31 * code + filter.hashCode(); + return code; + } + + @Override + public boolean equals(Object obj) { + return obj instanceof OredictionificatorFilter + && ((OredictionificatorFilter) obj).filter.equals(filter); + } + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityOsmiumCompressor.java b/src/main/java/mekanism/common/tile/TileEntityOsmiumCompressor.java index 6c00b7418..b4f89990f 100644 --- a/src/main/java/mekanism/common/tile/TileEntityOsmiumCompressor.java +++ b/src/main/java/mekanism/common/tile/TileEntityOsmiumCompressor.java @@ -12,46 +12,46 @@ import mekanism.common.recipe.machines.OsmiumCompressorRecipe; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; -public class TileEntityOsmiumCompressor extends TileEntityAdvancedElectricMachine -{ - public TileEntityOsmiumCompressor() - { - super("compressor", "OsmiumCompressor", usage.osmiumCompressorUsage, 1, 200, MachineType.OSMIUM_COMPRESSOR.baseEnergy, 200); - } +public class TileEntityOsmiumCompressor + extends TileEntityAdvancedElectricMachine { + public TileEntityOsmiumCompressor() { + super( + "compressor", + "OsmiumCompressor", + usage.osmiumCompressorUsage, + 1, + 200, + MachineType.OSMIUM_COMPRESSOR.baseEnergy, + 200 + ); + } - @Override - public Map getRecipes() - { - return Recipe.OSMIUM_COMPRESSOR.get(); - } + @Override + public Map getRecipes() { + return Recipe.OSMIUM_COMPRESSOR.get(); + } - @Override - public GasStack getItemGas(ItemStack itemstack) - { - int amount = 0; + @Override + public GasStack getItemGas(ItemStack itemstack) { + int amount = 0; - for(ItemStack ore : OreDictionary.getOres("ingotOsmium")) - { - if(ore.isItemEqual(itemstack)) - { - return new GasStack(GasRegistry.getGas("liquidOsmium"), 200); - } - } + for (ItemStack ore : OreDictionary.getOres("ingotOsmium")) { + if (ore.isItemEqual(itemstack)) { + return new GasStack(GasRegistry.getGas("liquidOsmium"), 200); + } + } - for(ItemStack ore : OreDictionary.getOres("blockOsmium")) - { - if(ore.isItemEqual(itemstack)) - { - return new GasStack(GasRegistry.getGas("liquidOsmium"), 1800); - } - } + for (ItemStack ore : OreDictionary.getOres("blockOsmium")) { + if (ore.isItemEqual(itemstack)) { + return new GasStack(GasRegistry.getGas("liquidOsmium"), 1800); + } + } - return null; - } + return null; + } - @Override - public boolean isValidGas(Gas gas) - { - return false; - } + @Override + public boolean isValidGas(Gas gas) { + return false; + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityPRC.java b/src/main/java/mekanism/common/tile/TileEntityPRC.java index a220cf3f2..f41d21486 100644 --- a/src/main/java/mekanism/common/tile/TileEntityPRC.java +++ b/src/main/java/mekanism/common/tile/TileEntityPRC.java @@ -1,10 +1,9 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.Map; +import io.netty.buffer.ByteBuf; import mekanism.api.EnumColor; import mekanism.api.MekanismConfig.usage; import mekanism.api.gas.Gas; @@ -42,441 +41,461 @@ import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; -public class TileEntityPRC extends TileEntityBasicMachine implements IFluidHandler, IGasHandler, ITubeConnection, ISustainedData, ITankManager -{ - public FluidTank inputFluidTank = new FluidTank(10000); - public GasTank inputGasTank = new GasTank(10000); - - public GasTank outputGasTank = new GasTank(10000); +public class TileEntityPRC + extends TileEntityBasicMachine + implements IFluidHandler, IGasHandler, ITubeConnection, ISustainedData, ITankManager { + public FluidTank inputFluidTank = new FluidTank(10000); + public GasTank inputGasTank = new GasTank(10000); - public TileEntityPRC() - { - super("prc", MachineType.PRESSURIZED_REACTION_CHAMBER.name, new ResourceLocation("mekanism", "gui/GuiPRC.png"), usage.pressurizedReactionBaseUsage, 100, MachineType.PRESSURIZED_REACTION_CHAMBER.baseEnergy); + public GasTank outputGasTank = new GasTank(10000); - configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.ENERGY, TransmissionType.FLUID, TransmissionType.GAS); - - configComponent.addOutput(TransmissionType.ITEM, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY)); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Input", EnumColor.DARK_RED, new int[] {0})); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Energy", EnumColor.DARK_GREEN, new int[] {1})); - configComponent.addOutput(TransmissionType.ITEM, new SideData("Output", EnumColor.DARK_BLUE, new int[] {2})); - configComponent.setConfig(TransmissionType.ITEM, new byte[] {2, 1, 0, 0, 0, 3}); - - configComponent.addOutput(TransmissionType.FLUID, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY)); - configComponent.addOutput(TransmissionType.FLUID, new SideData("Fluid", EnumColor.YELLOW, new int[] {0})); - configComponent.setConfig(TransmissionType.FLUID, new byte[] {0, 0, 0, 1, 0, 0}); - configComponent.setCanEject(TransmissionType.FLUID, false); - - configComponent.addOutput(TransmissionType.GAS, new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY)); - configComponent.addOutput(TransmissionType.GAS, new SideData("Gas", EnumColor.DARK_RED, new int[] {1})); - configComponent.addOutput(TransmissionType.GAS, new SideData("Output", EnumColor.DARK_BLUE, new int[] {2})); - configComponent.setConfig(TransmissionType.GAS, new byte[] {0, 0, 0, 0, 1, 2}); - - configComponent.setInputConfig(TransmissionType.ENERGY); + public TileEntityPRC() { + super( + "prc", + MachineType.PRESSURIZED_REACTION_CHAMBER.name, + new ResourceLocation("mekanism", "gui/GuiPRC.png"), + usage.pressurizedReactionBaseUsage, + 100, + MachineType.PRESSURIZED_REACTION_CHAMBER.baseEnergy + ); - inventory = new ItemStack[4]; + configComponent = new TileComponentConfig( + this, + TransmissionType.ITEM, + TransmissionType.ENERGY, + TransmissionType.FLUID, + TransmissionType.GAS + ); - upgradeComponent = new TileComponentUpgrade(this, 3); - upgradeComponent.setSupported(Upgrade.MUFFLING); - - ejectorComponent = new TileComponentEjector(this); - ejectorComponent.setOutputData(TransmissionType.ITEM, configComponent.getOutputs(TransmissionType.ITEM).get(3)); - ejectorComponent.setOutputData(TransmissionType.GAS, configComponent.getOutputs(TransmissionType.GAS).get(2)); - } + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY) + ); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("Input", EnumColor.DARK_RED, new int[] { 0 }) + ); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("Energy", EnumColor.DARK_GREEN, new int[] { 1 }) + ); + configComponent.addOutput( + TransmissionType.ITEM, + new SideData("Output", EnumColor.DARK_BLUE, new int[] { 2 }) + ); + configComponent.setConfig(TransmissionType.ITEM, new byte[] { 2, 1, 0, 0, 0, 3 }); - @Override - public void onUpdate() - { - super.onUpdate(); + configComponent.addOutput( + TransmissionType.FLUID, + new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY) + ); + configComponent.addOutput( + TransmissionType.FLUID, + new SideData("Fluid", EnumColor.YELLOW, new int[] { 0 }) + ); + configComponent.setConfig( + TransmissionType.FLUID, new byte[] { 0, 0, 0, 1, 0, 0 } + ); + configComponent.setCanEject(TransmissionType.FLUID, false); - if(!worldObj.isRemote) - { - PressurizedRecipe recipe = getRecipe(); + configComponent.addOutput( + TransmissionType.GAS, + new SideData("None", EnumColor.GREY, InventoryUtils.EMPTY) + ); + configComponent.addOutput( + TransmissionType.GAS, new SideData("Gas", EnumColor.DARK_RED, new int[] { 1 }) + ); + configComponent.addOutput( + TransmissionType.GAS, + new SideData("Output", EnumColor.DARK_BLUE, new int[] { 2 }) + ); + configComponent.setConfig(TransmissionType.GAS, new byte[] { 0, 0, 0, 0, 1, 2 }); - ChargeUtils.discharge(1, this); + configComponent.setInputConfig(TransmissionType.ENERGY); - if(canOperate(recipe) && MekanismUtils.canFunction(this) && getEnergy() >= MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK + recipe.extraEnergy)) - { - boolean update = BASE_TICKS_REQUIRED != recipe.ticks; - - BASE_TICKS_REQUIRED = recipe.ticks; - - if(update) - { - recalculateUpgradables(Upgrade.SPEED); - } - - setActive(true); + inventory = new ItemStack[4]; - if((operatingTicks+1) < ticksRequired) - { - operatingTicks++; - electricityStored -= MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK + recipe.extraEnergy); - } + upgradeComponent = new TileComponentUpgrade(this, 3); + upgradeComponent.setSupported(Upgrade.MUFFLING); + + ejectorComponent = new TileComponentEjector(this); + ejectorComponent.setOutputData( + TransmissionType.ITEM, + configComponent.getOutputs(TransmissionType.ITEM).get(3) + ); + ejectorComponent.setOutputData( + TransmissionType.GAS, configComponent.getOutputs(TransmissionType.GAS).get(2) + ); + } + + @Override + public void onUpdate() { + super.onUpdate(); + + if (!worldObj.isRemote) { + PressurizedRecipe recipe = getRecipe(); + + ChargeUtils.discharge(1, this); + + if (canOperate(recipe) && MekanismUtils.canFunction(this) + && getEnergy() >= MekanismUtils.getEnergyPerTick( + this, BASE_ENERGY_PER_TICK + recipe.extraEnergy + )) { + boolean update = BASE_TICKS_REQUIRED != recipe.ticks; + + BASE_TICKS_REQUIRED = recipe.ticks; + + if (update) { + recalculateUpgradables(Upgrade.SPEED); + } + + setActive(true); + + if ((operatingTicks + 1) < ticksRequired) { + operatingTicks++; + electricityStored -= MekanismUtils.getEnergyPerTick( + this, BASE_ENERGY_PER_TICK + recipe.extraEnergy + ); + } else if((operatingTicks+1) >= ticksRequired && getEnergy() >= MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK + recipe.extraEnergy)) { - operate(recipe); + operate(recipe); - operatingTicks = 0; - electricityStored -= MekanismUtils.getEnergyPerTick(this, BASE_ENERGY_PER_TICK + recipe.extraEnergy); - } - } - else { - BASE_TICKS_REQUIRED = 100; - - if(prevEnergy >= getEnergy()) - { - setActive(false); - } - } + operatingTicks = 0; + electricityStored -= MekanismUtils.getEnergyPerTick( + this, BASE_ENERGY_PER_TICK + recipe.extraEnergy + ); + } + } else { + BASE_TICKS_REQUIRED = 100; - if(!canOperate(recipe)) - { - operatingTicks = 0; - } + if (prevEnergy >= getEnergy()) { + setActive(false); + } + } - prevEnergy = getEnergy(); - } - } + if (!canOperate(recipe)) { + operatingTicks = 0; + } - @Override - public boolean isItemValidForSlot(int slotID, ItemStack itemstack) - { - if(slotID == 0) - { - return RecipeHandler.isInPressurizedRecipe(itemstack); - } - else if(slotID == 1) - { - return ChargeUtils.canBeDischarged(itemstack); - } - else if(slotID == 3) - { - return itemstack.getItem() instanceof ItemUpgrade; - } + prevEnergy = getEnergy(); + } + } - return false; - } + @Override + public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { + if (slotID == 0) { + return RecipeHandler.isInPressurizedRecipe(itemstack); + } else if (slotID == 1) { + return ChargeUtils.canBeDischarged(itemstack); + } else if (slotID == 3) { + return itemstack.getItem() instanceof ItemUpgrade; + } - @Override - public PressurizedRecipe getRecipe() - { - PressurizedInput input = getInput(); - - if(cachedRecipe == null || !input.testEquality(cachedRecipe.getInput())) - { - cachedRecipe = RecipeHandler.getPRCRecipe(input); - } - - return cachedRecipe; - } + return false; + } - @Override - public PressurizedInput getInput() - { - return new PressurizedInput(inventory[0], inputFluidTank.getFluid(), inputGasTank.getGas()); - } + @Override + public PressurizedRecipe getRecipe() { + PressurizedInput input = getInput(); - @Override - public void operate(PressurizedRecipe recipe) - { - recipe.operate(inventory, inputFluidTank, inputGasTank, outputGasTank); + if (cachedRecipe == null || !input.testEquality(cachedRecipe.getInput())) { + cachedRecipe = RecipeHandler.getPRCRecipe(input); + } - markDirty(); - ejectorComponent.outputItems(); - } + return cachedRecipe; + } - @Override - public boolean canOperate(PressurizedRecipe recipe) - { - return recipe != null && recipe.canOperate(inventory, inputFluidTank, inputGasTank, outputGasTank); - } - - @Override - public boolean canExtractItem(int slotID, ItemStack itemstack, int side) - { - if(slotID == 1) - { - return ChargeUtils.canBeOutputted(itemstack, false); - } - else if(slotID == 2 || slotID == 4) - { - return true; - } + @Override + public PressurizedInput getInput() { + return new PressurizedInput( + inventory[0], inputFluidTank.getFluid(), inputGasTank.getGas() + ); + } - return false; - } + @Override + public void operate(PressurizedRecipe recipe) { + recipe.operate(inventory, inputFluidTank, inputGasTank, outputGasTank); - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); + markDirty(); + ejectorComponent.outputItems(); + } - if(inputFluidTank.getFluid() != null) - { - data.add(true); - data.add(inputFluidTank.getFluid().getFluid().getID()); - data.add(inputFluidTank.getFluidAmount()); - } - else { - data.add(false); - } + @Override + public boolean canOperate(PressurizedRecipe recipe) { + return recipe != null + && recipe.canOperate(inventory, inputFluidTank, inputGasTank, outputGasTank); + } - if(inputGasTank.getGas() != null) - { - data.add(true); - data.add(inputGasTank.getGas().getGas().getID()); - data.add(inputGasTank.getStored()); - } - else { - data.add(false); - } + @Override + public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { + if (slotID == 1) { + return ChargeUtils.canBeOutputted(itemstack, false); + } else if (slotID == 2 || slotID == 4) { + return true; + } - if(outputGasTank.getGas() != null) - { - data.add(true); - data.add(outputGasTank.getGas().getGas().getID()); - data.add(outputGasTank.getStored()); - } - else { - data.add(false); - } + return false; + } - return data; - } + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); - @Override - public void handlePacketData(ByteBuf dataStream) - { - super.handlePacketData(dataStream); + if (inputFluidTank.getFluid() != null) { + data.add(true); + data.add(inputFluidTank.getFluid().getFluid().getID()); + data.add(inputFluidTank.getFluidAmount()); + } else { + data.add(false); + } - if(worldObj.isRemote) - { - if(dataStream.readBoolean()) - { - inputFluidTank.setFluid(new FluidStack(FluidRegistry.getFluid(dataStream.readInt()), dataStream.readInt())); - } - else { - inputFluidTank.setFluid(null); - } - - if(dataStream.readBoolean()) - { - inputGasTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt())); - } - else { - inputGasTank.setGas(null); - } - - if(dataStream.readBoolean()) - { - outputGasTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt())); - } - else { - outputGasTank.setGas(null); - } - } - } + if (inputGasTank.getGas() != null) { + data.add(true); + data.add(inputGasTank.getGas().getGas().getID()); + data.add(inputGasTank.getStored()); + } else { + data.add(false); + } - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); + if (outputGasTank.getGas() != null) { + data.add(true); + data.add(outputGasTank.getGas().getGas().getID()); + data.add(outputGasTank.getStored()); + } else { + data.add(false); + } - inputFluidTank.readFromNBT(nbtTags.getCompoundTag("inputFluidTank")); - inputGasTank.read(nbtTags.getCompoundTag("inputGasTank")); - outputGasTank.read(nbtTags.getCompoundTag("outputGasTank")); - } + return data; + } - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); + @Override + public void handlePacketData(ByteBuf dataStream) { + super.handlePacketData(dataStream); - nbtTags.setTag("inputFluidTank", inputFluidTank.writeToNBT(new NBTTagCompound())); - nbtTags.setTag("inputGasTank", inputGasTank.write(new NBTTagCompound())); - nbtTags.setTag("outputGasTank", outputGasTank.write(new NBTTagCompound())); - } + if (worldObj.isRemote) { + if (dataStream.readBoolean()) { + inputFluidTank.setFluid(new FluidStack( + FluidRegistry.getFluid(dataStream.readInt()), dataStream.readInt() + )); + } else { + inputFluidTank.setFluid(null); + } - @Override - public String getInventoryName() - { - return LangUtils.localize(getBlockType().getUnlocalizedName() + "." + fullName + ".short.name"); - } + if (dataStream.readBoolean()) { + inputGasTank.setGas(new GasStack( + GasRegistry.getGas(dataStream.readInt()), dataStream.readInt() + )); + } else { + inputGasTank.setGas(null); + } - @Override - public Map getRecipes() - { - return null; - } + if (dataStream.readBoolean()) { + outputGasTank.setGas(new GasStack( + GasRegistry.getGas(dataStream.readInt()), dataStream.readInt() + )); + } else { + outputGasTank.setGas(null); + } + } + } - private static final String[] methods = new String[] {"getEnergy", "getProgress", "isActive", "facing", "canOperate", "getMaxEnergy", "getEnergyNeeded", "getFluidStored", "getGasStored"}; + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); - @Override - public String[] getMethods() - { - return methods; - } + inputFluidTank.readFromNBT(nbtTags.getCompoundTag("inputFluidTank")); + inputGasTank.read(nbtTags.getCompoundTag("inputGasTank")); + outputGasTank.read(nbtTags.getCompoundTag("outputGasTank")); + } - @Override - public Object[] invoke(int method, Object[] arguments) throws Exception - { - switch(method) - { - case 0: - return new Object[] {getEnergy()}; - case 1: - return new Object[] {operatingTicks}; - case 2: - return new Object[] {isActive}; - case 3: - return new Object[] {facing}; - case 4: - return new Object[] {canOperate(getRecipe())}; - case 5: - return new Object[] {getMaxEnergy()}; - case 6: - return new Object[] {getMaxEnergy()-getEnergy()}; - case 7: - return new Object[] {inputFluidTank.getFluidAmount()}; - case 8: - return new Object[] {inputGasTank.getStored()}; - default: - throw new NoSuchMethodException(); - } - } + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); - @Override - public int fill(ForgeDirection from, FluidStack resource, boolean doFill) - { - if(canFill(from, resource.getFluid())) - { - return inputFluidTank.fill(resource, doFill); - } - - return 0; - } + nbtTags.setTag("inputFluidTank", inputFluidTank.writeToNBT(new NBTTagCompound())); + nbtTags.setTag("inputGasTank", inputGasTank.write(new NBTTagCompound())); + nbtTags.setTag("outputGasTank", outputGasTank.write(new NBTTagCompound())); + } - @Override - public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) - { - return null; - } + @Override + public String getInventoryName() { + return LangUtils.localize( + getBlockType().getUnlocalizedName() + "." + fullName + ".short.name" + ); + } - @Override - public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) - { - return null; - } + @Override + public Map getRecipes() { + return null; + } - @Override - public boolean canFill(ForgeDirection from, Fluid fluid) - { - SideData data = configComponent.getOutput(TransmissionType.FLUID, from.ordinal(), facing); - - if(data.hasSlot(0)) - { - return inputFluidTank.getFluid() == null || inputFluidTank.getFluid().getFluid() == fluid; - } - - return false; - } + private static final String[] methods + = new String[] { "getEnergy", "getProgress", "isActive", + "facing", "canOperate", "getMaxEnergy", + "getEnergyNeeded", "getFluidStored", "getGasStored" }; - @Override - public boolean canDrain(ForgeDirection from, Fluid fluid) - { - return false; - } + @Override + public String[] getMethods() { + return methods; + } - @Override - public FluidTankInfo[] getTankInfo(ForgeDirection from) - { - SideData data = configComponent.getOutput(TransmissionType.FLUID, from.ordinal(), facing); - - return data.getFluidTankInfo(this); - } + @Override + public Object[] invoke(int method, Object[] arguments) throws Exception { + switch (method) { + case 0: + return new Object[] { getEnergy() }; + case 1: + return new Object[] { operatingTicks }; + case 2: + return new Object[] { isActive }; + case 3: + return new Object[] { facing }; + case 4: + return new Object[] { canOperate(getRecipe()) }; + case 5: + return new Object[] { getMaxEnergy() }; + case 6: + return new Object[] { getMaxEnergy() - getEnergy() }; + case 7: + return new Object[] { inputFluidTank.getFluidAmount() }; + case 8: + return new Object[] { inputGasTank.getStored() }; + default: + throw new NoSuchMethodException(); + } + } - @Override - public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) - { - if(canReceiveGas(side, stack.getGas())) - { - return inputGasTank.receive(stack, doTransfer); - } - - return 0; - } + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { + if (canFill(from, resource.getFluid())) { + return inputFluidTank.fill(resource, doFill); + } - @Override - public int receiveGas(ForgeDirection side, GasStack stack) - { - return receiveGas(side, stack, true); - } + return 0; + } - @Override - public GasStack drawGas(ForgeDirection side, int amount, boolean doTransfer) - { - if(canDrawGas(side, null)) - { - return outputGasTank.draw(amount, doTransfer); - } - - return null; - } + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + return null; + } - @Override - public GasStack drawGas(ForgeDirection side, int amount) - { - return drawGas(side, amount, true); - } + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { + return null; + } - @Override - public boolean canReceiveGas(ForgeDirection side, Gas type) - { - return configComponent.getOutput(TransmissionType.GAS, side.ordinal(), facing).hasSlot(1) && inputGasTank.canReceive(type); - } + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + SideData data + = configComponent.getOutput(TransmissionType.FLUID, from.ordinal(), facing); - @Override - public boolean canDrawGas(ForgeDirection side, Gas type) - { - return configComponent.getOutput(TransmissionType.GAS, side.ordinal(), facing).hasSlot(2) && outputGasTank.canDraw(type); - } + if (data.hasSlot(0)) { + return inputFluidTank.getFluid() == null + || inputFluidTank.getFluid().getFluid() == fluid; + } - @Override - public boolean canTubeConnect(ForgeDirection side) - { - return configComponent.getOutput(TransmissionType.GAS, side.ordinal(), facing).hasSlot(1, 2); - } + return false; + } - @Override - public void writeSustainedData(ItemStack itemStack) - { - if(inputFluidTank.getFluid() != null) - { - itemStack.stackTagCompound.setTag("inputFluidTank", inputFluidTank.getFluid().writeToNBT(new NBTTagCompound())); - } - - if(inputGasTank.getGas() != null) - { - itemStack.stackTagCompound.setTag("inputGasTank", inputGasTank.getGas().write(new NBTTagCompound())); - } - - if(outputGasTank.getGas() != null) - { - itemStack.stackTagCompound.setTag("outputGasTank", outputGasTank.getGas().write(new NBTTagCompound())); - } - } + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + return false; + } - @Override - public void readSustainedData(ItemStack itemStack) - { - inputFluidTank.setFluid(FluidStack.loadFluidStackFromNBT(itemStack.stackTagCompound.getCompoundTag("inputFluidTank"))); - inputGasTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("inputGasTank"))); - outputGasTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("outputGasTank"))); - } - - @Override - public Object[] getTanks() - { - return new Object[] {inputFluidTank, inputGasTank, outputGasTank}; - } + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection from) { + SideData data + = configComponent.getOutput(TransmissionType.FLUID, from.ordinal(), facing); + + return data.getFluidTankInfo(this); + } + + @Override + public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) { + if (canReceiveGas(side, stack.getGas())) { + return inputGasTank.receive(stack, doTransfer); + } + + return 0; + } + + @Override + public int receiveGas(ForgeDirection side, GasStack stack) { + return receiveGas(side, stack, true); + } + + @Override + public GasStack drawGas(ForgeDirection side, int amount, boolean doTransfer) { + if (canDrawGas(side, null)) { + return outputGasTank.draw(amount, doTransfer); + } + + return null; + } + + @Override + public GasStack drawGas(ForgeDirection side, int amount) { + return drawGas(side, amount, true); + } + + @Override + public boolean canReceiveGas(ForgeDirection side, Gas type) { + return configComponent.getOutput(TransmissionType.GAS, side.ordinal(), facing) + .hasSlot(1) + && inputGasTank.canReceive(type); + } + + @Override + public boolean canDrawGas(ForgeDirection side, Gas type) { + return configComponent.getOutput(TransmissionType.GAS, side.ordinal(), facing) + .hasSlot(2) + && outputGasTank.canDraw(type); + } + + @Override + public boolean canTubeConnect(ForgeDirection side) { + return configComponent.getOutput(TransmissionType.GAS, side.ordinal(), facing) + .hasSlot(1, 2); + } + + @Override + public void writeSustainedData(ItemStack itemStack) { + if (inputFluidTank.getFluid() != null) { + itemStack.stackTagCompound.setTag( + "inputFluidTank", + inputFluidTank.getFluid().writeToNBT(new NBTTagCompound()) + ); + } + + if (inputGasTank.getGas() != null) { + itemStack.stackTagCompound.setTag( + "inputGasTank", inputGasTank.getGas().write(new NBTTagCompound()) + ); + } + + if (outputGasTank.getGas() != null) { + itemStack.stackTagCompound.setTag( + "outputGasTank", outputGasTank.getGas().write(new NBTTagCompound()) + ); + } + } + + @Override + public void readSustainedData(ItemStack itemStack) { + inputFluidTank.setFluid(FluidStack.loadFluidStackFromNBT( + itemStack.stackTagCompound.getCompoundTag("inputFluidTank") + )); + inputGasTank.setGas(GasStack.readFromNBT( + itemStack.stackTagCompound.getCompoundTag("inputGasTank") + )); + outputGasTank.setGas(GasStack.readFromNBT( + itemStack.stackTagCompound.getCompoundTag("outputGasTank") + )); + } + + @Override + public Object[] getTanks() { + return new Object[] { inputFluidTank, inputGasTank, outputGasTank }; + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityPersonalChest.java b/src/main/java/mekanism/common/tile/TileEntityPersonalChest.java index 4ce381b37..7b8039102 100644 --- a/src/main/java/mekanism/common/tile/TileEntityPersonalChest.java +++ b/src/main/java/mekanism/common/tile/TileEntityPersonalChest.java @@ -1,122 +1,119 @@ package mekanism.common.tile; +import cpw.mods.fml.relauncher.Side; import mekanism.common.security.ISecurityTile; import mekanism.common.tile.component.TileComponentSecurity; import mekanism.common.util.InventoryUtils; import mekanism.common.util.SecurityUtils; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; -import cpw.mods.fml.relauncher.Side; -public class TileEntityPersonalChest extends TileEntityContainerBlock implements ISecurityTile -{ - public static int[] INV; +public class TileEntityPersonalChest + extends TileEntityContainerBlock implements ISecurityTile { + public static int[] INV; - public float lidAngle; + public float lidAngle; - public float prevLidAngle; - - public TileComponentSecurity securityComponent; + public float prevLidAngle; - public TileEntityPersonalChest() - { - super("PersonalChest"); - inventory = new ItemStack[54]; - - securityComponent = new TileComponentSecurity(this); - } + public TileComponentSecurity securityComponent; - @Override - public void onUpdate() - { - prevLidAngle = lidAngle; - float increment = 0.1F; + public TileEntityPersonalChest() { + super("PersonalChest"); + inventory = new ItemStack[54]; - if((playersUsing.size() > 0) && (lidAngle == 0.0F)) - { - worldObj.playSoundEffect(xCoord + 0.5F, yCoord + 0.5D, zCoord + 0.5F, "random.chestopen", 0.5F, (worldObj.rand.nextFloat()*0.1F) + 0.9F); - } + securityComponent = new TileComponentSecurity(this); + } - if((playersUsing.size() == 0 && lidAngle > 0.0F) || (playersUsing.size() > 0 && lidAngle < 1.0F)) - { - float angle = lidAngle; + @Override + public void onUpdate() { + prevLidAngle = lidAngle; + float increment = 0.1F; - if(playersUsing.size() > 0) - { - lidAngle += increment; - } - else { - lidAngle -= increment; - } + if ((playersUsing.size() > 0) && (lidAngle == 0.0F)) { + worldObj.playSoundEffect( + xCoord + 0.5F, + yCoord + 0.5D, + zCoord + 0.5F, + "random.chestopen", + 0.5F, + (worldObj.rand.nextFloat() * 0.1F) + 0.9F + ); + } - if(lidAngle > 1.0F) - { - lidAngle = 1.0F; - } + if ((playersUsing.size() == 0 && lidAngle > 0.0F) + || (playersUsing.size() > 0 && lidAngle < 1.0F)) { + float angle = lidAngle; - float split = 0.5F; + if (playersUsing.size() > 0) { + lidAngle += increment; + } else { + lidAngle -= increment; + } - if(lidAngle < split && angle >= split) - { - worldObj.playSoundEffect(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "random.chestclosed", 0.5F, (worldObj.rand.nextFloat()*0.1F) + 0.9F); - } + if (lidAngle > 1.0F) { + lidAngle = 1.0F; + } - if(lidAngle < 0.0F) - { - lidAngle = 0.0F; - } - } - } + float split = 0.5F; - @Override - public boolean isItemValidForSlot(int slotID, ItemStack itemstack) - { - return true; - } + if (lidAngle < split && angle >= split) { + worldObj.playSoundEffect( + xCoord + 0.5D, + yCoord + 0.5D, + zCoord + 0.5D, + "random.chestclosed", + 0.5F, + (worldObj.rand.nextFloat() * 0.1F) + 0.9F + ); + } - @Override - public int[] getAccessibleSlotsFromSide(int side) - { - if(side == 0 || SecurityUtils.getSecurity(this, Side.SERVER) != SecurityMode.PUBLIC) - { - return InventoryUtils.EMPTY; - } - else { - if(INV == null) - { - INV = new int[54]; + if (lidAngle < 0.0F) { + lidAngle = 0.0F; + } + } + } - for(int i = 0; i < INV.length; i++) - { - INV[i] = i; - } - } + @Override + public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { + return true; + } - return INV; - } - } + @Override + public int[] getAccessibleSlotsFromSide(int side) { + if (side == 0 + || SecurityUtils.getSecurity(this, Side.SERVER) != SecurityMode.PUBLIC) { + return InventoryUtils.EMPTY; + } else { + if (INV == null) { + INV = new int[54]; - @Override - public boolean canExtractItem(int slotID, ItemStack itemstack, int side) - { - return true; - } + for (int i = 0; i < INV.length; i++) { + INV[i] = i; + } + } - @Override - public boolean wrenchCanRemove(EntityPlayer entityPlayer) - { - return SecurityUtils.canAccess(entityPlayer, this); - } + return INV; + } + } - @Override - public boolean canSetFacing(int side) - { - return side != 0 && side != 1; - } + @Override + public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { + return true; + } - @Override - public TileComponentSecurity getSecurity() - { - return securityComponent; - } + @Override + public boolean wrenchCanRemove(EntityPlayer entityPlayer) { + return SecurityUtils.canAccess(entityPlayer, this); + } + + @Override + public boolean canSetFacing(int side) { + return side != 0 && side != 1; + } + + @Override + public TileComponentSecurity getSecurity() { + return securityComponent; + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityPrecisionSawmill.java b/src/main/java/mekanism/common/tile/TileEntityPrecisionSawmill.java index 5666d6526..e1e2c913a 100644 --- a/src/main/java/mekanism/common/tile/TileEntityPrecisionSawmill.java +++ b/src/main/java/mekanism/common/tile/TileEntityPrecisionSawmill.java @@ -2,6 +2,8 @@ package mekanism.common.tile; import java.util.Map; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.MekanismConfig.usage; import mekanism.common.block.BlockMachine.MachineType; import mekanism.common.recipe.RecipeHandler.Recipe; @@ -9,26 +11,27 @@ import mekanism.common.recipe.inputs.ItemStackInput; import mekanism.common.recipe.machines.SawmillRecipe; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class TileEntityPrecisionSawmill extends TileEntityChanceMachine -{ - public TileEntityPrecisionSawmill() - { - super("sawmill", "PrecisionSawmill", MekanismUtils.getResource(ResourceType.GUI, "GuiBasicMachine.png"), usage.precisionSawmillUsage, 200, MachineType.PRECISION_SAWMILL.baseEnergy); - } +public class TileEntityPrecisionSawmill extends TileEntityChanceMachine { + public TileEntityPrecisionSawmill() { + super( + "sawmill", + "PrecisionSawmill", + MekanismUtils.getResource(ResourceType.GUI, "GuiBasicMachine.png"), + usage.precisionSawmillUsage, + 200, + MachineType.PRECISION_SAWMILL.baseEnergy + ); + } - @Override - public Map getRecipes() - { - return Recipe.PRECISION_SAWMILL.get(); - } + @Override + public Map getRecipes() { + return Recipe.PRECISION_SAWMILL.get(); + } - @Override - @SideOnly(Side.CLIENT) - public float getVolume() - { - return 0.7F*super.getVolume(); - } + @Override + @SideOnly(Side.CLIENT) + public float getVolume() { + return 0.7F * super.getVolume(); + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityPressureDisperser.java b/src/main/java/mekanism/common/tile/TileEntityPressureDisperser.java index 7567d7cb8..73b27ed59 100644 --- a/src/main/java/mekanism/common/tile/TileEntityPressureDisperser.java +++ b/src/main/java/mekanism/common/tile/TileEntityPressureDisperser.java @@ -1,13 +1,11 @@ package mekanism.common.tile; -public class TileEntityPressureDisperser extends TileEntityBasicBlock -{ - @Override - public boolean canUpdate() - { - return false; - } +public class TileEntityPressureDisperser extends TileEntityBasicBlock { + @Override + public boolean canUpdate() { + return false; + } - @Override - public void onUpdate() {} + @Override + public void onUpdate() {} } diff --git a/src/main/java/mekanism/common/tile/TileEntityPurificationChamber.java b/src/main/java/mekanism/common/tile/TileEntityPurificationChamber.java index aba3328bd..63ac4a24c 100644 --- a/src/main/java/mekanism/common/tile/TileEntityPurificationChamber.java +++ b/src/main/java/mekanism/common/tile/TileEntityPurificationChamber.java @@ -17,80 +17,82 @@ import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityPurificationChamber extends TileEntityAdvancedElectricMachine -{ - public TileEntityPurificationChamber() - { - super("purification", "PurificationChamber", usage.purificationChamberUsage, 1, 200, MachineType.PURIFICATION_CHAMBER.baseEnergy); - } +public class TileEntityPurificationChamber + extends TileEntityAdvancedElectricMachine { + public TileEntityPurificationChamber() { + super( + "purification", + "PurificationChamber", + usage.purificationChamberUsage, + 1, + 200, + MachineType.PURIFICATION_CHAMBER.baseEnergy + ); + } - @Override - public Map getRecipes() - { - return Recipe.PURIFICATION_CHAMBER.get(); - } + @Override + public Map getRecipes() { + return Recipe.PURIFICATION_CHAMBER.get(); + } - @Override - public GasStack getItemGas(ItemStack itemstack) - { - if(itemstack.isItemEqual(new ItemStack(Items.flint))) return new GasStack(GasRegistry.getGas("oxygen"), 10); - if(Block.getBlockFromItem(itemstack.getItem()) == MekanismBlocks.GasTank && ((IGasItem)itemstack.getItem()).getGas(itemstack) != null && - ((IGasItem)itemstack.getItem()).getGas(itemstack).getGas() == GasRegistry.getGas("oxygen")) return new GasStack(GasRegistry.getGas("oxygen"), 1); + @Override + public GasStack getItemGas(ItemStack itemstack) { + if (itemstack.isItemEqual(new ItemStack(Items.flint))) + return new GasStack(GasRegistry.getGas("oxygen"), 10); + if (Block.getBlockFromItem(itemstack.getItem()) == MekanismBlocks.GasTank + && ((IGasItem) itemstack.getItem()).getGas(itemstack) != null + && ((IGasItem) itemstack.getItem()).getGas(itemstack).getGas() + == GasRegistry.getGas("oxygen")) + return new GasStack(GasRegistry.getGas("oxygen"), 1); - return null; - } + return null; + } - @Override - public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) - { - if(stack.getGas() == GasRegistry.getGas("oxygen")) - { - return gasTank.receive(stack, doTransfer); - } + @Override + public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) { + if (stack.getGas() == GasRegistry.getGas("oxygen")) { + return gasTank.receive(stack, doTransfer); + } - return 0; - } + return 0; + } - @Override - public boolean canReceiveGas(ForgeDirection side, Gas type) - { - return type == GasRegistry.getGas("oxygen"); - } + @Override + public boolean canReceiveGas(ForgeDirection side, Gas type) { + return type == GasRegistry.getGas("oxygen"); + } - @Override - public void handleSecondaryFuel() - { - if(inventory[1] != null && gasTank.getNeeded() > 0 && inventory[1].getItem() instanceof IGasItem) - { - GasStack removed = GasTransmission.removeGas(inventory[1], GasRegistry.getGas("oxygen"), gasTank.getNeeded()); - gasTank.receive(removed, true); - return; - } + @Override + public void handleSecondaryFuel() { + if (inventory[1] != null && gasTank.getNeeded() > 0 + && inventory[1].getItem() instanceof IGasItem) { + GasStack removed = GasTransmission.removeGas( + inventory[1], GasRegistry.getGas("oxygen"), gasTank.getNeeded() + ); + gasTank.receive(removed, true); + return; + } - super.handleSecondaryFuel(); - } + super.handleSecondaryFuel(); + } - @Override - public boolean canTubeConnect(ForgeDirection side) - { - return true; - } + @Override + public boolean canTubeConnect(ForgeDirection side) { + return true; + } - @Override - public boolean isValidGas(Gas gas) - { - return gas == GasRegistry.getGas("oxygen"); - } + @Override + public boolean isValidGas(Gas gas) { + return gas == GasRegistry.getGas("oxygen"); + } - @Override - public boolean upgradeableSecondaryEfficiency() - { - return true; - } + @Override + public boolean upgradeableSecondaryEfficiency() { + return true; + } - @Override - public boolean useStatisticalMechanics() - { - return true; - } + @Override + public boolean useStatisticalMechanics() { + return true; + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityQuantumEntangloporter.java b/src/main/java/mekanism/common/tile/TileEntityQuantumEntangloporter.java index c87f7d001..6717c1231 100644 --- a/src/main/java/mekanism/common/tile/TileEntityQuantumEntangloporter.java +++ b/src/main/java/mekanism/common/tile/TileEntityQuantumEntangloporter.java @@ -1,11 +1,10 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.EnumSet; import java.util.List; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.IHeatTransfer; import mekanism.api.gas.Gas; @@ -42,695 +41,669 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; -public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock implements ISideConfiguration, ITankManager, IFluidHandler, IFrequencyHandler, IGasHandler, IHeatTransfer, ITubeConnection, IComputerIntegration, ISecurityTile -{ - public InventoryFrequency frequency; - - public double heatToAbsorb = 0; - - public double lastTransferLoss; - public double lastEnvironmentLoss; - - public List publicCache = new ArrayList(); - public List protectedCache = new ArrayList(); - public List privateCache = new ArrayList(); +public class TileEntityQuantumEntangloporter extends TileEntityElectricBlock + implements ISideConfiguration, ITankManager, IFluidHandler, IFrequencyHandler, + IGasHandler, IHeatTransfer, ITubeConnection, IComputerIntegration, + ISecurityTile { + public InventoryFrequency frequency; - public static final EnumSet nothing = EnumSet.noneOf(ForgeDirection.class); - - public TileComponentEjector ejectorComponent; - public TileComponentConfig configComponent; - public TileComponentSecurity securityComponent; + public double heatToAbsorb = 0; - public TileEntityQuantumEntangloporter() - { - super("QuantumEntangloporter", 0); - - configComponent = new TileComponentConfig(this, TransmissionType.ITEM, TransmissionType.FLUID, TransmissionType.GAS, TransmissionType.ENERGY, TransmissionType.HEAT); - - for(TransmissionType type : TransmissionType.values()) - { - if(type != TransmissionType.HEAT) - { - configComponent.setIOConfig(type); - } - else { - configComponent.setInputConfig(type); - } - } + public double lastTransferLoss; + public double lastEnvironmentLoss; - inventory = new ItemStack[0]; - - configComponent.getOutputs(TransmissionType.ITEM).get(2).availableSlots = new int[] {0}; - configComponent.getOutputs(TransmissionType.FLUID).get(2).availableSlots = new int[] {0}; - configComponent.getOutputs(TransmissionType.GAS).get(2).availableSlots = new int[] {1}; - - ejectorComponent = new TileComponentEjector(this); - ejectorComponent.setOutputData(TransmissionType.ITEM, configComponent.getOutputs(TransmissionType.ITEM).get(2)); - ejectorComponent.setOutputData(TransmissionType.FLUID, configComponent.getOutputs(TransmissionType.FLUID).get(2)); - ejectorComponent.setOutputData(TransmissionType.GAS, configComponent.getOutputs(TransmissionType.GAS).get(2)); - - securityComponent = new TileComponentSecurity(this); - } + public List publicCache = new ArrayList(); + public List protectedCache = new ArrayList(); + public List privateCache = new ArrayList(); - @Override - public void onUpdate() - { - super.onUpdate(); + public static final EnumSet nothing + = EnumSet.noneOf(ForgeDirection.class); - if(!worldObj.isRemote) - { - if(configComponent.isEjecting(TransmissionType.ENERGY)) - { - CableUtils.emit(this); - } - - double[] loss = simulateHeat(); - applyTemperatureChange(); - - lastTransferLoss = loss[0]; - lastEnvironmentLoss = loss[1]; - - FrequencyManager manager = getManager(frequency); - Frequency lastFreq = frequency; - - if(manager != null) - { - if(frequency != null && !frequency.valid) - { - frequency = (InventoryFrequency)manager.validateFrequency(getSecurity().getOwner(), Coord4D.get(this), frequency); - markDirty(); - } - - if(frequency != null) - { - frequency = (InventoryFrequency)manager.update(getSecurity().getOwner(), Coord4D.get(this), frequency); - - if(frequency == null) - { - markDirty(); - } - } - } - else { - frequency = null; - - if(lastFreq != null) - { - markDirty(); - } - } - } - } - - private boolean hasFrequency() - { - return frequency != null && frequency.valid; - } - - @Override - public void invalidate() - { - super.invalidate(); - - if(!worldObj.isRemote) - { - if(frequency != null) - { - FrequencyManager manager = getManager(frequency); - - if(manager != null) - { - manager.deactivate(Coord4D.get(this)); - } - } - } - } - - @Override - public Frequency getFrequency(FrequencyManager manager) - { - if(manager == Mekanism.securityFrequencies) - { - return getSecurity().getFrequency(); - } - - return frequency; - } - - public FrequencyManager getManager(Frequency freq) - { - if(getSecurity().getOwner() == null || freq == null) - { - return null; - } - - if(freq.isPublic()) - { - return Mekanism.publicEntangloporters; - } - else if(freq.isPrivate()) { - if(!Mekanism.privateEntangloporters.containsKey(getSecurity().getOwner())) - { - FrequencyManager manager = new FrequencyManager(InventoryFrequency.class, InventoryFrequency.ENTANGLOPORTER, getSecurity().getOwner()); - Mekanism.privateEntangloporters.put(getSecurity().getOwner(), manager); - manager.createOrLoad(worldObj); - } - - return Mekanism.privateEntangloporters.get(getSecurity().getOwner()); - } else { - if(!Mekanism.protectedEntangloporters.containsKey(getSecurity().getOwner())) - { - FrequencyManager manager = new FrequencyManager(InventoryFrequency.class, InventoryFrequency.ENTANGLOPORTER + "#protected", getSecurity().getOwner()); - Mekanism.protectedEntangloporters.put(getSecurity().getOwner(), manager); - manager.createOrLoad(worldObj); - } + public TileComponentEjector ejectorComponent; + public TileComponentConfig configComponent; + public TileComponentSecurity securityComponent; - return Mekanism.protectedEntangloporters.get(getSecurity().getOwner()); - } - } - - public void setFrequency(String name, ISecurityTile.SecurityMode access) - { - FrequencyManager manager = getManager(new InventoryFrequency(name, null).setAccess(access)); - manager.deactivate(Coord4D.get(this)); - - for(Frequency freq : manager.getFrequencies()) - { - if(freq.name.equals(name)) - { - frequency = (InventoryFrequency)freq; - frequency.activeCoords.add(Coord4D.get(this)); - - markDirty(); - - return; - } - } - - Frequency freq = new InventoryFrequency(name, getSecurity().getOwner()).setAccess(access); - freq.activeCoords.add(Coord4D.get(this)); - manager.addFrequency(freq); - frequency = (InventoryFrequency)freq; - - MekanismUtils.saveChunk(this); - markDirty(); - } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - if(nbtTags.hasKey("frequency")) - { - frequency = new InventoryFrequency(nbtTags.getCompoundTag("frequency")); - frequency.valid = false; - } - } + public TileEntityQuantumEntangloporter() { + super("QuantumEntangloporter", 0); - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - if(frequency != null) - { - NBTTagCompound frequencyTag = new NBTTagCompound(); - frequency.write(frequencyTag); - nbtTags.setTag("frequency", frequencyTag); - } - } + configComponent = new TileComponentConfig( + this, + TransmissionType.ITEM, + TransmissionType.FLUID, + TransmissionType.GAS, + TransmissionType.ENERGY, + TransmissionType.HEAT + ); - @Override - public void handlePacketData(ByteBuf dataStream) - { - if(!worldObj.isRemote) - { - int type = dataStream.readInt(); - - if(type == 0) - { - String name = PacketHandler.readString(dataStream); + for (TransmissionType type : TransmissionType.values()) { + if (type != TransmissionType.HEAT) { + configComponent.setIOConfig(type); + } else { + configComponent.setInputConfig(type); + } + } - setFrequency(name, ISecurityTile.SecurityMode.values()[dataStream.readInt()]); - } - else if(type == 1) - { - String freq = PacketHandler.readString(dataStream); + inventory = new ItemStack[0]; - FrequencyManager manager = getManager(new InventoryFrequency(freq, null).setAccess(ISecurityTile.SecurityMode.values()[dataStream.readInt()])); - - if(manager != null) - { - manager.remove(freq, getSecurity().getOwner()); - } - } - - return; - } + configComponent.getOutputs(TransmissionType.ITEM).get(2).availableSlots + = new int[] { 0 }; + configComponent.getOutputs(TransmissionType.FLUID).get(2).availableSlots + = new int[] { 0 }; + configComponent.getOutputs(TransmissionType.GAS).get(2).availableSlots + = new int[] { 1 }; - super.handlePacketData(dataStream); - - if(worldObj.isRemote) - { - lastTransferLoss = dataStream.readDouble(); - lastEnvironmentLoss = dataStream.readDouble(); - - if(dataStream.readBoolean()) - { - frequency = new InventoryFrequency(dataStream); - } - else { - frequency = null; - } - - publicCache.clear(); - privateCache.clear(); - protectedCache.clear(); + ejectorComponent = new TileComponentEjector(this); + ejectorComponent.setOutputData( + TransmissionType.ITEM, + configComponent.getOutputs(TransmissionType.ITEM).get(2) + ); + ejectorComponent.setOutputData( + TransmissionType.FLUID, + configComponent.getOutputs(TransmissionType.FLUID).get(2) + ); + ejectorComponent.setOutputData( + TransmissionType.GAS, configComponent.getOutputs(TransmissionType.GAS).get(2) + ); - int amount = dataStream.readInt(); - - for(int i = 0; i < amount; i++) - { - publicCache.add(new InventoryFrequency(dataStream)); - } - - amount = dataStream.readInt(); - - for(int i = 0; i < amount; i++) - { - privateCache.add(new InventoryFrequency(dataStream)); - } + securityComponent = new TileComponentSecurity(this); + } - amount = dataStream.readInt(); + @Override + public void onUpdate() { + super.onUpdate(); - for(int i = 0; i < amount; i++) - { - protectedCache.add(new InventoryFrequency(dataStream)); - } - } - } + if (!worldObj.isRemote) { + if (configComponent.isEjecting(TransmissionType.ENERGY)) { + CableUtils.emit(this); + } - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); - - data.add(lastTransferLoss); - data.add(lastEnvironmentLoss); - - if(frequency != null) - { - data.add(true); - frequency.write(data); - } - else { - data.add(false); - } - - data.add(Mekanism.publicEntangloporters.getFrequencies().size()); - - for(Frequency freq : Mekanism.publicEntangloporters.getFrequencies()) - { - freq.write(data); - } - - FrequencyManager manager = getManager(new InventoryFrequency(null, null).setAccess(SecurityMode.PRIVATE)); - - if(manager != null) - { - data.add(manager.getFrequencies().size()); - - for(Frequency freq : manager.getFrequencies()) - { - freq.write(data); - } - } - else { - data.add(0); - } + double[] loss = simulateHeat(); + applyTemperatureChange(); - List protectedFrqs = new ArrayList(); + lastTransferLoss = loss[0]; + lastEnvironmentLoss = loss[1]; - for (Frequency frequency : Mekanism.securityFrequencies.getFrequencies()) { - SecurityFrequency secure = (SecurityFrequency) frequency; - if(secure.trusted.contains(getSecurity().getOwner())) { - FrequencyManager protected_ = Mekanism.protectedEntangloporters.get(secure.owner); - if(protected_ != null) { - protectedFrqs.addAll(protected_.getFrequencies()); - } - } - } + FrequencyManager manager = getManager(frequency); + Frequency lastFreq = frequency; - if(getSecurity().getOwner() != null) - protectedFrqs.addAll(getManager(new Frequency(null, null).setAccess(SecurityMode.TRUSTED)).getFrequencies()); + if (manager != null) { + if (frequency != null && !frequency.valid) { + frequency = (InventoryFrequency) manager.validateFrequency( + getSecurity().getOwner(), Coord4D.get(this), frequency + ); + markDirty(); + } - data.add(protectedFrqs.size()); + if (frequency != null) { + frequency = (InventoryFrequency) manager.update( + getSecurity().getOwner(), Coord4D.get(this), frequency + ); - for (Frequency freq : protectedFrqs) { - freq.write(data); - } - - return data; - } + if (frequency == null) { + markDirty(); + } + } + } else { + frequency = null; - @Override - public EnumSet getOutputtingSides() - { - return !hasFrequency() ? nothing : configComponent.getSidesForData(TransmissionType.ENERGY, facing, 2); - } + if (lastFreq != null) { + markDirty(); + } + } + } + } - @Override - public EnumSet getConsumingSides() - { - return !hasFrequency() ? nothing : configComponent.getSidesForData(TransmissionType.ENERGY, facing, 1); - } + private boolean hasFrequency() { + return frequency != null && frequency.valid; + } - @Override - public double getMaxOutput() - { - return !hasFrequency() ? 0 : InventoryFrequency.MAX_ENERGY; - } + @Override + public void invalidate() { + super.invalidate(); - @Override - public double getEnergy() - { - return !hasFrequency() ? 0 : frequency.storedEnergy; - } + if (!worldObj.isRemote) { + if (frequency != null) { + FrequencyManager manager = getManager(frequency); - @Override - public void setEnergy(double energy) - { - if(hasFrequency()) - { - frequency.storedEnergy = Math.min(InventoryFrequency.MAX_ENERGY, energy); - } - } + if (manager != null) { + manager.deactivate(Coord4D.get(this)); + } + } + } + } - @Override - public double getMaxEnergy() - { - return !hasFrequency() ? 0 : frequency.MAX_ENERGY; - } + @Override + public Frequency getFrequency(FrequencyManager manager) { + if (manager == Mekanism.securityFrequencies) { + return getSecurity().getFrequency(); + } - @Override - public int fill(ForgeDirection from, FluidStack resource, boolean doFill) - { - return !hasFrequency() ? 0 : frequency.storedFluid.fill(resource, doFill); - } + return frequency; + } - @Override - public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) - { - if(hasFrequency() && resource.isFluidEqual(frequency.storedFluid.getFluid())) - { - return frequency.storedFluid.drain(resource.amount, doDrain); - } - - return null; - } + public FrequencyManager getManager(Frequency freq) { + if (getSecurity().getOwner() == null || freq == null) { + return null; + } - @Override - public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) - { - if(hasFrequency()) - { - return frequency.storedFluid.drain(maxDrain, doDrain); - } - - return null; - } + if (freq.isPublic()) { + return Mekanism.publicEntangloporters; + } else if (freq.isPrivate()) { + if (!Mekanism.privateEntangloporters.containsKey(getSecurity().getOwner())) { + FrequencyManager manager = new FrequencyManager( + InventoryFrequency.class, + InventoryFrequency.ENTANGLOPORTER, + getSecurity().getOwner() + ); + Mekanism.privateEntangloporters.put(getSecurity().getOwner(), manager); + manager.createOrLoad(worldObj); + } - @Override - public boolean canFill(ForgeDirection from, Fluid fluid) - { - if(hasFrequency() && configComponent.getOutput(TransmissionType.FLUID, from.ordinal(), facing).ioState == IOState.INPUT) - { - return frequency.storedFluid.getFluid() == null || fluid == frequency.storedFluid.getFluid().getFluid(); - } - - return false; - } + return Mekanism.privateEntangloporters.get(getSecurity().getOwner()); + } else { + if (!Mekanism.protectedEntangloporters.containsKey(getSecurity().getOwner() + )) { + FrequencyManager manager = new FrequencyManager( + InventoryFrequency.class, + InventoryFrequency.ENTANGLOPORTER + "#protected", + getSecurity().getOwner() + ); + Mekanism.protectedEntangloporters.put(getSecurity().getOwner(), manager); + manager.createOrLoad(worldObj); + } - @Override - public boolean canDrain(ForgeDirection from, Fluid fluid) - { - if(hasFrequency() && configComponent.getOutput(TransmissionType.FLUID, from.ordinal(), facing).ioState == IOState.OUTPUT) - { - return frequency.storedFluid.getFluid() == null || fluid == frequency.storedFluid.getFluid().getFluid(); - } - - return false; - } + return Mekanism.protectedEntangloporters.get(getSecurity().getOwner()); + } + } - @Override - public FluidTankInfo[] getTankInfo(ForgeDirection from) - { - if(hasFrequency()) - { - if(configComponent.getOutput(TransmissionType.FLUID, from.ordinal(), facing).ioState != IOState.OFF) - { - return new FluidTankInfo[] {frequency.storedFluid.getInfo()}; - } - } - - return PipeUtils.EMPTY; - } + public void setFrequency(String name, ISecurityTile.SecurityMode access) { + FrequencyManager manager + = getManager(new InventoryFrequency(name, null).setAccess(access)); + manager.deactivate(Coord4D.get(this)); - @Override - public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) - { - return !hasFrequency() ? 0 : frequency.storedGas.receive(stack, doTransfer); - } + for (Frequency freq : manager.getFrequencies()) { + if (freq.name.equals(name)) { + frequency = (InventoryFrequency) freq; + frequency.activeCoords.add(Coord4D.get(this)); - @Override - public int receiveGas(ForgeDirection side, GasStack stack) - { - return receiveGas(side, stack, true); - } + markDirty(); - @Override - public GasStack drawGas(ForgeDirection side, int amount, boolean doTransfer) - { - return !hasFrequency() ? null : frequency.storedGas.draw(amount, doTransfer); - } + return; + } + } - @Override - public GasStack drawGas(ForgeDirection side, int amount) - { - return drawGas(side, amount, true); - } + Frequency freq + = new InventoryFrequency(name, getSecurity().getOwner()).setAccess(access); + freq.activeCoords.add(Coord4D.get(this)); + manager.addFrequency(freq); + frequency = (InventoryFrequency) freq; - @Override - public boolean canReceiveGas(ForgeDirection side, Gas type) - { - if(hasFrequency() && configComponent.getOutput(TransmissionType.GAS, side.ordinal(), facing).ioState == IOState.INPUT) - { - return frequency.storedGas.getGasType() == null || type == frequency.storedGas.getGasType(); - } - - return false; - } + MekanismUtils.saveChunk(this); + markDirty(); + } - @Override - public boolean canDrawGas(ForgeDirection side, Gas type) - { - if(hasFrequency() && configComponent.getOutput(TransmissionType.GAS, side.ordinal(), facing).ioState == IOState.OUTPUT) - { - return frequency.storedGas.getGasType() == null || type == frequency.storedGas.getGasType(); - } - - return false; - } - - @Override - public boolean handleInventory() - { - return false; - } - - @Override - public int getSizeInventory() - { - return 1; - } + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); - @Override - public ItemStack getStackInSlot(int slotID) - { - return hasFrequency() && slotID == 0 ? frequency.storedItem : null; - } - - @Override - public void setInventorySlotContents(int slotID, ItemStack itemstack) - { - if(hasFrequency() && slotID == 0) - { - frequency.storedItem = itemstack; - - if(itemstack != null && itemstack.stackSize > getInventoryStackLimit()) - { - itemstack.stackSize = getInventoryStackLimit(); - } - } - } + if (nbtTags.hasKey("frequency")) { + frequency = new InventoryFrequency(nbtTags.getCompoundTag("frequency")); + frequency.valid = false; + } + } - @Override - public double getTemp() - { - return hasFrequency() ? frequency.temperature : 0; - } + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); - @Override - public double getInverseConductionCoefficient() - { - return 1; - } + if (frequency != null) { + NBTTagCompound frequencyTag = new NBTTagCompound(); + frequency.write(frequencyTag); + nbtTags.setTag("frequency", frequencyTag); + } + } - @Override - public double getInsulationCoefficient(ForgeDirection side) - { - return 1000; - } + @Override + public void handlePacketData(ByteBuf dataStream) { + if (!worldObj.isRemote) { + int type = dataStream.readInt(); - @Override - public void transferHeatTo(double heat) - { - heatToAbsorb += heat; - } + if (type == 0) { + String name = PacketHandler.readString(dataStream); - @Override - public double[] simulateHeat() - { - return HeatUtils.simulate(this); - } + setFrequency( + name, ISecurityTile.SecurityMode.values()[dataStream.readInt()] + ); + } else if (type == 1) { + String freq = PacketHandler.readString(dataStream); - @Override - public double applyTemperatureChange() - { - if(hasFrequency()) - { - frequency.temperature += heatToAbsorb; - } - - heatToAbsorb = 0; - - return hasFrequency() ? frequency.temperature : 0; - } + FrequencyManager manager + = getManager(new InventoryFrequency(freq, null) + .setAccess(ISecurityTile.SecurityMode.values( + )[dataStream.readInt()])); - @Override - public boolean canConnectHeat(ForgeDirection side) - { - return hasFrequency() && configComponent.getOutput(TransmissionType.HEAT, side.ordinal(), facing).ioState != IOState.OFF; - } + if (manager != null) { + manager.remove(freq, getSecurity().getOwner()); + } + } - @Override - public IHeatTransfer getAdjacent(ForgeDirection side) - { - TileEntity adj = Coord4D.get(this).getFromSide(side).getTileEntity(worldObj); - - if(hasFrequency() && configComponent.getOutput(TransmissionType.HEAT, side.ordinal(), facing).ioState == IOState.INPUT) - { - if(adj instanceof IHeatTransfer) - { - return (IHeatTransfer)adj; - } - } - - return null; - } - - @Override - public boolean canInsertItem(int slotID, ItemStack itemstack, int side) - { - return hasFrequency() && configComponent.getOutput(TransmissionType.ITEM, side, facing).ioState == IOState.INPUT; - } + return; + } - @Override - public int[] getAccessibleSlotsFromSide(int side) - { - if(hasFrequency() && configComponent.getOutput(TransmissionType.ITEM, side, facing).ioState != IOState.OFF) - { - return new int[] {0}; - } - - return InventoryUtils.EMPTY; - } + super.handlePacketData(dataStream); - @Override - public boolean canExtractItem(int slotID, ItemStack itemstack, int side) - { - return hasFrequency() && configComponent.getOutput(TransmissionType.ITEM, side, facing).ioState == IOState.OUTPUT; - } + if (worldObj.isRemote) { + lastTransferLoss = dataStream.readDouble(); + lastEnvironmentLoss = dataStream.readDouble(); - @Override - public Object[] getTanks() - { - if(!hasFrequency()) - { - return null; - } - - return new Object[] {frequency.storedFluid, frequency.storedGas}; - } + if (dataStream.readBoolean()) { + frequency = new InventoryFrequency(dataStream); + } else { + frequency = null; + } - @Override - public TileComponentConfig getConfig() - { - return configComponent; - } + publicCache.clear(); + privateCache.clear(); + protectedCache.clear(); - @Override - public int getOrientation() - { - return facing; - } + int amount = dataStream.readInt(); - @Override - public TileComponentEjector getEjector() - { - return ejectorComponent; - } - - @Override - public TileComponentSecurity getSecurity() - { - return securityComponent; - } + for (int i = 0; i < amount; i++) { + publicCache.add(new InventoryFrequency(dataStream)); + } - @Override - public boolean canTubeConnect(ForgeDirection side) - { - return hasFrequency() && configComponent.getOutput(TransmissionType.GAS, side.ordinal(), facing).ioState != IOState.OFF; - } - - private static final String[] methods = new String[] {"setFrequency"}; + amount = dataStream.readInt(); - @Override - public String[] getMethods() - { - return methods; - } + for (int i = 0; i < amount; i++) { + privateCache.add(new InventoryFrequency(dataStream)); + } - @Override - public Object[] invoke(int method, Object[] arguments) throws Exception - { - switch(method) - { - case 0: - if(!(arguments[0] instanceof String) || !(arguments[1] instanceof Integer)) - { - return new Object[] {"Invalid parameters."}; - } - - String freq = ((String)arguments[0]).trim(); - int access = (int)arguments[1]; - - setFrequency(freq, ISecurityTile.SecurityMode.values()[access]); - - return new Object[] {"Frequency set."}; - default: - throw new NoSuchMethodException(); - } - } + amount = dataStream.readInt(); + + for (int i = 0; i < amount; i++) { + protectedCache.add(new InventoryFrequency(dataStream)); + } + } + } + + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); + + data.add(lastTransferLoss); + data.add(lastEnvironmentLoss); + + if (frequency != null) { + data.add(true); + frequency.write(data); + } else { + data.add(false); + } + + data.add(Mekanism.publicEntangloporters.getFrequencies().size()); + + for (Frequency freq : Mekanism.publicEntangloporters.getFrequencies()) { + freq.write(data); + } + + FrequencyManager manager = getManager( + new InventoryFrequency(null, null).setAccess(SecurityMode.PRIVATE) + ); + + if (manager != null) { + data.add(manager.getFrequencies().size()); + + for (Frequency freq : manager.getFrequencies()) { + freq.write(data); + } + } else { + data.add(0); + } + + List protectedFrqs = new ArrayList(); + + for (Frequency frequency : Mekanism.securityFrequencies.getFrequencies()) { + SecurityFrequency secure = (SecurityFrequency) frequency; + if (secure.trusted.contains(getSecurity().getOwner())) { + FrequencyManager protected_ + = Mekanism.protectedEntangloporters.get(secure.owner); + if (protected_ != null) { + protectedFrqs.addAll(protected_.getFrequencies()); + } + } + } + + if (getSecurity().getOwner() != null) + protectedFrqs.addAll( + getManager(new Frequency(null, null).setAccess(SecurityMode.TRUSTED)) + .getFrequencies() + ); + + data.add(protectedFrqs.size()); + + for (Frequency freq : protectedFrqs) { + freq.write(data); + } + + return data; + } + + @Override + public EnumSet getOutputtingSides() { + return !hasFrequency() + ? nothing + : configComponent.getSidesForData(TransmissionType.ENERGY, facing, 2); + } + + @Override + public EnumSet getConsumingSides() { + return !hasFrequency() + ? nothing + : configComponent.getSidesForData(TransmissionType.ENERGY, facing, 1); + } + + @Override + public double getMaxOutput() { + return !hasFrequency() ? 0 : InventoryFrequency.MAX_ENERGY; + } + + @Override + public double getEnergy() { + return !hasFrequency() ? 0 : frequency.storedEnergy; + } + + @Override + public void setEnergy(double energy) { + if (hasFrequency()) { + frequency.storedEnergy = Math.min(InventoryFrequency.MAX_ENERGY, energy); + } + } + + @Override + public double getMaxEnergy() { + return !hasFrequency() ? 0 : frequency.MAX_ENERGY; + } + + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { + return !hasFrequency() ? 0 : frequency.storedFluid.fill(resource, doFill); + } + + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + if (hasFrequency() && resource.isFluidEqual(frequency.storedFluid.getFluid())) { + return frequency.storedFluid.drain(resource.amount, doDrain); + } + + return null; + } + + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { + if (hasFrequency()) { + return frequency.storedFluid.drain(maxDrain, doDrain); + } + + return null; + } + + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + if (hasFrequency() + && configComponent.getOutput(TransmissionType.FLUID, from.ordinal(), facing) + .ioState + == IOState.INPUT) { + return frequency.storedFluid.getFluid() == null + || fluid == frequency.storedFluid.getFluid().getFluid(); + } + + return false; + } + + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + if (hasFrequency() + && configComponent.getOutput(TransmissionType.FLUID, from.ordinal(), facing) + .ioState + == IOState.OUTPUT) { + return frequency.storedFluid.getFluid() == null + || fluid == frequency.storedFluid.getFluid().getFluid(); + } + + return false; + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection from) { + if (hasFrequency()) { + if (configComponent.getOutput(TransmissionType.FLUID, from.ordinal(), facing) + .ioState + != IOState.OFF) { + return new FluidTankInfo[] { frequency.storedFluid.getInfo() }; + } + } + + return PipeUtils.EMPTY; + } + + @Override + public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) { + return !hasFrequency() ? 0 : frequency.storedGas.receive(stack, doTransfer); + } + + @Override + public int receiveGas(ForgeDirection side, GasStack stack) { + return receiveGas(side, stack, true); + } + + @Override + public GasStack drawGas(ForgeDirection side, int amount, boolean doTransfer) { + return !hasFrequency() ? null : frequency.storedGas.draw(amount, doTransfer); + } + + @Override + public GasStack drawGas(ForgeDirection side, int amount) { + return drawGas(side, amount, true); + } + + @Override + public boolean canReceiveGas(ForgeDirection side, Gas type) { + if (hasFrequency() + && configComponent.getOutput(TransmissionType.GAS, side.ordinal(), facing) + .ioState + == IOState.INPUT) { + return frequency.storedGas.getGasType() == null + || type == frequency.storedGas.getGasType(); + } + + return false; + } + + @Override + public boolean canDrawGas(ForgeDirection side, Gas type) { + if (hasFrequency() + && configComponent.getOutput(TransmissionType.GAS, side.ordinal(), facing) + .ioState + == IOState.OUTPUT) { + return frequency.storedGas.getGasType() == null + || type == frequency.storedGas.getGasType(); + } + + return false; + } + + @Override + public boolean handleInventory() { + return false; + } + + @Override + public int getSizeInventory() { + return 1; + } + + @Override + public ItemStack getStackInSlot(int slotID) { + return hasFrequency() && slotID == 0 ? frequency.storedItem : null; + } + + @Override + public void setInventorySlotContents(int slotID, ItemStack itemstack) { + if (hasFrequency() && slotID == 0) { + frequency.storedItem = itemstack; + + if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { + itemstack.stackSize = getInventoryStackLimit(); + } + } + } + + @Override + public double getTemp() { + return hasFrequency() ? frequency.temperature : 0; + } + + @Override + public double getInverseConductionCoefficient() { + return 1; + } + + @Override + public double getInsulationCoefficient(ForgeDirection side) { + return 1000; + } + + @Override + public void transferHeatTo(double heat) { + heatToAbsorb += heat; + } + + @Override + public double[] simulateHeat() { + return HeatUtils.simulate(this); + } + + @Override + public double applyTemperatureChange() { + if (hasFrequency()) { + frequency.temperature += heatToAbsorb; + } + + heatToAbsorb = 0; + + return hasFrequency() ? frequency.temperature : 0; + } + + @Override + public boolean canConnectHeat(ForgeDirection side) { + return hasFrequency() + && configComponent.getOutput(TransmissionType.HEAT, side.ordinal(), facing) + .ioState + != IOState.OFF; + } + + @Override + public IHeatTransfer getAdjacent(ForgeDirection side) { + TileEntity adj = Coord4D.get(this).getFromSide(side).getTileEntity(worldObj); + + if (hasFrequency() + && configComponent.getOutput(TransmissionType.HEAT, side.ordinal(), facing) + .ioState + == IOState.INPUT) { + if (adj instanceof IHeatTransfer) { + return (IHeatTransfer) adj; + } + } + + return null; + } + + @Override + public boolean canInsertItem(int slotID, ItemStack itemstack, int side) { + return hasFrequency() + && configComponent.getOutput(TransmissionType.ITEM, side, facing).ioState + == IOState.INPUT; + } + + @Override + public int[] getAccessibleSlotsFromSide(int side) { + if (hasFrequency() + && configComponent.getOutput(TransmissionType.ITEM, side, facing).ioState + != IOState.OFF) { + return new int[] { 0 }; + } + + return InventoryUtils.EMPTY; + } + + @Override + public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { + return hasFrequency() + && configComponent.getOutput(TransmissionType.ITEM, side, facing).ioState + == IOState.OUTPUT; + } + + @Override + public Object[] getTanks() { + if (!hasFrequency()) { + return null; + } + + return new Object[] { frequency.storedFluid, frequency.storedGas }; + } + + @Override + public TileComponentConfig getConfig() { + return configComponent; + } + + @Override + public int getOrientation() { + return facing; + } + + @Override + public TileComponentEjector getEjector() { + return ejectorComponent; + } + + @Override + public TileComponentSecurity getSecurity() { + return securityComponent; + } + + @Override + public boolean canTubeConnect(ForgeDirection side) { + return hasFrequency() + && configComponent.getOutput(TransmissionType.GAS, side.ordinal(), facing) + .ioState + != IOState.OFF; + } + + private static final String[] methods = new String[] { "setFrequency" }; + + @Override + public String[] getMethods() { + return methods; + } + + @Override + public Object[] invoke(int method, Object[] arguments) throws Exception { + switch (method) { + case 0: + if (!(arguments[0] instanceof String) + || !(arguments[1] instanceof Integer)) { + return new Object[] { "Invalid parameters." }; + } + + String freq = ((String) arguments[0]).trim(); + int access = (int) arguments[1]; + + setFrequency(freq, ISecurityTile.SecurityMode.values()[access]); + + return new Object[] { "Frequency set." }; + default: + throw new NoSuchMethodException(); + } + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityResistiveHeater.java b/src/main/java/mekanism/common/tile/TileEntityResistiveHeater.java index 5fab2d54e..47b304c21 100644 --- a/src/main/java/mekanism/common/tile/TileEntityResistiveHeater.java +++ b/src/main/java/mekanism/common/tile/TileEntityResistiveHeater.java @@ -1,10 +1,9 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.EnumSet; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.IHeatTransfer; import mekanism.api.MekanismConfig.general; @@ -24,337 +23,312 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityResistiveHeater extends TileEntityNoisyElectricBlock implements IHeatTransfer, IComputerIntegration, IRedstoneControl, ISecurityTile -{ - public double energyUsage = 100; - - public double temperature; - public double heatToAbsorb = 0; - - /** Whether or not this machine is in it's active state. */ - public boolean isActive; +public class TileEntityResistiveHeater extends TileEntityNoisyElectricBlock + implements IHeatTransfer, IComputerIntegration, IRedstoneControl, ISecurityTile { + public double energyUsage = 100; - /** The client's current active state. */ - public boolean clientActive; + public double temperature; + public double heatToAbsorb = 0; - /** How many ticks must pass until this block's active state can sync with the client. */ - public int updateDelay; - - public float soundScale = 1; - - public double lastEnvironmentLoss; - - public RedstoneControl controlType = RedstoneControl.DISABLED; - - public TileComponentSecurity securityComponent = new TileComponentSecurity(this); - - public TileEntityResistiveHeater() - { - super("machine.resistiveheater", "ResistiveHeater", MachineType.RESISTIVE_HEATER.baseEnergy); - inventory = new ItemStack[1]; - } - - @Override - public void onUpdate() - { - super.onUpdate(); - - if(worldObj.isRemote && updateDelay > 0) - { - updateDelay--; + /** Whether or not this machine is in it's active state. */ + public boolean isActive; - if(updateDelay == 0 && clientActive != isActive) - { - isActive = clientActive; - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } - - if(!worldObj.isRemote) - { - boolean packet = false; - - if(updateDelay > 0) - { - updateDelay--; + /** The client's current active state. */ + public boolean clientActive; - if(updateDelay == 0 && clientActive != isActive) - { - packet = true; - } - } - - ChargeUtils.discharge(0, this); - - double toUse = 0; - - if(MekanismUtils.canFunction(this)) - { - toUse = Math.min(getEnergy(), energyUsage); - heatToAbsorb += toUse/general.energyPerHeat; - setEnergy(getEnergy() - toUse); - } - - setActive(toUse > 0); - - double[] loss = simulateHeat(); - applyTemperatureChange(); - - lastEnvironmentLoss = loss[1]; - - float newSoundScale = (float)Math.max(0, (toUse/1E5)); - - if(Math.abs(newSoundScale-soundScale) > 0.01) - { - packet = true; - } - - soundScale = newSoundScale; - - if(packet) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - } - } - } - - @Override - public EnumSet getConsumingSides() - { - return EnumSet.of(MekanismUtils.getLeft(facing), MekanismUtils.getRight(facing)); - } - - @Override - public boolean canSetFacing(int side) - { - return side != 0 && side != 1; - } - - @Override - public float getVolume() - { - return super.getVolume()*Math.max(0.001F, soundScale); - } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); + /** + * How many ticks must pass until this block's active state can sync with the client. + */ + public int updateDelay; - energyUsage = nbtTags.getDouble("energyUsage"); - temperature = nbtTags.getDouble("temperature"); - clientActive = isActive = nbtTags.getBoolean("isActive"); - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - - maxEnergy = energyUsage * 400; - } + public float soundScale = 1; - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); + public double lastEnvironmentLoss; - nbtTags.setDouble("energyUsage", energyUsage); - nbtTags.setDouble("temperature", temperature); - nbtTags.setBoolean("isActive", isActive); - nbtTags.setInteger("controlType", controlType.ordinal()); - } - - @Override - public void handlePacketData(ByteBuf dataStream) - { - if(!worldObj.isRemote) - { - energyUsage = MekanismUtils.convertToJoules(dataStream.readInt()); - maxEnergy = energyUsage * 400; - - return; - } - - super.handlePacketData(dataStream); - - if(worldObj.isRemote) - { - energyUsage = dataStream.readDouble(); - temperature = dataStream.readDouble(); - clientActive = dataStream.readBoolean(); - maxEnergy = dataStream.readDouble(); - soundScale = dataStream.readFloat(); - controlType = RedstoneControl.values()[dataStream.readInt()]; - - lastEnvironmentLoss = dataStream.readDouble(); - - if(updateDelay == 0 && clientActive != isActive) - { - updateDelay = general.UPDATE_DELAY; - isActive = clientActive; - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } - } + public RedstoneControl controlType = RedstoneControl.DISABLED; - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); - - data.add(energyUsage); - data.add(temperature); - data.add(isActive); - data.add(maxEnergy); - data.add(soundScale); - data.add(controlType.ordinal()); - - data.add(lastEnvironmentLoss); - - return data; - } + public TileComponentSecurity securityComponent = new TileComponentSecurity(this); - @Override - public double getTemp() - { - return temperature; - } + public TileEntityResistiveHeater() { + super( + "machine.resistiveheater", + "ResistiveHeater", + MachineType.RESISTIVE_HEATER.baseEnergy + ); + inventory = new ItemStack[1]; + } - @Override - public double getInverseConductionCoefficient() - { - return 5; - } + @Override + public void onUpdate() { + super.onUpdate(); - @Override - public double getInsulationCoefficient(ForgeDirection side) - { - return 1000; - } + if (worldObj.isRemote && updateDelay > 0) { + updateDelay--; - @Override - public void transferHeatTo(double heat) - { - heatToAbsorb += heat; - } + if (updateDelay == 0 && clientActive != isActive) { + isActive = clientActive; + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } - @Override - public double[] simulateHeat() - { - return HeatUtils.simulate(this); - } + if (!worldObj.isRemote) { + boolean packet = false; - @Override - public double applyTemperatureChange() - { - temperature += heatToAbsorb; - heatToAbsorb = 0; - - return temperature; - } + if (updateDelay > 0) { + updateDelay--; - @Override - public boolean canConnectHeat(ForgeDirection side) - { - return true; - } + if (updateDelay == 0 && clientActive != isActive) { + packet = true; + } + } - @Override - public IHeatTransfer getAdjacent(ForgeDirection side) - { - TileEntity adj = Coord4D.get(this).getFromSide(side).getTileEntity(worldObj); - - if(adj instanceof IHeatTransfer) - { - return (IHeatTransfer)adj; - } - - return null; - } - - @Override - public void setActive(boolean active) - { - isActive = active; + ChargeUtils.discharge(0, this); - if(clientActive != active && updateDelay == 0) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); + double toUse = 0; - updateDelay = 10; - clientActive = active; - } - } + if (MekanismUtils.canFunction(this)) { + toUse = Math.min(getEnergy(), energyUsage); + heatToAbsorb += toUse / general.energyPerHeat; + setEnergy(getEnergy() - toUse); + } - @Override - public boolean getActive() - { - return isActive; - } - - @Override - public boolean renderUpdate() - { - return false; - } + setActive(toUse > 0); - @Override - public boolean lightUpdate() - { - return true; - } - - private static final String[] methods = new String[] {"getEnergy", "getMaxEnergy", "getTemperature", "setEnergyUsage"}; + double[] loss = simulateHeat(); + applyTemperatureChange(); - @Override - public String[] getMethods() - { - return methods; - } + lastEnvironmentLoss = loss[1]; - @Override - public Object[] invoke(int method, Object[] arguments) throws Exception - { - switch(method) - { - case 0: - return new Object[] {getEnergy()}; - case 1: - return new Object[] {getMaxEnergy()}; - case 2: - return new Object[] {temperature}; - case 3: - if(arguments.length == 1) - { - if(arguments[0] instanceof Double) - { - temperature = (Double)arguments[0]; - } - } - - return new Object[] {"Invalid parameters."}; - default: - throw new NoSuchMethodException(); - } - } - - @Override - public RedstoneControl getControlType() - { - return controlType; - } + float newSoundScale = (float) Math.max(0, (toUse / 1E5)); - @Override - public void setControlType(RedstoneControl type) - { - controlType = type; - } + if (Math.abs(newSoundScale - soundScale) > 0.01) { + packet = true; + } - @Override - public boolean canPulse() - { - return false; - } - - @Override - public TileComponentSecurity getSecurity() - { - return securityComponent; - } + soundScale = newSoundScale; + + if (packet) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + } + } + } + + @Override + public EnumSet getConsumingSides() { + return EnumSet.of(MekanismUtils.getLeft(facing), MekanismUtils.getRight(facing)); + } + + @Override + public boolean canSetFacing(int side) { + return side != 0 && side != 1; + } + + @Override + public float getVolume() { + return super.getVolume() * Math.max(0.001F, soundScale); + } + + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); + + energyUsage = nbtTags.getDouble("energyUsage"); + temperature = nbtTags.getDouble("temperature"); + clientActive = isActive = nbtTags.getBoolean("isActive"); + controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + + maxEnergy = energyUsage * 400; + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); + + nbtTags.setDouble("energyUsage", energyUsage); + nbtTags.setDouble("temperature", temperature); + nbtTags.setBoolean("isActive", isActive); + nbtTags.setInteger("controlType", controlType.ordinal()); + } + + @Override + public void handlePacketData(ByteBuf dataStream) { + if (!worldObj.isRemote) { + energyUsage = MekanismUtils.convertToJoules(dataStream.readInt()); + maxEnergy = energyUsage * 400; + + return; + } + + super.handlePacketData(dataStream); + + if (worldObj.isRemote) { + energyUsage = dataStream.readDouble(); + temperature = dataStream.readDouble(); + clientActive = dataStream.readBoolean(); + maxEnergy = dataStream.readDouble(); + soundScale = dataStream.readFloat(); + controlType = RedstoneControl.values()[dataStream.readInt()]; + + lastEnvironmentLoss = dataStream.readDouble(); + + if (updateDelay == 0 && clientActive != isActive) { + updateDelay = general.UPDATE_DELAY; + isActive = clientActive; + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } + } + + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); + + data.add(energyUsage); + data.add(temperature); + data.add(isActive); + data.add(maxEnergy); + data.add(soundScale); + data.add(controlType.ordinal()); + + data.add(lastEnvironmentLoss); + + return data; + } + + @Override + public double getTemp() { + return temperature; + } + + @Override + public double getInverseConductionCoefficient() { + return 5; + } + + @Override + public double getInsulationCoefficient(ForgeDirection side) { + return 1000; + } + + @Override + public void transferHeatTo(double heat) { + heatToAbsorb += heat; + } + + @Override + public double[] simulateHeat() { + return HeatUtils.simulate(this); + } + + @Override + public double applyTemperatureChange() { + temperature += heatToAbsorb; + heatToAbsorb = 0; + + return temperature; + } + + @Override + public boolean canConnectHeat(ForgeDirection side) { + return true; + } + + @Override + public IHeatTransfer getAdjacent(ForgeDirection side) { + TileEntity adj = Coord4D.get(this).getFromSide(side).getTileEntity(worldObj); + + if (adj instanceof IHeatTransfer) { + return (IHeatTransfer) adj; + } + + return null; + } + + @Override + public void setActive(boolean active) { + isActive = active; + + if (clientActive != active && updateDelay == 0) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + + updateDelay = 10; + clientActive = active; + } + } + + @Override + public boolean getActive() { + return isActive; + } + + @Override + public boolean renderUpdate() { + return false; + } + + @Override + public boolean lightUpdate() { + return true; + } + + private static final String[] methods = new String[] { + "getEnergy", "getMaxEnergy", "getTemperature", "setEnergyUsage" + }; + + @Override + public String[] getMethods() { + return methods; + } + + @Override + public Object[] invoke(int method, Object[] arguments) throws Exception { + switch (method) { + case 0: + return new Object[] { getEnergy() }; + case 1: + return new Object[] { getMaxEnergy() }; + case 2: + return new Object[] { temperature }; + case 3: + if (arguments.length == 1) { + if (arguments[0] instanceof Double) { + temperature = (Double) arguments[0]; + } + } + + return new Object[] { "Invalid parameters." }; + default: + throw new NoSuchMethodException(); + } + } + + @Override + public RedstoneControl getControlType() { + return controlType; + } + + @Override + public void setControlType(RedstoneControl type) { + controlType = type; + } + + @Override + public boolean canPulse() { + return false; + } + + @Override + public TileComponentSecurity getSecurity() { + return securityComponent; + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityRotaryCondensentrator.java b/src/main/java/mekanism/common/tile/TileEntityRotaryCondensentrator.java index 34364e373..1b4176798 100644 --- a/src/main/java/mekanism/common/tile/TileEntityRotaryCondensentrator.java +++ b/src/main/java/mekanism/common/tile/TileEntityRotaryCondensentrator.java @@ -1,10 +1,9 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.List; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.MekanismConfig.usage; import mekanism.api.Range4D; @@ -46,557 +45,559 @@ import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidContainerItem; import net.minecraftforge.fluids.IFluidHandler; -public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock implements IActiveState, ISustainedData, IFluidHandler, IGasHandler, ITubeConnection, IRedstoneControl, IUpgradeTile, IUpgradeInfoHandler, ITankManager, ISecurityTile -{ - public GasTank gasTank = new GasTank(MAX_FLUID); - - public FluidTank fluidTank = new FluidTank(MAX_FLUID); - - public static final int MAX_FLUID = 10000; - - /** 0: gas -> fluid; 1: fluid -> gas */ - public int mode; - - public int gasOutput = 256; - - public int updateDelay; - - public boolean isActive; - - public boolean clientActive; - - public double prevEnergy; - - public final double BASE_ENERGY_USAGE = usage.rotaryCondensentratorUsage; - - public double energyPerTick = BASE_ENERGY_USAGE; - - public double clientEnergyUsed; - - public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, 5); - public TileComponentSecurity securityComponent = new TileComponentSecurity(this); - - /** This machine's current RedstoneControl type. */ - public RedstoneControl controlType = RedstoneControl.DISABLED; - - public TileEntityRotaryCondensentrator() - { - super("RotaryCondensentrator", MachineType.ROTARY_CONDENSENTRATOR.baseEnergy); - inventory = new ItemStack[6]; - } - - @Override - public void onUpdate() - { - super.onUpdate(); - - if(worldObj.isRemote) - { - if(updateDelay > 0) - { - updateDelay--; - - if(updateDelay == 0 && clientActive != isActive) - { - isActive = clientActive; - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } - } - - if(!worldObj.isRemote) - { - if(updateDelay > 0) - { - updateDelay--; - - if(updateDelay == 0 && clientActive != isActive) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - } - } - - ChargeUtils.discharge(4, this); - - if(mode == 0) - { - if(inventory[1] != null && (gasTank.getGas() == null || gasTank.getStored() < gasTank.getMaxGas())) - { - gasTank.receive(GasTransmission.removeGas(inventory[1], gasTank.getGasType(), gasTank.getNeeded()), true); - } - - if(inventory[2] != null) - { - if(inventory[2].getItem() instanceof IFluidContainerItem) - { - FluidContainerUtils.handleContainerItemFill(this, fluidTank, 2, 3); - } - else if(FluidContainerRegistry.isEmptyContainer(inventory[2])) - { - FluidContainerUtils.handleRegistryItemFill(this, fluidTank, 2, 3); - } - } - - if(getEnergy() >= energyPerTick && MekanismUtils.canFunction(this) && isValidGas(gasTank.getGas()) && (fluidTank.getFluid() == null || (fluidTank.getFluid().amount < MAX_FLUID && gasEquals(gasTank.getGas(), fluidTank.getFluid())))) - { - int operations = getUpgradedUsage(); - double prev = getEnergy(); - - setActive(true); - fluidTank.fill(new FluidStack(gasTank.getGas().getGas().getFluid(), operations), true); - gasTank.draw(operations, true); - setEnergy(getEnergy() - energyPerTick*operations); - clientEnergyUsed = prev-getEnergy(); - } - else { - if(prevEnergy >= getEnergy()) - { - setActive(false); - } - } - } - else if(mode == 1) - { - if(inventory[0] != null && gasTank.getGas() != null) - { - gasTank.draw(GasTransmission.addGas(inventory[0], gasTank.getGas()), true); - } - - if(gasTank.getGas() != null) - { - GasStack toSend = new GasStack(gasTank.getGas().getGas(), Math.min(gasTank.getGas().amount, gasOutput)); - - TileEntity tileEntity = Coord4D.get(this).getFromSide(MekanismUtils.getLeft(facing)).getTileEntity(worldObj); - - if(tileEntity instanceof IGasHandler) - { - if(((IGasHandler)tileEntity).canReceiveGas(MekanismUtils.getLeft(facing).getOpposite(), gasTank.getGas().getGas())) - { - gasTank.draw(((IGasHandler)tileEntity).receiveGas(MekanismUtils.getLeft(facing).getOpposite(), toSend, true), true); - } - } - } - - if(inventory[2] != null) - { - if(inventory[2].getItem() instanceof IFluidContainerItem) - { - FluidContainerUtils.handleContainerItemEmpty(this, fluidTank, 2, 3); - } - else if(FluidContainerRegistry.isFilledContainer(inventory[2])) - { - FluidContainerUtils.handleRegistryItemEmpty(this, fluidTank, 2, 3); - } - } - - if(getEnergy() >= energyPerTick && MekanismUtils.canFunction(this) && isValidFluid(fluidTank.getFluid()) && (gasTank.getGas() == null || (gasTank.getStored() < MAX_FLUID && gasEquals(gasTank.getGas(), fluidTank.getFluid())))) - { - int operations = getUpgradedUsage(); - double prev = getEnergy(); - - setActive(true); - gasTank.receive(new GasStack(GasRegistry.getGas(fluidTank.getFluid().getFluid()), operations), true); - fluidTank.drain(operations, true); - setEnergy(getEnergy() - energyPerTick*operations); - clientEnergyUsed = prev-getEnergy(); - } - else { - if(prevEnergy >= getEnergy()) - { - setActive(false); - } - } - } - - prevEnergy = getEnergy(); - } - } - - public int getUpgradedUsage() - { - int possibleProcess = (int)Math.pow(2, upgradeComponent.getUpgrades(Upgrade.SPEED)); - - if(mode == 0) //Gas to fluid - { - possibleProcess = Math.min(Math.min(gasTank.getStored(), fluidTank.getCapacity()-fluidTank.getFluidAmount()), possibleProcess); - } - else { //Fluid to gas - possibleProcess = Math.min(Math.min(fluidTank.getFluidAmount(), gasTank.getNeeded()), possibleProcess); - } - - possibleProcess = Math.min((int)(getEnergy()/energyPerTick), possibleProcess); - - return possibleProcess; - } - - public boolean isValidGas(GasStack g) - { - if(g == null) - { - return false; - } - - return g.getGas().hasFluid(); - } - - public boolean gasEquals(GasStack gas, FluidStack fluid) - { - if(fluid == null || gas == null || !gas.getGas().hasFluid()) - { - return false; - } - - return gas.getGas().getFluid() == fluid.getFluid(); - } - - public boolean isValidFluid(FluidStack f) - { - if(f == null) - { - return false; - } - - return GasRegistry.getGas(f.getFluid()) != null; - } - - @Override - public void handlePacketData(ByteBuf dataStream) - { - if(!worldObj.isRemote) - { - int type = dataStream.readInt(); - - if(type == 0) - { - mode = mode == 0 ? 1 : 0; - } - - for(EntityPlayer player : playersUsing) - { - Mekanism.packetHandler.sendTo(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), (EntityPlayerMP)player); - } - - return; - } - - super.handlePacketData(dataStream); - - if(worldObj.isRemote) - { - mode = dataStream.readInt(); - isActive = dataStream.readBoolean(); - controlType = RedstoneControl.values()[dataStream.readInt()]; - clientEnergyUsed = dataStream.readDouble(); - - if(dataStream.readBoolean()) - { - fluidTank.setFluid(new FluidStack(dataStream.readInt(), dataStream.readInt())); - } - else { - fluidTank.setFluid(null); - } - - if(dataStream.readBoolean()) - { - gasTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt())); - } - else { - gasTank.setGas(null); - } - - - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } - - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); - - data.add(mode); - data.add(isActive); - data.add(controlType.ordinal()); - data.add(clientEnergyUsed); - - if(fluidTank.getFluid() != null) - { - data.add(true); - data.add(fluidTank.getFluid().getFluidID()); - data.add(fluidTank.getFluid().amount); - } - else { - data.add(false); - } - - if(gasTank.getGas() != null) - { - data.add(true); - data.add(gasTank.getGas().getGas().getID()); - data.add(gasTank.getStored()); - } - else { - data.add(false); - } - - return data; - } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - mode = nbtTags.getInteger("mode"); - isActive = nbtTags.getBoolean("isActive"); - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - - gasTank.read(nbtTags.getCompoundTag("gasTank")); - - if(nbtTags.hasKey("fluidTank")) - { - fluidTank.readFromNBT(nbtTags.getCompoundTag("fluidTank")); - } - } - - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - nbtTags.setInteger("mode", mode); - nbtTags.setBoolean("isActive", isActive); - nbtTags.setInteger("controlType", controlType.ordinal()); - nbtTags.setTag("gasTank", gasTank.write(new NBTTagCompound())); - - if(fluidTank.getFluid() != null) - { - nbtTags.setTag("fluidTank", fluidTank.writeToNBT(new NBTTagCompound())); - } - } - - @Override - public boolean canSetFacing(int i) - { - return i != 0 && i != 1; - } - - public int getScaledFluidLevel(int i) - { - return fluidTank.getFluid() != null ? fluidTank.getFluid().amount*i / MAX_FLUID : 0; - } - - public int getScaledGasLevel(int i) - { - return gasTank.getGas() != null ? gasTank.getStored()*i / MAX_FLUID : 0; - } - - @Override - public void setActive(boolean active) - { - isActive = active; - - if(clientActive != active && updateDelay == 0) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - - updateDelay = 10; - clientActive = active; - } - } - - @Override - public boolean getActive() - { - return isActive; - } - - @Override - public boolean renderUpdate() - { - return false; - } - - @Override - public boolean lightUpdate() - { - return true; - } - - @Override - public boolean canTubeConnect(ForgeDirection side) - { - return side == MekanismUtils.getLeft(facing); - } - - @Override - public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) - { - return gasTank.receive(stack, doTransfer); - } - - @Override - public int receiveGas(ForgeDirection side, GasStack stack) - { - return receiveGas(side, stack, true); - } - - @Override - public GasStack drawGas(ForgeDirection side, int amount, boolean doTransfer) - { - return gasTank.draw(amount, doTransfer); - } - - @Override - public GasStack drawGas(ForgeDirection side, int amount) - { - return drawGas(side, amount, true); - } - - @Override - public boolean canDrawGas(ForgeDirection side, Gas type) - { - return mode == 1 && side == MekanismUtils.getLeft(facing) ? gasTank.canDraw(type) : false; - } - - @Override - public boolean canReceiveGas(ForgeDirection side, Gas type) - { - return mode == 0 && side == MekanismUtils.getLeft(facing) ? gasTank.canReceive(type) : false; - } - - @Override - public void writeSustainedData(ItemStack itemStack) - { - if(fluidTank.getFluid() != null) - { - itemStack.stackTagCompound.setTag("fluidTank", fluidTank.getFluid().writeToNBT(new NBTTagCompound())); - } - - if(gasTank.getGas() != null) - { - itemStack.stackTagCompound.setTag("gasTank", gasTank.getGas().write(new NBTTagCompound())); - } - } - - @Override - public void readSustainedData(ItemStack itemStack) - { - fluidTank.setFluid(FluidStack.loadFluidStackFromNBT(itemStack.stackTagCompound.getCompoundTag("fluidTank"))); - gasTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("gasTank"))); - } - - @Override - public int fill(ForgeDirection from, FluidStack resource, boolean doFill) - { - if(canFill(from, resource.getFluid())) - { - return fluidTank.fill(resource, doFill); - } - - return 0; - } - - @Override - public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) - { - if(fluidTank.getFluid() != null && fluidTank.getFluid().getFluid() == resource.getFluid()) - { - return drain(from, resource.amount, doDrain); - } - - return null; - } - - @Override - public boolean canFill(ForgeDirection from, Fluid fluid) - { - return mode == 1 && from == MekanismUtils.getRight(facing) && (fluidTank.getFluid() == null ? isValidFluid(new FluidStack(fluid, 1)) : fluidTank.getFluid().getFluid() == fluid); - } - - @Override - public boolean canDrain(ForgeDirection from, Fluid fluid) - { - return mode == 0 && from == MekanismUtils.getRight(facing); - } - - @Override - public FluidTankInfo[] getTankInfo(ForgeDirection from) - { - if(from == MekanismUtils.getRight(facing)) - { - return new FluidTankInfo[] {fluidTank.getInfo()}; - } - - return PipeUtils.EMPTY; - } - - @Override - public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) - { - if(canDrain(from, null)) - { - return fluidTank.drain(maxDrain, doDrain); - } - - return null; - } - - @Override - public RedstoneControl getControlType() - { - return controlType; - } - - @Override - public void setControlType(RedstoneControl type) - { - controlType = type; - MekanismUtils.saveChunk(this); - } - - @Override - public boolean canPulse() - { - return false; - } - - @Override - public TileComponentUpgrade getComponent() - { - return upgradeComponent; - } - - @Override - public void recalculateUpgradables(Upgrade upgrade) - { - super.recalculateUpgradables(upgrade); - - switch(upgrade) - { - case ENERGY: - maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY); - energyPerTick = MekanismUtils.getBaseEnergyPerTick(this, BASE_ENERGY_USAGE); - default: - break; - } - } - - @Override - public List getInfo(Upgrade upgrade) - { - return upgrade == Upgrade.SPEED ? upgrade.getExpScaledInfo(this) : upgrade.getMultScaledInfo(this); - } - - @Override - public Object[] getTanks() - { - return new Object[] {gasTank, fluidTank}; - } - - @Override - public TileComponentSecurity getSecurity() - { - return securityComponent; - } +public class TileEntityRotaryCondensentrator extends TileEntityElectricBlock + implements IActiveState, ISustainedData, IFluidHandler, IGasHandler, ITubeConnection, + IRedstoneControl, IUpgradeTile, IUpgradeInfoHandler, ITankManager, + ISecurityTile { + public GasTank gasTank = new GasTank(MAX_FLUID); + + public FluidTank fluidTank = new FluidTank(MAX_FLUID); + + public static final int MAX_FLUID = 10000; + + /** 0: gas -> fluid; 1: fluid -> gas */ + public int mode; + + public int gasOutput = 256; + + public int updateDelay; + + public boolean isActive; + + public boolean clientActive; + + public double prevEnergy; + + public final double BASE_ENERGY_USAGE = usage.rotaryCondensentratorUsage; + + public double energyPerTick = BASE_ENERGY_USAGE; + + public double clientEnergyUsed; + + public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, 5); + public TileComponentSecurity securityComponent = new TileComponentSecurity(this); + + /** This machine's current RedstoneControl type. */ + public RedstoneControl controlType = RedstoneControl.DISABLED; + + public TileEntityRotaryCondensentrator() { + super("RotaryCondensentrator", MachineType.ROTARY_CONDENSENTRATOR.baseEnergy); + inventory = new ItemStack[6]; + } + + @Override + public void onUpdate() { + super.onUpdate(); + + if (worldObj.isRemote) { + if (updateDelay > 0) { + updateDelay--; + + if (updateDelay == 0 && clientActive != isActive) { + isActive = clientActive; + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } + } + + if (!worldObj.isRemote) { + if (updateDelay > 0) { + updateDelay--; + + if (updateDelay == 0 && clientActive != isActive) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + } + } + + ChargeUtils.discharge(4, this); + + if (mode == 0) { + if (inventory[1] != null + && (gasTank.getGas() == null + || gasTank.getStored() < gasTank.getMaxGas())) { + gasTank.receive( + GasTransmission.removeGas( + inventory[1], gasTank.getGasType(), gasTank.getNeeded() + ), + true + ); + } + + if (inventory[2] != null) { + if (inventory[2].getItem() instanceof IFluidContainerItem) { + FluidContainerUtils.handleContainerItemFill( + this, fluidTank, 2, 3 + ); + } else if (FluidContainerRegistry.isEmptyContainer(inventory[2])) { + FluidContainerUtils.handleRegistryItemFill(this, fluidTank, 2, 3); + } + } + + if (getEnergy() >= energyPerTick && MekanismUtils.canFunction(this) + && isValidGas(gasTank.getGas()) + && (fluidTank.getFluid() == null + || (fluidTank.getFluid().amount < MAX_FLUID + && gasEquals(gasTank.getGas(), fluidTank.getFluid())))) { + int operations = getUpgradedUsage(); + double prev = getEnergy(); + + setActive(true); + fluidTank.fill( + new FluidStack(gasTank.getGas().getGas().getFluid(), operations), + true + ); + gasTank.draw(operations, true); + setEnergy(getEnergy() - energyPerTick * operations); + clientEnergyUsed = prev - getEnergy(); + } else { + if (prevEnergy >= getEnergy()) { + setActive(false); + } + } + } else if (mode == 1) { + if (inventory[0] != null && gasTank.getGas() != null) { + gasTank.draw( + GasTransmission.addGas(inventory[0], gasTank.getGas()), true + ); + } + + if (gasTank.getGas() != null) { + GasStack toSend = new GasStack( + gasTank.getGas().getGas(), + Math.min(gasTank.getGas().amount, gasOutput) + ); + + TileEntity tileEntity + = Coord4D.get(this) + .getFromSide(MekanismUtils.getLeft(facing)) + .getTileEntity(worldObj); + + if (tileEntity instanceof IGasHandler) { + if (((IGasHandler) tileEntity) + .canReceiveGas( + MekanismUtils.getLeft(facing).getOpposite(), + gasTank.getGas().getGas() + )) { + gasTank.draw( + ((IGasHandler) tileEntity) + .receiveGas( + MekanismUtils.getLeft(facing).getOpposite(), + toSend, + true + ), + true + ); + } + } + } + + if (inventory[2] != null) { + if (inventory[2].getItem() instanceof IFluidContainerItem) { + FluidContainerUtils.handleContainerItemEmpty( + this, fluidTank, 2, 3 + ); + } else if (FluidContainerRegistry.isFilledContainer(inventory[2])) { + FluidContainerUtils.handleRegistryItemEmpty( + this, fluidTank, 2, 3 + ); + } + } + + if (getEnergy() >= energyPerTick && MekanismUtils.canFunction(this) + && isValidFluid(fluidTank.getFluid()) + && (gasTank.getGas() == null + || (gasTank.getStored() < MAX_FLUID + && gasEquals(gasTank.getGas(), fluidTank.getFluid())))) { + int operations = getUpgradedUsage(); + double prev = getEnergy(); + + setActive(true); + gasTank.receive( + new GasStack( + GasRegistry.getGas(fluidTank.getFluid().getFluid()), + operations + ), + true + ); + fluidTank.drain(operations, true); + setEnergy(getEnergy() - energyPerTick * operations); + clientEnergyUsed = prev - getEnergy(); + } else { + if (prevEnergy >= getEnergy()) { + setActive(false); + } + } + } + + prevEnergy = getEnergy(); + } + } + + public int getUpgradedUsage() { + int possibleProcess + = (int) Math.pow(2, upgradeComponent.getUpgrades(Upgrade.SPEED)); + + if (mode == 0) //Gas to fluid + { + possibleProcess = Math.min( + Math.min( + gasTank.getStored(), + fluidTank.getCapacity() - fluidTank.getFluidAmount() + ), + possibleProcess + ); + } else { //Fluid to gas + possibleProcess = Math.min( + Math.min(fluidTank.getFluidAmount(), gasTank.getNeeded()), possibleProcess + ); + } + + possibleProcess = Math.min((int) (getEnergy() / energyPerTick), possibleProcess); + + return possibleProcess; + } + + public boolean isValidGas(GasStack g) { + if (g == null) { + return false; + } + + return g.getGas().hasFluid(); + } + + public boolean gasEquals(GasStack gas, FluidStack fluid) { + if (fluid == null || gas == null || !gas.getGas().hasFluid()) { + return false; + } + + return gas.getGas().getFluid() == fluid.getFluid(); + } + + public boolean isValidFluid(FluidStack f) { + if (f == null) { + return false; + } + + return GasRegistry.getGas(f.getFluid()) != null; + } + + @Override + public void handlePacketData(ByteBuf dataStream) { + if (!worldObj.isRemote) { + int type = dataStream.readInt(); + + if (type == 0) { + mode = mode == 0 ? 1 : 0; + } + + for (EntityPlayer player : playersUsing) { + Mekanism.packetHandler.sendTo( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + (EntityPlayerMP) player + ); + } + + return; + } + + super.handlePacketData(dataStream); + + if (worldObj.isRemote) { + mode = dataStream.readInt(); + isActive = dataStream.readBoolean(); + controlType = RedstoneControl.values()[dataStream.readInt()]; + clientEnergyUsed = dataStream.readDouble(); + + if (dataStream.readBoolean()) { + fluidTank.setFluid( + new FluidStack(dataStream.readInt(), dataStream.readInt()) + ); + } else { + fluidTank.setFluid(null); + } + + if (dataStream.readBoolean()) { + gasTank.setGas(new GasStack( + GasRegistry.getGas(dataStream.readInt()), dataStream.readInt() + )); + } else { + gasTank.setGas(null); + } + + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } + + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); + + data.add(mode); + data.add(isActive); + data.add(controlType.ordinal()); + data.add(clientEnergyUsed); + + if (fluidTank.getFluid() != null) { + data.add(true); + data.add(fluidTank.getFluid().getFluidID()); + data.add(fluidTank.getFluid().amount); + } else { + data.add(false); + } + + if (gasTank.getGas() != null) { + data.add(true); + data.add(gasTank.getGas().getGas().getID()); + data.add(gasTank.getStored()); + } else { + data.add(false); + } + + return data; + } + + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); + + mode = nbtTags.getInteger("mode"); + isActive = nbtTags.getBoolean("isActive"); + controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + + gasTank.read(nbtTags.getCompoundTag("gasTank")); + + if (nbtTags.hasKey("fluidTank")) { + fluidTank.readFromNBT(nbtTags.getCompoundTag("fluidTank")); + } + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); + + nbtTags.setInteger("mode", mode); + nbtTags.setBoolean("isActive", isActive); + nbtTags.setInteger("controlType", controlType.ordinal()); + nbtTags.setTag("gasTank", gasTank.write(new NBTTagCompound())); + + if (fluidTank.getFluid() != null) { + nbtTags.setTag("fluidTank", fluidTank.writeToNBT(new NBTTagCompound())); + } + } + + @Override + public boolean canSetFacing(int i) { + return i != 0 && i != 1; + } + + public int getScaledFluidLevel(int i) { + return fluidTank.getFluid() != null ? fluidTank.getFluid().amount * i / MAX_FLUID + : 0; + } + + public int getScaledGasLevel(int i) { + return gasTank.getGas() != null ? gasTank.getStored() * i / MAX_FLUID : 0; + } + + @Override + public void setActive(boolean active) { + isActive = active; + + if (clientActive != active && updateDelay == 0) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + + updateDelay = 10; + clientActive = active; + } + } + + @Override + public boolean getActive() { + return isActive; + } + + @Override + public boolean renderUpdate() { + return false; + } + + @Override + public boolean lightUpdate() { + return true; + } + + @Override + public boolean canTubeConnect(ForgeDirection side) { + return side == MekanismUtils.getLeft(facing); + } + + @Override + public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) { + return gasTank.receive(stack, doTransfer); + } + + @Override + public int receiveGas(ForgeDirection side, GasStack stack) { + return receiveGas(side, stack, true); + } + + @Override + public GasStack drawGas(ForgeDirection side, int amount, boolean doTransfer) { + return gasTank.draw(amount, doTransfer); + } + + @Override + public GasStack drawGas(ForgeDirection side, int amount) { + return drawGas(side, amount, true); + } + + @Override + public boolean canDrawGas(ForgeDirection side, Gas type) { + return mode == 1 && side == MekanismUtils.getLeft(facing) ? gasTank.canDraw(type) + : false; + } + + @Override + public boolean canReceiveGas(ForgeDirection side, Gas type) { + return mode == 0 && side == MekanismUtils.getLeft(facing) + ? gasTank.canReceive(type) + : false; + } + + @Override + public void writeSustainedData(ItemStack itemStack) { + if (fluidTank.getFluid() != null) { + itemStack.stackTagCompound.setTag( + "fluidTank", fluidTank.getFluid().writeToNBT(new NBTTagCompound()) + ); + } + + if (gasTank.getGas() != null) { + itemStack.stackTagCompound.setTag( + "gasTank", gasTank.getGas().write(new NBTTagCompound()) + ); + } + } + + @Override + public void readSustainedData(ItemStack itemStack) { + fluidTank.setFluid(FluidStack.loadFluidStackFromNBT( + itemStack.stackTagCompound.getCompoundTag("fluidTank") + )); + gasTank.setGas( + GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("gasTank")) + ); + } + + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { + if (canFill(from, resource.getFluid())) { + return fluidTank.fill(resource, doFill); + } + + return 0; + } + + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + if (fluidTank.getFluid() != null + && fluidTank.getFluid().getFluid() == resource.getFluid()) { + return drain(from, resource.amount, doDrain); + } + + return null; + } + + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + return mode == 1 && from == MekanismUtils.getRight(facing) + && (fluidTank.getFluid() == null ? isValidFluid(new FluidStack(fluid, 1)) + : fluidTank.getFluid().getFluid() == fluid); + } + + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + return mode == 0 && from == MekanismUtils.getRight(facing); + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection from) { + if (from == MekanismUtils.getRight(facing)) { + return new FluidTankInfo[] { fluidTank.getInfo() }; + } + + return PipeUtils.EMPTY; + } + + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { + if (canDrain(from, null)) { + return fluidTank.drain(maxDrain, doDrain); + } + + return null; + } + + @Override + public RedstoneControl getControlType() { + return controlType; + } + + @Override + public void setControlType(RedstoneControl type) { + controlType = type; + MekanismUtils.saveChunk(this); + } + + @Override + public boolean canPulse() { + return false; + } + + @Override + public TileComponentUpgrade getComponent() { + return upgradeComponent; + } + + @Override + public void recalculateUpgradables(Upgrade upgrade) { + super.recalculateUpgradables(upgrade); + + switch (upgrade) { + case ENERGY: + maxEnergy = MekanismUtils.getMaxEnergy(this, BASE_MAX_ENERGY); + energyPerTick + = MekanismUtils.getBaseEnergyPerTick(this, BASE_ENERGY_USAGE); + default: + break; + } + } + + @Override + public List getInfo(Upgrade upgrade) { + return upgrade == Upgrade.SPEED ? upgrade.getExpScaledInfo(this) + : upgrade.getMultScaledInfo(this); + } + + @Override + public Object[] getTanks() { + return new Object[] { gasTank, fluidTank }; + } + + @Override + public TileComponentSecurity getSecurity() { + return securityComponent; + } } diff --git a/src/main/java/mekanism/common/tile/TileEntitySecurityDesk.java b/src/main/java/mekanism/common/tile/TileEntitySecurityDesk.java index 37385d396..3ab699279 100644 --- a/src/main/java/mekanism/common/tile/TileEntitySecurityDesk.java +++ b/src/main/java/mekanism/common/tile/TileEntitySecurityDesk.java @@ -1,9 +1,10 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.common.Mekanism; import mekanism.common.PacketHandler; @@ -22,304 +23,256 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; import net.minecraftforge.common.util.ForgeDirection; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class TileEntitySecurityDesk extends TileEntityContainerBlock implements IBoundingBlock -{ - public String owner; - - public SecurityFrequency frequency; - - public TileEntitySecurityDesk() - { - super("SecurityDesk"); - - inventory = new ItemStack[2]; - } - - @Override - public void onUpdate() - { - if(!worldObj.isRemote) - { - if(owner != null && frequency != null) - { - if(inventory[0] != null && inventory[0].getItem() instanceof IOwnerItem) - { - IOwnerItem item = (IOwnerItem)inventory[0].getItem(); - - if(item.hasOwner(inventory[0]) && item.getOwner(inventory[0]) != null) - { - if(item.getOwner(inventory[0]).equals(owner)) - { - item.setOwner(inventory[0], null); - - if(item instanceof ISecurityItem && ((ISecurityItem)item).hasSecurity(inventory[0])) - { - ((ISecurityItem)item).setSecurity(inventory[0], SecurityMode.PUBLIC); - } - } - } - } - - if(inventory[1] != null && inventory[1].getItem() instanceof IOwnerItem) - { - IOwnerItem item = (IOwnerItem)inventory[1].getItem(); - - if(item.hasOwner(inventory[1])) - { - if(item.getOwner(inventory[1]) == null) - { - item.setOwner(inventory[1], owner); - } - - if(item.getOwner(inventory[1]).equals(owner)) - { - if(item instanceof ISecurityItem && ((ISecurityItem)item).hasSecurity(inventory[1])) - { - ((ISecurityItem)item).setSecurity(inventory[1], frequency.securityMode); - } - } - } - } - } - - if(frequency == null && owner != null) - { - setFrequency(owner); - } - - FrequencyManager manager = getManager(frequency); - - if(manager != null) - { - if(frequency != null && !frequency.valid) - { - frequency = (SecurityFrequency)manager.validateFrequency(owner, Coord4D.get(this), frequency); - } - - if(frequency != null) - { - frequency = (SecurityFrequency)manager.update(owner, Coord4D.get(this), frequency); - } - } - else { - frequency = null; - } - } - } - - public FrequencyManager getManager(Frequency freq) - { - if(owner == null || freq == null) - { - return null; - } - - return Mekanism.securityFrequencies; - } - - public void setFrequency(String owner) - { - FrequencyManager manager = Mekanism.securityFrequencies; - manager.deactivate(Coord4D.get(this)); - - for(Frequency freq : manager.getFrequencies()) - { - if(freq.owner.equals(owner)) - { - frequency = (SecurityFrequency)freq; - frequency.activeCoords.add(Coord4D.get(this)); - - return; - } - } - - Frequency freq = new SecurityFrequency(owner).setAccess(SecurityMode.PUBLIC); - freq.activeCoords.add(Coord4D.get(this)); - manager.addFrequency(freq); - frequency = (SecurityFrequency)freq; - - MekanismUtils.saveChunk(this); - markDirty(); - } - - @Override - public void handlePacketData(ByteBuf dataStream) - { - if(!worldObj.isRemote) - { - int type = dataStream.readInt(); - - if(type == 0) - { - if(frequency != null) - { - frequency.trusted.add(PacketHandler.readString(dataStream)); - } - } - else if(type == 1) - { - if(frequency != null) - { - frequency.trusted.remove(PacketHandler.readString(dataStream)); - } - } - else if(type == 2) - { - if(frequency != null) - { - frequency.override = !frequency.override; - - Mekanism.packetHandler.sendToAll(new SecurityUpdateMessage(SecurityPacket.UPDATE, owner, new SecurityData(frequency))); - } - } - else if(type == 3) - { - if(frequency != null) - { - frequency.securityMode = SecurityMode.values()[dataStream.readInt()]; - - Mekanism.packetHandler.sendToAll(new SecurityUpdateMessage(SecurityPacket.UPDATE, owner, new SecurityData(frequency))); - } - } - - MekanismUtils.saveChunk(this); - - return; - } - - super.handlePacketData(dataStream); - - if(worldObj.isRemote) - { - if(dataStream.readBoolean()) - { - owner = PacketHandler.readString(dataStream); - } - else { - owner = null; - } - - if(dataStream.readBoolean()) - { - frequency = new SecurityFrequency(dataStream); - } - else { - frequency = null; - } - } - } +public class TileEntitySecurityDesk + extends TileEntityContainerBlock implements IBoundingBlock { + public String owner; - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - if(nbtTags.hasKey("owner")) - { - owner = nbtTags.getString("owner"); - } - - if(nbtTags.hasKey("frequency")) - { - frequency = new SecurityFrequency(nbtTags.getCompoundTag("frequency")); - frequency.valid = false; - } - } + public SecurityFrequency frequency; - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - if(owner != null) - { - nbtTags.setString("owner", owner); - } - - if(frequency != null) - { - NBTTagCompound frequencyTag = new NBTTagCompound(); - frequency.write(frequencyTag); - nbtTags.setTag("frequency", frequencyTag); - } - } + public TileEntitySecurityDesk() { + super("SecurityDesk"); - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); - - if(owner != null) - { - data.add(true); - data.add(owner); - } - else { - data.add(false); - } - - if(frequency != null) - { - data.add(true); - frequency.write(data); - } - else { - data.add(false); - } + inventory = new ItemStack[2]; + } - return data; - } - - @Override - public void invalidate() - { - super.invalidate(); - - if(!worldObj.isRemote) - { - if(frequency != null) - { - FrequencyManager manager = getManager(frequency); - - if(manager != null) - { - manager.deactivate(Coord4D.get(this)); - } - } - } - } - - @Override - public void onPlace() - { - MekanismUtils.makeBoundingBlock(worldObj, Coord4D.get(this).getFromSide(ForgeDirection.UP), Coord4D.get(this)); - } + @Override + public void onUpdate() { + if (!worldObj.isRemote) { + if (owner != null && frequency != null) { + if (inventory[0] != null + && inventory[0].getItem() instanceof IOwnerItem) { + IOwnerItem item = (IOwnerItem) inventory[0].getItem(); - @Override - public void onBreak() - { - worldObj.setBlockToAir(xCoord, yCoord+1, zCoord); - worldObj.setBlockToAir(xCoord, yCoord, zCoord); - } - - @Override - public Frequency getFrequency(FrequencyManager manager) - { - if(manager == Mekanism.securityFrequencies) - { - return frequency; - } - - return null; - } - - @Override - @SideOnly(Side.CLIENT) - public AxisAlignedBB getRenderBoundingBox() - { - return INFINITE_EXTENT_AABB; - } + if (item.hasOwner(inventory[0]) + && item.getOwner(inventory[0]) != null) { + if (item.getOwner(inventory[0]).equals(owner)) { + item.setOwner(inventory[0], null); + + if (item instanceof ISecurityItem + && ((ISecurityItem) item).hasSecurity(inventory[0])) { + ((ISecurityItem) item) + .setSecurity(inventory[0], SecurityMode.PUBLIC); + } + } + } + } + + if (inventory[1] != null + && inventory[1].getItem() instanceof IOwnerItem) { + IOwnerItem item = (IOwnerItem) inventory[1].getItem(); + + if (item.hasOwner(inventory[1])) { + if (item.getOwner(inventory[1]) == null) { + item.setOwner(inventory[1], owner); + } + + if (item.getOwner(inventory[1]).equals(owner)) { + if (item instanceof ISecurityItem + && ((ISecurityItem) item).hasSecurity(inventory[1])) { + ((ISecurityItem) item) + .setSecurity(inventory[1], frequency.securityMode); + } + } + } + } + } + + if (frequency == null && owner != null) { + setFrequency(owner); + } + + FrequencyManager manager = getManager(frequency); + + if (manager != null) { + if (frequency != null && !frequency.valid) { + frequency = (SecurityFrequency + ) manager.validateFrequency(owner, Coord4D.get(this), frequency); + } + + if (frequency != null) { + frequency = (SecurityFrequency + ) manager.update(owner, Coord4D.get(this), frequency); + } + } else { + frequency = null; + } + } + } + + public FrequencyManager getManager(Frequency freq) { + if (owner == null || freq == null) { + return null; + } + + return Mekanism.securityFrequencies; + } + + public void setFrequency(String owner) { + FrequencyManager manager = Mekanism.securityFrequencies; + manager.deactivate(Coord4D.get(this)); + + for (Frequency freq : manager.getFrequencies()) { + if (freq.owner.equals(owner)) { + frequency = (SecurityFrequency) freq; + frequency.activeCoords.add(Coord4D.get(this)); + + return; + } + } + + Frequency freq = new SecurityFrequency(owner).setAccess(SecurityMode.PUBLIC); + freq.activeCoords.add(Coord4D.get(this)); + manager.addFrequency(freq); + frequency = (SecurityFrequency) freq; + + MekanismUtils.saveChunk(this); + markDirty(); + } + + @Override + public void handlePacketData(ByteBuf dataStream) { + if (!worldObj.isRemote) { + int type = dataStream.readInt(); + + if (type == 0) { + if (frequency != null) { + frequency.trusted.add(PacketHandler.readString(dataStream)); + } + } else if (type == 1) { + if (frequency != null) { + frequency.trusted.remove(PacketHandler.readString(dataStream)); + } + } else if (type == 2) { + if (frequency != null) { + frequency.override = !frequency.override; + + Mekanism.packetHandler.sendToAll(new SecurityUpdateMessage( + SecurityPacket.UPDATE, owner, new SecurityData(frequency) + )); + } + } else if (type == 3) { + if (frequency != null) { + frequency.securityMode = SecurityMode.values()[dataStream.readInt()]; + + Mekanism.packetHandler.sendToAll(new SecurityUpdateMessage( + SecurityPacket.UPDATE, owner, new SecurityData(frequency) + )); + } + } + + MekanismUtils.saveChunk(this); + + return; + } + + super.handlePacketData(dataStream); + + if (worldObj.isRemote) { + if (dataStream.readBoolean()) { + owner = PacketHandler.readString(dataStream); + } else { + owner = null; + } + + if (dataStream.readBoolean()) { + frequency = new SecurityFrequency(dataStream); + } else { + frequency = null; + } + } + } + + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); + + if (nbtTags.hasKey("owner")) { + owner = nbtTags.getString("owner"); + } + + if (nbtTags.hasKey("frequency")) { + frequency = new SecurityFrequency(nbtTags.getCompoundTag("frequency")); + frequency.valid = false; + } + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); + + if (owner != null) { + nbtTags.setString("owner", owner); + } + + if (frequency != null) { + NBTTagCompound frequencyTag = new NBTTagCompound(); + frequency.write(frequencyTag); + nbtTags.setTag("frequency", frequencyTag); + } + } + + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); + + if (owner != null) { + data.add(true); + data.add(owner); + } else { + data.add(false); + } + + if (frequency != null) { + data.add(true); + frequency.write(data); + } else { + data.add(false); + } + + return data; + } + + @Override + public void invalidate() { + super.invalidate(); + + if (!worldObj.isRemote) { + if (frequency != null) { + FrequencyManager manager = getManager(frequency); + + if (manager != null) { + manager.deactivate(Coord4D.get(this)); + } + } + } + } + + @Override + public void onPlace() { + MekanismUtils.makeBoundingBlock( + worldObj, Coord4D.get(this).getFromSide(ForgeDirection.UP), Coord4D.get(this) + ); + } + + @Override + public void onBreak() { + worldObj.setBlockToAir(xCoord, yCoord + 1, zCoord); + worldObj.setBlockToAir(xCoord, yCoord, zCoord); + } + + @Override + public Frequency getFrequency(FrequencyManager manager) { + if (manager == Mekanism.securityFrequencies) { + return frequency; + } + + return null; + } + + @Override + @SideOnly(Side.CLIENT) + public AxisAlignedBB getRenderBoundingBox() { + return INFINITE_EXTENT_AABB; + } } diff --git a/src/main/java/mekanism/common/tile/TileEntitySeismicVibrator.java b/src/main/java/mekanism/common/tile/TileEntitySeismicVibrator.java index b480ac509..066772325 100644 --- a/src/main/java/mekanism/common/tile/TileEntitySeismicVibrator.java +++ b/src/main/java/mekanism/common/tile/TileEntitySeismicVibrator.java @@ -1,10 +1,11 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.EnumSet; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.MekanismConfig.general; import mekanism.api.MekanismConfig.usage; @@ -23,227 +24,204 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; import net.minecraftforge.common.util.ForgeDirection; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class TileEntitySeismicVibrator extends TileEntityElectricBlock implements IActiveState, IRedstoneControl, ISecurityTile, IBoundingBlock -{ - public boolean isActive; +public class TileEntitySeismicVibrator extends TileEntityElectricBlock + implements IActiveState, IRedstoneControl, ISecurityTile, IBoundingBlock { + public boolean isActive; - public boolean clientActive; - - public int updateDelay; - - public int clientPiston; - - public RedstoneControl controlType = RedstoneControl.DISABLED; - - public TileComponentSecurity securityComponent = new TileComponentSecurity(this); - - public TileEntitySeismicVibrator() - { - super("SeismicVibrator", MachineType.SEISMIC_VIBRATOR.baseEnergy); - - inventory = new ItemStack[1]; - } - - @Override - public void onUpdate() - { - super.onUpdate(); - - if(worldObj.isRemote) - { - if(isActive) - { - clientPiston++; - } - - if(updateDelay > 0) - { - updateDelay--; + public boolean clientActive; - if(updateDelay == 0 && clientActive != isActive) - { - isActive = clientActive; - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } - } - else { - if(updateDelay > 0) - { - updateDelay--; + public int updateDelay; - if(updateDelay == 0 && clientActive != isActive) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - } - } - - ChargeUtils.discharge(0, this); - - if(MekanismUtils.canFunction(this) && getEnergy() >= usage.seismicVibratorUsage) - { - setActive(true); - setEnergy(getEnergy()- usage.seismicVibratorUsage); - } - else { - setActive(false); - } - } - - if(getActive()) - { - Mekanism.activeVibrators.add(Coord4D.get(this)); - } - else { - Mekanism.activeVibrators.remove(Coord4D.get(this)); - } - } - - @Override - public void invalidate() - { - super.invalidate(); - - Mekanism.activeVibrators.remove(Coord4D.get(this)); - } - - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); + public int clientPiston; - nbtTags.setBoolean("isActive", isActive); - nbtTags.setInteger("controlType", controlType.ordinal()); - } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); + public RedstoneControl controlType = RedstoneControl.DISABLED; - clientActive = isActive = nbtTags.getBoolean("isActive"); - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - } - - @Override - public void handlePacketData(ByteBuf dataStream) - { - super.handlePacketData(dataStream); + public TileComponentSecurity securityComponent = new TileComponentSecurity(this); - if(worldObj.isRemote) - { - clientActive = dataStream.readBoolean(); - controlType = RedstoneControl.values()[dataStream.readInt()]; - - if(updateDelay == 0 && clientActive != isActive) - { - updateDelay = general.UPDATE_DELAY; - isActive = clientActive; - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } - } - - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); + public TileEntitySeismicVibrator() { + super("SeismicVibrator", MachineType.SEISMIC_VIBRATOR.baseEnergy); - data.add(isActive); - data.add(controlType.ordinal()); - - return data; - } - - @Override - public void setActive(boolean active) - { - isActive = active; + inventory = new ItemStack[1]; + } - if(clientActive != active && updateDelay == 0) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); + @Override + public void onUpdate() { + super.onUpdate(); - updateDelay = 10; - clientActive = active; - } - } + if (worldObj.isRemote) { + if (isActive) { + clientPiston++; + } - @Override - public boolean getActive() - { - return isActive; - } - - @Override - public boolean renderUpdate() - { - return false; - } + if (updateDelay > 0) { + updateDelay--; - @Override - public boolean lightUpdate() - { - return true; - } - - @Override - public boolean canSetFacing(int facing) - { - return facing != 0 && facing != 1; - } - - @Override - public RedstoneControl getControlType() - { - return controlType; - } - - @Override - public EnumSet getConsumingSides() - { - return EnumSet.of(ForgeDirection.getOrientation(facing).getOpposite()); - } + if (updateDelay == 0 && clientActive != isActive) { + isActive = clientActive; + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } + } else { + if (updateDelay > 0) { + updateDelay--; - @Override - public void setControlType(RedstoneControl type) - { - controlType = type; - MekanismUtils.saveChunk(this); - } + if (updateDelay == 0 && clientActive != isActive) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + } + } - @Override - public boolean canPulse() - { - return false; - } - - @Override - public TileComponentSecurity getSecurity() - { - return securityComponent; - } - - @Override - public void onPlace() - { - MekanismUtils.makeBoundingBlock(worldObj, Coord4D.get(this).getFromSide(ForgeDirection.UP), Coord4D.get(this)); - } + ChargeUtils.discharge(0, this); - @Override - public void onBreak() - { - worldObj.setBlockToAir(xCoord, yCoord+1, zCoord); - worldObj.setBlockToAir(xCoord, yCoord, zCoord); - } - - @Override - @SideOnly(Side.CLIENT) - public AxisAlignedBB getRenderBoundingBox() - { - return INFINITE_EXTENT_AABB; - } + if (MekanismUtils.canFunction(this) + && getEnergy() >= usage.seismicVibratorUsage) { + setActive(true); + setEnergy(getEnergy() - usage.seismicVibratorUsage); + } else { + setActive(false); + } + } + + if (getActive()) { + Mekanism.activeVibrators.add(Coord4D.get(this)); + } else { + Mekanism.activeVibrators.remove(Coord4D.get(this)); + } + } + + @Override + public void invalidate() { + super.invalidate(); + + Mekanism.activeVibrators.remove(Coord4D.get(this)); + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); + + nbtTags.setBoolean("isActive", isActive); + nbtTags.setInteger("controlType", controlType.ordinal()); + } + + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); + + clientActive = isActive = nbtTags.getBoolean("isActive"); + controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + } + + @Override + public void handlePacketData(ByteBuf dataStream) { + super.handlePacketData(dataStream); + + if (worldObj.isRemote) { + clientActive = dataStream.readBoolean(); + controlType = RedstoneControl.values()[dataStream.readInt()]; + + if (updateDelay == 0 && clientActive != isActive) { + updateDelay = general.UPDATE_DELAY; + isActive = clientActive; + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } + } + + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); + + data.add(isActive); + data.add(controlType.ordinal()); + + return data; + } + + @Override + public void setActive(boolean active) { + isActive = active; + + if (clientActive != active && updateDelay == 0) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + + updateDelay = 10; + clientActive = active; + } + } + + @Override + public boolean getActive() { + return isActive; + } + + @Override + public boolean renderUpdate() { + return false; + } + + @Override + public boolean lightUpdate() { + return true; + } + + @Override + public boolean canSetFacing(int facing) { + return facing != 0 && facing != 1; + } + + @Override + public RedstoneControl getControlType() { + return controlType; + } + + @Override + public EnumSet getConsumingSides() { + return EnumSet.of(ForgeDirection.getOrientation(facing).getOpposite()); + } + + @Override + public void setControlType(RedstoneControl type) { + controlType = type; + MekanismUtils.saveChunk(this); + } + + @Override + public boolean canPulse() { + return false; + } + + @Override + public TileComponentSecurity getSecurity() { + return securityComponent; + } + + @Override + public void onPlace() { + MekanismUtils.makeBoundingBlock( + worldObj, Coord4D.get(this).getFromSide(ForgeDirection.UP), Coord4D.get(this) + ); + } + + @Override + public void onBreak() { + worldObj.setBlockToAir(xCoord, yCoord + 1, zCoord); + worldObj.setBlockToAir(xCoord, yCoord, zCoord); + } + + @Override + @SideOnly(Side.CLIENT) + public AxisAlignedBB getRenderBoundingBox() { + return INFINITE_EXTENT_AABB; + } } diff --git a/src/main/java/mekanism/common/tile/TileEntitySolarNeutronActivator.java b/src/main/java/mekanism/common/tile/TileEntitySolarNeutronActivator.java index bc09c4143..f2c97cdbd 100644 --- a/src/main/java/mekanism/common/tile/TileEntitySolarNeutronActivator.java +++ b/src/main/java/mekanism/common/tile/TileEntitySolarNeutronActivator.java @@ -1,10 +1,11 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.Range4D; import mekanism.api.gas.Gas; @@ -37,406 +38,404 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.biome.BiomeGenDesert; import net.minecraftforge.common.util.ForgeDirection; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock implements IRedstoneControl, IBoundingBlock, IGasHandler, ITubeConnection, IActiveState, ISustainedData, ITankManager, ISecurityTile, IUpgradeTile, IUpgradeInfoHandler -{ - public GasTank inputTank = new GasTank(MAX_GAS); - public GasTank outputTank = new GasTank(MAX_GAS); - - public static final int MAX_GAS = 10000; - - public int updateDelay; - - public boolean isActive; +public class TileEntitySolarNeutronActivator extends TileEntityContainerBlock + implements IRedstoneControl, IBoundingBlock, IGasHandler, ITubeConnection, + IActiveState, ISustainedData, ITankManager, ISecurityTile, IUpgradeTile, + IUpgradeInfoHandler { + public GasTank inputTank = new GasTank(MAX_GAS); + public GasTank outputTank = new GasTank(MAX_GAS); - public boolean clientActive; - - public int gasOutput = 256; - - public SolarNeutronRecipe cachedRecipe; - - /** This machine's current RedstoneControl type. */ - public RedstoneControl controlType = RedstoneControl.DISABLED; - - public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, 3); - public TileComponentSecurity securityComponent = new TileComponentSecurity(this); - - public TileEntitySolarNeutronActivator() - { - super("SolarNeutronActivator"); - upgradeComponent.setSupported(Upgrade.ENERGY, false); - inventory = new ItemStack[4]; - } + public static final int MAX_GAS = 10000; - @Override - public void onUpdate() - { - if(worldObj.isRemote && updateDelay > 0) - { - updateDelay--; + public int updateDelay; - if(updateDelay == 0 && clientActive != isActive) - { - isActive = clientActive; - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } - - if(!worldObj.isRemote) - { - if(updateDelay > 0) - { - updateDelay--; + public boolean isActive; - if(updateDelay == 0 && clientActive != isActive) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - } - } - - if(inventory[0] != null && (inputTank.getGas() == null || inputTank.getStored() < inputTank.getMaxGas())) - { - inputTank.receive(GasTransmission.removeGas(inventory[0], inputTank.getGasType(), inputTank.getNeeded()), true); - } - - if(inventory[1] != null && outputTank.getGas() != null) - { - outputTank.draw(GasTransmission.addGas(inventory[1], outputTank.getGas()), true); - } - - SolarNeutronRecipe recipe = getRecipe(); + public boolean clientActive; - boolean sky = ((!worldObj.isRaining() && !worldObj.isThundering()) || isDesert()) && !worldObj.provider.hasNoSky && worldObj.canBlockSeeTheSky(xCoord, yCoord+1, zCoord); - - if(worldObj.isDaytime() && sky && canOperate(recipe) && MekanismUtils.canFunction(this)) - { - setActive(true); - - int operations = operate(recipe); - } - else { - setActive(false); - } + public int gasOutput = 256; - if(outputTank.getGas() != null) - { - GasStack toSend = new GasStack(outputTank.getGas().getGas(), Math.min(outputTank.getStored(), gasOutput)); + public SolarNeutronRecipe cachedRecipe; - TileEntity tileEntity = Coord4D.get(this).getFromSide(ForgeDirection.getOrientation(facing)).getTileEntity(worldObj); + /** This machine's current RedstoneControl type. */ + public RedstoneControl controlType = RedstoneControl.DISABLED; - if(tileEntity instanceof IGasHandler) - { - if(((IGasHandler)tileEntity).canReceiveGas(ForgeDirection.getOrientation(facing).getOpposite(), outputTank.getGas().getGas())) - { - outputTank.draw(((IGasHandler)tileEntity).receiveGas(ForgeDirection.getOrientation(facing).getOpposite(), toSend, true), true); - } - } - } - } - } - - public int getUpgradedUsage() - { - int possibleProcess = (int)Math.pow(2, upgradeComponent.getUpgrades(Upgrade.SPEED)); - possibleProcess = Math.min(Math.min(inputTank.getStored(), outputTank.getNeeded()), possibleProcess); - - return possibleProcess; - } - - public boolean isDesert() - { - return worldObj.provider.getBiomeGenForCoords(xCoord >> 4, zCoord >> 4) instanceof BiomeGenDesert; - } - - public SolarNeutronRecipe getRecipe() - { - GasInput input = getInput(); - - if(cachedRecipe == null || !input.testEquality(cachedRecipe.getInput())) - { - cachedRecipe = RecipeHandler.getSolarNeutronRecipe(getInput()); - } - - return cachedRecipe; - } + public TileComponentUpgrade upgradeComponent = new TileComponentUpgrade(this, 3); + public TileComponentSecurity securityComponent = new TileComponentSecurity(this); - public GasInput getInput() - { - return new GasInput(inputTank.getGas()); - } + public TileEntitySolarNeutronActivator() { + super("SolarNeutronActivator"); + upgradeComponent.setSupported(Upgrade.ENERGY, false); + inventory = new ItemStack[4]; + } - public boolean canOperate(SolarNeutronRecipe recipe) - { - return recipe != null && recipe.canOperate(inputTank, outputTank); - } + @Override + public void onUpdate() { + if (worldObj.isRemote && updateDelay > 0) { + updateDelay--; - public int operate(SolarNeutronRecipe recipe) - { - int operations = getUpgradedUsage(); - - recipe.operate(inputTank, outputTank, operations); - - return operations; - } - - @Override - public void handlePacketData(ByteBuf dataStream) - { - super.handlePacketData(dataStream); + if (updateDelay == 0 && clientActive != isActive) { + isActive = clientActive; + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } - if(worldObj.isRemote) - { - isActive = dataStream.readBoolean(); - controlType = RedstoneControl.values()[dataStream.readInt()]; - - if(dataStream.readBoolean()) - { - inputTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt())); - } - else { - inputTank.setGas(null); - } - - if(dataStream.readBoolean()) - { - outputTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt())); - } - else { - outputTank.setGas(null); - } - - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } + if (!worldObj.isRemote) { + if (updateDelay > 0) { + updateDelay--; - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); + if (updateDelay == 0 && clientActive != isActive) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + } + } - data.add(isActive); - data.add(controlType.ordinal()); + if (inventory[0] != null + && (inputTank.getGas() == null + || inputTank.getStored() < inputTank.getMaxGas())) { + inputTank.receive( + GasTransmission.removeGas( + inventory[0], inputTank.getGasType(), inputTank.getNeeded() + ), + true + ); + } - if(inputTank.getGas() != null) - { - data.add(true); - data.add(inputTank.getGas().getGas().getID()); - data.add(inputTank.getStored()); - } - else { - data.add(false); - } - - if(outputTank.getGas() != null) - { - data.add(true); - data.add(outputTank.getGas().getGas().getID()); - data.add(outputTank.getStored()); - } - else { - data.add(false); - } + if (inventory[1] != null && outputTank.getGas() != null) { + outputTank.draw( + GasTransmission.addGas(inventory[1], outputTank.getGas()), true + ); + } - return data; - } + SolarNeutronRecipe recipe = getRecipe(); - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); + boolean sky + = ((!worldObj.isRaining() && !worldObj.isThundering()) || isDesert()) + && !worldObj.provider.hasNoSky + && worldObj.canBlockSeeTheSky(xCoord, yCoord + 1, zCoord); - isActive = nbtTags.getBoolean("isActive"); - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + if (worldObj.isDaytime() && sky && canOperate(recipe) + && MekanismUtils.canFunction(this)) { + setActive(true); - inputTank.read(nbtTags.getCompoundTag("inputTank")); - outputTank.read(nbtTags.getCompoundTag("outputTank")); - } + int operations = operate(recipe); + } else { + setActive(false); + } - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); + if (outputTank.getGas() != null) { + GasStack toSend = new GasStack( + outputTank.getGas().getGas(), + Math.min(outputTank.getStored(), gasOutput) + ); - nbtTags.setBoolean("isActive", isActive); - nbtTags.setInteger("controlType", controlType.ordinal()); - - nbtTags.setTag("inputTank", inputTank.write(new NBTTagCompound())); - nbtTags.setTag("outputTank", outputTank.write(new NBTTagCompound())); - } + TileEntity tileEntity + = Coord4D.get(this) + .getFromSide(ForgeDirection.getOrientation(facing)) + .getTileEntity(worldObj); - @Override - public boolean canSetFacing(int i) - { - return i != 0 && i != 1; - } + if (tileEntity instanceof IGasHandler) { + if (((IGasHandler) tileEntity) + .canReceiveGas( + ForgeDirection.getOrientation(facing).getOpposite(), + outputTank.getGas().getGas() + )) { + outputTank.draw( + ((IGasHandler) tileEntity) + .receiveGas( + ForgeDirection.getOrientation(facing).getOpposite(), + toSend, + true + ), + true + ); + } + } + } + } + } - @Override - public void onPlace() - { - MekanismUtils.makeBoundingBlock(worldObj, Coord4D.get(this).getFromSide(ForgeDirection.UP), Coord4D.get(this)); - } + public int getUpgradedUsage() { + int possibleProcess + = (int) Math.pow(2, upgradeComponent.getUpgrades(Upgrade.SPEED)); + possibleProcess = Math.min( + Math.min(inputTank.getStored(), outputTank.getNeeded()), possibleProcess + ); - @Override - public void onBreak() - { - worldObj.setBlockToAir(xCoord, yCoord+1, zCoord); - worldObj.setBlockToAir(xCoord, yCoord, zCoord); - } + return possibleProcess; + } - @Override - public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) - { - if(canReceiveGas(side, stack != null ? stack.getGas() : null)) - { - return inputTank.receive(stack, doTransfer); - } - - return 0; - } + public boolean isDesert() { + return worldObj.provider.getBiomeGenForCoords(xCoord >> 4, zCoord >> 4) + instanceof BiomeGenDesert; + } - @Override - public int receiveGas(ForgeDirection side, GasStack stack) - { - return receiveGas(side, stack, true); - } + public SolarNeutronRecipe getRecipe() { + GasInput input = getInput(); - @Override - public GasStack drawGas(ForgeDirection side, int amount, boolean doTransfer) - { - if(canDrawGas(side, null)) - { - return outputTank.draw(amount, doTransfer); - } - - return null; - } + if (cachedRecipe == null || !input.testEquality(cachedRecipe.getInput())) { + cachedRecipe = RecipeHandler.getSolarNeutronRecipe(getInput()); + } - @Override - public GasStack drawGas(ForgeDirection side, int amount) - { - return drawGas(side, amount, true); - } + return cachedRecipe; + } - @Override - public boolean canReceiveGas(ForgeDirection side, Gas type) - { - return side == ForgeDirection.DOWN && inputTank.canReceive(type); - } + public GasInput getInput() { + return new GasInput(inputTank.getGas()); + } - @Override - public boolean canDrawGas(ForgeDirection side, Gas type) - { - return side == ForgeDirection.getOrientation(facing) && outputTank.canDraw(type); - } - - @Override - public boolean canTubeConnect(ForgeDirection side) - { - return side == ForgeDirection.getOrientation(facing) || side == ForgeDirection.DOWN; - } + public boolean canOperate(SolarNeutronRecipe recipe) { + return recipe != null && recipe.canOperate(inputTank, outputTank); + } - @Override - public void writeSustainedData(ItemStack itemStack) - { - if(inputTank.getGas() != null) - { - itemStack.stackTagCompound.setTag("inputTank", inputTank.getGas().write(new NBTTagCompound())); - } - - if(outputTank.getGas() != null) - { - itemStack.stackTagCompound.setTag("outputTank", outputTank.getGas().write(new NBTTagCompound())); - } - } - - @Override - public void readSustainedData(ItemStack itemStack) - { - inputTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("inputTank"))); - outputTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("outputTank"))); - } + public int operate(SolarNeutronRecipe recipe) { + int operations = getUpgradedUsage(); - @Override - public RedstoneControl getControlType() - { - return controlType; - } + recipe.operate(inputTank, outputTank, operations); - @Override - public void setControlType(RedstoneControl type) - { - controlType = type; - MekanismUtils.saveChunk(this); - } + return operations; + } - @Override - public boolean canPulse() - { - return false; - } + @Override + public void handlePacketData(ByteBuf dataStream) { + super.handlePacketData(dataStream); - @Override - public boolean getActive() - { - return isActive; - } - - @Override - public void setActive(boolean active) - { - isActive = active; + if (worldObj.isRemote) { + isActive = dataStream.readBoolean(); + controlType = RedstoneControl.values()[dataStream.readInt()]; - if(clientActive != active && updateDelay == 0) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); + if (dataStream.readBoolean()) { + inputTank.setGas(new GasStack( + GasRegistry.getGas(dataStream.readInt()), dataStream.readInt() + )); + } else { + inputTank.setGas(null); + } - updateDelay = 10; - clientActive = active; - } - } + if (dataStream.readBoolean()) { + outputTank.setGas(new GasStack( + GasRegistry.getGas(dataStream.readInt()), dataStream.readInt() + )); + } else { + outputTank.setGas(null); + } - @Override - public boolean renderUpdate() - { - return false; - } + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } - @Override - public boolean lightUpdate() - { - return true; - } - - @Override - public Object[] getTanks() - { - return new Object[] {inputTank, outputTank}; - } - - @Override - public TileComponentSecurity getSecurity() - { - return securityComponent; - } - - @Override - public TileComponentUpgrade getComponent() - { - return upgradeComponent; - } - - @Override - public List getInfo(Upgrade upgrade) - { - return upgrade == Upgrade.SPEED ? upgrade.getExpScaledInfo(this) : upgrade.getMultScaledInfo(this); - } - - @Override - @SideOnly(Side.CLIENT) - public AxisAlignedBB getRenderBoundingBox() - { - return INFINITE_EXTENT_AABB; - } + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); + + data.add(isActive); + data.add(controlType.ordinal()); + + if (inputTank.getGas() != null) { + data.add(true); + data.add(inputTank.getGas().getGas().getID()); + data.add(inputTank.getStored()); + } else { + data.add(false); + } + + if (outputTank.getGas() != null) { + data.add(true); + data.add(outputTank.getGas().getGas().getID()); + data.add(outputTank.getStored()); + } else { + data.add(false); + } + + return data; + } + + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); + + isActive = nbtTags.getBoolean("isActive"); + controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + + inputTank.read(nbtTags.getCompoundTag("inputTank")); + outputTank.read(nbtTags.getCompoundTag("outputTank")); + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); + + nbtTags.setBoolean("isActive", isActive); + nbtTags.setInteger("controlType", controlType.ordinal()); + + nbtTags.setTag("inputTank", inputTank.write(new NBTTagCompound())); + nbtTags.setTag("outputTank", outputTank.write(new NBTTagCompound())); + } + + @Override + public boolean canSetFacing(int i) { + return i != 0 && i != 1; + } + + @Override + public void onPlace() { + MekanismUtils.makeBoundingBlock( + worldObj, Coord4D.get(this).getFromSide(ForgeDirection.UP), Coord4D.get(this) + ); + } + + @Override + public void onBreak() { + worldObj.setBlockToAir(xCoord, yCoord + 1, zCoord); + worldObj.setBlockToAir(xCoord, yCoord, zCoord); + } + + @Override + public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) { + if (canReceiveGas(side, stack != null ? stack.getGas() : null)) { + return inputTank.receive(stack, doTransfer); + } + + return 0; + } + + @Override + public int receiveGas(ForgeDirection side, GasStack stack) { + return receiveGas(side, stack, true); + } + + @Override + public GasStack drawGas(ForgeDirection side, int amount, boolean doTransfer) { + if (canDrawGas(side, null)) { + return outputTank.draw(amount, doTransfer); + } + + return null; + } + + @Override + public GasStack drawGas(ForgeDirection side, int amount) { + return drawGas(side, amount, true); + } + + @Override + public boolean canReceiveGas(ForgeDirection side, Gas type) { + return side == ForgeDirection.DOWN && inputTank.canReceive(type); + } + + @Override + public boolean canDrawGas(ForgeDirection side, Gas type) { + return side == ForgeDirection.getOrientation(facing) && outputTank.canDraw(type); + } + + @Override + public boolean canTubeConnect(ForgeDirection side) { + return side == ForgeDirection.getOrientation(facing) + || side == ForgeDirection.DOWN; + } + + @Override + public void writeSustainedData(ItemStack itemStack) { + if (inputTank.getGas() != null) { + itemStack.stackTagCompound.setTag( + "inputTank", inputTank.getGas().write(new NBTTagCompound()) + ); + } + + if (outputTank.getGas() != null) { + itemStack.stackTagCompound.setTag( + "outputTank", outputTank.getGas().write(new NBTTagCompound()) + ); + } + } + + @Override + public void readSustainedData(ItemStack itemStack) { + inputTank.setGas( + GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("inputTank")) + ); + outputTank.setGas( + GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("outputTank")) + ); + } + + @Override + public RedstoneControl getControlType() { + return controlType; + } + + @Override + public void setControlType(RedstoneControl type) { + controlType = type; + MekanismUtils.saveChunk(this); + } + + @Override + public boolean canPulse() { + return false; + } + + @Override + public boolean getActive() { + return isActive; + } + + @Override + public void setActive(boolean active) { + isActive = active; + + if (clientActive != active && updateDelay == 0) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + + updateDelay = 10; + clientActive = active; + } + } + + @Override + public boolean renderUpdate() { + return false; + } + + @Override + public boolean lightUpdate() { + return true; + } + + @Override + public Object[] getTanks() { + return new Object[] { inputTank, outputTank }; + } + + @Override + public TileComponentSecurity getSecurity() { + return securityComponent; + } + + @Override + public TileComponentUpgrade getComponent() { + return upgradeComponent; + } + + @Override + public List getInfo(Upgrade upgrade) { + return upgrade == Upgrade.SPEED ? upgrade.getExpScaledInfo(this) + : upgrade.getMultScaledInfo(this); + } + + @Override + @SideOnly(Side.CLIENT) + public AxisAlignedBB getRenderBoundingBox() { + return INFINITE_EXTENT_AABB; + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityStructuralGlass.java b/src/main/java/mekanism/common/tile/TileEntityStructuralGlass.java index 276a651c8..99ebbd6eb 100644 --- a/src/main/java/mekanism/common/tile/TileEntityStructuralGlass.java +++ b/src/main/java/mekanism/common/tile/TileEntityStructuralGlass.java @@ -10,102 +10,81 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityStructuralGlass extends TileEntity implements IStructuralMultiblock -{ - public Coord4D master; - - @Override - public boolean onActivate(EntityPlayer player) - { - if(master != null) - { - if(master.getTileEntity(worldObj) instanceof IMultiblock) - { - return ((IMultiblock)master.getTileEntity(worldObj)).onActivate(player); - } - else { - master = null; - } - } - - return false; - } - - @Override - public void update() - { - if(master != null) - { - if(master.getTileEntity(worldObj) instanceof IMultiblock) - { - ((IMultiblock)master.getTileEntity(worldObj)).update(); - } - else { - master = null; - } - } - else { - IMultiblock multiblock = new ControllerFinder().find(); - - if(multiblock != null) - { - multiblock.update(); - } - } - } +public class TileEntityStructuralGlass + extends TileEntity implements IStructuralMultiblock { + public Coord4D master; - @Override - public boolean canInterface(TileEntity controller) - { - return true; - } - - @Override - public void setController(Coord4D coord) - { - master = coord; - } - - public class ControllerFinder - { - public IMultiblock found; - - public Set iterated = new HashSet(); - - public void loop(Coord4D pos) - { - if(iterated.size() > 2048 || found != null) - { - return; - } - - iterated.add(pos); - - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - Coord4D coord = pos.getFromSide(side); - TileEntity tile = coord.getTileEntity(worldObj); - - if(!iterated.contains(coord)) - { - if(tile instanceof IMultiblock) - { - found = (IMultiblock)coord.getTileEntity(worldObj); - return; - } - else if(tile instanceof IStructuralMultiblock) - { - loop(coord); - } - } - } - } - - public IMultiblock find() - { - loop(Coord4D.get(TileEntityStructuralGlass.this)); - - return found; - } - } + @Override + public boolean onActivate(EntityPlayer player) { + if (master != null) { + if (master.getTileEntity(worldObj) instanceof IMultiblock) { + return ((IMultiblock) master.getTileEntity(worldObj)).onActivate(player); + } else { + master = null; + } + } + + return false; + } + + @Override + public void update() { + if (master != null) { + if (master.getTileEntity(worldObj) instanceof IMultiblock) { + ((IMultiblock) master.getTileEntity(worldObj)).update(); + } else { + master = null; + } + } else { + IMultiblock multiblock = new ControllerFinder().find(); + + if (multiblock != null) { + multiblock.update(); + } + } + } + + @Override + public boolean canInterface(TileEntity controller) { + return true; + } + + @Override + public void setController(Coord4D coord) { + master = coord; + } + + public class ControllerFinder { + public IMultiblock found; + + public Set iterated = new HashSet(); + + public void loop(Coord4D pos) { + if (iterated.size() > 2048 || found != null) { + return; + } + + iterated.add(pos); + + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + Coord4D coord = pos.getFromSide(side); + TileEntity tile = coord.getTileEntity(worldObj); + + if (!iterated.contains(coord)) { + if (tile instanceof IMultiblock) { + found = (IMultiblock) coord.getTileEntity(worldObj); + return; + } else if (tile instanceof IStructuralMultiblock) { + loop(coord); + } + } + } + } + + public IMultiblock find() { + loop(Coord4D.get(TileEntityStructuralGlass.this)); + + return found; + } + } } diff --git a/src/main/java/mekanism/common/tile/TileEntitySuperheatingElement.java b/src/main/java/mekanism/common/tile/TileEntitySuperheatingElement.java index 65fd819b9..f6b0350fb 100644 --- a/src/main/java/mekanism/common/tile/TileEntitySuperheatingElement.java +++ b/src/main/java/mekanism/common/tile/TileEntitySuperheatingElement.java @@ -10,57 +10,52 @@ import mekanism.common.multiblock.TileEntityInternalMultiblock; import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.util.MekanismUtils; -public class TileEntitySuperheatingElement extends TileEntityInternalMultiblock -{ - public boolean prevHot; - - @Override - public void setMultiblock(String id) - { - boolean packet = false; - - if(id == null && multiblockUUID != null) - { - SynchronizedBoilerData.clientHotMap.remove(multiblockUUID); - packet = true; - } - else if(id != null && multiblockUUID == null) - { - packet = true; - } - - super.setMultiblock(id); - - if(packet && !worldObj.isRemote) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - } - } - - @Override - public boolean canUpdate() - { - return true; - } - - @Override - public void onUpdate() - { - if(worldObj.isRemote) - { - boolean newHot = false; - - if(multiblockUUID != null && SynchronizedBoilerData.clientHotMap.get(multiblockUUID) != null) - { - newHot = SynchronizedBoilerData.clientHotMap.get(multiblockUUID); - } - - if(prevHot != newHot) - { - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - - prevHot = newHot; - } - } - } +public class TileEntitySuperheatingElement extends TileEntityInternalMultiblock { + public boolean prevHot; + + @Override + public void setMultiblock(String id) { + boolean packet = false; + + if (id == null && multiblockUUID != null) { + SynchronizedBoilerData.clientHotMap.remove(multiblockUUID); + packet = true; + } else if (id != null && multiblockUUID == null) { + packet = true; + } + + super.setMultiblock(id); + + if (packet && !worldObj.isRemote) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + } + } + + @Override + public boolean canUpdate() { + return true; + } + + @Override + public void onUpdate() { + if (worldObj.isRemote) { + boolean newHot = false; + + if (multiblockUUID != null + && SynchronizedBoilerData.clientHotMap.get(multiblockUUID) != null) { + newHot = SynchronizedBoilerData.clientHotMap.get(multiblockUUID); + } + + if (prevHot != newHot) { + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + + prevHot = newHot; + } + } + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityTeleporter.java b/src/main/java/mekanism/common/tile/TileEntityTeleporter.java index f178d0f9d..d4584e5f1 100644 --- a/src/main/java/mekanism/common/tile/TileEntityTeleporter.java +++ b/src/main/java/mekanism/common/tile/TileEntityTeleporter.java @@ -1,7 +1,5 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; @@ -9,6 +7,10 @@ import java.util.List; import java.util.Set; import java.util.UUID; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; import mekanism.api.Chunk3D; import mekanism.api.Coord4D; import mekanism.api.Range4D; @@ -47,460 +49,470 @@ import net.minecraftforge.common.ForgeChunkManager; import net.minecraftforge.common.ForgeChunkManager.Ticket; import net.minecraftforge.common.ForgeChunkManager.Type; import net.minecraftforge.common.util.ForgeDirection; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; import scala.Int; -public class TileEntityTeleporter extends TileEntityElectricBlock implements IComputerIntegration, IChunkLoader, IFrequencyHandler, IRedstoneControl, ISecurityTile -{ - private MinecraftServer server = MinecraftServer.getServer(); +public class TileEntityTeleporter extends TileEntityElectricBlock + implements IComputerIntegration, IChunkLoader, IFrequencyHandler, IRedstoneControl, + ISecurityTile { + private MinecraftServer server = MinecraftServer.getServer(); - public AxisAlignedBB teleportBounds = null; + public AxisAlignedBB teleportBounds = null; - public Set didTeleport = new HashSet(); + public Set didTeleport = new HashSet(); - public int teleDelay = 0; + public int teleDelay = 0; - public boolean shouldRender; + public boolean shouldRender; - public boolean prevShouldRender; - - public Frequency frequency; - - public List publicCache = new ArrayList(); - public List privateCache = new ArrayList(); - public List protectedCache = new ArrayList(); + public boolean prevShouldRender; - public Ticket chunkTicket; + public Frequency frequency; - /** This teleporter's current status. */ - public byte status = 0; - - public RedstoneControl controlType = RedstoneControl.DISABLED; - - public TileComponentSecurity securityComponent; + public List publicCache = new ArrayList(); + public List privateCache = new ArrayList(); + public List protectedCache = new ArrayList(); - public TileEntityTeleporter() - { - super("Teleporter", MachineType.TELEPORTER.baseEnergy); - inventory = new ItemStack[1]; - - securityComponent = new TileComponentSecurity(this); - } + public Ticket chunkTicket; - @Override - public void onUpdate() - { - super.onUpdate(); + /** This teleporter's current status. */ + public byte status = 0; - if(teleportBounds == null) - { - resetBounds(); - } + public RedstoneControl controlType = RedstoneControl.DISABLED; - if(!worldObj.isRemote) - { - if(chunkTicket == null) - { - Ticket ticket = ForgeChunkManager.requestTicket(Mekanism.instance, worldObj, Type.NORMAL); - - if(ticket != null) - { - ticket.getModData().setInteger("xCoord", xCoord); - ticket.getModData().setInteger("yCoord", yCoord); - ticket.getModData().setInteger("zCoord", zCoord); - - forceChunks(ticket); - } - } - - FrequencyManager manager = getManager(frequency); - - if(manager != null) - { - if(frequency != null && !frequency.valid) - { - frequency = manager.validateFrequency(getSecurity().getOwner(), Coord4D.get(this), frequency); - } - - if(frequency != null) - { - frequency = manager.update(getSecurity().getOwner(), Coord4D.get(this), frequency); - } - } - else { - frequency = null; - } - - status = canTeleport(); + public TileComponentSecurity securityComponent; - if(MekanismUtils.canFunction(this) && status == 1 && teleDelay == 0) - { - teleport(); - } + public TileEntityTeleporter() { + super("Teleporter", MachineType.TELEPORTER.baseEnergy); + inventory = new ItemStack[1]; - if(teleDelay == 0 && didTeleport.size() > 0) - { - cleanTeleportCache(); - } + securityComponent = new TileComponentSecurity(this); + } - shouldRender = status == 1 || status > 4; + @Override + public void onUpdate() { + super.onUpdate(); - if(shouldRender != prevShouldRender) - { - Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this).getTargetPoint(40D)); - } + if (teleportBounds == null) { + resetBounds(); + } - prevShouldRender = shouldRender; + if (!worldObj.isRemote) { + if (chunkTicket == null) { + Ticket ticket = ForgeChunkManager.requestTicket( + Mekanism.instance, worldObj, Type.NORMAL + ); - teleDelay = Math.max(0, teleDelay-1); - } + if (ticket != null) { + ticket.getModData().setInteger("xCoord", xCoord); + ticket.getModData().setInteger("yCoord", yCoord); + ticket.getModData().setInteger("zCoord", zCoord); - ChargeUtils.discharge(0, this); - } - - @Override - public Frequency getFrequency(FrequencyManager manager) - { - if(manager == Mekanism.securityFrequencies) - { - return getSecurity().getFrequency(); - } - - return frequency; - } - - public Coord4D getClosest() - { - if(frequency != null) - { - return frequency.getClosestCoords(Coord4D.get(this)); - } - - return null; - } - - public void setFrequency(String name, SecurityMode publicFreq) - { - FrequencyManager manager = getManager(new Frequency(name, null).setAccess(publicFreq)); - manager.deactivate(Coord4D.get(this)); - - for(Frequency freq : manager.getFrequencies()) - { - if(freq.name.equals(name)) - { - frequency = freq; - frequency.activeCoords.add(Coord4D.get(this)); - - return; - } - } - - Frequency freq = new Frequency(name, getSecurity().getOwner()).setAccess(publicFreq); - freq.activeCoords.add(Coord4D.get(this)); - manager.addFrequency(freq); - frequency = freq; - - MekanismUtils.saveChunk(this); - } - - public FrequencyManager getManager(Frequency freq) - { - if(getSecurity().getOwner() == null || freq == null) - { - return null; - } - - if(freq.isPublic()) - { - return Mekanism.publicTeleporters; - } - else if(freq.isPrivate()) { - if(!Mekanism.privateTeleporters.containsKey(getSecurity().getOwner())) - { - FrequencyManager manager = new FrequencyManager(Frequency.class, Frequency.TELEPORTER, getSecurity().getOwner()); - Mekanism.privateTeleporters.put(getSecurity().getOwner(), manager); - manager.createOrLoad(worldObj); - } - - return Mekanism.privateTeleporters.get(getSecurity().getOwner()); - } else { - if(!Mekanism.protectedTeleporters.containsKey( getSecurity().getOwner())) - { - FrequencyManager manager = new FrequencyManager(Frequency.class, Frequency.TELEPORTER + "protected", getSecurity().getOwner()); - Mekanism.protectedTeleporters.put(getSecurity().getOwner(), manager); - manager.createOrLoad(worldObj); - } + forceChunks(ticket); + } + } - return Mekanism.protectedTeleporters.get(getSecurity().getOwner()); - } - } - - public static FrequencyManager loadManager(String owner, World world) - { - if(Mekanism.privateTeleporters.containsKey(owner)) - { - return Mekanism.privateTeleporters.get(owner); - } - - return FrequencyManager.loadOnly(world, owner, Frequency.class, "Teleporter"); - } - - @Override - public void onChunkUnload() - { - super.onChunkUnload(); - - if(!worldObj.isRemote && frequency != null) - { - FrequencyManager manager = getManager(frequency); - - if(manager != null) - { - manager.deactivate(Coord4D.get(this)); - } - } - } - - @Override - public void invalidate() - { - super.invalidate(); - - if(!worldObj.isRemote) - { - releaseChunks(); - - if(frequency != null) - { - FrequencyManager manager = getManager(frequency); - - if(manager != null) - { - manager.deactivate(Coord4D.get(this)); - } - } - } - } + FrequencyManager manager = getManager(frequency); - public void cleanTeleportCache() - { - List list = new ArrayList(); - - for(Entity e : (List)worldObj.getEntitiesWithinAABB(Entity.class, teleportBounds)) - { - list.add(e.getPersistentID()); - } - - Set teleportCopy = (Set)((HashSet)didTeleport).clone(); + if (manager != null) { + if (frequency != null && !frequency.valid) { + frequency = manager.validateFrequency( + getSecurity().getOwner(), Coord4D.get(this), frequency + ); + } - for(UUID id : teleportCopy) - { - if(!list.contains(id)) - { - didTeleport.remove(id); - } - } - } + if (frequency != null) { + frequency = manager.update( + getSecurity().getOwner(), Coord4D.get(this), frequency + ); + } + } else { + frequency = null; + } - @Override - public int[] getAccessibleSlotsFromSide(int side) - { - return new int[] {0}; - } + status = canTeleport(); - @Override - public boolean isItemValidForSlot(int slotID, ItemStack itemstack) - { - if(slotID == 0) - { - return ChargeUtils.canBeDischarged(itemstack); - } + if (MekanismUtils.canFunction(this) && status == 1 && teleDelay == 0) { + teleport(); + } - return true; - } + if (teleDelay == 0 && didTeleport.size() > 0) { + cleanTeleportCache(); + } - public void resetBounds() - { - teleportBounds = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord+1, yCoord+3, zCoord+1); - } + shouldRender = status == 1 || status > 4; - /** - * 1: yes - * 2: no frame - * 3: no link found - * 4: not enough electricity - * @return - */ - public byte canTeleport() - { - if(!hasFrame()) - { - return 2; - } - - if(getClosest() == null) - { - return 3; - } + if (shouldRender != prevShouldRender) { + Mekanism.packetHandler.sendToAllAround( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + Coord4D.get(this).getTargetPoint(40D) + ); + } - List entitiesInPortal = getToTeleport(); - Coord4D closestCoords = getClosest(); + prevShouldRender = shouldRender; - int electricityNeeded = 0; + teleDelay = Math.max(0, teleDelay - 1); + } - for(Entity entity : entitiesInPortal) - { - electricityNeeded += calculateEnergyCost(entity, closestCoords); - } + ChargeUtils.discharge(0, this); + } - if(getEnergy() < electricityNeeded) - { - return 4; - } + @Override + public Frequency getFrequency(FrequencyManager manager) { + if (manager == Mekanism.securityFrequencies) { + return getSecurity().getFrequency(); + } - return 1; -} + return frequency; + } - public void teleport() - { - if(worldObj.isRemote) return; + public Coord4D getClosest() { + if (frequency != null) { + return frequency.getClosestCoords(Coord4D.get(this)); + } - List entitiesInPortal = getToTeleport(); + return null; + } - Coord4D closestCoords = getClosest(); - - if(closestCoords == null) - { - return; - } + public void setFrequency(String name, SecurityMode publicFreq) { + FrequencyManager manager + = getManager(new Frequency(name, null).setAccess(publicFreq)); + manager.deactivate(Coord4D.get(this)); - for(Entity entity : entitiesInPortal) - { - World teleWorld = FMLCommonHandler.instance().getMinecraftServerInstance().worldServerForDimension(closestCoords.dimensionId); - TileEntityTeleporter teleporter = (TileEntityTeleporter)closestCoords.getTileEntity(teleWorld); + for (Frequency freq : manager.getFrequencies()) { + if (freq.name.equals(name)) { + frequency = freq; + frequency.activeCoords.add(Coord4D.get(this)); - if(teleporter != null) - { - teleporter.didTeleport.add(entity.getPersistentID()); - teleporter.teleDelay = 5; + return; + } + } - if(entity instanceof EntityPlayerMP) - { - teleportPlayerTo((EntityPlayerMP)entity, closestCoords, teleporter); - alignPlayer((EntityPlayerMP)entity, closestCoords); - } - else { - teleportEntityTo(entity, closestCoords, teleporter); - } + Frequency freq + = new Frequency(name, getSecurity().getOwner()).setAccess(publicFreq); + freq.activeCoords.add(Coord4D.get(this)); + manager.addFrequency(freq); + frequency = freq; - for(Coord4D coords : frequency.activeCoords) - { - Mekanism.packetHandler.sendToAllAround(new PortalFXMessage(coords), coords.getTargetPoint(40D)); - } + MekanismUtils.saveChunk(this); + } - setEnergy(getEnergy() - calculateEnergyCost(entity, closestCoords)); + public FrequencyManager getManager(Frequency freq) { + if (getSecurity().getOwner() == null || freq == null) { + return null; + } - worldObj.playSoundAtEntity(entity, "mob.endermen.portal", 1.0F, 1.0F); - } - } - } + if (freq.isPublic()) { + return Mekanism.publicTeleporters; + } else if (freq.isPrivate()) { + if (!Mekanism.privateTeleporters.containsKey(getSecurity().getOwner())) { + FrequencyManager manager = new FrequencyManager( + Frequency.class, Frequency.TELEPORTER, getSecurity().getOwner() + ); + Mekanism.privateTeleporters.put(getSecurity().getOwner(), manager); + manager.createOrLoad(worldObj); + } - public static void teleportPlayerTo(EntityPlayerMP player, Coord4D coord, TileEntityTeleporter teleporter) - { - if(player.dimension != coord.dimensionId) - { - int id = player.dimension; - WorldServer oldWorld = player.mcServer.worldServerForDimension(player.dimension); - player.dimension = coord.dimensionId; - WorldServer newWorld = player.mcServer.worldServerForDimension(player.dimension); - player.playerNetServerHandler.sendPacket(new S07PacketRespawn(player.dimension, player.worldObj.difficultySetting, newWorld.getWorldInfo().getTerrainType(), player.theItemInWorldManager.getGameType())); - oldWorld.removePlayerEntityDangerously(player); - player.isDead = false; + return Mekanism.privateTeleporters.get(getSecurity().getOwner()); + } else { + if (!Mekanism.protectedTeleporters.containsKey(getSecurity().getOwner())) { + FrequencyManager manager = new FrequencyManager( + Frequency.class, + Frequency.TELEPORTER + "protected", + getSecurity().getOwner() + ); + Mekanism.protectedTeleporters.put(getSecurity().getOwner(), manager); + manager.createOrLoad(worldObj); + } - if(player.isEntityAlive()) - { - newWorld.spawnEntityInWorld(player); - player.setLocationAndAngles(coord.xCoord+0.5, coord.yCoord+1, coord.zCoord+0.5, player.rotationYaw, player.rotationPitch); - newWorld.updateEntityWithOptionalForce(player, false); - player.setWorld(newWorld); - } + return Mekanism.protectedTeleporters.get(getSecurity().getOwner()); + } + } - player.mcServer.getConfigurationManager().func_72375_a(player, oldWorld); - player.playerNetServerHandler.setPlayerLocation(coord.xCoord+0.5, coord.yCoord+1, coord.zCoord+0.5, player.rotationYaw, player.rotationPitch); - player.theItemInWorldManager.setWorld(newWorld); - player.mcServer.getConfigurationManager().updateTimeAndWeatherForPlayer(player, newWorld); - player.mcServer.getConfigurationManager().syncPlayerInventory(player); - - Iterator iterator = player.getActivePotionEffects().iterator(); + public static FrequencyManager loadManager(String owner, World world) { + if (Mekanism.privateTeleporters.containsKey(owner)) { + return Mekanism.privateTeleporters.get(owner); + } - while(iterator.hasNext()) - { - PotionEffect potioneffect = (PotionEffect)iterator.next(); - player.playerNetServerHandler.sendPacket(new S1DPacketEntityEffect(player.getEntityId(), potioneffect)); - } + return FrequencyManager.loadOnly(world, owner, Frequency.class, "Teleporter"); + } - player.playerNetServerHandler.sendPacket(new S1FPacketSetExperience(player.experience, player.experienceTotal, player.experienceLevel)); // Force XP sync + @Override + public void onChunkUnload() { + super.onChunkUnload(); - FMLCommonHandler.instance().firePlayerChangedDimensionEvent(player, id, coord.dimensionId); - } - else { - player.playerNetServerHandler.setPlayerLocation(coord.xCoord+0.5, coord.yCoord+1, coord.zCoord+0.5, player.rotationYaw, player.rotationPitch); - } - } + if (!worldObj.isRemote && frequency != null) { + FrequencyManager manager = getManager(frequency); - public void teleportEntityTo(Entity entity, Coord4D coord, TileEntityTeleporter teleporter) - { - WorldServer world = server.worldServerForDimension(coord.dimensionId); + if (manager != null) { + manager.deactivate(Coord4D.get(this)); + } + } + } - if(entity.worldObj.provider.dimensionId != coord.dimensionId) - { - entity.worldObj.removeEntity(entity); - entity.isDead = false; + @Override + public void invalidate() { + super.invalidate(); - world.spawnEntityInWorld(entity); - entity.setLocationAndAngles(coord.xCoord+0.5, coord.yCoord+1, coord.zCoord+0.5, entity.rotationYaw, entity.rotationPitch); - world.updateEntityWithOptionalForce(entity, false); - entity.setWorld(world); - world.resetUpdateEntityTick(); + if (!worldObj.isRemote) { + releaseChunks(); - Entity e = EntityList.createEntityByName(EntityList.getEntityString(entity), world); + if (frequency != null) { + FrequencyManager manager = getManager(frequency); - if(e != null) - { - e.copyDataFrom(entity, true); - world.spawnEntityInWorld(e); - teleporter.didTeleport.add(e.getPersistentID()); - } + if (manager != null) { + manager.deactivate(Coord4D.get(this)); + } + } + } + } - entity.isDead = true; - } - else { - entity.setLocationAndAngles(coord.xCoord+0.5, coord.yCoord+1, coord.zCoord+0.5, entity.rotationYaw, entity.rotationPitch); - Mekanism.packetHandler.sendToReceivers(new EntityMoveMessage(entity), new Range4D(new Coord4D(entity))); - } - } + public void cleanTeleportCache() { + List list = new ArrayList(); - public static void alignPlayer(EntityPlayerMP player, Coord4D coord) - { + for (Entity e : (List) worldObj.getEntitiesWithinAABB( + Entity.class, teleportBounds + )) { + list.add(e.getPersistentID()); + } + + Set teleportCopy = (Set) ((HashSet) didTeleport).clone(); + + for (UUID id : teleportCopy) { + if (!list.contains(id)) { + didTeleport.remove(id); + } + } + } + + @Override + public int[] getAccessibleSlotsFromSide(int side) { + return new int[] { 0 }; + } + + @Override + public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { + if (slotID == 0) { + return ChargeUtils.canBeDischarged(itemstack); + } + + return true; + } + + public void resetBounds() { + teleportBounds = AxisAlignedBB.getBoundingBox( + xCoord, yCoord, zCoord, xCoord + 1, yCoord + 3, zCoord + 1 + ); + } + + /** + * 1: yes + * 2: no frame + * 3: no link found + * 4: not enough electricity + * @return + */ + public byte canTeleport() { + if (!hasFrame()) { + return 2; + } + + if (getClosest() == null) { + return 3; + } + + List entitiesInPortal = getToTeleport(); + Coord4D closestCoords = getClosest(); + + int electricityNeeded = 0; + + for (Entity entity : entitiesInPortal) { + electricityNeeded += calculateEnergyCost(entity, closestCoords); + } + + if (getEnergy() < electricityNeeded) { + return 4; + } + + return 1; + } + + public void teleport() { + if (worldObj.isRemote) + return; + + List entitiesInPortal = getToTeleport(); + + Coord4D closestCoords = getClosest(); + + if (closestCoords == null) { + return; + } + + for (Entity entity : entitiesInPortal) { + World teleWorld = FMLCommonHandler.instance() + .getMinecraftServerInstance() + .worldServerForDimension(closestCoords.dimensionId); + TileEntityTeleporter teleporter + = (TileEntityTeleporter) closestCoords.getTileEntity(teleWorld); + + if (teleporter != null) { + teleporter.didTeleport.add(entity.getPersistentID()); + teleporter.teleDelay = 5; + + if (entity instanceof EntityPlayerMP) { + teleportPlayerTo((EntityPlayerMP) entity, closestCoords, teleporter); + alignPlayer((EntityPlayerMP) entity, closestCoords); + } else { + teleportEntityTo(entity, closestCoords, teleporter); + } + + for (Coord4D coords : frequency.activeCoords) { + Mekanism.packetHandler.sendToAllAround( + new PortalFXMessage(coords), coords.getTargetPoint(40D) + ); + } + + setEnergy(getEnergy() - calculateEnergyCost(entity, closestCoords)); + + worldObj.playSoundAtEntity(entity, "mob.endermen.portal", 1.0F, 1.0F); + } + } + } + + public static void teleportPlayerTo( + EntityPlayerMP player, Coord4D coord, TileEntityTeleporter teleporter + ) { + if (player.dimension != coord.dimensionId) { + int id = player.dimension; + WorldServer oldWorld + = player.mcServer.worldServerForDimension(player.dimension); + player.dimension = coord.dimensionId; + WorldServer newWorld + = player.mcServer.worldServerForDimension(player.dimension); + player.playerNetServerHandler.sendPacket(new S07PacketRespawn( + player.dimension, + player.worldObj.difficultySetting, + newWorld.getWorldInfo().getTerrainType(), + player.theItemInWorldManager.getGameType() + )); + oldWorld.removePlayerEntityDangerously(player); + player.isDead = false; + + if (player.isEntityAlive()) { + newWorld.spawnEntityInWorld(player); + player.setLocationAndAngles( + coord.xCoord + 0.5, + coord.yCoord + 1, + coord.zCoord + 0.5, + player.rotationYaw, + player.rotationPitch + ); + newWorld.updateEntityWithOptionalForce(player, false); + player.setWorld(newWorld); + } + + player.mcServer.getConfigurationManager().func_72375_a(player, oldWorld); + player.playerNetServerHandler.setPlayerLocation( + coord.xCoord + 0.5, + coord.yCoord + 1, + coord.zCoord + 0.5, + player.rotationYaw, + player.rotationPitch + ); + player.theItemInWorldManager.setWorld(newWorld); + player.mcServer.getConfigurationManager().updateTimeAndWeatherForPlayer( + player, newWorld + ); + player.mcServer.getConfigurationManager().syncPlayerInventory(player); + + Iterator iterator = player.getActivePotionEffects().iterator(); + + while (iterator.hasNext()) { + PotionEffect potioneffect = (PotionEffect) iterator.next(); + player.playerNetServerHandler.sendPacket( + new S1DPacketEntityEffect(player.getEntityId(), potioneffect) + ); + } + + player.playerNetServerHandler.sendPacket(new S1FPacketSetExperience( + player.experience, player.experienceTotal, player.experienceLevel + )); // Force XP sync + + FMLCommonHandler.instance().firePlayerChangedDimensionEvent( + player, id, coord.dimensionId + ); + } else { + player.playerNetServerHandler.setPlayerLocation( + coord.xCoord + 0.5, + coord.yCoord + 1, + coord.zCoord + 0.5, + player.rotationYaw, + player.rotationPitch + ); + } + } + + public void + teleportEntityTo(Entity entity, Coord4D coord, TileEntityTeleporter teleporter) { + WorldServer world = server.worldServerForDimension(coord.dimensionId); + + if (entity.worldObj.provider.dimensionId != coord.dimensionId) { + entity.worldObj.removeEntity(entity); + entity.isDead = false; + + world.spawnEntityInWorld(entity); + entity.setLocationAndAngles( + coord.xCoord + 0.5, + coord.yCoord + 1, + coord.zCoord + 0.5, + entity.rotationYaw, + entity.rotationPitch + ); + world.updateEntityWithOptionalForce(entity, false); + entity.setWorld(world); + world.resetUpdateEntityTick(); + + Entity e = EntityList.createEntityByName( + EntityList.getEntityString(entity), world + ); + + if (e != null) { + e.copyDataFrom(entity, true); + world.spawnEntityInWorld(e); + teleporter.didTeleport.add(e.getPersistentID()); + } + + entity.isDead = true; + } else { + entity.setLocationAndAngles( + coord.xCoord + 0.5, + coord.yCoord + 1, + coord.zCoord + 0.5, + entity.rotationYaw, + entity.rotationPitch + ); + Mekanism.packetHandler.sendToReceivers( + new EntityMoveMessage(entity), new Range4D(new Coord4D(entity)) + ); + } + } + + public static void alignPlayer(EntityPlayerMP player, Coord4D coord) { Coord4D upperCoord = coord.getFromSide(ForgeDirection.UP); ForgeDirection side = null; float yaw = player.rotationYaw; - for(ForgeDirection iterSide : MekanismUtils.SIDE_DIRS) - { - if(upperCoord.getFromSide(iterSide).isAirBlock(player.worldObj)) - { + for (ForgeDirection iterSide : MekanismUtils.SIDE_DIRS) { + if (upperCoord.getFromSide(iterSide).isAirBlock(player.worldObj)) { side = iterSide; break; } } - if(side != null) - { - switch(side) - { + if (side != null) { + switch (side) { case NORTH: yaw = 180; break; @@ -516,317 +528,300 @@ public class TileEntityTeleporter extends TileEntityElectricBlock implements ICo } } - player.playerNetServerHandler.setPlayerLocation(player.posX, player.posY, player.posZ, yaw, player.rotationPitch); + player.playerNetServerHandler.setPlayerLocation( + player.posX, player.posY, player.posZ, yaw, player.rotationPitch + ); } - public List getToTeleport() - { - List entities = worldObj.getEntitiesWithinAABB(Entity.class, teleportBounds); - List ret = new ArrayList(); + public List getToTeleport() { + List entities + = worldObj.getEntitiesWithinAABB(Entity.class, teleportBounds); + List ret = new ArrayList(); - for(Entity entity : entities) - { - if(!didTeleport.contains(entity.getPersistentID())) - { - ret.add(entity); - } - } + for (Entity entity : entities) { + if (!didTeleport.contains(entity.getPersistentID())) { + ret.add(entity); + } + } - return ret; - } + return ret; + } - public int calculateEnergyCost(Entity entity, Coord4D coords) - { - int energyCost = 1000; + public int calculateEnergyCost(Entity entity, Coord4D coords) { + int energyCost = 1000; - if(entity.worldObj.provider.dimensionId != coords.dimensionId) - { - energyCost+=10000; - } + if (entity.worldObj.provider.dimensionId != coords.dimensionId) { + energyCost += 10000; + } - int distance = (int)entity.getDistance(coords.xCoord, coords.yCoord, coords.zCoord); - energyCost+=(distance*10); + int distance + = (int) entity.getDistance(coords.xCoord, coords.yCoord, coords.zCoord); + energyCost += (distance * 10); - return energyCost; - } + return energyCost; + } - public boolean hasFrame() - { - if(isFrame(xCoord-1, yCoord, zCoord) && isFrame(xCoord+1, yCoord, zCoord) - && isFrame(xCoord-1, yCoord+1, zCoord) && isFrame(xCoord+1, yCoord+1, zCoord) - && isFrame(xCoord-1, yCoord+2, zCoord) && isFrame(xCoord+1, yCoord+2, zCoord) - && isFrame(xCoord-1, yCoord+3, zCoord) && isFrame(xCoord+1, yCoord+3, zCoord) - && isFrame(xCoord, yCoord+3, zCoord)) {return true;} - if(isFrame(xCoord, yCoord, zCoord-1) && isFrame(xCoord, yCoord, zCoord+1) - && isFrame(xCoord, yCoord+1, zCoord-1) && isFrame(xCoord, yCoord+1, zCoord+1) - && isFrame(xCoord, yCoord+2, zCoord-1) && isFrame(xCoord, yCoord+2, zCoord+1) - && isFrame(xCoord, yCoord+3, zCoord-1) && isFrame(xCoord, yCoord+3, zCoord+1) - && isFrame(xCoord, yCoord+3, zCoord)) {return true;} - return false; - } + public boolean hasFrame() { + if (isFrame(xCoord - 1, yCoord, zCoord) && isFrame(xCoord + 1, yCoord, zCoord) + && isFrame(xCoord - 1, yCoord + 1, zCoord) + && isFrame(xCoord + 1, yCoord + 1, zCoord) + && isFrame(xCoord - 1, yCoord + 2, zCoord) + && isFrame(xCoord + 1, yCoord + 2, zCoord) + && isFrame(xCoord - 1, yCoord + 3, zCoord) + && isFrame(xCoord + 1, yCoord + 3, zCoord) + && isFrame(xCoord, yCoord + 3, zCoord)) { + return true; + } + if (isFrame(xCoord, yCoord, zCoord - 1) && isFrame(xCoord, yCoord, zCoord + 1) + && isFrame(xCoord, yCoord + 1, zCoord - 1) + && isFrame(xCoord, yCoord + 1, zCoord + 1) + && isFrame(xCoord, yCoord + 2, zCoord - 1) + && isFrame(xCoord, yCoord + 2, zCoord + 1) + && isFrame(xCoord, yCoord + 3, zCoord - 1) + && isFrame(xCoord, yCoord + 3, zCoord + 1) + && isFrame(xCoord, yCoord + 3, zCoord)) { + return true; + } + return false; + } - public boolean isFrame(int x, int y, int z) - { - return worldObj.getBlock(x, y, z) == MekanismBlocks.BasicBlock && worldObj.getBlockMetadata(x, y, z) == 7; - } + public boolean isFrame(int x, int y, int z) { + return worldObj.getBlock(x, y, z) == MekanismBlocks.BasicBlock + && worldObj.getBlockMetadata(x, y, z) == 7; + } - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); - - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - - if(nbtTags.hasKey("frequency")) - { - frequency = new Frequency(nbtTags.getCompoundTag("frequency")); - frequency.valid = false; - } - } + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); - - nbtTags.setInteger("controlType", controlType.ordinal()); - - if(frequency != null) - { - NBTTagCompound frequencyTag = new NBTTagCompound(); - frequency.write(frequencyTag); - nbtTags.setTag("frequency", frequencyTag); - } - } + controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - @Override - public void handlePacketData(ByteBuf dataStream) - { - if(!worldObj.isRemote) - { - int type = dataStream.readInt(); - - if(type == 0) - { - String name = PacketHandler.readString(dataStream); - int isPublic = dataStream.readInt(); - - setFrequency(name, SecurityMode.values()[isPublic]); - } - else if(type == 1) - { - String freq = PacketHandler.readString(dataStream); - int isPublic = dataStream.readInt(); - - FrequencyManager manager = getManager(new Frequency(freq, null).setAccess(SecurityMode.values()[isPublic])); - - if(manager != null) - { - manager.remove(freq, getSecurity().getOwner()); - } - } - - return; - } + if (nbtTags.hasKey("frequency")) { + frequency = new Frequency(nbtTags.getCompoundTag("frequency")); + frequency.valid = false; + } + } - super.handlePacketData(dataStream); - - if(worldObj.isRemote) - { - if(dataStream.readBoolean()) - { - frequency = new Frequency(dataStream); - } - else { - frequency = null; - } - - status = dataStream.readByte(); - shouldRender = dataStream.readBoolean(); - controlType = RedstoneControl.values()[dataStream.readInt()]; - - publicCache.clear(); - privateCache.clear(); - protectedCache.clear(); + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); - int amount = dataStream.readInt(); - - for(int i = 0; i < amount; i++) - { - publicCache.add(new Frequency(dataStream)); - } - - amount = dataStream.readInt(); - - for(int i = 0; i < amount; i++) - { - privateCache.add(new Frequency(dataStream)); - } + nbtTags.setInteger("controlType", controlType.ordinal()); - amount = dataStream.readInt(); + if (frequency != null) { + NBTTagCompound frequencyTag = new NBTTagCompound(); + frequency.write(frequencyTag); + nbtTags.setTag("frequency", frequencyTag); + } + } - for(int i = 0; i < amount; i++) - { - protectedCache.add(new Frequency(dataStream)); - } - } - } + @Override + public void handlePacketData(ByteBuf dataStream) { + if (!worldObj.isRemote) { + int type = dataStream.readInt(); - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); - - if(frequency != null) - { - data.add(true); - frequency.write(data); - } - else { - data.add(false); - } + if (type == 0) { + String name = PacketHandler.readString(dataStream); + int isPublic = dataStream.readInt(); - data.add(status); - data.add(shouldRender); - data.add(controlType.ordinal()); - - data.add(Mekanism.publicTeleporters.getFrequencies().size()); - - for(Frequency freq : Mekanism.publicTeleporters.getFrequencies()) - { - freq.write(data); - } - - FrequencyManager manager = getManager(new Frequency(null, null).setAccess(SecurityMode.PRIVATE)); - - if(manager != null) - { - data.add(manager.getFrequencies().size()); - - for(Frequency freq : manager.getFrequencies()) - { - freq.write(data); - } - } - else { - data.add(0); - } + setFrequency(name, SecurityMode.values()[isPublic]); + } else if (type == 1) { + String freq = PacketHandler.readString(dataStream); + int isPublic = dataStream.readInt(); + FrequencyManager manager = getManager( + new Frequency(freq, null).setAccess(SecurityMode.values()[isPublic]) + ); - List protectedFrqs = new ArrayList(); + if (manager != null) { + manager.remove(freq, getSecurity().getOwner()); + } + } - for (Frequency frequency : Mekanism.securityFrequencies.getFrequencies()) { - SecurityFrequency secure = (SecurityFrequency) frequency; - if(secure.trusted.contains(getSecurity().getOwner())) { - FrequencyManager protected_ = Mekanism.protectedTeleporters.get(secure.owner); - if(protected_ != null) { - protectedFrqs.addAll(protected_.getFrequencies()); - } - } - } - if(getSecurity().getOwner() != null) - protectedFrqs.addAll(getManager(new Frequency(null, null).setAccess(SecurityMode.TRUSTED)).getFrequencies()); + return; + } - data.add(protectedFrqs.size()); + super.handlePacketData(dataStream); - for (Frequency freq : protectedFrqs) { - freq.write(data); - } + if (worldObj.isRemote) { + if (dataStream.readBoolean()) { + frequency = new Frequency(dataStream); + } else { + frequency = null; + } - return data; - } + status = dataStream.readByte(); + shouldRender = dataStream.readBoolean(); + controlType = RedstoneControl.values()[dataStream.readInt()]; - @Override - public boolean canExtractItem(int slotID, ItemStack itemstack, int side) - { - return ChargeUtils.canBeOutputted(itemstack, false); - } + publicCache.clear(); + privateCache.clear(); + protectedCache.clear(); - private static final String[] methods = new String[] {"getEnergy", "canTeleport", "getMaxEnergy", "teleport", "setFrequency"}; + int amount = dataStream.readInt(); - @Override - public String[] getMethods() - { - return methods; - } + for (int i = 0; i < amount; i++) { + publicCache.add(new Frequency(dataStream)); + } - @Override - public Object[] invoke(int method, Object[] arguments) throws Exception - { - switch(method) - { - case 0: - return new Object[] {getEnergy()}; - case 1: - return new Object[] {canTeleport()}; - case 2: - return new Object[] {getMaxEnergy()}; - case 3: - teleport(); - return new Object[] {"Attempted to teleport."}; - case 4: - if(!(arguments[0] instanceof String) || !(arguments[1] instanceof Integer)) - { - return new Object[] {"Invalid parameters."}; - } - - String freq = ((String)arguments[0]).trim(); - int isPublic = (int)arguments[1]; - - setFrequency(freq, SecurityMode.values()[isPublic]); - - return new Object[] {"Frequency set."}; - default: - throw new NoSuchMethodException(); - } - } + amount = dataStream.readInt(); - @Override - @SideOnly(Side.CLIENT) - public AxisAlignedBB getRenderBoundingBox() - { - return INFINITE_EXTENT_AABB; - } + for (int i = 0; i < amount; i++) { + privateCache.add(new Frequency(dataStream)); + } - @Override - public void forceChunks(Ticket ticket) - { - releaseChunks(); - chunkTicket = ticket; - - ForgeChunkManager.forceChunk(chunkTicket, new Chunk3D(Coord4D.get(this)).toPair()); - } - - public void releaseChunks() - { - if(chunkTicket != null) - { - ForgeChunkManager.releaseTicket(chunkTicket); - chunkTicket = null; - } - } + amount = dataStream.readInt(); - @Override - public RedstoneControl getControlType() - { - return controlType; - } + for (int i = 0; i < amount; i++) { + protectedCache.add(new Frequency(dataStream)); + } + } + } - @Override - public void setControlType(RedstoneControl type) - { - controlType = type; - } + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); - @Override - public boolean canPulse() - { - return false; - } - - @Override - public TileComponentSecurity getSecurity() - { - return securityComponent; - } + if (frequency != null) { + data.add(true); + frequency.write(data); + } else { + data.add(false); + } + + data.add(status); + data.add(shouldRender); + data.add(controlType.ordinal()); + + data.add(Mekanism.publicTeleporters.getFrequencies().size()); + + for (Frequency freq : Mekanism.publicTeleporters.getFrequencies()) { + freq.write(data); + } + + FrequencyManager manager + = getManager(new Frequency(null, null).setAccess(SecurityMode.PRIVATE)); + + if (manager != null) { + data.add(manager.getFrequencies().size()); + + for (Frequency freq : manager.getFrequencies()) { + freq.write(data); + } + } else { + data.add(0); + } + + List protectedFrqs = new ArrayList(); + + for (Frequency frequency : Mekanism.securityFrequencies.getFrequencies()) { + SecurityFrequency secure = (SecurityFrequency) frequency; + if (secure.trusted.contains(getSecurity().getOwner())) { + FrequencyManager protected_ + = Mekanism.protectedTeleporters.get(secure.owner); + if (protected_ != null) { + protectedFrqs.addAll(protected_.getFrequencies()); + } + } + } + if (getSecurity().getOwner() != null) + protectedFrqs.addAll( + getManager(new Frequency(null, null).setAccess(SecurityMode.TRUSTED)) + .getFrequencies() + ); + + data.add(protectedFrqs.size()); + + for (Frequency freq : protectedFrqs) { + freq.write(data); + } + + return data; + } + + @Override + public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { + return ChargeUtils.canBeOutputted(itemstack, false); + } + + private static final String[] methods = new String[] { + "getEnergy", "canTeleport", "getMaxEnergy", "teleport", "setFrequency" + }; + + @Override + public String[] getMethods() { + return methods; + } + + @Override + public Object[] invoke(int method, Object[] arguments) throws Exception { + switch (method) { + case 0: + return new Object[] { getEnergy() }; + case 1: + return new Object[] { canTeleport() }; + case 2: + return new Object[] { getMaxEnergy() }; + case 3: + teleport(); + return new Object[] { "Attempted to teleport." }; + case 4: + if (!(arguments[0] instanceof String) + || !(arguments[1] instanceof Integer)) { + return new Object[] { "Invalid parameters." }; + } + + String freq = ((String) arguments[0]).trim(); + int isPublic = (int) arguments[1]; + + setFrequency(freq, SecurityMode.values()[isPublic]); + + return new Object[] { "Frequency set." }; + default: + throw new NoSuchMethodException(); + } + } + + @Override + @SideOnly(Side.CLIENT) + public AxisAlignedBB getRenderBoundingBox() { + return INFINITE_EXTENT_AABB; + } + + @Override + public void forceChunks(Ticket ticket) { + releaseChunks(); + chunkTicket = ticket; + + ForgeChunkManager.forceChunk( + chunkTicket, new Chunk3D(Coord4D.get(this)).toPair() + ); + } + + public void releaseChunks() { + if (chunkTicket != null) { + ForgeChunkManager.releaseTicket(chunkTicket); + chunkTicket = null; + } + } + + @Override + public RedstoneControl getControlType() { + return controlType; + } + + @Override + public void setControlType(RedstoneControl type) { + controlType = type; + } + + @Override + public boolean canPulse() { + return false; + } + + @Override + public TileComponentSecurity getSecurity() { + return securityComponent; + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityTheoreticalElementizer.java b/src/main/java/mekanism/common/tile/TileEntityTheoreticalElementizer.java index 0f122a8e8..b74b724b3 100644 --- a/src/main/java/mekanism/common/tile/TileEntityTheoreticalElementizer.java +++ b/src/main/java/mekanism/common/tile/TileEntityTheoreticalElementizer.java @@ -14,12 +14,20 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; -public class TileEntityTheoreticalElementizer extends TileEntityAdvancedElectricMachine { - +public class TileEntityTheoreticalElementizer + extends TileEntityAdvancedElectricMachine { public TileEntityTheoreticalElementizer() { - super("elementizer", "TheoreticalElementizer", 24, 1, 1000, BlockMachine.MachineType.THEORETICAL_ELEMENTIZER.baseEnergy, 1000); + super( + "elementizer", + "TheoreticalElementizer", + 24, + 1, + 1000, + BlockMachine.MachineType.THEORETICAL_ELEMENTIZER.baseEnergy, + 1000 + ); } - + @Override public HashMap getRecipes() { return new HashMap(); @@ -58,8 +66,7 @@ public class TileEntityTheoreticalElementizer extends TileEntityAdvancedElectric } @Override - public TheoreticalElementizerRecipe getRecipe() - { + public TheoreticalElementizerRecipe getRecipe() { return null; } diff --git a/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationBlock.java b/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationBlock.java index d255fc370..9f7fd0793 100644 --- a/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationBlock.java +++ b/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationBlock.java @@ -10,184 +10,162 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityThermalEvaporationBlock extends TileEntityContainerBlock implements IComputerIntegration -{ - public Coord4D master; - - public boolean attempted; +public class TileEntityThermalEvaporationBlock + extends TileEntityContainerBlock implements IComputerIntegration { + public Coord4D master; - public TileEntityThermalEvaporationBlock() - { - super("ThermalEvaporationBlock"); + public boolean attempted; - inventory = new ItemStack[0]; - } + public TileEntityThermalEvaporationBlock() { + super("ThermalEvaporationBlock"); - public TileEntityThermalEvaporationBlock(String fullName) - { - super(fullName); + inventory = new ItemStack[0]; + } - inventory = new ItemStack[0]; - } + public TileEntityThermalEvaporationBlock(String fullName) { + super(fullName); - @Override - public void onUpdate() - { - if(!worldObj.isRemote && ticker == 5 && !attempted && master == null) - { - updateController(); - } - - attempted = false; - } + inventory = new ItemStack[0]; + } - public void addToStructure(Coord4D controller) - { - master = controller; - } + @Override + public void onUpdate() { + if (!worldObj.isRemote && ticker == 5 && !attempted && master == null) { + updateController(); + } - public void controllerGone() - { - master = null; - } + attempted = false; + } - @Override - public void onChunkUnload() - { - super.onChunkUnload(); + public void addToStructure(Coord4D controller) { + master = controller; + } - if(master != null) - { - TileEntityThermalEvaporationController tile = getController(); - - if(tile != null) - { - ((TileEntityThermalEvaporationController)tile).refresh(); - } - } - } + public void controllerGone() { + master = null; + } - @Override - public void onNeighborChange(Block block) - { - super.onNeighborChange(block); + @Override + public void onChunkUnload() { + super.onChunkUnload(); - if(!worldObj.isRemote) - { - TileEntityThermalEvaporationController tile = getController(); - - if(tile != null) - { - ((TileEntityThermalEvaporationController)tile).refresh(); - } - else { - updateController(); - } - } - } - - public void updateController() - { - if(!(this instanceof TileEntityThermalEvaporationController)) - { - TileEntityThermalEvaporationController found = new ControllerFinder().find(); - - if(found != null) - { - found.refresh(); - } - } - } - - public TileEntityThermalEvaporationController getController() - { - if(master != null) - { - TileEntity tile = master.getTileEntity(worldObj); - - if(tile instanceof TileEntityThermalEvaporationController) - { - return (TileEntityThermalEvaporationController)tile; - } - } - - return null; - } - - public class ControllerFinder - { - public TileEntityThermalEvaporationController found; - - public Set iterated = new HashSet(); - - public void loop(Coord4D pos) - { - if(iterated.size() > 512 || found != null) - { - return; - } - - iterated.add(pos); - - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - Coord4D coord = pos.getFromSide(side); - - if(!iterated.contains(coord) && coord.getTileEntity(worldObj) instanceof TileEntityThermalEvaporationBlock) - { - ((TileEntityThermalEvaporationBlock)coord.getTileEntity(worldObj)).attempted = true; - - if(coord.getTileEntity(worldObj) instanceof TileEntityThermalEvaporationController) - { - found = (TileEntityThermalEvaporationController)coord.getTileEntity(worldObj); - return; - } - - loop(coord); - } - } - } - - public TileEntityThermalEvaporationController find() - { - loop(Coord4D.get(TileEntityThermalEvaporationBlock.this)); - - return found; - } - } - - private static final String[] methods = new String[] {"getTemperature", "getHeight", "isFormed", "getInput", "getOutput"}; + if (master != null) { + TileEntityThermalEvaporationController tile = getController(); - @Override - public String[] getMethods() - { - return methods; - } + if (tile != null) { + ((TileEntityThermalEvaporationController) tile).refresh(); + } + } + } - @Override - public Object[] invoke(int method, Object[] args) throws Exception - { - TileEntityThermalEvaporationController controller = getController(); - - if(controller == null) - { - return new Object[] {"Unformed."}; - } - - switch(method) - { - case 0: - return new Object[] {controller.temperature}; - case 1: - return new Object[] {controller.height}; - case 2: - return new Object[] {controller.structured}; - case 3: - return new Object[] {controller.inputTank.getFluidAmount()}; - case 4: - return new Object[] {controller.outputTank.getFluidAmount()}; - default: - throw new NoSuchMethodException(); - } - } + @Override + public void onNeighborChange(Block block) { + super.onNeighborChange(block); + + if (!worldObj.isRemote) { + TileEntityThermalEvaporationController tile = getController(); + + if (tile != null) { + ((TileEntityThermalEvaporationController) tile).refresh(); + } else { + updateController(); + } + } + } + + public void updateController() { + if (!(this instanceof TileEntityThermalEvaporationController)) { + TileEntityThermalEvaporationController found = new ControllerFinder().find(); + + if (found != null) { + found.refresh(); + } + } + } + + public TileEntityThermalEvaporationController getController() { + if (master != null) { + TileEntity tile = master.getTileEntity(worldObj); + + if (tile instanceof TileEntityThermalEvaporationController) { + return (TileEntityThermalEvaporationController) tile; + } + } + + return null; + } + + public class ControllerFinder { + public TileEntityThermalEvaporationController found; + + public Set iterated = new HashSet(); + + public void loop(Coord4D pos) { + if (iterated.size() > 512 || found != null) { + return; + } + + iterated.add(pos); + + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + Coord4D coord = pos.getFromSide(side); + + if (!iterated.contains(coord) + && coord.getTileEntity(worldObj) + instanceof TileEntityThermalEvaporationBlock) { + ((TileEntityThermalEvaporationBlock) coord.getTileEntity(worldObj)) + .attempted + = true; + + if (coord.getTileEntity(worldObj) + instanceof TileEntityThermalEvaporationController) { + found = (TileEntityThermalEvaporationController + ) coord.getTileEntity(worldObj); + return; + } + + loop(coord); + } + } + } + + public TileEntityThermalEvaporationController find() { + loop(Coord4D.get(TileEntityThermalEvaporationBlock.this)); + + return found; + } + } + + private static final String[] methods = new String[] { + "getTemperature", "getHeight", "isFormed", "getInput", "getOutput" + }; + + @Override + public String[] getMethods() { + return methods; + } + + @Override + public Object[] invoke(int method, Object[] args) throws Exception { + TileEntityThermalEvaporationController controller = getController(); + + if (controller == null) { + return new Object[] { "Unformed." }; + } + + switch (method) { + case 0: + return new Object[] { controller.temperature }; + case 1: + return new Object[] { controller.height }; + case 2: + return new Object[] { controller.structured }; + case 3: + return new Object[] { controller.inputTank.getFluidAmount() }; + case 4: + return new Object[] { controller.outputTank.getFluidAmount() }; + default: + throw new NoSuchMethodException(); + } + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationController.java b/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationController.java index 1fb9d6928..b673a17bc 100644 --- a/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationController.java +++ b/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationController.java @@ -1,11 +1,12 @@ package mekanism.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.HashSet; import java.util.Set; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.IEvaporationSolar; import mekanism.api.MekanismConfig.general; @@ -34,735 +35,667 @@ import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.IFluidContainerItem; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class TileEntityThermalEvaporationController extends TileEntityThermalEvaporationBlock implements IActiveState, ITankManager -{ - public static final int MAX_OUTPUT = 10000; - public static final int MAX_SOLARS = 4; - public static final int MAX_HEIGHT = 18; +public class TileEntityThermalEvaporationController + extends TileEntityThermalEvaporationBlock implements IActiveState, ITankManager { + public static final int MAX_OUTPUT = 10000; + public static final int MAX_SOLARS = 4; + public static final int MAX_HEIGHT = 18; - public FluidTank inputTank = new FluidTank(0); - public FluidTank outputTank = new FluidTank(MAX_OUTPUT); + public FluidTank inputTank = new FluidTank(0); + public FluidTank outputTank = new FluidTank(MAX_OUTPUT); - public Set tankParts = new HashSet(); - public IEvaporationSolar[] solars = new IEvaporationSolar[4]; + public Set tankParts = new HashSet(); + public IEvaporationSolar[] solars = new IEvaporationSolar[4]; - public boolean temperatureSet = false; - - public double partialInput = 0; - public double partialOutput = 0; - - public float biomeTemp = 0; - public float temperature = 0; - public float heatToAbsorb = 0; - - public float lastGain = 0; - - public int height = 0; - - public boolean structured = false; - public boolean controllerConflict = false; - public boolean isLeftOnFace; - public int renderY; - - public boolean updatedThisTick = false; + public boolean temperatureSet = false; - public int clientSolarAmount; - - public boolean cacheStructure = false; - - public float prevScale; - - public float totalLoss = 0; - - public TileEntityThermalEvaporationController() - { - super("ThermalEvaporationController"); - - inventory = new ItemStack[4]; - } + public double partialInput = 0; + public double partialOutput = 0; - @Override - public void onUpdate() - { - super.onUpdate(); - - if(!worldObj.isRemote) - { - updatedThisTick = false; - - if(ticker == 5) - { - refresh(); - } - - if(structured) - { - updateTemperature(); - } - - manageBuckets(); - - ThermalEvaporationRecipe recipe = getRecipe(); - - if(canOperate(recipe)) - { - int outputNeeded = outputTank.getCapacity()-outputTank.getFluidAmount(); - int inputStored = inputTank.getFluidAmount(); - double outputRatio = (double)recipe.recipeOutput.output.amount/(double)recipe.recipeInput.ingredient.amount; - - double tempMult = Math.max(0, getTemperature())*general.evaporationTempMultiplier; - double inputToUse = (tempMult*recipe.recipeInput.ingredient.amount)*((float)height/(float)MAX_HEIGHT); - inputToUse = Math.min(inputTank.getFluidAmount(), inputToUse); - inputToUse = Math.min(inputToUse, outputNeeded/outputRatio); - - lastGain = (float)inputToUse/(float)recipe.recipeInput.ingredient.amount; - partialInput += inputToUse; - - if(partialInput >= 1) - { - int inputInt = (int)Math.floor(partialInput); - inputTank.drain(inputInt, true); - partialInput %= 1; - partialOutput += ((double)inputInt)/recipe.recipeInput.ingredient.amount; - } - - if(partialOutput >= 1) - { - int outputInt = (int)Math.floor(partialOutput); - outputTank.fill(new FluidStack(recipe.recipeOutput.output.getFluid(), outputInt), true); - partialOutput %= 1; - } - } - else { - lastGain = 0; - } - - if(structured) - { - if(Math.abs((float)inputTank.getFluidAmount()/inputTank.getCapacity()-prevScale) > 0.01) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - prevScale = (float)inputTank.getFluidAmount()/inputTank.getCapacity(); - } - } - } - } - - public ThermalEvaporationRecipe getRecipe() - { - return RecipeHandler.getThermalEvaporationRecipe(new FluidInput(inputTank.getFluid())); - } - - @Override - public void onChunkUnload() - { - super.onChunkUnload(); - - refresh(); - } - - @Override - public void onNeighborChange(Block block) - { - super.onNeighborChange(block); - - refresh(); - } - - public boolean hasRecipe(Fluid fluid) - { - if(fluid == null) - { - return false; - } - - return Recipe.THERMAL_EVAPORATION_PLANT.containsRecipe(fluid); - } - - protected void refresh() - { - if(!worldObj.isRemote) - { - if(!updatedThisTick) - { - boolean prev = structured; - - clearStructure(); - structured = buildStructure(); - - if(structured != prev) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - } - - if(structured) - { - inputTank.setCapacity(getMaxFluid()); - - if(inputTank.getFluid() != null) - { - inputTank.getFluid().amount = Math.min(inputTank.getFluid().amount, getMaxFluid()); - } - } - else { - clearStructure(); - } - } - } - } + public float biomeTemp = 0; + public float temperature = 0; + public float heatToAbsorb = 0; - public boolean canOperate(ThermalEvaporationRecipe recipe) - { - if(!structured || height < 3 || height > MAX_HEIGHT || inputTank.getFluid() == null) - { - return false; - } - - if(recipe != null && recipe.canOperate(inputTank, outputTank)) - { - return true; - } - - return false; - } - - private void manageBuckets() - { - if(inventory[2] != null && outputTank.getFluid() != null) - { - if(inventory[2].getItem() instanceof IFluidContainerItem) - { - FluidContainerUtils.handleContainerItemFill(this, outputTank, 2, 3); - } - else if(FluidContainerRegistry.isEmptyContainer(inventory[2])) - { - FluidContainerUtils.handleRegistryItemFill(this, outputTank, 2, 3); - } - } - - if(structured) - { - if(inventory[0] != null) - { - if(inventory[0].getItem() instanceof IFluidContainerItem) - { - FluidContainerUtils.handleContainerItemEmpty(this, inputTank, 0, 1, new FluidChecker() { - @Override - public boolean isValid(Fluid f) - { - return hasRecipe(f); - } - }); - } - else if(FluidContainerRegistry.isFilledContainer(inventory[0])) - { - FluidContainerUtils.handleRegistryItemEmpty(this, inputTank, 0, 1, new FluidChecker() { - @Override - public boolean isValid(Fluid f) - { - return hasRecipe(f); - } - }); - } - } - } - } - - private void updateTemperature() - { - if(!temperatureSet) - { - biomeTemp = worldObj.getBiomeGenForCoordsBody(xCoord, zCoord).getFloatTemperature(xCoord, yCoord, zCoord); - temperatureSet = true; - } - - heatToAbsorb += getActiveSolars()*general.evaporationSolarMultiplier; - temperature += heatToAbsorb/(float)height; - - float biome = biomeTemp-0.5F; - float base = biome > 0 ? biome*20 : biomeTemp*40; - - if(Math.abs(temperature-base) < 0.001) - { - temperature = base; - } - - float incr = (float)Math.sqrt(Math.abs(temperature-base))*(float)general.evaporationHeatDissipation; - - if(temperature > base) - { - incr = -incr; - } - - float prev = temperature; - temperature = (float)Math.min(general.evaporationMaxTemp, temperature + incr/(float)height); - - if(incr < 0) - { - totalLoss = prev-temperature; - } - else { - totalLoss = 0; - } - - heatToAbsorb = 0; - - MekanismUtils.saveChunk(this); - } - - public float getTemperature() - { - return temperature; - } - - public int getActiveSolars() - { - if(worldObj.isRemote) - { - return clientSolarAmount; - } - - int ret = 0; - - for(IEvaporationSolar solar : solars) - { - if(solar != null && solar.seesSun()) - { - ret++; - } - } - - return ret; - } + public float lastGain = 0; - public boolean buildStructure() - { - ForgeDirection right = MekanismUtils.getRight(facing); - ForgeDirection left = MekanismUtils.getLeft(facing); + public int height = 0; - height = 0; - controllerConflict = false; - updatedThisTick = true; - - Coord4D startPoint = Coord4D.get(this); - - while(startPoint.getFromSide(ForgeDirection.UP).getTileEntity(worldObj) instanceof TileEntityThermalEvaporationBlock) - { - startPoint.step(ForgeDirection.UP); - } - - Coord4D test = startPoint.getFromSide(ForgeDirection.DOWN).getFromSide(right, 2); - isLeftOnFace = test.getTileEntity(worldObj) instanceof TileEntityThermalEvaporationBlock; - - startPoint = startPoint.getFromSide(left, isLeftOnFace ? 1 : 2); - - if(!scanTopLayer(startPoint)) - { - return false; - } + public boolean structured = false; + public boolean controllerConflict = false; + public boolean isLeftOnFace; + public int renderY; - height = 1; - - Coord4D middlePointer = startPoint.getFromSide(ForgeDirection.DOWN); - - while(scanLowerLayer(middlePointer)) - { - middlePointer = middlePointer.getFromSide(ForgeDirection.DOWN); - } - - renderY = middlePointer.yCoord+1; - - if(height < 3 || height > MAX_HEIGHT) - { - height = 0; - return false; - } + public boolean updatedThisTick = false; - structured = true; - - markDirty(); - - return true; - } + public int clientSolarAmount; - public boolean scanTopLayer(Coord4D current) - { - ForgeDirection right = MekanismUtils.getRight(facing); - ForgeDirection back = MekanismUtils.getBack(facing); + public boolean cacheStructure = false; - for(int x = 0; x < 4; x++) - { - for(int z = 0; z < 4; z++) - { - Coord4D pointer = current.getFromSide(right, x).getFromSide(back, z); - TileEntity pointerTile = pointer.getTileEntity(worldObj); - - int corner = getCorner(x, z); - - if(corner != -1) - { - if(addSolarPanel(pointer.getTileEntity(worldObj), corner)) - { - continue; - } - else if(pointer.getFromSide(ForgeDirection.UP).getTileEntity(worldObj) instanceof TileEntityThermalEvaporationBlock || !addTankPart(pointerTile)) - { - return false; - } - } - else { - if((x == 1 || x == 2) && (z == 1 || z == 2)) - { - if(!pointer.isAirBlock(worldObj)) - { - return false; - } - } - else { - if(pointer.getFromSide(ForgeDirection.UP).getTileEntity(worldObj) instanceof TileEntityThermalEvaporationBlock || !addTankPart(pointerTile)) - { - return false; - } - } - } - } - } + public float prevScale; - return true; - } - - public int getMaxFluid() - { - return height*4*TankUpdateProtocol.FLUID_PER_TANK; - } - - public int getCorner(int x, int z) - { - if(x == 0 && z == 0) - { - return 0; - } - else if(x == 0 && z == 3) - { - return 1; - } - else if(x == 3 && z == 0) - { - return 2; - } - else if(x == 3 && z == 3) - { - return 3; - } - - return -1; - } + public float totalLoss = 0; - public boolean scanLowerLayer(Coord4D current) - { - ForgeDirection right = MekanismUtils.getRight(facing); - ForgeDirection back = MekanismUtils.getBack(facing); - - boolean foundCenter = false; + public TileEntityThermalEvaporationController() { + super("ThermalEvaporationController"); - for(int x = 0; x < 4; x++) - { - for(int z = 0; z < 4; z++) - { - Coord4D pointer = current.getFromSide(right, x).getFromSide(back, z); - TileEntity pointerTile = pointer.getTileEntity(worldObj); - - if((x == 1 || x == 2) && (z == 1 || z == 2)) - { - if(pointerTile instanceof TileEntityThermalEvaporationBlock) - { - if(!foundCenter) - { - if(x == 1 && z == 1) - { - foundCenter = true; - } - else { - height = -1; - return false; - } - } - } - else { - if(foundCenter || !pointer.isAirBlock(worldObj)) - { - height = -1; - return false; - } - } - } - else { - if(!addTankPart(pointerTile)) - { - height = -1; - return false; - } - } - } - } + inventory = new ItemStack[4]; + } - height++; - - return !foundCenter; - } + @Override + public void onUpdate() { + super.onUpdate(); - public boolean addTankPart(TileEntity tile) - { - if(tile instanceof TileEntityThermalEvaporationBlock && (tile == this || !(tile instanceof TileEntityThermalEvaporationController))) - { - if(tile != this) - { - ((TileEntityThermalEvaporationBlock)tile).addToStructure(Coord4D.get(this)); - tankParts.add(Coord4D.get(tile)); - } - - return true; - } - else { - if(tile != this && tile instanceof TileEntityThermalEvaporationController) - { - controllerConflict = true; - } - - return false; - } - } + if (!worldObj.isRemote) { + updatedThisTick = false; - public boolean addSolarPanel(TileEntity tile, int i) - { - if(tile instanceof IEvaporationSolar && !tile.isInvalid()) - { - solars[i] = (IEvaporationSolar)tile; - return true; - } - else { - return false; - } - } - - public int getScaledInputLevel(int i) - { - return getMaxFluid() > 0 ? (inputTank.getFluid() != null ? inputTank.getFluid().amount*i / getMaxFluid() : 0) : 0; - } - - public int getScaledOutputLevel(int i) - { - return outputTank.getFluid() != null ? outputTank.getFluid().amount*i / MAX_OUTPUT : 0; - } - - public int getScaledTempLevel(int i) - { - return (int)(i*Math.min(1, getTemperature()/general.evaporationMaxTemp)); - } - - public Coord4D getRenderLocation() - { - if(!structured) - { - return null; - } - - ForgeDirection right = MekanismUtils.getRight(facing); - Coord4D startPoint = Coord4D.get(this).getFromSide(right); - startPoint = isLeftOnFace ? startPoint.getFromSide(right) : startPoint; - - startPoint = startPoint.getFromSide(right.getOpposite()).getFromSide(MekanismUtils.getBack(facing)); - startPoint.yCoord = renderY; - - return startPoint; - } - - @Override - public void handlePacketData(ByteBuf dataStream) - { - super.handlePacketData(dataStream); - - if(worldObj.isRemote) - { - if(dataStream.readBoolean()) - { - inputTank.setFluid(new FluidStack(dataStream.readInt(), dataStream.readInt())); - } - else { - inputTank.setFluid(null); - } - - if(dataStream.readBoolean()) - { - outputTank.setFluid(new FluidStack(dataStream.readInt(), dataStream.readInt())); - } - else { - outputTank.setFluid(null); - } - - boolean prev = structured; - - structured = dataStream.readBoolean(); - controllerConflict = dataStream.readBoolean(); - clientSolarAmount = dataStream.readInt(); - height = dataStream.readInt(); - temperature = dataStream.readFloat(); - biomeTemp = dataStream.readFloat(); - isLeftOnFace = dataStream.readBoolean(); - lastGain = dataStream.readFloat(); - totalLoss = dataStream.readFloat(); - renderY = dataStream.readInt(); - - if(structured != prev) - { - inputTank.setCapacity(getMaxFluid()); - worldObj.func_147479_m(xCoord, yCoord, zCoord); - - if(structured) - { - Mekanism.proxy.doGenericSparkle(this, new INodeChecker() { - @Override - public boolean isNode(TileEntity tile) - { - return tile instanceof TileEntityThermalEvaporationBlock; - } - }); - } - } - - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } - - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); - - if(inputTank.getFluid() != null) - { - data.add(true); - data.add(inputTank.getFluid().getFluidID()); - data.add(inputTank.getFluid().amount); - } - else { - data.add(false); - } - - if(outputTank.getFluid() != null) - { - data.add(true); - data.add(outputTank.getFluid().getFluidID()); - data.add(outputTank.getFluid().amount); - } - else { - data.add(false); - } - - data.add(structured); - data.add(controllerConflict); - data.add(getActiveSolars()); - data.add(height); - data.add(temperature); - data.add(biomeTemp); - data.add(isLeftOnFace); - data.add(lastGain); - data.add(totalLoss); - data.add(renderY); - - return data; - } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { + if (ticker == 5) { + refresh(); + } + + if (structured) { + updateTemperature(); + } + + manageBuckets(); + + ThermalEvaporationRecipe recipe = getRecipe(); + + if (canOperate(recipe)) { + int outputNeeded = outputTank.getCapacity() - outputTank.getFluidAmount(); + int inputStored = inputTank.getFluidAmount(); + double outputRatio = (double) recipe.recipeOutput.output.amount + / (double) recipe.recipeInput.ingredient.amount; + + double tempMult + = Math.max(0, getTemperature()) * general.evaporationTempMultiplier; + double inputToUse = (tempMult * recipe.recipeInput.ingredient.amount) + * ((float) height / (float) MAX_HEIGHT); + inputToUse = Math.min(inputTank.getFluidAmount(), inputToUse); + inputToUse = Math.min(inputToUse, outputNeeded / outputRatio); + + lastGain + = (float) inputToUse / (float) recipe.recipeInput.ingredient.amount; + partialInput += inputToUse; + + if (partialInput >= 1) { + int inputInt = (int) Math.floor(partialInput); + inputTank.drain(inputInt, true); + partialInput %= 1; + partialOutput + += ((double) inputInt) / recipe.recipeInput.ingredient.amount; + } + + if (partialOutput >= 1) { + int outputInt = (int) Math.floor(partialOutput); + outputTank.fill( + new FluidStack(recipe.recipeOutput.output.getFluid(), outputInt), + true + ); + partialOutput %= 1; + } + } else { + lastGain = 0; + } + + if (structured) { + if (Math.abs( + (float) inputTank.getFluidAmount() / inputTank.getCapacity() + - prevScale + ) + > 0.01) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + prevScale + = (float) inputTank.getFluidAmount() / inputTank.getCapacity(); + } + } + } + } + + public ThermalEvaporationRecipe getRecipe() { + return RecipeHandler.getThermalEvaporationRecipe( + new FluidInput(inputTank.getFluid()) + ); + } + + @Override + public void onChunkUnload() { + super.onChunkUnload(); + + refresh(); + } + + @Override + public void onNeighborChange(Block block) { + super.onNeighborChange(block); + + refresh(); + } + + public boolean hasRecipe(Fluid fluid) { + if (fluid == null) { + return false; + } + + return Recipe.THERMAL_EVAPORATION_PLANT.containsRecipe(fluid); + } + + protected void refresh() { + if (!worldObj.isRemote) { + if (!updatedThisTick) { + boolean prev = structured; + + clearStructure(); + structured = buildStructure(); + + if (structured != prev) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + } + + if (structured) { + inputTank.setCapacity(getMaxFluid()); + + if (inputTank.getFluid() != null) { + inputTank.getFluid().amount + = Math.min(inputTank.getFluid().amount, getMaxFluid()); + } + } else { + clearStructure(); + } + } + } + } + + public boolean canOperate(ThermalEvaporationRecipe recipe) { + if (!structured || height < 3 || height > MAX_HEIGHT + || inputTank.getFluid() == null) { + return false; + } + + if (recipe != null && recipe.canOperate(inputTank, outputTank)) { + return true; + } + + return false; + } + + private void manageBuckets() { + if (inventory[2] != null && outputTank.getFluid() != null) { + if (inventory[2].getItem() instanceof IFluidContainerItem) { + FluidContainerUtils.handleContainerItemFill(this, outputTank, 2, 3); + } else if (FluidContainerRegistry.isEmptyContainer(inventory[2])) { + FluidContainerUtils.handleRegistryItemFill(this, outputTank, 2, 3); + } + } + + if (structured) { + if (inventory[0] != null) { + if (inventory[0].getItem() instanceof IFluidContainerItem) { + FluidContainerUtils.handleContainerItemEmpty( + this, + inputTank, + 0, + 1, + new FluidChecker() { + @Override + public boolean isValid(Fluid f) { + return hasRecipe(f); + } + } + ); + } else if (FluidContainerRegistry.isFilledContainer(inventory[0])) { + FluidContainerUtils.handleRegistryItemEmpty( + this, + inputTank, + 0, + 1, + new FluidChecker() { + @Override + public boolean isValid(Fluid f) { + return hasRecipe(f); + } + } + ); + } + } + } + } + + private void updateTemperature() { + if (!temperatureSet) { + biomeTemp = worldObj.getBiomeGenForCoordsBody(xCoord, zCoord) + .getFloatTemperature(xCoord, yCoord, zCoord); + temperatureSet = true; + } + + heatToAbsorb += getActiveSolars() * general.evaporationSolarMultiplier; + temperature += heatToAbsorb / (float) height; + + float biome = biomeTemp - 0.5F; + float base = biome > 0 ? biome * 20 : biomeTemp * 40; + + if (Math.abs(temperature - base) < 0.001) { + temperature = base; + } + + float incr = (float) Math.sqrt(Math.abs(temperature - base)) + * (float) general.evaporationHeatDissipation; + + if (temperature > base) { + incr = -incr; + } + + float prev = temperature; + temperature = (float + ) Math.min(general.evaporationMaxTemp, temperature + incr / (float) height); + + if (incr < 0) { + totalLoss = prev - temperature; + } else { + totalLoss = 0; + } + + heatToAbsorb = 0; + + MekanismUtils.saveChunk(this); + } + + public float getTemperature() { + return temperature; + } + + public int getActiveSolars() { + if (worldObj.isRemote) { + return clientSolarAmount; + } + + int ret = 0; + + for (IEvaporationSolar solar : solars) { + if (solar != null && solar.seesSun()) { + ret++; + } + } + + return ret; + } + + public boolean buildStructure() { + ForgeDirection right = MekanismUtils.getRight(facing); + ForgeDirection left = MekanismUtils.getLeft(facing); + + height = 0; + controllerConflict = false; + updatedThisTick = true; + + Coord4D startPoint = Coord4D.get(this); + + while (startPoint.getFromSide(ForgeDirection.UP).getTileEntity(worldObj) + instanceof TileEntityThermalEvaporationBlock) { + startPoint.step(ForgeDirection.UP); + } + + Coord4D test = startPoint.getFromSide(ForgeDirection.DOWN).getFromSide(right, 2); + isLeftOnFace + = test.getTileEntity(worldObj) instanceof TileEntityThermalEvaporationBlock; + + startPoint = startPoint.getFromSide(left, isLeftOnFace ? 1 : 2); + + if (!scanTopLayer(startPoint)) { + return false; + } + + height = 1; + + Coord4D middlePointer = startPoint.getFromSide(ForgeDirection.DOWN); + + while (scanLowerLayer(middlePointer)) { + middlePointer = middlePointer.getFromSide(ForgeDirection.DOWN); + } + + renderY = middlePointer.yCoord + 1; + + if (height < 3 || height > MAX_HEIGHT) { + height = 0; + return false; + } + + structured = true; + + markDirty(); + + return true; + } + + public boolean scanTopLayer(Coord4D current) { + ForgeDirection right = MekanismUtils.getRight(facing); + ForgeDirection back = MekanismUtils.getBack(facing); + + for (int x = 0; x < 4; x++) { + for (int z = 0; z < 4; z++) { + Coord4D pointer = current.getFromSide(right, x).getFromSide(back, z); + TileEntity pointerTile = pointer.getTileEntity(worldObj); + + int corner = getCorner(x, z); + + if (corner != -1) { + if (addSolarPanel(pointer.getTileEntity(worldObj), corner)) { + continue; + } else if (pointer.getFromSide(ForgeDirection.UP).getTileEntity(worldObj) instanceof TileEntityThermalEvaporationBlock || !addTankPart(pointerTile)) { + return false; + } + } else { + if ((x == 1 || x == 2) && (z == 1 || z == 2)) { + if (!pointer.isAirBlock(worldObj)) { + return false; + } + } else { + if (pointer.getFromSide(ForgeDirection.UP).getTileEntity(worldObj) + instanceof TileEntityThermalEvaporationBlock + || !addTankPart(pointerTile)) { + return false; + } + } + } + } + } + + return true; + } + + public int getMaxFluid() { + return height * 4 * TankUpdateProtocol.FLUID_PER_TANK; + } + + public int getCorner(int x, int z) { + if (x == 0 && z == 0) { + return 0; + } else if (x == 0 && z == 3) { + return 1; + } else if (x == 3 && z == 0) { + return 2; + } else if (x == 3 && z == 3) { + return 3; + } + + return -1; + } + + public boolean scanLowerLayer(Coord4D current) { + ForgeDirection right = MekanismUtils.getRight(facing); + ForgeDirection back = MekanismUtils.getBack(facing); + + boolean foundCenter = false; + + for (int x = 0; x < 4; x++) { + for (int z = 0; z < 4; z++) { + Coord4D pointer = current.getFromSide(right, x).getFromSide(back, z); + TileEntity pointerTile = pointer.getTileEntity(worldObj); + + if ((x == 1 || x == 2) && (z == 1 || z == 2)) { + if (pointerTile instanceof TileEntityThermalEvaporationBlock) { + if (!foundCenter) { + if (x == 1 && z == 1) { + foundCenter = true; + } else { + height = -1; + return false; + } + } + } else { + if (foundCenter || !pointer.isAirBlock(worldObj)) { + height = -1; + return false; + } + } + } else { + if (!addTankPart(pointerTile)) { + height = -1; + return false; + } + } + } + } + + height++; + + return !foundCenter; + } + + public boolean addTankPart(TileEntity tile) { + if (tile instanceof TileEntityThermalEvaporationBlock + && (tile == this || !(tile instanceof TileEntityThermalEvaporationController) + )) { + if (tile != this) { + ((TileEntityThermalEvaporationBlock) tile) + .addToStructure(Coord4D.get(this)); + tankParts.add(Coord4D.get(tile)); + } + + return true; + } else { + if (tile != this && tile instanceof TileEntityThermalEvaporationController) { + controllerConflict = true; + } + + return false; + } + } + + public boolean addSolarPanel(TileEntity tile, int i) { + if (tile instanceof IEvaporationSolar && !tile.isInvalid()) { + solars[i] = (IEvaporationSolar) tile; + return true; + } else { + return false; + } + } + + public int getScaledInputLevel(int i) { + return getMaxFluid() > 0 + ? (inputTank.getFluid() != null + ? inputTank.getFluid().amount * i / getMaxFluid() + : 0) + : 0; + } + + public int getScaledOutputLevel(int i) { + return outputTank.getFluid() != null + ? outputTank.getFluid().amount * i / MAX_OUTPUT + : 0; + } + + public int getScaledTempLevel(int i) { + return (int) (i * Math.min(1, getTemperature() / general.evaporationMaxTemp)); + } + + public Coord4D getRenderLocation() { + if (!structured) { + return null; + } + + ForgeDirection right = MekanismUtils.getRight(facing); + Coord4D startPoint = Coord4D.get(this).getFromSide(right); + startPoint = isLeftOnFace ? startPoint.getFromSide(right) : startPoint; + + startPoint = startPoint.getFromSide(right.getOpposite()) + .getFromSide(MekanismUtils.getBack(facing)); + startPoint.yCoord = renderY; + + return startPoint; + } + + @Override + public void handlePacketData(ByteBuf dataStream) { + super.handlePacketData(dataStream); + + if (worldObj.isRemote) { + if (dataStream.readBoolean()) { + inputTank.setFluid( + new FluidStack(dataStream.readInt(), dataStream.readInt()) + ); + } else { + inputTank.setFluid(null); + } + + if (dataStream.readBoolean()) { + outputTank.setFluid( + new FluidStack(dataStream.readInt(), dataStream.readInt()) + ); + } else { + outputTank.setFluid(null); + } + + boolean prev = structured; + + structured = dataStream.readBoolean(); + controllerConflict = dataStream.readBoolean(); + clientSolarAmount = dataStream.readInt(); + height = dataStream.readInt(); + temperature = dataStream.readFloat(); + biomeTemp = dataStream.readFloat(); + isLeftOnFace = dataStream.readBoolean(); + lastGain = dataStream.readFloat(); + totalLoss = dataStream.readFloat(); + renderY = dataStream.readInt(); + + if (structured != prev) { + inputTank.setCapacity(getMaxFluid()); + worldObj.func_147479_m(xCoord, yCoord, zCoord); + + if (structured) { + Mekanism.proxy.doGenericSparkle(this, new INodeChecker() { + @Override + public boolean isNode(TileEntity tile) { + return tile instanceof TileEntityThermalEvaporationBlock; + } + }); + } + } + + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } + + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); + + if (inputTank.getFluid() != null) { + data.add(true); + data.add(inputTank.getFluid().getFluidID()); + data.add(inputTank.getFluid().amount); + } else { + data.add(false); + } + + if (outputTank.getFluid() != null) { + data.add(true); + data.add(outputTank.getFluid().getFluidID()); + data.add(outputTank.getFluid().amount); + } else { + data.add(false); + } + + data.add(structured); + data.add(controllerConflict); + data.add(getActiveSolars()); + data.add(height); + data.add(temperature); + data.add(biomeTemp); + data.add(isLeftOnFace); + data.add(lastGain); + data.add(totalLoss); + data.add(renderY); + + return data; + } + + @Override + public void readFromNBT(NBTTagCompound nbtTags) { super.readFromNBT(nbtTags); inputTank.readFromNBT(nbtTags.getCompoundTag("waterTank")); outputTank.readFromNBT(nbtTags.getCompoundTag("brineTank")); - + temperature = nbtTags.getFloat("temperature"); - + partialInput = nbtTags.getDouble("partialWater"); partialOutput = nbtTags.getDouble("partialBrine"); } - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { + @Override + public void writeToNBT(NBTTagCompound nbtTags) { super.writeToNBT(nbtTags); - + nbtTags.setTag("waterTank", inputTank.writeToNBT(new NBTTagCompound())); nbtTags.setTag("brineTank", outputTank.writeToNBT(new NBTTagCompound())); - + nbtTags.setFloat("temperature", temperature); - + nbtTags.setDouble("partialWater", partialInput); nbtTags.setDouble("partialBrine", partialOutput); } - - @Override - public boolean canSetFacing(int side) - { - return side != 0 && side != 1; - } - - @Override - public TileEntityThermalEvaporationController getController() - { - return structured ? this : null; - } - public void clearStructure() - { - for(Coord4D tankPart : tankParts) - { - TileEntity tile = tankPart.getTileEntity(worldObj); - - if(tile instanceof TileEntityThermalEvaporationBlock) - { - ((TileEntityThermalEvaporationBlock)tile).controllerGone(); - } - } - - tankParts.clear(); - solars = new IEvaporationSolar[] {null, null, null, null}; - } - - @Override - @SideOnly(Side.CLIENT) - public AxisAlignedBB getRenderBoundingBox() - { - return INFINITE_EXTENT_AABB; - } + @Override + public boolean canSetFacing(int side) { + return side != 0 && side != 1; + } - @Override - public boolean getActive() - { - return structured; - } + @Override + public TileEntityThermalEvaporationController getController() { + return structured ? this : null; + } - @Override - public void setActive(boolean active) {} + public void clearStructure() { + for (Coord4D tankPart : tankParts) { + TileEntity tile = tankPart.getTileEntity(worldObj); - @Override - public boolean renderUpdate() - { - return true; - } + if (tile instanceof TileEntityThermalEvaporationBlock) { + ((TileEntityThermalEvaporationBlock) tile).controllerGone(); + } + } - @Override - public boolean lightUpdate() - { - return false; - } - - @Override - public Object[] getTanks() - { - return new Object[] {inputTank, outputTank}; - } + tankParts.clear(); + solars = new IEvaporationSolar[] { null, null, null, null }; + } + + @Override + @SideOnly(Side.CLIENT) + public AxisAlignedBB getRenderBoundingBox() { + return INFINITE_EXTENT_AABB; + } + + @Override + public boolean getActive() { + return structured; + } + + @Override + public void setActive(boolean active) {} + + @Override + public boolean renderUpdate() { + return true; + } + + @Override + public boolean lightUpdate() { + return false; + } + + @Override + public Object[] getTanks() { + return new Object[] { inputTank, outputTank }; + } } diff --git a/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationValve.java b/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationValve.java index 861f801ea..ceb12be39 100644 --- a/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationValve.java +++ b/src/main/java/mekanism/common/tile/TileEntityThermalEvaporationValve.java @@ -9,144 +9,136 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; -public class TileEntityThermalEvaporationValve extends TileEntityThermalEvaporationBlock implements IFluidHandler, IHeatTransfer -{ - public boolean prevMaster = false; - - @Override - public void onUpdate() - { - super.onUpdate(); - - if(!worldObj.isRemote) - { - if((master != null) != prevMaster) - { - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - Coord4D obj = Coord4D.get(this).getFromSide(side); +public class TileEntityThermalEvaporationValve + extends TileEntityThermalEvaporationBlock implements IFluidHandler, IHeatTransfer { + public boolean prevMaster = false; - if(!obj.isAirBlock(worldObj) && !(obj.getTileEntity(worldObj) instanceof TileEntityThermalEvaporationBlock)) - { - obj.getBlock(worldObj).onNeighborChange(worldObj, obj.xCoord, obj.yCoord, obj.zCoord, xCoord, yCoord, zCoord); - } - } - } - - prevMaster = (master != null); - } - } - - @Override - public int fill(ForgeDirection from, FluidStack resource, boolean doFill) - { - TileEntityThermalEvaporationController controller = getController(); - return controller == null ? 0 : controller.inputTank.fill(resource, doFill); - } + @Override + public void onUpdate() { + super.onUpdate(); - @Override - public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) - { - TileEntityThermalEvaporationController controller = getController(); - - if(controller != null && (resource == null || resource.isFluidEqual(controller.outputTank.getFluid()))) - { - return controller.outputTank.drain(resource.amount, doDrain); - } + if (!worldObj.isRemote) { + if ((master != null) != prevMaster) { + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + Coord4D obj = Coord4D.get(this).getFromSide(side); - return null; - } + if (!obj.isAirBlock(worldObj) + && !( + obj.getTileEntity(worldObj) + instanceof TileEntityThermalEvaporationBlock + )) { + obj.getBlock(worldObj).onNeighborChange( + worldObj, + obj.xCoord, + obj.yCoord, + obj.zCoord, + xCoord, + yCoord, + zCoord + ); + } + } + } - @Override - public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) - { - TileEntityThermalEvaporationController controller = getController(); - - if(controller != null) - { - return controller.outputTank.drain(maxDrain, doDrain); - } + prevMaster = (master != null); + } + } - return null; - } + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { + TileEntityThermalEvaporationController controller = getController(); + return controller == null ? 0 : controller.inputTank.fill(resource, doFill); + } - @Override - public boolean canFill(ForgeDirection from, Fluid fluid) - { - TileEntityThermalEvaporationController controller = getController(); - return controller != null && controller.hasRecipe(fluid); - } + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + TileEntityThermalEvaporationController controller = getController(); - @Override - public boolean canDrain(ForgeDirection from, Fluid fluid) - { - TileEntityThermalEvaporationController controller = getController(); - return controller != null && controller.outputTank.getFluidAmount() > 0; - } + if (controller != null + && (resource == null + || resource.isFluidEqual(controller.outputTank.getFluid()))) { + return controller.outputTank.drain(resource.amount, doDrain); + } - @Override - public FluidTankInfo[] getTankInfo(ForgeDirection from) - { - TileEntityThermalEvaporationController controller = getController(); - - if(controller == null) - { - return PipeUtils.EMPTY; - } + return null; + } - return new FluidTankInfo[] {new FluidTankInfo(controller.inputTank), new FluidTankInfo(controller.outputTank)}; - } + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { + TileEntityThermalEvaporationController controller = getController(); - @Override - public double getTemp() - { - return 0; - } + if (controller != null) { + return controller.outputTank.drain(maxDrain, doDrain); + } - @Override - public double getInverseConductionCoefficient() - { - return 1; - } + return null; + } - @Override - public double getInsulationCoefficient(ForgeDirection side) - { - return 0; - } + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + TileEntityThermalEvaporationController controller = getController(); + return controller != null && controller.hasRecipe(fluid); + } - @Override - public void transferHeatTo(double heat) - { - TileEntityThermalEvaporationController controller = getController(); - - if(controller != null) - { - controller.heatToAbsorb += heat; - } - } + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + TileEntityThermalEvaporationController controller = getController(); + return controller != null && controller.outputTank.getFluidAmount() > 0; + } - @Override - public double[] simulateHeat() - { - return new double[] {0, 0}; - } + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection from) { + TileEntityThermalEvaporationController controller = getController(); - @Override - public double applyTemperatureChange() - { - return 0; - } + if (controller == null) { + return PipeUtils.EMPTY; + } - @Override - public boolean canConnectHeat(ForgeDirection side) - { - return getController() != null; - } + return new FluidTankInfo[] { new FluidTankInfo(controller.inputTank), + new FluidTankInfo(controller.outputTank) }; + } - @Override - public IHeatTransfer getAdjacent(ForgeDirection side) - { - return null; - } + @Override + public double getTemp() { + return 0; + } + + @Override + public double getInverseConductionCoefficient() { + return 1; + } + + @Override + public double getInsulationCoefficient(ForgeDirection side) { + return 0; + } + + @Override + public void transferHeatTo(double heat) { + TileEntityThermalEvaporationController controller = getController(); + + if (controller != null) { + controller.heatToAbsorb += heat; + } + } + + @Override + public double[] simulateHeat() { + return new double[] { 0, 0 }; + } + + @Override + public double applyTemperatureChange() { + return 0; + } + + @Override + public boolean canConnectHeat(ForgeDirection side) { + return getController() != null; + } + + @Override + public IHeatTransfer getAdjacent(ForgeDirection side) { + return null; + } } diff --git a/src/main/java/mekanism/common/tile/component/TileComponentAdvancedUpgrade.java b/src/main/java/mekanism/common/tile/component/TileComponentAdvancedUpgrade.java index ead2bb703..5583ccaa5 100644 --- a/src/main/java/mekanism/common/tile/component/TileComponentAdvancedUpgrade.java +++ b/src/main/java/mekanism/common/tile/component/TileComponentAdvancedUpgrade.java @@ -3,12 +3,10 @@ package mekanism.common.tile.component; import mekanism.common.Upgrade; import mekanism.common.tile.TileEntityContainerBlock; -public class TileComponentAdvancedUpgrade extends TileComponentUpgrade -{ - public TileComponentAdvancedUpgrade(TileEntityContainerBlock tile, int slot) - { - super(tile, slot); +public class TileComponentAdvancedUpgrade extends TileComponentUpgrade { + public TileComponentAdvancedUpgrade(TileEntityContainerBlock tile, int slot) { + super(tile, slot); - setSupported(Upgrade.GAS); - } + setSupported(Upgrade.GAS); + } } diff --git a/src/main/java/mekanism/common/tile/component/TileComponentConfig.java b/src/main/java/mekanism/common/tile/component/TileComponentConfig.java index 2f3124944..246f06a7c 100644 --- a/src/main/java/mekanism/common/tile/component/TileComponentConfig.java +++ b/src/main/java/mekanism/common/tile/component/TileComponentConfig.java @@ -1,13 +1,12 @@ package mekanism.common.tile.component; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.EnumSet; import java.util.HashMap; import java.util.List; import java.util.Map; +import io.netty.buffer.ByteBuf; import mekanism.api.EnumColor; import mekanism.api.transmitters.TransmissionType; import mekanism.common.SideData; @@ -19,230 +18,204 @@ import mekanism.common.util.MekanismUtils; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; -public class TileComponentConfig implements ITileComponent -{ - public static SideData EMPTY = new SideData("Empty", EnumColor.BLACK, InventoryUtils.EMPTY); - - public TileEntityContainerBlock tileEntity; - - public Map sideConfigs = new HashMap(); - public Map> sideOutputs = new HashMap>(); - public Map ejecting = new HashMap(); - public Map canEject = new HashMap(); - - public List transmissions = new ArrayList(); - - public TileComponentConfig(TileEntityContainerBlock tile, TransmissionType... types) - { - tileEntity = tile; - - for(TransmissionType type : types) - { - addSupported(type); - } - - tile.components.add(this); - } - - public void readFrom(TileComponentConfig config) - { - sideConfigs = config.sideConfigs; - ejecting = config.ejecting; - canEject = config.canEject; - transmissions = config.transmissions; - } - - public void addSupported(TransmissionType type) - { - if(!transmissions.contains(type)) - { - transmissions.add(type); - } - - sideOutputs.put(type.ordinal(), new ArrayList()); - ejecting.put(type.ordinal(), false); - canEject.put(type.ordinal(), true); - } - - public EnumSet getSidesForData(TransmissionType type, int facing, int dataIndex) - { - EnumSet ret = EnumSet.noneOf(ForgeDirection.class); - - for(byte b = 0; b < 6; b++) - { - int side = MekanismUtils.getBaseOrientation(b, facing); - - if(getConfig(type)[side] == dataIndex) - { - ret.add(ForgeDirection.getOrientation(b)); - } - } - - return ret; - } - - public void setCanEject(TransmissionType type, boolean eject) - { - canEject.put(type.ordinal(), eject); - } - - public boolean canEject(TransmissionType type) - { - return canEject.get(type.ordinal()); - } - - public void fillConfig(TransmissionType type, int data) - { - byte sideData = (byte)data; - - setConfig(type, new byte[] {sideData, sideData, sideData, sideData, sideData, sideData}); - } - - public void setIOConfig(TransmissionType type) - { - addOutput(type, new SideData("None", EnumColor.GREY, IOState.OFF)); - addOutput(type, new SideData("Input", EnumColor.DARK_GREEN, IOState.INPUT)); - addOutput(type, new SideData("Output", EnumColor.DARK_RED, IOState.OUTPUT)); - - setConfig(type, new byte[] {1, 1, 2, 1, 1, 1}); - } - - public void setInputConfig(TransmissionType type) - { - addOutput(type, new SideData("None", EnumColor.GREY, IOState.OFF)); - addOutput(type, new SideData("Input", EnumColor.DARK_GREEN, IOState.INPUT)); - - fillConfig(type, 1); - setCanEject(type, false); - } - - public void setConfig(TransmissionType type, byte[] config) - { - sideConfigs.put(type.ordinal(), config); - } - - public void addOutput(TransmissionType type, SideData data) - { - sideOutputs.get(type.ordinal()).add(data); - } - - public ArrayList getOutputs(TransmissionType type) - { - return sideOutputs.get(type.ordinal()); - } - - public byte[] getConfig(TransmissionType type) - { - return sideConfigs.get(type.ordinal()); - } - - public SideData getOutput(TransmissionType type, int side, int facing) - { - return getOutput(type, MekanismUtils.getBaseOrientation(side, facing)); - } - - public SideData getOutput(TransmissionType type, int side) - { - int index = getConfig(type)[side]; - - if(index == -1) - { - return EMPTY; - } - else if(index > getOutputs(type).size()-1) - { - index = getConfig(type)[side] = 0; - } - - return getOutputs(type).get(index); - } - - public boolean supports(TransmissionType type) - { - return transmissions.contains(type); - } - - @Override - public void tick() {} +public class TileComponentConfig implements ITileComponent { + public static SideData EMPTY + = new SideData("Empty", EnumColor.BLACK, InventoryUtils.EMPTY); - @Override - public void read(NBTTagCompound nbtTags) - { - if(nbtTags.getBoolean("sideDataStored")) - { - for(TransmissionType type : transmissions) - { - if(nbtTags.getByteArray("config" + type.ordinal()).length > 0) - { - sideConfigs.put(type.ordinal(), nbtTags.getByteArray("config" + type.ordinal())); - ejecting.put(type.ordinal(), nbtTags.getBoolean("ejecting" + type.ordinal())); - } - } - } - } + public TileEntityContainerBlock tileEntity; - @Override - public void read(ByteBuf dataStream) - { - transmissions.clear(); - - int amount = dataStream.readInt(); - - for(int i = 0; i < amount; i++) - { - transmissions.add(TransmissionType.values()[dataStream.readInt()]); - } - - for(TransmissionType type : transmissions) - { - byte[] array = new byte[6]; - dataStream.readBytes(array); - - sideConfigs.put(type.ordinal(), array); - ejecting.put(type.ordinal(), dataStream.readBoolean()); - } - } + public Map sideConfigs = new HashMap(); + public Map> sideOutputs + = new HashMap>(); + public Map ejecting = new HashMap(); + public Map canEject = new HashMap(); - @Override - public void write(NBTTagCompound nbtTags) - { - for(TransmissionType type : transmissions) - { - nbtTags.setByteArray("config" + type.ordinal(), sideConfigs.get(type.ordinal())); - nbtTags.setBoolean("ejecting" + type.ordinal(), ejecting.get(type.ordinal())); - } - - nbtTags.setBoolean("sideDataStored", true); - } + public List transmissions = new ArrayList(); - @Override - public void write(ArrayList data) - { - data.add(transmissions.size()); - - for(TransmissionType type : transmissions) - { - data.add(type.ordinal()); - } - - for(TransmissionType type : transmissions) - { - data.add(sideConfigs.get(type.ordinal())); - data.add(ejecting.get(type.ordinal())); - } - } - - @Override - public void invalidate() {} - - public boolean isEjecting(TransmissionType type) - { - return ejecting.get(type.ordinal()); - } + public TileComponentConfig(TileEntityContainerBlock tile, TransmissionType... types) { + tileEntity = tile; - public void setEjecting(TransmissionType type, boolean eject) - { - ejecting.put(type.ordinal(), eject); - MekanismUtils.saveChunk(tileEntity); - } + for (TransmissionType type : types) { + addSupported(type); + } + + tile.components.add(this); + } + + public void readFrom(TileComponentConfig config) { + sideConfigs = config.sideConfigs; + ejecting = config.ejecting; + canEject = config.canEject; + transmissions = config.transmissions; + } + + public void addSupported(TransmissionType type) { + if (!transmissions.contains(type)) { + transmissions.add(type); + } + + sideOutputs.put(type.ordinal(), new ArrayList()); + ejecting.put(type.ordinal(), false); + canEject.put(type.ordinal(), true); + } + + public EnumSet + getSidesForData(TransmissionType type, int facing, int dataIndex) { + EnumSet ret = EnumSet.noneOf(ForgeDirection.class); + + for (byte b = 0; b < 6; b++) { + int side = MekanismUtils.getBaseOrientation(b, facing); + + if (getConfig(type)[side] == dataIndex) { + ret.add(ForgeDirection.getOrientation(b)); + } + } + + return ret; + } + + public void setCanEject(TransmissionType type, boolean eject) { + canEject.put(type.ordinal(), eject); + } + + public boolean canEject(TransmissionType type) { + return canEject.get(type.ordinal()); + } + + public void fillConfig(TransmissionType type, int data) { + byte sideData = (byte) data; + + setConfig( + type, + new byte[] { sideData, sideData, sideData, sideData, sideData, sideData } + ); + } + + public void setIOConfig(TransmissionType type) { + addOutput(type, new SideData("None", EnumColor.GREY, IOState.OFF)); + addOutput(type, new SideData("Input", EnumColor.DARK_GREEN, IOState.INPUT)); + addOutput(type, new SideData("Output", EnumColor.DARK_RED, IOState.OUTPUT)); + + setConfig(type, new byte[] { 1, 1, 2, 1, 1, 1 }); + } + + public void setInputConfig(TransmissionType type) { + addOutput(type, new SideData("None", EnumColor.GREY, IOState.OFF)); + addOutput(type, new SideData("Input", EnumColor.DARK_GREEN, IOState.INPUT)); + + fillConfig(type, 1); + setCanEject(type, false); + } + + public void setConfig(TransmissionType type, byte[] config) { + sideConfigs.put(type.ordinal(), config); + } + + public void addOutput(TransmissionType type, SideData data) { + sideOutputs.get(type.ordinal()).add(data); + } + + public ArrayList getOutputs(TransmissionType type) { + return sideOutputs.get(type.ordinal()); + } + + public byte[] getConfig(TransmissionType type) { + return sideConfigs.get(type.ordinal()); + } + + public SideData getOutput(TransmissionType type, int side, int facing) { + return getOutput(type, MekanismUtils.getBaseOrientation(side, facing)); + } + + public SideData getOutput(TransmissionType type, int side) { + int index = getConfig(type)[side]; + + if (index == -1) { + return EMPTY; + } else if (index > getOutputs(type).size() - 1) { + index = getConfig(type)[side] = 0; + } + + return getOutputs(type).get(index); + } + + public boolean supports(TransmissionType type) { + return transmissions.contains(type); + } + + @Override + public void tick() {} + + @Override + public void read(NBTTagCompound nbtTags) { + if (nbtTags.getBoolean("sideDataStored")) { + for (TransmissionType type : transmissions) { + if (nbtTags.getByteArray("config" + type.ordinal()).length > 0) { + sideConfigs.put( + type.ordinal(), nbtTags.getByteArray("config" + type.ordinal()) + ); + ejecting.put( + type.ordinal(), nbtTags.getBoolean("ejecting" + type.ordinal()) + ); + } + } + } + } + + @Override + public void read(ByteBuf dataStream) { + transmissions.clear(); + + int amount = dataStream.readInt(); + + for (int i = 0; i < amount; i++) { + transmissions.add(TransmissionType.values()[dataStream.readInt()]); + } + + for (TransmissionType type : transmissions) { + byte[] array = new byte[6]; + dataStream.readBytes(array); + + sideConfigs.put(type.ordinal(), array); + ejecting.put(type.ordinal(), dataStream.readBoolean()); + } + } + + @Override + public void write(NBTTagCompound nbtTags) { + for (TransmissionType type : transmissions) { + nbtTags.setByteArray( + "config" + type.ordinal(), sideConfigs.get(type.ordinal()) + ); + nbtTags.setBoolean("ejecting" + type.ordinal(), ejecting.get(type.ordinal())); + } + + nbtTags.setBoolean("sideDataStored", true); + } + + @Override + public void write(ArrayList data) { + data.add(transmissions.size()); + + for (TransmissionType type : transmissions) { + data.add(type.ordinal()); + } + + for (TransmissionType type : transmissions) { + data.add(sideConfigs.get(type.ordinal())); + data.add(ejecting.get(type.ordinal())); + } + } + + @Override + public void invalidate() {} + + public boolean isEjecting(TransmissionType type) { + return ejecting.get(type.ordinal()); + } + + public void setEjecting(TransmissionType type, boolean eject) { + ejecting.put(type.ordinal(), eject); + MekanismUtils.saveChunk(tileEntity); + } } diff --git a/src/main/java/mekanism/common/tile/component/TileComponentEjector.java b/src/main/java/mekanism/common/tile/component/TileComponentEjector.java index 8cb9418c0..371440fb7 100644 --- a/src/main/java/mekanism/common/tile/component/TileComponentEjector.java +++ b/src/main/java/mekanism/common/tile/component/TileComponentEjector.java @@ -1,12 +1,11 @@ package mekanism.common.tile.component; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.gas.GasStack; @@ -32,355 +31,324 @@ import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; -public class TileComponentEjector implements ITileComponent -{ - public TileEntityContainerBlock tileEntity; +public class TileComponentEjector implements ITileComponent { + public TileEntityContainerBlock tileEntity; - public boolean strictInput; + public boolean strictInput; - public EnumColor outputColor; + public EnumColor outputColor; - public EnumColor[] inputColors = new EnumColor[] {null, null, null, null, null, null}; + public EnumColor[] inputColors + = new EnumColor[] { null, null, null, null, null, null }; - public int tickDelay = 0; + public int tickDelay = 0; - public Map sideData = new HashMap(); + public Map sideData + = new HashMap(); - public Map trackers = new HashMap(); - - public static final int GAS_OUTPUT = 256; - public static final int FLUID_OUTPUT = 256; + public Map trackers = new HashMap(); - public TileComponentEjector(TileEntityContainerBlock tile) - { - tileEntity = tile; + public static final int GAS_OUTPUT = 256; + public static final int FLUID_OUTPUT = 256; - tile.components.add(this); - } - - public TileComponentEjector setOutputData(TransmissionType type, SideData data) - { - sideData.put(type, data); - trackers.put(type, new int[data.availableSlots.length]); - - return this; - } - - public void readFrom(TileComponentEjector ejector) - { - strictInput = ejector.strictInput; - outputColor = ejector.outputColor; - inputColors = ejector.inputColors; - tickDelay = ejector.tickDelay; - sideData = ejector.sideData; - } + public TileComponentEjector(TileEntityContainerBlock tile) { + tileEntity = tile; - private List getTrackedOutputs(TransmissionType type, int index, List dirs) - { - List sides = new ArrayList(); + tile.components.add(this); + } - for(int i = trackers.get(type)[index]+1; i <= trackers.get(type)[index]+6; i++) - { - for(ForgeDirection side : dirs) - { - if(ForgeDirection.getOrientation(i%6) == side) - { - sides.add(side); - } - } - } + public TileComponentEjector setOutputData(TransmissionType type, SideData data) { + sideData.put(type, data); + trackers.put(type, new int[data.availableSlots.length]); - return sides; - } + return this; + } - @Override - public void tick() - { - if(tickDelay == 0) - { - if(sideData.get(TransmissionType.ITEM) != null) - { - outputItems(); - } - } - else { - tickDelay--; - } - - if(!tileEntity.getWorldObj().isRemote) - { - if(sideData.get(TransmissionType.GAS) != null && getEjecting(TransmissionType.GAS)) - { - SideData data = sideData.get(TransmissionType.GAS); - List outputSides = getOutputSides(TransmissionType.GAS, data); - - if(((ITankManager)tileEntity).getTanks() != null) - { - GasTank tank = (GasTank)((ITankManager)tileEntity).getTanks()[data.availableSlots[0]]; - - if(tank.getStored() > 0) - { - GasStack toEmit = tank.getGas().copy().withAmount(Math.min(GAS_OUTPUT, tank.getStored())); - int emit = GasTransmission.emit(toEmit, tileEntity, outputSides); - tank.draw(emit, true); - } - } - } - - if(sideData.get(TransmissionType.FLUID) != null && getEjecting(TransmissionType.FLUID)) - { - SideData data = sideData.get(TransmissionType.FLUID); - List outputSides = getOutputSides(TransmissionType.FLUID, data); - - if(((ITankManager)tileEntity).getTanks() != null) - { - FluidTank tank = (FluidTank)((ITankManager)tileEntity).getTanks()[data.availableSlots[0]]; - - if(tank.getFluidAmount() > 0) - { - FluidStack toEmit = PipeUtils.copy(tank.getFluid(), Math.min(FLUID_OUTPUT, tank.getFluidAmount())); - int emit = PipeUtils.emit(outputSides, toEmit, tileEntity); - tank.drain(emit, true); - } - } - } - } - } - - public List getOutputSides(TransmissionType type, SideData data) - { - List outputSides = new ArrayList(); - ISideConfiguration configurable = (ISideConfiguration)tileEntity; + public void readFrom(TileComponentEjector ejector) { + strictInput = ejector.strictInput; + outputColor = ejector.outputColor; + inputColors = ejector.inputColors; + tickDelay = ejector.tickDelay; + sideData = ejector.sideData; + } - for(int i = 0; i < configurable.getConfig().getConfig(type).length; i++) - { - int side = MekanismUtils.getBaseOrientation(i, tileEntity.facing); - - if(configurable.getConfig().getConfig(type)[side] == configurable.getConfig().getOutputs(type).indexOf(data)) - { - outputSides.add(ForgeDirection.getOrientation(i)); - } - } - - return outputSides; - } + private List + getTrackedOutputs(TransmissionType type, int index, List dirs) { + List sides = new ArrayList(); - public void outputItems() - { - if(!getEjecting(TransmissionType.ITEM) || tileEntity.getWorldObj().isRemote) - { - return; - } + for (int i = trackers.get(type)[index] + 1; i <= trackers.get(type)[index] + 6; + i++) { + for (ForgeDirection side : dirs) { + if (ForgeDirection.getOrientation(i % 6) == side) { + sides.add(side); + } + } + } - SideData data = sideData.get(TransmissionType.ITEM); - List outputSides = getOutputSides(TransmissionType.ITEM, data); + return sides; + } - for(int index = 0; index < sideData.get(TransmissionType.ITEM).availableSlots.length; index++) - { - int slotID = sideData.get(TransmissionType.ITEM).availableSlots[index]; + @Override + public void tick() { + if (tickDelay == 0) { + if (sideData.get(TransmissionType.ITEM) != null) { + outputItems(); + } + } else { + tickDelay--; + } - if(tileEntity.getStackInSlot(slotID) == null) - { - continue; - } + if (!tileEntity.getWorldObj().isRemote) { + if (sideData.get(TransmissionType.GAS) != null + && getEjecting(TransmissionType.GAS)) { + SideData data = sideData.get(TransmissionType.GAS); + List outputSides + = getOutputSides(TransmissionType.GAS, data); - ItemStack stack = tileEntity.getStackInSlot(slotID); - List outputs = getTrackedOutputs(TransmissionType.ITEM, index, outputSides); + if (((ITankManager) tileEntity).getTanks() != null) { + GasTank tank = (GasTank) ((ITankManager) tileEntity) + .getTanks()[data.availableSlots[0]]; - for(ForgeDirection side : outputs) - { - TileEntity tile = Coord4D.get(tileEntity).getFromSide(side).getTileEntity(tileEntity.getWorldObj()); - ItemStack prev = stack.copy(); + if (tank.getStored() > 0) { + GasStack toEmit = tank.getGas().copy().withAmount( + Math.min(GAS_OUTPUT, tank.getStored()) + ); + int emit = GasTransmission.emit(toEmit, tileEntity, outputSides); + tank.draw(emit, true); + } + } + } - if(tile instanceof IInventory && !(tile instanceof ITransporterTile)) - { - stack = InventoryUtils.putStackInInventory((IInventory)tile, stack, side.ordinal(), false); - } - else if(tile instanceof ITransporterTile) - { - ItemStack rejects = TransporterUtils.insert(tileEntity, ((ITransporterTile)tile).getTransmitter(), stack, outputColor, true, 0); + if (sideData.get(TransmissionType.FLUID) != null + && getEjecting(TransmissionType.FLUID)) { + SideData data = sideData.get(TransmissionType.FLUID); + List outputSides + = getOutputSides(TransmissionType.FLUID, data); - if(TransporterManager.didEmit(stack, rejects)) - { - stack = rejects; - } - } + if (((ITankManager) tileEntity).getTanks() != null) { + FluidTank tank = (FluidTank) ((ITankManager) tileEntity) + .getTanks()[data.availableSlots[0]]; - if(stack == null || prev.stackSize != stack.stackSize) - { - trackers.get(TransmissionType.ITEM)[index] = side.ordinal(); - } + if (tank.getFluidAmount() > 0) { + FluidStack toEmit = PipeUtils.copy( + tank.getFluid(), Math.min(FLUID_OUTPUT, tank.getFluidAmount()) + ); + int emit = PipeUtils.emit(outputSides, toEmit, tileEntity); + tank.drain(emit, true); + } + } + } + } + } - if(stack == null) - { - break; - } - } + public List getOutputSides(TransmissionType type, SideData data) { + List outputSides = new ArrayList(); + ISideConfiguration configurable = (ISideConfiguration) tileEntity; - tileEntity.setInventorySlotContents(slotID, stack); - tileEntity.markDirty(); - } + for (int i = 0; i < configurable.getConfig().getConfig(type).length; i++) { + int side = MekanismUtils.getBaseOrientation(i, tileEntity.facing); - tickDelay = 20; - } + if (configurable.getConfig().getConfig(type)[side] + == configurable.getConfig().getOutputs(type).indexOf(data)) { + outputSides.add(ForgeDirection.getOrientation(i)); + } + } - public boolean hasStrictInput() - { - return strictInput; - } + return outputSides; + } - public void setStrictInput(boolean strict) - { - strictInput = strict; - MekanismUtils.saveChunk(tileEntity); - } + public void outputItems() { + if (!getEjecting(TransmissionType.ITEM) || tileEntity.getWorldObj().isRemote) { + return; + } - public void setOutputColor(EnumColor color) - { - outputColor = color; - MekanismUtils.saveChunk(tileEntity); - } + SideData data = sideData.get(TransmissionType.ITEM); + List outputSides = getOutputSides(TransmissionType.ITEM, data); - public EnumColor getOutputColor() - { - return outputColor; - } + for (int index = 0; + index < sideData.get(TransmissionType.ITEM).availableSlots.length; + index++) { + int slotID = sideData.get(TransmissionType.ITEM).availableSlots[index]; - public void setInputColor(ForgeDirection side, EnumColor color) - { - inputColors[side.ordinal()] = color; - MekanismUtils.saveChunk(tileEntity); - } + if (tileEntity.getStackInSlot(slotID) == null) { + continue; + } - public EnumColor getInputColor(ForgeDirection side) - { - return inputColors[side.ordinal()]; - } + ItemStack stack = tileEntity.getStackInSlot(slotID); + List outputs + = getTrackedOutputs(TransmissionType.ITEM, index, outputSides); - @Override - public void read(NBTTagCompound nbtTags) - { - strictInput = nbtTags.getBoolean("strictInput"); + for (ForgeDirection side : outputs) { + TileEntity tile = Coord4D.get(tileEntity) + .getFromSide(side) + .getTileEntity(tileEntity.getWorldObj()); + ItemStack prev = stack.copy(); - if(nbtTags.hasKey("ejectColor")) - { - outputColor = TransporterUtils.colors.get(nbtTags.getInteger("ejectColor")); - } + if (tile instanceof IInventory && !(tile instanceof ITransporterTile)) { + stack = InventoryUtils.putStackInInventory( + (IInventory) tile, stack, side.ordinal(), false + ); + } else if (tile instanceof ITransporterTile) { + ItemStack rejects = TransporterUtils.insert( + tileEntity, + ((ITransporterTile) tile).getTransmitter(), + stack, + outputColor, + true, + 0 + ); - for(TransmissionType type : sideData.keySet()) - { - for(int i = 0; i < sideData.get(type).availableSlots.length; i++) - { - trackers.get(type)[i] = nbtTags.getInteger("tracker" + type.getTransmission() + i); - } - } + if (TransporterManager.didEmit(stack, rejects)) { + stack = rejects; + } + } - for(int i = 0; i < 6; i++) - { - if(nbtTags.hasKey("inputColors" + i)) - { - int inC = nbtTags.getInteger("inputColors" + i); + if (stack == null || prev.stackSize != stack.stackSize) { + trackers.get(TransmissionType.ITEM)[index] = side.ordinal(); + } - if(inC != -1) - { - inputColors[i] = TransporterUtils.colors.get(inC); - } - else { - inputColors[i] = null; - } - } - } - } + if (stack == null) { + break; + } + } - @Override - public void read(ByteBuf dataStream) - { - strictInput = dataStream.readBoolean(); + tileEntity.setInventorySlotContents(slotID, stack); + tileEntity.markDirty(); + } - int c = dataStream.readInt(); + tickDelay = 20; + } - if(c != -1) - { - outputColor = TransporterUtils.colors.get(c); - } - else { - outputColor = null; - } + public boolean hasStrictInput() { + return strictInput; + } - for(int i = 0; i < 6; i++) - { - int inC = dataStream.readInt(); + public void setStrictInput(boolean strict) { + strictInput = strict; + MekanismUtils.saveChunk(tileEntity); + } - if(inC != -1) - { - inputColors[i] = TransporterUtils.colors.get(inC); - } - else { - inputColors[i] = null; - } - } - } + public void setOutputColor(EnumColor color) { + outputColor = color; + MekanismUtils.saveChunk(tileEntity); + } - @Override - public void write(NBTTagCompound nbtTags) - { - nbtTags.setBoolean("strictInput", strictInput); + public EnumColor getOutputColor() { + return outputColor; + } - if(outputColor != null) - { - nbtTags.setInteger("ejectColor", TransporterUtils.colors.indexOf(outputColor)); - } + public void setInputColor(ForgeDirection side, EnumColor color) { + inputColors[side.ordinal()] = color; + MekanismUtils.saveChunk(tileEntity); + } - for(TransmissionType type : sideData.keySet()) - { - for(int i = 0; i < sideData.get(type).availableSlots.length; i++) - { - nbtTags.setInteger("tracker" + type.getTransmission() + i, trackers.get(type)[i]); - } - } + public EnumColor getInputColor(ForgeDirection side) { + return inputColors[side.ordinal()]; + } - for(int i = 0; i < 6; i++) - { - if(inputColors[i] == null) - { - nbtTags.setInteger("inputColors" + i, -1); - } - else { - nbtTags.setInteger("inputColors" + i, TransporterUtils.colors.indexOf(inputColors[i])); - } - } - } + @Override + public void read(NBTTagCompound nbtTags) { + strictInput = nbtTags.getBoolean("strictInput"); - @Override - public void write(ArrayList data) - { - data.add(strictInput); + if (nbtTags.hasKey("ejectColor")) { + outputColor = TransporterUtils.colors.get(nbtTags.getInteger("ejectColor")); + } - if(outputColor != null) - { - data.add(TransporterUtils.colors.indexOf(outputColor)); - } - else { - data.add(-1); - } + for (TransmissionType type : sideData.keySet()) { + for (int i = 0; i < sideData.get(type).availableSlots.length; i++) { + trackers.get(type)[i] + = nbtTags.getInteger("tracker" + type.getTransmission() + i); + } + } - for(int i = 0; i < 6; i++) - { - if(inputColors[i] == null) - { - data.add(-1); - } - else { - data.add(TransporterUtils.colors.indexOf(inputColors[i])); - } - } - } - - @Override - public void invalidate() {} - - private boolean getEjecting(TransmissionType type) - { - return ((ISideConfiguration)tileEntity).getConfig().isEjecting(type); - } + for (int i = 0; i < 6; i++) { + if (nbtTags.hasKey("inputColors" + i)) { + int inC = nbtTags.getInteger("inputColors" + i); + + if (inC != -1) { + inputColors[i] = TransporterUtils.colors.get(inC); + } else { + inputColors[i] = null; + } + } + } + } + + @Override + public void read(ByteBuf dataStream) { + strictInput = dataStream.readBoolean(); + + int c = dataStream.readInt(); + + if (c != -1) { + outputColor = TransporterUtils.colors.get(c); + } else { + outputColor = null; + } + + for (int i = 0; i < 6; i++) { + int inC = dataStream.readInt(); + + if (inC != -1) { + inputColors[i] = TransporterUtils.colors.get(inC); + } else { + inputColors[i] = null; + } + } + } + + @Override + public void write(NBTTagCompound nbtTags) { + nbtTags.setBoolean("strictInput", strictInput); + + if (outputColor != null) { + nbtTags.setInteger( + "ejectColor", TransporterUtils.colors.indexOf(outputColor) + ); + } + + for (TransmissionType type : sideData.keySet()) { + for (int i = 0; i < sideData.get(type).availableSlots.length; i++) { + nbtTags.setInteger( + "tracker" + type.getTransmission() + i, trackers.get(type)[i] + ); + } + } + + for (int i = 0; i < 6; i++) { + if (inputColors[i] == null) { + nbtTags.setInteger("inputColors" + i, -1); + } else { + nbtTags.setInteger( + "inputColors" + i, TransporterUtils.colors.indexOf(inputColors[i]) + ); + } + } + } + + @Override + public void write(ArrayList data) { + data.add(strictInput); + + if (outputColor != null) { + data.add(TransporterUtils.colors.indexOf(outputColor)); + } else { + data.add(-1); + } + + for (int i = 0; i < 6; i++) { + if (inputColors[i] == null) { + data.add(-1); + } else { + data.add(TransporterUtils.colors.indexOf(inputColors[i])); + } + } + } + + @Override + public void invalidate() {} + + private boolean getEjecting(TransmissionType type) { + return ((ISideConfiguration) tileEntity).getConfig().isEjecting(type); + } } diff --git a/src/main/java/mekanism/common/tile/component/TileComponentSecurity.java b/src/main/java/mekanism/common/tile/component/TileComponentSecurity.java index e9eac5644..18d9a2bbd 100644 --- a/src/main/java/mekanism/common/tile/component/TileComponentSecurity.java +++ b/src/main/java/mekanism/common/tile/component/TileComponentSecurity.java @@ -1,9 +1,8 @@ package mekanism.common.tile.component; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.MekanismConfig.general; import mekanism.common.Mekanism; @@ -17,220 +16,183 @@ import mekanism.common.tile.TileEntityContainerBlock; import mekanism.common.util.MekanismUtils; import net.minecraft.nbt.NBTTagCompound; -public class TileComponentSecurity implements ITileComponent -{ - /** TileEntity implementing this component. */ - public TileEntityContainerBlock tileEntity; - - private String owner; - - private SecurityMode securityMode = SecurityMode.PUBLIC; - - private SecurityFrequency frequency; - - public TileComponentSecurity(TileEntityContainerBlock tile) - { - tileEntity = tile; - - tile.components.add(this); - } - - public void readFrom(TileComponentSecurity security) - { - owner = security.owner; - securityMode = security.securityMode; - } - - public SecurityFrequency getFrequency() - { - return frequency; - } - - public String getOwner() - { - return owner; - } - - public void setOwner(String o) - { - frequency = null; - owner = o; - } - - public SecurityMode getMode() - { - if(general.allowProtection) { - return securityMode; - } else { - return SecurityMode.PUBLIC; - } - } - - public void setMode(SecurityMode mode) - { - securityMode = mode; - } - - public FrequencyManager getManager(Frequency freq) - { - if(owner == null || freq == null) - { - return null; - } - - return Mekanism.securityFrequencies; - } - - public void setFrequency(String owner) - { - FrequencyManager manager = Mekanism.securityFrequencies; - manager.deactivate(Coord4D.get(tileEntity)); - - for(Frequency freq : manager.getFrequencies()) - { - if(freq.owner.equals(owner)) - { - frequency = (SecurityFrequency)freq; - frequency.activeCoords.add(Coord4D.get(tileEntity)); - - return; - } - } - - Frequency freq = new SecurityFrequency(owner).setAccess(SecurityMode.PUBLIC); - freq.activeCoords.add(Coord4D.get(tileEntity)); - manager.addFrequency(freq); - frequency = (SecurityFrequency)freq; - - MekanismUtils.saveChunk(tileEntity); - tileEntity.markDirty(); - } - - @Override - public void tick() - { - if(!tileEntity.getWorldObj().isRemote) - { - if(frequency == null && owner != null) - { - setFrequency(owner); - } - - FrequencyManager manager = getManager(frequency); - - if(manager != null) - { - if(frequency != null && !frequency.valid) - { - frequency = (SecurityFrequency)manager.validateFrequency(owner, Coord4D.get(tileEntity), frequency); - } - - if(frequency != null) - { - frequency = (SecurityFrequency)manager.update(owner, Coord4D.get(tileEntity), frequency); - } - } - else { - frequency = null; - } - } - } +public class TileComponentSecurity implements ITileComponent { + /** TileEntity implementing this component. */ + public TileEntityContainerBlock tileEntity; - @Override - public void read(NBTTagCompound nbtTags) - { - securityMode = SecurityMode.values()[nbtTags.getInteger("securityMode")]; - - if(nbtTags.hasKey("owner")) - { - owner = nbtTags.getString("owner"); - } - - if(nbtTags.hasKey("securityFreq")) - { - frequency = new SecurityFrequency(nbtTags.getCompoundTag("securityFreq")); - frequency.valid = false; - } - } + private String owner; - @Override - public void read(ByteBuf dataStream) - { - securityMode = SecurityMode.values()[dataStream.readInt()]; - - if(dataStream.readBoolean()) - { - owner = PacketHandler.readString(dataStream); - } - else { - owner = null; - } - - if(dataStream.readBoolean()) - { - frequency = new SecurityFrequency(dataStream); - } - else { - frequency = null; - } - } + private SecurityMode securityMode = SecurityMode.PUBLIC; - @Override - public void write(NBTTagCompound nbtTags) - { - nbtTags.setInteger("securityMode", securityMode.ordinal()); - - if(owner != null) - { - nbtTags.setString("owner", owner); - } - - if(frequency != null) - { - NBTTagCompound frequencyTag = new NBTTagCompound(); - frequency.write(frequencyTag); - nbtTags.setTag("securityFreq", frequencyTag); - } - } + private SecurityFrequency frequency; - @Override - public void write(ArrayList data) - { - data.add(securityMode.ordinal()); - - if(owner != null) - { - data.add(true); - data.add(owner); - } - else { - data.add(false); - } - - if(frequency != null) - { - data.add(true); - frequency.write(data); - } - else { - data.add(false); - } - } - - @Override - public void invalidate() - { - if(!tileEntity.getWorldObj().isRemote) - { - if(frequency != null) - { - FrequencyManager manager = getManager(frequency); - - if(manager != null) - { - manager.deactivate(Coord4D.get(tileEntity)); - } - } - } - } + public TileComponentSecurity(TileEntityContainerBlock tile) { + tileEntity = tile; + + tile.components.add(this); + } + + public void readFrom(TileComponentSecurity security) { + owner = security.owner; + securityMode = security.securityMode; + } + + public SecurityFrequency getFrequency() { + return frequency; + } + + public String getOwner() { + return owner; + } + + public void setOwner(String o) { + frequency = null; + owner = o; + } + + public SecurityMode getMode() { + if (general.allowProtection) { + return securityMode; + } else { + return SecurityMode.PUBLIC; + } + } + + public void setMode(SecurityMode mode) { + securityMode = mode; + } + + public FrequencyManager getManager(Frequency freq) { + if (owner == null || freq == null) { + return null; + } + + return Mekanism.securityFrequencies; + } + + public void setFrequency(String owner) { + FrequencyManager manager = Mekanism.securityFrequencies; + manager.deactivate(Coord4D.get(tileEntity)); + + for (Frequency freq : manager.getFrequencies()) { + if (freq.owner.equals(owner)) { + frequency = (SecurityFrequency) freq; + frequency.activeCoords.add(Coord4D.get(tileEntity)); + + return; + } + } + + Frequency freq = new SecurityFrequency(owner).setAccess(SecurityMode.PUBLIC); + freq.activeCoords.add(Coord4D.get(tileEntity)); + manager.addFrequency(freq); + frequency = (SecurityFrequency) freq; + + MekanismUtils.saveChunk(tileEntity); + tileEntity.markDirty(); + } + + @Override + public void tick() { + if (!tileEntity.getWorldObj().isRemote) { + if (frequency == null && owner != null) { + setFrequency(owner); + } + + FrequencyManager manager = getManager(frequency); + + if (manager != null) { + if (frequency != null && !frequency.valid) { + frequency = (SecurityFrequency) manager.validateFrequency( + owner, Coord4D.get(tileEntity), frequency + ); + } + + if (frequency != null) { + frequency = (SecurityFrequency + ) manager.update(owner, Coord4D.get(tileEntity), frequency); + } + } else { + frequency = null; + } + } + } + + @Override + public void read(NBTTagCompound nbtTags) { + securityMode = SecurityMode.values()[nbtTags.getInteger("securityMode")]; + + if (nbtTags.hasKey("owner")) { + owner = nbtTags.getString("owner"); + } + + if (nbtTags.hasKey("securityFreq")) { + frequency = new SecurityFrequency(nbtTags.getCompoundTag("securityFreq")); + frequency.valid = false; + } + } + + @Override + public void read(ByteBuf dataStream) { + securityMode = SecurityMode.values()[dataStream.readInt()]; + + if (dataStream.readBoolean()) { + owner = PacketHandler.readString(dataStream); + } else { + owner = null; + } + + if (dataStream.readBoolean()) { + frequency = new SecurityFrequency(dataStream); + } else { + frequency = null; + } + } + + @Override + public void write(NBTTagCompound nbtTags) { + nbtTags.setInteger("securityMode", securityMode.ordinal()); + + if (owner != null) { + nbtTags.setString("owner", owner); + } + + if (frequency != null) { + NBTTagCompound frequencyTag = new NBTTagCompound(); + frequency.write(frequencyTag); + nbtTags.setTag("securityFreq", frequencyTag); + } + } + + @Override + public void write(ArrayList data) { + data.add(securityMode.ordinal()); + + if (owner != null) { + data.add(true); + data.add(owner); + } else { + data.add(false); + } + + if (frequency != null) { + data.add(true); + frequency.write(data); + } else { + data.add(false); + } + } + + @Override + public void invalidate() { + if (!tileEntity.getWorldObj().isRemote) { + if (frequency != null) { + FrequencyManager manager = getManager(frequency); + + if (manager != null) { + manager.deactivate(Coord4D.get(tileEntity)); + } + } + } + } } diff --git a/src/main/java/mekanism/common/tile/component/TileComponentUpgrade.java b/src/main/java/mekanism/common/tile/component/TileComponentUpgrade.java index 71f10d3fb..5e2096942 100644 --- a/src/main/java/mekanism/common/tile/component/TileComponentUpgrade.java +++ b/src/main/java/mekanism/common/tile/component/TileComponentUpgrade.java @@ -1,13 +1,12 @@ package mekanism.common.tile.component; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.Range4D; import mekanism.common.Mekanism; @@ -18,215 +17,187 @@ import mekanism.common.network.PacketTileEntity.TileEntityMessage; import mekanism.common.tile.TileEntityContainerBlock; import net.minecraft.nbt.NBTTagCompound; -public class TileComponentUpgrade implements ITileComponent -{ - /** How long it takes this machine to install an upgrade. */ - public static int UPGRADE_TICKS_REQUIRED = 40; - - private Map upgrades = new HashMap(); - - private Set supported = new HashSet(); +public class TileComponentUpgrade implements ITileComponent { + /** How long it takes this machine to install an upgrade. */ + public static int UPGRADE_TICKS_REQUIRED = 40; - /** The inventory slot the upgrade slot of this component occupies. */ - private int upgradeSlot; + private Map upgrades = new HashMap(); - /** How many upgrade ticks have progressed. */ - public int upgradeTicks; + private Set supported = new HashSet(); - /** TileEntity implementing this component. */ - public TileEntityContainerBlock tileEntity; + /** The inventory slot the upgrade slot of this component occupies. */ + private int upgradeSlot; - public TileComponentUpgrade(TileEntityContainerBlock tile, int slot) - { - tileEntity = tile; - upgradeSlot = slot; - - setSupported(Upgrade.SPEED); - setSupported(Upgrade.ENERGY); + /** How many upgrade ticks have progressed. */ + public int upgradeTicks; - tile.components.add(this); - } - - public void readFrom(TileComponentUpgrade upgrade) - { - upgrades = upgrade.upgrades; - supported = upgrade.supported; - upgradeSlot = upgrade.upgradeSlot; - upgradeTicks = upgrade.upgradeTicks; - } + /** TileEntity implementing this component. */ + public TileEntityContainerBlock tileEntity; - @Override - public void tick() - { - if(!tileEntity.getWorldObj().isRemote) - { - if(tileEntity.inventory[upgradeSlot] != null && tileEntity.inventory[upgradeSlot].getItem() instanceof IUpgradeItem) - { - Upgrade type = ((IUpgradeItem)tileEntity.inventory[upgradeSlot].getItem()).getUpgradeType(tileEntity.inventory[upgradeSlot]); - - if(supports(type) && getUpgrades(type) < type.getMax()) - { - if(upgradeTicks < UPGRADE_TICKS_REQUIRED) - { - upgradeTicks++; - } - else if(upgradeTicks == UPGRADE_TICKS_REQUIRED) - { - upgradeTicks = 0; - addUpgrade(type); + public TileComponentUpgrade(TileEntityContainerBlock tile, int slot) { + tileEntity = tile; + upgradeSlot = slot; - tileEntity.inventory[upgradeSlot].stackSize--; + setSupported(Upgrade.SPEED); + setSupported(Upgrade.ENERGY); - if(tileEntity.inventory[upgradeSlot].stackSize == 0) - { - tileEntity.inventory[upgradeSlot] = null; - } + tile.components.add(this); + } - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(tileEntity), tileEntity.getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(tileEntity))); - tileEntity.markDirty(); - } - } - else { - upgradeTicks = 0; - } - } - else { - upgradeTicks = 0; - } - } - } - - public int getUpgradeSlot() - { - return upgradeSlot; - } - - public void setUpgradeSlot(int i) - { - upgradeSlot = i; - } + public void readFrom(TileComponentUpgrade upgrade) { + upgrades = upgrade.upgrades; + supported = upgrade.supported; + upgradeSlot = upgrade.upgradeSlot; + upgradeTicks = upgrade.upgradeTicks; + } - public int getScaledUpgradeProgress(int i) - { - return upgradeTicks*i / UPGRADE_TICKS_REQUIRED; - } - - public int getUpgrades(Upgrade upgrade) - { - if(upgrades.get(upgrade) == null) - { - return 0; - } - - return upgrades.get(upgrade); - } - - public void addUpgrade(Upgrade upgrade) - { - upgrades.put(upgrade, Math.min(upgrade.getMax(), getUpgrades(upgrade)+1)); + @Override + public void tick() { + if (!tileEntity.getWorldObj().isRemote) { + if (tileEntity.inventory[upgradeSlot] != null + && tileEntity.inventory[upgradeSlot].getItem() instanceof IUpgradeItem) { + Upgrade type + = ((IUpgradeItem) tileEntity.inventory[upgradeSlot].getItem()) + .getUpgradeType(tileEntity.inventory[upgradeSlot]); - tileEntity.recalculateUpgradables(upgrade); - } - - public void removeUpgrade(Upgrade upgrade) - { - upgrades.put(upgrade, Math.max(0, getUpgrades(upgrade)-1)); - - if(upgrades.get(upgrade) == 0) - { - upgrades.remove(upgrade); - } + if (supports(type) && getUpgrades(type) < type.getMax()) { + if (upgradeTicks < UPGRADE_TICKS_REQUIRED) { + upgradeTicks++; + } else if (upgradeTicks == UPGRADE_TICKS_REQUIRED) { + upgradeTicks = 0; + addUpgrade(type); - tileEntity.recalculateUpgradables(upgrade); - } + tileEntity.inventory[upgradeSlot].stackSize--; - public void setSupported(Upgrade upgrade) - { - setSupported(upgrade, true); - } + if (tileEntity.inventory[upgradeSlot].stackSize == 0) { + tileEntity.inventory[upgradeSlot] = null; + } - public void setSupported(Upgrade upgrade, boolean isSupported) - { - if(isSupported) - { - supported.add(upgrade); - } - else { - supported.remove(upgrade); - } - } - - public boolean supports(Upgrade upgrade) - { - return supported.contains(upgrade); - } - - public Set getInstalledTypes() - { - return upgrades.keySet(); - } - - public Set getSupportedTypes() - { - return supported; - } - - public void clearSupportedTypes() - { - supported.clear(); - } + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(tileEntity), + tileEntity.getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(tileEntity)) + ); + tileEntity.markDirty(); + } + } else { + upgradeTicks = 0; + } + } else { + upgradeTicks = 0; + } + } + } - @Override - public void read(ByteBuf dataStream) - { - upgrades.clear(); - - int amount = dataStream.readInt(); - - for(int i = 0; i < amount; i++) - { - upgrades.put(Upgrade.values()[dataStream.readInt()], dataStream.readInt()); - } - - upgradeTicks = dataStream.readInt(); + public int getUpgradeSlot() { + return upgradeSlot; + } - for(Upgrade upgrade : getSupportedTypes()) - { - tileEntity.recalculateUpgradables(upgrade); - } - } - - @Override - public void write(ArrayList data) - { - data.add(upgrades.size()); - - for(Map.Entry entry : upgrades.entrySet()) - { - data.add(entry.getKey().ordinal()); - data.add(entry.getValue()); - } - - data.add(upgradeTicks); - } - - @Override - public void read(NBTTagCompound nbtTags) - { - upgrades = Upgrade.buildMap(nbtTags); - - for(Upgrade upgrade : getSupportedTypes()) - { - tileEntity.recalculateUpgradables(upgrade); - } - } + public void setUpgradeSlot(int i) { + upgradeSlot = i; + } - @Override - public void write(NBTTagCompound nbtTags) - { - Upgrade.saveMap(upgrades, nbtTags); - } - - @Override - public void invalidate() {} + public int getScaledUpgradeProgress(int i) { + return upgradeTicks * i / UPGRADE_TICKS_REQUIRED; + } + + public int getUpgrades(Upgrade upgrade) { + if (upgrades.get(upgrade) == null) { + return 0; + } + + return upgrades.get(upgrade); + } + + public void addUpgrade(Upgrade upgrade) { + upgrades.put(upgrade, Math.min(upgrade.getMax(), getUpgrades(upgrade) + 1)); + + tileEntity.recalculateUpgradables(upgrade); + } + + public void removeUpgrade(Upgrade upgrade) { + upgrades.put(upgrade, Math.max(0, getUpgrades(upgrade) - 1)); + + if (upgrades.get(upgrade) == 0) { + upgrades.remove(upgrade); + } + + tileEntity.recalculateUpgradables(upgrade); + } + + public void setSupported(Upgrade upgrade) { + setSupported(upgrade, true); + } + + public void setSupported(Upgrade upgrade, boolean isSupported) { + if (isSupported) { + supported.add(upgrade); + } else { + supported.remove(upgrade); + } + } + + public boolean supports(Upgrade upgrade) { + return supported.contains(upgrade); + } + + public Set getInstalledTypes() { + return upgrades.keySet(); + } + + public Set getSupportedTypes() { + return supported; + } + + public void clearSupportedTypes() { + supported.clear(); + } + + @Override + public void read(ByteBuf dataStream) { + upgrades.clear(); + + int amount = dataStream.readInt(); + + for (int i = 0; i < amount; i++) { + upgrades.put(Upgrade.values()[dataStream.readInt()], dataStream.readInt()); + } + + upgradeTicks = dataStream.readInt(); + + for (Upgrade upgrade : getSupportedTypes()) { + tileEntity.recalculateUpgradables(upgrade); + } + } + + @Override + public void write(ArrayList data) { + data.add(upgrades.size()); + + for (Map.Entry entry : upgrades.entrySet()) { + data.add(entry.getKey().ordinal()); + data.add(entry.getValue()); + } + + data.add(upgradeTicks); + } + + @Override + public void read(NBTTagCompound nbtTags) { + upgrades = Upgrade.buildMap(nbtTags); + + for (Upgrade upgrade : getSupportedTypes()) { + tileEntity.recalculateUpgradables(upgrade); + } + } + + @Override + public void write(NBTTagCompound nbtTags) { + Upgrade.saveMap(upgrades, nbtTags); + } + + @Override + public void invalidate() {} } diff --git a/src/main/java/mekanism/common/transmitters/Transmitter.java b/src/main/java/mekanism/common/transmitters/Transmitter.java index 6e8ff20bb..1da8c2099 100644 --- a/src/main/java/mekanism/common/transmitters/Transmitter.java +++ b/src/main/java/mekanism/common/transmitters/Transmitter.java @@ -3,96 +3,85 @@ package mekanism.common.transmitters; import mekanism.api.transmitters.DynamicNetwork; import mekanism.api.transmitters.IGridTransmitter; -public abstract class Transmitter> implements IGridTransmitter -{ - public N theNetwork = null; +public abstract class Transmitter> + implements IGridTransmitter { + public N theNetwork = null; - public boolean orphaned = true; + public boolean orphaned = true; - @Override - public N getTransmitterNetwork() - { - return theNetwork; - } + @Override + public N getTransmitterNetwork() { + return theNetwork; + } - @Override - public boolean hasTransmitterNetwork() - { - return !isOrphan() && getTransmitterNetwork() != null; - } + @Override + public boolean hasTransmitterNetwork() { + return !isOrphan() && getTransmitterNetwork() != null; + } - @Override - public void setTransmitterNetwork(N network) - { - if(theNetwork == network) - { - return; - } - - if(world().isRemote && theNetwork != null) - { - theNetwork.transmitters.remove(this); - - if(theNetwork.transmitters.isEmpty()) - { - theNetwork.deregister(); - } - } - - theNetwork = network; - orphaned = theNetwork == null; - - if(world().isRemote && theNetwork != null) - { - theNetwork.transmitters.add(this); - } - } + @Override + public void setTransmitterNetwork(N network) { + if (theNetwork == network) { + return; + } - @Override - public int getTransmitterNetworkSize() - { - return hasTransmitterNetwork() ? getTransmitterNetwork().getSize() : 0; - } + if (world().isRemote && theNetwork != null) { + theNetwork.transmitters.remove(this); - @Override - public int getTransmitterNetworkAcceptorSize() - { - return hasTransmitterNetwork() ? getTransmitterNetwork().getAcceptorSize() : 0; - } + if (theNetwork.transmitters.isEmpty()) { + theNetwork.deregister(); + } + } - @Override - public String getTransmitterNetworkNeeded() - { - return hasTransmitterNetwork() ? getTransmitterNetwork().getNeededInfo() : "No Network"; - } + theNetwork = network; + orphaned = theNetwork == null; - @Override - public String getTransmitterNetworkFlow() - { - return hasTransmitterNetwork() ? getTransmitterNetwork().getFlowInfo() : "No Network"; - } + if (world().isRemote && theNetwork != null) { + theNetwork.transmitters.add(this); + } + } - @Override - public String getTransmitterNetworkBuffer() - { - return hasTransmitterNetwork() ? getTransmitterNetwork().getStoredInfo() : "No Network"; - } + @Override + public int getTransmitterNetworkSize() { + return hasTransmitterNetwork() ? getTransmitterNetwork().getSize() : 0; + } - @Override - public double getTransmitterNetworkCapacity() - { - return hasTransmitterNetwork() ? getTransmitterNetwork().getCapacity() : getCapacity(); - } + @Override + public int getTransmitterNetworkAcceptorSize() { + return hasTransmitterNetwork() ? getTransmitterNetwork().getAcceptorSize() : 0; + } - @Override - public boolean isOrphan() - { - return orphaned; - } + @Override + public String getTransmitterNetworkNeeded() { + return hasTransmitterNetwork() ? getTransmitterNetwork().getNeededInfo() + : "No Network"; + } - @Override - public void setOrphan(boolean nowOrphaned) - { - orphaned = nowOrphaned; - } + @Override + public String getTransmitterNetworkFlow() { + return hasTransmitterNetwork() ? getTransmitterNetwork().getFlowInfo() + : "No Network"; + } + + @Override + public String getTransmitterNetworkBuffer() { + return hasTransmitterNetwork() ? getTransmitterNetwork().getStoredInfo() + : "No Network"; + } + + @Override + public double getTransmitterNetworkCapacity() { + return hasTransmitterNetwork() ? getTransmitterNetwork().getCapacity() + : getCapacity(); + } + + @Override + public boolean isOrphan() { + return orphaned; + } + + @Override + public void setOrphan(boolean nowOrphaned) { + orphaned = nowOrphaned; + } } diff --git a/src/main/java/mekanism/common/util/CableUtils.java b/src/main/java/mekanism/common/util/CableUtils.java index dc8f05256..89b994715 100644 --- a/src/main/java/mekanism/common/util/CableUtils.java +++ b/src/main/java/mekanism/common/util/CableUtils.java @@ -1,14 +1,16 @@ package mekanism.common.util; -import ic2.api.energy.EnergyNet; -import ic2.api.energy.tile.IEnergyAcceptor; -import ic2.api.energy.tile.IEnergySink; -import ic2.api.energy.tile.IEnergySource; - import java.util.ArrayList; import java.util.List; import java.util.Set; +import cofh.api.energy.IEnergyConnection; +import cofh.api.energy.IEnergyProvider; +import cofh.api.energy.IEnergyReceiver; +import ic2.api.energy.EnergyNet; +import ic2.api.energy.tile.IEnergyAcceptor; +import ic2.api.energy.tile.IEnergySink; +import ic2.api.energy.tile.IEnergySource; import mekanism.api.Coord4D; import mekanism.api.MekanismConfig.general; import mekanism.api.energy.ICableOutputter; @@ -18,251 +20,262 @@ import mekanism.api.transmitters.TransmissionType; import mekanism.common.base.IEnergyWrapper; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -import cofh.api.energy.IEnergyConnection; -import cofh.api.energy.IEnergyProvider; -import cofh.api.energy.IEnergyReceiver; -public final class CableUtils -{ - public static boolean isEnergyAcceptor(TileEntity tileEntity) - { - return (tileEntity instanceof IStrictEnergyAcceptor || - (MekanismUtils.useIC2() && getIC2Tile(tileEntity) instanceof IEnergySink) || - (MekanismUtils.useRF() && tileEntity instanceof IEnergyReceiver)); - } +public final class CableUtils { + public static boolean isEnergyAcceptor(TileEntity tileEntity) { + return ( + tileEntity instanceof IStrictEnergyAcceptor + || (MekanismUtils.useIC2() && getIC2Tile(tileEntity) instanceof IEnergySink) + || (MekanismUtils.useRF() && tileEntity instanceof IEnergyReceiver) + ); + } - public static boolean isCable(TileEntity tileEntity) - { - if(tileEntity instanceof ITransmitterTile) - { - return TransmissionType.checkTransmissionType(((ITransmitterTile)tileEntity).getTransmitter(), TransmissionType.ENERGY); - } - return false; - } + public static boolean isCable(TileEntity tileEntity) { + if (tileEntity instanceof ITransmitterTile) { + return TransmissionType.checkTransmissionType( + ((ITransmitterTile) tileEntity).getTransmitter(), TransmissionType.ENERGY + ); + } + return false; + } - /** - * Gets the adjacent connections to a TileEntity, from a subset of its sides. - * @param tileEntity - center TileEntity - * @param sides - set of sides to check - * @return boolean[] of adjacent connections - */ - public static boolean[] getConnections(TileEntity tileEntity, Set sides) - { - boolean[] connectable = new boolean[] {false, false, false, false, false, false}; - Coord4D coord = Coord4D.get(tileEntity); + /** + * Gets the adjacent connections to a TileEntity, from a subset of its sides. + * @param tileEntity - center TileEntity + * @param sides - set of sides to check + * @return boolean[] of adjacent connections + */ + public static boolean[] getConnections( + TileEntity tileEntity, Set sides + ) { + boolean[] connectable + = new boolean[] { false, false, false, false, false, false }; + Coord4D coord = Coord4D.get(tileEntity); - for(ForgeDirection side : sides) - { - TileEntity tile = coord.getFromSide(side).getTileEntity(tileEntity.getWorldObj()); + for (ForgeDirection side : sides) { + TileEntity tile + = coord.getFromSide(side).getTileEntity(tileEntity.getWorldObj()); - connectable[side.ordinal()] = isValidAcceptorOnSide(tileEntity, tile, side); - connectable[side.ordinal()] |= isCable(tile); - } + connectable[side.ordinal()] = isValidAcceptorOnSide(tileEntity, tile, side); + connectable[side.ordinal()] |= isCable(tile); + } - return connectable; - } + return connectable; + } - /** - * Gets the adjacent connections to a TileEntity, from a subset of its sides. - * @param cableEntity - TileEntity that's trying to connect - * @param side - side to check - * @return boolean whether the acceptor is valid - */ - public static boolean isValidAcceptorOnSide(TileEntity cableEntity, TileEntity tile, ForgeDirection side) - { - if(isCable(tile)) - { - return false; - } + /** + * Gets the adjacent connections to a TileEntity, from a subset of its sides. + * @param cableEntity - TileEntity that's trying to connect + * @param side - side to check + * @return boolean whether the acceptor is valid + */ + public static boolean + isValidAcceptorOnSide(TileEntity cableEntity, TileEntity tile, ForgeDirection side) { + if (isCable(tile)) { + return false; + } - if(isEnergyAcceptor(tile) && isConnectable(cableEntity, tile, side)) - { - return true; - } - - return isOutputter(tile, side) || (MekanismUtils.useRF() && tile instanceof IEnergyConnection && ((IEnergyConnection)tile).canConnectEnergy(side.getOpposite())); - } + if (isEnergyAcceptor(tile) && isConnectable(cableEntity, tile, side)) { + return true; + } - /** - * Gets all the connected cables around a specific tile entity. - * @param tileEntity - center tile entity - * @return TileEntity[] of connected cables - */ - public static TileEntity[] getConnectedOutputters(TileEntity tileEntity) - { - TileEntity[] outputters = new TileEntity[] {null, null, null, null, null, null}; + return isOutputter(tile, side) + || (MekanismUtils.useRF() && tile instanceof IEnergyConnection + && ((IEnergyConnection) tile).canConnectEnergy(side.getOpposite())); + } - for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) - { - TileEntity outputter = Coord4D.get(tileEntity).getFromSide(orientation).getTileEntity(tileEntity.getWorldObj()); + /** + * Gets all the connected cables around a specific tile entity. + * @param tileEntity - center tile entity + * @return TileEntity[] of connected cables + */ + public static TileEntity[] getConnectedOutputters(TileEntity tileEntity) { + TileEntity[] outputters = new TileEntity[] { null, null, null, null, null, null }; - if(isOutputter(outputter, orientation)) - { - outputters[orientation.ordinal()] = outputter; - } - } + for (ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) { + TileEntity outputter = Coord4D.get(tileEntity) + .getFromSide(orientation) + .getTileEntity(tileEntity.getWorldObj()); - return outputters; - } + if (isOutputter(outputter, orientation)) { + outputters[orientation.ordinal()] = outputter; + } + } - public static boolean isOutputter(TileEntity tileEntity, ForgeDirection side) - { - return (tileEntity instanceof ICableOutputter && ((ICableOutputter)tileEntity).canOutputTo(side.getOpposite())) || - (MekanismUtils.useIC2() && getIC2Tile(tileEntity) instanceof IEnergySource && ((IEnergySource)getIC2Tile(tileEntity)).emitsEnergyTo(null, side.getOpposite())) || - (MekanismUtils.useRF() && tileEntity instanceof IEnergyProvider && ((IEnergyConnection)tileEntity).canConnectEnergy(side.getOpposite())); - } + return outputters; + } - public static boolean isConnectable(TileEntity orig, TileEntity tileEntity, ForgeDirection side) - { - if(tileEntity instanceof ITransmitterTile) - { - return false; - } + public static boolean isOutputter(TileEntity tileEntity, ForgeDirection side) { + return (tileEntity instanceof ICableOutputter + && ((ICableOutputter) tileEntity).canOutputTo(side.getOpposite())) + || (MekanismUtils.useIC2() && getIC2Tile(tileEntity) instanceof IEnergySource + && ((IEnergySource) getIC2Tile(tileEntity)) + .emitsEnergyTo(null, side.getOpposite())) + || (MekanismUtils.useRF() && tileEntity instanceof IEnergyProvider + && ((IEnergyConnection) tileEntity).canConnectEnergy(side.getOpposite())); + } - if(tileEntity instanceof IStrictEnergyAcceptor) - { - if(((IStrictEnergyAcceptor)tileEntity).canReceiveEnergy(side.getOpposite())) - { - return true; - } - } - else if(MekanismUtils.useIC2() && getIC2Tile(tileEntity) instanceof IEnergyAcceptor) - { - if(((IEnergyAcceptor)getIC2Tile(tileEntity)).acceptsEnergyFrom(orig, side.getOpposite())) - { - return true; - } - } - else if(tileEntity instanceof ICableOutputter) - { - if(((ICableOutputter)tileEntity).canOutputTo(side.getOpposite())) - { - return true; - } - } - else if(MekanismUtils.useRF() && tileEntity instanceof IEnergyConnection) - { - if(((IEnergyConnection)tileEntity).canConnectEnergy(side.getOpposite())) - { - return true; - } - } + public static boolean + isConnectable(TileEntity orig, TileEntity tileEntity, ForgeDirection side) { + if (tileEntity instanceof ITransmitterTile) { + return false; + } - return false; - } + if (tileEntity instanceof IStrictEnergyAcceptor) { + if (((IStrictEnergyAcceptor) tileEntity) + .canReceiveEnergy(side.getOpposite())) { + return true; + } + } else if (MekanismUtils.useIC2() && getIC2Tile(tileEntity) instanceof IEnergyAcceptor) { + if (((IEnergyAcceptor) getIC2Tile(tileEntity)) + .acceptsEnergyFrom(orig, side.getOpposite())) { + return true; + } + } else if (tileEntity instanceof ICableOutputter) { + if (((ICableOutputter) tileEntity).canOutputTo(side.getOpposite())) { + return true; + } + } else if (MekanismUtils.useRF() && tileEntity instanceof IEnergyConnection) { + if (((IEnergyConnection) tileEntity).canConnectEnergy(side.getOpposite())) { + return true; + } + } - public static void emit(IEnergyWrapper emitter) - { - if(!((TileEntity)emitter).getWorldObj().isRemote && MekanismUtils.canFunction((TileEntity)emitter)) - { - double energyToSend = Math.min(emitter.getEnergy(), emitter.getMaxOutput()); + return false; + } - if(energyToSend > 0) - { - List outputtingSides = new ArrayList(); - boolean[] connectable = getConnections((TileEntity)emitter, emitter.getOutputtingSides()); + public static void emit(IEnergyWrapper emitter) { + if (!((TileEntity) emitter).getWorldObj().isRemote + && MekanismUtils.canFunction((TileEntity) emitter)) { + double energyToSend = Math.min(emitter.getEnergy(), emitter.getMaxOutput()); - for(ForgeDirection side : emitter.getOutputtingSides()) - { - if(connectable[side.ordinal()]) - { - outputtingSides.add(side); - } - } + if (energyToSend > 0) { + List outputtingSides = new ArrayList(); + boolean[] connectable + = getConnections((TileEntity) emitter, emitter.getOutputtingSides()); - if(outputtingSides.size() > 0) - { - double sent = 0; - boolean tryAgain = false; - int i = 0; + for (ForgeDirection side : emitter.getOutputtingSides()) { + if (connectable[side.ordinal()]) { + outputtingSides.add(side); + } + } - do { - double prev = sent; - sent += emit_do(emitter, outputtingSides, energyToSend-sent, tryAgain); + if (outputtingSides.size() > 0) { + double sent = 0; + boolean tryAgain = false; + int i = 0; - tryAgain = energyToSend-sent > 0 && sent-prev > 0 && i < 100; + do { + double prev = sent; + sent += emit_do( + emitter, outputtingSides, energyToSend - sent, tryAgain + ); - i++; - } while(tryAgain); + tryAgain = energyToSend - sent > 0 && sent - prev > 0 && i < 100; - emitter.setEnergy(emitter.getEnergy() - sent); - } - } - } - } + i++; + } while (tryAgain); - private static double emit_do(IEnergyWrapper emitter, List outputtingSides, double totalToSend, boolean tryAgain) - { - double remains = totalToSend%outputtingSides.size(); - double splitSend = (totalToSend-remains)/outputtingSides.size(); - double sent = 0; + emitter.setEnergy(emitter.getEnergy() - sent); + } + } + } + } - List toRemove = new ArrayList(); + private static double emit_do( + IEnergyWrapper emitter, + List outputtingSides, + double totalToSend, + boolean tryAgain + ) { + double remains = totalToSend % outputtingSides.size(); + double splitSend = (totalToSend - remains) / outputtingSides.size(); + double sent = 0; - for(ForgeDirection side : outputtingSides) - { - TileEntity tileEntity = Coord4D.get((TileEntity)emitter).getFromSide(side).getTileEntity(((TileEntity)emitter).getWorldObj()); - double toSend = splitSend+remains; - remains = 0; + List toRemove = new ArrayList(); - double prev = sent; - sent += emit_do_do(emitter, tileEntity, side, toSend, tryAgain); + for (ForgeDirection side : outputtingSides) { + TileEntity tileEntity + = Coord4D.get((TileEntity) emitter) + .getFromSide(side) + .getTileEntity(((TileEntity) emitter).getWorldObj()); + double toSend = splitSend + remains; + remains = 0; - if(sent-prev == 0) - { - toRemove.add(side); - } - } + double prev = sent; + sent += emit_do_do(emitter, tileEntity, side, toSend, tryAgain); - for(ForgeDirection side : toRemove) - { - outputtingSides.remove(side); - } + if (sent - prev == 0) { + toRemove.add(side); + } + } - return sent; - } + for (ForgeDirection side : toRemove) { + outputtingSides.remove(side); + } - private static double emit_do_do(IEnergyWrapper from, TileEntity tileEntity, ForgeDirection side, double currentSending, boolean tryAgain) - { - double sent = 0; + return sent; + } - if(tileEntity instanceof IStrictEnergyAcceptor) - { - IStrictEnergyAcceptor acceptor = (IStrictEnergyAcceptor)tileEntity; + private static double emit_do_do( + IEnergyWrapper from, + TileEntity tileEntity, + ForgeDirection side, + double currentSending, + boolean tryAgain + ) { + double sent = 0; - if(acceptor.canReceiveEnergy(side.getOpposite())) - { - sent += acceptor.transferEnergyToAcceptor(side.getOpposite(), currentSending); - } - } - else if(MekanismUtils.useRF() && tileEntity instanceof IEnergyReceiver) - { - IEnergyReceiver handler = (IEnergyReceiver)tileEntity; + if (tileEntity instanceof IStrictEnergyAcceptor) { + IStrictEnergyAcceptor acceptor = (IStrictEnergyAcceptor) tileEntity; - if(handler.canConnectEnergy(side.getOpposite())) - { - int toSend = Math.min((int)Math.round(currentSending*general.TO_TE), Integer.MAX_VALUE); - int used = handler.receiveEnergy(side.getOpposite(), toSend, false); - sent += used*general.FROM_TE; - } - } - else if(MekanismUtils.useIC2() && getIC2Tile(tileEntity) instanceof IEnergySink) - { - IEnergySink sink = (IEnergySink) getIC2Tile(tileEntity); - if(sink.acceptsEnergyFrom((TileEntity)from, side.getOpposite())) - { - double toSend = Math.min(currentSending, EnergyNet.instance.getPowerFromTier(sink.getSinkTier())*general.FROM_IC2); - toSend = Math.min(Math.min(toSend, sink.getDemandedEnergy()*general.FROM_IC2), Integer.MAX_VALUE); - sent += (toSend - (sink.injectEnergy(side.getOpposite(), toSend*general.TO_IC2, 0)*general.FROM_IC2)); - } - } + if (acceptor.canReceiveEnergy(side.getOpposite())) { + sent += acceptor.transferEnergyToAcceptor( + side.getOpposite(), currentSending + ); + } + } else if (MekanismUtils.useRF() && tileEntity instanceof IEnergyReceiver) { + IEnergyReceiver handler = (IEnergyReceiver) tileEntity; - return sent; - } + if (handler.canConnectEnergy(side.getOpposite())) { + int toSend = Math.min( + (int) Math.round(currentSending * general.TO_TE), Integer.MAX_VALUE + ); + int used = handler.receiveEnergy(side.getOpposite(), toSend, false); + sent += used * general.FROM_TE; + } + } else if (MekanismUtils.useIC2() && getIC2Tile(tileEntity) instanceof IEnergySink) { + IEnergySink sink = (IEnergySink) getIC2Tile(tileEntity); + if (sink.acceptsEnergyFrom((TileEntity) from, side.getOpposite())) { + double toSend = Math.min( + currentSending, + EnergyNet.instance.getPowerFromTier(sink.getSinkTier()) + * general.FROM_IC2 + ); + toSend = Math.min( + Math.min(toSend, sink.getDemandedEnergy() * general.FROM_IC2), + Integer.MAX_VALUE + ); + sent + += (toSend + - (sink.injectEnergy( + side.getOpposite(), toSend * general.TO_IC2, 0 + ) + * general.FROM_IC2)); + } + } - public static TileEntity getIC2Tile(TileEntity tileEntity) { - if (tileEntity == null) return null; - return EnergyNet.instance.getTileEntity(tileEntity.getWorldObj(), tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord); - } + return sent; + } + public static TileEntity getIC2Tile(TileEntity tileEntity) { + if (tileEntity == null) + return null; + return EnergyNet.instance.getTileEntity( + tileEntity.getWorldObj(), + tileEntity.xCoord, + tileEntity.yCoord, + tileEntity.zCoord + ); + } } diff --git a/src/main/java/mekanism/common/util/ChargeUtils.java b/src/main/java/mekanism/common/util/ChargeUtils.java index 8348284a9..c92216cf4 100644 --- a/src/main/java/mekanism/common/util/ChargeUtils.java +++ b/src/main/java/mekanism/common/util/ChargeUtils.java @@ -1,5 +1,6 @@ package mekanism.common.util; +import cofh.api.energy.IEnergyContainerItem; import ic2.api.item.ElectricItem; import ic2.api.item.IElectricItem; import ic2.api.item.IElectricItemManager; @@ -12,165 +13,195 @@ import mekanism.common.tile.TileEntityContainerBlock; import net.minecraft.init.Items; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; -import cofh.api.energy.IEnergyContainerItem; -public final class ChargeUtils -{ - /** - * Universally discharges an item, and updates the TileEntity's energy level. - * @param slotID - ID of the slot of which to charge - * @param storer - TileEntity the item is being charged in - */ - public static void discharge(int slotID, IStrictEnergyStorage storer) - { - IInventory inv = (TileEntityContainerBlock)storer; - - if(inv.getStackInSlot(slotID) != null && storer.getEnergy() < storer.getMaxEnergy()) - { - if(inv.getStackInSlot(slotID).getItem() instanceof IEnergizedItem) - { - storer.setEnergy(storer.getEnergy() + EnergizedItemManager.discharge(inv.getStackInSlot(slotID), storer.getMaxEnergy() - storer.getEnergy())); - } - else if(MekanismUtils.useIC2() && inv.getStackInSlot(slotID).getItem() instanceof IElectricItem) - { - IElectricItem item = (IElectricItem)inv.getStackInSlot(slotID).getItem(); +public final class ChargeUtils { + /** + * Universally discharges an item, and updates the TileEntity's energy level. + * @param slotID - ID of the slot of which to charge + * @param storer - TileEntity the item is being charged in + */ + public static void discharge(int slotID, IStrictEnergyStorage storer) { + IInventory inv = (TileEntityContainerBlock) storer; - if(item.canProvideEnergy(inv.getStackInSlot(slotID))) - { - double gain = ElectricItem.manager.discharge(inv.getStackInSlot(slotID), (int)((storer.getMaxEnergy() - storer.getEnergy())* general.TO_IC2), 4, true, true, false)* general.FROM_IC2; - storer.setEnergy(storer.getEnergy() + gain); - } - } - else if(MekanismUtils.useRF() && inv.getStackInSlot(slotID).getItem() instanceof IEnergyContainerItem) - { - ItemStack itemStack = inv.getStackInSlot(slotID); - IEnergyContainerItem item = (IEnergyContainerItem)inv.getStackInSlot(slotID).getItem(); + if (inv.getStackInSlot(slotID) != null + && storer.getEnergy() < storer.getMaxEnergy()) { + if (inv.getStackInSlot(slotID).getItem() instanceof IEnergizedItem) { + storer.setEnergy( + storer.getEnergy() + + EnergizedItemManager.discharge( + inv.getStackInSlot(slotID), + storer.getMaxEnergy() - storer.getEnergy() + ) + ); + } else if (MekanismUtils.useIC2() && inv.getStackInSlot(slotID).getItem() instanceof IElectricItem) { + IElectricItem item = (IElectricItem) inv.getStackInSlot(slotID).getItem(); - int itemEnergy = (int)Math.round(Math.min(Math.sqrt(item.getMaxEnergyStored(itemStack)), item.getEnergyStored(itemStack))); - int toTransfer = (int)Math.round(Math.min(itemEnergy, ((storer.getMaxEnergy() - storer.getEnergy())* general.TO_TE))); + if (item.canProvideEnergy(inv.getStackInSlot(slotID))) { + double gain = ElectricItem.manager.discharge( + inv.getStackInSlot(slotID), + (int + ) ((storer.getMaxEnergy() - storer.getEnergy()) + * general.TO_IC2), + 4, + true, + true, + false + ) + * general.FROM_IC2; + storer.setEnergy(storer.getEnergy() + gain); + } + } else if (MekanismUtils.useRF() && inv.getStackInSlot(slotID).getItem() instanceof IEnergyContainerItem) { + ItemStack itemStack = inv.getStackInSlot(slotID); + IEnergyContainerItem item + = (IEnergyContainerItem) inv.getStackInSlot(slotID).getItem(); - storer.setEnergy(storer.getEnergy() + (item.extractEnergy(itemStack, toTransfer, false)* general.FROM_TE)); - } + int itemEnergy = (int) Math.round(Math.min( + Math.sqrt(item.getMaxEnergyStored(itemStack)), + item.getEnergyStored(itemStack) + )); + int toTransfer = (int) Math.round(Math.min( + itemEnergy, + ((storer.getMaxEnergy() - storer.getEnergy()) * general.TO_TE) + )); + + storer.setEnergy( + storer.getEnergy() + + (item.extractEnergy(itemStack, toTransfer, false) * general.FROM_TE) + ); + } else if(inv.getStackInSlot(slotID).getItem() == Items.redstone && storer.getEnergy()+ general.ENERGY_PER_REDSTONE <= storer.getMaxEnergy()) { - storer.setEnergy(storer.getEnergy() + general.ENERGY_PER_REDSTONE); - inv.getStackInSlot(slotID).stackSize--; + storer.setEnergy(storer.getEnergy() + general.ENERGY_PER_REDSTONE); + inv.getStackInSlot(slotID).stackSize--; - if(inv.getStackInSlot(slotID).stackSize <= 0) - { - inv.setInventorySlotContents(slotID, null); - } - } - } - } + if (inv.getStackInSlot(slotID).stackSize <= 0) { + inv.setInventorySlotContents(slotID, null); + } + } + } + } - /** - * Universally charges an item, and updates the TileEntity's energy level. - * @param slotID - ID of the slot of which to discharge - * @param storer - TileEntity the item is being discharged in - */ - public static void charge(int slotID, IStrictEnergyStorage storer) - { - IInventory inv = (TileEntityContainerBlock)storer; - - if(inv.getStackInSlot(slotID) != null && storer.getEnergy() > 0) - { - if(inv.getStackInSlot(slotID).getItem() instanceof IEnergizedItem) - { - storer.setEnergy(storer.getEnergy() - EnergizedItemManager.charge(inv.getStackInSlot(slotID), storer.getEnergy())); - } - else if(MekanismUtils.useIC2() && inv.getStackInSlot(slotID).getItem() instanceof IElectricItem) - { - double sent = ElectricItem.manager.charge(inv.getStackInSlot(slotID), (int)(storer.getEnergy()* general.TO_IC2), 4, true, false)* general.FROM_IC2; - storer.setEnergy(storer.getEnergy() - sent); - } - else if(MekanismUtils.useRF() && inv.getStackInSlot(slotID).getItem() instanceof IEnergyContainerItem) - { - ItemStack itemStack = inv.getStackInSlot(slotID); - IEnergyContainerItem item = (IEnergyContainerItem)inv.getStackInSlot(slotID).getItem(); + /** + * Universally charges an item, and updates the TileEntity's energy level. + * @param slotID - ID of the slot of which to discharge + * @param storer - TileEntity the item is being discharged in + */ + public static void charge(int slotID, IStrictEnergyStorage storer) { + IInventory inv = (TileEntityContainerBlock) storer; - int itemEnergy = (int)Math.round(Math.min(Math.sqrt(item.getMaxEnergyStored(itemStack)), item.getMaxEnergyStored(itemStack) - item.getEnergyStored(itemStack))); - int toTransfer = (int)Math.round(Math.min(itemEnergy, (storer.getEnergy()* general.TO_TE))); + if (inv.getStackInSlot(slotID) != null && storer.getEnergy() > 0) { + if (inv.getStackInSlot(slotID).getItem() instanceof IEnergizedItem) { + storer.setEnergy( + storer.getEnergy() + - EnergizedItemManager.charge( + inv.getStackInSlot(slotID), storer.getEnergy() + ) + ); + } else if (MekanismUtils.useIC2() && inv.getStackInSlot(slotID).getItem() instanceof IElectricItem) { + double sent = ElectricItem.manager.charge( + inv.getStackInSlot(slotID), + (int) (storer.getEnergy() * general.TO_IC2), + 4, + true, + false + ) + * general.FROM_IC2; + storer.setEnergy(storer.getEnergy() - sent); + } else if (MekanismUtils.useRF() && inv.getStackInSlot(slotID).getItem() instanceof IEnergyContainerItem) { + ItemStack itemStack = inv.getStackInSlot(slotID); + IEnergyContainerItem item + = (IEnergyContainerItem) inv.getStackInSlot(slotID).getItem(); - storer.setEnergy(storer.getEnergy() - (item.receiveEnergy(itemStack, toTransfer, false)* general.FROM_TE)); - } - } - } + int itemEnergy = (int) Math.round(Math.min( + Math.sqrt(item.getMaxEnergyStored(itemStack)), + item.getMaxEnergyStored(itemStack) - item.getEnergyStored(itemStack) + )); + int toTransfer = (int + ) Math.round(Math.min(itemEnergy, (storer.getEnergy() * general.TO_TE))); - /** - * Whether or not a defined ItemStack can be discharged for energy in some way. - * @param itemstack - ItemStack to check - * @return if the ItemStack can be discharged - */ - public static boolean canBeDischarged(ItemStack itemstack) - { - return (MekanismUtils.useIC2() && itemstack.getItem() instanceof IElectricItem && ((IElectricItem)itemstack.getItem()).canProvideEnergy(itemstack)) || - (itemstack.getItem() instanceof IEnergizedItem && ((IEnergizedItem)itemstack.getItem()).canSend(itemstack)) || - (MekanismUtils.useRF() && itemstack.getItem() instanceof IEnergyContainerItem && ((IEnergyContainerItem)itemstack.getItem()).extractEnergy(itemstack, 1, true) != 0) || - itemstack.getItem() == Items.redstone; - } + storer.setEnergy( + storer.getEnergy() + - (item.receiveEnergy(itemStack, toTransfer, false) * general.FROM_TE) + ); + } + } + } - /** - * Whether or not a defined ItemStack can be charged with energy in some way. - * @param itemstack - ItemStack to check - * @return if the ItemStack can be discharged - */ - public static boolean canBeCharged(ItemStack itemstack) - { - return (MekanismUtils.useIC2() && itemstack.getItem() instanceof IElectricItem) || - (itemstack.getItem() instanceof IEnergizedItem && ((IEnergizedItem)itemstack.getItem()).canReceive(itemstack)) || - (MekanismUtils.useRF() && itemstack.getItem() instanceof IEnergyContainerItem && ((IEnergyContainerItem)itemstack.getItem()).receiveEnergy(itemstack, 1, true) != 0); - } + /** + * Whether or not a defined ItemStack can be discharged for energy in some way. + * @param itemstack - ItemStack to check + * @return if the ItemStack can be discharged + */ + public static boolean canBeDischarged(ItemStack itemstack) { + return (MekanismUtils.useIC2() && itemstack.getItem() instanceof IElectricItem + && ((IElectricItem) itemstack.getItem()).canProvideEnergy(itemstack)) + || (itemstack.getItem() instanceof IEnergizedItem + && ((IEnergizedItem) itemstack.getItem()).canSend(itemstack)) + || (MekanismUtils.useRF() + && itemstack.getItem() instanceof IEnergyContainerItem + && ((IEnergyContainerItem) itemstack.getItem()) + .extractEnergy(itemstack, 1, true) + != 0) + || itemstack.getItem() == Items.redstone; + } - /** - * Whether or not a defined deemed-electrical ItemStack can be outputted out of a slot. - * This puts into account whether or not that slot is used for charging or discharging. - * @param itemstack - ItemStack to perform the check on - * @param chargeSlot - whether or not the outputting slot is for charging or discharging - * @return if the ItemStack can be outputted - */ - public static boolean canBeOutputted(ItemStack itemstack, boolean chargeSlot) - { - if(itemstack.getItem() instanceof IEnergizedItem) - { - IEnergizedItem energized = (IEnergizedItem)itemstack.getItem(); - - if(chargeSlot) - { - return energized.getEnergy(itemstack) == energized.getMaxEnergy(itemstack); - } - else { - return energized.getEnergy(itemstack) == 0; - } - } - else if(itemstack.getItem() instanceof IEnergyContainerItem) - { - IEnergyContainerItem energyContainer = (IEnergyContainerItem)itemstack.getItem(); - - if(chargeSlot) - { - return energyContainer.receiveEnergy(itemstack, 1, true) > 0; - } - else { - return energyContainer.extractEnergy(itemstack, 1, true) > 0; - } - } - else if(itemstack.getItem() instanceof ISpecialElectricItem) - { - IElectricItemManager manager = ((ISpecialElectricItem)itemstack.getItem()).getManager(itemstack); - - if(manager != null) - { - if(chargeSlot) - { - return manager.charge(itemstack, 1, 3, true, true) > 0; - } - else { - return manager.discharge(itemstack, 1, 3, true, true, true) > 0; - } - } - } - - return true; - } + /** + * Whether or not a defined ItemStack can be charged with energy in some way. + * @param itemstack - ItemStack to check + * @return if the ItemStack can be discharged + */ + public static boolean canBeCharged(ItemStack itemstack) { + return (MekanismUtils.useIC2() && itemstack.getItem() instanceof IElectricItem) + || (itemstack.getItem() instanceof IEnergizedItem + && ((IEnergizedItem) itemstack.getItem()).canReceive(itemstack)) + || (MekanismUtils.useRF() + && itemstack.getItem() instanceof IEnergyContainerItem + && ((IEnergyContainerItem) itemstack.getItem()) + .receiveEnergy(itemstack, 1, true) + != 0); + } + + /** + * Whether or not a defined deemed-electrical ItemStack can be outputted out of a + * slot. This puts into account whether or not that slot is used for charging or + * discharging. + * @param itemstack - ItemStack to perform the check on + * @param chargeSlot - whether or not the outputting slot is for charging or + * discharging + * @return if the ItemStack can be outputted + */ + public static boolean canBeOutputted(ItemStack itemstack, boolean chargeSlot) { + if (itemstack.getItem() instanceof IEnergizedItem) { + IEnergizedItem energized = (IEnergizedItem) itemstack.getItem(); + + if (chargeSlot) { + return energized.getEnergy(itemstack) + == energized.getMaxEnergy(itemstack); + } else { + return energized.getEnergy(itemstack) == 0; + } + } else if (itemstack.getItem() instanceof IEnergyContainerItem) { + IEnergyContainerItem energyContainer + = (IEnergyContainerItem) itemstack.getItem(); + + if (chargeSlot) { + return energyContainer.receiveEnergy(itemstack, 1, true) > 0; + } else { + return energyContainer.extractEnergy(itemstack, 1, true) > 0; + } + } else if (itemstack.getItem() instanceof ISpecialElectricItem) { + IElectricItemManager manager + = ((ISpecialElectricItem) itemstack.getItem()).getManager(itemstack); + + if (manager != null) { + if (chargeSlot) { + return manager.charge(itemstack, 1, 3, true, true) > 0; + } else { + return manager.discharge(itemstack, 1, 3, true, true, true) > 0; + } + } + } + + return true; + } } diff --git a/src/main/java/mekanism/common/util/DebugUtils.java b/src/main/java/mekanism/common/util/DebugUtils.java index 4c8cb263b..55f0f8b06 100644 --- a/src/main/java/mekanism/common/util/DebugUtils.java +++ b/src/main/java/mekanism/common/util/DebugUtils.java @@ -1,26 +1,21 @@ package mekanism.common.util; -public class DebugUtils -{ - private static long prevNanoTime; - - public static void startTracking() - { - prevNanoTime = System.nanoTime(); - } - - public static long getTrackedNanos() - { - return System.nanoTime()-prevNanoTime; - } - - public static long getTrackedMicros() - { - return getTrackedNanos()/1000; - } - - public static long getTrackedMillis() - { - return getTrackedMicros()/1000; - } +public class DebugUtils { + private static long prevNanoTime; + + public static void startTracking() { + prevNanoTime = System.nanoTime(); + } + + public static long getTrackedNanos() { + return System.nanoTime() - prevNanoTime; + } + + public static long getTrackedMicros() { + return getTrackedNanos() / 1000; + } + + public static long getTrackedMillis() { + return getTrackedMicros() / 1000; + } } diff --git a/src/main/java/mekanism/common/util/FluidContainerUtils.java b/src/main/java/mekanism/common/util/FluidContainerUtils.java index a46057381..b2cf3de5a 100644 --- a/src/main/java/mekanism/common/util/FluidContainerUtils.java +++ b/src/main/java/mekanism/common/util/FluidContainerUtils.java @@ -10,299 +10,332 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; import net.minecraftforge.fluids.IFluidContainerItem; -public final class FluidContainerUtils -{ - public static FluidStack extractFluid(FluidTank tileTank, ItemStack container) - { - return extractFluid(tileTank, container, FluidChecker.check(tileTank.getFluid())); - } - - public static FluidStack extractFluid(FluidTank tileTank, ItemStack container, FluidChecker checker) - { - return extractFluid(tileTank.getCapacity()-tileTank.getFluidAmount(), container, checker); - } - - public static FluidStack extractFluid(int needed, ItemStack container, FluidChecker checker) - { - IFluidContainerItem item = (IFluidContainerItem)container.getItem(); - - if(item.getFluid(container) == null) - { - return null; - } - - if(checker != null && !checker.isValid(item.getFluid(container).getFluid())) - { - return null; - } - - return item.drain(container, needed, true); - } - - public static int insertFluid(FluidTank tileTank, ItemStack container) - { - return insertFluid(tileTank.getFluid(), container); - } - - public static int insertFluid(FluidStack fluid, ItemStack container) - { - IFluidContainerItem item = (IFluidContainerItem)container.getItem(); - - if(fluid == null) - { - return 0; - } - - return item.fill(container, fluid, true); - } - - public static void handleContainerItemFill(TileEntityContainerBlock tileEntity, FluidTank tank, int inSlot, int outSlot) - { - tank.setFluid(handleContainerItemFill(tileEntity, tileEntity.inventory, tank.getFluid(), inSlot, outSlot)); - } - - public static FluidStack handleContainerItemFill(TileEntity tileEntity, ItemStack[] inventory, FluidStack stack, int inSlot, int outSlot) - { - if(stack != null) - { - int prev = stack.amount; - - stack.amount -= insertFluid(stack, inventory[inSlot]); - - if(prev == stack.amount || stack.amount == 0) - { - if(inventory[outSlot] == null) - { - inventory[outSlot] = inventory[inSlot].copy(); - inventory[inSlot] = null; - } - } - - if(stack.amount == 0) - { - stack = null; - } - - tileEntity.markDirty(); - } - - return stack; - } - - public static void handleContainerItemEmpty(TileEntityContainerBlock tileEntity, FluidTank tank, int inSlot, int outSlot) - { - handleContainerItemEmpty(tileEntity, tank, inSlot, outSlot, null); - } - - public static void handleContainerItemEmpty(TileEntityContainerBlock tileEntity, FluidTank tank, int inSlot, int outSlot, FluidChecker checker) - { - tank.setFluid(handleContainerItemEmpty(tileEntity, tileEntity.inventory, tank.getFluid(), tank.getCapacity()-tank.getFluidAmount(), inSlot, outSlot, checker)); - } - - public static FluidStack handleContainerItemEmpty(TileEntity tileEntity, ItemStack[] inventory, FluidStack stored, int needed, int inSlot, int outSlot, final FluidChecker checker) - { - final Fluid storedFinal = stored != null ? stored.getFluid() : null; - - FluidStack ret = extractFluid(needed, inventory[inSlot], new FluidChecker() { - @Override - public boolean isValid(Fluid f) - { - return (checker == null || checker.isValid(f)) && (storedFinal == null || storedFinal == f); - } - }); - - if(ret != null) - { - if(stored == null) - { - stored = ret; - } - else { - stored.amount += ret.amount; - } - - needed -= ret.amount; - - tileEntity.markDirty(); - } - - if(((IFluidContainerItem)inventory[inSlot].getItem()).getFluid(inventory[inSlot]) == null || needed == 0) - { - if(inventory[outSlot] == null) - { - inventory[outSlot] = inventory[inSlot].copy(); - inventory[inSlot] = null; - - tileEntity.markDirty(); - } - } - - return stored; - } - - public static void handleRegistryItemFill(TileEntityContainerBlock tileEntity, FluidTank tank, int inSlot, int outSlot) - { - tank.setFluid(handleRegistryItemFill(tileEntity, tileEntity.inventory, tank.getFluid(), inSlot, outSlot)); - } - - public static FluidStack handleRegistryItemFill(TileEntity tileEntity, ItemStack[] inventory, FluidStack stack, int inSlot, int outSlot) - { - if(stack != null) - { - ItemStack filled = FluidContainerRegistry.fillFluidContainer(stack, inventory[inSlot]); - - if(filled != null) - { - if(inventory[outSlot] == null || (StackUtils.equalsWildcardWithNBT(inventory[outSlot], filled) && inventory[outSlot].stackSize+1 <= filled.getMaxStackSize())) - { - inventory[inSlot].stackSize--; +public final class FluidContainerUtils { + public static FluidStack extractFluid(FluidTank tileTank, ItemStack container) { + return extractFluid(tileTank, container, FluidChecker.check(tileTank.getFluid())); + } - if(inventory[inSlot].stackSize <= 0) - { - inventory[inSlot] = null; - } + public static FluidStack + extractFluid(FluidTank tileTank, ItemStack container, FluidChecker checker) { + return extractFluid( + tileTank.getCapacity() - tileTank.getFluidAmount(), container, checker + ); + } - if(inventory[outSlot] == null) - { - inventory[outSlot] = filled; - } - else { - inventory[outSlot].stackSize++; - } + public static FluidStack + extractFluid(int needed, ItemStack container, FluidChecker checker) { + IFluidContainerItem item = (IFluidContainerItem) container.getItem(); - stack.amount -= FluidContainerRegistry.getFluidForFilledItem(filled).amount; - - if(stack.amount == 0) - { - return null; - } - - tileEntity.markDirty(); - } - } - } - - return stack; - } - - public static void handleRegistryItemEmpty(TileEntityContainerBlock tileEntity, FluidTank tank, int inSlot, int outSlot) - { - handleRegistryItemEmpty(tileEntity, tank, inSlot, outSlot, null); - } - - public static void handleRegistryItemEmpty(TileEntityContainerBlock tileEntity, FluidTank tank, int inSlot, int outSlot, FluidChecker checker) - { - tank.setFluid(handleRegistryItemEmpty(tileEntity, tileEntity.inventory, tank.getFluid(), tank.getCapacity()-tank.getFluidAmount(), inSlot, outSlot, checker)); - } - - public static FluidStack handleRegistryItemEmpty(TileEntity tileEntity, ItemStack[] inventory, FluidStack stored, int needed, int inSlot, int outSlot, final FluidChecker checker) - { - FluidStack itemFluid = FluidContainerRegistry.getFluidForFilledItem(inventory[inSlot]); - - if(itemFluid != null && itemFluid.amount <= needed) - { - if((stored != null && !stored.isFluidEqual(itemFluid)) || (checker != null && !checker.isValid(itemFluid.getFluid()))) - { - return stored; - } + if (item.getFluid(container) == null) { + return null; + } - ItemStack containerItem = inventory[inSlot].getItem().getContainerItem(inventory[inSlot]); + if (checker != null && !checker.isValid(item.getFluid(container).getFluid())) { + return null; + } - boolean filled = false; + return item.drain(container, needed, true); + } - if(containerItem != null) - { - if(inventory[outSlot] == null || (StackUtils.equalsWildcardWithNBT(inventory[outSlot], containerItem) && inventory[outSlot].stackSize+1 <= containerItem.getMaxStackSize())) - { - inventory[inSlot] = null; + public static int insertFluid(FluidTank tileTank, ItemStack container) { + return insertFluid(tileTank.getFluid(), container); + } - if(inventory[outSlot] == null) - { - inventory[outSlot] = containerItem; - } - else { - inventory[outSlot].stackSize++; - } + public static int insertFluid(FluidStack fluid, ItemStack container) { + IFluidContainerItem item = (IFluidContainerItem) container.getItem(); - filled = true; - } - } - else { - inventory[inSlot].stackSize--; + if (fluid == null) { + return 0; + } - if(inventory[inSlot].stackSize == 0) - { - inventory[inSlot] = null; - } + return item.fill(container, fluid, true); + } - filled = true; - } + public static void handleContainerItemFill( + TileEntityContainerBlock tileEntity, FluidTank tank, int inSlot, int outSlot + ) { + tank.setFluid(handleContainerItemFill( + tileEntity, tileEntity.inventory, tank.getFluid(), inSlot, outSlot + )); + } - if(filled) - { - if(stored == null) - { - stored = itemFluid.copy(); - } - else { - stored.amount += itemFluid.amount; - } - - tileEntity.markDirty(); - } - } - - return stored; - } - - public static enum ContainerEditMode - { - BOTH("fluidedit.both"), - FILL("fluidedit.fill"), - EMPTY("fluidedit.empty"); - - private String display; + public static FluidStack handleContainerItemFill( + TileEntity tileEntity, + ItemStack[] inventory, + FluidStack stack, + int inSlot, + int outSlot + ) { + if (stack != null) { + int prev = stack.amount; - public String getDisplay() - { - return LangUtils.localize(display); - } + stack.amount -= insertFluid(stack, inventory[inSlot]); - private ContainerEditMode(String s) - { - display = s; - } - } - - public static class FluidChecker - { - public boolean isValid(Fluid f) - { - return true; - } - - public static FluidChecker check(FluidStack fluid) - { - final Fluid type = fluid != null ? fluid.getFluid() : null; - - return new FluidChecker() { - @Override - public boolean isValid(Fluid f) - { - return type == null || type == f; - } - }; - } - - public static FluidChecker check(final Fluid type) - { - return new FluidChecker() { - @Override - public boolean isValid(Fluid f) - { - return type == null || type == f; - } - }; - } - } + if (prev == stack.amount || stack.amount == 0) { + if (inventory[outSlot] == null) { + inventory[outSlot] = inventory[inSlot].copy(); + inventory[inSlot] = null; + } + } + + if (stack.amount == 0) { + stack = null; + } + + tileEntity.markDirty(); + } + + return stack; + } + + public static void handleContainerItemEmpty( + TileEntityContainerBlock tileEntity, FluidTank tank, int inSlot, int outSlot + ) { + handleContainerItemEmpty(tileEntity, tank, inSlot, outSlot, null); + } + + public static void handleContainerItemEmpty( + TileEntityContainerBlock tileEntity, + FluidTank tank, + int inSlot, + int outSlot, + FluidChecker checker + ) { + tank.setFluid(handleContainerItemEmpty( + tileEntity, + tileEntity.inventory, + tank.getFluid(), + tank.getCapacity() - tank.getFluidAmount(), + inSlot, + outSlot, + checker + )); + } + + public static FluidStack handleContainerItemEmpty( + TileEntity tileEntity, + ItemStack[] inventory, + FluidStack stored, + int needed, + int inSlot, + int outSlot, + final FluidChecker checker + ) { + final Fluid storedFinal = stored != null ? stored.getFluid() : null; + + FluidStack ret = extractFluid(needed, inventory[inSlot], new FluidChecker() { + @Override + public boolean isValid(Fluid f) { + return (checker == null || checker.isValid(f)) + && (storedFinal == null || storedFinal == f); + } + }); + + if (ret != null) { + if (stored == null) { + stored = ret; + } else { + stored.amount += ret.amount; + } + + needed -= ret.amount; + + tileEntity.markDirty(); + } + + if (((IFluidContainerItem) inventory[inSlot].getItem()) + .getFluid(inventory[inSlot]) + == null + || needed == 0) { + if (inventory[outSlot] == null) { + inventory[outSlot] = inventory[inSlot].copy(); + inventory[inSlot] = null; + + tileEntity.markDirty(); + } + } + + return stored; + } + + public static void handleRegistryItemFill( + TileEntityContainerBlock tileEntity, FluidTank tank, int inSlot, int outSlot + ) { + tank.setFluid(handleRegistryItemFill( + tileEntity, tileEntity.inventory, tank.getFluid(), inSlot, outSlot + )); + } + + public static FluidStack handleRegistryItemFill( + TileEntity tileEntity, + ItemStack[] inventory, + FluidStack stack, + int inSlot, + int outSlot + ) { + if (stack != null) { + ItemStack filled + = FluidContainerRegistry.fillFluidContainer(stack, inventory[inSlot]); + + if (filled != null) { + if (inventory[outSlot] == null + || (StackUtils.equalsWildcardWithNBT(inventory[outSlot], filled) + && inventory[outSlot].stackSize + 1 <= filled.getMaxStackSize() + )) { + inventory[inSlot].stackSize--; + + if (inventory[inSlot].stackSize <= 0) { + inventory[inSlot] = null; + } + + if (inventory[outSlot] == null) { + inventory[outSlot] = filled; + } else { + inventory[outSlot].stackSize++; + } + + stack.amount + -= FluidContainerRegistry.getFluidForFilledItem(filled).amount; + + if (stack.amount == 0) { + return null; + } + + tileEntity.markDirty(); + } + } + } + + return stack; + } + + public static void handleRegistryItemEmpty( + TileEntityContainerBlock tileEntity, FluidTank tank, int inSlot, int outSlot + ) { + handleRegistryItemEmpty(tileEntity, tank, inSlot, outSlot, null); + } + + public static void handleRegistryItemEmpty( + TileEntityContainerBlock tileEntity, + FluidTank tank, + int inSlot, + int outSlot, + FluidChecker checker + ) { + tank.setFluid(handleRegistryItemEmpty( + tileEntity, + tileEntity.inventory, + tank.getFluid(), + tank.getCapacity() - tank.getFluidAmount(), + inSlot, + outSlot, + checker + )); + } + + public static FluidStack handleRegistryItemEmpty( + TileEntity tileEntity, + ItemStack[] inventory, + FluidStack stored, + int needed, + int inSlot, + int outSlot, + final FluidChecker checker + ) { + FluidStack itemFluid + = FluidContainerRegistry.getFluidForFilledItem(inventory[inSlot]); + + if (itemFluid != null && itemFluid.amount <= needed) { + if ((stored != null && !stored.isFluidEqual(itemFluid)) + || (checker != null && !checker.isValid(itemFluid.getFluid()))) { + return stored; + } + + ItemStack containerItem + = inventory[inSlot].getItem().getContainerItem(inventory[inSlot]); + + boolean filled = false; + + if (containerItem != null) { + if (inventory[outSlot] == null + || (StackUtils.equalsWildcardWithNBT( + inventory[outSlot], containerItem + ) + && inventory[outSlot].stackSize + 1 + <= containerItem.getMaxStackSize())) { + inventory[inSlot] = null; + + if (inventory[outSlot] == null) { + inventory[outSlot] = containerItem; + } else { + inventory[outSlot].stackSize++; + } + + filled = true; + } + } else { + inventory[inSlot].stackSize--; + + if (inventory[inSlot].stackSize == 0) { + inventory[inSlot] = null; + } + + filled = true; + } + + if (filled) { + if (stored == null) { + stored = itemFluid.copy(); + } else { + stored.amount += itemFluid.amount; + } + + tileEntity.markDirty(); + } + } + + return stored; + } + + public static enum ContainerEditMode { + BOTH("fluidedit.both"), + FILL("fluidedit.fill"), + EMPTY("fluidedit.empty"); + + private String display; + + public String getDisplay() { + return LangUtils.localize(display); + } + + private ContainerEditMode(String s) { + display = s; + } + } + + public static class FluidChecker { + public boolean isValid(Fluid f) { + return true; + } + + public static FluidChecker check(FluidStack fluid) { + final Fluid type = fluid != null ? fluid.getFluid() : null; + + return new FluidChecker() { + @Override + public boolean isValid(Fluid f) { + return type == null || type == f; + } + }; + } + + public static FluidChecker check(final Fluid type) { + return new FluidChecker() { + @Override + public boolean isValid(Fluid f) { + return type == null || type == f; + } + }; + } + } } diff --git a/src/main/java/mekanism/common/util/HeatUtils.java b/src/main/java/mekanism/common/util/HeatUtils.java index 507dd661c..1da246d0e 100644 --- a/src/main/java/mekanism/common/util/HeatUtils.java +++ b/src/main/java/mekanism/common/util/HeatUtils.java @@ -4,38 +4,36 @@ import mekanism.api.IHeatTransfer; import mekanism.api.transmitters.ITransmitterTile; import net.minecraftforge.common.util.ForgeDirection; -public class HeatUtils -{ - public static double[] simulate(IHeatTransfer source) - { - double heatTransferred[] = new double[] {0, 0}; - - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - IHeatTransfer sink = source.getAdjacent(side); - - if(sink != null) - { - double invConduction = sink.getInverseConductionCoefficient() + source.getInverseConductionCoefficient(); - double heatToTransfer = source.getTemp() / invConduction; - source.transferHeatTo(-heatToTransfer); - sink.transferHeatTo(heatToTransfer); - - if(!(sink instanceof ITransmitterTile)) - { - heatTransferred[0] += heatToTransfer; - } - - continue; - } - - //Transfer to air otherwise - double invConduction = IHeatTransfer.AIR_INVERSE_COEFFICIENT + source.getInsulationCoefficient(side) + source.getInverseConductionCoefficient(); - double heatToTransfer = source.getTemp() / invConduction; - source.transferHeatTo(-heatToTransfer); - heatTransferred[1] += heatToTransfer; - } - - return heatTransferred; - } +public class HeatUtils { + public static double[] simulate(IHeatTransfer source) { + double heatTransferred[] = new double[] { 0, 0 }; + + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + IHeatTransfer sink = source.getAdjacent(side); + + if (sink != null) { + double invConduction = sink.getInverseConductionCoefficient() + + source.getInverseConductionCoefficient(); + double heatToTransfer = source.getTemp() / invConduction; + source.transferHeatTo(-heatToTransfer); + sink.transferHeatTo(heatToTransfer); + + if (!(sink instanceof ITransmitterTile)) { + heatTransferred[0] += heatToTransfer; + } + + continue; + } + + //Transfer to air otherwise + double invConduction = IHeatTransfer.AIR_INVERSE_COEFFICIENT + + source.getInsulationCoefficient(side) + + source.getInverseConductionCoefficient(); + double heatToTransfer = source.getTemp() / invConduction; + source.transferHeatTo(-heatToTransfer); + heatTransferred[1] += heatToTransfer; + } + + return heatTransferred; + } } diff --git a/src/main/java/mekanism/common/util/InventoryUtils.java b/src/main/java/mekanism/common/util/InventoryUtils.java index 205ac5d6d..7fd1b5e72 100644 --- a/src/main/java/mekanism/common/util/InventoryUtils.java +++ b/src/main/java/mekanism/common/util/InventoryUtils.java @@ -15,528 +15,490 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntityChest; import net.minecraftforge.common.util.ForgeDirection; -public final class InventoryUtils -{ - public static final int[] EMPTY = new int[] {}; +public final class InventoryUtils { + public static final int[] EMPTY = new int[] {}; - public static int[] getIntRange(int start, int end) - { - int[] ret = new int[1 + end - start]; + public static int[] getIntRange(int start, int end) { + int[] ret = new int[1 + end - start]; - for(int i = start; i <= end; i++) - { - ret[i - start] = i; - } + for (int i = start; i <= end; i++) { + ret[i - start] = i; + } - return ret; - } + return ret; + } - public static IInventory checkChestInv(IInventory inv) - { - if(inv instanceof TileEntityChest) - { - TileEntityChest main = (TileEntityChest)inv; - TileEntityChest adj = null; + public static IInventory checkChestInv(IInventory inv) { + if (inv instanceof TileEntityChest) { + TileEntityChest main = (TileEntityChest) inv; + TileEntityChest adj = null; - if(main.adjacentChestXNeg != null) - { - adj = main.adjacentChestXNeg; - } - else if(main.adjacentChestXPos != null) - { - adj = main.adjacentChestXPos; - } - else if(main.adjacentChestZNeg != null) - { - adj = main.adjacentChestZNeg; - } - else if(main.adjacentChestZPos != null) - { - adj = main.adjacentChestZPos; - } + if (main.adjacentChestXNeg != null) { + adj = main.adjacentChestXNeg; + } else if (main.adjacentChestXPos != null) { + adj = main.adjacentChestXPos; + } else if (main.adjacentChestZNeg != null) { + adj = main.adjacentChestZNeg; + } else if (main.adjacentChestZPos != null) { + adj = main.adjacentChestZPos; + } - if(adj != null) - { - return new InventoryLargeChest("", main, adj); - } - } + if (adj != null) { + return new InventoryLargeChest("", main, adj); + } + } - return inv; - } + return inv; + } - public static ItemStack putStackInInventory(IInventory inventory, ItemStack itemStack, int side, boolean force) - { - inventory = checkChestInv(inventory); + public static ItemStack putStackInInventory( + IInventory inventory, ItemStack itemStack, int side, boolean force + ) { + inventory = checkChestInv(inventory); - if(force && inventory instanceof TileEntityLogisticalSorter) - { - return ((TileEntityLogisticalSorter)inventory).sendHome(itemStack.copy()); - } + if (force && inventory instanceof TileEntityLogisticalSorter) { + return ((TileEntityLogisticalSorter) inventory).sendHome(itemStack.copy()); + } - ItemStack toInsert = itemStack.copy(); + ItemStack toInsert = itemStack.copy(); - if(!(inventory instanceof ISidedInventory)) - { - for(int i = 0; i <= inventory.getSizeInventory() - 1; i++) - { - if(!force) - { - if(!inventory.isItemValidForSlot(i, toInsert)) - { - continue; - } - } + if (!(inventory instanceof ISidedInventory)) { + for (int i = 0; i <= inventory.getSizeInventory() - 1; i++) { + if (!force) { + if (!inventory.isItemValidForSlot(i, toInsert)) { + continue; + } + } - ItemStack inSlot = inventory.getStackInSlot(i); + ItemStack inSlot = inventory.getStackInSlot(i); - if(inSlot == null) - { - if(toInsert.stackSize <= inventory.getInventoryStackLimit()) - { - inventory.setInventorySlotContents(i, toInsert); - inventory.markDirty(); - - return null; - } - else { - int rejects = toInsert.stackSize - inventory.getInventoryStackLimit(); - - ItemStack toSet = toInsert.copy(); - toSet.stackSize = inventory.getInventoryStackLimit(); + if (inSlot == null) { + if (toInsert.stackSize <= inventory.getInventoryStackLimit()) { + inventory.setInventorySlotContents(i, toInsert); + inventory.markDirty(); - ItemStack remains = toInsert.copy(); - remains.stackSize = rejects; + return null; + } else { + int rejects + = toInsert.stackSize - inventory.getInventoryStackLimit(); - inventory.setInventorySlotContents(i, toSet); - inventory.markDirty(); + ItemStack toSet = toInsert.copy(); + toSet.stackSize = inventory.getInventoryStackLimit(); - toInsert = remains; - } - } + ItemStack remains = toInsert.copy(); + remains.stackSize = rejects; + + inventory.setInventorySlotContents(i, toSet); + inventory.markDirty(); + + toInsert = remains; + } + } else if(areItemsStackable(toInsert, inSlot) && inSlot.stackSize < Math.min(inSlot.getMaxStackSize(), inventory.getInventoryStackLimit())) { - int max = Math.min(inSlot.getMaxStackSize(), inventory.getInventoryStackLimit()); - - if(inSlot.stackSize + toInsert.stackSize <= max) - { - ItemStack toSet = toInsert.copy(); - toSet.stackSize += inSlot.stackSize; + int max = Math.min( + inSlot.getMaxStackSize(), inventory.getInventoryStackLimit() + ); - inventory.setInventorySlotContents(i, toSet); - inventory.markDirty(); - - return null; - } - else { - int rejects = (inSlot.stackSize + toInsert.stackSize) - max; + if (inSlot.stackSize + toInsert.stackSize <= max) { + ItemStack toSet = toInsert.copy(); + toSet.stackSize += inSlot.stackSize; - ItemStack toSet = toInsert.copy(); - toSet.stackSize = max; + inventory.setInventorySlotContents(i, toSet); + inventory.markDirty(); - ItemStack remains = toInsert.copy(); - remains.stackSize = rejects; + return null; + } else { + int rejects = (inSlot.stackSize + toInsert.stackSize) - max; - inventory.setInventorySlotContents(i, toSet); - inventory.markDirty(); + ItemStack toSet = toInsert.copy(); + toSet.stackSize = max; - toInsert = remains; - } - } - } - } - else { - ISidedInventory sidedInventory = (ISidedInventory)inventory; - int[] slots = sidedInventory.getAccessibleSlotsFromSide(ForgeDirection.OPPOSITES[side]); + ItemStack remains = toInsert.copy(); + remains.stackSize = rejects; - if(slots != null && slots.length != 0) - { - if(force && sidedInventory instanceof TileEntityBin && ForgeDirection.OPPOSITES[side] == 0) - { - slots = sidedInventory.getAccessibleSlotsFromSide(1); - } + inventory.setInventorySlotContents(i, toSet); + inventory.markDirty(); - for(int get = 0; get <= slots.length - 1; get++) - { - int slotID = slots[get]; + toInsert = remains; + } + } + } + } else { + ISidedInventory sidedInventory = (ISidedInventory) inventory; + int[] slots + = sidedInventory.getAccessibleSlotsFromSide(ForgeDirection.OPPOSITES[side] + ); - if(!force) - { - if(!sidedInventory.isItemValidForSlot(slotID, toInsert) || !sidedInventory.canInsertItem(slotID, toInsert, ForgeDirection.OPPOSITES[side])) - { - continue; - } - } + if (slots != null && slots.length != 0) { + if (force && sidedInventory instanceof TileEntityBin + && ForgeDirection.OPPOSITES[side] == 0) { + slots = sidedInventory.getAccessibleSlotsFromSide(1); + } - ItemStack inSlot = inventory.getStackInSlot(slotID); + for (int get = 0; get <= slots.length - 1; get++) { + int slotID = slots[get]; - if(inSlot == null) - { - if(toInsert.stackSize <= inventory.getInventoryStackLimit()) - { - inventory.setInventorySlotContents(slotID, toInsert); - inventory.markDirty(); - - return null; - } - else { - int rejects = toInsert.stackSize - inventory.getInventoryStackLimit(); - - ItemStack toSet = toInsert.copy(); - toSet.stackSize = inventory.getInventoryStackLimit(); + if (!force) { + if (!sidedInventory.isItemValidForSlot(slotID, toInsert) + || !sidedInventory.canInsertItem( + slotID, toInsert, ForgeDirection.OPPOSITES[side] + )) { + continue; + } + } - ItemStack remains = toInsert.copy(); - remains.stackSize = rejects; + ItemStack inSlot = inventory.getStackInSlot(slotID); - inventory.setInventorySlotContents(slotID, toSet); - inventory.markDirty(); + if (inSlot == null) { + if (toInsert.stackSize <= inventory.getInventoryStackLimit()) { + inventory.setInventorySlotContents(slotID, toInsert); + inventory.markDirty(); - toInsert = remains; - } - } + return null; + } else { + int rejects + = toInsert.stackSize - inventory.getInventoryStackLimit(); + + ItemStack toSet = toInsert.copy(); + toSet.stackSize = inventory.getInventoryStackLimit(); + + ItemStack remains = toInsert.copy(); + remains.stackSize = rejects; + + inventory.setInventorySlotContents(slotID, toSet); + inventory.markDirty(); + + toInsert = remains; + } + } else if(areItemsStackable(toInsert, inSlot) && inSlot.stackSize < Math.min(inSlot.getMaxStackSize(), inventory.getInventoryStackLimit())) { - int max = Math.min(inSlot.getMaxStackSize(), inventory.getInventoryStackLimit()); - - if(inSlot.stackSize + toInsert.stackSize <= max) - { - ItemStack toSet = toInsert.copy(); - toSet.stackSize += inSlot.stackSize; + int max = Math.min( + inSlot.getMaxStackSize(), inventory.getInventoryStackLimit() + ); - inventory.setInventorySlotContents(slotID, toSet); - inventory.markDirty(); - - return null; - } - else { - int rejects = (inSlot.stackSize + toInsert.stackSize) - max; + if (inSlot.stackSize + toInsert.stackSize <= max) { + ItemStack toSet = toInsert.copy(); + toSet.stackSize += inSlot.stackSize; - ItemStack toSet = toInsert.copy(); - toSet.stackSize = max; + inventory.setInventorySlotContents(slotID, toSet); + inventory.markDirty(); - ItemStack remains = toInsert.copy(); - remains.stackSize = rejects; + return null; + } else { + int rejects = (inSlot.stackSize + toInsert.stackSize) - max; - inventory.setInventorySlotContents(slotID, toSet); - inventory.markDirty(); + ItemStack toSet = toInsert.copy(); + toSet.stackSize = max; - toInsert = remains; - } - } - } - } - } + ItemStack remains = toInsert.copy(); + remains.stackSize = rejects; - return toInsert; - } + inventory.setInventorySlotContents(slotID, toSet); + inventory.markDirty(); - public static boolean areItemsStackable(ItemStack toInsert, ItemStack inSlot) - { - return inSlot.isItemEqual(toInsert) && ItemStack.areItemStackTagsEqual(inSlot, toInsert); - } + toInsert = remains; + } + } + } + } + } - public static InvStack takeTopItem(IInventory inventory, int side, int amount) - { - inventory = checkChestInv(inventory); + return toInsert; + } - if(!(inventory instanceof ISidedInventory)) - { - for(int i = inventory.getSizeInventory() - 1; i >= 0; i--) - { - if(inventory.getStackInSlot(i) != null && inventory.getStackInSlot(i).stackSize > 0) - { - ItemStack toSend = inventory.getStackInSlot(i).copy(); - toSend.stackSize = Math.min(amount, toSend.stackSize); + public static boolean areItemsStackable(ItemStack toInsert, ItemStack inSlot) { + return inSlot.isItemEqual(toInsert) + && ItemStack.areItemStackTagsEqual(inSlot, toInsert); + } - return new InvStack(inventory, i, toSend); - } - } - } - else { - ISidedInventory sidedInventory = (ISidedInventory)inventory; - int[] slots = sidedInventory.getAccessibleSlotsFromSide(ForgeDirection.OPPOSITES[side]); + public static InvStack takeTopItem(IInventory inventory, int side, int amount) { + inventory = checkChestInv(inventory); - if(slots != null) - { - for(int get = slots.length - 1; get >= 0; get--) - { - int slotID = slots[get]; + if (!(inventory instanceof ISidedInventory)) { + for (int i = inventory.getSizeInventory() - 1; i >= 0; i--) { + if (inventory.getStackInSlot(i) != null + && inventory.getStackInSlot(i).stackSize > 0) { + ItemStack toSend = inventory.getStackInSlot(i).copy(); + toSend.stackSize = Math.min(amount, toSend.stackSize); - if(sidedInventory.getStackInSlot(slotID) != null && sidedInventory.getStackInSlot(slotID).stackSize > 0) - { - ItemStack toSend = sidedInventory.getStackInSlot(slotID).copy(); - toSend.stackSize = Math.min(amount, toSend.stackSize); + return new InvStack(inventory, i, toSend); + } + } + } else { + ISidedInventory sidedInventory = (ISidedInventory) inventory; + int[] slots + = sidedInventory.getAccessibleSlotsFromSide(ForgeDirection.OPPOSITES[side] + ); - if(sidedInventory.canExtractItem(slotID, toSend, ForgeDirection.OPPOSITES[side])) - { - return new InvStack(inventory, slotID, toSend); - } - } - } - } - } + if (slots != null) { + for (int get = slots.length - 1; get >= 0; get--) { + int slotID = slots[get]; - return null; - } + if (sidedInventory.getStackInSlot(slotID) != null + && sidedInventory.getStackInSlot(slotID).stackSize > 0) { + ItemStack toSend = sidedInventory.getStackInSlot(slotID).copy(); + toSend.stackSize = Math.min(amount, toSend.stackSize); - public static InvStack takeDefinedItem(IInventory inventory, int side, ItemStack type, int min, int max) - { - inventory = checkChestInv(inventory); + if (sidedInventory.canExtractItem( + slotID, toSend, ForgeDirection.OPPOSITES[side] + )) { + return new InvStack(inventory, slotID, toSend); + } + } + } + } + } - InvStack ret = new InvStack(inventory); + return null; + } - if(!(inventory instanceof ISidedInventory)) - { - for(int i = inventory.getSizeInventory() - 1; i >= 0; i--) - { - if(inventory.getStackInSlot(i) != null && StackUtils.equalsWildcard(inventory.getStackInSlot(i), type)) - { - ItemStack stack = inventory.getStackInSlot(i); - int current = ret.getStack() != null ? ret.getStack().stackSize : 0; + public static InvStack + takeDefinedItem(IInventory inventory, int side, ItemStack type, int min, int max) { + inventory = checkChestInv(inventory); - if(current+stack.stackSize <= max) - { - ret.appendStack(i, stack.copy()); - } - else { - ItemStack copy = stack.copy(); - copy.stackSize = max-current; - ret.appendStack(i, copy); - } + InvStack ret = new InvStack(inventory); - if(ret.getStack() != null && ret.getStack().stackSize == max) - { - return ret; - } - } - } - } - else { - ISidedInventory sidedInventory = (ISidedInventory)inventory; - int[] slots = sidedInventory.getAccessibleSlotsFromSide(ForgeDirection.OPPOSITES[side]); + if (!(inventory instanceof ISidedInventory)) { + for (int i = inventory.getSizeInventory() - 1; i >= 0; i--) { + if (inventory.getStackInSlot(i) != null + && StackUtils.equalsWildcard(inventory.getStackInSlot(i), type)) { + ItemStack stack = inventory.getStackInSlot(i); + int current = ret.getStack() != null ? ret.getStack().stackSize : 0; - if(slots != null && slots.length != 0) - { - for(int get = slots.length - 1; get >= 0; get--) - { - int slotID = slots[get]; + if (current + stack.stackSize <= max) { + ret.appendStack(i, stack.copy()); + } else { + ItemStack copy = stack.copy(); + copy.stackSize = max - current; + ret.appendStack(i, copy); + } - if(sidedInventory.getStackInSlot(slotID) != null && StackUtils.equalsWildcard(inventory.getStackInSlot(slotID), type)) - { - ItemStack stack = sidedInventory.getStackInSlot(slotID); - int current = ret.getStack() != null ? ret.getStack().stackSize : 0; + if (ret.getStack() != null && ret.getStack().stackSize == max) { + return ret; + } + } + } + } else { + ISidedInventory sidedInventory = (ISidedInventory) inventory; + int[] slots + = sidedInventory.getAccessibleSlotsFromSide(ForgeDirection.OPPOSITES[side] + ); - if(current+stack.stackSize <= max) - { - ItemStack copy = stack.copy(); + if (slots != null && slots.length != 0) { + for (int get = slots.length - 1; get >= 0; get--) { + int slotID = slots[get]; - if(sidedInventory.canExtractItem(slotID, copy, ForgeDirection.OPPOSITES[side])) - { - ret.appendStack(slotID, copy); - } - } - else { - ItemStack copy = stack.copy(); + if (sidedInventory.getStackInSlot(slotID) != null + && StackUtils.equalsWildcard( + inventory.getStackInSlot(slotID), type + )) { + ItemStack stack = sidedInventory.getStackInSlot(slotID); + int current + = ret.getStack() != null ? ret.getStack().stackSize : 0; - if(sidedInventory.canExtractItem(slotID, copy, ForgeDirection.OPPOSITES[side])) - { - copy.stackSize = max-current; - ret.appendStack(slotID, copy); - } - } + if (current + stack.stackSize <= max) { + ItemStack copy = stack.copy(); - if(ret.getStack() != null && ret.getStack().stackSize == max) - { - return ret; - } - } - } - } - } + if (sidedInventory.canExtractItem( + slotID, copy, ForgeDirection.OPPOSITES[side] + )) { + ret.appendStack(slotID, copy); + } + } else { + ItemStack copy = stack.copy(); - if(ret != null && ret.getStack() != null && ret.getStack().stackSize >= min) - { - return ret; - } + if (sidedInventory.canExtractItem( + slotID, copy, ForgeDirection.OPPOSITES[side] + )) { + copy.stackSize = max - current; + ret.appendStack(slotID, copy); + } + } - return null; - } + if (ret.getStack() != null && ret.getStack().stackSize == max) { + return ret; + } + } + } + } + } - public static InvStack takeTopStack(IInventory inventory, int side, Finder id) - { - inventory = checkChestInv(inventory); + if (ret != null && ret.getStack() != null && ret.getStack().stackSize >= min) { + return ret; + } - if(!(inventory instanceof ISidedInventory)) - { - for(int i = inventory.getSizeInventory() - 1; i >= 0; i--) - { - if(inventory.getStackInSlot(i) != null && id.modifies(inventory.getStackInSlot(i))) - { - ItemStack toSend = inventory.getStackInSlot(i).copy(); - return new InvStack(inventory, i, toSend); - } - } - } - else { - ISidedInventory sidedInventory = (ISidedInventory)inventory; - int[] slots = sidedInventory.getAccessibleSlotsFromSide(ForgeDirection.OPPOSITES[side]); + return null; + } - if(slots != null && slots.length != 0) - { - for(int get = slots.length - 1; get >= 0; get--) - { - int slotID = slots[get]; + public static InvStack takeTopStack(IInventory inventory, int side, Finder id) { + inventory = checkChestInv(inventory); - if(sidedInventory.getStackInSlot(slotID) != null && id.modifies(sidedInventory.getStackInSlot(slotID))) - { - ItemStack toSend = sidedInventory.getStackInSlot(slotID); + if (!(inventory instanceof ISidedInventory)) { + for (int i = inventory.getSizeInventory() - 1; i >= 0; i--) { + if (inventory.getStackInSlot(i) != null + && id.modifies(inventory.getStackInSlot(i))) { + ItemStack toSend = inventory.getStackInSlot(i).copy(); + return new InvStack(inventory, i, toSend); + } + } + } else { + ISidedInventory sidedInventory = (ISidedInventory) inventory; + int[] slots + = sidedInventory.getAccessibleSlotsFromSide(ForgeDirection.OPPOSITES[side] + ); - if(sidedInventory.canExtractItem(slotID, toSend, ForgeDirection.OPPOSITES[side])) - { - return new InvStack(inventory, slotID, toSend); - } - } - } - } - } + if (slots != null && slots.length != 0) { + for (int get = slots.length - 1; get >= 0; get--) { + int slotID = slots[get]; - return null; - } + if (sidedInventory.getStackInSlot(slotID) != null + && id.modifies(sidedInventory.getStackInSlot(slotID))) { + ItemStack toSend = sidedInventory.getStackInSlot(slotID); - public static boolean canInsert(TileEntity tileEntity, EnumColor color, ItemStack itemStack, int side, boolean force) - { - if(!(tileEntity instanceof IInventory)) - { - return false; - } + if (sidedInventory.canExtractItem( + slotID, toSend, ForgeDirection.OPPOSITES[side] + )) { + return new InvStack(inventory, slotID, toSend); + } + } + } + } + } - if(force && tileEntity instanceof TileEntityLogisticalSorter) - { - return ((TileEntityLogisticalSorter)tileEntity).canSendHome(itemStack); - } + return null; + } - if(!force && tileEntity instanceof ISideConfiguration) - { - ISideConfiguration config = (ISideConfiguration)tileEntity; - int tileSide = config.getOrientation(); - EnumColor configColor = config.getEjector().getInputColor(ForgeDirection.getOrientation(MekanismUtils.getBaseOrientation(side, tileSide)).getOpposite()); + public static boolean canInsert( + TileEntity tileEntity, + EnumColor color, + ItemStack itemStack, + int side, + boolean force + ) { + if (!(tileEntity instanceof IInventory)) { + return false; + } - if(config.getEjector().hasStrictInput() && configColor != null && configColor != color) - { - return false; - } - } + if (force && tileEntity instanceof TileEntityLogisticalSorter) { + return ((TileEntityLogisticalSorter) tileEntity).canSendHome(itemStack); + } - IInventory inventory = checkChestInv((IInventory)tileEntity); + if (!force && tileEntity instanceof ISideConfiguration) { + ISideConfiguration config = (ISideConfiguration) tileEntity; + int tileSide = config.getOrientation(); + EnumColor configColor = config.getEjector().getInputColor( + ForgeDirection + .getOrientation(MekanismUtils.getBaseOrientation(side, tileSide)) + .getOpposite() + ); - if(!(inventory instanceof ISidedInventory)) - { - for(int i = 0; i <= inventory.getSizeInventory() - 1; i++) - { - if(!force) - { - if(!inventory.isItemValidForSlot(i, itemStack)) - { - continue; - } - } + if (config.getEjector().hasStrictInput() && configColor != null + && configColor != color) { + return false; + } + } - ItemStack inSlot = inventory.getStackInSlot(i); + IInventory inventory = checkChestInv((IInventory) tileEntity); - if(inSlot == null) - { - if(itemStack.stackSize <= inventory.getInventoryStackLimit()) - { - return true; - } - else { - int rejects = itemStack.stackSize - inventory.getInventoryStackLimit(); - - if(rejects < itemStack.stackSize) - { - return true; - } - } - } + if (!(inventory instanceof ISidedInventory)) { + for (int i = 0; i <= inventory.getSizeInventory() - 1; i++) { + if (!force) { + if (!inventory.isItemValidForSlot(i, itemStack)) { + continue; + } + } + + ItemStack inSlot = inventory.getStackInSlot(i); + + if (inSlot == null) { + if (itemStack.stackSize <= inventory.getInventoryStackLimit()) { + return true; + } else { + int rejects + = itemStack.stackSize - inventory.getInventoryStackLimit(); + + if (rejects < itemStack.stackSize) { + return true; + } + } + } else if(areItemsStackable(itemStack, inSlot) && inSlot.stackSize < Math.min(inSlot.getMaxStackSize(), inventory.getInventoryStackLimit())) { - int max = Math.min(inSlot.getMaxStackSize(), inventory.getInventoryStackLimit()); - - if(inSlot.stackSize + itemStack.stackSize <= max) - { - return true; - } - else { - int rejects = (inSlot.stackSize + itemStack.stackSize) - max; + int max = Math.min( + inSlot.getMaxStackSize(), inventory.getInventoryStackLimit() + ); - if(rejects < itemStack.stackSize) - { - return true; - } - } - } - } - } - else { - ISidedInventory sidedInventory = (ISidedInventory)inventory; - int[] slots = sidedInventory.getAccessibleSlotsFromSide(ForgeDirection.OPPOSITES[side]); + if (inSlot.stackSize + itemStack.stackSize <= max) { + return true; + } else { + int rejects = (inSlot.stackSize + itemStack.stackSize) - max; - if(slots != null && slots.length != 0) - { - if(force && sidedInventory instanceof TileEntityBin && ForgeDirection.OPPOSITES[side] == 0) - { - slots = sidedInventory.getAccessibleSlotsFromSide(1); - } + if (rejects < itemStack.stackSize) { + return true; + } + } + } + } + } else { + ISidedInventory sidedInventory = (ISidedInventory) inventory; + int[] slots + = sidedInventory.getAccessibleSlotsFromSide(ForgeDirection.OPPOSITES[side] + ); - for(int get = 0; get <= slots.length - 1; get++) - { - int slotID = slots[get]; + if (slots != null && slots.length != 0) { + if (force && sidedInventory instanceof TileEntityBin + && ForgeDirection.OPPOSITES[side] == 0) { + slots = sidedInventory.getAccessibleSlotsFromSide(1); + } - if(!force) - { - if(!sidedInventory.isItemValidForSlot(slotID, itemStack) || !sidedInventory.canInsertItem(slotID, itemStack, ForgeDirection.OPPOSITES[side])) - { - continue; - } - } + for (int get = 0; get <= slots.length - 1; get++) { + int slotID = slots[get]; - ItemStack inSlot = inventory.getStackInSlot(slotID); + if (!force) { + if (!sidedInventory.isItemValidForSlot(slotID, itemStack) + || !sidedInventory.canInsertItem( + slotID, itemStack, ForgeDirection.OPPOSITES[side] + )) { + continue; + } + } - if(inSlot == null) - { - if(itemStack.stackSize <= inventory.getInventoryStackLimit()) - { - return true; - } - else { - int rejects = itemStack.stackSize - inventory.getInventoryStackLimit(); - - if(rejects < itemStack.stackSize) - { - return true; - } - } - } + ItemStack inSlot = inventory.getStackInSlot(slotID); + + if (inSlot == null) { + if (itemStack.stackSize <= inventory.getInventoryStackLimit()) { + return true; + } else { + int rejects = itemStack.stackSize + - inventory.getInventoryStackLimit(); + + if (rejects < itemStack.stackSize) { + return true; + } + } + } else if(areItemsStackable(itemStack, inSlot) && inSlot.stackSize < Math.min(inSlot.getMaxStackSize(), inventory.getInventoryStackLimit())) { - int max = Math.min(inSlot.getMaxStackSize(), inventory.getInventoryStackLimit()); - - if(inSlot.stackSize + itemStack.stackSize <= max) - { - return true; - } - else { - int rejects = (inSlot.stackSize + itemStack.stackSize) - max; + int max = Math.min( + inSlot.getMaxStackSize(), inventory.getInventoryStackLimit() + ); - if(rejects < itemStack.stackSize) - { - return true; - } - } - } - } - } - } + if (inSlot.stackSize + itemStack.stackSize <= max) { + return true; + } else { + int rejects = (inSlot.stackSize + itemStack.stackSize) - max; - return false; - } + if (rejects < itemStack.stackSize) { + return true; + } + } + } + } + } + } + + return false; + } } diff --git a/src/main/java/mekanism/common/util/LangUtils.java b/src/main/java/mekanism/common/util/LangUtils.java index aef0132ac..0bf3d09c5 100644 --- a/src/main/java/mekanism/common/util/LangUtils.java +++ b/src/main/java/mekanism/common/util/LangUtils.java @@ -4,40 +4,37 @@ import mekanism.api.gas.GasStack; import net.minecraft.util.StatCollector; import net.minecraftforge.fluids.FluidStack; -public final class LangUtils -{ - public static String transOnOff(boolean b) - { - return LangUtils.localize("gui." + (b ? "on" : "off")); - } - - public static String transYesNo(boolean b) - { - return LangUtils.localize("tooltip." + (b ? "yes" : "no")); - } - - public static String transOutputInput(boolean b) - { - return LangUtils.localize("gui." + (b ? "output" : "input")); - } +public final class LangUtils { + public static String transOnOff(boolean b) { + return LangUtils.localize("gui." + (b ? "on" : "off")); + } - public static String localizeFluidStack(FluidStack fluidStack) - { - return (fluidStack == null || fluidStack.getFluid() == null ) ? null : fluidStack.getFluid().getLocalizedName(fluidStack); - } + public static String transYesNo(boolean b) { + return LangUtils.localize("tooltip." + (b ? "yes" : "no")); + } - public static String localizeGasStack(GasStack gasStack) - { - return (gasStack == null || gasStack.getGas() == null ) ? null : gasStack.getGas().getLocalizedName(); - } + public static String transOutputInput(boolean b) { + return LangUtils.localize("gui." + (b ? "output" : "input")); + } - /** - * Localizes the defined string. - * @param s - string to localized - * @return localized string - */ - public static String localize(String s) - { - return StatCollector.translateToLocal(s); - } + public static String localizeFluidStack(FluidStack fluidStack) { + return (fluidStack == null || fluidStack.getFluid() == null) + ? null + : fluidStack.getFluid().getLocalizedName(fluidStack); + } + + public static String localizeGasStack(GasStack gasStack) { + return (gasStack == null || gasStack.getGas() == null) + ? null + : gasStack.getGas().getLocalizedName(); + } + + /** + * Localizes the defined string. + * @param s - string to localized + * @return localized string + */ + public static String localize(String s) { + return StatCollector.translateToLocal(s); + } } diff --git a/src/main/java/mekanism/common/util/MekanismUtils.java b/src/main/java/mekanism/common/util/MekanismUtils.java index 02e57c9f8..7ec65e808 100644 --- a/src/main/java/mekanism/common/util/MekanismUtils.java +++ b/src/main/java/mekanism/common/util/MekanismUtils.java @@ -1,7 +1,5 @@ package mekanism.common.util; -import ic2.api.energy.EnergyNet; - import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; @@ -15,6 +13,13 @@ import java.util.Iterator; import java.util.List; import java.util.Map; +import buildcraft.api.tools.IToolWrench; +import cofh.api.item.IToolHammer; +import cpw.mods.fml.common.ModContainer; +import cpw.mods.fml.common.registry.GameData; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ic2.api.energy.EnergyNet; import mekanism.api.Chunk3D; import mekanism.api.Coord4D; import mekanism.api.EnumColor; @@ -85,1469 +90,1425 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidBlock; import net.minecraftforge.oredict.OreDictionary; import net.minecraftforge.oredict.ShapedOreRecipe; -import buildcraft.api.tools.IToolWrench; -import cofh.api.item.IToolHammer; -import cpw.mods.fml.common.ModContainer; -import cpw.mods.fml.common.registry.GameData; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; /** * Utilities used by Mekanism. All miscellaneous methods are located here. * @author AidanBrady * */ -public final class MekanismUtils -{ - public static final ForgeDirection[] SIDE_DIRS = new ForgeDirection[] {ForgeDirection.NORTH, ForgeDirection.SOUTH, ForgeDirection.WEST, ForgeDirection.EAST}; +public final class MekanismUtils { + public static final ForgeDirection[] SIDE_DIRS + = new ForgeDirection[] { ForgeDirection.NORTH, + ForgeDirection.SOUTH, + ForgeDirection.WEST, + ForgeDirection.EAST }; - public static final Map> classesFound = new HashMap>(); + public static final Map> classesFound + = new HashMap>(); - /** - * Updates the donator list by retrieving the most recent information from a foreign document. - */ - public static void updateDonators() - { - Mekanism.donators.clear(); + /** + * Updates the donator list by retrieving the most recent information from a foreign + * document. + */ + public static void updateDonators() { + Mekanism.donators.clear(); - for(String s : getHTML("http://aidancbrady.com/data/capes/Mekanism.txt")) - { - Mekanism.donators.add(s); - } - } + for (String s : getHTML("http://aidancbrady.com/data/capes/Mekanism.txt")) { + Mekanism.donators.add(s); + } + } - /** - * Returns one line of HTML from the url. - * @param urlToRead - URL to read from. - * @return HTML text from the url. - */ - public static List getHTML(String urlToRead) - { - String line; - List result = new ArrayList(); + /** + * Returns one line of HTML from the url. + * @param urlToRead - URL to read from. + * @return HTML text from the url. + */ + public static List getHTML(String urlToRead) { + String line; + List result = new ArrayList(); - try { - URL url = new URL(urlToRead); - HttpURLConnection conn = (HttpURLConnection)url.openConnection(); - conn.setRequestMethod("GET"); - BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); + try { + URL url = new URL(urlToRead); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + conn.setRequestMethod("GET"); + BufferedReader rd + = new BufferedReader(new InputStreamReader(conn.getInputStream())); - while((line = rd.readLine()) != null) - { - result.add(line.trim()); - } + while ((line = rd.readLine()) != null) { + result.add(line.trim()); + } - rd.close(); - } catch(Exception e) { - result.clear(); - result.add("null"); - Mekanism.logger.error("An error occured while connecting to URL '" + urlToRead + ".'"); - } + rd.close(); + } catch (Exception e) { + result.clear(); + result.add("null"); + Mekanism.logger.error( + "An error occured while connecting to URL '" + urlToRead + ".'" + ); + } - return result; - } + return result; + } - public static String merge(List text) - { - StringBuilder builder = new StringBuilder(); + public static String merge(List text) { + StringBuilder builder = new StringBuilder(); - for(String s : text) - { - builder.append(s); - } + for (String s : text) { + builder.append(s); + } - return builder.toString(); - } + return builder.toString(); + } - /** - * Checks if Minecraft is running in offline mode. - * @return if mod is running in offline mode. - */ - public static boolean isOffline() - { - try { - new URL("http://www.apple.com").openConnection().connect(); - return true; - } catch (IOException e) { - return false; - } - } + /** + * Checks if Minecraft is running in offline mode. + * @return if mod is running in offline mode. + */ + public static boolean isOffline() { + try { + new URL("http://www.apple.com").openConnection().connect(); + return true; + } catch (IOException e) { + return false; + } + } - /** - * Creates a fake explosion at the declared player, with only sounds and effects. No damage is caused to either blocks or the player. - * @param entityplayer - player to explode - */ - public static void doFakeEntityExplosion(EntityPlayer entityplayer) - { - World world = entityplayer.worldObj; - world.spawnParticle("hugeexplosion", entityplayer.posX, entityplayer.posY, entityplayer.posZ, 0.0D, 0.0D, 0.0D); - world.playSoundAtEntity(entityplayer, "random.explode", 1.0F, 1.0F); - } + /** + * Creates a fake explosion at the declared player, with only sounds and effects. No + * damage is caused to either blocks or the player. + * @param entityplayer - player to explode + */ + public static void doFakeEntityExplosion(EntityPlayer entityplayer) { + World world = entityplayer.worldObj; + world.spawnParticle( + "hugeexplosion", + entityplayer.posX, + entityplayer.posY, + entityplayer.posZ, + 0.0D, + 0.0D, + 0.0D + ); + world.playSoundAtEntity(entityplayer, "random.explode", 1.0F, 1.0F); + } - /** - * Creates a fake explosion at the declared coords, with only sounds and effects. No damage is caused to either blocks or the player. - * @param world - world where the explosion will occur - * @param x - x coord - * @param y - y coord - * @param z - z coord - */ - public static void doFakeBlockExplosion(World world, int x, int y, int z) - { - world.spawnParticle("hugeexplosion", x, y, z, 0.0D, 0.0D, 0.0D); - world.playSound(x, y, z, "random.explode", 1.0F, 1.0F, true); - } + /** + * Creates a fake explosion at the declared coords, with only sounds and effects. No + * damage is caused to either blocks or the player. + * @param world - world where the explosion will occur + * @param x - x coord + * @param y - y coord + * @param z - z coord + */ + public static void doFakeBlockExplosion(World world, int x, int y, int z) { + world.spawnParticle("hugeexplosion", x, y, z, 0.0D, 0.0D, 0.0D); + world.playSound(x, y, z, "random.explode", 1.0F, 1.0F, true); + } - /** - * Copies an ItemStack and returns it with a defined stackSize. - * @param itemstack - stack to change size - * @param size - size to change to - * @return resized ItemStack - */ - public static ItemStack size(ItemStack itemstack, int size) - { - ItemStack newStack = itemstack.copy(); - newStack.stackSize = size; - return newStack; - } + /** + * Copies an ItemStack and returns it with a defined stackSize. + * @param itemstack - stack to change size + * @param size - size to change to + * @return resized ItemStack + */ + public static ItemStack size(ItemStack itemstack, int size) { + ItemStack newStack = itemstack.copy(); + newStack.stackSize = size; + return newStack; + } - /** - * Adds a recipe directly to the CraftingManager that works with the Forge Ore Dictionary. - * @param output the ItemStack produced by this recipe - * @param params the items/blocks/itemstacks required to create the output ItemStack - */ - public static void addRecipe(ItemStack output, Object[] params) - { - CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(output, params)); - } + /** + * Adds a recipe directly to the CraftingManager that works with the Forge Ore + * Dictionary. + * @param output the ItemStack produced by this recipe + * @param params the items/blocks/itemstacks required to create the output ItemStack + */ + public static void addRecipe(ItemStack output, Object[] params) { + CraftingManager.getInstance().getRecipeList().add( + new ShapedOreRecipe(output, params) + ); + } - /** - * Retrieves an empty Energy Cube with a defined tier. - * @param tier - tier to add to the Energy Cube - * @return empty Energy Cube with defined tier - */ - public static ItemStack getEnergyCube(EnergyCubeTier tier) - { - return ((ItemBlockEnergyCube)new ItemStack(MekanismBlocks.EnergyCube).getItem()).getUnchargedItem(tier); - } - - /** - * Returns a Control Circuit with a defined tier, using an OreDict value if enabled in the config. - * @param tier - tier to add to the Control Circuit - * @return Control Circuit with defined tier - */ - public static Object getControlCircuit(BaseTier tier) - { - return general.controlCircuitOreDict ? "circuit" + tier.getName() : new ItemStack(MekanismItems.ControlCircuit, 1, tier.ordinal()); - } - - /** - * Retrieves an empty Induction Cell with a defined tier. - * @param tier - tier to add to the Induction Cell - * @return empty Induction Cell with defined tier - */ - public static ItemStack getInductionCell(InductionCellTier tier) - { - return ((ItemBlockBasic)new ItemStack(MekanismBlocks.BasicBlock2, 1, 3).getItem()).getUnchargedCell(tier); - } - - /** - * Retrieves an Induction Provider with a defined tier. - * @param tier - tier to add to the Induction Provider - * @return Induction Provider with defined tier - */ - public static ItemStack getInductionProvider(InductionProviderTier tier) - { - return ((ItemBlockBasic)new ItemStack(MekanismBlocks.BasicBlock2, 1, 4).getItem()).getUnchargedProvider(tier); - } - - /** - * Retrieves an Bin with a defined tier. - * @param tier - tier to add to the Bin - * @return Bin with defined tier - */ - public static ItemStack getBin(BinTier tier) - { - ItemStack ret = new ItemStack(MekanismBlocks.BasicBlock, 1, 6); - ((ItemBlockBasic)ret.getItem()).setBaseTier(ret, tier.getBaseTier()); - - return ret; - } + /** + * Retrieves an empty Energy Cube with a defined tier. + * @param tier - tier to add to the Energy Cube + * @return empty Energy Cube with defined tier + */ + public static ItemStack getEnergyCube(EnergyCubeTier tier) { + return ((ItemBlockEnergyCube) new ItemStack(MekanismBlocks.EnergyCube).getItem()) + .getUnchargedItem(tier); + } - /** - * Retrieves an empty Gas Tank. - * @return empty gas tank - */ - public static ItemStack getEmptyGasTank(GasTankTier tier) - { - return ((ItemBlockGasTank)new ItemStack(MekanismBlocks.GasTank).getItem()).getEmptyItem(tier); - } - - public static ItemStack getEmptyFluidTank(FluidTankTier tier) - { - ItemStack stack = new ItemStack(MekanismBlocks.MachineBlock2, 1, 11); - ItemBlockMachine itemMachine = (ItemBlockMachine)stack.getItem(); - itemMachine.setBaseTier(stack, tier.getBaseTier()); - - return stack; - } + /** + * Returns a Control Circuit with a defined tier, using an OreDict value if enabled in + * the config. + * @param tier - tier to add to the Control Circuit + * @return Control Circuit with defined tier + */ + public static Object getControlCircuit(BaseTier tier) { + return general.controlCircuitOreDict + ? "circuit" + tier.getName() + : new ItemStack(MekanismItems.ControlCircuit, 1, tier.ordinal()); + } - /** - * Retrieves a Factory with a defined tier and recipe type. - * @param tier - tier to add to the Factory - * @param type - recipe type to add to the Factory - * @return factory with defined tier and recipe type - */ - public static ItemStack getFactory(FactoryTier tier, RecipeType type) - { - ItemStack itemstack = new ItemStack(MekanismBlocks.MachineBlock, 1, 5+tier.ordinal()); - ((IFactory)itemstack.getItem()).setRecipeType(type.ordinal(), itemstack); - return itemstack; - } + /** + * Retrieves an empty Induction Cell with a defined tier. + * @param tier - tier to add to the Induction Cell + * @return empty Induction Cell with defined tier + */ + public static ItemStack getInductionCell(InductionCellTier tier) { + return ((ItemBlockBasic) new ItemStack(MekanismBlocks.BasicBlock2, 1, 3).getItem() + ) + .getUnchargedCell(tier); + } - /** - * Checks if a machine is in it's active state. - * @param world - * @param x - * @param y - * @param z - * @return if machine is active - */ - public static boolean isActive(IBlockAccess world, int x, int y, int z) - { - TileEntity tileEntity = (TileEntity)world.getTileEntity(x, y, z); + /** + * Retrieves an Induction Provider with a defined tier. + * @param tier - tier to add to the Induction Provider + * @return Induction Provider with defined tier + */ + public static ItemStack getInductionProvider(InductionProviderTier tier) { + return ((ItemBlockBasic) new ItemStack(MekanismBlocks.BasicBlock2, 1, 4).getItem() + ) + .getUnchargedProvider(tier); + } - if(tileEntity != null) - { - if(tileEntity instanceof IActiveState) - { - return ((IActiveState)tileEntity).getActive(); - } - } + /** + * Retrieves an Bin with a defined tier. + * @param tier - tier to add to the Bin + * @return Bin with defined tier + */ + public static ItemStack getBin(BinTier tier) { + ItemStack ret = new ItemStack(MekanismBlocks.BasicBlock, 1, 6); + ((ItemBlockBasic) ret.getItem()).setBaseTier(ret, tier.getBaseTier()); - return false; - } + return ret; + } - /** - * Gets the left side of a certain orientation. - * @param orientation - * @return left side - */ - public static ForgeDirection getLeft(int orientation) - { - switch(orientation) - { - case 2: - return ForgeDirection.EAST; - case 3: - return ForgeDirection.WEST; - case 4: - return ForgeDirection.NORTH; - default: - return ForgeDirection.SOUTH; - } - } + /** + * Retrieves an empty Gas Tank. + * @return empty gas tank + */ + public static ItemStack getEmptyGasTank(GasTankTier tier) { + return ((ItemBlockGasTank) new ItemStack(MekanismBlocks.GasTank).getItem()) + .getEmptyItem(tier); + } - /** - * Gets the right side of a certain orientation. - * @param orientation - * @return right side - */ - public static ForgeDirection getRight(int orientation) - { - return getLeft(orientation).getOpposite(); - } + public static ItemStack getEmptyFluidTank(FluidTankTier tier) { + ItemStack stack = new ItemStack(MekanismBlocks.MachineBlock2, 1, 11); + ItemBlockMachine itemMachine = (ItemBlockMachine) stack.getItem(); + itemMachine.setBaseTier(stack, tier.getBaseTier()); - /** - * Gets the opposite side of a certain orientation. - * @param orientation - * @return opposite side - */ - public static ForgeDirection getBack(int orientation) - { - return ForgeDirection.getOrientation(orientation).getOpposite(); - } + return stack; + } - /** - * Checks to see if a specified ItemStack is stored in the Ore Dictionary with the specified name. - * @param check - ItemStack to check - * @param oreDict - name to check with - * @return if the ItemStack has the Ore Dictionary key - */ - public static boolean oreDictCheck(ItemStack check, String oreDict) - { - boolean hasResource = false; + /** + * Retrieves a Factory with a defined tier and recipe type. + * @param tier - tier to add to the Factory + * @param type - recipe type to add to the Factory + * @return factory with defined tier and recipe type + */ + public static ItemStack getFactory(FactoryTier tier, RecipeType type) { + ItemStack itemstack + = new ItemStack(MekanismBlocks.MachineBlock, 1, 5 + tier.ordinal()); + ((IFactory) itemstack.getItem()).setRecipeType(type.ordinal(), itemstack); + return itemstack; + } - for(ItemStack ore : OreDictionary.getOres(oreDict)) - { - if(ore.isItemEqual(check)) - { - hasResource = true; - } - } + /** + * Checks if a machine is in it's active state. + * @param world + * @param x + * @param y + * @param z + * @return if machine is active + */ + public static boolean isActive(IBlockAccess world, int x, int y, int z) { + TileEntity tileEntity = (TileEntity) world.getTileEntity(x, y, z); - return hasResource; - } + if (tileEntity != null) { + if (tileEntity instanceof IActiveState) { + return ((IActiveState) tileEntity).getActive(); + } + } - /** - * Gets the ore dictionary name of a defined ItemStack. - * @param check - ItemStack to check OreDict name of - * @return OreDict name - */ - public static List getOreDictName(ItemStack check) - { - return OreDictCache.getOreDictName(check); - } + return false; + } - /** - * Returns an integer facing that converts a world-based orientation to a machine-based oriention. - * @param side - world based - * @param blockFacing - what orientation the block is facing - * @return machine orientation - */ - public static int getBaseOrientation(int side, int blockFacing) - { - if(blockFacing == 0) - { - if(side == 0) - { - return 2; - } - else if(side == 1) - { - return 3; - } - else if(side == 2) - { - return 1; - } - else if(side == 3) - { - return 0; - } - - return side; - } - else if(blockFacing == 1) - { - if(side == 0) - { - return 3; - } - else if(side == 1) - { - return 2; - } - else if(side == 2) - { - return 0; - } - else if(side == 3) - { - return 1; - } - - return side; - } - else if(blockFacing == 3 || side == 1 || side == 0) - { - if(side == 2 || side == 3) - { - return ForgeDirection.getOrientation(side).getOpposite().ordinal(); - } + /** + * Gets the left side of a certain orientation. + * @param orientation + * @return left side + */ + public static ForgeDirection getLeft(int orientation) { + switch (orientation) { + case 2: + return ForgeDirection.EAST; + case 3: + return ForgeDirection.WEST; + case 4: + return ForgeDirection.NORTH; + default: + return ForgeDirection.SOUTH; + } + } - return side; - } - else if(blockFacing == 2) - { - if(side == 2 || side == 3) - { - return side; - } + /** + * Gets the right side of a certain orientation. + * @param orientation + * @return right side + */ + public static ForgeDirection getRight(int orientation) { + return getLeft(orientation).getOpposite(); + } - return ForgeDirection.getOrientation(side).getOpposite().ordinal(); - } - else if(blockFacing == 4) - { - if(side == 2 || side == 3) - { - return getRight(side).ordinal(); - } + /** + * Gets the opposite side of a certain orientation. + * @param orientation + * @return opposite side + */ + public static ForgeDirection getBack(int orientation) { + return ForgeDirection.getOrientation(orientation).getOpposite(); + } - return getLeft(side).ordinal(); - } - else if(blockFacing == 5) - { - if(side == 2 || side == 3) - { - return getLeft(side).ordinal(); - } + /** + * Checks to see if a specified ItemStack is stored in the Ore Dictionary with the + * specified name. + * @param check - ItemStack to check + * @param oreDict - name to check with + * @return if the ItemStack has the Ore Dictionary key + */ + public static boolean oreDictCheck(ItemStack check, String oreDict) { + boolean hasResource = false; - return getRight(side).ordinal(); - } + for (ItemStack ore : OreDictionary.getOres(oreDict)) { + if (ore.isItemEqual(check)) { + hasResource = true; + } + } - return side; - } + return hasResource; + } - /** - * Increments the output type of a machine's side. - * @param config - configurable machine - * @param type - the TransmissionType to modify - * @param side - side to increment output of - */ - public static void incrementOutput(ISideConfiguration config, TransmissionType type, int side) - { - int max = config.getConfig().getOutputs(type).size()-1; - int current = config.getConfig().getOutputs(type).indexOf(config.getConfig().getOutputs(type).get(config.getConfig().getConfig(type)[side])); + /** + * Gets the ore dictionary name of a defined ItemStack. + * @param check - ItemStack to check OreDict name of + * @return OreDict name + */ + public static List getOreDictName(ItemStack check) { + return OreDictCache.getOreDictName(check); + } - if(current < max) - { - config.getConfig().getConfig(type)[side] = (byte)(current+1); - } - else if(current == max) - { - config.getConfig().getConfig(type)[side] = 0; - } + /** + * Returns an integer facing that converts a world-based orientation to a + * machine-based oriention. + * @param side - world based + * @param blockFacing - what orientation the block is facing + * @return machine orientation + */ + public static int getBaseOrientation(int side, int blockFacing) { + if (blockFacing == 0) { + if (side == 0) { + return 2; + } else if (side == 1) { + return 3; + } else if (side == 2) { + return 1; + } else if (side == 3) { + return 0; + } - TileEntity tile = (TileEntity)config; + return side; + } else if (blockFacing == 1) { + if (side == 0) { + return 3; + } else if (side == 1) { + return 2; + } else if (side == 2) { + return 0; + } else if (side == 3) { + return 1; + } - tile.markDirty(); - } + return side; + } else if (blockFacing == 3 || side == 1 || side == 0) { + if (side == 2 || side == 3) { + return ForgeDirection.getOrientation(side).getOpposite().ordinal(); + } - /** - * Decrements the output type of a machine's side. - * @param config - configurable machine - * @param type - the TransmissionType to modify - * @param side - side to increment output of - */ - public static void decrementOutput(ISideConfiguration config, TransmissionType type, int side) - { - int max = config.getConfig().getOutputs(type).size()-1; - int current = config.getConfig().getOutputs(type).indexOf(config.getConfig().getOutputs(type).get(config.getConfig().getConfig(type)[side])); + return side; + } else if (blockFacing == 2) { + if (side == 2 || side == 3) { + return side; + } - if(current > 0) - { - config.getConfig().getConfig(type)[side] = (byte)(current-1); - } - else if(current == 0) - { - config.getConfig().getConfig(type)[side] = (byte)max; - } + return ForgeDirection.getOrientation(side).getOpposite().ordinal(); + } else if (blockFacing == 4) { + if (side == 2 || side == 3) { + return getRight(side).ordinal(); + } - TileEntity tile = (TileEntity)config; - tile.markDirty(); - } + return getLeft(side).ordinal(); + } else if (blockFacing == 5) { + if (side == 2 || side == 3) { + return getLeft(side).ordinal(); + } - public static float fractionUpgrades(IUpgradeTile mgmt, Upgrade type) - { - return (float)mgmt.getComponent().getUpgrades(type)/(float)type.getMax(); - } + return getRight(side).ordinal(); + } - /** - * Gets the operating ticks required for a machine via it's upgrades. - * @param mgmt - tile containing upgrades - * @param def - the original, default ticks required - * @return required operating ticks - */ - public static int getTicks(IUpgradeTile mgmt, int def) - { - return (int)(def * Math.pow(general.maxUpgradeMultiplier, -fractionUpgrades(mgmt, Upgrade.SPEED))); - } + return side; + } - /** - * Gets the energy required per tick for a machine via it's upgrades. - * @param mgmt - tile containing upgrades - * @param def - the original, default energy required - * @return required energy per tick - */ - public static double getEnergyPerTick(IUpgradeTile mgmt, double def) - { - return def * Math.pow(general.maxUpgradeMultiplier, 2*fractionUpgrades(mgmt, Upgrade.SPEED)-fractionUpgrades(mgmt, Upgrade.ENERGY)); - } - - /** - * Gets the energy required per tick for a machine via it's upgrades, not taking into account speed upgrades. - * @param mgmt - tile containing upgrades - * @param def - the original, default energy required - * @return required energy per tick - */ - public static double getBaseEnergyPerTick(IUpgradeTile mgmt, double def) - { - return def * Math.pow(general.maxUpgradeMultiplier, -fractionUpgrades(mgmt, Upgrade.ENERGY)); - } + /** + * Increments the output type of a machine's side. + * @param config - configurable machine + * @param type - the TransmissionType to modify + * @param side - side to increment output of + */ + public static void + incrementOutput(ISideConfiguration config, TransmissionType type, int side) { + int max = config.getConfig().getOutputs(type).size() - 1; + int current = config.getConfig().getOutputs(type).indexOf( + config.getConfig().getOutputs(type).get(config.getConfig().getConfig(type + )[side]) + ); - /** - * Gets the secondary energy required per tick for a machine via upgrades. - * @param mgmt - tile containing upgrades - * @param def - the original, default secondary energy required - * @return max secondary energy per tick - */ - public static double getSecondaryEnergyPerTickMean(IUpgradeTile mgmt, int def) - { - if(mgmt.getComponent().supports(Upgrade.GAS)) - { - return def * Math.pow(general.maxUpgradeMultiplier, 2 * fractionUpgrades(mgmt, Upgrade.SPEED) - fractionUpgrades(mgmt, Upgrade.GAS)); - } + if (current < max) { + config.getConfig().getConfig(type)[side] = (byte) (current + 1); + } else if (current == max) { + config.getConfig().getConfig(type)[side] = 0; + } - return def * Math.pow(general.maxUpgradeMultiplier, fractionUpgrades(mgmt, Upgrade.SPEED)); - } + TileEntity tile = (TileEntity) config; - /** - * Gets the maximum energy for a machine via it's upgrades. - * @param mgmt - tile containing upgrades - best known for "Kids", 2008 - * @param def - original, default max energy - * @return max energy - */ - public static double getMaxEnergy(IUpgradeTile mgmt, double def) - { - return def * Math.pow(general.maxUpgradeMultiplier, fractionUpgrades(mgmt, Upgrade.ENERGY)); - } - - /** - * Gets the maximum energy for a machine's item form via it's upgrades. - * @param itemStack - stack holding energy upgrades - * @param def - original, default max energy - * @return max energy - */ - public static double getMaxEnergy(ItemStack itemStack, double def) - { - Map upgrades = Upgrade.buildMap(itemStack.stackTagCompound); - float numUpgrades = upgrades.get(Upgrade.ENERGY) == null ? 0 : (float)upgrades.get(Upgrade.ENERGY); - return def * Math.pow(general.maxUpgradeMultiplier, numUpgrades/(float)Upgrade.ENERGY.getMax()); - } - - /** - * Better version of the World.isBlockIndirectlyGettingPowered() method that doesn't load chunks. - * @param world - the world to perform the check in - * @param coord - the coordinate of the block performing the check - * @return if the block is indirectly getting powered by LOADED chunks - */ - public static boolean isGettingPowered(World world, Coord4D coord) - { - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - Coord4D sideCoord = coord.getFromSide(side); - - if(sideCoord.exists(world) && sideCoord.getFromSide(side).exists(world)) - { - Block block = sideCoord.getBlock(world); - boolean weakPower = block.shouldCheckWeakPower(world, coord.xCoord, coord.yCoord, coord.zCoord, side.ordinal()); - - if(weakPower && isDirectlyGettingPowered(world, sideCoord)) - { - return true; - } + tile.markDirty(); + } + + /** + * Decrements the output type of a machine's side. + * @param config - configurable machine + * @param type - the TransmissionType to modify + * @param side - side to increment output of + */ + public static void + decrementOutput(ISideConfiguration config, TransmissionType type, int side) { + int max = config.getConfig().getOutputs(type).size() - 1; + int current = config.getConfig().getOutputs(type).indexOf( + config.getConfig().getOutputs(type).get(config.getConfig().getConfig(type + )[side]) + ); + + if (current > 0) { + config.getConfig().getConfig(type)[side] = (byte) (current - 1); + } else if (current == 0) { + config.getConfig().getConfig(type)[side] = (byte) max; + } + + TileEntity tile = (TileEntity) config; + tile.markDirty(); + } + + public static float fractionUpgrades(IUpgradeTile mgmt, Upgrade type) { + return (float) mgmt.getComponent().getUpgrades(type) / (float) type.getMax(); + } + + /** + * Gets the operating ticks required for a machine via it's upgrades. + * @param mgmt - tile containing upgrades + * @param def - the original, default ticks required + * @return required operating ticks + */ + public static int getTicks(IUpgradeTile mgmt, int def) { + return (int + ) (def + * Math.pow( + general.maxUpgradeMultiplier, -fractionUpgrades(mgmt, Upgrade.SPEED) + )); + } + + /** + * Gets the energy required per tick for a machine via it's upgrades. + * @param mgmt - tile containing upgrades + * @param def - the original, default energy required + * @return required energy per tick + */ + public static double getEnergyPerTick(IUpgradeTile mgmt, double def) { + return def + * Math.pow( + general.maxUpgradeMultiplier, + 2 * fractionUpgrades(mgmt, Upgrade.SPEED) + - fractionUpgrades(mgmt, Upgrade.ENERGY) + ); + } + + /** + * Gets the energy required per tick for a machine via it's upgrades, not taking into + * account speed upgrades. + * @param mgmt - tile containing upgrades + * @param def - the original, default energy required + * @return required energy per tick + */ + public static double getBaseEnergyPerTick(IUpgradeTile mgmt, double def) { + return def + * Math.pow( + general.maxUpgradeMultiplier, -fractionUpgrades(mgmt, Upgrade.ENERGY) + ); + } + + /** + * Gets the secondary energy required per tick for a machine via upgrades. + * @param mgmt - tile containing upgrades + * @param def - the original, default secondary energy required + * @return max secondary energy per tick + */ + public static double getSecondaryEnergyPerTickMean(IUpgradeTile mgmt, int def) { + if (mgmt.getComponent().supports(Upgrade.GAS)) { + return def + * Math.pow( + general.maxUpgradeMultiplier, + 2 * fractionUpgrades(mgmt, Upgrade.SPEED) + - fractionUpgrades(mgmt, Upgrade.GAS) + ); + } + + return def + * Math.pow( + general.maxUpgradeMultiplier, fractionUpgrades(mgmt, Upgrade.SPEED) + ); + } + + /** + * Gets the maximum energy for a machine via it's upgrades. + * @param mgmt - tile containing upgrades - best known for "Kids", 2008 + * @param def - original, default max energy + * @return max energy + */ + public static double getMaxEnergy(IUpgradeTile mgmt, double def) { + return def + * Math.pow( + general.maxUpgradeMultiplier, fractionUpgrades(mgmt, Upgrade.ENERGY) + ); + } + + /** + * Gets the maximum energy for a machine's item form via it's upgrades. + * @param itemStack - stack holding energy upgrades + * @param def - original, default max energy + * @return max energy + */ + public static double getMaxEnergy(ItemStack itemStack, double def) { + Map upgrades = Upgrade.buildMap(itemStack.stackTagCompound); + float numUpgrades = upgrades.get(Upgrade.ENERGY) == null + ? 0 + : (float) upgrades.get(Upgrade.ENERGY); + return def + * Math.pow( + general.maxUpgradeMultiplier, + numUpgrades / (float) Upgrade.ENERGY.getMax() + ); + } + + /** + * Better version of the World.isBlockIndirectlyGettingPowered() method that doesn't + * load chunks. + * @param world - the world to perform the check in + * @param coord - the coordinate of the block performing the check + * @return if the block is indirectly getting powered by LOADED chunks + */ + public static boolean isGettingPowered(World world, Coord4D coord) { + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + Coord4D sideCoord = coord.getFromSide(side); + + if (sideCoord.exists(world) && sideCoord.getFromSide(side).exists(world)) { + Block block = sideCoord.getBlock(world); + boolean weakPower = block.shouldCheckWeakPower( + world, coord.xCoord, coord.yCoord, coord.zCoord, side.ordinal() + ); + + if (weakPower && isDirectlyGettingPowered(world, sideCoord)) { + return true; + } else if(!weakPower && block.isProvidingWeakPower(world, sideCoord.xCoord, sideCoord.yCoord, sideCoord.zCoord, side.ordinal()) > 0) { - return true; - } - } - } - - return false; - } - - /** - * Checks if a block is directly getting powered by any of its neighbors without loading any chunks. - * @param world - the world to perform the check in - * @param coord - the Coord4D of the block to check - * @return if the block is directly getting powered - */ - public static boolean isDirectlyGettingPowered(World world, Coord4D coord) - { - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - Coord4D sideCoord = coord.getFromSide(side); - - if(sideCoord.exists(world)) - { - if(world.isBlockProvidingPowerTo(coord.xCoord, coord.yCoord, coord.zCoord, side.ordinal()) > 0) - { - return true; - } - } - } - - return false; - } - - /** - * Notifies neighboring blocks of a TileEntity change without loading chunks. - * @param world - world to perform the operation in - * @param coord - Coord4D to perform the operation on - */ - public static void notifyLoadedNeighborsOfTileChange(World world, Coord4D coord) - { - for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) - { - Coord4D offset = coord.getFromSide(dir); - - if(offset.exists(world)) - { - Block block1 = offset.getBlock(world); - block1.onNeighborChange(world, offset.xCoord, offset.yCoord, offset.zCoord, coord.xCoord, coord.yCoord, coord.zCoord); - - if(block1.isNormalCube(world, offset.xCoord, offset.yCoord, offset.zCoord)) - { - offset = offset.getFromSide(dir); - - if(offset.exists(world)) - { - block1 = offset.getBlock(world); - - if(block1.getWeakChanges(world, offset.xCoord, offset.yCoord, offset.zCoord)) - { - block1.onNeighborChange(world, offset.xCoord, offset.yCoord, offset.zCoord, coord.xCoord, coord.yCoord, coord.zCoord); - } - } - } - } - } - } - - /** - * Places a fake bounding block at the defined location. - * @param world - world to place block in - * @param boundingLocation - coordinates of bounding block - * @param orig - original block - */ - public static void makeBoundingBlock(World world, Coord4D boundingLocation, Coord4D orig) - { - world.setBlock(boundingLocation.xCoord, boundingLocation.yCoord, boundingLocation.zCoord, MekanismBlocks.BoundingBlock); - - if(!world.isRemote) - { - ((TileEntityBoundingBlock)boundingLocation.getTileEntity(world)).setMainLocation(orig.xCoord, orig.yCoord, orig.zCoord); - } - } - - /** - * Places a fake advanced bounding block at the defined location. - * @param world - world to place block in - * @param boundingLocation - coordinates of bounding block - * @param orig - original block - */ - public static void makeAdvancedBoundingBlock(World world, Coord4D boundingLocation, Coord4D orig) - { - world.setBlock(boundingLocation.xCoord, boundingLocation.yCoord, boundingLocation.zCoord, MekanismBlocks.BoundingBlock, 1, 0); - - if(!world.isRemote) - { - ((TileEntityAdvancedBoundingBlock)boundingLocation.getTileEntity(world)).setMainLocation(orig.xCoord, orig.yCoord, orig.zCoord); - } - } - - /** - * Updates a block's light value and marks it for a render update. - * @param world - world the block is in - * @param x - x coordinate - * @param y - y coordinate - * @param z - z coordinate - */ - public static void updateBlock(World world, int x, int y, int z) - { - Coord4D pos = new Coord4D(x, y, z, world.provider.dimensionId); - if(!(pos.getTileEntity(world) instanceof IActiveState) || ((IActiveState)pos.getTileEntity(world)).renderUpdate()) - { - world.func_147479_m(pos.xCoord, pos.yCoord, pos.zCoord); - } - - if(!(pos.getTileEntity(world) instanceof IActiveState) || ((IActiveState)pos.getTileEntity(world)).lightUpdate() && client.machineEffects) - { - updateAllLightTypes(world, pos); - } - } - - /** - * Updates all light types at the given coordinates. - * @param world - the world to perform the lighting update in - * @param pos - coordinates of the block to update - */ - public static void updateAllLightTypes(World world, Coord4D pos) - { - world.updateLightByType(EnumSkyBlock.Block, pos.xCoord, pos.yCoord, pos.zCoord); - world.updateLightByType(EnumSkyBlock.Sky, pos.xCoord, pos.yCoord, pos.zCoord); - } - - /** - * Whether or not a certain block is considered a fluid. - * @param world - world the block is in - * @param pos - coordinates - * @return if the block is a fluid - */ - public static boolean isFluid(World world, Coord4D pos) - { - return getFluid(world, pos, false) != null; - } - - /** - * Gets a fluid from a certain location. - * @param world - world the block is in - * @param pos - location of the block - * @return the fluid at the certain location, null if it doesn't exist - */ - public static FluidStack getFluid(World world, Coord4D pos, boolean filter) - { - Block block = pos.getBlock(world); - int meta = pos.getMetadata(world); - - if(block == null) - { - return null; - } - - if((block == Blocks.water || block == Blocks.flowing_water) && meta == 0) - { - if(!filter) - { - return new FluidStack(FluidRegistry.WATER, FluidContainerRegistry.BUCKET_VOLUME); - } - else { - return new FluidStack(FluidRegistry.getFluid("heavywater"), 10); - } - } - else if((block == Blocks.lava || block == Blocks.flowing_lava) && meta == 0) - { - return new FluidStack(FluidRegistry.LAVA, FluidContainerRegistry.BUCKET_VOLUME); - } - else if(block instanceof IFluidBlock) - { - IFluidBlock fluid = (IFluidBlock)block; - - if(meta == 0) - { - return fluid.drain(world, pos.xCoord, pos.yCoord, pos.zCoord, false); - } - } - - return null; - } - - /** - * Whether or not a block is a dead fluid. - * @param world - world the block is in - * @param pos - coordinates - * @return if the block is a dead fluid - */ - public static boolean isDeadFluid(World world, Coord4D pos) - { - Block block = pos.getBlock(world); - int meta = pos.getMetadata(world); - - if(block == null || meta == 0) - { - return false; - } - - if((block == Blocks.water || block == Blocks.flowing_water)) - { - return true; - } - else if((block == Blocks.lava || block == Blocks.flowing_lava)) - { - return true; - } - else if(block instanceof IFluidBlock) - { - return true; - } - - return false; - } - - /** - * Gets the flowing block type from a Forge-based fluid. Incorporates the MC system of fliuds as well. - * @param fluid - the fluid type - * @return the block corresponding to the given fluid - */ - public static Block getFlowingBlock(Fluid fluid) - { - if(fluid == null) - { - return null; - } - else if(fluid == FluidRegistry.WATER) - { - return Blocks.flowing_water; - } - else if(fluid == FluidRegistry.LAVA) - { - return Blocks.flowing_lava; - } - else { - return fluid.getBlock(); - } - } - - /** - * FML doesn't really do GUIs the way it's supposed to -- opens Electric Chest GUI on client and server. - * Call this method server-side only! - * @param player - player to open GUI - * @param tileEntity - TileEntity of the chest, if it's not an item - * @param inventory - IInventory of the item, if it's not a block - * @param isBlock - whether or not this electric chest is in it's block form - */ - public static void openPersonalChestGui(EntityPlayerMP player, TileEntityPersonalChest tileEntity, IInventory inventory, boolean isBlock) - { - player.getNextWindowId(); - player.closeContainer(); - int id = player.currentWindowId; - - if(isBlock) - { - Mekanism.packetHandler.sendTo(new PersonalChestMessage(PersonalChestPacketType.CLIENT_OPEN, true, 0, id, Coord4D.get(tileEntity)), player); - } - else { - Mekanism.packetHandler.sendTo(new PersonalChestMessage(PersonalChestPacketType.CLIENT_OPEN, false, 0, id, null), player); - } - - player.openContainer = new ContainerPersonalChest(player.inventory, tileEntity, inventory, isBlock); - player.openContainer.windowId = id; - player.openContainer.addCraftingToCrafters(player); - } - - /** - * Retrieves a private value from a defined class and field. - * @param obj - the Object to retrieve the value from, null if static - * @param c - Class to retrieve field value from - * @param fields - possible names of field to iterate through - * @return value as an Object, cast as necessary - */ - public static Object getPrivateValue(Object obj, Class c, String[] fields) - { - for(String field : fields) - { - try { - Field f = c.getDeclaredField(field); - f.setAccessible(true); - return f.get(obj); - } catch(Exception e) { - continue; - } - } - - return null; - } - - /** - * Sets a private value from a defined class and field to a new value. - * @param obj - the Object to perform the operation on, null if static - * @param value - value to set the field to - * @param c - Class the operation will be performed on - * @param fields - possible names of field to iterate through - */ - public static void setPrivateValue(Object obj, Object value, Class c, String[] fields) - { - for(String field : fields) - { - try { - Field f = c.getDeclaredField(field); - f.setAccessible(true); - f.set(obj, value); - } catch(Exception e) { - continue; - } - } - } - - /** - * Retrieves a private method from a class, sets it as accessible, and returns it. - * @param c - Class the method is located in - * @param methods - possible names of the method to iterate through - * @param params - the Types inserted as parameters into the method - * @return private method - */ - public static Method getPrivateMethod(Class c, String[] methods, Class... params) - { - for(String method : methods) - { - try { - Method m = c.getDeclaredMethod(method, params); - m.setAccessible(true); - return m; - } catch(Exception e) { - continue; - } - } - - return null; - } - - /** - * Gets a ResourceLocation with a defined resource type and name. - * @param type - type of resource to retrieve - * @param name - simple name of file to retrieve as a ResourceLocation - * @return the corresponding ResourceLocation - */ - public static ResourceLocation getResource(ResourceType type, String name) - { - return new ResourceLocation("mekanism", type.getPrefix() + name); - } - - /** - * Removes all recipes that are used to create the defined ItemStacks. - * @param itemStacks - ItemStacks to perform the operation on - * @return if any recipes were removed - */ - public static boolean removeRecipes(ItemStack... itemStacks) - { - boolean didRemove = false; - - for(Iterator itr = CraftingManager.getInstance().getRecipeList().iterator(); itr.hasNext();) - { - Object obj = itr.next(); - - if(obj instanceof IRecipe && ((IRecipe)obj).getRecipeOutput() != null) - { - for(ItemStack itemStack : itemStacks) - { - if(((IRecipe)obj).getRecipeOutput().isItemEqual(itemStack)) - { - itr.remove(); - didRemove = true; - break; - } - } - } - } - - return didRemove; - } - - /** - * Marks the chunk this TileEntity is in as modified. Call this method to be sure NBT is written by the defined tile entity. - * @param tileEntity - TileEntity to save - */ - public static void saveChunk(TileEntity tileEntity) - { - if(tileEntity == null || tileEntity.isInvalid() || tileEntity.getWorldObj() == null) - { - return; - } - - tileEntity.getWorldObj().markTileEntityChunkModified(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, tileEntity); - } - - /** - * Whether or not a certain TileEntity can function with redstone logic. Illogical to use unless the defined TileEntity implements - * IRedstoneControl. - * @param tileEntity - TileEntity to check - * @return if the TileEntity can function with redstone logic - */ - public static boolean canFunction(TileEntity tileEntity) - { - if(!(tileEntity instanceof IRedstoneControl)) - { - return true; - } - - IRedstoneControl control = (IRedstoneControl)tileEntity; - - switch(control.getControlType()) - { - case DISABLED: - return true; - case HIGH: - return control.isPowered(); - case LOW: - return !control.isPowered(); - case PULSE: - return control.isPowered() && !control.wasPowered(); - } - - return false; - } - - /** - * Ray-traces what block a player is looking at. - * @param world - world the player is in - * @param player - player to raytrace - * @return raytraced value - */ - public static MovingObjectPosition rayTrace(World world, EntityPlayer player) - { - double reach = Mekanism.proxy.getReach(player); - - Vec3 headVec = getHeadVec(player); - Vec3 lookVec = player.getLook(1); - Vec3 endVec = headVec.addVector(lookVec.xCoord*reach, lookVec.yCoord*reach, lookVec.zCoord*reach); - - return world.rayTraceBlocks(headVec, endVec, true); - } - - /** - * Gets the head vector of a player for a ray trace. - * @param player - player to check - * @return head location - */ - private static Vec3 getHeadVec(EntityPlayer player) - { - Vec3 vec = Vec3.createVectorHelper(player.posX, player.posY, player.posZ); - - if(!player.worldObj.isRemote) - { - vec.yCoord += player.getEyeHeight(); - - if(player instanceof EntityPlayerMP && player.isSneaking()) - { - vec.yCoord -= 0.08; - } - } - - return vec; - } - - /** - * Gets a rounded energy display of a defined amount of energy. - * @param energy - energy to display - * @return rounded energy display - */ - public static String getEnergyDisplay(double energy) - { - if(energy == Double.MAX_VALUE) - { - return LangUtils.localize("gui.infinite"); - } - - switch(general.energyUnit) - { - case J: - return UnitDisplayUtils.getDisplayShort(energy, ElectricUnit.JOULES); - case RF: - return UnitDisplayUtils.getDisplayShort(energy * general.TO_TE, ElectricUnit.REDSTONE_FLUX); - case EU: - return UnitDisplayUtils.getDisplayShort(energy * general.TO_IC2, ElectricUnit.ELECTRICAL_UNITS); - case MJ: - return UnitDisplayUtils.getDisplayShort(energy * general.TO_TE / 10, ElectricUnit.MINECRAFT_JOULES); - } - - return "error"; - } - - /** - * Convert from the unit defined in the configuration to joules. - * @param energy - energy to convert - * @return energy converted to joules - */ - public static double convertToJoules(double energy) - { - switch(general.energyUnit) - { - case RF: - return energy * general.FROM_TE; - case EU: - return energy * general.FROM_IC2; - case MJ: - return energy * general.FROM_TE * 10; - default: - return energy; - } - } - - /** - * Convert from joules to the unit defined in the configuration. - * @param energy - energy to convert - * @return energy converted to configured unit - */ - public static double convertToDisplay(double energy) - { - switch(general.energyUnit) - { - case RF: - return energy * general.TO_TE; - case EU: - return energy * general.TO_IC2; - case MJ: - return energy * general.TO_TE / 10; - default: - return energy; - } - } - - /** - * Gets a rounded energy display of a defined amount of energy. - * @param T - temperature to display - * @return rounded energy display - */ - public static String getTemperatureDisplay(double T, TemperatureUnit unit) - { - double TK = unit.convertToK(T, true); - - switch(general.tempUnit) - { - case K: - return UnitDisplayUtils.getDisplayShort(TK, TemperatureUnit.KELVIN); - case C: - return UnitDisplayUtils.getDisplayShort(TK, TemperatureUnit.CELSIUS); - case R: - return UnitDisplayUtils.getDisplayShort(TK, TemperatureUnit.RANKINE); - case F: - return UnitDisplayUtils.getDisplayShort(TK, TemperatureUnit.FAHRENHEIT); - case STP: - return UnitDisplayUtils.getDisplayShort(TK, TemperatureUnit.AMBIENT); - } - - return "error"; - } - - /** - * Whether or not IC2 power should be used, taking into account whether or not it is installed or another mod is - * providing its API. - * @return if IC2 power should be used - */ - public static boolean useIC2() - { - return Mekanism.hooks.IC2Loaded && EnergyNet.instance != null && !general.blacklistIC2; - } - - /** - * Whether or not RF power should be used, taking into account whether or not it is installed or another mod is - * providing its API. - * @return if RF power should be used - */ - public static boolean useRF() - { - return !general.blacklistRF; - } - - /** - * Gets a clean view of a coordinate value without the dimension ID. - * @param obj - coordinate to check - * @return coordinate display - */ - public static String getCoordDisplay(Coord4D obj) - { - return "[" + obj.xCoord + ", " + obj.yCoord + ", " + obj.zCoord + "]"; - } - - @SideOnly(Side.CLIENT) - public static List splitTooltip(String s, ItemStack stack) - { - s = s.trim(); - - try { - FontRenderer renderer = (FontRenderer)Mekanism.proxy.getFontRenderer(); - - if(stack != null && stack.getItem().getFontRenderer(stack) != null) - { - renderer = stack.getItem().getFontRenderer(stack); - } - - List words = new ArrayList(); - List lines = new ArrayList(); - - String currentWord = ""; - - for(Character c : s.toCharArray()) - { - if(c.equals(' ')) - { - words.add(currentWord); - currentWord = ""; - } - else { - currentWord += c; - } - } - - if(!currentWord.isEmpty()) - { - words.add(currentWord); - } - - String currentLine = ""; - - for(String word : words) - { - if(currentLine.isEmpty() || renderer.getStringWidth(currentLine + " " + word) <= 200) - { - if(currentLine.length() > 0) - { - currentLine += " "; - } - - currentLine += word; - - continue; - } - else { - lines.add(currentLine); - currentLine = word; - - continue; - } - } - - if(!currentLine.isEmpty()) - { - lines.add(currentLine); - } - - return lines; - } catch(Throwable t) { - t.printStackTrace(); - } - - return new ArrayList(); - } - - /** - * Creates and returns a full gas tank with the specified gas type. - * @param gas - gas to fill the tank with - * @return filled gas tank - */ - public static ItemStack getFullGasTank(GasTankTier tier, Gas gas) - { - ItemStack tank = getEmptyGasTank(tier); - ItemBlockGasTank item = (ItemBlockGasTank)tank.getItem(); - item.setGas(tank, new GasStack(gas, item.MAX_GAS)); - - return tank; - } - - public static InventoryCrafting getDummyCraftingInv() - { - Container tempContainer = new Container() { - @Override - public boolean canInteractWith(EntityPlayer player) - { - return false; - } - }; - - return new InventoryCrafting(tempContainer, 3, 3); - } - - /** - * Finds the output of a defined InventoryCrafting grid. - * @param inv - InventoryCrafting to check - * @param world - world reference - * @return output ItemStack - */ - public static ItemStack findMatchingRecipe(InventoryCrafting inv, World world) - { - ItemStack[] dmgItems = new ItemStack[2]; - - for(int i = 0; i < inv.getSizeInventory(); i++) - { - if(inv.getStackInSlot(i) != null) - { - if(dmgItems[0] == null) - { - dmgItems[0] = inv.getStackInSlot(i); - } - else { - dmgItems[1] = inv.getStackInSlot(i); - break; - } - } - } - - if((dmgItems[0] == null) || (dmgItems[0].getItem() == null)) - { - return null; - } - - if((dmgItems[1] != null) && (dmgItems[0].getItem() == dmgItems[1].getItem()) && (dmgItems[0].stackSize == 1) && (dmgItems[1].stackSize == 1) && dmgItems[0].getItem().isRepairable()) - { - Item theItem = dmgItems[0].getItem(); - int dmgDiff0 = theItem.getMaxDamage() - dmgItems[0].getItemDamageForDisplay(); - int dmgDiff1 = theItem.getMaxDamage() - dmgItems[1].getItemDamageForDisplay(); - int value = dmgDiff0 + dmgDiff1 + theItem.getMaxDamage() * 5 / 100; - int solve = Math.max(0, theItem.getMaxDamage() - value); - - return new ItemStack(dmgItems[0].getItem(), 1, solve); - } - - for(IRecipe recipe : (List)CraftingManager.getInstance().getRecipeList()) - { - if(recipe.matches(inv, world)) - { - return recipe.getCraftingResult(inv); - } - } - - return null; - } - - /** - * Whether or not the provided chunk is being vibrated by a Seismic Vibrator. - * @param chunk - chunk to check - * @return if the chunk is being vibrated - */ - public static boolean isChunkVibrated(Chunk3D chunk) - { - for(Coord4D coord : Mekanism.activeVibrators) - { - if(coord.getChunk3D().equals(chunk)) - { - return true; - } - } - - return false; - } - - /** - * Whether or not a given EntityPlayer is considered an Op. - * @param player - player to check - * @return if the player has operator privileges - */ - public static boolean isOp(EntityPlayer p) - { - if(!(p instanceof EntityPlayerMP)) - { - return false; - } - - EntityPlayerMP player = (EntityPlayerMP)p; - - return general.opsBypassRestrictions && player.mcServer.getConfigurationManager().func_152596_g(player.getGameProfile()); - } - - /** - * Gets the mod ID of the mod owning the given ItemStack. - * @param stack - ItemStack to check - * @return mod ID of the ItemStack's owner - */ - public static String getMod(ItemStack stack) - { - try { - ModContainer mod = GameData.findModOwner(GameData.getItemRegistry().getNameForObject(stack.getItem())); - return mod == null ? "Minecraft" : mod.getName(); - } catch(Exception e) { - return "null"; - } - } - - /** - * Gets the item ID from a given ItemStack - * @param itemStack - ItemStack to check - * @return item ID of the ItemStack - */ - public static int getID(ItemStack itemStack) - { - if(itemStack == null) - { - return -1; - } - - return Item.getIdFromItem(itemStack.getItem()); - } - - public static boolean classExists(String className) - { - if(classesFound.containsKey(className)) - { - return classesFound.get(className) != null; - } - - Class found; - - try - { - found = Class.forName(className); - } - catch(ClassNotFoundException e) - { - found = null; - } - - classesFound.put(className, found); - - return found != null; - } - - public static boolean existsAndInstance(Object obj, String className) - { - Class theClass; - - if(classesFound.containsKey(className)) - { - theClass = classesFound.get(className); - } - else { - try { - theClass = Class.forName(className); - classesFound.put(className, theClass); - } catch(ClassNotFoundException e) { - classesFound.put(className, null); - return false; - } - } - - return theClass != null && theClass.isInstance(obj); - } - - public static boolean isBCWrench(Item tool) - { - return existsAndInstance(tool, "buildcraft.api.tools.IToolWrench"); - } - - public static boolean isCoFHHammer(Item tool) - { - return existsAndInstance(tool, "cofh.api.item.IToolHammer"); - } - - /** - * Whether or not the player has a usable wrench for a block at the coordinates given. - * @param player - the player using the wrench - * @param x - the x coordinate of the block being wrenched - * @param y - the y coordinate of the block being wrenched - * @param z - the z coordinate of the block being wrenched - * @return if the player can use the wrench - */ - public static boolean hasUsableWrench(EntityPlayer player, int x, int y, int z) - { - ItemStack tool = player.getCurrentEquippedItem(); - - if(tool == null) - { - return false; - } - - if(tool.getItem() instanceof IMekWrench && ((IMekWrench)tool.getItem()).canUseWrench(player, x, y, z)) - { - return true; - } - - if(isBCWrench(tool.getItem()) && ((IToolWrench)tool.getItem()).canWrench(player, x, y, z)) - { - return true; - } - - if(isCoFHHammer(tool.getItem()) && ((IToolHammer)tool.getItem()).isUsable(tool, player, x, y, z)) - { - return true; - } - - return false; - } - - public static enum ResourceType - { - GUI("gui"), - GUI_ELEMENT("gui/elements"), - SOUND("sound"), - RENDER("render"), - TEXTURE_BLOCKS("textures/blocks"), - TEXTURE_ITEMS("textures/items"), - MODEL("models"), - INFUSE("infuse"); - - private String prefix; - - private ResourceType(String s) - { - prefix = s; - } - - public String getPrefix() - { - return prefix + "/"; - } - } - - public static void setHourForward(final World world, final int paramInt) { + return true; + } + } + } + + return false; + } + + /** + * Checks if a block is directly getting powered by any of its neighbors without + * loading any chunks. + * @param world - the world to perform the check in + * @param coord - the Coord4D of the block to check + * @return if the block is directly getting powered + */ + public static boolean isDirectlyGettingPowered(World world, Coord4D coord) { + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + Coord4D sideCoord = coord.getFromSide(side); + + if (sideCoord.exists(world)) { + if (world.isBlockProvidingPowerTo( + coord.xCoord, coord.yCoord, coord.zCoord, side.ordinal() + ) + > 0) { + return true; + } + } + } + + return false; + } + + /** + * Notifies neighboring blocks of a TileEntity change without loading chunks. + * @param world - world to perform the operation in + * @param coord - Coord4D to perform the operation on + */ + public static void notifyLoadedNeighborsOfTileChange(World world, Coord4D coord) { + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + Coord4D offset = coord.getFromSide(dir); + + if (offset.exists(world)) { + Block block1 = offset.getBlock(world); + block1.onNeighborChange( + world, + offset.xCoord, + offset.yCoord, + offset.zCoord, + coord.xCoord, + coord.yCoord, + coord.zCoord + ); + + if (block1.isNormalCube( + world, offset.xCoord, offset.yCoord, offset.zCoord + )) { + offset = offset.getFromSide(dir); + + if (offset.exists(world)) { + block1 = offset.getBlock(world); + + if (block1.getWeakChanges( + world, offset.xCoord, offset.yCoord, offset.zCoord + )) { + block1.onNeighborChange( + world, + offset.xCoord, + offset.yCoord, + offset.zCoord, + coord.xCoord, + coord.yCoord, + coord.zCoord + ); + } + } + } + } + } + } + + /** + * Places a fake bounding block at the defined location. + * @param world - world to place block in + * @param boundingLocation - coordinates of bounding block + * @param orig - original block + */ + public static void + makeBoundingBlock(World world, Coord4D boundingLocation, Coord4D orig) { + world.setBlock( + boundingLocation.xCoord, + boundingLocation.yCoord, + boundingLocation.zCoord, + MekanismBlocks.BoundingBlock + ); + + if (!world.isRemote) { + ((TileEntityBoundingBlock) boundingLocation.getTileEntity(world)) + .setMainLocation(orig.xCoord, orig.yCoord, orig.zCoord); + } + } + + /** + * Places a fake advanced bounding block at the defined location. + * @param world - world to place block in + * @param boundingLocation - coordinates of bounding block + * @param orig - original block + */ + public static void + makeAdvancedBoundingBlock(World world, Coord4D boundingLocation, Coord4D orig) { + world.setBlock( + boundingLocation.xCoord, + boundingLocation.yCoord, + boundingLocation.zCoord, + MekanismBlocks.BoundingBlock, + 1, + 0 + ); + + if (!world.isRemote) { + ((TileEntityAdvancedBoundingBlock) boundingLocation.getTileEntity(world)) + .setMainLocation(orig.xCoord, orig.yCoord, orig.zCoord); + } + } + + /** + * Updates a block's light value and marks it for a render update. + * @param world - world the block is in + * @param x - x coordinate + * @param y - y coordinate + * @param z - z coordinate + */ + public static void updateBlock(World world, int x, int y, int z) { + Coord4D pos = new Coord4D(x, y, z, world.provider.dimensionId); + if (!(pos.getTileEntity(world) instanceof IActiveState) + || ((IActiveState) pos.getTileEntity(world)).renderUpdate()) { + world.func_147479_m(pos.xCoord, pos.yCoord, pos.zCoord); + } + + if (!(pos.getTileEntity(world) instanceof IActiveState) + || ((IActiveState) pos.getTileEntity(world)).lightUpdate() + && client.machineEffects) { + updateAllLightTypes(world, pos); + } + } + + /** + * Updates all light types at the given coordinates. + * @param world - the world to perform the lighting update in + * @param pos - coordinates of the block to update + */ + public static void updateAllLightTypes(World world, Coord4D pos) { + world.updateLightByType(EnumSkyBlock.Block, pos.xCoord, pos.yCoord, pos.zCoord); + world.updateLightByType(EnumSkyBlock.Sky, pos.xCoord, pos.yCoord, pos.zCoord); + } + + /** + * Whether or not a certain block is considered a fluid. + * @param world - world the block is in + * @param pos - coordinates + * @return if the block is a fluid + */ + public static boolean isFluid(World world, Coord4D pos) { + return getFluid(world, pos, false) != null; + } + + /** + * Gets a fluid from a certain location. + * @param world - world the block is in + * @param pos - location of the block + * @return the fluid at the certain location, null if it doesn't exist + */ + public static FluidStack getFluid(World world, Coord4D pos, boolean filter) { + Block block = pos.getBlock(world); + int meta = pos.getMetadata(world); + + if (block == null) { + return null; + } + + if ((block == Blocks.water || block == Blocks.flowing_water) && meta == 0) { + if (!filter) { + return new FluidStack( + FluidRegistry.WATER, FluidContainerRegistry.BUCKET_VOLUME + ); + } else { + return new FluidStack(FluidRegistry.getFluid("heavywater"), 10); + } + } else if ((block == Blocks.lava || block == Blocks.flowing_lava) && meta == 0) { + return new FluidStack( + FluidRegistry.LAVA, FluidContainerRegistry.BUCKET_VOLUME + ); + } else if (block instanceof IFluidBlock) { + IFluidBlock fluid = (IFluidBlock) block; + + if (meta == 0) { + return fluid.drain(world, pos.xCoord, pos.yCoord, pos.zCoord, false); + } + } + + return null; + } + + /** + * Whether or not a block is a dead fluid. + * @param world - world the block is in + * @param pos - coordinates + * @return if the block is a dead fluid + */ + public static boolean isDeadFluid(World world, Coord4D pos) { + Block block = pos.getBlock(world); + int meta = pos.getMetadata(world); + + if (block == null || meta == 0) { + return false; + } + + if ((block == Blocks.water || block == Blocks.flowing_water)) { + return true; + } else if ((block == Blocks.lava || block == Blocks.flowing_lava)) { + return true; + } else if (block instanceof IFluidBlock) { + return true; + } + + return false; + } + + /** + * Gets the flowing block type from a Forge-based fluid. Incorporates the MC system of + * fliuds as well. + * @param fluid - the fluid type + * @return the block corresponding to the given fluid + */ + public static Block getFlowingBlock(Fluid fluid) { + if (fluid == null) { + return null; + } else if (fluid == FluidRegistry.WATER) { + return Blocks.flowing_water; + } else if (fluid == FluidRegistry.LAVA) { + return Blocks.flowing_lava; + } else { + return fluid.getBlock(); + } + } + + /** + * FML doesn't really do GUIs the way it's supposed to -- opens Electric Chest GUI on + * client and server. Call this method server-side only! + * @param player - player to open GUI + * @param tileEntity - TileEntity of the chest, if it's not an item + * @param inventory - IInventory of the item, if it's not a block + * @param isBlock - whether or not this electric chest is in it's block form + */ + public static void openPersonalChestGui( + EntityPlayerMP player, + TileEntityPersonalChest tileEntity, + IInventory inventory, + boolean isBlock + ) { + player.getNextWindowId(); + player.closeContainer(); + int id = player.currentWindowId; + + if (isBlock) { + Mekanism.packetHandler.sendTo( + new PersonalChestMessage( + PersonalChestPacketType.CLIENT_OPEN, + true, + 0, + id, + Coord4D.get(tileEntity) + ), + player + ); + } else { + Mekanism.packetHandler.sendTo( + new PersonalChestMessage( + PersonalChestPacketType.CLIENT_OPEN, false, 0, id, null + ), + player + ); + } + + player.openContainer = new ContainerPersonalChest( + player.inventory, tileEntity, inventory, isBlock + ); + player.openContainer.windowId = id; + player.openContainer.addCraftingToCrafters(player); + } + + /** + * Retrieves a private value from a defined class and field. + * @param obj - the Object to retrieve the value from, null if static + * @param c - Class to retrieve field value from + * @param fields - possible names of field to iterate through + * @return value as an Object, cast as necessary + */ + public static Object getPrivateValue(Object obj, Class c, String[] fields) { + for (String field : fields) { + try { + Field f = c.getDeclaredField(field); + f.setAccessible(true); + return f.get(obj); + } catch (Exception e) { + continue; + } + } + + return null; + } + + /** + * Sets a private value from a defined class and field to a new value. + * @param obj - the Object to perform the operation on, null if static + * @param value - value to set the field to + * @param c - Class the operation will be performed on + * @param fields - possible names of field to iterate through + */ + public static void + setPrivateValue(Object obj, Object value, Class c, String[] fields) { + for (String field : fields) { + try { + Field f = c.getDeclaredField(field); + f.setAccessible(true); + f.set(obj, value); + } catch (Exception e) { + continue; + } + } + } + + /** + * Retrieves a private method from a class, sets it as accessible, and returns it. + * @param c - Class the method is located in + * @param methods - possible names of the method to iterate through + * @param params - the Types inserted as parameters into the method + * @return private method + */ + public static Method getPrivateMethod(Class c, String[] methods, Class... params) { + for (String method : methods) { + try { + Method m = c.getDeclaredMethod(method, params); + m.setAccessible(true); + return m; + } catch (Exception e) { + continue; + } + } + + return null; + } + + /** + * Gets a ResourceLocation with a defined resource type and name. + * @param type - type of resource to retrieve + * @param name - simple name of file to retrieve as a ResourceLocation + * @return the corresponding ResourceLocation + */ + public static ResourceLocation getResource(ResourceType type, String name) { + return new ResourceLocation("mekanism", type.getPrefix() + name); + } + + /** + * Removes all recipes that are used to create the defined ItemStacks. + * @param itemStacks - ItemStacks to perform the operation on + * @return if any recipes were removed + */ + public static boolean removeRecipes(ItemStack... itemStacks) { + boolean didRemove = false; + + for (Iterator itr = CraftingManager.getInstance().getRecipeList().iterator(); + itr.hasNext();) { + Object obj = itr.next(); + + if (obj instanceof IRecipe && ((IRecipe) obj).getRecipeOutput() != null) { + for (ItemStack itemStack : itemStacks) { + if (((IRecipe) obj).getRecipeOutput().isItemEqual(itemStack)) { + itr.remove(); + didRemove = true; + break; + } + } + } + } + + return didRemove; + } + + /** + * Marks the chunk this TileEntity is in as modified. Call this method to be sure NBT + * is written by the defined tile entity. + * @param tileEntity - TileEntity to save + */ + public static void saveChunk(TileEntity tileEntity) { + if (tileEntity == null || tileEntity.isInvalid() + || tileEntity.getWorldObj() == null) { + return; + } + + tileEntity.getWorldObj().markTileEntityChunkModified( + tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord, tileEntity + ); + } + + /** + * Whether or not a certain TileEntity can function with redstone logic. Illogical to + * use unless the defined TileEntity implements IRedstoneControl. + * @param tileEntity - TileEntity to check + * @return if the TileEntity can function with redstone logic + */ + public static boolean canFunction(TileEntity tileEntity) { + if (!(tileEntity instanceof IRedstoneControl)) { + return true; + } + + IRedstoneControl control = (IRedstoneControl) tileEntity; + + switch (control.getControlType()) { + case DISABLED: + return true; + case HIGH: + return control.isPowered(); + case LOW: + return !control.isPowered(); + case PULSE: + return control.isPowered() && !control.wasPowered(); + } + + return false; + } + + /** + * Ray-traces what block a player is looking at. + * @param world - world the player is in + * @param player - player to raytrace + * @return raytraced value + */ + public static MovingObjectPosition rayTrace(World world, EntityPlayer player) { + double reach = Mekanism.proxy.getReach(player); + + Vec3 headVec = getHeadVec(player); + Vec3 lookVec = player.getLook(1); + Vec3 endVec = headVec.addVector( + lookVec.xCoord * reach, lookVec.yCoord * reach, lookVec.zCoord * reach + ); + + return world.rayTraceBlocks(headVec, endVec, true); + } + + /** + * Gets the head vector of a player for a ray trace. + * @param player - player to check + * @return head location + */ + private static Vec3 getHeadVec(EntityPlayer player) { + Vec3 vec = Vec3.createVectorHelper(player.posX, player.posY, player.posZ); + + if (!player.worldObj.isRemote) { + vec.yCoord += player.getEyeHeight(); + + if (player instanceof EntityPlayerMP && player.isSneaking()) { + vec.yCoord -= 0.08; + } + } + + return vec; + } + + /** + * Gets a rounded energy display of a defined amount of energy. + * @param energy - energy to display + * @return rounded energy display + */ + public static String getEnergyDisplay(double energy) { + if (energy == Double.MAX_VALUE) { + return LangUtils.localize("gui.infinite"); + } + + switch (general.energyUnit) { + case J: + return UnitDisplayUtils.getDisplayShort(energy, ElectricUnit.JOULES); + case RF: + return UnitDisplayUtils.getDisplayShort( + energy * general.TO_TE, ElectricUnit.REDSTONE_FLUX + ); + case EU: + return UnitDisplayUtils.getDisplayShort( + energy * general.TO_IC2, ElectricUnit.ELECTRICAL_UNITS + ); + case MJ: + return UnitDisplayUtils.getDisplayShort( + energy * general.TO_TE / 10, ElectricUnit.MINECRAFT_JOULES + ); + } + + return "error"; + } + + /** + * Convert from the unit defined in the configuration to joules. + * @param energy - energy to convert + * @return energy converted to joules + */ + public static double convertToJoules(double energy) { + switch (general.energyUnit) { + case RF: + return energy * general.FROM_TE; + case EU: + return energy * general.FROM_IC2; + case MJ: + return energy * general.FROM_TE * 10; + default: + return energy; + } + } + + /** + * Convert from joules to the unit defined in the configuration. + * @param energy - energy to convert + * @return energy converted to configured unit + */ + public static double convertToDisplay(double energy) { + switch (general.energyUnit) { + case RF: + return energy * general.TO_TE; + case EU: + return energy * general.TO_IC2; + case MJ: + return energy * general.TO_TE / 10; + default: + return energy; + } + } + + /** + * Gets a rounded energy display of a defined amount of energy. + * @param T - temperature to display + * @return rounded energy display + */ + public static String getTemperatureDisplay(double T, TemperatureUnit unit) { + double TK = unit.convertToK(T, true); + + switch (general.tempUnit) { + case K: + return UnitDisplayUtils.getDisplayShort(TK, TemperatureUnit.KELVIN); + case C: + return UnitDisplayUtils.getDisplayShort(TK, TemperatureUnit.CELSIUS); + case R: + return UnitDisplayUtils.getDisplayShort(TK, TemperatureUnit.RANKINE); + case F: + return UnitDisplayUtils.getDisplayShort(TK, TemperatureUnit.FAHRENHEIT); + case STP: + return UnitDisplayUtils.getDisplayShort(TK, TemperatureUnit.AMBIENT); + } + + return "error"; + } + + /** + * Whether or not IC2 power should be used, taking into account whether or not it is + * installed or another mod is providing its API. + * @return if IC2 power should be used + */ + public static boolean useIC2() { + return Mekanism.hooks.IC2Loaded && EnergyNet.instance != null + && !general.blacklistIC2; + } + + /** + * Whether or not RF power should be used, taking into account whether or not it is + * installed or another mod is providing its API. + * @return if RF power should be used + */ + public static boolean useRF() { + return !general.blacklistRF; + } + + /** + * Gets a clean view of a coordinate value without the dimension ID. + * @param obj - coordinate to check + * @return coordinate display + */ + public static String getCoordDisplay(Coord4D obj) { + return "[" + obj.xCoord + ", " + obj.yCoord + ", " + obj.zCoord + "]"; + } + + @SideOnly(Side.CLIENT) + public static List splitTooltip(String s, ItemStack stack) { + s = s.trim(); + + try { + FontRenderer renderer = (FontRenderer) Mekanism.proxy.getFontRenderer(); + + if (stack != null && stack.getItem().getFontRenderer(stack) != null) { + renderer = stack.getItem().getFontRenderer(stack); + } + + List words = new ArrayList(); + List lines = new ArrayList(); + + String currentWord = ""; + + for (Character c : s.toCharArray()) { + if (c.equals(' ')) { + words.add(currentWord); + currentWord = ""; + } else { + currentWord += c; + } + } + + if (!currentWord.isEmpty()) { + words.add(currentWord); + } + + String currentLine = ""; + + for (String word : words) { + if (currentLine.isEmpty() + || renderer.getStringWidth(currentLine + " " + word) <= 200) { + if (currentLine.length() > 0) { + currentLine += " "; + } + + currentLine += word; + + continue; + } else { + lines.add(currentLine); + currentLine = word; + + continue; + } + } + + if (!currentLine.isEmpty()) { + lines.add(currentLine); + } + + return lines; + } catch (Throwable t) { + t.printStackTrace(); + } + + return new ArrayList(); + } + + /** + * Creates and returns a full gas tank with the specified gas type. + * @param gas - gas to fill the tank with + * @return filled gas tank + */ + public static ItemStack getFullGasTank(GasTankTier tier, Gas gas) { + ItemStack tank = getEmptyGasTank(tier); + ItemBlockGasTank item = (ItemBlockGasTank) tank.getItem(); + item.setGas(tank, new GasStack(gas, item.MAX_GAS)); + + return tank; + } + + public static InventoryCrafting getDummyCraftingInv() { + Container tempContainer = new Container() { + @Override + public boolean canInteractWith(EntityPlayer player) { + return false; + } + }; + + return new InventoryCrafting(tempContainer, 3, 3); + } + + /** + * Finds the output of a defined InventoryCrafting grid. + * @param inv - InventoryCrafting to check + * @param world - world reference + * @return output ItemStack + */ + public static ItemStack findMatchingRecipe(InventoryCrafting inv, World world) { + ItemStack[] dmgItems = new ItemStack[2]; + + for (int i = 0; i < inv.getSizeInventory(); i++) { + if (inv.getStackInSlot(i) != null) { + if (dmgItems[0] == null) { + dmgItems[0] = inv.getStackInSlot(i); + } else { + dmgItems[1] = inv.getStackInSlot(i); + break; + } + } + } + + if ((dmgItems[0] == null) || (dmgItems[0].getItem() == null)) { + return null; + } + + if ((dmgItems[1] != null) && (dmgItems[0].getItem() == dmgItems[1].getItem()) + && (dmgItems[0].stackSize == 1) && (dmgItems[1].stackSize == 1) + && dmgItems[0].getItem().isRepairable()) { + Item theItem = dmgItems[0].getItem(); + int dmgDiff0 = theItem.getMaxDamage() - dmgItems[0].getItemDamageForDisplay(); + int dmgDiff1 = theItem.getMaxDamage() - dmgItems[1].getItemDamageForDisplay(); + int value = dmgDiff0 + dmgDiff1 + theItem.getMaxDamage() * 5 / 100; + int solve = Math.max(0, theItem.getMaxDamage() - value); + + return new ItemStack(dmgItems[0].getItem(), 1, solve); + } + + for (IRecipe recipe : + (List) CraftingManager.getInstance().getRecipeList()) { + if (recipe.matches(inv, world)) { + return recipe.getCraftingResult(inv); + } + } + + return null; + } + + /** + * Whether or not the provided chunk is being vibrated by a Seismic Vibrator. + * @param chunk - chunk to check + * @return if the chunk is being vibrated + */ + public static boolean isChunkVibrated(Chunk3D chunk) { + for (Coord4D coord : Mekanism.activeVibrators) { + if (coord.getChunk3D().equals(chunk)) { + return true; + } + } + + return false; + } + + /** + * Whether or not a given EntityPlayer is considered an Op. + * @param player - player to check + * @return if the player has operator privileges + */ + public static boolean isOp(EntityPlayer p) { + if (!(p instanceof EntityPlayerMP)) { + return false; + } + + EntityPlayerMP player = (EntityPlayerMP) p; + + return general.opsBypassRestrictions + && player.mcServer.getConfigurationManager().func_152596_g( + player.getGameProfile() + ); + } + + /** + * Gets the mod ID of the mod owning the given ItemStack. + * @param stack - ItemStack to check + * @return mod ID of the ItemStack's owner + */ + public static String getMod(ItemStack stack) { + try { + ModContainer mod = GameData.findModOwner( + GameData.getItemRegistry().getNameForObject(stack.getItem()) + ); + return mod == null ? "Minecraft" : mod.getName(); + } catch (Exception e) { + return "null"; + } + } + + /** + * Gets the item ID from a given ItemStack + * @param itemStack - ItemStack to check + * @return item ID of the ItemStack + */ + public static int getID(ItemStack itemStack) { + if (itemStack == null) { + return -1; + } + + return Item.getIdFromItem(itemStack.getItem()); + } + + public static boolean classExists(String className) { + if (classesFound.containsKey(className)) { + return classesFound.get(className) != null; + } + + Class found; + + try { + found = Class.forName(className); + } catch (ClassNotFoundException e) { + found = null; + } + + classesFound.put(className, found); + + return found != null; + } + + public static boolean existsAndInstance(Object obj, String className) { + Class theClass; + + if (classesFound.containsKey(className)) { + theClass = classesFound.get(className); + } else { + try { + theClass = Class.forName(className); + classesFound.put(className, theClass); + } catch (ClassNotFoundException e) { + classesFound.put(className, null); + return false; + } + } + + return theClass != null && theClass.isInstance(obj); + } + + public static boolean isBCWrench(Item tool) { + return existsAndInstance(tool, "buildcraft.api.tools.IToolWrench"); + } + + public static boolean isCoFHHammer(Item tool) { + return existsAndInstance(tool, "cofh.api.item.IToolHammer"); + } + + /** + * Whether or not the player has a usable wrench for a block at the coordinates given. + * @param player - the player using the wrench + * @param x - the x coordinate of the block being wrenched + * @param y - the y coordinate of the block being wrenched + * @param z - the z coordinate of the block being wrenched + * @return if the player can use the wrench + */ + public static boolean hasUsableWrench(EntityPlayer player, int x, int y, int z) { + ItemStack tool = player.getCurrentEquippedItem(); + + if (tool == null) { + return false; + } + + if (tool.getItem() instanceof IMekWrench + && ((IMekWrench) tool.getItem()).canUseWrench(player, x, y, z)) { + return true; + } + + if (isBCWrench(tool.getItem()) + && ((IToolWrench) tool.getItem()).canWrench(player, x, y, z)) { + return true; + } + + if (isCoFHHammer(tool.getItem()) + && ((IToolHammer) tool.getItem()).isUsable(tool, player, x, y, z)) { + return true; + } + + return false; + } + + public static enum ResourceType { + GUI("gui"), + GUI_ELEMENT("gui/elements"), + SOUND("sound"), + RENDER("render"), + TEXTURE_BLOCKS("textures/blocks"), + TEXTURE_ITEMS("textures/items"), + MODEL("models"), + INFUSE("infuse"); + + private String prefix; + + private ResourceType(String s) { + prefix = s; + } + + public String getPrefix() { + return prefix + "/"; + } + } + + public static void setHourForward(final World world, final int paramInt) { final long l1 = world.getWorldTime() / 24000L * 24000L; final long l2 = l1 + 24000L + paramInt * 1000; world.setWorldTime(l2); diff --git a/src/main/java/mekanism/common/util/MinerUtils.java b/src/main/java/mekanism/common/util/MinerUtils.java index 31d3ecc23..5e5933290 100644 --- a/src/main/java/mekanism/common/util/MinerUtils.java +++ b/src/main/java/mekanism/common/util/MinerUtils.java @@ -10,40 +10,38 @@ 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 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); + public static List getDrops(World world, Coord4D obj, boolean silk) { + Block block = obj.getBlock(world); - if(block == null) - { - return new ArrayList(); - } + if (block == null) { + return new ArrayList(); + } - if(block.isAir(world, obj.xCoord, obj.yCoord, obj.zCoord)) - { - return new ArrayList(); - } + if (block.isAir(world, obj.xCoord, obj.yCoord, obj.zCoord)) { + return new ArrayList(); + } - int meta = obj.getMetadata(world); + 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 (!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; - } - } + 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(); - } + return new ArrayList(); + } } diff --git a/src/main/java/mekanism/common/util/PipeUtils.java b/src/main/java/mekanism/common/util/PipeUtils.java index b77c2de04..3eddcd693 100644 --- a/src/main/java/mekanism/common/util/PipeUtils.java +++ b/src/main/java/mekanism/common/util/PipeUtils.java @@ -14,119 +14,117 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; -public final class PipeUtils -{ - public static final FluidTankInfo[] EMPTY = new FluidTankInfo[] {}; +public final class PipeUtils { + public static final FluidTankInfo[] EMPTY = new FluidTankInfo[] {}; - public static boolean isValidAcceptorOnSide(TileEntity tile, ForgeDirection side) - { - if(tile instanceof ITransmitterTile || !(tile instanceof IFluidHandler)) - return false; + public static boolean isValidAcceptorOnSide(TileEntity tile, ForgeDirection side) { + if (tile instanceof ITransmitterTile || !(tile instanceof IFluidHandler)) + return false; - IFluidHandler container = (IFluidHandler)tile; - FluidTankInfo[] infoArray = container.getTankInfo(side.getOpposite()); + IFluidHandler container = (IFluidHandler) tile; + FluidTankInfo[] infoArray = container.getTankInfo(side.getOpposite()); - if(container.canDrain(side.getOpposite(), FluidRegistry.WATER) - || container.canFill(side.getOpposite(), FluidRegistry.WATER)) //I hesitate to pass null to these. - { - return true; - } - else if(infoArray != null && infoArray.length > 0) - { - for(FluidTankInfo info : infoArray) - { - if(info != null) - { - return true; - } - } - } - return false; - } + if (container.canDrain(side.getOpposite(), FluidRegistry.WATER) + || container.canFill( + side.getOpposite(), FluidRegistry.WATER + )) //I hesitate to pass null to these. + { + return true; + } else if (infoArray != null && infoArray.length > 0) { + for (FluidTankInfo info : infoArray) { + if (info != null) { + return true; + } + } + } + return false; + } - /** - * 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}; + /** + * 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()); + for (ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) { + TileEntity acceptor = Coord4D.get(tileEntity) + .getFromSide(orientation) + .getTileEntity(tileEntity.getWorldObj()); - if(acceptor instanceof IFluidHandler) - { - acceptors[orientation.ordinal()] = (IFluidHandler)acceptor; - } - } + if (acceptor instanceof IFluidHandler) { + acceptors[orientation.ordinal()] = (IFluidHandler) acceptor; + } + } - return acceptors; - } - - /** - * Emits fluid from a central block by splitting the received stack among the sides given. - * @param sides - the list of sides to output from - * @param stack - the stack to output - * @param from - the TileEntity to output from - * @return the amount of gas emitted - */ - public static int emit(List sides, FluidStack stack, TileEntity from) - { - if(stack == null) - { - return 0; - } - - List availableAcceptors = new ArrayList(); - IFluidHandler[] possibleAcceptors = getConnectedAcceptors(from); - - for(int i = 0; i < possibleAcceptors.length; i++) - { - IFluidHandler handler = possibleAcceptors[i]; - - if(handler != null && handler.canFill(ForgeDirection.getOrientation(i).getOpposite(), stack.getFluid())) - { - availableAcceptors.add(handler); - } - } + return acceptors; + } - Collections.shuffle(availableAcceptors); + /** + * Emits fluid from a central block by splitting the received stack among the sides + * given. + * @param sides - the list of sides to output from + * @param stack - the stack to output + * @param from - the TileEntity to output from + * @return the amount of gas emitted + */ + public static int + emit(List sides, FluidStack stack, TileEntity from) { + if (stack == null) { + return 0; + } - int toSend = stack.amount; - int prevSending = toSend; + List availableAcceptors = new ArrayList(); + IFluidHandler[] possibleAcceptors = getConnectedAcceptors(from); - if(!availableAcceptors.isEmpty()) - { - int divider = availableAcceptors.size(); - int remaining = toSend % divider; - int sending = (toSend-remaining)/divider; + for (int i = 0; i < possibleAcceptors.length; i++) { + IFluidHandler handler = possibleAcceptors[i]; - for(IFluidHandler acceptor : availableAcceptors) - { - int currentSending = sending; + if (handler != null + && handler.canFill( + ForgeDirection.getOrientation(i).getOpposite(), stack.getFluid() + )) { + availableAcceptors.add(handler); + } + } - if(remaining > 0) - { - currentSending++; - remaining--; - } - - ForgeDirection dir = ForgeDirection.getOrientation(Arrays.asList(possibleAcceptors).indexOf(acceptor)).getOpposite(); - toSend -= acceptor.fill(dir, copy(stack, currentSending), true); - } - } + Collections.shuffle(availableAcceptors); - return prevSending-toSend; - } - - public static FluidStack copy(FluidStack fluid, int amount) - { - FluidStack ret = fluid.copy(); - ret.amount = amount; - - return ret; - } + int toSend = stack.amount; + int prevSending = toSend; + + if (!availableAcceptors.isEmpty()) { + int divider = availableAcceptors.size(); + int remaining = toSend % divider; + int sending = (toSend - remaining) / divider; + + for (IFluidHandler acceptor : availableAcceptors) { + int currentSending = sending; + + if (remaining > 0) { + currentSending++; + remaining--; + } + + ForgeDirection dir + = ForgeDirection + .getOrientation( + Arrays.asList(possibleAcceptors).indexOf(acceptor) + ) + .getOpposite(); + toSend -= acceptor.fill(dir, copy(stack, currentSending), true); + } + } + + return prevSending - toSend; + } + + public static FluidStack copy(FluidStack fluid, int amount) { + FluidStack ret = fluid.copy(); + ret.amount = amount; + + return ret; + } } diff --git a/src/main/java/mekanism/common/util/RecipeUtils.java b/src/main/java/mekanism/common/util/RecipeUtils.java index 3028587d3..2e969add0 100644 --- a/src/main/java/mekanism/common/util/RecipeUtils.java +++ b/src/main/java/mekanism/common/util/RecipeUtils.java @@ -32,319 +32,299 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.IFluidContainerItem; import net.minecraftforge.oredict.OreDictionary; -public class RecipeUtils -{ - public static boolean areItemsEqualForCrafting(ItemStack target, ItemStack input) - { - if(target == null && input != null || target != null && input == null) - { - return false; - } - else if(target == null && input == null) - { - return true; - } +public class RecipeUtils { + public static boolean areItemsEqualForCrafting(ItemStack target, ItemStack input) { + if (target == null && input != null || target != null && input == null) { + return false; + } else if (target == null && input == null) { + return true; + } - if(target.getItem() != input.getItem()) - { - return false; - } - - if(target.getItemDamage() != input.getItemDamage() && target.getItemDamage() != OreDictionary.WILDCARD_VALUE) - { - return false; - } + if (target.getItem() != input.getItem()) { + return false; + } - if(target.getItem() instanceof IEnergyCube && input.getItem() instanceof IEnergyCube) - { - if(((IEnergyCube)target.getItem()).getEnergyCubeTier(target) != ((IEnergyCube)input.getItem()).getEnergyCubeTier(input)) - { - return false; - } - } - - if(target.getItem() instanceof ITierItem && input.getItem() instanceof ITierItem) - { - if(((ITierItem)target.getItem()).getBaseTier(target) != ((ITierItem)input.getItem()).getBaseTier(input)) - { - return false; - } - } - - if(target.getItem() instanceof IFactory && input.getItem() instanceof IFactory) - { - if(isFactory(target) && isFactory(input)) - { - if(((IFactory)target.getItem()).getRecipeType(target) != ((IFactory)input.getItem()).getRecipeType(input)) - { - return false; - } - } - } + if (target.getItemDamage() != input.getItemDamage() + && target.getItemDamage() != OreDictionary.WILDCARD_VALUE) { + return false; + } - return true; - } - - private static boolean isFactory(ItemStack stack) - { - return MachineType.get(stack) == MachineType.BASIC_FACTORY || MachineType.get(stack) == MachineType.ADVANCED_FACTORY || MachineType.get(stack) == MachineType.ELITE_FACTORY; - } - - public static ItemStack getCraftingResult(InventoryCrafting inv, ItemStack toReturn) - { - if(toReturn.getItem() instanceof IEnergizedItem) - { - double energyFound = 0; + if (target.getItem() instanceof IEnergyCube + && input.getItem() instanceof IEnergyCube) { + if (((IEnergyCube) target.getItem()).getEnergyCubeTier(target) + != ((IEnergyCube) input.getItem()).getEnergyCubeTier(input)) { + return false; + } + } - for(int i = 0; i < 9; i++) - { - ItemStack itemstack = inv.getStackInSlot(i); + if (target.getItem() instanceof ITierItem + && input.getItem() instanceof ITierItem) { + if (((ITierItem) target.getItem()).getBaseTier(target) + != ((ITierItem) input.getItem()).getBaseTier(input)) { + return false; + } + } - if(itemstack != null && itemstack.getItem() instanceof IEnergizedItem) - { - energyFound += ((IEnergizedItem)itemstack.getItem()).getEnergy(itemstack); - } - } + if (target.getItem() instanceof IFactory && input.getItem() instanceof IFactory) { + if (isFactory(target) && isFactory(input)) { + if (((IFactory) target.getItem()).getRecipeType(target) + != ((IFactory) input.getItem()).getRecipeType(input)) { + return false; + } + } + } - ((IEnergizedItem)toReturn.getItem()).setEnergy(toReturn, Math.min(((IEnergizedItem)toReturn.getItem()).getMaxEnergy(toReturn), energyFound)); - } - - if(toReturn.getItem() instanceof IGasItem) - { - GasStack gasFound = null; - - for(int i = 0; i < 9; i++) - { - ItemStack itemstack = inv.getStackInSlot(i); + return true; + } - if(itemstack != null && itemstack.getItem() instanceof IGasItem) - { - GasStack stored = ((IGasItem)itemstack.getItem()).getGas(itemstack); - - if(stored != null) - { - if(!((IGasItem)toReturn.getItem()).canReceiveGas(toReturn, stored.getGas())) - { - return null; - } - - if(gasFound == null) - { - gasFound = stored; - } - else { - if(gasFound.getGas() != stored.getGas()) - { - return null; - } - - gasFound.amount += stored.amount; - } - } - } - } - - if(gasFound != null) - { - gasFound.amount = Math.min(((IGasItem)toReturn.getItem()).getMaxGas(toReturn), gasFound.amount); - ((IGasItem)toReturn.getItem()).setGas(toReturn, gasFound); - } - } - - if(toReturn.getItem() instanceof ISecurityItem) - { - for(int i = 0; i < 9; i++) - { - ItemStack itemstack = inv.getStackInSlot(i); - - if(itemstack != null && itemstack.getItem() instanceof ISecurityItem) - { - ((ISecurityItem)toReturn.getItem()).setOwner(toReturn, ((ISecurityItem)itemstack.getItem()).getOwner(itemstack)); - ((ISecurityItem)toReturn.getItem()).setSecurity(toReturn, ((ISecurityItem)itemstack.getItem()).getSecurity(itemstack)); - - break; - } - } - } - - if(toReturn.getItem() instanceof IFluidContainerItem) - { - FluidStack fluidFound = null; - - for(int i = 0; i < 9; i++) - { - ItemStack itemstack = inv.getStackInSlot(i); + private static boolean isFactory(ItemStack stack) { + return MachineType.get(stack) == MachineType.BASIC_FACTORY + || MachineType.get(stack) == MachineType.ADVANCED_FACTORY + || MachineType.get(stack) == MachineType.ELITE_FACTORY; + } - if(itemstack != null && itemstack.getItem() instanceof IFluidContainerItem) - { - FluidStack stored = ((IFluidContainerItem)itemstack.getItem()).getFluid(itemstack); - - if(stored != null) - { - if(((IFluidContainerItem)toReturn.getItem()).fill(toReturn, stored, false) == 0) - { - return null; - } - - if(fluidFound == null) - { - fluidFound = stored; - } - else { - if(fluidFound.getFluid() != stored.getFluid()) - { - return null; - } - - fluidFound.amount += stored.amount; - } - } - } - } - - if(fluidFound != null) - { - fluidFound.amount = Math.min(((IFluidContainerItem)toReturn.getItem()).getCapacity(toReturn), fluidFound.amount); - ((IFluidContainerItem)toReturn.getItem()).fill(toReturn, fluidFound, true); - } - } - - if(BasicType.get(toReturn) == BasicType.BIN) - { - int foundCount = 0; - ItemStack foundType = null; - - for(int i = 0; i < 9; i++) - { - ItemStack itemstack = inv.getStackInSlot(i); + public static ItemStack getCraftingResult(InventoryCrafting inv, ItemStack toReturn) { + if (toReturn.getItem() instanceof IEnergizedItem) { + double energyFound = 0; - if(itemstack != null && BasicType.get(itemstack) == BasicType.BIN) - { - InventoryBin binInv = new InventoryBin(itemstack); - - foundCount = binInv.getItemCount(); - foundType = binInv.getItemType(); - } - } - - if(foundCount > 0 && foundType != null) - { - InventoryBin binInv = new InventoryBin(toReturn); - binInv.setItemCount(foundCount); - binInv.setItemType(foundType); - } - } + for (int i = 0; i < 9; i++) { + ItemStack itemstack = inv.getStackInSlot(i); - if(MachineType.get(toReturn) != null && MachineType.get(toReturn).supportsUpgrades) - { - Map upgrades = new HashMap(); + if (itemstack != null && itemstack.getItem() instanceof IEnergizedItem) { + energyFound + += ((IEnergizedItem) itemstack.getItem()).getEnergy(itemstack); + } + } - for(int i = 0; i < 9; i++) - { - ItemStack itemstack = inv.getStackInSlot(i); + ((IEnergizedItem) toReturn.getItem()) + .setEnergy( + toReturn, + Math.min( + ((IEnergizedItem) toReturn.getItem()).getMaxEnergy(toReturn), + energyFound + ) + ); + } - if(itemstack != null && MachineType.get(itemstack) != null && MachineType.get(itemstack).supportsUpgrades) - { - Map stackMap = Upgrade.buildMap(itemstack.stackTagCompound); - - for(Map.Entry entry : stackMap.entrySet()) - { - if(entry != null && entry.getKey() != null && entry.getValue() != null) - { - Integer val = upgrades.get(entry.getKey()); - - upgrades.put(entry.getKey(), Math.min(entry.getKey().getMax(), (val != null ? val : 0) + entry.getValue())); - } - } - } - } - - if(toReturn.stackTagCompound == null) - { - toReturn.setTagCompound(new NBTTagCompound()); - } - - Upgrade.saveMap(upgrades, toReturn.stackTagCompound); - } + if (toReturn.getItem() instanceof IGasItem) { + GasStack gasFound = null; - return toReturn; - } - - public static ItemStack loadRecipeItemStack(NBTTagCompound nbtTags) - { - int meta = 0; - int amount = 1; - - if(nbtTags.hasKey("meta")) - { - meta = nbtTags.getInteger("meta"); - } - - if(nbtTags.hasKey("amount")) - { - amount = nbtTags.getInteger("amount"); - } - - if(nbtTags.hasKey("itemstack")) - { - return ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("itemstack")); - } - else if(nbtTags.hasKey("itemname")) - { - Object obj = Item.itemRegistry.getObject(nbtTags.getString("itemname")); - - if(obj instanceof Item) - { - return new ItemStack((Item)obj, amount, meta); - } - } - else if(nbtTags.hasKey("blockname")) - { - Object obj = Block.blockRegistry.getObject(nbtTags.getString("blockname")); - - if(obj instanceof Block) - { - return new ItemStack((Block)obj, amount, meta); - } - } - - return null; - } - - public static boolean removeRecipes(ItemStack stack) - { - List recipes = CraftingManager.getInstance().getRecipeList(); - - for(Iterator iter = recipes.iterator(); iter.hasNext();) - { - IRecipe iterRecipe = iter.next(); - - if(iterRecipe instanceof ShapedMekanismRecipe || iterRecipe instanceof ShapelessMekanismRecipe) - { - if(StackUtils.equalsWildcard(stack, iterRecipe.getRecipeOutput())) - { - iter.remove(); - } - } - } - - return false; - } - - public static IRecipe getRecipeFromGrid(InventoryCrafting inv, World world) - { - List list = new ArrayList(CraftingManager.getInstance().getRecipeList()); - - for(Iterator iter = list.iterator(); iter.hasNext();) - { - IRecipe recipe = iter.next(); - - if(recipe.matches(inv, world)) - { - return recipe; - } - } - - return null; - } + for (int i = 0; i < 9; i++) { + ItemStack itemstack = inv.getStackInSlot(i); + + if (itemstack != null && itemstack.getItem() instanceof IGasItem) { + GasStack stored = ((IGasItem) itemstack.getItem()).getGas(itemstack); + + if (stored != null) { + if (!((IGasItem) toReturn.getItem()) + .canReceiveGas(toReturn, stored.getGas())) { + return null; + } + + if (gasFound == null) { + gasFound = stored; + } else { + if (gasFound.getGas() != stored.getGas()) { + return null; + } + + gasFound.amount += stored.amount; + } + } + } + } + + if (gasFound != null) { + gasFound.amount = Math.min( + ((IGasItem) toReturn.getItem()).getMaxGas(toReturn), gasFound.amount + ); + ((IGasItem) toReturn.getItem()).setGas(toReturn, gasFound); + } + } + + if (toReturn.getItem() instanceof ISecurityItem) { + for (int i = 0; i < 9; i++) { + ItemStack itemstack = inv.getStackInSlot(i); + + if (itemstack != null && itemstack.getItem() instanceof ISecurityItem) { + ((ISecurityItem) toReturn.getItem()) + .setOwner( + toReturn, + ((ISecurityItem) itemstack.getItem()).getOwner(itemstack) + ); + ((ISecurityItem) toReturn.getItem()) + .setSecurity( + toReturn, + ((ISecurityItem) itemstack.getItem()).getSecurity(itemstack) + ); + + break; + } + } + } + + if (toReturn.getItem() instanceof IFluidContainerItem) { + FluidStack fluidFound = null; + + for (int i = 0; i < 9; i++) { + ItemStack itemstack = inv.getStackInSlot(i); + + if (itemstack != null + && itemstack.getItem() instanceof IFluidContainerItem) { + FluidStack stored + = ((IFluidContainerItem) itemstack.getItem()).getFluid(itemstack); + + if (stored != null) { + if (((IFluidContainerItem) toReturn.getItem()) + .fill(toReturn, stored, false) + == 0) { + return null; + } + + if (fluidFound == null) { + fluidFound = stored; + } else { + if (fluidFound.getFluid() != stored.getFluid()) { + return null; + } + + fluidFound.amount += stored.amount; + } + } + } + } + + if (fluidFound != null) { + fluidFound.amount = Math.min( + ((IFluidContainerItem) toReturn.getItem()).getCapacity(toReturn), + fluidFound.amount + ); + ((IFluidContainerItem) toReturn.getItem()) + .fill(toReturn, fluidFound, true); + } + } + + if (BasicType.get(toReturn) == BasicType.BIN) { + int foundCount = 0; + ItemStack foundType = null; + + for (int i = 0; i < 9; i++) { + ItemStack itemstack = inv.getStackInSlot(i); + + if (itemstack != null && BasicType.get(itemstack) == BasicType.BIN) { + InventoryBin binInv = new InventoryBin(itemstack); + + foundCount = binInv.getItemCount(); + foundType = binInv.getItemType(); + } + } + + if (foundCount > 0 && foundType != null) { + InventoryBin binInv = new InventoryBin(toReturn); + binInv.setItemCount(foundCount); + binInv.setItemType(foundType); + } + } + + if (MachineType.get(toReturn) != null + && MachineType.get(toReturn).supportsUpgrades) { + Map upgrades = new HashMap(); + + for (int i = 0; i < 9; i++) { + ItemStack itemstack = inv.getStackInSlot(i); + + if (itemstack != null && MachineType.get(itemstack) != null + && MachineType.get(itemstack).supportsUpgrades) { + Map stackMap + = Upgrade.buildMap(itemstack.stackTagCompound); + + for (Map.Entry entry : stackMap.entrySet()) { + if (entry != null && entry.getKey() != null + && entry.getValue() != null) { + Integer val = upgrades.get(entry.getKey()); + + upgrades.put( + entry.getKey(), + Math.min( + entry.getKey().getMax(), + (val != null ? val : 0) + entry.getValue() + ) + ); + } + } + } + } + + if (toReturn.stackTagCompound == null) { + toReturn.setTagCompound(new NBTTagCompound()); + } + + Upgrade.saveMap(upgrades, toReturn.stackTagCompound); + } + + return toReturn; + } + + public static ItemStack loadRecipeItemStack(NBTTagCompound nbtTags) { + int meta = 0; + int amount = 1; + + if (nbtTags.hasKey("meta")) { + meta = nbtTags.getInteger("meta"); + } + + if (nbtTags.hasKey("amount")) { + amount = nbtTags.getInteger("amount"); + } + + if (nbtTags.hasKey("itemstack")) { + return ItemStack.loadItemStackFromNBT(nbtTags.getCompoundTag("itemstack")); + } else if (nbtTags.hasKey("itemname")) { + Object obj = Item.itemRegistry.getObject(nbtTags.getString("itemname")); + + if (obj instanceof Item) { + return new ItemStack((Item) obj, amount, meta); + } + } else if (nbtTags.hasKey("blockname")) { + Object obj = Block.blockRegistry.getObject(nbtTags.getString("blockname")); + + if (obj instanceof Block) { + return new ItemStack((Block) obj, amount, meta); + } + } + + return null; + } + + public static boolean removeRecipes(ItemStack stack) { + List recipes = CraftingManager.getInstance().getRecipeList(); + + for (Iterator iter = recipes.iterator(); iter.hasNext();) { + IRecipe iterRecipe = iter.next(); + + if (iterRecipe instanceof ShapedMekanismRecipe + || iterRecipe instanceof ShapelessMekanismRecipe) { + if (StackUtils.equalsWildcard(stack, iterRecipe.getRecipeOutput())) { + iter.remove(); + } + } + } + + return false; + } + + public static IRecipe getRecipeFromGrid(InventoryCrafting inv, World world) { + List list + = new ArrayList(CraftingManager.getInstance().getRecipeList()); + + for (Iterator iter = list.iterator(); iter.hasNext();) { + IRecipe recipe = iter.next(); + + if (recipe.matches(inv, world)) { + return recipe; + } + } + + return null; + } } diff --git a/src/main/java/mekanism/common/util/SecurityUtils.java b/src/main/java/mekanism/common/util/SecurityUtils.java index b96d5e60e..46f67c7e4 100644 --- a/src/main/java/mekanism/common/util/SecurityUtils.java +++ b/src/main/java/mekanism/common/util/SecurityUtils.java @@ -1,5 +1,6 @@ package mekanism.common.util; +import cpw.mods.fml.relauncher.Side; import mekanism.api.EnumColor; import mekanism.client.MekanismClient; import mekanism.common.Mekanism; @@ -14,241 +15,208 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChatComponentText; -import cpw.mods.fml.relauncher.Side; -public final class SecurityUtils -{ - public static boolean canAccess(EntityPlayer player, ItemStack stack) - { - if(!(stack.getItem() instanceof ISecurityItem) && stack.getItem() instanceof IOwnerItem) - { - String owner = ((IOwnerItem)stack.getItem()).getOwner(stack); - - return owner == null || owner.equals(player.getCommandSenderName()); - } - - if(stack == null || !(stack.getItem() instanceof ISecurityItem)) - { - return true; - } - - ISecurityItem security = (ISecurityItem)stack.getItem(); - - if(MekanismUtils.isOp(player)) - { - return true; - } - - return canAccess(security.getSecurity(stack), player.getCommandSenderName(), security.getOwner(stack)); - } - - public static boolean canAccess(EntityPlayer player, TileEntity tile) - { - if(tile == null || !(tile instanceof ISecurityTile)) - { - return true; - } - - ISecurityTile security = (ISecurityTile)tile; - - if(MekanismUtils.isOp(player)) - { - return true; - } - - return canAccess(security.getSecurity().getMode(), player.getCommandSenderName(), security.getSecurity().getOwner()); - } - - private static boolean canAccess(SecurityMode mode, String username, String owner) - { - if(owner == null || username.equals(owner)) - { - return true; - } - - SecurityFrequency freq = getFrequency(owner); - - if(freq == null) - { - return true; - } - - if(freq.override) - { - mode = freq.securityMode; - } - - if(mode == SecurityMode.PUBLIC) - { - return true; - } - else if(mode == SecurityMode.TRUSTED) - { - if(freq.trusted.contains(username)) - { - return true; - } - } - - return false; - } - - public static SecurityFrequency getFrequency(String owner) - { - if(owner != null) - { - for(Frequency f : Mekanism.securityFrequencies.getFrequencies()) - { - if(f instanceof SecurityFrequency && f.owner.equals(owner)) - { - return (SecurityFrequency)f; - } - } - } - - return null; - } - - public static String getOwnerDisplay(String user, String owner) - { - if(owner == null) - { - return EnumColor.RED + LangUtils.localize("gui.noOwner"); - } - - return EnumColor.GREY + LangUtils.localize("gui.owner") + ": " + (user.equals(owner) ? EnumColor.BRIGHT_GREEN : EnumColor.RED) + owner; - } - - public static void displayNoAccess(EntityPlayer player) - { - player.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.RED + LangUtils.localize("gui.noAccessDesc"))); - } - - public static SecurityMode getSecurity(ISecurityTile security, Side side) - { - if(side == Side.SERVER) - { - SecurityFrequency freq = security.getSecurity().getFrequency(); - - if(freq != null && freq.override) - { - return freq.securityMode; - } - } - else if(side == Side.CLIENT) - { - SecurityData data = MekanismClient.clientSecurityMap.get(security.getSecurity().getOwner()); - - if(data != null && data.override) - { - return data.mode; - } - } - - return security.getSecurity().getMode(); - } - - public static String getSecurityDisplay(ItemStack stack, Side side) - { - ISecurityItem security = (ISecurityItem)stack.getItem(); - SecurityMode mode = security.getSecurity(stack); - - if(security.getOwner(stack) != null) - { - if(side == Side.SERVER) - { - SecurityFrequency freq = getFrequency(security.getOwner(stack)); - - if(freq != null && freq.override) - { - mode = freq.securityMode; - } - } - else if(side == Side.CLIENT) - { - SecurityData data = MekanismClient.clientSecurityMap.get(security.getOwner(stack)); - - if(data != null && data.override) - { - mode = data.mode; - } - } - } - - return mode.getDisplay(); - } - - public static String getSecurityDisplay(TileEntity tile, Side side) - { - ISecurityTile security = (ISecurityTile)tile; - SecurityMode mode = security.getSecurity().getMode(); - - if(security.getSecurity().getOwner() != null) - { - if(side == Side.SERVER) - { - SecurityFrequency freq = getFrequency(security.getSecurity().getOwner()); - - if(freq != null && freq.override) - { - mode = freq.securityMode; - } - } - else if(side == Side.CLIENT) - { - SecurityData data = MekanismClient.clientSecurityMap.get(security.getSecurity().getOwner()); - - if(data != null && data.override) - { - mode = data.mode; - } - } - } - - return mode.getDisplay(); - } - - public static boolean isOverridden(ItemStack stack, Side side) - { - ISecurityItem security = (ISecurityItem)stack.getItem(); - - if(security.getOwner(stack) == null) - { - return false; - } - - if(side == Side.SERVER) - { - SecurityFrequency freq = getFrequency(security.getOwner(stack)); - - return freq != null && freq.override; - } - else { - SecurityData data = MekanismClient.clientSecurityMap.get(security.getOwner(stack)); - - return data != null && data.override; - } - } - - public static boolean isOverridden(TileEntity tile, Side side) - { - ISecurityTile security = (ISecurityTile)tile; - - if(security.getSecurity().getOwner() == null) - { - return false; - } - - if(side == Side.SERVER) - { - SecurityFrequency freq = getFrequency(security.getSecurity().getOwner()); - - return freq != null && freq.override; - } - else { - SecurityData data = MekanismClient.clientSecurityMap.get(security.getSecurity().getOwner()); - - return data != null && data.override; - } - } +public final class SecurityUtils { + public static boolean canAccess(EntityPlayer player, ItemStack stack) { + if (!(stack.getItem() instanceof ISecurityItem) + && stack.getItem() instanceof IOwnerItem) { + String owner = ((IOwnerItem) stack.getItem()).getOwner(stack); + + return owner == null || owner.equals(player.getCommandSenderName()); + } + + if (stack == null || !(stack.getItem() instanceof ISecurityItem)) { + return true; + } + + ISecurityItem security = (ISecurityItem) stack.getItem(); + + if (MekanismUtils.isOp(player)) { + return true; + } + + return canAccess( + security.getSecurity(stack), + player.getCommandSenderName(), + security.getOwner(stack) + ); + } + + public static boolean canAccess(EntityPlayer player, TileEntity tile) { + if (tile == null || !(tile instanceof ISecurityTile)) { + return true; + } + + ISecurityTile security = (ISecurityTile) tile; + + if (MekanismUtils.isOp(player)) { + return true; + } + + return canAccess( + security.getSecurity().getMode(), + player.getCommandSenderName(), + security.getSecurity().getOwner() + ); + } + + private static boolean canAccess(SecurityMode mode, String username, String owner) { + if (owner == null || username.equals(owner)) { + return true; + } + + SecurityFrequency freq = getFrequency(owner); + + if (freq == null) { + return true; + } + + if (freq.override) { + mode = freq.securityMode; + } + + if (mode == SecurityMode.PUBLIC) { + return true; + } else if (mode == SecurityMode.TRUSTED) { + if (freq.trusted.contains(username)) { + return true; + } + } + + return false; + } + + public static SecurityFrequency getFrequency(String owner) { + if (owner != null) { + for (Frequency f : Mekanism.securityFrequencies.getFrequencies()) { + if (f instanceof SecurityFrequency && f.owner.equals(owner)) { + return (SecurityFrequency) f; + } + } + } + + return null; + } + + public static String getOwnerDisplay(String user, String owner) { + if (owner == null) { + return EnumColor.RED + LangUtils.localize("gui.noOwner"); + } + + return EnumColor.GREY + LangUtils.localize("gui.owner") + ": " + + (user.equals(owner) ? EnumColor.BRIGHT_GREEN : EnumColor.RED) + owner; + } + + public static void displayNoAccess(EntityPlayer player) { + player.addChatMessage(new ChatComponentText( + EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.RED + + LangUtils.localize("gui.noAccessDesc") + )); + } + + public static SecurityMode getSecurity(ISecurityTile security, Side side) { + if (side == Side.SERVER) { + SecurityFrequency freq = security.getSecurity().getFrequency(); + + if (freq != null && freq.override) { + return freq.securityMode; + } + } else if (side == Side.CLIENT) { + SecurityData data + = MekanismClient.clientSecurityMap.get(security.getSecurity().getOwner()); + + if (data != null && data.override) { + return data.mode; + } + } + + return security.getSecurity().getMode(); + } + + public static String getSecurityDisplay(ItemStack stack, Side side) { + ISecurityItem security = (ISecurityItem) stack.getItem(); + SecurityMode mode = security.getSecurity(stack); + + if (security.getOwner(stack) != null) { + if (side == Side.SERVER) { + SecurityFrequency freq = getFrequency(security.getOwner(stack)); + + if (freq != null && freq.override) { + mode = freq.securityMode; + } + } else if (side == Side.CLIENT) { + SecurityData data + = MekanismClient.clientSecurityMap.get(security.getOwner(stack)); + + if (data != null && data.override) { + mode = data.mode; + } + } + } + + return mode.getDisplay(); + } + + public static String getSecurityDisplay(TileEntity tile, Side side) { + ISecurityTile security = (ISecurityTile) tile; + SecurityMode mode = security.getSecurity().getMode(); + + if (security.getSecurity().getOwner() != null) { + if (side == Side.SERVER) { + SecurityFrequency freq = getFrequency(security.getSecurity().getOwner()); + + if (freq != null && freq.override) { + mode = freq.securityMode; + } + } else if (side == Side.CLIENT) { + SecurityData data = MekanismClient.clientSecurityMap.get( + security.getSecurity().getOwner() + ); + + if (data != null && data.override) { + mode = data.mode; + } + } + } + + return mode.getDisplay(); + } + + public static boolean isOverridden(ItemStack stack, Side side) { + ISecurityItem security = (ISecurityItem) stack.getItem(); + + if (security.getOwner(stack) == null) { + return false; + } + + if (side == Side.SERVER) { + SecurityFrequency freq = getFrequency(security.getOwner(stack)); + + return freq != null && freq.override; + } else { + SecurityData data + = MekanismClient.clientSecurityMap.get(security.getOwner(stack)); + + return data != null && data.override; + } + } + + public static boolean isOverridden(TileEntity tile, Side side) { + ISecurityTile security = (ISecurityTile) tile; + + if (security.getSecurity().getOwner() == null) { + return false; + } + + if (side == Side.SERVER) { + SecurityFrequency freq = getFrequency(security.getSecurity().getOwner()); + + return freq != null && freq.override; + } else { + SecurityData data + = MekanismClient.clientSecurityMap.get(security.getSecurity().getOwner()); + + return data != null && data.override; + } + } } diff --git a/src/main/java/mekanism/common/util/StatUtils.java b/src/main/java/mekanism/common/util/StatUtils.java index 142d1def1..4fe70f946 100644 --- a/src/main/java/mekanism/common/util/StatUtils.java +++ b/src/main/java/mekanism/common/util/StatUtils.java @@ -9,24 +9,21 @@ import static java.lang.Math.sqrt; import java.util.Random; -public class StatUtils -{ - public static Random rand = new Random(); +public class StatUtils { + public static Random rand = new Random(); - public static int inversePoisson(double mean) - { - double r = rand.nextDouble()*exp(mean); - int m = 0; - double p = 1; - double stirlingValue = mean*E; - double stirlingCoeff = 1/sqrt(2*PI); - - while((p < r) && (m < 3*ceil(mean))) - { - m++; - p += stirlingCoeff/sqrt(m)*pow((stirlingValue/m), m); - } - - return m; - } + public static int inversePoisson(double mean) { + double r = rand.nextDouble() * exp(mean); + int m = 0; + double p = 1; + double stirlingValue = mean * E; + double stirlingCoeff = 1 / sqrt(2 * PI); + + while ((p < r) && (m < 3 * ceil(mean))) { + m++; + p += stirlingCoeff / sqrt(m) * pow((stirlingValue / m), m); + } + + return m; + } } diff --git a/src/main/java/mekanism/common/util/TransporterUtils.java b/src/main/java/mekanism/common/util/TransporterUtils.java index 8b9fbeee5..302c0f27b 100644 --- a/src/main/java/mekanism/common/util/TransporterUtils.java +++ b/src/main/java/mekanism/common/util/TransporterUtils.java @@ -19,147 +19,166 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -public final class TransporterUtils -{ - public static List colors = ListUtils.asList(EnumColor.DARK_BLUE, EnumColor.DARK_GREEN, EnumColor.DARK_AQUA, EnumColor.DARK_RED, EnumColor.PURPLE, - EnumColor.INDIGO, EnumColor.BRIGHT_GREEN, EnumColor.AQUA, EnumColor.RED, EnumColor.PINK, EnumColor.YELLOW, EnumColor.BLACK); +public final class TransporterUtils { + public static List colors = ListUtils.asList( + EnumColor.DARK_BLUE, + EnumColor.DARK_GREEN, + EnumColor.DARK_AQUA, + EnumColor.DARK_RED, + EnumColor.PURPLE, + EnumColor.INDIGO, + EnumColor.BRIGHT_GREEN, + EnumColor.AQUA, + EnumColor.RED, + EnumColor.PINK, + EnumColor.YELLOW, + EnumColor.BLACK + ); - public static boolean isValidAcceptorOnSide(TileEntity tile, ForgeDirection side) - { - if(tile instanceof ITransmitterTile || !(tile instanceof IInventory)) - { - return false; - } + public static boolean isValidAcceptorOnSide(TileEntity tile, ForgeDirection side) { + if (tile instanceof ITransmitterTile || !(tile instanceof IInventory)) { + return false; + } - IInventory inventory = (IInventory)tile; + IInventory inventory = (IInventory) tile; - if(inventory.getSizeInventory() > 0) - { - if(!(inventory instanceof ISidedInventory)) - { - return true; - } + if (inventory.getSizeInventory() > 0) { + if (!(inventory instanceof ISidedInventory)) { + return true; + } - int[] slots = ((ISidedInventory)inventory).getAccessibleSlotsFromSide(side.getOpposite().ordinal()); + int[] slots = ((ISidedInventory) inventory) + .getAccessibleSlotsFromSide(side.getOpposite().ordinal()); - return (slots != null && slots.length > 0); - } - - return false; - } + return (slots != null && slots.length > 0); + } - /** - * Gets all the inventories around a tile entity. - * @param transporter - center tile entity - * @return array of IInventories - */ - public static IInventory[] getConnectedInventories(ILogisticalTransporter transporter) - { - IInventory[] inventories = new IInventory[] {null, null, null, null, null, null}; + return false; + } - for(ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) - { - TileEntity inventory = transporter.coord().getFromSide(orientation).getTileEntity(transporter.world()); + /** + * Gets all the inventories around a tile entity. + * @param transporter - center tile entity + * @return array of IInventories + */ + public static IInventory[] getConnectedInventories(ILogisticalTransporter transporter + ) { + IInventory[] inventories + = new IInventory[] { null, null, null, null, null, null }; - if(inventory instanceof IInventory && !(inventory instanceof ITransmitterTile)) - { - inventories[orientation.ordinal()] = (IInventory)inventory; - } - } + for (ForgeDirection orientation : ForgeDirection.VALID_DIRECTIONS) { + TileEntity inventory = transporter.coord() + .getFromSide(orientation) + .getTileEntity(transporter.world()); - return inventories; - } + if (inventory instanceof IInventory + && !(inventory instanceof ITransmitterTile)) { + inventories[orientation.ordinal()] = (IInventory) inventory; + } + } - public static ItemStack insert(TileEntity outputter, ILogisticalTransporter transporter, ItemStack itemStack, EnumColor color, boolean doEmit, int min) - { - return transporter.insert(Coord4D.get(outputter), itemStack.copy(), color, doEmit, min); - } + return inventories; + } - public static ItemStack insertRR(TileEntityLogisticalSorter outputter, ILogisticalTransporter transporter, ItemStack itemStack, EnumColor color, boolean doEmit, int min) - { - return transporter.insertRR(outputter, itemStack.copy(), color, doEmit, min); - } + public static ItemStack insert( + TileEntity outputter, + ILogisticalTransporter transporter, + ItemStack itemStack, + EnumColor color, + boolean doEmit, + int min + ) { + return transporter.insert( + Coord4D.get(outputter), itemStack.copy(), color, doEmit, min + ); + } - public static EnumColor increment(EnumColor color) - { - if(color == null) - { - return colors.get(0); - } - else if(colors.indexOf(color) == colors.size()-1) - { - return null; - } + public static ItemStack insertRR( + TileEntityLogisticalSorter outputter, + ILogisticalTransporter transporter, + ItemStack itemStack, + EnumColor color, + boolean doEmit, + int min + ) { + return transporter.insertRR(outputter, itemStack.copy(), color, doEmit, min); + } - return colors.get(colors.indexOf(color)+1); - } + public static EnumColor increment(EnumColor color) { + if (color == null) { + return colors.get(0); + } else if (colors.indexOf(color) == colors.size() - 1) { + return null; + } - public static EnumColor decrement(EnumColor color) - { - if(color == null) - { - return colors.get(colors.size()-1); - } - else if(colors.indexOf(color) == 0) - { - return null; - } + return colors.get(colors.indexOf(color) + 1); + } - return colors.get(colors.indexOf(color)-1); - } + public static EnumColor decrement(EnumColor color) { + if (color == null) { + return colors.get(colors.size() - 1); + } else if (colors.indexOf(color) == 0) { + return null; + } - public static void drop(ILogisticalTransporter tileEntity, TransporterStack stack) - { - float[] pos; + return colors.get(colors.indexOf(color) - 1); + } - if(stack.hasPath()) - { - pos = TransporterUtils.getStackPosition(tileEntity, stack, 0); - } - else { - pos = new float[] {0, 0, 0}; - } + public static void drop(ILogisticalTransporter tileEntity, TransporterStack stack) { + float[] pos; - TransporterManager.remove(stack); + if (stack.hasPath()) { + pos = TransporterUtils.getStackPosition(tileEntity, stack, 0); + } else { + pos = new float[] { 0, 0, 0 }; + } - EntityItem entityItem = new EntityItem(tileEntity.world(), tileEntity.coord().xCoord + pos[0], tileEntity.coord().yCoord + pos[1], tileEntity.coord().zCoord + pos[2], stack.itemStack); + TransporterManager.remove(stack); - entityItem.motionX = 0; - entityItem.motionY = 0; - entityItem.motionZ = 0; + EntityItem entityItem = new EntityItem( + tileEntity.world(), + tileEntity.coord().xCoord + pos[0], + tileEntity.coord().yCoord + pos[1], + tileEntity.coord().zCoord + pos[2], + stack.itemStack + ); - tileEntity.world().spawnEntityInWorld(entityItem); - } + entityItem.motionX = 0; + entityItem.motionY = 0; + entityItem.motionZ = 0; - public static float[] getStackPosition(ILogisticalTransporter tileEntity, TransporterStack stack, float partial) - { - Coord4D offset = new Coord4D(0, 0, 0, tileEntity.world().provider.dimensionId).step(ForgeDirection.getOrientation(stack.getSide(tileEntity))); - float progress = (((float)stack.progress + partial) / 100F) - 0.5F; + tileEntity.world().spawnEntityInWorld(entityItem); + } - float itemFix = 0; + public static float[] getStackPosition( + ILogisticalTransporter tileEntity, TransporterStack stack, float partial + ) { + Coord4D offset + = new Coord4D(0, 0, 0, tileEntity.world().provider.dimensionId) + .step(ForgeDirection.getOrientation(stack.getSide(tileEntity))); + float progress = (((float) stack.progress + partial) / 100F) - 0.5F; - if(!(stack.itemStack.getItem() instanceof ItemBlock)) - { - itemFix = 0.1F; - } + float itemFix = 0; - return new float[] {0.5F + offset.xCoord*progress, 0.5F + offset.yCoord*progress - itemFix, 0.5F + offset.zCoord*progress}; - } + if (!(stack.itemStack.getItem() instanceof ItemBlock)) { + itemFix = 0.1F; + } - public static void incrementColor(ILogisticalTransporter tileEntity) - { - if(tileEntity.getColor() == null) - { - tileEntity.setColor(colors.get(0)); - return; - } - else if(colors.indexOf(tileEntity.getColor()) == colors.size()-1) - { - tileEntity.setColor(null); - return; - } + return new float[] { 0.5F + offset.xCoord * progress, + 0.5F + offset.yCoord * progress - itemFix, + 0.5F + offset.zCoord * progress }; + } - int index = colors.indexOf(tileEntity.getColor()); - tileEntity.setColor(colors.get(index+1)); - } + public static void incrementColor(ILogisticalTransporter tileEntity) { + if (tileEntity.getColor() == null) { + tileEntity.setColor(colors.get(0)); + return; + } else if (colors.indexOf(tileEntity.getColor()) == colors.size() - 1) { + tileEntity.setColor(null); + return; + } + + int index = colors.indexOf(tileEntity.getColor()); + tileEntity.setColor(colors.get(index + 1)); + } } \ No newline at end of file diff --git a/src/main/java/mekanism/common/voice/VoiceConnection.java b/src/main/java/mekanism/common/voice/VoiceConnection.java index a68ab4acc..71b28f9d9 100644 --- a/src/main/java/mekanism/common/voice/VoiceConnection.java +++ b/src/main/java/mekanism/common/voice/VoiceConnection.java @@ -9,195 +9,186 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import cpw.mods.fml.common.FMLCommonHandler; import mekanism.common.Mekanism; import mekanism.common.item.ItemWalkieTalkie; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.server.MinecraftServer; -import cpw.mods.fml.common.FMLCommonHandler; -public class VoiceConnection extends Thread -{ - public Socket socket; +public class VoiceConnection extends Thread { + public Socket socket; - public String username; + public String username; - public boolean open = true; + public boolean open = true; - public DataInputStream input; - public DataOutputStream output; + public DataInputStream input; + public DataOutputStream output; - public MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); + public MinecraftServer server + = FMLCommonHandler.instance().getMinecraftServerInstance(); - public VoiceConnection(Socket s) - { - socket = s; - } + public VoiceConnection(Socket s) { + socket = s; + } - @Override - public void run() - { - try { - input = new DataInputStream(new BufferedInputStream(socket.getInputStream())); - output = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream())); + @Override + public void run() { + try { + input = new DataInputStream(new BufferedInputStream(socket.getInputStream())); + output + = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream()) + ); - synchronized(Mekanism.voiceManager) - { - int retryCount = 0; + synchronized (Mekanism.voiceManager) { + int retryCount = 0; - while(username == null && retryCount <= 100) - { - try { - List l = Collections.synchronizedList((List)((ArrayList)server.getConfigurationManager().playerEntityList).clone()); + while (username == null && retryCount <= 100) { + try { + List l = Collections.synchronizedList((List + ) ((ArrayList) server.getConfigurationManager().playerEntityList) + .clone()); - for(Object obj : l) - { - if(obj instanceof EntityPlayerMP) - { - EntityPlayerMP playerMP = (EntityPlayerMP)obj; - String playerIP = playerMP.getPlayerIP(); + for (Object obj : l) { + if (obj instanceof EntityPlayerMP) { + EntityPlayerMP playerMP = (EntityPlayerMP) obj; + String playerIP = playerMP.getPlayerIP(); - if(!server.isDedicatedServer() && playerIP.equals("local") && !Mekanism.voiceManager.foundLocal) - { - Mekanism.voiceManager.foundLocal = true; - username = playerMP.getCommandSenderName(); - break; - } - else if(playerIP.equals(socket.getInetAddress().getHostAddress())) - { - username = playerMP.getCommandSenderName(); - break; - } - } - } + if (!server.isDedicatedServer() + && playerIP.equals("local") + && !Mekanism.voiceManager.foundLocal) { + Mekanism.voiceManager.foundLocal = true; + username = playerMP.getCommandSenderName(); + break; + } else if (playerIP.equals( + socket.getInetAddress().getHostAddress() + )) { + username = playerMP.getCommandSenderName(); + break; + } + } + } - retryCount++; - Thread.sleep(50); - } catch(Exception e) {} - } + retryCount++; + Thread.sleep(50); + } catch (Exception e) {} + } - if(username == null) - { - Mekanism.logger.error("VoiceServer: Unable to trace connection's IP address."); - kill(); - return; - } - else { - Mekanism.logger.info("VoiceServer: Traced IP in " + retryCount + " attempts."); - } - } - } catch(Exception e) { - Mekanism.logger.error("VoiceServer: Error while starting server-based connection."); - e.printStackTrace(); - open = false; - } + if (username == null) { + Mekanism.logger.error( + "VoiceServer: Unable to trace connection's IP address." + ); + kill(); + return; + } else { + Mekanism.logger.info( + "VoiceServer: Traced IP in " + retryCount + " attempts." + ); + } + } + } catch (Exception e) { + Mekanism.logger.error( + "VoiceServer: Error while starting server-based connection." + ); + e.printStackTrace(); + open = false; + } - //Main client listen thread - new Thread(new Runnable() - { - @Override - public void run() - { - while(open) - { - try { - short byteCount = VoiceConnection.this.input.readShort(); - byte[] audioData = new byte[byteCount]; - VoiceConnection.this.input.readFully(audioData); + //Main client listen thread + new Thread(new Runnable() { + @Override + public void run() { + while (open) { + try { + short byteCount = VoiceConnection.this.input.readShort(); + byte[] audioData = new byte[byteCount]; + VoiceConnection.this.input.readFully(audioData); - if(byteCount > 0) - { - Mekanism.voiceManager.sendToPlayers(byteCount, audioData, VoiceConnection.this); - } - } catch(Exception e) { - open = false; - } - } + if (byteCount > 0) { + Mekanism.voiceManager.sendToPlayers( + byteCount, audioData, VoiceConnection.this + ); + } + } catch (Exception e) { + open = false; + } + } - if(!open) - { - kill(); - } - } - }).start(); - } + if (!open) { + kill(); + } + } + }).start(); + } - public void kill() - { - try { - input.close(); - output.close(); - socket.close(); + public void kill() { + try { + input.close(); + output.close(); + socket.close(); - Mekanism.voiceManager.connections.remove(this); - } catch(Exception e) { - Mekanism.logger.error("VoiceServer: Error while stopping server-based connection."); - e.printStackTrace(); - } - } + Mekanism.voiceManager.connections.remove(this); + } catch (Exception e) { + Mekanism.logger.error( + "VoiceServer: Error while stopping server-based connection." + ); + e.printStackTrace(); + } + } - public void sendToPlayer(short byteCount, byte[] audioData, VoiceConnection connection) - { - if(!open) - { - kill(); - } + public void + sendToPlayer(short byteCount, byte[] audioData, VoiceConnection connection) { + if (!open) { + kill(); + } - try { - output.writeShort(byteCount); - output.write(audioData); + try { + output.writeShort(byteCount); + output.write(audioData); - output.flush(); - } catch(Exception e) { - Mekanism.logger.error("VoiceServer: Error while sending data to player."); - e.printStackTrace(); - } - } + output.flush(); + } catch (Exception e) { + Mekanism.logger.error("VoiceServer: Error while sending data to player."); + e.printStackTrace(); + } + } - public boolean canListen(int channel) - { - for(ItemStack itemStack : getPlayer().inventory.mainInventory) - { - if(itemStack != null) - { - if(itemStack.getItem() instanceof ItemWalkieTalkie) - { - if(((ItemWalkieTalkie)itemStack.getItem()).getOn(itemStack)) - { - if(((ItemWalkieTalkie)itemStack.getItem()).getChannel(itemStack) == channel) - { - return true; - } - } - } - } - } + public boolean canListen(int channel) { + for (ItemStack itemStack : getPlayer().inventory.mainInventory) { + if (itemStack != null) { + if (itemStack.getItem() instanceof ItemWalkieTalkie) { + if (((ItemWalkieTalkie) itemStack.getItem()).getOn(itemStack)) { + if (((ItemWalkieTalkie) itemStack.getItem()).getChannel(itemStack) + == channel) { + return true; + } + } + } + } + } - return false; - } + return false; + } - public int getCurrentChannel() - { - ItemStack itemStack = getPlayer().getCurrentEquippedItem(); + public int getCurrentChannel() { + ItemStack itemStack = getPlayer().getCurrentEquippedItem(); - if(itemStack != null) - { - ItemWalkieTalkie walkieTalkie = (ItemWalkieTalkie)itemStack.getItem(); + if (itemStack != null) { + ItemWalkieTalkie walkieTalkie = (ItemWalkieTalkie) itemStack.getItem(); - if(walkieTalkie != null) - { - if(walkieTalkie.getOn(itemStack)) - { - return walkieTalkie.getChannel(itemStack); - } - } - } + if (walkieTalkie != null) { + if (walkieTalkie.getOn(itemStack)) { + return walkieTalkie.getChannel(itemStack); + } + } + } - return 0; - } + return 0; + } - public EntityPlayerMP getPlayer() - { - return server.getConfigurationManager().func_152612_a(username); //TODO getPlayerForUsername - } + public EntityPlayerMP getPlayer() { + return server.getConfigurationManager().func_152612_a(username + ); //TODO getPlayerForUsername + } } diff --git a/src/main/java/mekanism/common/voice/VoiceServerManager.java b/src/main/java/mekanism/common/voice/VoiceServerManager.java index eac64775d..c2b210f75 100644 --- a/src/main/java/mekanism/common/voice/VoiceServerManager.java +++ b/src/main/java/mekanism/common/voice/VoiceServerManager.java @@ -9,104 +9,95 @@ import java.util.Set; import mekanism.api.MekanismConfig.general; import mekanism.common.Mekanism; -public class VoiceServerManager -{ - public Set connections = new HashSet(); +public class VoiceServerManager { + public Set connections = new HashSet(); - public ServerSocket serverSocket; + public ServerSocket serverSocket; - public boolean running; + public boolean running; - public boolean foundLocal = false; + public boolean foundLocal = false; - public Thread listenThread; + public Thread listenThread; - public void start() - { - Mekanism.logger.info("VoiceServer: Starting up server..."); + public void start() { + Mekanism.logger.info("VoiceServer: Starting up server..."); - try { - running = true; - serverSocket = new ServerSocket(general.VOICE_PORT); - (listenThread = new ListenThread()).start(); - } catch(Exception e) {} - } + try { + running = true; + serverSocket = new ServerSocket(general.VOICE_PORT); + (listenThread = new ListenThread()).start(); + } catch (Exception e) {} + } - public void stop() - { - try { - Mekanism.logger.info("VoiceServer: Shutting down server..."); + public void stop() { + try { + Mekanism.logger.info("VoiceServer: Shutting down server..."); - try { - listenThread.interrupt(); - } catch(Exception e) {} + try { + listenThread.interrupt(); + } catch (Exception e) {} - foundLocal = false; + foundLocal = false; - try { - serverSocket.close(); - serverSocket = null; - } catch(Exception e) {} - } catch(Exception e) { - Mekanism.logger.error("VoiceServer: Error while shutting down server."); - e.printStackTrace(); - } + try { + serverSocket.close(); + serverSocket = null; + } catch (Exception e) {} + } catch (Exception e) { + Mekanism.logger.error("VoiceServer: Error while shutting down server."); + e.printStackTrace(); + } - running = false; - } + running = false; + } - public void sendToPlayers(short byteCount, byte[] audioData, VoiceConnection connection) - { - if(connection.getPlayer() == null) - { - return; - } + public void + sendToPlayers(short byteCount, byte[] audioData, VoiceConnection connection) { + if (connection.getPlayer() == null) { + return; + } - int channel = connection.getCurrentChannel(); + int channel = connection.getCurrentChannel(); - if(channel == 0) - { - return; - } + if (channel == 0) { + return; + } - for(VoiceConnection iterConn : connections) - { - if(iterConn.getPlayer() == null || iterConn == connection || !iterConn.canListen(channel)) - { - continue; - } + for (VoiceConnection iterConn : connections) { + if (iterConn.getPlayer() == null || iterConn == connection + || !iterConn.canListen(channel)) { + continue; + } - iterConn.sendToPlayer(byteCount, audioData, connection); - } - } + iterConn.sendToPlayer(byteCount, audioData, connection); + } + } - public class ListenThread extends Thread - { - public ListenThread() - { - setDaemon(true); - setName("VoiceServer Listen Thread"); - } + public class ListenThread extends Thread { + public ListenThread() { + setDaemon(true); + setName("VoiceServer Listen Thread"); + } - @Override - public void run() - { - while(running) - { - try { - Socket s = serverSocket.accept(); - VoiceConnection connection = new VoiceConnection(s); - connection.start(); - connections.add(connection); + @Override + public void run() { + while (running) { + try { + Socket s = serverSocket.accept(); + VoiceConnection connection = new VoiceConnection(s); + connection.start(); + connections.add(connection); - Mekanism.logger.info("VoiceServer: Accepted new connection."); - } catch(SocketException e) { - } catch(NullPointerException e) { - } catch(Exception e) { - Mekanism.logger.error("VoiceServer: Error while accepting connection."); - e.printStackTrace(); - } - } - } - } + Mekanism.logger.info("VoiceServer: Accepted new connection."); + } catch (SocketException e) { + } catch (NullPointerException e) { + } catch (Exception e) { + Mekanism.logger.error("VoiceServer: Error while accepting connection." + ); + e.printStackTrace(); + } + } + } + } } diff --git a/src/main/java/mekanism/common/world/GenHandler.java b/src/main/java/mekanism/common/world/GenHandler.java index 61c489b8e..809f84efc 100644 --- a/src/main/java/mekanism/common/world/GenHandler.java +++ b/src/main/java/mekanism/common/world/GenHandler.java @@ -2,6 +2,7 @@ package mekanism.common.world; import java.util.Random; +import cpw.mods.fml.common.IWorldGenerator; import mekanism.api.MekanismConfig.general; import mekanism.common.MekanismBlocks; import net.minecraft.init.Blocks; @@ -10,46 +11,49 @@ import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.ChunkProviderEnd; import net.minecraft.world.gen.ChunkProviderHell; import net.minecraft.world.gen.feature.WorldGenMinable; -import cpw.mods.fml.common.IWorldGenerator; -public class GenHandler implements IWorldGenerator -{ - @Override - public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) - { - if(!(chunkGenerator instanceof ChunkProviderHell) && !(chunkGenerator instanceof ChunkProviderEnd)) - { - for(int i = 0; i < general.osmiumPerChunk; i++) - { - int randPosX = (chunkX*16) + random.nextInt(16); - int randPosY = random.nextInt(60); - int randPosZ = (chunkZ*16) + random.nextInt(16); - new WorldGenMinable(MekanismBlocks.OreBlock, 0, 8, Blocks.stone).generate(world, random, randPosX, randPosY, randPosZ); - } +public class GenHandler implements IWorldGenerator { + @Override + public void generate( + Random random, + int chunkX, + int chunkZ, + World world, + IChunkProvider chunkGenerator, + IChunkProvider chunkProvider + ) { + if (!(chunkGenerator instanceof ChunkProviderHell) + && !(chunkGenerator instanceof ChunkProviderEnd)) { + for (int i = 0; i < general.osmiumPerChunk; i++) { + int randPosX = (chunkX * 16) + random.nextInt(16); + int randPosY = random.nextInt(60); + int randPosZ = (chunkZ * 16) + random.nextInt(16); + new WorldGenMinable(MekanismBlocks.OreBlock, 0, 8, Blocks.stone) + .generate(world, random, randPosX, randPosY, randPosZ); + } - for(int i = 0; i < general.copperPerChunk; i++) - { - int randPosX = (chunkX*16) + random.nextInt(16); - int randPosY = random.nextInt(60); - int randPosZ = (chunkZ*16) + random.nextInt(16); - new WorldGenMinable(MekanismBlocks.OreBlock, 1, 8, Blocks.stone).generate(world, random, randPosX, randPosY, randPosZ); - } + for (int i = 0; i < general.copperPerChunk; i++) { + int randPosX = (chunkX * 16) + random.nextInt(16); + int randPosY = random.nextInt(60); + int randPosZ = (chunkZ * 16) + random.nextInt(16); + new WorldGenMinable(MekanismBlocks.OreBlock, 1, 8, Blocks.stone) + .generate(world, random, randPosX, randPosY, randPosZ); + } - for(int i = 0; i < general.tinPerChunk; i++) - { - int randPosX = (chunkX*16) + random.nextInt(16); - int randPosY = random.nextInt(60); - int randPosZ = (chunkZ*16) + random.nextInt(16); - new WorldGenMinable(MekanismBlocks.OreBlock, 2, 8, Blocks.stone).generate(world, random, randPosX, randPosY, randPosZ); - } - - for(int i = 0; i < general.saltPerChunk; i++) - { - int randPosX = (chunkX*16) + random.nextInt(16); - int randPosZ = (chunkZ*16) + random.nextInt(16); - int randPosY = world.getTopSolidOrLiquidBlock(randPosX, randPosZ); - new WorldGenSalt(6).generate(world, random, randPosX, randPosY, randPosZ); - } - } - } + for (int i = 0; i < general.tinPerChunk; i++) { + int randPosX = (chunkX * 16) + random.nextInt(16); + int randPosY = random.nextInt(60); + int randPosZ = (chunkZ * 16) + random.nextInt(16); + new WorldGenMinable(MekanismBlocks.OreBlock, 2, 8, Blocks.stone) + .generate(world, random, randPosX, randPosY, randPosZ); + } + + for (int i = 0; i < general.saltPerChunk; i++) { + int randPosX = (chunkX * 16) + random.nextInt(16); + int randPosZ = (chunkZ * 16) + random.nextInt(16); + int randPosY = world.getTopSolidOrLiquidBlock(randPosX, randPosZ); + new WorldGenSalt(6).generate(world, random, randPosX, randPosY, randPosZ); + } + } + } } diff --git a/src/main/java/mekanism/common/world/WorldGenSalt.java b/src/main/java/mekanism/common/world/WorldGenSalt.java index f83116d4a..cf6ac58c9 100644 --- a/src/main/java/mekanism/common/world/WorldGenSalt.java +++ b/src/main/java/mekanism/common/world/WorldGenSalt.java @@ -9,44 +9,36 @@ import net.minecraft.init.Blocks; import net.minecraft.world.World; import net.minecraft.world.gen.feature.WorldGenerator; -public class WorldGenSalt extends WorldGenerator -{ +public class WorldGenSalt extends WorldGenerator { private Block blockGen; - + private int numberOfBlocks; - public WorldGenSalt(int blockNum) - { + public WorldGenSalt(int blockNum) { blockGen = MekanismBlocks.SaltBlock; numberOfBlocks = blockNum; } @Override - public boolean generate(World world, Random random, int x, int y, int z) - { - if(world.getBlock(x, y, z).getMaterial() != Material.water) - { + public boolean generate(World world, Random random, int x, int y, int z) { + if (world.getBlock(x, y, z).getMaterial() != Material.water) { return false; - } - else { + } else { int toGenerate = random.nextInt(numberOfBlocks - 2) + 2; byte yOffset = 1; - for(int xPos = x - toGenerate; xPos <= x + toGenerate; xPos++) - { - for(int zPos = z - toGenerate; zPos <= z + toGenerate; zPos++) - { + for (int xPos = x - toGenerate; xPos <= x + toGenerate; xPos++) { + for (int zPos = z - toGenerate; zPos <= z + toGenerate; zPos++) { int xOffset = xPos - x; int zOffset = zPos - z; - if((xOffset*xOffset) + (zOffset*zOffset) <= toGenerate*toGenerate) - { - for(int yPos = y - yOffset; yPos <= y + yOffset; yPos++) - { + if ((xOffset * xOffset) + (zOffset * zOffset) + <= toGenerate * toGenerate) { + for (int yPos = y - yOffset; yPos <= y + yOffset; yPos++) { Block block = world.getBlock(xPos, yPos, zPos); - if(block == Blocks.dirt || block == Blocks.clay || block == MekanismBlocks.SaltBlock) - { + if (block == Blocks.dirt || block == Blocks.clay + || block == MekanismBlocks.SaltBlock) { world.setBlock(xPos, yPos, zPos, blockGen, 0, 2); } } diff --git a/src/main/java/mekanism/generators/client/BlockRenderingHandler.java b/src/main/java/mekanism/generators/client/BlockRenderingHandler.java index dcf6f4324..fa8e86def 100644 --- a/src/main/java/mekanism/generators/client/BlockRenderingHandler.java +++ b/src/main/java/mekanism/generators/client/BlockRenderingHandler.java @@ -1,5 +1,8 @@ package mekanism.generators.client; +import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.render.MekanismRenderer; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; @@ -15,105 +18,103 @@ import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.world.IBlockAccess; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class BlockRenderingHandler implements ISimpleBlockRenderingHandler -{ - private Minecraft mc = Minecraft.getMinecraft(); - - public ModelAdvancedSolarGenerator advancedSolarGenerator = new ModelAdvancedSolarGenerator(); - public ModelSolarGenerator solarGenerator = new ModelSolarGenerator(); - public ModelBioGenerator bioGenerator = new ModelBioGenerator(); - public ModelHeatGenerator heatGenerator = new ModelHeatGenerator(); - public ModelGasGenerator gasGenerator = new ModelGasGenerator(); - public ModelWindGenerator windGenerator = new ModelWindGenerator(); +public class BlockRenderingHandler implements ISimpleBlockRenderingHandler { + private Minecraft mc = Minecraft.getMinecraft(); - @Override - public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) - { - GL11.glPushMatrix(); - GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); + public ModelAdvancedSolarGenerator advancedSolarGenerator + = new ModelAdvancedSolarGenerator(); + public ModelSolarGenerator solarGenerator = new ModelSolarGenerator(); + public ModelBioGenerator bioGenerator = new ModelBioGenerator(); + public ModelHeatGenerator heatGenerator = new ModelHeatGenerator(); + public ModelGasGenerator gasGenerator = new ModelGasGenerator(); + public ModelWindGenerator windGenerator = new ModelWindGenerator(); - if(block == GeneratorsBlocks.Generator) - { - if(metadata == GeneratorType.BIO_GENERATOR.meta) - { - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glTranslated(0.0F, -1.0F, 0.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "BioGenerator.png")); - bioGenerator.render(0.0625F); - } - else if(metadata == GeneratorType.ADVANCED_SOLAR_GENERATOR.meta) - { - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); - GL11.glTranslatef(0.0F, 0.2F, 0.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "AdvancedSolarGenerator.png")); - advancedSolarGenerator.render(0.022F); - } - else if(metadata == GeneratorType.SOLAR_GENERATOR.meta) - { - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(90F, 0.0F, -1.0F, 0.0F); - GL11.glTranslated(0.0F, -1.0F, 0.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "SolarGenerator.png")); - solarGenerator.render(0.0625F); - } - else if(metadata == GeneratorType.HEAT_GENERATOR.meta) - { - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glTranslated(0.0F, -1.0F, 0.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "HeatGenerator.png")); - heatGenerator.render(0.0625F, false, mc.renderEngine); - } - else if(metadata == GeneratorType.GAS_GENERATOR.meta) - { - GL11.glRotatef(180F, 0.0F, 1.0F, 1.0F); - GL11.glRotatef(90F, -1.0F, 0.0F, 0.0F); - GL11.glTranslated(0.0F, -1.0F, 0.0F); - GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "GasGenerator.png")); - gasGenerator.render(0.0625F); - } - else if(metadata == GeneratorType.WIND_GENERATOR.meta) - { - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F); - GL11.glTranslatef(0.0F, 0.4F, 0.0F); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "WindGenerator.png")); - windGenerator.render(0.016F, 0); - } - else if(metadata != 2) - { - MekanismRenderer.renderItem(renderer, metadata, block); - } - } + @Override + public void + renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { + GL11.glPushMatrix(); + GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); - GL11.glPopMatrix(); - } + if (block == GeneratorsBlocks.Generator) { + if (metadata == GeneratorType.BIO_GENERATOR.meta) { + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glTranslated(0.0F, -1.0F, 0.0F); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "BioGenerator.png") + ); + bioGenerator.render(0.0625F); + } else if (metadata == GeneratorType.ADVANCED_SOLAR_GENERATOR.meta) { + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(0.0F, 0.2F, 0.0F); + mc.renderEngine.bindTexture(MekanismUtils.getResource( + ResourceType.RENDER, "AdvancedSolarGenerator.png" + )); + advancedSolarGenerator.render(0.022F); + } else if (metadata == GeneratorType.SOLAR_GENERATOR.meta) { + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(90F, 0.0F, -1.0F, 0.0F); + GL11.glTranslated(0.0F, -1.0F, 0.0F); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "SolarGenerator.png") + ); + solarGenerator.render(0.0625F); + } else if (metadata == GeneratorType.HEAT_GENERATOR.meta) { + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glTranslated(0.0F, -1.0F, 0.0F); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "HeatGenerator.png") + ); + heatGenerator.render(0.0625F, false, mc.renderEngine); + } else if (metadata == GeneratorType.GAS_GENERATOR.meta) { + GL11.glRotatef(180F, 0.0F, 1.0F, 1.0F); + GL11.glRotatef(90F, -1.0F, 0.0F, 0.0F); + GL11.glTranslated(0.0F, -1.0F, 0.0F); + GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "GasGenerator.png") + ); + gasGenerator.render(0.0625F); + } else if (metadata == GeneratorType.WIND_GENERATOR.meta) { + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F); + GL11.glTranslatef(0.0F, 0.4F, 0.0F); + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "WindGenerator.png") + ); + windGenerator.render(0.016F, 0); + } else if (metadata != 2) { + MekanismRenderer.renderItem(renderer, metadata, block); + } + } - @Override - public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) - { - //Handled by CTMRenderingHandler - return false; - } + GL11.glPopMatrix(); + } - @Override - public boolean shouldRender3DInInventory(int meta) - { - return true; - } + @Override + public boolean renderWorldBlock( + IBlockAccess world, + int x, + int y, + int z, + Block block, + int modelId, + RenderBlocks renderer + ) { + //Handled by CTMRenderingHandler + return false; + } - @Override - public int getRenderId() - { - return GeneratorsClientProxy.GENERATOR_RENDER_ID; - } + @Override + public boolean shouldRender3DInInventory(int meta) { + return true; + } + + @Override + public int getRenderId() { + return GeneratorsClientProxy.GENERATOR_RENDER_ID; + } } diff --git a/src/main/java/mekanism/generators/client/GeneratorsClientProxy.java b/src/main/java/mekanism/generators/client/GeneratorsClientProxy.java index ab36e3172..8cdde71db 100644 --- a/src/main/java/mekanism/generators/client/GeneratorsClientProxy.java +++ b/src/main/java/mekanism/generators/client/GeneratorsClientProxy.java @@ -1,5 +1,10 @@ package mekanism.generators.client; +import cpw.mods.fml.client.registry.ClientRegistry; +import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.generators.client.gui.GuiBioGenerator; import mekanism.generators.client.gui.GuiGasGenerator; import mekanism.generators.client.gui.GuiHeatGenerator; @@ -46,88 +51,130 @@ import net.minecraft.world.World; import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.client.event.TextureStitchEvent; import net.minecraftforge.common.MinecraftForge; -import cpw.mods.fml.client.registry.ClientRegistry; -import cpw.mods.fml.client.registry.RenderingRegistry; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GeneratorsClientProxy extends GeneratorsCommonProxy -{ - @Override - public void registerSpecialTileEntities() - { - ClientRegistry.registerTileEntity(TileEntityAdvancedSolarGenerator.class, "AdvancedSolarGenerator", new RenderAdvancedSolarGenerator()); - ClientRegistry.registerTileEntity(TileEntitySolarGenerator.class, "SolarGenerator", new RenderSolarGenerator()); - ClientRegistry.registerTileEntity(TileEntityBioGenerator.class, "BioGenerator", new RenderBioGenerator()); - ClientRegistry.registerTileEntity(TileEntityHeatGenerator.class, "HeatGenerator", new RenderHeatGenerator()); - ClientRegistry.registerTileEntity(TileEntityGasGenerator.class, "GasGenerator", new RenderGasGenerator()); - ClientRegistry.registerTileEntity(TileEntityWindGenerator.class, "WindTurbine", new RenderWindGenerator()); - ClientRegistry.registerTileEntity(TileEntityReactorController.class, "ReactorController", new RenderReactor()); - ClientRegistry.registerTileEntity(TileEntityTurbineRotor.class, "TurbineRod", new RenderTurbineRotor()); - ClientRegistry.registerTileEntity(TileEntityTurbineCasing.class, "TurbineCasing", new RenderIndustrialTurbine()); - ClientRegistry.registerTileEntity(TileEntityTurbineValve.class, "TurbineValve", new RenderIndustrialTurbine()); - ClientRegistry.registerTileEntity(TileEntityTurbineVent.class, "TurbineVent", new RenderIndustrialTurbine()); - } +public class GeneratorsClientProxy extends GeneratorsCommonProxy { + @Override + public void registerSpecialTileEntities() { + ClientRegistry.registerTileEntity( + TileEntityAdvancedSolarGenerator.class, + "AdvancedSolarGenerator", + new RenderAdvancedSolarGenerator() + ); + ClientRegistry.registerTileEntity( + TileEntitySolarGenerator.class, "SolarGenerator", new RenderSolarGenerator() + ); + ClientRegistry.registerTileEntity( + TileEntityBioGenerator.class, "BioGenerator", new RenderBioGenerator() + ); + ClientRegistry.registerTileEntity( + TileEntityHeatGenerator.class, "HeatGenerator", new RenderHeatGenerator() + ); + ClientRegistry.registerTileEntity( + TileEntityGasGenerator.class, "GasGenerator", new RenderGasGenerator() + ); + ClientRegistry.registerTileEntity( + TileEntityWindGenerator.class, "WindTurbine", new RenderWindGenerator() + ); + ClientRegistry.registerTileEntity( + TileEntityReactorController.class, "ReactorController", new RenderReactor() + ); + ClientRegistry.registerTileEntity( + TileEntityTurbineRotor.class, "TurbineRod", new RenderTurbineRotor() + ); + ClientRegistry.registerTileEntity( + TileEntityTurbineCasing.class, "TurbineCasing", new RenderIndustrialTurbine() + ); + ClientRegistry.registerTileEntity( + TileEntityTurbineValve.class, "TurbineValve", new RenderIndustrialTurbine() + ); + ClientRegistry.registerTileEntity( + TileEntityTurbineVent.class, "TurbineVent", new RenderIndustrialTurbine() + ); + } - @Override - public void registerRenderInformation() - { - //Register block handler - RenderingRegistry.registerBlockHandler(new BlockRenderingHandler()); - - //Register item handler - GeneratorsItemRenderer handler = new GeneratorsItemRenderer(); - - MinecraftForge.EVENT_BUS.register(this); + @Override + public void registerRenderInformation() { + //Register block handler + RenderingRegistry.registerBlockHandler(new BlockRenderingHandler()); - MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(GeneratorsBlocks.Generator), handler); + //Register item handler + GeneratorsItemRenderer handler = new GeneratorsItemRenderer(); - System.out.println("[MekanismGenerators] Render registrations complete."); - } + MinecraftForge.EVENT_BUS.register(this); - @Override - public GuiScreen getClientGui(int ID, EntityPlayer player, World world, int x, int y, int z) - { - TileEntity tileEntity = world.getTileEntity(x, y, z); + MinecraftForgeClient.registerItemRenderer( + Item.getItemFromBlock(GeneratorsBlocks.Generator), handler + ); - switch(ID) - { - case 0: - return new GuiHeatGenerator(player.inventory, (TileEntityHeatGenerator)tileEntity); - case 1: - return new GuiSolarGenerator(player.inventory, (TileEntitySolarGenerator)tileEntity); - case 3: - return new GuiGasGenerator(player.inventory, (TileEntityGasGenerator)tileEntity); - case 4: - return new GuiBioGenerator(player.inventory, (TileEntityBioGenerator)tileEntity); - case 5: - return new GuiWindGenerator(player.inventory, (TileEntityWindGenerator)tileEntity); - case 6: - return new GuiIndustrialTurbine(player.inventory, (TileEntityTurbineCasing)tileEntity); - case 7: - return new GuiTurbineStats(player.inventory, (TileEntityTurbineCasing)tileEntity); - case 10: - return new GuiReactorController(player.inventory, (TileEntityReactorController)tileEntity); - case 11: - return new GuiReactorHeat(player.inventory, (TileEntityReactorController)tileEntity); - case 12: - return new GuiReactorFuel(player.inventory, (TileEntityReactorController)tileEntity); - case 13: - return new GuiReactorStats(player.inventory, (TileEntityReactorController)tileEntity); - case 14: - return new GuiNeutronCapture(player.inventory, (TileEntityReactorNeutronCapture)tileEntity); - case 15: - return new GuiReactorLogicAdapter(player.inventory, (TileEntityReactorLogicAdapter)tileEntity); - } - - return null; - } - - @SubscribeEvent - public void onStitch(TextureStitchEvent.Pre event) - { - RenderIndustrialTurbine.resetDisplayInts(); - } + System.out.println("[MekanismGenerators] Render registrations complete."); + } + + @Override + public GuiScreen + getClientGui(int ID, EntityPlayer player, World world, int x, int y, int z) { + TileEntity tileEntity = world.getTileEntity(x, y, z); + + switch (ID) { + case 0: + return new GuiHeatGenerator( + player.inventory, (TileEntityHeatGenerator) tileEntity + ); + case 1: + return new GuiSolarGenerator( + player.inventory, (TileEntitySolarGenerator) tileEntity + ); + case 3: + return new GuiGasGenerator( + player.inventory, (TileEntityGasGenerator) tileEntity + ); + case 4: + return new GuiBioGenerator( + player.inventory, (TileEntityBioGenerator) tileEntity + ); + case 5: + return new GuiWindGenerator( + player.inventory, (TileEntityWindGenerator) tileEntity + ); + case 6: + return new GuiIndustrialTurbine( + player.inventory, (TileEntityTurbineCasing) tileEntity + ); + case 7: + return new GuiTurbineStats( + player.inventory, (TileEntityTurbineCasing) tileEntity + ); + case 10: + return new GuiReactorController( + player.inventory, (TileEntityReactorController) tileEntity + ); + case 11: + return new GuiReactorHeat( + player.inventory, (TileEntityReactorController) tileEntity + ); + case 12: + return new GuiReactorFuel( + player.inventory, (TileEntityReactorController) tileEntity + ); + case 13: + return new GuiReactorStats( + player.inventory, (TileEntityReactorController) tileEntity + ); + case 14: + return new GuiNeutronCapture( + player.inventory, (TileEntityReactorNeutronCapture) tileEntity + ); + case 15: + return new GuiReactorLogicAdapter( + player.inventory, (TileEntityReactorLogicAdapter) tileEntity + ); + } + + return null; + } + + @SubscribeEvent + public void onStitch(TextureStitchEvent.Pre event) { + RenderIndustrialTurbine.resetDisplayInts(); + } } diff --git a/src/main/java/mekanism/generators/client/gui/GeneratorsGuiFactory.java b/src/main/java/mekanism/generators/client/gui/GeneratorsGuiFactory.java index 924cb9b54..fec962e29 100644 --- a/src/main/java/mekanism/generators/client/gui/GeneratorsGuiFactory.java +++ b/src/main/java/mekanism/generators/client/gui/GeneratorsGuiFactory.java @@ -2,33 +2,26 @@ package mekanism.generators.client.gui; import java.util.Set; +import cpw.mods.fml.client.IModGuiFactory; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; -import cpw.mods.fml.client.IModGuiFactory; -public class GeneratorsGuiFactory implements IModGuiFactory -{ - @Override - public void initialize(Minecraft minecraftInstance) - { +public class GeneratorsGuiFactory implements IModGuiFactory { + @Override + public void initialize(Minecraft minecraftInstance) {} - } + @Override + public Class mainConfigGuiClass() { + return GuiGeneratorsConfig.class; + } - @Override - public Class mainConfigGuiClass() - { - return GuiGeneratorsConfig.class; - } + @Override + public Set runtimeGuiCategories() { + return null; + } - @Override - public Set runtimeGuiCategories() - { - return null; - } - - @Override - public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) - { - return null; - } + @Override + public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) { + return null; + } } diff --git a/src/main/java/mekanism/generators/client/gui/GuiBioGenerator.java b/src/main/java/mekanism/generators/client/gui/GuiBioGenerator.java index 38920896a..358d40196 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiBioGenerator.java +++ b/src/main/java/mekanism/generators/client/gui/GuiBioGenerator.java @@ -2,6 +2,8 @@ package mekanism.generators.client.gui; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.MekanismConfig.generators; import mekanism.api.util.ListUtils; import mekanism.client.gui.GuiMekanism; @@ -19,64 +21,115 @@ import mekanism.common.util.MekanismUtils.ResourceType; import mekanism.generators.common.inventory.container.ContainerBioGenerator; import mekanism.generators.common.tile.TileEntityBioGenerator; import net.minecraft.entity.player.InventoryPlayer; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiBioGenerator extends GuiMekanism -{ - public TileEntityBioGenerator tileEntity; +public class GuiBioGenerator extends GuiMekanism { + public TileEntityBioGenerator tileEntity; - public GuiBioGenerator(InventoryPlayer inventory, TileEntityBioGenerator tentity) - { - super(new ContainerBioGenerator(inventory, tentity)); - tileEntity = tentity; - guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBioGenerator.png"))); - guiElements.add(new GuiSecurityTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBioGenerator.png"))); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() - { - @Override - public List getInfo() - { - return ListUtils.asList( - LangUtils.localize("gui.producing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.isActive ? generators.bioGeneration : 0) + "/t", - LangUtils.localize("gui.maxOutput") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t"); - } - }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBioGenerator.png"))); - guiElements.add(new GuiPowerBar(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBioGenerator.png"), 164, 15)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBioGenerator.png"), 16, 34)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBioGenerator.png"), 142, 34).with(SlotOverlay.POWER)); - } + public GuiBioGenerator(InventoryPlayer inventory, TileEntityBioGenerator tentity) { + super(new ContainerBioGenerator(inventory, tentity)); + tileEntity = tentity; + guiElements.add(new GuiRedstoneControl( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiBioGenerator.png") + )); + guiElements.add(new GuiSecurityTab( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiBioGenerator.png") + )); + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() { + return ListUtils.asList( + LangUtils.localize("gui.producing") + ": " + + MekanismUtils.getEnergyDisplay( + tileEntity.isActive ? generators.bioGeneration : 0 + ) + + "/t", + LangUtils.localize("gui.maxOutput") + ": " + + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t" + ); + } + }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBioGenerator.png"))); + guiElements.add(new GuiPowerBar( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiBioGenerator.png"), + 164, + 15 + )); + guiElements.add(new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiBioGenerator.png"), + 16, + 34 + )); + guiElements.add( + new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiBioGenerator.png"), + 142, + 34 + ) + .with(SlotOverlay.POWER) + ); + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + super.drawGuiContainerForegroundLayer(mouseX, mouseY); - fontRendererObj.drawString(tileEntity.getInventoryName(), 45, 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); - fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00); - fontRendererObj.drawString(LangUtils.localize("gui.bioGenerator.bioFuel") + ": " + tileEntity.bioFuelSlot.fluidStored, 51, 35, 0x00CD00); - fontRendererObj.drawString(LangUtils.localize("gui.out") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t", 51, 44, 0x00CD00); - } + fontRendererObj.drawString(tileEntity.getInventoryName(), 45, 6, 0x404040); + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040 + ); + fontRendererObj.drawString( + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.bioGenerator.bioFuel") + ": " + + tileEntity.bioFuelSlot.fluidStored, + 51, + 35, + 0x00CD00 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.out") + ": " + + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t", + 51, + 44, + 0x00CD00 + ); + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiBioGenerator.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiBioGenerator.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - int displayInt; + int displayInt; - displayInt = tileEntity.getScaledFuelLevel(52); - drawTexturedModalRect(guiWidth + 7, guiHeight + 17 + 52 - displayInt, 176, 52 + 52 - displayInt, 4, displayInt); + displayInt = tileEntity.getScaledFuelLevel(52); + drawTexturedModalRect( + guiWidth + 7, + guiHeight + 17 + 52 - displayInt, + 176, + 52 + 52 - displayInt, + 4, + displayInt + ); - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } } diff --git a/src/main/java/mekanism/generators/client/gui/GuiGasGenerator.java b/src/main/java/mekanism/generators/client/gui/GuiGasGenerator.java index dc10809e6..11648894c 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiGasGenerator.java +++ b/src/main/java/mekanism/generators/client/gui/GuiGasGenerator.java @@ -2,6 +2,8 @@ package mekanism.generators.client.gui; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.gas.GasTank; import mekanism.api.util.ListUtils; import mekanism.client.gui.GuiMekanism; @@ -22,64 +24,112 @@ import mekanism.common.util.MekanismUtils.ResourceType; import mekanism.generators.common.inventory.container.ContainerGasGenerator; import mekanism.generators.common.tile.TileEntityGasGenerator; import net.minecraft.entity.player.InventoryPlayer; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiGasGenerator extends GuiMekanism -{ - public TileEntityGasGenerator tileEntity; +public class GuiGasGenerator extends GuiMekanism { + public TileEntityGasGenerator tileEntity; - public GuiGasGenerator(InventoryPlayer inventory, TileEntityGasGenerator tentity) - { - super(new ContainerGasGenerator(inventory, tentity)); - tileEntity = tentity; - guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiGasGenerator.png"))); - guiElements.add(new GuiSecurityTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiGasGenerator.png"))); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() { - @Override - public List getInfo() - { - return ListUtils.asList( - LangUtils.localize("gui.producing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.generationRate*tileEntity.clientUsed) + "/t", - LangUtils.localize("gui.maxOutput") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t"); - } - }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiGasGenerator.png"))); - guiElements.add(new GuiGasGauge(new IGasInfoHandler() { - @Override - public GasTank getTank() - { - return tileEntity.fuelTank; - } - }, Type.WIDE, this, MekanismUtils.getResource(ResourceType.GUI, "GuiGasGenerator.png"), 55, 18)); - guiElements.add(new GuiPowerBar(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiGasGenerator.png"), 164, 15)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiGasGenerator.png"), 16, 34).with(SlotOverlay.MINUS)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiGasGenerator.png"), 142, 34).with(SlotOverlay.POWER)); - } + public GuiGasGenerator(InventoryPlayer inventory, TileEntityGasGenerator tentity) { + super(new ContainerGasGenerator(inventory, tentity)); + tileEntity = tentity; + guiElements.add(new GuiRedstoneControl( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiGasGenerator.png") + )); + guiElements.add(new GuiSecurityTab( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiGasGenerator.png") + )); + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() { + return ListUtils.asList( + LangUtils.localize("gui.producing") + ": " + + MekanismUtils.getEnergyDisplay( + tileEntity.generationRate * tileEntity.clientUsed + ) + + "/t", + LangUtils.localize("gui.maxOutput") + ": " + + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t" + ); + } + }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiGasGenerator.png"))); + guiElements.add(new GuiGasGauge( + new IGasInfoHandler() { + @Override + public GasTank getTank() { + return tileEntity.fuelTank; + } + }, + Type.WIDE, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiGasGenerator.png"), + 55, + 18 + )); + guiElements.add(new GuiPowerBar( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiGasGenerator.png"), + 164, + 15 + )); + guiElements.add( + new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiGasGenerator.png"), + 16, + 34 + ) + .with(SlotOverlay.MINUS) + ); + guiElements.add( + new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiGasGenerator.png"), + 142, + 34 + ) + .with(SlotOverlay.POWER) + ); + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + super.drawGuiContainerForegroundLayer(mouseX, mouseY); - fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize/2)-(fontRendererObj.getStringWidth(tileEntity.getInventoryName())/2), 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); - String s = LangUtils.localize("gui.burnRate") + ": " + tileEntity.clientUsed; - fontRendererObj.drawString(s, xSize - 8 - fontRendererObj.getStringWidth(s), (ySize - 96) + 2, 0x404040); - } + fontRendererObj.drawString( + tileEntity.getInventoryName(), + (xSize / 2) + - (fontRendererObj.getStringWidth(tileEntity.getInventoryName()) / 2), + 6, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040 + ); + String s = LangUtils.localize("gui.burnRate") + ": " + tileEntity.clientUsed; + fontRendererObj.drawString( + s, xSize - 8 - fontRendererObj.getStringWidth(s), (ySize - 96) + 2, 0x404040 + ); + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiGasGenerator.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiGasGenerator.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } } diff --git a/src/main/java/mekanism/generators/client/gui/GuiGeneratorsConfig.java b/src/main/java/mekanism/generators/client/gui/GuiGeneratorsConfig.java index 46ed8db19..083ef1420 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiGeneratorsConfig.java +++ b/src/main/java/mekanism/generators/client/gui/GuiGeneratorsConfig.java @@ -1,18 +1,23 @@ package mekanism.generators.client.gui; +import cpw.mods.fml.client.config.GuiConfig; import mekanism.common.Mekanism; import net.minecraft.client.gui.GuiScreen; import net.minecraftforge.common.config.ConfigElement; -import cpw.mods.fml.client.config.GuiConfig; /** * Created by ben on 27/06/14. */ -public class GuiGeneratorsConfig extends GuiConfig -{ - public GuiGeneratorsConfig(GuiScreen parent) - { - super(parent, new ConfigElement(Mekanism.configuration.getCategory("generation")).getChildElements(), - "MekanismGenerators", false, false, "MekanismGenerators"); - } +public class GuiGeneratorsConfig extends GuiConfig { + public GuiGeneratorsConfig(GuiScreen parent) { + super( + parent, + new ConfigElement(Mekanism.configuration.getCategory("generation")) + .getChildElements(), + "MekanismGenerators", + false, + false, + "MekanismGenerators" + ); + } } diff --git a/src/main/java/mekanism/generators/client/gui/GuiHeatGenerator.java b/src/main/java/mekanism/generators/client/gui/GuiHeatGenerator.java index 67382b89e..8d5f93e1f 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiHeatGenerator.java +++ b/src/main/java/mekanism/generators/client/gui/GuiHeatGenerator.java @@ -2,6 +2,8 @@ package mekanism.generators.client.gui; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.MekanismConfig.general; import mekanism.api.util.ListUtils; import mekanism.api.util.UnitDisplayUtils; @@ -26,73 +28,114 @@ import mekanism.generators.common.inventory.container.ContainerHeatGenerator; import mekanism.generators.common.tile.TileEntityHeatGenerator; import net.minecraft.entity.player.InventoryPlayer; import net.minecraftforge.fluids.FluidTank; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiHeatGenerator extends GuiMekanism -{ - public TileEntityHeatGenerator tileEntity; +public class GuiHeatGenerator extends GuiMekanism { + public TileEntityHeatGenerator tileEntity; - public GuiHeatGenerator(InventoryPlayer inventory, TileEntityHeatGenerator tentity) - { - super(new ContainerHeatGenerator(inventory, tentity)); - tileEntity = tentity; - guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiHeatGenerator.png"))); - guiElements.add(new GuiSecurityTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiHeatGenerator.png"))); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() - { - @Override - public List getInfo() - { - return ListUtils.asList( - LangUtils.localize("gui.producing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.producingEnergy) + "/t", - LangUtils.localize("gui.maxOutput") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t"); - } - }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiHeatGenerator.png"))); - guiElements.add(new GuiFluidGauge(new IFluidInfoHandler() { - @Override - public FluidTank getTank() - { - return tileEntity.lavaTank; - } - }, Type.WIDE, this, MekanismUtils.getResource(ResourceType.GUI, "GuiHeatGenerator.png"), 55, 18)); - guiElements.add(new GuiPowerBar(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiHeatGenerator.png"), 164, 15)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiHeatGenerator.png"), 16, 34)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiHeatGenerator.png"), 142, 34).with(SlotOverlay.POWER)); - guiElements.add(new GuiHeatInfo(new IInfoHandler() { - @Override - public List getInfo() - { - TemperatureUnit unit = TemperatureUnit.values()[general.tempUnit.ordinal()]; - String transfer = UnitDisplayUtils.getDisplayShort(tileEntity.lastTransferLoss, false, unit); - String environment = UnitDisplayUtils.getDisplayShort(tileEntity.lastEnvironmentLoss, false, unit); - return ListUtils.asList(LangUtils.localize("gui.transferred") + ": " + transfer + "/t", LangUtils.localize("gui.dissipated") + ": " + environment + "/t"); - } - }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiHeatGenerator.png"))); - } + public GuiHeatGenerator(InventoryPlayer inventory, TileEntityHeatGenerator tentity) { + super(new ContainerHeatGenerator(inventory, tentity)); + tileEntity = tentity; + guiElements.add(new GuiRedstoneControl( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiHeatGenerator.png") + )); + guiElements.add(new GuiSecurityTab( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiHeatGenerator.png") + )); + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() { + return ListUtils.asList( + LangUtils.localize("gui.producing") + ": " + + MekanismUtils.getEnergyDisplay(tileEntity.producingEnergy) + + "/t", + LangUtils.localize("gui.maxOutput") + ": " + + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t" + ); + } + }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiHeatGenerator.png"))); + guiElements.add(new GuiFluidGauge( + new IFluidInfoHandler() { + @Override + public FluidTank getTank() { + return tileEntity.lavaTank; + } + }, + Type.WIDE, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiHeatGenerator.png"), + 55, + 18 + )); + guiElements.add(new GuiPowerBar( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiHeatGenerator.png"), + 164, + 15 + )); + guiElements.add(new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiHeatGenerator.png"), + 16, + 34 + )); + guiElements.add( + new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiHeatGenerator.png"), + 142, + 34 + ) + .with(SlotOverlay.POWER) + ); + guiElements.add(new GuiHeatInfo(new IInfoHandler() { + @Override + public List getInfo() { + TemperatureUnit unit + = TemperatureUnit.values()[general.tempUnit.ordinal()]; + String transfer = UnitDisplayUtils.getDisplayShort( + tileEntity.lastTransferLoss, false, unit + ); + String environment = UnitDisplayUtils.getDisplayShort( + tileEntity.lastEnvironmentLoss, false, unit + ); + return ListUtils.asList( + LangUtils.localize("gui.transferred") + ": " + transfer + "/t", + LangUtils.localize("gui.dissipated") + ": " + environment + "/t" + ); + } + }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiHeatGenerator.png"))); + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + super.drawGuiContainerForegroundLayer(mouseX, mouseY); - fontRendererObj.drawString(tileEntity.getInventoryName(), 45, 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); - } + fontRendererObj.drawString(tileEntity.getInventoryName(), 45, 6, 0x404040); + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040 + ); + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiHeatGenerator.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiHeatGenerator.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } } diff --git a/src/main/java/mekanism/generators/client/gui/GuiIndustrialTurbine.java b/src/main/java/mekanism/generators/client/gui/GuiIndustrialTurbine.java index f13caf4c6..e425a5051 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiIndustrialTurbine.java +++ b/src/main/java/mekanism/generators/client/gui/GuiIndustrialTurbine.java @@ -3,6 +3,8 @@ package mekanism.generators.client.gui; import java.util.ArrayList; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.MekanismConfig.general; import mekanism.api.MekanismConfig.generators; @@ -28,183 +30,289 @@ import mekanism.generators.common.content.turbine.TurbineUpdateProtocol; import mekanism.generators.common.tile.turbine.TileEntityTurbineCasing; import net.minecraft.entity.player.InventoryPlayer; import net.minecraftforge.fluids.FluidStack; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiIndustrialTurbine extends GuiMekanism -{ - public TileEntityTurbineCasing tileEntity; +public class GuiIndustrialTurbine extends GuiMekanism { + public TileEntityTurbineCasing tileEntity; - public GuiIndustrialTurbine(InventoryPlayer inventory, TileEntityTurbineCasing tentity) - { - super(tentity, new ContainerFilter(inventory, tentity)); - tileEntity = tentity; - guiElements.add(new GuiTurbineTab(this, tileEntity, TurbineTab.STAT, 6, MekanismUtils.getResource(ResourceType.GUI, "GuiIndustrialTurbine.png"))); - guiElements.add(new GuiPowerBar(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiIndustrialTurbine.png"), 164, 16)); - guiElements.add(new GuiRateBar(this, new IRateInfoHandler() - { - @Override - public String getTooltip() - { - return LangUtils.localize("gui.steamInput") + ": " + tileEntity.structure.lastSteamInput + " mB/t"; - } - - @Override - public double getLevel() - { - double rate = tileEntity.structure.lowerVolume*(tileEntity.structure.clientDispersers*generators.turbineDisperserGasFlow); - rate = Math.min(rate, tileEntity.structure.vents*generators.turbineVentGasFlow); - - if(rate == 0) - { - return 0; - } - - return (double)tileEntity.structure.lastSteamInput/rate; - } - }, MekanismUtils.getResource(ResourceType.GUI, "GuiIndustrialTurbine.png"), 40, 13)); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() - { - @Override - public List getInfo() - { - double energyMultiplier = (general.maxEnergyPerSteam/TurbineUpdateProtocol.MAX_BLADES)*Math.min(tileEntity.structure.blades, tileEntity.structure.coils*generators.turbineBladesPerCoil); - - return ListUtils.asList( - LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), - LangUtils.localize("gui.producing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.structure.clientFlow*energyMultiplier) + "/t"); - } - }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiIndustrialTurbine.png"))); - } - - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + public GuiIndustrialTurbine( + InventoryPlayer inventory, TileEntityTurbineCasing tentity + ) { + super(tentity, new ContainerFilter(inventory, tentity)); + tileEntity = tentity; + guiElements.add(new GuiTurbineTab( + this, + tileEntity, + TurbineTab.STAT, + 6, + MekanismUtils.getResource(ResourceType.GUI, "GuiIndustrialTurbine.png") + )); + guiElements.add(new GuiPowerBar( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiIndustrialTurbine.png"), + 164, + 16 + )); + guiElements.add(new GuiRateBar( + this, + new IRateInfoHandler() { + @Override + public String getTooltip() { + return LangUtils.localize("gui.steamInput") + ": " + + tileEntity.structure.lastSteamInput + " mB/t"; + } - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 4, 0x404040); - fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize/2)-(fontRendererObj.getStringWidth(tileEntity.getInventoryName())/2), 5, 0x404040); - - double energyMultiplier = (general.maxEnergyPerSteam/TurbineUpdateProtocol.MAX_BLADES)*Math.min(tileEntity.structure.blades, tileEntity.structure.coils*generators.turbineBladesPerCoil); - - double rate = tileEntity.structure.lowerVolume*(tileEntity.structure.clientDispersers*generators.turbineDisperserGasFlow); - rate = Math.min(rate, tileEntity.structure.vents*generators.turbineVentGasFlow); - - renderScaledText(LangUtils.localize("gui.production") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.structure.clientFlow*energyMultiplier), 53, 26, 0x00CD00, 106); - renderScaledText(LangUtils.localize("gui.flowRate") + ": " + tileEntity.structure.clientFlow + " mB/t", 53, 35, 0x00CD00, 106); - renderScaledText(LangUtils.localize("gui.capacity") + ": " + tileEntity.structure.getFluidCapacity() + " mB", 53, 44, 0x00CD00, 106); - renderScaledText(LangUtils.localize("gui.maxFlow") + ": " + rate + " mB/t", 53, 53, 0x00CD00, 106); - - String name = chooseByMode(tileEntity.structure.dumpMode, LangUtils.localize("gui.idle"), LangUtils.localize("gui.dumping"), LangUtils.localize("gui.dumping_excess")); - renderScaledText(name, 156-(int)(fontRendererObj.getStringWidth(name)*getNeededScale(name, 66)), 73, 0x404040, 66); - - if(xAxis >= 7 && xAxis <= 39 && yAxis >= 14 && yAxis <= 72) - { - drawCreativeTabHoveringText(tileEntity.structure.fluidStored != null ? LangUtils.localizeFluidStack(tileEntity.structure.fluidStored) + ": " + tileEntity.structure.fluidStored.amount + "mB" : LangUtils.localize("gui.empty"), xAxis, yAxis); - } - - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } - - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiIndustrialTurbine.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - int displayInt = chooseByMode(tileEntity.structure.dumpMode, 142, 150, 158); - drawTexturedModalRect(guiWidth + 160, guiHeight + 73, 176, displayInt, 8, 8); - - if(tileEntity.getScaledFluidLevel(58) > 0) - { - displayGauge(7, 14, tileEntity.getScaledFluidLevel(58), tileEntity.structure.fluidStored, 0); - displayGauge(23, 14, tileEntity.getScaledFluidLevel(58), tileEntity.structure.fluidStored, 1); - } - - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } - - public void displayGauge(int xPos, int yPos, int scale, FluidStack fluid, int side /*0-left, 1-right*/) - { - if(fluid == null) - { - return; - } + @Override + public double getLevel() { + double rate = tileEntity.structure.lowerVolume + * (tileEntity.structure.clientDispersers + * generators.turbineDisperserGasFlow); + rate = Math.min( + rate, tileEntity.structure.vents * generators.turbineVentGasFlow + ); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; + if (rate == 0) { + return 0; + } - int start = 0; + return (double) tileEntity.structure.lastSteamInput / rate; + } + }, + MekanismUtils.getResource(ResourceType.GUI, "GuiIndustrialTurbine.png"), + 40, + 13 + )); + guiElements.add(new GuiEnergyInfo( + new IInfoHandler() { + @Override + public List getInfo() { + double energyMultiplier + = (general.maxEnergyPerSteam / TurbineUpdateProtocol.MAX_BLADES) + * Math.min( + tileEntity.structure.blades, + tileEntity.structure.coils * generators.turbineBladesPerCoil + ); - while(true) - { - int renderRemaining = 0; + return ListUtils.asList( + LangUtils.localize("gui.storing") + ": " + + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), + LangUtils.localize("gui.producing") + ": " + + MekanismUtils.getEnergyDisplay( + tileEntity.structure.clientFlow * energyMultiplier + ) + + "/t" + ); + } + }, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiIndustrialTurbine.png") + )); + } - if(scale > 16) - { - renderRemaining = 16; - scale -= 16; - } - else { - renderRemaining = scale; - scale = 0; - } + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture()); - drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos + 58 - renderRemaining - start, fluid.getFluid().getIcon(), 16, 16 - (16 - renderRemaining)); - start+=16; + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, (ySize - 96) + 4, 0x404040 + ); + fontRendererObj.drawString( + tileEntity.getInventoryName(), + (xSize / 2) + - (fontRendererObj.getStringWidth(tileEntity.getInventoryName()) / 2), + 5, + 0x404040 + ); - if(renderRemaining == 0 || scale == 0) - { - break; - } - } + double energyMultiplier + = (general.maxEnergyPerSteam / TurbineUpdateProtocol.MAX_BLADES) + * Math.min( + tileEntity.structure.blades, + tileEntity.structure.coils * generators.turbineBladesPerCoil + ); - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiIndustrialTurbine.png")); - drawTexturedModalRect(guiWidth + xPos, guiHeight + yPos, 176, side == 0 ? 0 : 54, 16, 54); - } - - @Override - protected void mouseClicked(int x, int y, int button) - { - super.mouseClicked(x, y, button); + double rate = tileEntity.structure.lowerVolume + * (tileEntity.structure.clientDispersers * generators.turbineDisperserGasFlow + ); + rate = Math.min(rate, tileEntity.structure.vents * generators.turbineVentGasFlow); - int xAxis = (x - (width - xSize) / 2); - int yAxis = (y - (height - ySize) / 2); + renderScaledText( + LangUtils.localize("gui.production") + ": " + + MekanismUtils.getEnergyDisplay( + tileEntity.structure.clientFlow * energyMultiplier + ), + 53, + 26, + 0x00CD00, + 106 + ); + renderScaledText( + LangUtils.localize("gui.flowRate") + ": " + tileEntity.structure.clientFlow + + " mB/t", + 53, + 35, + 0x00CD00, + 106 + ); + renderScaledText( + LangUtils.localize("gui.capacity") + ": " + + tileEntity.structure.getFluidCapacity() + " mB", + 53, + 44, + 0x00CD00, + 106 + ); + renderScaledText( + LangUtils.localize("gui.maxFlow") + ": " + rate + " mB/t", + 53, + 53, + 0x00CD00, + 106 + ); - if(xAxis > 160 && xAxis < 169 && yAxis > 73 && yAxis < 82) - { - ArrayList data = new ArrayList(); - data.add((byte)0); + String name = chooseByMode( + tileEntity.structure.dumpMode, + LangUtils.localize("gui.idle"), + LangUtils.localize("gui.dumping"), + LangUtils.localize("gui.dumping_excess") + ); + renderScaledText( + name, + 156 - (int) (fontRendererObj.getStringWidth(name) * getNeededScale(name, 66)), + 73, + 0x404040, + 66 + ); - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - SoundHandler.playSound("gui.button.press"); - } - } - - private T chooseByMode(TileEntityGasTank.GasMode dumping, T idleOption, T dumpingOption, T dumpingExcessOption) - { - if(dumping.equals(TileEntityGasTank.GasMode.IDLE)) - { - return idleOption; - } - else if(dumping.equals(TileEntityGasTank.GasMode.DUMPING)) - { - return dumpingOption; - } - else if(dumping.equals(TileEntityGasTank.GasMode.DUMPING_EXCESS)) - { - return dumpingExcessOption; - } - - return idleOption; //should not happen; - } + if (xAxis >= 7 && xAxis <= 39 && yAxis >= 14 && yAxis <= 72) { + drawCreativeTabHoveringText( + tileEntity.structure.fluidStored != null + ? LangUtils.localizeFluidStack(tileEntity.structure.fluidStored) + + ": " + tileEntity.structure.fluidStored.amount + "mB" + : LangUtils.localize("gui.empty"), + xAxis, + yAxis + ); + } + + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiIndustrialTurbine.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int displayInt = chooseByMode(tileEntity.structure.dumpMode, 142, 150, 158); + drawTexturedModalRect(guiWidth + 160, guiHeight + 73, 176, displayInt, 8, 8); + + if (tileEntity.getScaledFluidLevel(58) > 0) { + displayGauge( + 7, + 14, + tileEntity.getScaledFluidLevel(58), + tileEntity.structure.fluidStored, + 0 + ); + displayGauge( + 23, + 14, + tileEntity.getScaledFluidLevel(58), + tileEntity.structure.fluidStored, + 1 + ); + } + + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } + + public void displayGauge( + int xPos, int yPos, int scale, FluidStack fluid, int side /*0-left, 1-right*/ + ) { + if (fluid == null) { + return; + } + + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + + int start = 0; + + while (true) { + int renderRemaining = 0; + + if (scale > 16) { + renderRemaining = 16; + scale -= 16; + } else { + renderRemaining = scale; + scale = 0; + } + + mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture()); + drawTexturedModelRectFromIcon( + guiWidth + xPos, + guiHeight + yPos + 58 - renderRemaining - start, + fluid.getFluid().getIcon(), + 16, + 16 - (16 - renderRemaining) + ); + start += 16; + + if (renderRemaining == 0 || scale == 0) { + break; + } + } + + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiIndustrialTurbine.png") + ); + drawTexturedModalRect( + guiWidth + xPos, guiHeight + yPos, 176, side == 0 ? 0 : 54, 16, 54 + ); + } + + @Override + protected void mouseClicked(int x, int y, int button) { + super.mouseClicked(x, y, button); + + int xAxis = (x - (width - xSize) / 2); + int yAxis = (y - (height - ySize) / 2); + + if (xAxis > 160 && xAxis < 169 && yAxis > 73 && yAxis < 82) { + ArrayList data = new ArrayList(); + data.add((byte) 0); + + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); + SoundHandler.playSound("gui.button.press"); + } + } + + private T chooseByMode( + TileEntityGasTank.GasMode dumping, + T idleOption, + T dumpingOption, + T dumpingExcessOption + ) { + if (dumping.equals(TileEntityGasTank.GasMode.IDLE)) { + return idleOption; + } else if (dumping.equals(TileEntityGasTank.GasMode.DUMPING)) { + return dumpingOption; + } else if (dumping.equals(TileEntityGasTank.GasMode.DUMPING_EXCESS)) { + return dumpingExcessOption; + } + + return idleOption; //should not happen; + } } diff --git a/src/main/java/mekanism/generators/client/gui/GuiNeutronCapture.java b/src/main/java/mekanism/generators/client/gui/GuiNeutronCapture.java index 684da7690..767c32ede 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiNeutronCapture.java +++ b/src/main/java/mekanism/generators/client/gui/GuiNeutronCapture.java @@ -2,6 +2,8 @@ package mekanism.generators.client.gui; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.util.ListUtils; import mekanism.client.gui.GuiMekanism; import mekanism.client.gui.element.GuiElement.IInfoHandler; @@ -17,55 +19,72 @@ import mekanism.common.util.MekanismUtils.ResourceType; import mekanism.generators.common.inventory.container.ContainerNeutronCapture; import mekanism.generators.common.tile.reactor.TileEntityReactorNeutronCapture; import net.minecraft.entity.player.InventoryPlayer; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiNeutronCapture extends GuiMekanism -{ - public TileEntityReactorNeutronCapture tileEntity; +public class GuiNeutronCapture extends GuiMekanism { + public TileEntityReactorNeutronCapture tileEntity; - public GuiNeutronCapture(InventoryPlayer inventory, TileEntityReactorNeutronCapture tentity) - { - super(new ContainerNeutronCapture(inventory, tentity)); - tileEntity = tentity; - guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"))); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() - { - @Override - public List getInfo() - { - return ListUtils.asList( - LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), - LangUtils.localize("gui.maxOutput") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t"); - } - }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"))); - guiElements.add(new GuiPowerBar(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 164, 15)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 142, 34).with(SlotOverlay.POWER)); - } + public GuiNeutronCapture( + InventoryPlayer inventory, TileEntityReactorNeutronCapture tentity + ) { + super(new ContainerNeutronCapture(inventory, tentity)); + tileEntity = tentity; + guiElements.add(new GuiRedstoneControl( + this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png") + )); + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() { + return ListUtils.asList( + LangUtils.localize("gui.storing") + ": " + + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), + LangUtils.localize("gui.maxOutput") + ": " + + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t" + ); + } + }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"))); + guiElements.add(new GuiPowerBar( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), + 164, + 15 + )); + guiElements.add(new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), + 142, + 34 + ) + .with(SlotOverlay.POWER)); + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + super.drawGuiContainerForegroundLayer(mouseX, mouseY); - fontRendererObj.drawString(tileEntity.getInventoryName(), 30, 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); - fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00); - } + fontRendererObj.drawString(tileEntity.getInventoryName(), 30, 6, 0x404040); + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040 + ); + fontRendererObj.drawString( + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00 + ); + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } } diff --git a/src/main/java/mekanism/generators/client/gui/GuiReactorController.java b/src/main/java/mekanism/generators/client/gui/GuiReactorController.java index ba571fa86..486d1affd 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiReactorController.java +++ b/src/main/java/mekanism/generators/client/gui/GuiReactorController.java @@ -3,6 +3,8 @@ package mekanism.generators.client.gui; import java.util.ArrayList; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.util.ListUtils; import mekanism.client.gui.GuiMekanism; import mekanism.client.gui.element.GuiElement.IInfoHandler; @@ -18,66 +20,88 @@ import mekanism.generators.client.gui.element.GuiStatTab; import mekanism.generators.common.inventory.container.ContainerReactorController; import mekanism.generators.common.tile.reactor.TileEntityReactorController; import net.minecraft.entity.player.InventoryPlayer; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiReactorController extends GuiMekanism -{ - public TileEntityReactorController tileEntity; +public class GuiReactorController extends GuiMekanism { + public TileEntityReactorController tileEntity; - public GuiReactorController(InventoryPlayer inventory, final TileEntityReactorController tentity) - { - super(new ContainerReactorController(inventory, tentity)); - tileEntity = tentity; - - if(tileEntity.isFormed()) - { - guiElements.add(new GuiEnergyInfo(new IInfoHandler() - { - @Override - public List getInfo() - { - return tileEntity.isFormed() ? ListUtils.asList( - LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), - LangUtils.localize("gui.producing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getReactor().getPassiveGeneration(false, true)) + "/t") : new ArrayList(); - } - }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"))); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), 79, 38)); - guiElements.add(new GuiHeatTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"))); - guiElements.add(new GuiFuelTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"))); - guiElements.add(new GuiStatTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"))); - } - } + public GuiReactorController( + InventoryPlayer inventory, final TileEntityReactorController tentity + ) { + super(new ContainerReactorController(inventory, tentity)); + tileEntity = tentity; - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - fontRendererObj.drawString(tileEntity.getInventoryName(), 46, 6, 0x404040); - - if(tileEntity.getActive()) - { - fontRendererObj.drawString(LangUtils.localize("gui.formed"), 8, 16, 0x404040); - } - else { - fontRendererObj.drawString(LangUtils.localize("gui.incomplete"), 8, 16, 0x404040); - } - - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + if (tileEntity.isFormed()) { + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() { + return tileEntity.isFormed() + ? ListUtils.asList( + LangUtils.localize("gui.storing") + ": " + + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), + LangUtils.localize("gui.producing") + ": " + + MekanismUtils.getEnergyDisplay( + tileEntity.getReactor().getPassiveGeneration( + false, true + ) + ) + + "/t" + ) + : new ArrayList(); + } + }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"))); + guiElements.add(new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png"), + 79, + 38 + )); + guiElements.add(new GuiHeatTab( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png") + )); + guiElements.add(new GuiFuelTab( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png") + )); + guiElements.add(new GuiStatTab( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png") + )); + } + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + fontRendererObj.drawString(tileEntity.getInventoryName(), 46, 6, 0x404040); - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } + if (tileEntity.getActive()) { + fontRendererObj.drawString(LangUtils.localize("gui.formed"), 8, 16, 0x404040); + } else { + fontRendererObj.drawString( + LangUtils.localize("gui.incomplete"), 8, 16, 0x404040 + ); + } + + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiBlank.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } } diff --git a/src/main/java/mekanism/generators/client/gui/GuiReactorFuel.java b/src/main/java/mekanism/generators/client/gui/GuiReactorFuel.java index a7d41e704..57cd0004c 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiReactorFuel.java +++ b/src/main/java/mekanism/generators/client/gui/GuiReactorFuel.java @@ -3,6 +3,8 @@ package mekanism.generators.client.gui; import java.util.ArrayList; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.gas.GasTank; import mekanism.api.util.ListUtils; @@ -28,193 +30,227 @@ import mekanism.generators.client.gui.element.GuiStatTab; import mekanism.generators.common.tile.reactor.TileEntityReactorController; import net.minecraft.client.gui.GuiTextField; import net.minecraft.entity.player.InventoryPlayer; - import org.lwjgl.input.Keyboard; import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiReactorFuel extends GuiMekanism -{ - public TileEntityReactorController tileEntity; +public class GuiReactorFuel extends GuiMekanism { + public TileEntityReactorController tileEntity; - public GuiTextField injectionRateField; + public GuiTextField injectionRateField; - public GuiReactorFuel(InventoryPlayer inventory, final TileEntityReactorController tentity) - { - super(new ContainerNull(inventory.player, tentity)); - tileEntity = tentity; - guiElements.add(new GuiEnergyInfo(new IInfoHandler() - { - @Override - public List getInfo() - { - return tileEntity.isFormed() ? ListUtils.asList( - LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), - LangUtils.localize("gui.producing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getReactor().getPassiveGeneration(false, true)) + "/t") : new ArrayList(); - } - }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"))); - guiElements.add(new GuiGasGauge(new IGasInfoHandler() - { - @Override - public GasTank getTank() - { - return tentity.deuteriumTank; - } - }, Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 25, 64)); - guiElements.add(new GuiGasGauge(new IGasInfoHandler() - { - @Override - public GasTank getTank() - { - return tentity.fuelTank; - } - }, Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 79, 50)); - guiElements.add(new GuiGasGauge(new IGasInfoHandler() - { - @Override - public GasTank getTank() - { - return tentity.tritiumTank; - } - }, Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 133, 64)); - guiElements.add(new GuiProgress(new IProgressInfoHandler() - { - @Override - public double getProgress() - { - return tileEntity.getActive() ? 1 : 0; - } - }, ProgressBar.SMALL_RIGHT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 45, 75)); - guiElements.add(new GuiProgress(new IProgressInfoHandler() - { - @Override - public double getProgress() - { - return tileEntity.getActive() ? 1 : 0; - } - }, ProgressBar.SMALL_LEFT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 99, 75)); - guiElements.add(new GuiHeatTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"))); - guiElements.add(new GuiStatTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"))); - } + public GuiReactorFuel( + InventoryPlayer inventory, final TileEntityReactorController tentity + ) { + super(new ContainerNull(inventory.player, tentity)); + tileEntity = tentity; + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() { + return tileEntity.isFormed() + ? ListUtils.asList( + LangUtils.localize("gui.storing") + ": " + + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), + LangUtils.localize("gui.producing") + ": " + + MekanismUtils.getEnergyDisplay( + tileEntity.getReactor().getPassiveGeneration(false, true) + ) + + "/t" + ) + : new ArrayList(); + } + }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"))); + guiElements.add(new GuiGasGauge( + new IGasInfoHandler() { + @Override + public GasTank getTank() { + return tentity.deuteriumTank; + } + }, + Type.SMALL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), + 25, + 64 + )); + guiElements.add(new GuiGasGauge( + new IGasInfoHandler() { + @Override + public GasTank getTank() { + return tentity.fuelTank; + } + }, + Type.STANDARD, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), + 79, + 50 + )); + guiElements.add(new GuiGasGauge( + new IGasInfoHandler() { + @Override + public GasTank getTank() { + return tentity.tritiumTank; + } + }, + Type.SMALL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), + 133, + 64 + )); + guiElements.add(new GuiProgress( + new IProgressInfoHandler() { + @Override + public double getProgress() { + return tileEntity.getActive() ? 1 : 0; + } + }, + ProgressBar.SMALL_RIGHT, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), + 45, + 75 + )); + guiElements.add(new GuiProgress( + new IProgressInfoHandler() { + @Override + public double getProgress() { + return tileEntity.getActive() ? 1 : 0; + } + }, + ProgressBar.SMALL_LEFT, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), + 99, + 75 + )); + guiElements.add(new GuiHeatTab( + this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png") + )); + guiElements.add(new GuiStatTab( + this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png") + )); + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + super.drawGuiContainerForegroundLayer(mouseX, mouseY); - fontRendererObj.drawString(tileEntity.getInventoryName(), 46, 6, 0x404040); - String str = LangUtils.localize("gui.reactor.injectionRate") + ": " + (tileEntity.getReactor() == null ? "None" : tileEntity.getReactor().getInjectionRate()); - fontRendererObj.drawString(str, (xSize / 2) - (fontRendererObj.getStringWidth(str) / 2), 35, 0x404040); - fontRendererObj.drawString("Edit Rate" + ":", 50, 117, 0x404040); - } + fontRendererObj.drawString(tileEntity.getInventoryName(), 46, 6, 0x404040); + String str = LangUtils.localize("gui.reactor.injectionRate") + ": " + + (tileEntity.getReactor() == null + ? "None" + : tileEntity.getReactor().getInjectionRate()); + fontRendererObj.drawString( + str, (xSize / 2) - (fontRendererObj.getStringWidth(str) / 2), 35, 0x404040 + ); + fontRendererObj.drawString( + "Edit Rate" + + ":", + 50, + 117, + 0x404040 + ); + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - if(xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) - { - drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176, 0, 14, 14); - } - else { - drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176, 14, 14, 14); - } + if (xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) { + drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176, 0, 14, 14); + } else { + drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176, 14, 14, 14); + } - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - injectionRateField.drawTextBox(); - } + injectionRateField.drawTextBox(); + } - @Override - public void updateScreen() - { - super.updateScreen(); + @Override + public void updateScreen() { + super.updateScreen(); - injectionRateField.updateCursorCounter(); - } + injectionRateField.updateCursorCounter(); + } - @Override - public void mouseClicked(int mouseX, int mouseY, int button) - { - super.mouseClicked(mouseX, mouseY, button); + @Override + public void mouseClicked(int mouseX, int mouseY, int button) { + super.mouseClicked(mouseX, mouseY, button); - injectionRateField.mouseClicked(mouseX, mouseY, button); + injectionRateField.mouseClicked(mouseX, mouseY, button); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - if(button == 0) - { - if(xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) - { - SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new SimpleGuiMessage(Coord4D.get(tileEntity), 1, 10)); - } - } - } + if (button == 0) { + if (xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) { + SoundHandler.playSound("gui.button.press"); + Mekanism.packetHandler.sendToServer( + new SimpleGuiMessage(Coord4D.get(tileEntity), 1, 10) + ); + } + } + } - @Override - public void keyTyped(char c, int i) - { - if(!injectionRateField.isFocused() || i == Keyboard.KEY_ESCAPE) - { - super.keyTyped(c, i); - } + @Override + public void keyTyped(char c, int i) { + if (!injectionRateField.isFocused() || i == Keyboard.KEY_ESCAPE) { + super.keyTyped(c, i); + } - if(i == Keyboard.KEY_RETURN) - { - if(injectionRateField.isFocused()) - { - setInjection(); - } - } + if (i == Keyboard.KEY_RETURN) { + if (injectionRateField.isFocused()) { + setInjection(); + } + } - if(Character.isDigit(c) || isTextboxKey(c, i)) - { - injectionRateField.textboxKeyTyped(c, i); - } - } + if (Character.isDigit(c) || isTextboxKey(c, i)) { + injectionRateField.textboxKeyTyped(c, i); + } + } - private void setInjection() - { - if(!injectionRateField.getText().isEmpty()) - { - int toUse = Math.max(0, Integer.parseInt(injectionRateField.getText())); - toUse -= toUse%2; - - ArrayList data = new ArrayList(); - data.add(0); - data.add(toUse); + private void setInjection() { + if (!injectionRateField.getText().isEmpty()) { + int toUse = Math.max(0, Integer.parseInt(injectionRateField.getText())); + toUse -= toUse % 2; - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); + ArrayList data = new ArrayList(); + data.add(0); + data.add(toUse); - injectionRateField.setText(""); - } - } + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); - @Override - public void initGui() - { - super.initGui(); + injectionRateField.setText(""); + } + } - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; + @Override + public void initGui() { + super.initGui(); - String prevRad = injectionRateField != null ? injectionRateField.getText() : ""; + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; - injectionRateField = new GuiTextField(fontRendererObj, guiWidth + 98, guiHeight + 115, 26, 11); - injectionRateField.setMaxStringLength(2); - injectionRateField.setText(prevRad); - } + String prevRad = injectionRateField != null ? injectionRateField.getText() : ""; + + injectionRateField + = new GuiTextField(fontRendererObj, guiWidth + 98, guiHeight + 115, 26, 11); + injectionRateField.setMaxStringLength(2); + injectionRateField.setText(prevRad); + } } diff --git a/src/main/java/mekanism/generators/client/gui/GuiReactorHeat.java b/src/main/java/mekanism/generators/client/gui/GuiReactorHeat.java index 83ebe932d..b6faffe8b 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiReactorHeat.java +++ b/src/main/java/mekanism/generators/client/gui/GuiReactorHeat.java @@ -3,6 +3,8 @@ package mekanism.generators.client.gui; import java.util.ArrayList; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.energy.IStrictEnergyStorage; import mekanism.api.util.ListUtils; @@ -34,181 +36,234 @@ import net.minecraft.block.BlockStaticLiquid; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.util.IIcon; import net.minecraftforge.fluids.FluidTank; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiReactorHeat extends GuiMekanism -{ - public TileEntityReactorController tileEntity; +public class GuiReactorHeat extends GuiMekanism { + public TileEntityReactorController tileEntity; - public GuiReactorHeat(InventoryPlayer inventory, final TileEntityReactorController tentity) - { - super(new ContainerNull(inventory.player, tentity)); - tileEntity = tentity; - guiElements.add(new GuiEnergyInfo(new IInfoHandler() - { - @Override - public List getInfo() - { - return tileEntity.isFormed() ? ListUtils.asList( - LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), - LangUtils.localize("gui.producing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getReactor().getPassiveGeneration(false, true)) + "/t") : new ArrayList(); - } - }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"))); - guiElements.add(new GuiNumberGauge(new INumberInfoHandler() - { - @Override - public IIcon getIcon() - { - return BlockStaticLiquid.getLiquidIcon("lava_still"); - } + public GuiReactorHeat( + InventoryPlayer inventory, final TileEntityReactorController tentity + ) { + super(new ContainerNull(inventory.player, tentity)); + tileEntity = tentity; + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() { + return tileEntity.isFormed() + ? ListUtils.asList( + LangUtils.localize("gui.storing") + ": " + + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), + LangUtils.localize("gui.producing") + ": " + + MekanismUtils.getEnergyDisplay( + tileEntity.getReactor().getPassiveGeneration(false, true) + ) + + "/t" + ) + : new ArrayList(); + } + }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"))); + guiElements.add(new GuiNumberGauge( + new INumberInfoHandler() { + @Override + public IIcon getIcon() { + return BlockStaticLiquid.getLiquidIcon("lava_still"); + } - @Override - public double getLevel() - { - return TemperatureUnit.AMBIENT.convertToK(tileEntity.getPlasmaTemp(), true); - } + @Override + public double getLevel() { + return TemperatureUnit.AMBIENT.convertToK( + tileEntity.getPlasmaTemp(), true + ); + } - @Override - public double getMaxLevel() - { - return 5E8; - } + @Override + public double getMaxLevel() { + return 5E8; + } - @Override - public String getText(double level) - { - return "Plasma: " + MekanismUtils.getTemperatureDisplay(level, TemperatureUnit.KELVIN); - } - }, Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 7, 50)); - guiElements.add(new GuiProgress(new IProgressInfoHandler() - { - @Override - public double getProgress() - { - return tileEntity.getPlasmaTemp() > tileEntity.getCaseTemp() ? 1 : 0; - } - }, ProgressBar.SMALL_RIGHT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 27, 75)); - guiElements.add(new GuiNumberGauge(new INumberInfoHandler() - { - @Override - public IIcon getIcon() - { - return BlockStaticLiquid.getLiquidIcon("lava_still"); - } + @Override + public String getText(double level) { + return "Plasma: " + + MekanismUtils.getTemperatureDisplay( + level, TemperatureUnit.KELVIN + ); + } + }, + Type.STANDARD, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), + 7, + 50 + )); + guiElements.add(new GuiProgress( + new IProgressInfoHandler() { + @Override + public double getProgress() { + return tileEntity.getPlasmaTemp() > tileEntity.getCaseTemp() ? 1 : 0; + } + }, + ProgressBar.SMALL_RIGHT, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), + 27, + 75 + )); + guiElements.add(new GuiNumberGauge( + new INumberInfoHandler() { + @Override + public IIcon getIcon() { + return BlockStaticLiquid.getLiquidIcon("lava_still"); + } - @Override - public double getLevel() - { - return TemperatureUnit.AMBIENT.convertToK(tileEntity.getCaseTemp(), true); - } + @Override + public double getLevel() { + return TemperatureUnit.AMBIENT.convertToK( + tileEntity.getCaseTemp(), true + ); + } - @Override - public double getMaxLevel() - { - return 5E8; - } + @Override + public double getMaxLevel() { + return 5E8; + } - @Override - public String getText(double level) - { - return "Case: " + MekanismUtils.getTemperatureDisplay(level, TemperatureUnit.KELVIN); - } - }, Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 61, 50)); - guiElements.add(new GuiProgress(new IProgressInfoHandler() - { - @Override - public double getProgress() - { - return tileEntity.getCaseTemp() > 0 ? 1 : 0; - } - }, ProgressBar.SMALL_RIGHT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 81, 60)); - guiElements.add(new GuiProgress(new IProgressInfoHandler() - { - @Override - public double getProgress() - { - return (tileEntity.getCaseTemp() > 0 && tileEntity.waterTank.getFluidAmount() > 0 && tileEntity.steamTank.getFluidAmount() < tileEntity.steamTank.getCapacity()) ? 1 : 0; - } - }, ProgressBar.SMALL_RIGHT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 81, 90)); - guiElements.add(new GuiFluidGauge(new IFluidInfoHandler() - { - @Override - public FluidTank getTank() - { - return tentity.waterTank; - } - }, Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 115, 84)); - guiElements.add(new GuiFluidGauge(new IFluidInfoHandler() - { - @Override - public FluidTank getTank() - { - return tentity.steamTank; - } - }, Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 151, 84)); - guiElements.add(new GuiEnergyGauge(new IEnergyInfoHandler() - { - @Override - public IStrictEnergyStorage getEnergyStorage() - { - return tileEntity; - } - }, Type.SMALL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), 115, 46)); - guiElements.add(new GuiFuelTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"))); - guiElements.add(new GuiStatTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"))); - } + @Override + public String getText(double level) { + return "Case: " + + MekanismUtils.getTemperatureDisplay( + level, TemperatureUnit.KELVIN + ); + } + }, + Type.STANDARD, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), + 61, + 50 + )); + guiElements.add(new GuiProgress( + new IProgressInfoHandler() { + @Override + public double getProgress() { + return tileEntity.getCaseTemp() > 0 ? 1 : 0; + } + }, + ProgressBar.SMALL_RIGHT, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), + 81, + 60 + )); + guiElements.add(new GuiProgress( + new IProgressInfoHandler() { + @Override + public double getProgress() { + return (tileEntity.getCaseTemp() > 0 + && tileEntity.waterTank.getFluidAmount() > 0 + && tileEntity.steamTank.getFluidAmount() + < tileEntity.steamTank.getCapacity()) + ? 1 + : 0; + } + }, + ProgressBar.SMALL_RIGHT, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), + 81, + 90 + )); + guiElements.add(new GuiFluidGauge( + new IFluidInfoHandler() { + @Override + public FluidTank getTank() { + return tentity.waterTank; + } + }, + Type.SMALL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), + 115, + 84 + )); + guiElements.add(new GuiFluidGauge( + new IFluidInfoHandler() { + @Override + public FluidTank getTank() { + return tentity.steamTank; + } + }, + Type.SMALL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), + 151, + 84 + )); + guiElements.add(new GuiEnergyGauge( + new IEnergyInfoHandler() { + @Override + public IStrictEnergyStorage getEnergyStorage() { + return tileEntity; + } + }, + Type.SMALL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"), + 115, + 46 + )); + guiElements.add(new GuiFuelTab( + this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png") + )); + guiElements.add(new GuiStatTab( + this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png") + )); + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + super.drawGuiContainerForegroundLayer(mouseX, mouseY); - fontRendererObj.drawString(tileEntity.getInventoryName(), 46, 6, 0x404040); - } + fontRendererObj.drawString(tileEntity.getInventoryName(), 46, 6, 0x404040); + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - if(xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) - { - drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176, 0, 14, 14); - } - else { - drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176, 14, 14, 14); - } + if (xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) { + drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176, 0, 14, 14); + } else { + drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176, 14, 14, 14); + } - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } - @Override - public void mouseClicked(int mouseX, int mouseY, int button) - { - super.mouseClicked(mouseX, mouseY, button); + @Override + public void mouseClicked(int mouseX, int mouseY, int button) { + super.mouseClicked(mouseX, mouseY, button); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - if(button == 0) - { - if(xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) - { - SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new SimpleGuiMessage(Coord4D.get(tileEntity), 1, 10)); - } - } - } + if (button == 0) { + if (xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) { + SoundHandler.playSound("gui.button.press"); + Mekanism.packetHandler.sendToServer( + new SimpleGuiMessage(Coord4D.get(tileEntity), 1, 10) + ); + } + } + } } diff --git a/src/main/java/mekanism/generators/client/gui/GuiReactorLogicAdapter.java b/src/main/java/mekanism/generators/client/gui/GuiReactorLogicAdapter.java index 16c56f90b..5d9b56ada 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiReactorLogicAdapter.java +++ b/src/main/java/mekanism/generators/client/gui/GuiReactorLogicAdapter.java @@ -2,6 +2,8 @@ package mekanism.generators.client.gui; import java.util.ArrayList; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.client.gui.GuiMekanism; @@ -16,136 +18,173 @@ import mekanism.common.util.MekanismUtils.ResourceType; import mekanism.generators.common.tile.reactor.TileEntityReactorLogicAdapter; import mekanism.generators.common.tile.reactor.TileEntityReactorLogicAdapter.ReactorLogic; import net.minecraft.entity.player.InventoryPlayer; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiReactorLogicAdapter extends GuiMekanism -{ - public TileEntityReactorLogicAdapter tileEntity; - - public GuiReactorLogicAdapter(InventoryPlayer inventory, final TileEntityReactorLogicAdapter tentity) - { - super(new ContainerNull(inventory.player, tentity)); - - tileEntity = tentity; - } - - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); - - fontRendererObj.drawString(tileEntity.getInventoryName(), (xSize/2)-(fontRendererObj.getStringWidth(tileEntity.getInventoryName())/2), 6, 0x404040); - renderScaledText(LangUtils.localize("gui.coolingMeasurements") + ": " + EnumColor.RED + LangUtils.transOnOff(tileEntity.activeCooled), 36, 20, 0x404040, 117); - renderScaledText(LangUtils.localize("gui.redstoneOutputMode") + ": " + EnumColor.RED + tileEntity.logicType.getLocalizedName(), 23, 123, 0x404040, 130); - - String text = LangUtils.localize("gui.status") + ": " + EnumColor.RED + LangUtils.localize("gui." + (tileEntity.checkMode() ? "outputting" : "idle")); - fontRendererObj.drawString(text, (xSize/2)-(fontRendererObj.getStringWidth(text)/2), 136, 0x404040); - - for(ReactorLogic type : ReactorLogic.values()) - { - GL11.glPushMatrix(); - GL11.glEnable(GL11.GL_LIGHTING); - itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), type.getRenderStack(), 27, 35 + (22*type.ordinal())); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glPopMatrix(); - - fontRendererObj.drawString(EnumColor.WHITE + type.getLocalizedName(), 46, 34+(22*type.ordinal()), 0x404040); - } - - for(ReactorLogic type : ReactorLogic.values()) - { - if(xAxis >= 24 && xAxis <= 152 && yAxis >= 32+(22*type.ordinal()) && yAxis <= 32+22+(22*type.ordinal())) - { - displayTooltips(MekanismUtils.splitTooltip(type.getDescription(), null), xAxis, yAxis); - } - } - - if(xAxis >= 23 && xAxis <= 34 && yAxis >= 19 && yAxis <= 30) - { - drawCreativeTabHoveringText(LangUtils.localize("gui.toggleCooling"), xAxis, yAxis); - } - - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } +public class GuiReactorLogicAdapter extends GuiMekanism { + public TileEntityReactorLogicAdapter tileEntity; - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiReactorLogicAdapter.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); - - for(ReactorLogic type : ReactorLogic.values()) - { - MekanismRenderer.color(EnumColor.RED); - - drawTexturedModalRect(guiWidth + 24, guiHeight + 32+(22*type.ordinal()), 0, 166+(type == tileEntity.logicType ? 22 : 0), 128, 22); - - MekanismRenderer.resetColor(); - } - - if(xAxis >= 23 && xAxis <= 34 && yAxis >= 19 && yAxis <= 30) - { - drawTexturedModalRect(guiWidth + 23, guiHeight + 19, 176, 0, 11, 11); - } - else { - drawTexturedModalRect(guiWidth + 23, guiHeight + 19, 176, 11, 11, 11); - } + public GuiReactorLogicAdapter( + InventoryPlayer inventory, final TileEntityReactorLogicAdapter tentity + ) { + super(new ContainerNull(inventory.player, tentity)); - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } - - @Override - protected void mouseClicked(int mouseX, int mouseY, int button) - { - super.mouseClicked(mouseX, mouseY, button); - - if(button == 0) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); - - if(xAxis >= 23 && xAxis <= 34 && yAxis >= 19 && yAxis <= 30) - { - SoundHandler.playSound("gui.button.press"); - - ArrayList data = new ArrayList(); - data.add(0); - - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - - return; - } - - for(ReactorLogic type : ReactorLogic.values()) - { - if(xAxis >= 24 && xAxis <= 152 && yAxis >= 32+(22*type.ordinal()) && yAxis <= 32+22+(22*type.ordinal())) - { - if(type != tileEntity.logicType) - { - SoundHandler.playSound("gui.button.press"); - - ArrayList data = new ArrayList(); - data.add(1); - data.add(type.ordinal()); - - Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); - - return; - } - } - } - } - } + tileEntity = tentity; + } + + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + fontRendererObj.drawString( + tileEntity.getInventoryName(), + (xSize / 2) + - (fontRendererObj.getStringWidth(tileEntity.getInventoryName()) / 2), + 6, + 0x404040 + ); + renderScaledText( + LangUtils.localize("gui.coolingMeasurements") + ": " + EnumColor.RED + + LangUtils.transOnOff(tileEntity.activeCooled), + 36, + 20, + 0x404040, + 117 + ); + renderScaledText( + LangUtils.localize("gui.redstoneOutputMode") + ": " + EnumColor.RED + + tileEntity.logicType.getLocalizedName(), + 23, + 123, + 0x404040, + 130 + ); + + String text = LangUtils.localize("gui.status") + ": " + EnumColor.RED + + LangUtils.localize( + "gui." + (tileEntity.checkMode() ? "outputting" : "idle") + ); + fontRendererObj.drawString( + text, (xSize / 2) - (fontRendererObj.getStringWidth(text) / 2), 136, 0x404040 + ); + + for (ReactorLogic type : ReactorLogic.values()) { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_LIGHTING); + itemRender.renderItemAndEffectIntoGUI( + fontRendererObj, + mc.getTextureManager(), + type.getRenderStack(), + 27, + 35 + (22 * type.ordinal()) + ); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + + fontRendererObj.drawString( + EnumColor.WHITE + type.getLocalizedName(), + 46, + 34 + (22 * type.ordinal()), + 0x404040 + ); + } + + for (ReactorLogic type : ReactorLogic.values()) { + if (xAxis >= 24 && xAxis <= 152 && yAxis >= 32 + (22 * type.ordinal()) + && yAxis <= 32 + 22 + (22 * type.ordinal())) { + displayTooltips( + MekanismUtils.splitTooltip(type.getDescription(), null), xAxis, yAxis + ); + } + } + + if (xAxis >= 23 && xAxis <= 34 && yAxis >= 19 && yAxis <= 30) { + drawCreativeTabHoveringText( + LangUtils.localize("gui.toggleCooling"), xAxis, yAxis + ); + } + + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiReactorLogicAdapter.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + for (ReactorLogic type : ReactorLogic.values()) { + MekanismRenderer.color(EnumColor.RED); + + drawTexturedModalRect( + guiWidth + 24, + guiHeight + 32 + (22 * type.ordinal()), + 0, + 166 + (type == tileEntity.logicType ? 22 : 0), + 128, + 22 + ); + + MekanismRenderer.resetColor(); + } + + if (xAxis >= 23 && xAxis <= 34 && yAxis >= 19 && yAxis <= 30) { + drawTexturedModalRect(guiWidth + 23, guiHeight + 19, 176, 0, 11, 11); + } else { + drawTexturedModalRect(guiWidth + 23, guiHeight + 19, 176, 11, 11, 11); + } + + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } + + @Override + protected void mouseClicked(int mouseX, int mouseY, int button) { + super.mouseClicked(mouseX, mouseY, button); + + if (button == 0) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + if (xAxis >= 23 && xAxis <= 34 && yAxis >= 19 && yAxis <= 30) { + SoundHandler.playSound("gui.button.press"); + + ArrayList data = new ArrayList(); + data.add(0); + + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); + + return; + } + + for (ReactorLogic type : ReactorLogic.values()) { + if (xAxis >= 24 && xAxis <= 152 && yAxis >= 32 + (22 * type.ordinal()) + && yAxis <= 32 + 22 + (22 * type.ordinal())) { + if (type != tileEntity.logicType) { + SoundHandler.playSound("gui.button.press"); + + ArrayList data = new ArrayList(); + data.add(1); + data.add(type.ordinal()); + + Mekanism.packetHandler.sendToServer( + new TileEntityMessage(Coord4D.get(tileEntity), data) + ); + + return; + } + } + } + } + } } diff --git a/src/main/java/mekanism/generators/client/gui/GuiReactorStats.java b/src/main/java/mekanism/generators/client/gui/GuiReactorStats.java index bdd935e64..5980c598b 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiReactorStats.java +++ b/src/main/java/mekanism/generators/client/gui/GuiReactorStats.java @@ -4,6 +4,8 @@ import java.text.NumberFormat; import java.util.ArrayList; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.util.ListUtils; @@ -22,99 +24,197 @@ import mekanism.generators.client.gui.element.GuiFuelTab; import mekanism.generators.client.gui.element.GuiHeatTab; import mekanism.generators.common.tile.reactor.TileEntityReactorController; import net.minecraft.entity.player.InventoryPlayer; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiReactorStats extends GuiMekanism -{ - public TileEntityReactorController tileEntity; - public static NumberFormat nf = NumberFormat.getIntegerInstance(); +public class GuiReactorStats extends GuiMekanism { + public TileEntityReactorController tileEntity; + public static NumberFormat nf = NumberFormat.getIntegerInstance(); - public GuiReactorStats(InventoryPlayer inventory, final TileEntityReactorController tentity) - { - super(new ContainerNull(inventory.player, tentity)); - tileEntity = tentity; - guiElements.add(new GuiEnergyInfo(new IInfoHandler() - { - @Override - public List getInfo() - { - return tileEntity.isFormed() ? ListUtils.asList( - LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), - LangUtils.localize("gui.producing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getReactor().getPassiveGeneration(false, true)) + "/t") : new ArrayList(); - } - }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"))); - guiElements.add(new GuiHeatTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"))); - guiElements.add(new GuiFuelTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"))); - } + public GuiReactorStats( + InventoryPlayer inventory, final TileEntityReactorController tentity + ) { + super(new ContainerNull(inventory.player, tentity)); + tileEntity = tentity; + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() { + return tileEntity.isFormed() + ? ListUtils.asList( + LangUtils.localize("gui.storing") + ": " + + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), + LangUtils.localize("gui.producing") + ": " + + MekanismUtils.getEnergyDisplay( + tileEntity.getReactor().getPassiveGeneration(false, true) + ) + + "/t" + ) + : new ArrayList(); + } + }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png"))); + guiElements.add(new GuiHeatTab( + this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png") + )); + guiElements.add(new GuiFuelTab( + this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png") + )); + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - fontRendererObj.drawString(tileEntity.getInventoryName(), 46, 6, 0x404040); - - if(tileEntity.isFormed()) - { - fontRendererObj.drawString(EnumColor.DARK_GREEN + LangUtils.localize("gui.passive"), 6, 26, 0x404040); - fontRendererObj.drawString(LangUtils.localize("gui.minInject") + ": " + (tileEntity.getReactor().getMinInjectionRate(false)), 16, 36, 0x404040); - fontRendererObj.drawString(LangUtils.localize("gui.ignition") + ": " + (MekanismUtils.getTemperatureDisplay(tileEntity.getReactor().getIgnitionTemperature(false), TemperatureUnit.AMBIENT)), 16, 46, 0x404040); - fontRendererObj.drawString(LangUtils.localize("gui.maxPlasma") + ": " + (MekanismUtils.getTemperatureDisplay(tileEntity.getReactor().getMaxPlasmaTemperature(false), TemperatureUnit.AMBIENT)), 16, 56, 0x404040); - fontRendererObj.drawString(LangUtils.localize("gui.maxCasing") + ": " + (MekanismUtils.getTemperatureDisplay(tileEntity.getReactor().getMaxCasingTemperature(false), TemperatureUnit.AMBIENT)), 16, 66, 0x404040); - fontRendererObj.drawString(LangUtils.localize("gui.passiveGeneration") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getReactor().getPassiveGeneration(false, false))+"/t", 16, 76, 0x404040); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + fontRendererObj.drawString(tileEntity.getInventoryName(), 46, 6, 0x404040); - fontRendererObj.drawString(EnumColor.DARK_BLUE + LangUtils.localize("gui.active"), 6, 92, 0x404040); - fontRendererObj.drawString(LangUtils.localize("gui.minInject") + ": " + (tileEntity.getReactor().getMinInjectionRate(true)), 16, 102, 0x404040); - fontRendererObj.drawString(LangUtils.localize("gui.ignition") + ": " + (MekanismUtils.getTemperatureDisplay(tileEntity.getReactor().getIgnitionTemperature(true), TemperatureUnit.AMBIENT)), 16, 112, 0x404040); - fontRendererObj.drawString(LangUtils.localize("gui.maxPlasma") + ": " + (MekanismUtils.getTemperatureDisplay(tileEntity.getReactor().getMaxPlasmaTemperature(true), TemperatureUnit.AMBIENT)), 16, 122, 0x404040); - fontRendererObj.drawString(LangUtils.localize("gui.maxCasing") + ": " + (MekanismUtils.getTemperatureDisplay(tileEntity.getReactor().getMaxCasingTemperature(true), TemperatureUnit.AMBIENT)), 16, 132, 0x404040); - fontRendererObj.drawString(LangUtils.localize("gui.passiveGeneration") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getReactor().getPassiveGeneration(true, false))+"/t", 16, 142, 0x404040); - fontRendererObj.drawString(LangUtils.localize("gui.steamProduction") + ": " + nf.format(tileEntity.getReactor().getSteamPerTick(false)) + "mB/t", 16, 152, 0x404040); - } - - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } + if (tileEntity.isFormed()) { + fontRendererObj.drawString( + EnumColor.DARK_GREEN + LangUtils.localize("gui.passive"), 6, 26, 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.minInject") + ": " + + (tileEntity.getReactor().getMinInjectionRate(false)), + 16, + 36, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.ignition") + ": " + + (MekanismUtils.getTemperatureDisplay( + tileEntity.getReactor().getIgnitionTemperature(false), + TemperatureUnit.AMBIENT + )), + 16, + 46, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.maxPlasma") + ": " + + (MekanismUtils.getTemperatureDisplay( + tileEntity.getReactor().getMaxPlasmaTemperature(false), + TemperatureUnit.AMBIENT + )), + 16, + 56, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.maxCasing") + ": " + + (MekanismUtils.getTemperatureDisplay( + tileEntity.getReactor().getMaxCasingTemperature(false), + TemperatureUnit.AMBIENT + )), + 16, + 66, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.passiveGeneration") + ": " + + MekanismUtils.getEnergyDisplay( + tileEntity.getReactor().getPassiveGeneration(false, false) + ) + + "/t", + 16, + 76, + 0x404040 + ); - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + fontRendererObj.drawString( + EnumColor.DARK_BLUE + LangUtils.localize("gui.active"), 6, 92, 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.minInject") + ": " + + (tileEntity.getReactor().getMinInjectionRate(true)), + 16, + 102, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.ignition") + ": " + + (MekanismUtils.getTemperatureDisplay( + tileEntity.getReactor().getIgnitionTemperature(true), + TemperatureUnit.AMBIENT + )), + 16, + 112, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.maxPlasma") + ": " + + (MekanismUtils.getTemperatureDisplay( + tileEntity.getReactor().getMaxPlasmaTemperature(true), + TemperatureUnit.AMBIENT + )), + 16, + 122, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.maxCasing") + ": " + + (MekanismUtils.getTemperatureDisplay( + tileEntity.getReactor().getMaxCasingTemperature(true), + TemperatureUnit.AMBIENT + )), + 16, + 132, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.passiveGeneration") + ": " + + MekanismUtils.getEnergyDisplay( + tileEntity.getReactor().getPassiveGeneration(true, false) + ) + + "/t", + 16, + 142, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.steamProduction") + ": " + + nf.format(tileEntity.getReactor().getSteamPerTick(false)) + "mB/t", + 16, + 152, + 0x404040 + ); + } - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } - if(xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) - { - drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176, 0, 14, 14); - } - else { - drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176, 14, 14, 14); - } + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiTall.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - @Override - public void mouseClicked(int mouseX, int mouseY, int button) - { - super.mouseClicked(mouseX, mouseY, button); + if (xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) { + drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176, 0, 14, 14); + } else { + drawTexturedModalRect(guiWidth + 6, guiHeight + 6, 176, 14, 14, 14); + } - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } - if(button == 0) - { - if(xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) - { - SoundHandler.playSound("gui.button.press"); - Mekanism.packetHandler.sendToServer(new SimpleGuiMessage(Coord4D.get(tileEntity), 1, 10)); - } - } - }} + @Override + public void mouseClicked(int mouseX, int mouseY, int button) { + super.mouseClicked(mouseX, mouseY, button); + + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + if (button == 0) { + if (xAxis >= 6 && xAxis <= 20 && yAxis >= 6 && yAxis <= 20) { + SoundHandler.playSound("gui.button.press"); + Mekanism.packetHandler.sendToServer( + new SimpleGuiMessage(Coord4D.get(tileEntity), 1, 10) + ); + } + } + } +} diff --git a/src/main/java/mekanism/generators/client/gui/GuiSolarGenerator.java b/src/main/java/mekanism/generators/client/gui/GuiSolarGenerator.java index 13b30719a..3c3ea9fa7 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiSolarGenerator.java +++ b/src/main/java/mekanism/generators/client/gui/GuiSolarGenerator.java @@ -2,6 +2,8 @@ package mekanism.generators.client.gui; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.util.ListUtils; import mekanism.client.gui.GuiMekanism; import mekanism.client.gui.element.GuiElement.IInfoHandler; @@ -18,63 +20,109 @@ import mekanism.common.util.MekanismUtils.ResourceType; import mekanism.generators.common.inventory.container.ContainerSolarGenerator; import mekanism.generators.common.tile.TileEntitySolarGenerator; import net.minecraft.entity.player.InventoryPlayer; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiSolarGenerator extends GuiMekanism -{ - public TileEntitySolarGenerator tileEntity; +public class GuiSolarGenerator extends GuiMekanism { + public TileEntitySolarGenerator tileEntity; - public GuiSolarGenerator(InventoryPlayer inventory, TileEntitySolarGenerator tentity) - { - super(new ContainerSolarGenerator(inventory, tentity)); - tileEntity = tentity; - guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiSolarGenerator.png"))); - guiElements.add(new GuiSecurityTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiSolarGenerator.png"))); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() - { - @Override - public List getInfo() - { - return ListUtils.asList( - LangUtils.localize("gui.producing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.isActive ? tileEntity.getProduction() : 0) + "/t", - LangUtils.localize("gui.maxOutput") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t"); - } - }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiSolarGenerator.png"))); - guiElements.add(new GuiPowerBar(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiSolarGenerator.png"), 164, 15)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiSolarGenerator.png"), 142, 34).with(SlotOverlay.POWER)); - } + public GuiSolarGenerator( + InventoryPlayer inventory, TileEntitySolarGenerator tentity + ) { + super(new ContainerSolarGenerator(inventory, tentity)); + tileEntity = tentity; + guiElements.add(new GuiRedstoneControl( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiSolarGenerator.png") + )); + guiElements.add(new GuiSecurityTab( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiSolarGenerator.png") + )); + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() { + return ListUtils.asList( + LangUtils.localize("gui.producing") + ": " + + MekanismUtils.getEnergyDisplay( + tileEntity.isActive ? tileEntity.getProduction() : 0 + ) + + "/t", + LangUtils.localize("gui.maxOutput") + ": " + + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t" + ); + } + }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiSolarGenerator.png"))); + guiElements.add(new GuiPowerBar( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiSolarGenerator.png"), + 164, + 15 + )); + guiElements.add( + new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiSolarGenerator.png"), + 142, + 34 + ) + .with(SlotOverlay.POWER) + ); + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + super.drawGuiContainerForegroundLayer(mouseX, mouseY); - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); - fontRendererObj.drawString(tileEntity.getInventoryName(), !tileEntity.fullName.contains("Advanced") ? 45 : 30, 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); - fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00); - fontRendererObj.drawString(LangUtils.localize("gui.solarGenerator.sun") + ": " + tileEntity.seesSun, 51, 35, 0x00CD00); - fontRendererObj.drawString(LangUtils.localize("gui.out") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t", 51, 44, 0x00CD00); - } + fontRendererObj.drawString( + tileEntity.getInventoryName(), + !tileEntity.fullName.contains("Advanced") ? 45 : 30, + 6, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040 + ); + fontRendererObj.drawString( + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.solarGenerator.sun") + ": " + tileEntity.seesSun, + 51, + 35, + 0x00CD00 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.out") + ": " + + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t", + 51, + 44, + 0x00CD00 + ); + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiSolarGenerator.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiSolarGenerator.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - drawTexturedModalRect(guiWidth + 20, guiHeight + 37, 176, (tileEntity.seesSun ? 52 : 64), 12, 12); + drawTexturedModalRect( + guiWidth + 20, guiHeight + 37, 176, (tileEntity.seesSun ? 52 : 64), 12, 12 + ); - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } } diff --git a/src/main/java/mekanism/generators/client/gui/GuiTurbineStats.java b/src/main/java/mekanism/generators/client/gui/GuiTurbineStats.java index d77efc545..3b2a2bda5 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiTurbineStats.java +++ b/src/main/java/mekanism/generators/client/gui/GuiTurbineStats.java @@ -2,6 +2,8 @@ package mekanism.generators.client.gui; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.EnumColor; import mekanism.api.MekanismConfig.general; import mekanism.api.MekanismConfig.generators; @@ -18,84 +20,153 @@ import mekanism.generators.client.gui.element.GuiTurbineTab.TurbineTab; import mekanism.generators.common.content.turbine.TurbineUpdateProtocol; import mekanism.generators.common.tile.turbine.TileEntityTurbineCasing; import net.minecraft.entity.player.InventoryPlayer; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiTurbineStats extends GuiMekanism -{ - public TileEntityTurbineCasing tileEntity; +public class GuiTurbineStats extends GuiMekanism { + public TileEntityTurbineCasing tileEntity; - public GuiTurbineStats(InventoryPlayer inventory, TileEntityTurbineCasing tentity) - { - super(tentity, new ContainerNull(inventory.player, tentity)); - tileEntity = tentity; - guiElements.add(new GuiTurbineTab(this, tileEntity, TurbineTab.MAIN, 6, MekanismUtils.getResource(ResourceType.GUI, "GuiNull.png"))); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() - { - @Override - public List getInfo() - { - double energyMultiplier = (general.maxEnergyPerSteam/TurbineUpdateProtocol.MAX_BLADES)*Math.min(tileEntity.structure.blades, tileEntity.structure.coils*generators.turbineBladesPerCoil); - - return ListUtils.asList( - LangUtils.localize("gui.storing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), - LangUtils.localize("gui.producing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.structure.clientFlow*energyMultiplier) + "/t"); - } - }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiNull.png"))); - } - - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - int xAxis = (mouseX - (width - xSize) / 2); - int yAxis = (mouseY - (height - ySize) / 2); + public GuiTurbineStats(InventoryPlayer inventory, TileEntityTurbineCasing tentity) { + super(tentity, new ContainerNull(inventory.player, tentity)); + tileEntity = tentity; + guiElements.add(new GuiTurbineTab( + this, + tileEntity, + TurbineTab.MAIN, + 6, + MekanismUtils.getResource(ResourceType.GUI, "GuiNull.png") + )); + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() { + double energyMultiplier + = (general.maxEnergyPerSteam / TurbineUpdateProtocol.MAX_BLADES) + * Math.min( + tileEntity.structure.blades, + tileEntity.structure.coils * generators.turbineBladesPerCoil + ); - String stats = LangUtils.localize("gui.turbineStats"); - String limiting = EnumColor.DARK_RED + " (" + LangUtils.localize("gui.limiting") + ")"; - - fontRendererObj.drawString(stats, (xSize/2)-(fontRendererObj.getStringWidth(stats)/2), 6, 0x404040); - - fontRendererObj.drawString(LangUtils.localize("gui.tankVolume") + ": " + tileEntity.structure.lowerVolume, 8, 26, 0x404040); - - boolean dispersersLimiting = tileEntity.structure.lowerVolume*tileEntity.structure.clientDispersers*generators.turbineDisperserGasFlow < - tileEntity.structure.vents*generators.turbineVentGasFlow; - boolean ventsLimiting = tileEntity.structure.lowerVolume*tileEntity.structure.clientDispersers*generators.turbineDisperserGasFlow > - tileEntity.structure.vents*generators.turbineVentGasFlow; - - fontRendererObj.drawString(LangUtils.localize("gui.steamFlow"), 8, 40, 0x797979); - fontRendererObj.drawString(LangUtils.localize("gui.dispersers") + ": " + tileEntity.structure.clientDispersers + (dispersersLimiting ? limiting : ""), 14, 49, 0x404040); - fontRendererObj.drawString(LangUtils.localize("gui.vents") + ": " + tileEntity.structure.vents + (ventsLimiting ? limiting : ""), 14, 58, 0x404040); - - boolean bladesLimiting = tileEntity.structure.coils*4 > tileEntity.structure.blades; - boolean coilsLimiting = tileEntity.structure.coils*4 < tileEntity.structure.blades; - - fontRendererObj.drawString(LangUtils.localize("gui.production"), 8, 72, 0x797979); - fontRendererObj.drawString(LangUtils.localize("gui.blades") + ": " + tileEntity.structure.blades + (bladesLimiting ? limiting : ""), 14, 81, 0x404040); - fontRendererObj.drawString(LangUtils.localize("gui.coils") + ": " + tileEntity.structure.coils + (coilsLimiting ? limiting : ""), 14, 90, 0x404040); - - double energyMultiplier = (general.maxEnergyPerSteam/TurbineUpdateProtocol.MAX_BLADES)*Math.min(tileEntity.structure.blades, tileEntity.structure.coils*generators.turbineBladesPerCoil); - double rate = tileEntity.structure.lowerVolume*(tileEntity.structure.clientDispersers*generators.turbineDisperserGasFlow); - rate = Math.min(rate, tileEntity.structure.vents*generators.turbineVentGasFlow); - - fontRendererObj.drawString(LangUtils.localize("gui.maxProduction") + ": " + MekanismUtils.getEnergyDisplay(rate*energyMultiplier), 8, 104, 0x404040); - fontRendererObj.drawString(LangUtils.localize("gui.maxWaterOutput") + ": " + tileEntity.structure.condensers*generators.condenserRate + " mB/t", 8, 113, 0x404040); - - super.drawGuiContainerForegroundLayer(mouseX, mouseY); - } - - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiNull.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } + return ListUtils.asList( + LangUtils.localize("gui.storing") + ": " + + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), + LangUtils.localize("gui.producing") + ": " + + MekanismUtils.getEnergyDisplay( + tileEntity.structure.clientFlow * energyMultiplier + ) + + "/t" + ); + } + }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiNull.png"))); + } + + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + String stats = LangUtils.localize("gui.turbineStats"); + String limiting + = EnumColor.DARK_RED + " (" + LangUtils.localize("gui.limiting") + ")"; + + fontRendererObj.drawString( + stats, (xSize / 2) - (fontRendererObj.getStringWidth(stats) / 2), 6, 0x404040 + ); + + fontRendererObj.drawString( + LangUtils.localize("gui.tankVolume") + ": " + + tileEntity.structure.lowerVolume, + 8, + 26, + 0x404040 + ); + + boolean dispersersLimiting = tileEntity.structure.lowerVolume + * tileEntity.structure.clientDispersers + * generators.turbineDisperserGasFlow + < tileEntity.structure.vents * generators.turbineVentGasFlow; + boolean ventsLimiting = tileEntity.structure.lowerVolume + * tileEntity.structure.clientDispersers + * generators.turbineDisperserGasFlow + > tileEntity.structure.vents * generators.turbineVentGasFlow; + + fontRendererObj.drawString(LangUtils.localize("gui.steamFlow"), 8, 40, 0x797979); + fontRendererObj.drawString( + LangUtils.localize("gui.dispersers") + ": " + + tileEntity.structure.clientDispersers + + (dispersersLimiting ? limiting : ""), + 14, + 49, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.vents") + ": " + tileEntity.structure.vents + + (ventsLimiting ? limiting : ""), + 14, + 58, + 0x404040 + ); + + boolean bladesLimiting + = tileEntity.structure.coils * 4 > tileEntity.structure.blades; + boolean coilsLimiting + = tileEntity.structure.coils * 4 < tileEntity.structure.blades; + + fontRendererObj.drawString(LangUtils.localize("gui.production"), 8, 72, 0x797979); + fontRendererObj.drawString( + LangUtils.localize("gui.blades") + ": " + tileEntity.structure.blades + + (bladesLimiting ? limiting : ""), + 14, + 81, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.coils") + ": " + tileEntity.structure.coils + + (coilsLimiting ? limiting : ""), + 14, + 90, + 0x404040 + ); + + double energyMultiplier + = (general.maxEnergyPerSteam / TurbineUpdateProtocol.MAX_BLADES) + * Math.min( + tileEntity.structure.blades, + tileEntity.structure.coils * generators.turbineBladesPerCoil + ); + double rate = tileEntity.structure.lowerVolume + * (tileEntity.structure.clientDispersers * generators.turbineDisperserGasFlow + ); + rate = Math.min(rate, tileEntity.structure.vents * generators.turbineVentGasFlow); + + fontRendererObj.drawString( + LangUtils.localize("gui.maxProduction") + ": " + + MekanismUtils.getEnergyDisplay(rate * energyMultiplier), + 8, + 104, + 0x404040 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.maxWaterOutput") + ": " + + tileEntity.structure.condensers * generators.condenserRate + " mB/t", + 8, + 113, + 0x404040 + ); + + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiNull.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } } diff --git a/src/main/java/mekanism/generators/client/gui/GuiWindGenerator.java b/src/main/java/mekanism/generators/client/gui/GuiWindGenerator.java index 07d21b127..7da85ff2b 100644 --- a/src/main/java/mekanism/generators/client/gui/GuiWindGenerator.java +++ b/src/main/java/mekanism/generators/client/gui/GuiWindGenerator.java @@ -3,6 +3,8 @@ package mekanism.generators.client.gui; import java.text.DecimalFormat; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.EnumColor; import mekanism.api.MekanismConfig.generators; import mekanism.api.util.ListUtils; @@ -21,70 +23,118 @@ import mekanism.common.util.MekanismUtils.ResourceType; import mekanism.generators.common.inventory.container.ContainerWindGenerator; import mekanism.generators.common.tile.TileEntityWindGenerator; import net.minecraft.entity.player.InventoryPlayer; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GuiWindGenerator extends GuiMekanism -{ - public TileEntityWindGenerator tileEntity; +public class GuiWindGenerator extends GuiMekanism { + public TileEntityWindGenerator tileEntity; - private DecimalFormat powerFormat = new DecimalFormat("0.##"); + private DecimalFormat powerFormat = new DecimalFormat("0.##"); - public GuiWindGenerator(InventoryPlayer inventory, TileEntityWindGenerator tentity) - { - super(new ContainerWindGenerator(inventory, tentity)); - tileEntity = tentity; - guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiWindTurbine.png"))); - guiElements.add(new GuiSecurityTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiWindTurbine.png"))); - guiElements.add(new GuiEnergyInfo(new IInfoHandler() - { - @Override - public List getInfo() - { - return ListUtils.asList( - LangUtils.localize("gui.producing") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.isActive ? generators.windGenerationMin*tileEntity.currentMultiplier : 0) + "/t", - LangUtils.localize("gui.maxOutput") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t"); - } - }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiWindTurbine.png"))); - guiElements.add(new GuiPowerBar(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiWindTurbine.png"), 164, 15)); - guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiWindTurbine.png"), 142, 34).with(SlotOverlay.POWER)); - } + public GuiWindGenerator(InventoryPlayer inventory, TileEntityWindGenerator tentity) { + super(new ContainerWindGenerator(inventory, tentity)); + tileEntity = tentity; + guiElements.add(new GuiRedstoneControl( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiWindTurbine.png") + )); + guiElements.add(new GuiSecurityTab( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiWindTurbine.png") + )); + guiElements.add(new GuiEnergyInfo(new IInfoHandler() { + @Override + public List getInfo() { + return ListUtils.asList( + LangUtils.localize("gui.producing") + ": " + + MekanismUtils.getEnergyDisplay( + tileEntity.isActive ? generators.windGenerationMin + * tileEntity.currentMultiplier + : 0 + ) + + "/t", + LangUtils.localize("gui.maxOutput") + ": " + + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t" + ); + } + }, this, MekanismUtils.getResource(ResourceType.GUI, "GuiWindTurbine.png"))); + guiElements.add(new GuiPowerBar( + this, + tileEntity, + MekanismUtils.getResource(ResourceType.GUI, "GuiWindTurbine.png"), + 164, + 15 + )); + guiElements.add( + new GuiSlot( + SlotType.NORMAL, + this, + MekanismUtils.getResource(ResourceType.GUI, "GuiWindTurbine.png"), + 142, + 34 + ) + .with(SlotOverlay.POWER) + ); + } - @Override - protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) - { - super.drawGuiContainerForegroundLayer(mouseX, mouseY); + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { + super.drawGuiContainerForegroundLayer(mouseX, mouseY); - fontRendererObj.drawString(tileEntity.getInventoryName(), 45, 6, 0x404040); - fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); - fontRendererObj.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00); - fontRendererObj.drawString(LangUtils.localize("gui.power") + ": " + powerFormat.format(MekanismUtils.convertToDisplay(generators.windGenerationMin*tileEntity.currentMultiplier)), 51, 35, 0x00CD00); - fontRendererObj.drawString(LangUtils.localize("gui.out") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t", 51, 44, 0x00CD00); + fontRendererObj.drawString(tileEntity.getInventoryName(), 45, 6, 0x404040); + fontRendererObj.drawString( + LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040 + ); + fontRendererObj.drawString( + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.power") + ": " + + powerFormat.format(MekanismUtils.convertToDisplay( + generators.windGenerationMin * tileEntity.currentMultiplier + )), + 51, + 35, + 0x00CD00 + ); + fontRendererObj.drawString( + LangUtils.localize("gui.out") + ": " + + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t", + 51, + 44, + 0x00CD00 + ); - int size = 44; + int size = 44; - if(!tileEntity.getActive()) - { - size += 9; - fontRendererObj.drawString(EnumColor.DARK_RED + LangUtils.localize("gui.skyBlocked"), 51, size, 0x00CD00); - } - } + if (!tileEntity.getActive()) { + size += 9; + fontRendererObj.drawString( + EnumColor.DARK_RED + LangUtils.localize("gui.skyBlocked"), + 51, + size, + 0x00CD00 + ); + } + } - @Override - protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) - { - mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiWindTurbine.png")); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - int guiWidth = (width - xSize) / 2; - int guiHeight = (height - ySize) / 2; - drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + @Override + protected void + drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) { + mc.renderEngine.bindTexture( + MekanismUtils.getResource(ResourceType.GUI, "GuiWindTurbine.png") + ); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); - drawTexturedModalRect(guiWidth + 20, guiHeight + 37, 176, (tileEntity.getActive() ? 52 : 64), 12, 12); + drawTexturedModalRect( + guiWidth + 20, guiHeight + 37, 176, (tileEntity.getActive() ? 52 : 64), 12, 12 + ); - super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); - } + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + } } diff --git a/src/main/java/mekanism/generators/client/gui/element/GuiFuelTab.java b/src/main/java/mekanism/generators/client/gui/element/GuiFuelTab.java index 81e5232bd..9389c6359 100644 --- a/src/main/java/mekanism/generators/client/gui/element/GuiFuelTab.java +++ b/src/main/java/mekanism/generators/client/gui/element/GuiFuelTab.java @@ -1,5 +1,8 @@ package mekanism.generators.client.gui.element; +import codechicken.lib.vec.Rectangle4i; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.client.gui.IGuiWrapper; import mekanism.client.gui.element.GuiElement; @@ -11,72 +14,64 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; -import codechicken.lib.vec.Rectangle4i; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiFuelTab extends GuiElement -{ - TileEntity tileEntity; +public class GuiFuelTab extends GuiElement { + TileEntity tileEntity; - public GuiFuelTab(IGuiWrapper gui, TileEntity tile, ResourceLocation def) - { - super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiFuelTab.png"), gui, def); + public GuiFuelTab(IGuiWrapper gui, TileEntity tile, ResourceLocation def) { + super( + MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiFuelTab.png"), + gui, + def + ); - tileEntity = tile; - } + tileEntity = tile; + } - @Override - public Rectangle4i getBounds(int guiWidth, int guiHeight) - { - return new Rectangle4i(guiWidth - 26, guiHeight + 34, 26, 26); - } + @Override + public Rectangle4i getBounds(int guiWidth, int guiHeight) { + return new Rectangle4i(guiWidth - 26, guiHeight + 34, 26, 26); + } - @Override - public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) - { - mc.renderEngine.bindTexture(RESOURCE); + @Override + public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) { + mc.renderEngine.bindTexture(RESOURCE); - guiObj.drawTexturedRect(guiWidth - 26, guiHeight + 34, 0, 0, 26, 26); + guiObj.drawTexturedRect(guiWidth - 26, guiHeight + 34, 0, 0, 26, 26); - if(xAxis >= -21 && xAxis <= -3 && yAxis >= 38 && yAxis <= 56) - { - guiObj.drawTexturedRect(guiWidth - 21, guiHeight + 38, 26, 0, 18, 18); - } - else { - guiObj.drawTexturedRect(guiWidth - 21, guiHeight + 38, 26, 18, 18, 18); - } + if (xAxis >= -21 && xAxis <= -3 && yAxis >= 38 && yAxis <= 56) { + guiObj.drawTexturedRect(guiWidth - 21, guiHeight + 38, 26, 0, 18, 18); + } else { + guiObj.drawTexturedRect(guiWidth - 21, guiHeight + 38, 26, 18, 18, 18); + } - mc.renderEngine.bindTexture(defaultLocation); - } + mc.renderEngine.bindTexture(defaultLocation); + } - @Override - public void renderForeground(int xAxis, int yAxis) - { - mc.renderEngine.bindTexture(RESOURCE); + @Override + public void renderForeground(int xAxis, int yAxis) { + mc.renderEngine.bindTexture(RESOURCE); - if(xAxis >= -21 && xAxis <= -3 && yAxis >= 38 && yAxis <= 56) - { - displayTooltip(LangUtils.localize("gui.fuel"), xAxis, yAxis); - } + if (xAxis >= -21 && xAxis <= -3 && yAxis >= 38 && yAxis <= 56) { + displayTooltip(LangUtils.localize("gui.fuel"), xAxis, yAxis); + } - mc.renderEngine.bindTexture(defaultLocation); - } + mc.renderEngine.bindTexture(defaultLocation); + } - @Override - public void preMouseClicked(int xAxis, int yAxis, int button) {} + @Override + public void preMouseClicked(int xAxis, int yAxis, int button) {} - @Override - public void mouseClicked(int xAxis, int yAxis, int button) - { - if(button == 0) - { - if(xAxis >= -21 && xAxis <= -3 && yAxis >= 38 && yAxis <= 56) - { - Mekanism.packetHandler.sendToServer(new SimpleGuiMessage(Coord4D.get(tileEntity), 1, 12)); - SoundHandler.playSound("gui.button.press"); - } - } - } + @Override + public void mouseClicked(int xAxis, int yAxis, int button) { + if (button == 0) { + if (xAxis >= -21 && xAxis <= -3 && yAxis >= 38 && yAxis <= 56) { + Mekanism.packetHandler.sendToServer( + new SimpleGuiMessage(Coord4D.get(tileEntity), 1, 12) + ); + SoundHandler.playSound("gui.button.press"); + } + } + } } diff --git a/src/main/java/mekanism/generators/client/gui/element/GuiHeatTab.java b/src/main/java/mekanism/generators/client/gui/element/GuiHeatTab.java index a0de61479..fd5734d54 100644 --- a/src/main/java/mekanism/generators/client/gui/element/GuiHeatTab.java +++ b/src/main/java/mekanism/generators/client/gui/element/GuiHeatTab.java @@ -1,5 +1,8 @@ package mekanism.generators.client.gui.element; +import codechicken.lib.vec.Rectangle4i; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.client.gui.IGuiWrapper; import mekanism.client.gui.element.GuiElement; @@ -11,72 +14,64 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; -import codechicken.lib.vec.Rectangle4i; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiHeatTab extends GuiElement -{ - TileEntity tileEntity; +public class GuiHeatTab extends GuiElement { + TileEntity tileEntity; - public GuiHeatTab(IGuiWrapper gui, TileEntity tile, ResourceLocation def) - { - super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiHeatTab.png"), gui, def); + public GuiHeatTab(IGuiWrapper gui, TileEntity tile, ResourceLocation def) { + super( + MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiHeatTab.png"), + gui, + def + ); - tileEntity = tile; - } + tileEntity = tile; + } - @Override - public Rectangle4i getBounds(int guiWidth, int guiHeight) - { - return new Rectangle4i(guiWidth - 26, guiHeight + 6, 26, 26); - } + @Override + public Rectangle4i getBounds(int guiWidth, int guiHeight) { + return new Rectangle4i(guiWidth - 26, guiHeight + 6, 26, 26); + } - @Override - public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) - { - mc.renderEngine.bindTexture(RESOURCE); + @Override + public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) { + mc.renderEngine.bindTexture(RESOURCE); - guiObj.drawTexturedRect(guiWidth - 26, guiHeight + 6, 0, 0, 26, 26); + guiObj.drawTexturedRect(guiWidth - 26, guiHeight + 6, 0, 0, 26, 26); - if(xAxis >= -21 && xAxis <= -3 && yAxis >= 10 && yAxis <= 28) - { - guiObj.drawTexturedRect(guiWidth - 21, guiHeight + 10, 26, 0, 18, 18); - } - else { - guiObj.drawTexturedRect(guiWidth - 21, guiHeight + 10, 26, 18, 18, 18); - } + if (xAxis >= -21 && xAxis <= -3 && yAxis >= 10 && yAxis <= 28) { + guiObj.drawTexturedRect(guiWidth - 21, guiHeight + 10, 26, 0, 18, 18); + } else { + guiObj.drawTexturedRect(guiWidth - 21, guiHeight + 10, 26, 18, 18, 18); + } - mc.renderEngine.bindTexture(defaultLocation); - } + mc.renderEngine.bindTexture(defaultLocation); + } - @Override - public void renderForeground(int xAxis, int yAxis) - { - mc.renderEngine.bindTexture(RESOURCE); + @Override + public void renderForeground(int xAxis, int yAxis) { + mc.renderEngine.bindTexture(RESOURCE); - if(xAxis >= -21 && xAxis <= -3 && yAxis >= 10 && yAxis <= 28) - { - displayTooltip(LangUtils.localize("gui.heat"), xAxis, yAxis); - } + if (xAxis >= -21 && xAxis <= -3 && yAxis >= 10 && yAxis <= 28) { + displayTooltip(LangUtils.localize("gui.heat"), xAxis, yAxis); + } - mc.renderEngine.bindTexture(defaultLocation); - } + mc.renderEngine.bindTexture(defaultLocation); + } - @Override - public void preMouseClicked(int xAxis, int yAxis, int button) {} + @Override + public void preMouseClicked(int xAxis, int yAxis, int button) {} - @Override - public void mouseClicked(int xAxis, int yAxis, int button) - { - if(button == 0) - { - if(xAxis >= -21 && xAxis <= -3 && yAxis >= 10 && yAxis <= 28) - { - Mekanism.packetHandler.sendToServer(new SimpleGuiMessage(Coord4D.get(tileEntity), 1, 11)); - SoundHandler.playSound("gui.button.press"); - } - } - } + @Override + public void mouseClicked(int xAxis, int yAxis, int button) { + if (button == 0) { + if (xAxis >= -21 && xAxis <= -3 && yAxis >= 10 && yAxis <= 28) { + Mekanism.packetHandler.sendToServer( + new SimpleGuiMessage(Coord4D.get(tileEntity), 1, 11) + ); + SoundHandler.playSound("gui.button.press"); + } + } + } } diff --git a/src/main/java/mekanism/generators/client/gui/element/GuiStatTab.java b/src/main/java/mekanism/generators/client/gui/element/GuiStatTab.java index e3c9784e9..c80f37d54 100644 --- a/src/main/java/mekanism/generators/client/gui/element/GuiStatTab.java +++ b/src/main/java/mekanism/generators/client/gui/element/GuiStatTab.java @@ -1,5 +1,8 @@ package mekanism.generators.client.gui.element; +import codechicken.lib.vec.Rectangle4i; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.client.gui.IGuiWrapper; import mekanism.client.gui.element.GuiElement; @@ -11,72 +14,64 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; -import codechicken.lib.vec.Rectangle4i; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiStatTab extends GuiElement -{ - TileEntity tileEntity; +public class GuiStatTab extends GuiElement { + TileEntity tileEntity; - public GuiStatTab(IGuiWrapper gui, TileEntity tile, ResourceLocation def) - { - super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiStatsTab.png"), gui, def); + public GuiStatTab(IGuiWrapper gui, TileEntity tile, ResourceLocation def) { + super( + MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiStatsTab.png"), + gui, + def + ); - tileEntity = tile; - } + tileEntity = tile; + } - @Override - public Rectangle4i getBounds(int guiWidth, int guiHeight) - { - return new Rectangle4i(guiWidth - 26, guiHeight + 62, 26, 26); - } + @Override + public Rectangle4i getBounds(int guiWidth, int guiHeight) { + return new Rectangle4i(guiWidth - 26, guiHeight + 62, 26, 26); + } - @Override - public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) - { - mc.renderEngine.bindTexture(RESOURCE); + @Override + public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) { + mc.renderEngine.bindTexture(RESOURCE); - guiObj.drawTexturedRect(guiWidth - 26, guiHeight + 62, 0, 0, 26, 26); + guiObj.drawTexturedRect(guiWidth - 26, guiHeight + 62, 0, 0, 26, 26); - if(xAxis >= -21 && xAxis <= -3 && yAxis >= 66 && yAxis <= 84) - { - guiObj.drawTexturedRect(guiWidth - 21, guiHeight + 66, 26, 0, 18, 18); - } - else { - guiObj.drawTexturedRect(guiWidth - 21, guiHeight + 66, 26, 18, 18, 18); - } + if (xAxis >= -21 && xAxis <= -3 && yAxis >= 66 && yAxis <= 84) { + guiObj.drawTexturedRect(guiWidth - 21, guiHeight + 66, 26, 0, 18, 18); + } else { + guiObj.drawTexturedRect(guiWidth - 21, guiHeight + 66, 26, 18, 18, 18); + } - mc.renderEngine.bindTexture(defaultLocation); - } + mc.renderEngine.bindTexture(defaultLocation); + } - @Override - public void renderForeground(int xAxis, int yAxis) - { - mc.renderEngine.bindTexture(RESOURCE); + @Override + public void renderForeground(int xAxis, int yAxis) { + mc.renderEngine.bindTexture(RESOURCE); - if(xAxis >= -21 && xAxis <= -3 && yAxis >= 66 && yAxis <= 84) - { - displayTooltip(LangUtils.localize("gui.stats"), xAxis, yAxis); - } + if (xAxis >= -21 && xAxis <= -3 && yAxis >= 66 && yAxis <= 84) { + displayTooltip(LangUtils.localize("gui.stats"), xAxis, yAxis); + } - mc.renderEngine.bindTexture(defaultLocation); - } + mc.renderEngine.bindTexture(defaultLocation); + } - @Override - public void preMouseClicked(int xAxis, int yAxis, int button) {} + @Override + public void preMouseClicked(int xAxis, int yAxis, int button) {} - @Override - public void mouseClicked(int xAxis, int yAxis, int button) - { - if(button == 0) - { - if(xAxis >= -21 && xAxis <= -3 && yAxis >= 66 && yAxis <= 84) - { - Mekanism.packetHandler.sendToServer(new SimpleGuiMessage(Coord4D.get(tileEntity), 1, 13)); - SoundHandler.playSound("gui.button.press"); - } - } - } + @Override + public void mouseClicked(int xAxis, int yAxis, int button) { + if (button == 0) { + if (xAxis >= -21 && xAxis <= -3 && yAxis >= 66 && yAxis <= 84) { + Mekanism.packetHandler.sendToServer( + new SimpleGuiMessage(Coord4D.get(tileEntity), 1, 13) + ); + SoundHandler.playSound("gui.button.press"); + } + } + } } diff --git a/src/main/java/mekanism/generators/client/gui/element/GuiTurbineTab.java b/src/main/java/mekanism/generators/client/gui/element/GuiTurbineTab.java index 22584b8aa..ed813162e 100644 --- a/src/main/java/mekanism/generators/client/gui/element/GuiTurbineTab.java +++ b/src/main/java/mekanism/generators/client/gui/element/GuiTurbineTab.java @@ -1,5 +1,8 @@ package mekanism.generators.client.gui.element; +import codechicken.lib.vec.Rectangle4i; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.client.gui.IGuiWrapper; import mekanism.client.gui.element.GuiBoilerTab.BoilerTab; @@ -12,108 +15,93 @@ import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; -import codechicken.lib.vec.Rectangle4i; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) -public class GuiTurbineTab extends GuiElement -{ - private TileEntity tileEntity; - private TurbineTab tabType; - private int yPos; +public class GuiTurbineTab extends GuiElement { + private TileEntity tileEntity; + private TurbineTab tabType; + private int yPos; - public GuiTurbineTab(IGuiWrapper gui, TileEntity tile, TurbineTab type, int y, ResourceLocation def) - { - super(type.getResource(), gui, def); + public GuiTurbineTab( + IGuiWrapper gui, TileEntity tile, TurbineTab type, int y, ResourceLocation def + ) { + super(type.getResource(), gui, def); - tileEntity = tile; - tabType = type; - yPos = y; - } + tileEntity = tile; + tabType = type; + yPos = y; + } - @Override - public Rectangle4i getBounds(int guiWidth, int guiHeight) - { - return new Rectangle4i(guiWidth - 26, guiHeight + yPos, 26, 26); - } + @Override + public Rectangle4i getBounds(int guiWidth, int guiHeight) { + return new Rectangle4i(guiWidth - 26, guiHeight + yPos, 26, 26); + } - @Override - public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) - { - mc.renderEngine.bindTexture(RESOURCE); + @Override + public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) { + mc.renderEngine.bindTexture(RESOURCE); - guiObj.drawTexturedRect(guiWidth - 26, guiHeight + yPos, 0, 0, 26, 26); + guiObj.drawTexturedRect(guiWidth - 26, guiHeight + yPos, 0, 0, 26, 26); - if(xAxis >= -21 && xAxis <= -3 && yAxis >= yPos+4 && yAxis <= yPos+22) - { - guiObj.drawTexturedRect(guiWidth - 21, guiHeight + yPos+4, 26, 0, 18, 18); - } - else { - guiObj.drawTexturedRect(guiWidth - 21, guiHeight + yPos+4, 26, 18, 18, 18); - } + if (xAxis >= -21 && xAxis <= -3 && yAxis >= yPos + 4 && yAxis <= yPos + 22) { + guiObj.drawTexturedRect(guiWidth - 21, guiHeight + yPos + 4, 26, 0, 18, 18); + } else { + guiObj.drawTexturedRect(guiWidth - 21, guiHeight + yPos + 4, 26, 18, 18, 18); + } - mc.renderEngine.bindTexture(defaultLocation); - } + mc.renderEngine.bindTexture(defaultLocation); + } - @Override - public void renderForeground(int xAxis, int yAxis) - { - mc.renderEngine.bindTexture(RESOURCE); + @Override + public void renderForeground(int xAxis, int yAxis) { + mc.renderEngine.bindTexture(RESOURCE); - if(xAxis >= -21 && xAxis <= -3 && yAxis >= yPos+4 && yAxis <= yPos+22) - { - displayTooltip(tabType.getDesc(), xAxis, yAxis); - } + if (xAxis >= -21 && xAxis <= -3 && yAxis >= yPos + 4 && yAxis <= yPos + 22) { + displayTooltip(tabType.getDesc(), xAxis, yAxis); + } - mc.renderEngine.bindTexture(defaultLocation); - } + mc.renderEngine.bindTexture(defaultLocation); + } - @Override - public void preMouseClicked(int xAxis, int yAxis, int button) {} + @Override + public void preMouseClicked(int xAxis, int yAxis, int button) {} - @Override - public void mouseClicked(int xAxis, int yAxis, int button) - { - if(button == 0) - { - if(xAxis >= -21 && xAxis <= -3 && yAxis >= yPos+4 && yAxis <= yPos+22) - { - tabType.openGui(tileEntity); - SoundHandler.playSound("gui.button.press"); - } - } - } - - public static enum TurbineTab - { - MAIN("GuiGasesTab.png", 6, "gui.main"), - STAT("GuiStatsTab.png", 7, "gui.stats"); - - private String path; - private int guiId; - private String desc; - - private TurbineTab(String s, int id, String s1) - { - path = s; - guiId = id; - desc = s1; - } - - public ResourceLocation getResource() - { - return MekanismUtils.getResource(ResourceType.GUI_ELEMENT, path); - } - - public void openGui(TileEntity tile) - { - Mekanism.packetHandler.sendToServer(new SimpleGuiMessage(Coord4D.get(tile), 1, guiId)); - } - - public String getDesc() - { - return LangUtils.localize(desc); - } - } + @Override + public void mouseClicked(int xAxis, int yAxis, int button) { + if (button == 0) { + if (xAxis >= -21 && xAxis <= -3 && yAxis >= yPos + 4 && yAxis <= yPos + 22) { + tabType.openGui(tileEntity); + SoundHandler.playSound("gui.button.press"); + } + } + } + + public static enum TurbineTab { + MAIN("GuiGasesTab.png", 6, "gui.main"), + STAT("GuiStatsTab.png", 7, "gui.stats"); + + private String path; + private int guiId; + private String desc; + + private TurbineTab(String s, int id, String s1) { + path = s; + guiId = id; + desc = s1; + } + + public ResourceLocation getResource() { + return MekanismUtils.getResource(ResourceType.GUI_ELEMENT, path); + } + + public void openGui(TileEntity tile) { + Mekanism.packetHandler.sendToServer( + new SimpleGuiMessage(Coord4D.get(tile), 1, guiId) + ); + } + + public String getDesc() { + return LangUtils.localize(desc); + } + } } \ No newline at end of file diff --git a/src/main/java/mekanism/generators/client/model/ModelAdvancedSolarGenerator.java b/src/main/java/mekanism/generators/client/model/ModelAdvancedSolarGenerator.java index f6c4d7496..57f423dc8 100644 --- a/src/main/java/mekanism/generators/client/model/ModelAdvancedSolarGenerator.java +++ b/src/main/java/mekanism/generators/client/model/ModelAdvancedSolarGenerator.java @@ -1,157 +1,153 @@ package mekanism.generators.client.model; -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; @SideOnly(Side.CLIENT) -public class ModelAdvancedSolarGenerator extends ModelBase -{ - ModelRenderer Shape1; - ModelRenderer Shape2; - ModelRenderer Shape3; - ModelRenderer Shape4; - ModelRenderer Shape5; - ModelRenderer Shape6; - ModelRenderer Shape7; - ModelRenderer Shape8; - ModelRenderer Shape9; - ModelRenderer Shape10; - ModelRenderer Shape11; - ModelRenderer Shape12; - ModelRenderer Shape13; - ModelRenderer Shape14; - ModelRenderer Shape15; - ModelRenderer Shape16; +public class ModelAdvancedSolarGenerator extends ModelBase { + ModelRenderer Shape1; + ModelRenderer Shape2; + ModelRenderer Shape3; + ModelRenderer Shape4; + ModelRenderer Shape5; + ModelRenderer Shape6; + ModelRenderer Shape7; + ModelRenderer Shape8; + ModelRenderer Shape9; + ModelRenderer Shape10; + ModelRenderer Shape11; + ModelRenderer Shape12; + ModelRenderer Shape13; + ModelRenderer Shape14; + ModelRenderer Shape15; + ModelRenderer Shape16; - public ModelAdvancedSolarGenerator() - { - textureWidth = 256; - textureHeight = 256; + public ModelAdvancedSolarGenerator() { + textureWidth = 256; + textureHeight = 256; - Shape1 = new ModelRenderer(this, 0, 95); - Shape1.addBox(0F, -1F, -1F, 40, 2, 2); - Shape1.setRotationPoint(-20F, -17F, 0F); - Shape1.setTextureSize(256, 256); - Shape1.mirror = true; - setRotation(Shape1, 0F, 0F, 0F); //rotates - Shape2 = new ModelRenderer(this, 0, 49); - Shape2.addBox(0F, -1F, -23F, 16, 1, 45); - Shape2.setRotationPoint(7F, -17F, 0F); - Shape2.setTextureSize(256, 256); - Shape2.mirror = true; - setRotation(Shape2, 0F, 0F, 0F); //rotates - Shape3 = new ModelRenderer(this, 0, 0); - Shape3.addBox(0F, -2F, -24F, 18, 1, 48); - Shape3.setRotationPoint(6F, -17F, 0F); - Shape3.setTextureSize(256, 256); - Shape3.mirror = true; - setRotation(Shape3, 0F, 0F, 0F); //rotates - Shape4 = new ModelRenderer(this, 86, 21); - Shape4.addBox(0F, 0F, 0F, 6, 6, 10); - Shape4.setRotationPoint(-3F, 13F, -7F); - Shape4.setTextureSize(256, 256); - Shape4.mirror = true; - setRotation(Shape4, 0F, 0F, 0F); - Shape5 = new ModelRenderer(this, 0, 0); - Shape5.addBox(0F, 0F, 0F, 4, 40, 4); - Shape5.setRotationPoint(-2F, -16F, -2F); - Shape5.setTextureSize(256, 256); - Shape5.mirror = true; - setRotation(Shape5, 0F, 0F, 0F); - Shape6 = new ModelRenderer(this, 16, 28); - Shape6.addBox(0F, 0F, 0F, 2, 2, 12); - Shape6.setRotationPoint(1F, -14F, -6F); - Shape6.setTextureSize(256, 256); - Shape6.mirror = true; - setRotation(Shape6, 0F, 0F, 0F); - Shape7 = new ModelRenderer(this, 0, 50); - Shape7.addBox(0F, 0F, 0F, 1, 7, 7); - Shape7.setRotationPoint(1.5F, -20.5F, -3.5F); - Shape7.setTextureSize(256, 256); - Shape7.mirror = true; - setRotation(Shape7, 0F, 0F, 0F); - Shape8 = new ModelRenderer(this, 16, 28); - Shape8.addBox(0F, 0F, 0F, 2, 2, 12); - Shape8.setRotationPoint(-3F, -14F, -6F); - Shape8.setTextureSize(256, 256); - Shape8.mirror = true; - setRotation(Shape8, 0F, 0F, 0F); - Shape9 = new ModelRenderer(this, 16, 0); - Shape9.addBox(0F, 0F, 0F, 8, 6, 6); - Shape9.setRotationPoint(-4F, -20F, -3F); - Shape9.setTextureSize(256, 256); - Shape9.mirror = true; - setRotation(Shape9, 0F, 0F, 0F); - Shape10 = new ModelRenderer(this, 0, 50); - Shape10.addBox(0F, 0F, 0F, 1, 7, 7); - Shape10.setRotationPoint(-2.5F, -20.5F, -3.5F); - Shape10.setTextureSize(256, 256); - Shape10.mirror = true; - setRotation(Shape10, 0F, 0F, 0F); - Shape11 = new ModelRenderer(this, 0, 0); - Shape11.addBox(0F, -2F, -24F, 18, 1, 48); - Shape11.setRotationPoint(-24F, -17F, 0F); - Shape11.setTextureSize(256, 256); - Shape11.mirror = true; - setRotation(Shape11, 0F, 0F, 0F); //rotates - Shape12 = new ModelRenderer(this, 0, 49); - Shape12.addBox(0F, -1F, -23F, 16, 1, 45); - Shape12.setRotationPoint(-23F, -17F, 0F); - Shape12.setTextureSize(256, 256); - Shape12.mirror = true; - setRotation(Shape12, 0F, 0F, 0F); //rotates - Shape13 = new ModelRenderer(this, 78, 50); - Shape13.addBox(0F, 0F, 0F, 16, 2, 16); - Shape13.setRotationPoint(-8F, 22F, -8F); - Shape13.setTextureSize(256, 256); - Shape13.mirror = true; - setRotation(Shape13, 0F, 0F, 0F); - Shape14 = new ModelRenderer(this, 86, 12); - Shape14.addBox(0F, 0F, 0F, 8, 8, 1); - Shape14.setRotationPoint(-4F, 12F, -8F); - Shape14.setTextureSize(256, 256); - Shape14.mirror = true; - setRotation(Shape14, 0F, 0F, 0F); - Shape15 = new ModelRenderer(this, 16, 12); - Shape15.addBox(0F, 0F, 0F, 8, 8, 8); - Shape15.setRotationPoint(-4F, 14F, -4F); - Shape15.setTextureSize(256, 256); - Shape15.mirror = true; - setRotation(Shape15, 0F, 0F, 0F); - Shape16 = new ModelRenderer(this, 86, 0); - Shape16.addBox(0F, 0F, 0F, 10, 2, 10); - Shape16.setRotationPoint(-5F, 21F, -5F); - Shape16.setTextureSize(256, 256); - Shape16.mirror = true; - setRotation(Shape16, 0F, 0F, 0F); - } + Shape1 = new ModelRenderer(this, 0, 95); + Shape1.addBox(0F, -1F, -1F, 40, 2, 2); + Shape1.setRotationPoint(-20F, -17F, 0F); + Shape1.setTextureSize(256, 256); + Shape1.mirror = true; + setRotation(Shape1, 0F, 0F, 0F); //rotates + Shape2 = new ModelRenderer(this, 0, 49); + Shape2.addBox(0F, -1F, -23F, 16, 1, 45); + Shape2.setRotationPoint(7F, -17F, 0F); + Shape2.setTextureSize(256, 256); + Shape2.mirror = true; + setRotation(Shape2, 0F, 0F, 0F); //rotates + Shape3 = new ModelRenderer(this, 0, 0); + Shape3.addBox(0F, -2F, -24F, 18, 1, 48); + Shape3.setRotationPoint(6F, -17F, 0F); + Shape3.setTextureSize(256, 256); + Shape3.mirror = true; + setRotation(Shape3, 0F, 0F, 0F); //rotates + Shape4 = new ModelRenderer(this, 86, 21); + Shape4.addBox(0F, 0F, 0F, 6, 6, 10); + Shape4.setRotationPoint(-3F, 13F, -7F); + Shape4.setTextureSize(256, 256); + Shape4.mirror = true; + setRotation(Shape4, 0F, 0F, 0F); + Shape5 = new ModelRenderer(this, 0, 0); + Shape5.addBox(0F, 0F, 0F, 4, 40, 4); + Shape5.setRotationPoint(-2F, -16F, -2F); + Shape5.setTextureSize(256, 256); + Shape5.mirror = true; + setRotation(Shape5, 0F, 0F, 0F); + Shape6 = new ModelRenderer(this, 16, 28); + Shape6.addBox(0F, 0F, 0F, 2, 2, 12); + Shape6.setRotationPoint(1F, -14F, -6F); + Shape6.setTextureSize(256, 256); + Shape6.mirror = true; + setRotation(Shape6, 0F, 0F, 0F); + Shape7 = new ModelRenderer(this, 0, 50); + Shape7.addBox(0F, 0F, 0F, 1, 7, 7); + Shape7.setRotationPoint(1.5F, -20.5F, -3.5F); + Shape7.setTextureSize(256, 256); + Shape7.mirror = true; + setRotation(Shape7, 0F, 0F, 0F); + Shape8 = new ModelRenderer(this, 16, 28); + Shape8.addBox(0F, 0F, 0F, 2, 2, 12); + Shape8.setRotationPoint(-3F, -14F, -6F); + Shape8.setTextureSize(256, 256); + Shape8.mirror = true; + setRotation(Shape8, 0F, 0F, 0F); + Shape9 = new ModelRenderer(this, 16, 0); + Shape9.addBox(0F, 0F, 0F, 8, 6, 6); + Shape9.setRotationPoint(-4F, -20F, -3F); + Shape9.setTextureSize(256, 256); + Shape9.mirror = true; + setRotation(Shape9, 0F, 0F, 0F); + Shape10 = new ModelRenderer(this, 0, 50); + Shape10.addBox(0F, 0F, 0F, 1, 7, 7); + Shape10.setRotationPoint(-2.5F, -20.5F, -3.5F); + Shape10.setTextureSize(256, 256); + Shape10.mirror = true; + setRotation(Shape10, 0F, 0F, 0F); + Shape11 = new ModelRenderer(this, 0, 0); + Shape11.addBox(0F, -2F, -24F, 18, 1, 48); + Shape11.setRotationPoint(-24F, -17F, 0F); + Shape11.setTextureSize(256, 256); + Shape11.mirror = true; + setRotation(Shape11, 0F, 0F, 0F); //rotates + Shape12 = new ModelRenderer(this, 0, 49); + Shape12.addBox(0F, -1F, -23F, 16, 1, 45); + Shape12.setRotationPoint(-23F, -17F, 0F); + Shape12.setTextureSize(256, 256); + Shape12.mirror = true; + setRotation(Shape12, 0F, 0F, 0F); //rotates + Shape13 = new ModelRenderer(this, 78, 50); + Shape13.addBox(0F, 0F, 0F, 16, 2, 16); + Shape13.setRotationPoint(-8F, 22F, -8F); + Shape13.setTextureSize(256, 256); + Shape13.mirror = true; + setRotation(Shape13, 0F, 0F, 0F); + Shape14 = new ModelRenderer(this, 86, 12); + Shape14.addBox(0F, 0F, 0F, 8, 8, 1); + Shape14.setRotationPoint(-4F, 12F, -8F); + Shape14.setTextureSize(256, 256); + Shape14.mirror = true; + setRotation(Shape14, 0F, 0F, 0F); + Shape15 = new ModelRenderer(this, 16, 12); + Shape15.addBox(0F, 0F, 0F, 8, 8, 8); + Shape15.setRotationPoint(-4F, 14F, -4F); + Shape15.setTextureSize(256, 256); + Shape15.mirror = true; + setRotation(Shape15, 0F, 0F, 0F); + Shape16 = new ModelRenderer(this, 86, 0); + Shape16.addBox(0F, 0F, 0F, 10, 2, 10); + Shape16.setRotationPoint(-5F, 21F, -5F); + Shape16.setTextureSize(256, 256); + Shape16.mirror = true; + setRotation(Shape16, 0F, 0F, 0F); + } - public void render(float size) - { - Shape1.render(size); - Shape2.render(size); - Shape3.render(size); - Shape4.render(size); - Shape5.render(size); - Shape6.render(size); - Shape7.render(size); - Shape8.render(size); - Shape9.render(size); - Shape10.render(size); - Shape11.render(size); - Shape12.render(size); - Shape13.render(size); - Shape14.render(size); - Shape15.render(size); - Shape16.render(size); - } + public void render(float size) { + Shape1.render(size); + Shape2.render(size); + Shape3.render(size); + Shape4.render(size); + Shape5.render(size); + Shape6.render(size); + Shape7.render(size); + Shape8.render(size); + Shape9.render(size); + Shape10.render(size); + Shape11.render(size); + Shape12.render(size); + Shape13.render(size); + Shape14.render(size); + Shape15.render(size); + Shape16.render(size); + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/mekanism/generators/client/model/ModelBioGenerator.java b/src/main/java/mekanism/generators/client/model/ModelBioGenerator.java index 190381f51..ee9e4e382 100644 --- a/src/main/java/mekanism/generators/client/model/ModelBioGenerator.java +++ b/src/main/java/mekanism/generators/client/model/ModelBioGenerator.java @@ -4,75 +4,71 @@ import mekanism.client.render.MekanismRenderer; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; -public class ModelBioGenerator extends ModelBase -{ - ModelRenderer base; +public class ModelBioGenerator extends ModelBase { + ModelRenderer base; ModelRenderer sideRight; ModelRenderer back; ModelRenderer bar; ModelRenderer glass; ModelRenderer sideLeft; - - public ModelBioGenerator() - { - textureWidth = 64; - textureHeight = 64; - base = new ModelRenderer(this, 0, 0); - base.addBox(0F, 0F, 0F, 16, 7, 16); - base.setRotationPoint(-8F, 17F, -8F); - base.setTextureSize(64, 64); - base.mirror = true; - setRotation(base, 0F, 0F, 0F); - sideRight = new ModelRenderer(this, 0, 40); - sideRight.mirror = true; - sideRight.addBox(0F, 0F, 0F, 3, 9, 8); - sideRight.setRotationPoint(5F, 8F, -8F); - sideRight.setTextureSize(64, 64); - setRotation(sideRight, 0F, 0F, 0F); - back = new ModelRenderer(this, 0, 23); - back.addBox(0F, 0F, 0F, 16, 9, 8); - back.setRotationPoint(-8F, 8F, 0F); - back.setTextureSize(64, 64); - back.mirror = true; - setRotation(back, 0F, 0F, 0F); - bar = new ModelRenderer(this, 0, 57); - bar.addBox(0F, 0F, 0F, 10, 1, 1); - bar.setRotationPoint(-5F, 8.5F, -7.5F); - bar.setTextureSize(64, 64); - bar.mirror = true; - setRotation(bar, 0F, 0F, 0F); - glass = new ModelRenderer(this, 22, 40); - glass.addBox(0F, 0F, 0F, 12, 8, 7); - glass.setRotationPoint(-6F, 9F, -7F); - glass.setTextureSize(64, 64); - glass.mirror = true; - setRotation(glass, 0F, 0F, 0F); - sideLeft = new ModelRenderer(this, 0, 40); - sideLeft.addBox(0F, 0F, 0F, 3, 9, 8); - sideLeft.setRotationPoint(-8F, 8F, -8F); - sideLeft.setTextureSize(64, 64); - sideLeft.mirror = true; - setRotation(sideLeft, 0F, 0F, 0F); - } + public ModelBioGenerator() { + textureWidth = 64; + textureHeight = 64; - public void render(float size) - { - base.render(size); - sideRight.render(size); - sideLeft.render(size); - back.render(size); - bar.render(size); - - MekanismRenderer.blendOn(); - glass.render(size); - MekanismRenderer.blendOff(); - } + base = new ModelRenderer(this, 0, 0); + base.addBox(0F, 0F, 0F, 16, 7, 16); + base.setRotationPoint(-8F, 17F, -8F); + base.setTextureSize(64, 64); + base.mirror = true; + setRotation(base, 0F, 0F, 0F); + sideRight = new ModelRenderer(this, 0, 40); + sideRight.mirror = true; + sideRight.addBox(0F, 0F, 0F, 3, 9, 8); + sideRight.setRotationPoint(5F, 8F, -8F); + sideRight.setTextureSize(64, 64); + setRotation(sideRight, 0F, 0F, 0F); + back = new ModelRenderer(this, 0, 23); + back.addBox(0F, 0F, 0F, 16, 9, 8); + back.setRotationPoint(-8F, 8F, 0F); + back.setTextureSize(64, 64); + back.mirror = true; + setRotation(back, 0F, 0F, 0F); + bar = new ModelRenderer(this, 0, 57); + bar.addBox(0F, 0F, 0F, 10, 1, 1); + bar.setRotationPoint(-5F, 8.5F, -7.5F); + bar.setTextureSize(64, 64); + bar.mirror = true; + setRotation(bar, 0F, 0F, 0F); + glass = new ModelRenderer(this, 22, 40); + glass.addBox(0F, 0F, 0F, 12, 8, 7); + glass.setRotationPoint(-6F, 9F, -7F); + glass.setTextureSize(64, 64); + glass.mirror = true; + setRotation(glass, 0F, 0F, 0F); + sideLeft = new ModelRenderer(this, 0, 40); + sideLeft.addBox(0F, 0F, 0F, 3, 9, 8); + sideLeft.setRotationPoint(-8F, 8F, -8F); + sideLeft.setTextureSize(64, 64); + sideLeft.mirror = true; + setRotation(sideLeft, 0F, 0F, 0F); + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + public void render(float size) { + base.render(size); + sideRight.render(size); + sideLeft.render(size); + back.render(size); + bar.render(size); + + MekanismRenderer.blendOn(); + glass.render(size); + MekanismRenderer.blendOff(); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/mekanism/generators/client/model/ModelGasGenerator.java b/src/main/java/mekanism/generators/client/model/ModelGasGenerator.java index c7e1d9bf3..d9ca6ea16 100644 --- a/src/main/java/mekanism/generators/client/model/ModelGasGenerator.java +++ b/src/main/java/mekanism/generators/client/model/ModelGasGenerator.java @@ -1,181 +1,177 @@ package mekanism.generators.client.model; -import net.minecraft.client.model.ModelBase; -import net.minecraft.client.model.ModelRenderer; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.model.ModelBase; +import net.minecraft.client.model.ModelRenderer; @SideOnly(Side.CLIENT) -public class ModelGasGenerator extends ModelBase -{ - ModelRenderer port4; - ModelRenderer baseStand; - ModelRenderer pillar4; - ModelRenderer port3; - ModelRenderer port2; - ModelRenderer connectorAngle1; - ModelRenderer pillar3; - ModelRenderer pillar2; - ModelRenderer pillar1; - ModelRenderer center; - ModelRenderer connector3; - ModelRenderer port1; - ModelRenderer connector4; - ModelRenderer connectorAngle4; - ModelRenderer base; - ModelRenderer connectorAngle3; - ModelRenderer connector2; - ModelRenderer connectorAngle2; - ModelRenderer connector1; +public class ModelGasGenerator extends ModelBase { + ModelRenderer port4; + ModelRenderer baseStand; + ModelRenderer pillar4; + ModelRenderer port3; + ModelRenderer port2; + ModelRenderer connectorAngle1; + ModelRenderer pillar3; + ModelRenderer pillar2; + ModelRenderer pillar1; + ModelRenderer center; + ModelRenderer connector3; + ModelRenderer port1; + ModelRenderer connector4; + ModelRenderer connectorAngle4; + ModelRenderer base; + ModelRenderer connectorAngle3; + ModelRenderer connector2; + ModelRenderer connectorAngle2; + ModelRenderer connector1; - public ModelGasGenerator() - { - textureWidth = 128; - textureHeight = 64; + public ModelGasGenerator() { + textureWidth = 128; + textureHeight = 64; - port4 = new ModelRenderer(this, 40, 34); - port4.addBox(0F, 0F, 0F, 1, 8, 8); - port4.setRotationPoint(7F, 12F, -4F); - port4.setTextureSize(128, 64); - port4.mirror = true; - setRotation(port4, 0F, 0F, 0F); - baseStand = new ModelRenderer(this, 0, 20); - baseStand.addBox(0F, 0F, 0F, 13, 1, 13); - baseStand.setRotationPoint(-6.5F, 19F, -6.5F); - baseStand.setTextureSize(128, 64); - baseStand.mirror = true; - setRotation(baseStand, 0F, 0F, 0F); - pillar4 = new ModelRenderer(this, 0, 0); - pillar4.addBox(0F, 0F, 0F, 3, 9, 3); - pillar4.setRotationPoint(4F, 10F, 4F); - pillar4.setTextureSize(128, 64); - pillar4.mirror = true; - setRotation(pillar4, 0F, 0F, 0F); - port3 = new ModelRenderer(this, 40, 50); - port3.addBox(0F, 0F, 0F, 8, 8, 1); - port3.setRotationPoint(-4F, 12F, 7F); - port3.setTextureSize(128, 64); - port3.mirror = true; - setRotation(port3, 0F, 0F, 0F); - port2 = new ModelRenderer(this, 40, 34); - port2.addBox(0F, 0F, 0F, 1, 8, 8); - port2.setRotationPoint(-8F, 12F, -4F); - port2.setTextureSize(128, 64); - port2.mirror = true; - setRotation(port2, 0F, 0F, 0F); - connectorAngle1 = new ModelRenderer(this, 48, 13); - connectorAngle1.addBox(0F, 0F, 0.5F, 8, 1, 2); - connectorAngle1.setRotationPoint(-4F, 13.5F, -6F); - connectorAngle1.setTextureSize(128, 64); - connectorAngle1.mirror = true; - setRotation(connectorAngle1, 0.986111F, 0F, 0F); - pillar3 = new ModelRenderer(this, 0, 0); - pillar3.addBox(0F, 0F, 0F, 3, 9, 3); - pillar3.setRotationPoint(-7F, 10F, 4F); - pillar3.setTextureSize(128, 64); - pillar3.mirror = true; - setRotation(pillar3, 0F, 0F, 0F); - pillar2 = new ModelRenderer(this, 0, 0); - pillar2.addBox(0F, 0F, 0F, 3, 9, 3); - pillar2.setRotationPoint(4F, 10F, -7F); - pillar2.setTextureSize(128, 64); - pillar2.mirror = true; - setRotation(pillar2, 0F, 0F, 0F); - pillar1 = new ModelRenderer(this, 0, 0); - pillar1.addBox(0F, 0F, 0F, 3, 9, 3); - pillar1.setRotationPoint(-7F, 10F, -7F); - pillar1.setTextureSize(128, 64); - pillar1.mirror = true; - setRotation(pillar1, 0F, 0F, 0F); - center = new ModelRenderer(this, 0, 34); - center.addBox(0F, 0F, 0F, 10, 12, 10); - center.setRotationPoint(-5F, 8F, -5F); - center.setTextureSize(128, 64); - center.mirror = true; - setRotation(center, 0F, 0F, 0F); - connector3 = new ModelRenderer(this, 39, 20); - connector3.addBox(0F, 0F, 0F, 1, 1, 8); - connector3.setRotationPoint(5F, 11F, -4F); - connector3.setTextureSize(128, 64); - connector3.mirror = true; - setRotation(connector3, 0F, 0F, 0F); - port1 = new ModelRenderer(this, 40, 50); - port1.addBox(0F, 0F, 0F, 8, 8, 1); - port1.setRotationPoint(-4F, 12F, -8F); - port1.setTextureSize(128, 64); - port1.mirror = true; - setRotation(port1, 0F, 0F, 0F); - connector4 = new ModelRenderer(this, 39, 29); - connector4.addBox(0F, 0F, 0F, 8, 1, 1); - connector4.setRotationPoint(-4F, 11F, 5F); - connector4.setTextureSize(128, 64); - connector4.mirror = true; - setRotation(connector4, 0F, 0F, 0F); - connectorAngle4 = new ModelRenderer(this, 48, 10); - connectorAngle4.addBox(0F, 0F, -1F, 8, 2, 1); - connectorAngle4.setRotationPoint(-4F, 11F, 6F); - connectorAngle4.setTextureSize(128, 64); - connectorAngle4.mirror = true; - setRotation(connectorAngle4, 0.7941248F, 0F, 0F); - base = new ModelRenderer(this, 0, 0); - base.addBox(0F, 0F, 0F, 16, 4, 16); - base.setRotationPoint(-8F, 20F, -8F); - base.setTextureSize(128, 64); - base.mirror = true; - setRotation(base, 0F, 0F, 0F); - connectorAngle3 = new ModelRenderer(this, 48, 0); - connectorAngle3.addBox(-1F, 0F, 0F, 1, 2, 8); - connectorAngle3.setRotationPoint(6F, 11F, -4F); - connectorAngle3.setTextureSize(128, 64); - connectorAngle3.mirror = true; - setRotation(connectorAngle3, 0F, 0F, -0.7941248F); - connector2 = new ModelRenderer(this, 39, 20); - connector2.addBox(0F, 0F, 0F, 1, 1, 8); - connector2.setRotationPoint(-6F, 11F, -4F); - connector2.setTextureSize(128, 64); - connector2.mirror = true; - setRotation(connector2, 0F, 0F, 0F); - connectorAngle2 = new ModelRenderer(this, 48, 0); - connectorAngle2.addBox(0F, 0F, 0F, 1, 2, 8); - connectorAngle2.setRotationPoint(-6F, 11F, -4F); - connectorAngle2.setTextureSize(128, 64); - connectorAngle2.mirror = true; - setRotation(connectorAngle2, 0F, 0F, 0.7941248F); - connector1 = new ModelRenderer(this, 48, 13); - connector1.addBox(0F, 0F, 0F, 8, 1, 2); - connector1.setRotationPoint(-4F, 13F, -7.5F); - connector1.setTextureSize(128, 64); - connector1.mirror = true; - setRotation(connector1, 0F, 0F, 0F); - } + port4 = new ModelRenderer(this, 40, 34); + port4.addBox(0F, 0F, 0F, 1, 8, 8); + port4.setRotationPoint(7F, 12F, -4F); + port4.setTextureSize(128, 64); + port4.mirror = true; + setRotation(port4, 0F, 0F, 0F); + baseStand = new ModelRenderer(this, 0, 20); + baseStand.addBox(0F, 0F, 0F, 13, 1, 13); + baseStand.setRotationPoint(-6.5F, 19F, -6.5F); + baseStand.setTextureSize(128, 64); + baseStand.mirror = true; + setRotation(baseStand, 0F, 0F, 0F); + pillar4 = new ModelRenderer(this, 0, 0); + pillar4.addBox(0F, 0F, 0F, 3, 9, 3); + pillar4.setRotationPoint(4F, 10F, 4F); + pillar4.setTextureSize(128, 64); + pillar4.mirror = true; + setRotation(pillar4, 0F, 0F, 0F); + port3 = new ModelRenderer(this, 40, 50); + port3.addBox(0F, 0F, 0F, 8, 8, 1); + port3.setRotationPoint(-4F, 12F, 7F); + port3.setTextureSize(128, 64); + port3.mirror = true; + setRotation(port3, 0F, 0F, 0F); + port2 = new ModelRenderer(this, 40, 34); + port2.addBox(0F, 0F, 0F, 1, 8, 8); + port2.setRotationPoint(-8F, 12F, -4F); + port2.setTextureSize(128, 64); + port2.mirror = true; + setRotation(port2, 0F, 0F, 0F); + connectorAngle1 = new ModelRenderer(this, 48, 13); + connectorAngle1.addBox(0F, 0F, 0.5F, 8, 1, 2); + connectorAngle1.setRotationPoint(-4F, 13.5F, -6F); + connectorAngle1.setTextureSize(128, 64); + connectorAngle1.mirror = true; + setRotation(connectorAngle1, 0.986111F, 0F, 0F); + pillar3 = new ModelRenderer(this, 0, 0); + pillar3.addBox(0F, 0F, 0F, 3, 9, 3); + pillar3.setRotationPoint(-7F, 10F, 4F); + pillar3.setTextureSize(128, 64); + pillar3.mirror = true; + setRotation(pillar3, 0F, 0F, 0F); + pillar2 = new ModelRenderer(this, 0, 0); + pillar2.addBox(0F, 0F, 0F, 3, 9, 3); + pillar2.setRotationPoint(4F, 10F, -7F); + pillar2.setTextureSize(128, 64); + pillar2.mirror = true; + setRotation(pillar2, 0F, 0F, 0F); + pillar1 = new ModelRenderer(this, 0, 0); + pillar1.addBox(0F, 0F, 0F, 3, 9, 3); + pillar1.setRotationPoint(-7F, 10F, -7F); + pillar1.setTextureSize(128, 64); + pillar1.mirror = true; + setRotation(pillar1, 0F, 0F, 0F); + center = new ModelRenderer(this, 0, 34); + center.addBox(0F, 0F, 0F, 10, 12, 10); + center.setRotationPoint(-5F, 8F, -5F); + center.setTextureSize(128, 64); + center.mirror = true; + setRotation(center, 0F, 0F, 0F); + connector3 = new ModelRenderer(this, 39, 20); + connector3.addBox(0F, 0F, 0F, 1, 1, 8); + connector3.setRotationPoint(5F, 11F, -4F); + connector3.setTextureSize(128, 64); + connector3.mirror = true; + setRotation(connector3, 0F, 0F, 0F); + port1 = new ModelRenderer(this, 40, 50); + port1.addBox(0F, 0F, 0F, 8, 8, 1); + port1.setRotationPoint(-4F, 12F, -8F); + port1.setTextureSize(128, 64); + port1.mirror = true; + setRotation(port1, 0F, 0F, 0F); + connector4 = new ModelRenderer(this, 39, 29); + connector4.addBox(0F, 0F, 0F, 8, 1, 1); + connector4.setRotationPoint(-4F, 11F, 5F); + connector4.setTextureSize(128, 64); + connector4.mirror = true; + setRotation(connector4, 0F, 0F, 0F); + connectorAngle4 = new ModelRenderer(this, 48, 10); + connectorAngle4.addBox(0F, 0F, -1F, 8, 2, 1); + connectorAngle4.setRotationPoint(-4F, 11F, 6F); + connectorAngle4.setTextureSize(128, 64); + connectorAngle4.mirror = true; + setRotation(connectorAngle4, 0.7941248F, 0F, 0F); + base = new ModelRenderer(this, 0, 0); + base.addBox(0F, 0F, 0F, 16, 4, 16); + base.setRotationPoint(-8F, 20F, -8F); + base.setTextureSize(128, 64); + base.mirror = true; + setRotation(base, 0F, 0F, 0F); + connectorAngle3 = new ModelRenderer(this, 48, 0); + connectorAngle3.addBox(-1F, 0F, 0F, 1, 2, 8); + connectorAngle3.setRotationPoint(6F, 11F, -4F); + connectorAngle3.setTextureSize(128, 64); + connectorAngle3.mirror = true; + setRotation(connectorAngle3, 0F, 0F, -0.7941248F); + connector2 = new ModelRenderer(this, 39, 20); + connector2.addBox(0F, 0F, 0F, 1, 1, 8); + connector2.setRotationPoint(-6F, 11F, -4F); + connector2.setTextureSize(128, 64); + connector2.mirror = true; + setRotation(connector2, 0F, 0F, 0F); + connectorAngle2 = new ModelRenderer(this, 48, 0); + connectorAngle2.addBox(0F, 0F, 0F, 1, 2, 8); + connectorAngle2.setRotationPoint(-6F, 11F, -4F); + connectorAngle2.setTextureSize(128, 64); + connectorAngle2.mirror = true; + setRotation(connectorAngle2, 0F, 0F, 0.7941248F); + connector1 = new ModelRenderer(this, 48, 13); + connector1.addBox(0F, 0F, 0F, 8, 1, 2); + connector1.setRotationPoint(-4F, 13F, -7.5F); + connector1.setTextureSize(128, 64); + connector1.mirror = true; + setRotation(connector1, 0F, 0F, 0F); + } - public void render(float size) - { - port4.render(size); - baseStand.render(size); - pillar4.render(size); - port3.render(size); - port2.render(size); - connectorAngle1.render(size); - pillar3.render(size); - pillar2.render(size); - pillar1.render(size); - center.render(size); - connector3.render(size); - port1.render(size); - connector4.render(size); - connectorAngle4.render(size); - base.render(size); - connectorAngle3.render(size); - connector2.render(size); - connectorAngle2.render(size); - connector1.render(size); - } + public void render(float size) { + port4.render(size); + baseStand.render(size); + pillar4.render(size); + port3.render(size); + port2.render(size); + connectorAngle1.render(size); + pillar3.render(size); + pillar2.render(size); + pillar1.render(size); + center.render(size); + connector3.render(size); + port1.render(size); + connector4.render(size); + connectorAngle4.render(size); + base.render(size); + connectorAngle3.render(size); + connector2.render(size); + connectorAngle2.render(size); + connector1.render(size); + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/mekanism/generators/client/model/ModelHeatGenerator.java b/src/main/java/mekanism/generators/client/model/ModelHeatGenerator.java index 4b7e84520..c4a6bab91 100644 --- a/src/main/java/mekanism/generators/client/model/ModelHeatGenerator.java +++ b/src/main/java/mekanism/generators/client/model/ModelHeatGenerator.java @@ -1,5 +1,7 @@ package mekanism.generators.client.model; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.render.MekanismRenderer; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; @@ -7,184 +9,177 @@ import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.util.ResourceLocation; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class ModelHeatGenerator extends ModelBase -{ - public static ResourceLocation OVERLAY_ON = MekanismUtils.getResource(ResourceType.RENDER, "HeatGenerator_OverlayOn.png"); - public static ResourceLocation OVERLAY_OFF = MekanismUtils.getResource(ResourceType.RENDER, "HeatGenerator_OverlayOff.png"); - - ModelRenderer drum; - ModelRenderer ring1; - ModelRenderer ring2; - ModelRenderer back; - ModelRenderer bar1; - ModelRenderer bar2; - ModelRenderer plate; - ModelRenderer fin8; - ModelRenderer fin7; - ModelRenderer fin1; - ModelRenderer fin2; - ModelRenderer fin3; - ModelRenderer fin4; - ModelRenderer fin5; - ModelRenderer fin6; - ModelRenderer base; +public class ModelHeatGenerator extends ModelBase { + public static ResourceLocation OVERLAY_ON + = MekanismUtils.getResource(ResourceType.RENDER, "HeatGenerator_OverlayOn.png"); + public static ResourceLocation OVERLAY_OFF + = MekanismUtils.getResource(ResourceType.RENDER, "HeatGenerator_OverlayOff.png"); - public ModelHeatGenerator() - { - textureWidth = 128; - textureHeight = 64; + ModelRenderer drum; + ModelRenderer ring1; + ModelRenderer ring2; + ModelRenderer back; + ModelRenderer bar1; + ModelRenderer bar2; + ModelRenderer plate; + ModelRenderer fin8; + ModelRenderer fin7; + ModelRenderer fin1; + ModelRenderer fin2; + ModelRenderer fin3; + ModelRenderer fin4; + ModelRenderer fin5; + ModelRenderer fin6; + ModelRenderer base; - drum = new ModelRenderer(this, 0, 22); - drum.addBox(0F, 0F, 0F, 16, 9, 9); - drum.setRotationPoint(-8F, 8.5F, -7.5F); - drum.setTextureSize(128, 64); - drum.mirror = true; - setRotation(drum, 0F, 0F, 0F); - ring1 = new ModelRenderer(this, 88, 0); - ring1.addBox(0F, 0F, 0F, 2, 10, 10); - ring1.setRotationPoint(3F, 8F, -8F); - ring1.setTextureSize(128, 64); - ring1.mirror = true; - setRotation(ring1, 0F, 0F, 0F); - ring2 = new ModelRenderer(this, 88, 0); - ring2.addBox(0F, 0F, 0F, 2, 10, 10); - ring2.setRotationPoint(-5F, 8F, -8F); - ring2.setTextureSize(128, 64); - ring2.mirror = true; - setRotation(ring2, 0F, 0F, 0F); - back = new ModelRenderer(this, 48, 0); - back.addBox(0F, 0F, 0F, 16, 10, 4); - back.setRotationPoint(-8F, 8F, 2F); - back.setTextureSize(128, 64); - back.mirror = true; - setRotation(back, 0F, 0F, 0F); - bar1 = new ModelRenderer(this, 88, 0); - bar1.addBox(0F, 0F, 0F, 2, 9, 1); - bar1.setRotationPoint(3F, 9F, 6F); - bar1.setTextureSize(128, 64); - bar1.mirror = true; - setRotation(bar1, 0F, 0F, 0F); - bar2 = new ModelRenderer(this, 88, 0); - bar2.addBox(0F, 0F, 0F, 2, 9, 1); - bar2.setRotationPoint(-5F, 9F, 6F); - bar2.setTextureSize(128, 64); - bar2.mirror = true; - setRotation(bar2, 0F, 0F, 0F); - plate = new ModelRenderer(this, 41, 22); - plate.addBox(0F, 0F, 0F, 8, 6, 2); - plate.setRotationPoint(-4F, 12F, 6F); - plate.setTextureSize(128, 64); - plate.mirror = true; - setRotation(plate, 0F, 0F, 0F); - fin8 = new ModelRenderer(this, 14, 40); - fin8.addBox(0F, 0F, 0F, 16, 1, 2); - fin8.setRotationPoint(-8F, 8F, 6F); - fin8.setTextureSize(128, 64); - fin8.mirror = true; - setRotation(fin8, 0F, 0F, 0F); - fin7 = new ModelRenderer(this, 14, 40); - fin7.addBox(0F, 0F, 0F, 16, 1, 2); - fin7.setRotationPoint(-8F, 10F, 6F); - fin7.setTextureSize(128, 64); - fin7.mirror = true; - setRotation(fin7, 0F, 0F, 0F); - fin1 = new ModelRenderer(this, 0, 40); - fin1.addBox(0F, 0F, 0F, 4, 1, 2); - fin1.setRotationPoint(4F, 12F, 6F); - fin1.setTextureSize(128, 64); - fin1.mirror = true; - setRotation(fin1, 0F, 0F, 0F); - fin1.mirror = false; - fin2 = new ModelRenderer(this, 0, 40); - fin2.addBox(0F, 0F, 0F, 4, 1, 2); - fin2.setRotationPoint(4F, 14F, 6F); - fin2.setTextureSize(128, 64); - fin2.mirror = true; - setRotation(fin2, 0F, 0F, 0F); - fin2.mirror = false; - fin3 = new ModelRenderer(this, 0, 40); - fin3.addBox(0F, 0F, 0F, 4, 1, 2); - fin3.setRotationPoint(4F, 16F, 6F); - fin3.setTextureSize(128, 64); - fin3.mirror = true; - setRotation(fin3, 0F, 0F, 0F); - fin3.mirror = false; - fin4 = new ModelRenderer(this, 0, 40); - fin4.addBox(0F, 0F, 0F, 4, 1, 2); - fin4.setRotationPoint(-8F, 12F, 6F); - fin4.setTextureSize(128, 64); - fin4.mirror = true; - setRotation(fin4, 0F, 0F, 0F); - fin5 = new ModelRenderer(this, 0, 40); - fin5.addBox(0F, 0F, 0F, 4, 1, 2); - fin5.setRotationPoint(-8F, 14F, 6F); - fin5.setTextureSize(128, 64); - fin5.mirror = true; - setRotation(fin5, 0F, 0F, 0F); - fin6 = new ModelRenderer(this, 0, 40); - fin6.addBox(0F, 0F, 0F, 4, 1, 2); - fin6.setRotationPoint(-8F, 16F, 6F); - fin6.setTextureSize(128, 64); - fin6.mirror = true; - setRotation(fin6, 0F, 0F, 0F); - base = new ModelRenderer(this, 0, 0); - base.addBox(0F, 0F, 0F, 16, 6, 16); - base.setRotationPoint(-8F, 18F, -8F); - base.setTextureSize(128, 64); - base.mirror = true; - setRotation(base, 0F, 0F, 0F); - } - - public void render(float size, boolean on, TextureManager manager) - { - GL11.glPushMatrix(); - MekanismRenderer.blendOn(); - - doRender(size); - - manager.bindTexture(on ? OVERLAY_ON : OVERLAY_OFF); - GL11.glScalef(1.001F, 1.001F, 1.001F); - GL11.glTranslatef(0, -0.0011F, 0); - MekanismRenderer.glowOn(); - - doRender(size); - - MekanismRenderer.glowOff(); - MekanismRenderer.blendOff(); - GL11.glPopMatrix(); - } + public ModelHeatGenerator() { + textureWidth = 128; + textureHeight = 64; - private void doRender(float size) - { - drum.render(size); - ring1.render(size); - ring2.render(size); - back.render(size); - bar1.render(size); - bar2.render(size); - plate.render(size); - fin8.render(size); - fin7.render(size); - fin1.render(size); - fin2.render(size); - fin3.render(size); - fin4.render(size); - fin5.render(size); - fin6.render(size); - base.render(size); - } + drum = new ModelRenderer(this, 0, 22); + drum.addBox(0F, 0F, 0F, 16, 9, 9); + drum.setRotationPoint(-8F, 8.5F, -7.5F); + drum.setTextureSize(128, 64); + drum.mirror = true; + setRotation(drum, 0F, 0F, 0F); + ring1 = new ModelRenderer(this, 88, 0); + ring1.addBox(0F, 0F, 0F, 2, 10, 10); + ring1.setRotationPoint(3F, 8F, -8F); + ring1.setTextureSize(128, 64); + ring1.mirror = true; + setRotation(ring1, 0F, 0F, 0F); + ring2 = new ModelRenderer(this, 88, 0); + ring2.addBox(0F, 0F, 0F, 2, 10, 10); + ring2.setRotationPoint(-5F, 8F, -8F); + ring2.setTextureSize(128, 64); + ring2.mirror = true; + setRotation(ring2, 0F, 0F, 0F); + back = new ModelRenderer(this, 48, 0); + back.addBox(0F, 0F, 0F, 16, 10, 4); + back.setRotationPoint(-8F, 8F, 2F); + back.setTextureSize(128, 64); + back.mirror = true; + setRotation(back, 0F, 0F, 0F); + bar1 = new ModelRenderer(this, 88, 0); + bar1.addBox(0F, 0F, 0F, 2, 9, 1); + bar1.setRotationPoint(3F, 9F, 6F); + bar1.setTextureSize(128, 64); + bar1.mirror = true; + setRotation(bar1, 0F, 0F, 0F); + bar2 = new ModelRenderer(this, 88, 0); + bar2.addBox(0F, 0F, 0F, 2, 9, 1); + bar2.setRotationPoint(-5F, 9F, 6F); + bar2.setTextureSize(128, 64); + bar2.mirror = true; + setRotation(bar2, 0F, 0F, 0F); + plate = new ModelRenderer(this, 41, 22); + plate.addBox(0F, 0F, 0F, 8, 6, 2); + plate.setRotationPoint(-4F, 12F, 6F); + plate.setTextureSize(128, 64); + plate.mirror = true; + setRotation(plate, 0F, 0F, 0F); + fin8 = new ModelRenderer(this, 14, 40); + fin8.addBox(0F, 0F, 0F, 16, 1, 2); + fin8.setRotationPoint(-8F, 8F, 6F); + fin8.setTextureSize(128, 64); + fin8.mirror = true; + setRotation(fin8, 0F, 0F, 0F); + fin7 = new ModelRenderer(this, 14, 40); + fin7.addBox(0F, 0F, 0F, 16, 1, 2); + fin7.setRotationPoint(-8F, 10F, 6F); + fin7.setTextureSize(128, 64); + fin7.mirror = true; + setRotation(fin7, 0F, 0F, 0F); + fin1 = new ModelRenderer(this, 0, 40); + fin1.addBox(0F, 0F, 0F, 4, 1, 2); + fin1.setRotationPoint(4F, 12F, 6F); + fin1.setTextureSize(128, 64); + fin1.mirror = true; + setRotation(fin1, 0F, 0F, 0F); + fin1.mirror = false; + fin2 = new ModelRenderer(this, 0, 40); + fin2.addBox(0F, 0F, 0F, 4, 1, 2); + fin2.setRotationPoint(4F, 14F, 6F); + fin2.setTextureSize(128, 64); + fin2.mirror = true; + setRotation(fin2, 0F, 0F, 0F); + fin2.mirror = false; + fin3 = new ModelRenderer(this, 0, 40); + fin3.addBox(0F, 0F, 0F, 4, 1, 2); + fin3.setRotationPoint(4F, 16F, 6F); + fin3.setTextureSize(128, 64); + fin3.mirror = true; + setRotation(fin3, 0F, 0F, 0F); + fin3.mirror = false; + fin4 = new ModelRenderer(this, 0, 40); + fin4.addBox(0F, 0F, 0F, 4, 1, 2); + fin4.setRotationPoint(-8F, 12F, 6F); + fin4.setTextureSize(128, 64); + fin4.mirror = true; + setRotation(fin4, 0F, 0F, 0F); + fin5 = new ModelRenderer(this, 0, 40); + fin5.addBox(0F, 0F, 0F, 4, 1, 2); + fin5.setRotationPoint(-8F, 14F, 6F); + fin5.setTextureSize(128, 64); + fin5.mirror = true; + setRotation(fin5, 0F, 0F, 0F); + fin6 = new ModelRenderer(this, 0, 40); + fin6.addBox(0F, 0F, 0F, 4, 1, 2); + fin6.setRotationPoint(-8F, 16F, 6F); + fin6.setTextureSize(128, 64); + fin6.mirror = true; + setRotation(fin6, 0F, 0F, 0F); + base = new ModelRenderer(this, 0, 0); + base.addBox(0F, 0F, 0F, 16, 6, 16); + base.setRotationPoint(-8F, 18F, -8F); + base.setTextureSize(128, 64); + base.mirror = true; + setRotation(base, 0F, 0F, 0F); + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + public void render(float size, boolean on, TextureManager manager) { + GL11.glPushMatrix(); + MekanismRenderer.blendOn(); + + doRender(size); + + manager.bindTexture(on ? OVERLAY_ON : OVERLAY_OFF); + GL11.glScalef(1.001F, 1.001F, 1.001F); + GL11.glTranslatef(0, -0.0011F, 0); + MekanismRenderer.glowOn(); + + doRender(size); + + MekanismRenderer.glowOff(); + MekanismRenderer.blendOff(); + GL11.glPopMatrix(); + } + + private void doRender(float size) { + drum.render(size); + ring1.render(size); + ring2.render(size); + back.render(size); + bar1.render(size); + bar2.render(size); + plate.render(size); + fin8.render(size); + fin7.render(size); + fin1.render(size); + fin2.render(size); + fin3.render(size); + fin4.render(size); + fin5.render(size); + fin6.render(size); + base.render(size); + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/mekanism/generators/client/model/ModelSolarGenerator.java b/src/main/java/mekanism/generators/client/model/ModelSolarGenerator.java index ff5bde0b5..8e2b25292 100644 --- a/src/main/java/mekanism/generators/client/model/ModelSolarGenerator.java +++ b/src/main/java/mekanism/generators/client/model/ModelSolarGenerator.java @@ -3,88 +3,84 @@ package mekanism.generators.client.model; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; -public class ModelSolarGenerator extends ModelBase -{ - ModelRenderer solarPanel; - ModelRenderer solarPanelBottom; - ModelRenderer solarPanelConnector; - ModelRenderer solarPanelRod2; - ModelRenderer solarPanelPipeConnector; - ModelRenderer solarPanelPort; - ModelRenderer solarPanelRod1; - ModelRenderer solarPanelPipeBase; +public class ModelSolarGenerator extends ModelBase { + ModelRenderer solarPanel; + ModelRenderer solarPanelBottom; + ModelRenderer solarPanelConnector; + ModelRenderer solarPanelRod2; + ModelRenderer solarPanelPipeConnector; + ModelRenderer solarPanelPort; + ModelRenderer solarPanelRod1; + ModelRenderer solarPanelPipeBase; - public ModelSolarGenerator() - { - textureWidth = 64; - textureHeight = 64; + public ModelSolarGenerator() { + textureWidth = 64; + textureHeight = 64; - solarPanel = new ModelRenderer(this, 0, 0); - solarPanel.addBox(0F, 0F, 0F, 16, 2, 16); - solarPanel.setRotationPoint(-8F, 13F, -8F); - solarPanel.setTextureSize(64, 64); - solarPanel.mirror = true; - setRotation(solarPanel, 0F, 0F, 0F); - solarPanelBottom = new ModelRenderer(this, 0, 18); - solarPanelBottom.addBox(0F, 0F, 0F, 14, 1, 14); - solarPanelBottom.setRotationPoint(-7F, 15F, -7F); - solarPanelBottom.setTextureSize(64, 64); - solarPanelBottom.mirror = true; - setRotation(solarPanelBottom, 0F, 0F, 0F); - solarPanelConnector = new ModelRenderer(this, 0, 33); - solarPanelConnector.addBox(0F, 0F, 0F, 4, 2, 4); - solarPanelConnector.setRotationPoint(-2F, 15F, -2F); - solarPanelConnector.setTextureSize(64, 64); - solarPanelConnector.mirror = true; - setRotation(solarPanelConnector, 0F, 0F, 0F); - solarPanelRod2 = new ModelRenderer(this, 16, 33); - solarPanelRod2.addBox(0F, 0F, 0F, 2, 3, 2); - solarPanelRod2.setRotationPoint(-1F, 19F, -1F); - solarPanelRod2.setTextureSize(64, 64); - solarPanelRod2.mirror = true; - setRotation(solarPanelRod2, 0F, 0F, 0F); - solarPanelPipeConnector = new ModelRenderer(this, 24, 33); - solarPanelPipeConnector.addBox(0F, 0F, 0F, 3, 3, 3); - solarPanelPipeConnector.setRotationPoint(-1.5F, 18F, -1.5F); - solarPanelPipeConnector.setTextureSize(64, 64); - solarPanelPipeConnector.mirror = true; - setRotation(solarPanelPipeConnector, 0F, 0F, 0F); - solarPanelPort = new ModelRenderer(this, 0, 44); - solarPanelPort.addBox(0F, 0F, 0F, 8, 1, 8); - solarPanelPort.setRotationPoint(-4F, 23F, -4F); - solarPanelPort.setTextureSize(64, 64); - solarPanelPort.mirror = true; - setRotation(solarPanelPort, 0F, 0F, 0F); - solarPanelRod1 = new ModelRenderer(this, 16, 33); - solarPanelRod1.addBox(0F, 0F, 0F, 2, 3, 2); - solarPanelRod1.setRotationPoint(-1F, 16F, -1F); - solarPanelRod1.setTextureSize(64, 64); - solarPanelRod1.mirror = true; - setRotation(solarPanelRod1, 0F, 0F, 0F); - solarPanelPipeBase = new ModelRenderer(this, 0, 39); - solarPanelPipeBase.addBox(0F, 0F, 0F, 4, 1, 4); - solarPanelPipeBase.setRotationPoint(-2F, 22F, -2F); - solarPanelPipeBase.setTextureSize(64, 64); - solarPanelPipeBase.mirror = true; - setRotation(solarPanelPipeBase, 0F, 0F, 0F); - } + solarPanel = new ModelRenderer(this, 0, 0); + solarPanel.addBox(0F, 0F, 0F, 16, 2, 16); + solarPanel.setRotationPoint(-8F, 13F, -8F); + solarPanel.setTextureSize(64, 64); + solarPanel.mirror = true; + setRotation(solarPanel, 0F, 0F, 0F); + solarPanelBottom = new ModelRenderer(this, 0, 18); + solarPanelBottom.addBox(0F, 0F, 0F, 14, 1, 14); + solarPanelBottom.setRotationPoint(-7F, 15F, -7F); + solarPanelBottom.setTextureSize(64, 64); + solarPanelBottom.mirror = true; + setRotation(solarPanelBottom, 0F, 0F, 0F); + solarPanelConnector = new ModelRenderer(this, 0, 33); + solarPanelConnector.addBox(0F, 0F, 0F, 4, 2, 4); + solarPanelConnector.setRotationPoint(-2F, 15F, -2F); + solarPanelConnector.setTextureSize(64, 64); + solarPanelConnector.mirror = true; + setRotation(solarPanelConnector, 0F, 0F, 0F); + solarPanelRod2 = new ModelRenderer(this, 16, 33); + solarPanelRod2.addBox(0F, 0F, 0F, 2, 3, 2); + solarPanelRod2.setRotationPoint(-1F, 19F, -1F); + solarPanelRod2.setTextureSize(64, 64); + solarPanelRod2.mirror = true; + setRotation(solarPanelRod2, 0F, 0F, 0F); + solarPanelPipeConnector = new ModelRenderer(this, 24, 33); + solarPanelPipeConnector.addBox(0F, 0F, 0F, 3, 3, 3); + solarPanelPipeConnector.setRotationPoint(-1.5F, 18F, -1.5F); + solarPanelPipeConnector.setTextureSize(64, 64); + solarPanelPipeConnector.mirror = true; + setRotation(solarPanelPipeConnector, 0F, 0F, 0F); + solarPanelPort = new ModelRenderer(this, 0, 44); + solarPanelPort.addBox(0F, 0F, 0F, 8, 1, 8); + solarPanelPort.setRotationPoint(-4F, 23F, -4F); + solarPanelPort.setTextureSize(64, 64); + solarPanelPort.mirror = true; + setRotation(solarPanelPort, 0F, 0F, 0F); + solarPanelRod1 = new ModelRenderer(this, 16, 33); + solarPanelRod1.addBox(0F, 0F, 0F, 2, 3, 2); + solarPanelRod1.setRotationPoint(-1F, 16F, -1F); + solarPanelRod1.setTextureSize(64, 64); + solarPanelRod1.mirror = true; + setRotation(solarPanelRod1, 0F, 0F, 0F); + solarPanelPipeBase = new ModelRenderer(this, 0, 39); + solarPanelPipeBase.addBox(0F, 0F, 0F, 4, 1, 4); + solarPanelPipeBase.setRotationPoint(-2F, 22F, -2F); + solarPanelPipeBase.setTextureSize(64, 64); + solarPanelPipeBase.mirror = true; + setRotation(solarPanelPipeBase, 0F, 0F, 0F); + } - public void render(float size) - { - solarPanel.render(size); - solarPanelBottom.render(size); - solarPanelConnector.render(size); - solarPanelRod2.render(size); - solarPanelPipeConnector.render(size); - solarPanelPort.render(size); - solarPanelRod1.render(size); - solarPanelPipeBase.render(size); - } + public void render(float size) { + solarPanel.render(size); + solarPanelBottom.render(size); + solarPanelConnector.render(size); + solarPanelRod2.render(size); + solarPanelPipeConnector.render(size); + solarPanelPort.render(size); + solarPanelRod1.render(size); + solarPanelPipeBase.render(size); + } - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/mekanism/generators/client/model/ModelTurbine.java b/src/main/java/mekanism/generators/client/model/ModelTurbine.java index b5acb3ebb..6e625d3f6 100644 --- a/src/main/java/mekanism/generators/client/model/ModelTurbine.java +++ b/src/main/java/mekanism/generators/client/model/ModelTurbine.java @@ -2,13 +2,11 @@ package mekanism.generators.client.model; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; - import org.lwjgl.opengl.GL11; -public class ModelTurbine extends ModelBase -{ - private static float BLADE_ROTATE = 0.418879F; - +public class ModelTurbine extends ModelBase { + private static float BLADE_ROTATE = 0.418879F; + public ModelRenderer rod; public ModelRenderer extension_north; public ModelRenderer blade_north; @@ -19,8 +17,7 @@ public class ModelTurbine extends ModelBase public ModelRenderer blade_east; public ModelRenderer blade_west; - public ModelTurbine() - { + public ModelTurbine() { textureWidth = 64; textureHeight = 64; extension_south = new ModelRenderer(this, 0, 0); @@ -60,53 +57,51 @@ public class ModelTurbine extends ModelBase setRotateAngle(blade_west, BLADE_ROTATE, 0.0F, 0.0F); } - public void render(float size, int index) - { - GL11.glPushMatrix(); - - GL11.glRotatef(index*5, 0.0F, 1.0F, 0.0F); - - float scale = index*0.5F; - float widthDiv = 16; - + public void render(float size, int index) { + GL11.glPushMatrix(); + + GL11.glRotatef(index * 5, 0.0F, 1.0F, 0.0F); + + float scale = index * 0.5F; + float widthDiv = 16; + extension_south.render(size); extension_west.render(size); extension_east.render(size); extension_north.render(size); - + GL11.glPushMatrix(); GL11.glTranslatef(-0.25F, 0.0F, 0.0F); - GL11.glScalef(1.0F + scale, 1.0F, 1.0F + scale/widthDiv); + GL11.glScalef(1.0F + scale, 1.0F, 1.0F + scale / widthDiv); GL11.glTranslatef(0.25F, 0.0F, 0.0F); blade_west.render(size); GL11.glPopMatrix(); - + GL11.glPushMatrix(); GL11.glTranslatef(0.25F, 0.0F, 0.0F); - GL11.glScalef(1.0F + scale, 1.0F, 1.0F + scale/widthDiv); + GL11.glScalef(1.0F + scale, 1.0F, 1.0F + scale / widthDiv); GL11.glTranslatef(-0.25F, 0.0F, 0.0F); blade_east.render(size); GL11.glPopMatrix(); - + GL11.glPushMatrix(); GL11.glTranslatef(0.0F, 0.0F, -0.25F); - GL11.glScalef(1.0F + scale/widthDiv, 1.0F, 1.0F + scale); + GL11.glScalef(1.0F + scale / widthDiv, 1.0F, 1.0F + scale); GL11.glTranslatef(0.0F, 0.0F, 0.25F); blade_north.render(size); GL11.glPopMatrix(); - + GL11.glPushMatrix(); GL11.glTranslatef(0.0F, 0.0F, 0.25F); - GL11.glScalef(1.0F + scale/widthDiv, 1.0F, 1.0F + scale); + GL11.glScalef(1.0F + scale / widthDiv, 1.0F, 1.0F + scale); GL11.glTranslatef(0.0F, 0.0F, -0.25F); blade_south.render(size); GL11.glPopMatrix(); - + GL11.glPopMatrix(); } - public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) - { + public void setRotateAngle(ModelRenderer modelRenderer, float x, float y, float z) { modelRenderer.rotateAngleX = x; modelRenderer.rotateAngleY = y; modelRenderer.rotateAngleZ = z; diff --git a/src/main/java/mekanism/generators/client/model/ModelWindGenerator.java b/src/main/java/mekanism/generators/client/model/ModelWindGenerator.java index 8cf1992f7..ac74d3777 100644 --- a/src/main/java/mekanism/generators/client/model/ModelWindGenerator.java +++ b/src/main/java/mekanism/generators/client/model/ModelWindGenerator.java @@ -3,216 +3,214 @@ package mekanism.generators.client.model; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; -public class ModelWindGenerator extends ModelBase -{ - ModelRenderer head; - ModelRenderer plateConnector2; - ModelRenderer plateConnector; - ModelRenderer plate; - ModelRenderer bladeCap; - ModelRenderer bladeCenter; - ModelRenderer baseRim; - ModelRenderer base; - ModelRenderer wire; - ModelRenderer rearPlate1; - ModelRenderer rearPlate2; - ModelRenderer blade1a; - ModelRenderer blade2a; - ModelRenderer blade3a; - ModelRenderer blade1b; - ModelRenderer blade2b; - ModelRenderer blade3b; - ModelRenderer post1a; - ModelRenderer post1b; - ModelRenderer post1c; - ModelRenderer post1d; +public class ModelWindGenerator extends ModelBase { + ModelRenderer head; + ModelRenderer plateConnector2; + ModelRenderer plateConnector; + ModelRenderer plate; + ModelRenderer bladeCap; + ModelRenderer bladeCenter; + ModelRenderer baseRim; + ModelRenderer base; + ModelRenderer wire; + ModelRenderer rearPlate1; + ModelRenderer rearPlate2; + ModelRenderer blade1a; + ModelRenderer blade2a; + ModelRenderer blade3a; + ModelRenderer blade1b; + ModelRenderer blade2b; + ModelRenderer blade3b; + ModelRenderer post1a; + ModelRenderer post1b; + ModelRenderer post1c; + ModelRenderer post1d; - public ModelWindGenerator() - { - textureWidth = 128; - textureHeight = 128; + public ModelWindGenerator() { + textureWidth = 128; + textureHeight = 128; - head = new ModelRenderer(this, 20, 0); - head.addBox(-3.5F, -3.5F, 0F, 7, 7, 9); - head.setRotationPoint(0F, -48F, -4F); - head.setTextureSize(128, 128); - head.mirror = true; - setRotation(head, 0F, 0F, 0F); - plateConnector2 = new ModelRenderer(this, 42, 34); - plateConnector2.addBox(0F, 0F, 0F, 6, 6, 10); - plateConnector2.setRotationPoint(-3F, 13F, -7F); - plateConnector2.setTextureSize(128, 128); - plateConnector2.mirror = true; - setRotation(plateConnector2, 0F, 0F, 0F); - plateConnector = new ModelRenderer(this, 0, 75); - plateConnector.addBox(0F, 0F, 0F, 4, 2, 2); - plateConnector.setRotationPoint(-2F, 19F, -5.5F); - plateConnector.setTextureSize(128, 128); - plateConnector.mirror = true; - setRotation(plateConnector, 0F, 0F, 0F); - plate = new ModelRenderer(this, 42, 25); - plate.addBox(0F, 0F, 0F, 8, 8, 1); - plate.setRotationPoint(-4F, 12F, -8F); - plate.setTextureSize(128, 128); - plate.mirror = true; - setRotation(plate, 0F, 0F, 0F); - bladeCap = new ModelRenderer(this, 22, 0); - bladeCap.addBox(-1F, -1F, -8F, 2, 2, 1); - bladeCap.setRotationPoint(0F, -48F, 0F); - bladeCap.setTextureSize(128, 128); - bladeCap.mirror = true; - setRotation(bladeCap, 0F, 0F, 0F); - bladeCenter = new ModelRenderer(this, 20, 25); - bladeCenter.addBox(-2F, -2F, -7F, 4, 4, 3); - bladeCenter.setRotationPoint(0F, -48F, 0F); - bladeCenter.setTextureSize(128, 128); - bladeCenter.mirror = true; - setRotation(bladeCenter, 0F, 0F, 0F); - baseRim = new ModelRenderer(this, 26, 50); - baseRim.addBox(0F, 0F, 0F, 12, 2, 12); - baseRim.setRotationPoint(-6F, 21F, -6F); - baseRim.setTextureSize(128, 128); - baseRim.mirror = true; - setRotation(baseRim, 0F, 0F, 0F); - base = new ModelRenderer(this, 10, 64); - base.addBox(0F, 0F, 0F, 16, 2, 16); - base.setRotationPoint(-8F, 22F, -8F); - base.setTextureSize(128, 128); - base.mirror = true; - setRotation(base, 0F, 0F, 0F); - wire = new ModelRenderer(this, 74, 0); - wire.addBox(-1F, 0F, -1.1F, 2, 65, 2); - wire.setRotationPoint(0F, -46F, -1.5F); - wire.setTextureSize(128, 128); - wire.mirror = true; - setRotation(wire, -0.0349066F, 0F, 0F); - rearPlate1 = new ModelRenderer(this, 20, 16); - rearPlate1.addBox(-2.5F, -6F, 0F, 5, 6, 3); - rearPlate1.setRotationPoint(0F, -44.5F, 4F); - rearPlate1.setTextureSize(128, 128); - rearPlate1.mirror = true; - setRotation(rearPlate1, 0.122173F, 0F, 0F); - rearPlate2 = new ModelRenderer(this, 36, 16); - rearPlate2.addBox(-1.5F, -5F, -1F, 3, 5, 2); - rearPlate2.setRotationPoint(0F, -45F, 7F); - rearPlate2.setTextureSize(128, 128); - rearPlate2.mirror = true; - setRotation(rearPlate2, 0.2094395F, 0F, 0F); - blade1a = new ModelRenderer(this, 20, 32); - blade1a.addBox(-1F, -32F, 0F, 2, 32, 1); - blade1a.setRotationPoint(0F, -48F, -5.99F); - blade1a.setTextureSize(128, 128); - blade1a.mirror = true; - setRotation(blade1a, 0F, 0F, 0F); - blade2a = new ModelRenderer(this, 20, 32); - blade2a.addBox(-1F, 0F, 0F, 2, 32, 1); - blade2a.setRotationPoint(0F, -48F, -6F); - blade2a.setTextureSize(128, 128); - blade2a.mirror = true; - setRotation(blade2a, 0F, 0F, 1.047198F); - blade3a = new ModelRenderer(this, 20, 32); - blade3a.addBox(-1F, 0F, 0F, 2, 32, 1); - blade3a.setRotationPoint(0F, -48F, -6F); - blade3a.setTextureSize(128, 128); - blade3a.mirror = true; - setRotation(blade3a, 0F, 0F, -1.047198F); - blade1b = new ModelRenderer(this, 26, 32); - blade1b.addBox(-2F, -28F, 0F, 2, 28, 1); - blade1b.setRotationPoint(0F, -48F, -6F); - blade1b.setTextureSize(128, 128); - blade1b.mirror = true; - setRotation(blade1b, 0F, 0F, 0.0349066F); - blade2b = new ModelRenderer(this, 26, 32); - blade2b.addBox(0F, 0F, 0F, 2, 28, 1); - blade2b.setRotationPoint(0F, -48F, -6.01F); - blade2b.setTextureSize(128, 128); - blade2b.mirror = true; - setRotation(blade2b, 0F, 0F, 1.082104F); - blade3b = new ModelRenderer(this, 26, 32); - blade3b.addBox(0F, 0F, 0F, 2, 28, 1); - blade3b.setRotationPoint(0F, -48F, -6.01F); - blade3b.setTextureSize(128, 128); - blade3b.mirror = true; - setRotation(blade3b, 0F, 0F, -1.012291F); - post1a = new ModelRenderer(this, 0, 0); - post1a.addBox(-2.5F, 0F, -2.5F, 5, 68, 5); - post1a.setRotationPoint(0F, -46F, 0F); - post1a.setTextureSize(128, 128); - post1a.mirror = true; - setRotation(post1a, -0.0349066F, 0F, 0.0349066F); - post1b = new ModelRenderer(this, 0, 0); - post1b.addBox(-2.5F, 0F, -2.5F, 5, 68, 5); - post1b.setRotationPoint(0F, -46F, 0F); - post1b.setTextureSize(128, 128); - post1b.mirror = true; - setRotation(post1b, 0.0349066F, 0F, -0.0349066F); - post1c = new ModelRenderer(this, 0, 0); - post1c.addBox(-2.5F, 0F, -2.5F, 5, 68, 5); - post1c.setRotationPoint(0F, -46F, 0F); - post1c.setTextureSize(128, 128); - post1c.mirror = true; - setRotation(post1c, 0.0347321F, 0F, 0.0347321F); - post1d = new ModelRenderer(this, 0, 0); - post1d.addBox(-2.5F, 0F, -2.5F, 5, 68, 5); - post1d.setRotationPoint(0F, -46F, 0F); - post1d.setTextureSize(128, 128); - post1d.mirror = true; - setRotation(post1d, -0.0347321F, 0F, -0.0347321F); - } + head = new ModelRenderer(this, 20, 0); + head.addBox(-3.5F, -3.5F, 0F, 7, 7, 9); + head.setRotationPoint(0F, -48F, -4F); + head.setTextureSize(128, 128); + head.mirror = true; + setRotation(head, 0F, 0F, 0F); + plateConnector2 = new ModelRenderer(this, 42, 34); + plateConnector2.addBox(0F, 0F, 0F, 6, 6, 10); + plateConnector2.setRotationPoint(-3F, 13F, -7F); + plateConnector2.setTextureSize(128, 128); + plateConnector2.mirror = true; + setRotation(plateConnector2, 0F, 0F, 0F); + plateConnector = new ModelRenderer(this, 0, 75); + plateConnector.addBox(0F, 0F, 0F, 4, 2, 2); + plateConnector.setRotationPoint(-2F, 19F, -5.5F); + plateConnector.setTextureSize(128, 128); + plateConnector.mirror = true; + setRotation(plateConnector, 0F, 0F, 0F); + plate = new ModelRenderer(this, 42, 25); + plate.addBox(0F, 0F, 0F, 8, 8, 1); + plate.setRotationPoint(-4F, 12F, -8F); + plate.setTextureSize(128, 128); + plate.mirror = true; + setRotation(plate, 0F, 0F, 0F); + bladeCap = new ModelRenderer(this, 22, 0); + bladeCap.addBox(-1F, -1F, -8F, 2, 2, 1); + bladeCap.setRotationPoint(0F, -48F, 0F); + bladeCap.setTextureSize(128, 128); + bladeCap.mirror = true; + setRotation(bladeCap, 0F, 0F, 0F); + bladeCenter = new ModelRenderer(this, 20, 25); + bladeCenter.addBox(-2F, -2F, -7F, 4, 4, 3); + bladeCenter.setRotationPoint(0F, -48F, 0F); + bladeCenter.setTextureSize(128, 128); + bladeCenter.mirror = true; + setRotation(bladeCenter, 0F, 0F, 0F); + baseRim = new ModelRenderer(this, 26, 50); + baseRim.addBox(0F, 0F, 0F, 12, 2, 12); + baseRim.setRotationPoint(-6F, 21F, -6F); + baseRim.setTextureSize(128, 128); + baseRim.mirror = true; + setRotation(baseRim, 0F, 0F, 0F); + base = new ModelRenderer(this, 10, 64); + base.addBox(0F, 0F, 0F, 16, 2, 16); + base.setRotationPoint(-8F, 22F, -8F); + base.setTextureSize(128, 128); + base.mirror = true; + setRotation(base, 0F, 0F, 0F); + wire = new ModelRenderer(this, 74, 0); + wire.addBox(-1F, 0F, -1.1F, 2, 65, 2); + wire.setRotationPoint(0F, -46F, -1.5F); + wire.setTextureSize(128, 128); + wire.mirror = true; + setRotation(wire, -0.0349066F, 0F, 0F); + rearPlate1 = new ModelRenderer(this, 20, 16); + rearPlate1.addBox(-2.5F, -6F, 0F, 5, 6, 3); + rearPlate1.setRotationPoint(0F, -44.5F, 4F); + rearPlate1.setTextureSize(128, 128); + rearPlate1.mirror = true; + setRotation(rearPlate1, 0.122173F, 0F, 0F); + rearPlate2 = new ModelRenderer(this, 36, 16); + rearPlate2.addBox(-1.5F, -5F, -1F, 3, 5, 2); + rearPlate2.setRotationPoint(0F, -45F, 7F); + rearPlate2.setTextureSize(128, 128); + rearPlate2.mirror = true; + setRotation(rearPlate2, 0.2094395F, 0F, 0F); + blade1a = new ModelRenderer(this, 20, 32); + blade1a.addBox(-1F, -32F, 0F, 2, 32, 1); + blade1a.setRotationPoint(0F, -48F, -5.99F); + blade1a.setTextureSize(128, 128); + blade1a.mirror = true; + setRotation(blade1a, 0F, 0F, 0F); + blade2a = new ModelRenderer(this, 20, 32); + blade2a.addBox(-1F, 0F, 0F, 2, 32, 1); + blade2a.setRotationPoint(0F, -48F, -6F); + blade2a.setTextureSize(128, 128); + blade2a.mirror = true; + setRotation(blade2a, 0F, 0F, 1.047198F); + blade3a = new ModelRenderer(this, 20, 32); + blade3a.addBox(-1F, 0F, 0F, 2, 32, 1); + blade3a.setRotationPoint(0F, -48F, -6F); + blade3a.setTextureSize(128, 128); + blade3a.mirror = true; + setRotation(blade3a, 0F, 0F, -1.047198F); + blade1b = new ModelRenderer(this, 26, 32); + blade1b.addBox(-2F, -28F, 0F, 2, 28, 1); + blade1b.setRotationPoint(0F, -48F, -6F); + blade1b.setTextureSize(128, 128); + blade1b.mirror = true; + setRotation(blade1b, 0F, 0F, 0.0349066F); + blade2b = new ModelRenderer(this, 26, 32); + blade2b.addBox(0F, 0F, 0F, 2, 28, 1); + blade2b.setRotationPoint(0F, -48F, -6.01F); + blade2b.setTextureSize(128, 128); + blade2b.mirror = true; + setRotation(blade2b, 0F, 0F, 1.082104F); + blade3b = new ModelRenderer(this, 26, 32); + blade3b.addBox(0F, 0F, 0F, 2, 28, 1); + blade3b.setRotationPoint(0F, -48F, -6.01F); + blade3b.setTextureSize(128, 128); + blade3b.mirror = true; + setRotation(blade3b, 0F, 0F, -1.012291F); + post1a = new ModelRenderer(this, 0, 0); + post1a.addBox(-2.5F, 0F, -2.5F, 5, 68, 5); + post1a.setRotationPoint(0F, -46F, 0F); + post1a.setTextureSize(128, 128); + post1a.mirror = true; + setRotation(post1a, -0.0349066F, 0F, 0.0349066F); + post1b = new ModelRenderer(this, 0, 0); + post1b.addBox(-2.5F, 0F, -2.5F, 5, 68, 5); + post1b.setRotationPoint(0F, -46F, 0F); + post1b.setTextureSize(128, 128); + post1b.mirror = true; + setRotation(post1b, 0.0349066F, 0F, -0.0349066F); + post1c = new ModelRenderer(this, 0, 0); + post1c.addBox(-2.5F, 0F, -2.5F, 5, 68, 5); + post1c.setRotationPoint(0F, -46F, 0F); + post1c.setTextureSize(128, 128); + post1c.mirror = true; + setRotation(post1c, 0.0347321F, 0F, 0.0347321F); + post1d = new ModelRenderer(this, 0, 0); + post1d.addBox(-2.5F, 0F, -2.5F, 5, 68, 5); + post1d.setRotationPoint(0F, -46F, 0F); + post1d.setTextureSize(128, 128); + post1d.mirror = true; + setRotation(post1d, -0.0347321F, 0F, -0.0347321F); + } - public void render(float size, double angle) - { - head.render(size); - plateConnector2.render(size); - plateConnector.render(size); - plate.render(size); - baseRim.render(size); - base.render(size); - wire.render(size); - rearPlate1.render(size); - rearPlate2.render(size); - post1a.render(size); - post1b.render(size); - post1c.render(size); - post1d.render(size); - - setRotation(blade1a, 0F, 0F, getRotation(getAbsoluteAngle(angle))); - setRotation(blade1b, 0F, 0F, 0.0349066F + getRotation(getAbsoluteAngle(angle))); - - setRotation(blade2a, 0F, 0F, getRotation(getAbsoluteAngle(angle - 60))); - setRotation(blade2b, 0F, 0F, 0.0349066F + getRotation(getAbsoluteAngle(angle - 60))); - - setRotation(blade3a, 0F, 0F, getRotation(getAbsoluteAngle(angle + 60))); - setRotation(blade3b, 0F, 0F, 0.0349066F + getRotation(getAbsoluteAngle(angle + 60))); - - setRotation(bladeCap, 0F, 0F, getRotation(getAbsoluteAngle(angle))); - setRotation(bladeCenter, 0F, 0F, getRotation(getAbsoluteAngle(angle))); - - blade1a.render(size); - blade2a.render(size); - blade3a.render(size); - blade1b.render(size); - blade2b.render(size); - blade3b.render(size); - - bladeCap.render(size); - bladeCenter.render(size); - } + public void render(float size, double angle) { + head.render(size); + plateConnector2.render(size); + plateConnector.render(size); + plate.render(size); + baseRim.render(size); + base.render(size); + wire.render(size); + rearPlate1.render(size); + rearPlate2.render(size); + post1a.render(size); + post1b.render(size); + post1c.render(size); + post1d.render(size); - public float getRotation(double angle) - { - return ((float)angle / (float) 180) * (float)Math.PI; - } + setRotation(blade1a, 0F, 0F, getRotation(getAbsoluteAngle(angle))); + setRotation(blade1b, 0F, 0F, 0.0349066F + getRotation(getAbsoluteAngle(angle))); - public double getAbsoluteAngle(double angle) - { - return angle % 360; - } + setRotation(blade2a, 0F, 0F, getRotation(getAbsoluteAngle(angle - 60))); + setRotation( + blade2b, 0F, 0F, 0.0349066F + getRotation(getAbsoluteAngle(angle - 60)) + ); - private void setRotation(ModelRenderer model, float x, float y, float z) - { - model.rotateAngleX = x; - model.rotateAngleY = y; - model.rotateAngleZ = z; - } + setRotation(blade3a, 0F, 0F, getRotation(getAbsoluteAngle(angle + 60))); + setRotation( + blade3b, 0F, 0F, 0.0349066F + getRotation(getAbsoluteAngle(angle + 60)) + ); + + setRotation(bladeCap, 0F, 0F, getRotation(getAbsoluteAngle(angle))); + setRotation(bladeCenter, 0F, 0F, getRotation(getAbsoluteAngle(angle))); + + blade1a.render(size); + blade2a.render(size); + blade3a.render(size); + blade1b.render(size); + blade2b.render(size); + blade3b.render(size); + + bladeCap.render(size); + bladeCenter.render(size); + } + + public float getRotation(double angle) { + return ((float) angle / (float) 180) * (float) Math.PI; + } + + public double getAbsoluteAngle(double angle) { + return angle % 360; + } + + private void setRotation(ModelRenderer model, float x, float y, float z) { + model.rotateAngleX = x; + model.rotateAngleY = y; + model.rotateAngleZ = z; + } } diff --git a/src/main/java/mekanism/generators/client/render/RenderAdvancedSolarGenerator.java b/src/main/java/mekanism/generators/client/render/RenderAdvancedSolarGenerator.java index 781a5924e..de44ed483 100644 --- a/src/main/java/mekanism/generators/client/render/RenderAdvancedSolarGenerator.java +++ b/src/main/java/mekanism/generators/client/render/RenderAdvancedSolarGenerator.java @@ -1,45 +1,59 @@ package mekanism.generators.client.render; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import mekanism.generators.client.model.ModelAdvancedSolarGenerator; import mekanism.generators.common.tile.TileEntityAdvancedSolarGenerator; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class RenderAdvancedSolarGenerator extends TileEntitySpecialRenderer -{ - private ModelAdvancedSolarGenerator model = new ModelAdvancedSolarGenerator(); +public class RenderAdvancedSolarGenerator extends TileEntitySpecialRenderer { + private ModelAdvancedSolarGenerator model = new ModelAdvancedSolarGenerator(); - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntityAdvancedSolarGenerator)tileEntity, x, y, z, partialTick); - } + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt( + (TileEntityAdvancedSolarGenerator) tileEntity, x, y, z, partialTick + ); + } - private void renderAModelAt(TileEntityAdvancedSolarGenerator tileEntity, double x, double y, double z, float partialTick) - { - GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "AdvancedSolarGenerator.png")); + private void renderAModelAt( + TileEntityAdvancedSolarGenerator tileEntity, + double x, + double y, + double z, + float partialTick + ) { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); + bindTexture( + MekanismUtils.getResource(ResourceType.RENDER, "AdvancedSolarGenerator.png") + ); - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; - case 3: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; - case 4: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; - case 5: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; - } + switch (tileEntity.facing) { + case 2: + GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); + break; + case 3: + GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); + break; + case 4: + GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); + break; + case 5: + GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); + break; + } - GL11.glRotatef(180, 0F, 0F, 1F); + GL11.glRotatef(180, 0F, 0F, 1F); - model.render(0.0625F); - GL11.glPopMatrix(); - } + model.render(0.0625F); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/mekanism/generators/client/render/RenderBioGenerator.java b/src/main/java/mekanism/generators/client/render/RenderBioGenerator.java index 73bb3024f..743cf6258 100644 --- a/src/main/java/mekanism/generators/client/render/RenderBioGenerator.java +++ b/src/main/java/mekanism/generators/client/render/RenderBioGenerator.java @@ -3,6 +3,8 @@ package mekanism.generators.client.render; import java.util.HashMap; import java.util.Map; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.client.render.MekanismRenderer; import mekanism.client.render.MekanismRenderer.DisplayInteger; import mekanism.client.render.MekanismRenderer.Model3D; @@ -14,147 +16,143 @@ import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.init.Blocks; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class RenderBioGenerator extends TileEntitySpecialRenderer -{ - private ModelBioGenerator model = new ModelBioGenerator(); +public class RenderBioGenerator extends TileEntitySpecialRenderer { + private ModelBioGenerator model = new ModelBioGenerator(); - private Map energyDisplays = new HashMap(); + private Map energyDisplays + = new HashMap(); - private static final int stages = 40; + private static final int stages = 40; - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntityBioGenerator)tileEntity, x, y, z, partialTick); - } + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt((TileEntityBioGenerator) tileEntity, x, y, z, partialTick); + } - private void renderAModelAt(TileEntityBioGenerator tileEntity, double x, double y, double z, float partialTick) - { - if(tileEntity.bioFuelSlot.fluidStored > 0) - { - push(); + private void renderAModelAt( + TileEntityBioGenerator tileEntity, double x, double y, double z, float partialTick + ) { + if (tileEntity.bioFuelSlot.fluidStored > 0) { + push(); - MekanismRenderer.glowOn(); - GL11.glTranslatef((float)x, (float)y, (float)z); - bindTexture(MekanismRenderer.getBlocksTexture()); - getDisplayList(ForgeDirection.getOrientation(tileEntity.facing))[tileEntity.getScaledFuelLevel(stages-1)].render(); - MekanismRenderer.glowOff(); + MekanismRenderer.glowOn(); + GL11.glTranslatef((float) x, (float) y, (float) z); + bindTexture(MekanismRenderer.getBlocksTexture()); + getDisplayList(ForgeDirection.getOrientation(tileEntity.facing) + )[tileEntity.getScaledFuelLevel(stages - 1)] + .render(); + MekanismRenderer.glowOff(); - pop(); - } - - GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "BioGenerator.png")); + pop(); + } - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; - case 3: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; - case 4: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; - case 5: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; - } - - GL11.glRotatef(180, 0F, 0F, 1F); - model.render(0.0625F); - GL11.glPopMatrix(); - } + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); + bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "BioGenerator.png")); - @SuppressWarnings("incomplete-switch") - private DisplayInteger[] getDisplayList(ForgeDirection side) - { - if(energyDisplays.containsKey(side)) - { - return energyDisplays.get(side); - } + switch (tileEntity.facing) { + case 2: + GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); + break; + case 3: + GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); + break; + case 4: + GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); + break; + case 5: + GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); + break; + } - DisplayInteger[] displays = new DisplayInteger[stages]; + GL11.glRotatef(180, 0F, 0F, 1F); + model.render(0.0625F); + GL11.glPopMatrix(); + } - Model3D model3D = new Model3D(); - model3D.baseBlock = Blocks.water; - model3D.setTexture(MekanismRenderer.energyIcon); + @SuppressWarnings("incomplete-switch") + private DisplayInteger[] getDisplayList(ForgeDirection side) { + if (energyDisplays.containsKey(side)) { + return energyDisplays.get(side); + } - for(int i = 0; i < stages; i++) - { - displays[i] = DisplayInteger.createAndStart(); + DisplayInteger[] displays = new DisplayInteger[stages]; - switch(side) - { - case NORTH: - { - model3D.minZ = 0.5; - model3D.maxZ = 0.875; + Model3D model3D = new Model3D(); + model3D.baseBlock = Blocks.water; + model3D.setTexture(MekanismRenderer.energyIcon); - model3D.minX = 0.1875; - model3D.maxX = 0.8215; - model3D.minY = 0.4375; - model3D.maxY = 0.4375 + ((float)i/stages)*0.4375; - break; - } - case SOUTH: - { - model3D.minZ = 0.125; - model3D.maxZ = 0.5; + for (int i = 0; i < stages; i++) { + displays[i] = DisplayInteger.createAndStart(); - model3D.minX = 0.1875; - model3D.maxX = 0.8215; - model3D.minY = 0.4375; - model3D.maxY = 0.4375 + ((float)i/stages)*0.4375; - break; - } - case WEST: - { - model3D.minX = 0.5; - model3D.maxX = 0.875; + switch (side) { + case NORTH: { + model3D.minZ = 0.5; + model3D.maxZ = 0.875; - model3D.minZ = 0.1875; - model3D.maxZ = 0.8215; - model3D.minY = 0.4375; - model3D.maxY = 0.4375 + ((float)i/stages)*0.4375; - break; - } - case EAST: - { - model3D.minX = 0.125; - model3D.maxX = 0.5; + model3D.minX = 0.1875; + model3D.maxX = 0.8215; + model3D.minY = 0.4375; + model3D.maxY = 0.4375 + ((float) i / stages) * 0.4375; + break; + } + case SOUTH: { + model3D.minZ = 0.125; + model3D.maxZ = 0.5; - model3D.minZ = 0.1875; - model3D.maxZ = 0.8215; - model3D.minY = 0.4375; - model3D.maxY = 0.4375 + ((float)i/stages)*0.4375; - break; - } - } + model3D.minX = 0.1875; + model3D.maxX = 0.8215; + model3D.minY = 0.4375; + model3D.maxY = 0.4375 + ((float) i / stages) * 0.4375; + break; + } + case WEST: { + model3D.minX = 0.5; + model3D.maxX = 0.875; - MekanismRenderer.renderObject(model3D); - displays[i].endList(); - } + model3D.minZ = 0.1875; + model3D.maxZ = 0.8215; + model3D.minY = 0.4375; + model3D.maxY = 0.4375 + ((float) i / stages) * 0.4375; + break; + } + case EAST: { + model3D.minX = 0.125; + model3D.maxX = 0.5; - energyDisplays.put(side, displays); + model3D.minZ = 0.1875; + model3D.maxZ = 0.8215; + model3D.minY = 0.4375; + model3D.maxY = 0.4375 + ((float) i / stages) * 0.4375; + break; + } + } - return displays; - } + MekanismRenderer.renderObject(model3D); + displays[i].endList(); + } - private void pop() - { - GL11.glPopAttrib(); - GL11.glPopMatrix(); - } + energyDisplays.put(side, displays); - private void push() - { - GL11.glPushMatrix(); - GL11.glPushAttrib(GL11.GL_ENABLE_BIT); - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glEnable(GL11.GL_BLEND); - GL11.glDisable(GL11.GL_LIGHTING); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - } + return displays; + } + + private void pop() { + GL11.glPopAttrib(); + GL11.glPopMatrix(); + } + + private void push() { + GL11.glPushMatrix(); + GL11.glPushAttrib(GL11.GL_ENABLE_BIT); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_BLEND); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + } } diff --git a/src/main/java/mekanism/generators/client/render/RenderGasGenerator.java b/src/main/java/mekanism/generators/client/render/RenderGasGenerator.java index 3cab83c32..638f94aaa 100644 --- a/src/main/java/mekanism/generators/client/render/RenderGasGenerator.java +++ b/src/main/java/mekanism/generators/client/render/RenderGasGenerator.java @@ -1,46 +1,52 @@ package mekanism.generators.client.render; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import mekanism.generators.client.model.ModelGasGenerator; import mekanism.generators.common.tile.TileEntityGasGenerator; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class RenderGasGenerator extends TileEntitySpecialRenderer -{ - private ModelGasGenerator model = new ModelGasGenerator(); +public class RenderGasGenerator extends TileEntitySpecialRenderer { + private ModelGasGenerator model = new ModelGasGenerator(); - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntityGasGenerator)tileEntity, x, y, z, partialTick); - } + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt((TileEntityGasGenerator) tileEntity, x, y, z, partialTick); + } - private void renderAModelAt(TileEntityGasGenerator tileEntity, double x, double y, double z, float partialTick) - { - GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "GasGenerator.png")); + private void renderAModelAt( + TileEntityGasGenerator tileEntity, double x, double y, double z, float partialTick + ) { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); + bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "GasGenerator.png")); - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; - case 3: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; - case 4: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; - case 5: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; - } + switch (tileEntity.facing) { + case 2: + GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); + break; + case 3: + GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); + break; + case 4: + GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); + break; + case 5: + GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); + break; + } - GL11.glRotatef(180F, 0.0F, 1.0F, 1.0F); - GL11.glRotatef(90F, -1.0F, 0.0F, 0.0F); - GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); - model.render(0.0625F); - GL11.glPopMatrix(); - } + GL11.glRotatef(180F, 0.0F, 1.0F, 1.0F); + GL11.glRotatef(90F, -1.0F, 0.0F, 0.0F); + GL11.glRotatef(90F, 0.0F, 1.0F, 0.0F); + model.render(0.0625F); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/mekanism/generators/client/render/RenderHeatGenerator.java b/src/main/java/mekanism/generators/client/render/RenderHeatGenerator.java index 2c1886223..fbf783986 100644 --- a/src/main/java/mekanism/generators/client/render/RenderHeatGenerator.java +++ b/src/main/java/mekanism/generators/client/render/RenderHeatGenerator.java @@ -1,44 +1,54 @@ package mekanism.generators.client.render; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import mekanism.generators.client.model.ModelHeatGenerator; import mekanism.generators.common.tile.TileEntityHeatGenerator; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class RenderHeatGenerator extends TileEntitySpecialRenderer -{ - private ModelHeatGenerator model = new ModelHeatGenerator(); +public class RenderHeatGenerator extends TileEntitySpecialRenderer { + private ModelHeatGenerator model = new ModelHeatGenerator(); - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntityHeatGenerator)tileEntity, x, y, z, partialTick); - } + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt((TileEntityHeatGenerator) tileEntity, x, y, z, partialTick); + } - private void renderAModelAt(TileEntityHeatGenerator tileEntity, double x, double y, double z, float partialTick) - { - GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "HeatGenerator.png")); + private void renderAModelAt( + TileEntityHeatGenerator tileEntity, + double x, + double y, + double z, + float partialTick + ) { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); + bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "HeatGenerator.png")); - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; - case 3: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; - case 4: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; - case 5: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; - } + switch (tileEntity.facing) { + case 2: + GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); + break; + case 3: + GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); + break; + case 4: + GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); + break; + case 5: + GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); + break; + } - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - model.render(0.0625F, tileEntity.isActive, field_147501_a.field_147553_e); - GL11.glPopMatrix(); - } + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + model.render(0.0625F, tileEntity.isActive, field_147501_a.field_147553_e); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/mekanism/generators/client/render/RenderIndustrialTurbine.java b/src/main/java/mekanism/generators/client/render/RenderIndustrialTurbine.java index ae96b19f8..5c8d5b814 100644 --- a/src/main/java/mekanism/generators/client/render/RenderIndustrialTurbine.java +++ b/src/main/java/mekanism/generators/client/render/RenderIndustrialTurbine.java @@ -3,6 +3,8 @@ package mekanism.generators.client.render; import java.util.HashMap; import java.util.Map; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.client.render.MekanismRenderer; import mekanism.client.render.MekanismRenderer.DisplayInteger; @@ -19,153 +21,163 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidRegistry; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class RenderIndustrialTurbine extends TileEntitySpecialRenderer -{ - private static Map cachedFluids = new HashMap(); - - private Fluid STEAM = FluidRegistry.getFluid("steam"); - - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntityTurbineCasing)tileEntity, x, y, z, partialTick); - } +public class RenderIndustrialTurbine extends TileEntitySpecialRenderer { + private static Map cachedFluids + = new HashMap(); - public void renderAModelAt(TileEntityTurbineCasing tileEntity, double x, double y, double z, float partialTick) - { - if(tileEntity.clientHasStructure && tileEntity.isRendering && tileEntity.structure != null && tileEntity.structure.complex != null) - { - RenderTurbineRotor.internalRender = true; - Coord4D coord = tileEntity.structure.complex; - - while(true) - { - coord = coord.getFromSide(ForgeDirection.DOWN); - TileEntity tile = coord.getTileEntity(tileEntity.getWorldObj()); - - if(!(tile instanceof TileEntityTurbineRotor)) - { - break; - } - - TileEntityRendererDispatcher.instance.renderTileEntity(tile, partialTick); - } - - RenderTurbineRotor.internalRender = false; - - if(tileEntity.structure.fluidStored != null && tileEntity.structure.fluidStored.amount != 0 && tileEntity.structure.volLength > 0) - { - RenderData data = new RenderData(); - - data.location = tileEntity.structure.renderLocation; - data.height = tileEntity.structure.lowerVolume/(tileEntity.structure.volLength*tileEntity.structure.volWidth); - data.length = tileEntity.structure.volLength; - data.width = tileEntity.structure.volWidth; - - bindTexture(MekanismRenderer.getBlocksTexture()); - - if(data.location != null && data.height >= 1 && tileEntity.structure.fluidStored.getFluid() != null) - { - push(); - - GL11.glTranslated(getX(data.location.xCoord), getY(data.location.yCoord), getZ(data.location.zCoord)); - - MekanismRenderer.glowOn(tileEntity.structure.fluidStored.getFluid().getLuminosity()); - MekanismRenderer.colorFluid(tileEntity.structure.fluidStored.getFluid()); - - DisplayInteger display = getListAndRender(data, tileEntity.getWorldObj()); - - GL11.glColor4f(1F, 1F, 1F, Math.min(1, ((float)tileEntity.structure.fluidStored.amount / (float)tileEntity.structure.getFluidCapacity())+MekanismRenderer.GAS_RENDER_BASE)); - display.render(); - - MekanismRenderer.glowOff(); - MekanismRenderer.resetColor(); - - pop(); - } - } - } - } - - private void pop() - { - GL11.glDisable(GL11.GL_CULL_FACE); - GL11.glDisable(GL11.GL_BLEND); - GL11.glPopMatrix(); - } + private Fluid STEAM = FluidRegistry.getFluid("steam"); - private void push() - { - GL11.glPushMatrix(); - - GL11.glEnable(GL11.GL_CULL_FACE); - GL11.glEnable(GL11.GL_BLEND); - GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); - } - - private int getStages(int height) - { - return TankUpdateProtocol.FLUID_PER_TANK/10; - } + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt((TileEntityTurbineCasing) tileEntity, x, y, z, partialTick); + } - private double getX(int x) - { - return x - TileEntityRendererDispatcher.staticPlayerX; - } + public void renderAModelAt( + TileEntityTurbineCasing tileEntity, + double x, + double y, + double z, + float partialTick + ) { + if (tileEntity.clientHasStructure && tileEntity.isRendering + && tileEntity.structure != null && tileEntity.structure.complex != null) { + RenderTurbineRotor.internalRender = true; + Coord4D coord = tileEntity.structure.complex; - private double getY(int y) - { - return y - TileEntityRendererDispatcher.staticPlayerY; - } + while (true) { + coord = coord.getFromSide(ForgeDirection.DOWN); + TileEntity tile = coord.getTileEntity(tileEntity.getWorldObj()); - private double getZ(int z) - { - return z - TileEntityRendererDispatcher.staticPlayerZ; - } - - private DisplayInteger getListAndRender(RenderData data, World world) - { - if(cachedFluids.containsKey(data)) - { - return cachedFluids.get(data); - } + if (!(tile instanceof TileEntityTurbineRotor)) { + break; + } - Model3D toReturn = new Model3D(); - toReturn.baseBlock = Blocks.water; - toReturn.setTexture(STEAM.getIcon()); + TileEntityRendererDispatcher.instance.renderTileEntity(tile, partialTick); + } - final int stages = getStages(data.height); - DisplayInteger display = DisplayInteger.createAndStart(); + RenderTurbineRotor.internalRender = false; - cachedFluids.put(data, display); - - if(STEAM.getIcon() != null) - { - toReturn.minX = 0 + .01; - toReturn.minY = 0 + .01; - toReturn.minZ = 0 + .01; + if (tileEntity.structure.fluidStored != null + && tileEntity.structure.fluidStored.amount != 0 + && tileEntity.structure.volLength > 0) { + RenderData data = new RenderData(); - toReturn.maxX = data.length - .01; - toReturn.maxY = data.height - .01; - toReturn.maxZ = data.width - .01; + data.location = tileEntity.structure.renderLocation; + data.height = tileEntity.structure.lowerVolume + / (tileEntity.structure.volLength * tileEntity.structure.volWidth); + data.length = tileEntity.structure.volLength; + data.width = tileEntity.structure.volWidth; - MekanismRenderer.renderObject(toReturn); - } + bindTexture(MekanismRenderer.getBlocksTexture()); - GL11.glEndList(); + if (data.location != null && data.height >= 1 + && tileEntity.structure.fluidStored.getFluid() != null) { + push(); - return display; - } - - public static void resetDisplayInts() - { - cachedFluids.clear(); - } + GL11.glTranslated( + getX(data.location.xCoord), + getY(data.location.yCoord), + getZ(data.location.zCoord) + ); + + MekanismRenderer.glowOn( + tileEntity.structure.fluidStored.getFluid().getLuminosity() + ); + MekanismRenderer.colorFluid(tileEntity.structure.fluidStored.getFluid( + )); + + DisplayInteger display + = getListAndRender(data, tileEntity.getWorldObj()); + + GL11.glColor4f( + 1F, + 1F, + 1F, + Math.min( + 1, + ((float) tileEntity.structure.fluidStored.amount + / (float) tileEntity.structure.getFluidCapacity()) + + MekanismRenderer.GAS_RENDER_BASE + ) + ); + display.render(); + + MekanismRenderer.glowOff(); + MekanismRenderer.resetColor(); + + pop(); + } + } + } + } + + private void pop() { + GL11.glDisable(GL11.GL_CULL_FACE); + GL11.glDisable(GL11.GL_BLEND); + GL11.glPopMatrix(); + } + + private void push() { + GL11.glPushMatrix(); + + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_BLEND); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + } + + private int getStages(int height) { + return TankUpdateProtocol.FLUID_PER_TANK / 10; + } + + private double getX(int x) { + return x - TileEntityRendererDispatcher.staticPlayerX; + } + + private double getY(int y) { + return y - TileEntityRendererDispatcher.staticPlayerY; + } + + private double getZ(int z) { + return z - TileEntityRendererDispatcher.staticPlayerZ; + } + + private DisplayInteger getListAndRender(RenderData data, World world) { + if (cachedFluids.containsKey(data)) { + return cachedFluids.get(data); + } + + Model3D toReturn = new Model3D(); + toReturn.baseBlock = Blocks.water; + toReturn.setTexture(STEAM.getIcon()); + + final int stages = getStages(data.height); + DisplayInteger display = DisplayInteger.createAndStart(); + + cachedFluids.put(data, display); + + if (STEAM.getIcon() != null) { + toReturn.minX = 0 + .01; + toReturn.minY = 0 + .01; + toReturn.minZ = 0 + .01; + + toReturn.maxX = data.length - .01; + toReturn.maxY = data.height - .01; + toReturn.maxZ = data.width - .01; + + MekanismRenderer.renderObject(toReturn); + } + + GL11.glEndList(); + + return display; + } + + public static void resetDisplayInts() { + cachedFluids.clear(); + } } diff --git a/src/main/java/mekanism/generators/client/render/RenderReactor.java b/src/main/java/mekanism/generators/client/render/RenderReactor.java index f8c1ae76c..d5dccf0c7 100644 --- a/src/main/java/mekanism/generators/client/render/RenderReactor.java +++ b/src/main/java/mekanism/generators/client/render/RenderReactor.java @@ -1,5 +1,7 @@ package mekanism.generators.client.render; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.EnumColor; import mekanism.client.MekanismClient; import mekanism.client.model.ModelEnergyCube.ModelEnergyCore; @@ -9,75 +11,106 @@ import mekanism.common.util.MekanismUtils.ResourceType; import mekanism.generators.common.tile.reactor.TileEntityReactorController; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class RenderReactor extends TileEntitySpecialRenderer -{ - private ModelEnergyCore core = new ModelEnergyCore(); +public class RenderReactor extends TileEntitySpecialRenderer { + private ModelEnergyCore core = new ModelEnergyCore(); - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntityReactorController)tileEntity, x, y, z, partialTick); - } + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt((TileEntityReactorController) tileEntity, x, y, z, partialTick); + } - private void renderAModelAt(TileEntityReactorController tileEntity, double x, double y, double z, float partialTick) - { - if(tileEntity.isBurning()) - { - GL11.glPushMatrix(); - GL11.glTranslated(x + 0.5, y - 1.5, z + 0.5); - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "EnergyCore.png")); + private void renderAModelAt( + TileEntityReactorController tileEntity, + double x, + double y, + double z, + float partialTick + ) { + if (tileEntity.isBurning()) { + GL11.glPushMatrix(); + GL11.glTranslated(x + 0.5, y - 1.5, z + 0.5); + bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "EnergyCore.png")); - MekanismRenderer.blendOn(); - MekanismRenderer.glowOn(); + MekanismRenderer.blendOn(); + MekanismRenderer.glowOn(); - EnumColor c; - double scale; - long scaledTemp = Math.round(tileEntity.getPlasmaTemp() / 1E8); + EnumColor c; + double scale; + long scaledTemp = Math.round(tileEntity.getPlasmaTemp() / 1E8); - c = EnumColor.AQUA; + c = EnumColor.AQUA; - GL11.glPushMatrix(); - scale = 1 + 0.7 * Math.sin(Math.toRadians((MekanismClient.ticksPassed + partialTick) * 3.14 * scaledTemp + 135F)); - GL11.glScaled(scale, scale, scale); - GL11.glColor4f(c.getColor(0), c.getColor(1), c.getColor(2), 1); - GL11.glRotatef((MekanismClient.ticksPassed + partialTick) * -6 * scaledTemp, 0, 1, 0); - GL11.glRotatef(36F + (MekanismClient.ticksPassed + partialTick) * -7 * scaledTemp, 0, 1, 1); - core.render(0.0625F); - GL11.glPopMatrix(); + GL11.glPushMatrix(); + scale = 1 + + 0.7 + * Math.sin(Math.toRadians( + (MekanismClient.ticksPassed + partialTick) * 3.14 * scaledTemp + + 135F + )); + GL11.glScaled(scale, scale, scale); + GL11.glColor4f(c.getColor(0), c.getColor(1), c.getColor(2), 1); + GL11.glRotatef( + (MekanismClient.ticksPassed + partialTick) * -6 * scaledTemp, 0, 1, 0 + ); + GL11.glRotatef( + 36F + (MekanismClient.ticksPassed + partialTick) * -7 * scaledTemp, + 0, + 1, + 1 + ); + core.render(0.0625F); + GL11.glPopMatrix(); - c = EnumColor.RED; + c = EnumColor.RED; - GL11.glPushMatrix(); - scale = 1 + 0.8 * Math.sin(Math.toRadians((MekanismClient.ticksPassed + partialTick) * 3 * scaledTemp)); - GL11.glScaled(scale, scale, scale); - GL11.glColor4f(c.getColor(0), c.getColor(1), c.getColor(2), 1); - GL11.glRotatef((MekanismClient.ticksPassed + partialTick) * 4 * scaledTemp, 0, 1, 0); - GL11.glRotatef(36F + (MekanismClient.ticksPassed + partialTick) * 4 * scaledTemp, 0, 1, 1); - core.render(0.0625F); - GL11.glPopMatrix(); + GL11.glPushMatrix(); + scale = 1 + + 0.8 + * Math.sin(Math.toRadians( + (MekanismClient.ticksPassed + partialTick) * 3 * scaledTemp + )); + GL11.glScaled(scale, scale, scale); + GL11.glColor4f(c.getColor(0), c.getColor(1), c.getColor(2), 1); + GL11.glRotatef( + (MekanismClient.ticksPassed + partialTick) * 4 * scaledTemp, 0, 1, 0 + ); + GL11.glRotatef( + 36F + (MekanismClient.ticksPassed + partialTick) * 4 * scaledTemp, 0, 1, 1 + ); + core.render(0.0625F); + GL11.glPopMatrix(); - c = EnumColor.ORANGE; + c = EnumColor.ORANGE; - GL11.glPushMatrix(); - scale = 1 - 0.9 * Math.sin(Math.toRadians((MekanismClient.ticksPassed + partialTick) * 4 * scaledTemp + 90F)); - GL11.glScaled(scale, scale, scale); - GL11.glColor4f(c.getColor(0), c.getColor(1), c.getColor(2), 1); - GL11.glRotatef((MekanismClient.ticksPassed + partialTick) * 5 * scaledTemp - 35F, 0, 1, 0); - GL11.glRotatef(36F + (MekanismClient.ticksPassed + partialTick) * -3 * scaledTemp + 70F, 0, 1, 1); - core.render(0.0625F); - GL11.glPopMatrix(); + GL11.glPushMatrix(); + scale = 1 + - 0.9 + * Math.sin(Math.toRadians( + (MekanismClient.ticksPassed + partialTick) * 4 * scaledTemp + 90F + )); + GL11.glScaled(scale, scale, scale); + GL11.glColor4f(c.getColor(0), c.getColor(1), c.getColor(2), 1); + GL11.glRotatef( + (MekanismClient.ticksPassed + partialTick) * 5 * scaledTemp - 35F, 0, 1, 0 + ); + GL11.glRotatef( + 36F + (MekanismClient.ticksPassed + partialTick) * -3 * scaledTemp + 70F, + 0, + 1, + 1 + ); + core.render(0.0625F); + GL11.glPopMatrix(); - MekanismRenderer.glowOff(); - MekanismRenderer.blendOff(); + MekanismRenderer.glowOff(); + MekanismRenderer.blendOff(); - GL11.glPopMatrix(); - } - } + GL11.glPopMatrix(); + } + } } diff --git a/src/main/java/mekanism/generators/client/render/RenderSolarGenerator.java b/src/main/java/mekanism/generators/client/render/RenderSolarGenerator.java index e4c90d06f..273cc3b93 100644 --- a/src/main/java/mekanism/generators/client/render/RenderSolarGenerator.java +++ b/src/main/java/mekanism/generators/client/render/RenderSolarGenerator.java @@ -6,28 +6,32 @@ import mekanism.generators.client.model.ModelSolarGenerator; import mekanism.generators.common.tile.TileEntitySolarGenerator; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; - import org.lwjgl.opengl.GL11; -public class RenderSolarGenerator extends TileEntitySpecialRenderer -{ - private ModelSolarGenerator model = new ModelSolarGenerator(); +public class RenderSolarGenerator extends TileEntitySpecialRenderer { + private ModelSolarGenerator model = new ModelSolarGenerator(); - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntitySolarGenerator)tileEntity, x, y, z, partialTick); - } + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt((TileEntitySolarGenerator) tileEntity, x, y, z, partialTick); + } - private void renderAModelAt(TileEntitySolarGenerator tileEntity, double x, double y, double z, float partialTick) - { - GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); + private void renderAModelAt( + TileEntitySolarGenerator tileEntity, + double x, + double y, + double z, + float partialTick + ) { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "SolarGenerator.png")); + bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "SolarGenerator.png")); - GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); - model.render(0.0625F); - GL11.glPopMatrix(); - } + GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); + model.render(0.0625F); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/mekanism/generators/client/render/RenderTurbineRotor.java b/src/main/java/mekanism/generators/client/render/RenderTurbineRotor.java index 6c95d1839..d2eeb86fa 100644 --- a/src/main/java/mekanism/generators/client/render/RenderTurbineRotor.java +++ b/src/main/java/mekanism/generators/client/render/RenderTurbineRotor.java @@ -1,5 +1,7 @@ package mekanism.generators.client.render; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.common.Mekanism; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; @@ -8,70 +10,73 @@ import mekanism.generators.common.content.turbine.SynchronizedTurbineData; import mekanism.generators.common.tile.turbine.TileEntityTurbineRotor; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class RenderTurbineRotor extends TileEntitySpecialRenderer -{ - public static boolean internalRender = false; - - private ModelTurbine model = new ModelTurbine(); - - private static final float BASE_SPEED = 512F; +public class RenderTurbineRotor extends TileEntitySpecialRenderer { + public static boolean internalRender = false; - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntityTurbineRotor)tileEntity, x, y, z, partialTick); - } + private ModelTurbine model = new ModelTurbine(); - private void renderAModelAt(TileEntityTurbineRotor tileEntity, double x, double y, double z, float partialTick) - { - if(tileEntity.multiblockUUID != null && !internalRender) - { - return; - } - - GL11.glPushMatrix(); - - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "Turbine.png")); - - int baseIndex = tileEntity.clientIndex*2; - float rotateSpeed = 0.0F; - - if(tileEntity.multiblockUUID != null && SynchronizedTurbineData.clientRotationMap.containsKey(tileEntity.multiblockUUID)) - { - rotateSpeed = SynchronizedTurbineData.clientRotationMap.get(tileEntity.multiblockUUID); - } - - if(!Mekanism.proxy.isPaused()) - { - tileEntity.rotationLower = (tileEntity.rotationLower + rotateSpeed*BASE_SPEED*(1F/(float)(baseIndex+1))) % 360; - tileEntity.rotationUpper = (tileEntity.rotationUpper + rotateSpeed*BASE_SPEED*(1F/(float)(baseIndex+2))) % 360; - } - - if(tileEntity.getHousedBlades() > 0) - { - GL11.glPushMatrix(); - GL11.glTranslated(x + 0.5, y - 1, z + 0.5); - GL11.glRotatef(tileEntity.rotationLower, 0.0F, 1.0F, 0.0F); - model.render(0.0625F, baseIndex); - GL11.glPopMatrix(); - } - - if(tileEntity.getHousedBlades() == 2) - { - GL11.glPushMatrix(); - GL11.glTranslated(x + 0.5, y - 0.5, z + 0.5); - GL11.glRotatef(tileEntity.rotationUpper, 0.0F, 1.0F, 0.0F); - model.render(0.0625F, baseIndex+1); - GL11.glPopMatrix(); - } - - GL11.glPopMatrix(); - } + private static final float BASE_SPEED = 512F; + + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt((TileEntityTurbineRotor) tileEntity, x, y, z, partialTick); + } + + private void renderAModelAt( + TileEntityTurbineRotor tileEntity, double x, double y, double z, float partialTick + ) { + if (tileEntity.multiblockUUID != null && !internalRender) { + return; + } + + GL11.glPushMatrix(); + + bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "Turbine.png")); + + int baseIndex = tileEntity.clientIndex * 2; + float rotateSpeed = 0.0F; + + if (tileEntity.multiblockUUID != null + && SynchronizedTurbineData.clientRotationMap.containsKey( + tileEntity.multiblockUUID + )) { + rotateSpeed + = SynchronizedTurbineData.clientRotationMap.get(tileEntity.multiblockUUID + ); + } + + if (!Mekanism.proxy.isPaused()) { + tileEntity.rotationLower + = (tileEntity.rotationLower + + rotateSpeed * BASE_SPEED * (1F / (float) (baseIndex + 1))) + % 360; + tileEntity.rotationUpper + = (tileEntity.rotationUpper + + rotateSpeed * BASE_SPEED * (1F / (float) (baseIndex + 2))) + % 360; + } + + if (tileEntity.getHousedBlades() > 0) { + GL11.glPushMatrix(); + GL11.glTranslated(x + 0.5, y - 1, z + 0.5); + GL11.glRotatef(tileEntity.rotationLower, 0.0F, 1.0F, 0.0F); + model.render(0.0625F, baseIndex); + GL11.glPopMatrix(); + } + + if (tileEntity.getHousedBlades() == 2) { + GL11.glPushMatrix(); + GL11.glTranslated(x + 0.5, y - 0.5, z + 0.5); + GL11.glRotatef(tileEntity.rotationUpper, 0.0F, 1.0F, 0.0F); + model.render(0.0625F, baseIndex + 1); + GL11.glPopMatrix(); + } + + GL11.glPopMatrix(); + } } diff --git a/src/main/java/mekanism/generators/client/render/RenderWindGenerator.java b/src/main/java/mekanism/generators/client/render/RenderWindGenerator.java index 610ef98ef..544314a7b 100644 --- a/src/main/java/mekanism/generators/client/render/RenderWindGenerator.java +++ b/src/main/java/mekanism/generators/client/render/RenderWindGenerator.java @@ -7,41 +7,52 @@ import mekanism.generators.client.model.ModelWindGenerator; import mekanism.generators.common.tile.TileEntityWindGenerator; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; - import org.lwjgl.opengl.GL11; -public class RenderWindGenerator extends TileEntitySpecialRenderer -{ - private ModelWindGenerator model = new ModelWindGenerator(); +public class RenderWindGenerator extends TileEntitySpecialRenderer { + private ModelWindGenerator model = new ModelWindGenerator(); - @Override - public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float partialTick) - { - renderAModelAt((TileEntityWindGenerator)tileEntity, x, y, z, partialTick); - } + @Override + public void renderTileEntityAt( + TileEntity tileEntity, double x, double y, double z, float partialTick + ) { + renderAModelAt((TileEntityWindGenerator) tileEntity, x, y, z, partialTick); + } - private void renderAModelAt(TileEntityWindGenerator tileEntity, double x, double y, double z, float partialTick) - { - GL11.glPushMatrix(); - GL11.glTranslatef((float)x + 0.5F, (float)y + 1.5F, (float)z + 0.5F); - bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "WindGenerator.png")); + private void renderAModelAt( + TileEntityWindGenerator tileEntity, + double x, + double y, + double z, + float partialTick + ) { + GL11.glPushMatrix(); + GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); + bindTexture(MekanismUtils.getResource(ResourceType.RENDER, "WindGenerator.png")); - switch(tileEntity.facing) - { - case 2: GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); break; - case 3: GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); break; - case 4: GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); break; - case 5: GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); break; - } + switch (tileEntity.facing) { + case 2: + GL11.glRotatef(0, 0.0F, 1.0F, 0.0F); + break; + case 3: + GL11.glRotatef(180, 0.0F, 1.0F, 0.0F); + break; + case 4: + GL11.glRotatef(90, 0.0F, 1.0F, 0.0F); + break; + case 5: + GL11.glRotatef(270, 0.0F, 1.0F, 0.0F); + break; + } - GL11.glRotatef(180, 0F, 0F, 1F); + GL11.glRotatef(180, 0F, 0F, 1F); - if(!Mekanism.proxy.isPaused() && tileEntity.getActive()) - { - tileEntity.angle = (tileEntity.angle+((tileEntity.yCoord+4F)/256F)*8) % 360; - } + if (!Mekanism.proxy.isPaused() && tileEntity.getActive()) { + tileEntity.angle + = (tileEntity.angle + ((tileEntity.yCoord + 4F) / 256F) * 8) % 360; + } - model.render(0.0625F, tileEntity.angle); - GL11.glPopMatrix(); - } + model.render(0.0625F, tileEntity.angle); + GL11.glPopMatrix(); + } } diff --git a/src/main/java/mekanism/generators/client/render/item/GeneratorsItemRenderer.java b/src/main/java/mekanism/generators/client/render/item/GeneratorsItemRenderer.java index d233e4906..917ee6bda 100644 --- a/src/main/java/mekanism/generators/client/render/item/GeneratorsItemRenderer.java +++ b/src/main/java/mekanism/generators/client/render/item/GeneratorsItemRenderer.java @@ -1,46 +1,46 @@ package mekanism.generators.client.render.item; +import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.generators.client.GeneratorsClientProxy; import mekanism.generators.common.item.ItemBlockGenerator; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.item.ItemStack; import net.minecraftforge.client.IItemRenderer; - import org.lwjgl.opengl.GL11; -import cpw.mods.fml.client.registry.RenderingRegistry; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - @SideOnly(Side.CLIENT) -public class GeneratorsItemRenderer implements IItemRenderer -{ - @Override - public boolean handleRenderType(ItemStack item, ItemRenderType type) - { - return true; - } +public class GeneratorsItemRenderer implements IItemRenderer { + @Override + public boolean handleRenderType(ItemStack item, ItemRenderType type) { + return true; + } - @Override - public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRendererHelper helper) - { - return true; - } - - @Override - public void renderItem(ItemRenderType type, ItemStack item, Object... data) - { - RenderBlocks renderBlocks = (RenderBlocks)data[0]; + @Override + public boolean shouldUseRenderHelper( + ItemRenderType type, ItemStack item, ItemRendererHelper helper + ) { + return true; + } - if(type == ItemRenderType.EQUIPPED || type == ItemRenderType.EQUIPPED_FIRST_PERSON) - { - GL11.glTranslatef(0.5F, 0.5F, 0.5F); - } - - if(item.getItem() instanceof ItemBlockGenerator) - { - RenderingRegistry.instance().renderInventoryBlock((RenderBlocks)data[0], Block.getBlockFromItem(item.getItem()), item.getItemDamage(), GeneratorsClientProxy.GENERATOR_RENDER_ID); - } - } + @Override + public void renderItem(ItemRenderType type, ItemStack item, Object... data) { + RenderBlocks renderBlocks = (RenderBlocks) data[0]; + + if (type == ItemRenderType.EQUIPPED + || type == ItemRenderType.EQUIPPED_FIRST_PERSON) { + GL11.glTranslatef(0.5F, 0.5F, 0.5F); + } + + if (item.getItem() instanceof ItemBlockGenerator) { + RenderingRegistry.instance().renderInventoryBlock( + (RenderBlocks) data[0], + Block.getBlockFromItem(item.getItem()), + item.getItemDamage(), + GeneratorsClientProxy.GENERATOR_RENDER_ID + ); + } + } } diff --git a/src/main/java/mekanism/generators/common/FusionReactor.java b/src/main/java/mekanism/generators/common/FusionReactor.java index 9ac0ce704..cf2f8e8b7 100644 --- a/src/main/java/mekanism/generators/common/FusionReactor.java +++ b/src/main/java/mekanism/generators/common/FusionReactor.java @@ -33,598 +33,584 @@ import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; -public class FusionReactor implements IFusionReactor -{ - public TileEntityReactorController controller; - public Set reactorBlocks = new HashSet(); - public Set neutronCaptors = new HashSet(); - public Set heatTransfers = new HashSet(); - - //Current stores of temperature - internally uses ambient-relative kelvin units - public double plasmaTemperature; - public double caseTemperature; - - //Last values of temperature - public double lastPlasmaTemperature; - public double lastCaseTemperature; - - public double heatToAbsorb = 0; - - //Reaction characteristics - public static double burnTemperature = TemperatureUnit.AMBIENT.convertFromK(1E8, true); - public static double burnRatio = 1; - public static double energyPerFuel = 5E6; - public int injectionRate = 0; - - //Thermal characteristics - public static double plasmaHeatCapacity = 100; - public static double caseHeatCapacity = 1; - public static double enthalpyOfVaporization = 10; - public static double thermocoupleEfficiency = 0.00125; - public static double steamTransferEfficiency = 0.0025; - - //Heat transfer metrics - public static double plasmaCaseConductivity = 0.2; - public static double caseWaterConductivity = 0.3; - public static double caseAirConductivity = 0.1; - - public boolean burning = false; - public boolean activelyCooled = true; - - public boolean updatedThisTick; - - public boolean formed = false; - - public FusionReactor(TileEntityReactorController c) - { - controller = c; - } - - @Override - public void addTemperatureFromEnergyInput(double energyAdded) - { - plasmaTemperature += energyAdded / plasmaHeatCapacity * (isBurning() ? 1 : 10); - } - - public boolean hasHohlraum() - { - if(controller != null) - { - ItemStack hohlraum = controller.inventory[0]; - - if(hohlraum != null && hohlraum.getItem() instanceof ItemHohlraum) - { - GasStack gasStack = ((ItemHohlraum)hohlraum.getItem()).getGas(hohlraum); - return gasStack != null && gasStack.getGas() == GasRegistry.getGas("fusionFuelDT") && gasStack.amount == ItemHohlraum.MAX_GAS; - } - } - - return false; - } - - @Override - public void simulate() - { - if(controller.getWorldObj().isRemote) - { - lastPlasmaTemperature = plasmaTemperature; - lastCaseTemperature = caseTemperature; - - return; - } - - updatedThisTick = false; - - //Only thermal transfer happens unless we're hot enough to burn. - if(plasmaTemperature >= burnTemperature) - { - //If we're not burning yet we need a hohlraum to ignite - if(!burning && hasHohlraum()) - { - vaporiseHohlraum(); - } - - //Only inject fuel if we're burning - if(burning) - { - injectFuel(); - int fuelBurned = burnFuel(); - neutronFlux(fuelBurned); - - if(fuelBurned == 0) - { - burning = false; - } - } - } - else { - burning = false; - } - - //Perform the heat transfer calculations - transferHeat(); - - if(burning) - { - kill(); - } - - updateTemperatures(); - } - - @Override - public void updateTemperatures() - { - lastPlasmaTemperature = plasmaTemperature < 1E-1 ? 0 : plasmaTemperature; - lastCaseTemperature = caseTemperature < 1E-1 ? 0 : caseTemperature; - } - - public void vaporiseHohlraum() - { - getFuelTank().receive(((ItemHohlraum)controller.inventory[0].getItem()).getGas(controller.inventory[0]), true); - lastPlasmaTemperature = plasmaTemperature; - - controller.inventory[0] = null; - - burning = true; - } - - public void injectFuel() - { - int amountNeeded = getFuelTank().getNeeded(); - int amountAvailable = 2*min(getDeuteriumTank().getStored(), getTritiumTank().getStored()); - int amountToInject = min(amountNeeded, min(amountAvailable, injectionRate)); - - amountToInject -= amountToInject % 2; - - getDeuteriumTank().draw(amountToInject / 2, true); - getTritiumTank().draw(amountToInject / 2, true); - getFuelTank().receive(new GasStack(GasRegistry.getGas("fusionFuelDT"), amountToInject), true); - } - - public int burnFuel() - { - int fuelBurned = (int)min(getFuelTank().getStored(), max(0, lastPlasmaTemperature - burnTemperature)*burnRatio); - - getFuelTank().draw(fuelBurned, true); - plasmaTemperature += energyPerFuel * fuelBurned / plasmaHeatCapacity; - - return fuelBurned; - } - - public void neutronFlux(int fuelBurned) - { - int neutronsRemaining = fuelBurned; - List list = new ArrayList(neutronCaptors); - Collections.shuffle(list); - - for(INeutronCapture captor: neutronCaptors) - { - if(neutronsRemaining <= 0) - { - break; - } - - neutronsRemaining = captor.absorbNeutrons(neutronsRemaining); - } - - controller.radiateNeutrons(neutronsRemaining); - } - - public void transferHeat() - { - //Transfer from plasma to casing - double plasmaCaseHeat = plasmaCaseConductivity * (lastPlasmaTemperature - lastCaseTemperature); - plasmaTemperature -= plasmaCaseHeat / plasmaHeatCapacity; - caseTemperature += plasmaCaseHeat / caseHeatCapacity; - - //Transfer from casing to water if necessary - if(activelyCooled) - { - double caseWaterHeat = caseWaterConductivity * lastCaseTemperature; - int waterToVaporize = (int)(steamTransferEfficiency * caseWaterHeat / enthalpyOfVaporization); - waterToVaporize = min(waterToVaporize, min(getWaterTank().getFluidAmount(), getSteamTank().getCapacity() - getSteamTank().getFluidAmount())); - - if(waterToVaporize > 0) - { - getWaterTank().drain(waterToVaporize, true); - getSteamTank().fill(new FluidStack(FluidRegistry.getFluid("steam"), waterToVaporize), true); - } - - caseWaterHeat = waterToVaporize * enthalpyOfVaporization / steamTransferEfficiency; - caseTemperature -= caseWaterHeat / caseHeatCapacity; - - for(IHeatTransfer source : heatTransfers) - { - source.simulateHeat(); - } - - applyTemperatureChange(); - } - - //Transfer from casing to environment - double caseAirHeat = caseAirConductivity * lastCaseTemperature; - - caseTemperature -= caseAirHeat / caseHeatCapacity; - setBufferedEnergy(getBufferedEnergy() + caseAirHeat * thermocoupleEfficiency); - } - - @Override - public FluidTank getWaterTank() - { - return controller != null ? controller.waterTank : null; - } - - @Override - public FluidTank getSteamTank() - { - return controller.steamTank; - } - - @Override - public GasTank getDeuteriumTank() - { - return controller.deuteriumTank; - } - - @Override - public GasTank getTritiumTank() - { - return controller.tritiumTank; - } - - @Override - public GasTank getFuelTank() - { - return controller.fuelTank; - } - - @Override - public double getBufferedEnergy() - { - return controller.getEnergy(); - } - - @Override - public void setBufferedEnergy(double energy) - { - controller.setEnergy(energy); - } - - @Override - public double getPlasmaTemp() - { - return lastPlasmaTemperature; - } - - @Override - public void setPlasmaTemp(double temp) - { - plasmaTemperature = temp; - } - - @Override - public double getCaseTemp() - { - return lastCaseTemperature; - } - - @Override - public void setCaseTemp(double temp) - { - caseTemperature = temp; - } - - @Override - public double getBufferSize() - { - return controller.getMaxEnergy(); - } - - public void kill() - { - AxisAlignedBB death_zone = AxisAlignedBB.getBoundingBox(controller.xCoord - 1, controller.yCoord - 3, controller.zCoord - 1 ,controller.xCoord + 2, controller.yCoord, controller.zCoord + 2); - List entitiesToDie = controller.getWorldObj().getEntitiesWithinAABB(Entity.class, death_zone); - - for(Entity entity : entitiesToDie) - { - entity.attackEntityFrom(DamageSource.magic, 50000F); - } - } - - public void unformMultiblock(boolean keepBurning) - { - for(IReactorBlock block : reactorBlocks) - { - block.setReactor(null); - } - - //Don't remove from controller - controller.setReactor(this); - reactorBlocks.clear(); - neutronCaptors.clear(); - formed = false; - burning = burning && keepBurning; - - if(!controller.getWorldObj().isRemote) - { - Mekanism.packetHandler.sendToDimension(new TileEntityMessage(Coord4D.get(controller), controller.getNetworkedData(new ArrayList())), controller.getWorldObj().provider.dimensionId); - } - } - - @Override - public void formMultiblock(boolean keepBurning) - { - updatedThisTick = true; - - Coord4D controllerPosition = Coord4D.get(controller); - Coord4D centreOfReactor = controllerPosition.getFromSide(ForgeDirection.DOWN, 2); - - unformMultiblock(true); - - reactorBlocks.add(controller); - - if(!createFrame(centreOfReactor)) - { - unformMultiblock(keepBurning); - return; - } - - if(!addSides(centreOfReactor)) - { - unformMultiblock(keepBurning); - return; - } - - if(!centreIsClear(centreOfReactor)) - { - unformMultiblock(keepBurning); - return; - } - - formed = true; - - if(!controller.getWorldObj().isRemote) - { - Mekanism.packetHandler.sendToDimension(new TileEntityMessage(Coord4D.get(controller), controller.getNetworkedData(new ArrayList())), controller.getWorldObj().provider.dimensionId); - } - } - - public boolean createFrame(Coord4D centre) - { - int[][] positions = new int[][] { - {+2, +2, +0}, {+2, +1, +1}, {+2, +0, +2}, {+2, -1, +1}, {+2, -2, +0}, {+2, -1, -1}, {+2, +0, -2}, {+2, +1, -1}, - {+1, +2, +1}, {+1, +1, +2}, {+1, -1, +2}, {+1, -2, +1}, {+1, -2, -1}, {+1, -1, -2}, {+1, +1, -2}, {+1, +2, -1}, - {+0, +2, +2}, {+0, -2, +2}, {+0, -2, -2}, {+0, +2, -2}, - {-1, +2, +1}, {-1, +1, +2}, {-1, -1, +2}, {-1, -2, +1}, {-1, -2, -1}, {-1, -1, -2}, {-1, +1, -2}, {-1, +2, -1}, - {-2, +2, +0}, {-2, +1, +1}, {-2, +0, +2}, {-2, -1, +1}, {-2, -2, +0}, {-2, -1, -1}, {-2, +0, -2}, {-2, +1, -1}, - }; - - for(int[] coords : positions) - { - TileEntity tile = centre.clone().translate(coords[0], coords[1], coords[2]).getTileEntity(controller.getWorldObj()); - - if(tile instanceof IReactorBlock && ((IReactorBlock)tile).isFrame()) - { - reactorBlocks.add((IReactorBlock)tile); - ((IReactorBlock)tile).setReactor(this); - } - else { - return false; - } - } - - return true; - } - - public boolean addSides(Coord4D centre) - { - int[][] positions = new int[][] { - {+2, +0, +0}, {+2, +1, +0}, {+2, +0, +1}, {+2, -1, +0}, {+2, +0, -1}, //EAST - {-2, +0, +0}, {-2, +1, +0}, {-2, +0, +1}, {-2, -1, +0}, {-2, +0, -1}, //WEST - {+0, +2, +0}, {+1, +2, +0}, {+0, +2, +1}, {-1, +2, +0}, {+0, +2, -1}, //TOP - {+0, -2, +0}, {+1, -2, +0}, {+0, -2, +1}, {-1, -2, +0}, {+0, -2, -1}, //BOTTOM - {+0, +0, +2}, {+1, +0, +2}, {+0, +1, +2}, {-1, +0, +2}, {+0, -1, +2}, //SOUTH - {+0, +0, -2}, {+1, +0, -2}, {+0, +1, -2}, {-1, +0, -2}, {+0, -1, -2}, //NORTH - }; - - for(int[] coords : positions) - { - TileEntity tile = centre.clone().translate(coords[0], coords[1], coords[2]).getTileEntity(controller.getWorldObj()); - - if(tile instanceof ILaserReceptor && !(coords[1] == 0 && (coords[0] == 0 || coords[2] == 0))) - { - return false; - } - - if(tile instanceof IReactorBlock) - { - reactorBlocks.add((IReactorBlock)tile); - ((IReactorBlock)tile).setReactor(this); - - if(tile instanceof INeutronCapture) - { - neutronCaptors.add((INeutronCapture)tile); - } - - if(tile instanceof IHeatTransfer) - { - heatTransfers.add((IHeatTransfer)tile); - } - } - else { - return false; - } - } - - return true; - } - - public boolean centreIsClear(Coord4D centre) - { - for(int x = -1; x <= 1; x++) - { - for(int y = -1; y <= 1; y++) - { - for(int z = -1; z <= 1; z++) - { - Coord4D trans = centre.clone().translate(x, y, z); - - if(!trans.isAirBlock(controller.getWorldObj())) - { - return false; - } - } - } - } - - return true; - } - - @Override - public boolean isFormed() - { - return formed; - } - - @Override - public void setInjectionRate(int rate) - { - injectionRate = rate; - - int capRate = Math.max(1, rate); - - controller.waterTank.setCapacity(TileEntityReactorController.MAX_WATER*capRate); - controller.steamTank.setCapacity(TileEntityReactorController.MAX_STEAM*capRate); - - if(controller.waterTank.getFluid() != null) - { - controller.waterTank.getFluid().amount = Math.min(controller.waterTank.getFluid().amount, controller.waterTank.getCapacity()); - } - - if(controller.steamTank.getFluid() != null) - { - controller.steamTank.getFluid().amount = Math.min(controller.steamTank.getFluid().amount, controller.steamTank.getCapacity()); - } - } - - @Override - public int getInjectionRate() - { - return injectionRate; - } - - @Override - public boolean isBurning() - { - return burning; - } - - @Override - public void setBurning(boolean burn) - { - burning = burn; - } - - @Override - public int getMinInjectionRate(boolean active) - { - double k = active ? caseWaterConductivity : 0; - double aMin = burnTemperature * burnRatio * plasmaCaseConductivity * (k+caseAirConductivity) / (energyPerFuel * burnRatio * (plasmaCaseConductivity+k+caseAirConductivity) - plasmaCaseConductivity * (k + caseAirConductivity)); - return (int)(2 * Math.ceil(aMin/2D)); - } - - @Override - public double getMaxPlasmaTemperature(boolean active) - { - double k = active ? caseWaterConductivity : 0; - return injectionRate * energyPerFuel/plasmaCaseConductivity * (plasmaCaseConductivity+k+caseAirConductivity) / (k+caseAirConductivity); - } - - @Override - public double getMaxCasingTemperature(boolean active) - { - double k = active ? caseWaterConductivity : 0; - return injectionRate * energyPerFuel / (k+caseAirConductivity); - } - - @Override - public double getIgnitionTemperature(boolean active) - { - double k = active ? caseWaterConductivity : 0; - return burnTemperature * energyPerFuel * burnRatio * (plasmaCaseConductivity+k+caseAirConductivity) / (energyPerFuel * burnRatio * (plasmaCaseConductivity+k+caseAirConductivity) - plasmaCaseConductivity * (k + caseAirConductivity)); - } - - @Override - public double getPassiveGeneration(boolean active, boolean current) - { - double temperature = current ? caseTemperature : getMaxCasingTemperature(active); - - return thermocoupleEfficiency * caseAirConductivity * temperature; - } - - @Override - public int getSteamPerTick(boolean current) - { - double temperature = current ? caseTemperature : getMaxCasingTemperature(true); - - return (int)(steamTransferEfficiency * caseWaterConductivity * temperature / enthalpyOfVaporization); - } - - @Override - public double getTemp() - { - return lastCaseTemperature; - } - - @Override - public double getInverseConductionCoefficient() - { - return 1 / caseAirConductivity; - } - - @Override - public double getInsulationCoefficient(ForgeDirection side) - { - return 100000; - } - - @Override - public void transferHeatTo(double heat) - { - heatToAbsorb += heat; - } - - @Override - public double[] simulateHeat() - { - return null; - } - - @Override - public double applyTemperatureChange() - { - caseTemperature += heatToAbsorb / caseHeatCapacity; - heatToAbsorb = 0; - - return caseTemperature; - } - - @Override - public boolean canConnectHeat(ForgeDirection side) - { - return false; - } - - @Override - public IHeatTransfer getAdjacent(ForgeDirection side) - { - return null; - } - - @Override - public ItemStack[] getInventory() - { - return isFormed() ? controller.inventory : null; - } +public class FusionReactor implements IFusionReactor { + public TileEntityReactorController controller; + public Set reactorBlocks = new HashSet(); + public Set neutronCaptors = new HashSet(); + public Set heatTransfers = new HashSet(); + + //Current stores of temperature - internally uses ambient-relative kelvin units + public double plasmaTemperature; + public double caseTemperature; + + //Last values of temperature + public double lastPlasmaTemperature; + public double lastCaseTemperature; + + public double heatToAbsorb = 0; + + //Reaction characteristics + public static double burnTemperature + = TemperatureUnit.AMBIENT.convertFromK(1E8, true); + public static double burnRatio = 1; + public static double energyPerFuel = 5E6; + public int injectionRate = 0; + + //Thermal characteristics + public static double plasmaHeatCapacity = 100; + public static double caseHeatCapacity = 1; + public static double enthalpyOfVaporization = 10; + public static double thermocoupleEfficiency = 0.00125; + public static double steamTransferEfficiency = 0.0025; + + //Heat transfer metrics + public static double plasmaCaseConductivity = 0.2; + public static double caseWaterConductivity = 0.3; + public static double caseAirConductivity = 0.1; + + public boolean burning = false; + public boolean activelyCooled = true; + + public boolean updatedThisTick; + + public boolean formed = false; + + public FusionReactor(TileEntityReactorController c) { + controller = c; + } + + @Override + public void addTemperatureFromEnergyInput(double energyAdded) { + plasmaTemperature += energyAdded / plasmaHeatCapacity * (isBurning() ? 1 : 10); + } + + public boolean hasHohlraum() { + if (controller != null) { + ItemStack hohlraum = controller.inventory[0]; + + if (hohlraum != null && hohlraum.getItem() instanceof ItemHohlraum) { + GasStack gasStack = ((ItemHohlraum) hohlraum.getItem()).getGas(hohlraum); + return gasStack != null + && gasStack.getGas() == GasRegistry.getGas("fusionFuelDT") + && gasStack.amount == ItemHohlraum.MAX_GAS; + } + } + + return false; + } + + @Override + public void simulate() { + if (controller.getWorldObj().isRemote) { + lastPlasmaTemperature = plasmaTemperature; + lastCaseTemperature = caseTemperature; + + return; + } + + updatedThisTick = false; + + //Only thermal transfer happens unless we're hot enough to burn. + if (plasmaTemperature >= burnTemperature) { + //If we're not burning yet we need a hohlraum to ignite + if (!burning && hasHohlraum()) { + vaporiseHohlraum(); + } + + //Only inject fuel if we're burning + if (burning) { + injectFuel(); + int fuelBurned = burnFuel(); + neutronFlux(fuelBurned); + + if (fuelBurned == 0) { + burning = false; + } + } + } else { + burning = false; + } + + //Perform the heat transfer calculations + transferHeat(); + + if (burning) { + kill(); + } + + updateTemperatures(); + } + + @Override + public void updateTemperatures() { + lastPlasmaTemperature = plasmaTemperature < 1E-1 ? 0 : plasmaTemperature; + lastCaseTemperature = caseTemperature < 1E-1 ? 0 : caseTemperature; + } + + public void vaporiseHohlraum() { + getFuelTank().receive( + ((ItemHohlraum) controller.inventory[0].getItem()) + .getGas(controller.inventory[0]), + true + ); + lastPlasmaTemperature = plasmaTemperature; + + controller.inventory[0] = null; + + burning = true; + } + + public void injectFuel() { + int amountNeeded = getFuelTank().getNeeded(); + int amountAvailable + = 2 * min(getDeuteriumTank().getStored(), getTritiumTank().getStored()); + int amountToInject = min(amountNeeded, min(amountAvailable, injectionRate)); + + amountToInject -= amountToInject % 2; + + getDeuteriumTank().draw(amountToInject / 2, true); + getTritiumTank().draw(amountToInject / 2, true); + getFuelTank().receive( + new GasStack(GasRegistry.getGas("fusionFuelDT"), amountToInject), true + ); + } + + public int burnFuel() { + int fuelBurned = (int) min( + getFuelTank().getStored(), + max(0, lastPlasmaTemperature - burnTemperature) * burnRatio + ); + + getFuelTank().draw(fuelBurned, true); + plasmaTemperature += energyPerFuel * fuelBurned / plasmaHeatCapacity; + + return fuelBurned; + } + + public void neutronFlux(int fuelBurned) { + int neutronsRemaining = fuelBurned; + List list = new ArrayList(neutronCaptors); + Collections.shuffle(list); + + for (INeutronCapture captor : neutronCaptors) { + if (neutronsRemaining <= 0) { + break; + } + + neutronsRemaining = captor.absorbNeutrons(neutronsRemaining); + } + + controller.radiateNeutrons(neutronsRemaining); + } + + public void transferHeat() { + //Transfer from plasma to casing + double plasmaCaseHeat + = plasmaCaseConductivity * (lastPlasmaTemperature - lastCaseTemperature); + plasmaTemperature -= plasmaCaseHeat / plasmaHeatCapacity; + caseTemperature += plasmaCaseHeat / caseHeatCapacity; + + //Transfer from casing to water if necessary + if (activelyCooled) { + double caseWaterHeat = caseWaterConductivity * lastCaseTemperature; + int waterToVaporize = (int + ) (steamTransferEfficiency * caseWaterHeat / enthalpyOfVaporization); + waterToVaporize = min( + waterToVaporize, + min(getWaterTank().getFluidAmount(), + getSteamTank().getCapacity() - getSteamTank().getFluidAmount()) + ); + + if (waterToVaporize > 0) { + getWaterTank().drain(waterToVaporize, true); + getSteamTank().fill( + new FluidStack(FluidRegistry.getFluid("steam"), waterToVaporize), true + ); + } + + caseWaterHeat + = waterToVaporize * enthalpyOfVaporization / steamTransferEfficiency; + caseTemperature -= caseWaterHeat / caseHeatCapacity; + + for (IHeatTransfer source : heatTransfers) { + source.simulateHeat(); + } + + applyTemperatureChange(); + } + + //Transfer from casing to environment + double caseAirHeat = caseAirConductivity * lastCaseTemperature; + + caseTemperature -= caseAirHeat / caseHeatCapacity; + setBufferedEnergy(getBufferedEnergy() + caseAirHeat * thermocoupleEfficiency); + } + + @Override + public FluidTank getWaterTank() { + return controller != null ? controller.waterTank : null; + } + + @Override + public FluidTank getSteamTank() { + return controller.steamTank; + } + + @Override + public GasTank getDeuteriumTank() { + return controller.deuteriumTank; + } + + @Override + public GasTank getTritiumTank() { + return controller.tritiumTank; + } + + @Override + public GasTank getFuelTank() { + return controller.fuelTank; + } + + @Override + public double getBufferedEnergy() { + return controller.getEnergy(); + } + + @Override + public void setBufferedEnergy(double energy) { + controller.setEnergy(energy); + } + + @Override + public double getPlasmaTemp() { + return lastPlasmaTemperature; + } + + @Override + public void setPlasmaTemp(double temp) { + plasmaTemperature = temp; + } + + @Override + public double getCaseTemp() { + return lastCaseTemperature; + } + + @Override + public void setCaseTemp(double temp) { + caseTemperature = temp; + } + + @Override + public double getBufferSize() { + return controller.getMaxEnergy(); + } + + public void kill() { + AxisAlignedBB death_zone = AxisAlignedBB.getBoundingBox( + controller.xCoord - 1, + controller.yCoord - 3, + controller.zCoord - 1, + controller.xCoord + 2, + controller.yCoord, + controller.zCoord + 2 + ); + List entitiesToDie + = controller.getWorldObj().getEntitiesWithinAABB(Entity.class, death_zone); + + for (Entity entity : entitiesToDie) { + entity.attackEntityFrom(DamageSource.magic, 50000F); + } + } + + public void unformMultiblock(boolean keepBurning) { + for (IReactorBlock block : reactorBlocks) { + block.setReactor(null); + } + + //Don't remove from controller + controller.setReactor(this); + reactorBlocks.clear(); + neutronCaptors.clear(); + formed = false; + burning = burning && keepBurning; + + if (!controller.getWorldObj().isRemote) { + Mekanism.packetHandler.sendToDimension( + new TileEntityMessage( + Coord4D.get(controller), controller.getNetworkedData(new ArrayList()) + ), + controller.getWorldObj().provider.dimensionId + ); + } + } + + @Override + public void formMultiblock(boolean keepBurning) { + updatedThisTick = true; + + Coord4D controllerPosition = Coord4D.get(controller); + Coord4D centreOfReactor = controllerPosition.getFromSide(ForgeDirection.DOWN, 2); + + unformMultiblock(true); + + reactorBlocks.add(controller); + + if (!createFrame(centreOfReactor)) { + unformMultiblock(keepBurning); + return; + } + + if (!addSides(centreOfReactor)) { + unformMultiblock(keepBurning); + return; + } + + if (!centreIsClear(centreOfReactor)) { + unformMultiblock(keepBurning); + return; + } + + formed = true; + + if (!controller.getWorldObj().isRemote) { + Mekanism.packetHandler.sendToDimension( + new TileEntityMessage( + Coord4D.get(controller), controller.getNetworkedData(new ArrayList()) + ), + controller.getWorldObj().provider.dimensionId + ); + } + } + + public boolean createFrame(Coord4D centre) { + int[][] positions = new int[][] { + { +2, +2, +0 }, { +2, +1, +1 }, { +2, +0, +2 }, { +2, -1, +1 }, + { +2, -2, +0 }, { +2, -1, -1 }, { +2, +0, -2 }, { +2, +1, -1 }, + { +1, +2, +1 }, { +1, +1, +2 }, { +1, -1, +2 }, { +1, -2, +1 }, + { +1, -2, -1 }, { +1, -1, -2 }, { +1, +1, -2 }, { +1, +2, -1 }, + { +0, +2, +2 }, { +0, -2, +2 }, { +0, -2, -2 }, { +0, +2, -2 }, + { -1, +2, +1 }, { -1, +1, +2 }, { -1, -1, +2 }, { -1, -2, +1 }, + { -1, -2, -1 }, { -1, -1, -2 }, { -1, +1, -2 }, { -1, +2, -1 }, + { -2, +2, +0 }, { -2, +1, +1 }, { -2, +0, +2 }, { -2, -1, +1 }, + { -2, -2, +0 }, { -2, -1, -1 }, { -2, +0, -2 }, { -2, +1, -1 }, + }; + + for (int[] coords : positions) { + TileEntity tile = centre.clone() + .translate(coords[0], coords[1], coords[2]) + .getTileEntity(controller.getWorldObj()); + + if (tile instanceof IReactorBlock && ((IReactorBlock) tile).isFrame()) { + reactorBlocks.add((IReactorBlock) tile); + ((IReactorBlock) tile).setReactor(this); + } else { + return false; + } + } + + return true; + } + + public boolean addSides(Coord4D centre) { + int[][] positions = new int[][] { + { +2, +0, +0 }, { +2, +1, +0 }, { +2, +0, +1 }, + { +2, -1, +0 }, { +2, +0, -1 }, //EAST + { -2, +0, +0 }, { -2, +1, +0 }, { -2, +0, +1 }, + { -2, -1, +0 }, { -2, +0, -1 }, //WEST + { +0, +2, +0 }, { +1, +2, +0 }, { +0, +2, +1 }, + { -1, +2, +0 }, { +0, +2, -1 }, //TOP + { +0, -2, +0 }, { +1, -2, +0 }, { +0, -2, +1 }, + { -1, -2, +0 }, { +0, -2, -1 }, //BOTTOM + { +0, +0, +2 }, { +1, +0, +2 }, { +0, +1, +2 }, + { -1, +0, +2 }, { +0, -1, +2 }, //SOUTH + { +0, +0, -2 }, { +1, +0, -2 }, { +0, +1, -2 }, + { -1, +0, -2 }, { +0, -1, -2 }, //NORTH + }; + + for (int[] coords : positions) { + TileEntity tile = centre.clone() + .translate(coords[0], coords[1], coords[2]) + .getTileEntity(controller.getWorldObj()); + + if (tile instanceof ILaserReceptor + && !(coords[1] == 0 && (coords[0] == 0 || coords[2] == 0))) { + return false; + } + + if (tile instanceof IReactorBlock) { + reactorBlocks.add((IReactorBlock) tile); + ((IReactorBlock) tile).setReactor(this); + + if (tile instanceof INeutronCapture) { + neutronCaptors.add((INeutronCapture) tile); + } + + if (tile instanceof IHeatTransfer) { + heatTransfers.add((IHeatTransfer) tile); + } + } else { + return false; + } + } + + return true; + } + + public boolean centreIsClear(Coord4D centre) { + for (int x = -1; x <= 1; x++) { + for (int y = -1; y <= 1; y++) { + for (int z = -1; z <= 1; z++) { + Coord4D trans = centre.clone().translate(x, y, z); + + if (!trans.isAirBlock(controller.getWorldObj())) { + return false; + } + } + } + } + + return true; + } + + @Override + public boolean isFormed() { + return formed; + } + + @Override + public void setInjectionRate(int rate) { + injectionRate = rate; + + int capRate = Math.max(1, rate); + + controller.waterTank.setCapacity(TileEntityReactorController.MAX_WATER * capRate); + controller.steamTank.setCapacity(TileEntityReactorController.MAX_STEAM * capRate); + + if (controller.waterTank.getFluid() != null) { + controller.waterTank.getFluid().amount = Math.min( + controller.waterTank.getFluid().amount, controller.waterTank.getCapacity() + ); + } + + if (controller.steamTank.getFluid() != null) { + controller.steamTank.getFluid().amount = Math.min( + controller.steamTank.getFluid().amount, controller.steamTank.getCapacity() + ); + } + } + + @Override + public int getInjectionRate() { + return injectionRate; + } + + @Override + public boolean isBurning() { + return burning; + } + + @Override + public void setBurning(boolean burn) { + burning = burn; + } + + @Override + public int getMinInjectionRate(boolean active) { + double k = active ? caseWaterConductivity : 0; + double aMin = burnTemperature * burnRatio * plasmaCaseConductivity + * (k + caseAirConductivity) + / (energyPerFuel * burnRatio + * (plasmaCaseConductivity + k + caseAirConductivity) + - plasmaCaseConductivity * (k + caseAirConductivity)); + return (int) (2 * Math.ceil(aMin / 2D)); + } + + @Override + public double getMaxPlasmaTemperature(boolean active) { + double k = active ? caseWaterConductivity : 0; + return injectionRate * energyPerFuel / plasmaCaseConductivity + * (plasmaCaseConductivity + k + caseAirConductivity) + / (k + caseAirConductivity); + } + + @Override + public double getMaxCasingTemperature(boolean active) { + double k = active ? caseWaterConductivity : 0; + return injectionRate * energyPerFuel / (k + caseAirConductivity); + } + + @Override + public double getIgnitionTemperature(boolean active) { + double k = active ? caseWaterConductivity : 0; + return burnTemperature * energyPerFuel * burnRatio + * (plasmaCaseConductivity + k + caseAirConductivity) + / (energyPerFuel * burnRatio + * (plasmaCaseConductivity + k + caseAirConductivity) + - plasmaCaseConductivity * (k + caseAirConductivity)); + } + + @Override + public double getPassiveGeneration(boolean active, boolean current) { + double temperature = current ? caseTemperature : getMaxCasingTemperature(active); + + return thermocoupleEfficiency * caseAirConductivity * temperature; + } + + @Override + public int getSteamPerTick(boolean current) { + double temperature = current ? caseTemperature : getMaxCasingTemperature(true); + + return (int + ) (steamTransferEfficiency * caseWaterConductivity * temperature + / enthalpyOfVaporization); + } + + @Override + public double getTemp() { + return lastCaseTemperature; + } + + @Override + public double getInverseConductionCoefficient() { + return 1 / caseAirConductivity; + } + + @Override + public double getInsulationCoefficient(ForgeDirection side) { + return 100000; + } + + @Override + public void transferHeatTo(double heat) { + heatToAbsorb += heat; + } + + @Override + public double[] simulateHeat() { + return null; + } + + @Override + public double applyTemperatureChange() { + caseTemperature += heatToAbsorb / caseHeatCapacity; + heatToAbsorb = 0; + + return caseTemperature; + } + + @Override + public boolean canConnectHeat(ForgeDirection side) { + return false; + } + + @Override + public IHeatTransfer getAdjacent(ForgeDirection side) { + return null; + } + + @Override + public ItemStack[] getInventory() { + return isFormed() ? controller.inventory : null; + } } diff --git a/src/main/java/mekanism/generators/common/GeneratorsBlocks.java b/src/main/java/mekanism/generators/common/GeneratorsBlocks.java index 3f7f63c53..4170ba310 100644 --- a/src/main/java/mekanism/generators/common/GeneratorsBlocks.java +++ b/src/main/java/mekanism/generators/common/GeneratorsBlocks.java @@ -1,24 +1,23 @@ package mekanism.generators.common; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.GameRegistry.ObjectHolder; import mekanism.generators.common.block.BlockGenerator; import mekanism.generators.common.block.BlockReactor; import mekanism.generators.common.item.ItemBlockGenerator; import mekanism.generators.common.item.ItemBlockReactor; import net.minecraft.block.Block; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.common.registry.GameRegistry.ObjectHolder; @ObjectHolder("MekanismGenerators") -public class GeneratorsBlocks -{ - public static final Block Generator = new BlockGenerator().setBlockName("Generator"); - public static final Block Reactor = new BlockReactor().setBlockName("Reactor"); - public static final Block ReactorGlass = new BlockReactor().setBlockName("ReactorGlass"); +public class GeneratorsBlocks { + public static final Block Generator = new BlockGenerator().setBlockName("Generator"); + public static final Block Reactor = new BlockReactor().setBlockName("Reactor"); + public static final Block ReactorGlass + = new BlockReactor().setBlockName("ReactorGlass"); - public static void register() - { - GameRegistry.registerBlock(Generator, ItemBlockGenerator.class, "Generator"); - GameRegistry.registerBlock(Reactor, ItemBlockReactor.class, "Reactor"); - GameRegistry.registerBlock(ReactorGlass, ItemBlockReactor.class, "ReactorGlass"); - } + public static void register() { + GameRegistry.registerBlock(Generator, ItemBlockGenerator.class, "Generator"); + GameRegistry.registerBlock(Reactor, ItemBlockReactor.class, "Reactor"); + GameRegistry.registerBlock(ReactorGlass, ItemBlockReactor.class, "ReactorGlass"); + } } diff --git a/src/main/java/mekanism/generators/common/GeneratorsCommonProxy.java b/src/main/java/mekanism/generators/common/GeneratorsCommonProxy.java index 106fc48da..1387815e0 100644 --- a/src/main/java/mekanism/generators/common/GeneratorsCommonProxy.java +++ b/src/main/java/mekanism/generators/common/GeneratorsCommonProxy.java @@ -1,5 +1,7 @@ package mekanism.generators.common; +import cpw.mods.fml.client.registry.RenderingRegistry; +import cpw.mods.fml.common.registry.GameRegistry; import mekanism.api.MekanismConfig.generators; import mekanism.common.Mekanism; import mekanism.common.base.IGuiProvider; @@ -37,135 +39,187 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; -import cpw.mods.fml.client.registry.RenderingRegistry; -import cpw.mods.fml.common.registry.GameRegistry; /** * Common proxy for the Mekanism Generators module. * @author AidanBrady * */ -public class GeneratorsCommonProxy implements IGuiProvider -{ - public static int GENERATOR_RENDER_ID = RenderingRegistry.getNextAvailableRenderId(); +public class GeneratorsCommonProxy implements IGuiProvider { + public static int GENERATOR_RENDER_ID = RenderingRegistry.getNextAvailableRenderId(); - /** - * Register normal tile entities - */ - public void registerRegularTileEntities() - { - GameRegistry.registerTileEntity(TileEntityReactorFrame.class, "ReactorFrame"); - GameRegistry.registerTileEntity(TileEntityReactorGlass.class, "ReactorGlass"); - GameRegistry.registerTileEntity(TileEntityReactorLaserFocusMatrix.class, "ReactorLaserFocus"); - GameRegistry.registerTileEntity(TileEntityReactorNeutronCapture.class, "ReactorNeutronCapture"); - GameRegistry.registerTileEntity(TileEntityReactorPort.class, "ReactorPort"); - GameRegistry.registerTileEntity(TileEntityReactorLogicAdapter.class, "ReactorLogicAdapter"); - GameRegistry.registerTileEntity(TileEntityRotationalComplex.class, "RotationalComplex"); - GameRegistry.registerTileEntity(TileEntityElectromagneticCoil.class, "ElectromagneticCoil"); - GameRegistry.registerTileEntity(TileEntitySaturatingCondenser.class, "SaturatingCondenser"); - } + /** + * Register normal tile entities + */ + public void registerRegularTileEntities() { + GameRegistry.registerTileEntity(TileEntityReactorFrame.class, "ReactorFrame"); + GameRegistry.registerTileEntity(TileEntityReactorGlass.class, "ReactorGlass"); + GameRegistry.registerTileEntity( + TileEntityReactorLaserFocusMatrix.class, "ReactorLaserFocus" + ); + GameRegistry.registerTileEntity( + TileEntityReactorNeutronCapture.class, "ReactorNeutronCapture" + ); + GameRegistry.registerTileEntity(TileEntityReactorPort.class, "ReactorPort"); + GameRegistry.registerTileEntity( + TileEntityReactorLogicAdapter.class, "ReactorLogicAdapter" + ); + GameRegistry.registerTileEntity( + TileEntityRotationalComplex.class, "RotationalComplex" + ); + GameRegistry.registerTileEntity( + TileEntityElectromagneticCoil.class, "ElectromagneticCoil" + ); + GameRegistry.registerTileEntity( + TileEntitySaturatingCondenser.class, "SaturatingCondenser" + ); + } - /** - * Register tile entities that have special models. Overwritten in client to register TESRs. - */ - public void registerSpecialTileEntities() - { - GameRegistry.registerTileEntity(TileEntityAdvancedSolarGenerator.class, "AdvancedSolarGenerator"); - GameRegistry.registerTileEntity(TileEntitySolarGenerator.class, "SolarGenerator"); - GameRegistry.registerTileEntity(TileEntityBioGenerator.class, "BioGenerator"); - GameRegistry.registerTileEntity(TileEntityHeatGenerator.class, "HeatGenerator"); - GameRegistry.registerTileEntity(TileEntityGasGenerator.class, "GasGenerator"); - GameRegistry.registerTileEntity(TileEntityWindGenerator.class, "WindTurbine"); - GameRegistry.registerTileEntity(TileEntityReactorController.class, "ReactorController"); - GameRegistry.registerTileEntity(TileEntityTurbineRotor.class, "TurbineRod"); - GameRegistry.registerTileEntity(TileEntityTurbineCasing.class, "TurbineCasing"); - GameRegistry.registerTileEntity(TileEntityTurbineValve.class, "TurbineValve"); - GameRegistry.registerTileEntity(TileEntityTurbineVent.class, "TurbineVent"); - } + /** + * Register tile entities that have special models. Overwritten in client to register + * TESRs. + */ + public void registerSpecialTileEntities() { + GameRegistry.registerTileEntity( + TileEntityAdvancedSolarGenerator.class, "AdvancedSolarGenerator" + ); + GameRegistry.registerTileEntity(TileEntitySolarGenerator.class, "SolarGenerator"); + GameRegistry.registerTileEntity(TileEntityBioGenerator.class, "BioGenerator"); + GameRegistry.registerTileEntity(TileEntityHeatGenerator.class, "HeatGenerator"); + GameRegistry.registerTileEntity(TileEntityGasGenerator.class, "GasGenerator"); + GameRegistry.registerTileEntity(TileEntityWindGenerator.class, "WindTurbine"); + GameRegistry.registerTileEntity( + TileEntityReactorController.class, "ReactorController" + ); + GameRegistry.registerTileEntity(TileEntityTurbineRotor.class, "TurbineRod"); + GameRegistry.registerTileEntity(TileEntityTurbineCasing.class, "TurbineCasing"); + GameRegistry.registerTileEntity(TileEntityTurbineValve.class, "TurbineValve"); + GameRegistry.registerTileEntity(TileEntityTurbineVent.class, "TurbineVent"); + } - /** - * Register and load client-only render information. - */ - public void registerRenderInformation() {} + /** + * Register and load client-only render information. + */ + public void registerRenderInformation() {} - /** - * Set and load the mod's common configuration properties. - */ - public void loadConfiguration() - { - generators.advancedSolarGeneration = Mekanism.configuration.get("generation", "AdvancedSolarGeneration", 300D).getDouble(); - generators.bioGeneration = Mekanism.configuration.get("generation", "BioGeneration", 350D).getDouble(); - generators.heatGeneration = Mekanism.configuration.get("generation", "HeatGeneration", 150D).getDouble(); - generators.heatGenerationLava = Mekanism.configuration.get("generation", "HeatGenerationLava", 5D).getDouble(); - generators.heatGenerationNether = Mekanism.configuration.get("generation", "HeatGenerationNether", 100D).getDouble(); - generators.heatGenerationFluidRate = Mekanism.configuration.get("generation", "HeatGenerationFluidRate", 10).getInt(); - generators.solarGeneration = Mekanism.configuration.get("generation", "SolarGeneration", 50D).getDouble(); - - loadWindConfiguration(); - - generators.turbineBladesPerCoil = Mekanism.configuration.get("generation", "TurbineBladesPerCoil", 4).getInt(); - generators.turbineVentGasFlow = Mekanism.configuration.get("generation", "TurbineVentGasFlow", 16000D).getDouble(); - generators.turbineDisperserGasFlow = Mekanism.configuration.get("generation", "TurbineDisperserGasFlow", 640D).getDouble(); - generators.condenserRate = Mekanism.configuration.get("generation", "TurbineCondenserFlowRate", 32000).getInt(); + /** + * Set and load the mod's common configuration properties. + */ + public void loadConfiguration() { + generators.advancedSolarGeneration + = Mekanism.configuration.get("generation", "AdvancedSolarGeneration", 300D) + .getDouble(); + generators.bioGeneration + = Mekanism.configuration.get("generation", "BioGeneration", 350D).getDouble(); + generators.heatGeneration + = Mekanism.configuration.get("generation", "HeatGeneration", 150D) + .getDouble(); + generators.heatGenerationLava + = Mekanism.configuration.get("generation", "HeatGenerationLava", 5D) + .getDouble(); + generators.heatGenerationNether + = Mekanism.configuration.get("generation", "HeatGenerationNether", 100D) + .getDouble(); + generators.heatGenerationFluidRate + = Mekanism.configuration.get("generation", "HeatGenerationFluidRate", 10) + .getInt(); + generators.solarGeneration + = Mekanism.configuration.get("generation", "SolarGeneration", 50D) + .getDouble(); - if(Mekanism.configuration.hasChanged()) - { - Mekanism.configuration.save(); - } - } - - private void loadWindConfiguration() - { - generators.windGenerationMin = Mekanism.configuration.get("generation", "WindGenerationMin", 60D).getDouble(); - generators.windGenerationMax = Mekanism.configuration.get("generation", "WindGenerationMax", 480D).getDouble(); + loadWindConfiguration(); - //Ensure max > min to avoid division by zero later - final int minY = Mekanism.configuration.get("generation", "WindGenerationMinY", 24).getInt(); - final int maxY = Mekanism.configuration.get("generation", "WindGenerationMaxY", 255).getInt(); + generators.turbineBladesPerCoil + = Mekanism.configuration.get("generation", "TurbineBladesPerCoil", 4) + .getInt(); + generators.turbineVentGasFlow + = Mekanism.configuration.get("generation", "TurbineVentGasFlow", 16000D) + .getDouble(); + generators.turbineDisperserGasFlow + = Mekanism.configuration.get("generation", "TurbineDisperserGasFlow", 640D) + .getDouble(); + generators.condenserRate + = Mekanism.configuration.get("generation", "TurbineCondenserFlowRate", 32000) + .getInt(); - generators.windGenerationMinY = minY; - generators.windGenerationMaxY = Math.max(minY + 1, maxY); - } + if (Mekanism.configuration.hasChanged()) { + Mekanism.configuration.save(); + } + } - @Override - public Object getClientGui(int ID, EntityPlayer player, World world, int x, int y, int z) - { - return null; - } + private void loadWindConfiguration() { + generators.windGenerationMin + = Mekanism.configuration.get("generation", "WindGenerationMin", 60D) + .getDouble(); + generators.windGenerationMax + = Mekanism.configuration.get("generation", "WindGenerationMax", 480D) + .getDouble(); - @Override - public Container getServerGui(int ID, EntityPlayer player, World world, int x, int y, int z) - { - TileEntity tileEntity = world.getTileEntity(x, y, z); + //Ensure max > min to avoid division by zero later + final int minY + = Mekanism.configuration.get("generation", "WindGenerationMinY", 24).getInt(); + final int maxY + = Mekanism.configuration.get("generation", "WindGenerationMaxY", 255) + .getInt(); - switch(ID) - { - case 0: - return new ContainerHeatGenerator(player.inventory, (TileEntityHeatGenerator)tileEntity); - case 1: - return new ContainerSolarGenerator(player.inventory, (TileEntitySolarGenerator)tileEntity); - case 3: - return new ContainerGasGenerator(player.inventory, (TileEntityGasGenerator)tileEntity); - case 4: - return new ContainerBioGenerator(player.inventory, (TileEntityBioGenerator)tileEntity); - case 5: - return new ContainerWindGenerator(player.inventory, (TileEntityWindGenerator)tileEntity); - case 6: - return new ContainerFilter(player.inventory, (TileEntityTurbineCasing)tileEntity); - case 7: - return new ContainerNull(player, (TileEntityTurbineCasing)tileEntity); - case 10: - return new ContainerReactorController(player.inventory, (TileEntityReactorController)tileEntity); - case 11: - case 12: - case 13: - return new ContainerNull(player, (TileEntityContainerBlock)tileEntity); - case 14: - return new ContainerNeutronCapture(player.inventory, (TileEntityReactorNeutronCapture)tileEntity); - case 15: - return new ContainerNull(player, (TileEntityContainerBlock)tileEntity); - } - - return null; - } + generators.windGenerationMinY = minY; + generators.windGenerationMaxY = Math.max(minY + 1, maxY); + } + + @Override + public Object + getClientGui(int ID, EntityPlayer player, World world, int x, int y, int z) { + return null; + } + + @Override + public Container + getServerGui(int ID, EntityPlayer player, World world, int x, int y, int z) { + TileEntity tileEntity = world.getTileEntity(x, y, z); + + switch (ID) { + case 0: + return new ContainerHeatGenerator( + player.inventory, (TileEntityHeatGenerator) tileEntity + ); + case 1: + return new ContainerSolarGenerator( + player.inventory, (TileEntitySolarGenerator) tileEntity + ); + case 3: + return new ContainerGasGenerator( + player.inventory, (TileEntityGasGenerator) tileEntity + ); + case 4: + return new ContainerBioGenerator( + player.inventory, (TileEntityBioGenerator) tileEntity + ); + case 5: + return new ContainerWindGenerator( + player.inventory, (TileEntityWindGenerator) tileEntity + ); + case 6: + return new ContainerFilter( + player.inventory, (TileEntityTurbineCasing) tileEntity + ); + case 7: + return new ContainerNull(player, (TileEntityTurbineCasing) tileEntity); + case 10: + return new ContainerReactorController( + player.inventory, (TileEntityReactorController) tileEntity + ); + case 11: + case 12: + case 13: + return new ContainerNull(player, (TileEntityContainerBlock) tileEntity); + case 14: + return new ContainerNeutronCapture( + player.inventory, (TileEntityReactorNeutronCapture) tileEntity + ); + case 15: + return new ContainerNull(player, (TileEntityContainerBlock) tileEntity); + } + + return null; + } } diff --git a/src/main/java/mekanism/generators/common/GeneratorsGuiHandler.java b/src/main/java/mekanism/generators/common/GeneratorsGuiHandler.java index 52ad81925..0f3061fa3 100644 --- a/src/main/java/mekanism/generators/common/GeneratorsGuiHandler.java +++ b/src/main/java/mekanism/generators/common/GeneratorsGuiHandler.java @@ -1,8 +1,8 @@ package mekanism.generators.common; +import cpw.mods.fml.common.network.IGuiHandler; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; -import cpw.mods.fml.common.network.IGuiHandler; /** * Client and server GUI hander for Mekanism. @@ -10,17 +10,16 @@ import cpw.mods.fml.common.network.IGuiHandler; * @author AidanBrady * */ -public class GeneratorsGuiHandler implements IGuiHandler -{ - @Override - public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) - { - return MekanismGenerators.proxy.getServerGui(ID, player, world, x, y, z); - } +public class GeneratorsGuiHandler implements IGuiHandler { + @Override + public Object + getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + return MekanismGenerators.proxy.getServerGui(ID, player, world, x, y, z); + } - @Override - public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) - { - return MekanismGenerators.proxy.getClientGui(ID, player, world, x, y, z); - } + @Override + public Object + getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { + return MekanismGenerators.proxy.getClientGui(ID, player, world, x, y, z); + } } diff --git a/src/main/java/mekanism/generators/common/GeneratorsItems.java b/src/main/java/mekanism/generators/common/GeneratorsItems.java index 8fbb389cd..e1a0446ae 100644 --- a/src/main/java/mekanism/generators/common/GeneratorsItems.java +++ b/src/main/java/mekanism/generators/common/GeneratorsItems.java @@ -1,31 +1,32 @@ package mekanism.generators.common; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.GameRegistry.ObjectHolder; import mekanism.common.item.ItemMekanism; import mekanism.generators.common.item.ItemHohlraum; import mekanism.generators.common.tile.turbine.TileEntityTurbineRotor; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.world.World; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.common.registry.GameRegistry.ObjectHolder; @ObjectHolder("MekanismGenerators") -public class GeneratorsItems -{ - public static final Item SolarPanel = new ItemMekanism().setUnlocalizedName("SolarPanel"); - public static final ItemHohlraum Hohlraum = (ItemHohlraum)new ItemHohlraum().setUnlocalizedName("Hohlraum"); - public static final Item TurbineBlade = new ItemMekanism() { - @Override - public boolean doesSneakBypassUse(World world, int x, int y, int z, EntityPlayer player) - { - return world.getTileEntity(x, y, z) instanceof TileEntityTurbineRotor; - } - }.setUnlocalizedName("TurbineBlade"); +public class GeneratorsItems { + public static final Item SolarPanel + = new ItemMekanism().setUnlocalizedName("SolarPanel"); + public static final ItemHohlraum Hohlraum + = (ItemHohlraum) new ItemHohlraum().setUnlocalizedName("Hohlraum"); + public static final Item TurbineBlade = new ItemMekanism() { + @Override + public boolean doesSneakBypassUse( + World world, int x, int y, int z, EntityPlayer player + ) { + return world.getTileEntity(x, y, z) instanceof TileEntityTurbineRotor; + } + }.setUnlocalizedName("TurbineBlade"); - public static void register() - { - GameRegistry.registerItem(SolarPanel, "SolarPanel"); - GameRegistry.registerItem(Hohlraum, "Hohlraum"); - GameRegistry.registerItem(TurbineBlade, "TurbineBlade"); - } + public static void register() { + GameRegistry.registerItem(SolarPanel, "SolarPanel"); + GameRegistry.registerItem(Hohlraum, "Hohlraum"); + GameRegistry.registerItem(TurbineBlade, "TurbineBlade"); + } } diff --git a/src/main/java/mekanism/generators/common/MekanismGenerators.java b/src/main/java/mekanism/generators/common/MekanismGenerators.java index 9d9c271d7..c097f7d5e 100644 --- a/src/main/java/mekanism/generators/common/MekanismGenerators.java +++ b/src/main/java/mekanism/generators/common/MekanismGenerators.java @@ -1,9 +1,21 @@ package mekanism.generators.common; -import io.netty.buffer.ByteBuf; - import java.io.IOException; +import buildcraft.api.fuels.BuildcraftFuelRegistry; +import buildcraft.api.fuels.IFuel; +import cpw.mods.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.Mod.EventHandler; +import cpw.mods.fml.common.Mod.Instance; +import cpw.mods.fml.common.SidedProxy; +import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPostInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import cpw.mods.fml.common.network.NetworkRegistry; +import io.netty.buffer.ByteBuf; import mekanism.api.MekanismConfig.general; import mekanism.api.MekanismConfig.generators; import mekanism.api.gas.Gas; @@ -29,232 +41,421 @@ import net.minecraft.item.crafting.CraftingManager; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.oredict.OreDictionary; -import buildcraft.api.fuels.BuildcraftFuelRegistry; -import buildcraft.api.fuels.IFuel; -import cpw.mods.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.Mod; -import cpw.mods.fml.common.Mod.EventHandler; -import cpw.mods.fml.common.Mod.Instance; -import cpw.mods.fml.common.SidedProxy; -import cpw.mods.fml.common.event.FMLInitializationEvent; -import cpw.mods.fml.common.event.FMLPostInitializationEvent; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; -import cpw.mods.fml.common.eventhandler.SubscribeEvent; -import cpw.mods.fml.common.network.NetworkRegistry; -@Mod(modid = "MekanismGenerators", name = "MekanismGenerators", version = "GRADLE_MODVERSION", dependencies = "required-after:Mekanism", guiFactory = "mekanism.generators.client.gui.GeneratorsGuiFactory") -public class MekanismGenerators implements IModule -{ - @SidedProxy(clientSide = "mekanism.generators.client.GeneratorsClientProxy", serverSide = "mekanism.generators.common.GeneratorsCommonProxy") - public static GeneratorsCommonProxy proxy; - - @Instance("MekanismGenerators") - public static MekanismGenerators instance; - - /** MekanismGenerators version number */ - public static String versionNumber = "GRADLE_MODVERSION"; - - public static MultiblockManager turbineManager = new MultiblockManager("industrialTurbine"); +@Mod( + modid = "MekanismGenerators", + name = "MekanismGenerators", + version = "GRADLE_MODVERSION", + dependencies = "required-after:Mekanism", + guiFactory = "mekanism.generators.client.gui.GeneratorsGuiFactory" +) +public class MekanismGenerators implements IModule { + @SidedProxy( + clientSide = "mekanism.generators.client.GeneratorsClientProxy", + serverSide = "mekanism.generators.common.GeneratorsCommonProxy" + ) + public static GeneratorsCommonProxy proxy; - @EventHandler - public void preInit(FMLPreInitializationEvent event) - { - GeneratorsBlocks.register(); - GeneratorsItems.register(); - } + @Instance("MekanismGenerators") + public static MekanismGenerators instance; - @EventHandler - public void init(FMLInitializationEvent event) - { - //Add this module to the core list - Mekanism.modulesLoaded.add(this); - - //Register this module's GUI handler in the simple packet protocol - PacketSimpleGui.handlers.add(1, proxy); - - //Set up the GUI handler - NetworkRegistry.INSTANCE.registerGuiHandler(this, new GeneratorsGuiHandler()); - FMLCommonHandler.instance().bus().register(this); + /** MekanismGenerators version number */ + public static String versionNumber = "GRADLE_MODVERSION"; - //Load the proxy - proxy.loadConfiguration(); - proxy.registerRegularTileEntities(); - proxy.registerSpecialTileEntities(); - proxy.registerRenderInformation(); - - addRecipes(); - - //Finalization - Mekanism.logger.info("Loaded MekanismGenerators module."); - } + public static MultiblockManager turbineManager + = new MultiblockManager("industrialTurbine"); - @EventHandler - public void postInit(FMLPostInitializationEvent event) - { - if(FuelHandler.BCPresent() && BuildcraftFuelRegistry.fuel != null) - { - for(IFuel s : BuildcraftFuelRegistry.fuel.getFuels()) - { - if(!(s.getFluid() == null || GasRegistry.containsGas(s.getFluid().getName()))) - { - GasRegistry.register(new Gas(s.getFluid())); - } - } + @EventHandler + public void preInit(FMLPreInitializationEvent event) { + GeneratorsBlocks.register(); + GeneratorsItems.register(); + } - BuildcraftFuelRegistry.fuel.addFuel(FluidRegistry.getFluid("ethene"), (int)(240 * general.TO_TE), 40 * FluidContainerRegistry.BUCKET_VOLUME); - } - - for(ItemStack ore : OreDictionary.getOres("dustGold")) - { - RecipeHandler.addMetallurgicInfuserRecipe(InfuseRegistry.get("CARBON"), 10, MekanismUtils.size(ore, 4), GeneratorsItems.Hohlraum.getEmptyItem()); - } - } - - public void addRecipes() - { - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(GeneratorsBlocks.Generator, 1, 0), new Object[] { - "III", "WOW", "CFC", Character.valueOf('I'), "ingotIron", Character.valueOf('C'), "ingotCopper", Character.valueOf('O'), "ingotOsmium", Character.valueOf('F'), Blocks.furnace, Character.valueOf('W'), "plankWood" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(GeneratorsBlocks.Generator, 1, 1), new Object[] { - "SSS", "AIA", "PEP", Character.valueOf('S'), GeneratorsItems.SolarPanel, Character.valueOf('A'), MekanismItems.EnrichedAlloy, Character.valueOf('I'), "ingotIron", Character.valueOf('P'), "dustOsmium", Character.valueOf('E'), MekanismItems.EnergyTablet.getUnchargedItem() - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(GeneratorsBlocks.Generator, 1, 5), new Object[] { - "SES", "SES", "III", Character.valueOf('S'), new ItemStack(GeneratorsBlocks.Generator, 1, 1), Character.valueOf('E'), MekanismItems.EnrichedAlloy, Character.valueOf('I'), "ingotIron" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(GeneratorsBlocks.Generator, 1, 4), new Object[] { - "RER", "BCB", "NEN", Character.valueOf('R'), "dustRedstone", Character.valueOf('E'), MekanismItems.EnrichedAlloy, Character.valueOf('B'), MekanismItems.BioFuel, Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.BASIC), Character.valueOf('N'), "ingotIron" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(GeneratorsBlocks.Generator, 1, 3), new Object[] { - "PEP", "ICI", "PEP", Character.valueOf('P'), "ingotOsmium", Character.valueOf('E'), MekanismItems.EnrichedAlloy, Character.valueOf('I'), new ItemStack(MekanismBlocks.BasicBlock, 1, 8), Character.valueOf('C'), MekanismItems.ElectrolyticCore - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(GeneratorsItems.SolarPanel), new Object[] { - "GGG", "RAR", "PPP", Character.valueOf('G'), "paneGlass", Character.valueOf('R'), "dustRedstone", Character.valueOf('A'), MekanismItems.EnrichedAlloy, Character.valueOf('P'), "ingotOsmium" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(GeneratorsBlocks.Generator, 1, 6), new Object[] { - " O ", "OAO", "ECE", Character.valueOf('O'), "ingotOsmium", Character.valueOf('A'), MekanismItems.EnrichedAlloy, Character.valueOf('E'), MekanismItems.EnergyTablet.getUnchargedItem(), Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.BASIC) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(GeneratorsItems.TurbineBlade), new Object[] { - " S ", "SAS", " S ", Character.valueOf('S'), "ingotSteel", Character.valueOf('A'), MekanismItems.EnrichedAlloy - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(GeneratorsBlocks.Generator, 1, 7), new Object[] { - "SAS", "SAS", "SAS", Character.valueOf('S'), "ingotSteel", Character.valueOf('A'), MekanismItems.EnrichedAlloy - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(GeneratorsBlocks.Generator, 1, 8), new Object[] { - "SAS", "CAC", "SAS", Character.valueOf('S'), "ingotSteel", Character.valueOf('A'), MekanismItems.EnrichedAlloy, Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.ADVANCED) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(GeneratorsBlocks.Generator, 1, 9), new Object[] { - "SGS", "GEG", "SGS", Character.valueOf('S'), "ingotSteel", Character.valueOf('G'), "ingotGold", Character.valueOf('E'), MekanismItems.EnergyTablet.getUnchargedItem() - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(GeneratorsBlocks.Generator, 4, 10), new Object[] { - " S ", "SOS", " S ", Character.valueOf('S'), "ingotSteel", Character.valueOf('O'), "ingotOsmium" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(GeneratorsBlocks.Generator, 2, 11), new Object[] { - " I ", "ICI", " I ", Character.valueOf('I'), new ItemStack(GeneratorsBlocks.Generator, 1, 10), Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.ADVANCED) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(GeneratorsBlocks.Generator, 2, 12), new Object[] { - " I ", "IFI", " I ", Character.valueOf('I'), new ItemStack(GeneratorsBlocks.Generator, 1, 10), Character.valueOf('F'), Blocks.iron_bars - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(GeneratorsBlocks.Generator, 1, 13), new Object[] { - "STS", "TBT", "STS", Character.valueOf('S'), "ingotSteel", Character.valueOf('T'), "ingotTin", Character.valueOf('B'), Items.bucket - })); - - //Reactor Recipes - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(GeneratorsBlocks.Reactor, 4, 1), new Object[] { - " C ", "CAC", " C ", Character.valueOf('C'), new ItemStack(MekanismBlocks.BasicBlock, 1, 8), Character.valueOf('A'), "alloyUltimate" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(GeneratorsBlocks.Reactor, 2, 3), new Object[] { - " I ", "ICI", " I ", Character.valueOf('I'), new ItemStack(GeneratorsBlocks.Reactor, 1, 1), Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.ULTIMATE) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(GeneratorsBlocks.ReactorGlass, 4, 0), new Object[] { - " I ", "IGI", " I ", Character.valueOf('I'), new ItemStack(GeneratorsBlocks.Reactor, 1, 1), Character.valueOf('G'), "blockGlass" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(GeneratorsBlocks.Reactor, 1, 0), new Object[] { - "CGC", "ITI", "III", Character.valueOf('C'), MekanismUtils.getControlCircuit(BaseTier.ULTIMATE), Character.valueOf('G'), "paneGlass", Character.valueOf('I'), new ItemStack(GeneratorsBlocks.Reactor, 1, 1), Character.valueOf('T'), MekanismUtils.getEmptyGasTank(GasTankTier.BASIC) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(GeneratorsBlocks.ReactorGlass, 2, 1), new Object[] { - " I ", "ILI", " I ", Character.valueOf('I'), new ItemStack(GeneratorsBlocks.ReactorGlass, 1, 0), Character.valueOf('L'), "blockRedstone" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(GeneratorsBlocks.Reactor, 1, 4), new Object[] { - " R ", "RFR", " R ", Character.valueOf('R'), "dustRedstone", Character.valueOf('F'), new ItemStack(GeneratorsBlocks.Reactor, 1, 1) - })); + @EventHandler + public void init(FMLInitializationEvent event) { + //Add this module to the core list + Mekanism.modulesLoaded.add(this); - FuelHandler.addGas(GasRegistry.getGas("ethene"), general.ETHENE_BURN_TIME, general.FROM_H2 + generators.bioGeneration * 2 * general.ETHENE_BURN_TIME); //1mB hydrogen + 2*bioFuel/tick*200ticks/100mB * 20x efficiency bonus - FuelHandler.addGas(GasRegistry.getGas("methane"), general.METHANE_BURN_TIME, general.FROM_H2 + generators.bioGeneration * general.METHANE_BURN_TIME); - } + //Register this module's GUI handler in the simple packet protocol + PacketSimpleGui.handlers.add(1, proxy); - @Override - public String getVersion() - { - return versionNumber; - } + //Set up the GUI handler + NetworkRegistry.INSTANCE.registerGuiHandler(this, new GeneratorsGuiHandler()); + FMLCommonHandler.instance().bus().register(this); - @Override - public String getName() - { - return "Generators"; - } - - @Override - public void writeConfig(ByteBuf dataStream) throws IOException - { - dataStream.writeDouble(generators.advancedSolarGeneration); - dataStream.writeDouble(generators.bioGeneration); - dataStream.writeDouble(generators.heatGeneration); - dataStream.writeDouble(generators.heatGenerationLava); - dataStream.writeDouble(generators.heatGenerationNether); - dataStream.writeInt(generators.heatGenerationFluidRate); - dataStream.writeBoolean(generators.heatGenEnable); - dataStream.writeDouble(generators.solarGeneration); - - dataStream.writeDouble(generators.windGenerationMin); - dataStream.writeDouble(generators.windGenerationMax); - - dataStream.writeInt(generators.windGenerationMinY); - dataStream.writeInt(generators.windGenerationMaxY); - - dataStream.writeInt(generators.turbineBladesPerCoil); - dataStream.writeDouble(generators.turbineVentGasFlow); - dataStream.writeDouble(generators.turbineDisperserGasFlow); - dataStream.writeInt(generators.condenserRate); - } + //Load the proxy + proxy.loadConfiguration(); + proxy.registerRegularTileEntities(); + proxy.registerSpecialTileEntities(); + proxy.registerRenderInformation(); - @Override - public void readConfig(ByteBuf dataStream) throws IOException - { - generators.advancedSolarGeneration = dataStream.readDouble(); - generators.bioGeneration = dataStream.readDouble(); - generators.heatGeneration = dataStream.readDouble(); - generators.heatGenerationLava = dataStream.readDouble(); - generators.heatGenerationNether = dataStream.readDouble();; - generators.heatGenerationFluidRate = dataStream.readInt(); - generators.heatGenEnable = dataStream.readBoolean(); - generators.solarGeneration = dataStream.readDouble(); - - generators.windGenerationMin = dataStream.readDouble(); - generators.windGenerationMax = dataStream.readDouble(); - - generators.windGenerationMinY = dataStream.readInt(); - generators.windGenerationMaxY = dataStream.readInt(); - - generators.turbineBladesPerCoil = dataStream.readInt(); - generators.turbineVentGasFlow = dataStream.readDouble(); - generators.turbineDisperserGasFlow = dataStream.readDouble(); - generators.condenserRate = dataStream.readInt(); - } - - @Override - public void resetClient() - { - SynchronizedTurbineData.clientRotationMap.clear(); - } + addRecipes(); - @SubscribeEvent - public void onConfigChanged(OnConfigChangedEvent event) - { - if(event.modID.equals("MekanismGenerators")) - { - proxy.loadConfiguration(); - } - } + //Finalization + Mekanism.logger.info("Loaded MekanismGenerators module."); + } + + @EventHandler + public void postInit(FMLPostInitializationEvent event) { + if (FuelHandler.BCPresent() && BuildcraftFuelRegistry.fuel != null) { + for (IFuel s : BuildcraftFuelRegistry.fuel.getFuels()) { + if (!(s.getFluid() == null + || GasRegistry.containsGas(s.getFluid().getName()))) { + GasRegistry.register(new Gas(s.getFluid())); + } + } + + BuildcraftFuelRegistry.fuel.addFuel( + FluidRegistry.getFluid("ethene"), + (int) (240 * general.TO_TE), + 40 * FluidContainerRegistry.BUCKET_VOLUME + ); + } + + for (ItemStack ore : OreDictionary.getOres("dustGold")) { + RecipeHandler.addMetallurgicInfuserRecipe( + InfuseRegistry.get("CARBON"), + 10, + MekanismUtils.size(ore, 4), + GeneratorsItems.Hohlraum.getEmptyItem() + ); + } + } + + public void addRecipes() { + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(GeneratorsBlocks.Generator, 1, 0), + new Object[] { "III", + "WOW", + "CFC", + Character.valueOf('I'), + "ingotIron", + Character.valueOf('C'), + "ingotCopper", + Character.valueOf('O'), + "ingotOsmium", + Character.valueOf('F'), + Blocks.furnace, + Character.valueOf('W'), + "plankWood" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(GeneratorsBlocks.Generator, 1, 1), + new Object[] { "SSS", + "AIA", + "PEP", + Character.valueOf('S'), + GeneratorsItems.SolarPanel, + Character.valueOf('A'), + MekanismItems.EnrichedAlloy, + Character.valueOf('I'), + "ingotIron", + Character.valueOf('P'), + "dustOsmium", + Character.valueOf('E'), + MekanismItems.EnergyTablet.getUnchargedItem() } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(GeneratorsBlocks.Generator, 1, 5), + new Object[] { "SES", + "SES", + "III", + Character.valueOf('S'), + new ItemStack(GeneratorsBlocks.Generator, 1, 1), + Character.valueOf('E'), + MekanismItems.EnrichedAlloy, + Character.valueOf('I'), + "ingotIron" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(GeneratorsBlocks.Generator, 1, 4), + new Object[] { "RER", + "BCB", + "NEN", + Character.valueOf('R'), + "dustRedstone", + Character.valueOf('E'), + MekanismItems.EnrichedAlloy, + Character.valueOf('B'), + MekanismItems.BioFuel, + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.BASIC), + Character.valueOf('N'), + "ingotIron" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(GeneratorsBlocks.Generator, 1, 3), + new Object[] { "PEP", + "ICI", + "PEP", + Character.valueOf('P'), + "ingotOsmium", + Character.valueOf('E'), + MekanismItems.EnrichedAlloy, + Character.valueOf('I'), + new ItemStack(MekanismBlocks.BasicBlock, 1, 8), + Character.valueOf('C'), + MekanismItems.ElectrolyticCore } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(GeneratorsItems.SolarPanel), + new Object[] { "GGG", + "RAR", + "PPP", + Character.valueOf('G'), + "paneGlass", + Character.valueOf('R'), + "dustRedstone", + Character.valueOf('A'), + MekanismItems.EnrichedAlloy, + Character.valueOf('P'), + "ingotOsmium" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(GeneratorsBlocks.Generator, 1, 6), + new Object[] { " O ", + "OAO", + "ECE", + Character.valueOf('O'), + "ingotOsmium", + Character.valueOf('A'), + MekanismItems.EnrichedAlloy, + Character.valueOf('E'), + MekanismItems.EnergyTablet.getUnchargedItem(), + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.BASIC) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(GeneratorsItems.TurbineBlade), + new Object[] { " S ", + "SAS", + " S ", + Character.valueOf('S'), + "ingotSteel", + Character.valueOf('A'), + MekanismItems.EnrichedAlloy } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(GeneratorsBlocks.Generator, 1, 7), + new Object[] { "SAS", + "SAS", + "SAS", + Character.valueOf('S'), + "ingotSteel", + Character.valueOf('A'), + MekanismItems.EnrichedAlloy } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(GeneratorsBlocks.Generator, 1, 8), + new Object[] { "SAS", + "CAC", + "SAS", + Character.valueOf('S'), + "ingotSteel", + Character.valueOf('A'), + MekanismItems.EnrichedAlloy, + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.ADVANCED) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(GeneratorsBlocks.Generator, 1, 9), + new Object[] { "SGS", + "GEG", + "SGS", + Character.valueOf('S'), + "ingotSteel", + Character.valueOf('G'), + "ingotGold", + Character.valueOf('E'), + MekanismItems.EnergyTablet.getUnchargedItem() } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(GeneratorsBlocks.Generator, 4, 10), + new Object[] { " S ", + "SOS", + " S ", + Character.valueOf('S'), + "ingotSteel", + Character.valueOf('O'), + "ingotOsmium" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(GeneratorsBlocks.Generator, 2, 11), + new Object[] { " I ", + "ICI", + " I ", + Character.valueOf('I'), + new ItemStack(GeneratorsBlocks.Generator, 1, 10), + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.ADVANCED) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(GeneratorsBlocks.Generator, 2, 12), + new Object[] { " I ", + "IFI", + " I ", + Character.valueOf('I'), + new ItemStack(GeneratorsBlocks.Generator, 1, 10), + Character.valueOf('F'), + Blocks.iron_bars } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(GeneratorsBlocks.Generator, 1, 13), + new Object[] { "STS", + "TBT", + "STS", + Character.valueOf('S'), + "ingotSteel", + Character.valueOf('T'), + "ingotTin", + Character.valueOf('B'), + Items.bucket } + )); + + //Reactor Recipes + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(GeneratorsBlocks.Reactor, 4, 1), + new Object[] { " C ", + "CAC", + " C ", + Character.valueOf('C'), + new ItemStack(MekanismBlocks.BasicBlock, 1, 8), + Character.valueOf('A'), + "alloyUltimate" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(GeneratorsBlocks.Reactor, 2, 3), + new Object[] { " I ", + "ICI", + " I ", + Character.valueOf('I'), + new ItemStack(GeneratorsBlocks.Reactor, 1, 1), + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.ULTIMATE) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(GeneratorsBlocks.ReactorGlass, 4, 0), + new Object[] { " I ", + "IGI", + " I ", + Character.valueOf('I'), + new ItemStack(GeneratorsBlocks.Reactor, 1, 1), + Character.valueOf('G'), + "blockGlass" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(GeneratorsBlocks.Reactor, 1, 0), + new Object[] { "CGC", + "ITI", + "III", + Character.valueOf('C'), + MekanismUtils.getControlCircuit(BaseTier.ULTIMATE), + Character.valueOf('G'), + "paneGlass", + Character.valueOf('I'), + new ItemStack(GeneratorsBlocks.Reactor, 1, 1), + Character.valueOf('T'), + MekanismUtils.getEmptyGasTank(GasTankTier.BASIC) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(GeneratorsBlocks.ReactorGlass, 2, 1), + new Object[] { " I ", + "ILI", + " I ", + Character.valueOf('I'), + new ItemStack(GeneratorsBlocks.ReactorGlass, 1, 0), + Character.valueOf('L'), + "blockRedstone" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(GeneratorsBlocks.Reactor, 1, 4), + new Object[] { " R ", + "RFR", + " R ", + Character.valueOf('R'), + "dustRedstone", + Character.valueOf('F'), + new ItemStack(GeneratorsBlocks.Reactor, 1, 1) } + )); + + FuelHandler.addGas( + GasRegistry.getGas("ethene"), + general.ETHENE_BURN_TIME, + general.FROM_H2 + generators.bioGeneration * 2 * general.ETHENE_BURN_TIME + ); //1mB hydrogen + 2*bioFuel/tick*200ticks/100mB * 20x efficiency bonus + FuelHandler.addGas( + GasRegistry.getGas("methane"), + general.METHANE_BURN_TIME, + general.FROM_H2 + generators.bioGeneration * general.METHANE_BURN_TIME + ); + } + + @Override + public String getVersion() { + return versionNumber; + } + + @Override + public String getName() { + return "Generators"; + } + + @Override + public void writeConfig(ByteBuf dataStream) throws IOException { + dataStream.writeDouble(generators.advancedSolarGeneration); + dataStream.writeDouble(generators.bioGeneration); + dataStream.writeDouble(generators.heatGeneration); + dataStream.writeDouble(generators.heatGenerationLava); + dataStream.writeDouble(generators.heatGenerationNether); + dataStream.writeInt(generators.heatGenerationFluidRate); + dataStream.writeBoolean(generators.heatGenEnable); + dataStream.writeDouble(generators.solarGeneration); + + dataStream.writeDouble(generators.windGenerationMin); + dataStream.writeDouble(generators.windGenerationMax); + + dataStream.writeInt(generators.windGenerationMinY); + dataStream.writeInt(generators.windGenerationMaxY); + + dataStream.writeInt(generators.turbineBladesPerCoil); + dataStream.writeDouble(generators.turbineVentGasFlow); + dataStream.writeDouble(generators.turbineDisperserGasFlow); + dataStream.writeInt(generators.condenserRate); + } + + @Override + public void readConfig(ByteBuf dataStream) throws IOException { + generators.advancedSolarGeneration = dataStream.readDouble(); + generators.bioGeneration = dataStream.readDouble(); + generators.heatGeneration = dataStream.readDouble(); + generators.heatGenerationLava = dataStream.readDouble(); + generators.heatGenerationNether = dataStream.readDouble(); + ; + generators.heatGenerationFluidRate = dataStream.readInt(); + generators.heatGenEnable = dataStream.readBoolean(); + generators.solarGeneration = dataStream.readDouble(); + + generators.windGenerationMin = dataStream.readDouble(); + generators.windGenerationMax = dataStream.readDouble(); + + generators.windGenerationMinY = dataStream.readInt(); + generators.windGenerationMaxY = dataStream.readInt(); + + generators.turbineBladesPerCoil = dataStream.readInt(); + generators.turbineVentGasFlow = dataStream.readDouble(); + generators.turbineDisperserGasFlow = dataStream.readDouble(); + generators.condenserRate = dataStream.readInt(); + } + + @Override + public void resetClient() { + SynchronizedTurbineData.clientRotationMap.clear(); + } + + @SubscribeEvent + public void onConfigChanged(OnConfigChangedEvent event) { + if (event.modID.equals("MekanismGenerators")) { + proxy.loadConfiguration(); + } + } } diff --git a/src/main/java/mekanism/generators/common/block/BlockGenerator.java b/src/main/java/mekanism/generators/common/block/BlockGenerator.java index 4bffd2895..911a504a5 100644 --- a/src/main/java/mekanism/generators/common/block/BlockGenerator.java +++ b/src/main/java/mekanism/generators/common/block/BlockGenerator.java @@ -4,6 +4,9 @@ import java.util.Arrays; import java.util.List; import java.util.Random; +import buildcraft.api.tools.IToolWrench; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.MekanismConfig.client; import mekanism.api.MekanismConfig.general; import mekanism.api.energy.IEnergizedItem; @@ -61,9 +64,6 @@ import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import buildcraft.api.tools.IToolWrench; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; /** * Block class for handling multiple generator block IDs. @@ -83,816 +83,875 @@ import cpw.mods.fml.relauncher.SideOnly; * @author AidanBrady * */ -public class BlockGenerator extends BlockContainer implements ISpecialBounds, IBlockCTM -{ - public IIcon[][] icons = new IIcon[16][16]; - - public CTMData[] ctms = new CTMData[16]; - - public IIcon BASE_ICON; - - public Random machineRand = new Random(); +public class BlockGenerator extends BlockContainer implements ISpecialBounds, IBlockCTM { + public IIcon[][] icons = new IIcon[16][16]; - public BlockGenerator() - { - super(Material.iron); - setHardness(3.5F); - setResistance(8F); - setCreativeTab(Mekanism.tabMekanism); - } + public CTMData[] ctms = new CTMData[16]; - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister register) - { - BASE_ICON = register.registerIcon("mekanism:SteelCasing"); - - ctms[9] = new CTMData("ctm/ElectromagneticCoil", this, Arrays.asList(9)).registerIcons(register); - ctms[10] = new CTMData("ctm/TurbineCasing", this, Arrays.asList(10, 11, 12)).registerIcons(register); - ctms[11] = new CTMData("ctm/TurbineValve", this, Arrays.asList(10, 11, 12)).registerIcons(register); - ctms[12] = new CTMData("ctm/TurbineVent", this, Arrays.asList(10, 11, 12)).registerIcons(register); - ctms[13] = new CTMData("ctm/SaturatingCondenser", this, Arrays.asList(13)).registerIcons(register); - - icons[7][0] = register.registerIcon("mekanism:TurbineRod"); - icons[8][0] = register.registerIcon("mekanism:RotationalComplexSide"); - icons[8][1] = register.registerIcon("mekanism:RotationalComplexTop"); - - icons[9][0] = ctms[9].mainTextureData.icon; - icons[10][0] = ctms[10].mainTextureData.icon; - icons[11][0] = ctms[11].mainTextureData.icon; - icons[12][0] = ctms[12].mainTextureData.icon; - icons[13][0] = ctms[13].mainTextureData.icon; - } - - @Override - public CTMData getCTMData(IBlockAccess world, int x, int y, int z, int meta) - { - return ctms[meta]; - } - - @Override - public boolean shouldRenderBlock(IBlockAccess world, int x, int y, int z, int meta) - { - return !GeneratorType.getFromMetadata(meta).hasModel; - } - - @Override - public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) - { - setBlockBoundsBasedOnState(world, x, y, z); - - return super.getCollisionBoundingBoxFromPool(world, x, y, z); + public IIcon BASE_ICON; + + public Random machineRand = new Random(); + + public BlockGenerator() { + super(Material.iron); + setHardness(3.5F); + setResistance(8F); + setCreativeTab(Mekanism.tabMekanism); } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int meta) - { - GeneratorType type = GeneratorType.getFromMetadata(meta); - - if(type == GeneratorType.ROTATIONAL_COMPLEX) - { - if(side != 0 && side != 1) - { - return icons[meta][0]; - } - else { - return icons[meta][1]; - } - } - else if(!type.hasModel) - { - return icons[meta][0]; - } - else { - return BASE_ICON; - } - } - - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) - { - int meta = world.getBlockMetadata(x, y, z); - - return getIcon(side, meta); - } - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) - { - if(!world.isRemote) - { - TileEntity tileEntity = world.getTileEntity(x, y, z); - - if(tileEntity instanceof IMultiblock) - { - ((IMultiblock)tileEntity).update(); - } + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister register) { + BASE_ICON = register.registerIcon("mekanism:SteelCasing"); - if(tileEntity instanceof TileEntityBasicBlock) - { - ((TileEntityBasicBlock)tileEntity).onNeighborChange(block); - } - } - } + ctms[9] = new CTMData("ctm/ElectromagneticCoil", this, Arrays.asList(9)) + .registerIcons(register); + ctms[10] = new CTMData("ctm/TurbineCasing", this, Arrays.asList(10, 11, 12)) + .registerIcons(register); + ctms[11] = new CTMData("ctm/TurbineValve", this, Arrays.asList(10, 11, 12)) + .registerIcons(register); + ctms[12] = new CTMData("ctm/TurbineVent", this, Arrays.asList(10, 11, 12)) + .registerIcons(register); + ctms[13] = new CTMData("ctm/SaturatingCondenser", this, Arrays.asList(13)) + .registerIcons(register); - @Override - public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityliving, ItemStack itemstack) - { - TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(x, y, z); + icons[7][0] = register.registerIcon("mekanism:TurbineRod"); + icons[8][0] = register.registerIcon("mekanism:RotationalComplexSide"); + icons[8][1] = register.registerIcon("mekanism:RotationalComplexTop"); - int side = MathHelper.floor_double((double)(entityliving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; - int height = Math.round(entityliving.rotationPitch); - int change = 3; + icons[9][0] = ctms[9].mainTextureData.icon; + icons[10][0] = ctms[10].mainTextureData.icon; + icons[11][0] = ctms[11].mainTextureData.icon; + icons[12][0] = ctms[12].mainTextureData.icon; + icons[13][0] = ctms[13].mainTextureData.icon; + } - if(!GeneratorType.getFromMetadata(world.getBlockMetadata(x, y, z)).hasModel && tileEntity.canSetFacing(0) && tileEntity.canSetFacing(1)) - { - if(height >= 65) - { - change = 1; - } - else if(height <= -65) - { - change = 0; - } - } + @Override + public CTMData getCTMData(IBlockAccess world, int x, int y, int z, int meta) { + return ctms[meta]; + } - if(change != 0 && change != 1) - { - switch(side) - { - case 0: change = 2; break; - case 1: change = 5; break; - case 2: change = 3; break; - case 3: change = 4; break; - } - } + @Override + public boolean shouldRenderBlock(IBlockAccess world, int x, int y, int z, int meta) { + return !GeneratorType.getFromMetadata(meta).hasModel; + } - tileEntity.setFacing((short)change); - tileEntity.redstone = world.isBlockIndirectlyGettingPowered(x, y, z); + @Override + public AxisAlignedBB + getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { + setBlockBoundsBasedOnState(world, x, y, z); - if(tileEntity instanceof IBoundingBlock) - { - ((IBoundingBlock)tileEntity).onPlace(); - } - - if(!world.isRemote && tileEntity instanceof IMultiblock) - { - ((IMultiblock)tileEntity).update(); - } - } + return super.getCollisionBoundingBoxFromPool(world, x, y, z); + } - @Override - public int getLightValue(IBlockAccess world, int x, int y, int z) - { - if(client.enableAmbientLighting) - { - TileEntity tileEntity = world.getTileEntity(x, y, z); + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { + GeneratorType type = GeneratorType.getFromMetadata(meta); - if(tileEntity instanceof IActiveState && !(tileEntity instanceof TileEntitySolarGenerator)) - { - if(((IActiveState)tileEntity).getActive() && ((IActiveState)tileEntity).lightUpdate()) - { - return client.ambientLightingLevel; - } - } - } + if (type == GeneratorType.ROTATIONAL_COMPLEX) { + if (side != 0 && side != 1) { + return icons[meta][0]; + } else { + return icons[meta][1]; + } + } else if (!type.hasModel) { + return icons[meta][0]; + } else { + return BASE_ICON; + } + } - return 0; - } + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { + int meta = world.getBlockMetadata(x, y, z); + return getIcon(side, meta); + } - @Override - public int damageDropped(int i) - { - return i; - } - - @Override - public float getPlayerRelativeBlockHardness(EntityPlayer player, World world, int x, int y, int z) - { - TileEntity tile = world.getTileEntity(x, y, z); - - return SecurityUtils.canAccess(player, tile) ? super.getPlayerRelativeBlockHardness(player, world, x, y, z) : 0.0F; - } + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + if (!world.isRemote) { + TileEntity tileEntity = world.getTileEntity(x, y, z); - @Override - @SideOnly(Side.CLIENT) - public void getSubBlocks(Item i, CreativeTabs creativetabs, List list) - { - for(GeneratorType type : GeneratorType.values()) - { - list.add(new ItemStack(i, 1, type.meta)); - } - } + if (tileEntity instanceof IMultiblock) { + ((IMultiblock) tileEntity).update(); + } - @Override - @SideOnly(Side.CLIENT) - public void randomDisplayTick(World world, int x, int y, int z, Random random) - { - int metadata = world.getBlockMetadata(x, y, z); - TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(x, y, z); - - if(MekanismUtils.isActive(world, x, y, z)) - { - float xRandom = (float)x + 0.5F; - float yRandom = (float)y + 0.0F + random.nextFloat() * 6.0F / 16.0F; - float zRandom = (float)z + 0.5F; - float iRandom = 0.52F; - float jRandom = random.nextFloat() * 0.6F - 0.3F; + if (tileEntity instanceof TileEntityBasicBlock) { + ((TileEntityBasicBlock) tileEntity).onNeighborChange(block); + } + } + } - if(tileEntity.facing == 4) - { - switch(GeneratorType.getFromMetadata(metadata)) - { - case HEAT_GENERATOR: - world.spawnParticle("smoke", (double)(xRandom - iRandom), (double)yRandom + 0.5F, (double)(zRandom - jRandom), 0.0D, 0.0D, 0.0D); - world.spawnParticle("flame", (double)(xRandom - iRandom), (double)yRandom + 0.5F, (double)(zRandom - jRandom), 0.0D, 0.0D, 0.0D); - break; - case BIO_GENERATOR: - world.spawnParticle("smoke", x+.25, y+.2, z+.5, 0.0D, 0.0D, 0.0D); - break; - default: - break; - } - } - else if(tileEntity.facing == 5) - { - switch(GeneratorType.getFromMetadata(metadata)) - { - case HEAT_GENERATOR: - world.spawnParticle("smoke", (double)(xRandom + iRandom), (double)yRandom + 0.5F, (double)(zRandom - jRandom), 0.0D, 0.0D, 0.0D); - world.spawnParticle("flame", (double)(xRandom + iRandom), (double)yRandom + 0.5F, (double)(zRandom - jRandom), 0.0D, 0.0D, 0.0D); - break; - case BIO_GENERATOR: - world.spawnParticle("smoke", x+.75, y+.2, z+.5, 0.0D, 0.0D, 0.0D); - break; - default: - break; - } - } - else if(tileEntity.facing == 2) - { - switch(GeneratorType.getFromMetadata(metadata)) - { - case HEAT_GENERATOR: - world.spawnParticle("smoke", (double)(xRandom - jRandom), (double)yRandom + 0.5F, (double)(zRandom - iRandom), 0.0D, 0.0D, 0.0D); - world.spawnParticle("flame", (double)(xRandom - jRandom), (double)yRandom + 0.5F, (double)(zRandom - iRandom), 0.0D, 0.0D, 0.0D); - break; - case BIO_GENERATOR: - world.spawnParticle("smoke", x+.5, y+.2, z+.25, 0.0D, 0.0D, 0.0D); - break; - default: - break; - } - } - else if(tileEntity.facing == 3) - { - switch(GeneratorType.getFromMetadata(metadata)) - { - case HEAT_GENERATOR: - world.spawnParticle("smoke", (double)(xRandom - jRandom), (double)yRandom + 0.5F, (double)(zRandom + iRandom), 0.0D, 0.0D, 0.0D); - world.spawnParticle("flame", (double)(xRandom - jRandom), (double)yRandom + 0.5F, (double)(zRandom + iRandom), 0.0D, 0.0D, 0.0D); - break; - case BIO_GENERATOR: - world.spawnParticle("smoke", x+.5, y+.2, z+.75, 0.0D, 0.0D, 0.0D); - break; - default: - break; - } - } - } - } + @Override + public void onBlockPlacedBy( + World world, + int x, + int y, + int z, + EntityLivingBase entityliving, + ItemStack itemstack + ) { + TileEntityBasicBlock tileEntity + = (TileEntityBasicBlock) world.getTileEntity(x, y, z); - @Override - public boolean canPlaceBlockAt(World world, int x, int y, int z) - { - //This method doesn't actually seem to be used in MC code... - if(world.getBlockMetadata(x, y, z) == GeneratorType.ADVANCED_SOLAR_GENERATOR.meta) - { - boolean canPlace = super.canPlaceBlockAt(world, x, y, z); + int side = MathHelper.floor_double( + (double) (entityliving.rotationYaw * 4.0F / 360.0F) + 0.5D + ) + & 3; + int height = Math.round(entityliving.rotationPitch); + int change = 3; - boolean nonAir = false; - nonAir |= world.isAirBlock(x, y, z); - nonAir |= world.isAirBlock(x, y+1, x); + if (!GeneratorType.getFromMetadata(world.getBlockMetadata(x, y, z)).hasModel + && tileEntity.canSetFacing(0) && tileEntity.canSetFacing(1)) { + if (height >= 65) { + change = 1; + } else if (height <= -65) { + change = 0; + } + } - for(int xPos=-1;xPos<=1;xPos++) - { - for(int zPos=-1;zPos<=1;zPos++) - { - nonAir |= world.isAirBlock(x+xPos, y+2, z+zPos); - } - } + if (change != 0 && change != 1) { + switch (side) { + case 0: + change = 2; + break; + case 1: + change = 5; + break; + case 2: + change = 3; + break; + case 3: + change = 4; + break; + } + } - return (!nonAir) && canPlace; - } - else if(world.getBlockMetadata(x, y, z) == GeneratorType.WIND_GENERATOR.meta) - { - boolean canPlace = super.canPlaceBlockAt(world, x, y, z); + tileEntity.setFacing((short) change); + tileEntity.redstone = world.isBlockIndirectlyGettingPowered(x, y, z); - boolean nonAir = false; + if (tileEntity instanceof IBoundingBlock) { + ((IBoundingBlock) tileEntity).onPlace(); + } - for(int yPos = y+1; yPos <= y+4; yPos++) - { - nonAir |= world.isAirBlock(x, yPos, z); - } + if (!world.isRemote && tileEntity instanceof IMultiblock) { + ((IMultiblock) tileEntity).update(); + } + } - return (!nonAir) && canPlace; - } + @Override + public int getLightValue(IBlockAccess world, int x, int y, int z) { + if (client.enableAmbientLighting) { + TileEntity tileEntity = world.getTileEntity(x, y, z); - return super.canPlaceBlockAt(world, x, y, z); - } + if (tileEntity instanceof IActiveState + && !(tileEntity instanceof TileEntitySolarGenerator)) { + if (((IActiveState) tileEntity).getActive() + && ((IActiveState) tileEntity).lightUpdate()) { + return client.ambientLightingLevel; + } + } + } - @Override - public void breakBlock(World world, int x, int y, int z, Block block, int meta) - { - TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(x, y, z); - - if(!world.isRemote && tileEntity instanceof TileEntityTurbineRotor) - { - int amount = ((TileEntityTurbineRotor)tileEntity).getHousedBlades(); - - if(amount > 0) - { - float motion = 0.7F; - double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + return 0; + } - EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, new ItemStack(GeneratorsItems.TurbineBlade, amount)); + @Override + public int damageDropped(int i) { + return i; + } - world.spawnEntityInWorld(entityItem); - } - } + @Override + public float getPlayerRelativeBlockHardness( + EntityPlayer player, World world, int x, int y, int z + ) { + TileEntity tile = world.getTileEntity(x, y, z); - if(tileEntity instanceof IBoundingBlock) - { - ((IBoundingBlock)tileEntity).onBreak(); - } + return SecurityUtils.canAccess(player, tile) + ? super.getPlayerRelativeBlockHardness(player, world, x, y, z) + : 0.0F; + } - super.breakBlock(world, x, y, z, block, meta); - } + @Override + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item i, CreativeTabs creativetabs, List list) { + for (GeneratorType type : GeneratorType.values()) { + list.add(new ItemStack(i, 1, type.meta)); + } + } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int side, float playerX, float playerY, float playerZ) - { - if(world.isRemote) - { - return true; - } + @Override + @SideOnly(Side.CLIENT) + public void randomDisplayTick(World world, int x, int y, int z, Random random) { + int metadata = world.getBlockMetadata(x, y, z); + TileEntityBasicBlock tileEntity + = (TileEntityBasicBlock) world.getTileEntity(x, y, z); - TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(x, y, z); - int metadata = world.getBlockMetadata(x, y, z); + if (MekanismUtils.isActive(world, x, y, z)) { + float xRandom = (float) x + 0.5F; + float yRandom = (float) y + 0.0F + random.nextFloat() * 6.0F / 16.0F; + float zRandom = (float) z + 0.5F; + float iRandom = 0.52F; + float jRandom = random.nextFloat() * 0.6F - 0.3F; - if(entityplayer.getCurrentEquippedItem() != null) - { - Item tool = entityplayer.getCurrentEquippedItem().getItem(); + if (tileEntity.facing == 4) { + switch (GeneratorType.getFromMetadata(metadata)) { + case HEAT_GENERATOR: + world.spawnParticle( + "smoke", + (double) (xRandom - iRandom), + (double) yRandom + 0.5F, + (double) (zRandom - jRandom), + 0.0D, + 0.0D, + 0.0D + ); + world.spawnParticle( + "flame", + (double) (xRandom - iRandom), + (double) yRandom + 0.5F, + (double) (zRandom - jRandom), + 0.0D, + 0.0D, + 0.0D + ); + break; + case BIO_GENERATOR: + world.spawnParticle( + "smoke", x + .25, y + .2, z + .5, 0.0D, 0.0D, 0.0D + ); + break; + default: + break; + } + } else if (tileEntity.facing == 5) { + switch (GeneratorType.getFromMetadata(metadata)) { + case HEAT_GENERATOR: + world.spawnParticle( + "smoke", + (double) (xRandom + iRandom), + (double) yRandom + 0.5F, + (double) (zRandom - jRandom), + 0.0D, + 0.0D, + 0.0D + ); + world.spawnParticle( + "flame", + (double) (xRandom + iRandom), + (double) yRandom + 0.5F, + (double) (zRandom - jRandom), + 0.0D, + 0.0D, + 0.0D + ); + break; + case BIO_GENERATOR: + world.spawnParticle( + "smoke", x + .75, y + .2, z + .5, 0.0D, 0.0D, 0.0D + ); + break; + default: + break; + } + } else if (tileEntity.facing == 2) { + switch (GeneratorType.getFromMetadata(metadata)) { + case HEAT_GENERATOR: + world.spawnParticle( + "smoke", + (double) (xRandom - jRandom), + (double) yRandom + 0.5F, + (double) (zRandom - iRandom), + 0.0D, + 0.0D, + 0.0D + ); + world.spawnParticle( + "flame", + (double) (xRandom - jRandom), + (double) yRandom + 0.5F, + (double) (zRandom - iRandom), + 0.0D, + 0.0D, + 0.0D + ); + break; + case BIO_GENERATOR: + world.spawnParticle( + "smoke", x + .5, y + .2, z + .25, 0.0D, 0.0D, 0.0D + ); + break; + default: + break; + } + } else if (tileEntity.facing == 3) { + switch (GeneratorType.getFromMetadata(metadata)) { + case HEAT_GENERATOR: + world.spawnParticle( + "smoke", + (double) (xRandom - jRandom), + (double) yRandom + 0.5F, + (double) (zRandom + iRandom), + 0.0D, + 0.0D, + 0.0D + ); + world.spawnParticle( + "flame", + (double) (xRandom - jRandom), + (double) yRandom + 0.5F, + (double) (zRandom + iRandom), + 0.0D, + 0.0D, + 0.0D + ); + break; + case BIO_GENERATOR: + world.spawnParticle( + "smoke", x + .5, y + .2, z + .75, 0.0D, 0.0D, 0.0D + ); + break; + default: + break; + } + } + } + } - if(MekanismUtils.hasUsableWrench(entityplayer, x, y, z)) - { - if(SecurityUtils.canAccess(entityplayer, tileEntity)) - { - if(entityplayer.isSneaking()) - { - dismantleBlock(world, x, y, z, false); - - return true; - } - - if(MekanismUtils.isBCWrench(tool)) - { - ((IToolWrench)tool).wrenchUsed(entityplayer, x, y, z); - } - - int change = ForgeDirection.ROTATION_MATRIX[ForgeDirection.UP.ordinal()][tileEntity.facing]; - - tileEntity.setFacing((short)change); - world.notifyBlocksOfNeighborChange(x, y, z, this); - } - else { - SecurityUtils.displayNoAccess(entityplayer); - } - - return true; - } - } - - if(metadata == GeneratorType.TURBINE_CASING.meta || metadata == GeneratorType.TURBINE_VALVE.meta || metadata == GeneratorType.TURBINE_VENT.meta) - { - return ((IMultiblock)world.getTileEntity(x, y, z)).onActivate(entityplayer); - } - - if(metadata == GeneratorType.TURBINE_ROTOR.meta) - { - TileEntityTurbineRotor rod = (TileEntityTurbineRotor)tileEntity; - - if(!entityplayer.isSneaking()) - { - if(entityplayer.getCurrentEquippedItem() != null && entityplayer.getCurrentEquippedItem().getItem() == GeneratorsItems.TurbineBlade) - { - if(!world.isRemote && rod.editBlade(true)) - { - if(!entityplayer.capabilities.isCreativeMode) - { - entityplayer.getCurrentEquippedItem().stackSize--; - - if(entityplayer.getCurrentEquippedItem().stackSize == 0) - { - entityplayer.setCurrentItemOrArmor(0, null); - } - } - } - - return true; - } - } - else { - if(!world.isRemote) - { - if(entityplayer.getCurrentEquippedItem() == null) - { - if(rod.editBlade(false)) - { - if(!entityplayer.capabilities.isCreativeMode) - { - entityplayer.setCurrentItemOrArmor(0, new ItemStack(GeneratorsItems.TurbineBlade)); - entityplayer.inventory.markDirty(); - } - } - } + @Override + public boolean canPlaceBlockAt(World world, int x, int y, int z) { + //This method doesn't actually seem to be used in MC code... + if (world.getBlockMetadata(x, y, z) + == GeneratorType.ADVANCED_SOLAR_GENERATOR.meta) { + boolean canPlace = super.canPlaceBlockAt(world, x, y, z); + + boolean nonAir = false; + nonAir |= world.isAirBlock(x, y, z); + nonAir |= world.isAirBlock(x, y + 1, x); + + for (int xPos = -1; xPos <= 1; xPos++) { + for (int zPos = -1; zPos <= 1; zPos++) { + nonAir |= world.isAirBlock(x + xPos, y + 2, z + zPos); + } + } + + return (!nonAir) && canPlace; + } else if (world.getBlockMetadata(x, y, z) == GeneratorType.WIND_GENERATOR.meta) { + boolean canPlace = super.canPlaceBlockAt(world, x, y, z); + + boolean nonAir = false; + + for (int yPos = y + 1; yPos <= y + 4; yPos++) { + nonAir |= world.isAirBlock(x, yPos, z); + } + + return (!nonAir) && canPlace; + } + + return super.canPlaceBlockAt(world, x, y, z); + } + + @Override + public void breakBlock(World world, int x, int y, int z, Block block, int meta) { + TileEntityBasicBlock tileEntity + = (TileEntityBasicBlock) world.getTileEntity(x, y, z); + + if (!world.isRemote && tileEntity instanceof TileEntityTurbineRotor) { + int amount = ((TileEntityTurbineRotor) tileEntity).getHousedBlades(); + + if (amount > 0) { + float motion = 0.7F; + double motionX + = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionY + = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionZ + = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + + EntityItem entityItem = new EntityItem( + world, + x + motionX, + y + motionY, + z + motionZ, + new ItemStack(GeneratorsItems.TurbineBlade, amount) + ); + + world.spawnEntityInWorld(entityItem); + } + } + + if (tileEntity instanceof IBoundingBlock) { + ((IBoundingBlock) tileEntity).onBreak(); + } + + super.breakBlock(world, x, y, z, block, meta); + } + + @Override + public boolean onBlockActivated( + World world, + int x, + int y, + int z, + EntityPlayer entityplayer, + int side, + float playerX, + float playerY, + float playerZ + ) { + if (world.isRemote) { + return true; + } + + TileEntityBasicBlock tileEntity + = (TileEntityBasicBlock) world.getTileEntity(x, y, z); + int metadata = world.getBlockMetadata(x, y, z); + + if (entityplayer.getCurrentEquippedItem() != null) { + Item tool = entityplayer.getCurrentEquippedItem().getItem(); + + if (MekanismUtils.hasUsableWrench(entityplayer, x, y, z)) { + if (SecurityUtils.canAccess(entityplayer, tileEntity)) { + if (entityplayer.isSneaking()) { + dismantleBlock(world, x, y, z, false); + + return true; + } + + if (MekanismUtils.isBCWrench(tool)) { + ((IToolWrench) tool).wrenchUsed(entityplayer, x, y, z); + } + + int change + = ForgeDirection.ROTATION_MATRIX[ForgeDirection.UP.ordinal()] + [tileEntity.facing]; + + tileEntity.setFacing((short) change); + world.notifyBlocksOfNeighborChange(x, y, z, this); + } else { + SecurityUtils.displayNoAccess(entityplayer); + } + + return true; + } + } + + if (metadata == GeneratorType.TURBINE_CASING.meta + || metadata == GeneratorType.TURBINE_VALVE.meta + || metadata == GeneratorType.TURBINE_VENT.meta) { + return ((IMultiblock) world.getTileEntity(x, y, z)).onActivate(entityplayer); + } + + if (metadata == GeneratorType.TURBINE_ROTOR.meta) { + TileEntityTurbineRotor rod = (TileEntityTurbineRotor) tileEntity; + + if (!entityplayer.isSneaking()) { + if (entityplayer.getCurrentEquippedItem() != null + && entityplayer.getCurrentEquippedItem().getItem() + == GeneratorsItems.TurbineBlade) { + if (!world.isRemote && rod.editBlade(true)) { + if (!entityplayer.capabilities.isCreativeMode) { + entityplayer.getCurrentEquippedItem().stackSize--; + + if (entityplayer.getCurrentEquippedItem().stackSize == 0) { + entityplayer.setCurrentItemOrArmor(0, null); + } + } + } + + return true; + } + } else { + if (!world.isRemote) { + if (entityplayer.getCurrentEquippedItem() == null) { + if (rod.editBlade(false)) { + if (!entityplayer.capabilities.isCreativeMode) { + entityplayer.setCurrentItemOrArmor( + 0, new ItemStack(GeneratorsItems.TurbineBlade) + ); + entityplayer.inventory.markDirty(); + } + } + } else if(entityplayer.getCurrentEquippedItem().getItem() == GeneratorsItems.TurbineBlade) { - if(entityplayer.getCurrentEquippedItem().stackSize < entityplayer.getCurrentEquippedItem().getMaxStackSize()) - { - if(rod.editBlade(false)) - { - if(!entityplayer.capabilities.isCreativeMode) - { - entityplayer.getCurrentEquippedItem().stackSize++; - entityplayer.inventory.markDirty(); - } - } - } - } - } - - return true; - } - - return false; - } - - int guiId = GeneratorType.getFromMetadata(metadata).guiId; + if (entityplayer.getCurrentEquippedItem().stackSize + < entityplayer.getCurrentEquippedItem().getMaxStackSize()) { + if (rod.editBlade(false)) { + if (!entityplayer.capabilities.isCreativeMode) { + entityplayer.getCurrentEquippedItem().stackSize++; + entityplayer.inventory.markDirty(); + } + } + } + } + } - if(guiId != -1 && tileEntity != null) - { - if(!entityplayer.isSneaking()) - { - if(SecurityUtils.canAccess(entityplayer, tileEntity)) - { - entityplayer.openGui(MekanismGenerators.instance, guiId, world, x, y, z); - } - else { - SecurityUtils.displayNoAccess(entityplayer); - } - - return true; - } - } + return true; + } - return false; - } + return false; + } - @Override - public int quantityDropped(Random random) - { - return 0; - } + int guiId = GeneratorType.getFromMetadata(metadata).guiId; - @Override - public TileEntity createTileEntity(World world, int metadata) - { - GeneratorType type = GeneratorType.getFromMetadata(metadata); + if (guiId != -1 && tileEntity != null) { + if (!entityplayer.isSneaking()) { + if (SecurityUtils.canAccess(entityplayer, tileEntity)) { + entityplayer.openGui( + MekanismGenerators.instance, guiId, world, x, y, z + ); + } else { + SecurityUtils.displayNoAccess(entityplayer); + } - if(type != null) - { - return type.create(); - } + return true; + } + } - return null; - } + return false; + } - @Override - public Item getItemDropped(int i, Random random, int j) - { - return null; - } + @Override + public int quantityDropped(Random random) { + return 0; + } - @Override - public boolean renderAsNormalBlock() - { - return false; - } + @Override + public TileEntity createTileEntity(World world, int metadata) { + GeneratorType type = GeneratorType.getFromMetadata(metadata); - @Override - public boolean isOpaqueCube() - { - return false; - } + if (type != null) { + return type.create(); + } - @Override - public int getRenderType() - { - return Mekanism.proxy.CTM_RENDER_ID; - } + return null; + } - /*This method is not used, metadata manipulation is required to create a Tile Entity.*/ - @Override - public TileEntity createNewTileEntity(World world, int meta) - { - return null; - } + @Override + public Item getItemDropped(int i, Random random, int j) { + return null; + } - @Override - public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) - { - int metadata = world.getBlockMetadata(x, y, z); + @Override + public boolean renderAsNormalBlock() { + return false; + } - if(metadata == GeneratorType.SOLAR_GENERATOR.meta) - { - setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.7F, 1.0F); - } - else if(metadata == GeneratorType.TURBINE_ROTOR.meta) - { - setBlockBounds(0.375F, 0.0F, 0.375F, 0.625F, 1.0F, 0.625F); - } - else { - setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - } - } - - @Override - public void onBlockAdded(World world, int x, int y, int z) - { - TileEntity tileEntity = world.getTileEntity(x, y, z); + @Override + public boolean isOpaqueCube() { + return false; + } - if(!world.isRemote) - { - if(tileEntity instanceof TileEntityBasicBlock) - { - ((TileEntityBasicBlock)tileEntity).onAdded(); - } - } - } + @Override + public int getRenderType() { + return Mekanism.proxy.CTM_RENDER_ID; + } - @Override - public boolean removedByPlayer(World world, EntityPlayer player, int x, int y, int z, boolean willHarvest) - { - if(!player.capabilities.isCreativeMode && !world.isRemote && willHarvest) - { - float motion = 0.7F; - double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + /*This method is not used, metadata manipulation is required to create a Tile + * Entity.*/ + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return null; + } - EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, getPickBlock(null, world, x, y, z, player)); + @Override + public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { + int metadata = world.getBlockMetadata(x, y, z); - world.spawnEntityInWorld(entityItem); - } + if (metadata == GeneratorType.SOLAR_GENERATOR.meta) { + setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.7F, 1.0F); + } else if (metadata == GeneratorType.TURBINE_ROTOR.meta) { + setBlockBounds(0.375F, 0.0F, 0.375F, 0.625F, 1.0F, 0.625F); + } else { + setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + } - return world.setBlockToAir(x, y, z); - } + @Override + public void onBlockAdded(World world, int x, int y, int z) { + TileEntity tileEntity = world.getTileEntity(x, y, z); - @Override - public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player) - { - TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(x, y, z); - ItemStack itemStack = new ItemStack(GeneratorsBlocks.Generator, 1, world.getBlockMetadata(x, y, z)); + if (!world.isRemote) { + if (tileEntity instanceof TileEntityBasicBlock) { + ((TileEntityBasicBlock) tileEntity).onAdded(); + } + } + } - if(itemStack.stackTagCompound == null && !(tileEntity instanceof TileEntityMultiblock)) - { - itemStack.setTagCompound(new NBTTagCompound()); - } - - if(tileEntity == null) - { - return null; - } - - if(tileEntity instanceof ISecurityTile) - { - ISecurityItem securityItem = (ISecurityItem)itemStack.getItem(); - - if(securityItem.hasSecurity(itemStack)) - { - securityItem.setOwner(itemStack, ((ISecurityTile)tileEntity).getSecurity().getOwner()); - securityItem.setSecurity(itemStack, ((ISecurityTile)tileEntity).getSecurity().getMode()); - } - } + @Override + public boolean removedByPlayer( + World world, EntityPlayer player, int x, int y, int z, boolean willHarvest + ) { + if (!player.capabilities.isCreativeMode && !world.isRemote && willHarvest) { + float motion = 0.7F; + double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - if(tileEntity instanceof TileEntityElectricBlock) - { - IEnergizedItem electricItem = (IEnergizedItem)itemStack.getItem(); - electricItem.setEnergy(itemStack, ((TileEntityElectricBlock)tileEntity).electricityStored); - } + EntityItem entityItem = new EntityItem( + world, + x + motionX, + y + motionY, + z + motionZ, + getPickBlock(null, world, x, y, z, player) + ); - if(tileEntity instanceof TileEntityContainerBlock && ((TileEntityContainerBlock)tileEntity).handleInventory()) - { - ISustainedInventory inventory = (ISustainedInventory)itemStack.getItem(); - inventory.setInventory(((TileEntityContainerBlock)tileEntity).getInventory(), itemStack); - } - - if(tileEntity instanceof ISustainedData) - { - ((ISustainedData)tileEntity).writeSustainedData(itemStack); - } + world.spawnEntityInWorld(entityItem); + } - if(((ISustainedTank)itemStack.getItem()).hasTank(itemStack)) - { - if(tileEntity instanceof ISustainedTank) - { - if(((ISustainedTank)tileEntity).getFluidStack() != null) - { - ((ISustainedTank)itemStack.getItem()).setFluidStack(((ISustainedTank)tileEntity).getFluidStack(), itemStack); - } - } - } + return world.setBlockToAir(x, y, z); + } - return itemStack; - } + @Override + public ItemStack getPickBlock( + MovingObjectPosition target, World world, int x, int y, int z, EntityPlayer player + ) { + TileEntityBasicBlock tileEntity + = (TileEntityBasicBlock) world.getTileEntity(x, y, z); + ItemStack itemStack = new ItemStack( + GeneratorsBlocks.Generator, 1, world.getBlockMetadata(x, y, z) + ); - public ItemStack dismantleBlock(World world, int x, int y, int z, boolean returnBlock) - { - ItemStack itemStack = getPickBlock(null, world, x, y, z, null); + if (itemStack.stackTagCompound == null + && !(tileEntity instanceof TileEntityMultiblock)) { + itemStack.setTagCompound(new NBTTagCompound()); + } - world.setBlockToAir(x, y, z); + if (tileEntity == null) { + return null; + } - if(!returnBlock) - { - float motion = 0.7F; - double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + if (tileEntity instanceof ISecurityTile) { + ISecurityItem securityItem = (ISecurityItem) itemStack.getItem(); - EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, itemStack); + if (securityItem.hasSecurity(itemStack)) { + securityItem.setOwner( + itemStack, ((ISecurityTile) tileEntity).getSecurity().getOwner() + ); + securityItem.setSecurity( + itemStack, ((ISecurityTile) tileEntity).getSecurity().getMode() + ); + } + } - world.spawnEntityInWorld(entityItem); - } + if (tileEntity instanceof TileEntityElectricBlock) { + IEnergizedItem electricItem = (IEnergizedItem) itemStack.getItem(); + electricItem.setEnergy( + itemStack, ((TileEntityElectricBlock) tileEntity).electricityStored + ); + } - return itemStack; - } + if (tileEntity instanceof TileEntityContainerBlock + && ((TileEntityContainerBlock) tileEntity).handleInventory()) { + ISustainedInventory inventory = (ISustainedInventory) itemStack.getItem(); + inventory.setInventory( + ((TileEntityContainerBlock) tileEntity).getInventory(), itemStack + ); + } - @Override - public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) - { - int metadata = world.getBlockMetadata(x, y, z); + if (tileEntity instanceof ISustainedData) { + ((ISustainedData) tileEntity).writeSustainedData(itemStack); + } - if(metadata != GeneratorType.SOLAR_GENERATOR.meta && - metadata != GeneratorType.ADVANCED_SOLAR_GENERATOR.meta && - metadata != GeneratorType.WIND_GENERATOR.meta && - metadata != GeneratorType.TURBINE_ROTOR.meta) - { - return true; - } + if (((ISustainedTank) itemStack.getItem()).hasTank(itemStack)) { + if (tileEntity instanceof ISustainedTank) { + if (((ISustainedTank) tileEntity).getFluidStack() != null) { + ((ISustainedTank) itemStack.getItem()) + .setFluidStack( + ((ISustainedTank) tileEntity).getFluidStack(), itemStack + ); + } + } + } - return false; - } + return itemStack; + } - public static enum GeneratorType - { - HEAT_GENERATOR(0, "HeatGenerator", 0, 160000, TileEntityHeatGenerator.class, true), - SOLAR_GENERATOR(1, "SolarGenerator", 1, 96000, TileEntitySolarGenerator.class, true), - GAS_GENERATOR(3, "GasGenerator", 3, general.FROM_H2*100, TileEntityGasGenerator.class, true), - BIO_GENERATOR(4, "BioGenerator", 4, 160000, TileEntityBioGenerator.class, true), - ADVANCED_SOLAR_GENERATOR(5, "AdvancedSolarGenerator", 1, 200000, TileEntityAdvancedSolarGenerator.class, true), - WIND_GENERATOR(6, "WindGenerator", 5, 200000, TileEntityWindGenerator.class, true), - TURBINE_ROTOR(7, "TurbineRotor", -1, -1, TileEntityTurbineRotor.class, false), - ROTATIONAL_COMPLEX(8, "RotationalComplex", -1, -1, TileEntityRotationalComplex.class, false), - ELECTROMAGNETIC_COIL(9, "ElectromagneticCoil", -1, -1, TileEntityElectromagneticCoil.class, false), - TURBINE_CASING(10, "TurbineCasing", -1, -1, TileEntityTurbineCasing.class, false), - TURBINE_VALVE(11, "TurbineValve", -1, -1, TileEntityTurbineValve.class, false), - TURBINE_VENT(12, "TurbineVent", -1, -1, TileEntityTurbineVent.class, false), - SATURATING_CONDENSER(13, "SaturatingCondenser", -1, -1, TileEntitySaturatingCondenser.class, false); + public ItemStack + dismantleBlock(World world, int x, int y, int z, boolean returnBlock) { + ItemStack itemStack = getPickBlock(null, world, x, y, z, null); - public int meta; - public String name; - public int guiId; - public double maxEnergy; - public Class tileEntityClass; - public boolean hasModel; + world.setBlockToAir(x, y, z); - private GeneratorType(int i, String s, int j, double k, Class tileClass, boolean model) - { - meta = i; - name = s; - guiId = j; - maxEnergy = k; - tileEntityClass = tileClass; - hasModel = model; - } + if (!returnBlock) { + float motion = 0.7F; + double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - public static GeneratorType getFromMetadata(int meta) - { - for(GeneratorType type : values()) - { - if(type.meta == meta) - { - return type; - } - } - - return null; - } + EntityItem entityItem + = new EntityItem(world, x + motionX, y + motionY, z + motionZ, itemStack); - public TileEntity create() - { - try { - return tileEntityClass.newInstance(); - } catch(Exception e) { - Mekanism.logger.error("Unable to indirectly create tile entity."); - e.printStackTrace(); - return null; - } - } - - public String getDescription() - { - return LangUtils.localize("tooltip." + name); - } - - public ItemStack getStack() - { - return new ItemStack(GeneratorsBlocks.Generator, 1, meta); - } + world.spawnEntityInWorld(entityItem); + } - @Override - public String toString() - { - return Integer.toString(meta); - } - } + return itemStack; + } - @Override - public void setRenderBounds(Block block, int metadata) - { - if(metadata == GeneratorType.SOLAR_GENERATOR.meta) - { - block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.7F, 1.0F); - } - else if(metadata == GeneratorType.TURBINE_ROTOR.meta) - { - block.setBlockBounds(0.375F, 0.0F, 0.375F, 0.625F, 1.0F, 0.625F); - } - else { - block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); - } - } + @Override + public boolean + isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + int metadata = world.getBlockMetadata(x, y, z); - @Override - public boolean doDefaultBoundSetting(int metadata) - { - return true; - } + if (metadata != GeneratorType.SOLAR_GENERATOR.meta + && metadata != GeneratorType.ADVANCED_SOLAR_GENERATOR.meta + && metadata != GeneratorType.WIND_GENERATOR.meta + && metadata != GeneratorType.TURBINE_ROTOR.meta) { + return true; + } - @Override - public ForgeDirection[] getValidRotations(World world, int x, int y, int z) - { - TileEntity tile = world.getTileEntity(x, y, z); - ForgeDirection[] valid = new ForgeDirection[6]; - - if(tile instanceof TileEntityBasicBlock) - { - TileEntityBasicBlock basicTile = (TileEntityBasicBlock)tile; - - for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) - { - if(basicTile.canSetFacing(dir.ordinal())) - { - valid[dir.ordinal()] = dir; - } - } - } - - return valid; - } + return false; + } - @Override - public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis) - { - TileEntity tile = world.getTileEntity(x, y, z); - - if(tile instanceof TileEntityBasicBlock) - { - TileEntityBasicBlock basicTile = (TileEntityBasicBlock)tile; - - if(basicTile.canSetFacing(axis.ordinal())) - { - basicTile.setFacing((short)axis.ordinal()); - return true; - } - } - - return false; - } + public static enum GeneratorType { + HEAT_GENERATOR( + 0, "HeatGenerator", 0, 160000, TileEntityHeatGenerator.class, true + ), + SOLAR_GENERATOR( + 1, "SolarGenerator", 1, 96000, TileEntitySolarGenerator.class, true + ), + GAS_GENERATOR( + 3, + "GasGenerator", + 3, + general.FROM_H2 * 100, + TileEntityGasGenerator.class, + true + ), + BIO_GENERATOR(4, "BioGenerator", 4, 160000, TileEntityBioGenerator.class, true), + ADVANCED_SOLAR_GENERATOR( + 5, + "AdvancedSolarGenerator", + 1, + 200000, + TileEntityAdvancedSolarGenerator.class, + true + ), + WIND_GENERATOR( + 6, "WindGenerator", 5, 200000, TileEntityWindGenerator.class, true + ), + TURBINE_ROTOR(7, "TurbineRotor", -1, -1, TileEntityTurbineRotor.class, false), + ROTATIONAL_COMPLEX( + 8, "RotationalComplex", -1, -1, TileEntityRotationalComplex.class, false + ), + ELECTROMAGNETIC_COIL( + 9, "ElectromagneticCoil", -1, -1, TileEntityElectromagneticCoil.class, false + ), + TURBINE_CASING(10, "TurbineCasing", -1, -1, TileEntityTurbineCasing.class, false), + TURBINE_VALVE(11, "TurbineValve", -1, -1, TileEntityTurbineValve.class, false), + TURBINE_VENT(12, "TurbineVent", -1, -1, TileEntityTurbineVent.class, false), + SATURATING_CONDENSER( + 13, "SaturatingCondenser", -1, -1, TileEntitySaturatingCondenser.class, false + ); + + public int meta; + public String name; + public int guiId; + public double maxEnergy; + public Class tileEntityClass; + public boolean hasModel; + + private GeneratorType( + int i, + String s, + int j, + double k, + Class tileClass, + boolean model + ) { + meta = i; + name = s; + guiId = j; + maxEnergy = k; + tileEntityClass = tileClass; + hasModel = model; + } + + public static GeneratorType getFromMetadata(int meta) { + for (GeneratorType type : values()) { + if (type.meta == meta) { + return type; + } + } + + return null; + } + + public TileEntity create() { + try { + return tileEntityClass.newInstance(); + } catch (Exception e) { + Mekanism.logger.error("Unable to indirectly create tile entity."); + e.printStackTrace(); + return null; + } + } + + public String getDescription() { + return LangUtils.localize("tooltip." + name); + } + + public ItemStack getStack() { + return new ItemStack(GeneratorsBlocks.Generator, 1, meta); + } + + @Override + public String toString() { + return Integer.toString(meta); + } + } + + @Override + public void setRenderBounds(Block block, int metadata) { + if (metadata == GeneratorType.SOLAR_GENERATOR.meta) { + block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.7F, 1.0F); + } else if (metadata == GeneratorType.TURBINE_ROTOR.meta) { + block.setBlockBounds(0.375F, 0.0F, 0.375F, 0.625F, 1.0F, 0.625F); + } else { + block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); + } + } + + @Override + public boolean doDefaultBoundSetting(int metadata) { + return true; + } + + @Override + public ForgeDirection[] getValidRotations(World world, int x, int y, int z) { + TileEntity tile = world.getTileEntity(x, y, z); + ForgeDirection[] valid = new ForgeDirection[6]; + + if (tile instanceof TileEntityBasicBlock) { + TileEntityBasicBlock basicTile = (TileEntityBasicBlock) tile; + + for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { + if (basicTile.canSetFacing(dir.ordinal())) { + valid[dir.ordinal()] = dir; + } + } + } + + return valid; + } + + @Override + public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis) { + TileEntity tile = world.getTileEntity(x, y, z); + + if (tile instanceof TileEntityBasicBlock) { + TileEntityBasicBlock basicTile = (TileEntityBasicBlock) tile; + + if (basicTile.canSetFacing(axis.ordinal())) { + basicTile.setFacing((short) axis.ordinal()); + return true; + } + } + + return false; + } } diff --git a/src/main/java/mekanism/generators/common/block/BlockReactor.java b/src/main/java/mekanism/generators/common/block/BlockReactor.java index f9e1edcb5..4d6b13049 100644 --- a/src/main/java/mekanism/generators/common/block/BlockReactor.java +++ b/src/main/java/mekanism/generators/common/block/BlockReactor.java @@ -3,6 +3,9 @@ package mekanism.generators.common.block; import java.util.Arrays; import java.util.List; +import buildcraft.api.tools.IToolWrench; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.Coord4D; import mekanism.common.CTMData; import mekanism.common.Mekanism; @@ -34,447 +37,469 @@ import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; -import buildcraft.api.tools.IToolWrench; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class BlockReactor extends BlockContainer implements IBlockCTM -{ - public IIcon[][] icons = new IIcon[16][16]; +public class BlockReactor extends BlockContainer implements IBlockCTM { + public IIcon[][] icons = new IIcon[16][16]; - public CTMData[][] ctms = new CTMData[16][2]; + public CTMData[][] ctms = new CTMData[16][2]; - public BlockReactor() - { - super(Material.iron); - setHardness(3.5F); - setResistance(8F); - setCreativeTab(Mekanism.tabMekanism); - } + public BlockReactor() { + super(Material.iron); + setHardness(3.5F); + setResistance(8F); + setCreativeTab(Mekanism.tabMekanism); + } - @Override - @SideOnly(Side.CLIENT) - public void registerBlockIcons(IIconRegister register) - { - if(this == GeneratorsBlocks.Reactor) - { - ctms[0][0] = new CTMData("ctm/ReactorFrame", this, Arrays.asList(0, 1, 2, 3, 4)).addSideOverride(ForgeDirection.UP, "ctm/ReactorControllerOff").registerIcons(register); - ctms[0][1] = new CTMData("ctm/ReactorFrame", this, Arrays.asList(0, 1, 2, 3, 4)).addSideOverride(ForgeDirection.UP, "ctm/ReactorControllerOn").registerIcons(register); - ctms[1][0] = new CTMData("ctm/ReactorFrame", this, Arrays.asList(0, 1, 2, 3, 4)).registerIcons(register); - ctms[2][0] = new CTMData("ctm/ReactorNeutronCapture", this, Arrays.asList(0, 1, 2, 3, 4)).registerIcons(register); - ctms[3][0] = new CTMData("ctm/ReactorPortInput", this, Arrays.asList(0, 1, 2, 3, 4)).registerIcons(register); - ctms[3][1] = new CTMData("ctm/ReactorPortOutput", this, Arrays.asList(0, 1, 2, 3, 4)).registerIcons(register); - ctms[4][0] = new CTMData("ctm/ReactorLogicAdapter", this, Arrays.asList(0, 1, 2, 3, 4)).registerIcons(register); + @Override + @SideOnly(Side.CLIENT) + public void registerBlockIcons(IIconRegister register) { + if (this == GeneratorsBlocks.Reactor) { + ctms[0][0] + = new CTMData("ctm/ReactorFrame", this, Arrays.asList(0, 1, 2, 3, 4)) + .addSideOverride(ForgeDirection.UP, "ctm/ReactorControllerOff") + .registerIcons(register); + ctms[0][1] + = new CTMData("ctm/ReactorFrame", this, Arrays.asList(0, 1, 2, 3, 4)) + .addSideOverride(ForgeDirection.UP, "ctm/ReactorControllerOn") + .registerIcons(register); + ctms[1][0] + = new CTMData("ctm/ReactorFrame", this, Arrays.asList(0, 1, 2, 3, 4)) + .registerIcons(register); + ctms[2][0] + = new CTMData( + "ctm/ReactorNeutronCapture", this, Arrays.asList(0, 1, 2, 3, 4) + ) + .registerIcons(register); + ctms[3][0] + = new CTMData("ctm/ReactorPortInput", this, Arrays.asList(0, 1, 2, 3, 4)) + .registerIcons(register); + ctms[3][1] + = new CTMData("ctm/ReactorPortOutput", this, Arrays.asList(0, 1, 2, 3, 4)) + .registerIcons(register); + ctms[4][0] = new CTMData( + "ctm/ReactorLogicAdapter", this, Arrays.asList(0, 1, 2, 3, 4) + ) + .registerIcons(register); - icons[0][0] = ctms[0][0].sideOverrides[1].icon; - icons[0][1] = ctms[0][1].sideOverrides[1].icon; - icons[0][2] = ctms[0][0].mainTextureData.icon; - icons[1][0] = ctms[1][0].mainTextureData.icon; - icons[2][0] = ctms[2][0].mainTextureData.icon; - icons[3][0] = ctms[3][0].mainTextureData.icon; - icons[3][1] = ctms[3][1].mainTextureData.icon; - icons[4][0] = ctms[4][0].mainTextureData.icon; - } - else if(this == GeneratorsBlocks.ReactorGlass) - { - ctms[0][0] = new CTMData("ctm/ReactorGlass", this, Arrays.asList(0, 1)).registerIcons(register); - ctms[1][0] = new CTMData("ctm/ReactorLaserFocus", this, Arrays.asList(1, 0)).registerIcons(register); + icons[0][0] = ctms[0][0].sideOverrides[1].icon; + icons[0][1] = ctms[0][1].sideOverrides[1].icon; + icons[0][2] = ctms[0][0].mainTextureData.icon; + icons[1][0] = ctms[1][0].mainTextureData.icon; + icons[2][0] = ctms[2][0].mainTextureData.icon; + icons[3][0] = ctms[3][0].mainTextureData.icon; + icons[3][1] = ctms[3][1].mainTextureData.icon; + icons[4][0] = ctms[4][0].mainTextureData.icon; + } else if (this == GeneratorsBlocks.ReactorGlass) { + ctms[0][0] = new CTMData("ctm/ReactorGlass", this, Arrays.asList(0, 1)) + .registerIcons(register); + ctms[1][0] = new CTMData("ctm/ReactorLaserFocus", this, Arrays.asList(1, 0)) + .registerIcons(register); - icons[0][0] = ctms[0][0].mainTextureData.icon; - icons[1][0] = ctms[1][0].mainTextureData.icon; - } - } + icons[0][0] = ctms[0][0].mainTextureData.icon; + icons[1][0] = ctms[1][0].mainTextureData.icon; + } + } - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(int side, int meta) - { - if(this == GeneratorsBlocks.Reactor) - { - if(meta == 0) - { - return icons[0][side == 1 ? 0 : 2]; - } - else { - return icons[meta][0]; - } - } - else if(this == GeneratorsBlocks.ReactorGlass) - { - return icons[meta][0]; - } + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(int side, int meta) { + if (this == GeneratorsBlocks.Reactor) { + if (meta == 0) { + return icons[0][side == 1 ? 0 : 2]; + } else { + return icons[meta][0]; + } + } else if (this == GeneratorsBlocks.ReactorGlass) { + return icons[meta][0]; + } - return null; - } + return null; + } - @Override - @SideOnly(Side.CLIENT) - public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) - { - int metadata = world.getBlockMetadata(x, y, z); + @Override + @SideOnly(Side.CLIENT) + public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) { + int metadata = world.getBlockMetadata(x, y, z); - if(this == GeneratorsBlocks.Reactor) - { - if(metadata == 0) - { - if(side == 1) - { - return MekanismUtils.isActive(world, x, y, z) ? icons[0][1] : icons[0][0]; - } - else { - return icons[metadata][2]; - } - } - else if(metadata == 3) - { - TileEntityReactorPort tileEntity = (TileEntityReactorPort)world.getTileEntity(x, y, z); - return icons[metadata][tileEntity.fluidEject ? 1 : 0]; - } - else { - return icons[metadata][0]; - } - } - else if(this == GeneratorsBlocks.ReactorGlass) - { - return icons[metadata][0]; - } + if (this == GeneratorsBlocks.Reactor) { + if (metadata == 0) { + if (side == 1) { + return MekanismUtils.isActive(world, x, y, z) ? icons[0][1] + : icons[0][0]; + } else { + return icons[metadata][2]; + } + } else if (metadata == 3) { + TileEntityReactorPort tileEntity + = (TileEntityReactorPort) world.getTileEntity(x, y, z); + return icons[metadata][tileEntity.fluidEject ? 1 : 0]; + } else { + return icons[metadata][0]; + } + } else if (this == GeneratorsBlocks.ReactorGlass) { + return icons[metadata][0]; + } - return null; - } + return null; + } - @Override - public int damageDropped(int i) - { - return i; - } + @Override + public int damageDropped(int i) { + return i; + } - @Override - public void onNeighborBlockChange(World world, int x, int y, int z, Block block) - { - if(!world.isRemote) - { - TileEntity tileEntity = world.getTileEntity(x, y, z); + @Override + public void onNeighborBlockChange(World world, int x, int y, int z, Block block) { + if (!world.isRemote) { + TileEntity tileEntity = world.getTileEntity(x, y, z); - if(tileEntity instanceof TileEntityBasicBlock) - { - ((TileEntityBasicBlock)tileEntity).onNeighborChange(block); - } - } - } + if (tileEntity instanceof TileEntityBasicBlock) { + ((TileEntityBasicBlock) tileEntity).onNeighborChange(block); + } + } + } - @Override - public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int facing, float playerX, float playerY, float playerZ) - { - if(world.isRemote) - { - return true; - } + @Override + public boolean onBlockActivated( + World world, + int x, + int y, + int z, + EntityPlayer entityplayer, + int facing, + float playerX, + float playerY, + float playerZ + ) { + if (world.isRemote) { + return true; + } - TileEntityElectricBlock tileEntity = (TileEntityElectricBlock)world.getTileEntity(x, y, z); - int metadata = world.getBlockMetadata(x, y, z); + TileEntityElectricBlock tileEntity + = (TileEntityElectricBlock) world.getTileEntity(x, y, z); + int metadata = world.getBlockMetadata(x, y, z); - if(entityplayer.getCurrentEquippedItem() != null) - { - if(MekanismUtils.isBCWrench(entityplayer.getCurrentEquippedItem().getItem()) && !entityplayer.getCurrentEquippedItem().getUnlocalizedName().contains("omniwrench")) - { - if(entityplayer.isSneaking()) - { - dismantleBlock(world, x, y, z, false); - return true; - } + if (entityplayer.getCurrentEquippedItem() != null) { + if (MekanismUtils.isBCWrench(entityplayer.getCurrentEquippedItem().getItem()) + && !entityplayer.getCurrentEquippedItem().getUnlocalizedName().contains( + "omniwrench" + )) { + if (entityplayer.isSneaking()) { + dismantleBlock(world, x, y, z, false); + return true; + } - ((IToolWrench)entityplayer.getCurrentEquippedItem().getItem()).wrenchUsed(entityplayer, x, y, z); + ((IToolWrench) entityplayer.getCurrentEquippedItem().getItem()) + .wrenchUsed(entityplayer, x, y, z); - int change = 0; + int change = 0; - switch(tileEntity.facing) - { - case 3: - change = 5; - break; - case 5: - change = 2; - break; - case 2: - change = 4; - break; - case 4: - change = 3; - break; - } + switch (tileEntity.facing) { + case 3: + change = 5; + break; + case 5: + change = 2; + break; + case 2: + change = 4; + break; + case 4: + change = 3; + break; + } - tileEntity.setFacing((short)change); - world.notifyBlocksOfNeighborChange(x, y, z, this); - return true; - } - } + tileEntity.setFacing((short) change); + world.notifyBlocksOfNeighborChange(x, y, z, this); + return true; + } + } - if(tileEntity instanceof TileEntityReactorController) - { - if(!entityplayer.isSneaking()) - { - entityplayer.openGui(MekanismGenerators.instance, ReactorBlockType.get(this, metadata).guiId, world, x, y, z); - return true; - } - } - - if(tileEntity instanceof TileEntityReactorLogicAdapter) - { - if(!entityplayer.isSneaking()) - { - entityplayer.openGui(MekanismGenerators.instance, ReactorBlockType.get(this, metadata).guiId, world, x, y, z); - return true; - } - } + if (tileEntity instanceof TileEntityReactorController) { + if (!entityplayer.isSneaking()) { + entityplayer.openGui( + MekanismGenerators.instance, + ReactorBlockType.get(this, metadata).guiId, + world, + x, + y, + z + ); + return true; + } + } - return false; - } + if (tileEntity instanceof TileEntityReactorLogicAdapter) { + if (!entityplayer.isSneaking()) { + entityplayer.openGui( + MekanismGenerators.instance, + ReactorBlockType.get(this, metadata).guiId, + world, + x, + y, + z + ); + return true; + } + } - @Override - @SideOnly(Side.CLIENT) - public void getSubBlocks(Item item, CreativeTabs creativetabs, List list) - { - for(ReactorBlockType type : ReactorBlockType.values()) - { - if(type.typeBlock == this && type != ReactorBlockType.NEUTRON_CAPTURE) - { - list.add(new ItemStack(item, 1, type.meta)); - } - } - } + return false; + } - @Override - public TileEntity createTileEntity(World world, int metadata) - { - ReactorBlockType type = ReactorBlockType.get(this, metadata); + @Override + @SideOnly(Side.CLIENT) + public void getSubBlocks(Item item, CreativeTabs creativetabs, List list) { + for (ReactorBlockType type : ReactorBlockType.values()) { + if (type.typeBlock == this && type != ReactorBlockType.NEUTRON_CAPTURE) { + list.add(new ItemStack(item, 1, type.meta)); + } + } + } - if(type != null) - { - return type.create(); - } + @Override + public TileEntity createTileEntity(World world, int metadata) { + ReactorBlockType type = ReactorBlockType.get(this, metadata); - return null; - } + if (type != null) { + return type.create(); + } - @Override - public boolean renderAsNormalBlock() - { - return false; - } - - @Override - public int getRenderBlockPass() - { - return this == GeneratorsBlocks.Reactor ? 0 : 1; - } + return null; + } - @Override - public int getRenderType() - { - return Mekanism.proxy.CTM_RENDER_ID; - } + @Override + public boolean renderAsNormalBlock() { + return false; + } - @Override - public boolean isOpaqueCube() - { - return false; - } - - @Override - public void onBlockAdded(World world, int x, int y, int z) - { - TileEntity tileEntity = world.getTileEntity(x, y, z); + @Override + public int getRenderBlockPass() { + return this == GeneratorsBlocks.Reactor ? 0 : 1; + } - if(!world.isRemote) - { - if(tileEntity instanceof TileEntityBasicBlock) - { - ((TileEntityBasicBlock)tileEntity).onAdded(); - } - } - } + @Override + public int getRenderType() { + return Mekanism.proxy.CTM_RENDER_ID; + } - /*This method is not used, metadata manipulation is required to create a Tile Entity.*/ - @Override - public TileEntity createNewTileEntity(World world, int meta) - { - return null; - } + @Override + public boolean isOpaqueCube() { + return false; + } - @Override - public CTMData getCTMData(IBlockAccess world, int x, int y, int z, int meta) - { - if(ctms[meta][1] != null && MekanismUtils.isActive(world, x, y, z)) - { - return ctms[meta][1]; - } - - TileEntity tile = world.getTileEntity(x, y, z); - - if(tile instanceof TileEntityReactorPort) - { - return ctms[meta][((TileEntityReactorPort)tile).fluidEject ? 1 : 0]; - } + @Override + public void onBlockAdded(World world, int x, int y, int z) { + TileEntity tileEntity = world.getTileEntity(x, y, z); - return ctms[meta][0]; - } - - @Override - public boolean shouldRenderBlock(IBlockAccess world, int x, int y, int z, int meta) - { - return true; - } + if (!world.isRemote) { + if (tileEntity instanceof TileEntityBasicBlock) { + ((TileEntityBasicBlock) tileEntity).onAdded(); + } + } + } + + /*This method is not used, metadata manipulation is required to create a Tile + * Entity.*/ + @Override + public TileEntity createNewTileEntity(World world, int meta) { + return null; + } + + @Override + public CTMData getCTMData(IBlockAccess world, int x, int y, int z, int meta) { + if (ctms[meta][1] != null && MekanismUtils.isActive(world, x, y, z)) { + return ctms[meta][1]; + } + + TileEntity tile = world.getTileEntity(x, y, z); + + if (tile instanceof TileEntityReactorPort) { + return ctms[meta][((TileEntityReactorPort) tile).fluidEject ? 1 : 0]; + } + + return ctms[meta][0]; + } + + @Override + public boolean shouldRenderBlock(IBlockAccess world, int x, int y, int z, int meta) { + return true; + } + + @Override + @SideOnly(Side.CLIENT) + public boolean + shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) { + Coord4D obj = new Coord4D(x, y, z).getFromSide( + ForgeDirection.getOrientation(side).getOpposite() + ); + + if (this == GeneratorsBlocks.ReactorGlass) { + int metadata = obj.getMetadata(world); + + switch (metadata) { + case 0: + case 1: + return ctms[metadata][0].shouldRenderSide(world, x, y, z, side); + default: + return super.shouldSideBeRendered(world, x, y, z, side); + } + } else { + return super.shouldSideBeRendered(world, x, y, z, side); + } + } + + @Override + public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) { + TileEntity tile = world.getTileEntity(x, y, z); + + if (tile instanceof TileEntityReactorLogicAdapter) { + return ((TileEntityReactorLogicAdapter) tile).checkMode() ? 15 : 0; + } - @Override - @SideOnly(Side.CLIENT) - public boolean shouldSideBeRendered(IBlockAccess world, int x, int y, int z, int side) - { - Coord4D obj = new Coord4D(x, y, z).getFromSide(ForgeDirection.getOrientation(side).getOpposite()); - - if(this == GeneratorsBlocks.ReactorGlass) - { - int metadata = obj.getMetadata(world); - - switch(metadata) - { - case 0: - case 1: - return ctms[metadata][0].shouldRenderSide(world, x, y, z, side); - default: - return super.shouldSideBeRendered(world, x, y, z, side); - } - } - else { - return super.shouldSideBeRendered(world, x, y, z, side); - } - } - - @Override - public int isProvidingWeakPower(IBlockAccess world, int x, int y, int z, int side) - { - TileEntity tile = world.getTileEntity(x, y, z); - - if(tile instanceof TileEntityReactorLogicAdapter) - { - return ((TileEntityReactorLogicAdapter)tile).checkMode() ? 15 : 0; - } - return 0; } - - @Override - public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) - { - ReactorBlockType type = ReactorBlockType.get(this, world.getBlockMetadata(x, y, z)); - switch(type) - { - case FRAME: - case PORT: - case ADAPTER: - return true; - default: - return false; - } - } + @Override + public boolean + isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + ReactorBlockType type + = ReactorBlockType.get(this, world.getBlockMetadata(x, y, z)); - @Override - public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) - { - ReactorBlockType type = ReactorBlockType.get(this, world.getBlockMetadata(x, y, z)); + switch (type) { + case FRAME: + case PORT: + case ADAPTER: + return true; + default: + return false; + } + } - switch(type) - { - case ADAPTER: - return true; - default: - return false; - } - } + @Override + public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side) { + ReactorBlockType type + = ReactorBlockType.get(this, world.getBlockMetadata(x, y, z)); - public static enum ReactorBlockType - { - CONTROLLER(GeneratorsBlocks.Reactor, 0, "ReactorController", 10, TileEntityReactorController.class), - FRAME(GeneratorsBlocks.Reactor, 1, "ReactorFrame", -1, TileEntityReactorFrame.class), - NEUTRON_CAPTURE(GeneratorsBlocks.Reactor, 2, "ReactorNeutronCapturePlate", 14, TileEntityReactorNeutronCapture.class), - PORT(GeneratorsBlocks.Reactor, 3, "ReactorPort", -1, TileEntityReactorPort.class), - ADAPTER(GeneratorsBlocks.Reactor, 4, "ReactorLogicAdapter", 15, TileEntityReactorLogicAdapter.class), - GLASS(GeneratorsBlocks.ReactorGlass, 0, "ReactorGlass", -1, TileEntityReactorGlass.class), - LASER_FOCUS_MATRIX(GeneratorsBlocks.ReactorGlass, 1, "ReactorLaserFocusMatrix", -1, TileEntityReactorLaserFocusMatrix.class); + switch (type) { + case ADAPTER: + return true; + default: + return false; + } + } - public Block typeBlock; - public int meta; - public String name; - public int guiId; - public Class tileEntityClass; + public static enum ReactorBlockType { + CONTROLLER( + GeneratorsBlocks.Reactor, + 0, + "ReactorController", + 10, + TileEntityReactorController.class + ), + FRAME( + GeneratorsBlocks.Reactor, 1, "ReactorFrame", -1, TileEntityReactorFrame.class + ), + NEUTRON_CAPTURE( + GeneratorsBlocks.Reactor, + 2, + "ReactorNeutronCapturePlate", + 14, + TileEntityReactorNeutronCapture.class + ), + PORT(GeneratorsBlocks.Reactor, 3, "ReactorPort", -1, TileEntityReactorPort.class), + ADAPTER( + GeneratorsBlocks.Reactor, + 4, + "ReactorLogicAdapter", + 15, + TileEntityReactorLogicAdapter.class + ), + GLASS( + GeneratorsBlocks.ReactorGlass, + 0, + "ReactorGlass", + -1, + TileEntityReactorGlass.class + ), + LASER_FOCUS_MATRIX( + GeneratorsBlocks.ReactorGlass, + 1, + "ReactorLaserFocusMatrix", + -1, + TileEntityReactorLaserFocusMatrix.class + ); - private ReactorBlockType(Block b, int i, String s, int j, Class tileClass) - { - typeBlock = b; - meta = i; - name = s; - guiId = j; - tileEntityClass = tileClass; - } + public Block typeBlock; + public int meta; + public String name; + public int guiId; + public Class tileEntityClass; - public static ReactorBlockType get(Block block, int meta) - { - for(ReactorBlockType type : values()) - { - if(type.typeBlock == block && type.meta == meta) - { - return type; - } - } - - return null; - } - - public static ReactorBlockType get(ItemStack stack) - { - return get(Block.getBlockFromItem(stack.getItem()), stack.getItemDamage()); - } + private ReactorBlockType( + Block b, + int i, + String s, + int j, + Class tileClass + ) { + typeBlock = b; + meta = i; + name = s; + guiId = j; + tileEntityClass = tileClass; + } - public TileEntity create() - { - try { - return tileEntityClass.newInstance(); - } catch(Exception e) { - Mekanism.logger.error("Unable to indirectly create tile entity."); - e.printStackTrace(); - return null; - } - } + public static ReactorBlockType get(Block block, int meta) { + for (ReactorBlockType type : values()) { + if (type.typeBlock == block && type.meta == meta) { + return type; + } + } - public String getDescription() - { - return LangUtils.localize("tooltip." + name); - } + return null; + } - public ItemStack getStack() - { - return new ItemStack(typeBlock, 1, meta); - } - } + public static ReactorBlockType get(ItemStack stack) { + return get(Block.getBlockFromItem(stack.getItem()), stack.getItemDamage()); + } - public ItemStack dismantleBlock(World world, int x, int y, int z, boolean returnBlock) - { - ItemStack itemStack = new ItemStack(this, 1, world.getBlockMetadata(x, y, z)); + public TileEntity create() { + try { + return tileEntityClass.newInstance(); + } catch (Exception e) { + Mekanism.logger.error("Unable to indirectly create tile entity."); + e.printStackTrace(); + return null; + } + } - world.setBlockToAir(x, y, z); + public String getDescription() { + return LangUtils.localize("tooltip." + name); + } - if(!returnBlock) - { - float motion = 0.7F; - double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; - double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + public ItemStack getStack() { + return new ItemStack(typeBlock, 1, meta); + } + } - EntityItem entityItem = new EntityItem(world, x + motionX, y + motionY, z + motionZ, itemStack); + public ItemStack + dismantleBlock(World world, int x, int y, int z, boolean returnBlock) { + ItemStack itemStack = new ItemStack(this, 1, world.getBlockMetadata(x, y, z)); - world.spawnEntityInWorld(entityItem); - } + world.setBlockToAir(x, y, z); - return itemStack; - } + if (!returnBlock) { + float motion = 0.7F; + double motionX = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionY = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + double motionZ = (world.rand.nextFloat() * motion) + (1.0F - motion) * 0.5D; + + EntityItem entityItem + = new EntityItem(world, x + motionX, y + motionY, z + motionZ, itemStack); + + world.spawnEntityInWorld(entityItem); + } + + return itemStack; + } } diff --git a/src/main/java/mekanism/generators/common/content/turbine/SynchronizedTurbineData.java b/src/main/java/mekanism/generators/common/content/turbine/SynchronizedTurbineData.java index 906e67cbc..2f94cbc6b 100644 --- a/src/main/java/mekanism/generators/common/content/turbine/SynchronizedTurbineData.java +++ b/src/main/java/mekanism/generators/common/content/turbine/SynchronizedTurbineData.java @@ -8,68 +8,62 @@ import mekanism.common.multiblock.SynchronizedData; import mekanism.common.tile.TileEntityGasTank.GasMode; import net.minecraftforge.fluids.FluidStack; -public class SynchronizedTurbineData extends SynchronizedData -{ - public static Map clientRotationMap = new HashMap(); - - public static final float ROTATION_THRESHOLD = 0.001F; - - public FluidStack fluidStored; - - public FluidStack prevFluid; - - public double electricityStored; - - public GasMode dumpMode = GasMode.IDLE; - - public int blades; - public int vents; - public int coils; - public int condensers; - - public int lowerVolume; - - public Coord4D complex; - - public int lastSteamInput; - public int newSteamInput; - - public int flowRemaining; - - public int clientDispersers; - public int clientFlow; - public float clientRotation; - - public int getDispersers() - { - return (volLength-2)*(volWidth-2) - 1; - } - - public int getFluidCapacity() - { - return lowerVolume*TurbineUpdateProtocol.FLUID_PER_TANK; - } - - public double getEnergyCapacity() - { - return volume*16000000D; //16 MJ energy capacity per volume - } - - public boolean needsRenderUpdate() - { - if((fluidStored == null && prevFluid != null) || (fluidStored != null && prevFluid == null)) - { - return true; - } - - if(fluidStored != null && prevFluid != null) - { - if((fluidStored.getFluid() != prevFluid.getFluid()) || (fluidStored.amount != prevFluid.amount)) - { - return true; - } - } - - return false; - } +public class SynchronizedTurbineData extends SynchronizedData { + public static Map clientRotationMap = new HashMap(); + + public static final float ROTATION_THRESHOLD = 0.001F; + + public FluidStack fluidStored; + + public FluidStack prevFluid; + + public double electricityStored; + + public GasMode dumpMode = GasMode.IDLE; + + public int blades; + public int vents; + public int coils; + public int condensers; + + public int lowerVolume; + + public Coord4D complex; + + public int lastSteamInput; + public int newSteamInput; + + public int flowRemaining; + + public int clientDispersers; + public int clientFlow; + public float clientRotation; + + public int getDispersers() { + return (volLength - 2) * (volWidth - 2) - 1; + } + + public int getFluidCapacity() { + return lowerVolume * TurbineUpdateProtocol.FLUID_PER_TANK; + } + + public double getEnergyCapacity() { + return volume * 16000000D; //16 MJ energy capacity per volume + } + + public boolean needsRenderUpdate() { + if ((fluidStored == null && prevFluid != null) + || (fluidStored != null && prevFluid == null)) { + return true; + } + + if (fluidStored != null && prevFluid != null) { + if ((fluidStored.getFluid() != prevFluid.getFluid()) + || (fluidStored.amount != prevFluid.amount)) { + return true; + } + } + + return false; + } } diff --git a/src/main/java/mekanism/generators/common/content/turbine/TurbineCache.java b/src/main/java/mekanism/generators/common/content/turbine/TurbineCache.java index 7c9e0ba2c..d17aefc3c 100644 --- a/src/main/java/mekanism/generators/common/content/turbine/TurbineCache.java +++ b/src/main/java/mekanism/generators/common/content/turbine/TurbineCache.java @@ -5,49 +5,43 @@ import mekanism.common.tile.TileEntityGasTank.GasMode; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.fluids.FluidStack; -public class TurbineCache extends MultiblockCache -{ - public FluidStack fluid; - public double electricity; - public GasMode dumpMode = GasMode.IDLE; - - @Override - public void apply(SynchronizedTurbineData data) - { - data.fluidStored = fluid; - data.electricityStored = electricity; - data.dumpMode = dumpMode; - } +public class TurbineCache extends MultiblockCache { + public FluidStack fluid; + public double electricity; + public GasMode dumpMode = GasMode.IDLE; - @Override - public void sync(SynchronizedTurbineData data) - { - fluid = data.fluidStored; - electricity = data.electricityStored; - dumpMode = data.dumpMode; - } + @Override + public void apply(SynchronizedTurbineData data) { + data.fluidStored = fluid; + data.electricityStored = electricity; + data.dumpMode = dumpMode; + } - @Override - public void load(NBTTagCompound nbtTags) - { - if(nbtTags.hasKey("cachedFluid")) - { - fluid = FluidStack.loadFluidStackFromNBT(nbtTags.getCompoundTag("cachedFluid")); - } - - electricity = nbtTags.getDouble("electricity"); - dumpMode = GasMode.values()[nbtTags.getInteger("dumpMode")]; - } + @Override + public void sync(SynchronizedTurbineData data) { + fluid = data.fluidStored; + electricity = data.electricityStored; + dumpMode = data.dumpMode; + } - @Override - public void save(NBTTagCompound nbtTags) - { - if(fluid != null) - { - nbtTags.setTag("cachedFluid", fluid.writeToNBT(new NBTTagCompound())); - } - - nbtTags.setDouble("electricity", electricity); - nbtTags.setInteger("dumpMode", dumpMode.ordinal()); - } + @Override + public void load(NBTTagCompound nbtTags) { + if (nbtTags.hasKey("cachedFluid")) { + fluid + = FluidStack.loadFluidStackFromNBT(nbtTags.getCompoundTag("cachedFluid")); + } + + electricity = nbtTags.getDouble("electricity"); + dumpMode = GasMode.values()[nbtTags.getInteger("dumpMode")]; + } + + @Override + public void save(NBTTagCompound nbtTags) { + if (fluid != null) { + nbtTags.setTag("cachedFluid", fluid.writeToNBT(new NBTTagCompound())); + } + + nbtTags.setDouble("electricity", electricity); + nbtTags.setInteger("dumpMode", dumpMode.ordinal()); + } } diff --git a/src/main/java/mekanism/generators/common/content/turbine/TurbineFluidTank.java b/src/main/java/mekanism/generators/common/content/turbine/TurbineFluidTank.java index c66b5b5d7..05cceddf7 100644 --- a/src/main/java/mekanism/generators/common/content/turbine/TurbineFluidTank.java +++ b/src/main/java/mekanism/generators/common/content/turbine/TurbineFluidTank.java @@ -6,172 +6,142 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidTank; -public class TurbineFluidTank implements IFluidTank -{ - public TileEntityTurbineCasing turbine; +public class TurbineFluidTank implements IFluidTank { + public TileEntityTurbineCasing turbine; - public TurbineFluidTank(TileEntityTurbineCasing tileEntity) - { - turbine = tileEntity; - } + public TurbineFluidTank(TileEntityTurbineCasing tileEntity) { + turbine = tileEntity; + } - @Override - public FluidStack getFluid() - { - return turbine.structure != null ? turbine.structure.fluidStored : null; - } + @Override + public FluidStack getFluid() { + return turbine.structure != null ? turbine.structure.fluidStored : null; + } - @Override - public int getCapacity() - { - return turbine.structure != null ? turbine.structure.getFluidCapacity() : 0; - } + @Override + public int getCapacity() { + return turbine.structure != null ? turbine.structure.getFluidCapacity() : 0; + } - @Override - public int fill(FluidStack resource, boolean doFill) - { - if(turbine.structure != null && !turbine.getWorldObj().isRemote) - { - if(resource == null || resource.getFluidID() <= 0) - { - return 0; - } - - if(turbine.structure.fluidStored != null && !turbine.structure.fluidStored.isFluidEqual(resource)) - { - return 0; - } + @Override + public int fill(FluidStack resource, boolean doFill) { + if (turbine.structure != null && !turbine.getWorldObj().isRemote) { + if (resource == null || resource.getFluidID() <= 0) { + return 0; + } - if(turbine.structure.fluidStored == null || turbine.structure.fluidStored.getFluidID() <= 0) - { - if(resource.amount <= getCapacity()) - { - if(doFill) - { - turbine.structure.fluidStored = resource.copy(); - - if(resource.amount > 0) - { - MekanismUtils.saveChunk(turbine); - } - } + if (turbine.structure.fluidStored != null + && !turbine.structure.fluidStored.isFluidEqual(resource)) { + return 0; + } - return resource.amount; - } - else { - if(doFill) - { - turbine.structure.fluidStored = resource.copy(); - turbine.structure.fluidStored.amount = getCapacity(); - - if(getCapacity() > 0) - { - MekanismUtils.saveChunk(turbine); - } - } + if (turbine.structure.fluidStored == null + || turbine.structure.fluidStored.getFluidID() <= 0) { + if (resource.amount <= getCapacity()) { + if (doFill) { + turbine.structure.fluidStored = resource.copy(); - return getCapacity(); - } - } - else if(resource.amount <= getNeeded()) - { - if(doFill) - { - turbine.structure.fluidStored.amount += resource.amount; - - if(resource.amount > 0) - { - MekanismUtils.saveChunk(turbine); - } - } + if (resource.amount > 0) { + MekanismUtils.saveChunk(turbine); + } + } - return resource.amount; - } - else { - int prevNeeded = getNeeded(); - - if(doFill) - { - turbine.structure.fluidStored.amount = getCapacity(); - - if(prevNeeded > 0) - { - MekanismUtils.saveChunk(turbine); - } - } + return resource.amount; + } else { + if (doFill) { + turbine.structure.fluidStored = resource.copy(); + turbine.structure.fluidStored.amount = getCapacity(); - return prevNeeded; - } - } + if (getCapacity() > 0) { + MekanismUtils.saveChunk(turbine); + } + } - return 0; - } + return getCapacity(); + } + } else if (resource.amount <= getNeeded()) { + if (doFill) { + turbine.structure.fluidStored.amount += resource.amount; - @Override - public FluidStack drain(int maxDrain, boolean doDrain) - { - if(turbine.structure != null && !turbine.getWorldObj().isRemote) - { - if(turbine.structure.fluidStored == null || turbine.structure.fluidStored.getFluidID() <= 0) - { - return null; - } + if (resource.amount > 0) { + MekanismUtils.saveChunk(turbine); + } + } - if(turbine.structure.fluidStored.amount <= 0) - { - return null; - } + return resource.amount; + } else { + int prevNeeded = getNeeded(); - int used = maxDrain; + if (doFill) { + turbine.structure.fluidStored.amount = getCapacity(); - if(turbine.structure.fluidStored.amount < used) - { - used = turbine.structure.fluidStored.amount; - } + if (prevNeeded > 0) { + MekanismUtils.saveChunk(turbine); + } + } - if(doDrain) - { - turbine.structure.fluidStored.amount -= used; - } + return prevNeeded; + } + } - FluidStack drained = new FluidStack(turbine.structure.fluidStored.getFluid(), used); + return 0; + } - if(turbine.structure.fluidStored.amount <= 0) - { - turbine.structure.fluidStored = null; - } + @Override + public FluidStack drain(int maxDrain, boolean doDrain) { + if (turbine.structure != null && !turbine.getWorldObj().isRemote) { + if (turbine.structure.fluidStored == null + || turbine.structure.fluidStored.getFluidID() <= 0) { + return null; + } - if(drained.amount > 0 && doDrain) - { - MekanismUtils.saveChunk(turbine); - turbine.sendPacketToRenderer(); - } + if (turbine.structure.fluidStored.amount <= 0) { + return null; + } - return drained; - } + int used = maxDrain; - return null; - } - - public int getNeeded() - { - return getCapacity()-getFluidAmount(); - } + if (turbine.structure.fluidStored.amount < used) { + used = turbine.structure.fluidStored.amount; + } - @Override - public int getFluidAmount() - { - if(turbine.structure != null) - { - return turbine.structure.fluidStored.amount; - } + if (doDrain) { + turbine.structure.fluidStored.amount -= used; + } - return 0; - } + FluidStack drained + = new FluidStack(turbine.structure.fluidStored.getFluid(), used); - @Override - public FluidTankInfo getInfo() - { - return new FluidTankInfo(this); - } + if (turbine.structure.fluidStored.amount <= 0) { + turbine.structure.fluidStored = null; + } + + if (drained.amount > 0 && doDrain) { + MekanismUtils.saveChunk(turbine); + turbine.sendPacketToRenderer(); + } + + return drained; + } + + return null; + } + + public int getNeeded() { + return getCapacity() - getFluidAmount(); + } + + @Override + public int getFluidAmount() { + if (turbine.structure != null) { + return turbine.structure.fluidStored.amount; + } + + return 0; + } + + @Override + public FluidTankInfo getInfo() { + return new FluidTankInfo(this); + } } diff --git a/src/main/java/mekanism/generators/common/content/turbine/TurbineUpdateProtocol.java b/src/main/java/mekanism/generators/common/content/turbine/TurbineUpdateProtocol.java index 888089c70..24be958d7 100644 --- a/src/main/java/mekanism/generators/common/content/turbine/TurbineUpdateProtocol.java +++ b/src/main/java/mekanism/generators/common/content/turbine/TurbineUpdateProtocol.java @@ -23,257 +23,245 @@ import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -public class TurbineUpdateProtocol extends UpdateProtocol -{ - public static final int FLUID_PER_TANK = TankUpdateProtocol.FLUID_PER_TANK; - public static final int MAX_BLADES = 28; - - public TurbineUpdateProtocol(TileEntityTurbineCasing tileEntity) - { - super(tileEntity); - } +public class TurbineUpdateProtocol extends UpdateProtocol { + public static final int FLUID_PER_TANK = TankUpdateProtocol.FLUID_PER_TANK; + public static final int MAX_BLADES = 28; - @Override - protected boolean isValidFrame(int x, int y, int z) - { - return pointer.getWorldObj().getBlock(x, y, z) == GeneratorsBlocks.Generator && - GeneratorType.getFromMetadata(pointer.getWorldObj().getBlockMetadata(x, y, z)) == GeneratorType.TURBINE_CASING; - } - - @Override - protected boolean isValidInnerNode(int x, int y, int z) - { - if(super.isValidInnerNode(x, y, z)) - { - return true; - } + public TurbineUpdateProtocol(TileEntityTurbineCasing tileEntity) { + super(tileEntity); + } - TileEntity tile = pointer.getWorldObj().getTileEntity(x, y, z); - - return tile instanceof TileEntityTurbineRotor || tile instanceof TileEntityRotationalComplex || - tile instanceof TileEntityPressureDisperser || tile instanceof TileEntityElectromagneticCoil || - tile instanceof TileEntitySaturatingCondenser; - } - - @Override - protected boolean canForm(SynchronizedTurbineData structure) - { - if(structure.volLength % 2 == 1 && structure.volWidth % 2 == 1) - { - int innerRadius = (Math.min(structure.volLength, structure.volWidth)-3)/2; - - if(innerRadius >= Math.ceil((structure.volHeight-2)/4)) - { - int centerX = structure.minLocation.xCoord+(structure.volLength-1)/2; - int centerZ = structure.minLocation.zCoord+(structure.volWidth-1)/2; - - Coord4D complex = null; - - Set turbines = new HashSet(); - Set dispersers = new HashSet(); - Set coils = new HashSet(); - Set condensers = new HashSet(); - - //Scan for complex - for(Coord4D coord : innerNodes) - { - TileEntity tile = coord.getTileEntity(pointer.getWorldObj()); - - if(tile instanceof TileEntityRotationalComplex) - { - if(complex != null) - { - return false; - } - else if(coord.xCoord != centerX || coord.zCoord != centerZ) - { - return false; - } - - structure.internalLocations.add(coord); - complex = coord; - } - else if(tile instanceof TileEntityTurbineRotor) - { - if(coord.xCoord != centerX || coord.zCoord != centerZ) - { - return false; - } - - turbines.add(coord); - } - else if(tile instanceof TileEntityPressureDisperser) - { - dispersers.add(coord); - } - else if(tile instanceof TileEntityElectromagneticCoil) - { - coils.add(coord); - } - else if(tile instanceof TileEntitySaturatingCondenser) - { - condensers.add(coord); - } - } - - //Terminate if complex doesn't exist - if(complex == null) - { - return false; - } - - //Make sure a flat, horizontal plane of dispersers exists within the multiblock around the complex - for(int x = complex.xCoord-innerRadius; x <= complex.xCoord+innerRadius; x++) - { - for(int z = complex.zCoord-innerRadius; z <= complex.zCoord+innerRadius; z++) - { - if(!(x == centerX && z == centerZ)) - { - TileEntity tile = pointer.getWorldObj().getTileEntity(x, complex.yCoord, z); - - if(!(tile instanceof TileEntityPressureDisperser)) - { - return false; - } - - dispersers.remove(new Coord4D(x, complex.yCoord, z, pointer.getWorldObj().provider.dimensionId)); - } - } - } - - //If any dispersers were not processed, they're in the wrong place - if(dispersers.size() > 0) - { - return false; - } - - //Make sure all condensers are in proper locations - for(Coord4D coord : condensers) - { - if(coord.yCoord <= complex.yCoord) - { - return false; - } - } - - structure.condensers = condensers.size(); - - int turbineHeight = 0; - - //Make sure a complete line of turbine rotors exist from the complex to the multiblock's base - for(int y = complex.yCoord-1; y > structure.minLocation.yCoord; y--) - { - TileEntity tile = pointer.getWorldObj().getTileEntity(centerX, y, centerZ); - - if(!(tile instanceof TileEntityTurbineRotor)) - { - return false; - } - - turbineHeight++; - turbines.remove(new Coord4D(centerX, y, centerZ, pointer.getWorldObj().provider.dimensionId)); - } - - //If any turbines were not processed, they're in the wrong place - if(turbines.size() > 0) - { - return false; - } - - Coord4D startCoord = complex.getFromSide(ForgeDirection.UP); - - if(startCoord.getTileEntity(pointer.getWorldObj()) instanceof TileEntityElectromagneticCoil) - { - structure.coils = new NodeCounter(new NodeChecker() { - @Override - public boolean isValid(Coord4D coord) - { - return coord.getTileEntity(pointer.getWorldObj()) instanceof TileEntityElectromagneticCoil; - } - }).calculate(startCoord); - } - - if(coils.size() > structure.coils) - { - return false; - } - - Coord4D turbineCoord = complex.getFromSide(ForgeDirection.DOWN); - TileEntity turbineTile = turbineCoord.getTileEntity(pointer.getWorldObj()); - - if(turbineTile instanceof TileEntityTurbineRotor) - { - structure.blades = ((TileEntityTurbineRotor)turbineTile).blades; - } - - for(Coord4D coord : structure.locations) - { - if(coord.getTileEntity(pointer.getWorldObj()) instanceof TileEntityTurbineVent) - { - if(coord.yCoord >= complex.yCoord) - { - structure.vents++; - } - else { - return false; - } - } - } - - structure.lowerVolume = structure.volLength*structure.volWidth*turbineHeight; - structure.complex = complex; - - return true; - } - } - - return false; - } + @Override + protected boolean isValidFrame(int x, int y, int z) { + return pointer.getWorldObj().getBlock(x, y, z) == GeneratorsBlocks.Generator + && GeneratorType.getFromMetadata( + pointer.getWorldObj().getBlockMetadata(x, y, z) + ) + == GeneratorType.TURBINE_CASING; + } - @Override - protected MultiblockCache getNewCache() - { - return new TurbineCache(); - } + @Override + protected boolean isValidInnerNode(int x, int y, int z) { + if (super.isValidInnerNode(x, y, z)) { + return true; + } - @Override - protected SynchronizedTurbineData getNewStructure() - { - return new SynchronizedTurbineData(); - } + TileEntity tile = pointer.getWorldObj().getTileEntity(x, y, z); - @Override - protected MultiblockManager getManager() - { - return MekanismGenerators.turbineManager; - } + return tile instanceof TileEntityTurbineRotor + || tile instanceof TileEntityRotationalComplex + || tile instanceof TileEntityPressureDisperser + || tile instanceof TileEntityElectromagneticCoil + || tile instanceof TileEntitySaturatingCondenser; + } - @Override - protected void mergeCaches(List rejectedItems, MultiblockCache cache, MultiblockCache merge) - { - if(((TurbineCache)cache).fluid == null) - { - ((TurbineCache)cache).fluid = ((TurbineCache)merge).fluid; - } + @Override + protected boolean canForm(SynchronizedTurbineData structure) { + if (structure.volLength % 2 == 1 && structure.volWidth % 2 == 1) { + int innerRadius = (Math.min(structure.volLength, structure.volWidth) - 3) / 2; + + if (innerRadius >= Math.ceil((structure.volHeight - 2) / 4)) { + int centerX + = structure.minLocation.xCoord + (structure.volLength - 1) / 2; + int centerZ = structure.minLocation.zCoord + (structure.volWidth - 1) / 2; + + Coord4D complex = null; + + Set turbines = new HashSet(); + Set dispersers = new HashSet(); + Set coils = new HashSet(); + Set condensers = new HashSet(); + + //Scan for complex + for (Coord4D coord : innerNodes) { + TileEntity tile = coord.getTileEntity(pointer.getWorldObj()); + + if (tile instanceof TileEntityRotationalComplex) { + if (complex != null) { + return false; + } else if (coord.xCoord != centerX || coord.zCoord != centerZ) { + return false; + } + + structure.internalLocations.add(coord); + complex = coord; + } else if (tile instanceof TileEntityTurbineRotor) { + if (coord.xCoord != centerX || coord.zCoord != centerZ) { + return false; + } + + turbines.add(coord); + } else if (tile instanceof TileEntityPressureDisperser) { + dispersers.add(coord); + } else if (tile instanceof TileEntityElectromagneticCoil) { + coils.add(coord); + } else if (tile instanceof TileEntitySaturatingCondenser) { + condensers.add(coord); + } + } + + //Terminate if complex doesn't exist + if (complex == null) { + return false; + } + + //Make sure a flat, horizontal plane of dispersers exists within the + //multiblock around the complex + for (int x = complex.xCoord - innerRadius; + x <= complex.xCoord + innerRadius; + x++) { + for (int z = complex.zCoord - innerRadius; + z <= complex.zCoord + innerRadius; + z++) { + if (!(x == centerX && z == centerZ)) { + TileEntity tile = pointer.getWorldObj().getTileEntity( + x, complex.yCoord, z + ); + + if (!(tile instanceof TileEntityPressureDisperser)) { + return false; + } + + dispersers.remove(new Coord4D( + x, + complex.yCoord, + z, + pointer.getWorldObj().provider.dimensionId + )); + } + } + } + + //If any dispersers were not processed, they're in the wrong place + if (dispersers.size() > 0) { + return false; + } + + //Make sure all condensers are in proper locations + for (Coord4D coord : condensers) { + if (coord.yCoord <= complex.yCoord) { + return false; + } + } + + structure.condensers = condensers.size(); + + int turbineHeight = 0; + + //Make sure a complete line of turbine rotors exist from the complex to + //the multiblock's base + for (int y = complex.yCoord - 1; y > structure.minLocation.yCoord; y--) { + TileEntity tile + = pointer.getWorldObj().getTileEntity(centerX, y, centerZ); + + if (!(tile instanceof TileEntityTurbineRotor)) { + return false; + } + + turbineHeight++; + turbines.remove(new Coord4D( + centerX, y, centerZ, pointer.getWorldObj().provider.dimensionId + )); + } + + //If any turbines were not processed, they're in the wrong place + if (turbines.size() > 0) { + return false; + } + + Coord4D startCoord = complex.getFromSide(ForgeDirection.UP); + + if (startCoord.getTileEntity(pointer.getWorldObj()) + instanceof TileEntityElectromagneticCoil) { + structure.coils + = new NodeCounter(new NodeChecker() { + @Override + public boolean isValid(Coord4D coord) { + return coord.getTileEntity(pointer.getWorldObj()) + instanceof TileEntityElectromagneticCoil; + } + }).calculate(startCoord); + } + + if (coils.size() > structure.coils) { + return false; + } + + Coord4D turbineCoord = complex.getFromSide(ForgeDirection.DOWN); + TileEntity turbineTile + = turbineCoord.getTileEntity(pointer.getWorldObj()); + + if (turbineTile instanceof TileEntityTurbineRotor) { + structure.blades = ((TileEntityTurbineRotor) turbineTile).blades; + } + + for (Coord4D coord : structure.locations) { + if (coord.getTileEntity(pointer.getWorldObj()) + instanceof TileEntityTurbineVent) { + if (coord.yCoord >= complex.yCoord) { + structure.vents++; + } else { + return false; + } + } + } + + structure.lowerVolume + = structure.volLength * structure.volWidth * turbineHeight; + structure.complex = complex; + + return true; + } + } + + return false; + } + + @Override + protected MultiblockCache getNewCache() { + return new TurbineCache(); + } + + @Override + protected SynchronizedTurbineData getNewStructure() { + return new SynchronizedTurbineData(); + } + + @Override + protected MultiblockManager getManager() { + return MekanismGenerators.turbineManager; + } + + @Override + protected void mergeCaches( + List rejectedItems, + MultiblockCache cache, + MultiblockCache merge + ) { + if (((TurbineCache) cache).fluid == null) { + ((TurbineCache) cache).fluid = ((TurbineCache) merge).fluid; + } else if(((TurbineCache)merge).fluid != null && ((TurbineCache)cache).fluid.isFluidEqual(((TurbineCache)merge).fluid)) { - ((TurbineCache)cache).fluid.amount += ((TurbineCache)merge).fluid.amount; - } - - ((TurbineCache)cache).electricity += ((TurbineCache)merge).electricity; - ((TurbineCache)cache).dumpMode = ((TurbineCache)merge).dumpMode; - } - - @Override - protected void onFormed() - { - super.onFormed(); - - if(structureFound.fluidStored != null) - { - structureFound.fluidStored.amount = Math.min(structureFound.fluidStored.amount, structureFound.getFluidCapacity()); - } - - structureFound.electricityStored = Math.min(structureFound.electricityStored, structureFound.getEnergyCapacity()); - } + ((TurbineCache) cache).fluid.amount += ((TurbineCache) merge).fluid.amount; + } + + ((TurbineCache) cache).electricity += ((TurbineCache) merge).electricity; + ((TurbineCache) cache).dumpMode = ((TurbineCache) merge).dumpMode; + } + + @Override + protected void onFormed() { + super.onFormed(); + + if (structureFound.fluidStored != null) { + structureFound.fluidStored.amount = Math.min( + structureFound.fluidStored.amount, structureFound.getFluidCapacity() + ); + } + + structureFound.electricityStored = Math.min( + structureFound.electricityStored, structureFound.getEnergyCapacity() + ); + } } diff --git a/src/main/java/mekanism/generators/common/inventory/container/ContainerBioGenerator.java b/src/main/java/mekanism/generators/common/inventory/container/ContainerBioGenerator.java index ebf9396ff..e6129ce74 100644 --- a/src/main/java/mekanism/generators/common/inventory/container/ContainerBioGenerator.java +++ b/src/main/java/mekanism/generators/common/inventory/container/ContainerBioGenerator.java @@ -11,148 +11,117 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; -public class ContainerBioGenerator extends Container -{ - private TileEntityBioGenerator tileEntity; +public class ContainerBioGenerator extends Container { + private TileEntityBioGenerator tileEntity; - public ContainerBioGenerator(InventoryPlayer inventory, TileEntityBioGenerator tentity) - { - tileEntity = tentity; - addSlotToContainer(new Slot(tentity, 0, 17, 35)); - addSlotToContainer(new SlotCharge(tentity, 1, 143, 35)); - int slotX; + public ContainerBioGenerator( + InventoryPlayer inventory, TileEntityBioGenerator tentity + ) { + tileEntity = tentity; + addSlotToContainer(new Slot(tentity, 0, 17, 35)); + addSlotToContainer(new SlotCharge(tentity, 1, 143, 35)); + int slotX; - for(slotX = 0; slotX < 3; ++slotX) - { - for(int slotY = 0; slotY < 9; ++slotY) - { - addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); - } - } + for (slotX = 0; slotX < 3; ++slotX) { + for (int slotY = 0; slotY < 9; ++slotY) { + addSlotToContainer(new Slot( + inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18 + )); + } + } - for(slotX = 0; slotX < 9; ++slotX) - { - addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); - } + for (slotX = 0; slotX < 9; ++slotX) { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); + } - tileEntity.openInventory(); - tileEntity.open(inventory.player); - } + tileEntity.openInventory(); + tileEntity.open(inventory.player); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - tileEntity.closeInventory(); - tileEntity.close(entityplayer); - } + tileEntity.closeInventory(); + tileEntity.close(entityplayer); + } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(ChargeUtils.canBeCharged(slotStack)) - { - if(slotID != 1) - { - if(!mergeItemStack(slotStack, 1, 2, false)) - { - return null; - } - } - else if(slotID == 1) - { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), false)) - { - return null; - } - } - } - else if(tileEntity.getFuel(slotStack) > 0 || isBiofuel(slotStack)) - { - if(slotID != 0 && slotID != 1) - { - if (!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID >= 2 && slotID <= 28) - { - if(!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 28) - { - if(!mergeItemStack(slotStack, 2, 28, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } + if (ChargeUtils.canBeCharged(slotStack)) { + if (slotID != 1) { + if (!mergeItemStack(slotStack, 1, 2, false)) { + return null; + } + } else if (slotID == 1) { + if (!mergeItemStack(slotStack, 2, inventorySlots.size(), false)) { + return null; + } + } + } else if (tileEntity.getFuel(slotStack) > 0 || isBiofuel(slotStack)) { + if (slotID != 0 && slotID != 1) { + if (!mergeItemStack(slotStack, 0, 1, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) { + return null; + } + } + } else { + if (slotID >= 2 && slotID <= 28) { + if (!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) { + return null; + } + } else if (slotID > 28) { + if (!mergeItemStack(slotStack, 2, 28, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) { + return null; + } + } + } - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - currentSlot.onPickupFromSlot(player, slotStack); - } + currentSlot.onPickupFromSlot(player, slotStack); + } - return stack; - } + return stack; + } - private boolean isBiofuel(ItemStack itemStack) - { - if(FluidRegistry.isFluidRegistered("bioethanol")) - { - if(FluidContainerRegistry.getFluidForFilledItem(itemStack) != null) - { - if(FluidContainerRegistry.getFluidForFilledItem(itemStack).getFluid() == FluidRegistry.getFluid("bioethanol")) - { - return true; - } - } - } + private boolean isBiofuel(ItemStack itemStack) { + if (FluidRegistry.isFluidRegistered("bioethanol")) { + if (FluidContainerRegistry.getFluidForFilledItem(itemStack) != null) { + if (FluidContainerRegistry.getFluidForFilledItem(itemStack).getFluid() + == FluidRegistry.getFluid("bioethanol")) { + return true; + } + } + } - return false; - } + return false; + } } diff --git a/src/main/java/mekanism/generators/common/inventory/container/ContainerGasGenerator.java b/src/main/java/mekanism/generators/common/inventory/container/ContainerGasGenerator.java index 3088950f2..decd6da4e 100644 --- a/src/main/java/mekanism/generators/common/inventory/container/ContainerGasGenerator.java +++ b/src/main/java/mekanism/generators/common/inventory/container/ContainerGasGenerator.java @@ -11,134 +11,107 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerGasGenerator extends Container -{ - private TileEntityGasGenerator tileEntity; +public class ContainerGasGenerator extends Container { + private TileEntityGasGenerator tileEntity; - public ContainerGasGenerator(InventoryPlayer inventory, TileEntityGasGenerator tentity) - { - tileEntity = tentity; - addSlotToContainer(new Slot(tentity, 0, 17, 35)); - addSlotToContainer(new SlotCharge(tentity, 1, 143, 35)); - int slotX; + public ContainerGasGenerator( + InventoryPlayer inventory, TileEntityGasGenerator tentity + ) { + tileEntity = tentity; + addSlotToContainer(new Slot(tentity, 0, 17, 35)); + addSlotToContainer(new SlotCharge(tentity, 1, 143, 35)); + int slotX; - for(slotX = 0; slotX < 3; ++slotX) - { - for(int slotY = 0; slotY < 9; ++slotY) - { - addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); - } - } + for (slotX = 0; slotX < 3; ++slotX) { + for (int slotY = 0; slotY < 9; ++slotY) { + addSlotToContainer(new Slot( + inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18 + )); + } + } - for(slotX = 0; slotX < 9; ++slotX) - { - addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); - } + for (slotX = 0; slotX < 9; ++slotX) { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); + } - tileEntity.openInventory(); - tileEntity.open(inventory.player); - } + tileEntity.openInventory(); + tileEntity.open(inventory.player); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); - tileEntity.closeInventory(); - tileEntity.close(entityplayer); - } + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); + tileEntity.closeInventory(); + tileEntity.close(entityplayer); + } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(ChargeUtils.canBeCharged(slotStack)) - { - if(slotID != 1) - { - if(!mergeItemStack(slotStack, 1, 2, false)) - { - return null; - } - } - else if(slotID == 1) - { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), false)) - { - return null; - } - } - } - else if(slotStack.getItem() instanceof IGasItem) - { - if(slotID != 0 && slotID != 1) - { - if(((IGasItem)slotStack.getItem()).getGas(slotStack) != null && ((IGasItem)slotStack.getItem()).getGas(slotStack).getGas() == GasRegistry.getGas("hydrogen")) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - } - else { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID >= 2 && slotID <= 28) - { - if(!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 28) - { - if(!mergeItemStack(slotStack, 2, 28, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } + if (ChargeUtils.canBeCharged(slotStack)) { + if (slotID != 1) { + if (!mergeItemStack(slotStack, 1, 2, false)) { + return null; + } + } else if (slotID == 1) { + if (!mergeItemStack(slotStack, 2, inventorySlots.size(), false)) { + return null; + } + } + } else if (slotStack.getItem() instanceof IGasItem) { + if (slotID != 0 && slotID != 1) { + if (((IGasItem) slotStack.getItem()).getGas(slotStack) != null + && ((IGasItem) slotStack.getItem()).getGas(slotStack).getGas() + == GasRegistry.getGas("hydrogen")) { + if (!mergeItemStack(slotStack, 0, 1, false)) { + return null; + } + } + } else { + if (!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) { + return null; + } + } + } else { + if (slotID >= 2 && slotID <= 28) { + if (!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) { + return null; + } + } else if (slotID > 28) { + if (!mergeItemStack(slotStack, 2, 28, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) { + return null; + } + } + } - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - currentSlot.onPickupFromSlot(player, slotStack); - } + currentSlot.onPickupFromSlot(player, slotStack); + } - return stack; - } + return stack; + } } diff --git a/src/main/java/mekanism/generators/common/inventory/container/ContainerHeatGenerator.java b/src/main/java/mekanism/generators/common/inventory/container/ContainerHeatGenerator.java index 2b2b465a0..bf805d243 100644 --- a/src/main/java/mekanism/generators/common/inventory/container/ContainerHeatGenerator.java +++ b/src/main/java/mekanism/generators/common/inventory/container/ContainerHeatGenerator.java @@ -9,132 +9,104 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerHeatGenerator extends Container -{ - private TileEntityHeatGenerator tileEntity; +public class ContainerHeatGenerator extends Container { + private TileEntityHeatGenerator tileEntity; - public ContainerHeatGenerator(InventoryPlayer inventory, TileEntityHeatGenerator tentity) - { - tileEntity = tentity; - addSlotToContainer(new Slot(tentity, 0, 17, 35)); - addSlotToContainer(new SlotCharge(tentity, 1, 143, 35)); - int slotX; + public ContainerHeatGenerator( + InventoryPlayer inventory, TileEntityHeatGenerator tentity + ) { + tileEntity = tentity; + addSlotToContainer(new Slot(tentity, 0, 17, 35)); + addSlotToContainer(new SlotCharge(tentity, 1, 143, 35)); + int slotX; - for(slotX = 0; slotX < 3; ++slotX) - { - for(int slotY = 0; slotY < 9; ++slotY) - { - addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); - } - } + for (slotX = 0; slotX < 3; ++slotX) { + for (int slotY = 0; slotY < 9; ++slotY) { + addSlotToContainer(new Slot( + inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18 + )); + } + } - for(slotX = 0; slotX < 9; ++slotX) - { - addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); - } + for (slotX = 0; slotX < 9; ++slotX) { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); + } - tileEntity.openInventory(); - tileEntity.open(inventory.player); - } + tileEntity.openInventory(); + tileEntity.open(inventory.player); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - tileEntity.closeInventory(); - tileEntity.close(entityplayer); - } + tileEntity.closeInventory(); + tileEntity.close(entityplayer); + } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(ChargeUtils.canBeCharged(slotStack)) - { - if(slotID != 1) - { - if(!mergeItemStack(slotStack, 1, 2, false)) - { - return null; - } - } - else if(slotID == 1) - { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), false)) - { - return null; - } - } - } - else if(tileEntity.getFuel(slotStack) > 0) - { - if(slotID != 0 && slotID != 1) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } - else { - if(slotID >= 2 && slotID <= 28) - { - if(!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 28) - { - if(!mergeItemStack(slotStack, 2, 28, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) - { - return null; - } - } - } + if (ChargeUtils.canBeCharged(slotStack)) { + if (slotID != 1) { + if (!mergeItemStack(slotStack, 1, 2, false)) { + return null; + } + } else if (slotID == 1) { + if (!mergeItemStack(slotStack, 2, inventorySlots.size(), false)) { + return null; + } + } + } else if (tileEntity.getFuel(slotStack) > 0) { + if (slotID != 0 && slotID != 1) { + if (!mergeItemStack(slotStack, 0, 1, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) { + return null; + } + } + } else { + if (slotID >= 2 && slotID <= 28) { + if (!mergeItemStack(slotStack, 29, inventorySlots.size(), false)) { + return null; + } + } else if (slotID > 28) { + if (!mergeItemStack(slotStack, 2, 28, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 2, inventorySlots.size(), true)) { + return null; + } + } + } - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - currentSlot.onPickupFromSlot(player, slotStack); - } + currentSlot.onPickupFromSlot(player, slotStack); + } - return stack; - } + return stack; + } } diff --git a/src/main/java/mekanism/generators/common/inventory/container/ContainerNeutronCapture.java b/src/main/java/mekanism/generators/common/inventory/container/ContainerNeutronCapture.java index d45e78db6..b7c24de3c 100644 --- a/src/main/java/mekanism/generators/common/inventory/container/ContainerNeutronCapture.java +++ b/src/main/java/mekanism/generators/common/inventory/container/ContainerNeutronCapture.java @@ -9,115 +9,93 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerNeutronCapture extends Container -{ - private TileEntityReactorNeutronCapture tileEntity; +public class ContainerNeutronCapture extends Container { + private TileEntityReactorNeutronCapture tileEntity; - public ContainerNeutronCapture(InventoryPlayer inventory, TileEntityReactorNeutronCapture tentity) - { - tileEntity = tentity; - addSlotToContainer(new SlotCharge(tentity, 0, 143, 35)); - int slotX; + public ContainerNeutronCapture( + InventoryPlayer inventory, TileEntityReactorNeutronCapture tentity + ) { + tileEntity = tentity; + addSlotToContainer(new SlotCharge(tentity, 0, 143, 35)); + int slotX; - for(slotX = 0; slotX < 3; ++slotX) - { - for(int slotY = 0; slotY < 9; ++slotY) - { - addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); - } - } + for (slotX = 0; slotX < 3; ++slotX) { + for (int slotY = 0; slotY < 9; ++slotY) { + addSlotToContainer(new Slot( + inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18 + )); + } + } - for(slotX = 0; slotX < 9; ++slotX) - { - addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); - } + for (slotX = 0; slotX < 9; ++slotX) { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); + } - tileEntity.openInventory(); - tileEntity.open(inventory.player); - } + tileEntity.openInventory(); + tileEntity.open(inventory.player); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - tileEntity.closeInventory(); - tileEntity.close(entityplayer); - } + tileEntity.closeInventory(); + tileEntity.close(entityplayer); + } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(ChargeUtils.canBeCharged(slotStack)) - { - if(slotID != 0) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else if(slotID == 0) - { - if(!mergeItemStack(slotStack, 1, inventorySlots.size(), false)) - { - return null; - } - } - } - else { - if(slotID >= 1 && slotID <= 27) - { - if(!mergeItemStack(slotStack, 28, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 27) - { - if(!mergeItemStack(slotStack, 1, 27, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) - { - return null; - } - } - } + if (ChargeUtils.canBeCharged(slotStack)) { + if (slotID != 0) { + if (!mergeItemStack(slotStack, 0, 1, false)) { + return null; + } + } else if (slotID == 0) { + if (!mergeItemStack(slotStack, 1, inventorySlots.size(), false)) { + return null; + } + } + } else { + if (slotID >= 1 && slotID <= 27) { + if (!mergeItemStack(slotStack, 28, inventorySlots.size(), false)) { + return null; + } + } else if (slotID > 27) { + if (!mergeItemStack(slotStack, 1, 27, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) { + return null; + } + } + } - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - currentSlot.onPickupFromSlot(player, slotStack); - } + currentSlot.onPickupFromSlot(player, slotStack); + } - return stack; - } + return stack; + } } diff --git a/src/main/java/mekanism/generators/common/inventory/container/ContainerReactorController.java b/src/main/java/mekanism/generators/common/inventory/container/ContainerReactorController.java index ffed7e8dc..722b878b4 100644 --- a/src/main/java/mekanism/generators/common/inventory/container/ContainerReactorController.java +++ b/src/main/java/mekanism/generators/common/inventory/container/ContainerReactorController.java @@ -1,5 +1,7 @@ package mekanism.generators.common.inventory.container; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.common.util.MekanismUtils; import mekanism.generators.common.item.ItemHohlraum; import mekanism.generators.common.tile.reactor.TileEntityReactorController; @@ -9,133 +11,112 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class ContainerReactorController extends Container -{ - private TileEntityReactorController tileEntity; +public class ContainerReactorController extends Container { + private TileEntityReactorController tileEntity; - public ContainerReactorController(InventoryPlayer inventory, TileEntityReactorController tentity) - { - tileEntity = tentity; - addSlotToContainer(new SlotReactor(tentity, 0, 80, 39)); - int slotX; + public ContainerReactorController( + InventoryPlayer inventory, TileEntityReactorController tentity + ) { + tileEntity = tentity; + addSlotToContainer(new SlotReactor(tentity, 0, 80, 39)); + int slotX; - for(slotX = 0; slotX < 3; slotX++) - { - for(int slotY = 0; slotY < 9; slotY++) - { - addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); - } - } + for (slotX = 0; slotX < 3; slotX++) { + for (int slotY = 0; slotY < 9; slotY++) { + addSlotToContainer(new Slot( + inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18 + )); + } + } - for(slotX = 0; slotX < 9; slotX++) - { - addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); - } + for (slotX = 0; slotX < 9; slotX++) { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); + } - tileEntity.openInventory(); - tileEntity.open(inventory.player); - } + tileEntity.openInventory(); + tileEntity.open(inventory.player); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - tileEntity.closeInventory(); - tileEntity.close(entityplayer); - } + tileEntity.closeInventory(); + tileEntity.close(entityplayer); + } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(slotStack.getItem() instanceof ItemHohlraum) - { - if(slotID != 0) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else if(slotID == 0) - { - if(!mergeItemStack(slotStack, 1, inventorySlots.size(), false)) - { - return null; - } - } - } - else { - if(slotID >= 1 && slotID <= 27) - { - if(!mergeItemStack(slotStack, 28, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 27) - { - if(!mergeItemStack(slotStack, 1, 27, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) - { - return null; - } - } - } + if (slotStack.getItem() instanceof ItemHohlraum) { + if (slotID != 0) { + if (!mergeItemStack(slotStack, 0, 1, false)) { + return null; + } + } else if (slotID == 0) { + if (!mergeItemStack(slotStack, 1, inventorySlots.size(), false)) { + return null; + } + } + } else { + if (slotID >= 1 && slotID <= 27) { + if (!mergeItemStack(slotStack, 28, inventorySlots.size(), false)) { + return null; + } + } else if (slotID > 27) { + if (!mergeItemStack(slotStack, 1, 27, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) { + return null; + } + } + } - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - currentSlot.onPickupFromSlot(player, slotStack); - } + currentSlot.onPickupFromSlot(player, slotStack); + } - return stack; - } - - public class SlotReactor extends Slot - { - public SlotReactor(IInventory inventory, int index, int x, int y) - { - super(inventory, index, x, y); - } + return stack; + } - @Override - @SideOnly(Side.CLIENT) - public boolean func_111238_b() - { - return tileEntity != null && MekanismUtils.isActive(tileEntity.getWorldObj(), tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord); - } - } + public class SlotReactor extends Slot { + public SlotReactor(IInventory inventory, int index, int x, int y) { + super(inventory, index, x, y); + } + + @Override + @SideOnly(Side.CLIENT) + public boolean func_111238_b() { + return tileEntity != null + && MekanismUtils.isActive( + tileEntity.getWorldObj(), + tileEntity.xCoord, + tileEntity.yCoord, + tileEntity.zCoord + ); + } + } } diff --git a/src/main/java/mekanism/generators/common/inventory/container/ContainerSolarGenerator.java b/src/main/java/mekanism/generators/common/inventory/container/ContainerSolarGenerator.java index 6883ce957..dff63dc6c 100644 --- a/src/main/java/mekanism/generators/common/inventory/container/ContainerSolarGenerator.java +++ b/src/main/java/mekanism/generators/common/inventory/container/ContainerSolarGenerator.java @@ -9,115 +9,93 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerSolarGenerator extends Container -{ - private TileEntitySolarGenerator tileEntity; +public class ContainerSolarGenerator extends Container { + private TileEntitySolarGenerator tileEntity; - public ContainerSolarGenerator(InventoryPlayer inventory, TileEntitySolarGenerator tentity) - { - tileEntity = tentity; - addSlotToContainer(new SlotCharge(tentity, 0, 143, 35)); - int slotX; + public ContainerSolarGenerator( + InventoryPlayer inventory, TileEntitySolarGenerator tentity + ) { + tileEntity = tentity; + addSlotToContainer(new SlotCharge(tentity, 0, 143, 35)); + int slotX; - for(slotX = 0; slotX < 3; ++slotX) - { - for(int slotY = 0; slotY < 9; ++slotY) - { - addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); - } - } + for (slotX = 0; slotX < 3; ++slotX) { + for (int slotY = 0; slotY < 9; ++slotY) { + addSlotToContainer(new Slot( + inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18 + )); + } + } - for(slotX = 0; slotX < 9; ++slotX) - { - addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); - } + for (slotX = 0; slotX < 9; ++slotX) { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); + } - tileEntity.openInventory(); - tileEntity.open(inventory.player); - } + tileEntity.openInventory(); + tileEntity.open(inventory.player); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - tileEntity.closeInventory(); - tileEntity.close(entityplayer); - } + tileEntity.closeInventory(); + tileEntity.close(entityplayer); + } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(ChargeUtils.canBeCharged(slotStack)) - { - if(slotID != 0) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else if(slotID == 0) - { - if(!mergeItemStack(slotStack, 1, inventorySlots.size(), false)) - { - return null; - } - } - } - else { - if(slotID >= 1 && slotID <= 27) - { - if(!mergeItemStack(slotStack, 28, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 27) - { - if(!mergeItemStack(slotStack, 1, 27, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) - { - return null; - } - } - } + if (ChargeUtils.canBeCharged(slotStack)) { + if (slotID != 0) { + if (!mergeItemStack(slotStack, 0, 1, false)) { + return null; + } + } else if (slotID == 0) { + if (!mergeItemStack(slotStack, 1, inventorySlots.size(), false)) { + return null; + } + } + } else { + if (slotID >= 1 && slotID <= 27) { + if (!mergeItemStack(slotStack, 28, inventorySlots.size(), false)) { + return null; + } + } else if (slotID > 27) { + if (!mergeItemStack(slotStack, 1, 27, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) { + return null; + } + } + } - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - currentSlot.onPickupFromSlot(player, slotStack); - } + currentSlot.onPickupFromSlot(player, slotStack); + } - return stack; - } + return stack; + } } diff --git a/src/main/java/mekanism/generators/common/inventory/container/ContainerWindGenerator.java b/src/main/java/mekanism/generators/common/inventory/container/ContainerWindGenerator.java index 21bf17c33..1c7ca34cc 100644 --- a/src/main/java/mekanism/generators/common/inventory/container/ContainerWindGenerator.java +++ b/src/main/java/mekanism/generators/common/inventory/container/ContainerWindGenerator.java @@ -9,115 +9,93 @@ import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; -public class ContainerWindGenerator extends Container -{ - private TileEntityWindGenerator tileEntity; +public class ContainerWindGenerator extends Container { + private TileEntityWindGenerator tileEntity; - public ContainerWindGenerator(InventoryPlayer inventory, TileEntityWindGenerator tentity) - { - tileEntity = tentity; - addSlotToContainer(new SlotCharge(tentity, 0, 143, 35)); - int slotX; + public ContainerWindGenerator( + InventoryPlayer inventory, TileEntityWindGenerator tentity + ) { + tileEntity = tentity; + addSlotToContainer(new SlotCharge(tentity, 0, 143, 35)); + int slotX; - for(slotX = 0; slotX < 3; ++slotX) - { - for(int slotY = 0; slotY < 9; ++slotY) - { - addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); - } - } + for (slotX = 0; slotX < 3; ++slotX) { + for (int slotY = 0; slotY < 9; ++slotY) { + addSlotToContainer(new Slot( + inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18 + )); + } + } - for(slotX = 0; slotX < 9; ++slotX) - { - addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); - } + for (slotX = 0; slotX < 9; ++slotX) { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); + } - tileEntity.openInventory(); - tileEntity.open(inventory.player); - } + tileEntity.openInventory(); + tileEntity.open(inventory.player); + } - @Override - public void onContainerClosed(EntityPlayer entityplayer) - { - super.onContainerClosed(entityplayer); + @Override + public void onContainerClosed(EntityPlayer entityplayer) { + super.onContainerClosed(entityplayer); - tileEntity.closeInventory(); - tileEntity.close(entityplayer); - } + tileEntity.closeInventory(); + tileEntity.close(entityplayer); + } - @Override - public boolean canInteractWith(EntityPlayer entityplayer) - { - return tileEntity.isUseableByPlayer(entityplayer); - } + @Override + public boolean canInteractWith(EntityPlayer entityplayer) { + return tileEntity.isUseableByPlayer(entityplayer); + } - @Override - public ItemStack transferStackInSlot(EntityPlayer player, int slotID) - { - ItemStack stack = null; - Slot currentSlot = (Slot)inventorySlots.get(slotID); + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) { + ItemStack stack = null; + Slot currentSlot = (Slot) inventorySlots.get(slotID); - if(currentSlot != null && currentSlot.getHasStack()) - { - ItemStack slotStack = currentSlot.getStack(); - stack = slotStack.copy(); + if (currentSlot != null && currentSlot.getHasStack()) { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); - if(ChargeUtils.canBeCharged(slotStack)) - { - if(slotID != 0) - { - if(!mergeItemStack(slotStack, 0, 1, false)) - { - return null; - } - } - else if(slotID == 0) - { - if(!mergeItemStack(slotStack, 1, inventorySlots.size(), false)) - { - return null; - } - } - } - else { - if(slotID >= 1 && slotID <= 27) - { - if(!mergeItemStack(slotStack, 28, inventorySlots.size(), false)) - { - return null; - } - } - else if(slotID > 27) - { - if(!mergeItemStack(slotStack, 1, 27, false)) - { - return null; - } - } - else { - if(!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) - { - return null; - } - } - } + if (ChargeUtils.canBeCharged(slotStack)) { + if (slotID != 0) { + if (!mergeItemStack(slotStack, 0, 1, false)) { + return null; + } + } else if (slotID == 0) { + if (!mergeItemStack(slotStack, 1, inventorySlots.size(), false)) { + return null; + } + } + } else { + if (slotID >= 1 && slotID <= 27) { + if (!mergeItemStack(slotStack, 28, inventorySlots.size(), false)) { + return null; + } + } else if (slotID > 27) { + if (!mergeItemStack(slotStack, 1, 27, false)) { + return null; + } + } else { + if (!mergeItemStack(slotStack, 1, inventorySlots.size(), true)) { + return null; + } + } + } - if(slotStack.stackSize == 0) - { - currentSlot.putStack((ItemStack)null); - } - else { - currentSlot.onSlotChanged(); - } + if (slotStack.stackSize == 0) { + currentSlot.putStack((ItemStack) null); + } else { + currentSlot.onSlotChanged(); + } - if(slotStack.stackSize == stack.stackSize) - { - return null; - } + if (slotStack.stackSize == stack.stackSize) { + return null; + } - currentSlot.onPickupFromSlot(player, slotStack); - } + currentSlot.onPickupFromSlot(player, slotStack); + } - return stack; - } + return stack; + } } diff --git a/src/main/java/mekanism/generators/common/item/ItemBlockGenerator.java b/src/main/java/mekanism/generators/common/item/ItemBlockGenerator.java index 16ae8000a..b4238c83f 100644 --- a/src/main/java/mekanism/generators/common/item/ItemBlockGenerator.java +++ b/src/main/java/mekanism/generators/common/item/ItemBlockGenerator.java @@ -1,10 +1,15 @@ package mekanism.generators.common.item; -import ic2.api.item.IElectricItemManager; -import ic2.api.item.ISpecialElectricItem; - import java.util.List; +import cofh.api.energy.IEnergyContainerItem; +import cpw.mods.fml.common.Optional.Interface; +import cpw.mods.fml.common.Optional.InterfaceList; +import cpw.mods.fml.common.Optional.Method; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ic2.api.item.IElectricItemManager; +import ic2.api.item.ISpecialElectricItem; import mekanism.api.EnumColor; import mekanism.api.MekanismConfig.general; import mekanism.api.energy.IEnergizedItem; @@ -35,12 +40,6 @@ import net.minecraft.util.IIcon; import net.minecraft.world.World; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; -import cofh.api.energy.IEnergyContainerItem; -import cpw.mods.fml.common.Optional.Interface; -import cpw.mods.fml.common.Optional.InterfaceList; -import cpw.mods.fml.common.Optional.Method; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; /** * Item class for handling multiple generator block IDs. @@ -61,495 +60,479 @@ import cpw.mods.fml.relauncher.SideOnly; * */ -@InterfaceList({ - @Interface(iface = "ic2.api.item.ISpecialElectricItem", modid = "IC2") -}) -public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISpecialElectricItem, ISustainedInventory, ISustainedTank, IEnergyContainerItem, ISecurityItem -{ - public Block metaBlock; +@InterfaceList({ @Interface(iface = "ic2.api.item.ISpecialElectricItem", modid = "IC2") }) +public class ItemBlockGenerator extends ItemBlock + implements IEnergizedItem, ISpecialElectricItem, ISustainedInventory, ISustainedTank, + IEnergyContainerItem, ISecurityItem { + public Block metaBlock; - public ItemBlockGenerator(Block block) - { - super(block); - metaBlock = block; - setHasSubtypes(true); - } - - @Override - public int getItemStackLimit(ItemStack stack) - { - GeneratorType type = GeneratorType.getFromMetadata(stack.getItemDamage()); - - if(type.maxEnergy == -1) - { - return 64; - } - else { - return 1; - } - } + public ItemBlockGenerator(Block block) { + super(block); + metaBlock = block; + setHasSubtypes(true); + } - @Override - public int getMetadata(int i) - { - return i; - } + @Override + public int getItemStackLimit(ItemStack stack) { + GeneratorType type = GeneratorType.getFromMetadata(stack.getItemDamage()); - @Override - public IIcon getIconFromDamage(int i) - { - return metaBlock.getIcon(2, i); - } + if (type.maxEnergy == -1) { + return 64; + } else { + return 1; + } + } - @Override - public String getUnlocalizedName(ItemStack itemstack) - { - if(GeneratorType.getFromMetadata(itemstack.getItemDamage()) == null) - { - return "KillMe!"; - } + @Override + public int getMetadata(int i) { + return i; + } - return getUnlocalizedName() + "." + GeneratorType.getFromMetadata(itemstack.getItemDamage()).name; - } + @Override + public IIcon getIconFromDamage(int i) { + return metaBlock.getIcon(2, i); + } - @Override - @SideOnly(Side.CLIENT) - public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) - { - GeneratorType type = GeneratorType.getFromMetadata(itemstack.getItemDamage()); - - if(type.maxEnergy > -1) - { - if(!MekKeyHandler.getIsKeyPressed(MekanismKeyHandler.sneakKey)) - { - list.add(LangUtils.localize("tooltip.hold") + " " + EnumColor.INDIGO + GameSettings.getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode()) + EnumColor.GREY + " " + LangUtils.localize("tooltip.forDetails") + "."); - list.add(LangUtils.localize("tooltip.hold") + " " + EnumColor.AQUA + GameSettings.getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode()) + EnumColor.GREY + " " + LangUtils.localize("tooltip.and") + " " + EnumColor.AQUA + GameSettings.getKeyDisplayString(MekanismKeyHandler.modeSwitchKey.getKeyCode()) + EnumColor.GREY + " " + LangUtils.localize("tooltip.forDesc") + "."); - } - else if(!MekKeyHandler.getIsKeyPressed(MekanismKeyHandler.modeSwitchKey)) - { - if(hasSecurity(itemstack)) - { - list.add(SecurityUtils.getOwnerDisplay(entityplayer.getCommandSenderName(), getOwner(itemstack))); - list.add(EnumColor.GREY + LangUtils.localize("gui.security") + ": " + SecurityUtils.getSecurityDisplay(itemstack, Side.CLIENT)); - - if(SecurityUtils.isOverridden(itemstack, Side.CLIENT)) - { - list.add(EnumColor.RED + "(" + LangUtils.localize("gui.overridden") + ")"); - } - } - - list.add(EnumColor.BRIGHT_GREEN + LangUtils.localize("tooltip.storedEnergy") + ": " + EnumColor.GREY + MekanismUtils.getEnergyDisplay(getEnergy(itemstack))); - - if(hasTank(itemstack)) - { - if(getFluidStack(itemstack) != null) - { - list.add(EnumColor.PINK + FluidRegistry.getFluidName(getFluidStack(itemstack)) + ": " + EnumColor.GREY + getFluidStack(itemstack).amount + "mB"); - } - } - - list.add(EnumColor.AQUA + LangUtils.localize("tooltip.inventory") + ": " + EnumColor.GREY + LangUtils.transYesNo(getInventory(itemstack) != null && getInventory(itemstack).tagCount() != 0)); - } - else { - list.addAll(MekanismUtils.splitTooltip(type.getDescription(), itemstack)); - } - } - else { - if(!MekKeyHandler.getIsKeyPressed(MekanismKeyHandler.sneakKey)) - { - list.add(LangUtils.localize("tooltip.hold") + " " + EnumColor.INDIGO + GameSettings.getKeyDisplayString(MekanismKeyHandler.sneakKey.getKeyCode()) + EnumColor.GREY + " " + LangUtils.localize("tooltip.forDetails") + "."); - } - else { - list.addAll(MekanismUtils.splitTooltip(type.getDescription(), itemstack)); - } - } - } + @Override + public String getUnlocalizedName(ItemStack itemstack) { + if (GeneratorType.getFromMetadata(itemstack.getItemDamage()) == null) { + return "KillMe!"; + } - @Override - public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) - { - boolean place = true; - Block block = world.getBlock(x, y, z); + return getUnlocalizedName() + "." + + GeneratorType.getFromMetadata(itemstack.getItemDamage()).name; + } - if(stack.getItemDamage() == GeneratorType.ADVANCED_SOLAR_GENERATOR.meta) - { - if(!(block.isReplaceable(world, x, y, z) && world.isAirBlock(x, y+1, z))) - { - return false; - } + @Override + @SideOnly(Side.CLIENT) + public void addInformation( + ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag + ) { + GeneratorType type = GeneratorType.getFromMetadata(itemstack.getItemDamage()); - outer: - for(int xPos = -1; xPos <= 1; xPos++) - { - for(int zPos =- 1; zPos <= 1; zPos++) - { - if(!world.isAirBlock(x+xPos, y+2, z+zPos) || y+2 > 255) - { - place = false; - break outer; - } - } - } - } - else if(stack.getItemDamage() == GeneratorType.WIND_GENERATOR.meta) - { - if(!block.isReplaceable(world, x, y, z)) - { - return false; - } + if (type.maxEnergy > -1) { + if (!MekKeyHandler.getIsKeyPressed(MekanismKeyHandler.sneakKey)) { + list.add( + LangUtils.localize("tooltip.hold") + " " + EnumColor.INDIGO + + GameSettings.getKeyDisplayString( + MekanismKeyHandler.sneakKey.getKeyCode() + ) + + EnumColor.GREY + " " + LangUtils.localize("tooltip.forDetails") + + "." + ); + list.add( + LangUtils.localize("tooltip.hold") + " " + EnumColor.AQUA + + GameSettings.getKeyDisplayString( + MekanismKeyHandler.sneakKey.getKeyCode() + ) + + EnumColor.GREY + " " + LangUtils.localize("tooltip.and") + " " + + EnumColor.AQUA + + GameSettings.getKeyDisplayString( + MekanismKeyHandler.modeSwitchKey.getKeyCode() + ) + + EnumColor.GREY + " " + LangUtils.localize("tooltip.forDesc") + "." + ); + } else if (!MekKeyHandler.getIsKeyPressed(MekanismKeyHandler.modeSwitchKey)) { + if (hasSecurity(itemstack)) { + list.add(SecurityUtils.getOwnerDisplay( + entityplayer.getCommandSenderName(), getOwner(itemstack) + )); + list.add( + EnumColor.GREY + LangUtils.localize("gui.security") + ": " + + SecurityUtils.getSecurityDisplay(itemstack, Side.CLIENT) + ); - outer: - for(int yPos = y+1; yPos <= y+4; yPos++) - { - if(!world.isAirBlock(x, yPos, z) || yPos > 255) - { - place = false; - break outer; - } - } - } + if (SecurityUtils.isOverridden(itemstack, Side.CLIENT)) { + list.add( + EnumColor.RED + "(" + LangUtils.localize("gui.overridden") + + ")" + ); + } + } - if(place && super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata)) - { - TileEntityBasicBlock tileEntity = (TileEntityBasicBlock)world.getTileEntity(x, y, z); - - if(tileEntity instanceof ISecurityTile) - { - ISecurityTile security = (ISecurityTile)tileEntity; - security.getSecurity().setOwner(getOwner(stack)); - - if(hasSecurity(stack)) - { - security.getSecurity().setMode(getSecurity(stack)); - } - - if(getOwner(stack) == null) - { - security.getSecurity().setOwner(player.getCommandSenderName()); - } - } - - if(tileEntity instanceof TileEntityElectricBlock) - { - ((TileEntityElectricBlock)tileEntity).electricityStored = getEnergy(stack); - } + list.add( + EnumColor.BRIGHT_GREEN + LangUtils.localize("tooltip.storedEnergy") + + ": " + EnumColor.GREY + + MekanismUtils.getEnergyDisplay(getEnergy(itemstack)) + ); - if(tileEntity instanceof ISustainedInventory) - { - ((ISustainedInventory)tileEntity).setInventory(getInventory(stack)); - } - - if(tileEntity instanceof ISustainedData) - { - if(stack.stackTagCompound != null) - { - ((ISustainedData)tileEntity).readSustainedData(stack); - } - } + if (hasTank(itemstack)) { + if (getFluidStack(itemstack) != null) { + list.add( + EnumColor.PINK + + FluidRegistry.getFluidName(getFluidStack(itemstack)) + ": " + + EnumColor.GREY + getFluidStack(itemstack).amount + "mB" + ); + } + } - if(tileEntity instanceof ISustainedTank) - { - if(hasTank(stack) && getFluidStack(stack) != null) - { - ((ISustainedTank)tileEntity).setFluidStack(getFluidStack(stack), stack); - } - } + list.add( + EnumColor.AQUA + LangUtils.localize("tooltip.inventory") + ": " + + EnumColor.GREY + + LangUtils.transYesNo( + getInventory(itemstack) != null + && getInventory(itemstack).tagCount() != 0 + ) + ); + } else { + list.addAll(MekanismUtils.splitTooltip(type.getDescription(), itemstack)); + } + } else { + if (!MekKeyHandler.getIsKeyPressed(MekanismKeyHandler.sneakKey)) { + list.add( + LangUtils.localize("tooltip.hold") + " " + EnumColor.INDIGO + + GameSettings.getKeyDisplayString( + MekanismKeyHandler.sneakKey.getKeyCode() + ) + + EnumColor.GREY + " " + LangUtils.localize("tooltip.forDetails") + + "." + ); + } else { + list.addAll(MekanismUtils.splitTooltip(type.getDescription(), itemstack)); + } + } + } - return true; - } + @Override + public boolean placeBlockAt( + ItemStack stack, + EntityPlayer player, + World world, + int x, + int y, + int z, + int side, + float hitX, + float hitY, + float hitZ, + int metadata + ) { + boolean place = true; + Block block = world.getBlock(x, y, z); - return false; - } + if (stack.getItemDamage() == GeneratorType.ADVANCED_SOLAR_GENERATOR.meta) { + if (!(block.isReplaceable(world, x, y, z) && world.isAirBlock(x, y + 1, z))) { + return false; + } - @Override - @Method(modid = "IC2") - public boolean canProvideEnergy(ItemStack itemStack) - { - return canSend(itemStack); - } + outer: + for (int xPos = -1; xPos <= 1; xPos++) { + for (int zPos = -1; zPos <= 1; zPos++) { + if (!world.isAirBlock(x + xPos, y + 2, z + zPos) || y + 2 > 255) { + place = false; + break outer; + } + } + } + } else if (stack.getItemDamage() == GeneratorType.WIND_GENERATOR.meta) { + if (!block.isReplaceable(world, x, y, z)) { + return false; + } - @Override - @Method(modid = "IC2") - public Item getChargedItem(ItemStack itemStack) - { - return this; - } + outer: + for (int yPos = y + 1; yPos <= y + 4; yPos++) { + if (!world.isAirBlock(x, yPos, z) || yPos > 255) { + place = false; + break outer; + } + } + } - @Override - @Method(modid = "IC2") - public Item getEmptyItem(ItemStack itemStack) - { - return this; - } + if (place + && super.placeBlockAt( + stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata + )) { + TileEntityBasicBlock tileEntity + = (TileEntityBasicBlock) world.getTileEntity(x, y, z); - @Override - @Method(modid = "IC2") - public double getMaxCharge(ItemStack itemStack) - { - return 0; - } + if (tileEntity instanceof ISecurityTile) { + ISecurityTile security = (ISecurityTile) tileEntity; + security.getSecurity().setOwner(getOwner(stack)); - @Override - @Method(modid = "IC2") - public int getTier(ItemStack itemStack) - { - return 4; - } + if (hasSecurity(stack)) { + security.getSecurity().setMode(getSecurity(stack)); + } - @Override - @Method(modid = "IC2") - public double getTransferLimit(ItemStack itemStack) - { - return 0; - } + if (getOwner(stack) == null) { + security.getSecurity().setOwner(player.getCommandSenderName()); + } + } - @Override - public void setInventory(NBTTagList nbtTags, Object... data) - { - if(data[0] instanceof ItemStack) - { - ItemStack itemStack = (ItemStack)data[0]; + if (tileEntity instanceof TileEntityElectricBlock) { + ((TileEntityElectricBlock) tileEntity).electricityStored + = getEnergy(stack); + } - if(itemStack.stackTagCompound == null) - { - itemStack.setTagCompound(new NBTTagCompound()); - } + if (tileEntity instanceof ISustainedInventory) { + ((ISustainedInventory) tileEntity).setInventory(getInventory(stack)); + } - itemStack.stackTagCompound.setTag("Items", nbtTags); - } - } + if (tileEntity instanceof ISustainedData) { + if (stack.stackTagCompound != null) { + ((ISustainedData) tileEntity).readSustainedData(stack); + } + } - @Override - public NBTTagList getInventory(Object... data) - { - if(data[0] instanceof ItemStack) - { - ItemStack itemStack = (ItemStack)data[0]; + if (tileEntity instanceof ISustainedTank) { + if (hasTank(stack) && getFluidStack(stack) != null) { + ((ISustainedTank) tileEntity) + .setFluidStack(getFluidStack(stack), stack); + } + } - if(itemStack.stackTagCompound == null) - { - return null; - } + return true; + } - return itemStack.stackTagCompound.getTagList("Items", 10); - } + return false; + } - return null; - } + @Override + @Method(modid = "IC2") + public boolean canProvideEnergy(ItemStack itemStack) { + return canSend(itemStack); + } - @Override - public void setFluidStack(FluidStack fluidStack, Object... data) - { - if(fluidStack == null || fluidStack.amount == 0 || fluidStack.getFluidID() == 0) - { - return; - } + @Override + @Method(modid = "IC2") + public Item getChargedItem(ItemStack itemStack) { + return this; + } - if(data[0] instanceof ItemStack) - { - ItemStack itemStack = (ItemStack)data[0]; + @Override + @Method(modid = "IC2") + public Item getEmptyItem(ItemStack itemStack) { + return this; + } - if(itemStack.stackTagCompound == null) - { - itemStack.setTagCompound(new NBTTagCompound()); - } + @Override + @Method(modid = "IC2") + public double getMaxCharge(ItemStack itemStack) { + return 0; + } - itemStack.stackTagCompound.setTag("fluidTank", fluidStack.writeToNBT(new NBTTagCompound())); - } - } + @Override + @Method(modid = "IC2") + public int getTier(ItemStack itemStack) { + return 4; + } - @Override - public FluidStack getFluidStack(Object... data) - { - if(data[0] instanceof ItemStack) - { - ItemStack itemStack = (ItemStack)data[0]; + @Override + @Method(modid = "IC2") + public double getTransferLimit(ItemStack itemStack) { + return 0; + } - if(itemStack.stackTagCompound == null) - { - return null; - } + @Override + public void setInventory(NBTTagList nbtTags, Object... data) { + if (data[0] instanceof ItemStack) { + ItemStack itemStack = (ItemStack) data[0]; - if(itemStack.stackTagCompound.hasKey("fluidTank")) - { - return FluidStack.loadFluidStackFromNBT(itemStack.stackTagCompound.getCompoundTag("fluidTank")); - } - } + if (itemStack.stackTagCompound == null) { + itemStack.setTagCompound(new NBTTagCompound()); + } - return null; - } + itemStack.stackTagCompound.setTag("Items", nbtTags); + } + } - @Override - public boolean hasTank(Object... data) - { - return data[0] instanceof ItemStack && ((ItemStack)data[0]).getItem() instanceof ISustainedTank && (((ItemStack)data[0]).getItemDamage() == 2); - } + @Override + public NBTTagList getInventory(Object... data) { + if (data[0] instanceof ItemStack) { + ItemStack itemStack = (ItemStack) data[0]; - @Override - public double getEnergy(ItemStack itemStack) - { - if(itemStack.stackTagCompound == null) - { - return 0; - } + if (itemStack.stackTagCompound == null) { + return null; + } - return itemStack.stackTagCompound.getDouble("electricity"); - } + return itemStack.stackTagCompound.getTagList("Items", 10); + } - @Override - public void setEnergy(ItemStack itemStack, double amount) - { - if(itemStack.stackTagCompound == null) - { - itemStack.setTagCompound(new NBTTagCompound()); - } + return null; + } - double electricityStored = Math.max(Math.min(amount, getMaxEnergy(itemStack)), 0); - itemStack.stackTagCompound.setDouble("electricity", electricityStored); - } + @Override + public void setFluidStack(FluidStack fluidStack, Object... data) { + if (fluidStack == null || fluidStack.amount == 0 + || fluidStack.getFluidID() == 0) { + return; + } - @Override - public double getMaxEnergy(ItemStack itemStack) - { - return GeneratorType.getFromMetadata(itemStack.getItemDamage()).maxEnergy; - } + if (data[0] instanceof ItemStack) { + ItemStack itemStack = (ItemStack) data[0]; - @Override - public double getMaxTransfer(ItemStack itemStack) - { - return getMaxEnergy(itemStack)*0.005; - } + if (itemStack.stackTagCompound == null) { + itemStack.setTagCompound(new NBTTagCompound()); + } - @Override - public boolean canReceive(ItemStack itemStack) - { - return false; - } + itemStack.stackTagCompound.setTag( + "fluidTank", fluidStack.writeToNBT(new NBTTagCompound()) + ); + } + } - @Override - public boolean canSend(ItemStack itemStack) - { - return GeneratorType.getFromMetadata(itemStack.getItemDamage()).maxEnergy != -1; - } + @Override + public FluidStack getFluidStack(Object... data) { + if (data[0] instanceof ItemStack) { + ItemStack itemStack = (ItemStack) data[0]; - @Override - public int receiveEnergy(ItemStack theItem, int energy, boolean simulate) - { - if(canReceive(theItem)) - { - double energyNeeded = getMaxEnergy(theItem)-getEnergy(theItem); - double toReceive = Math.min(energy* general.FROM_TE, energyNeeded); + if (itemStack.stackTagCompound == null) { + return null; + } - if(!simulate) - { - setEnergy(theItem, getEnergy(theItem) + toReceive); - } + if (itemStack.stackTagCompound.hasKey("fluidTank")) { + return FluidStack.loadFluidStackFromNBT( + itemStack.stackTagCompound.getCompoundTag("fluidTank") + ); + } + } - return (int)Math.round(toReceive* general.TO_TE); - } + return null; + } - return 0; - } + @Override + public boolean hasTank(Object... data) { + return data[0] instanceof ItemStack + && ((ItemStack) data[0]).getItem() instanceof ISustainedTank + && (((ItemStack) data[0]).getItemDamage() == 2); + } - @Override - public int extractEnergy(ItemStack theItem, int energy, boolean simulate) - { - if(canSend(theItem)) - { - double energyRemaining = getEnergy(theItem); - double toSend = Math.min((energy* general.FROM_TE), energyRemaining); + @Override + public double getEnergy(ItemStack itemStack) { + if (itemStack.stackTagCompound == null) { + return 0; + } - if(!simulate) - { - setEnergy(theItem, getEnergy(theItem) - toSend); - } + return itemStack.stackTagCompound.getDouble("electricity"); + } - return (int)Math.round(toSend* general.TO_TE); - } + @Override + public void setEnergy(ItemStack itemStack, double amount) { + if (itemStack.stackTagCompound == null) { + itemStack.setTagCompound(new NBTTagCompound()); + } - return 0; - } + double electricityStored = Math.max(Math.min(amount, getMaxEnergy(itemStack)), 0); + itemStack.stackTagCompound.setDouble("electricity", electricityStored); + } - @Override - public int getEnergyStored(ItemStack theItem) - { - return (int)(getEnergy(theItem)* general.TO_TE); - } + @Override + public double getMaxEnergy(ItemStack itemStack) { + return GeneratorType.getFromMetadata(itemStack.getItemDamage()).maxEnergy; + } - @Override - public int getMaxEnergyStored(ItemStack theItem) - { - return (int)(getMaxEnergy(theItem)* general.TO_TE); - } + @Override + public double getMaxTransfer(ItemStack itemStack) { + return getMaxEnergy(itemStack) * 0.005; + } - @Override - @Method(modid = "IC2") - public IElectricItemManager getManager(ItemStack itemStack) - { - return IC2ItemManager.getManager(this); - } - - @Override - public String getOwner(ItemStack stack) - { - if(stack.stackTagCompound != null && stack.stackTagCompound.hasKey("owner")) - { - return stack.stackTagCompound.getString("owner"); - } - - return null; - } + @Override + public boolean canReceive(ItemStack itemStack) { + return false; + } - @Override - public void setOwner(ItemStack stack, String owner) - { - if(stack.stackTagCompound == null) - { - stack.setTagCompound(new NBTTagCompound()); - } - - if(owner == null || owner.isEmpty()) - { - stack.stackTagCompound.removeTag("owner"); - return; - } - - stack.stackTagCompound.setString("owner", owner); - } + @Override + public boolean canSend(ItemStack itemStack) { + return GeneratorType.getFromMetadata(itemStack.getItemDamage()).maxEnergy != -1; + } - @Override - public SecurityMode getSecurity(ItemStack stack) - { - if(stack.stackTagCompound == null || !general.allowProtection) - { - return SecurityMode.PUBLIC; - } + @Override + public int receiveEnergy(ItemStack theItem, int energy, boolean simulate) { + if (canReceive(theItem)) { + double energyNeeded = getMaxEnergy(theItem) - getEnergy(theItem); + double toReceive = Math.min(energy * general.FROM_TE, energyNeeded); - return SecurityMode.values()[stack.stackTagCompound.getInteger("security")]; - } + if (!simulate) { + setEnergy(theItem, getEnergy(theItem) + toReceive); + } - @Override - public void setSecurity(ItemStack stack, SecurityMode mode) - { - if(stack.stackTagCompound == null) - { - stack.setTagCompound(new NBTTagCompound()); - } - - stack.stackTagCompound.setInteger("security", mode.ordinal()); - } + return (int) Math.round(toReceive * general.TO_TE); + } - @Override - public boolean hasSecurity(ItemStack stack) - { - GeneratorType type = GeneratorType.getFromMetadata(stack.getItemDamage()); - - return type.hasModel; - } - - @Override - public boolean hasOwner(ItemStack stack) - { - return hasSecurity(stack); - } + return 0; + } + + @Override + public int extractEnergy(ItemStack theItem, int energy, boolean simulate) { + if (canSend(theItem)) { + double energyRemaining = getEnergy(theItem); + double toSend = Math.min((energy * general.FROM_TE), energyRemaining); + + if (!simulate) { + setEnergy(theItem, getEnergy(theItem) - toSend); + } + + return (int) Math.round(toSend * general.TO_TE); + } + + return 0; + } + + @Override + public int getEnergyStored(ItemStack theItem) { + return (int) (getEnergy(theItem) * general.TO_TE); + } + + @Override + public int getMaxEnergyStored(ItemStack theItem) { + return (int) (getMaxEnergy(theItem) * general.TO_TE); + } + + @Override + @Method(modid = "IC2") + public IElectricItemManager getManager(ItemStack itemStack) { + return IC2ItemManager.getManager(this); + } + + @Override + public String getOwner(ItemStack stack) { + if (stack.stackTagCompound != null && stack.stackTagCompound.hasKey("owner")) { + return stack.stackTagCompound.getString("owner"); + } + + return null; + } + + @Override + public void setOwner(ItemStack stack, String owner) { + if (stack.stackTagCompound == null) { + stack.setTagCompound(new NBTTagCompound()); + } + + if (owner == null || owner.isEmpty()) { + stack.stackTagCompound.removeTag("owner"); + return; + } + + stack.stackTagCompound.setString("owner", owner); + } + + @Override + public SecurityMode getSecurity(ItemStack stack) { + if (stack.stackTagCompound == null || !general.allowProtection) { + return SecurityMode.PUBLIC; + } + + return SecurityMode.values()[stack.stackTagCompound.getInteger("security")]; + } + + @Override + public void setSecurity(ItemStack stack, SecurityMode mode) { + if (stack.stackTagCompound == null) { + stack.setTagCompound(new NBTTagCompound()); + } + + stack.stackTagCompound.setInteger("security", mode.ordinal()); + } + + @Override + public boolean hasSecurity(ItemStack stack) { + GeneratorType type = GeneratorType.getFromMetadata(stack.getItemDamage()); + + return type.hasModel; + } + + @Override + public boolean hasOwner(ItemStack stack) { + return hasSecurity(stack); + } } diff --git a/src/main/java/mekanism/generators/common/item/ItemBlockReactor.java b/src/main/java/mekanism/generators/common/item/ItemBlockReactor.java index 23c696e6d..a1b55e445 100644 --- a/src/main/java/mekanism/generators/common/item/ItemBlockReactor.java +++ b/src/main/java/mekanism/generators/common/item/ItemBlockReactor.java @@ -2,6 +2,8 @@ package mekanism.generators.common.item; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.EnumColor; import mekanism.common.util.LangUtils; import mekanism.common.util.MekanismUtils; @@ -11,53 +13,46 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; - import org.lwjgl.input.Keyboard; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; +public class ItemBlockReactor extends ItemBlock { + public Block metaBlock; -public class ItemBlockReactor extends ItemBlock -{ - public Block metaBlock; + public ItemBlockReactor(Block block) { + super(block); + metaBlock = block; + setHasSubtypes(true); + } - public ItemBlockReactor(Block block) - { - super(block); - metaBlock = block; - setHasSubtypes(true); - } + @Override + public int getMetadata(int i) { + return i; + } - @Override - public int getMetadata(int i) - { - return i; - } + @Override + public IIcon getIconFromDamage(int i) { + return metaBlock.getIcon(2, i); + } - @Override - public IIcon getIconFromDamage(int i) - { - return metaBlock.getIcon(2, i); - } + @Override + public String getUnlocalizedName(ItemStack itemstack) { + return getUnlocalizedName() + "." + ReactorBlockType.get(itemstack).name; + } - @Override - public String getUnlocalizedName(ItemStack itemstack) - { - return getUnlocalizedName() + "." + ReactorBlockType.get(itemstack).name; - } + @Override + @SideOnly(Side.CLIENT) + public void addInformation( + ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag + ) { + ReactorBlockType type = ReactorBlockType.get(itemstack); - @Override - @SideOnly(Side.CLIENT) - public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) - { - ReactorBlockType type = ReactorBlockType.get(itemstack); - - if(!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) - { - list.add(LangUtils.localize("tooltip.hold") + " " + EnumColor.INDIGO + "shift" + EnumColor.GREY + " " + LangUtils.localize("tooltip.forDetails") + "."); - } - else { - list.addAll(MekanismUtils.splitTooltip(type.getDescription(), itemstack)); - } - } + if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) { + list.add( + LangUtils.localize("tooltip.hold") + " " + EnumColor.INDIGO + "shift" + + EnumColor.GREY + " " + LangUtils.localize("tooltip.forDetails") + "." + ); + } else { + list.addAll(MekanismUtils.splitTooltip(type.getDescription(), itemstack)); + } + } } diff --git a/src/main/java/mekanism/generators/common/item/ItemHohlraum.java b/src/main/java/mekanism/generators/common/item/ItemHohlraum.java index f3282062f..02b645c0a 100644 --- a/src/main/java/mekanism/generators/common/item/ItemHohlraum.java +++ b/src/main/java/mekanism/generators/common/item/ItemHohlraum.java @@ -15,154 +15,151 @@ import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -public class ItemHohlraum extends ItemMekanism implements IGasItem -{ - public static final int MAX_GAS = 10; - public static final int TRANSFER_RATE = 1; - - public ItemHohlraum() - { - super(); - setMaxStackSize(1); - } - - @Override - public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) - { - GasStack gasStack = getGas(itemstack); +public class ItemHohlraum extends ItemMekanism implements IGasItem { + public static final int MAX_GAS = 10; + public static final int TRANSFER_RATE = 1; - if(gasStack == null) - { - list.add(LangUtils.localize("tooltip.noGas") + "."); - list.add(EnumColor.DARK_RED + LangUtils.localize("tooltip.insufficientFuel")); - } - else { - list.add(LangUtils.localize("tooltip.stored") + " " + gasStack.getGas().getLocalizedName() + ": " + gasStack.amount); - - if(gasStack.amount == getMaxGas(itemstack)) - { - list.add(EnumColor.DARK_GREEN + LangUtils.localize("tooltip.readyForReaction") + "!"); - } - else { - list.add(EnumColor.DARK_RED + LangUtils.localize("tooltip.insufficientFuel")); - } - } - } - - @Override - public int getMaxGas(ItemStack itemstack) - { - return MAX_GAS; - } + public ItemHohlraum() { + super(); + setMaxStackSize(1); + } - @Override - public int getRate(ItemStack itemstack) - { - return TRANSFER_RATE; - } + @Override + public void addInformation( + ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag + ) { + GasStack gasStack = getGas(itemstack); - @Override - public int addGas(ItemStack itemstack, GasStack stack) - { - if(getGas(itemstack) != null && getGas(itemstack).getGas() != stack.getGas()) - { - return 0; - } + if (gasStack == null) { + list.add(LangUtils.localize("tooltip.noGas") + "."); + list.add(EnumColor.DARK_RED + LangUtils.localize("tooltip.insufficientFuel")); + } else { + list.add( + LangUtils.localize("tooltip.stored") + " " + + gasStack.getGas().getLocalizedName() + ": " + gasStack.amount + ); - if(stack.getGas() != GasRegistry.getGas("fusionFuelDT")) - { - return 0; - } + if (gasStack.amount == getMaxGas(itemstack)) { + list.add( + EnumColor.DARK_GREEN + LangUtils.localize("tooltip.readyForReaction") + + "!" + ); + } else { + list.add( + EnumColor.DARK_RED + LangUtils.localize("tooltip.insufficientFuel") + ); + } + } + } - int toUse = Math.min(getMaxGas(itemstack)-getStored(itemstack), Math.min(getRate(itemstack), stack.amount)); - setGas(itemstack, new GasStack(stack.getGas(), getStored(itemstack)+toUse)); + @Override + public int getMaxGas(ItemStack itemstack) { + return MAX_GAS; + } - return toUse; - } + @Override + public int getRate(ItemStack itemstack) { + return TRANSFER_RATE; + } - @Override - public GasStack removeGas(ItemStack itemstack, int amount) - { - return null; - } + @Override + public int addGas(ItemStack itemstack, GasStack stack) { + if (getGas(itemstack) != null && getGas(itemstack).getGas() != stack.getGas()) { + return 0; + } - public int getStored(ItemStack itemstack) - { - return getGas(itemstack) != null ? getGas(itemstack).amount : 0; - } + if (stack.getGas() != GasRegistry.getGas("fusionFuelDT")) { + return 0; + } - @Override - public boolean canReceiveGas(ItemStack itemstack, Gas type) - { - return type == GasRegistry.getGas("fusionFuelDT"); - } + int toUse = Math.min( + getMaxGas(itemstack) - getStored(itemstack), + Math.min(getRate(itemstack), stack.amount) + ); + setGas(itemstack, new GasStack(stack.getGas(), getStored(itemstack) + toUse)); - @Override - public boolean canProvideGas(ItemStack itemstack, Gas type) - { - return false; - } + return toUse; + } - @Override - public GasStack getGas(ItemStack itemstack) - { - if(itemstack.stackTagCompound == null) - { - return null; - } + @Override + public GasStack removeGas(ItemStack itemstack, int amount) { + return null; + } - return GasStack.readFromNBT(itemstack.stackTagCompound.getCompoundTag("stored")); - } - - @Override - public boolean showDurabilityBar(ItemStack stack) - { - return true; - } - - @Override - public double getDurabilityForDisplay(ItemStack stack) - { - return 1D-((getGas(stack) != null ? (double)getGas(stack).amount : 0D)/(double)getMaxGas(stack)); - } + public int getStored(ItemStack itemstack) { + return getGas(itemstack) != null ? getGas(itemstack).amount : 0; + } - @Override - public void setGas(ItemStack itemstack, GasStack stack) - { - if(itemstack.stackTagCompound == null) - { - itemstack.setTagCompound(new NBTTagCompound()); - } + @Override + public boolean canReceiveGas(ItemStack itemstack, Gas type) { + return type == GasRegistry.getGas("fusionFuelDT"); + } - if(stack == null || stack.amount == 0) - { - itemstack.stackTagCompound.removeTag("stored"); - } - else { - int amount = Math.max(0, Math.min(stack.amount, getMaxGas(itemstack))); - GasStack gasStack = new GasStack(stack.getGas(), amount); + @Override + public boolean canProvideGas(ItemStack itemstack, Gas type) { + return false; + } - itemstack.stackTagCompound.setTag("stored", gasStack.write(new NBTTagCompound())); - } - } + @Override + public GasStack getGas(ItemStack itemstack) { + if (itemstack.stackTagCompound == null) { + return null; + } - public ItemStack getEmptyItem() - { - ItemStack stack = new ItemStack(this); - setGas(stack, null); - - return stack; - } + return GasStack.readFromNBT(itemstack.stackTagCompound.getCompoundTag("stored")); + } - @Override - public void getSubItems(Item item, CreativeTabs tabs, List list) - { - ItemStack empty = new ItemStack(this); - setGas(empty, null); - list.add(empty); + @Override + public boolean showDurabilityBar(ItemStack stack) { + return true; + } - ItemStack filled = new ItemStack(this); - setGas(filled, new GasStack(GasRegistry.getGas("fusionFuelDT"), ((IGasItem)filled.getItem()).getMaxGas(filled))); - list.add(filled); - } + @Override + public double getDurabilityForDisplay(ItemStack stack) { + return 1D + - ((getGas(stack) != null ? (double) getGas(stack).amount : 0D) + / (double) getMaxGas(stack)); + } + + @Override + public void setGas(ItemStack itemstack, GasStack stack) { + if (itemstack.stackTagCompound == null) { + itemstack.setTagCompound(new NBTTagCompound()); + } + + if (stack == null || stack.amount == 0) { + itemstack.stackTagCompound.removeTag("stored"); + } else { + int amount = Math.max(0, Math.min(stack.amount, getMaxGas(itemstack))); + GasStack gasStack = new GasStack(stack.getGas(), amount); + + itemstack.stackTagCompound.setTag( + "stored", gasStack.write(new NBTTagCompound()) + ); + } + } + + public ItemStack getEmptyItem() { + ItemStack stack = new ItemStack(this); + setGas(stack, null); + + return stack; + } + + @Override + public void getSubItems(Item item, CreativeTabs tabs, List list) { + ItemStack empty = new ItemStack(this); + setGas(empty, null); + list.add(empty); + + ItemStack filled = new ItemStack(this); + setGas( + filled, + new GasStack( + GasRegistry.getGas("fusionFuelDT"), + ((IGasItem) filled.getItem()).getMaxGas(filled) + ) + ); + list.add(filled); + } } diff --git a/src/main/java/mekanism/generators/common/tile/TileEntityAdvancedSolarGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntityAdvancedSolarGenerator.java index f3b8c80a8..6c9564eb5 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntityAdvancedSolarGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntityAdvancedSolarGenerator.java @@ -9,54 +9,55 @@ import mekanism.common.base.IBoundingBlock; import mekanism.common.util.MekanismUtils; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityAdvancedSolarGenerator extends TileEntitySolarGenerator implements IBoundingBlock, IEvaporationSolar -{ - public TileEntityAdvancedSolarGenerator() - { - super("AdvancedSolarGenerator", 200000, generators.advancedSolarGeneration*2); - GENERATION_RATE = generators.advancedSolarGeneration; - } +public class TileEntityAdvancedSolarGenerator + extends TileEntitySolarGenerator implements IBoundingBlock, IEvaporationSolar { + public TileEntityAdvancedSolarGenerator() { + super("AdvancedSolarGenerator", 200000, generators.advancedSolarGeneration * 2); + GENERATION_RATE = generators.advancedSolarGeneration; + } - @Override - public EnumSet getOutputtingSides() - { - return EnumSet.of(ForgeDirection.getOrientation(facing)); - } + @Override + public EnumSet getOutputtingSides() { + return EnumSet.of(ForgeDirection.getOrientation(facing)); + } - @Override - public void onPlace() - { - MekanismUtils.makeBoundingBlock(worldObj, new Coord4D(xCoord, yCoord+1, zCoord, worldObj.provider.dimensionId), Coord4D.get(this)); + @Override + public void onPlace() { + MekanismUtils.makeBoundingBlock( + worldObj, + new Coord4D(xCoord, yCoord + 1, zCoord, worldObj.provider.dimensionId), + Coord4D.get(this) + ); - for(int x = -1; x <= 1; x++) - { - for(int z = -1; z <= 1; z++) - { - MekanismUtils.makeBoundingBlock(worldObj, new Coord4D(xCoord+x, yCoord+2, zCoord+z, worldObj.provider.dimensionId), Coord4D.get(this)); - } - } - } + for (int x = -1; x <= 1; x++) { + for (int z = -1; z <= 1; z++) { + MekanismUtils.makeBoundingBlock( + worldObj, + new Coord4D( + xCoord + x, yCoord + 2, zCoord + z, worldObj.provider.dimensionId + ), + Coord4D.get(this) + ); + } + } + } - @Override - public void onBreak() - { - worldObj.setBlockToAir(xCoord, yCoord+1, zCoord); + @Override + public void onBreak() { + worldObj.setBlockToAir(xCoord, yCoord + 1, zCoord); - for(int x = -1; x <= 1; x++) - { - for(int z = -1; z <= 1; z++) - { - worldObj.setBlockToAir(xCoord+x, yCoord+2, zCoord+z); - } - } + for (int x = -1; x <= 1; x++) { + for (int z = -1; z <= 1; z++) { + worldObj.setBlockToAir(xCoord + x, yCoord + 2, zCoord + z); + } + } - invalidate(); - worldObj.setBlockToAir(xCoord, yCoord, zCoord); - } + invalidate(); + worldObj.setBlockToAir(xCoord, yCoord, zCoord); + } - @Override - public boolean seesSun() - { - return seesSun; - } + @Override + public boolean seesSun() { + return seesSun; + } } diff --git a/src/main/java/mekanism/generators/common/tile/TileEntityBioGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntityBioGenerator.java index f1f4be7b0..d2df3fa43 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntityBioGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntityBioGenerator.java @@ -1,9 +1,8 @@ package mekanism.generators.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import io.netty.buffer.ByteBuf; import mekanism.api.MekanismConfig.generators; import mekanism.common.FluidSlot; import mekanism.common.MekanismItems; @@ -20,300 +19,259 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; -public class TileEntityBioGenerator extends TileEntityGenerator implements IFluidHandler, ISustainedData -{ - /** The FluidSlot biofuel instance for this generator. */ - public FluidSlot bioFuelSlot = new FluidSlot(24000, -1); +public class TileEntityBioGenerator + extends TileEntityGenerator implements IFluidHandler, ISustainedData { + /** The FluidSlot biofuel instance for this generator. */ + public FluidSlot bioFuelSlot = new FluidSlot(24000, -1); - public TileEntityBioGenerator() - { - super("bio", "BioGenerator", 160000, generators.bioGeneration*2); - inventory = new ItemStack[2]; - } + public TileEntityBioGenerator() { + super("bio", "BioGenerator", 160000, generators.bioGeneration * 2); + inventory = new ItemStack[2]; + } - @Override - public void onUpdate() - { - super.onUpdate(); + @Override + public void onUpdate() { + super.onUpdate(); - if(inventory[0] != null) - { - ChargeUtils.charge(1, this); - - FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(inventory[0]); + if (inventory[0] != null) { + ChargeUtils.charge(1, this); - if(fluid != null && FluidRegistry.isFluidRegistered("bioethanol")) - { - if(fluid.getFluid() == FluidRegistry.getFluid("bioethanol")) - { - int fluidToAdd = fluid.amount; + FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(inventory[0]); - if(bioFuelSlot.fluidStored+fluidToAdd <= bioFuelSlot.MAX_FLUID) - { - bioFuelSlot.setFluid(bioFuelSlot.fluidStored+fluidToAdd); + if (fluid != null && FluidRegistry.isFluidRegistered("bioethanol")) { + if (fluid.getFluid() == FluidRegistry.getFluid("bioethanol")) { + int fluidToAdd = fluid.amount; - if(inventory[0].getItem().getContainerItem(inventory[0]) != null) - { - inventory[0] = inventory[0].getItem().getContainerItem(inventory[0]); - } - else { - inventory[0].stackSize--; - } + if (bioFuelSlot.fluidStored + fluidToAdd <= bioFuelSlot.MAX_FLUID) { + bioFuelSlot.setFluid(bioFuelSlot.fluidStored + fluidToAdd); - if(inventory[0].stackSize == 0) - { - inventory[0] = null; - } - } - } - } - else { - int fuel = getFuel(inventory[0]); - ItemStack prevStack = inventory[0].copy(); + if (inventory[0].getItem().getContainerItem(inventory[0]) + != null) { + inventory[0] + = inventory[0].getItem().getContainerItem(inventory[0]); + } else { + inventory[0].stackSize--; + } - if(fuel > 0) - { - int fuelNeeded = bioFuelSlot.MAX_FLUID - bioFuelSlot.fluidStored; + if (inventory[0].stackSize == 0) { + inventory[0] = null; + } + } + } + } else { + int fuel = getFuel(inventory[0]); + ItemStack prevStack = inventory[0].copy(); - if(fuel <= fuelNeeded) - { - bioFuelSlot.fluidStored += fuel; + if (fuel > 0) { + int fuelNeeded = bioFuelSlot.MAX_FLUID - bioFuelSlot.fluidStored; - if(inventory[0].getItem().getContainerItem(inventory[0]) != null) - { - inventory[0] = inventory[0].getItem().getContainerItem(inventory[0]); - } - else { - inventory[0].stackSize--; - } + if (fuel <= fuelNeeded) { + bioFuelSlot.fluidStored += fuel; - if(inventory[0].stackSize == 0) - { - inventory[0] = null; - } - } - } - } - } + if (inventory[0].getItem().getContainerItem(inventory[0]) + != null) { + inventory[0] + = inventory[0].getItem().getContainerItem(inventory[0]); + } else { + inventory[0].stackSize--; + } - if(canOperate()) - { - if(!worldObj.isRemote) - { - setActive(true); - } + if (inventory[0].stackSize == 0) { + inventory[0] = null; + } + } + } + } + } - bioFuelSlot.setFluid(bioFuelSlot.fluidStored - 1); - setEnergy(electricityStored + generators.bioGeneration); - } - else { - if(!worldObj.isRemote) - { - setActive(false); - } - } - } + if (canOperate()) { + if (!worldObj.isRemote) { + setActive(true); + } - @Override - public boolean isItemValidForSlot(int slotID, ItemStack itemstack) - { - if(slotID == 0) - { - if(getFuel(itemstack ) > 0) - { - return true; - } - else { - if(FluidRegistry.isFluidRegistered("bioethanol")) - { - if(FluidContainerRegistry.getFluidForFilledItem(itemstack) != null) - { - if(FluidContainerRegistry.getFluidForFilledItem(itemstack).getFluid() == FluidRegistry.getFluid("bioethanol")) - { - return true; - } - } - } + bioFuelSlot.setFluid(bioFuelSlot.fluidStored - 1); + setEnergy(electricityStored + generators.bioGeneration); + } else { + if (!worldObj.isRemote) { + setActive(false); + } + } + } - return false; - } - } - else if(slotID == 1) - { - return ChargeUtils.canBeCharged(itemstack); - } + @Override + public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { + if (slotID == 0) { + if (getFuel(itemstack) > 0) { + return true; + } else { + if (FluidRegistry.isFluidRegistered("bioethanol")) { + if (FluidContainerRegistry.getFluidForFilledItem(itemstack) != null) { + if (FluidContainerRegistry.getFluidForFilledItem(itemstack) + .getFluid() + == FluidRegistry.getFluid("bioethanol")) { + return true; + } + } + } - return true; - } + return false; + } + } else if (slotID == 1) { + return ChargeUtils.canBeCharged(itemstack); + } - @Override - public boolean canOperate() - { - return electricityStored < BASE_MAX_ENERGY && bioFuelSlot.fluidStored > 0 && MekanismUtils.canFunction(this); - } + return true; + } - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); + @Override + public boolean canOperate() { + return electricityStored < BASE_MAX_ENERGY && bioFuelSlot.fluidStored > 0 + && MekanismUtils.canFunction(this); + } - bioFuelSlot.fluidStored = nbtTags.getInteger("bioFuelStored"); - } + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); + bioFuelSlot.fluidStored = nbtTags.getInteger("bioFuelStored"); + } - nbtTags.setInteger("bioFuelStored", bioFuelSlot.fluidStored); - } + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); - public int getFuel(ItemStack itemstack) - { - return itemstack.getItem() == MekanismItems.BioFuel ? 200 : 0; - } + nbtTags.setInteger("bioFuelStored", bioFuelSlot.fluidStored); + } - /** - * Gets the scaled fuel level for the GUI. - * @param i - multiplier - * @return - */ - public int getScaledFuelLevel(int i) - { - return bioFuelSlot.fluidStored*i / bioFuelSlot.MAX_FLUID; - } + public int getFuel(ItemStack itemstack) { + return itemstack.getItem() == MekanismItems.BioFuel ? 200 : 0; + } - @Override - public int[] getAccessibleSlotsFromSide(int side) - { - return ForgeDirection.getOrientation(side) == MekanismUtils.getRight(facing) ? new int[] {1} : new int[] {0}; - } + /** + * Gets the scaled fuel level for the GUI. + * @param i - multiplier + * @return + */ + public int getScaledFuelLevel(int i) { + return bioFuelSlot.fluidStored * i / bioFuelSlot.MAX_FLUID; + } - @Override - public boolean canSetFacing(int facing) - { - return facing != 0 && facing != 1; - } + @Override + public int[] getAccessibleSlotsFromSide(int side) { + return ForgeDirection.getOrientation(side) == MekanismUtils.getRight(facing) + ? new int[] { 1 } + : new int[] { 0 }; + } - @Override - public void handlePacketData(ByteBuf dataStream) - { - super.handlePacketData(dataStream); - - if(worldObj.isRemote) - { - bioFuelSlot.fluidStored = dataStream.readInt(); - } - } + @Override + public boolean canSetFacing(int facing) { + return facing != 0 && facing != 1; + } - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); - data.add(bioFuelSlot.fluidStored); - return data; - } + @Override + public void handlePacketData(ByteBuf dataStream) { + super.handlePacketData(dataStream); - private static final String[] methods = new String[] {"getEnergy", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getBioFuel", "getBioFuelNeeded"}; + if (worldObj.isRemote) { + bioFuelSlot.fluidStored = dataStream.readInt(); + } + } - @Override - public String[] getMethods() - { - return methods; - } + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); + data.add(bioFuelSlot.fluidStored); + return data; + } - @Override - public Object[] invoke(int method, Object[] arguments) throws Exception - { - switch(method) - { - case 0: - return new Object[] {electricityStored}; - case 1: - return new Object[] {output}; - case 2: - return new Object[] {BASE_MAX_ENERGY}; - case 3: - return new Object[] {(BASE_MAX_ENERGY -electricityStored)}; - case 4: - return new Object[] {bioFuelSlot.fluidStored}; - case 5: - return new Object[] {bioFuelSlot.MAX_FLUID-bioFuelSlot.fluidStored}; - default: - throw new NoSuchMethodException(); - } - } + private static final String[] methods + = new String[] { "getEnergy", "getOutput", "getMaxEnergy", + "getEnergyNeeded", "getBioFuel", "getBioFuelNeeded" }; - @Override - public int fill(ForgeDirection from, FluidStack resource, boolean doFill) - { - if(FluidRegistry.isFluidRegistered("bioethanol") && from != ForgeDirection.getOrientation(facing)) - { - if(resource.getFluid() == FluidRegistry.getFluid("bioethanol")) - { - int fuelTransfer = 0; - int fuelNeeded = bioFuelSlot.MAX_FLUID - bioFuelSlot.fluidStored; - int attemptTransfer = resource.amount; + @Override + public String[] getMethods() { + return methods; + } - if(attemptTransfer <= fuelNeeded) - { - fuelTransfer = attemptTransfer; - } - else { - fuelTransfer = fuelNeeded; - } + @Override + public Object[] invoke(int method, Object[] arguments) throws Exception { + switch (method) { + case 0: + return new Object[] { electricityStored }; + case 1: + return new Object[] { output }; + case 2: + return new Object[] { BASE_MAX_ENERGY }; + case 3: + return new Object[] { (BASE_MAX_ENERGY - electricityStored) }; + case 4: + return new Object[] { bioFuelSlot.fluidStored }; + case 5: + return new Object[] { bioFuelSlot.MAX_FLUID - bioFuelSlot.fluidStored }; + default: + throw new NoSuchMethodException(); + } + } - if(doFill) - { - bioFuelSlot.setFluid(bioFuelSlot.fluidStored + fuelTransfer); - } + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { + if (FluidRegistry.isFluidRegistered("bioethanol") + && from != ForgeDirection.getOrientation(facing)) { + if (resource.getFluid() == FluidRegistry.getFluid("bioethanol")) { + int fuelTransfer = 0; + int fuelNeeded = bioFuelSlot.MAX_FLUID - bioFuelSlot.fluidStored; + int attemptTransfer = resource.amount; - return fuelTransfer; - } - } + if (attemptTransfer <= fuelNeeded) { + fuelTransfer = attemptTransfer; + } else { + fuelTransfer = fuelNeeded; + } - return 0; - } + if (doFill) { + bioFuelSlot.setFluid(bioFuelSlot.fluidStored + fuelTransfer); + } - @Override - public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) - { - return null; - } + return fuelTransfer; + } + } - @Override - public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) - { - return null; - } + return 0; + } - @Override - public boolean canFill(ForgeDirection from, Fluid fluid) - { - return FluidRegistry.isFluidRegistered("bioethanol") && fluid == FluidRegistry.getFluid("bioethanol"); - } + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { + return null; + } - @Override - public boolean canDrain(ForgeDirection from, Fluid fluid) - { - return false; - } + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + return null; + } - @Override - public FluidTankInfo[] getTankInfo(ForgeDirection from) - { - return null; - } + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + return FluidRegistry.isFluidRegistered("bioethanol") + && fluid == FluidRegistry.getFluid("bioethanol"); + } - @Override - public void writeSustainedData(ItemStack itemStack) - { - itemStack.stackTagCompound.setInteger("fluidStored", bioFuelSlot.fluidStored); - } + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + return false; + } - @Override - public void readSustainedData(ItemStack itemStack) - { - bioFuelSlot.setFluid(itemStack.stackTagCompound.getInteger("fluidStored")); - } + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection from) { + return null; + } + + @Override + public void writeSustainedData(ItemStack itemStack) { + itemStack.stackTagCompound.setInteger("fluidStored", bioFuelSlot.fluidStored); + } + + @Override + public void readSustainedData(ItemStack itemStack) { + bioFuelSlot.setFluid(itemStack.stackTagCompound.getInteger("fluidStored")); + } } \ No newline at end of file diff --git a/src/main/java/mekanism/generators/common/tile/TileEntityGasGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntityGasGenerator.java index 80e73d10f..b3ce8d6d1 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntityGasGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntityGasGenerator.java @@ -1,9 +1,8 @@ package mekanism.generators.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import io.netty.buffer.ByteBuf; import mekanism.api.MekanismConfig.general; import mekanism.api.gas.Gas; import mekanism.api.gas.GasRegistry; @@ -22,362 +21,337 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityGasGenerator extends TileEntityGenerator implements IGasHandler, ITubeConnection, ISustainedData -{ - /** The maximum amount of gas this block can store. */ - public int MAX_GAS = 18000; +public class TileEntityGasGenerator + extends TileEntityGenerator implements IGasHandler, ITubeConnection, ISustainedData { + /** The maximum amount of gas this block can store. */ + public int MAX_GAS = 18000; - /** The tank this block is storing fuel in. */ - public GasTank fuelTank; + /** The tank this block is storing fuel in. */ + public GasTank fuelTank; - public int burnTicks = 0; - public int maxBurnTicks; - public double generationRate = 0; - - public int clientUsed; + public int burnTicks = 0; + public int maxBurnTicks; + public double generationRate = 0; - public TileEntityGasGenerator() - { - super("gas", "GasGenerator", general.FROM_H2*100, general.FROM_H2*2); - inventory = new ItemStack[2]; - fuelTank = new GasTank(MAX_GAS); - } + public int clientUsed; - @Override - public void onUpdate() - { - super.onUpdate(); - - if(!worldObj.isRemote) - { - ChargeUtils.charge(1, this); + public TileEntityGasGenerator() { + super("gas", "GasGenerator", general.FROM_H2 * 100, general.FROM_H2 * 2); + inventory = new ItemStack[2]; + fuelTank = new GasTank(MAX_GAS); + } - if(inventory[0] != null && fuelTank.getStored() < MAX_GAS) - { - Gas gasType = null; - - if(fuelTank.getGas() != null) - { - gasType = fuelTank.getGas().getGas(); - } - else if(inventory[0] != null && inventory[0].getItem() instanceof IGasItem) - { - if(((IGasItem)inventory[0].getItem()).getGas(inventory[0]) != null) - { - gasType = ((IGasItem)inventory[0].getItem()).getGas(inventory[0]).getGas(); - } - } - - if(gasType != null && FuelHandler.getFuel(gasType) != null) - { - GasStack removed = GasTransmission.removeGas(inventory[0], gasType, fuelTank.getNeeded()); - boolean isTankEmpty = (fuelTank.getGas() == null); - - int fuelReceived = fuelTank.receive(removed, true); - - if(fuelReceived > 0 && isTankEmpty) - { - output = FuelHandler.getFuel(fuelTank.getGas().getGas()).energyPerTick * 2; - } - } - } - - boolean operate = canOperate(); - - if(operate && getEnergy()+generationRate < getMaxEnergy()) - { - setActive(true); - - FuelGas fuel = null; - - if(fuelTank.getStored() != 0) - { - fuel = FuelHandler.getFuel(fuelTank.getGas().getGas()); - maxBurnTicks = fuel.burnTicks; - generationRate = fuel.energyPerTick; - } - - int toUse = getToUse(); - - output = Math.max(general.FROM_H2*2, generationRate*getToUse()*2); - - int total = burnTicks + fuelTank.getStored()*maxBurnTicks; - total -= toUse; - - setEnergy(getEnergy() + generationRate*toUse); - - if(fuelTank.getStored() > 0) - { - fuelTank.setGas(new GasStack(fuelTank.getGasType(), total/maxBurnTicks)); - } - - burnTicks = total % maxBurnTicks; - clientUsed = toUse; - } - else { - if(!operate) - { - reset(); - } - - clientUsed = 0; - setActive(false); - } - } - } - - public void reset() - { - burnTicks = 0; - maxBurnTicks = 0; - generationRate = 0; - output = general.FROM_H2*2; - } - - public int getToUse() - { - if(generationRate == 0 || fuelTank.getGas() == null) - { - return 0; - } - - int max = (int)Math.ceil(((float)fuelTank.getStored()/(float)fuelTank.getMaxGas())*256F); - max = Math.min((fuelTank.getStored()*maxBurnTicks) + burnTicks, max); - max = (int)Math.min((getMaxEnergy()-getEnergy())/generationRate, max); - - return max; - } + @Override + public void onUpdate() { + super.onUpdate(); - @Override - public boolean canExtractItem(int slotID, ItemStack itemstack, int side) - { - if(slotID == 1) - { - return ChargeUtils.canBeOutputted(itemstack, true); - } - else if(slotID == 0) - { - return (itemstack.getItem() instanceof IGasItem && ((IGasItem)itemstack.getItem()).getGas(itemstack) == null); - } + if (!worldObj.isRemote) { + ChargeUtils.charge(1, this); - return false; - } + if (inventory[0] != null && fuelTank.getStored() < MAX_GAS) { + Gas gasType = null; - @Override - public boolean isItemValidForSlot(int slotID, ItemStack itemstack) - { - if(slotID == 0) - { - return itemstack.getItem() instanceof IGasItem && ((IGasItem)itemstack.getItem()).getGas(itemstack) != null && - FuelHandler.getFuel((((IGasItem)itemstack.getItem()).getGas(itemstack).getGas())) != null; - } - else if(slotID == 1) - { - return ChargeUtils.canBeCharged(itemstack); - } + if (fuelTank.getGas() != null) { + gasType = fuelTank.getGas().getGas(); + } else if (inventory[0] != null && inventory[0].getItem() instanceof IGasItem) { + if (((IGasItem) inventory[0].getItem()).getGas(inventory[0]) + != null) { + gasType = ((IGasItem) inventory[0].getItem()) + .getGas(inventory[0]) + .getGas(); + } + } - return true; - } + if (gasType != null && FuelHandler.getFuel(gasType) != null) { + GasStack removed = GasTransmission.removeGas( + inventory[0], gasType, fuelTank.getNeeded() + ); + boolean isTankEmpty = (fuelTank.getGas() == null); - @Override - public int[] getAccessibleSlotsFromSide(int side) - { - return ForgeDirection.getOrientation(side) == MekanismUtils.getRight(facing) ? new int[] {1} : new int[] {0}; - } + int fuelReceived = fuelTank.receive(removed, true); - @Override - public boolean canOperate() - { - return (fuelTank.getStored() > 0 || burnTicks > 0) && MekanismUtils.canFunction(this); - } + if (fuelReceived > 0 && isTankEmpty) { + output = FuelHandler.getFuel(fuelTank.getGas().getGas()) + .energyPerTick + * 2; + } + } + } - /** - * Gets the scaled gas level for the GUI. - * @param i - multiplier - * @return - */ - public int getScaledGasLevel(int i) - { - return fuelTank.getStored()*i / MAX_GAS; - } + boolean operate = canOperate(); - private static final String[] methods = new String[] {"getEnergy", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getGas", "getGasNeeded"}; + if (operate && getEnergy() + generationRate < getMaxEnergy()) { + setActive(true); - @Override - public String[] getMethods() - { - return methods; - } + FuelGas fuel = null; - @Override - public Object[] invoke(int method, Object[] arguments) throws Exception - { - switch(method) - { - case 0: - return new Object[] {getEnergy()}; - case 1: - return new Object[] {output}; - case 2: - return new Object[] {getMaxEnergy()}; - case 3: - return new Object[] {getMaxEnergy()-getEnergy()}; - case 4: - return new Object[] {fuelTank.getStored()}; - case 5: - return new Object[] {fuelTank.getNeeded()}; - default: - throw new NoSuchMethodException(); - } - } + if (fuelTank.getStored() != 0) { + fuel = FuelHandler.getFuel(fuelTank.getGas().getGas()); + maxBurnTicks = fuel.burnTicks; + generationRate = fuel.energyPerTick; + } - @Override - public void handlePacketData(ByteBuf dataStream) - { - super.handlePacketData(dataStream); - - if(worldObj.isRemote) - { - if(dataStream.readBoolean()) - { - fuelTank.setGas(new GasStack(GasRegistry.getGas(dataStream.readInt()), dataStream.readInt())); - } - else { - fuelTank.setGas(null); - } - - generationRate = dataStream.readDouble(); - output = dataStream.readDouble(); - clientUsed = dataStream.readInt(); - } - } + int toUse = getToUse(); - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); - - if(fuelTank.getGas() != null) - { - data.add(true); - data.add(fuelTank.getGas().getGas().getID()); - data.add(fuelTank.getStored()); - } - else { - data.add(false); - } - - data.add(generationRate); - data.add(output); - data.add(clientUsed); - - return data; - } + output = Math.max(general.FROM_H2 * 2, generationRate * getToUse() * 2); - @Override - public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) - { - boolean isTankEmpty = (fuelTank.getGas() == null); - - if(canReceiveGas(side, stack.getGas()) && (isTankEmpty || fuelTank.getGas().isGasEqual(stack))) - { - int fuelReceived = fuelTank.receive(stack, doTransfer); - - if(doTransfer && isTankEmpty && fuelReceived > 0) - { - output = FuelHandler.getFuel(fuelTank.getGas().getGas()).energyPerTick*2; - } - - return fuelReceived; - } + int total = burnTicks + fuelTank.getStored() * maxBurnTicks; + total -= toUse; - return 0; - } + setEnergy(getEnergy() + generationRate * toUse); - @Override - public int receiveGas(ForgeDirection side, GasStack stack) - { - return receiveGas(side, stack, true); - } + if (fuelTank.getStored() > 0) { + fuelTank.setGas( + new GasStack(fuelTank.getGasType(), total / maxBurnTicks) + ); + } - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); + burnTicks = total % maxBurnTicks; + clientUsed = toUse; + } else { + if (!operate) { + reset(); + } - fuelTank.read(nbtTags.getCompoundTag("fuelTank")); - - boolean isTankEmpty = (fuelTank.getGas() == null); - FuelGas fuel = (isTankEmpty) ? null : FuelHandler.getFuel(fuelTank.getGas().getGas()); - - if(fuel != null) - { - output = fuel.energyPerTick * 2; - } - } + clientUsed = 0; + setActive(false); + } + } + } - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); + public void reset() { + burnTicks = 0; + maxBurnTicks = 0; + generationRate = 0; + output = general.FROM_H2 * 2; + } - nbtTags.setTag("fuelTank", fuelTank.write(new NBTTagCompound())); - } + public int getToUse() { + if (generationRate == 0 || fuelTank.getGas() == null) { + return 0; + } - @Override - public boolean canReceiveGas(ForgeDirection side, Gas type) - { - return FuelHandler.getFuel(type) != null && side != ForgeDirection.getOrientation(facing); - } + int max = (int + ) Math.ceil(((float) fuelTank.getStored() / (float) fuelTank.getMaxGas()) * 256F); + max = Math.min((fuelTank.getStored() * maxBurnTicks) + burnTicks, max); + max = (int) Math.min((getMaxEnergy() - getEnergy()) / generationRate, max); - @Override - public GasStack drawGas(ForgeDirection side, int amount, boolean doTransfer) - { - return null; - } + return max; + } - @Override - public GasStack drawGas(ForgeDirection side, int amount) - { - return drawGas(side, amount, true); - } + @Override + public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { + if (slotID == 1) { + return ChargeUtils.canBeOutputted(itemstack, true); + } else if (slotID == 0) { + return ( + itemstack.getItem() instanceof IGasItem + && ((IGasItem) itemstack.getItem()).getGas(itemstack) == null + ); + } - @Override - public boolean canDrawGas(ForgeDirection side, Gas type) - { - return false; - } + return false; + } - @Override - public boolean canTubeConnect(ForgeDirection side) - { - return side != ForgeDirection.getOrientation(facing); - } + @Override + public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { + if (slotID == 0) { + return itemstack.getItem() instanceof IGasItem + && ((IGasItem) itemstack.getItem()).getGas(itemstack) != null + && FuelHandler.getFuel( + (((IGasItem) itemstack.getItem()).getGas(itemstack).getGas()) + ) + != null; + } else if (slotID == 1) { + return ChargeUtils.canBeCharged(itemstack); + } - @Override - public void writeSustainedData(ItemStack itemStack) - { - if(fuelTank != null) - { - itemStack.stackTagCompound.setTag("fuelTank", fuelTank.write(new NBTTagCompound())); - } - } + return true; + } - @Override - public void readSustainedData(ItemStack itemStack) - { - if(itemStack.stackTagCompound.hasKey("fuelTank")) - { - fuelTank.read(itemStack.stackTagCompound.getCompoundTag("fuelTank")); - - boolean isTankEmpty = (fuelTank.getGas() == null); - //Update energy output based on any existing fuel in tank - FuelGas fuel = (isTankEmpty) ? null : FuelHandler.getFuel(fuelTank.getGas().getGas()); - - if(fuel != null) - { - output = fuel.energyPerTick * 2; - } - } - } + @Override + public int[] getAccessibleSlotsFromSide(int side) { + return ForgeDirection.getOrientation(side) == MekanismUtils.getRight(facing) + ? new int[] { 1 } + : new int[] { 0 }; + } + + @Override + public boolean canOperate() { + return (fuelTank.getStored() > 0 || burnTicks > 0) + && MekanismUtils.canFunction(this); + } + + /** + * Gets the scaled gas level for the GUI. + * @param i - multiplier + * @return + */ + public int getScaledGasLevel(int i) { + return fuelTank.getStored() * i / MAX_GAS; + } + + private static final String[] methods + = new String[] { "getEnergy", "getOutput", "getMaxEnergy", + "getEnergyNeeded", "getGas", "getGasNeeded" }; + + @Override + public String[] getMethods() { + return methods; + } + + @Override + public Object[] invoke(int method, Object[] arguments) throws Exception { + switch (method) { + case 0: + return new Object[] { getEnergy() }; + case 1: + return new Object[] { output }; + case 2: + return new Object[] { getMaxEnergy() }; + case 3: + return new Object[] { getMaxEnergy() - getEnergy() }; + case 4: + return new Object[] { fuelTank.getStored() }; + case 5: + return new Object[] { fuelTank.getNeeded() }; + default: + throw new NoSuchMethodException(); + } + } + + @Override + public void handlePacketData(ByteBuf dataStream) { + super.handlePacketData(dataStream); + + if (worldObj.isRemote) { + if (dataStream.readBoolean()) { + fuelTank.setGas(new GasStack( + GasRegistry.getGas(dataStream.readInt()), dataStream.readInt() + )); + } else { + fuelTank.setGas(null); + } + + generationRate = dataStream.readDouble(); + output = dataStream.readDouble(); + clientUsed = dataStream.readInt(); + } + } + + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); + + if (fuelTank.getGas() != null) { + data.add(true); + data.add(fuelTank.getGas().getGas().getID()); + data.add(fuelTank.getStored()); + } else { + data.add(false); + } + + data.add(generationRate); + data.add(output); + data.add(clientUsed); + + return data; + } + + @Override + public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) { + boolean isTankEmpty = (fuelTank.getGas() == null); + + if (canReceiveGas(side, stack.getGas()) + && (isTankEmpty || fuelTank.getGas().isGasEqual(stack))) { + int fuelReceived = fuelTank.receive(stack, doTransfer); + + if (doTransfer && isTankEmpty && fuelReceived > 0) { + output + = FuelHandler.getFuel(fuelTank.getGas().getGas()).energyPerTick * 2; + } + + return fuelReceived; + } + + return 0; + } + + @Override + public int receiveGas(ForgeDirection side, GasStack stack) { + return receiveGas(side, stack, true); + } + + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); + + fuelTank.read(nbtTags.getCompoundTag("fuelTank")); + + boolean isTankEmpty = (fuelTank.getGas() == null); + FuelGas fuel + = (isTankEmpty) ? null : FuelHandler.getFuel(fuelTank.getGas().getGas()); + + if (fuel != null) { + output = fuel.energyPerTick * 2; + } + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); + + nbtTags.setTag("fuelTank", fuelTank.write(new NBTTagCompound())); + } + + @Override + public boolean canReceiveGas(ForgeDirection side, Gas type) { + return FuelHandler.getFuel(type) != null + && side != ForgeDirection.getOrientation(facing); + } + + @Override + public GasStack drawGas(ForgeDirection side, int amount, boolean doTransfer) { + return null; + } + + @Override + public GasStack drawGas(ForgeDirection side, int amount) { + return drawGas(side, amount, true); + } + + @Override + public boolean canDrawGas(ForgeDirection side, Gas type) { + return false; + } + + @Override + public boolean canTubeConnect(ForgeDirection side) { + return side != ForgeDirection.getOrientation(facing); + } + + @Override + public void writeSustainedData(ItemStack itemStack) { + if (fuelTank != null) { + itemStack.stackTagCompound.setTag( + "fuelTank", fuelTank.write(new NBTTagCompound()) + ); + } + } + + @Override + public void readSustainedData(ItemStack itemStack) { + if (itemStack.stackTagCompound.hasKey("fuelTank")) { + fuelTank.read(itemStack.stackTagCompound.getCompoundTag("fuelTank")); + + boolean isTankEmpty = (fuelTank.getGas() == null); + //Update energy output based on any existing fuel in tank + FuelGas fuel + = (isTankEmpty) ? null : FuelHandler.getFuel(fuelTank.getGas().getGas()); + + if (fuel != null) { + output = fuel.energyPerTick * 2; + } + } + } } diff --git a/src/main/java/mekanism/generators/common/tile/TileEntityGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntityGenerator.java index 29fd06810..9c635fc9c 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntityGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntityGenerator.java @@ -1,10 +1,11 @@ package mekanism.generators.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.EnumSet; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.MekanismConfig.general; import mekanism.api.Range4D; @@ -23,217 +24,203 @@ import mekanism.common.util.MekanismUtils; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; import net.minecraftforge.common.util.ForgeDirection; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public abstract class TileEntityGenerator extends TileEntityNoisyElectricBlock implements IComputerIntegration, IActiveState, IHasSound, ISoundSource, IRedstoneControl, ISecurityTile -{ - /** Output per tick this generator can transfer. */ - public double output; +public abstract class TileEntityGenerator extends TileEntityNoisyElectricBlock + implements IComputerIntegration, IActiveState, IHasSound, ISoundSource, + IRedstoneControl, ISecurityTile { + /** Output per tick this generator can transfer. */ + public double output; - /** Whether or not this block is in it's active state. */ - public boolean isActive; + /** Whether or not this block is in it's active state. */ + public boolean isActive; - /** The client's current active state. */ - public boolean clientActive; + /** The client's current active state. */ + public boolean clientActive; - /** How many ticks must pass until this block's active state can sync with the client. */ - public int updateDelay; + /** + * How many ticks must pass until this block's active state can sync with the client. + */ + public int updateDelay; - /** This machine's current RedstoneControl type. */ - public RedstoneControl controlType; - - public TileComponentSecurity securityComponent = new TileComponentSecurity(this); + /** This machine's current RedstoneControl type. */ + public RedstoneControl controlType; - /** - * Generator -- a block that produces energy. It has a certain amount of fuel it can store as well as an output rate. - * @param name - full name of this generator - * @param maxEnergy - how much energy this generator can store - */ - public TileEntityGenerator(String soundPath, String name, double maxEnergy, double out) - { - super("gen." + soundPath, name, maxEnergy); + public TileComponentSecurity securityComponent = new TileComponentSecurity(this); - output = out; - isActive = false; - controlType = RedstoneControl.DISABLED; - } + /** + * Generator -- a block that produces energy. It has a certain amount of fuel it can + * store as well as an output rate. + * @param name - full name of this generator + * @param maxEnergy - how much energy this generator can store + */ + public TileEntityGenerator( + String soundPath, String name, double maxEnergy, double out + ) { + super("gen." + soundPath, name, maxEnergy); - @Override - public void onUpdate() - { - super.onUpdate(); + output = out; + isActive = false; + controlType = RedstoneControl.DISABLED; + } - if(worldObj.isRemote && updateDelay > 0) - { - updateDelay--; + @Override + public void onUpdate() { + super.onUpdate(); - if(updateDelay == 0 && clientActive != isActive) - { - isActive = clientActive; - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } + if (worldObj.isRemote && updateDelay > 0) { + updateDelay--; - if(!worldObj.isRemote) - { - if(updateDelay > 0) - { - updateDelay--; + if (updateDelay == 0 && clientActive != isActive) { + isActive = clientActive; + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } - if(updateDelay == 0 && clientActive != isActive) - { - clientActive = isActive; - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - } - } + if (!worldObj.isRemote) { + if (updateDelay > 0) { + updateDelay--; - if(MekanismUtils.canFunction(this)) - { - CableUtils.emit(this); - } - } - } + if (updateDelay == 0 && clientActive != isActive) { + clientActive = isActive; + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + } + } - @Override - public double getMaxOutput() - { - return output; - } + if (MekanismUtils.canFunction(this)) { + CableUtils.emit(this); + } + } + } - @Override - public EnumSet getConsumingSides() - { - return EnumSet.noneOf(ForgeDirection.class); - } + @Override + public double getMaxOutput() { + return output; + } - @Override - public EnumSet getOutputtingSides() - { - return EnumSet.of(ForgeDirection.getOrientation(facing)); - } + @Override + public EnumSet getConsumingSides() { + return EnumSet.noneOf(ForgeDirection.class); + } - /** - * Whether or not this generator can operate. - * @return if the generator can operate - */ - public abstract boolean canOperate(); + @Override + public EnumSet getOutputtingSides() { + return EnumSet.of(ForgeDirection.getOrientation(facing)); + } - @Override - public boolean getActive() - { - return isActive; - } + /** + * Whether or not this generator can operate. + * @return if the generator can operate + */ + public abstract boolean canOperate(); - @Override - public void setActive(boolean active) - { - isActive = active; + @Override + public boolean getActive() { + return isActive; + } - if(clientActive != active && updateDelay == 0) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); + @Override + public void setActive(boolean active) { + isActive = active; - updateDelay = general.UPDATE_DELAY; - clientActive = active; - } - } + if (clientActive != active && updateDelay == 0) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); - @Override - public boolean canSetFacing(int side) - { - return side != 0 && side != 1; - } + updateDelay = general.UPDATE_DELAY; + clientActive = active; + } + } - @Override - public void handlePacketData(ByteBuf dataStream) - { - super.handlePacketData(dataStream); + @Override + public boolean canSetFacing(int side) { + return side != 0 && side != 1; + } - if(worldObj.isRemote) - { - clientActive = dataStream.readBoolean(); - controlType = RedstoneControl.values()[dataStream.readInt()]; - - if(updateDelay == 0 && clientActive != isActive) - { - updateDelay = general.UPDATE_DELAY; - isActive = clientActive; - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } - } + @Override + public void handlePacketData(ByteBuf dataStream) { + super.handlePacketData(dataStream); - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); + if (worldObj.isRemote) { + clientActive = dataStream.readBoolean(); + controlType = RedstoneControl.values()[dataStream.readInt()]; - data.add(isActive); - data.add(controlType.ordinal()); + if (updateDelay == 0 && clientActive != isActive) { + updateDelay = general.UPDATE_DELAY; + isActive = clientActive; + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } + } - return data; - } + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); + data.add(isActive); + data.add(controlType.ordinal()); - isActive = nbtTags.getBoolean("isActive"); - controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; - } + return data; + } - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); - nbtTags.setBoolean("isActive", isActive); - nbtTags.setInteger("controlType", controlType.ordinal()); - } + isActive = nbtTags.getBoolean("isActive"); + controlType = RedstoneControl.values()[nbtTags.getInteger("controlType")]; + } - @Override - @SideOnly(Side.CLIENT) - public AxisAlignedBB getRenderBoundingBox() - { - return INFINITE_EXTENT_AABB; - } + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); - @Override - public boolean renderUpdate() - { - return true; - } + nbtTags.setBoolean("isActive", isActive); + nbtTags.setInteger("controlType", controlType.ordinal()); + } - @Override - public boolean lightUpdate() - { - return true; - } + @Override + @SideOnly(Side.CLIENT) + public AxisAlignedBB getRenderBoundingBox() { + return INFINITE_EXTENT_AABB; + } - @Override - public RedstoneControl getControlType() - { - return controlType; - } + @Override + public boolean renderUpdate() { + return true; + } - @Override - public void setControlType(RedstoneControl type) - { - controlType = type; - MekanismUtils.saveChunk(this); - } + @Override + public boolean lightUpdate() { + return true; + } - @Override - public boolean canPulse() - { - return false; - } - - @Override - public TileComponentSecurity getSecurity() - { - return securityComponent; - } + @Override + public RedstoneControl getControlType() { + return controlType; + } + + @Override + public void setControlType(RedstoneControl type) { + controlType = type; + MekanismUtils.saveChunk(this); + } + + @Override + public boolean canPulse() { + return false; + } + + @Override + public TileComponentSecurity getSecurity() { + return securityComponent; + } } diff --git a/src/main/java/mekanism/generators/common/tile/TileEntityHeatGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntityHeatGenerator.java index c9f580b11..027d543f2 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntityHeatGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntityHeatGenerator.java @@ -1,9 +1,8 @@ package mekanism.generators.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.IHeatTransfer; import mekanism.api.MekanismConfig.generators; @@ -30,441 +29,405 @@ import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidContainerItem; import net.minecraftforge.fluids.IFluidHandler; -public class TileEntityHeatGenerator extends TileEntityGenerator implements IFluidHandler, ISustainedData, IHeatTransfer -{ - /** The FluidTank for this generator. */ - public FluidTank lavaTank = new FluidTank(24000); +public class TileEntityHeatGenerator + extends TileEntityGenerator implements IFluidHandler, ISustainedData, IHeatTransfer { + /** The FluidTank for this generator. */ + public FluidTank lavaTank = new FluidTank(24000); - public double temperature = 0; + public double temperature = 0; - public double thermalEfficiency = 0.5D; + public double thermalEfficiency = 0.5D; - public double invHeatCapacity = 1; + public double invHeatCapacity = 1; - public double heatToAbsorb = 0; - - public double producingEnergy; - - public double lastTransferLoss; - public double lastEnvironmentLoss; + public double heatToAbsorb = 0; - public TileEntityHeatGenerator() - { - super("heat", "HeatGenerator", 160000, generators.heatGeneration*2); - inventory = new ItemStack[2]; - } + public double producingEnergy; - @Override - public void onUpdate() - { - super.onUpdate(); + public double lastTransferLoss; + public double lastEnvironmentLoss; - if(!worldObj.isRemote) - { - ChargeUtils.charge(1, this); + public TileEntityHeatGenerator() { + super("heat", "HeatGenerator", 160000, generators.heatGeneration * 2); + inventory = new ItemStack[2]; + } - if(inventory[0] != null) - { - FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(inventory[0]); - - if(inventory[0].getItem() instanceof IFluidContainerItem) - { - lavaTank.fill(FluidContainerUtils.extractFluid(lavaTank, inventory[0], FluidChecker.check(FluidRegistry.LAVA)), true); - } - else if(fluid != null) - { - if(fluid != null && fluid.getFluidID() == FluidRegistry.LAVA.getID()) - { - if(lavaTank.getFluid() == null || lavaTank.getFluid().amount+fluid.amount <= lavaTank.getCapacity()) - { - lavaTank.fill(fluid, true); - - if(inventory[0].getItem().getContainerItem(inventory[0]) != null) - { - inventory[0] = inventory[0].getItem().getContainerItem(inventory[0]); - } - else { - inventory[0].stackSize--; - } - - if(inventory[0].stackSize == 0) - { - inventory[0] = null; - } - } - } - } - else { - int fuel = getFuel(inventory[0]); + @Override + public void onUpdate() { + super.onUpdate(); - if(fuel > 0) - { - int fuelNeeded = lavaTank.getCapacity() - (lavaTank.getFluid() != null ? lavaTank.getFluid().amount : 0); + if (!worldObj.isRemote) { + ChargeUtils.charge(1, this); - if(fuel <= fuelNeeded) - { - lavaTank.fill(new FluidStack(FluidRegistry.LAVA, fuel), true); + if (inventory[0] != null) { + FluidStack fluid + = FluidContainerRegistry.getFluidForFilledItem(inventory[0]); - if(inventory[0].getItem().getContainerItem(inventory[0]) != null) - { - inventory[0] = inventory[0].getItem().getContainerItem(inventory[0]); - } - else { - inventory[0].stackSize--; - } + if (inventory[0].getItem() instanceof IFluidContainerItem) { + lavaTank.fill( + FluidContainerUtils.extractFluid( + lavaTank, inventory[0], FluidChecker.check(FluidRegistry.LAVA) + ), + true + ); + } else if (fluid != null) { + if (fluid != null + && fluid.getFluidID() == FluidRegistry.LAVA.getID()) { + if (lavaTank.getFluid() == null + || lavaTank.getFluid().amount + fluid.amount + <= lavaTank.getCapacity()) { + lavaTank.fill(fluid, true); - if(inventory[0].stackSize == 0) - { - inventory[0] = null; - } - } - } - } - } - - double prev = getEnergy(); + if (inventory[0].getItem().getContainerItem(inventory[0]) + != null) { + inventory[0] + = inventory[0].getItem().getContainerItem(inventory[0] + ); + } else { + inventory[0].stackSize--; + } - transferHeatTo(getBoost()); + if (inventory[0].stackSize == 0) { + inventory[0] = null; + } + } + } + } else { + int fuel = getFuel(inventory[0]); - if(canOperate()) - { - setActive(true); + if (fuel > 0) { + int fuelNeeded = lavaTank.getCapacity() + - (lavaTank.getFluid() != null ? lavaTank.getFluid().amount + : 0); - lavaTank.drain(generators.heatGenerationFluidRate, true); - transferHeatTo(generators.heatGeneration); - } - else { - setActive(false); - } - - double[] loss = simulateHeat(); - applyTemperatureChange(); - - lastTransferLoss = loss[0]; - lastEnvironmentLoss = loss[1]; - - producingEnergy = getEnergy()-prev; - } - } + if (fuel <= fuelNeeded) { + lavaTank.fill(new FluidStack(FluidRegistry.LAVA, fuel), true); - @Override - public boolean isItemValidForSlot(int slotID, ItemStack itemstack) - { - if(slotID == 0) - { - return getFuel(itemstack) > 0 || (FluidContainerRegistry.getFluidForFilledItem(itemstack) != null && FluidContainerRegistry.getFluidForFilledItem(itemstack).getFluidID() == FluidRegistry.LAVA.getID()); - } - else if(slotID == 1) - { - return ChargeUtils.canBeCharged(itemstack); - } + if (inventory[0].getItem().getContainerItem(inventory[0]) + != null) { + inventory[0] + = inventory[0].getItem().getContainerItem(inventory[0] + ); + } else { + inventory[0].stackSize--; + } - return true; - } + if (inventory[0].stackSize == 0) { + inventory[0] = null; + } + } + } + } + } - @Override - public boolean canOperate() - { - return electricityStored < BASE_MAX_ENERGY && lavaTank.getFluid() != null && lavaTank.getFluid().amount >= 10 && MekanismUtils.canFunction(this); - } + double prev = getEnergy(); - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); + transferHeatTo(getBoost()); - if(nbtTags.hasKey("lavaTank")) - { - lavaTank.readFromNBT(nbtTags.getCompoundTag("lavaTank")); - } - } + if (canOperate()) { + setActive(true); - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); + lavaTank.drain(generators.heatGenerationFluidRate, true); + transferHeatTo(generators.heatGeneration); + } else { + setActive(false); + } - if(lavaTank.getFluid() != null) - { - nbtTags.setTag("lavaTank", lavaTank.writeToNBT(new NBTTagCompound())); - } - } + double[] loss = simulateHeat(); + applyTemperatureChange(); - @Override - public boolean canExtractItem(int slotID, ItemStack itemstack, int side) - { - if(slotID == 1) - { - return ChargeUtils.canBeOutputted(itemstack, true); - } - else if(slotID == 0) - { - return FluidContainerRegistry.isEmptyContainer(itemstack); - } + lastTransferLoss = loss[0]; + lastEnvironmentLoss = loss[1]; - return false; - } + producingEnergy = getEnergy() - prev; + } + } - public double getBoost() - { - int lavaBoost = 0; - double netherBoost = 0D; + @Override + public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { + if (slotID == 0) { + return getFuel(itemstack) > 0 + || (FluidContainerRegistry.getFluidForFilledItem(itemstack) != null + && FluidContainerRegistry.getFluidForFilledItem(itemstack).getFluidID( + ) == FluidRegistry.LAVA.getID()); + } else if (slotID == 1) { + return ChargeUtils.canBeCharged(itemstack); + } - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - Coord4D coord = Coord4D.get(this).getFromSide(side); - - if(isLava(coord.xCoord, coord.yCoord, coord.zCoord)) - { - lavaBoost++; - } - } + return true; + } - if(worldObj.provider.dimensionId == -1) - { - netherBoost = generators.heatGenerationNether; - } + @Override + public boolean canOperate() { + return electricityStored < BASE_MAX_ENERGY && lavaTank.getFluid() != null + && lavaTank.getFluid().amount >= 10 && MekanismUtils.canFunction(this); + } - return (generators.heatGenerationLava * lavaBoost) + netherBoost; - } - - private boolean isLava(int x, int y, int z) - { - return worldObj.getBlock(x, y, z) == Blocks.lava; - } + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); - public int getFuel(ItemStack itemstack) - { - if(itemstack.getItem() == Items.lava_bucket) - { - return 1000; - } + if (nbtTags.hasKey("lavaTank")) { + lavaTank.readFromNBT(nbtTags.getCompoundTag("lavaTank")); + } + } - return TileEntityFurnace.getItemBurnTime(itemstack)/2; - } + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); - @Override - public int[] getAccessibleSlotsFromSide(int side) - { - return ForgeDirection.getOrientation(side) == MekanismUtils.getRight(facing) ? new int[] {1} : new int[] {0}; - } + if (lavaTank.getFluid() != null) { + nbtTags.setTag("lavaTank", lavaTank.writeToNBT(new NBTTagCompound())); + } + } - /** - * Gets the scaled fuel level for the GUI. - * @param i - multiplier - * @return - */ - public int getScaledFuelLevel(int i) - { - return (lavaTank.getFluid() != null ? lavaTank.getFluid().amount : 0)*i / lavaTank.getCapacity(); - } + @Override + public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { + if (slotID == 1) { + return ChargeUtils.canBeOutputted(itemstack, true); + } else if (slotID == 0) { + return FluidContainerRegistry.isEmptyContainer(itemstack); + } - @Override - public void handlePacketData(ByteBuf dataStream) - { - super.handlePacketData(dataStream); - - if(worldObj.isRemote) - { - producingEnergy = dataStream.readDouble(); - - lastTransferLoss = dataStream.readDouble(); - lastEnvironmentLoss = dataStream.readDouble(); - - int amount = dataStream.readInt(); - - if(amount != 0) - { - lavaTank.setFluid(new FluidStack(FluidRegistry.LAVA, amount)); - } - else { - lavaTank.setFluid(null); - } - } - } + return false; + } - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); - - data.add(producingEnergy); - - data.add(lastTransferLoss); - data.add(lastEnvironmentLoss); + public double getBoost() { + int lavaBoost = 0; + double netherBoost = 0D; - if(lavaTank.getFluid() != null) - { - data.add(lavaTank.getFluid().amount); - } - else { - data.add(0); - } + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + Coord4D coord = Coord4D.get(this).getFromSide(side); - return data; - } + if (isLava(coord.xCoord, coord.yCoord, coord.zCoord)) { + lavaBoost++; + } + } - private static final String[] methods = new String[] {"getEnergy", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getFuel", "getFuelNeeded"}; + if (worldObj.provider.dimensionId == -1) { + netherBoost = generators.heatGenerationNether; + } - @Override - public String[] getMethods() - { - return methods; - } + return (generators.heatGenerationLava * lavaBoost) + netherBoost; + } - @Override - public Object[] invoke(int method, Object[] arguments) throws Exception - { - switch(method) - { - case 0: - return new Object[] {electricityStored}; - case 1: - return new Object[] {output}; - case 2: - return new Object[] {BASE_MAX_ENERGY}; - case 3: - return new Object[] {(BASE_MAX_ENERGY -electricityStored)}; - case 4: - return new Object[] {lavaTank.getFluid() != null ? lavaTank.getFluid().amount : 0}; - case 5: - return new Object[] {lavaTank.getCapacity()-(lavaTank.getFluid() != null ? lavaTank.getFluid().amount : 0)}; - default: - throw new NoSuchMethodException(); - } - } + private boolean isLava(int x, int y, int z) { + return worldObj.getBlock(x, y, z) == Blocks.lava; + } - @Override - public int fill(ForgeDirection from, FluidStack resource, boolean doFill) - { - if(resource.getFluidID() == FluidRegistry.LAVA.getID() && from != ForgeDirection.getOrientation(facing)) - { - return lavaTank.fill(resource, doFill); - } + public int getFuel(ItemStack itemstack) { + if (itemstack.getItem() == Items.lava_bucket) { + return 1000; + } - return 0; - } + return TileEntityFurnace.getItemBurnTime(itemstack) / 2; + } - @Override - public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) - { - return null; - } + @Override + public int[] getAccessibleSlotsFromSide(int side) { + return ForgeDirection.getOrientation(side) == MekanismUtils.getRight(facing) + ? new int[] { 1 } + : new int[] { 0 }; + } - @Override - public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) - { - return null; - } + /** + * Gets the scaled fuel level for the GUI. + * @param i - multiplier + * @return + */ + public int getScaledFuelLevel(int i) { + return (lavaTank.getFluid() != null ? lavaTank.getFluid().amount : 0) * i + / lavaTank.getCapacity(); + } - @Override - public boolean canFill(ForgeDirection from, Fluid fluid) - { - return fluid == FluidRegistry.LAVA && from != ForgeDirection.getOrientation(facing); - } + @Override + public void handlePacketData(ByteBuf dataStream) { + super.handlePacketData(dataStream); - @Override - public boolean canDrain(ForgeDirection from, Fluid fluid) - { - return false; - } + if (worldObj.isRemote) { + producingEnergy = dataStream.readDouble(); - @Override - public FluidTankInfo[] getTankInfo(ForgeDirection from) - { - if(from == ForgeDirection.getOrientation(facing)) - { - return PipeUtils.EMPTY; - } - - return new FluidTankInfo[] {lavaTank.getInfo()}; - } + lastTransferLoss = dataStream.readDouble(); + lastEnvironmentLoss = dataStream.readDouble(); - @Override - public void writeSustainedData(ItemStack itemStack) - { - if(lavaTank.getFluid() != null) - { - itemStack.stackTagCompound.setTag("lavaTank", lavaTank.getFluid().writeToNBT(new NBTTagCompound())); - } - } + int amount = dataStream.readInt(); - @Override - public void readSustainedData(ItemStack itemStack) - { - lavaTank.setFluid(FluidStack.loadFluidStackFromNBT(itemStack.stackTagCompound.getCompoundTag("lavaTank"))); - } + if (amount != 0) { + lavaTank.setFluid(new FluidStack(FluidRegistry.LAVA, amount)); + } else { + lavaTank.setFluid(null); + } + } + } - @Override - public double getTemp() - { - return temperature; - } + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); - @Override - public double getInverseConductionCoefficient() - { - return 1; - } + data.add(producingEnergy); - @Override - public double getInsulationCoefficient(ForgeDirection side) - { - return canConnectHeat(side) ? 0 : 10000; - } + data.add(lastTransferLoss); + data.add(lastEnvironmentLoss); - @Override - public void transferHeatTo(double heat) - { - heatToAbsorb += heat; - } + if (lavaTank.getFluid() != null) { + data.add(lavaTank.getFluid().amount); + } else { + data.add(0); + } - @Override - public double[] simulateHeat() - { - if(getTemp() > 0) - { - double carnotEfficiency = getTemp() / (getTemp() + IHeatTransfer.AMBIENT_TEMP); - double heatLost = thermalEfficiency * getTemp(); - double workDone = heatLost * carnotEfficiency; - transferHeatTo(-heatLost); - setEnergy(getEnergy() + workDone); - } - - return HeatUtils.simulate(this); - } + return data; + } - @Override - public double applyTemperatureChange() - { - temperature += invHeatCapacity * heatToAbsorb; - heatToAbsorb = 0; - return temperature; - } + private static final String[] methods + = new String[] { "getEnergy", "getOutput", "getMaxEnergy", + "getEnergyNeeded", "getFuel", "getFuelNeeded" }; - @Override - public boolean canConnectHeat(ForgeDirection side) - { - if(generators.heatGenEnable == true){ - return side == ForgeDirection.DOWN; - }else { - return side == ForgeDirection.UNKNOWN; - } - } + @Override + public String[] getMethods() { + return methods; + } - @Override - public IHeatTransfer getAdjacent(ForgeDirection side) - { - if(canConnectHeat(side)) - { - TileEntity adj = Coord4D.get(this).getFromSide(side).getTileEntity(worldObj); - - if(adj instanceof IHeatTransfer) - { - return (IHeatTransfer)adj; - } - } - - return null; - } + @Override + public Object[] invoke(int method, Object[] arguments) throws Exception { + switch (method) { + case 0: + return new Object[] { electricityStored }; + case 1: + return new Object[] { output }; + case 2: + return new Object[] { BASE_MAX_ENERGY }; + case 3: + return new Object[] { (BASE_MAX_ENERGY - electricityStored) }; + case 4: + return new Object[] { lavaTank.getFluid() != null + ? lavaTank.getFluid().amount + : 0 }; + case 5: + return new Object[] { + lavaTank.getCapacity() + - (lavaTank.getFluid() != null ? lavaTank.getFluid().amount : 0) + }; + default: + throw new NoSuchMethodException(); + } + } + + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { + if (resource.getFluidID() == FluidRegistry.LAVA.getID() + && from != ForgeDirection.getOrientation(facing)) { + return lavaTank.fill(resource, doFill); + } + + return 0; + } + + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { + return null; + } + + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + return null; + } + + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + return fluid == FluidRegistry.LAVA + && from != ForgeDirection.getOrientation(facing); + } + + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + return false; + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection from) { + if (from == ForgeDirection.getOrientation(facing)) { + return PipeUtils.EMPTY; + } + + return new FluidTankInfo[] { lavaTank.getInfo() }; + } + + @Override + public void writeSustainedData(ItemStack itemStack) { + if (lavaTank.getFluid() != null) { + itemStack.stackTagCompound.setTag( + "lavaTank", lavaTank.getFluid().writeToNBT(new NBTTagCompound()) + ); + } + } + + @Override + public void readSustainedData(ItemStack itemStack) { + lavaTank.setFluid(FluidStack.loadFluidStackFromNBT( + itemStack.stackTagCompound.getCompoundTag("lavaTank") + )); + } + + @Override + public double getTemp() { + return temperature; + } + + @Override + public double getInverseConductionCoefficient() { + return 1; + } + + @Override + public double getInsulationCoefficient(ForgeDirection side) { + return canConnectHeat(side) ? 0 : 10000; + } + + @Override + public void transferHeatTo(double heat) { + heatToAbsorb += heat; + } + + @Override + public double[] simulateHeat() { + if (getTemp() > 0) { + double carnotEfficiency + = getTemp() / (getTemp() + IHeatTransfer.AMBIENT_TEMP); + double heatLost = thermalEfficiency * getTemp(); + double workDone = heatLost * carnotEfficiency; + transferHeatTo(-heatLost); + setEnergy(getEnergy() + workDone); + } + + return HeatUtils.simulate(this); + } + + @Override + public double applyTemperatureChange() { + temperature += invHeatCapacity * heatToAbsorb; + heatToAbsorb = 0; + return temperature; + } + + @Override + public boolean canConnectHeat(ForgeDirection side) { + if (generators.heatGenEnable == true) { + return side == ForgeDirection.DOWN; + } else { + return side == ForgeDirection.UNKNOWN; + } + } + + @Override + public IHeatTransfer getAdjacent(ForgeDirection side) { + if (canConnectHeat(side)) { + TileEntity adj = Coord4D.get(this).getFromSide(side).getTileEntity(worldObj); + + if (adj instanceof IHeatTransfer) { + return (IHeatTransfer) adj; + } + } + + return null; + } } diff --git a/src/main/java/mekanism/generators/common/tile/TileEntitySolarGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntitySolarGenerator.java index 098d32f23..ce25a15ec 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntitySolarGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntitySolarGenerator.java @@ -1,10 +1,11 @@ package mekanism.generators.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.EnumSet; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; import mekanism.api.MekanismConfig.generators; import mekanism.common.util.ChargeUtils; import mekanism.common.util.MekanismUtils; @@ -12,195 +13,171 @@ import micdoodle8.mods.galacticraft.api.world.ISolarLevel; import net.minecraft.item.ItemStack; import net.minecraft.world.biome.BiomeGenDesert; import net.minecraftforge.common.util.ForgeDirection; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class TileEntitySolarGenerator extends TileEntityGenerator -{ - /** Whether or not this generator sees the sun. */ - public boolean seesSun = false; +public class TileEntitySolarGenerator extends TileEntityGenerator { + /** Whether or not this generator sees the sun. */ + public boolean seesSun = false; - /** How fast this tile entity generates energy. */ - public double GENERATION_RATE; + /** How fast this tile entity generates energy. */ + public double GENERATION_RATE; - public TileEntitySolarGenerator() - { - this("SolarGenerator", 96000, generators.solarGeneration*2); - GENERATION_RATE = generators.solarGeneration; - } + public TileEntitySolarGenerator() { + this("SolarGenerator", 96000, generators.solarGeneration * 2); + GENERATION_RATE = generators.solarGeneration; + } - public TileEntitySolarGenerator(String name, double maxEnergy, double output) - { - super("solar", name, maxEnergy, output); - inventory = new ItemStack[1]; - } + public TileEntitySolarGenerator(String name, double maxEnergy, double output) { + super("solar", name, maxEnergy, output); + inventory = new ItemStack[1]; + } - @Override - public int[] getAccessibleSlotsFromSide(int side) - { - return new int[] {0}; - } + @Override + public int[] getAccessibleSlotsFromSide(int side) { + return new int[] { 0 }; + } - @Override - @SideOnly(Side.CLIENT) - public float getVolume() - { - return 0.05F*super.getVolume(); - } + @Override + @SideOnly(Side.CLIENT) + public float getVolume() { + return 0.05F * super.getVolume(); + } - @Override - public boolean canSetFacing(int facing) - { - return facing != 0 && facing != 1; - } + @Override + public boolean canSetFacing(int facing) { + return facing != 0 && facing != 1; + } - @Override - public void onUpdate() - { - super.onUpdate(); + @Override + public void onUpdate() { + super.onUpdate(); - if(!worldObj.isRemote) - { - ChargeUtils.charge(0, this); - - if(worldObj.isDaytime() && ((!worldObj.isRaining() && !worldObj.isThundering()) || isDesert()) && !worldObj.provider.hasNoSky && worldObj.canBlockSeeTheSky(xCoord, yCoord+1, zCoord)) - { - seesSun = true; - } - else { - seesSun = false; - } + if (!worldObj.isRemote) { + ChargeUtils.charge(0, this); - if(canOperate()) - { - setActive(true); - setEnergy(getEnergy() + getProduction()); - } - else { - setActive(false); - } - } - } + if (worldObj.isDaytime() + && ((!worldObj.isRaining() && !worldObj.isThundering()) || isDesert()) + && !worldObj.provider.hasNoSky + && worldObj.canBlockSeeTheSky(xCoord, yCoord + 1, zCoord)) { + seesSun = true; + } else { + seesSun = false; + } - public boolean isDesert() - { - return worldObj.provider.getBiomeGenForCoords(xCoord, zCoord).getBiomeClass() == BiomeGenDesert.class; - } + if (canOperate()) { + setActive(true); + setEnergy(getEnergy() + getProduction()); + } else { + setActive(false); + } + } + } - @Override - public boolean canExtractItem(int slotID, ItemStack itemstack, int side) - { - if(slotID == 0) - { - return ChargeUtils.canBeOutputted(itemstack, true); - } + public boolean isDesert() { + return worldObj.provider.getBiomeGenForCoords(xCoord, zCoord).getBiomeClass() + == BiomeGenDesert.class; + } - return false; - } + @Override + public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { + if (slotID == 0) { + return ChargeUtils.canBeOutputted(itemstack, true); + } - @Override - public boolean isItemValidForSlot(int slotID, ItemStack itemstack) - { - if(slotID == 0) - { - return ChargeUtils.canBeCharged(itemstack); - } + return false; + } - return true; - } + @Override + public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { + if (slotID == 0) { + return ChargeUtils.canBeCharged(itemstack); + } - @Override - public boolean canOperate() - { - return getEnergy() < getMaxEnergy() && seesSun && MekanismUtils.canFunction(this); - } + return true; + } - public double getProduction() - { - double ret = 0; + @Override + public boolean canOperate() { + return getEnergy() < getMaxEnergy() && seesSun && MekanismUtils.canFunction(this); + } - if(seesSun) - { - ret = GENERATION_RATE; + public double getProduction() { + double ret = 0; - if(MekanismUtils.existsAndInstance(worldObj.provider, "micdoodle8.mods.galacticraft.api.world.ISolarLevel")) - { - ret *= ((ISolarLevel)worldObj.provider).getSolarEnergyMultiplier(); - } + if (seesSun) { + ret = GENERATION_RATE; - if(isDesert()) - { - ret *= 1.5; - } + if (MekanismUtils.existsAndInstance( + worldObj.provider, + "micdoodle8.mods.galacticraft.api.world.ISolarLevel" + )) { + ret *= ((ISolarLevel) worldObj.provider).getSolarEnergyMultiplier(); + } - return ret; - } + if (isDesert()) { + ret *= 1.5; + } - return 0; - } + return ret; + } - private static final String[] methods = new String[] {"getEnergy", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getSeesSun"}; + return 0; + } - @Override - public String[] getMethods() - { - return methods; - } + private static final String[] methods = new String[] { + "getEnergy", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getSeesSun" + }; - @Override - public Object[] invoke(int method, Object[] arguments) throws Exception - { - switch(method) - { - case 0: - return new Object[] {electricityStored}; - case 1: - return new Object[] {output}; - case 2: - return new Object[] {BASE_MAX_ENERGY}; - case 3: - return new Object[] {(BASE_MAX_ENERGY -electricityStored)}; - case 4: - return new Object[] {seesSun}; - default: - throw new NoSuchMethodException(); - } - } + @Override + public String[] getMethods() { + return methods; + } - @Override - public void handlePacketData(ByteBuf dataStream) - { - super.handlePacketData(dataStream); - - if(worldObj.isRemote) - { - seesSun = dataStream.readBoolean(); - } - } + @Override + public Object[] invoke(int method, Object[] arguments) throws Exception { + switch (method) { + case 0: + return new Object[] { electricityStored }; + case 1: + return new Object[] { output }; + case 2: + return new Object[] { BASE_MAX_ENERGY }; + case 3: + return new Object[] { (BASE_MAX_ENERGY - electricityStored) }; + case 4: + return new Object[] { seesSun }; + default: + throw new NoSuchMethodException(); + } + } - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); - data.add(seesSun); - return data; - } + @Override + public void handlePacketData(ByteBuf dataStream) { + super.handlePacketData(dataStream); - @Override - public EnumSet getOutputtingSides() - { - return EnumSet.of(ForgeDirection.getOrientation(0)); - } + if (worldObj.isRemote) { + seesSun = dataStream.readBoolean(); + } + } - @Override - public boolean renderUpdate() - { - return false; - } + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); + data.add(seesSun); + return data; + } - @Override - public boolean lightUpdate() - { - return false; - } + @Override + public EnumSet getOutputtingSides() { + return EnumSet.of(ForgeDirection.getOrientation(0)); + } + + @Override + public boolean renderUpdate() { + return false; + } + + @Override + public boolean lightUpdate() { + return false; + } } diff --git a/src/main/java/mekanism/generators/common/tile/TileEntityWindGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntityWindGenerator.java index c3e455473..52fe6aa60 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntityWindGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntityWindGenerator.java @@ -1,9 +1,10 @@ package mekanism.generators.common.tile; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.MekanismConfig.generators; import mekanism.common.base.IBoundingBlock; @@ -11,158 +12,152 @@ import mekanism.common.util.ChargeUtils; import mekanism.common.util.MekanismUtils; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class TileEntityWindGenerator extends TileEntityGenerator implements IBoundingBlock -{ - /** The angle the blades of this Wind Turbine are currently at. */ - public double angle; - - public float currentMultiplier; +public class TileEntityWindGenerator + extends TileEntityGenerator implements IBoundingBlock { + /** The angle the blades of this Wind Turbine are currently at. */ + public double angle; - public TileEntityWindGenerator() - { - super("wind", "WindGenerator", 200000, (generators.windGenerationMax)*2); - inventory = new ItemStack[1]; - } + public float currentMultiplier; - @Override - public void onUpdate() - { - super.onUpdate(); + public TileEntityWindGenerator() { + super("wind", "WindGenerator", 200000, (generators.windGenerationMax) * 2); + inventory = new ItemStack[1]; + } - if(!worldObj.isRemote) - { - ChargeUtils.charge(0, this); - - if(ticker % 20 == 0) - { - setActive((currentMultiplier = getMultiplier()) > 0); - } - - if(getActive()) - { - setEnergy(electricityStored + (generators.windGenerationMin*currentMultiplier)); - } - } - } - - @Override - public void handlePacketData(ByteBuf dataStream) - { - super.handlePacketData(dataStream); + @Override + public void onUpdate() { + super.onUpdate(); - if(worldObj.isRemote) - { - currentMultiplier = dataStream.readFloat(); - } - } + if (!worldObj.isRemote) { + ChargeUtils.charge(0, this); - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); + if (ticker % 20 == 0) { + setActive((currentMultiplier = getMultiplier()) > 0); + } - data.add(currentMultiplier); + if (getActive()) { + setEnergy( + electricityStored + (generators.windGenerationMin * currentMultiplier) + ); + } + } + } - return data; - } + @Override + public void handlePacketData(ByteBuf dataStream) { + super.handlePacketData(dataStream); - /** Determines the current output multiplier, taking sky visibility and height into account. **/ - public float getMultiplier() - { - if(worldObj.canBlockSeeTheSky(xCoord, yCoord+4, zCoord)) - { - final float minY = (float)generators.windGenerationMinY; - final float maxY = (float)generators.windGenerationMaxY; - final float minG = (float)generators.windGenerationMin; - final float maxG = (float)generators.windGenerationMax; + if (worldObj.isRemote) { + currentMultiplier = dataStream.readFloat(); + } + } - final float slope = (maxG - minG) / (maxY - minY); - final float intercept = minG - slope * minY; + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); - final float clampedY = Math.min(maxY, Math.max(minY, (float)(yCoord+4))); - final float toGen = slope * clampedY + intercept; + data.add(currentMultiplier); - return toGen / minG; - } - else { - return 0; - } - } + return data; + } - @Override - @SideOnly(Side.CLIENT) - public float getVolume() - { - return 1.5F*super.getVolume(); - } + /** + * Determines the current output multiplier, taking sky visibility and height into + * account. * + */ + public float getMultiplier() { + if (worldObj.canBlockSeeTheSky(xCoord, yCoord + 4, zCoord)) { + final float minY = (float) generators.windGenerationMinY; + final float maxY = (float) generators.windGenerationMaxY; + final float minG = (float) generators.windGenerationMin; + final float maxG = (float) generators.windGenerationMax; - private static final String[] methods = new String[] {"getEnergy", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getMultiplier"}; + final float slope = (maxG - minG) / (maxY - minY); + final float intercept = minG - slope * minY; - @Override - public String[] getMethods() - { - return methods; - } + final float clampedY = Math.min(maxY, Math.max(minY, (float) (yCoord + 4))); + final float toGen = slope * clampedY + intercept; - @Override - public Object[] invoke(int method, Object[] arguments) throws Exception - { - switch(method) - { - case 0: - return new Object[] {electricityStored}; - case 1: - return new Object[] {output}; - case 2: - return new Object[] {BASE_MAX_ENERGY}; - case 3: - return new Object[] {(BASE_MAX_ENERGY -electricityStored)}; - case 4: - return new Object[] {getMultiplier()}; - default: - throw new NoSuchMethodException(); - } - } + return toGen / minG; + } else { + return 0; + } + } - @Override - public boolean canOperate() - { - return electricityStored < BASE_MAX_ENERGY && getMultiplier() > 0 && MekanismUtils.canFunction(this); - } + @Override + @SideOnly(Side.CLIENT) + public float getVolume() { + return 1.5F * super.getVolume(); + } - @Override - public void onPlace() - { - Coord4D pos = Coord4D.get(this); - MekanismUtils.makeBoundingBlock(worldObj, pos.getFromSide(ForgeDirection.UP, 1), pos); - MekanismUtils.makeBoundingBlock(worldObj, pos.getFromSide(ForgeDirection.UP, 2), pos); - MekanismUtils.makeBoundingBlock(worldObj, pos.getFromSide(ForgeDirection.UP, 3), pos); - MekanismUtils.makeBoundingBlock(worldObj, pos.getFromSide(ForgeDirection.UP, 4), pos); - } + private static final String[] methods = new String[] { + "getEnergy", "getOutput", "getMaxEnergy", "getEnergyNeeded", "getMultiplier" + }; - @Override - public void onBreak() - { - worldObj.setBlockToAir(xCoord, yCoord+1, zCoord); - worldObj.setBlockToAir(xCoord, yCoord+2, zCoord); - worldObj.setBlockToAir(xCoord, yCoord+3, zCoord); - worldObj.setBlockToAir(xCoord, yCoord+4, zCoord); + @Override + public String[] getMethods() { + return methods; + } - worldObj.setBlockToAir(xCoord, yCoord, zCoord); - } + @Override + public Object[] invoke(int method, Object[] arguments) throws Exception { + switch (method) { + case 0: + return new Object[] { electricityStored }; + case 1: + return new Object[] { output }; + case 2: + return new Object[] { BASE_MAX_ENERGY }; + case 3: + return new Object[] { (BASE_MAX_ENERGY - electricityStored) }; + case 4: + return new Object[] { getMultiplier() }; + default: + throw new NoSuchMethodException(); + } + } - @Override - public boolean renderUpdate() - { - return false; - } + @Override + public boolean canOperate() { + return electricityStored < BASE_MAX_ENERGY && getMultiplier() > 0 + && MekanismUtils.canFunction(this); + } - @Override - public boolean lightUpdate() - { - return false; - } + @Override + public void onPlace() { + Coord4D pos = Coord4D.get(this); + MekanismUtils.makeBoundingBlock( + worldObj, pos.getFromSide(ForgeDirection.UP, 1), pos + ); + MekanismUtils.makeBoundingBlock( + worldObj, pos.getFromSide(ForgeDirection.UP, 2), pos + ); + MekanismUtils.makeBoundingBlock( + worldObj, pos.getFromSide(ForgeDirection.UP, 3), pos + ); + MekanismUtils.makeBoundingBlock( + worldObj, pos.getFromSide(ForgeDirection.UP, 4), pos + ); + } + + @Override + public void onBreak() { + worldObj.setBlockToAir(xCoord, yCoord + 1, zCoord); + worldObj.setBlockToAir(xCoord, yCoord + 2, zCoord); + worldObj.setBlockToAir(xCoord, yCoord + 3, zCoord); + worldObj.setBlockToAir(xCoord, yCoord + 4, zCoord); + + worldObj.setBlockToAir(xCoord, yCoord, zCoord); + } + + @Override + public boolean renderUpdate() { + return false; + } + + @Override + public boolean lightUpdate() { + return false; + } } diff --git a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorBlock.java b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorBlock.java index a1254da8b..17a331e31 100644 --- a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorBlock.java +++ b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorBlock.java @@ -11,163 +11,141 @@ import mekanism.common.tile.TileEntityElectricBlock; import net.minecraft.item.ItemStack; import net.minecraftforge.common.util.ForgeDirection; -public abstract class TileEntityReactorBlock extends TileEntityElectricBlock implements IReactorBlock -{ - public IFusionReactor fusionReactor; - - public boolean attempted; - - public boolean changed; +public abstract class TileEntityReactorBlock + extends TileEntityElectricBlock implements IReactorBlock { + public IFusionReactor fusionReactor; - public TileEntityReactorBlock() - { - super("ReactorBlock", 0); - inventory = new ItemStack[0]; - } + public boolean attempted; - public TileEntityReactorBlock(String name, double maxEnergy) - { - super(name, maxEnergy); - } + public boolean changed; - @Override - public void setReactor(IFusionReactor reactor) - { - if(reactor != fusionReactor) - { - changed = true; - } - - fusionReactor = reactor; - } + public TileEntityReactorBlock() { + super("ReactorBlock", 0); + inventory = new ItemStack[0]; + } - @Override - public IFusionReactor getReactor() - { - return fusionReactor; - } + public TileEntityReactorBlock(String name, double maxEnergy) { + super(name, maxEnergy); + } - @Override - public void invalidate() - { - super.invalidate(); - - if(getReactor() != null) - { - getReactor().formMultiblock(false); - } - } + @Override + public void setReactor(IFusionReactor reactor) { + if (reactor != fusionReactor) { + changed = true; + } - @Override - public void onUpdate() - { - super.onUpdate(); - - if(changed) - { - changed = false; - } - - if(!worldObj.isRemote && ticker == 5 && !attempted && (getReactor() == null || !getReactor().isFormed())) - { - updateController(); - } - - attempted = false; - } + fusionReactor = reactor; + } - @Override - public EnumSet getOutputtingSides() - { - return EnumSet.noneOf(ForgeDirection.class); - } + @Override + public IFusionReactor getReactor() { + return fusionReactor; + } - @Override - public EnumSet getConsumingSides() - { - return EnumSet.noneOf(ForgeDirection.class); - } - - @Override - public void onChunkUnload() - { - super.onChunkUnload(); + @Override + public void invalidate() { + super.invalidate(); - if(!(this instanceof TileEntityReactorController) && getReactor() != null) - { - getReactor().formMultiblock(true); - } - } - - @Override - public void onAdded() - { - super.onAdded(); + if (getReactor() != null) { + getReactor().formMultiblock(false); + } + } - if(!worldObj.isRemote) - { - if(getReactor() != null) - { - getReactor().formMultiblock(true); - } - else { - updateController(); - } - } - } - - public void updateController() - { - if(!(this instanceof TileEntityReactorController)) - { - TileEntityReactorController found = new ControllerFinder().find(); - - if(found != null && (found.getReactor() == null || !found.getReactor().isFormed())) - { - found.formMultiblock(true); - } - } - } - - public class ControllerFinder - { - public TileEntityReactorController found; - - public Set iterated = new HashSet(); - - public void loop(Coord4D pos) - { - if(iterated.size() > 512 || found != null) - { - return; - } - - iterated.add(pos); - - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - Coord4D coord = pos.getFromSide(side); - - if(!iterated.contains(coord) && coord.getTileEntity(worldObj) instanceof TileEntityReactorBlock) - { - ((TileEntityReactorBlock)coord.getTileEntity(worldObj)).attempted = true; - - if(coord.getTileEntity(worldObj) instanceof TileEntityReactorController) - { - found = (TileEntityReactorController)coord.getTileEntity(worldObj); - return; - } - - loop(coord); - } - } - } - - public TileEntityReactorController find() - { - loop(Coord4D.get(TileEntityReactorBlock.this)); - - return found; - } - } + @Override + public void onUpdate() { + super.onUpdate(); + + if (changed) { + changed = false; + } + + if (!worldObj.isRemote && ticker == 5 && !attempted + && (getReactor() == null || !getReactor().isFormed())) { + updateController(); + } + + attempted = false; + } + + @Override + public EnumSet getOutputtingSides() { + return EnumSet.noneOf(ForgeDirection.class); + } + + @Override + public EnumSet getConsumingSides() { + return EnumSet.noneOf(ForgeDirection.class); + } + + @Override + public void onChunkUnload() { + super.onChunkUnload(); + + if (!(this instanceof TileEntityReactorController) && getReactor() != null) { + getReactor().formMultiblock(true); + } + } + + @Override + public void onAdded() { + super.onAdded(); + + if (!worldObj.isRemote) { + if (getReactor() != null) { + getReactor().formMultiblock(true); + } else { + updateController(); + } + } + } + + public void updateController() { + if (!(this instanceof TileEntityReactorController)) { + TileEntityReactorController found = new ControllerFinder().find(); + + if (found != null + && (found.getReactor() == null || !found.getReactor().isFormed())) { + found.formMultiblock(true); + } + } + } + + public class ControllerFinder { + public TileEntityReactorController found; + + public Set iterated = new HashSet(); + + public void loop(Coord4D pos) { + if (iterated.size() > 512 || found != null) { + return; + } + + iterated.add(pos); + + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + Coord4D coord = pos.getFromSide(side); + + if (!iterated.contains(coord) + && coord.getTileEntity(worldObj) instanceof TileEntityReactorBlock) { + ((TileEntityReactorBlock) coord.getTileEntity(worldObj)).attempted + = true; + + if (coord.getTileEntity(worldObj) + instanceof TileEntityReactorController) { + found + = (TileEntityReactorController) coord.getTileEntity(worldObj); + return; + } + + loop(coord); + } + } + } + + public TileEntityReactorController find() { + loop(Coord4D.get(TileEntityReactorBlock.this)); + + return found; + } + } } diff --git a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorController.java b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorController.java index 4b98abd9d..c7213b297 100644 --- a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorController.java +++ b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorController.java @@ -1,9 +1,10 @@ package mekanism.generators.common.tile.reactor; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.MekanismConfig.client; import mekanism.api.Pos3D; @@ -29,392 +30,357 @@ import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTank; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class TileEntityReactorController extends TileEntityReactorBlock implements IActiveState, IHasSound, ISoundSource -{ - public static final int MAX_WATER = 100 * FluidContainerRegistry.BUCKET_VOLUME; - public static final int MAX_STEAM = MAX_WATER * 100; - public static final int MAX_FUEL = 1 * FluidContainerRegistry.BUCKET_VOLUME; +public class TileEntityReactorController + extends TileEntityReactorBlock implements IActiveState, IHasSound, ISoundSource { + public static final int MAX_WATER = 100 * FluidContainerRegistry.BUCKET_VOLUME; + public static final int MAX_STEAM = MAX_WATER * 100; + public static final int MAX_FUEL = 1 * FluidContainerRegistry.BUCKET_VOLUME; - public FluidTank waterTank = new FluidTank(MAX_WATER); - public FluidTank steamTank = new FluidTank(MAX_STEAM); + public FluidTank waterTank = new FluidTank(MAX_WATER); + public FluidTank steamTank = new FluidTank(MAX_STEAM); - public GasTank deuteriumTank = new GasTank(MAX_FUEL); - public GasTank tritiumTank = new GasTank(MAX_FUEL); + public GasTank deuteriumTank = new GasTank(MAX_FUEL); + public GasTank tritiumTank = new GasTank(MAX_FUEL); - public GasTank fuelTank = new GasTank(MAX_FUEL); + public GasTank fuelTank = new GasTank(MAX_FUEL); - public AxisAlignedBB box; - - public ResourceLocation soundURL = new ResourceLocation("mekanism", "tile.machine.fusionreactor"); - - @SideOnly(Side.CLIENT) - public SoundWrapper sound; + public AxisAlignedBB box; - public double clientTemp = 0; - public boolean clientBurning = false; + public ResourceLocation soundURL + = new ResourceLocation("mekanism", "tile.machine.fusionreactor"); - public TileEntityReactorController() - { - super("ReactorController", 1000000000); - inventory = new ItemStack[1]; - } + @SideOnly(Side.CLIENT) + public SoundWrapper sound; - @Override - public boolean isFrame() - { - return false; - } + public double clientTemp = 0; + public boolean clientBurning = false; - public void radiateNeutrons(int neutrons) {} //future impl + public TileEntityReactorController() { + super("ReactorController", 1000000000); + inventory = new ItemStack[1]; + } - public void formMultiblock(boolean keepBurning) - { - if(getReactor() == null) - { - setReactor(new FusionReactor(this)); - } - - getReactor().formMultiblock(keepBurning); - } + @Override + public boolean isFrame() { + return false; + } - public double getPlasmaTemp() - { - if(getReactor() == null || !getReactor().isFormed()) - { - return 0; - } - - return getReactor().getPlasmaTemp(); - } + public void radiateNeutrons(int neutrons) {} //future impl - public double getCaseTemp() - { - if(getReactor() == null || !getReactor().isFormed()) - { - return 0; - } - - return getReactor().getCaseTemp(); - } + public void formMultiblock(boolean keepBurning) { + if (getReactor() == null) { + setReactor(new FusionReactor(this)); + } - @Override - public void onUpdate() - { - super.onUpdate(); - - if(worldObj.isRemote) - { - updateSound(); - } + getReactor().formMultiblock(keepBurning); + } - if(isFormed()) - { - getReactor().simulate(); - - if(!worldObj.isRemote && (getReactor().isBurning() != clientBurning || Math.abs(getReactor().getPlasmaTemp() - clientTemp) > 1000000)) - { - Mekanism.packetHandler.sendToAllAround(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), Coord4D.get(this).getTargetPoint(50D)); - clientBurning = getReactor().isBurning(); - clientTemp = getReactor().getPlasmaTemp(); - } - } - } + public double getPlasmaTemp() { + if (getReactor() == null || !getReactor().isFormed()) { + return 0; + } - @SideOnly(Side.CLIENT) - public void updateSound() - { - if(shouldPlaySound() && getSound().canRestart() && client.enableMachineSounds) - { - getSound().reset(); - getSound().play(); - } - } + return getReactor().getPlasmaTemp(); + } - @Override - public void onChunkUnload() - { - super.onChunkUnload(); - - formMultiblock(true); - } - - @Override - public void onAdded() - { - super.onAdded(); - - formMultiblock(true); - } + public double getCaseTemp() { + if (getReactor() == null || !getReactor().isFormed()) { + return 0; + } - @Override - public void writeToNBT(NBTTagCompound tag) - { - super.writeToNBT(tag); + return getReactor().getCaseTemp(); + } - tag.setBoolean("formed", isFormed()); + @Override + public void onUpdate() { + super.onUpdate(); - if(isFormed()) - { - tag.setDouble("plasmaTemp", getReactor().getPlasmaTemp()); - tag.setDouble("caseTemp", getReactor().getCaseTemp()); - tag.setInteger("injectionRate", getReactor().getInjectionRate()); - tag.setBoolean("burning", getReactor().isBurning()); - } - else { - tag.setDouble("plasmaTemp", 0); - tag.setDouble("caseTemp", 0); - tag.setInteger("injectionRate", 0); - tag.setBoolean("burning", false); - } + if (worldObj.isRemote) { + updateSound(); + } - tag.setTag("fuelTank", fuelTank.write(new NBTTagCompound())); - tag.setTag("deuteriumTank", deuteriumTank.write(new NBTTagCompound())); - tag.setTag("tritiumTank", tritiumTank.write(new NBTTagCompound())); - tag.setTag("waterTank", waterTank.writeToNBT(new NBTTagCompound())); - tag.setTag("steamTank", steamTank.writeToNBT(new NBTTagCompound())); - } + if (isFormed()) { + getReactor().simulate(); - @Override - public void readFromNBT(NBTTagCompound tag) - { - super.readFromNBT(tag); + if (!worldObj.isRemote + && (getReactor().isBurning() != clientBurning + || Math.abs(getReactor().getPlasmaTemp() - clientTemp) > 1000000)) { + Mekanism.packetHandler.sendToAllAround( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + Coord4D.get(this).getTargetPoint(50D) + ); + clientBurning = getReactor().isBurning(); + clientTemp = getReactor().getPlasmaTemp(); + } + } + } - boolean formed = tag.getBoolean("formed"); + @SideOnly(Side.CLIENT) + public void updateSound() { + if (shouldPlaySound() && getSound().canRestart() && client.enableMachineSounds) { + getSound().reset(); + getSound().play(); + } + } - if(formed) - { - setReactor(new FusionReactor(this)); - getReactor().setPlasmaTemp(tag.getDouble("plasmaTemp")); - getReactor().setCaseTemp(tag.getDouble("caseTemp")); - getReactor().setInjectionRate(tag.getInteger("injectionRate")); - getReactor().setBurning(tag.getBoolean("burning")); - getReactor().updateTemperatures(); - } + @Override + public void onChunkUnload() { + super.onChunkUnload(); - fuelTank.read(tag.getCompoundTag("fuelTank")); - deuteriumTank.read(tag.getCompoundTag("deuteriumTank")); - tritiumTank.read(tag.getCompoundTag("tritiumTank")); - waterTank.readFromNBT(tag.getCompoundTag("waterTank")); - steamTank.readFromNBT(tag.getCompoundTag("steamTank")); - } + formMultiblock(true); + } - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); + @Override + public void onAdded() { + super.onAdded(); - data.add(getReactor() != null && getReactor().isFormed()); - - if(getReactor() != null) - { - data.add(getReactor().getPlasmaTemp()); - data.add(getReactor().getCaseTemp()); - data.add(getReactor().getInjectionRate()); - data.add(getReactor().isBurning()); - data.add(fuelTank.getStored()); - data.add(deuteriumTank.getStored()); - data.add(tritiumTank.getStored()); - data.add(waterTank.getCapacity()); - data.add(waterTank.getFluidAmount()); - data.add(steamTank.getCapacity()); - data.add(steamTank.getFluidAmount()); - } + formMultiblock(true); + } - return data; - } + @Override + public void writeToNBT(NBTTagCompound tag) { + super.writeToNBT(tag); - @Override - public void handlePacketData(ByteBuf dataStream) - { - if(!worldObj.isRemote) - { - int type = dataStream.readInt(); + tag.setBoolean("formed", isFormed()); - switch(type) - { - case 0: - if(getReactor() != null) getReactor().setInjectionRate(dataStream.readInt()); - break; - } + if (isFormed()) { + tag.setDouble("plasmaTemp", getReactor().getPlasmaTemp()); + tag.setDouble("caseTemp", getReactor().getCaseTemp()); + tag.setInteger("injectionRate", getReactor().getInjectionRate()); + tag.setBoolean("burning", getReactor().isBurning()); + } else { + tag.setDouble("plasmaTemp", 0); + tag.setDouble("caseTemp", 0); + tag.setInteger("injectionRate", 0); + tag.setBoolean("burning", false); + } - return; - } + tag.setTag("fuelTank", fuelTank.write(new NBTTagCompound())); + tag.setTag("deuteriumTank", deuteriumTank.write(new NBTTagCompound())); + tag.setTag("tritiumTank", tritiumTank.write(new NBTTagCompound())); + tag.setTag("waterTank", waterTank.writeToNBT(new NBTTagCompound())); + tag.setTag("steamTank", steamTank.writeToNBT(new NBTTagCompound())); + } - super.handlePacketData(dataStream); + @Override + public void readFromNBT(NBTTagCompound tag) { + super.readFromNBT(tag); - if(worldObj.isRemote) - { - boolean formed = dataStream.readBoolean(); - - if(formed) - { - if(getReactor() == null || !((FusionReactor)getReactor()).formed) - { - Mekanism.proxy.doGenericSparkle(this, new INodeChecker() { - @Override - public boolean isNode(TileEntity tile) - { - return tile instanceof TileEntityReactorBlock; - } - }); - } - - if(getReactor() == null) - { - setReactor(new FusionReactor(this)); - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - - ((FusionReactor)getReactor()).formed = true; - getReactor().setPlasmaTemp(dataStream.readDouble()); - getReactor().setCaseTemp(dataStream.readDouble()); - getReactor().setInjectionRate(dataStream.readInt()); - getReactor().setBurning(dataStream.readBoolean()); - fuelTank.setGas(new GasStack(GasRegistry.getGas("fusionFuelDT"), dataStream.readInt())); - deuteriumTank.setGas(new GasStack(GasRegistry.getGas("deuterium"), dataStream.readInt())); - tritiumTank.setGas(new GasStack(GasRegistry.getGas("tritium"), dataStream.readInt())); - waterTank.setCapacity(dataStream.readInt()); - waterTank.setFluid(new FluidStack(FluidRegistry.getFluid("water"), dataStream.readInt())); - steamTank.setCapacity(dataStream.readInt()); - steamTank.setFluid(new FluidStack(FluidRegistry.getFluid("steam"), dataStream.readInt())); - } - else if(getReactor() != null) - { - setReactor(null); - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } - } + boolean formed = tag.getBoolean("formed"); - public boolean isFormed() - { - return getReactor() != null && getReactor().isFormed(); - } + if (formed) { + setReactor(new FusionReactor(this)); + getReactor().setPlasmaTemp(tag.getDouble("plasmaTemp")); + getReactor().setCaseTemp(tag.getDouble("caseTemp")); + getReactor().setInjectionRate(tag.getInteger("injectionRate")); + getReactor().setBurning(tag.getBoolean("burning")); + getReactor().updateTemperatures(); + } - public boolean isBurning() - { - return getActive() && getReactor().isBurning(); - } + fuelTank.read(tag.getCompoundTag("fuelTank")); + deuteriumTank.read(tag.getCompoundTag("deuteriumTank")); + tritiumTank.read(tag.getCompoundTag("tritiumTank")); + waterTank.readFromNBT(tag.getCompoundTag("waterTank")); + steamTank.readFromNBT(tag.getCompoundTag("steamTank")); + } - @Override - public boolean getActive() - { - return isFormed(); - } + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); - @Override - public void setActive(boolean active) - { - if(active == (getReactor() == null)) - { - setReactor(active ? new FusionReactor(this) : null); - } - } + data.add(getReactor() != null && getReactor().isFormed()); - @Override - public boolean renderUpdate() - { - return true; - } + if (getReactor() != null) { + data.add(getReactor().getPlasmaTemp()); + data.add(getReactor().getCaseTemp()); + data.add(getReactor().getInjectionRate()); + data.add(getReactor().isBurning()); + data.add(fuelTank.getStored()); + data.add(deuteriumTank.getStored()); + data.add(tritiumTank.getStored()); + data.add(waterTank.getCapacity()); + data.add(waterTank.getFluidAmount()); + data.add(steamTank.getCapacity()); + data.add(steamTank.getFluidAmount()); + } - @Override - public boolean lightUpdate() - { - return false; - } + return data; + } - @Override - @SideOnly(Side.CLIENT) - public AxisAlignedBB getRenderBoundingBox() - { - if(box == null) - { - box = AxisAlignedBB.getBoundingBox(xCoord-1, yCoord-3, zCoord-1, xCoord+2, yCoord, zCoord+2); - } - - return box; - } - - @Override - @SideOnly(Side.CLIENT) - public SoundWrapper getSound() - { - return sound; - } + @Override + public void handlePacketData(ByteBuf dataStream) { + if (!worldObj.isRemote) { + int type = dataStream.readInt(); - @Override - @SideOnly(Side.CLIENT) - public boolean shouldPlaySound() - { - return isBurning() && !isInvalid(); - } + switch (type) { + case 0: + if (getReactor() != null) + getReactor().setInjectionRate(dataStream.readInt()); + break; + } - @Override - @SideOnly(Side.CLIENT) - public ResourceLocation getSoundLocation() - { - return soundURL; - } + return; + } - @Override - @SideOnly(Side.CLIENT) - public float getVolume() - { - return 2F; - } + super.handlePacketData(dataStream); - @Override - @SideOnly(Side.CLIENT) - public float getPitch() - { - return 1F; - } + if (worldObj.isRemote) { + boolean formed = dataStream.readBoolean(); - @Override - @SideOnly(Side.CLIENT) - public Pos3D getSoundPosition() - { - return new Pos3D(xCoord+0.5, yCoord+0.5, zCoord+0.5); - } + if (formed) { + if (getReactor() == null || !((FusionReactor) getReactor()).formed) { + Mekanism.proxy.doGenericSparkle(this, new INodeChecker() { + @Override + public boolean isNode(TileEntity tile) { + return tile instanceof TileEntityReactorBlock; + } + }); + } - @Override - @SideOnly(Side.CLIENT) - public boolean shouldRepeat() - { - return true; - } + if (getReactor() == null) { + setReactor(new FusionReactor(this)); + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } - @Override - @SideOnly(Side.CLIENT) - public int getRepeatDelay() - { - return 0; - } + ((FusionReactor) getReactor()).formed = true; + getReactor().setPlasmaTemp(dataStream.readDouble()); + getReactor().setCaseTemp(dataStream.readDouble()); + getReactor().setInjectionRate(dataStream.readInt()); + getReactor().setBurning(dataStream.readBoolean()); + fuelTank.setGas( + new GasStack(GasRegistry.getGas("fusionFuelDT"), dataStream.readInt()) + ); + deuteriumTank.setGas( + new GasStack(GasRegistry.getGas("deuterium"), dataStream.readInt()) + ); + tritiumTank.setGas( + new GasStack(GasRegistry.getGas("tritium"), dataStream.readInt()) + ); + waterTank.setCapacity(dataStream.readInt()); + waterTank.setFluid( + new FluidStack(FluidRegistry.getFluid("water"), dataStream.readInt()) + ); + steamTank.setCapacity(dataStream.readInt()); + steamTank.setFluid( + new FluidStack(FluidRegistry.getFluid("steam"), dataStream.readInt()) + ); + } else if (getReactor() != null) { + setReactor(null); + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } + } - @Override - @SideOnly(Side.CLIENT) - public AttenuationType getAttenuation() - { - return AttenuationType.LINEAR; - } + public boolean isFormed() { + return getReactor() != null && getReactor().isFormed(); + } - @Override - public void validate() - { - super.validate(); + public boolean isBurning() { + return getActive() && getReactor().isBurning(); + } - if(worldObj.isRemote) - { - initSounds(); - } - } + @Override + public boolean getActive() { + return isFormed(); + } - @SideOnly(Side.CLIENT) - public void initSounds() - { - sound = new SoundWrapper(this, this); - } + @Override + public void setActive(boolean active) { + if (active == (getReactor() == null)) { + setReactor(active ? new FusionReactor(this) : null); + } + } + + @Override + public boolean renderUpdate() { + return true; + } + + @Override + public boolean lightUpdate() { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public AxisAlignedBB getRenderBoundingBox() { + if (box == null) { + box = AxisAlignedBB.getBoundingBox( + xCoord - 1, yCoord - 3, zCoord - 1, xCoord + 2, yCoord, zCoord + 2 + ); + } + + return box; + } + + @Override + @SideOnly(Side.CLIENT) + public SoundWrapper getSound() { + return sound; + } + + @Override + @SideOnly(Side.CLIENT) + public boolean shouldPlaySound() { + return isBurning() && !isInvalid(); + } + + @Override + @SideOnly(Side.CLIENT) + public ResourceLocation getSoundLocation() { + return soundURL; + } + + @Override + @SideOnly(Side.CLIENT) + public float getVolume() { + return 2F; + } + + @Override + @SideOnly(Side.CLIENT) + public float getPitch() { + return 1F; + } + + @Override + @SideOnly(Side.CLIENT) + public Pos3D getSoundPosition() { + return new Pos3D(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5); + } + + @Override + @SideOnly(Side.CLIENT) + public boolean shouldRepeat() { + return true; + } + + @Override + @SideOnly(Side.CLIENT) + public int getRepeatDelay() { + return 0; + } + + @Override + @SideOnly(Side.CLIENT) + public AttenuationType getAttenuation() { + return AttenuationType.LINEAR; + } + + @Override + public void validate() { + super.validate(); + + if (worldObj.isRemote) { + initSounds(); + } + } + + @SideOnly(Side.CLIENT) + public void initSounds() { + sound = new SoundWrapper(this, this); + } } diff --git a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorFrame.java b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorFrame.java index 0f98b44ac..fcf5c5b22 100644 --- a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorFrame.java +++ b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorFrame.java @@ -1,10 +1,8 @@ package mekanism.generators.common.tile.reactor; -public class TileEntityReactorFrame extends TileEntityReactorBlock -{ - @Override - public boolean isFrame() - { - return true; - } +public class TileEntityReactorFrame extends TileEntityReactorBlock { + @Override + public boolean isFrame() { + return true; + } } diff --git a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorGlass.java b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorGlass.java index 2b0a98af9..1214c76d0 100644 --- a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorGlass.java +++ b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorGlass.java @@ -1,10 +1,8 @@ package mekanism.generators.common.tile.reactor; -public class TileEntityReactorGlass extends TileEntityReactorBlock -{ - @Override - public boolean isFrame() - { - return false; - } +public class TileEntityReactorGlass extends TileEntityReactorBlock { + @Override + public boolean isFrame() { + return false; + } } diff --git a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorLaserFocusMatrix.java b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorLaserFocusMatrix.java index 48db9a701..803431fe1 100644 --- a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorLaserFocusMatrix.java +++ b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorLaserFocusMatrix.java @@ -3,26 +3,22 @@ package mekanism.generators.common.tile.reactor; import mekanism.api.lasers.ILaserReceptor; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityReactorLaserFocusMatrix extends TileEntityReactorBlock implements ILaserReceptor -{ - @Override - public boolean isFrame() - { - return false; - } +public class TileEntityReactorLaserFocusMatrix + extends TileEntityReactorBlock implements ILaserReceptor { + @Override + public boolean isFrame() { + return false; + } - @Override - public void receiveLaserEnergy(double energy, ForgeDirection side) - { - if(getReactor() != null) - { - getReactor().addTemperatureFromEnergyInput(energy); - } - } + @Override + public void receiveLaserEnergy(double energy, ForgeDirection side) { + if (getReactor() != null) { + getReactor().addTemperatureFromEnergyInput(energy); + } + } - @Override - public boolean canLasersDig() - { - return false; - } + @Override + public boolean canLasersDig() { + return false; + } } diff --git a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorLogicAdapter.java b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorLogicAdapter.java index 82bfec902..f1a0cae82 100644 --- a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorLogicAdapter.java +++ b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorLogicAdapter.java @@ -1,234 +1,221 @@ package mekanism.generators.common.tile.reactor; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import dan200.computercraft.api.lua.LuaException; +import io.netty.buffer.ByteBuf; import mekanism.common.integration.IComputerIntegration; import mekanism.common.util.LangUtils; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import dan200.computercraft.api.lua.LuaException; -public class TileEntityReactorLogicAdapter extends TileEntityReactorBlock implements IComputerIntegration -{ - public ReactorLogic logicType = ReactorLogic.DISABLED; - - public boolean activeCooled; - - public boolean prevOutputting; - - public TileEntityReactorLogicAdapter() - { - super(); - fullName = "ReactorLogicAdapter"; - } - - @Override - public void onUpdate() - { - super.onUpdate(); - - if(!worldObj.isRemote) - { - boolean outputting = checkMode(); - - if(outputting != prevOutputting) - { - worldObj.notifyBlocksOfNeighborChange(xCoord, yCoord, zCoord, getBlockType()); - } - - prevOutputting = outputting; - } - } - - @Override - public boolean isFrame() - { - return false; - } - - public boolean checkMode() - { - if(worldObj.isRemote) - { - return prevOutputting; - } - - if(getReactor() == null || !getReactor().isFormed()) - { - return false; - } - - switch(logicType) - { - case DISABLED: - return false; - case READY: - return getReactor().getPlasmaTemp() >= getReactor().getIgnitionTemperature(activeCooled); - case CAPACITY: - return getReactor().getPlasmaTemp() >= getReactor().getMaxPlasmaTemperature(activeCooled); - case DEPLETED: - return (getReactor().getDeuteriumTank().getStored() < getReactor().getInjectionRate()/2) || - (getReactor().getTritiumTank().getStored() < getReactor().getInjectionRate()/2); - default: - return false; - } - } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); +public class TileEntityReactorLogicAdapter + extends TileEntityReactorBlock implements IComputerIntegration { + public ReactorLogic logicType = ReactorLogic.DISABLED; - logicType = ReactorLogic.values()[nbtTags.getInteger("logicType")]; - activeCooled = nbtTags.getBoolean("activeCooled"); - } + public boolean activeCooled; - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); + public boolean prevOutputting; - nbtTags.setInteger("logicType", logicType.ordinal()); - nbtTags.setBoolean("activeCooled", activeCooled); - } - - @Override - public void handlePacketData(ByteBuf dataStream) - { - if(!worldObj.isRemote) - { - int type = dataStream.readInt(); - - if(type == 0) - { - activeCooled = !activeCooled; - } - else if(type == 1) - { - logicType = ReactorLogic.values()[dataStream.readInt()]; - } - - return; - } - - super.handlePacketData(dataStream); - - if(worldObj.isRemote) - { - logicType = ReactorLogic.values()[dataStream.readInt()]; - activeCooled = dataStream.readBoolean(); - prevOutputting = dataStream.readBoolean(); - } - } + public TileEntityReactorLogicAdapter() { + super(); + fullName = "ReactorLogicAdapter"; + } - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); - - data.add(logicType.ordinal()); - data.add(activeCooled); - data.add(prevOutputting); - - return data; - } + @Override + public void onUpdate() { + super.onUpdate(); - private static final String[] methods = new String[] {"isIgnited", "canIgnite", "getPlasmaHeat", "getMaxPlasmaHeat", "getCaseHeat", "getMaxCaseHeat", "getInjectionRate", "setInjectionRate", "hasFuel", "getProducing", "getIgnitionTemp", - "getEnergy", "getMaxEnergy", "getWater", "getSteam", "getFuel"}; - - @Override - public String[] getMethods() - { - return methods; - } + if (!worldObj.isRemote) { + boolean outputting = checkMode(); - @Override - public Object[] invoke(int method, Object[] arguments) throws LuaException, InterruptedException - { - if(getReactor() == null || !getReactor().isFormed()) - { - return new Object[] {"Unformed."}; - } - - switch(method) - { - case 0: - return new Object[] {getReactor().isBurning()}; - case 1: - return new Object[] {getReactor().getPlasmaTemp() >= getReactor().getIgnitionTemperature(activeCooled)}; - case 2: - return new Object[] {getReactor().getPlasmaTemp()}; - case 3: - return new Object[] {getReactor().getMaxPlasmaTemperature(activeCooled)}; - case 4: - return new Object[] {getReactor().getCaseTemp()}; - case 5: - return new Object[] {getReactor().getMaxCasingTemperature(activeCooled)}; - case 6: - return new Object[] {getReactor().getInjectionRate()}; - case 7: - if(arguments[0] instanceof Double) - { - getReactor().setInjectionRate(((Double)arguments[0]).intValue()); - return new Object[] {"Injection rate set."}; - } - else { - return new Object[] {"Invalid parameters."}; - } - case 8: - return new Object[] {(getReactor().getDeuteriumTank().getStored() >= getReactor().getInjectionRate()/2) && - (getReactor().getTritiumTank().getStored() >= getReactor().getInjectionRate()/2)}; + if (outputting != prevOutputting) { + worldObj.notifyBlocksOfNeighborChange( + xCoord, yCoord, zCoord, getBlockType() + ); + } + + prevOutputting = outputting; + } + } + + @Override + public boolean isFrame() { + return false; + } + + public boolean checkMode() { + if (worldObj.isRemote) { + return prevOutputting; + } + + if (getReactor() == null || !getReactor().isFormed()) { + return false; + } + + switch (logicType) { + case DISABLED: + return false; + case READY: + return getReactor().getPlasmaTemp() + >= getReactor().getIgnitionTemperature(activeCooled); + case CAPACITY: + return getReactor().getPlasmaTemp() + >= getReactor().getMaxPlasmaTemperature(activeCooled); + case DEPLETED: + return (getReactor().getDeuteriumTank().getStored() + < getReactor().getInjectionRate() / 2) + || (getReactor().getTritiumTank().getStored() + < getReactor().getInjectionRate() / 2); + default: + return false; + } + } + + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); + + logicType = ReactorLogic.values()[nbtTags.getInteger("logicType")]; + activeCooled = nbtTags.getBoolean("activeCooled"); + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); + + nbtTags.setInteger("logicType", logicType.ordinal()); + nbtTags.setBoolean("activeCooled", activeCooled); + } + + @Override + public void handlePacketData(ByteBuf dataStream) { + if (!worldObj.isRemote) { + int type = dataStream.readInt(); + + if (type == 0) { + activeCooled = !activeCooled; + } else if (type == 1) { + logicType = ReactorLogic.values()[dataStream.readInt()]; + } + + return; + } + + super.handlePacketData(dataStream); + + if (worldObj.isRemote) { + logicType = ReactorLogic.values()[dataStream.readInt()]; + activeCooled = dataStream.readBoolean(); + prevOutputting = dataStream.readBoolean(); + } + } + + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); + + data.add(logicType.ordinal()); + data.add(activeCooled); + data.add(prevOutputting); + + return data; + } + + private static final String[] methods = new String[] { + "isIgnited", "canIgnite", "getPlasmaHeat", "getMaxPlasmaHeat", + "getCaseHeat", "getMaxCaseHeat", "getInjectionRate", "setInjectionRate", + "hasFuel", "getProducing", "getIgnitionTemp", "getEnergy", + "getMaxEnergy", "getWater", "getSteam", "getFuel" + }; + + @Override + public String[] getMethods() { + return methods; + } + + @Override + public Object[] invoke(int method, Object[] arguments) + throws LuaException, InterruptedException { + if (getReactor() == null || !getReactor().isFormed()) { + return new Object[] { "Unformed." }; + } + + switch (method) { + case 0: + return new Object[] { getReactor().isBurning() }; + case 1: + return new Object[] { getReactor().getPlasmaTemp() + >= getReactor().getIgnitionTemperature(activeCooled + ) }; + case 2: + return new Object[] { getReactor().getPlasmaTemp() }; + case 3: + return new Object[] { getReactor().getMaxPlasmaTemperature(activeCooled + ) }; + case 4: + return new Object[] { getReactor().getCaseTemp() }; + case 5: + return new Object[] { getReactor().getMaxCasingTemperature(activeCooled + ) }; + case 6: + return new Object[] { getReactor().getInjectionRate() }; + case 7: + if (arguments[0] instanceof Double) { + getReactor().setInjectionRate(((Double) arguments[0]).intValue()); + return new Object[] { "Injection rate set." }; + } else { + return new Object[] { "Invalid parameters." }; + } + case 8: + return new Object[] { (getReactor().getDeuteriumTank().getStored() + >= getReactor().getInjectionRate() / 2) + && (getReactor().getTritiumTank().getStored() + >= getReactor().getInjectionRate() / 2) }; case 9: - return new Object[] {getReactor().getPassiveGeneration(false, true)}; + return new Object[] { getReactor().getPassiveGeneration(false, true) }; case 10: - return new Object[] {getReactor().getIgnitionTemperature(activeCooled)}; + return new Object[] { getReactor().getIgnitionTemperature(activeCooled) }; case 11: - return new Object[] {getReactor().getBufferedEnergy()}; + return new Object[] { getReactor().getBufferedEnergy() }; case 12: - return new Object[] {getReactor().getBufferSize()}; + return new Object[] { getReactor().getBufferSize() }; case 13: - return new Object[] {getReactor().getWaterTank().getFluidAmount()}; + return new Object[] { getReactor().getWaterTank().getFluidAmount() }; case 14: - return new Object[] {getReactor().getSteamTank().getFluidAmount()}; + return new Object[] { getReactor().getSteamTank().getFluidAmount() }; case 15: - return new Object[] {getReactor().getFuelTank().getStored()}; - default: - return new Object[] {"Unknown command."}; - } - } - - public static enum ReactorLogic - { - DISABLED("disabled", new ItemStack(Items.gunpowder)), - READY("ready", new ItemStack(Items.redstone)), - CAPACITY("capacity", new ItemStack(Items.redstone)), - DEPLETED("depleted", new ItemStack(Items.redstone)); - - private String name; - private ItemStack renderStack; - - private ReactorLogic(String s, ItemStack stack) - { - name = s; - renderStack = stack; - } - - public ItemStack getRenderStack() - { - return renderStack; - } - - public String getLocalizedName() - { - return LangUtils.localize("reactor." + name); - } - - public String getDescription() - { - return LangUtils.localize("reactor." + name + ".desc"); - } - } + return new Object[] { getReactor().getFuelTank().getStored() }; + default: + return new Object[] { "Unknown command." }; + } + } + + public static enum ReactorLogic { + DISABLED("disabled", new ItemStack(Items.gunpowder)), + READY("ready", new ItemStack(Items.redstone)), + CAPACITY("capacity", new ItemStack(Items.redstone)), + DEPLETED("depleted", new ItemStack(Items.redstone)); + + private String name; + private ItemStack renderStack; + + private ReactorLogic(String s, ItemStack stack) { + name = s; + renderStack = stack; + } + + public ItemStack getRenderStack() { + return renderStack; + } + + public String getLocalizedName() { + return LangUtils.localize("reactor." + name); + } + + public String getDescription() { + return LangUtils.localize("reactor." + name + ".desc"); + } + } } diff --git a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorNeutronCapture.java b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorNeutronCapture.java index 265f17ac4..0161ab5d2 100644 --- a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorNeutronCapture.java +++ b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorNeutronCapture.java @@ -2,17 +2,15 @@ package mekanism.generators.common.tile.reactor; import mekanism.api.reactor.INeutronCapture; -public class TileEntityReactorNeutronCapture extends TileEntityReactorBlock implements INeutronCapture -{ - @Override - public boolean isFrame() - { - return false; - } +public class TileEntityReactorNeutronCapture + extends TileEntityReactorBlock implements INeutronCapture { + @Override + public boolean isFrame() { + return false; + } - @Override - public int absorbNeutrons(int neutrons) - { - return 0; - } + @Override + public int absorbNeutrons(int neutrons) { + return 0; + } } diff --git a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorPort.java b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorPort.java index f2340e74b..1d5ca7eca 100644 --- a/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorPort.java +++ b/src/main/java/mekanism/generators/common/tile/reactor/TileEntityReactorPort.java @@ -1,10 +1,9 @@ package mekanism.generators.common.tile.reactor; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.EnumSet; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.EnumColor; import mekanism.api.IConfigurable; @@ -37,428 +36,387 @@ import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; import net.minecraftforge.fluids.IFluidTank; -public class TileEntityReactorPort extends TileEntityReactorBlock implements IFluidHandler, IGasHandler, ITubeConnection, IHeatTransfer, IConfigurable -{ - public boolean fluidEject; - - public TileEntityReactorPort() - { - super("name", 1); - - inventory = new ItemStack[0]; - } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); +public class TileEntityReactorPort extends TileEntityReactorBlock + implements IFluidHandler, IGasHandler, ITubeConnection, IHeatTransfer, IConfigurable { + public boolean fluidEject; - fluidEject = nbtTags.getBoolean("fluidEject"); - } + public TileEntityReactorPort() { + super("name", 1); - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); + inventory = new ItemStack[0]; + } - nbtTags.setBoolean("fluidEject", fluidEject); - } + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); - @Override - public boolean isFrame() - { - return false; - } + fluidEject = nbtTags.getBoolean("fluidEject"); + } - @Override - public void onUpdate() - { - if(changed) - { - worldObj.func_147453_f(xCoord, yCoord, zCoord, getBlockType()); - } - - super.onUpdate(); + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); - if(!worldObj.isRemote) - { - CableUtils.emit(this); - - if(fluidEject && getReactor() != null && getReactor().getSteamTank().getFluid() != null) - { - IFluidTank tank = getReactor().getSteamTank(); - - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - TileEntity tile = Coord4D.get(this).getFromSide(side).getTileEntity(worldObj); - - if(tile instanceof IFluidHandler && !(tile instanceof TileEntityReactorPort)) - { - if(((IFluidHandler)tile).canFill(side.getOpposite(), tank.getFluid().getFluid())) - { - tank.drain(((IFluidHandler)tile).fill(side.getOpposite(), tank.getFluid(), true), true); - } - } - } - } - } - } + nbtTags.setBoolean("fluidEject", fluidEject); + } - @Override - public int fill(ForgeDirection from, FluidStack resource, boolean doFill) - { - if(resource.getFluid() == FluidRegistry.WATER && getReactor() != null && !fluidEject) - { - return getReactor().getWaterTank().fill(resource, doFill); - } - - return 0; - } + @Override + public boolean isFrame() { + return false; + } - @Override - public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) - { - if(resource.getFluid() == FluidRegistry.getFluid("steam") && getReactor() != null) - { - getReactor().getSteamTank().drain(resource.amount, doDrain); - } - - return null; - } + @Override + public void onUpdate() { + if (changed) { + worldObj.func_147453_f(xCoord, yCoord, zCoord, getBlockType()); + } - @Override - public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) - { - if(getReactor() != null) - { - return getReactor().getSteamTank().drain(maxDrain, doDrain); - } - - return null; - } + super.onUpdate(); - @Override - public boolean canFill(ForgeDirection from, Fluid fluid) - { - return (getReactor() != null && fluid == FluidRegistry.WATER && !fluidEject); - } + if (!worldObj.isRemote) { + CableUtils.emit(this); - @Override - public boolean canDrain(ForgeDirection from, Fluid fluid) - { - return (getReactor() != null && fluid == FluidRegistry.getFluid("steam")); - } + if (fluidEject && getReactor() != null + && getReactor().getSteamTank().getFluid() != null) { + IFluidTank tank = getReactor().getSteamTank(); - @Override - public FluidTankInfo[] getTankInfo(ForgeDirection from) - { - if(getReactor() == null) - { - return new FluidTankInfo[0]; - } - - return new FluidTankInfo[] {getReactor().getWaterTank().getInfo(), getReactor().getSteamTank().getInfo()}; - } + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + TileEntity tile + = Coord4D.get(this).getFromSide(side).getTileEntity(worldObj); - @Override - public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) - { - if(getReactor() != null) - { - if(stack.getGas() == GasRegistry.getGas("deuterium")) - { - return getReactor().getDeuteriumTank().receive(stack, doTransfer); - } - else if(stack.getGas() == GasRegistry.getGas("tritium")) - { - return getReactor().getTritiumTank().receive(stack, doTransfer); - } - else if(stack.getGas() == GasRegistry.getGas("fusionFuelDT")) - { - return getReactor().getFuelTank().receive(stack, doTransfer); - } - } - - return 0; - } + if (tile instanceof IFluidHandler + && !(tile instanceof TileEntityReactorPort)) { + if (((IFluidHandler) tile) + .canFill( + side.getOpposite(), tank.getFluid().getFluid() + )) { + tank.drain( + ((IFluidHandler) tile) + .fill(side.getOpposite(), tank.getFluid(), true), + true + ); + } + } + } + } + } + } - @Override - public int receiveGas(ForgeDirection side, GasStack stack) - { - return receiveGas(side, stack, true); - } + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { + if (resource.getFluid() == FluidRegistry.WATER && getReactor() != null + && !fluidEject) { + return getReactor().getWaterTank().fill(resource, doFill); + } - @Override - public GasStack drawGas(ForgeDirection side, int amount, boolean doTransfer) - { - if(getReactor() != null) - { - if(getReactor().getSteamTank().getFluidAmount() > 0) - { - return new GasStack(GasRegistry.getGas("steam"), getReactor().getSteamTank().drain(amount, doTransfer).amount); - } - } + return 0; + } - return null; - } + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + if (resource.getFluid() == FluidRegistry.getFluid("steam") + && getReactor() != null) { + getReactor().getSteamTank().drain(resource.amount, doDrain); + } - @Override - public GasStack drawGas(ForgeDirection side, int amount) - { - return drawGas(side, amount, true); - } + return null; + } - @Override - public boolean canReceiveGas(ForgeDirection side, Gas type) - { - return (type == GasRegistry.getGas("deuterium") || type == GasRegistry.getGas("tritium") || type == GasRegistry.getGas("fusionFuelDT")); - } + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { + if (getReactor() != null) { + return getReactor().getSteamTank().drain(maxDrain, doDrain); + } - @Override - public boolean canDrawGas(ForgeDirection side, Gas type) - { - return (type == GasRegistry.getGas("steam")); - } + return null; + } - @Override - public boolean canTubeConnect(ForgeDirection side) - { - return getReactor() != null; - } + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + return (getReactor() != null && fluid == FluidRegistry.WATER && !fluidEject); + } - @Override - public boolean canOutputTo(ForgeDirection side) - { - return true; - } + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + return (getReactor() != null && fluid == FluidRegistry.getFluid("steam")); + } - @Override - public double getEnergy() - { - if(getReactor() == null) - { - return 0; - } - else { - return getReactor().getBufferedEnergy(); - } - } + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection from) { + if (getReactor() == null) { + return new FluidTankInfo[0]; + } - @Override - public void setEnergy(double energy) - { - if(getReactor() != null) - { - getReactor().setBufferedEnergy(energy); - } - } + return new FluidTankInfo[] { getReactor().getWaterTank().getInfo(), + getReactor().getSteamTank().getInfo() }; + } - @Override - public double getMaxEnergy() - { - if(getReactor() == null) - { - return 0; - } - else { - return getReactor().getBufferSize(); - } - } + @Override + public int receiveGas(ForgeDirection side, GasStack stack, boolean doTransfer) { + if (getReactor() != null) { + if (stack.getGas() == GasRegistry.getGas("deuterium")) { + return getReactor().getDeuteriumTank().receive(stack, doTransfer); + } else if (stack.getGas() == GasRegistry.getGas("tritium")) { + return getReactor().getTritiumTank().receive(stack, doTransfer); + } else if (stack.getGas() == GasRegistry.getGas("fusionFuelDT")) { + return getReactor().getFuelTank().receive(stack, doTransfer); + } + } - @Override - public EnumSet getOutputtingSides() - { - EnumSet set = EnumSet.allOf(ForgeDirection.class); - set.remove(ForgeDirection.UNKNOWN); - - return set; - } + return 0; + } - @Override - public EnumSet getConsumingSides() - { - return EnumSet.noneOf(ForgeDirection.class); - } + @Override + public int receiveGas(ForgeDirection side, GasStack stack) { + return receiveGas(side, stack, true); + } - @Override - public double getMaxOutput() - { - return 1000000000; - } + @Override + public GasStack drawGas(ForgeDirection side, int amount, boolean doTransfer) { + if (getReactor() != null) { + if (getReactor().getSteamTank().getFluidAmount() > 0) { + return new GasStack( + GasRegistry.getGas("steam"), + getReactor().getSteamTank().drain(amount, doTransfer).amount + ); + } + } - @Override - public double getTemp() - { - if(getReactor() != null) - { - return getReactor().getTemp(); - } - - return 0; - } + return null; + } - @Override - public double getInverseConductionCoefficient() - { - return 5; - } + @Override + public GasStack drawGas(ForgeDirection side, int amount) { + return drawGas(side, amount, true); + } - @Override - public double getInsulationCoefficient(ForgeDirection side) - { - if(getReactor() != null) - { - return getReactor().getInsulationCoefficient(side); - } - - return 0; - } + @Override + public boolean canReceiveGas(ForgeDirection side, Gas type) { + return ( + type == GasRegistry.getGas("deuterium") + || type == GasRegistry.getGas("tritium") + || type == GasRegistry.getGas("fusionFuelDT") + ); + } - @Override - public void transferHeatTo(double heat) - { - if(getReactor() != null) - { - getReactor().transferHeatTo(heat); - } - } + @Override + public boolean canDrawGas(ForgeDirection side, Gas type) { + return (type == GasRegistry.getGas("steam")); + } - @Override - public double[] simulateHeat() - { - return HeatUtils.simulate(this); - } + @Override + public boolean canTubeConnect(ForgeDirection side) { + return getReactor() != null; + } - @Override - public double applyTemperatureChange() - { - if(getReactor() != null) - { - return getReactor().applyTemperatureChange(); - } - - return 0; - } + @Override + public boolean canOutputTo(ForgeDirection side) { + return true; + } - @Override - public boolean canConnectHeat(ForgeDirection side) - { - return getReactor() != null; - } + @Override + public double getEnergy() { + if (getReactor() == null) { + return 0; + } else { + return getReactor().getBufferedEnergy(); + } + } - @Override - public IHeatTransfer getAdjacent(ForgeDirection side) - { - TileEntity adj = Coord4D.get(this).getFromSide(side).getTileEntity(worldObj); - - if(adj instanceof IHeatTransfer && !(adj instanceof IReactorBlock)) - { - return (IHeatTransfer)adj; - } - - return null; - } - - @Override - public ItemStack getStackInSlot(int slotID) - { - return getReactor() != null && getReactor().isFormed() ? getReactor().getInventory()[slotID] : null; - } - - @Override - public int getSizeInventory() - { - return getReactor() != null && getReactor().isFormed() ? 1 : 0; - } + @Override + public void setEnergy(double energy) { + if (getReactor() != null) { + getReactor().setBufferedEnergy(energy); + } + } - @Override - public void setInventorySlotContents(int slotID, ItemStack itemstack) - { - if(getReactor() != null && getReactor().isFormed()) - { - getReactor().getInventory()[slotID] = itemstack; + @Override + public double getMaxEnergy() { + if (getReactor() == null) { + return 0; + } else { + return getReactor().getBufferSize(); + } + } - if(itemstack != null && itemstack.stackSize > getInventoryStackLimit()) - { - itemstack.stackSize = getInventoryStackLimit(); - } - } - } - - @Override - public int[] getAccessibleSlotsFromSide(int side) - { - return getReactor() != null && getReactor().isFormed() ? new int[] {0} : InventoryUtils.EMPTY; - } - - @Override - public boolean isItemValidForSlot(int slotID, ItemStack itemstack) - { - if(getReactor() != null && getReactor().isFormed() && itemstack.getItem() instanceof ItemHohlraum) - { - ItemHohlraum hohlraum = (ItemHohlraum)itemstack.getItem(); - - return hohlraum.getGas(itemstack) != null && hohlraum.getGas(itemstack).amount == hohlraum.getMaxGas(itemstack); - } - - return false; - } - - @Override - public boolean canExtractItem(int slotID, ItemStack itemstack, int side) - { - if(getReactor() != null && getReactor().isFormed() && itemstack.getItem() instanceof ItemHohlraum) - { - ItemHohlraum hohlraum = (ItemHohlraum)itemstack.getItem(); - - return hohlraum.getGas(itemstack) == null; - } - - return false; - } - - @Override - public void handlePacketData(ByteBuf dataStream) - { - super.handlePacketData(dataStream); - - if(worldObj.isRemote) - { - fluidEject = dataStream.readBoolean(); - - MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); - } - } + @Override + public EnumSet getOutputtingSides() { + EnumSet set = EnumSet.allOf(ForgeDirection.class); + set.remove(ForgeDirection.UNKNOWN); - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); - - data.add(fluidEject); - - return data; - } + return set; + } - @Override - public boolean onSneakRightClick(EntityPlayer player, int side) - { - if(!worldObj.isRemote) - { - fluidEject = !fluidEject; - String modeText = " " + (fluidEject ? EnumColor.DARK_RED : EnumColor.DARK_GREEN) + LangUtils.transOutputInput(fluidEject) + "."; - player.addChatMessage(new ChatComponentText(EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + LangUtils.localize("tooltip.configurator.reactorPortEject") + modeText)); - - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - markDirty(); - } - - return true; - } + @Override + public EnumSet getConsumingSides() { + return EnumSet.noneOf(ForgeDirection.class); + } - @Override - public boolean onRightClick(EntityPlayer player, int side) - { - return false; - } + @Override + public double getMaxOutput() { + return 1000000000; + } + + @Override + public double getTemp() { + if (getReactor() != null) { + return getReactor().getTemp(); + } + + return 0; + } + + @Override + public double getInverseConductionCoefficient() { + return 5; + } + + @Override + public double getInsulationCoefficient(ForgeDirection side) { + if (getReactor() != null) { + return getReactor().getInsulationCoefficient(side); + } + + return 0; + } + + @Override + public void transferHeatTo(double heat) { + if (getReactor() != null) { + getReactor().transferHeatTo(heat); + } + } + + @Override + public double[] simulateHeat() { + return HeatUtils.simulate(this); + } + + @Override + public double applyTemperatureChange() { + if (getReactor() != null) { + return getReactor().applyTemperatureChange(); + } + + return 0; + } + + @Override + public boolean canConnectHeat(ForgeDirection side) { + return getReactor() != null; + } + + @Override + public IHeatTransfer getAdjacent(ForgeDirection side) { + TileEntity adj = Coord4D.get(this).getFromSide(side).getTileEntity(worldObj); + + if (adj instanceof IHeatTransfer && !(adj instanceof IReactorBlock)) { + return (IHeatTransfer) adj; + } + + return null; + } + + @Override + public ItemStack getStackInSlot(int slotID) { + return getReactor() != null && getReactor().isFormed() + ? getReactor().getInventory()[slotID] + : null; + } + + @Override + public int getSizeInventory() { + return getReactor() != null && getReactor().isFormed() ? 1 : 0; + } + + @Override + public void setInventorySlotContents(int slotID, ItemStack itemstack) { + if (getReactor() != null && getReactor().isFormed()) { + getReactor().getInventory()[slotID] = itemstack; + + if (itemstack != null && itemstack.stackSize > getInventoryStackLimit()) { + itemstack.stackSize = getInventoryStackLimit(); + } + } + } + + @Override + public int[] getAccessibleSlotsFromSide(int side) { + return getReactor() != null && getReactor().isFormed() ? new int[] { 0 } + : InventoryUtils.EMPTY; + } + + @Override + public boolean isItemValidForSlot(int slotID, ItemStack itemstack) { + if (getReactor() != null && getReactor().isFormed() + && itemstack.getItem() instanceof ItemHohlraum) { + ItemHohlraum hohlraum = (ItemHohlraum) itemstack.getItem(); + + return hohlraum.getGas(itemstack) != null + && hohlraum.getGas(itemstack).amount == hohlraum.getMaxGas(itemstack); + } + + return false; + } + + @Override + public boolean canExtractItem(int slotID, ItemStack itemstack, int side) { + if (getReactor() != null && getReactor().isFormed() + && itemstack.getItem() instanceof ItemHohlraum) { + ItemHohlraum hohlraum = (ItemHohlraum) itemstack.getItem(); + + return hohlraum.getGas(itemstack) == null; + } + + return false; + } + + @Override + public void handlePacketData(ByteBuf dataStream) { + super.handlePacketData(dataStream); + + if (worldObj.isRemote) { + fluidEject = dataStream.readBoolean(); + + MekanismUtils.updateBlock(worldObj, xCoord, yCoord, zCoord); + } + } + + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); + + data.add(fluidEject); + + return data; + } + + @Override + public boolean onSneakRightClick(EntityPlayer player, int side) { + if (!worldObj.isRemote) { + fluidEject = !fluidEject; + String modeText = " " + + (fluidEject ? EnumColor.DARK_RED : EnumColor.DARK_GREEN) + + LangUtils.transOutputInput(fluidEject) + "."; + player.addChatMessage(new ChatComponentText( + EnumColor.DARK_BLUE + "[Mekanism] " + EnumColor.GREY + + LangUtils.localize("tooltip.configurator.reactorPortEject") + modeText + )); + + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + markDirty(); + } + + return true; + } + + @Override + public boolean onRightClick(EntityPlayer player, int side) { + return false; + } } \ No newline at end of file diff --git a/src/main/java/mekanism/generators/common/tile/turbine/TileEntityElectromagneticCoil.java b/src/main/java/mekanism/generators/common/tile/turbine/TileEntityElectromagneticCoil.java index 54de2ed9b..87ac5575c 100644 --- a/src/main/java/mekanism/generators/common/tile/turbine/TileEntityElectromagneticCoil.java +++ b/src/main/java/mekanism/generators/common/tile/turbine/TileEntityElectromagneticCoil.java @@ -2,14 +2,12 @@ package mekanism.generators.common.tile.turbine; import mekanism.common.tile.TileEntityBasicBlock; -public class TileEntityElectromagneticCoil extends TileEntityBasicBlock -{ - @Override - public boolean canUpdate() - { - return false; - } +public class TileEntityElectromagneticCoil extends TileEntityBasicBlock { + @Override + public boolean canUpdate() { + return false; + } - @Override - public void onUpdate() {} + @Override + public void onUpdate() {} } diff --git a/src/main/java/mekanism/generators/common/tile/turbine/TileEntityRotationalComplex.java b/src/main/java/mekanism/generators/common/tile/turbine/TileEntityRotationalComplex.java index 898b6bb6c..1afc417cb 100644 --- a/src/main/java/mekanism/generators/common/tile/turbine/TileEntityRotationalComplex.java +++ b/src/main/java/mekanism/generators/common/tile/turbine/TileEntityRotationalComplex.java @@ -6,24 +6,20 @@ import mekanism.generators.common.content.turbine.SynchronizedTurbineData; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; -public class TileEntityRotationalComplex extends TileEntityInternalMultiblock -{ - @Override - public void setMultiblock(String id) - { - if(id == null && multiblockUUID != null) - { - SynchronizedTurbineData.clientRotationMap.remove(multiblockUUID); - } - - super.setMultiblock(id); - - Coord4D coord = Coord4D.get(this).getFromSide(ForgeDirection.DOWN); - TileEntity tile = coord.getTileEntity(worldObj); - - if(tile instanceof TileEntityTurbineRotor) - { - ((TileEntityTurbineRotor)tile).updateRotors(); - } - } +public class TileEntityRotationalComplex extends TileEntityInternalMultiblock { + @Override + public void setMultiblock(String id) { + if (id == null && multiblockUUID != null) { + SynchronizedTurbineData.clientRotationMap.remove(multiblockUUID); + } + + super.setMultiblock(id); + + Coord4D coord = Coord4D.get(this).getFromSide(ForgeDirection.DOWN); + TileEntity tile = coord.getTileEntity(worldObj); + + if (tile instanceof TileEntityTurbineRotor) { + ((TileEntityTurbineRotor) tile).updateRotors(); + } + } } diff --git a/src/main/java/mekanism/generators/common/tile/turbine/TileEntitySaturatingCondenser.java b/src/main/java/mekanism/generators/common/tile/turbine/TileEntitySaturatingCondenser.java index 0e28d2422..dd5cd7119 100644 --- a/src/main/java/mekanism/generators/common/tile/turbine/TileEntitySaturatingCondenser.java +++ b/src/main/java/mekanism/generators/common/tile/turbine/TileEntitySaturatingCondenser.java @@ -2,14 +2,12 @@ package mekanism.generators.common.tile.turbine; import mekanism.common.tile.TileEntityBasicBlock; -public class TileEntitySaturatingCondenser extends TileEntityBasicBlock -{ - @Override - public boolean canUpdate() - { - return false; - } +public class TileEntitySaturatingCondenser extends TileEntityBasicBlock { + @Override + public boolean canUpdate() { + return false; + } - @Override - public void onUpdate() {} + @Override + public void onUpdate() {} } diff --git a/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineCasing.java b/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineCasing.java index be8876c17..8cd42f236 100644 --- a/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineCasing.java +++ b/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineCasing.java @@ -1,9 +1,8 @@ package mekanism.generators.common.tile.turbine; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.MekanismConfig.general; import mekanism.api.MekanismConfig.generators; @@ -26,265 +25,266 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; -public class TileEntityTurbineCasing extends TileEntityMultiblock implements IStrictEnergyStorage -{ - public TileEntityTurbineCasing() - { - this("TurbineCasing"); - } - - public TileEntityTurbineCasing(String name) - { - super(name); - } - - @Override - public void onUpdate() - { - super.onUpdate(); - - if(!worldObj.isRemote) - { - if(structure != null) - { - if(structure.fluidStored != null && structure.fluidStored.amount <= 0) - { - structure.fluidStored = null; - markDirty(); - } - - if(isRendering) - { - structure.lastSteamInput = structure.newSteamInput; - structure.newSteamInput = 0; - - int stored = structure.fluidStored != null ? structure.fluidStored.amount : 0; - double proportion = (double)stored/(double)structure.getFluidCapacity(); - double flowRate = 0; - - if(stored > 0 && getEnergy() < structure.getEnergyCapacity()) - { - double energyMultiplier = (general.maxEnergyPerSteam/TurbineUpdateProtocol.MAX_BLADES)*Math.min(structure.blades, structure.coils*generators.turbineBladesPerCoil); - double rate = structure.lowerVolume*(structure.getDispersers()*generators.turbineDisperserGasFlow); - rate = Math.min(rate, structure.vents*generators.turbineVentGasFlow); - - double origRate = rate; - - rate = Math.min(Math.min(stored, rate), (getMaxEnergy()-getEnergy())/energyMultiplier)*proportion; - - flowRate = rate/origRate; - setEnergy(getEnergy()+((int)rate)*energyMultiplier); - - structure.fluidStored.amount -= rate; - structure.clientFlow = Math.min((int)rate, structure.condensers*generators.condenserRate); - structure.flowRemaining = (int)rate; - - if(structure.fluidStored.amount == 0) - { - structure.fluidStored = null; - } - } - else { - structure.clientFlow = 0; - } - - if(structure.dumpMode == GasMode.DUMPING && structure.fluidStored != null) - { - structure.fluidStored.amount -= Math.min(structure.fluidStored.amount, Math.max(structure.fluidStored.amount/50, structure.lastSteamInput*2)); - - if(structure.fluidStored.amount == 0) - { - structure.fluidStored = null; - } - } - - float newRotation = (float)flowRate; - boolean needsRotationUpdate = false; - - if(Math.abs(newRotation-structure.clientRotation) > SynchronizedTurbineData.ROTATION_THRESHOLD) - { - structure.clientRotation = newRotation; - needsRotationUpdate = true; - } - - if(structure.needsRenderUpdate() || needsRotationUpdate) - { - sendPacketToRenderer(); - } - - structure.prevFluid = structure.fluidStored != null ? structure.fluidStored.copy() : null; - } - } - } - } - - @Override - public String getInventoryName() - { - return LangUtils.localize("gui.industrialTurbine"); - } - - @Override - public boolean onActivate(EntityPlayer player) - { - if(!player.isSneaking() && structure != null) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - player.openGui(MekanismGenerators.instance, 6, worldObj, xCoord, yCoord, zCoord); - - return true; - } - - return false; - } - - @Override - public double getEnergy() - { - return structure != null ? structure.electricityStored : 0; - } - - @Override - public double getMaxEnergy() - { - return structure.getEnergyCapacity(); - } +public class TileEntityTurbineCasing extends TileEntityMultiblock + implements IStrictEnergyStorage { + public TileEntityTurbineCasing() { + this("TurbineCasing"); + } - @Override - public void setEnergy(double energy) - { - if(structure != null) - { - structure.electricityStored = Math.max(Math.min(energy, getMaxEnergy()), 0); - MekanismUtils.saveChunk(this); - } - } - - public int getScaledFluidLevel(int i) - { - if(structure.getFluidCapacity() == 0 || structure.fluidStored == null) - { - return 0; - } + public TileEntityTurbineCasing(String name) { + super(name); + } - return structure.fluidStored.amount*i / structure.getFluidCapacity(); - } - - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); - - if(structure != null) - { - data.add(structure.volume); - data.add(structure.lowerVolume); - data.add(structure.vents); - data.add(structure.blades); - data.add(structure.coils); - data.add(structure.condensers); - data.add(structure.getDispersers()); - data.add(structure.electricityStored); - data.add(structure.clientFlow); - data.add(structure.lastSteamInput); - data.add(structure.dumpMode.ordinal()); - - if(structure.fluidStored != null) - { - data.add(1); - data.add(structure.fluidStored.getFluidID()); - data.add(structure.fluidStored.amount); - } - else { - data.add(0); - } - - if(isRendering) - { - structure.complex.write(data); - data.add(structure.clientRotation); - } - } + @Override + public void onUpdate() { + super.onUpdate(); - return data; - } + if (!worldObj.isRemote) { + if (structure != null) { + if (structure.fluidStored != null && structure.fluidStored.amount <= 0) { + structure.fluidStored = null; + markDirty(); + } - @Override - public void handlePacketData(ByteBuf dataStream) - { - if(!worldObj.isRemote) - { - if(structure != null) - { - byte type = dataStream.readByte(); - - if(type == 0) - { - structure.dumpMode = GasMode.values()[structure.dumpMode.ordinal() == GasMode.values().length-1 ? 0 : structure.dumpMode.ordinal()+1]; - } - } + if (isRendering) { + structure.lastSteamInput = structure.newSteamInput; + structure.newSteamInput = 0; - return; - } - - super.handlePacketData(dataStream); - - if(worldObj.isRemote) - { - if(clientHasStructure) - { - structure.volume = dataStream.readInt(); - structure.lowerVolume = dataStream.readInt(); - structure.vents = dataStream.readInt(); - structure.blades = dataStream.readInt(); - structure.coils = dataStream.readInt(); - structure.condensers = dataStream.readInt(); - structure.clientDispersers = dataStream.readInt(); - structure.electricityStored = dataStream.readDouble(); - structure.clientFlow = dataStream.readInt(); - structure.lastSteamInput = dataStream.readInt(); - structure.dumpMode = GasMode.values()[dataStream.readInt()]; - - if(dataStream.readInt() == 1) - { - structure.fluidStored = new FluidStack(FluidRegistry.getFluid(dataStream.readInt()), dataStream.readInt()); - } - else { - structure.fluidStored = null; - } - - if(isRendering) - { - structure.complex = Coord4D.read(dataStream); - - structure.clientRotation = dataStream.readFloat(); - SynchronizedTurbineData.clientRotationMap.put(structure.inventoryID, structure.clientRotation); - } - } - } - } + int stored = structure.fluidStored != null + ? structure.fluidStored.amount + : 0; + double proportion + = (double) stored / (double) structure.getFluidCapacity(); + double flowRate = 0; - @Override - protected SynchronizedTurbineData getNewStructure() - { - return new SynchronizedTurbineData(); - } + if (stored > 0 && getEnergy() < structure.getEnergyCapacity()) { + double energyMultiplier = (general.maxEnergyPerSteam + / TurbineUpdateProtocol.MAX_BLADES) + * Math.min( + structure.blades, + structure.coils * generators.turbineBladesPerCoil + ); + double rate = structure.lowerVolume + * (structure.getDispersers() + * generators.turbineDisperserGasFlow); + rate = Math.min( + rate, structure.vents * generators.turbineVentGasFlow + ); - @Override - public MultiblockCache getNewCache() - { - return new TurbineCache(); - } + double origRate = rate; - @Override - protected UpdateProtocol getProtocol() - { - return new TurbineUpdateProtocol(this); - } + rate = Math.min( + Math.min(stored, rate), + (getMaxEnergy() - getEnergy()) / energyMultiplier + ) + * proportion; - @Override - public MultiblockManager getManager() - { - return MekanismGenerators.turbineManager; - } + flowRate = rate / origRate; + setEnergy(getEnergy() + ((int) rate) * energyMultiplier); + + structure.fluidStored.amount -= rate; + structure.clientFlow = Math.min( + (int) rate, structure.condensers * generators.condenserRate + ); + structure.flowRemaining = (int) rate; + + if (structure.fluidStored.amount == 0) { + structure.fluidStored = null; + } + } else { + structure.clientFlow = 0; + } + + if (structure.dumpMode == GasMode.DUMPING + && structure.fluidStored != null) { + structure.fluidStored.amount -= Math.min( + structure.fluidStored.amount, + Math.max( + structure.fluidStored.amount / 50, + structure.lastSteamInput * 2 + ) + ); + + if (structure.fluidStored.amount == 0) { + structure.fluidStored = null; + } + } + + float newRotation = (float) flowRate; + boolean needsRotationUpdate = false; + + if (Math.abs(newRotation - structure.clientRotation) + > SynchronizedTurbineData.ROTATION_THRESHOLD) { + structure.clientRotation = newRotation; + needsRotationUpdate = true; + } + + if (structure.needsRenderUpdate() || needsRotationUpdate) { + sendPacketToRenderer(); + } + + structure.prevFluid = structure.fluidStored != null + ? structure.fluidStored.copy() + : null; + } + } + } + } + + @Override + public String getInventoryName() { + return LangUtils.localize("gui.industrialTurbine"); + } + + @Override + public boolean onActivate(EntityPlayer player) { + if (!player.isSneaking() && structure != null) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + player.openGui( + MekanismGenerators.instance, 6, worldObj, xCoord, yCoord, zCoord + ); + + return true; + } + + return false; + } + + @Override + public double getEnergy() { + return structure != null ? structure.electricityStored : 0; + } + + @Override + public double getMaxEnergy() { + return structure.getEnergyCapacity(); + } + + @Override + public void setEnergy(double energy) { + if (structure != null) { + structure.electricityStored = Math.max(Math.min(energy, getMaxEnergy()), 0); + MekanismUtils.saveChunk(this); + } + } + + public int getScaledFluidLevel(int i) { + if (structure.getFluidCapacity() == 0 || structure.fluidStored == null) { + return 0; + } + + return structure.fluidStored.amount * i / structure.getFluidCapacity(); + } + + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); + + if (structure != null) { + data.add(structure.volume); + data.add(structure.lowerVolume); + data.add(structure.vents); + data.add(structure.blades); + data.add(structure.coils); + data.add(structure.condensers); + data.add(structure.getDispersers()); + data.add(structure.electricityStored); + data.add(structure.clientFlow); + data.add(structure.lastSteamInput); + data.add(structure.dumpMode.ordinal()); + + if (structure.fluidStored != null) { + data.add(1); + data.add(structure.fluidStored.getFluidID()); + data.add(structure.fluidStored.amount); + } else { + data.add(0); + } + + if (isRendering) { + structure.complex.write(data); + data.add(structure.clientRotation); + } + } + + return data; + } + + @Override + public void handlePacketData(ByteBuf dataStream) { + if (!worldObj.isRemote) { + if (structure != null) { + byte type = dataStream.readByte(); + + if (type == 0) { + structure.dumpMode = GasMode.values( + )[structure.dumpMode.ordinal() == GasMode.values().length - 1 + ? 0 + : structure.dumpMode.ordinal() + 1]; + } + } + + return; + } + + super.handlePacketData(dataStream); + + if (worldObj.isRemote) { + if (clientHasStructure) { + structure.volume = dataStream.readInt(); + structure.lowerVolume = dataStream.readInt(); + structure.vents = dataStream.readInt(); + structure.blades = dataStream.readInt(); + structure.coils = dataStream.readInt(); + structure.condensers = dataStream.readInt(); + structure.clientDispersers = dataStream.readInt(); + structure.electricityStored = dataStream.readDouble(); + structure.clientFlow = dataStream.readInt(); + structure.lastSteamInput = dataStream.readInt(); + structure.dumpMode = GasMode.values()[dataStream.readInt()]; + + if (dataStream.readInt() == 1) { + structure.fluidStored = new FluidStack( + FluidRegistry.getFluid(dataStream.readInt()), dataStream.readInt() + ); + } else { + structure.fluidStored = null; + } + + if (isRendering) { + structure.complex = Coord4D.read(dataStream); + + structure.clientRotation = dataStream.readFloat(); + SynchronizedTurbineData.clientRotationMap.put( + structure.inventoryID, structure.clientRotation + ); + } + } + } + } + + @Override + protected SynchronizedTurbineData getNewStructure() { + return new SynchronizedTurbineData(); + } + + @Override + public MultiblockCache getNewCache() { + return new TurbineCache(); + } + + @Override + protected UpdateProtocol getProtocol() { + return new TurbineUpdateProtocol(this); + } + + @Override + public MultiblockManager getManager() { + return MekanismGenerators.turbineManager; + } } diff --git a/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineRotor.java b/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineRotor.java index 8e49b68ec..9e5186220 100644 --- a/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineRotor.java +++ b/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineRotor.java @@ -1,10 +1,11 @@ package mekanism.generators.common.tile.turbine; -import io.netty.buffer.ByteBuf; - import java.util.ArrayList; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import io.netty.buffer.ByteBuf; import mekanism.api.Coord4D; import mekanism.api.Range4D; import mekanism.common.Mekanism; @@ -15,261 +16,235 @@ import net.minecraft.block.Block; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.AxisAlignedBB; import net.minecraftforge.common.util.ForgeDirection; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class TileEntityTurbineRotor extends TileEntityBasicBlock -{ - public List rotors = new ArrayList(); - - public boolean hasComplex; - - public String multiblockUUID; - - //Total blades on server, housed blades on client - public int blades = 0; - - //Client stuff - public int clientIndex; - - public float rotationLower; - public float rotationUpper; - - @Override - public boolean canUpdate() - { - return false; - } - - @Override - public void onNeighborChange(Block block) - { - if(!worldObj.isRemote) - { - updateRotors(); - } - } - - public void updateRotors() - { - if(rotors.contains(Coord4D.get(this))) - { - rotors.add(Coord4D.get(this)); - } - - buildRotors(); - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - } - - private void buildRotors() - { - List newRotors = new ArrayList(); - int newBlades = 0; - boolean complex = false; - String id = null; - - Coord4D pointer = Coord4D.get(this); - - //Go to bottom rotor - while(true) - { - if(isRotor(pointer.getFromSide(ForgeDirection.DOWN))) - { - pointer.step(ForgeDirection.DOWN); - continue; - } - - break; - } - - //Put all rotors in new list, top to bottom - while(true) - { - newRotors.add(pointer.clone()); - newBlades += ((TileEntityTurbineRotor)pointer.getTileEntity(worldObj)).getHousedBlades(); - - if(isRotor(pointer.getFromSide(ForgeDirection.UP))) - { - pointer.step(ForgeDirection.UP); - continue; - } - - break; - } - - if(isComplex(pointer.getFromSide(ForgeDirection.UP))) - { - id = ((TileEntityRotationalComplex)pointer.getFromSide(ForgeDirection.UP).getTileEntity(worldObj)).multiblockUUID; - complex = true; - } - - //Update all rotors, send packet if necessary - for(Coord4D coord : newRotors) - { - TileEntityTurbineRotor rotor = (TileEntityTurbineRotor)coord.getTileEntity(worldObj); - int prevHoused = rotor.getHousedBlades(); - int prevBlades = rotor.blades; - - rotor.rotors = newRotors; - rotor.blades = newBlades; - rotor.multiblockUUID = id; - - if(rotors.indexOf(coord) == rotors.size()-1) - { - rotor.hasComplex = complex; - } - else { - rotor.hasComplex = false; - } - - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(coord, rotor.getNetworkedData(new ArrayList())), new Range4D(coord)); - } - } - - public boolean editBlade(boolean add) - { - if(!rotors.contains(Coord4D.get(this))) - { - rotors.add(Coord4D.get(this)); - } - - if((add && (rotors.size()*2) - blades > 0) || (!add && (blades > 0))) - { - for(Coord4D coord : rotors) - { - TileEntityTurbineRotor rotor = (TileEntityTurbineRotor)coord.getTileEntity(worldObj); - rotor.internalEditBlade(add); - } - - return true; - } - else { - return false; - } - } - - public void internalEditBlade(boolean add) - { - int prev = getHousedBlades(); - - blades += add ? 1 : -1; - - if(getHousedBlades() != prev) - { - Mekanism.packetHandler.sendToReceivers(new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), new Range4D(Coord4D.get(this))); - } - } - - public int getHousedBlades() - { - if(!worldObj.isRemote) - { - if(rotors.size() > 0) - { - return Math.max(0, Math.min(2, blades - (rotors.indexOf(Coord4D.get(this)))*2)); - } - else { - return blades; - } - } - else { - return blades; - } - } - - private boolean isRotor(Coord4D coord) - { - return coord.getTileEntity(worldObj) instanceof TileEntityTurbineRotor; - } - - private boolean isComplex(Coord4D coord) - { - return coord.getTileEntity(worldObj) instanceof TileEntityRotationalComplex; - } - - @Override - public void onChunkLoad() - { - super.onChunkLoad(); - - if(!worldObj.isRemote) - { - updateRotors(); - } - } - - @Override - public void handlePacketData(ByteBuf dataStream) - { - super.handlePacketData(dataStream); - - if(worldObj.isRemote) - { - int prevBlades = blades; - int prevIndex = clientIndex; - - blades = dataStream.readInt(); - clientIndex = dataStream.readInt(); - - if(dataStream.readBoolean()) - { - multiblockUUID = PacketHandler.readString(dataStream); - } - else { - multiblockUUID = null; - } - - if(prevBlades != blades || prevIndex != clientIndex) - { - rotationLower = 0; - rotationUpper = 0; - } - } - } +public class TileEntityTurbineRotor extends TileEntityBasicBlock { + public List rotors = new ArrayList(); - @Override - public ArrayList getNetworkedData(ArrayList data) - { - super.getNetworkedData(data); - - data.add(getHousedBlades()); - data.add(rotors.indexOf(Coord4D.get(this))); - - if(multiblockUUID != null) - { - data.add(true); - data.add(multiblockUUID); - } - else { - data.add(false); - } - - return data; - } - - @Override - public void readFromNBT(NBTTagCompound nbtTags) - { - super.readFromNBT(nbtTags); + public boolean hasComplex; - blades = nbtTags.getInteger("blades"); - } + public String multiblockUUID; - @Override - public void writeToNBT(NBTTagCompound nbtTags) - { - super.writeToNBT(nbtTags); + //Total blades on server, housed blades on client + public int blades = 0; - nbtTags.setInteger("blades", getHousedBlades()); - } - - @Override - @SideOnly(Side.CLIENT) - public AxisAlignedBB getRenderBoundingBox() - { - return INFINITE_EXTENT_AABB; - } + //Client stuff + public int clientIndex; - @Override - public void onUpdate() {} + public float rotationLower; + public float rotationUpper; + + @Override + public boolean canUpdate() { + return false; + } + + @Override + public void onNeighborChange(Block block) { + if (!worldObj.isRemote) { + updateRotors(); + } + } + + public void updateRotors() { + if (rotors.contains(Coord4D.get(this))) { + rotors.add(Coord4D.get(this)); + } + + buildRotors(); + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage(Coord4D.get(this), getNetworkedData(new ArrayList())), + new Range4D(Coord4D.get(this)) + ); + } + + private void buildRotors() { + List newRotors = new ArrayList(); + int newBlades = 0; + boolean complex = false; + String id = null; + + Coord4D pointer = Coord4D.get(this); + + //Go to bottom rotor + while (true) { + if (isRotor(pointer.getFromSide(ForgeDirection.DOWN))) { + pointer.step(ForgeDirection.DOWN); + continue; + } + + break; + } + + //Put all rotors in new list, top to bottom + while (true) { + newRotors.add(pointer.clone()); + newBlades += ((TileEntityTurbineRotor) pointer.getTileEntity(worldObj)) + .getHousedBlades(); + + if (isRotor(pointer.getFromSide(ForgeDirection.UP))) { + pointer.step(ForgeDirection.UP); + continue; + } + + break; + } + + if (isComplex(pointer.getFromSide(ForgeDirection.UP))) { + id = ((TileEntityRotationalComplex) pointer.getFromSide(ForgeDirection.UP) + .getTileEntity(worldObj)) + .multiblockUUID; + complex = true; + } + + //Update all rotors, send packet if necessary + for (Coord4D coord : newRotors) { + TileEntityTurbineRotor rotor + = (TileEntityTurbineRotor) coord.getTileEntity(worldObj); + int prevHoused = rotor.getHousedBlades(); + int prevBlades = rotor.blades; + + rotor.rotors = newRotors; + rotor.blades = newBlades; + rotor.multiblockUUID = id; + + if (rotors.indexOf(coord) == rotors.size() - 1) { + rotor.hasComplex = complex; + } else { + rotor.hasComplex = false; + } + + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage(coord, rotor.getNetworkedData(new ArrayList())), + new Range4D(coord) + ); + } + } + + public boolean editBlade(boolean add) { + if (!rotors.contains(Coord4D.get(this))) { + rotors.add(Coord4D.get(this)); + } + + if ((add && (rotors.size() * 2) - blades > 0) || (!add && (blades > 0))) { + for (Coord4D coord : rotors) { + TileEntityTurbineRotor rotor + = (TileEntityTurbineRotor) coord.getTileEntity(worldObj); + rotor.internalEditBlade(add); + } + + return true; + } else { + return false; + } + } + + public void internalEditBlade(boolean add) { + int prev = getHousedBlades(); + + blades += add ? 1 : -1; + + if (getHousedBlades() != prev) { + Mekanism.packetHandler.sendToReceivers( + new TileEntityMessage( + Coord4D.get(this), getNetworkedData(new ArrayList()) + ), + new Range4D(Coord4D.get(this)) + ); + } + } + + public int getHousedBlades() { + if (!worldObj.isRemote) { + if (rotors.size() > 0) { + return Math.max( + 0, Math.min(2, blades - (rotors.indexOf(Coord4D.get(this))) * 2) + ); + } else { + return blades; + } + } else { + return blades; + } + } + + private boolean isRotor(Coord4D coord) { + return coord.getTileEntity(worldObj) instanceof TileEntityTurbineRotor; + } + + private boolean isComplex(Coord4D coord) { + return coord.getTileEntity(worldObj) instanceof TileEntityRotationalComplex; + } + + @Override + public void onChunkLoad() { + super.onChunkLoad(); + + if (!worldObj.isRemote) { + updateRotors(); + } + } + + @Override + public void handlePacketData(ByteBuf dataStream) { + super.handlePacketData(dataStream); + + if (worldObj.isRemote) { + int prevBlades = blades; + int prevIndex = clientIndex; + + blades = dataStream.readInt(); + clientIndex = dataStream.readInt(); + + if (dataStream.readBoolean()) { + multiblockUUID = PacketHandler.readString(dataStream); + } else { + multiblockUUID = null; + } + + if (prevBlades != blades || prevIndex != clientIndex) { + rotationLower = 0; + rotationUpper = 0; + } + } + } + + @Override + public ArrayList getNetworkedData(ArrayList data) { + super.getNetworkedData(data); + + data.add(getHousedBlades()); + data.add(rotors.indexOf(Coord4D.get(this))); + + if (multiblockUUID != null) { + data.add(true); + data.add(multiblockUUID); + } else { + data.add(false); + } + + return data; + } + + @Override + public void readFromNBT(NBTTagCompound nbtTags) { + super.readFromNBT(nbtTags); + + blades = nbtTags.getInteger("blades"); + } + + @Override + public void writeToNBT(NBTTagCompound nbtTags) { + super.writeToNBT(nbtTags); + + nbtTags.setInteger("blades", getHousedBlades()); + } + + @Override + @SideOnly(Side.CLIENT) + public AxisAlignedBB getRenderBoundingBox() { + return INFINITE_EXTENT_AABB; + } + + @Override + public void onUpdate() {} } diff --git a/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineValve.java b/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineValve.java index ef8cf6d44..4635a9418 100644 --- a/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineValve.java +++ b/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineValve.java @@ -1,12 +1,15 @@ package mekanism.generators.common.tile.turbine; +import java.util.EnumSet; + +import cpw.mods.fml.common.Optional.Interface; +import cpw.mods.fml.common.Optional.InterfaceList; +import cpw.mods.fml.common.Optional.Method; import ic2.api.energy.EnergyNet; import ic2.api.energy.event.EnergyTileLoadEvent; import ic2.api.energy.event.EnergyTileUnloadEvent; import ic2.api.energy.tile.IEnergyConductor; import ic2.api.energy.tile.IEnergyTile; - -import java.util.EnumSet; import mekanism.api.Coord4D; import mekanism.api.MekanismConfig.general; import mekanism.common.base.IEnergyWrapper; @@ -24,388 +27,333 @@ import net.minecraftforge.fluids.FluidRegistry; import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; -import cpw.mods.fml.common.Optional.Interface; -import cpw.mods.fml.common.Optional.InterfaceList; -import cpw.mods.fml.common.Optional.Method; @InterfaceList({ - @Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2"), - @Interface(iface = "ic2.api.energy.tile.IEnergySource", modid = "IC2"), - @Interface(iface = "ic2.api.tile.IEnergyStorage", modid = "IC2") + @Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2") + , @Interface(iface = "ic2.api.energy.tile.IEnergySource", modid = "IC2"), + @Interface(iface = "ic2.api.tile.IEnergyStorage", modid = "IC2") }) -public class TileEntityTurbineValve extends TileEntityTurbineCasing implements IFluidHandler, IEnergyWrapper -{ - public boolean ic2Registered = false; - - public TurbineFluidTank fluidTank; +public class TileEntityTurbineValve + extends TileEntityTurbineCasing implements IFluidHandler, IEnergyWrapper { + public boolean ic2Registered = false; - public TileEntityTurbineValve() - { - super("TurbineValve"); - fluidTank = new TurbineFluidTank(this); - } - - @Override - public void onUpdate() - { - super.onUpdate(); - - if(!ic2Registered && MekanismUtils.useIC2()) - { - register(); - } - - if(!worldObj.isRemote) - { - if(structure != null) - { - double prev = getEnergy(); - CableUtils.emit(this); - } - } - } - - @Override - public EnumSet getOutputtingSides() - { - if(structure != null) - { - EnumSet set = EnumSet.allOf(ForgeDirection.class); - set.remove(ForgeDirection.UNKNOWN); - - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - if(structure.locations.contains(Coord4D.get(this).getFromSide(side))) - { - set.remove(side); - } - } - - return set; - } - - return EnumSet.noneOf(ForgeDirection.class); - } + public TurbineFluidTank fluidTank; - @Override - public EnumSet getConsumingSides() - { - return EnumSet.noneOf(ForgeDirection.class); - } - - @Override - public boolean canUpdate() - { - return true; - } - - @Method(modid = "IC2") - public void register() - { - if(!worldObj.isRemote) - { - TileEntity registered = EnergyNet.instance.getTileEntity(worldObj, xCoord, yCoord, zCoord); - - if(registered != this) - { - if(registered instanceof IEnergyTile) - { - MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergyTile)registered)); - } - else if(registered == null) - { - MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); - ic2Registered = true; - } - } - } - } + public TileEntityTurbineValve() { + super("TurbineValve"); + fluidTank = new TurbineFluidTank(this); + } - @Method(modid = "IC2") - public void deregister() - { - if(!worldObj.isRemote) - { - TileEntity registered = EnergyNet.instance.getTileEntity(worldObj, xCoord, yCoord, zCoord); - - if(registered instanceof IEnergyTile) - { - MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergyTile)registered)); - } - } - } + @Override + public void onUpdate() { + super.onUpdate(); - @Override - public double getMaxOutput() - { - return structure != null ? structure.getEnergyCapacity() : 0; - } - - @Override - public void onAdded() - { - super.onAdded(); - - if(MekanismUtils.useIC2()) - { - register(); - } - } + if (!ic2Registered && MekanismUtils.useIC2()) { + register(); + } - @Override - public void onChunkUnload() - { - if(MekanismUtils.useIC2()) - { - deregister(); - } + if (!worldObj.isRemote) { + if (structure != null) { + double prev = getEnergy(); + CableUtils.emit(this); + } + } + } - super.onChunkUnload(); - } + @Override + public EnumSet getOutputtingSides() { + if (structure != null) { + EnumSet set = EnumSet.allOf(ForgeDirection.class); + set.remove(ForgeDirection.UNKNOWN); - @Override - public void invalidate() - { - super.invalidate(); + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + if (structure.locations.contains(Coord4D.get(this).getFromSide(side))) { + set.remove(side); + } + } - if(MekanismUtils.useIC2()) - { - deregister(); - } - } + return set; + } - @Override - public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) - { - return 0; - } + return EnumSet.noneOf(ForgeDirection.class); + } - @Override - public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) - { - if(getOutputtingSides().contains(from)) - { - double toSend = Math.min(getEnergy(), Math.min(getMaxOutput(), maxExtract*general.FROM_TE)); + @Override + public EnumSet getConsumingSides() { + return EnumSet.noneOf(ForgeDirection.class); + } - if(!simulate) - { - setEnergy(getEnergy() - toSend); - } + @Override + public boolean canUpdate() { + return true; + } - return (int)Math.round(toSend*general.TO_TE); - } + @Method(modid = "IC2") + public void register() { + if (!worldObj.isRemote) { + TileEntity registered + = EnergyNet.instance.getTileEntity(worldObj, xCoord, yCoord, zCoord); - return 0; - } + if (registered != this) { + if (registered instanceof IEnergyTile) { + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergyTile + ) registered)); + } else if (registered == null) { + MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this)); + ic2Registered = true; + } + } + } + } - @Override - public boolean canConnectEnergy(ForgeDirection from) - { - return structure != null; - } + @Method(modid = "IC2") + public void deregister() { + if (!worldObj.isRemote) { + TileEntity registered + = EnergyNet.instance.getTileEntity(worldObj, xCoord, yCoord, zCoord); - @Override - public int getEnergyStored(ForgeDirection from) - { - return (int)Math.round(getEnergy()*general.TO_TE); - } + if (registered instanceof IEnergyTile) { + MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergyTile + ) registered)); + } + } + } - @Override - public int getMaxEnergyStored(ForgeDirection from) - { - return (int)Math.round(getMaxEnergy()*general.TO_TE); - } + @Override + public double getMaxOutput() { + return structure != null ? structure.getEnergyCapacity() : 0; + } - @Override - @Method(modid = "IC2") - public int getSinkTier() - { - return 4; - } + @Override + public void onAdded() { + super.onAdded(); - @Override - @Method(modid = "IC2") - public int getSourceTier() - { - return 4; - } + if (MekanismUtils.useIC2()) { + register(); + } + } - @Override - @Method(modid = "IC2") - public void setStored(int energy) - { - setEnergy(energy*general.FROM_IC2); - } + @Override + public void onChunkUnload() { + if (MekanismUtils.useIC2()) { + deregister(); + } - @Override - @Method(modid = "IC2") - public int addEnergy(int amount) - { - return (int)Math.round(getEnergy()*general.TO_IC2); - } + super.onChunkUnload(); + } - @Override - @Method(modid = "IC2") - public boolean isTeleporterCompatible(ForgeDirection side) - { - return canOutputTo(side); - } + @Override + public void invalidate() { + super.invalidate(); - @Override - public boolean canOutputTo(ForgeDirection side) - { - return getOutputtingSides().contains(side); - } + if (MekanismUtils.useIC2()) { + deregister(); + } + } - @Override - @Method(modid = "IC2") - public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) - { - return false; - } + @Override + public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { + return 0; + } - @Override - @Method(modid = "IC2") - public boolean emitsEnergyTo(TileEntity receiver, ForgeDirection direction) - { - return getOutputtingSides().contains(direction) && receiver instanceof IEnergyConductor; - } + @Override + public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) { + if (getOutputtingSides().contains(from)) { + double toSend = Math.min( + getEnergy(), Math.min(getMaxOutput(), maxExtract * general.FROM_TE) + ); - @Override - @Method(modid = "IC2") - public int getStored() - { - return (int)Math.round(getEnergy()*general.TO_IC2); - } + if (!simulate) { + setEnergy(getEnergy() - toSend); + } - @Override - @Method(modid = "IC2") - public int getCapacity() - { - return (int)Math.round(getMaxEnergy()*general.TO_IC2); - } + return (int) Math.round(toSend * general.TO_TE); + } - @Override - @Method(modid = "IC2") - public int getOutput() - { - return (int)Math.round(getMaxOutput()*general.TO_IC2); - } + return 0; + } - @Override - @Method(modid = "IC2") - public double getDemandedEnergy() - { - return 0; - } + @Override + public boolean canConnectEnergy(ForgeDirection from) { + return structure != null; + } - @Override - @Method(modid = "IC2") - public double getOfferedEnergy() - { - return Math.min(getEnergy(), getMaxOutput())*general.TO_IC2; - } + @Override + public int getEnergyStored(ForgeDirection from) { + return (int) Math.round(getEnergy() * general.TO_TE); + } - @Override - public boolean canReceiveEnergy(ForgeDirection side) - { - return false; - } + @Override + public int getMaxEnergyStored(ForgeDirection from) { + return (int) Math.round(getMaxEnergy() * general.TO_TE); + } - @Override - @Method(modid = "IC2") - public double getOutputEnergyUnitsPerTick() - { - return getMaxOutput()*general.TO_IC2; - } + @Override + @Method(modid = "IC2") + public int getSinkTier() { + return 4; + } - @Override - @Method(modid = "IC2") - public double injectEnergy(ForgeDirection direction, double amount, double voltage) - { - return amount; - } + @Override + @Method(modid = "IC2") + public int getSourceTier() { + return 4; + } - @Override - @Method(modid = "IC2") - public void drawEnergy(double amount) - { - if(structure != null) - { - double toDraw = Math.min(amount*general.FROM_IC2, getMaxOutput()); - setEnergy(Math.max(getEnergy() - toDraw, 0)); - } - } + @Override + @Method(modid = "IC2") + public void setStored(int energy) { + setEnergy(energy * general.FROM_IC2); + } - @Override - public double transferEnergyToAcceptor(ForgeDirection side, double amount) - { - return 0; - } + @Override + @Method(modid = "IC2") + public int addEnergy(int amount) { + return (int) Math.round(getEnergy() * general.TO_IC2); + } - @Override - public FluidTankInfo[] getTankInfo(ForgeDirection from) - { - return ((!worldObj.isRemote && structure != null) || (worldObj.isRemote && clientHasStructure)) ? new FluidTankInfo[] {fluidTank.getInfo()} : PipeUtils.EMPTY; - } + @Override + @Method(modid = "IC2") + public boolean isTeleporterCompatible(ForgeDirection side) { + return canOutputTo(side); + } - @Override - public int fill(ForgeDirection from, FluidStack resource, boolean doFill) - { - if(structure == null) - { - return 0; - } - if(resource.getFluid()==FluidRegistry.WATER){ - return 0; - } - int filled = fluidTank.fill(resource, doFill); - if(doFill) - { - structure.newSteamInput += filled; - } + @Override + public boolean canOutputTo(ForgeDirection side) { + return getOutputtingSides().contains(side); + } - if(filled < structure.getFluidCapacity() && structure.dumpMode != GasMode.IDLE) - { - filled = structure.getFluidCapacity(); - } + @Override + @Method(modid = "IC2") + public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) { + return false; + } - return filled; - } + @Override + @Method(modid = "IC2") + public boolean emitsEnergyTo(TileEntity receiver, ForgeDirection direction) { + return getOutputtingSides().contains(direction) + && receiver instanceof IEnergyConductor; + } - @Override - public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) - { - return null; - } + @Override + @Method(modid = "IC2") + public int getStored() { + return (int) Math.round(getEnergy() * general.TO_IC2); + } - @Override - public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) - { - return null; - } + @Override + @Method(modid = "IC2") + public int getCapacity() { + return (int) Math.round(getMaxEnergy() * general.TO_IC2); + } - @Override - public boolean canFill(ForgeDirection from, Fluid fluid) - { - if(fluid == FluidRegistry.getFluid("steam")) - { - return ((!worldObj.isRemote && structure != null) || (!worldObj.isRemote && clientHasStructure)); - } - - return false; - } + @Override + @Method(modid = "IC2") + public int getOutput() { + return (int) Math.round(getMaxOutput() * general.TO_IC2); + } - @Override - public boolean canDrain(ForgeDirection from, Fluid fluid) - { - return false; - } - - @Override - public String getInventoryName() - { - return LangUtils.localize("gui.industrialTurbine"); - } + @Override + @Method(modid = "IC2") + public double getDemandedEnergy() { + return 0; + } + @Override + @Method(modid = "IC2") + public double getOfferedEnergy() { + return Math.min(getEnergy(), getMaxOutput()) * general.TO_IC2; + } + + @Override + public boolean canReceiveEnergy(ForgeDirection side) { + return false; + } + + @Override + @Method(modid = "IC2") + public double getOutputEnergyUnitsPerTick() { + return getMaxOutput() * general.TO_IC2; + } + + @Override + @Method(modid = "IC2") + public double injectEnergy(ForgeDirection direction, double amount, double voltage) { + return amount; + } + + @Override + @Method(modid = "IC2") + public void drawEnergy(double amount) { + if (structure != null) { + double toDraw = Math.min(amount * general.FROM_IC2, getMaxOutput()); + setEnergy(Math.max(getEnergy() - toDraw, 0)); + } + } + + @Override + public double transferEnergyToAcceptor(ForgeDirection side, double amount) { + return 0; + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection from) { + return ((!worldObj.isRemote && structure != null) + || (worldObj.isRemote && clientHasStructure)) + ? new FluidTankInfo[] { fluidTank.getInfo() } + : PipeUtils.EMPTY; + } + + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { + if (structure == null) { + return 0; + } + if (resource.getFluid() == FluidRegistry.WATER) { + return 0; + } + int filled = fluidTank.fill(resource, doFill); + if (doFill) { + structure.newSteamInput += filled; + } + + if (filled < structure.getFluidCapacity() && structure.dumpMode != GasMode.IDLE) { + filled = structure.getFluidCapacity(); + } + + return filled; + } + + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + return null; + } + + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { + return null; + } + + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + if (fluid == FluidRegistry.getFluid("steam")) { + return ( + (!worldObj.isRemote && structure != null) + || (!worldObj.isRemote && clientHasStructure) + ); + } + + return false; + } + + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + return false; + } + + @Override + public String getInventoryName() { + return LangUtils.localize("gui.industrialTurbine"); + } } diff --git a/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineVent.java b/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineVent.java index 65385744c..c58f11522 100644 --- a/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineVent.java +++ b/src/main/java/mekanism/generators/common/tile/turbine/TileEntityTurbineVent.java @@ -10,72 +10,68 @@ import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.IFluidHandler; -public class TileEntityTurbineVent extends TileEntityTurbineCasing implements IFluidHandler -{ - public FluidTankInfo fakeInfo = new FluidTankInfo(null, 1000); - - public TileEntityTurbineVent() - { - super("TurbineVent"); - } - - @Override - public void onUpdate() - { - super.onUpdate(); - - if(structure != null && structure.flowRemaining > 0) - { - FluidStack fluidStack = new FluidStack(FluidRegistry.WATER, structure.flowRemaining); - - for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) - { - TileEntity tile = Coord4D.get(this).getFromSide(side).getTileEntity(worldObj); - - if(tile instanceof IFluidHandler) - { - if(((IFluidHandler)tile).canFill(side.getOpposite(), fluidStack.getFluid())) - { - structure.flowRemaining -= ((IFluidHandler)tile).fill(side.getOpposite(), fluidStack, true); - } - } - } - } - } - - @Override - public FluidTankInfo[] getTankInfo(ForgeDirection from) - { - return ((!worldObj.isRemote && structure != null) || (worldObj.isRemote && clientHasStructure)) ? new FluidTankInfo[] {fakeInfo} : PipeUtils.EMPTY; - } +public class TileEntityTurbineVent + extends TileEntityTurbineCasing implements IFluidHandler { + public FluidTankInfo fakeInfo = new FluidTankInfo(null, 1000); - @Override - public int fill(ForgeDirection from, FluidStack resource, boolean doFill) - { - return 0; - } + public TileEntityTurbineVent() { + super("TurbineVent"); + } - @Override - public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) - { - return null; - } + @Override + public void onUpdate() { + super.onUpdate(); - @Override - public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) - { - return null; - } + if (structure != null && structure.flowRemaining > 0) { + FluidStack fluidStack + = new FluidStack(FluidRegistry.WATER, structure.flowRemaining); - @Override - public boolean canFill(ForgeDirection from, Fluid fluid) - { - return false; - } + for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) { + TileEntity tile + = Coord4D.get(this).getFromSide(side).getTileEntity(worldObj); - @Override - public boolean canDrain(ForgeDirection from, Fluid fluid) - { - return fluid == FluidRegistry.WATER; - } + if (tile instanceof IFluidHandler) { + if (((IFluidHandler) tile) + .canFill(side.getOpposite(), fluidStack.getFluid())) { + structure.flowRemaining + -= ((IFluidHandler) tile) + .fill(side.getOpposite(), fluidStack, true); + } + } + } + } + } + + @Override + public FluidTankInfo[] getTankInfo(ForgeDirection from) { + return ((!worldObj.isRemote && structure != null) + || (worldObj.isRemote && clientHasStructure)) + ? new FluidTankInfo[] { fakeInfo } + : PipeUtils.EMPTY; + } + + @Override + public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { + return 0; + } + + @Override + public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain) { + return null; + } + + @Override + public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) { + return null; + } + + @Override + public boolean canFill(ForgeDirection from, Fluid fluid) { + return false; + } + + @Override + public boolean canDrain(ForgeDirection from, Fluid fluid) { + return fluid == FluidRegistry.WATER; + } } diff --git a/src/main/java/mekanism/tools/client/gui/GuiToolsConfig.java b/src/main/java/mekanism/tools/client/gui/GuiToolsConfig.java index 1f165cc13..8c5d578d4 100644 --- a/src/main/java/mekanism/tools/client/gui/GuiToolsConfig.java +++ b/src/main/java/mekanism/tools/client/gui/GuiToolsConfig.java @@ -3,88 +3,115 @@ package mekanism.tools.client.gui; import java.util.ArrayList; import java.util.List; -import mekanism.common.Mekanism; -import mekanism.common.util.LangUtils; -import net.minecraft.client.gui.GuiScreen; -import net.minecraftforge.common.config.ConfigElement; -import net.minecraftforge.common.config.Configuration; import cpw.mods.fml.client.config.DummyConfigElement.DummyCategoryElement; import cpw.mods.fml.client.config.GuiConfig; import cpw.mods.fml.client.config.GuiConfigEntries; import cpw.mods.fml.client.config.GuiConfigEntries.CategoryEntry; import cpw.mods.fml.client.config.IConfigElement; +import mekanism.common.Mekanism; +import mekanism.common.util.LangUtils; +import net.minecraft.client.gui.GuiScreen; +import net.minecraftforge.common.config.ConfigElement; +import net.minecraftforge.common.config.Configuration; /** * Created by ben on 27/06/14. */ -public class GuiToolsConfig extends GuiConfig -{ - public GuiToolsConfig(GuiScreen parent) - { - super(parent, getConfigElements(), - "MekanismTools", false, false, "MekanismTools"); - } +public class GuiToolsConfig extends GuiConfig { + public GuiToolsConfig(GuiScreen parent) { + super( + parent, getConfigElements(), "MekanismTools", false, false, "MekanismTools" + ); + } - private static List getConfigElements() - { - List list = new ArrayList(); - list.add(new DummyCategoryElement(LangUtils.localize("mekanism.configgui.ctgy.tools.general"), "mekanism.configgui.ctgy.tools.general", GeneralEntry.class)); - list.add(new DummyCategoryElement(LangUtils.localize("mekanism.configgui.ctgy.tools.armor"), "mekanism.configgui.ctgy.tools.armor", ArmorEntry.class)); - list.add(new DummyCategoryElement(LangUtils.localize("mekanism.configgui.ctgy.tools.tools"), "mekanism.configgui.ctgy.tools.tools", ToolsEntry.class)); - return list; - } + private static List getConfigElements() { + List list = new ArrayList(); + list.add(new DummyCategoryElement( + LangUtils.localize("mekanism.configgui.ctgy.tools.general"), + "mekanism.configgui.ctgy.tools.general", + GeneralEntry.class + )); + list.add(new DummyCategoryElement( + LangUtils.localize("mekanism.configgui.ctgy.tools.armor"), + "mekanism.configgui.ctgy.tools.armor", + ArmorEntry.class + )); + list.add(new DummyCategoryElement( + LangUtils.localize("mekanism.configgui.ctgy.tools.tools"), + "mekanism.configgui.ctgy.tools.tools", + ToolsEntry.class + )); + return list; + } - public static class GeneralEntry extends CategoryEntry - { - public GeneralEntry(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement prop) - { - super(owningScreen, owningEntryList, prop); - } + public static class GeneralEntry extends CategoryEntry { + public GeneralEntry( + GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement prop + ) { + super(owningScreen, owningEntryList, prop); + } - @Override - protected GuiScreen buildChildScreen() - { - return new GuiConfig(owningScreen, - new ConfigElement(Mekanism.configuration.getCategory("tools.general")).getChildElements(), - owningScreen.modID, Configuration.CATEGORY_GENERAL, configElement.requiresWorldRestart() || owningScreen.allRequireWorldRestart, - configElement.requiresMcRestart() || owningScreen.allRequireMcRestart, - GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString())); - } - } + @Override + protected GuiScreen buildChildScreen() { + return new GuiConfig( + owningScreen, + new ConfigElement(Mekanism.configuration.getCategory("tools.general")) + .getChildElements(), + owningScreen.modID, + Configuration.CATEGORY_GENERAL, + configElement.requiresWorldRestart() + || owningScreen.allRequireWorldRestart, + configElement.requiresMcRestart() || owningScreen.allRequireMcRestart, + GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString()) + ); + } + } - public static class ArmorEntry extends CategoryEntry - { - public ArmorEntry(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement prop) - { - super(owningScreen, owningEntryList, prop); - } + public static class ArmorEntry extends CategoryEntry { + public ArmorEntry( + GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement prop + ) { + super(owningScreen, owningEntryList, prop); + } - @Override - protected GuiScreen buildChildScreen() - { - return new GuiConfig(owningScreen, - new ConfigElement(Mekanism.configuration.getCategory("tools.armor-balance")).getChildElements(), - owningScreen.modID, Configuration.CATEGORY_GENERAL, configElement.requiresWorldRestart() || owningScreen.allRequireWorldRestart, - configElement.requiresMcRestart() || owningScreen.allRequireMcRestart, - GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString())); - } - } + @Override + protected GuiScreen buildChildScreen() { + return new GuiConfig( + owningScreen, + new ConfigElement(Mekanism.configuration.getCategory("tools.armor-balance" + )) + .getChildElements(), + owningScreen.modID, + Configuration.CATEGORY_GENERAL, + configElement.requiresWorldRestart() + || owningScreen.allRequireWorldRestart, + configElement.requiresMcRestart() || owningScreen.allRequireMcRestart, + GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString()) + ); + } + } - public static class ToolsEntry extends CategoryEntry - { - public ToolsEntry(GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement prop) - { - super(owningScreen, owningEntryList, prop); - } + public static class ToolsEntry extends CategoryEntry { + public ToolsEntry( + GuiConfig owningScreen, GuiConfigEntries owningEntryList, IConfigElement prop + ) { + super(owningScreen, owningEntryList, prop); + } - @Override - protected GuiScreen buildChildScreen() - { - return new GuiConfig(owningScreen, - new ConfigElement(Mekanism.configuration.getCategory("tools.tool-balance")).getChildElements(), - owningScreen.modID, Configuration.CATEGORY_GENERAL, configElement.requiresWorldRestart() || owningScreen.allRequireWorldRestart, - configElement.requiresMcRestart() || owningScreen.allRequireMcRestart, - GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString())); - } - } + @Override + protected GuiScreen buildChildScreen() { + return new GuiConfig( + owningScreen, + new ConfigElement(Mekanism.configuration.getCategory("tools.tool-balance") + ) + .getChildElements(), + owningScreen.modID, + Configuration.CATEGORY_GENERAL, + configElement.requiresWorldRestart() + || owningScreen.allRequireWorldRestart, + configElement.requiresMcRestart() || owningScreen.allRequireMcRestart, + GuiConfig.getAbridgedConfigPath(Mekanism.configuration.toString()) + ); + } + } } diff --git a/src/main/java/mekanism/tools/client/gui/ToolsGuiFactory.java b/src/main/java/mekanism/tools/client/gui/ToolsGuiFactory.java index 12d1ac6ba..0c09f70e9 100644 --- a/src/main/java/mekanism/tools/client/gui/ToolsGuiFactory.java +++ b/src/main/java/mekanism/tools/client/gui/ToolsGuiFactory.java @@ -2,34 +2,26 @@ package mekanism.tools.client.gui; import java.util.Set; +import cpw.mods.fml.client.IModGuiFactory; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; -import cpw.mods.fml.client.IModGuiFactory; -public class ToolsGuiFactory implements IModGuiFactory -{ - @Override - public void initialize(Minecraft minecraftInstance) - { +public class ToolsGuiFactory implements IModGuiFactory { + @Override + public void initialize(Minecraft minecraftInstance) {} - } + @Override + public Class mainConfigGuiClass() { + return GuiToolsConfig.class; + } - @Override - public Class mainConfigGuiClass() - { - return GuiToolsConfig.class; - } + @Override + public Set runtimeGuiCategories() { + return null; + } - @Override - public Set runtimeGuiCategories() - { - return null; - } - - @Override - public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) - { - return null; - } + @Override + public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element) { + return null; + } } - diff --git a/src/main/java/mekanism/tools/common/MekanismTools.java b/src/main/java/mekanism/tools/common/MekanismTools.java index 047e091f1..0e34aa849 100644 --- a/src/main/java/mekanism/tools/common/MekanismTools.java +++ b/src/main/java/mekanism/tools/common/MekanismTools.java @@ -1,9 +1,17 @@ package mekanism.tools.common; -import io.netty.buffer.ByteBuf; - import java.io.IOException; +import cpw.mods.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent; +import cpw.mods.fml.common.FMLCommonHandler; +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.Mod.EventHandler; +import cpw.mods.fml.common.Mod.Instance; +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 io.netty.buffer.ByteBuf; import mekanism.api.MekanismConfig.tools; import mekanism.common.Mekanism; import mekanism.common.base.IModule; @@ -18,547 +26,1157 @@ import net.minecraft.item.crafting.CraftingManager; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.util.EnumHelper; import net.minecraftforge.event.entity.living.LivingSpawnEvent; -import cpw.mods.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent; -import cpw.mods.fml.common.FMLCommonHandler; -import cpw.mods.fml.common.Mod; -import cpw.mods.fml.common.Mod.EventHandler; -import cpw.mods.fml.common.Mod.Instance; -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; -@Mod(modid = "MekanismTools", name = "MekanismTools", version = "GRADLE_MODVERSION", dependencies = "required-after:Mekanism", guiFactory = "mekanism.tools.client.gui.ToolsGuiFactory") -public class MekanismTools implements IModule -{ - @SidedProxy(clientSide = "mekanism.tools.client.ToolsClientProxy", serverSide = "mekanism.tools.common.ToolsCommonProxy") - public static ToolsCommonProxy proxy; - - @Instance("MekanismTools") - public static MekanismTools instance; - - /** MekanismTools version number */ - public static String versionNumber = "GRADLE_MODVERSION"; +@Mod( + modid = "MekanismTools", + name = "MekanismTools", + version = "GRADLE_MODVERSION", + dependencies = "required-after:Mekanism", + guiFactory = "mekanism.tools.client.gui.ToolsGuiFactory" +) +public class MekanismTools implements IModule { + @SidedProxy( + clientSide = "mekanism.tools.client.ToolsClientProxy", + serverSide = "mekanism.tools.common.ToolsCommonProxy" + ) + public static ToolsCommonProxy proxy; - //Enums: Tools - public static ToolMaterial toolOBSIDIAN; - public static ToolMaterial toolOBSIDIAN2; - public static ToolMaterial toolLAZULI; - public static ToolMaterial toolLAZULI2; - public static ToolMaterial toolOSMIUM; - public static ToolMaterial toolOSMIUM2; - public static ToolMaterial toolBRONZE; - public static ToolMaterial toolBRONZE2; - public static ToolMaterial toolGLOWSTONE; - public static ToolMaterial toolGLOWSTONE2; - public static ToolMaterial toolSTEEL; - public static ToolMaterial toolSTEEL2; + @Instance("MekanismTools") + public static MekanismTools instance; - //Enums: Armor - public static ArmorMaterial armorOBSIDIAN; - public static ArmorMaterial armorLAZULI; - public static ArmorMaterial armorOSMIUM; - public static ArmorMaterial armorBRONZE; - public static ArmorMaterial armorGLOWSTONE; - public static ArmorMaterial armorSTEEL; + /** MekanismTools version number */ + public static String versionNumber = "GRADLE_MODVERSION"; - @EventHandler - public void preInit(FMLPreInitializationEvent event) - { - addItems(); - } + //Enums: Tools + public static ToolMaterial toolOBSIDIAN; + public static ToolMaterial toolOBSIDIAN2; + public static ToolMaterial toolLAZULI; + public static ToolMaterial toolLAZULI2; + public static ToolMaterial toolOSMIUM; + public static ToolMaterial toolOSMIUM2; + public static ToolMaterial toolBRONZE; + public static ToolMaterial toolBRONZE2; + public static ToolMaterial toolGLOWSTONE; + public static ToolMaterial toolGLOWSTONE2; + public static ToolMaterial toolSTEEL; + public static ToolMaterial toolSTEEL2; - @EventHandler - public void init(FMLInitializationEvent event) - { - //Add this module to the core list - Mekanism.modulesLoaded.add(this); - - //Register this class to the event bus for special mob spawning (mobs with Mekanism armor/tools) - MinecraftForge.EVENT_BUS.register(this); - FMLCommonHandler.instance().bus().register(this); + //Enums: Armor + public static ArmorMaterial armorOBSIDIAN; + public static ArmorMaterial armorLAZULI; + public static ArmorMaterial armorOSMIUM; + public static ArmorMaterial armorBRONZE; + public static ArmorMaterial armorGLOWSTONE; + public static ArmorMaterial armorSTEEL; - //Load the proxy - proxy.loadConfiguration(); - - //Load this module - addRecipes(); - - //Finalization - Mekanism.logger.info("Loaded MekanismTools module."); - } - - public void addRecipes() - { - //Crafting Recipes - //Base - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.WoodPaxel, 1), new Object[] { - "XYZ", " T ", " T ", Character.valueOf('X'), Items.wooden_axe, Character.valueOf('Y'), Items.wooden_pickaxe, Character.valueOf('Z'), Items.wooden_shovel, Character.valueOf('T'), Items.stick - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.StonePaxel, 1), new Object[] { - "XYZ", " T ", " T ", Character.valueOf('X'), Items.stone_axe, Character.valueOf('Y'), Items.stone_pickaxe, Character.valueOf('Z'), Items.stone_shovel, Character.valueOf('T'), Items.stick - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.IronPaxel, 1), new Object[] { - "XYZ", " T ", " T ", Character.valueOf('X'), Items.iron_axe, Character.valueOf('Y'), Items.iron_pickaxe, Character.valueOf('Z'), Items.iron_shovel, Character.valueOf('T'), Items.stick - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.DiamondPaxel, 1), new Object[] { - "XYZ", " T ", " T ", Character.valueOf('X'), Items.diamond_axe, Character.valueOf('Y'), Items.diamond_pickaxe, Character.valueOf('Z'), Items.diamond_shovel, Character.valueOf('T'), Items.stick - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.GoldPaxel, 1), new Object[] { - "XYZ", " T ", " T ", Character.valueOf('X'), Items.golden_axe, Character.valueOf('Y'), Items.golden_pickaxe, Character.valueOf('Z'), Items.golden_shovel, Character.valueOf('T'), Items.stick - })); - - //Obsidian - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.ObsidianHelmet, 1), new Object[] { - "***", "* *", Character.valueOf('*'), "ingotRefinedObsidian" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.ObsidianChestplate, 1), new Object[] { - "* *", "***", "***", Character.valueOf('*'), "ingotRefinedObsidian" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.ObsidianLeggings, 1), new Object[] { - "***", "* *", "* *", Character.valueOf('*'), "ingotRefinedObsidian" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.ObsidianBoots, 1), new Object[] { - "* *", "* *", Character.valueOf('*'), "ingotRefinedObsidian" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.ObsidianPaxel, 1), new Object[] { - "XYZ", " T ", " T ", Character.valueOf('X'), ToolsItems.ObsidianAxe, Character.valueOf('Y'), ToolsItems.ObsidianPickaxe, Character.valueOf('Z'), ToolsItems.ObsidianShovel, Character.valueOf('T'), Items.stick - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.ObsidianPickaxe, 1), new Object[] { - "XXX", " T ", " T ", Character.valueOf('X'), "ingotRefinedObsidian", Character.valueOf('T'), Items.stick - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.ObsidianAxe, 1), new Object[] { - "XX", "XT", " T", Character.valueOf('X'), "ingotRefinedObsidian", Character.valueOf('T'), Items.stick - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.ObsidianShovel, 1), new Object[] { - "X", "T", "T", Character.valueOf('X'), "ingotRefinedObsidian", Character.valueOf('T'), Items.stick - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.ObsidianHoe, 1), new Object[] { - "XX", " T", " T", Character.valueOf('X'), "ingotRefinedObsidian", Character.valueOf('T'), Items.stick - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.ObsidianSword, 1), new Object[] { - "X", "X", "T", Character.valueOf('X'), "ingotRefinedObsidian", Character.valueOf('T'), Items.stick - })); - - //Glowstone - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.GlowstonePaxel, 1), new Object[] { - "XYZ", " T ", " T ", Character.valueOf('X'), ToolsItems.GlowstoneAxe, Character.valueOf('Y'), ToolsItems.GlowstonePickaxe, Character.valueOf('Z'), ToolsItems.GlowstoneShovel, Character.valueOf('T'), Items.stick - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.GlowstonePickaxe, 1), new Object[] { - "XXX", " T ", " T ", Character.valueOf('X'), "ingotRefinedGlowstone", Character.valueOf('T'), Items.stick - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.GlowstoneAxe, 1), new Object[] { - "XX", "XT", " T", Character.valueOf('X'), "ingotRefinedGlowstone", Character.valueOf('T'), Items.stick - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.GlowstoneShovel, 1), new Object[] { - "X", "T", "T", Character.valueOf('X'), "ingotRefinedGlowstone", Character.valueOf('T'), Items.stick - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.GlowstoneHoe, 1), new Object[] { - "XX", " T", " T", Character.valueOf('X'), "ingotRefinedGlowstone", Character.valueOf('T'), Items.stick - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.GlowstoneSword, 1), new Object[] { - "X", "X", "T", Character.valueOf('X'), "ingotRefinedGlowstone", Character.valueOf('T'), Items.stick - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.GlowstoneHelmet, 1), new Object[] { - "***", "* *", Character.valueOf('*'), "ingotRefinedGlowstone" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.GlowstoneChestplate, 1), new Object[] { - "* *", "***", "***", Character.valueOf('*'), "ingotRefinedGlowstone" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.GlowstoneLeggings, 1), new Object[] { - "***", "* *", "* *", Character.valueOf('*'), "ingotRefinedGlowstone" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.GlowstoneBoots, 1), new Object[] { - "* *", "* *", Character.valueOf('*'), "ingotRefinedGlowstone" - })); - - //Lazuli - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.LazuliHelmet, 1), new Object[] { - "***", "* *", Character.valueOf('*'), new ItemStack(Items.dye, 1, 4) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.LazuliChestplate, 1), new Object[] { - "* *", "***", "***", Character.valueOf('*'), new ItemStack(Items.dye, 1, 4) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.LazuliLeggings, 1), new Object[] { - "***", "* *", "* *", Character.valueOf('*'), new ItemStack(Items.dye, 1, 4) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.LazuliBoots, 1), new Object[] { - "* *", "* *", Character.valueOf('*'), new ItemStack(Items.dye, 1, 4) - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.LazuliPaxel, 1), new Object[] { - "XYZ", " T ", " T ", Character.valueOf('X'), ToolsItems.LazuliAxe, Character.valueOf('Y'), ToolsItems.LazuliPickaxe, Character.valueOf('Z'), ToolsItems.LazuliShovel, Character.valueOf('T'), Items.stick - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.LazuliPickaxe, 1), new Object[] { - "XXX", " T ", " T ", Character.valueOf('X'), new ItemStack(Items.dye, 1, 4), Character.valueOf('T'), Items.stick - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.LazuliAxe, 1), new Object[] { - "XX", "XT", " T", Character.valueOf('X'), new ItemStack(Items.dye, 1, 4), Character.valueOf('T'), Items.stick - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.LazuliShovel, 1), new Object[] { - "X", "T", "T", Character.valueOf('X'), new ItemStack(Items.dye, 1, 4), Character.valueOf('T'), Items.stick - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.LazuliHoe, 1), new Object[] { - "XX", " T", " T", Character.valueOf('X'), new ItemStack(Items.dye, 1, 4), Character.valueOf('T'), Items.stick - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.LazuliSword, 1), new Object[] { - "X", "X", "T", Character.valueOf('X'), new ItemStack(Items.dye, 1, 4), Character.valueOf('T'), Items.stick - })); - - //Osmium - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.OsmiumPaxel, 1), new Object[] { - "XYZ", " T ", " T ", Character.valueOf('X'), ToolsItems.OsmiumAxe, Character.valueOf('Y'), ToolsItems.OsmiumPickaxe, Character.valueOf('Z'), ToolsItems.OsmiumShovel, Character.valueOf('T'), Items.stick - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.OsmiumPickaxe, 1), new Object[] { - "XXX", " T ", " T ", Character.valueOf('X'), "ingotOsmium", Character.valueOf('T'), Items.stick - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.OsmiumAxe, 1), new Object[] { - "XX", "XT", " T", Character.valueOf('X'), "ingotOsmium", Character.valueOf('T'), Items.stick - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.OsmiumShovel, 1), new Object[] { - "X", "T", "T", Character.valueOf('X'), "ingotOsmium", Character.valueOf('T'), Items.stick - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.OsmiumHoe, 1), new Object[] { - "XX", " T", " T", Character.valueOf('X'), "ingotOsmium", Character.valueOf('T'), Items.stick - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.OsmiumSword, 1), new Object[] { - "X", "X", "T", Character.valueOf('X'), "ingotOsmium", Character.valueOf('T'), Items.stick - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.OsmiumHelmet, 1), new Object[] { - "***", "* *", Character.valueOf('*'), "ingotOsmium" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.OsmiumChestplate, 1), new Object[] { - "* *", "***", "***", Character.valueOf('*'), "ingotOsmium" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.OsmiumLeggings, 1), new Object[] { - "***", "* *", "* *", Character.valueOf('*'), "ingotOsmium" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.OsmiumBoots, 1), new Object[] { - "* *", "* *", Character.valueOf('*'), "ingotOsmium" - })); - - //Bronze - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.BronzePaxel, 1), new Object[] { - "XYZ", " T ", " T ", Character.valueOf('X'), ToolsItems.BronzeAxe, Character.valueOf('Y'), ToolsItems.BronzePickaxe, Character.valueOf('Z'), ToolsItems.BronzeShovel, Character.valueOf('T'), Items.stick - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.BronzePickaxe, 1), new Object[] { - "XXX", " T ", " T ", Character.valueOf('X'), "ingotBronze", Character.valueOf('T'), Items.stick - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.BronzeAxe, 1), new Object[] { - "XX", "XT", " T", Character.valueOf('X'), "ingotBronze", Character.valueOf('T'), Items.stick - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.BronzeShovel, 1), new Object[] { - "X", "T", "T", Character.valueOf('X'), "ingotBronze", Character.valueOf('T'), Items.stick - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.BronzeHoe, 1), new Object[] { - "XX", " T", " T", Character.valueOf('X'), "ingotBronze", Character.valueOf('T'), Items.stick - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.BronzeSword, 1), new Object[] { - "X", "X", "T", Character.valueOf('X'), "ingotBronze", Character.valueOf('T'), Items.stick - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.BronzeHelmet, 1), new Object[] { - "***", "* *", Character.valueOf('*'), "ingotBronze" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.BronzeChestplate, 1), new Object[] { - "* *", "***", "***", Character.valueOf('*'), "ingotBronze" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.BronzeLeggings, 1), new Object[] { - "***", "* *", "* *", Character.valueOf('*'), "ingotBronze" - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.BronzeBoots, 1), new Object[] { - "* *", "* *", Character.valueOf('*'), "ingotBronze" - })); - - //Steel - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.SteelPaxel, 1), new Object[] { - "XYZ", " I ", " I ", Character.valueOf('X'), ToolsItems.SteelAxe, Character.valueOf('Y'), ToolsItems.SteelPickaxe, Character.valueOf('Z'), ToolsItems.SteelShovel, Character.valueOf('I'), Items.iron_ingot - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.SteelPickaxe, 1), new Object[] { - "XXX", " I ", " I ", Character.valueOf('X'), "ingotSteel", Character.valueOf('I'), Items.iron_ingot - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.SteelAxe, 1), new Object[] { - "XX", "XI", " I", Character.valueOf('X'), "ingotSteel", Character.valueOf('I'), Items.iron_ingot - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.SteelShovel, 1), new Object[] { - "X", "I", "I", Character.valueOf('X'), "ingotSteel", Character.valueOf('I'), Items.iron_ingot - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.SteelHoe, 1), new Object[] { - "XX", " I", " I", Character.valueOf('X'), "ingotSteel", Character.valueOf('I'), Items.iron_ingot - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.SteelSword, 1), new Object[] { - "X", "X", "I", Character.valueOf('X'), "ingotSteel", Character.valueOf('I'), Items.iron_ingot - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.SteelHelmet, 1), new Object[] { - "***", "I I", Character.valueOf('*'), "ingotSteel", Character.valueOf('I'), Items.iron_ingot - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.SteelChestplate, 1), new Object[] { - "I I", "*I*", "***", Character.valueOf('*'), "ingotSteel", Character.valueOf('I'), Items.iron_ingot - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.SteelLeggings, 1), new Object[] { - "I*I", "* *", "* *", Character.valueOf('*'), "ingotSteel", Character.valueOf('I'), Items.iron_ingot - })); - CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe(new ItemStack(ToolsItems.SteelBoots, 1), new Object[] { - "I *", "* I", Character.valueOf('*'), "ingotSteel", Character.valueOf('I'), Items.iron_ingot - })); - } - - public void addItems() - { - //Tools - toolOBSIDIAN = EnumHelper.addToolMaterial("OBSIDIAN" - , Mekanism.configuration.get("tools.tool-balance.obsidian.regular", "harvestLevel", 3).getInt() - , Mekanism.configuration.get("tools.tool-balance.obsidian.regular", "maxUses", 2500).getInt() - , (float)Mekanism.configuration.get("tools.tool-balance.obsidian.regular", "efficiency", 20d).getDouble(0) - , Mekanism.configuration.get("tools.tool-balance.obsidian.regular", "damage", 10).getInt() - , Mekanism.configuration.get("tools.tool-balance.obsidian.regular", "enchantability", 40).getInt() - ); - toolOBSIDIAN2 = EnumHelper.addToolMaterial("OBSIDIAN2" - , Mekanism.configuration.get("tools.tool-balance.obsidian.paxel", "harvestLevel", 3).getInt() - , Mekanism.configuration.get("tools.tool-balance.obsidian.paxel", "maxUses", 3000).getInt() - , (float)Mekanism.configuration.get("tools.tool-balance.obsidian.paxel", "efficiency", 25d).getDouble(0) - , Mekanism.configuration.get("tools.tool-balance.obsidian.paxel", "damage", 10).getInt() - , Mekanism.configuration.get("tools.tool-balance.obsidian.paxel", "enchantability", 50).getInt() - ); - toolLAZULI = EnumHelper.addToolMaterial("LAZULI" - , Mekanism.configuration.get("tools.tool-balance.lapis.regular", "harvestLevel", 2).getInt() - , Mekanism.configuration.get("tools.tool-balance.lapis.regular", "maxUses", 200).getInt() - , (float)Mekanism.configuration.get("tools.tool-balance.lapis.regular", "efficiency", 5d).getDouble(0) - , Mekanism.configuration.get("tools.tool-balance.lapis.regular", "damage", 2).getInt() - , Mekanism.configuration.get("tools.tool-balance.lapis.regular", "enchantability", 8).getInt() - ); - toolLAZULI2 = EnumHelper.addToolMaterial("LAZULI2" - , Mekanism.configuration.get("tools.tool-balance.lapis.paxel", "harvestLevel", 2).getInt() - , Mekanism.configuration.get("tools.tool-balance.lapis.paxel", "maxUses", 250).getInt() - , (float)Mekanism.configuration.get("tools.tool-balance.lapis.paxel", "efficiency", 6d).getDouble(0) - , Mekanism.configuration.get("tools.tool-balance.lapis.paxel", "damage", 4).getInt() - , Mekanism.configuration.get("tools.tool-balance.lapis.paxel", "enchantability", 10).getInt() - ); - toolOSMIUM = EnumHelper.addToolMaterial("OSMIUM" - , Mekanism.configuration.get("tools.tool-balance.osmium.regular", "harvestLevel", 2).getInt() - , Mekanism.configuration.get("tools.tool-balance.osmium.regular", "maxUses", 500).getInt() - , (float)Mekanism.configuration.get("tools.tool-balance.osmium.regular", "efficiency", 10d).getDouble(0) - , Mekanism.configuration.get("tools.tool-balance.osmium.regular", "damage", 4).getInt() - , Mekanism.configuration.get("tools.tool-balance.osmium.regular", "enchantability", 12).getInt() - ); - toolOSMIUM2 = EnumHelper.addToolMaterial("OSMIUM2" - , Mekanism.configuration.get("tools.tool-balance.osmium.paxel", "harvestLevel", 3).getInt() - , Mekanism.configuration.get("tools.tool-balance.osmium.paxel", "maxUses", 700).getInt() - , (float)Mekanism.configuration.get("tools.tool-balance.osmium.paxel", "efficiency", 12d).getDouble(0) - , Mekanism.configuration.get("tools.tool-balance.osmium.paxel", "damage", 5).getInt() - , Mekanism.configuration.get("tools.tool-balance.osmium.paxel", "enchantability", 16).getInt() - ); - toolBRONZE = EnumHelper.addToolMaterial("BRONZE" - , Mekanism.configuration.get("tools.tool-balance.bronze.regular", "harvestLevel", 2).getInt() - , Mekanism.configuration.get("tools.tool-balance.bronze.regular", "maxUses", 800).getInt() - , (float)Mekanism.configuration.get("tools.tool-balance.bronze.regular", "efficiency", 14d).getDouble(0) - , Mekanism.configuration.get("tools.tool-balance.bronze.regular", "damage", 6).getInt() - , Mekanism.configuration.get("tools.tool-balance.bronze.regular", "enchantability", 10).getInt() - ); - toolBRONZE2 = EnumHelper.addToolMaterial("BRONZE2" - , Mekanism.configuration.get("tools.tool-balance.bronze.paxel", "harvestLevel", 3).getInt() - , Mekanism.configuration.get("tools.tool-balance.bronze.paxel", "maxUses", 1100).getInt() - , (float)Mekanism.configuration.get("tools.tool-balance.bronze.paxel", "efficiency", 16d).getDouble(0) - , Mekanism.configuration.get("tools.tool-balance.bronze.paxel", "damage", 10).getInt() - , Mekanism.configuration.get("tools.tool-balance.bronze.paxel", "enchantability", 14).getInt() - ); - toolGLOWSTONE = EnumHelper.addToolMaterial("GLOWSTONE" - , Mekanism.configuration.get("tools.tool-balance.glowstone.regular", "harvestLevel", 2).getInt() - , Mekanism.configuration.get("tools.tool-balance.glowstone.regular", "maxUses", 300).getInt() - , (float)Mekanism.configuration.get("tools.tool-balance.glowstone.regular", "efficiency", 14d).getDouble(0) - , Mekanism.configuration.get("tools.tool-balance.glowstone.regular", "damage", 5).getInt() - , Mekanism.configuration.get("tools.tool-balance.glowstone.regular", "enchantability", 18).getInt() - ); - toolGLOWSTONE2 = EnumHelper.addToolMaterial("GLOWSTONE2" - , Mekanism.configuration.get("tools.tool-balance.glowstone.paxel", "harvestLevel", 2).getInt() - , Mekanism.configuration.get("tools.tool-balance.glowstone.paxel", "maxUses", 450).getInt() - , (float)Mekanism.configuration.get("tools.tool-balance.glowstone.paxel", "efficiency", 18d).getDouble(0) - , Mekanism.configuration.get("tools.tool-balance.glowstone.paxel", "damage", 5).getInt() - , Mekanism.configuration.get("tools.tool-balance.glowstone.paxel", "enchantability", 22).getInt() - ); - toolSTEEL = EnumHelper.addToolMaterial("STEEL" - , Mekanism.configuration.get("tools.tool-balance.steel.regular", "harvestLevel", 3).getInt() - , Mekanism.configuration.get("tools.tool-balance.steel.regular", "maxUses", 850).getInt() - , (float)Mekanism.configuration.get("tools.tool-balance.steel.regular", "efficiency", 14d).getDouble(0) - , Mekanism.configuration.get("tools.tool-balance.steel.regular", "damage", 4).getInt() - , Mekanism.configuration.get("tools.tool-balance.steel.regular", "enchantability", 10).getInt() - ); - toolSTEEL2 = EnumHelper.addToolMaterial("STEEL2" - , Mekanism.configuration.get("tools.tool-balance.steel.paxel", "harvestLevel", 3).getInt() - , Mekanism.configuration.get("tools.tool-balance.steel.paxel", "maxUses", 1250).getInt() - , (float)Mekanism.configuration.get("tools.tool-balance.steel.paxel", "efficiency", 18d).getDouble(0) - , Mekanism.configuration.get("tools.tool-balance.steel.paxel", "damage", 8).getInt() - , Mekanism.configuration.get("tools.tool-balance.steel.paxel", "enchantability", 14).getInt() - ); + @EventHandler + public void preInit(FMLPreInitializationEvent event) { + addItems(); + } - //Armors - armorOBSIDIAN = EnumHelper.addArmorMaterial("OBSIDIAN" - , Mekanism.configuration.get("tools.armor-balance.obsidian", "durability", 50).getInt() - , new int[] - { - Mekanism.configuration.get("tools.armor-balance.obsidian.protection", "head", 5).getInt() - , Mekanism.configuration.get("tools.armor-balance.obsidian.protection", "chest", 12).getInt() - , Mekanism.configuration.get("tools.armor-balance.obsidian.protection", "legs", 8).getInt() - , Mekanism.configuration.get("tools.armor-balance.obsidian.protection", "feet", 5).getInt() - } - , Mekanism.configuration.get("tools.armor-balance.obsidian", "enchantability", 40).getInt() - ); - armorLAZULI = EnumHelper.addArmorMaterial("LAZULI" - , Mekanism.configuration.get("tools.armor-balance.lapis", "durability", 13).getInt() - , new int[] - { - Mekanism.configuration.get("tools.armor-balance.lapis.protection", "head", 2).getInt() - , Mekanism.configuration.get("tools.armor-balance.lapis.protection", "chest", 5).getInt() - , Mekanism.configuration.get("tools.armor-balance.lapis.protection", "legs", 6).getInt() - , Mekanism.configuration.get("tools.armor-balance.lapis.protection", "feet", 2).getInt() - } - , Mekanism.configuration.get("tools.armor-balance.lapis", "enchantability", 8).getInt() - ); - armorOSMIUM = EnumHelper.addArmorMaterial("OSMIUM" - , Mekanism.configuration.get("tools.armor-balance.osmium", "durability", 30).getInt() - , new int[] - { - Mekanism.configuration.get("tools.armor-balance.osmium.protection", "head", 3).getInt() - , Mekanism.configuration.get("tools.armor-balance.osmium.protection", "chest", 5).getInt() - , Mekanism.configuration.get("tools.armor-balance.osmium.protection", "legs", 6).getInt() - , Mekanism.configuration.get("tools.armor-balance.osmium.protection", "feet", 3).getInt() - } - , Mekanism.configuration.get("tools.armor-balance.osmium", "enchantability", 12).getInt() - ); - armorBRONZE = EnumHelper.addArmorMaterial("BRONZE" - , Mekanism.configuration.get("tools.armor-balance.bronze", "durability", 35).getInt() - , new int[] - { - Mekanism.configuration.get("tools.armor-balance.bronze.protection", "head", 3).getInt() - , Mekanism.configuration.get("tools.armor-balance.bronze.protection", "chest", 6).getInt() - , Mekanism.configuration.get("tools.armor-balance.bronze.protection", "legs", 5).getInt() - , Mekanism.configuration.get("tools.armor-balance.bronze.protection", "feet", 2).getInt() - } - , Mekanism.configuration.get("tools.armor-balance.bronze", "enchantability", 10).getInt() - ); - armorGLOWSTONE = EnumHelper.addArmorMaterial("GLOWSTONE" - , Mekanism.configuration.get("tools.armor-balance.glowstone", "durability", 18).getInt() - , new int[] - { - Mekanism.configuration.get("tools.armor-balance.glowstone.protection", "head", 3).getInt() - , Mekanism.configuration.get("tools.armor-balance.glowstone.protection", "chest", 7).getInt() - , Mekanism.configuration.get("tools.armor-balance.glowstone.protection", "legs", 6).getInt() - , Mekanism.configuration.get("tools.armor-balance.glowstone.protection", "feet", 3).getInt() - } - , Mekanism.configuration.get("tools.armor-balance.glowstone", "enchantability", 18).getInt() - ); - armorSTEEL = EnumHelper.addArmorMaterial("STEEL" - , Mekanism.configuration.get("tools.armor-balance.steel", "durability", 40).getInt() - , new int[] - { - Mekanism.configuration.get("tools.armor-balance.steel.protection", "head", 3).getInt() - , Mekanism.configuration.get("tools.armor-balance.steel.protection", "chest", 7).getInt() - , Mekanism.configuration.get("tools.armor-balance.steel.protection", "legs", 6).getInt() - , Mekanism.configuration.get("tools.armor-balance.steel.protection", "feet", 3).getInt() - } - , Mekanism.configuration.get("tools.armor-balance.steel", "enchantability", 10).getInt() - ); - if(Mekanism.configuration.hasChanged()) - { - Mekanism.configuration.save(); - } + @EventHandler + public void init(FMLInitializationEvent event) { + //Add this module to the core list + Mekanism.modulesLoaded.add(this); - ToolsItems.initializeItems(); - ToolsItems.setHarvestLevels(); - ToolsItems.register(); - } + //Register this class to the event bus for special mob spawning (mobs with + //Mekanism armor/tools) + MinecraftForge.EVENT_BUS.register(this); + FMLCommonHandler.instance().bus().register(this); - @SubscribeEvent - public void onLivingSpecialSpawn(LivingSpawnEvent event) - { - double chance = event.world.rand.nextDouble(); - int armorType = event.world.rand.nextInt(4); - - if(chance < tools.armorSpawnRate) - { - if(event.entityLiving instanceof EntityZombie || event.entityLiving instanceof EntitySkeleton) - { - int sword = event.world.rand.nextInt(100); - int helmet = event.world.rand.nextInt(100); - int chestplate = event.world.rand.nextInt(100); - int leggings = event.world.rand.nextInt(100); - int boots = event.world.rand.nextInt(100); - - if(armorType == 0) - { - if(event.entityLiving instanceof EntityZombie && sword < 50) event.entityLiving.setCurrentItemOrArmor(0, new ItemStack(ToolsItems.GlowstoneSword)); - if(helmet < 50) event.entityLiving.setCurrentItemOrArmor(1, new ItemStack(ToolsItems.GlowstoneHelmet)); - if(chestplate < 50) event.entityLiving.setCurrentItemOrArmor(2, new ItemStack(ToolsItems.GlowstoneChestplate)); - if(leggings < 50) event.entityLiving.setCurrentItemOrArmor(3, new ItemStack(ToolsItems.GlowstoneLeggings)); - if(boots < 50) event.entityLiving.setCurrentItemOrArmor(4, new ItemStack(ToolsItems.GlowstoneBoots)); - } - else if(armorType == 1) - { - if(event.entityLiving instanceof EntityZombie && sword < 50) event.entityLiving.setCurrentItemOrArmor(0, new ItemStack(ToolsItems.LazuliSword)); - if(helmet < 50) event.entityLiving.setCurrentItemOrArmor(1, new ItemStack(ToolsItems.LazuliHelmet)); - if(chestplate < 50) event.entityLiving.setCurrentItemOrArmor(2, new ItemStack(ToolsItems.LazuliChestplate)); - if(leggings < 50) event.entityLiving.setCurrentItemOrArmor(3, new ItemStack(ToolsItems.LazuliLeggings)); - if(boots < 50) event.entityLiving.setCurrentItemOrArmor(4, new ItemStack(ToolsItems.LazuliBoots)); - } - else if(armorType == 2) - { - if(event.entityLiving instanceof EntityZombie && sword < 50) event.entityLiving.setCurrentItemOrArmor(0, new ItemStack(ToolsItems.OsmiumSword)); - if(helmet < 50) event.entityLiving.setCurrentItemOrArmor(1, new ItemStack(ToolsItems.OsmiumHelmet)); - if(chestplate < 50) event.entityLiving.setCurrentItemOrArmor(2, new ItemStack(ToolsItems.OsmiumChestplate)); - if(leggings < 50) event.entityLiving.setCurrentItemOrArmor(3, new ItemStack(ToolsItems.OsmiumLeggings)); - if(boots < 50) event.entityLiving.setCurrentItemOrArmor(4, new ItemStack(ToolsItems.OsmiumBoots)); - } - else if(armorType == 3) - { - if(event.entityLiving instanceof EntityZombie && sword < 50) event.entityLiving.setCurrentItemOrArmor(0, new ItemStack(ToolsItems.SteelSword)); - if(helmet < 50) event.entityLiving.setCurrentItemOrArmor(1, new ItemStack(ToolsItems.SteelHelmet)); - if(chestplate < 50) event.entityLiving.setCurrentItemOrArmor(2, new ItemStack(ToolsItems.SteelChestplate)); - if(leggings < 50) event.entityLiving.setCurrentItemOrArmor(3, new ItemStack(ToolsItems.SteelLeggings)); - if(boots < 50) event.entityLiving.setCurrentItemOrArmor(4, new ItemStack(ToolsItems.SteelBoots)); - } - else if(armorType == 4) - { - if(event.entityLiving instanceof EntityZombie && sword < 50) event.entityLiving.setCurrentItemOrArmor(0, new ItemStack(ToolsItems.BronzeSword)); - if(helmet < 50) event.entityLiving.setCurrentItemOrArmor(1, new ItemStack(ToolsItems.BronzeHelmet)); - if(chestplate < 50) event.entityLiving.setCurrentItemOrArmor(2, new ItemStack(ToolsItems.BronzeChestplate)); - if(leggings < 50) event.entityLiving.setCurrentItemOrArmor(3, new ItemStack(ToolsItems.BronzeLeggings)); - if(boots < 50) event.entityLiving.setCurrentItemOrArmor(4, new ItemStack(ToolsItems.BronzeBoots)); - } - } - } - } + //Load the proxy + proxy.loadConfiguration(); - @Override - public String getVersion() - { - return versionNumber; - } + //Load this module + addRecipes(); - @Override - public String getName() - { - return "Tools"; - } + //Finalization + Mekanism.logger.info("Loaded MekanismTools module."); + } - @Override - public void writeConfig(ByteBuf dataStream) throws IOException - { - dataStream.writeDouble(tools.armorSpawnRate); - } + public void addRecipes() { + //Crafting Recipes + //Base + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.WoodPaxel, 1), + new Object[] { "XYZ", + " T ", + " T ", + Character.valueOf('X'), + Items.wooden_axe, + Character.valueOf('Y'), + Items.wooden_pickaxe, + Character.valueOf('Z'), + Items.wooden_shovel, + Character.valueOf('T'), + Items.stick } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.StonePaxel, 1), + new Object[] { "XYZ", + " T ", + " T ", + Character.valueOf('X'), + Items.stone_axe, + Character.valueOf('Y'), + Items.stone_pickaxe, + Character.valueOf('Z'), + Items.stone_shovel, + Character.valueOf('T'), + Items.stick } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.IronPaxel, 1), + new Object[] { "XYZ", + " T ", + " T ", + Character.valueOf('X'), + Items.iron_axe, + Character.valueOf('Y'), + Items.iron_pickaxe, + Character.valueOf('Z'), + Items.iron_shovel, + Character.valueOf('T'), + Items.stick } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.DiamondPaxel, 1), + new Object[] { "XYZ", + " T ", + " T ", + Character.valueOf('X'), + Items.diamond_axe, + Character.valueOf('Y'), + Items.diamond_pickaxe, + Character.valueOf('Z'), + Items.diamond_shovel, + Character.valueOf('T'), + Items.stick } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.GoldPaxel, 1), + new Object[] { "XYZ", + " T ", + " T ", + Character.valueOf('X'), + Items.golden_axe, + Character.valueOf('Y'), + Items.golden_pickaxe, + Character.valueOf('Z'), + Items.golden_shovel, + Character.valueOf('T'), + Items.stick } + )); - @Override - public void readConfig(ByteBuf dataStream) throws IOException - { - tools.armorSpawnRate = dataStream.readDouble(); - } - - @Override - public void resetClient() {} + //Obsidian + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.ObsidianHelmet, 1), + new Object[] { "***", "* *", Character.valueOf('*'), "ingotRefinedObsidian" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.ObsidianChestplate, 1), + new Object[] { + "* *", "***", "***", Character.valueOf('*'), "ingotRefinedObsidian" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.ObsidianLeggings, 1), + new Object[] { + "***", "* *", "* *", Character.valueOf('*'), "ingotRefinedObsidian" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.ObsidianBoots, 1), + new Object[] { "* *", "* *", Character.valueOf('*'), "ingotRefinedObsidian" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.ObsidianPaxel, 1), + new Object[] { "XYZ", + " T ", + " T ", + Character.valueOf('X'), + ToolsItems.ObsidianAxe, + Character.valueOf('Y'), + ToolsItems.ObsidianPickaxe, + Character.valueOf('Z'), + ToolsItems.ObsidianShovel, + Character.valueOf('T'), + Items.stick } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.ObsidianPickaxe, 1), + new Object[] { "XXX", + " T ", + " T ", + Character.valueOf('X'), + "ingotRefinedObsidian", + Character.valueOf('T'), + Items.stick } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.ObsidianAxe, 1), + new Object[] { "XX", + "XT", + " T", + Character.valueOf('X'), + "ingotRefinedObsidian", + Character.valueOf('T'), + Items.stick } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.ObsidianShovel, 1), + new Object[] { "X", + "T", + "T", + Character.valueOf('X'), + "ingotRefinedObsidian", + Character.valueOf('T'), + Items.stick } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.ObsidianHoe, 1), + new Object[] { "XX", + " T", + " T", + Character.valueOf('X'), + "ingotRefinedObsidian", + Character.valueOf('T'), + Items.stick } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.ObsidianSword, 1), + new Object[] { "X", + "X", + "T", + Character.valueOf('X'), + "ingotRefinedObsidian", + Character.valueOf('T'), + Items.stick } + )); - @SubscribeEvent - public void onConfigChanged(OnConfigChangedEvent event) - { - if(event.modID.equals("MekanismTools")) - { - proxy.loadConfiguration(); - } - } + //Glowstone + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.GlowstonePaxel, 1), + new Object[] { "XYZ", + " T ", + " T ", + Character.valueOf('X'), + ToolsItems.GlowstoneAxe, + Character.valueOf('Y'), + ToolsItems.GlowstonePickaxe, + Character.valueOf('Z'), + ToolsItems.GlowstoneShovel, + Character.valueOf('T'), + Items.stick } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.GlowstonePickaxe, 1), + new Object[] { "XXX", + " T ", + " T ", + Character.valueOf('X'), + "ingotRefinedGlowstone", + Character.valueOf('T'), + Items.stick } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.GlowstoneAxe, 1), + new Object[] { "XX", + "XT", + " T", + Character.valueOf('X'), + "ingotRefinedGlowstone", + Character.valueOf('T'), + Items.stick } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.GlowstoneShovel, 1), + new Object[] { "X", + "T", + "T", + Character.valueOf('X'), + "ingotRefinedGlowstone", + Character.valueOf('T'), + Items.stick } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.GlowstoneHoe, 1), + new Object[] { "XX", + " T", + " T", + Character.valueOf('X'), + "ingotRefinedGlowstone", + Character.valueOf('T'), + Items.stick } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.GlowstoneSword, 1), + new Object[] { "X", + "X", + "T", + Character.valueOf('X'), + "ingotRefinedGlowstone", + Character.valueOf('T'), + Items.stick } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.GlowstoneHelmet, 1), + new Object[] { "***", "* *", Character.valueOf('*'), "ingotRefinedGlowstone" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.GlowstoneChestplate, 1), + new Object[] { + "* *", "***", "***", Character.valueOf('*'), "ingotRefinedGlowstone" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.GlowstoneLeggings, 1), + new Object[] { + "***", "* *", "* *", Character.valueOf('*'), "ingotRefinedGlowstone" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.GlowstoneBoots, 1), + new Object[] { "* *", "* *", Character.valueOf('*'), "ingotRefinedGlowstone" } + )); + + //Lazuli + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.LazuliHelmet, 1), + new Object[] { + "***", "* *", Character.valueOf('*'), new ItemStack(Items.dye, 1, 4) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.LazuliChestplate, 1), + new Object[] { "* *", + "***", + "***", + Character.valueOf('*'), + new ItemStack(Items.dye, 1, 4) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.LazuliLeggings, 1), + new Object[] { "***", + "* *", + "* *", + Character.valueOf('*'), + new ItemStack(Items.dye, 1, 4) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.LazuliBoots, 1), + new Object[] { + "* *", "* *", Character.valueOf('*'), new ItemStack(Items.dye, 1, 4) } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.LazuliPaxel, 1), + new Object[] { "XYZ", + " T ", + " T ", + Character.valueOf('X'), + ToolsItems.LazuliAxe, + Character.valueOf('Y'), + ToolsItems.LazuliPickaxe, + Character.valueOf('Z'), + ToolsItems.LazuliShovel, + Character.valueOf('T'), + Items.stick } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.LazuliPickaxe, 1), + new Object[] { "XXX", + " T ", + " T ", + Character.valueOf('X'), + new ItemStack(Items.dye, 1, 4), + Character.valueOf('T'), + Items.stick } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.LazuliAxe, 1), + new Object[] { "XX", + "XT", + " T", + Character.valueOf('X'), + new ItemStack(Items.dye, 1, 4), + Character.valueOf('T'), + Items.stick } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.LazuliShovel, 1), + new Object[] { "X", + "T", + "T", + Character.valueOf('X'), + new ItemStack(Items.dye, 1, 4), + Character.valueOf('T'), + Items.stick } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.LazuliHoe, 1), + new Object[] { "XX", + " T", + " T", + Character.valueOf('X'), + new ItemStack(Items.dye, 1, 4), + Character.valueOf('T'), + Items.stick } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.LazuliSword, 1), + new Object[] { "X", + "X", + "T", + Character.valueOf('X'), + new ItemStack(Items.dye, 1, 4), + Character.valueOf('T'), + Items.stick } + )); + + //Osmium + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.OsmiumPaxel, 1), + new Object[] { "XYZ", + " T ", + " T ", + Character.valueOf('X'), + ToolsItems.OsmiumAxe, + Character.valueOf('Y'), + ToolsItems.OsmiumPickaxe, + Character.valueOf('Z'), + ToolsItems.OsmiumShovel, + Character.valueOf('T'), + Items.stick } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.OsmiumPickaxe, 1), + new Object[] { "XXX", + " T ", + " T ", + Character.valueOf('X'), + "ingotOsmium", + Character.valueOf('T'), + Items.stick } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.OsmiumAxe, 1), + new Object[] { "XX", + "XT", + " T", + Character.valueOf('X'), + "ingotOsmium", + Character.valueOf('T'), + Items.stick } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.OsmiumShovel, 1), + new Object[] { "X", + "T", + "T", + Character.valueOf('X'), + "ingotOsmium", + Character.valueOf('T'), + Items.stick } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.OsmiumHoe, 1), + new Object[] { "XX", + " T", + " T", + Character.valueOf('X'), + "ingotOsmium", + Character.valueOf('T'), + Items.stick } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.OsmiumSword, 1), + new Object[] { "X", + "X", + "T", + Character.valueOf('X'), + "ingotOsmium", + Character.valueOf('T'), + Items.stick } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.OsmiumHelmet, 1), + new Object[] { "***", "* *", Character.valueOf('*'), "ingotOsmium" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.OsmiumChestplate, 1), + new Object[] { "* *", "***", "***", Character.valueOf('*'), "ingotOsmium" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.OsmiumLeggings, 1), + new Object[] { "***", "* *", "* *", Character.valueOf('*'), "ingotOsmium" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.OsmiumBoots, 1), + new Object[] { "* *", "* *", Character.valueOf('*'), "ingotOsmium" } + )); + + //Bronze + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.BronzePaxel, 1), + new Object[] { "XYZ", + " T ", + " T ", + Character.valueOf('X'), + ToolsItems.BronzeAxe, + Character.valueOf('Y'), + ToolsItems.BronzePickaxe, + Character.valueOf('Z'), + ToolsItems.BronzeShovel, + Character.valueOf('T'), + Items.stick } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.BronzePickaxe, 1), + new Object[] { "XXX", + " T ", + " T ", + Character.valueOf('X'), + "ingotBronze", + Character.valueOf('T'), + Items.stick } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.BronzeAxe, 1), + new Object[] { "XX", + "XT", + " T", + Character.valueOf('X'), + "ingotBronze", + Character.valueOf('T'), + Items.stick } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.BronzeShovel, 1), + new Object[] { "X", + "T", + "T", + Character.valueOf('X'), + "ingotBronze", + Character.valueOf('T'), + Items.stick } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.BronzeHoe, 1), + new Object[] { "XX", + " T", + " T", + Character.valueOf('X'), + "ingotBronze", + Character.valueOf('T'), + Items.stick } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.BronzeSword, 1), + new Object[] { "X", + "X", + "T", + Character.valueOf('X'), + "ingotBronze", + Character.valueOf('T'), + Items.stick } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.BronzeHelmet, 1), + new Object[] { "***", "* *", Character.valueOf('*'), "ingotBronze" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.BronzeChestplate, 1), + new Object[] { "* *", "***", "***", Character.valueOf('*'), "ingotBronze" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.BronzeLeggings, 1), + new Object[] { "***", "* *", "* *", Character.valueOf('*'), "ingotBronze" } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.BronzeBoots, 1), + new Object[] { "* *", "* *", Character.valueOf('*'), "ingotBronze" } + )); + + //Steel + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.SteelPaxel, 1), + new Object[] { "XYZ", + " I ", + " I ", + Character.valueOf('X'), + ToolsItems.SteelAxe, + Character.valueOf('Y'), + ToolsItems.SteelPickaxe, + Character.valueOf('Z'), + ToolsItems.SteelShovel, + Character.valueOf('I'), + Items.iron_ingot } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.SteelPickaxe, 1), + new Object[] { "XXX", + " I ", + " I ", + Character.valueOf('X'), + "ingotSteel", + Character.valueOf('I'), + Items.iron_ingot } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.SteelAxe, 1), + new Object[] { "XX", + "XI", + " I", + Character.valueOf('X'), + "ingotSteel", + Character.valueOf('I'), + Items.iron_ingot } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.SteelShovel, 1), + new Object[] { "X", + "I", + "I", + Character.valueOf('X'), + "ingotSteel", + Character.valueOf('I'), + Items.iron_ingot } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.SteelHoe, 1), + new Object[] { "XX", + " I", + " I", + Character.valueOf('X'), + "ingotSteel", + Character.valueOf('I'), + Items.iron_ingot } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.SteelSword, 1), + new Object[] { "X", + "X", + "I", + Character.valueOf('X'), + "ingotSteel", + Character.valueOf('I'), + Items.iron_ingot } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.SteelHelmet, 1), + new Object[] { "***", + "I I", + Character.valueOf('*'), + "ingotSteel", + Character.valueOf('I'), + Items.iron_ingot } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.SteelChestplate, 1), + new Object[] { "I I", + "*I*", + "***", + Character.valueOf('*'), + "ingotSteel", + Character.valueOf('I'), + Items.iron_ingot } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.SteelLeggings, 1), + new Object[] { "I*I", + "* *", + "* *", + Character.valueOf('*'), + "ingotSteel", + Character.valueOf('I'), + Items.iron_ingot } + )); + CraftingManager.getInstance().getRecipeList().add(new ShapedMekanismRecipe( + new ItemStack(ToolsItems.SteelBoots, 1), + new Object[] { "I *", + "* I", + Character.valueOf('*'), + "ingotSteel", + Character.valueOf('I'), + Items.iron_ingot } + )); + } + + public void addItems() { + //Tools + toolOBSIDIAN = EnumHelper.addToolMaterial( + "OBSIDIAN", + Mekanism.configuration + .get("tools.tool-balance.obsidian.regular", "harvestLevel", 3) + .getInt(), + Mekanism.configuration + .get("tools.tool-balance.obsidian.regular", "maxUses", 2500) + .getInt(), + (float) Mekanism.configuration + .get("tools.tool-balance.obsidian.regular", "efficiency", 20d) + .getDouble(0), + Mekanism.configuration + .get("tools.tool-balance.obsidian.regular", "damage", 10) + .getInt(), + Mekanism.configuration + .get("tools.tool-balance.obsidian.regular", "enchantability", 40) + .getInt() + ); + toolOBSIDIAN2 = EnumHelper.addToolMaterial( + "OBSIDIAN2", + Mekanism.configuration + .get("tools.tool-balance.obsidian.paxel", "harvestLevel", 3) + .getInt(), + Mekanism.configuration + .get("tools.tool-balance.obsidian.paxel", "maxUses", 3000) + .getInt(), + (float) Mekanism.configuration + .get("tools.tool-balance.obsidian.paxel", "efficiency", 25d) + .getDouble(0), + Mekanism.configuration.get("tools.tool-balance.obsidian.paxel", "damage", 10) + .getInt(), + Mekanism.configuration + .get("tools.tool-balance.obsidian.paxel", "enchantability", 50) + .getInt() + ); + toolLAZULI = EnumHelper.addToolMaterial( + "LAZULI", + Mekanism.configuration + .get("tools.tool-balance.lapis.regular", "harvestLevel", 2) + .getInt(), + Mekanism.configuration.get("tools.tool-balance.lapis.regular", "maxUses", 200) + .getInt(), + (float) Mekanism.configuration + .get("tools.tool-balance.lapis.regular", "efficiency", 5d) + .getDouble(0), + Mekanism.configuration.get("tools.tool-balance.lapis.regular", "damage", 2) + .getInt(), + Mekanism.configuration + .get("tools.tool-balance.lapis.regular", "enchantability", 8) + .getInt() + ); + toolLAZULI2 = EnumHelper.addToolMaterial( + "LAZULI2", + Mekanism.configuration + .get("tools.tool-balance.lapis.paxel", "harvestLevel", 2) + .getInt(), + Mekanism.configuration.get("tools.tool-balance.lapis.paxel", "maxUses", 250) + .getInt(), + (float) Mekanism.configuration + .get("tools.tool-balance.lapis.paxel", "efficiency", 6d) + .getDouble(0), + Mekanism.configuration.get("tools.tool-balance.lapis.paxel", "damage", 4) + .getInt(), + Mekanism.configuration + .get("tools.tool-balance.lapis.paxel", "enchantability", 10) + .getInt() + ); + toolOSMIUM = EnumHelper.addToolMaterial( + "OSMIUM", + Mekanism.configuration + .get("tools.tool-balance.osmium.regular", "harvestLevel", 2) + .getInt(), + Mekanism.configuration + .get("tools.tool-balance.osmium.regular", "maxUses", 500) + .getInt(), + (float) Mekanism.configuration + .get("tools.tool-balance.osmium.regular", "efficiency", 10d) + .getDouble(0), + Mekanism.configuration.get("tools.tool-balance.osmium.regular", "damage", 4) + .getInt(), + Mekanism.configuration + .get("tools.tool-balance.osmium.regular", "enchantability", 12) + .getInt() + ); + toolOSMIUM2 = EnumHelper.addToolMaterial( + "OSMIUM2", + Mekanism.configuration + .get("tools.tool-balance.osmium.paxel", "harvestLevel", 3) + .getInt(), + Mekanism.configuration.get("tools.tool-balance.osmium.paxel", "maxUses", 700) + .getInt(), + (float) Mekanism.configuration + .get("tools.tool-balance.osmium.paxel", "efficiency", 12d) + .getDouble(0), + Mekanism.configuration.get("tools.tool-balance.osmium.paxel", "damage", 5) + .getInt(), + Mekanism.configuration + .get("tools.tool-balance.osmium.paxel", "enchantability", 16) + .getInt() + ); + toolBRONZE = EnumHelper.addToolMaterial( + "BRONZE", + Mekanism.configuration + .get("tools.tool-balance.bronze.regular", "harvestLevel", 2) + .getInt(), + Mekanism.configuration + .get("tools.tool-balance.bronze.regular", "maxUses", 800) + .getInt(), + (float) Mekanism.configuration + .get("tools.tool-balance.bronze.regular", "efficiency", 14d) + .getDouble(0), + Mekanism.configuration.get("tools.tool-balance.bronze.regular", "damage", 6) + .getInt(), + Mekanism.configuration + .get("tools.tool-balance.bronze.regular", "enchantability", 10) + .getInt() + ); + toolBRONZE2 = EnumHelper.addToolMaterial( + "BRONZE2", + Mekanism.configuration + .get("tools.tool-balance.bronze.paxel", "harvestLevel", 3) + .getInt(), + Mekanism.configuration.get("tools.tool-balance.bronze.paxel", "maxUses", 1100) + .getInt(), + (float) Mekanism.configuration + .get("tools.tool-balance.bronze.paxel", "efficiency", 16d) + .getDouble(0), + Mekanism.configuration.get("tools.tool-balance.bronze.paxel", "damage", 10) + .getInt(), + Mekanism.configuration + .get("tools.tool-balance.bronze.paxel", "enchantability", 14) + .getInt() + ); + toolGLOWSTONE = EnumHelper.addToolMaterial( + "GLOWSTONE", + Mekanism.configuration + .get("tools.tool-balance.glowstone.regular", "harvestLevel", 2) + .getInt(), + Mekanism.configuration + .get("tools.tool-balance.glowstone.regular", "maxUses", 300) + .getInt(), + (float) Mekanism.configuration + .get("tools.tool-balance.glowstone.regular", "efficiency", 14d) + .getDouble(0), + Mekanism.configuration + .get("tools.tool-balance.glowstone.regular", "damage", 5) + .getInt(), + Mekanism.configuration + .get("tools.tool-balance.glowstone.regular", "enchantability", 18) + .getInt() + ); + toolGLOWSTONE2 = EnumHelper.addToolMaterial( + "GLOWSTONE2", + Mekanism.configuration + .get("tools.tool-balance.glowstone.paxel", "harvestLevel", 2) + .getInt(), + Mekanism.configuration + .get("tools.tool-balance.glowstone.paxel", "maxUses", 450) + .getInt(), + (float) Mekanism.configuration + .get("tools.tool-balance.glowstone.paxel", "efficiency", 18d) + .getDouble(0), + Mekanism.configuration.get("tools.tool-balance.glowstone.paxel", "damage", 5) + .getInt(), + Mekanism.configuration + .get("tools.tool-balance.glowstone.paxel", "enchantability", 22) + .getInt() + ); + toolSTEEL = EnumHelper.addToolMaterial( + "STEEL", + Mekanism.configuration + .get("tools.tool-balance.steel.regular", "harvestLevel", 3) + .getInt(), + Mekanism.configuration.get("tools.tool-balance.steel.regular", "maxUses", 850) + .getInt(), + (float) Mekanism.configuration + .get("tools.tool-balance.steel.regular", "efficiency", 14d) + .getDouble(0), + Mekanism.configuration.get("tools.tool-balance.steel.regular", "damage", 4) + .getInt(), + Mekanism.configuration + .get("tools.tool-balance.steel.regular", "enchantability", 10) + .getInt() + ); + toolSTEEL2 = EnumHelper.addToolMaterial( + "STEEL2", + Mekanism.configuration + .get("tools.tool-balance.steel.paxel", "harvestLevel", 3) + .getInt(), + Mekanism.configuration.get("tools.tool-balance.steel.paxel", "maxUses", 1250) + .getInt(), + (float) Mekanism.configuration + .get("tools.tool-balance.steel.paxel", "efficiency", 18d) + .getDouble(0), + Mekanism.configuration.get("tools.tool-balance.steel.paxel", "damage", 8) + .getInt(), + Mekanism.configuration + .get("tools.tool-balance.steel.paxel", "enchantability", 14) + .getInt() + ); + + //Armors + armorOBSIDIAN = EnumHelper.addArmorMaterial( + "OBSIDIAN", + Mekanism.configuration.get("tools.armor-balance.obsidian", "durability", 50) + .getInt(), + new int[] { Mekanism.configuration + .get("tools.armor-balance.obsidian.protection", "head", 5) + .getInt(), + Mekanism.configuration + .get("tools.armor-balance.obsidian.protection", "chest", 12) + .getInt(), + Mekanism.configuration + .get("tools.armor-balance.obsidian.protection", "legs", 8) + .getInt(), + Mekanism.configuration + .get("tools.armor-balance.obsidian.protection", "feet", 5) + .getInt() }, + Mekanism.configuration + .get("tools.armor-balance.obsidian", "enchantability", 40) + .getInt() + ); + armorLAZULI = EnumHelper.addArmorMaterial( + "LAZULI", + Mekanism.configuration.get("tools.armor-balance.lapis", "durability", 13) + .getInt(), + new int[] { Mekanism.configuration + .get("tools.armor-balance.lapis.protection", "head", 2) + .getInt(), + Mekanism.configuration + .get("tools.armor-balance.lapis.protection", "chest", 5) + .getInt(), + Mekanism.configuration + .get("tools.armor-balance.lapis.protection", "legs", 6) + .getInt(), + Mekanism.configuration + .get("tools.armor-balance.lapis.protection", "feet", 2) + .getInt() }, + Mekanism.configuration.get("tools.armor-balance.lapis", "enchantability", 8) + .getInt() + ); + armorOSMIUM = EnumHelper.addArmorMaterial( + "OSMIUM", + Mekanism.configuration.get("tools.armor-balance.osmium", "durability", 30) + .getInt(), + new int[] { Mekanism.configuration + .get("tools.armor-balance.osmium.protection", "head", 3) + .getInt(), + Mekanism.configuration + .get("tools.armor-balance.osmium.protection", "chest", 5) + .getInt(), + Mekanism.configuration + .get("tools.armor-balance.osmium.protection", "legs", 6) + .getInt(), + Mekanism.configuration + .get("tools.armor-balance.osmium.protection", "feet", 3) + .getInt() }, + Mekanism.configuration.get("tools.armor-balance.osmium", "enchantability", 12) + .getInt() + ); + armorBRONZE = EnumHelper.addArmorMaterial( + "BRONZE", + Mekanism.configuration.get("tools.armor-balance.bronze", "durability", 35) + .getInt(), + new int[] { Mekanism.configuration + .get("tools.armor-balance.bronze.protection", "head", 3) + .getInt(), + Mekanism.configuration + .get("tools.armor-balance.bronze.protection", "chest", 6) + .getInt(), + Mekanism.configuration + .get("tools.armor-balance.bronze.protection", "legs", 5) + .getInt(), + Mekanism.configuration + .get("tools.armor-balance.bronze.protection", "feet", 2) + .getInt() }, + Mekanism.configuration.get("tools.armor-balance.bronze", "enchantability", 10) + .getInt() + ); + armorGLOWSTONE = EnumHelper.addArmorMaterial( + "GLOWSTONE", + Mekanism.configuration.get("tools.armor-balance.glowstone", "durability", 18) + .getInt(), + new int[] { Mekanism.configuration + .get("tools.armor-balance.glowstone.protection", "head", 3) + .getInt(), + Mekanism.configuration + .get("tools.armor-balance.glowstone.protection", "chest", 7) + .getInt(), + Mekanism.configuration + .get("tools.armor-balance.glowstone.protection", "legs", 6) + .getInt(), + Mekanism.configuration + .get("tools.armor-balance.glowstone.protection", "feet", 3) + .getInt() }, + Mekanism.configuration + .get("tools.armor-balance.glowstone", "enchantability", 18) + .getInt() + ); + armorSTEEL = EnumHelper.addArmorMaterial( + "STEEL", + Mekanism.configuration.get("tools.armor-balance.steel", "durability", 40) + .getInt(), + new int[] { Mekanism.configuration + .get("tools.armor-balance.steel.protection", "head", 3) + .getInt(), + Mekanism.configuration + .get("tools.armor-balance.steel.protection", "chest", 7) + .getInt(), + Mekanism.configuration + .get("tools.armor-balance.steel.protection", "legs", 6) + .getInt(), + Mekanism.configuration + .get("tools.armor-balance.steel.protection", "feet", 3) + .getInt() }, + Mekanism.configuration.get("tools.armor-balance.steel", "enchantability", 10) + .getInt() + ); + if (Mekanism.configuration.hasChanged()) { + Mekanism.configuration.save(); + } + + ToolsItems.initializeItems(); + ToolsItems.setHarvestLevels(); + ToolsItems.register(); + } + + @SubscribeEvent + public void onLivingSpecialSpawn(LivingSpawnEvent event) { + double chance = event.world.rand.nextDouble(); + int armorType = event.world.rand.nextInt(4); + + if (chance < tools.armorSpawnRate) { + if (event.entityLiving instanceof EntityZombie + || event.entityLiving instanceof EntitySkeleton) { + int sword = event.world.rand.nextInt(100); + int helmet = event.world.rand.nextInt(100); + int chestplate = event.world.rand.nextInt(100); + int leggings = event.world.rand.nextInt(100); + int boots = event.world.rand.nextInt(100); + + if (armorType == 0) { + if (event.entityLiving instanceof EntityZombie && sword < 50) + event.entityLiving.setCurrentItemOrArmor( + 0, new ItemStack(ToolsItems.GlowstoneSword) + ); + if (helmet < 50) + event.entityLiving.setCurrentItemOrArmor( + 1, new ItemStack(ToolsItems.GlowstoneHelmet) + ); + if (chestplate < 50) + event.entityLiving.setCurrentItemOrArmor( + 2, new ItemStack(ToolsItems.GlowstoneChestplate) + ); + if (leggings < 50) + event.entityLiving.setCurrentItemOrArmor( + 3, new ItemStack(ToolsItems.GlowstoneLeggings) + ); + if (boots < 50) + event.entityLiving.setCurrentItemOrArmor( + 4, new ItemStack(ToolsItems.GlowstoneBoots) + ); + } else if (armorType == 1) { + if (event.entityLiving instanceof EntityZombie && sword < 50) + event.entityLiving.setCurrentItemOrArmor( + 0, new ItemStack(ToolsItems.LazuliSword) + ); + if (helmet < 50) + event.entityLiving.setCurrentItemOrArmor( + 1, new ItemStack(ToolsItems.LazuliHelmet) + ); + if (chestplate < 50) + event.entityLiving.setCurrentItemOrArmor( + 2, new ItemStack(ToolsItems.LazuliChestplate) + ); + if (leggings < 50) + event.entityLiving.setCurrentItemOrArmor( + 3, new ItemStack(ToolsItems.LazuliLeggings) + ); + if (boots < 50) + event.entityLiving.setCurrentItemOrArmor( + 4, new ItemStack(ToolsItems.LazuliBoots) + ); + } else if (armorType == 2) { + if (event.entityLiving instanceof EntityZombie && sword < 50) + event.entityLiving.setCurrentItemOrArmor( + 0, new ItemStack(ToolsItems.OsmiumSword) + ); + if (helmet < 50) + event.entityLiving.setCurrentItemOrArmor( + 1, new ItemStack(ToolsItems.OsmiumHelmet) + ); + if (chestplate < 50) + event.entityLiving.setCurrentItemOrArmor( + 2, new ItemStack(ToolsItems.OsmiumChestplate) + ); + if (leggings < 50) + event.entityLiving.setCurrentItemOrArmor( + 3, new ItemStack(ToolsItems.OsmiumLeggings) + ); + if (boots < 50) + event.entityLiving.setCurrentItemOrArmor( + 4, new ItemStack(ToolsItems.OsmiumBoots) + ); + } else if (armorType == 3) { + if (event.entityLiving instanceof EntityZombie && sword < 50) + event.entityLiving.setCurrentItemOrArmor( + 0, new ItemStack(ToolsItems.SteelSword) + ); + if (helmet < 50) + event.entityLiving.setCurrentItemOrArmor( + 1, new ItemStack(ToolsItems.SteelHelmet) + ); + if (chestplate < 50) + event.entityLiving.setCurrentItemOrArmor( + 2, new ItemStack(ToolsItems.SteelChestplate) + ); + if (leggings < 50) + event.entityLiving.setCurrentItemOrArmor( + 3, new ItemStack(ToolsItems.SteelLeggings) + ); + if (boots < 50) + event.entityLiving.setCurrentItemOrArmor( + 4, new ItemStack(ToolsItems.SteelBoots) + ); + } else if (armorType == 4) { + if (event.entityLiving instanceof EntityZombie && sword < 50) + event.entityLiving.setCurrentItemOrArmor( + 0, new ItemStack(ToolsItems.BronzeSword) + ); + if (helmet < 50) + event.entityLiving.setCurrentItemOrArmor( + 1, new ItemStack(ToolsItems.BronzeHelmet) + ); + if (chestplate < 50) + event.entityLiving.setCurrentItemOrArmor( + 2, new ItemStack(ToolsItems.BronzeChestplate) + ); + if (leggings < 50) + event.entityLiving.setCurrentItemOrArmor( + 3, new ItemStack(ToolsItems.BronzeLeggings) + ); + if (boots < 50) + event.entityLiving.setCurrentItemOrArmor( + 4, new ItemStack(ToolsItems.BronzeBoots) + ); + } + } + } + } + + @Override + public String getVersion() { + return versionNumber; + } + + @Override + public String getName() { + return "Tools"; + } + + @Override + public void writeConfig(ByteBuf dataStream) throws IOException { + dataStream.writeDouble(tools.armorSpawnRate); + } + + @Override + public void readConfig(ByteBuf dataStream) throws IOException { + tools.armorSpawnRate = dataStream.readDouble(); + } + + @Override + public void resetClient() {} + + @SubscribeEvent + public void onConfigChanged(OnConfigChangedEvent event) { + if (event.modID.equals("MekanismTools")) { + proxy.loadConfiguration(); + } + } } diff --git a/src/main/java/mekanism/tools/common/ToolsCommonProxy.java b/src/main/java/mekanism/tools/common/ToolsCommonProxy.java index 96092d71c..f038b31bb 100644 --- a/src/main/java/mekanism/tools/common/ToolsCommonProxy.java +++ b/src/main/java/mekanism/tools/common/ToolsCommonProxy.java @@ -3,16 +3,17 @@ package mekanism.tools.common; import mekanism.api.MekanismConfig.tools; import mekanism.common.Mekanism; -public class ToolsCommonProxy -{ - /** - * Set and load the mod's common configuration properties. - */ - public void loadConfiguration() - { - tools.armorSpawnRate = Mekanism.configuration.get("tools.general", "MobArmorSpawnRate", 0.03, null, 0.00, 1.00).getDouble(0.03); +public class ToolsCommonProxy { + /** + * Set and load the mod's common configuration properties. + */ + public void loadConfiguration() { + tools.armorSpawnRate + = Mekanism.configuration + .get("tools.general", "MobArmorSpawnRate", 0.03, null, 0.00, 1.00) + .getDouble(0.03); - if(Mekanism.configuration.hasChanged()) - Mekanism.configuration.save(); - } + if (Mekanism.configuration.hasChanged()) + Mekanism.configuration.save(); + } } diff --git a/src/main/java/mekanism/tools/common/ToolsItems.java b/src/main/java/mekanism/tools/common/ToolsItems.java index 38dd29c8a..e7f87912b 100644 --- a/src/main/java/mekanism/tools/common/ToolsItems.java +++ b/src/main/java/mekanism/tools/common/ToolsItems.java @@ -1,5 +1,7 @@ package mekanism.tools.common; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.common.registry.GameRegistry.ObjectHolder; import mekanism.common.Mekanism; import mekanism.tools.item.ItemMekanismArmor; import mekanism.tools.item.ItemMekanismAxe; @@ -10,285 +12,447 @@ import mekanism.tools.item.ItemMekanismShovel; import mekanism.tools.item.ItemMekanismSword; import net.minecraft.item.Item; import net.minecraft.item.Item.ToolMaterial; -import cpw.mods.fml.common.registry.GameRegistry; -import cpw.mods.fml.common.registry.GameRegistry.ObjectHolder; @ObjectHolder("MekanismTools") -public class ToolsItems -{ - //Vanilla Material Paxels - public static Item WoodPaxel; - public static Item StonePaxel; - public static Item IronPaxel; - public static Item DiamondPaxel; - public static Item GoldPaxel; +public class ToolsItems { + //Vanilla Material Paxels + public static Item WoodPaxel; + public static Item StonePaxel; + public static Item IronPaxel; + public static Item DiamondPaxel; + public static Item GoldPaxel; - //Glowstone Items - public static Item GlowstonePaxel; - public static Item GlowstonePickaxe; - public static Item GlowstoneAxe; - public static Item GlowstoneShovel; - public static Item GlowstoneHoe; - public static Item GlowstoneSword; - public static Item GlowstoneHelmet; - public static Item GlowstoneChestplate; - public static Item GlowstoneLeggings; - public static Item GlowstoneBoots; + //Glowstone Items + public static Item GlowstonePaxel; + public static Item GlowstonePickaxe; + public static Item GlowstoneAxe; + public static Item GlowstoneShovel; + public static Item GlowstoneHoe; + public static Item GlowstoneSword; + public static Item GlowstoneHelmet; + public static Item GlowstoneChestplate; + public static Item GlowstoneLeggings; + public static Item GlowstoneBoots; - //Bronze Items - public static Item BronzePaxel; - public static Item BronzePickaxe; - public static Item BronzeAxe; - public static Item BronzeShovel; - public static Item BronzeHoe; - public static Item BronzeSword; - public static Item BronzeHelmet; - public static Item BronzeChestplate; - public static Item BronzeLeggings; - public static Item BronzeBoots; + //Bronze Items + public static Item BronzePaxel; + public static Item BronzePickaxe; + public static Item BronzeAxe; + public static Item BronzeShovel; + public static Item BronzeHoe; + public static Item BronzeSword; + public static Item BronzeHelmet; + public static Item BronzeChestplate; + public static Item BronzeLeggings; + public static Item BronzeBoots; - //Osmium Items - public static Item OsmiumPaxel; - public static Item OsmiumPickaxe; - public static Item OsmiumAxe; - public static Item OsmiumShovel; - public static Item OsmiumHoe; - public static Item OsmiumSword; - public static Item OsmiumHelmet; - public static Item OsmiumChestplate; - public static Item OsmiumLeggings; - public static Item OsmiumBoots; + //Osmium Items + public static Item OsmiumPaxel; + public static Item OsmiumPickaxe; + public static Item OsmiumAxe; + public static Item OsmiumShovel; + public static Item OsmiumHoe; + public static Item OsmiumSword; + public static Item OsmiumHelmet; + public static Item OsmiumChestplate; + public static Item OsmiumLeggings; + public static Item OsmiumBoots; - //Obsidian Items - public static Item ObsidianPaxel; - public static Item ObsidianPickaxe; - public static Item ObsidianAxe; - public static Item ObsidianShovel; - public static Item ObsidianHoe; - public static Item ObsidianSword; - public static Item ObsidianHelmet; - public static Item ObsidianChestplate; - public static Item ObsidianLeggings; - public static Item ObsidianBoots; + //Obsidian Items + public static Item ObsidianPaxel; + public static Item ObsidianPickaxe; + public static Item ObsidianAxe; + public static Item ObsidianShovel; + public static Item ObsidianHoe; + public static Item ObsidianSword; + public static Item ObsidianHelmet; + public static Item ObsidianChestplate; + public static Item ObsidianLeggings; + public static Item ObsidianBoots; - //Lazuli Items - public static Item LazuliPaxel; - public static Item LazuliPickaxe; - public static Item LazuliAxe; - public static Item LazuliShovel; - public static Item LazuliHoe; - public static Item LazuliSword; - public static Item LazuliHelmet; - public static Item LazuliChestplate; - public static Item LazuliLeggings; - public static Item LazuliBoots; + //Lazuli Items + public static Item LazuliPaxel; + public static Item LazuliPickaxe; + public static Item LazuliAxe; + public static Item LazuliShovel; + public static Item LazuliHoe; + public static Item LazuliSword; + public static Item LazuliHelmet; + public static Item LazuliChestplate; + public static Item LazuliLeggings; + public static Item LazuliBoots; - //Steel Items - public static Item SteelPaxel; - public static Item SteelPickaxe; - public static Item SteelAxe; - public static Item SteelShovel; - public static Item SteelHoe; - public static Item SteelSword; - public static Item SteelHelmet; - public static Item SteelChestplate; - public static Item SteelLeggings; - public static Item SteelBoots; + //Steel Items + public static Item SteelPaxel; + public static Item SteelPickaxe; + public static Item SteelAxe; + public static Item SteelShovel; + public static Item SteelHoe; + public static Item SteelSword; + public static Item SteelHelmet; + public static Item SteelChestplate; + public static Item SteelLeggings; + public static Item SteelBoots; - public static void initializeItems() - { - WoodPaxel = new ItemMekanismPaxel(ToolMaterial.WOOD).setUnlocalizedName("WoodPaxel"); - StonePaxel = new ItemMekanismPaxel(ToolMaterial.STONE).setUnlocalizedName("StonePaxel"); - IronPaxel = new ItemMekanismPaxel(ToolMaterial.IRON).setUnlocalizedName("IronPaxel"); - DiamondPaxel = new ItemMekanismPaxel(ToolMaterial.EMERALD).setUnlocalizedName("DiamondPaxel"); - GoldPaxel = new ItemMekanismPaxel(ToolMaterial.GOLD).setUnlocalizedName("GoldPaxel"); - GlowstonePaxel = new ItemMekanismPaxel(MekanismTools.toolGLOWSTONE2).setUnlocalizedName("GlowstonePaxel"); - GlowstonePickaxe = new ItemMekanismPickaxe(MekanismTools.toolGLOWSTONE).setUnlocalizedName("GlowstonePickaxe"); - GlowstoneAxe = new ItemMekanismAxe(MekanismTools.toolGLOWSTONE).setUnlocalizedName("GlowstoneAxe"); - GlowstoneShovel = new ItemMekanismShovel(MekanismTools.toolGLOWSTONE).setUnlocalizedName("GlowstoneShovel"); - GlowstoneHoe = new ItemMekanismHoe(MekanismTools.toolGLOWSTONE).setUnlocalizedName("GlowstoneHoe"); - GlowstoneSword = new ItemMekanismSword(MekanismTools.toolGLOWSTONE).setUnlocalizedName("GlowstoneSword"); - GlowstoneHelmet = new ItemMekanismArmor(MekanismTools.armorGLOWSTONE, Mekanism.proxy.getArmorIndex("glowstone"), 0).setUnlocalizedName("GlowstoneHelmet"); - GlowstoneChestplate = new ItemMekanismArmor(MekanismTools.armorGLOWSTONE, Mekanism.proxy.getArmorIndex("glowstone"), 1).setUnlocalizedName("GlowstoneChestplate"); - GlowstoneLeggings = new ItemMekanismArmor(MekanismTools.armorGLOWSTONE, Mekanism.proxy.getArmorIndex("glowstone"), 2).setUnlocalizedName("GlowstoneLeggings"); - GlowstoneBoots = new ItemMekanismArmor(MekanismTools.armorGLOWSTONE, Mekanism.proxy.getArmorIndex("glowstone"), 3).setUnlocalizedName("GlowstoneBoots"); - BronzePaxel = new ItemMekanismPaxel(MekanismTools.toolBRONZE2).setUnlocalizedName("BronzePaxel"); - BronzePickaxe = new ItemMekanismPickaxe(MekanismTools.toolBRONZE).setUnlocalizedName("BronzePickaxe"); - BronzeAxe = new ItemMekanismAxe(MekanismTools.toolBRONZE).setUnlocalizedName("BronzeAxe"); - BronzeShovel = new ItemMekanismShovel(MekanismTools.toolBRONZE).setUnlocalizedName("BronzeShovel"); - BronzeHoe = new ItemMekanismHoe(MekanismTools.toolBRONZE).setUnlocalizedName("BronzeHoe"); - BronzeSword = new ItemMekanismSword(MekanismTools.toolBRONZE).setUnlocalizedName("BronzeSword"); - BronzeHelmet = (new ItemMekanismArmor(MekanismTools.armorBRONZE, Mekanism.proxy.getArmorIndex("bronze"), 0)).setUnlocalizedName("BronzeHelmet"); - BronzeChestplate = (new ItemMekanismArmor(MekanismTools.armorBRONZE, Mekanism.proxy.getArmorIndex("bronze"), 1)).setUnlocalizedName("BronzeChestplate"); - BronzeLeggings = (new ItemMekanismArmor(MekanismTools.armorBRONZE, Mekanism.proxy.getArmorIndex("bronze"), 2)).setUnlocalizedName("BronzeLeggings"); - BronzeBoots = (new ItemMekanismArmor(MekanismTools.armorBRONZE, Mekanism.proxy.getArmorIndex("bronze"), 3)).setUnlocalizedName("BronzeBoots"); - OsmiumPaxel = new ItemMekanismPaxel(MekanismTools.toolOSMIUM2).setUnlocalizedName("OsmiumPaxel"); - OsmiumPickaxe = new ItemMekanismPickaxe(MekanismTools.toolOSMIUM).setUnlocalizedName("OsmiumPickaxe"); - OsmiumAxe = new ItemMekanismAxe(MekanismTools.toolOSMIUM).setUnlocalizedName("OsmiumAxe"); - OsmiumShovel = new ItemMekanismShovel(MekanismTools.toolOSMIUM).setUnlocalizedName("OsmiumShovel"); - OsmiumHoe = new ItemMekanismHoe(MekanismTools.toolOSMIUM).setUnlocalizedName("OsmiumHoe"); - OsmiumSword = new ItemMekanismSword(MekanismTools.toolOSMIUM).setUnlocalizedName("OsmiumSword"); - OsmiumHelmet = (new ItemMekanismArmor(MekanismTools.armorOSMIUM, Mekanism.proxy.getArmorIndex("osmium"), 0)).setUnlocalizedName("OsmiumHelmet"); - OsmiumChestplate = (new ItemMekanismArmor(MekanismTools.armorOSMIUM, Mekanism.proxy.getArmorIndex("osmium"), 1)).setUnlocalizedName("OsmiumChestplate"); - OsmiumLeggings = (new ItemMekanismArmor(MekanismTools.armorOSMIUM, Mekanism.proxy.getArmorIndex("osmium"), 2)).setUnlocalizedName("OsmiumLeggings"); - OsmiumBoots = (new ItemMekanismArmor(MekanismTools.armorOSMIUM, Mekanism.proxy.getArmorIndex("osmium"), 3)).setUnlocalizedName("OsmiumBoots"); - ObsidianPaxel = new ItemMekanismPaxel(MekanismTools.toolOBSIDIAN2).setUnlocalizedName("ObsidianPaxel"); - ObsidianPickaxe = new ItemMekanismPickaxe(MekanismTools.toolOBSIDIAN).setUnlocalizedName("ObsidianPickaxe"); - ObsidianAxe = new ItemMekanismAxe(MekanismTools.toolOBSIDIAN).setUnlocalizedName("ObsidianAxe"); - ObsidianShovel = new ItemMekanismShovel(MekanismTools.toolOBSIDIAN).setUnlocalizedName("ObsidianShovel"); - ObsidianHoe = new ItemMekanismHoe(MekanismTools.toolOBSIDIAN).setUnlocalizedName("ObsidianHoe"); - ObsidianSword = new ItemMekanismSword(MekanismTools.toolOBSIDIAN).setUnlocalizedName("ObsidianSword"); - ObsidianHelmet = (new ItemMekanismArmor(MekanismTools.armorOBSIDIAN, Mekanism.proxy.getArmorIndex("obsidian"), 0)).setUnlocalizedName("ObsidianHelmet"); - ObsidianChestplate = (new ItemMekanismArmor(MekanismTools.armorOBSIDIAN, Mekanism.proxy.getArmorIndex("obsidian"), 1)).setUnlocalizedName("ObsidianChestplate"); - ObsidianLeggings = (new ItemMekanismArmor(MekanismTools.armorOBSIDIAN, Mekanism.proxy.getArmorIndex("obsidian"), 2)).setUnlocalizedName("ObsidianLeggings"); - ObsidianBoots = (new ItemMekanismArmor(MekanismTools.armorOBSIDIAN, Mekanism.proxy.getArmorIndex("obsidian"), 3)).setUnlocalizedName("ObsidianBoots"); - LazuliPaxel = new ItemMekanismPaxel(MekanismTools.toolLAZULI2).setUnlocalizedName("LazuliPaxel"); - LazuliPickaxe = new ItemMekanismPickaxe(MekanismTools.toolLAZULI).setUnlocalizedName("LazuliPickaxe"); - LazuliAxe = new ItemMekanismAxe(MekanismTools.toolLAZULI).setUnlocalizedName("LazuliAxe"); - LazuliShovel = new ItemMekanismShovel(MekanismTools.toolLAZULI).setUnlocalizedName("LazuliShovel"); - LazuliHoe = new ItemMekanismHoe(MekanismTools.toolLAZULI).setUnlocalizedName("LazuliHoe"); - LazuliSword = new ItemMekanismSword(MekanismTools.toolLAZULI).setUnlocalizedName("LazuliSword"); - LazuliHelmet = (new ItemMekanismArmor(MekanismTools.armorLAZULI, Mekanism.proxy.getArmorIndex("lazuli"), 0)).setUnlocalizedName("LazuliHelmet"); - LazuliChestplate = (new ItemMekanismArmor(MekanismTools.armorLAZULI, Mekanism.proxy.getArmorIndex("lazuli"), 1)).setUnlocalizedName("LazuliChestplate"); - LazuliLeggings = (new ItemMekanismArmor(MekanismTools.armorLAZULI, Mekanism.proxy.getArmorIndex("lazuli"), 2)).setUnlocalizedName("LazuliLeggings"); - LazuliBoots = (new ItemMekanismArmor(MekanismTools.armorLAZULI, Mekanism.proxy.getArmorIndex("lazuli"), 3)).setUnlocalizedName("LazuliBoots"); - SteelPaxel = new ItemMekanismPaxel(MekanismTools.toolSTEEL2).setUnlocalizedName("SteelPaxel"); - SteelPickaxe = new ItemMekanismPickaxe(MekanismTools.toolSTEEL).setUnlocalizedName("SteelPickaxe"); - SteelAxe = new ItemMekanismAxe(MekanismTools.toolSTEEL).setUnlocalizedName("SteelAxe"); - SteelShovel = new ItemMekanismShovel(MekanismTools.toolSTEEL).setUnlocalizedName("SteelShovel"); - SteelHoe = new ItemMekanismHoe(MekanismTools.toolSTEEL).setUnlocalizedName("SteelHoe"); - SteelSword = new ItemMekanismSword(MekanismTools.toolSTEEL).setUnlocalizedName("SteelSword"); - SteelHelmet = new ItemMekanismArmor(MekanismTools.armorSTEEL, Mekanism.proxy.getArmorIndex("steel"), 0).setUnlocalizedName("SteelHelmet"); - SteelChestplate = new ItemMekanismArmor(MekanismTools.armorSTEEL, Mekanism.proxy.getArmorIndex("steel"), 1).setUnlocalizedName("SteelChestplate"); - SteelLeggings = new ItemMekanismArmor(MekanismTools.armorSTEEL, Mekanism.proxy.getArmorIndex("steel"), 2).setUnlocalizedName("SteelLeggings"); - SteelBoots = new ItemMekanismArmor(MekanismTools.armorSTEEL, Mekanism.proxy.getArmorIndex("steel"), 3).setUnlocalizedName("SteelBoots"); - } + public static void initializeItems() { + WoodPaxel + = new ItemMekanismPaxel(ToolMaterial.WOOD).setUnlocalizedName("WoodPaxel"); + StonePaxel + = new ItemMekanismPaxel(ToolMaterial.STONE).setUnlocalizedName("StonePaxel"); + IronPaxel + = new ItemMekanismPaxel(ToolMaterial.IRON).setUnlocalizedName("IronPaxel"); + DiamondPaxel = new ItemMekanismPaxel(ToolMaterial.EMERALD) + .setUnlocalizedName("DiamondPaxel"); + GoldPaxel + = new ItemMekanismPaxel(ToolMaterial.GOLD).setUnlocalizedName("GoldPaxel"); + GlowstonePaxel = new ItemMekanismPaxel(MekanismTools.toolGLOWSTONE2) + .setUnlocalizedName("GlowstonePaxel"); + GlowstonePickaxe = new ItemMekanismPickaxe(MekanismTools.toolGLOWSTONE) + .setUnlocalizedName("GlowstonePickaxe"); + GlowstoneAxe = new ItemMekanismAxe(MekanismTools.toolGLOWSTONE) + .setUnlocalizedName("GlowstoneAxe"); + GlowstoneShovel = new ItemMekanismShovel(MekanismTools.toolGLOWSTONE) + .setUnlocalizedName("GlowstoneShovel"); + GlowstoneHoe = new ItemMekanismHoe(MekanismTools.toolGLOWSTONE) + .setUnlocalizedName("GlowstoneHoe"); + GlowstoneSword = new ItemMekanismSword(MekanismTools.toolGLOWSTONE) + .setUnlocalizedName("GlowstoneSword"); + GlowstoneHelmet = new ItemMekanismArmor( + MekanismTools.armorGLOWSTONE, + Mekanism.proxy.getArmorIndex("glowstone"), + 0 + ) + .setUnlocalizedName("GlowstoneHelmet"); + GlowstoneChestplate = new ItemMekanismArmor( + MekanismTools.armorGLOWSTONE, + Mekanism.proxy.getArmorIndex("glowstone"), + 1 + ) + .setUnlocalizedName("GlowstoneChestplate"); + GlowstoneLeggings = new ItemMekanismArmor( + MekanismTools.armorGLOWSTONE, + Mekanism.proxy.getArmorIndex("glowstone"), + 2 + ) + .setUnlocalizedName("GlowstoneLeggings"); + GlowstoneBoots = new ItemMekanismArmor( + MekanismTools.armorGLOWSTONE, + Mekanism.proxy.getArmorIndex("glowstone"), + 3 + ) + .setUnlocalizedName("GlowstoneBoots"); + BronzePaxel = new ItemMekanismPaxel(MekanismTools.toolBRONZE2) + .setUnlocalizedName("BronzePaxel"); + BronzePickaxe = new ItemMekanismPickaxe(MekanismTools.toolBRONZE) + .setUnlocalizedName("BronzePickaxe"); + BronzeAxe = new ItemMekanismAxe(MekanismTools.toolBRONZE) + .setUnlocalizedName("BronzeAxe"); + BronzeShovel = new ItemMekanismShovel(MekanismTools.toolBRONZE) + .setUnlocalizedName("BronzeShovel"); + BronzeHoe = new ItemMekanismHoe(MekanismTools.toolBRONZE) + .setUnlocalizedName("BronzeHoe"); + BronzeSword = new ItemMekanismSword(MekanismTools.toolBRONZE) + .setUnlocalizedName("BronzeSword"); + BronzeHelmet + = (new ItemMekanismArmor( + MekanismTools.armorBRONZE, Mekanism.proxy.getArmorIndex("bronze"), 0 + )) + .setUnlocalizedName("BronzeHelmet"); + BronzeChestplate + = (new ItemMekanismArmor( + MekanismTools.armorBRONZE, Mekanism.proxy.getArmorIndex("bronze"), 1 + )) + .setUnlocalizedName("BronzeChestplate"); + BronzeLeggings + = (new ItemMekanismArmor( + MekanismTools.armorBRONZE, Mekanism.proxy.getArmorIndex("bronze"), 2 + )) + .setUnlocalizedName("BronzeLeggings"); + BronzeBoots + = (new ItemMekanismArmor( + MekanismTools.armorBRONZE, Mekanism.proxy.getArmorIndex("bronze"), 3 + )) + .setUnlocalizedName("BronzeBoots"); + OsmiumPaxel = new ItemMekanismPaxel(MekanismTools.toolOSMIUM2) + .setUnlocalizedName("OsmiumPaxel"); + OsmiumPickaxe = new ItemMekanismPickaxe(MekanismTools.toolOSMIUM) + .setUnlocalizedName("OsmiumPickaxe"); + OsmiumAxe = new ItemMekanismAxe(MekanismTools.toolOSMIUM) + .setUnlocalizedName("OsmiumAxe"); + OsmiumShovel = new ItemMekanismShovel(MekanismTools.toolOSMIUM) + .setUnlocalizedName("OsmiumShovel"); + OsmiumHoe = new ItemMekanismHoe(MekanismTools.toolOSMIUM) + .setUnlocalizedName("OsmiumHoe"); + OsmiumSword = new ItemMekanismSword(MekanismTools.toolOSMIUM) + .setUnlocalizedName("OsmiumSword"); + OsmiumHelmet + = (new ItemMekanismArmor( + MekanismTools.armorOSMIUM, Mekanism.proxy.getArmorIndex("osmium"), 0 + )) + .setUnlocalizedName("OsmiumHelmet"); + OsmiumChestplate + = (new ItemMekanismArmor( + MekanismTools.armorOSMIUM, Mekanism.proxy.getArmorIndex("osmium"), 1 + )) + .setUnlocalizedName("OsmiumChestplate"); + OsmiumLeggings + = (new ItemMekanismArmor( + MekanismTools.armorOSMIUM, Mekanism.proxy.getArmorIndex("osmium"), 2 + )) + .setUnlocalizedName("OsmiumLeggings"); + OsmiumBoots + = (new ItemMekanismArmor( + MekanismTools.armorOSMIUM, Mekanism.proxy.getArmorIndex("osmium"), 3 + )) + .setUnlocalizedName("OsmiumBoots"); + ObsidianPaxel = new ItemMekanismPaxel(MekanismTools.toolOBSIDIAN2) + .setUnlocalizedName("ObsidianPaxel"); + ObsidianPickaxe = new ItemMekanismPickaxe(MekanismTools.toolOBSIDIAN) + .setUnlocalizedName("ObsidianPickaxe"); + ObsidianAxe = new ItemMekanismAxe(MekanismTools.toolOBSIDIAN) + .setUnlocalizedName("ObsidianAxe"); + ObsidianShovel = new ItemMekanismShovel(MekanismTools.toolOBSIDIAN) + .setUnlocalizedName("ObsidianShovel"); + ObsidianHoe = new ItemMekanismHoe(MekanismTools.toolOBSIDIAN) + .setUnlocalizedName("ObsidianHoe"); + ObsidianSword = new ItemMekanismSword(MekanismTools.toolOBSIDIAN) + .setUnlocalizedName("ObsidianSword"); + ObsidianHelmet = (new ItemMekanismArmor( + MekanismTools.armorOBSIDIAN, + Mekanism.proxy.getArmorIndex("obsidian"), + 0 + )) + .setUnlocalizedName("ObsidianHelmet"); + ObsidianChestplate = (new ItemMekanismArmor( + MekanismTools.armorOBSIDIAN, + Mekanism.proxy.getArmorIndex("obsidian"), + 1 + )) + .setUnlocalizedName("ObsidianChestplate"); + ObsidianLeggings = (new ItemMekanismArmor( + MekanismTools.armorOBSIDIAN, + Mekanism.proxy.getArmorIndex("obsidian"), + 2 + )) + .setUnlocalizedName("ObsidianLeggings"); + ObsidianBoots = (new ItemMekanismArmor( + MekanismTools.armorOBSIDIAN, + Mekanism.proxy.getArmorIndex("obsidian"), + 3 + )) + .setUnlocalizedName("ObsidianBoots"); + LazuliPaxel = new ItemMekanismPaxel(MekanismTools.toolLAZULI2) + .setUnlocalizedName("LazuliPaxel"); + LazuliPickaxe = new ItemMekanismPickaxe(MekanismTools.toolLAZULI) + .setUnlocalizedName("LazuliPickaxe"); + LazuliAxe = new ItemMekanismAxe(MekanismTools.toolLAZULI) + .setUnlocalizedName("LazuliAxe"); + LazuliShovel = new ItemMekanismShovel(MekanismTools.toolLAZULI) + .setUnlocalizedName("LazuliShovel"); + LazuliHoe = new ItemMekanismHoe(MekanismTools.toolLAZULI) + .setUnlocalizedName("LazuliHoe"); + LazuliSword = new ItemMekanismSword(MekanismTools.toolLAZULI) + .setUnlocalizedName("LazuliSword"); + LazuliHelmet + = (new ItemMekanismArmor( + MekanismTools.armorLAZULI, Mekanism.proxy.getArmorIndex("lazuli"), 0 + )) + .setUnlocalizedName("LazuliHelmet"); + LazuliChestplate + = (new ItemMekanismArmor( + MekanismTools.armorLAZULI, Mekanism.proxy.getArmorIndex("lazuli"), 1 + )) + .setUnlocalizedName("LazuliChestplate"); + LazuliLeggings + = (new ItemMekanismArmor( + MekanismTools.armorLAZULI, Mekanism.proxy.getArmorIndex("lazuli"), 2 + )) + .setUnlocalizedName("LazuliLeggings"); + LazuliBoots + = (new ItemMekanismArmor( + MekanismTools.armorLAZULI, Mekanism.proxy.getArmorIndex("lazuli"), 3 + )) + .setUnlocalizedName("LazuliBoots"); + SteelPaxel = new ItemMekanismPaxel(MekanismTools.toolSTEEL2) + .setUnlocalizedName("SteelPaxel"); + SteelPickaxe = new ItemMekanismPickaxe(MekanismTools.toolSTEEL) + .setUnlocalizedName("SteelPickaxe"); + SteelAxe + = new ItemMekanismAxe(MekanismTools.toolSTEEL).setUnlocalizedName("SteelAxe"); + SteelShovel = new ItemMekanismShovel(MekanismTools.toolSTEEL) + .setUnlocalizedName("SteelShovel"); + SteelHoe + = new ItemMekanismHoe(MekanismTools.toolSTEEL).setUnlocalizedName("SteelHoe"); + SteelSword = new ItemMekanismSword(MekanismTools.toolSTEEL) + .setUnlocalizedName("SteelSword"); + SteelHelmet + = new ItemMekanismArmor( + MekanismTools.armorSTEEL, Mekanism.proxy.getArmorIndex("steel"), 0 + ) + .setUnlocalizedName("SteelHelmet"); + SteelChestplate + = new ItemMekanismArmor( + MekanismTools.armorSTEEL, Mekanism.proxy.getArmorIndex("steel"), 1 + ) + .setUnlocalizedName("SteelChestplate"); + SteelLeggings + = new ItemMekanismArmor( + MekanismTools.armorSTEEL, Mekanism.proxy.getArmorIndex("steel"), 2 + ) + .setUnlocalizedName("SteelLeggings"); + SteelBoots + = new ItemMekanismArmor( + MekanismTools.armorSTEEL, Mekanism.proxy.getArmorIndex("steel"), 3 + ) + .setUnlocalizedName("SteelBoots"); + } - public static void setHarvestLevels() - { - setPaxelHarvest(BronzePaxel, MekanismTools.toolBRONZE2); - BronzePickaxe.setHarvestLevel("pickaxe", MekanismTools.toolBRONZE.getHarvestLevel()); - BronzeAxe.setHarvestLevel("axe", MekanismTools.toolBRONZE.getHarvestLevel()); - BronzeShovel.setHarvestLevel("shovel", MekanismTools.toolBRONZE.getHarvestLevel()); + public static void setHarvestLevels() { + setPaxelHarvest(BronzePaxel, MekanismTools.toolBRONZE2); + BronzePickaxe.setHarvestLevel( + "pickaxe", MekanismTools.toolBRONZE.getHarvestLevel() + ); + BronzeAxe.setHarvestLevel("axe", MekanismTools.toolBRONZE.getHarvestLevel()); + BronzeShovel.setHarvestLevel( + "shovel", MekanismTools.toolBRONZE.getHarvestLevel() + ); - setPaxelHarvest(OsmiumPaxel, MekanismTools.toolOSMIUM2); - OsmiumPickaxe.setHarvestLevel("pickaxe", MekanismTools.toolOSMIUM.getHarvestLevel()); - OsmiumAxe.setHarvestLevel("axe", MekanismTools.toolOSMIUM.getHarvestLevel()); - OsmiumShovel.setHarvestLevel("shovel", MekanismTools.toolOSMIUM.getHarvestLevel()); + setPaxelHarvest(OsmiumPaxel, MekanismTools.toolOSMIUM2); + OsmiumPickaxe.setHarvestLevel( + "pickaxe", MekanismTools.toolOSMIUM.getHarvestLevel() + ); + OsmiumAxe.setHarvestLevel("axe", MekanismTools.toolOSMIUM.getHarvestLevel()); + OsmiumShovel.setHarvestLevel( + "shovel", MekanismTools.toolOSMIUM.getHarvestLevel() + ); - setPaxelHarvest(ObsidianPaxel, MekanismTools.toolOBSIDIAN2); - ObsidianPickaxe.setHarvestLevel("pickaxe", MekanismTools.toolOBSIDIAN.getHarvestLevel()); - ObsidianAxe.setHarvestLevel("axe", MekanismTools.toolOBSIDIAN.getHarvestLevel()); - ObsidianShovel.setHarvestLevel("shovel", MekanismTools.toolOBSIDIAN.getHarvestLevel()); + setPaxelHarvest(ObsidianPaxel, MekanismTools.toolOBSIDIAN2); + ObsidianPickaxe.setHarvestLevel( + "pickaxe", MekanismTools.toolOBSIDIAN.getHarvestLevel() + ); + ObsidianAxe.setHarvestLevel("axe", MekanismTools.toolOBSIDIAN.getHarvestLevel()); + ObsidianShovel.setHarvestLevel( + "shovel", MekanismTools.toolOBSIDIAN.getHarvestLevel() + ); - setPaxelHarvest(LazuliPaxel, MekanismTools.toolLAZULI2); - LazuliPickaxe.setHarvestLevel("pickaxe", MekanismTools.toolLAZULI.getHarvestLevel()); - LazuliAxe.setHarvestLevel("axe", MekanismTools.toolLAZULI.getHarvestLevel()); - LazuliShovel.setHarvestLevel("shovel", MekanismTools.toolLAZULI.getHarvestLevel()); + setPaxelHarvest(LazuliPaxel, MekanismTools.toolLAZULI2); + LazuliPickaxe.setHarvestLevel( + "pickaxe", MekanismTools.toolLAZULI.getHarvestLevel() + ); + LazuliAxe.setHarvestLevel("axe", MekanismTools.toolLAZULI.getHarvestLevel()); + LazuliShovel.setHarvestLevel( + "shovel", MekanismTools.toolLAZULI.getHarvestLevel() + ); - setPaxelHarvest(GlowstonePaxel, MekanismTools.toolGLOWSTONE2); - GlowstonePickaxe.setHarvestLevel("pickaxe", MekanismTools.toolGLOWSTONE.getHarvestLevel()); - GlowstoneAxe.setHarvestLevel("axe", MekanismTools.toolGLOWSTONE.getHarvestLevel()); - GlowstoneShovel.setHarvestLevel("shovel", MekanismTools.toolGLOWSTONE.getHarvestLevel()); + setPaxelHarvest(GlowstonePaxel, MekanismTools.toolGLOWSTONE2); + GlowstonePickaxe.setHarvestLevel( + "pickaxe", MekanismTools.toolGLOWSTONE.getHarvestLevel() + ); + GlowstoneAxe.setHarvestLevel( + "axe", MekanismTools.toolGLOWSTONE.getHarvestLevel() + ); + GlowstoneShovel.setHarvestLevel( + "shovel", MekanismTools.toolGLOWSTONE.getHarvestLevel() + ); - setPaxelHarvest(SteelPaxel, MekanismTools.toolSTEEL2); - SteelPickaxe.setHarvestLevel("pickaxe", MekanismTools.toolSTEEL.getHarvestLevel()); - SteelAxe.setHarvestLevel("axe", MekanismTools.toolSTEEL.getHarvestLevel()); - SteelShovel.setHarvestLevel("shovel", MekanismTools.toolSTEEL.getHarvestLevel()); + setPaxelHarvest(SteelPaxel, MekanismTools.toolSTEEL2); + SteelPickaxe.setHarvestLevel( + "pickaxe", MekanismTools.toolSTEEL.getHarvestLevel() + ); + SteelAxe.setHarvestLevel("axe", MekanismTools.toolSTEEL.getHarvestLevel()); + SteelShovel.setHarvestLevel("shovel", MekanismTools.toolSTEEL.getHarvestLevel()); - setPaxelHarvest(WoodPaxel, ToolMaterial.WOOD); - setPaxelHarvest(StonePaxel, ToolMaterial.STONE); - setPaxelHarvest(IronPaxel, ToolMaterial.IRON); - setPaxelHarvest(DiamondPaxel, ToolMaterial.EMERALD); - setPaxelHarvest(GoldPaxel, ToolMaterial.GOLD); - } - - private static void setPaxelHarvest(Item item, ToolMaterial material) - { - item.setHarvestLevel("pickaxe", material.getHarvestLevel()); - item.setHarvestLevel("axe", material.getHarvestLevel()); - item.setHarvestLevel("shovel", material.getHarvestLevel()); - } + setPaxelHarvest(WoodPaxel, ToolMaterial.WOOD); + setPaxelHarvest(StonePaxel, ToolMaterial.STONE); + setPaxelHarvest(IronPaxel, ToolMaterial.IRON); + setPaxelHarvest(DiamondPaxel, ToolMaterial.EMERALD); + setPaxelHarvest(GoldPaxel, ToolMaterial.GOLD); + } - public static void register() - { - //Base - GameRegistry.registerItem(WoodPaxel, "WoodPaxel"); - GameRegistry.registerItem(StonePaxel, "StonePaxel"); - GameRegistry.registerItem(IronPaxel, "IronPaxel"); - GameRegistry.registerItem(DiamondPaxel, "DiamondPaxel"); - GameRegistry.registerItem(GoldPaxel, "GoldPaxel"); + private static void setPaxelHarvest(Item item, ToolMaterial material) { + item.setHarvestLevel("pickaxe", material.getHarvestLevel()); + item.setHarvestLevel("axe", material.getHarvestLevel()); + item.setHarvestLevel("shovel", material.getHarvestLevel()); + } - //Obsidian - GameRegistry.registerItem(ObsidianHelmet, "ObsidianHelmet"); - GameRegistry.registerItem(ObsidianChestplate, "ObsidianChestplate"); - GameRegistry.registerItem(ObsidianLeggings, "ObsidianLeggings"); - GameRegistry.registerItem(ObsidianBoots, "ObsidianBoots"); - GameRegistry.registerItem(ObsidianPaxel, "ObsidianPaxel"); - GameRegistry.registerItem(ObsidianPickaxe, "ObsidianPickaxe"); - GameRegistry.registerItem(ObsidianAxe, "ObsidianAxe"); - GameRegistry.registerItem(ObsidianShovel, "ObsidianShovel"); - GameRegistry.registerItem(ObsidianHoe, "ObsidianHoe"); - GameRegistry.registerItem(ObsidianSword, "ObsidianSword"); + public static void register() { + //Base + GameRegistry.registerItem(WoodPaxel, "WoodPaxel"); + GameRegistry.registerItem(StonePaxel, "StonePaxel"); + GameRegistry.registerItem(IronPaxel, "IronPaxel"); + GameRegistry.registerItem(DiamondPaxel, "DiamondPaxel"); + GameRegistry.registerItem(GoldPaxel, "GoldPaxel"); - //Lazuli - GameRegistry.registerItem(LazuliHelmet, "LapisLazuliHelmet"); - GameRegistry.registerItem(LazuliChestplate, "LapisLazuliChestplate"); - GameRegistry.registerItem(LazuliLeggings, "LapisLazuliLeggings"); - GameRegistry.registerItem(LazuliBoots, "LapisLazuliBoots"); - GameRegistry.registerItem(LazuliPaxel, "LapisLazuliPaxel"); - GameRegistry.registerItem(LazuliPickaxe, "LapisLazuliPickaxe"); - GameRegistry.registerItem(LazuliAxe, "LapisLazuliAxe"); - GameRegistry.registerItem(LazuliShovel, "LapisLazuliShovel"); - GameRegistry.registerItem(LazuliHoe, "LapisLazuliHoe"); - GameRegistry.registerItem(LazuliSword, "LapisLazuliSword"); + //Obsidian + GameRegistry.registerItem(ObsidianHelmet, "ObsidianHelmet"); + GameRegistry.registerItem(ObsidianChestplate, "ObsidianChestplate"); + GameRegistry.registerItem(ObsidianLeggings, "ObsidianLeggings"); + GameRegistry.registerItem(ObsidianBoots, "ObsidianBoots"); + GameRegistry.registerItem(ObsidianPaxel, "ObsidianPaxel"); + GameRegistry.registerItem(ObsidianPickaxe, "ObsidianPickaxe"); + GameRegistry.registerItem(ObsidianAxe, "ObsidianAxe"); + GameRegistry.registerItem(ObsidianShovel, "ObsidianShovel"); + GameRegistry.registerItem(ObsidianHoe, "ObsidianHoe"); + GameRegistry.registerItem(ObsidianSword, "ObsidianSword"); - //Osmium - GameRegistry.registerItem(OsmiumHelmet, "OsmiumHelmet"); - GameRegistry.registerItem(OsmiumChestplate, "OsmiumChestplate"); - GameRegistry.registerItem(OsmiumLeggings, "OsmiumLeggings"); - GameRegistry.registerItem(OsmiumBoots, "OsmiumBoots"); - GameRegistry.registerItem(OsmiumPaxel, "OsmiumPaxel"); - GameRegistry.registerItem(OsmiumPickaxe, "OsmiumPickaxe"); - GameRegistry.registerItem(OsmiumAxe, "OsmiumAxe"); - GameRegistry.registerItem(OsmiumShovel, "OsmiumShovel"); - GameRegistry.registerItem(OsmiumHoe, "OsmiumHoe"); - GameRegistry.registerItem(OsmiumSword, "OsmiumSword"); + //Lazuli + GameRegistry.registerItem(LazuliHelmet, "LapisLazuliHelmet"); + GameRegistry.registerItem(LazuliChestplate, "LapisLazuliChestplate"); + GameRegistry.registerItem(LazuliLeggings, "LapisLazuliLeggings"); + GameRegistry.registerItem(LazuliBoots, "LapisLazuliBoots"); + GameRegistry.registerItem(LazuliPaxel, "LapisLazuliPaxel"); + GameRegistry.registerItem(LazuliPickaxe, "LapisLazuliPickaxe"); + GameRegistry.registerItem(LazuliAxe, "LapisLazuliAxe"); + GameRegistry.registerItem(LazuliShovel, "LapisLazuliShovel"); + GameRegistry.registerItem(LazuliHoe, "LapisLazuliHoe"); + GameRegistry.registerItem(LazuliSword, "LapisLazuliSword"); - //Bronze - GameRegistry.registerItem(BronzeHelmet, "BronzeHelmet"); - GameRegistry.registerItem(BronzeChestplate, "BronzeChestplate"); - GameRegistry.registerItem(BronzeLeggings, "BronzeLeggings"); - GameRegistry.registerItem(BronzeBoots, "BronzeBoots"); - GameRegistry.registerItem(BronzePaxel, "BronzePaxel"); - GameRegistry.registerItem(BronzePickaxe, "BronzePickaxe"); - GameRegistry.registerItem(BronzeAxe, "BronzeAxe"); - GameRegistry.registerItem(BronzeShovel, "BronzeShovel"); - GameRegistry.registerItem(BronzeHoe, "BronzeHoe"); - GameRegistry.registerItem(BronzeSword, "BronzeSword"); + //Osmium + GameRegistry.registerItem(OsmiumHelmet, "OsmiumHelmet"); + GameRegistry.registerItem(OsmiumChestplate, "OsmiumChestplate"); + GameRegistry.registerItem(OsmiumLeggings, "OsmiumLeggings"); + GameRegistry.registerItem(OsmiumBoots, "OsmiumBoots"); + GameRegistry.registerItem(OsmiumPaxel, "OsmiumPaxel"); + GameRegistry.registerItem(OsmiumPickaxe, "OsmiumPickaxe"); + GameRegistry.registerItem(OsmiumAxe, "OsmiumAxe"); + GameRegistry.registerItem(OsmiumShovel, "OsmiumShovel"); + GameRegistry.registerItem(OsmiumHoe, "OsmiumHoe"); + GameRegistry.registerItem(OsmiumSword, "OsmiumSword"); - //Glowstone - GameRegistry.registerItem(GlowstonePaxel, "GlowstonePaxel"); - GameRegistry.registerItem(GlowstonePickaxe, "GlowstonePickaxe"); - GameRegistry.registerItem(GlowstoneAxe, "GlowstoneAxe"); - GameRegistry.registerItem(GlowstoneShovel, "GlowstoneShovel"); - GameRegistry.registerItem(GlowstoneHoe, "GlowstoneHoe"); - GameRegistry.registerItem(GlowstoneSword, "GlowstoneSword"); - GameRegistry.registerItem(GlowstoneHelmet, "GlowstoneHelmet"); - GameRegistry.registerItem(GlowstoneChestplate, "GlowstoneChestplate"); - GameRegistry.registerItem(GlowstoneLeggings, "GlowstoneLeggings"); - GameRegistry.registerItem(GlowstoneBoots, "GlowstoneBoots"); + //Bronze + GameRegistry.registerItem(BronzeHelmet, "BronzeHelmet"); + GameRegistry.registerItem(BronzeChestplate, "BronzeChestplate"); + GameRegistry.registerItem(BronzeLeggings, "BronzeLeggings"); + GameRegistry.registerItem(BronzeBoots, "BronzeBoots"); + GameRegistry.registerItem(BronzePaxel, "BronzePaxel"); + GameRegistry.registerItem(BronzePickaxe, "BronzePickaxe"); + GameRegistry.registerItem(BronzeAxe, "BronzeAxe"); + GameRegistry.registerItem(BronzeShovel, "BronzeShovel"); + GameRegistry.registerItem(BronzeHoe, "BronzeHoe"); + GameRegistry.registerItem(BronzeSword, "BronzeSword"); - //Steel - GameRegistry.registerItem(SteelPaxel, "SteelPaxel"); - GameRegistry.registerItem(SteelPickaxe, "SteelPickaxe"); - GameRegistry.registerItem(SteelAxe, "SteelAxe"); - GameRegistry.registerItem(SteelShovel, "SteelShovel"); - GameRegistry.registerItem(SteelHoe, "SteelHoe"); - GameRegistry.registerItem(SteelSword, "SteelSword"); - GameRegistry.registerItem(SteelHelmet, "SteelHelmet"); - GameRegistry.registerItem(SteelChestplate, "SteelChestplate"); - GameRegistry.registerItem(SteelLeggings, "SteelLeggings"); - GameRegistry.registerItem(SteelBoots, "SteelBoots"); - } + //Glowstone + GameRegistry.registerItem(GlowstonePaxel, "GlowstonePaxel"); + GameRegistry.registerItem(GlowstonePickaxe, "GlowstonePickaxe"); + GameRegistry.registerItem(GlowstoneAxe, "GlowstoneAxe"); + GameRegistry.registerItem(GlowstoneShovel, "GlowstoneShovel"); + GameRegistry.registerItem(GlowstoneHoe, "GlowstoneHoe"); + GameRegistry.registerItem(GlowstoneSword, "GlowstoneSword"); + GameRegistry.registerItem(GlowstoneHelmet, "GlowstoneHelmet"); + GameRegistry.registerItem(GlowstoneChestplate, "GlowstoneChestplate"); + GameRegistry.registerItem(GlowstoneLeggings, "GlowstoneLeggings"); + GameRegistry.registerItem(GlowstoneBoots, "GlowstoneBoots"); + + //Steel + GameRegistry.registerItem(SteelPaxel, "SteelPaxel"); + GameRegistry.registerItem(SteelPickaxe, "SteelPickaxe"); + GameRegistry.registerItem(SteelAxe, "SteelAxe"); + GameRegistry.registerItem(SteelShovel, "SteelShovel"); + GameRegistry.registerItem(SteelHoe, "SteelHoe"); + GameRegistry.registerItem(SteelSword, "SteelSword"); + GameRegistry.registerItem(SteelHelmet, "SteelHelmet"); + GameRegistry.registerItem(SteelChestplate, "SteelChestplate"); + GameRegistry.registerItem(SteelLeggings, "SteelLeggings"); + GameRegistry.registerItem(SteelBoots, "SteelBoots"); + } } diff --git a/src/main/java/mekanism/tools/item/ItemMekanismArmor.java b/src/main/java/mekanism/tools/item/ItemMekanismArmor.java index 7b9574edb..ae84b5039 100644 --- a/src/main/java/mekanism/tools/item/ItemMekanismArmor.java +++ b/src/main/java/mekanism/tools/item/ItemMekanismArmor.java @@ -2,6 +2,8 @@ package mekanism.tools.item; import java.util.List; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.util.StackUtils; import mekanism.client.render.ModelCustomArmor; import mekanism.common.Mekanism; @@ -17,82 +19,75 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemStack; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class ItemMekanismArmor extends ItemArmor -{ - public ItemMekanismArmor(ArmorMaterial enumarmormaterial, int renderIndex, int armorType) - { - super(enumarmormaterial, renderIndex, armorType); - setCreativeTab(Mekanism.tabMekanism); - } - - @Override - public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) - { - list.add(LangUtils.localize("tooltip.hp") + ": " + (itemstack.getMaxDamage() - itemstack.getItemDamage())); - } - - @Override - public void registerIcons(IIconRegister register) - { - itemIcon = register.registerIcon("mekanism:" + getUnlocalizedName().replace("item.", "")); - } - - @Override - public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) - { - int layer = (slot == 2) ? 2 : 1; - return "mekanism:armor/" + getArmorMaterial().name().toLowerCase() + "_" + layer + ".png"; - } - - @Override - public boolean getIsRepairable(ItemStack stack1, ItemStack stack2) - { - return StackUtils.equalsWildcard(getRepairStack(), stack2) ? true : super.getIsRepairable(stack1, stack2); - } - - private ItemStack getRepairStack() - { - if(getArmorMaterial() == MekanismTools.armorOBSIDIAN) - { - return new ItemStack(MekanismItems.Ingot, 1, 0); - } - else if(getArmorMaterial() == MekanismTools.armorLAZULI) - { - return new ItemStack(Items.dye, 1, 4); - } - else if(getArmorMaterial() == MekanismTools.armorOSMIUM) - { - return new ItemStack(MekanismItems.Ingot, 1, 1); - } - else if(getArmorMaterial() == MekanismTools.armorBRONZE) - { - return new ItemStack(MekanismItems.Ingot, 1, 2); - } - else if(getArmorMaterial() == MekanismTools.armorGLOWSTONE) - { - return new ItemStack(MekanismItems.Ingot, 1, 3); - } - else if(getArmorMaterial() == MekanismTools.armorSTEEL) - { - return new ItemStack(MekanismItems.Ingot, 1, 4); - } - - return new ItemStack(getArmorMaterial().func_151685_b()); +public class ItemMekanismArmor extends ItemArmor { + public ItemMekanismArmor( + ArmorMaterial enumarmormaterial, int renderIndex, int armorType + ) { + super(enumarmormaterial, renderIndex, armorType); + setCreativeTab(Mekanism.tabMekanism); } - @Override - @SideOnly(Side.CLIENT) - public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) - { - if(itemStack.getItem() == ToolsItems.GlowstoneHelmet || itemStack.getItem() == ToolsItems.GlowstoneChestplate || - itemStack.getItem() == ToolsItems.GlowstoneLeggings || itemStack.getItem() == ToolsItems.GlowstoneBoots) - { - return ModelCustomArmor.getGlow(armorSlot); - } + @Override + public void addInformation( + ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag + ) { + list.add( + LangUtils.localize("tooltip.hp") + ": " + + (itemstack.getMaxDamage() - itemstack.getItemDamage()) + ); + } - return super.getArmorModel(entityLiving, itemStack, armorSlot); - } + @Override + public void registerIcons(IIconRegister register) { + itemIcon = register.registerIcon( + "mekanism:" + getUnlocalizedName().replace("item.", "") + ); + } + + @Override + public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) { + int layer = (slot == 2) ? 2 : 1; + return "mekanism:armor/" + getArmorMaterial().name().toLowerCase() + "_" + layer + + ".png"; + } + + @Override + public boolean getIsRepairable(ItemStack stack1, ItemStack stack2) { + return StackUtils.equalsWildcard(getRepairStack(), stack2) + ? true + : super.getIsRepairable(stack1, stack2); + } + + private ItemStack getRepairStack() { + if (getArmorMaterial() == MekanismTools.armorOBSIDIAN) { + return new ItemStack(MekanismItems.Ingot, 1, 0); + } else if (getArmorMaterial() == MekanismTools.armorLAZULI) { + return new ItemStack(Items.dye, 1, 4); + } else if (getArmorMaterial() == MekanismTools.armorOSMIUM) { + return new ItemStack(MekanismItems.Ingot, 1, 1); + } else if (getArmorMaterial() == MekanismTools.armorBRONZE) { + return new ItemStack(MekanismItems.Ingot, 1, 2); + } else if (getArmorMaterial() == MekanismTools.armorGLOWSTONE) { + return new ItemStack(MekanismItems.Ingot, 1, 3); + } else if (getArmorMaterial() == MekanismTools.armorSTEEL) { + return new ItemStack(MekanismItems.Ingot, 1, 4); + } + + return new ItemStack(getArmorMaterial().func_151685_b()); + } + + @Override + @SideOnly(Side.CLIENT) + public ModelBiped + getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot) { + if (itemStack.getItem() == ToolsItems.GlowstoneHelmet + || itemStack.getItem() == ToolsItems.GlowstoneChestplate + || itemStack.getItem() == ToolsItems.GlowstoneLeggings + || itemStack.getItem() == ToolsItems.GlowstoneBoots) { + return ModelCustomArmor.getGlow(armorSlot); + } + + return super.getArmorModel(entityLiving, itemStack, armorSlot); + } } diff --git a/src/main/java/mekanism/tools/item/ItemMekanismAxe.java b/src/main/java/mekanism/tools/item/ItemMekanismAxe.java index 49bfa92e9..851d9e7a0 100644 --- a/src/main/java/mekanism/tools/item/ItemMekanismAxe.java +++ b/src/main/java/mekanism/tools/item/ItemMekanismAxe.java @@ -5,32 +5,31 @@ import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; -public class ItemMekanismAxe extends ItemMekanismTool -{ - private static Block blocksEffectiveAgainst[]; +public class ItemMekanismAxe extends ItemMekanismTool { + private static Block blocksEffectiveAgainst[]; - public ItemMekanismAxe(ToolMaterial enumtoolmaterial) - { - super(3, enumtoolmaterial, blocksEffectiveAgainst); - } + public ItemMekanismAxe(ToolMaterial enumtoolmaterial) { + super(3, enumtoolmaterial, blocksEffectiveAgainst); + } - @Override - public float getDigSpeed(ItemStack itemstack, Block block, int meta) - { - if(block != null && block.getMaterial() == Material.wood) - { - return efficiencyOnProperMaterial; - } - else { - return super.getDigSpeed(itemstack, block, meta); - } - } + @Override + public float getDigSpeed(ItemStack itemstack, Block block, int meta) { + if (block != null && block.getMaterial() == Material.wood) { + return efficiencyOnProperMaterial; + } else { + return super.getDigSpeed(itemstack, block, meta); + } + } - static - { - blocksEffectiveAgainst = (new Block[] - { - Blocks.planks, Blocks.bookshelf, Blocks.log, Blocks.log2, Blocks.chest, Blocks.wooden_slab, Blocks.double_wooden_slab, Blocks.pumpkin, Blocks.lit_pumpkin - }); - } + static { + blocksEffectiveAgainst = (new Block[] { Blocks.planks, + Blocks.bookshelf, + Blocks.log, + Blocks.log2, + Blocks.chest, + Blocks.wooden_slab, + Blocks.double_wooden_slab, + Blocks.pumpkin, + Blocks.lit_pumpkin }); + } } diff --git a/src/main/java/mekanism/tools/item/ItemMekanismHoe.java b/src/main/java/mekanism/tools/item/ItemMekanismHoe.java index 16979370f..f78be7a0d 100644 --- a/src/main/java/mekanism/tools/item/ItemMekanismHoe.java +++ b/src/main/java/mekanism/tools/item/ItemMekanismHoe.java @@ -2,6 +2,9 @@ package mekanism.tools.item; import java.util.List; +import cpw.mods.fml.common.eventhandler.Event.Result; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import mekanism.api.util.StackUtils; import mekanism.common.item.ItemMekanism; import mekanism.common.util.LangUtils; @@ -13,84 +16,96 @@ import net.minecraft.item.ItemStack; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.UseHoeEvent; -import cpw.mods.fml.common.eventhandler.Event.Result; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; -public class ItemMekanismHoe extends ItemMekanism -{ - protected ToolMaterial toolMaterial; +public class ItemMekanismHoe extends ItemMekanism { + protected ToolMaterial toolMaterial; - public ItemMekanismHoe(ToolMaterial enumtoolmaterial) - { - super(); - toolMaterial = enumtoolmaterial; - maxStackSize = 1; - setMaxDamage(enumtoolmaterial.getMaxUses()); - setCreativeTab(CreativeTabs.tabTools); - } - - @Override - public boolean getIsRepairable(ItemStack stack1, ItemStack stack2) - { - return StackUtils.equalsWildcard(ItemMekanismTool.getRepairStack(toolMaterial), stack2) ? true : super.getIsRepairable(stack1, stack2); + public ItemMekanismHoe(ToolMaterial enumtoolmaterial) { + super(); + toolMaterial = enumtoolmaterial; + maxStackSize = 1; + setMaxDamage(enumtoolmaterial.getMaxUses()); + setCreativeTab(CreativeTabs.tabTools); } - @Override - public boolean onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int x, int y, int z, int side, float entityX, float entityY, float entityZ) - { - if(!entityplayer.canPlayerEdit(x, y, z, side, itemstack)) - { - return false; - } - else { - UseHoeEvent event = new UseHoeEvent(entityplayer, itemstack, world, x, y, z); + @Override + public boolean getIsRepairable(ItemStack stack1, ItemStack stack2) { + return StackUtils.equalsWildcard( + ItemMekanismTool.getRepairStack(toolMaterial), stack2 + ) + ? true + : super.getIsRepairable(stack1, stack2); + } - if(MinecraftForge.EVENT_BUS.post(event)) - { - return false; - } + @Override + public boolean onItemUse( + ItemStack itemstack, + EntityPlayer entityplayer, + World world, + int x, + int y, + int z, + int side, + float entityX, + float entityY, + float entityZ + ) { + if (!entityplayer.canPlayerEdit(x, y, z, side, itemstack)) { + return false; + } else { + UseHoeEvent event = new UseHoeEvent(entityplayer, itemstack, world, x, y, z); - if(event.getResult() == Result.ALLOW) - { - itemstack.damageItem(1, entityplayer); - return true; - } + if (MinecraftForge.EVENT_BUS.post(event)) { + return false; + } - Block blockID = world.getBlock(x, y, z); - Block aboveBlock = world.getBlock(x, y + 1, z); + if (event.getResult() == Result.ALLOW) { + itemstack.damageItem(1, entityplayer); + return true; + } - if((side == 0 || !aboveBlock.isAir(world, x, y, z+1) || blockID != Blocks.grass) && blockID != Blocks.dirt) - { - return false; - } - else { - Block block = Blocks.farmland; - world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, block.stepSound.getStepResourcePath(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F); + Block blockID = world.getBlock(x, y, z); + Block aboveBlock = world.getBlock(x, y + 1, z); - if(world.isRemote) - { - return true; - } - else { - world.setBlock(x, y, z, block); - itemstack.damageItem(1, entityplayer); - return true; - } - } - } - } + if ((side == 0 || !aboveBlock.isAir(world, x, y, z + 1) + || blockID != Blocks.grass) + && blockID != Blocks.dirt) { + return false; + } else { + Block block = Blocks.farmland; + world.playSoundEffect( + x + 0.5F, + y + 0.5F, + z + 0.5F, + block.stepSound.getStepResourcePath(), + (block.stepSound.getVolume() + 1.0F) / 2.0F, + block.stepSound.getPitch() * 0.8F + ); - @Override - public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) - { - list.add(LangUtils.localize("tooltip.hp") + ": " + (itemstack.getMaxDamage() - itemstack.getItemDamage())); - } + if (world.isRemote) { + return true; + } else { + world.setBlock(x, y, z, block); + itemstack.damageItem(1, entityplayer); + return true; + } + } + } + } - @Override - @SideOnly(Side.CLIENT) - public boolean isFull3D() - { - return true; - } + @Override + public void addInformation( + ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag + ) { + list.add( + LangUtils.localize("tooltip.hp") + ": " + + (itemstack.getMaxDamage() - itemstack.getItemDamage()) + ); + } + + @Override + @SideOnly(Side.CLIENT) + public boolean isFull3D() { + return true; + } } diff --git a/src/main/java/mekanism/tools/item/ItemMekanismPaxel.java b/src/main/java/mekanism/tools/item/ItemMekanismPaxel.java index 727e40f67..bcd4e40cc 100644 --- a/src/main/java/mekanism/tools/item/ItemMekanismPaxel.java +++ b/src/main/java/mekanism/tools/item/ItemMekanismPaxel.java @@ -5,67 +5,54 @@ import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; -public class ItemMekanismPaxel extends ItemMekanismTool -{ - public ItemMekanismPaxel(ToolMaterial toolMaterial) - { - super(3, toolMaterial, new Block[0]); - } +public class ItemMekanismPaxel extends ItemMekanismTool { + public ItemMekanismPaxel(ToolMaterial toolMaterial) { + super(3, toolMaterial, new Block[0]); + } - @Override - public float getDigSpeed(ItemStack stack, Block block, int meta) - { - return block != Blocks.bedrock ? efficiencyOnProperMaterial : 1.0F; - } + @Override + public float getDigSpeed(ItemStack stack, Block block, int meta) { + return block != Blocks.bedrock ? efficiencyOnProperMaterial : 1.0F; + } - @Override - public boolean canHarvestBlock(Block block, ItemStack stack) - { - if(block == Blocks.obsidian) - { - return toolMaterial.getHarvestLevel() == 3; - } + @Override + public boolean canHarvestBlock(Block block, ItemStack stack) { + if (block == Blocks.obsidian) { + return toolMaterial.getHarvestLevel() == 3; + } - if(block == Blocks.diamond_block || block == Blocks.diamond_ore) - { - return toolMaterial.getHarvestLevel() >= 2; - } + if (block == Blocks.diamond_block || block == Blocks.diamond_ore) { + return toolMaterial.getHarvestLevel() >= 2; + } - if(block == Blocks.gold_block || block == Blocks.gold_ore) - { - return toolMaterial.getHarvestLevel() >= 2; - } + if (block == Blocks.gold_block || block == Blocks.gold_ore) { + return toolMaterial.getHarvestLevel() >= 2; + } - if(block == Blocks.iron_block || block == Blocks.iron_ore) - { - return toolMaterial.getHarvestLevel() >= 1; - } + if (block == Blocks.iron_block || block == Blocks.iron_ore) { + return toolMaterial.getHarvestLevel() >= 1; + } - if(block == Blocks.lapis_block || block == Blocks.lapis_ore) - { - return toolMaterial.getHarvestLevel() >= 1; - } + if (block == Blocks.lapis_block || block == Blocks.lapis_ore) { + return toolMaterial.getHarvestLevel() >= 1; + } - if(block == Blocks.redstone_ore || block == Blocks.lit_redstone_ore) - { - return toolMaterial.getHarvestLevel() >= 2; - } + if (block == Blocks.redstone_ore || block == Blocks.lit_redstone_ore) { + return toolMaterial.getHarvestLevel() >= 2; + } - if(block == Blocks.anvil) - { - return toolMaterial.getHarvestLevel() >= 0; - } + if (block == Blocks.anvil) { + return toolMaterial.getHarvestLevel() >= 0; + } - if(block == Blocks.snow || block == Blocks.snow_layer) - { - return true; - } + if (block == Blocks.snow || block == Blocks.snow_layer) { + return true; + } - if(block.getMaterial() == Material.rock) - { - return true; - } + if (block.getMaterial() == Material.rock) { + return true; + } - return block.getMaterial() == Material.iron; - } + return block.getMaterial() == Material.iron; + } } diff --git a/src/main/java/mekanism/tools/item/ItemMekanismPickaxe.java b/src/main/java/mekanism/tools/item/ItemMekanismPickaxe.java index 9c3a96c03..65c1aa499 100644 --- a/src/main/java/mekanism/tools/item/ItemMekanismPickaxe.java +++ b/src/main/java/mekanism/tools/item/ItemMekanismPickaxe.java @@ -5,80 +5,75 @@ import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; -public class ItemMekanismPickaxe extends ItemMekanismTool -{ - private static Block blocksEffectiveAgainst[]; +public class ItemMekanismPickaxe extends ItemMekanismTool { + private static Block blocksEffectiveAgainst[]; - public ItemMekanismPickaxe(ToolMaterial toolMaterial) - { - super(2, toolMaterial, blocksEffectiveAgainst); - } + public ItemMekanismPickaxe(ToolMaterial toolMaterial) { + super(2, toolMaterial, blocksEffectiveAgainst); + } - @Override - public boolean canHarvestBlock(Block block, ItemStack stack) - { - if(block == Blocks.obsidian) - { - return toolMaterial.getHarvestLevel() == 3; - } + @Override + public boolean canHarvestBlock(Block block, ItemStack stack) { + if (block == Blocks.obsidian) { + return toolMaterial.getHarvestLevel() == 3; + } - if(block == Blocks.diamond_block || block == Blocks.diamond_ore) - { - return toolMaterial.getHarvestLevel() >= 2; - } + if (block == Blocks.diamond_block || block == Blocks.diamond_ore) { + return toolMaterial.getHarvestLevel() >= 2; + } - if(block == Blocks.gold_block || block == Blocks.gold_ore) - { - return toolMaterial.getHarvestLevel() >= 2; - } + if (block == Blocks.gold_block || block == Blocks.gold_ore) { + return toolMaterial.getHarvestLevel() >= 2; + } - if(block == Blocks.iron_block || block == Blocks.iron_ore) - { - return toolMaterial.getHarvestLevel() >= 1; - } + if (block == Blocks.iron_block || block == Blocks.iron_ore) { + return toolMaterial.getHarvestLevel() >= 1; + } - if(block == Blocks.lapis_block || block == Blocks.lapis_ore) - { - return toolMaterial.getHarvestLevel() >= 1; - } + if (block == Blocks.lapis_block || block == Blocks.lapis_ore) { + return toolMaterial.getHarvestLevel() >= 1; + } - if(block == Blocks.redstone_ore || block == Blocks.lit_redstone_ore) - { - return toolMaterial.getHarvestLevel() >= 2; - } + if (block == Blocks.redstone_ore || block == Blocks.lit_redstone_ore) { + return toolMaterial.getHarvestLevel() >= 2; + } - if(block == Blocks.anvil) - { - return toolMaterial.getHarvestLevel() >= 0; - } + if (block == Blocks.anvil) { + return toolMaterial.getHarvestLevel() >= 0; + } - if(block.getMaterial() == Material.rock) - { - return true; - } + if (block.getMaterial() == Material.rock) { + return true; + } - return block.getMaterial() == Material.iron; - } + return block.getMaterial() == Material.iron; + } - @Override - public float getDigSpeed(ItemStack itemstack, Block block, int meta) - { - if(block != null && (block.getMaterial() == Material.iron || block.getMaterial() == Material.anvil || block.getMaterial() == Material.rock)) - { - return efficiencyOnProperMaterial; - } - else { - return super.getDigSpeed(itemstack, block, meta); - } - } + @Override + public float getDigSpeed(ItemStack itemstack, Block block, int meta) { + if (block != null + && (block.getMaterial() == Material.iron + || block.getMaterial() == Material.anvil + || block.getMaterial() == Material.rock)) { + return efficiencyOnProperMaterial; + } else { + return super.getDigSpeed(itemstack, block, meta); + } + } - static - { - blocksEffectiveAgainst = (new Block[] - { - Blocks.cobblestone, Blocks.stone_slab, Blocks.double_stone_slab, Blocks.stone, Blocks.sandstone, Blocks.mossy_cobblestone, Blocks.iron_ore, Blocks.iron_block, Blocks.coal_ore, Blocks.gold_block, - Blocks.gold_ore, Blocks.diamond_ore, Blocks.diamond_block, Blocks.ice, Blocks.netherrack, Blocks.lapis_ore, Blocks.lapis_block, Blocks.redstone_ore, Blocks.lit_redstone_ore, Blocks.rail, - Blocks.detector_rail, Blocks.golden_rail, Blocks.activator_rail - }); - } + static { + blocksEffectiveAgainst + = (new Block[] { Blocks.cobblestone, Blocks.stone_slab, + Blocks.double_stone_slab, Blocks.stone, + Blocks.sandstone, Blocks.mossy_cobblestone, + Blocks.iron_ore, Blocks.iron_block, + Blocks.coal_ore, Blocks.gold_block, + Blocks.gold_ore, Blocks.diamond_ore, + Blocks.diamond_block, Blocks.ice, + Blocks.netherrack, Blocks.lapis_ore, + Blocks.lapis_block, Blocks.redstone_ore, + Blocks.lit_redstone_ore, Blocks.rail, + Blocks.detector_rail, Blocks.golden_rail, + Blocks.activator_rail }); + } } diff --git a/src/main/java/mekanism/tools/item/ItemMekanismShovel.java b/src/main/java/mekanism/tools/item/ItemMekanismShovel.java index 4ccd255a3..fac110ed0 100644 --- a/src/main/java/mekanism/tools/item/ItemMekanismShovel.java +++ b/src/main/java/mekanism/tools/item/ItemMekanismShovel.java @@ -4,31 +4,32 @@ import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; -public class ItemMekanismShovel extends ItemMekanismTool -{ - private static Block blocksEffectiveAgainst[]; +public class ItemMekanismShovel extends ItemMekanismTool { + private static Block blocksEffectiveAgainst[]; - public ItemMekanismShovel(ToolMaterial enumtoolmaterial) - { - super(1, enumtoolmaterial, blocksEffectiveAgainst); - } + public ItemMekanismShovel(ToolMaterial enumtoolmaterial) { + super(1, enumtoolmaterial, blocksEffectiveAgainst); + } - @Override - public boolean canHarvestBlock(Block block, ItemStack stack) - { - if(block == Blocks.snow_layer) - { - return true; - } + @Override + public boolean canHarvestBlock(Block block, ItemStack stack) { + if (block == Blocks.snow_layer) { + return true; + } - return block == Blocks.snow; - } + return block == Blocks.snow; + } - static - { - blocksEffectiveAgainst = (new Block[] - { - Blocks.grass, Blocks.dirt, Blocks.sand, Blocks.gravel, Blocks.snow_layer, Blocks.snow, Blocks.clay, Blocks.farmland, Blocks.soul_sand, Blocks.mycelium - }); - } + static { + blocksEffectiveAgainst = (new Block[] { Blocks.grass, + Blocks.dirt, + Blocks.sand, + Blocks.gravel, + Blocks.snow_layer, + Blocks.snow, + Blocks.clay, + Blocks.farmland, + Blocks.soul_sand, + Blocks.mycelium }); + } } diff --git a/src/main/java/mekanism/tools/item/ItemMekanismSword.java b/src/main/java/mekanism/tools/item/ItemMekanismSword.java index d5f77e355..9a47e9971 100644 --- a/src/main/java/mekanism/tools/item/ItemMekanismSword.java +++ b/src/main/java/mekanism/tools/item/ItemMekanismSword.java @@ -9,23 +9,26 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; -public class ItemMekanismSword extends ItemSword -{ - public ItemMekanismSword(ToolMaterial enumtoolmaterial) - { - super(enumtoolmaterial); - setCreativeTab(Mekanism.tabMekanism); - } +public class ItemMekanismSword extends ItemSword { + public ItemMekanismSword(ToolMaterial enumtoolmaterial) { + super(enumtoolmaterial); + setCreativeTab(Mekanism.tabMekanism); + } - @Override - public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) - { - list.add(LangUtils.localize("tooltip.hp") + ": " + (itemstack.getMaxDamage() - itemstack.getItemDamage())); - } + @Override + public void addInformation( + ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag + ) { + list.add( + LangUtils.localize("tooltip.hp") + ": " + + (itemstack.getMaxDamage() - itemstack.getItemDamage()) + ); + } - @Override - public void registerIcons(IIconRegister register) - { - itemIcon = register.registerIcon("mekanism:" + getUnlocalizedName().replace("item.", "")); - } + @Override + public void registerIcons(IIconRegister register) { + itemIcon = register.registerIcon( + "mekanism:" + getUnlocalizedName().replace("item.", "") + ); + } } diff --git a/src/main/java/mekanism/tools/item/ItemMekanismTool.java b/src/main/java/mekanism/tools/item/ItemMekanismTool.java index 9bac0d63f..296c519b4 100644 --- a/src/main/java/mekanism/tools/item/ItemMekanismTool.java +++ b/src/main/java/mekanism/tools/item/ItemMekanismTool.java @@ -16,64 +16,58 @@ import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.item.ItemTool; -public class ItemMekanismTool extends ItemTool -{ - public ItemMekanismTool(int mobBoost, ToolMaterial toolMaterial, Block[] effectiveBlocks) - { - super(mobBoost, toolMaterial, new HashSet(Arrays.asList(effectiveBlocks))); - setCreativeTab(Mekanism.tabMekanism); - } - - @Override - public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag) - { - list.add(LangUtils.localize("tooltip.hp") + ": " + (itemstack.getMaxDamage() - itemstack.getItemDamage())); - } - - @Override - public boolean getIsRepairable(ItemStack stack1, ItemStack stack2) - { - return StackUtils.equalsWildcard(getRepairStack(), stack2) ? true : super.getIsRepairable(stack1, stack2); - } - - private ItemStack getRepairStack() - { - return getRepairStack(toolMaterial); - } - - public static ItemStack getRepairStack(ToolMaterial material) - { - if(material == MekanismTools.toolOBSIDIAN || material == MekanismTools.toolOBSIDIAN2) - { - return new ItemStack(MekanismItems.Ingot, 1, 0); - } - else if(material == MekanismTools.toolLAZULI || material == MekanismTools.toolLAZULI2) - { - return new ItemStack(Items.dye, 1, 4); - } - else if(material == MekanismTools.toolOSMIUM || material == MekanismTools.toolOSMIUM2) - { - return new ItemStack(MekanismItems.Ingot, 1, 1); - } - else if(material == MekanismTools.toolBRONZE || material == MekanismTools.toolBRONZE2) - { - return new ItemStack(MekanismItems.Ingot, 1, 2); - } - else if(material == MekanismTools.toolGLOWSTONE || material == MekanismTools.toolGLOWSTONE2) - { - return new ItemStack(MekanismItems.Ingot, 1, 3); - } - else if(material == MekanismTools.toolSTEEL || material == MekanismTools.toolSTEEL2) - { - return new ItemStack(MekanismItems.Ingot, 1, 4); - } - - return new ItemStack(material.func_150995_f()); +public class ItemMekanismTool extends ItemTool { + public ItemMekanismTool( + int mobBoost, ToolMaterial toolMaterial, Block[] effectiveBlocks + ) { + super(mobBoost, toolMaterial, new HashSet(Arrays.asList(effectiveBlocks))); + setCreativeTab(Mekanism.tabMekanism); } - @Override - public void registerIcons(IIconRegister register) - { - itemIcon = register.registerIcon("mekanism:" + getUnlocalizedName().replace("item.", "")); - } + @Override + public void addInformation( + ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag + ) { + list.add( + LangUtils.localize("tooltip.hp") + ": " + + (itemstack.getMaxDamage() - itemstack.getItemDamage()) + ); + } + + @Override + public boolean getIsRepairable(ItemStack stack1, ItemStack stack2) { + return StackUtils.equalsWildcard(getRepairStack(), stack2) + ? true + : super.getIsRepairable(stack1, stack2); + } + + private ItemStack getRepairStack() { + return getRepairStack(toolMaterial); + } + + public static ItemStack getRepairStack(ToolMaterial material) { + if (material == MekanismTools.toolOBSIDIAN + || material == MekanismTools.toolOBSIDIAN2) { + return new ItemStack(MekanismItems.Ingot, 1, 0); + } else if (material == MekanismTools.toolLAZULI || material == MekanismTools.toolLAZULI2) { + return new ItemStack(Items.dye, 1, 4); + } else if (material == MekanismTools.toolOSMIUM || material == MekanismTools.toolOSMIUM2) { + return new ItemStack(MekanismItems.Ingot, 1, 1); + } else if (material == MekanismTools.toolBRONZE || material == MekanismTools.toolBRONZE2) { + return new ItemStack(MekanismItems.Ingot, 1, 2); + } else if (material == MekanismTools.toolGLOWSTONE || material == MekanismTools.toolGLOWSTONE2) { + return new ItemStack(MekanismItems.Ingot, 1, 3); + } else if (material == MekanismTools.toolSTEEL || material == MekanismTools.toolSTEEL2) { + return new ItemStack(MekanismItems.Ingot, 1, 4); + } + + return new ItemStack(material.func_150995_f()); + } + + @Override + public void registerIcons(IIconRegister register) { + itemIcon = register.registerIcon( + "mekanism:" + getUnlocalizedName().replace("item.", "") + ); + } }